summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-05-24 13:44:38 +0200
committerMiklos Vajna <vmiklos@collabora.com>2019-05-24 15:08:54 +0200
commit8a37f1ef63640de5d2dcb0e038d54117dfdb1067 (patch)
tree989ae5297bbe450a77933a373c373295d319f54d /sd
parentf6d2125bf3511701d261b83bbfc50785b707d026 (diff)
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@gmail.com> Tested-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r--sd/qa/unit/tiledrendering/data/language-all-text.odpbin0 -> 13083 bytes
-rw-r--r--sd/qa/unit/tiledrendering/tiledrendering.cxx31
-rw-r--r--sd/source/ui/docshell/docshel3.cxx14
3 files changed, 45 insertions, 0 deletions
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
--- /dev/null
+++ b/sd/qa/unit/tiledrendering/data/language-all-text.odp
Binary files 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