[Libreoffice-commits] core.git: Branch 'feature/liblibo' - desktop/inc desktop/Library_libreoffice.mk desktop/source smoketest/libtest.cxx

Jack Leigh leighman at gmx.se
Tue Mar 5 08:20:52 PST 2013


 desktop/Library_libreoffice.mk |    6 ++++++
 desktop/inc/liblibreoffice.h   |   38 --------------------------------------
 desktop/source/lib/init.cxx    |   32 +++++++++++++-------------------
 desktop/source/lib/shim.cxx    |   12 ++++++++----
 smoketest/libtest.cxx          |    6 ++++--
 5 files changed, 31 insertions(+), 63 deletions(-)

New commits:
commit 18b1da0d34f5712c78c4616a570a3a9114f5061c
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/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);


More information about the Libreoffice-commits mailing list