[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - sd/qa sd/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Fri May 24 13:10:38 UTC 2019


 sd/qa/unit/tiledrendering/data/language-all-text.odp |binary
 sd/qa/unit/tiledrendering/tiledrendering.cxx         |   31 +++++++++++++++++++
 sd/source/ui/docshell/docshel3.cxx                   |   14 ++++++++
 3 files changed, 45 insertions(+)

New commits:
commit 8a37f1ef63640de5d2dcb0e038d54117dfdb1067
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Fri May 24 13:44:38 2019 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Fri May 24 15:08:54 2019 +0200

    sd: make Tools -> Language -> For All Text affect shape text
    
    The problem was that in case the shape text has an explicit language
    set, then the shape language will have no effect on shape text language;
    need to clear those attributes explicitly.
    
    The const_cast<> for the EditTextObject should be OK, since we change
    the shape's item set anyway, so we don't omit any needed notifications.
    
    Conflicts:
            sd/qa/unit/tiledrendering/tiledrendering.cxx
    
    Change-Id: I721e3f0aefa103a6bfa320a671da2ee1e039fa38
    Reviewed-on: https://gerrit.libreoffice.org/72907
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/sd/qa/unit/tiledrendering/data/language-all-text.odp b/sd/qa/unit/tiledrendering/data/language-all-text.odp
new file mode 100644
index 000000000000..a484a6310e51
Binary files /dev/null and b/sd/qa/unit/tiledrendering/data/language-all-text.odp differ
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 1feb91f37efa..6044c1e8c554 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -115,6 +115,7 @@ public:
     void testTdf115873();
     void testTdf115873Group();
     void testCutSelectionChange();
+    void testLanguageAllText();
 
     CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
     CPPUNIT_TEST(testRegisterCallback);
@@ -161,6 +162,7 @@ public:
     CPPUNIT_TEST(testTdf115873);
     CPPUNIT_TEST(testTdf115873Group);
     CPPUNIT_TEST(testCutSelectionChange);
+    CPPUNIT_TEST(testLanguageAllText);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -1949,6 +1951,35 @@ void SdTiledRenderingTest::testLanguageStatus()
     comphelper::LibreOfficeKit::setActive(false);
 }
 
+void SdTiledRenderingTest::testLanguageAllText()
+{
+    // Load the document, which has a single shape, with Hungarian text.
+    comphelper::LibreOfficeKit::setActive();
+    createDoc("language-all-text.odp");
+
+    // Set tha language to English for all text.
+    uno::Sequence<beans::PropertyValue> aArgs = comphelper::InitPropertySequence({
+        { "Language", uno::makeAny(OUString("Default_English (USA)")) },
+    });
+    comphelper::dispatchCommand(".uno:LanguageStatus", aArgs);
+    Scheduler::ProcessEventsToIdle();
+
+    // Assert that the shape text language was changed.
+    uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<drawing::XDrawPage> xPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0),
+                                             uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> xShape(xPage->getByIndex(0), uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> xRun(
+        getRunFromParagraph(0, getParagraphFromShape(0, xShape)), uno::UNO_QUERY);
+    lang::Locale aLocale;
+    xRun->getPropertyValue("CharLocale") >>= aLocale;
+    // Without the accompanying fix in place, this test would have failed with 'Expected: en;
+    // Actual: hu', as the shape text language was not set.
+    CPPUNIT_ASSERT_EQUAL(OUString("en"), aLocale.Language);
+
+    comphelper::LibreOfficeKit::setActive(false);
+}
+
 void SdTiledRenderingTest::testDefaultView()
 {
     // Load the document with notes view.
diff --git a/sd/source/ui/docshell/docshel3.cxx b/sd/source/ui/docshell/docshel3.cxx
index b7e1c5b33feb..9c5b2b144054 100644
--- a/sd/source/ui/docshell/docshel3.cxx
+++ b/sd/source/ui/docshell/docshel3.cxx
@@ -41,6 +41,8 @@
 #include <editeng/unolingu.hxx>
 #include <editeng/langitem.hxx>
 #include <editeng/eeitem.hxx>
+#include <editeng/outlobj.hxx>
+#include <editeng/editobj.hxx>
 #include <com/sun/star/i18n/TextConversionOption.hpp>
 #include <sfx2/notebookbar/SfxNotebookBar.hxx>
 
@@ -97,6 +99,18 @@ static void lcl_setLanguageForObj( SdrObject *pObj, LanguageType nLang, bool bLa
                     return;
             }
             pObj->SetMergedItem( SvxLanguageItem( nLang, nLangWhichId ) );
+
+            // Reset shape text language to default, so it inherits the shape language set above.
+            OutlinerParaObject* pOutliner = pObj->GetOutlinerParaObject();
+            if (pOutliner)
+            {
+                EditTextObject& rEditTextObject
+                    = const_cast<EditTextObject&>(pOutliner->GetTextObject());
+                for (sal_uInt16 n : aLangWhichId_EE)
+                {
+                    rEditTextObject.RemoveCharAttribs(n);
+                }
+            }
         }
     }
     else    // Reset to default


More information about the Libreoffice-commits mailing list