[Libreoffice-commits] core.git: desktop/source include/LibreOfficeKit libreofficekit/source smoketest/libtest.cxx

Andrzej Hunt andrzej.hunt at collabora.com
Wed Jun 18 04:06:41 PDT 2014


 desktop/source/lib/init.cxx               |   20 +++++++++++++++++---
 include/LibreOfficeKit/LibreOfficeKit.h   |    1 -
 include/LibreOfficeKit/LibreOfficeKit.hxx |    5 -----
 libreofficekit/source/shim.c              |    4 ++--
 smoketest/libtest.cxx                     |    7 -------
 5 files changed, 19 insertions(+), 18 deletions(-)

New commits:
commit f73e4594d363c67042089f79f056fc8dae7cf61e
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Tue Jun 17 19:57:25 2014 +0100

    LOK: kill double initialize.
    
    Change-Id: I4d3dd913faea8b9f4a0bd3c13af37d097ced9888

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 6c05f81..eed7831 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -41,6 +41,7 @@
 #include <vcl/graphicfilter.hxx>
 #include <unotools/syslocaleoptions.hxx>
 #include <unotools/mediadescriptor.hxx>
+#include <osl/module.hxx>
 
 using namespace css;
 using namespace utl;
@@ -207,7 +208,6 @@ struct LibLibreOffice_Impl : public _LibreOfficeKit
             m_pOfficeClass->nSize = sizeof(LibreOfficeKitClass);
 
             m_pOfficeClass->destroy = lo_destroy;
-            m_pOfficeClass->initialize = lo_initialize;
             m_pOfficeClass->documentLoad = lo_documentLoad;
             m_pOfficeClass->getError = lo_getError;
 
@@ -411,7 +411,17 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath)
     if (!pAppPath)
         return 0;
 
-    OUString aAppPath(pAppPath, strlen(pAppPath), RTL_TEXTENCODING_UTF8);
+    OUString aAppPath;
+    if (pAppPath)
+    {
+        aAppPath = OUString(pAppPath, strlen(pAppPath), RTL_TEXTENCODING_UTF8);
+    }
+    else
+    {
+        ::osl::Module::getUrlFromAddress( reinterpret_cast< oslGenericFunction >(lo_initialize),
+                                          aAppPath);
+    }
+
     OUString aAppURL;
     if (osl::FileBase::getFileURLFromSystemPath(aAppPath, aAppURL) != osl::FileBase::E_None)
         return 0;
@@ -440,12 +450,16 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath)
     return bInitialized;
 }
 
-SAL_DLLPUBLIC_EXPORT LibreOfficeKit *libreofficekit_hook(void)
+SAL_DLLPUBLIC_EXPORT LibreOfficeKit *libreofficekit_hook(const char* install_path)
 {
     if (!gImpl)
     {
         fprintf(stderr, "create libreoffice object\n");
         gImpl = new LibLibreOffice_Impl();
+        if (!lo_initialize(gImpl, install_path))
+        {
+            lo_destroy(gImpl);
+        }
     }
     return static_cast<LibreOfficeKit*>(gImpl);
 }
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 6bc91e4..63c2c22 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -40,7 +40,6 @@ struct _LibreOfficeKitClass
   size_t  nSize;
 
   void                    (*destroy)       (LibreOfficeKit *pThis);
-  int                     (*initialize)    (LibreOfficeKit *pThis, const char *pInstallPath);
   LibreOfficeKitDocument* (*documentLoad)  (LibreOfficeKit *pThis, const char *pURL);
   char*                   (*getError)      (LibreOfficeKit *pThis);
 };
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 4cd502a..f1db388 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -64,11 +64,6 @@ public:
         mpThis->pClass->destroy(mpThis);
     }
 
-    inline bool initialize(const char* pInstallPath)
-    {
-        return mpThis->pClass->initialize(mpThis, pInstallPath);
-    }
-
     inline Document* documentLoad(const char* pUrl)
     {
         LibreOfficeKitDocument* pDoc = mpThis->pClass->documentLoad(mpThis, pUrl);
diff --git a/libreofficekit/source/shim.c b/libreofficekit/source/shim.c
index 78002ab..6a3f9a7 100644
--- a/libreofficekit/source/shim.c
+++ b/libreofficekit/source/shim.c
@@ -23,7 +23,7 @@
 
 #define TARGET_LIB SAL_MODULENAME( "sofficeapp" )
 
-typedef LibreOfficeKit *(HookFunction)(void);
+typedef LibreOfficeKit *(HookFunction)( const char *install_path);
 
 SAL_DLLPUBLIC_EXPORT LibreOfficeKit *lok_init( const char *install_path )
 {
@@ -59,7 +59,7 @@ SAL_DLLPUBLIC_EXPORT LibreOfficeKit *lok_init( const char *install_path )
     }
 
     free( imp_lib );
-    return pSym();
+    return pSym( install_path );
 }
 
 #endif // not LINUX => port me !
diff --git a/smoketest/libtest.cxx b/smoketest/libtest.cxx
index a116e0c..211d056 100644
--- a/smoketest/libtest.cxx
+++ b/smoketest/libtest.cxx
@@ -54,13 +54,6 @@ int main (int argc, char **argv)
         return -1;
     }
 
-    // This separate init is lame I think.
-    if( !pOffice->initialize( argv[1] ) )
-    {
-        fprintf( stderr, "failed to initialize\n" );
-        return -1;
-    }
-
     end = getTimeMS();
     fprintf( stderr, "init time: %ld ms\n", (end-start) );
     start = end;


More information about the Libreoffice-commits mailing list