Kaydet (Commit) 863533ee authored tarafından Miklos Vajna's avatar Miklos Vajna

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/72904Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
üst 891db260
......@@ -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.
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment