desktop/inc/liblibreoffice.h | 2 - desktop/source/lib/init.cxx | 38 ++++++++++++++++++++++---------- smoketest/CppunitTest_liblibreoffice.mk | 1 smoketest/libtest.cxx | 19 +++++++++++++++- 4 files changed, 47 insertions(+), 13 deletions(-)
New commits: commit e144cfad708f14b9e5dd29b6cb760688861bf310 Author: Michael Meeks <michael.me...@suse.com> Date: Tue Mar 5 14:06:47 2013 +0000 liblibo: export symbols correctly, and improve tests. Change-Id: I7d6688634aa423b62336c05a70d5047115c0081e diff --git a/desktop/inc/liblibreoffice.h b/desktop/inc/liblibreoffice.h index 200688b..dde50ce 100644 --- a/desktop/inc/liblibreoffice.h +++ b/desktop/inc/liblibreoffice.h @@ -22,7 +22,7 @@ typedef struct { typedef int loboolean; typedef struct _LODocument LODocument; -void lo_initialize (const char *install_path); +loboolean lo_initialize (const char *install_path); void lo_error_free (LOError *error); LOError *lo_error_new (int errno, const char *message); diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index cd8ce9f..8f96dbe 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -11,6 +11,7 @@ #include <liblibreoffice.h> #include <tools/errinf.hxx> +#include <osl/file.hxx> #include <rtl/strbuf.hxx> #include <rtl/bootstrap.hxx> #include <cppuhelper/bootstrap.hxx> @@ -34,22 +35,24 @@ static uno::Reference<css::uno::XComponentContext> xContext; static uno::Reference<css::lang::XMultiServiceFactory> xSFactory; static uno::Reference<css::lang::XMultiComponentFactory> xFactory; -void lo_error_free( LOError * ) +SAL_DLLPUBLIC_EXPORT void +lo_error_free( LOError * ) { } -LOError *lo_error_new( int, const char * ) +SAL_DLLPUBLIC_EXPORT LOError * +lo_error_new( int, const char * ) { return NULL; } -LODocument * +SAL_DLLPUBLIC_EXPORT LODocument * lo_document_load( const char *, LOError ** ) { return NULL; } -loboolean +SAL_DLLPUBLIC_EXPORT loboolean lo_document_save( const char *, LOError ** ) { return 1; @@ -78,24 +81,35 @@ aBasicErrorFunc( const OUString &rErr, const OUString &rAction ) } static void -initialize_uno( void ) +initialize_uno( const rtl::OUString &aUserProfileURL ) { // set UserInstallation to user profile dir in test/user-template rtl::Bootstrap aDefaultVars; - // madness ... - fprintf(stderr, "trying to bootstrap with no user install !\n"); -/* rtl::OUString sUserInstallURL = m_aSolverRootURL + rtl::OUString("/unittest"); - aDefaultVars.set(rtl::OUString("UserInstallation"), sUserInstallURL); */ + aDefaultVars.set(rtl::OUString("UserInstallation"), aUserProfileURL ); xContext = comphelper::getProcessComponentContext(); xFactory = xContext->getServiceManager(); xSFactory = uno::Reference<lang::XMultiServiceFactory>(xFactory, uno::UNO_QUERY_THROW); } -void lo_initialize( const char * ) +SAL_DLLPUBLIC_EXPORT loboolean +lo_initialize( const char *app_path ) { + static bool bInitialized = false; + if( bInitialized ) + return true; + + if( !app_path ) + return false; + + OUString aAppPath( app_path, strlen( app_path ), RTL_TEXTENCODING_UTF8 ); + OUString aAppURL; + if( osl::FileBase::getFileURLFromSystemPath( aAppPath, aAppURL ) != + osl::FileBase::E_None ) + return false; + try { - initialize_uno(); + initialize_uno( aAppURL + "../registry" ); force_c_locale(); InitVCL(); if (Application::IsHeadlessModeRequested()) @@ -104,10 +118,12 @@ void lo_initialize( const char * ) ErrorHandler::RegisterDisplay( aBasicErrorFunc ); fprintf (stderr, "do nothing yet"); + bInitialized = true; } catch (css::uno::Exception & e) { fprintf( stderr, "bootstrapping exception '%s'\n", OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ).getStr() ); } + return bInitialized; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/smoketest/CppunitTest_liblibreoffice.mk b/smoketest/CppunitTest_liblibreoffice.mk index 9a333c9..2cd3456 100644 --- a/smoketest/CppunitTest_liblibreoffice.mk +++ b/smoketest/CppunitTest_liblibreoffice.mk @@ -25,6 +25,7 @@ $(eval $(call gb_CppunitTest_use_api,liblibreoffice,\ $(eval $(call gb_CppunitTest_use_libraries,liblibreoffice,\ cppu \ cppuhelper \ + libreoffice \ sal \ unotest \ )) diff --git a/smoketest/libtest.cxx b/smoketest/libtest.cxx index 53c836a..39ab01b 100644 --- a/smoketest/libtest.cxx +++ b/smoketest/libtest.cxx @@ -1,7 +1,18 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + // yuck / FIXME ... #include "../desktop/inc/liblibreoffice.h" #include <sal/types.h> +#include <rtl/ustring.hxx> +#include <rtl/bootstrap.hxx> #include "cppunit/TestAssert.h" #include "cppunit/TestFixture.h" #include "cppunit/extensions/HelperMacros.h" @@ -29,9 +40,15 @@ void Test::tearDown() void Test::test() { - fprintf( stderr, " test me !\n" ); + rtl::OUString aArgSoffice; + rtl::Bootstrap::get( rtl::OUString( "arg-soffice" ), aArgSoffice ); + OString aInstall = OUStringToOString( aArgSoffice, RTL_TEXTENCODING_UTF8 ); + fprintf( stderr, "liblibreoffice test: '%s'\n", aInstall.getStr() ); + lo_initialize( aInstall.getStr() ); } CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits