summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrzej Hunt <andrzej.hunt@collabora.com>2014-06-17 19:57:25 +0100
committerMichael Meeks <michael.meeks@collabora.com>2014-06-18 12:07:16 +0100
commitf73e4594d363c67042089f79f056fc8dae7cf61e (patch)
tree06e89a421305489ec400d90940aa71ee49f7b9bc
parent2ddcc1afb07e75ef388a200faeeacf833520a0d9 (diff)
LOK: kill double initialize.
Change-Id: I4d3dd913faea8b9f4a0bd3c13af37d097ced9888
-rw-r--r--desktop/source/lib/init.cxx20
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.h1
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.hxx5
-rw-r--r--libreofficekit/source/shim.c4
-rw-r--r--smoketest/libtest.cxx7
5 files changed, 19 insertions, 18 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 6c05f815f008..eed7831eaf54 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 6bc91e453456..63c2c22cd471 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 4cd502addd97..f1db388655f0 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 78002ab81753..6a3f9a78cdfa 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 a116e0c5e60f..211d05616639 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;