diff options
author | Justin Luth <justin_luth@sil.org> | 2019-02-25 22:19:18 +0300 |
---|---|---|
committer | Justin Luth <justin_luth@sil.org> | 2019-03-19 19:23:10 +0100 |
commit | daa4aef1512eb7a6b615720725a5a682b0030f8e (patch) | |
tree | 11fa61ba93ff290653d019b8e058d391c21a3a53 /sw | |
parent | 31b017e31f4802f6d56acaa7b717fb84e4b6e318 (diff) |
try2 tdf#116404 filter\ww8: use bidi for default style in RTL locale
This reverts commit 06742182e5306d6d06e3253981723a69a3c978ab
and implements the same thing without altering the original document.
Thanks Miklos for pointing out that shortcoming.
Change-Id: I0eca9a730853f97251bc2a1cb1ee4128acf31c1f
Reviewed-on: https://gerrit.libreoffice.org/68358
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/CppunitTest_sw_uiwriter.mk | 1 | ||||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter2.cxx | 39 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8sty.cxx | 6 |
3 files changed, 41 insertions, 5 deletions
diff --git a/sw/CppunitTest_sw_uiwriter.mk b/sw/CppunitTest_sw_uiwriter.mk index 3ca0a664d52e..eaf0b0d15a17 100644 --- a/sw/CppunitTest_sw_uiwriter.mk +++ b/sw/CppunitTest_sw_uiwriter.mk @@ -23,6 +23,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_uiwriter, \ cppu \ cppuhelper \ editeng \ + i18nlangtag \ msword \ sal \ sfx \ diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 70d002897c9b..28217c7a3281 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -13,6 +13,7 @@ #include <com/sun/star/style/LineSpacing.hpp> #include <comphelper/propertysequence.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> +#include <i18nlangtag/languagetag.hxx> #include <svx/svdpage.hxx> #include <svx/svdview.hxx> #include <vcl/scheduler.hxx> @@ -57,6 +58,7 @@ public: void testUnfloatButton(); void testUnfloatButtonReadOnlyMode(); void testUnfloating(); + void testRTLparaStyle_LocaleArabic(); void testTdf122893(); void testTdf122901(); void testTdf122942(); @@ -84,6 +86,7 @@ public: CPPUNIT_TEST(testUnfloatButton); CPPUNIT_TEST(testUnfloatButtonReadOnlyMode); CPPUNIT_TEST(testUnfloating); + CPPUNIT_TEST(testRTLparaStyle_LocaleArabic); CPPUNIT_TEST(testTdf122893); CPPUNIT_TEST(testTdf122901); CPPUNIT_TEST(testTdf122942); @@ -96,6 +99,24 @@ public: CPPUNIT_TEST(testMixedFormFieldInsertion); CPPUNIT_TEST_SUITE_END(); + virtual std::unique_ptr<Resetter> preTest(const char* filename) override + { + m_aSavedSettings = Application::GetSettings(); + if (OString(filename).indexOf("LocaleArabic") != -1) + { + std::unique_ptr<Resetter> pResetter( + new Resetter([this]() { Application::SetSettings(this->m_aSavedSettings); })); + AllSettings aSettings(m_aSavedSettings); + aSettings.SetLanguageTag(LanguageTag("ar")); + Application::SetSettings(aSettings); + return pResetter; + } + return nullptr; + } + +protected: + AllSettings m_aSavedSettings; + private: SwDoc* createDoc(const char* pName = nullptr); }; @@ -727,6 +748,24 @@ void SwUiWriterTest2::testUnfloating() } } +void SwUiWriterTest2::testRTLparaStyle_LocaleArabic() +{ + // New documents, created in RTL locales, were not round-tripping the paragraph style as RTL. + // Set the locale to "ar" for this test - see preTest() at the top of this file. + std::unique_ptr<Resetter> const pChanges(preTest("LocaleArabic")); + + createDoc(); // new, empty doc - everything defaults to RTL with Arabic locale + + // Save it and load it back. + reload("Office Open XML Text", "tdf116404_paraStyleFrameDir.docx"); + + uno::Reference<beans::XPropertySet> xPageStyle( + getStyles("ParagraphStyles")->getByName("Default Style"), uno::UNO_QUERY_THROW); + // Test the text Direction value for the -none- based paragraph styles + CPPUNIT_ASSERT_EQUAL_MESSAGE("RTL Writing Mode", sal_Int32(1), + getProperty<sal_Int32>(xPageStyle, "WritingMode")); +} + void SwUiWriterTest2::testTdf122893() { load(DATA_DIRECTORY, "tdf105413.fodt"); diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx index 7a3afc42ebd5..eb0cd1dc664d 100644 --- a/sw/source/filter/ww8/wrtw8sty.cxx +++ b/sw/source/filter/ww8/wrtw8sty.cxx @@ -43,7 +43,6 @@ #include <ndtxt.hxx> #include <ftninfo.hxx> #include <fmthdft.hxx> -#include <frmatr.hxx> #include <section.hxx> #include <fmtcntnt.hxx> #include <fmtftn.hxx> @@ -469,6 +468,7 @@ void MSWordStyles::SetStyleDefaults( const SwFormat& rFormat, bool bPap ) { aFlags[ static_cast< sal_uInt16 >(RES_PARATR_WIDOWS) - RES_CHRATR_BEGIN ] = true; aFlags[ static_cast< sal_uInt16 >(RES_PARATR_HYPHENZONE) - RES_CHRATR_BEGIN ] = true; + aFlags[ static_cast< sal_uInt16 >(RES_FRAMEDIR) - RES_CHRATR_BEGIN ] = true; } else { @@ -598,10 +598,6 @@ void MSWordStyles::OutputStyle( SwFormat* pFormat, sal_uInt16 nPos ) { assert( pFormat->GetPoolFormatId() == RES_POOLCOLL_STANDARD ); aName = "Normal"; - - // force bidi property to be SET, so that it exports an appropriate locale value - if ( SfxItemState::SET != pFormat->GetItemState(RES_FRAMEDIR, false) ) - pFormat->SetFormatAttr(pFormat->GetFrameDir()); } else if (aName.equalsIgnoreAsciiCase("Normal")) { |