[Libreoffice-commits] core.git: Branch 'feature/cib_contract561' - 2 commits - desktop/source include/LibreOfficeKit libreofficekit/source

Pranav Kant pranavk at collabora.com
Fri Sep 15 07:14:05 UTC 2017


Rebased ref, commits from common ancestor:
commit f84f5ea96853132f84d0b5c2cea1245c2fd97adb
Author: Pranav Kant <pranavk at collabora.com>
Date:   Tue Jun 21 00:15:38 2016 +0530

    lok: Expose LO version information
    
    Change-Id: Ided924e928c04385457c7a2e231fdf57e7e38970

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index fc957bf2effb..bd8c768ea696 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -61,6 +61,7 @@
 #include <vcl/sysdata.hxx>
 #include <vcl/virdev.hxx>
 #include <vcl/ITiledRenderable.hxx>
+#include <unotools/configmgr.hxx>
 #include <unotools/syslocaleoptions.hxx>
 #include <unotools/mediadescriptor.hxx>
 #include <osl/module.hxx>
@@ -307,6 +308,7 @@ static LibreOfficeKitDocument* lo_documentLoadWithOptions  (LibreOfficeKit* pThi
 static void                    lo_registerCallback (LibreOfficeKit* pThis,
                                                     LibreOfficeKitCallback pCallback,
                                                     void* pData);
+static char*                   lo_getVersionInfo(LibreOfficeKit* pThis);
 
 struct LibLibreOffice_Impl : public _LibreOfficeKit
 {
@@ -324,6 +326,7 @@ struct LibLibreOffice_Impl : public _LibreOfficeKit
         if(!(m_pOfficeClass = gOfficeClass.lock())) {
             m_pOfficeClass.reset(new LibreOfficeKitClass);
             m_pOfficeClass->nSize = sizeof(LibreOfficeKitClass);
+        m_pOfficeClass->getVersionInfo = lo_getVersionInfo;
 
             m_pOfficeClass->destroy = lo_destroy;
             m_pOfficeClass->documentLoad = lo_documentLoad;
@@ -979,6 +982,15 @@ static void lo_freeError(char *pfree)
     free((void *) pfree);
 }
 
+static char* lo_getVersionInfo(LibreOfficeKit* /*pThis*/)
+{
+    const OString sVersionStr = OUStringToOString(ReplaceStringHookProc("%PRODUCTNAME %PRODUCTVERSION %PRODUCTEXTENSION %BUILDID"), RTL_TEXTENCODING_UTF8);
+
+    char* pVersion = static_cast<char*>(malloc(sVersionStr.getLength() + 1));
+    strcpy(pVersion, sVersionStr.getStr());
+    return pVersion;
+}
+
 static void force_c_locale()
 {
     // force locale (and resource files loaded) to en-US
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 85b37d3e6f25..4553c2d1e818 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -58,6 +58,9 @@ struct _LibreOfficeKitClass
                               void* pData);
 
     bool (*runMacro) (LibreOfficeKit *pThis, const char* pURL);
+
+    /// @see lok::Office::getVersionInfo().
+    char* (*getVersionInfo) (LibreOfficeKit* pThis);
 #endif
 
 };
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index f70bfea3beac..67b1dd0b378b 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -312,6 +312,19 @@ public:
     {
         return mpThis->pClass->runMacro( mpThis, pURL );
     }
+
+    /**
+     * Get version information of the LOKit process
+     *
+     * @returns string containing version information in format:
+     * PRODUCT_NAME PRODUCT_VERSION PRODUCT_EXTENSION BUILD_ID
+     *
+     * Eg: LibreOffice 5.3 .0.0 alpha0 <commit hash>
+     */
+    inline char* getVersionInfo()
+    {
+        return mpThis->pClass->getVersionInfo(mpThis);
+    }
 #endif // defined LOK_USE_UNSTABLE_API
 };
 
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 79cc649fa369..bb83cae71420 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1310,6 +1310,14 @@ SAL_DLLPUBLIC_EXPORT void lok_docview_post_command(LOKDocView* pDocView, const c
     pDocView->m_pImpl->m_pDocument->pClass->postUnoCommand(pDocView->m_pImpl->m_pDocument, pCommand, pArguments);
 }
 
+SAL_DLLPUBLIC_EXPORT gchar*
+lok_doc_view_get_version_info (LOKDocView* pDocView)
+{
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
+
+    return priv->m_pOffice->pClass->getVersionInfo(priv->m_pOffice);
+}
+
 SAL_DLLPUBLIC_EXPORT void lok_docview_post_key(GtkWidget* /*pWidget*/, GdkEventKey* pEvent, gpointer pData)
 {
     LOKDocView* pDocView = static_cast<LOKDocView *>(pData);
commit d564aa3e55e7e08a5cc19194983eabc1c4ca9c4f
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Jan 21 09:10:29 2016 +0100

    Clean up lok::Office::freeError()
    
    - let it take a non-const pointer, just like free() or g_free() does
    - remove lok::Document::freeError(), which was declared, but not
      implemented
    - move the declaration at the end of the stable API, but before the
      unstable section
    
    Change-Id: I5a8ced61fc87641dc2fa0ea3615a350361fae3a1

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index ff156399926f..fc957bf2effb 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -300,7 +300,7 @@ static int                     lo_initialize    (LibreOfficeKit* pThis, const ch
 static LibreOfficeKitDocument* lo_documentLoad  (LibreOfficeKit* pThis, const char* pURL);
 static bool                    lo_runMacro      (LibreOfficeKit* pThis, const char* pURL);
 static char *                  lo_getError      (LibreOfficeKit* pThis);
-static void                    lo_freeError     (const char *pfree);
+static void                    lo_freeError     (char* pFree);
 static LibreOfficeKitDocument* lo_documentLoadWithOptions  (LibreOfficeKit* pThis,
                                                            const char* pURL,
                                                            const char* pOptions);
@@ -974,7 +974,7 @@ static char* lo_getError (LibreOfficeKit *pThis)
     return pMemory;
 }
 
-static void lo_freeError(const char *pfree)
+static void lo_freeError(char *pfree)
 {
     free((void *) pfree);
 }
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index ad453ef37ab3..85b37d3e6f25 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -50,14 +50,15 @@ struct _LibreOfficeKitClass
     LibreOfficeKitDocument* (*documentLoadWithOptions) (LibreOfficeKit* pThis,
                                                         const char* pURL,
                                                         const char* pOptions);
-#ifdef LOK_USE_UNSTABLE_API
+    void (*freeError) (char* pFree);
+
+#if defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
     void (*registerCallback) (LibreOfficeKit* pThis,
                               LibreOfficeKitCallback pCallback,
                               void* pData);
 
     bool (*runMacro) (LibreOfficeKit *pThis, const char* pURL);
 #endif
-    void  (*freeError)     (const char *pfree);
 
 };
 
@@ -78,7 +79,6 @@ struct _LibreOfficeKitDocumentClass
                    const char* pUrl,
                    const char* pFormat,
                    const char* pFilterOptions);
-    void  (*freeError)     (const char *pfree);
 
 #ifdef LOK_USE_UNSTABLE_API
     /// @see lok::Document::getDocumentType().
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 060158d08800..f70bfea3beac 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -247,10 +247,6 @@ public:
         mpDoc->pClass->resetSelection(mpDoc);
     }
 #endif // LOK_USE_UNSTABLE_API
-    inline void freeError(const char *pfree)
-    {
-        mpDoc->pClass->freeError(pfree);
-    }
 };
 
 /// The lok::Office class represents one started LibreOfficeKit instance.
@@ -296,12 +292,14 @@ public:
     {
         return mpThis->pClass->getError(mpThis);
     }
-    inline void freeError(const char *pfree)
+
+    /// Frees the memory pointed to by pFree.
+    inline void freeError(char* pFree)
     {
-        mpThis->pClass->freeError(pfree);
+        mpThis->pClass->freeError(pFree);
     }
 
-#ifdef LOK_USE_UNSTABLE_API
+#if defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
     /**
      * Run a macro.
      *


More information about the Libreoffice-commits mailing list