[Libreoffice-commits] core.git: desktop/source include/LibreOfficeKit
Oliver Specht
oliver.specht at cib.de
Tue Jan 19 06:39:56 PST 2016
desktop/source/lib/init.cxx | 6 ++++++
include/LibreOfficeKit/LibreOfficeKit.h | 2 ++
include/LibreOfficeKit/LibreOfficeKit.hxx | 9 +++++++++
include/LibreOfficeKit/LibreOfficeKitInit.h | 18 +++++++++---------
4 files changed, 26 insertions(+), 9 deletions(-)
New commits:
commit 442a022cf7baefbd5519ea55c7978cf839e1f44d
Author: Oliver Specht <oliver.specht at cib.de>
Date: Tue Jan 19 10:58:07 2016 +0100
Make LibreOffice kit usable on windows
Uses Ascii variants of LoadLibrary,Get/SetEnvironmentVariable_A_
and adds a freeError function
includes windows.h instead of pre/postwin.h
Change-Id: I88b7e3ed3818078efec5688e207da47dc4049b98
Reviewed-on: https://gerrit.libreoffice.org/21600
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Oliver Specht <oliver.specht at cib.de>
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 28a5442..f8d6a6c 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -430,6 +430,7 @@ static void lo_destroy (LibreOfficeKit* pThis);
static int lo_initialize (LibreOfficeKit* pThis, const char* pInstallPath, const char* pUserProfilePath);
static LibreOfficeKitDocument* lo_documentLoad (LibreOfficeKit* pThis, const char* pURL);
static char * lo_getError (LibreOfficeKit* pThis);
+static void lo_freeError (const char *pfree);
static LibreOfficeKitDocument* lo_documentLoadWithOptions (LibreOfficeKit* pThis,
const char* pURL,
const char* pOptions);
@@ -451,6 +452,7 @@ LibLibreOffice_Impl::LibLibreOffice_Impl()
m_pOfficeClass->destroy = lo_destroy;
m_pOfficeClass->documentLoad = lo_documentLoad;
m_pOfficeClass->getError = lo_getError;
+ m_pOfficeClass->freeError = lo_freeError;
m_pOfficeClass->documentLoadWithOptions = lo_documentLoadWithOptions;
m_pOfficeClass->registerCallback = lo_registerCallback;
m_pOfficeClass->getFilterTypes = lo_getFilterTypes;
@@ -1571,6 +1573,10 @@ static char* lo_getError (LibreOfficeKit *pThis)
strcpy(pMemory, aString.getStr());
return pMemory;
}
+static void lo_freeError(const char *pfree)
+{
+ free((void *) pfree);
+}
static char* lo_getFilterTypes(LibreOfficeKit* pThis)
{
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 7d4210e..8057d75 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -51,6 +51,7 @@ struct _LibreOfficeKitClass
const char* pURL);
char* (*getError) (LibreOfficeKit* pThis);
+ void (*freeError) (const char *pfree);
LibreOfficeKitDocument* (*documentLoadWithOptions) (LibreOfficeKit* pThis,
const char* pURL,
@@ -82,6 +83,7 @@ struct _LibreOfficeKitDocumentClass
const char* pUrl,
const char* pFormat,
const char* pFilterOptions);
+ void (*freeError) (const char *pfree);
#if defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
/// @see lok::Document::getDocumentType().
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 9396f1e..5623fad 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -56,6 +56,10 @@ public:
/// Gives access to the underlying C pointer.
inline LibreOfficeKitDocument *get() { return mpDoc; }
+ inline void freeError(const char *pfree)
+ {
+ mpDoc->pClass->freeError(pfree);
+ }
#if defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
/**
@@ -434,6 +438,11 @@ public:
{
return mpThis->pClass->getError(mpThis);
}
+ inline void freeError(const char *pfree)
+ {
+ mpThis->pClass->freeError(pfree);
+ }
+
#if defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
/**
diff --git a/include/LibreOfficeKit/LibreOfficeKitInit.h b/include/LibreOfficeKit/LibreOfficeKitInit.h
index 880f11e..23e5772 100644
--- a/include/LibreOfficeKit/LibreOfficeKitInit.h
+++ b/include/LibreOfficeKit/LibreOfficeKitInit.h
@@ -76,8 +76,7 @@ extern "C"
#else
- #include "prewin.h"
- #include "postwin.h"
+ #include <windows.h>
#define TARGET_LIB "sofficeapp" ".dll"
#define TARGET_MERGED_LIB "mergedlo" ".dll"
#define SEPARATOR '\\'
@@ -85,7 +84,7 @@ extern "C"
void *lok_loadlib(const char *pFN)
{
- return (void *) LoadLibrary(pFN);
+ return (void *) LoadLibraryA(pFN);
}
char *lok_dlerror(void)
@@ -111,11 +110,11 @@ extern "C"
return;
char* sEnvPath = NULL;
- DWORD cChars = GetEnvironmentVariable("PATH", sEnvPath, 0);
+ DWORD cChars = GetEnvironmentVariableA("PATH", sEnvPath, 0);
if (cChars > 0)
{
sEnvPath = new char[cChars];
- cChars = GetEnvironmentVariable("PATH", sEnvPath, cChars);
+ cChars = GetEnvironmentVariableA("PATH", sEnvPath, cChars);
//If PATH is not set then it is no error
if (cChars == 0 && GetLastError() != ERROR_ENVVAR_NOT_FOUND)
{
@@ -125,17 +124,18 @@ extern "C"
}
//prepare the new PATH. Add the Ure/bin directory at the front.
//note also adding ';'
- char * sNewPath = new char[strlen(sEnvPath) + strlen(pPath) + strlen(UNOPATH) + 2];
+ char * sNewPath = new char[strlen(sEnvPath) + strlen(pPath) * 2 + strlen(UNOPATH) + 4];
sNewPath[0] = L'\0';
- strcat(sNewPath, pPath);
- strcat(sNewPath, UNOPATH);
+ strcat(sNewPath, pPath); // program to PATH
+ strcat(sNewPath, ";");
+ strcat(sNewPath, UNOPATH); // UNO to PATH
if (strlen(sEnvPath))
{
strcat(sNewPath, ";");
strcat(sNewPath, sEnvPath);
}
- SetEnvironmentVariable("PATH", sNewPath);
+ SetEnvironmentVariableA("PATH", sNewPath);
delete[] sEnvPath;
delete[] sNewPath;
More information about the Libreoffice-commits
mailing list