[Libreoffice-commits] core.git: 6 commits - desktop/inc desktop/Library_libreoffice.mk desktop/Library_sofficeapp.mk desktop/Module_desktop.mk desktop/source Repository.mk smoketest/Executable_libtest.mk smoketest/libtest.cxx smoketest/Module_smoketest.mk vcl/inc vcl/source vcl/unx
Michael Meeks
michael.meeks at suse.com
Tue Mar 12 08:36:21 PDT 2013
Repository.mk | 2
desktop/Library_libreoffice.mk | 32 ++++++
desktop/Library_sofficeapp.mk | 5 +
desktop/Module_desktop.mk | 6 +
desktop/inc/liblibreoffice.hxx | 29 +++++
desktop/inc/liblibreoffice_impl.hxx | 27 +++++
desktop/source/lib/init.cxx | 166 ++++++++++++++++++++++++++++++++++
desktop/source/lib/shim.cxx | 57 +++++++++++
smoketest/Executable_libtest.mk | 47 +++++++++
smoketest/Module_smoketest.mk | 6 +
smoketest/libtest.cxx | 38 +++++++
vcl/inc/vcl/svapp.hxx | 5 -
vcl/source/app/svapp.cxx | 2
vcl/unx/generic/plugadapt/salplug.cxx | 30 ++----
14 files changed, 429 insertions(+), 23 deletions(-)
New commits:
commit ddaf31f183fe3f2fbf76c1b87eb5a943dc6d833f
Author: Michael Meeks <michael.meeks at suse.com>
Date: Tue Mar 5 22:21:57 2013 +0000
liblibo: install test library by itself and install it.
Also fix debugging with threads, find fundamentalrc correctly,
make it headless, finally loads a document then exits.
Change-Id: I2017075bf3b3c7198bde53b9fe85585089e5ab6c
diff --git a/Repository.mk b/Repository.mk
index e3ea69b..ffcf18c 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -45,6 +45,7 @@ $(eval $(call gb_Helper_register_executables,NONE, \
gsicheck \
helpex \
idxdict \
+ libtest \
lngconvex \
localize \
makedepend \
diff --git a/desktop/Library_libreoffice.mk b/desktop/Library_libreoffice.mk
index 96b18a1..dbe3e81 100644
--- a/desktop/Library_libreoffice.mk
+++ b/desktop/Library_libreoffice.mk
@@ -17,6 +17,7 @@ $(eval $(call gb_Library_set_include,libreoffice,\
$(eval $(call gb_Library_add_libs,libreoffice,\
$(if $(filter $(OS),LINUX), \
-ldl \
+ -lpthread \
) \
))
diff --git a/desktop/Module_desktop.mk b/desktop/Module_desktop.mk
index d97bff3..a05cceb 100644
--- a/desktop/Module_desktop.mk
+++ b/desktop/Module_desktop.mk
@@ -33,7 +33,6 @@ $(eval $(call gb_Module_add_targets,desktop,\
AllLangResTarget_dkt \
Library_deployment \
Library_deploymentmisc \
- Library_libreoffice \
Library_offacc \
Library_sofficeapp \
Library_spl \
@@ -43,6 +42,12 @@ $(eval $(call gb_Module_add_targets,desktop,\
Zip_brand_dev \
))
+ifeq ($(OS),LINUX)
+$(eval $(call gb_Module_add_targets,desktop,\
+ Library_libreoffice \
+))
+endif
+
ifneq (,$(filter DESKTOP,$(BUILD_TYPE)))
$(eval $(call gb_Module_add_targets,desktop,\
Executable_unopkg.bin \
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index de5788d..06f5eac 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -87,8 +87,20 @@ aBasicErrorFunc( const OUString &rErr, const OUString &rAction )
}
static void
-initialize_uno( const rtl::OUString &aUserProfileURL )
+initialize_uno( const rtl::OUString &aAppURL )
{
+ rtl::Bootstrap::setIniFilename( aAppURL + "/fundamentalrc" );
+
+ OUString aValue;
+ rtl::Bootstrap::set( "CONFIGURATION_LAYERS",
+ "xcsxcu:${BRAND_BASE_DIR}/share/registry "
+ "res:${BRAND_BASE_DIR}/share/registry "
+// "bundledext:${${BRAND_BASE_DIR}/program/unorc:BUNDLED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini " );
+// "sharedext:${${BRAND_BASE_DIR}/program/unorc:SHARED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini "
+// "userext:${${BRAND_BASE_DIR}/program/unorc:UNO_USER_PACKAGES_CACHE}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini "
+// "user:${$BRAND_BASE_DIR/program/bootstraprc:UserInstallation}/user/registrymodifications.xcu"
+ );
+
xContext = cppu::defaultBootstrap_InitialComponentContext();
fprintf( stderr, "Uno initialized %d\n", xContext.is() );
xFactory = xContext->getServiceManager();
@@ -96,8 +108,9 @@ initialize_uno( const rtl::OUString &aUserProfileURL )
comphelper::setProcessServiceFactory(xSFactory);
// set UserInstallation to user profile dir in test/user-template
- rtl::Bootstrap aDefaultVars;
- aDefaultVars.set(rtl::OUString("UserInstallation"), aUserProfileURL );
+// rtl::Bootstrap aDefaultVars;
+// aDefaultVars.set(rtl::OUString("UserInstallation"), aAppURL + "../registry" );
+ // configmgr setup ?
}
bool
@@ -117,15 +130,17 @@ LibLibreOffice_Impl::initialize( const char *app_path )
return false;
try {
- initialize_uno( aAppURL + "../registry" );
+ initialize_uno( aAppURL );
force_c_locale();
+
+ // Force headless
+ rtl::Bootstrap::set( "SAL_USE_VCLPLUGIN", "svp" );
InitVCL();
- if (Application::IsHeadlessModeRequested())
- Application::EnableHeadlessMode(true);
+ Application::EnableHeadlessMode(true);
ErrorHandler::RegisterDisplay( aBasicErrorFunc );
- fprintf (stderr, "do nothing yet");
+ fprintf( stderr, "initialized\n" );
bInitialized = true;
} catch (css::uno::Exception & e) {
fprintf( stderr, "bootstrapping exception '%s'\n",
diff --git a/smoketest/CppunitTest_liblibreoffice.mk b/smoketest/CppunitTest_liblibreoffice.mk
deleted file mode 100644
index e784a3a..0000000
--- a/smoketest/CppunitTest_liblibreoffice.mk
+++ /dev/null
@@ -1,33 +0,0 @@
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
-#
-# 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/.
-#
-
-$(eval $(call gb_CppunitTest_CppunitTest,liblibreoffice))
-
-$(eval $(call gb_CppunitTest_abort_on_assertion,liblibreoffice))
-
-$(eval $(call gb_CppunitTest_add_exception_objects,liblibreoffice,\
- smoketest/libtest \
-))
-
-$(eval $(call gb_CppunitTest_use_libraries,liblibreoffice,\
- libreoffice \
-))
-
-ifeq ($(OS),MACOSX)
-liblibreoffice_SOFFICE_INST := $(DEVINSTALLDIR)/opt/LibreOffice.app/Contents/MacOS
-else
-liblibreoffice_SOFFICE_INST := $(DEVINSTALLDIR)/opt/program
-endif
-
-$(eval $(call gb_CppunitTest_add_arguments,liblibreoffice,\
- -env:arg-soffice=$(liblibreoffice_SOFFICE_INST) \
- -env:arg-testarg.smoketest.doc=$(OUTDIR)/bin/smoketestdoc.sxw \
-))
-
-# vim: set noet sw=4 ts=4:
diff --git a/smoketest/Executable_libtest.mk b/smoketest/Executable_libtest.mk
new file mode 100644
index 0000000..59ba80b
--- /dev/null
+++ b/smoketest/Executable_libtest.mk
@@ -0,0 +1,47 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+
+$(eval $(call gb_Executable_Executable,libtest))
+
+$(eval $(call gb_Executable_set_include,libtest,\
+ $$(INCLUDE) \
+ -I$(SRCDIR)/desktop/inc \
+))
+
+$(eval $(call gb_Executable_use_libraries,libtest,\
+ libreoffice \
+ $(gb_UWINAPI) \
+))
+
+$(eval $(call gb_Executable_add_libs,libtest,\
+ -pthread \
+))
+
+$(eval $(call gb_Executable_add_exception_objects,libtest,\
+ smoketest/libtest \
+))
+
+ifeq ($(OS),MACOSX)
+liblibreoffice_SOFFICE_INST := $(DEVINSTALLDIR)/opt/LibreOffice.app/Contents/MacOS
+else
+liblibreoffice_SOFFICE_INST := $(DEVINSTALLDIR)/opt/program
+endif
+liblibreoffice_OWN_LD_PATH_DIR := $(liblibreoffice_SOFFICE_INST)/libolib
+liblibreoffice_OWN_LD_SO := $(liblibreoffice_OWN_LD_PATH_DIR)/$(call gb_Library_get_linktargetname,libreoffice)
+
+$(liblibreoffice_OWN_LD_SO) : $(call gb_Library_get_target,libreoffice)
+ mkdir -p $(liblibreoffice_OWN_LD_PATH_DIR)/Library
+ cp -a $(call gb_Library_get_target,libreoffice) $(liblibreoffice_OWN_LD_SO)
+
+run_libtest: $(liblibreoffice_OWN_LD_SO)
+ $(gb_Helper_LIBRARY_PATH_VAR)=$${$(gb_Helper_LIBRARY_PATH_VAR):+$$$(gb_Helper_LIBRARY_PATH_VAR):}":$(liblibreoffice_OWN_LD_PATH_DIR)/Library" \
+ $(call gb_LinkTarget_get_target,Executable/libtest) \
+ $(liblibreoffice_SOFFICE_INST) $(OUTDIR)/bin/smoketestdoc.sxw \
+
+# vim: set noet sw=4 ts=4:
diff --git a/smoketest/Module_smoketest.mk b/smoketest/Module_smoketest.mk
index 9a2aa72..31efcce 100644
--- a/smoketest/Module_smoketest.mk
+++ b/smoketest/Module_smoketest.mk
@@ -42,9 +42,11 @@ $(eval $(call gb_Module_add_targets,smoketest,\
))
endif
+ifeq ($(OS),LINUX)
$(eval $(call gb_Module_add_check_targets,smoketest,\
- CppunitTest_liblibreoffice \
+ Executable_libtest \
))
+endif
$(eval $(call gb_Module_add_subsequentcheck_targets,smoketest,\
CppunitTest_smoketest \
diff --git a/smoketest/libtest.cxx b/smoketest/libtest.cxx
index 4e452a7..f3d207f 100644
--- a/smoketest/libtest.cxx
+++ b/smoketest/libtest.cxx
@@ -7,60 +7,32 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-// yuck / FIXME ...
-#include "../desktop/inc/liblibreoffice.hxx"
-
+#include <stdio.h>
#include <assert.h>
+#include <liblibreoffice.hxx>
-#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"
-#include "cppunit/plugin/TestPlugIn.h"
-
-class Test: public CppUnit::TestFixture {
-public:
- virtual void setUp();
- virtual void tearDown();
-
-private:
- CPPUNIT_TEST_SUITE(Test);
- CPPUNIT_TEST(test);
- CPPUNIT_TEST_SUITE_END();
-
- void test();
-};
-
-void Test::setUp()
-{
-}
-void Test::tearDown()
-{
-}
-
-void Test::test()
+int main (int argc, char **argv)
{
- 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() );
- LibLibreOffice *pOffice = lo_init( aInstall.getStr() );
- CPPUNIT_ASSERT( pOffice != NULL );
-
- bool bInited = pOffice->initialize( aInstall.getStr() );
- CPPUNIT_ASSERT( bInited );
-
- rtl::OUString aArgDoc;
- rtl::Bootstrap::get( rtl::OUString( "arg-testarg.smoketest.doc" ), aArgDoc );
- OString aDoc = OUStringToOString ( aArgDoc, RTL_TEXTENCODING_UTF8 );
- fprintf ( stderr, "liblibreoffice doc arg: '%s'\n", aDoc.getStr() );
- pOffice->documentLoad ( aDoc.getStr() );
+ if( argc < 2 )
+ return -1;
+ LibLibreOffice *pOffice = lo_init( argv[1] );
+ if( !pOffice )
+ return -1;
+ // This separate init is lame I think.
+ if( !pOffice->initialize( argv[1] ) )
+ {
+ fprintf( stderr, "failed to initialize\n" );
+ return -1;
+ }
+ fprintf( stderr, "start to load document '%s'\n", argv[2] );
+ LODocument *pDocument = pOffice->documentLoad( argv[2] );
+ if( !pDocument )
+ {
+ fprintf( stderr, "failed to load document '%s'\n", argv[2] );
+ return -1;
+ }
+ fprintf( stderr, "all tests passed." );
+ return 0;
}
-CPPUNIT_TEST_SUITE_REGISTRATION(Test);
-
-CPPUNIT_PLUGIN_IMPLEMENT();
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/vcl/svapp.hxx b/vcl/inc/vcl/svapp.hxx
index 9b4510e..b2c52ec 100644
--- a/vcl/inc/vcl/svapp.hxx
+++ b/vcl/inc/vcl/svapp.hxx
@@ -330,9 +330,8 @@ public:
static const Link& GetFilterHdl();
static void EnableHeadlessMode( bool dialogsAreFatal );
- static sal_Bool IsHeadlessModeEnabled();
-
- static bool IsHeadlessModeRequested();
+ static sal_Bool IsHeadlessModeEnabled();
+ static bool IsHeadlessModeRequested();
///< check command line arguments for --headless
static void ShowNativeErrorBox(const String& sTitle ,
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index cba609d..14b33ea 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -1760,7 +1760,7 @@ bool Application::IsHeadlessModeRequested()
for (sal_uInt32 i = 0; i < n; ++i) {
rtl::OUString arg;
rtl_getAppCommandArg(i, &arg.pData);
- if ( arg == "--headless" ) {
+ if ( arg == "--headless" || arg == "-headless" ) {
return true;
}
}
diff --git a/vcl/unx/generic/plugadapt/salplug.cxx b/vcl/unx/generic/plugadapt/salplug.cxx
index 3d87977..2dbd37f 100644
--- a/vcl/unx/generic/plugadapt/salplug.cxx
+++ b/vcl/unx/generic/plugadapt/salplug.cxx
@@ -21,6 +21,7 @@
#include "osl/process.h"
#include "rtl/ustrbuf.hxx"
+#include "rtl/bootstrap.hxx"
#include "salinst.hxx"
#include "generic/gensys.h"
@@ -198,31 +199,22 @@ static SalInstance* autodetect_plugin()
return pInst;
}
-static SalInstance* check_headless_plugin()
-{
- int nParams = osl_getCommandArgCount();
- OUString aParam;
- for( int i = 0; i < nParams; i++ )
- {
- osl_getCommandArg( i, &aParam.pData );
- if( aParam == "-headless" || aParam == "--headless" )
- {
- return tryInstance("svp");
- }
- }
- return NULL;
-}
-
SalInstance *CreateSalInstance()
{
- SalInstance* pInst = NULL;
+ SalInstance *pInst = NULL;
+ OUString aUsePlugin;
static const char* pUsePlugin = getenv( "SAL_USE_VCLPLUGIN" );
+ if( pUsePlugin )
+ aUsePlugin = OUString::createFromAscii( pUsePlugin );
+ else
+ rtl::Bootstrap::get( "SAL_USE_VCLPLUGIN", aUsePlugin );
- pInst = check_headless_plugin();
+ if( Application::IsHeadlessModeRequested() )
+ aUsePlugin = "svp";
- if( !pInst && pUsePlugin && *pUsePlugin )
- pInst = tryInstance( OUString::createFromAscii( pUsePlugin ), true );
+ if( !aUsePlugin.isEmpty() )
+ pInst = tryInstance( aUsePlugin );
if( ! pInst )
pInst = autodetect_plugin();
commit 08b6643eda69c1d4fc8a0b1277ffdd65834d5f46
Author: Jack Leigh <leighman at gmx.se>
Date: Tue Mar 5 16:47:03 2013 +0000
liblibo: test documentLoad method
Change-Id: I7827a9b96e5a18b7f0b8b374a49ab96625d22d0a
diff --git a/smoketest/CppunitTest_liblibreoffice.mk b/smoketest/CppunitTest_liblibreoffice.mk
index 8755fe8..e784a3a 100644
--- a/smoketest/CppunitTest_liblibreoffice.mk
+++ b/smoketest/CppunitTest_liblibreoffice.mk
@@ -27,6 +27,7 @@ endif
$(eval $(call gb_CppunitTest_add_arguments,liblibreoffice,\
-env:arg-soffice=$(liblibreoffice_SOFFICE_INST) \
+ -env:arg-testarg.smoketest.doc=$(OUTDIR)/bin/smoketestdoc.sxw \
))
# vim: set noet sw=4 ts=4:
diff --git a/smoketest/libtest.cxx b/smoketest/libtest.cxx
index cc71d08..4e452a7 100644
--- a/smoketest/libtest.cxx
+++ b/smoketest/libtest.cxx
@@ -51,6 +51,12 @@ void Test::test()
bool bInited = pOffice->initialize( aInstall.getStr() );
CPPUNIT_ASSERT( bInited );
+
+ rtl::OUString aArgDoc;
+ rtl::Bootstrap::get( rtl::OUString( "arg-testarg.smoketest.doc" ), aArgDoc );
+ OString aDoc = OUStringToOString ( aArgDoc, RTL_TEXTENCODING_UTF8 );
+ fprintf ( stderr, "liblibreoffice doc arg: '%s'\n", aDoc.getStr() );
+ pOffice->documentLoad ( aDoc.getStr() );
}
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
commit f751be6fa0c097ad51e28a79fa91141bf3313d8f
Author: Jack Leigh <leighman at gmx.se>
Date: Tue Mar 5 14:29:26 2013 +0000
liblibo: create XComponent for doc
Change-Id: Ie07ac4a3e89a9a82a107612b81be18d3826c49e1
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 0628b7f..de5788d 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -13,11 +13,14 @@
#include <tools/errinf.hxx>
#include <osl/file.hxx>
+#include <osl/process.h>
#include <rtl/strbuf.hxx>
#include <rtl/bootstrap.hxx>
#include <cppuhelper/bootstrap.hxx>
#include <comphelper/processfactory.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/lang/Locale.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
@@ -39,6 +42,19 @@ static uno::Reference<css::lang::XMultiComponentFactory> xFactory;
LODocument *
LibLibreOffice_Impl::documentLoad( const char *docUrl )
{
+ OUString sUrl = OUString::createFromAscii (docUrl);
+ OUString sAbsoluteDocUrl, sWorkingDir, sDocPathUrl;
+
+ uno::Reference < css::frame::XDesktop2 > xComponentLoader =
+ css::frame::Desktop::create(xContext);
+
+ osl_getProcessWorkingDir(&sWorkingDir.pData);
+ osl::FileBase::getFileURLFromSystemPath(sUrl, sDocPathUrl);
+ osl::FileBase::getAbsoluteFileURL(sWorkingDir, sDocPathUrl, sAbsoluteDocUrl);
+
+ uno::Reference < css::lang::XComponent > xComponent = xComponentLoader->loadComponentFromURL(
+ sAbsoluteDocUrl, OUString("_blank"), 0,
+ uno::Sequence < css::beans::PropertyValue >());
return NULL;
}
@@ -133,4 +149,3 @@ LibLibreOffice_Impl::~LibLibreOffice_Impl ()
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-
commit af969873cb01e44aacfa34623ce1f0d51a62c895
Author: Michael Meeks <michael.meeks at suse.com>
Date: Tue Mar 5 16:40:01 2013 +0000
liblibo: better init code.
Change-Id: I8757739960cb1c764a5a66bd67d34731e3dfbf31
diff --git a/desktop/inc/liblibreoffice.hxx b/desktop/inc/liblibreoffice.hxx
index 74f6769..48c0a24 100644
--- a/desktop/inc/liblibreoffice.hxx
+++ b/desktop/inc/liblibreoffice.hxx
@@ -10,16 +10,15 @@
#ifndef _LIBLIBREOFFICE_HXX
#define _LIBLIBREOFFICE_HXX
-typedef int loboolean;
typedef struct _LODocument LODocument;
class LibLibreOffice
{
public:
- virtual loboolean initialize (const char *installPath) = 0;
+ virtual bool initialize (const char *installPath) = 0;
virtual LODocument *documentLoad (const char *url) = 0;
- virtual loboolean documentSave (const char *url) = 0;
+ virtual bool documentSave (const char *url) = 0;
virtual ~LibLibreOffice () {};
};
diff --git a/desktop/inc/liblibreoffice_impl.hxx b/desktop/inc/liblibreoffice_impl.hxx
index d7686eb..3f7783e 100644
--- a/desktop/inc/liblibreoffice_impl.hxx
+++ b/desktop/inc/liblibreoffice_impl.hxx
@@ -12,16 +12,13 @@
#include "liblibreoffice.hxx"
-typedef int loboolean;
-typedef struct _LODocument LODocument;
-
class LibLibreOffice_Impl : public LibLibreOffice
{
public:
- virtual loboolean initialize (const char *installPath);
+ virtual bool initialize (const char *installPath);
virtual LODocument *documentLoad (const char *url);
- virtual loboolean documentSave (const char *url);
+ virtual bool documentSave (const char *url);
virtual ~LibLibreOffice_Impl ();
};
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 4b47ac6..0628b7f 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1,4 +1,4 @@
-/* -*- 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.
*
@@ -42,7 +42,7 @@ LibLibreOffice_Impl::documentLoad( const char *docUrl )
return NULL;
}
-loboolean
+bool
LibLibreOffice_Impl::documentSave( const char * )
{
return 1;
@@ -73,16 +73,18 @@ aBasicErrorFunc( const OUString &rErr, const OUString &rAction )
static void
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
rtl::Bootstrap aDefaultVars;
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 )
{
static bool bInitialized = false;
@@ -122,6 +124,7 @@ extern "C" {
LibLibreOffice *liblibreoffice_hook(void)
{
+ fprintf( stderr, "create libreoffice object\n" );
return new LibLibreOffice_Impl();
}
diff --git a/desktop/source/lib/shim.cxx b/desktop/source/lib/shim.cxx
index 4c8e61d..546d0da 100644
--- a/desktop/source/lib/shim.cxx
+++ b/desktop/source/lib/shim.cxx
@@ -41,13 +41,14 @@ SAL_DLLPUBLIC_EXPORT LibLibreOffice *lo_init( const char *install_path )
fprintf( stderr, "failed to open library '%s'\n", imp_lib );
return NULL;
}
- free( imp_lib );
HookFunction *pSym = (HookFunction *) dlsym( dlhandle, "liblibreoffice_hook" );
if( !pSym ) {
fprintf( stderr, "failed to find hook in library '%s'\n", imp_lib );
return NULL;
}
+
+ free( imp_lib );
return pSym();
}
diff --git a/smoketest/CppunitTest_liblibreoffice.mk b/smoketest/CppunitTest_liblibreoffice.mk
index 2cd3456..8755fe8 100644
--- a/smoketest/CppunitTest_liblibreoffice.mk
+++ b/smoketest/CppunitTest_liblibreoffice.mk
@@ -15,29 +15,16 @@ $(eval $(call gb_CppunitTest_add_exception_objects,liblibreoffice,\
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,\
- cppu \
- cppuhelper \
libreoffice \
- sal \
- unotest \
))
ifeq ($(OS),MACOSX)
-liblibreoffice_SOFFICE_INST := path:$(DEVINSTALLDIR)/opt/LibreOffice.app/Contents/MacOS
+liblibreoffice_SOFFICE_INST := $(DEVINSTALLDIR)/opt/LibreOffice.app/Contents/MacOS
else
-liblibreoffice_SOFFICE_INST := path:$(DEVINSTALLDIR)/opt/program
+liblibreoffice_SOFFICE_INST := $(DEVINSTALLDIR)/opt/program
endif
-$(eval $(call gb_CppunitTest_use_ure,liblibreoffice))
-
$(eval $(call gb_CppunitTest_add_arguments,liblibreoffice,\
-env:arg-soffice=$(liblibreoffice_SOFFICE_INST) \
))
diff --git a/smoketest/libtest.cxx b/smoketest/libtest.cxx
index 36c3a0c..cc71d08 100644
--- a/smoketest/libtest.cxx
+++ b/smoketest/libtest.cxx
@@ -46,7 +46,11 @@ void Test::test()
rtl::Bootstrap::get( rtl::OUString( "arg-soffice" ), aArgSoffice );
OString aInstall = OUStringToOString( aArgSoffice, RTL_TEXTENCODING_UTF8 );
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);
commit 07352f07ce40ef40e9b73fd05aa4f9c5eac38290
Author: Jack Leigh <leighman at gmx.se>
Date: Tue Mar 5 16:19:58 2013 +0000
liblibo: move to C++ interface.
Change-Id: Ie14a9446abd9524604feddf811d5373a26a30cbd
diff --git a/desktop/Library_libreoffice.mk b/desktop/Library_libreoffice.mk
index a40bbd7..96b18a1 100644
--- a/desktop/Library_libreoffice.mk
+++ b/desktop/Library_libreoffice.mk
@@ -14,6 +14,12 @@ $(eval $(call gb_Library_set_include,libreoffice,\
-I$(SRCDIR)/desktop/inc \
))
+$(eval $(call gb_Library_add_libs,libreoffice,\
+ $(if $(filter $(OS),LINUX), \
+ -ldl \
+ ) \
+))
+
$(eval $(call gb_Library_use_libraries,libreoffice,\
$(gb_UWINAPI) \
))
diff --git a/desktop/inc/liblibreoffice.h b/desktop/inc/liblibreoffice.h
deleted file mode 100644
index dde50ce..0000000
--- a/desktop/inc/liblibreoffice.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* -*- 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/.
- */
-
-/*
- * A simple C API to setup and use libreoffice
- */
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct {
- int errno;
- char *message;
-} LOError;
-
-typedef int loboolean;
-typedef struct _LODocument LODocument;
-
-loboolean lo_initialize (const char *install_path);
-
-void lo_error_free (LOError *error);
-LOError *lo_error_new (int errno, const char *message);
-
-LODocument *lo_document_load (const char *url, LOError **opt_error);
-loboolean lo_document_save (const char *url, LOError **opt_error);
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-
diff --git a/desktop/inc/liblibreoffice.hxx b/desktop/inc/liblibreoffice.hxx
new file mode 100644
index 0000000..74f6769
--- /dev/null
+++ b/desktop/inc/liblibreoffice.hxx
@@ -0,0 +1,30 @@
+/* -*- 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/.
+ */
+
+#ifndef _LIBLIBREOFFICE_HXX
+#define _LIBLIBREOFFICE_HXX
+
+typedef int loboolean;
+typedef struct _LODocument LODocument;
+
+class LibLibreOffice
+{
+public:
+ virtual loboolean initialize (const char *installPath) = 0;
+
+ virtual LODocument *documentLoad (const char *url) = 0;
+ virtual loboolean documentSave (const char *url) = 0;
+
+ virtual ~LibLibreOffice () {};
+};
+
+LibLibreOffice *lo_init (const char *install_path);
+
+#endif
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/desktop/inc/liblibreoffice_impl.hxx b/desktop/inc/liblibreoffice_impl.hxx
new file mode 100644
index 0000000..d7686eb
--- /dev/null
+++ b/desktop/inc/liblibreoffice_impl.hxx
@@ -0,0 +1,30 @@
+/* -*- 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/.
+ */
+
+#ifndef _LIBLIBREOFFICE_IMPL_HXX
+#define _LIBLIBREOFFICE_IMPL_HXX
+
+#include "liblibreoffice.hxx"
+
+typedef int loboolean;
+typedef struct _LODocument LODocument;
+
+class LibLibreOffice_Impl : public LibLibreOffice
+{
+public:
+ virtual loboolean initialize (const char *installPath);
+
+ virtual LODocument *documentLoad (const char *url);
+ virtual loboolean documentSave (const char *url);
+
+ virtual ~LibLibreOffice_Impl ();
+};
+
+#endif
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 5aab66b..4b47ac6 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -7,9 +7,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include <liblibreoffice_impl.hxx>
+
#include <stdio.h>
-#include <liblibreoffice.h>
#include <tools/errinf.hxx>
#include <osl/file.hxx>
#include <rtl/strbuf.hxx>
@@ -35,25 +36,14 @@ static uno::Reference<css::uno::XComponentContext> xContext;
static uno::Reference<css::lang::XMultiServiceFactory> xSFactory;
static uno::Reference<css::lang::XMultiComponentFactory> xFactory;
-SAL_DLLPUBLIC_EXPORT void
-lo_error_free( LOError * )
-{
-}
-
-SAL_DLLPUBLIC_EXPORT LOError *
-lo_error_new( int, const char * )
+LODocument *
+LibLibreOffice_Impl::documentLoad( const char *docUrl )
{
return NULL;
}
-SAL_DLLPUBLIC_EXPORT LODocument *
-lo_document_load( const char *, LOError ** )
-{
- return NULL;
-}
-
-SAL_DLLPUBLIC_EXPORT loboolean
-lo_document_save( const char *, LOError ** )
+loboolean
+LibLibreOffice_Impl::documentSave( const char * )
{
return 1;
}
@@ -92,8 +82,8 @@ initialize_uno( const rtl::OUString &aUserProfileURL )
xSFactory = uno::Reference<lang::XMultiServiceFactory>(xFactory, uno::UNO_QUERY_THROW);
}
-SAL_DLLPUBLIC_EXPORT loboolean
-lo_initialize( const char *app_path )
+loboolean
+LibLibreOffice_Impl::initialize( const char *app_path )
{
static bool bInitialized = false;
if( bInitialized )
@@ -132,7 +122,11 @@ extern "C" {
LibLibreOffice *liblibreoffice_hook(void)
{
- return new LibLibreOffice();
+ return new LibLibreOffice_Impl();
+}
+
+LibLibreOffice_Impl::~LibLibreOffice_Impl ()
+{
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/desktop/source/lib/shim.cxx b/desktop/source/lib/shim.cxx
index c57803e..4c8e61d 100644
--- a/desktop/source/lib/shim.cxx
+++ b/desktop/source/lib/shim.cxx
@@ -9,8 +9,12 @@
#ifdef LINUX
+#include <stdio.h>
+#include <string.h>
+
+#include <osl/module.h>
#include <sal/types.h>
-#include <liblibreoffice.h>
+#include <liblibreoffice.hxx>
#include <dlfcn.h>
#ifdef AIX
@@ -23,11 +27,11 @@ extern "C" {
typedef LibLibreOffice *(HookFunction)(void);
};
-extern LibLibreOffice *lo_init( const char *install_path )
+SAL_DLLPUBLIC_EXPORT LibLibreOffice *lo_init( const char *install_path )
{
if( !install_path )
return NULL;
- char *impl_lib = malloc( strlen (install_path) + sizeof( TARGET_LIB ) + 2 );
+ char *imp_lib = (char *) malloc( strlen (install_path) + sizeof( TARGET_LIB ) + 2 );
strcpy( imp_lib, install_path );
strcat( imp_lib, "/" );
strcat( imp_lib, TARGET_LIB );
@@ -39,7 +43,7 @@ extern LibLibreOffice *lo_init( const char *install_path )
}
free( imp_lib );
- HookFunction *pSym = dlsym( dlhandle, "liblibreoffice_hook" );
+ HookFunction *pSym = (HookFunction *) dlsym( dlhandle, "liblibreoffice_hook" );
if( !pSym ) {
fprintf( stderr, "failed to find hook in library '%s'\n", imp_lib );
return NULL;
diff --git a/smoketest/libtest.cxx b/smoketest/libtest.cxx
index 39ab01b..36c3a0c 100644
--- a/smoketest/libtest.cxx
+++ b/smoketest/libtest.cxx
@@ -8,7 +8,9 @@
*/
// yuck / FIXME ...
-#include "../desktop/inc/liblibreoffice.h"
+#include "../desktop/inc/liblibreoffice.hxx"
+
+#include <assert.h>
#include <sal/types.h>
#include <rtl/ustring.hxx>
@@ -44,7 +46,7 @@ void Test::test()
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() );
+ assert (lo_init( aInstall.getStr() ));
}
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
commit 8887de72c184bec6225a952ec90433ae1b7a5b26
Author: Michael Meeks <michael.meeks at suse.com>
Date: Tue Mar 5 13:16:36 2013 +0000
liblibo: create initial liblibreoffice.
bootstrap libreoffice, start a dummy test-harness: can't use CppUnit
or link to any URE / LibreOffice libraries.
Change-Id: I855b640557f93959749e966a2d8e5e577fd84574
diff --git a/Repository.mk b/Repository.mk
index a7b1706..e3ea69b 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -472,6 +472,7 @@ $(eval $(call gb_Helper_register_libraries,PLAINLIBS_OOO, \
hsqldb \
index_data \
java_uno_accessbridge \
+ libreoffice \
localedata_en \
localedata_es \
localedata_euro \
diff --git a/desktop/Library_libreoffice.mk b/desktop/Library_libreoffice.mk
new file mode 100644
index 0000000..a40bbd7
--- /dev/null
+++ b/desktop/Library_libreoffice.mk
@@ -0,0 +1,25 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+
+$(eval $(call gb_Library_Library,libreoffice))
+
+$(eval $(call gb_Library_set_include,libreoffice,\
+ $$(INCLUDE) \
+ -I$(SRCDIR)/desktop/inc \
+))
+
+$(eval $(call gb_Library_use_libraries,libreoffice,\
+ $(gb_UWINAPI) \
+))
+
+$(eval $(call gb_Library_add_exception_objects,libreoffice,\
+ desktop/source/lib/shim \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/desktop/Library_sofficeapp.mk b/desktop/Library_sofficeapp.mk
index 2a635b5..5ae66d2 100644
--- a/desktop/Library_sofficeapp.mk
+++ b/desktop/Library_sofficeapp.mk
@@ -90,6 +90,11 @@ $(eval $(call gb_Library_add_exception_objects,sofficeapp,\
desktop/source/migration/migration \
))
+# liblibreoffice bits
+$(eval $(call gb_Library_add_exception_objects,sofficeapp,\
+ desktop/source/lib/init \
+))
+
ifeq ($(ENABLE_TELEPATHY),TRUE)
$(eval $(call gb_Library_use_libraries,sofficeapp,tubes))
endif
diff --git a/desktop/Module_desktop.mk b/desktop/Module_desktop.mk
index 538553a..d97bff3 100644
--- a/desktop/Module_desktop.mk
+++ b/desktop/Module_desktop.mk
@@ -33,6 +33,7 @@ $(eval $(call gb_Module_add_targets,desktop,\
AllLangResTarget_dkt \
Library_deployment \
Library_deploymentmisc \
+ Library_libreoffice \
Library_offacc \
Library_sofficeapp \
Library_spl \
diff --git a/desktop/inc/liblibreoffice.h b/desktop/inc/liblibreoffice.h
new file mode 100644
index 0000000..dde50ce
--- /dev/null
+++ b/desktop/inc/liblibreoffice.h
@@ -0,0 +1,38 @@
+/* -*- 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/.
+ */
+
+/*
+ * A simple C API to setup and use libreoffice
+ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ int errno;
+ char *message;
+} LOError;
+
+typedef int loboolean;
+typedef struct _LODocument LODocument;
+
+loboolean lo_initialize (const char *install_path);
+
+void lo_error_free (LOError *error);
+LOError *lo_error_new (int errno, const char *message);
+
+LODocument *lo_document_load (const char *url, LOError **opt_error);
+loboolean lo_document_save (const char *url, LOError **opt_error);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
new file mode 100644
index 0000000..5aab66b
--- /dev/null
+++ b/desktop/source/lib/init.cxx
@@ -0,0 +1,139 @@
+/* -*- 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/.
+ */
+
+#include <stdio.h>
+
+#include <liblibreoffice.h>
+#include <tools/errinf.hxx>
+#include <osl/file.hxx>
+#include <rtl/strbuf.hxx>
+#include <rtl/bootstrap.hxx>
+#include <cppuhelper/bootstrap.hxx>
+#include <comphelper/processfactory.hxx>
+
+#include <com/sun/star/lang/Locale.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/ucb/XContentProvider.hpp>
+#include <com/sun/star/ucb/XUniversalContentBroker.hpp>
+
+#include <vcl/svapp.hxx>
+#include <tools/resmgr.hxx>
+#include <vcl/graphicfilter.hxx>
+#include <unotools/syslocaleoptions.hxx>
+
+using namespace ::com::sun::star;
+
+// Wonder global state ...
+static uno::Reference<css::uno::XComponentContext> xContext;
+static uno::Reference<css::lang::XMultiServiceFactory> xSFactory;
+static uno::Reference<css::lang::XMultiComponentFactory> xFactory;
+
+SAL_DLLPUBLIC_EXPORT void
+lo_error_free( LOError * )
+{
+}
+
+SAL_DLLPUBLIC_EXPORT LOError *
+lo_error_new( int, const char * )
+{
+ return NULL;
+}
+
+SAL_DLLPUBLIC_EXPORT LODocument *
+lo_document_load( const char *, LOError ** )
+{
+ return NULL;
+}
+
+SAL_DLLPUBLIC_EXPORT loboolean
+lo_document_save( const char *, LOError ** )
+{
+ return 1;
+}
+
+static void
+force_c_locale( void )
+{
+ // force locale (and resource files loaded) to en-US
+ css::lang::Locale aLocale( "en", "US", "");
+ ResMgr::SetDefaultLocale( aLocale );
+ SvtSysLocaleOptions aLocalOptions;
+ OUString aLangISO( "en-US" );
+ aLocalOptions.SetLocaleConfigString( aLangISO );
+ aLocalOptions.SetUILocaleConfigString( aLangISO );
+}
+
+static void
+aBasicErrorFunc( const OUString &rErr, const OUString &rAction )
+{
+ OStringBuffer aErr( "Unexpected dialog: " );
+ aErr.append( OUStringToOString( rAction, RTL_TEXTENCODING_ASCII_US ) );
+ aErr.append( " Error: " );
+ aErr.append( OUStringToOString( rErr, RTL_TEXTENCODING_ASCII_US ) );
+ fprintf( stderr, "Unexpected basic error dialog '%s'\n", aErr.getStr() );
+}
+
+static void
+initialize_uno( const rtl::OUString &aUserProfileURL )
+{
+ // set UserInstallation to user profile dir in test/user-template
+ rtl::Bootstrap aDefaultVars;
+ aDefaultVars.set(rtl::OUString("UserInstallation"), aUserProfileURL );
+
+ xContext = comphelper::getProcessComponentContext();
+ xFactory = xContext->getServiceManager();
+ xSFactory = uno::Reference<lang::XMultiServiceFactory>(xFactory, uno::UNO_QUERY_THROW);
+}
+
+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( aAppURL + "../registry" );
+ force_c_locale();
+ InitVCL();
+ if (Application::IsHeadlessModeRequested())
+ Application::EnableHeadlessMode(true);
+
+ 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;
+}
+
+extern "C" {
+ SAL_DLLPUBLIC_EXPORT LibLibreOffice *liblibreoffice_hook(void);
+}
+
+LibLibreOffice *liblibreoffice_hook(void)
+{
+ return new LibLibreOffice();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+
diff --git a/desktop/source/lib/shim.cxx b/desktop/source/lib/shim.cxx
new file mode 100644
index 0000000..c57803e
--- /dev/null
+++ b/desktop/source/lib/shim.cxx
@@ -0,0 +1,52 @@
+/* -*- 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/.
+ */
+
+#ifdef LINUX
+
+#include <sal/types.h>
+#include <liblibreoffice.h>
+
+#include <dlfcn.h>
+#ifdef AIX
+# include <sys/ldr.h>
+#endif
+
+#define TARGET_LIB SAL_MODULENAME( "sofficeapp" )
+
+extern "C" {
+ typedef LibLibreOffice *(HookFunction)(void);
+};
+
+extern LibLibreOffice *lo_init( const char *install_path )
+{
+ if( !install_path )
+ return NULL;
+ char *impl_lib = malloc( strlen (install_path) + sizeof( TARGET_LIB ) + 2 );
+ strcpy( imp_lib, install_path );
+ strcat( imp_lib, "/" );
+ strcat( imp_lib, TARGET_LIB );
+ void *dlhandle = dlopen( imp_lib, RTLD_LAZY );
+ if( !dlhandle )
+ {
+ fprintf( stderr, "failed to open library '%s'\n", imp_lib );
+ return NULL;
+ }
+ free( imp_lib );
+
+ HookFunction *pSym = dlsym( dlhandle, "liblibreoffice_hook" );
+ if( !pSym ) {
+ fprintf( stderr, "failed to find hook in library '%s'\n", imp_lib );
+ return NULL;
+ }
+ return pSym();
+}
+
+#endif // LINUX - port me !
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/smoketest/CppunitTest_liblibreoffice.mk b/smoketest/CppunitTest_liblibreoffice.mk
new file mode 100644
index 0000000..2cd3456
--- /dev/null
+++ b/smoketest/CppunitTest_liblibreoffice.mk
@@ -0,0 +1,45 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+
+$(eval $(call gb_CppunitTest_CppunitTest,liblibreoffice))
+
+$(eval $(call gb_CppunitTest_abort_on_assertion,liblibreoffice))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,liblibreoffice,\
+ 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,\
+ cppu \
+ cppuhelper \
+ libreoffice \
+ sal \
+ unotest \
+))
+
+ifeq ($(OS),MACOSX)
+liblibreoffice_SOFFICE_INST := path:$(DEVINSTALLDIR)/opt/LibreOffice.app/Contents/MacOS
+else
+liblibreoffice_SOFFICE_INST := path:$(DEVINSTALLDIR)/opt/program
+endif
+
+$(eval $(call gb_CppunitTest_use_ure,liblibreoffice))
+
+$(eval $(call gb_CppunitTest_add_arguments,liblibreoffice,\
+ -env:arg-soffice=$(liblibreoffice_SOFFICE_INST) \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/smoketest/Module_smoketest.mk b/smoketest/Module_smoketest.mk
index 9de8a44..9a2aa72 100644
--- a/smoketest/Module_smoketest.mk
+++ b/smoketest/Module_smoketest.mk
@@ -42,6 +42,10 @@ $(eval $(call gb_Module_add_targets,smoketest,\
))
endif
+$(eval $(call gb_Module_add_check_targets,smoketest,\
+ CppunitTest_liblibreoffice \
+))
+
$(eval $(call gb_Module_add_subsequentcheck_targets,smoketest,\
CppunitTest_smoketest \
))
diff --git a/smoketest/libtest.cxx b/smoketest/libtest.cxx
new file mode 100644
index 0000000..39ab01b
--- /dev/null
+++ b/smoketest/libtest.cxx
@@ -0,0 +1,54 @@
+/* -*- 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"
+#include "cppunit/plugin/TestPlugIn.h"
+
+class Test: public CppUnit::TestFixture {
+public:
+ virtual void setUp();
+ virtual void tearDown();
+
+private:
+ CPPUNIT_TEST_SUITE(Test);
+ CPPUNIT_TEST(test);
+ CPPUNIT_TEST_SUITE_END();
+
+ void test();
+};
+
+void Test::setUp()
+{
+}
+void Test::tearDown()
+{
+}
+
+void Test::test()
+{
+ 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: */
More information about the Libreoffice-commits
mailing list