Kaydet (Commit) af969873 authored tarafından Michael Meeks's avatar Michael Meeks

liblibo: better init code.

Change-Id: I8757739960cb1c764a5a66bd67d34731e3dfbf31
üst 07352f07
...@@ -10,16 +10,15 @@ ...@@ -10,16 +10,15 @@
#ifndef _LIBLIBREOFFICE_HXX #ifndef _LIBLIBREOFFICE_HXX
#define _LIBLIBREOFFICE_HXX #define _LIBLIBREOFFICE_HXX
typedef int loboolean;
typedef struct _LODocument LODocument; typedef struct _LODocument LODocument;
class LibLibreOffice class LibLibreOffice
{ {
public: public:
virtual loboolean initialize (const char *installPath) = 0; virtual bool initialize (const char *installPath) = 0;
virtual LODocument *documentLoad (const char *url) = 0; virtual LODocument *documentLoad (const char *url) = 0;
virtual loboolean documentSave (const char *url) = 0; virtual bool documentSave (const char *url) = 0;
virtual ~LibLibreOffice () {}; virtual ~LibLibreOffice () {};
}; };
......
...@@ -12,16 +12,13 @@ ...@@ -12,16 +12,13 @@
#include "liblibreoffice.hxx" #include "liblibreoffice.hxx"
typedef int loboolean;
typedef struct _LODocument LODocument;
class LibLibreOffice_Impl : public LibLibreOffice class LibLibreOffice_Impl : public LibLibreOffice
{ {
public: public:
virtual loboolean initialize (const char *installPath); virtual bool initialize (const char *installPath);
virtual LODocument *documentLoad (const char *url); virtual LODocument *documentLoad (const char *url);
virtual loboolean documentSave (const char *url); virtual bool documentSave (const char *url);
virtual ~LibLibreOffice_Impl (); virtual ~LibLibreOffice_Impl ();
}; };
......
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* /*
* This file is part of the LibreOffice project. * This file is part of the LibreOffice project.
* *
...@@ -42,7 +42,7 @@ LibLibreOffice_Impl::documentLoad( const char *docUrl ) ...@@ -42,7 +42,7 @@ LibLibreOffice_Impl::documentLoad( const char *docUrl )
return NULL; return NULL;
} }
loboolean bool
LibLibreOffice_Impl::documentSave( const char * ) LibLibreOffice_Impl::documentSave( const char * )
{ {
return 1; return 1;
...@@ -73,16 +73,18 @@ aBasicErrorFunc( const OUString &rErr, const OUString &rAction ) ...@@ -73,16 +73,18 @@ aBasicErrorFunc( const OUString &rErr, const OUString &rAction )
static void static void
initialize_uno( const rtl::OUString &aUserProfileURL ) initialize_uno( const rtl::OUString &aUserProfileURL )
{ {
xContext = cppu::defaultBootstrap_InitialComponentContext();
fprintf( stderr, "Uno initialized %d\n", xContext.is() );
xFactory = xContext->getServiceManager();
xSFactory = uno::Reference<lang::XMultiServiceFactory>(xFactory, uno::UNO_QUERY_THROW);
comphelper::setProcessServiceFactory(xSFactory);
// set UserInstallation to user profile dir in test/user-template // set UserInstallation to user profile dir in test/user-template
rtl::Bootstrap aDefaultVars; rtl::Bootstrap aDefaultVars;
aDefaultVars.set(rtl::OUString("UserInstallation"), aUserProfileURL ); aDefaultVars.set(rtl::OUString("UserInstallation"), aUserProfileURL );
xContext = comphelper::getProcessComponentContext();
xFactory = xContext->getServiceManager();
xSFactory = uno::Reference<lang::XMultiServiceFactory>(xFactory, uno::UNO_QUERY_THROW);
} }
loboolean bool
LibLibreOffice_Impl::initialize( const char *app_path ) LibLibreOffice_Impl::initialize( const char *app_path )
{ {
static bool bInitialized = false; static bool bInitialized = false;
...@@ -122,6 +124,7 @@ extern "C" { ...@@ -122,6 +124,7 @@ extern "C" {
LibLibreOffice *liblibreoffice_hook(void) LibLibreOffice *liblibreoffice_hook(void)
{ {
fprintf( stderr, "create libreoffice object\n" );
return new LibLibreOffice_Impl(); return new LibLibreOffice_Impl();
} }
......
...@@ -41,13 +41,14 @@ SAL_DLLPUBLIC_EXPORT LibLibreOffice *lo_init( const char *install_path ) ...@@ -41,13 +41,14 @@ SAL_DLLPUBLIC_EXPORT LibLibreOffice *lo_init( const char *install_path )
fprintf( stderr, "failed to open library '%s'\n", imp_lib ); fprintf( stderr, "failed to open library '%s'\n", imp_lib );
return NULL; return NULL;
} }
free( imp_lib );
HookFunction *pSym = (HookFunction *) dlsym( dlhandle, "liblibreoffice_hook" ); HookFunction *pSym = (HookFunction *) dlsym( dlhandle, "liblibreoffice_hook" );
if( !pSym ) { if( !pSym ) {
fprintf( stderr, "failed to find hook in library '%s'\n", imp_lib ); fprintf( stderr, "failed to find hook in library '%s'\n", imp_lib );
return NULL; return NULL;
} }
free( imp_lib );
return pSym(); return pSym();
} }
......
...@@ -15,29 +15,16 @@ $(eval $(call gb_CppunitTest_add_exception_objects,liblibreoffice,\ ...@@ -15,29 +15,16 @@ $(eval $(call gb_CppunitTest_add_exception_objects,liblibreoffice,\
smoketest/libtest \ smoketest/libtest \
)) ))
$(eval $(call gb_CppunitTest_use_external,liblibreoffice,boost_headers))
$(eval $(call gb_CppunitTest_use_api,liblibreoffice,\
offapi \
udkapi \
))
$(eval $(call gb_CppunitTest_use_libraries,liblibreoffice,\ $(eval $(call gb_CppunitTest_use_libraries,liblibreoffice,\
cppu \
cppuhelper \
libreoffice \ libreoffice \
sal \
unotest \
)) ))
ifeq ($(OS),MACOSX) ifeq ($(OS),MACOSX)
liblibreoffice_SOFFICE_INST := path:$(DEVINSTALLDIR)/opt/LibreOffice.app/Contents/MacOS liblibreoffice_SOFFICE_INST := $(DEVINSTALLDIR)/opt/LibreOffice.app/Contents/MacOS
else else
liblibreoffice_SOFFICE_INST := path:$(DEVINSTALLDIR)/opt/program liblibreoffice_SOFFICE_INST := $(DEVINSTALLDIR)/opt/program
endif endif
$(eval $(call gb_CppunitTest_use_ure,liblibreoffice))
$(eval $(call gb_CppunitTest_add_arguments,liblibreoffice,\ $(eval $(call gb_CppunitTest_add_arguments,liblibreoffice,\
-env:arg-soffice=$(liblibreoffice_SOFFICE_INST) \ -env:arg-soffice=$(liblibreoffice_SOFFICE_INST) \
)) ))
......
...@@ -46,7 +46,11 @@ void Test::test() ...@@ -46,7 +46,11 @@ void Test::test()
rtl::Bootstrap::get( rtl::OUString( "arg-soffice" ), aArgSoffice ); rtl::Bootstrap::get( rtl::OUString( "arg-soffice" ), aArgSoffice );
OString aInstall = OUStringToOString( aArgSoffice, RTL_TEXTENCODING_UTF8 ); OString aInstall = OUStringToOString( aArgSoffice, RTL_TEXTENCODING_UTF8 );
fprintf( stderr, "liblibreoffice test: '%s'\n", aInstall.getStr() ); fprintf( stderr, "liblibreoffice test: '%s'\n", aInstall.getStr() );
assert (lo_init( aInstall.getStr() )); LibLibreOffice *pOffice = lo_init( aInstall.getStr() );
CPPUNIT_ASSERT( pOffice != NULL );
bool bInited = pOffice->initialize( aInstall.getStr() );
CPPUNIT_ASSERT( bInited );
} }
CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_TEST_SUITE_REGISTRATION(Test);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment