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

Pranav Kant pranavk at collabora.com
Thu Sep 14 15:19:40 UTC 2017


 desktop/source/lib/init.cxx               |   12 ++++++++++++
 include/LibreOfficeKit/LibreOfficeKit.h   |    3 +++
 include/LibreOfficeKit/LibreOfficeKit.hxx |   13 +++++++++++++
 libreofficekit/source/gtk/lokdocview.cxx  |    8 ++++++++
 4 files changed, 36 insertions(+)

New commits:
commit fa473730068767b131a22add3ea3d7f5f2cf9c8e
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 7a49c0b962d2..22c256f7105e 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(const 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);


More information about the Libreoffice-commits mailing list