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

2014-11-18 Thread Juergen Funk
 include/LibreOfficeKit/LibreOfficeKit.hxx   |2 
 include/LibreOfficeKit/LibreOfficeKitInit.h |  117 +---
 smoketest/libtest.cxx   |   58 +++--
 3 files changed, 153 insertions(+), 24 deletions(-)

New commits:
commit 725a52c55e91d3629dfbfb9ba4758048d8bf1a77
Author: Juergen Funk juergen.funk...@cib.de
Date:   Fri Nov 14 10:56:40 2014 +0100

Preparation of the LibreOfficeKit for Windows

- not yet included in the make for windows

Change-Id: Iee31b0ed0c6545572295ce00a3bb0f909c428b5a
Reviewed-on: https://gerrit.libreoffice.org/12425
Reviewed-by: Caolán McNamara caol...@redhat.com
Tested-by: Caolán McNamara caol...@redhat.com

diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx 
b/include/LibreOfficeKit/LibreOfficeKit.hxx
index f61a4b8..f1255f4 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -38,7 +38,7 @@ public:
 
 inline bool saveAs(const char* pUrl, const char* pFormat = NULL, const 
char* pFilterOptions = NULL)
 {
-return mpDoc-pClass-saveAs(mpDoc, pUrl, pFormat, pFilterOptions);
+return mpDoc-pClass-saveAs(mpDoc, pUrl, pFormat, pFilterOptions) != 
0;
 }
 
 inline LibreOfficeKitDocument *get() { return mpDoc; }
diff --git a/include/LibreOfficeKit/LibreOfficeKitInit.h 
b/include/LibreOfficeKit/LibreOfficeKitInit.h
index 010ae9f..37a1fb5 100644
--- a/include/LibreOfficeKit/LibreOfficeKitInit.h
+++ b/include/LibreOfficeKit/LibreOfficeKitInit.h
@@ -17,22 +17,115 @@ extern C
 {
 #endif
 
-#if defined(__linux__) || defined (__FreeBSD_kernel__) || defined(_AIX)
+#if defined(__linux__) || defined (__FreeBSD_kernel__) || defined(_AIX) || 
defined(_WIN32)
 
 #include stdio.h
 #include stdlib.h
 #include string.h
 
-#include dlfcn.h
-#ifdef  _AIX
-#  include sys/ldr.h
+
+#ifndef _WIN32
+#include dlfcn.h
+#ifdef  _AIX
+#  include sys/ldr.h
+#endif
+#define TARGET_LIBlib sofficeapp .so
+#define TARGET_MERGED_LIB lib mergedlo .so
+#define SEPERATOR '/'
+
+void *_dlopen(const char *pFN)
+{
+return dlopen(pFN, RTLD_LAZY);
+}
+
+
+void *_dlsym(void *Hnd, const char *pName)
+{
+return dlsym(Hnd, pName);
+}
+
+
+int _dlclose(void *Hnd)
+{
+return dlclose(Hnd);
+}
+
+void extendUnoPath(const char *pPath)
+{
+(void)pPath;
+}
+
+
+#else
+
+#include windows.h
+#define TARGET_LIBsofficeapp .dll
+#define TARGET_MERGED_LIB mergedlo .dll
+#define SEPERATOR '\\'
+#define UNOPATH   \\..\\URE\\bin
+
+
+void *_dlopen(const char *pFN)
+{
+return (void *) LoadLibrary(pFN);
+}
+
+
+void *_dlsym(void *Hnd, const char *pName)
+{
+return GetProcAddress((HINSTANCE) Hnd, pName);
+}
+
+
+int _dlclose(void *Hnd)
+{
+return FreeLibrary((HINSTANCE) Hnd);
+}
+
+void extendUnoPath(const char *pPath)
+{
+if (!pPath)
+return;
+
+char* sEnvPath = NULL;
+DWORD  cChars = GetEnvironmentVariable(PATH, sEnvPath, 0);
+if (cChars  0)
+{
+sEnvPath = new char[cChars];
+cChars = GetEnvironmentVariable(PATH, sEnvPath, cChars);
+//If PATH is not set then it is no error
+if (cChars == 0  GetLastError() != ERROR_ENVVAR_NOT_FOUND)
+{
+delete[] sEnvPath;
+return;
+}
+}
+//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];
+sNewPath[0] = L'\0';
+strcat(sNewPath, pPath);
+strcat(sNewPath, UNOPATH);
+if (strlen(sEnvPath))
+{
+strcat(sNewPath, ;);
+strcat(sNewPath, sEnvPath);
+}
+
+SetEnvironmentVariable(PATH, sNewPath);
+
+delete[] sEnvPath;
+delete[] sNewPath;
+}
 #endif
 
-#define TARGET_LIBlib sofficeapp .so
-#define TARGET_MERGED_LIB lib mergedlo .so
+
+
+
 
 typedef LibreOfficeKit *(HookFunction)( const char *install_path);
 
+
 static LibreOfficeKit *lok_init( const char *install_path )
 {
 char *imp_lib;
@@ -54,15 +147,17 @@ static LibreOfficeKit *lok_init( const char *install_path )
 
 strcpy(imp_lib, install_path);
 
-imp_lib[partial_length++] = '/';
+ extendUnoPath(install_path);
+
+imp_lib[partial_length++] = SEPERATOR;
 strcpy(imp_lib + partial_length, TARGET_LIB);
 
-dlhandle = dlopen(imp_lib, RTLD_LAZY);
+dlhandle = _dlopen(imp_lib);
 if (!dlhandle)
 {
 strcpy(imp_lib + partial_length, TARGET_MERGED_LIB);
 
-dlhandle = dlopen(imp_lib, RTLD_LAZY);
+dlhandle = _dlopen(imp_lib);
 if (!dlhandle)
 {
 fprintf(stderr, failed to open library '%s' or 

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

2014-06-12 Thread Caolán McNamara
 include/LibreOfficeKit/LibreOfficeKit.h |8 
 smoketest/libtest.cxx   |7 ---
 2 files changed, 8 insertions(+), 7 deletions(-)

New commits:
commit 18c786cbcd45ee314bed6303c62e23ecf4022a8b
Author: Caolán McNamara caol...@redhat.com
Date:   Thu Jun 12 14:28:17 2014 +0100

cast loses precision

Change-Id: Ic688f08cada4ae70ea1dfb1e29e249a166456452

diff --git a/include/LibreOfficeKit/LibreOfficeKit.h 
b/include/LibreOfficeKit/LibreOfficeKit.h
index 657c16c..43eb212 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -20,14 +20,14 @@ typedef struct _LibreOfficeKitDocument 
LibreOfficeKitDocument;
 
 // Do we have an extended member in this struct ?
 #define LIBREOFFICEKIT_HAS_MEMBER(strct,member,nSize) \
-int)((unsigned char *)((strct *) 0)-member) +  \
-  (int)sizeof ((strct *) 0)-member)) = (nSize))
+size_t)((unsigned char *)((strct *) 0)-member) +  \
+  sizeof ((strct *) 0)-member)) = (nSize))
 
 #define LIBREOFFICEKIT_HAS(pKit,member) 
LIBREOFFICEKIT_HAS_MEMBER(LibreOfficeKit,member,(pKit)-nSize)
 
 struct _LibreOfficeKit
 {
-  int  nSize;
+  size_t  nSize;
 
   void(*destroy)   (LibreOfficeKit *pThis);
   int (*initialize)(LibreOfficeKit *pThis, const char 
*pInstallPath);
@@ -39,7 +39,7 @@ struct _LibreOfficeKit
 
 struct _LibreOfficeKitDocument
 {
-  int  nSize;
+  size_t  nSize;
 
   void (*destroy)   (LibreOfficeKitDocument* pThis);
   int (*saveAs) (LibreOfficeKitDocument* pThis,
diff --git a/smoketest/libtest.cxx b/smoketest/libtest.cxx
index 2316b8c..51c184b 100644
--- a/smoketest/libtest.cxx
+++ b/smoketest/libtest.cxx
@@ -13,6 +13,7 @@
 #include assert.h
 #include math.h
 #include sys/time.h
+#include sal/types.h
 #include LibreOfficeKit/LibreOfficeKit.hxx
 
 using namespace ::lok;
@@ -77,9 +78,9 @@ int main (int argc, char **argv)
 
 if (!LIBREOFFICEKIT_DOCUMENT_HAS(pDocument-get(), saveAsWithOptions))
 {
-fprintf( stderr, using obsolete LibreOffice %d + %d vs. %d\n,
- (int)((unsigned char *)((LibreOfficeKitDocument *) 
0)-saveAsWithOptions),
- (int)sizeof ((LibreOfficeKitDocument *) 0)-saveAsWithOptions,
+fprintf( stderr, using obsolete LibreOffice % SAL_PRI_SIZET d + % 
SAL_PRI_SIZET d vs. % SAL_PRI_SIZET d\n,
+ (size_t)((unsigned char *)((LibreOfficeKitDocument *) 
0)-saveAsWithOptions),
+ sizeof ((LibreOfficeKitDocument *) 0)-saveAsWithOptions,
  pDocument-get()-nSize );
 return -1;
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits