lok: Expose LO version information

Change-Id: Ided924e928c04385457c7a2e231fdf57e7e38970
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index a150535..2d30a32 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -73,6 +73,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>
@@ -656,6 +657,7 @@ static void lo_setOptionalFeatures(LibreOfficeKit* pThis, uint64_t features);
static void                    lo_setDocumentPassword(LibreOfficeKit* pThis,
                                                       const char* pURL,
                                                       const char* pPassword);
static char*                   lo_getVersionInfo(LibreOfficeKit* pThis);

LibLibreOffice_Impl::LibLibreOffice_Impl()
    : m_pOfficeClass( gOfficeClass.lock() )
@@ -677,6 +679,7 @@ LibLibreOffice_Impl::LibLibreOffice_Impl()
        m_pOfficeClass->getFilterTypes = lo_getFilterTypes;
        m_pOfficeClass->setOptionalFeatures = lo_setOptionalFeatures;
        m_pOfficeClass->setDocumentPassword = lo_setDocumentPassword;
        m_pOfficeClass->getVersionInfo = lo_getVersionInfo;

        gOfficeClass = m_pOfficeClass;
    }
@@ -2002,6 +2005,15 @@ static void lo_setDocumentPassword(LibreOfficeKit* pThis,
    pLib->mInteractionMap.find(OString(pURL))->second->SetPassword(pPassword);
}

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 a337bc3..559d28a 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -75,6 +75,9 @@ struct _LibreOfficeKitClass
    void (*setDocumentPassword) (LibreOfficeKit* pThis,
            char const* pURL,
            char const* pPassword);

    /// @see lok::Office::getVersionInfo().
    char* (*getVersionInfo) (LibreOfficeKit* pThis);
#endif

};
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index c496e2e..46a5e96 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -546,6 +546,19 @@ public:
    {
        mpThis->pClass->setDocumentPassword(mpThis, pURL, pPassword);
    }

    /**
     * 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 || defined LIBO_INTERNAL_ONLY
};

diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h
index a0082be..4b4284e 100644
--- a/include/LibreOfficeKit/LibreOfficeKitGtk.h
+++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h
@@ -316,6 +316,19 @@ void                            lok_doc_view_set_document_password (LOKDocView* 
                                                                    const gchar* pPassword);

/**
 * lok_doc_view_get_version_info:
 * @pDocView: The #LOKDocView instance
 *
 * Get version information of underlying 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>
 */
gchar*                         lok_doc_view_get_version_info       (LOKDocView* pDocView);

/**
 * lok_doc_view_pixel_to_twip:
 * @pDocView: The #LOKDocView instance
 * @fInput: The value in pixels to convert to twips
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 90f01d9..60d4cce 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -3162,6 +3162,15 @@ lok_doc_view_set_document_password (LOKDocView* pDocView,
    priv->m_pOffice->pClass->setDocumentPassword(priv->m_pOffice, pURL, pPassword);
}

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 gfloat
lok_doc_view_pixel_to_twip (LOKDocView* pDocView, float fInput)
{