diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2019-05-24 13:44:38 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2019-05-24 14:33:38 +0200 |
commit | 863533ee2c00db3dde1f078b9f21f7e8e1d1333e (patch) | |
tree | e7d422a9665350d43c3a8e82e3f5b304e9527780 /sd | |
parent | 891db26079e0983f2afb38d32aa57eec9dbefc98 (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.
Change-Id: I721e3f0aefa103a6bfa320a671da2ee1e039fa38
Reviewed-on: https://gerrit.libreoffice.org/72904
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sd')
-rw-r--r-- | sd/qa/unit/tiledrendering/data/language-all-text.odp | bin | 0 -> 13083 bytes | |||
-rw-r--r-- | sd/qa/unit/tiledrendering/tiledrendering.cxx | 31 | ||||
-rw-r--r-- | sd/source/ui/docshell/docshel3.cxx | 14 |
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 Binary files differnew file mode 100644 index 000000000000..a484a6310e51 --- /dev/null +++ b/sd/qa/unit/tiledrendering/data/language-all-text.odp diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 6e38741acd7d..80bd4e155cd3 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -121,6 +121,7 @@ public: void testTdf115873Group(); void testCutSelectionChange(); void testRegenerateDiagram(); + void testLanguageAllText(); CPPUNIT_TEST_SUITE(SdTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -168,6 +169,7 @@ public: CPPUNIT_TEST(testTdf115873Group); CPPUNIT_TEST(testCutSelectionChange); CPPUNIT_TEST(testRegenerateDiagram); + CPPUNIT_TEST(testLanguageAllText); CPPUNIT_TEST_SUITE_END(); @@ -1966,6 +1968,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 5cbb20d429ea..f93681c6c2a3 100644 --- a/sd/source/ui/docshell/docshel3.cxx +++ b/sd/source/ui/docshell/docshel3.cxx @@ -34,6 +34,8 @@ #include <svx/drawitem.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> @@ -84,6 +86,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 |