desktop/source/lib/init.cxx | 20 ++++++++++++++++++++ include/LibreOfficeKit/LibreOfficeKit.h | 3 +++ include/LibreOfficeKit/LibreOfficeKit.hxx | 16 ++++++++++++++++ include/LibreOfficeKit/LibreOfficeKitGtk.h | 16 ++++++++++++++++ libreofficekit/source/gtk/lokdocview.cxx | 9 +++++++++ 5 files changed, 64 insertions(+)
New commits: commit e63b8b2ca04c74c9585ece46d62ce98409381ffa Author: Pranav Kant <pran...@collabora.com> Date: Tue Jun 21 20:23:13 2016 +0530 lok: Change version string to JSON format (cherry-picked from d7b45c97b30f109aff0be6602a8fc8103af71e7f) Change-Id: Ie1264fed9964b09006980df2e151e170b48b4082 diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 346396d..74bcc6f 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1828,7 +1828,15 @@ static void lo_setDocumentPassword(LibreOfficeKit* pThis, static char* lo_getVersionInfo(LibreOfficeKit* /*pThis*/) { - const OString sVersionStr = OUStringToOString(ReplaceStringHookProc("%PRODUCTNAME %PRODUCTVERSION %PRODUCTEXTENSION %BUILDID"), RTL_TEXTENCODING_UTF8); + const OUString sVersionStrTemplate( + "{ " + "\"ProductName\": \"%PRODUCTNAME\", " + "\"ProductVersion\": \"%PRODUCTVERSION\", " + "\"ProductExtension\": \"%PRODUCTEXTENSION\", " + "\"BuildId\": \"%BUILDID\" " + "}" + ); + const OString sVersionStr = OUStringToOString(ReplaceStringHookProc(sVersionStrTemplate), RTL_TEXTENCODING_UTF8); char* pVersion = static_cast<char*>(malloc(sVersionStr.getLength() + 1)); strcpy(pVersion, sVersionStr.getStr()); diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx index f72db87..fed0acc 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.hxx +++ b/include/LibreOfficeKit/LibreOfficeKit.hxx @@ -546,10 +546,13 @@ public: /** * Get version information of the LOKit process * - * @returns string containing version information in format: - * PRODUCT_NAME PRODUCT_VERSION PRODUCT_EXTENSION BUILD_ID + * @returns JSON string containing version information in format: + * {ProductName: <>, ProductVersion: <>, ProductExtension: <>, BuildId: <>} * - * Eg: LibreOffice 5.3 .0.0 alpha0 <commit hash> + * Eg: {"ProductName": "LibreOffice", + * "ProductVersion": "5.3", + * "ProductExtension": ".0.0.alpha0", + * "BuildId": "<full 40 char git hash>"} */ inline char* getVersionInfo() { diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h index f6d0875..8202204 100644 --- a/include/LibreOfficeKit/LibreOfficeKitGtk.h +++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h @@ -307,12 +307,15 @@ void lok_doc_view_set_document_password (LOKDocView* * lok_doc_view_get_version_info: * @pDocView: The #LOKDocView instance * - * Get version information of underlying LOKit process + * Get version information of the LOKit process * - * Returns: string containing version information in format - * PRODUCT_NAME PRODUCT_VERSION PRODUCT_EXTENSION BUILD_ID + * Returns: JSON string containing version information in format: + * {ProductName: <>, ProductVersion: <>, ProductExtension: <>, BuildId: <>} * - * Eg: LibreOffice 5.3 .0.0.alpha0 <commit hash> + * Eg: {"ProductName": "LibreOffice", + * "ProductVersion": "5.3", + * "ProductExtension": ".0.0.alpha0", + * "BuildId": "<full 40 char git hash>"} */ gchar* lok_doc_view_get_version_info (LOKDocView* pDocView); commit dd84a8fc3b3c4052181c3a80c5e3a76a35af9f42 Author: Pranav Kant <pran...@collabora.com> Date: Tue Jun 21 00:15:38 2016 +0530 lok: Expose LO version information (cherry-picked from 90c75f775b6d1ca68389782a3768ee554b528e5d) Change-Id: Ided924e928c04385457c7a2e231fdf57e7e38970 diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 65447f0..346396d 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -76,6 +76,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> @@ -466,6 +467,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() ) @@ -487,6 +489,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; } @@ -1823,6 +1826,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 68ae432..63e475c 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.h +++ b/include/LibreOfficeKit/LibreOfficeKit.h @@ -73,6 +73,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 a417581..f72db87 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.hxx +++ b/include/LibreOfficeKit/LibreOfficeKit.hxx @@ -542,6 +542,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 91e29c8..f6d0875 100644 --- a/include/LibreOfficeKit/LibreOfficeKitGtk.h +++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h @@ -304,6 +304,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 289188c..856b400 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -2940,6 +2940,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) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits