Kaydet (Commit) f73e4594 authored tarafından Andrzej Hunt's avatar Andrzej Hunt Kaydeden (comit) Michael Meeks

LOK: kill double initialize.

Change-Id: I4d3dd913faea8b9f4a0bd3c13af37d097ced9888
üst 2ddcc1af
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include <vcl/graphicfilter.hxx> #include <vcl/graphicfilter.hxx>
#include <unotools/syslocaleoptions.hxx> #include <unotools/syslocaleoptions.hxx>
#include <unotools/mediadescriptor.hxx> #include <unotools/mediadescriptor.hxx>
#include <osl/module.hxx>
using namespace css; using namespace css;
using namespace utl; using namespace utl;
...@@ -207,7 +208,6 @@ struct LibLibreOffice_Impl : public _LibreOfficeKit ...@@ -207,7 +208,6 @@ struct LibLibreOffice_Impl : public _LibreOfficeKit
m_pOfficeClass->nSize = sizeof(LibreOfficeKitClass); m_pOfficeClass->nSize = sizeof(LibreOfficeKitClass);
m_pOfficeClass->destroy = lo_destroy; m_pOfficeClass->destroy = lo_destroy;
m_pOfficeClass->initialize = lo_initialize;
m_pOfficeClass->documentLoad = lo_documentLoad; m_pOfficeClass->documentLoad = lo_documentLoad;
m_pOfficeClass->getError = lo_getError; m_pOfficeClass->getError = lo_getError;
...@@ -411,7 +411,17 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath) ...@@ -411,7 +411,17 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath)
if (!pAppPath) if (!pAppPath)
return 0; 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; OUString aAppURL;
if (osl::FileBase::getFileURLFromSystemPath(aAppPath, aAppURL) != osl::FileBase::E_None) if (osl::FileBase::getFileURLFromSystemPath(aAppPath, aAppURL) != osl::FileBase::E_None)
return 0; return 0;
...@@ -440,12 +450,16 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath) ...@@ -440,12 +450,16 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath)
return bInitialized; return bInitialized;
} }
SAL_DLLPUBLIC_EXPORT LibreOfficeKit *libreofficekit_hook(void) SAL_DLLPUBLIC_EXPORT LibreOfficeKit *libreofficekit_hook(const char* install_path)
{ {
if (!gImpl) if (!gImpl)
{ {
fprintf(stderr, "create libreoffice object\n"); fprintf(stderr, "create libreoffice object\n");
gImpl = new LibLibreOffice_Impl(); gImpl = new LibLibreOffice_Impl();
if (!lo_initialize(gImpl, install_path))
{
lo_destroy(gImpl);
}
} }
return static_cast<LibreOfficeKit*>(gImpl); return static_cast<LibreOfficeKit*>(gImpl);
} }
......
...@@ -40,7 +40,6 @@ struct _LibreOfficeKitClass ...@@ -40,7 +40,6 @@ struct _LibreOfficeKitClass
size_t nSize; size_t nSize;
void (*destroy) (LibreOfficeKit *pThis); void (*destroy) (LibreOfficeKit *pThis);
int (*initialize) (LibreOfficeKit *pThis, const char *pInstallPath);
LibreOfficeKitDocument* (*documentLoad) (LibreOfficeKit *pThis, const char *pURL); LibreOfficeKitDocument* (*documentLoad) (LibreOfficeKit *pThis, const char *pURL);
char* (*getError) (LibreOfficeKit *pThis); char* (*getError) (LibreOfficeKit *pThis);
}; };
......
...@@ -64,11 +64,6 @@ public: ...@@ -64,11 +64,6 @@ public:
mpThis->pClass->destroy(mpThis); mpThis->pClass->destroy(mpThis);
} }
inline bool initialize(const char* pInstallPath)
{
return mpThis->pClass->initialize(mpThis, pInstallPath);
}
inline Document* documentLoad(const char* pUrl) inline Document* documentLoad(const char* pUrl)
{ {
LibreOfficeKitDocument* pDoc = mpThis->pClass->documentLoad(mpThis, pUrl); LibreOfficeKitDocument* pDoc = mpThis->pClass->documentLoad(mpThis, pUrl);
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#define TARGET_LIB SAL_MODULENAME( "sofficeapp" ) #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 ) SAL_DLLPUBLIC_EXPORT LibreOfficeKit *lok_init( const char *install_path )
{ {
...@@ -59,7 +59,7 @@ 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 ); free( imp_lib );
return pSym(); return pSym( install_path );
} }
#endif // not LINUX => port me ! #endif // not LINUX => port me !
......
...@@ -54,13 +54,6 @@ int main (int argc, char **argv) ...@@ -54,13 +54,6 @@ int main (int argc, char **argv)
return -1; return -1;
} }
// This separate init is lame I think.
if( !pOffice->initialize( argv[1] ) )
{
fprintf( stderr, "failed to initialize\n" );
return -1;
}
end = getTimeMS(); end = getTimeMS();
fprintf( stderr, "init time: %ld ms\n", (end-start) ); fprintf( stderr, "init time: %ld ms\n", (end-start) );
start = end; start = end;
......
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