[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - 3 commits - configmgr/source desktop/qa desktop/source include/LibreOfficeKit

Ashod Nakashian (via logerrit) logerrit at kemper.freedesktop.org
Fri Aug 2 20:11:17 UTC 2019


 configmgr/source/access.cxx                 |    9 +++++++++
 desktop/qa/desktop_lib/test_desktop_lib.cxx |    3 ++-
 desktop/source/lib/init.cxx                 |   24 ++++++++++++++++++++++--
 include/LibreOfficeKit/LibreOfficeKit.h     |    3 +++
 include/LibreOfficeKit/LibreOfficeKit.hxx   |   10 +++++++---
 5 files changed, 43 insertions(+), 6 deletions(-)

New commits:
commit 106c4786be04e60a25740d5b2af05c367563c669
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Mon Jan 28 10:03:32 2019 -0500
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Fri Aug 2 16:09:14 2019 -0400

    configmgr: support changing locale language
    
    Change-Id: Ia8318ce8ca3ae9fdbd526e0d41861e2863fb9a94
    Reviewed-on: https://gerrit.libreoffice.org/68262
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/73485
    Tested-by: Jenkins
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/configmgr/source/access.cxx b/configmgr/source/access.cxx
index 26c8e7e5c516..c7ad2c538ae8 100644
--- a/configmgr/source/access.cxx
+++ b/configmgr/source/access.cxx
@@ -71,6 +71,8 @@
 #include <com/sun/star/uno/XWeak.hpp>
 #include <com/sun/star/util/ElementChange.hpp>
 #include <comphelper/sequence.hxx>
+#include <comphelper/lok.hxx>
+#include <i18nlangtag/languagetag.hxx>
 #include <cppu/unotype.hxx>
 #include <cppuhelper/queryinterface.hxx>
 #include <cppuhelper/supportsservice.hxx>
@@ -1380,6 +1382,13 @@ rtl::Reference< ChildAccess > Access::getChild(OUString const & name) {
             locale.isEmpty(), "configmgr",
             ("access best-matching localized property value via \"*<locale>\""
              " with empty <locale>; falling back to defaults"));
+
+        // Since the locale given to us is the one used at initialization,
+        // here we override it with the actual current-user's language to
+        // support per-view localization in LOK.
+        if (comphelper::LibreOfficeKit::isActive())
+            locale = comphelper::LibreOfficeKit::getLanguageTag().getLanguage();
+
         if (!locale.isEmpty()) {
             // Find best match using an adaption of RFC 4647 lookup matching
             // rules, removing "-" or "_" delimited segments from the end:
commit d52461dbb1f918fe86bcf3f04630d44163e6f108
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Thu Jan 24 06:51:46 2019 -0500
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Fri Aug 2 16:08:45 2019 -0400

    LOK: support creating view with options
    
    This adds a new API createViewWithOptions
    that make createView similar to documentLoad,
    which also has documentViewWithOptions version.
    This is primarily to support setting per-view
    language and similar settings.
    
    Change-Id: I0ae5a5b2410cf9e053aee8f7c8a6204af9038a31
    Reviewed-on: https://gerrit.libreoffice.org/68261
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/71111
    Tested-by: Jenkins
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 2b1c6ae96af6..16e9a516fa9d 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -2455,9 +2455,10 @@ void DesktopLOKTest::testABI()
     CPPUNIT_ASSERT_EQUAL(documentClassOffset(45), offsetof(struct _LibreOfficeKitDocumentClass, getSignatureState));
     CPPUNIT_ASSERT_EQUAL(documentClassOffset(46), offsetof(struct _LibreOfficeKitDocumentClass, renderShapeSelection));
     CPPUNIT_ASSERT_EQUAL(documentClassOffset(47), offsetof(struct _LibreOfficeKitDocumentClass, postWindowGestureEvent));
+    CPPUNIT_ASSERT_EQUAL(documentClassOffset(48), offsetof(struct _LibreOfficeKitDocumentClass, createViewWithOptions));
     // Extending is fine, update this, and add new assert for the offsetof the
     // new method
-    CPPUNIT_ASSERT_EQUAL(documentClassOffset(48), sizeof(struct _LibreOfficeKitDocumentClass));
+    CPPUNIT_ASSERT_EQUAL(documentClassOffset(49), sizeof(struct _LibreOfficeKitDocumentClass));
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 5ad5f1b7e3bc..3f2a3e0cdf32 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -684,6 +684,7 @@ static void doc_setClientZoom(LibreOfficeKitDocument* pThis,
 static void doc_setClientVisibleArea(LibreOfficeKitDocument* pThis, int nX, int nY, int nWidth, int nHeight);
 static void doc_setOutlineState(LibreOfficeKitDocument* pThis, bool bColumn, int nLevel, int nIndex, bool bHidden);
 static int doc_createView(LibreOfficeKitDocument* pThis);
+static int doc_createViewWithOptions(LibreOfficeKitDocument* pThis, const char* pOptions);
 static void doc_destroyView(LibreOfficeKitDocument* pThis, int nId);
 static void doc_setView(LibreOfficeKitDocument* pThis, int nId);
 static int doc_getView(LibreOfficeKitDocument* pThis);
@@ -792,6 +793,8 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
         m_pDocumentClass->renderShapeSelection = doc_renderShapeSelection;
         m_pDocumentClass->postWindowGestureEvent = doc_postWindowGestureEvent;
 
+        m_pDocumentClass->createViewWithOptions = doc_createViewWithOptions;
+
         gDocumentClass = m_pDocumentClass;
     }
     pClass = m_pDocumentClass.get();
@@ -1487,7 +1490,7 @@ static LibreOfficeKitDocument* lo_documentLoadWithOptions(LibreOfficeKit* pThis,
         // 'Language=...' is an option that LOK consumes by itself, and does
         // not pass it as a parameter to the filter
         OUString aOptions = getUString(pOptions);
-        OUString aLanguage = extractParameter(aOptions, "Language");
+        const OUString aLanguage = extractParameter(aOptions, "Language");
 
         if (!aLanguage.isEmpty())
         {
@@ -3512,14 +3515,29 @@ static void doc_setOutlineState(LibreOfficeKitDocument* pThis, bool bColumn, int
     pDoc->setOutlineState(bColumn, nLevel, nIndex, bHidden);
 }
 
-static int doc_createView(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pThis*/)
+static int doc_createViewWithOptions(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pThis*/,
+                                     const char* pOptions)
 {
     SolarMutexGuard aGuard;
     SetLastExceptionMsg();
 
+    OUString aOptions = getUString(pOptions);
+    const OUString aLanguage = extractParameter(aOptions, "Language");
+
+    if (!aLanguage.isEmpty())
+    {
+        // Set the LOK language tag, used for dialog tunneling.
+        comphelper::LibreOfficeKit::setLanguageTag(LanguageTag(aLanguage));
+    }
+
     return SfxLokHelper::createView();
 }
 
+static int doc_createView(LibreOfficeKitDocument* pThis)
+{
+    return doc_createViewWithOptions(pThis, nullptr); // No options.
+}
+
 static void doc_destroyView(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pThis*/, int nId)
 {
     SolarMutexGuard aGuard;
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index dcaf4583b27e..5ac307536f5f 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -359,6 +359,9 @@ struct _LibreOfficeKitDocumentClass
                                   int nY,
                                   int nOffset);
 
+    /// @see lok::Document::createViewWithOptions().
+    int (*createViewWithOptions) (LibreOfficeKitDocument* pThis, const char* pOptions);
+
 #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
 };
 
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 2266fc80e7c5..3030f3db24b3 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -440,13 +440,17 @@ public:
     }
 
     /**
-     * Create a new view for an existing document.
+     * Create a new view for an existing document with
+     * options similar to documentLoadWithOptions.
      * By default a loaded document has 1 view.
      * @return the ID of the new view.
      */
-    int createView()
+    int createView(const char* pOptions = nullptr)
     {
-        return mpDoc->pClass->createView(mpDoc);
+        if (LIBREOFFICEKIT_DOCUMENT_HAS(mpDoc, createViewWithOptions))
+            return mpDoc->pClass->createViewWithOptions(mpDoc, pOptions);
+        else
+            return mpDoc->pClass->createView(mpDoc);
     }
 
     /**
commit 502c37e696cfc9673daddb1b82d0955b9c75df34
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Wed Jan 23 21:29:42 2019 -0500
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Fri Aug 2 16:08:18 2019 -0400

    LOK: set the language for LOK before document loading
    
    So default dialogs will be created in the correct
    language, as requested by the client.
    
    Change-Id: I12ebf7443b7f19e733f66b88b5fadfb01cd5e75e
    Reviewed-on: https://gerrit.libreoffice.org/68260
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/73484
    Tested-by: Jenkins
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index afceb472a8e6..5ad5f1b7e3bc 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1496,6 +1496,8 @@ static LibreOfficeKitDocument* lo_documentLoadWithOptions(LibreOfficeKit* pThis,
             SvtSysLocaleOptions aSysLocaleOptions;
             aSysLocaleOptions.SetLocaleConfigString(aLanguage);
             aSysLocaleOptions.SetUILocaleConfigString(aLanguage);
+            // Set the LOK language tag, used for dialog tunneling.
+            comphelper::LibreOfficeKit::setLanguageTag(aSysLocaleOptions.GetLanguageTag());
         }
 
         uno::Sequence<css::beans::PropertyValue> aFilterOptions(2);


More information about the Libreoffice-commits mailing list