oox/source/shape/WpsContext.cxx | 2 sw/qa/extras/layout/layout2.cxx | 26 +++--- sw/qa/extras/ooxmlexport/ooxmlexport10.cxx | 14 +-- sw/qa/extras/ooxmlexport/ooxmlexport11.cxx | 30 +++---- sw/qa/extras/ooxmlexport/ooxmlexport13.cxx | 4 sw/qa/extras/ooxmlexport/ooxmlexport2.cxx | 8 - sw/qa/extras/ooxmlexport/ooxmlexport3.cxx | 5 - sw/qa/extras/ooxmlexport/ooxmlexport8.cxx | 8 - sw/qa/extras/ooxmlexport/ooxmlexport9.cxx | 4 sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 10 +- sw/qa/extras/uiwriter/uiwriter5.cxx | 24 ++--- sw/qa/extras/ww8export/ww8export2.cxx | 49 +++++++----- sw/source/core/text/porrst.cxx | 7 - sw/source/filter/ww8/docxattributeoutput.cxx | 8 + sw/source/filter/ww8/ww8atr.cxx | 8 + sw/source/filter/ww8/ww8par6.cxx | 19 ++-- sw/source/writerfilter/dmapper/DomainMapper.cxx | 42 ++++++++-- sw/source/writerfilter/dmapper/DomainMapper.hxx | 4 sw/source/writerfilter/dmapper/DomainMapperTableHandler.cxx | 3 sw/source/writerfilter/dmapper/StyleSheetTable.cxx | 2 vcl/qa/cppunit/pdfexport/pdfexport.cxx | 2 21 files changed, 172 insertions(+), 107 deletions(-)
New commits: commit f883204cdb122de784b02e047ab3f57a95611bc4 Author: Jonathan Clark <[email protected]> AuthorDate: Fri Jan 9 15:47:36 2026 -0700 Commit: Jonathan Clark <[email protected]> CommitDate: Sat Jan 17 00:48:26 2026 +0100 sw: Add para align start/end support to DOC/DOCX filters In many cases, what DOC/DOCX represents as left/right paragraph alignment is actually a start/end alignment, relative to the text direction. Previously, we emulated support for this by automatically flipping the alignments of RTL paragraphs during parsing, with somewhat mixed success. This change updates the DOC/DOCX filters to instead take advantage of LO's native start/end paragraph alignment support, when possible. Change-Id: If837e10deb5273c15c6d5e521b48a419723cf13b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197306 Tested-by: Jenkins Reviewed-by: Jonathan Clark <[email protected]> diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx index f8d249c07af2..3059a63ed749 100644 --- a/oox/source/shape/WpsContext.cxx +++ b/oox/source/shape/WpsContext.cxx @@ -471,9 +471,11 @@ void lcl_setTextAnchorFromTextProps(const uno::Reference<beans::XPropertySet>& x aTextPropMap.getValue(u"ParaAdjust"_ustr) >>= nParaAlign; switch (nParaAlign) { + case sal_Int16(style::ParagraphAdjust_START): case sal_Int16(style::ParagraphAdjust_LEFT): eHorzAdjust = drawing::TextHorizontalAdjust_LEFT; break; + case sal_Int16(style::ParagraphAdjust_END): case sal_Int16(style::ParagraphAdjust_RIGHT): eHorzAdjust = drawing::TextHorizontalAdjust_RIGHT; break; diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx index 1c7eecdffb36..e4cdec863d79 100644 --- a/sw/qa/extras/layout/layout2.cxx +++ b/sw/qa/extras/layout/layout2.cxx @@ -1011,7 +1011,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testHiddenParaProps) pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); CPPUNIT_ASSERT_EQUAL(u"def"_ustr, pTextFrame->GetText()); CPPUNIT_ASSERT_EQUAL( - SvxAdjust::Left, + SvxAdjust::ParaStart, pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); CPPUNIT_ASSERT_EQUAL(u"6 hidden-merge, visible"_ustr, pTextFrame->GetText()); @@ -1023,7 +1023,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testHiddenParaProps) pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); CPPUNIT_ASSERT_EQUAL(u"def"_ustr, pTextFrame->GetText()); CPPUNIT_ASSERT_EQUAL( - SvxAdjust::Left, + SvxAdjust::ParaStart, pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); CPPUNIT_ASSERT_EQUAL(u"7 visible, hidden-merge"_ustr, pTextFrame->GetText()); @@ -1035,7 +1035,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testHiddenParaProps) pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); CPPUNIT_ASSERT_EQUAL(u"ghi"_ustr, pTextFrame->GetText()); CPPUNIT_ASSERT_EQUAL( - SvxAdjust::Left, + SvxAdjust::ParaStart, pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); CPPUNIT_ASSERT_EQUAL(u"8 visible, delete-merge, visible, hidden-merge, visible"_ustr, @@ -1043,7 +1043,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testHiddenParaProps) pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); CPPUNIT_ASSERT_EQUAL(u"abc"_ustr, pTextFrame->GetText()); CPPUNIT_ASSERT_EQUAL( - SvxAdjust::Right, + SvxAdjust::ParaEnd, pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); CPPUNIT_ASSERT_EQUAL(u"def"_ustr, pTextFrame->GetText()); @@ -1053,7 +1053,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testHiddenParaProps) pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); CPPUNIT_ASSERT_EQUAL(u"ghi"_ustr, pTextFrame->GetText()); CPPUNIT_ASSERT_EQUAL( - SvxAdjust::Left, + SvxAdjust::ParaStart, pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); CPPUNIT_ASSERT_EQUAL(u"9 hidden-merge"_ustr, pTextFrame->GetText()); @@ -1065,7 +1065,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testHiddenParaProps) pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); CPPUNIT_ASSERT_EQUAL(u"def"_ustr, pTextFrame->GetText()); CPPUNIT_ASSERT_EQUAL( - SvxAdjust::Left, + SvxAdjust::ParaStart, pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); CPPUNIT_ASSERT_EQUAL(u"10 visible, hidden-merge, visible, delete-merge, visible"_ustr, @@ -1073,7 +1073,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testHiddenParaProps) pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); CPPUNIT_ASSERT_EQUAL(u"abc"_ustr, pTextFrame->GetText()); CPPUNIT_ASSERT_EQUAL( - SvxAdjust::Right, + SvxAdjust::ParaEnd, pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); CPPUNIT_ASSERT_EQUAL(u"def"_ustr, pTextFrame->GetText()); @@ -1083,7 +1083,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testHiddenParaProps) pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); CPPUNIT_ASSERT_EQUAL(u"ghi"_ustr, pTextFrame->GetText()); CPPUNIT_ASSERT_EQUAL( - SvxAdjust::Left, + SvxAdjust::ParaStart, pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); aViewOptions.SetShowHiddenChar(false); @@ -1129,7 +1129,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testHiddenParaProps) pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); CPPUNIT_ASSERT_EQUAL(u"abcdef"_ustr, pTextFrame->GetText()); CPPUNIT_ASSERT_EQUAL( - SvxAdjust::Left, + SvxAdjust::ParaStart, pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); CPPUNIT_ASSERT_EQUAL(u"7 visible, hidden-merge"_ustr, pTextFrame->GetText()); @@ -1144,7 +1144,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testHiddenParaProps) pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); CPPUNIT_ASSERT_EQUAL(u"abc"_ustr, pTextFrame->GetText()); CPPUNIT_ASSERT_EQUAL( - SvxAdjust::Right, + SvxAdjust::ParaEnd, pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); CPPUNIT_ASSERT_EQUAL(u"defghi"_ustr, pTextFrame->GetText()); @@ -1156,7 +1156,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testHiddenParaProps) pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); CPPUNIT_ASSERT_EQUAL(u"abcdef"_ustr, pTextFrame->GetText()); CPPUNIT_ASSERT_EQUAL( - SvxAdjust::Left, + SvxAdjust::ParaStart, pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); CPPUNIT_ASSERT_EQUAL(u"10 visible, hidden-merge, visible, delete-merge, visible"_ustr, @@ -1164,12 +1164,12 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testHiddenParaProps) pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); CPPUNIT_ASSERT_EQUAL(u"abcdef"_ustr, pTextFrame->GetText()); CPPUNIT_ASSERT_EQUAL( - SvxAdjust::Right, + SvxAdjust::ParaEnd, pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); CPPUNIT_ASSERT_EQUAL(u"ghi"_ustr, pTextFrame->GetText()); CPPUNIT_ASSERT_EQUAL( - SvxAdjust::Left, + SvxAdjust::ParaStart, pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx index 6238bfd89e69..42b9e5f35189 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx @@ -352,10 +352,10 @@ DECLARE_OOXMLEXPORT_TEST(testFdo72560, "fdo72560.docx") // this will test the text direction and alignment for paragraphs CPPUNIT_ASSERT_EQUAL(text::WritingMode2::RL_TB, getProperty<sal_Int16>( xParaLeftRTL, u"WritingMode"_ustr )); - CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_LEFT), getProperty< sal_Int32 >( xParaLeftRTL, u"ParaAdjust"_ustr )); + CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_END), getProperty< sal_Int32 >( xParaLeftRTL, u"ParaAdjust"_ustr )); CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, getProperty<sal_Int16>( xParaRightLTR, u"WritingMode"_ustr )); - CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_RIGHT), getProperty< sal_Int32 >( xParaRightLTR, u"ParaAdjust"_ustr )); + CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_END), getProperty< sal_Int32 >( xParaRightLTR, u"ParaAdjust"_ustr )); } DECLARE_OOXMLEXPORT_TEST(testFdo72560b, "fdo72560b.docx") @@ -363,7 +363,7 @@ DECLARE_OOXMLEXPORT_TEST(testFdo72560b, "fdo72560b.docx") // The problem was libreoffice confuse when RTL was specified in non-default style uno::Reference<uno::XInterface> xParaEndRTL(getParagraph( 2, u"RTL END"_ustr)); CPPUNIT_ASSERT_EQUAL(text::WritingMode2::RL_TB, getProperty<sal_Int16>( xParaEndRTL, u"WritingMode"_ustr )); - CPPUNIT_ASSERT_EQUAL( sal_Int32(style::ParagraphAdjust_LEFT), getProperty< sal_Int32 >( xParaEndRTL, u"ParaAdjust"_ustr )); + CPPUNIT_ASSERT_EQUAL( sal_Int32(style::ParagraphAdjust_END), getProperty< sal_Int32 >( xParaEndRTL, u"ParaAdjust"_ustr )); } DECLARE_OOXMLEXPORT_TEST(testFdo72560c, "fdo72560c.docx") @@ -371,14 +371,14 @@ DECLARE_OOXMLEXPORT_TEST(testFdo72560c, "fdo72560c.docx") // The problem was libreoffice confuse when RTL was specified in DocDefaults uno::Reference<uno::XInterface> xParaEndRTL(getParagraph( 2, u"RTL END"_ustr)); CPPUNIT_ASSERT_EQUAL(text::WritingMode2::RL_TB, getProperty<sal_Int16>( xParaEndRTL, u"WritingMode"_ustr )); - CPPUNIT_ASSERT_EQUAL( sal_Int32(style::ParagraphAdjust_LEFT), getProperty< sal_Int32 >( xParaEndRTL, u"ParaAdjust"_ustr )); + CPPUNIT_ASSERT_EQUAL( sal_Int32(style::ParagraphAdjust_END), getProperty< sal_Int32 >( xParaEndRTL, u"ParaAdjust"_ustr )); } DECLARE_OOXMLEXPORT_TEST(testFdo72560d, "fdo72560d.docx") { // The problem was libreoffice confuse when RTL was specified in "Normal" when not using Normal at all - CPPUNIT_ASSERT_EQUAL( sal_Int32(style::ParagraphAdjust_RIGHT), getProperty< sal_Int32 >( getParagraph(1), u"ParaAdjust"_ustr )); - CPPUNIT_ASSERT_EQUAL( sal_Int32(style::ParagraphAdjust_RIGHT), getProperty< sal_Int32 >( getParagraph(2), u"ParaAdjust"_ustr )); + CPPUNIT_ASSERT_EQUAL( sal_Int32(style::ParagraphAdjust_END), getProperty< sal_Int32 >( getParagraph(1), u"ParaAdjust"_ustr )); + CPPUNIT_ASSERT_EQUAL( sal_Int32(style::ParagraphAdjust_END), getProperty< sal_Int32 >( getParagraph(2), u"ParaAdjust"_ustr )); } DECLARE_OOXMLEXPORT_TEST(testFdo72560e, "fdo72560e.docx") @@ -386,7 +386,7 @@ DECLARE_OOXMLEXPORT_TEST(testFdo72560e, "fdo72560e.docx") // The problem was libreoffice confuse when *locale* is RTL, but w:bidi / w:jc are never defined. // This unit test would only be noticed if the testing environment is set to something like an Arabic locale. CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, getProperty<sal_Int16>( getParagraph(2), u"WritingMode"_ustr )); - CPPUNIT_ASSERT_EQUAL(sal_Int32(style::ParagraphAdjust_LEFT), getProperty<sal_Int32>( getParagraph(2), u"ParaAdjust"_ustr )); + CPPUNIT_ASSERT_EQUAL(sal_Int32(style::ParagraphAdjust_START), getProperty<sal_Int32>( getParagraph(2), u"ParaAdjust"_ustr )); // widow/orphan control is on when never specified. CPPUNIT_ASSERT_EQUAL(sal_Int8(2), getProperty<sal_Int8>( getParagraph(2), u"ParaWidows"_ustr )); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx index 7b228ddfbdaf..428aebd888bd 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx @@ -229,19 +229,19 @@ DECLARE_OOXMLEXPORT_TEST(testTdf106174_rtlParaAlign, "tdf106174_rtlParaAlign.doc CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_CENTER), getProperty<sal_Int16>(getParagraph(1), u"ParaAdjust"_ustr)); CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_CENTER), getProperty<sal_Int16>(getParagraph(2), u"ParaAdjust"_ustr)); uno::Reference<beans::XPropertySet> xPropertySet(getStyles(u"ParagraphStyles"_ustr)->getByName(u"Another paragraph aligned to right"_ustr), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_RIGHT), getProperty<sal_Int16>(xPropertySet, u"ParaAdjust"_ustr)); - CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_RIGHT), getProperty<sal_Int16>(getParagraph(3), u"ParaAdjust"_ustr)); - CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_RIGHT), getProperty<sal_Int16>(getParagraph(4), u"ParaAdjust"_ustr)); - CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_RIGHT), getProperty<sal_Int16>(getParagraph(5), u"ParaAdjust"_ustr)); - CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_LEFT), getProperty<sal_Int16>(getParagraph(6), u"ParaAdjust"_ustr)); - CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_RIGHT), getProperty<sal_Int16>(getParagraph(7), u"ParaAdjust"_ustr)); - CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_RIGHT), getProperty<sal_Int16>(getParagraph(8), u"ParaAdjust"_ustr)); - CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_LEFT), getProperty<sal_Int16>(getParagraph(9), u"ParaAdjust"_ustr)); - CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_LEFT), getProperty<sal_Int16>(getParagraph(10), u"ParaAdjust"_ustr)); - CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_RIGHT), getProperty<sal_Int16>(getParagraph(11), u"ParaAdjust"_ustr)); - CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_LEFT), getProperty<sal_Int16>(getParagraph(12), u"ParaAdjust"_ustr)); - CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_LEFT), getProperty<sal_Int16>(getParagraph(13), u"ParaAdjust"_ustr)); - CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_RIGHT), getProperty<sal_Int16>(getParagraph(14), u"ParaAdjust"_ustr)); + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_END), getProperty<sal_Int16>(xPropertySet, u"ParaAdjust"_ustr)); + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_END), getProperty<sal_Int16>(getParagraph(3), u"ParaAdjust"_ustr)); + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_END), getProperty<sal_Int16>(getParagraph(4), u"ParaAdjust"_ustr)); + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_START), getProperty<sal_Int16>(getParagraph(5), u"ParaAdjust"_ustr)); + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_END), getProperty<sal_Int16>(getParagraph(6), u"ParaAdjust"_ustr)); + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_START), getProperty<sal_Int16>(getParagraph(7), u"ParaAdjust"_ustr)); + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_START), getProperty<sal_Int16>(getParagraph(8), u"ParaAdjust"_ustr)); + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_END), getProperty<sal_Int16>(getParagraph(9), u"ParaAdjust"_ustr)); + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_END), getProperty<sal_Int16>(getParagraph(10), u"ParaAdjust"_ustr)); + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_END), getProperty<sal_Int16>(getParagraph(11), u"ParaAdjust"_ustr)); + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_START), getProperty<sal_Int16>(getParagraph(12), u"ParaAdjust"_ustr)); + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_START), getProperty<sal_Int16>(getParagraph(13), u"ParaAdjust"_ustr)); + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_END), getProperty<sal_Int16>(getParagraph(14), u"ParaAdjust"_ustr)); } DECLARE_OOXMLEXPORT_TEST(testTdf82065_Ind_start_strict, "tdf82065_Ind_start_strict.docx") @@ -739,10 +739,10 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf98620_environmentBiDi) saveAndReload(TestFilter::DOCX); CPPUNIT_ASSERT_EQUAL(2, getPages()); CPPUNIT_ASSERT_EQUAL(text::WritingMode2::RL_TB, getProperty<sal_Int16>( getParagraph(1), u"WritingMode"_ustr )); - CPPUNIT_ASSERT_EQUAL(sal_Int32(style::ParagraphAdjust_RIGHT), getProperty<sal_Int32>( getParagraph(1), u"ParaAdjust"_ustr )); + CPPUNIT_ASSERT_EQUAL(sal_Int32(style::ParagraphAdjust_START), getProperty<sal_Int32>( getParagraph(1), u"ParaAdjust"_ustr )); CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, getProperty<sal_Int16>( getParagraph(2), u"WritingMode"_ustr )); - CPPUNIT_ASSERT_EQUAL(sal_Int32(style::ParagraphAdjust_RIGHT), getProperty<sal_Int32>( getParagraph(2), u"ParaAdjust"_ustr )); + CPPUNIT_ASSERT_EQUAL(sal_Int32(style::ParagraphAdjust_END), getProperty<sal_Int32>( getParagraph(2), u"ParaAdjust"_ustr )); } DECLARE_OOXMLEXPORT_TEST(testTdf116976, "tdf116976.docx") diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx index 4ada85283bde..621fd952887f 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx @@ -514,7 +514,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf118947_tableStyle, "tdf118947_tableStyle.docx") CPPUNIT_ASSERT_EQUAL_MESSAGE("Table style sets 0 right margin", sal_Int32(0), getProperty<sal_Int32>(xPara, u"ParaRightMargin"_ustr)); CPPUNIT_ASSERT_EQUAL_MESSAGE("Table sets 2.5 line-spacing", sal_Int16(250), getProperty<style::LineSpacing>(xPara, u"ParaLineSpacing"_ustr).Height); CPPUNIT_ASSERT_EQUAL_MESSAGE("Paragraph background color in cell A2", sal_Int32(-1), getProperty<sal_Int32>(xPara, u"ParaBackColor"_ustr)); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Compat mode overrides left adjust", style::ParagraphAdjust_RIGHT, + CPPUNIT_ASSERT_EQUAL_MESSAGE("Compat mode overrides left adjust", style::ParagraphAdjust_END, static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(xPara, u"ParaAdjust"_ustr))); } @@ -534,7 +534,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf118947_tableStyle2, "tdf118947_tableStyle2.docx" // Even though not specified, Table-Style tries to distribute the properties in DocDefault. DocDefault fontsize is 8pt. // However, this is overridden by the default style's specified fontsize of 12 and left justify. CPPUNIT_ASSERT_EQUAL_MESSAGE("Non-Compat mode has 12pt font size", 12.f, getProperty<float>(getRun(xPara,1), u"CharHeight"_ustr)); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Non-Compat mode keeps the style's left adjust", style::ParagraphAdjust_LEFT, + CPPUNIT_ASSERT_EQUAL_MESSAGE("Non-Compat mode keeps the style's left adjust", style::ParagraphAdjust_START, static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(xPara, u"ParaAdjust"_ustr))); } diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx index 5ab2d0a313c8..f1e6eb9a24e2 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx @@ -814,16 +814,16 @@ DECLARE_OOXMLEXPORT_TEST(testFdo43093, "fdo43093.docx") sal_Int16 nLRDir = getProperty< sal_Int32 >( xParaLtrRight, u"WritingMode"_ustr ); // this will test the both the text direction and alignment for each paragraph - CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_LEFT), nRtlLeft); + CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_END), nRtlLeft); CPPUNIT_ASSERT_EQUAL(text::WritingMode2::RL_TB, nRLDir); - CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_RIGHT), nRtlRight); + CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_START), nRtlRight); CPPUNIT_ASSERT_EQUAL(text::WritingMode2::RL_TB, nRRDir); - CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_LEFT), nLtrLeft); + CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_START), nLtrLeft); CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, nLLDir); - CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_RIGHT), nLtrRight); + CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_END), nLtrRight); CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, nLRDir); } diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx index c104d2040c0f..be972069b847 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx @@ -181,7 +181,8 @@ CPPUNIT_TEST_FIXTURE(Test, testStyleInheritance) assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:rPrDefault/w:rPr/w:rFonts", "ascii", u"Times New Roman"); assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:rPrDefault/w:rPr/w:lang", "bidi", u"ar-SA"); // pPrDefault contains only one hyphenation property - assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:pPrDefault/w:pPr/*", 1); + // tdf#169035: also contains alignment, because Start is not yet the default + assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:pPrDefault/w:pPr/*", 2); // Check latent styles uno::Sequence<beans::PropertyValue> aGrabBag = getProperty< uno::Sequence<beans::PropertyValue> >(mxComponent, u"InteropGrabBag"_ustr); @@ -709,7 +710,7 @@ DECLARE_OOXMLEXPORT_TEST(testFdo71646, "fdo71646.docx") sal_Int16 nLRDir = getProperty< sal_Int32 >( xParaLTRLeft, u"WritingMode"_ustr ); // this will test the both the text direction and alignment for paragraph - CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_LEFT), nLTRLeft); + CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_START), nLTRLeft); CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, nLRDir); } diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx index 43366a25a5de..563e63938222 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx @@ -1236,16 +1236,16 @@ DECLARE_OOXMLEXPORT_TEST(testFdo43093, "fdo43093b.docx") sal_Int16 nLLDir = getProperty< sal_Int32 >( xParaLtrLeft, u"WritingMode"_ustr ); // this will test the both the text direction and alignment for each paragraph - CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_RIGHT), nRtlRight); + CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_START), nRtlRight); CPPUNIT_ASSERT_EQUAL(text::WritingMode2::RL_TB, nRRDir); - CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_LEFT), nRtlLeft); + CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_END), nRtlLeft); CPPUNIT_ASSERT_EQUAL(text::WritingMode2::RL_TB, nRLDir); - CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_RIGHT), nLtrRight); + CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_END), nLtrRight); CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, nLRDir); - CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_LEFT), nLtrLeft); + CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_START), nLtrLeft); CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, nLLDir); } diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx index f98b7c9cf579..b67840e55f71 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx @@ -526,9 +526,9 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf97648_relativeWidth) CPPUNIT_ASSERT_DOUBLES_EQUAL( sal_Int32(7616), getShape(1)->getSize().Width, 10); CPPUNIT_ASSERT_DOUBLES_EQUAL( sal_Int32(8001), getShape(2)->getSize().Width, 10); CPPUNIT_ASSERT_DOUBLES_EQUAL( sal_Int32(4001), getShape(3)->getSize().Width, 10); - CPPUNIT_ASSERT_EQUAL( style::ParagraphAdjust_LEFT, static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(getParagraph(6), u"ParaAdjust"_ustr)) ); + CPPUNIT_ASSERT_EQUAL( style::ParagraphAdjust_START, static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(getParagraph(6), u"ParaAdjust"_ustr)) ); CPPUNIT_ASSERT_DOUBLES_EQUAL( sal_Int32(1600), getShape(4)->getSize().Width, 10); - CPPUNIT_ASSERT_EQUAL( style::ParagraphAdjust_RIGHT, static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(getParagraph(8), u"ParaAdjust"_ustr)) ); + CPPUNIT_ASSERT_EQUAL( style::ParagraphAdjust_END, static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(getParagraph(8), u"ParaAdjust"_ustr)) ); CPPUNIT_ASSERT_EQUAL( sal_Int32(0), getProperty<sal_Int32>(getShape(1), u"LeftMargin"_ustr) ); diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index c65c11c1ae02..05353b3a3a2c 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -1159,17 +1159,17 @@ CPPUNIT_TEST_FIXTURE(Test, testDMLGroupShapeParaAdjust) uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY); uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(1), uno::UNO_QUERY_THROW)->getText(); // 2nd line is adjusted to the right - CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_RIGHT), getProperty<sal_Int16>(getRun(getParagraphOfText(2, xText), 1), u"ParaAdjust"_ustr)); + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_END), getProperty<sal_Int16>(getRun(getParagraphOfText(2, xText), 1), u"ParaAdjust"_ustr)); // 3rd line has no adjustment - CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_LEFT), getProperty<sal_Int16>(getRun(getParagraphOfText(3, xText), 1), u"ParaAdjust"_ustr)); + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_START), getProperty<sal_Int16>(getRun(getParagraphOfText(3, xText), 1), u"ParaAdjust"_ustr)); // 4th line is adjusted to center CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_CENTER), getProperty<sal_Int16>(getRun(getParagraphOfText(4, xText), 1), u"ParaAdjust"_ustr)); // 5th line has no adjustment - CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_LEFT), getProperty<sal_Int16>(getRun(getParagraphOfText(5, xText), 1), u"ParaAdjust"_ustr)); + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_START), getProperty<sal_Int16>(getRun(getParagraphOfText(5, xText), 1), u"ParaAdjust"_ustr)); // 6th line is justified CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_BLOCK), getProperty<sal_Int16>(getRun(getParagraphOfText(6, xText), 1), u"ParaAdjust"_ustr)); // 7th line has no adjustment - CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_LEFT), getProperty<sal_Int16>(getRun(getParagraphOfText(7, xText), 1), u"ParaAdjust"_ustr)); + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_START), getProperty<sal_Int16>(getRun(getParagraphOfText(7, xText), 1), u"ParaAdjust"_ustr)); } CPPUNIT_TEST_FIXTURE(Test, testTdf99135) @@ -1834,7 +1834,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf136952_pgBreak3) //Do not lose the page::breakAfter. This SHOULD be on page 4, but sadly it is not. //The key part of this test is that the page starts with "Lorem ipsum" //Prior to this, there was no page break, and so it was in the middle of a page. - CPPUNIT_ASSERT(getXPath(pDump, "//page[6]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", "portion").startsWith("Lorem ipsum")); + CPPUNIT_ASSERT(getXPath(pDump, "//page[6]/body/txt[1]/SwParaPortion/SwLineLayout[1]", "portion").startsWith("Lorem ipsum")); } diff --git a/sw/qa/extras/uiwriter/uiwriter5.cxx b/sw/qa/extras/uiwriter/uiwriter5.cxx index 8b696d1385e7..5f3433c858ff 100644 --- a/sw/qa/extras/uiwriter/uiwriter5.cxx +++ b/sw/qa/extras/uiwriter/uiwriter5.cxx @@ -1549,14 +1549,14 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf120338) { createSwDoc("tdf120338.docx"); - CPPUNIT_ASSERT_EQUAL(sal_Int32(1), - getProperty<sal_Int32>(getParagraph(2), u"ParaAdjust"_ustr)); // right - CPPUNIT_ASSERT_EQUAL(sal_Int32(1), - getProperty<sal_Int32>(getParagraph(3), u"ParaAdjust"_ustr)); // right - CPPUNIT_ASSERT_EQUAL(sal_Int32(0), - getProperty<sal_Int32>(getParagraph(4), u"ParaAdjust"_ustr)); // left - CPPUNIT_ASSERT_EQUAL(sal_Int32(1), - getProperty<sal_Int32>(getParagraph(5), u"ParaAdjust"_ustr)); // right + CPPUNIT_ASSERT_EQUAL(sal_Int32(6), + getProperty<sal_Int32>(getParagraph(2), u"ParaAdjust"_ustr)); // end + CPPUNIT_ASSERT_EQUAL(sal_Int32(6), + getProperty<sal_Int32>(getParagraph(3), u"ParaAdjust"_ustr)); // end + CPPUNIT_ASSERT_EQUAL(sal_Int32(5), + getProperty<sal_Int32>(getParagraph(4), u"ParaAdjust"_ustr)); // start + CPPUNIT_ASSERT_EQUAL(sal_Int32(6), + getProperty<sal_Int32>(getParagraph(5), u"ParaAdjust"_ustr)); // end CPPUNIT_ASSERT_EQUAL(u""_ustr, getProperty<OUString>(getParagraph(7), u"NumberingStyleName"_ustr)); @@ -1572,14 +1572,14 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf120338) // reject tracked paragraph adjustments dispatchCommand(mxComponent, u".uno:RejectAllTrackedChanges"_ustr, {}); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0), - getProperty<sal_Int32>(getParagraph(2), u"ParaAdjust"_ustr)); // left + CPPUNIT_ASSERT_EQUAL(sal_Int32(5), + getProperty<sal_Int32>(getParagraph(2), u"ParaAdjust"_ustr)); // start CPPUNIT_ASSERT_EQUAL(sal_Int32(3), getProperty<sal_Int32>(getParagraph(3), u"ParaAdjust"_ustr)); // center CPPUNIT_ASSERT_EQUAL(sal_Int32(3), getProperty<sal_Int32>(getParagraph(4), u"ParaAdjust"_ustr)); // center - CPPUNIT_ASSERT_EQUAL(sal_Int32(0), - getProperty<sal_Int32>(getParagraph(5), u"ParaAdjust"_ustr)); // left + CPPUNIT_ASSERT_EQUAL(sal_Int32(5), + getProperty<sal_Int32>(getParagraph(5), u"ParaAdjust"_ustr)); // start // tdf#126245 revert numbering changes CPPUNIT_ASSERT_EQUAL(u"WWNum2"_ustr, diff --git a/sw/qa/extras/ww8export/ww8export2.cxx b/sw/qa/extras/ww8export/ww8export2.cxx index 005e6babc92f..0254d36de7f7 100644 --- a/sw/qa/extras/ww8export/ww8export2.cxx +++ b/sw/qa/extras/ww8export/ww8export2.cxx @@ -409,19 +409,34 @@ DECLARE_WW8EXPORT_TEST(testTdf112074_RTLtableJustification, "tdf112074_RTLtableJ CPPUNIT_ASSERT_EQUAL_MESSAGE("Horizontal Orientation", text::HoriOrientation::LEFT_AND_WIDTH, getProperty<sal_Int16>(xTable, u"HoriOrient"_ustr)); CPPUNIT_ASSERT_MESSAGE("Table Indent", getProperty<tools::Long>(xTable, u"LeftMargin"_ustr) > 3000); CPPUNIT_ASSERT_MESSAGE("Table Indent is 3750", getProperty<tools::Long>(xTable, u"LeftMargin"_ustr) < 4000 ); - CPPUNIT_ASSERT_EQUAL( style::ParagraphAdjust_RIGHT, static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(getParagraphOrTable(2), u"ParaAdjust"_ustr)) ); + + // tdf#169035: The document uses Jc80 adjustment, which is interpreted as literal left/right. + // However, on re-export, this value is converted to Jc adjustment, which is bidi-relative. + auto nAdjust = static_cast<style::ParagraphAdjust>( + getProperty<sal_Int16>(getParagraphOrTable(2), u"ParaAdjust"_ustr)); + CPPUNIT_ASSERT(style::ParagraphAdjust_RIGHT == nAdjust + || style::ParagraphAdjust_START == nAdjust); } DECLARE_WW8EXPORT_TEST(testTdf98620_rtlJustify, "tdf98620_rtlJustify.doc") { - CPPUNIT_ASSERT_EQUAL( style::ParagraphAdjust_RIGHT, static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(getParagraph(1), u"ParaAdjust"_ustr)) ); + CPPUNIT_ASSERT_EQUAL( style::ParagraphAdjust_START, static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(getParagraph(1), u"ParaAdjust"_ustr)) ); CPPUNIT_ASSERT_EQUAL_MESSAGE("Right To Left style", text::WritingMode2::RL_TB, getProperty<sal_Int16>(getParagraph(1), u"WritingMode"_ustr)); } DECLARE_WW8EXPORT_TEST(testTdf121110_absJustify, "tdf121110_absJustify.doc") { - CPPUNIT_ASSERT_EQUAL( style::ParagraphAdjust_RIGHT, static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(getParagraph(1), u"ParaAdjust"_ustr)) ); - CPPUNIT_ASSERT_EQUAL( style::ParagraphAdjust_LEFT, static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(getParagraph(3), u"ParaAdjust"_ustr)) ); + // tdf#169035: The document uses Jc80 adjustment, which is interpreted as literal left/right. + // However, on re-export, this value is converted to Jc adjustment, which is bidi-relative. + auto nParaAdjust1 = static_cast<style::ParagraphAdjust>( + getProperty<sal_Int16>(getParagraph(1), u"ParaAdjust"_ustr)); + CPPUNIT_ASSERT(style::ParagraphAdjust_RIGHT == nParaAdjust1 + || style::ParagraphAdjust_START == nParaAdjust1); + + auto nParaAdjust3 = static_cast<style::ParagraphAdjust>( + getProperty<sal_Int16>(getParagraph(3), u"ParaAdjust"_ustr)); + CPPUNIT_ASSERT(style::ParagraphAdjust_LEFT == nParaAdjust3 + || style::ParagraphAdjust_START == nParaAdjust3); } CPPUNIT_TEST_FIXTURE(Test, testTdf106174_rtlParaAlign) @@ -431,19 +446,19 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf106174_rtlParaAlign) CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_CENTER), getProperty<sal_Int16>(getParagraph(1), u"ParaAdjust"_ustr)); CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_CENTER), getProperty<sal_Int16>(getParagraph(2), u"ParaAdjust"_ustr)); uno::Reference<beans::XPropertySet> xPropertySet(getStyles(u"ParagraphStyles"_ustr)->getByName(u"Another paragraph aligned to right"_ustr), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_RIGHT), getProperty<sal_Int16>(xPropertySet, u"ParaAdjust"_ustr)); - CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_RIGHT), getProperty<sal_Int16>(getParagraph(3), u"ParaAdjust"_ustr)); - CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_RIGHT), getProperty<sal_Int16>(getParagraph(4), u"ParaAdjust"_ustr)); - CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_RIGHT), getProperty<sal_Int16>(getParagraph(5), u"ParaAdjust"_ustr)); - CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_LEFT), getProperty<sal_Int16>(getParagraph(6), u"ParaAdjust"_ustr)); - CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_RIGHT), getProperty<sal_Int16>(getParagraph(7), u"ParaAdjust"_ustr)); - CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_RIGHT), getProperty<sal_Int16>(getParagraph(8), u"ParaAdjust"_ustr)); - CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_LEFT), getProperty<sal_Int16>(getParagraph(9), u"ParaAdjust"_ustr)); - CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_LEFT), getProperty<sal_Int16>(getParagraph(10), u"ParaAdjust"_ustr)); - CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_RIGHT), getProperty<sal_Int16>(getParagraph(11), u"ParaAdjust"_ustr)); - CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_LEFT), getProperty<sal_Int16>(getParagraph(12), u"ParaAdjust"_ustr)); - CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_LEFT), getProperty<sal_Int16>(getParagraph(13), u"ParaAdjust"_ustr)); - CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_RIGHT), getProperty<sal_Int16>(getParagraph(14), u"ParaAdjust"_ustr)); + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_END), getProperty<sal_Int16>(xPropertySet, u"ParaAdjust"_ustr)); + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_END), getProperty<sal_Int16>(getParagraph(3), u"ParaAdjust"_ustr)); + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_END), getProperty<sal_Int16>(getParagraph(4), u"ParaAdjust"_ustr)); + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_START), getProperty<sal_Int16>(getParagraph(5), u"ParaAdjust"_ustr)); + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_END), getProperty<sal_Int16>(getParagraph(6), u"ParaAdjust"_ustr)); + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_START), getProperty<sal_Int16>(getParagraph(7), u"ParaAdjust"_ustr)); + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_START), getProperty<sal_Int16>(getParagraph(8), u"ParaAdjust"_ustr)); + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_END), getProperty<sal_Int16>(getParagraph(9), u"ParaAdjust"_ustr)); + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_END), getProperty<sal_Int16>(getParagraph(10), u"ParaAdjust"_ustr)); + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_END), getProperty<sal_Int16>(getParagraph(11), u"ParaAdjust"_ustr)); + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_START), getProperty<sal_Int16>(getParagraph(12), u"ParaAdjust"_ustr)); + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_START), getProperty<sal_Int16>(getParagraph(13), u"ParaAdjust"_ustr)); + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_END), getProperty<sal_Int16>(getParagraph(14), u"ParaAdjust"_ustr)); } DECLARE_WW8EXPORT_TEST(testTdf119232_startEvenPage, "tdf119232_startEvenPage.doc") diff --git a/sw/source/core/text/porrst.cxx b/sw/source/core/text/porrst.cxx index e367960177ed..2fffa9e9552e 100644 --- a/sw/source/core/text/porrst.cxx +++ b/sw/source/core/text/porrst.cxx @@ -442,9 +442,10 @@ bool SwTextFrame::FormatEmpty() return false; const SwAttrSet& aSet = GetTextNodeForParaProps()->GetSwAttrSet(); const SvxAdjust nAdjust = aSet.GetAdjust().GetAdjust(); - if( !bCollapse && ( ( ( ! IsRightToLeft() && ( SvxAdjust::Left != nAdjust ) ) || - ( IsRightToLeft() && ( SvxAdjust::Right != nAdjust ) ) ) || - aSet.GetRegister().GetValue() ) ) + bool bAdjustInsignificant = (!IsRightToLeft() && (SvxAdjust::Left == nAdjust)) + || (IsRightToLeft() && (SvxAdjust::Right == nAdjust)) + || (SvxAdjust::ParaStart == nAdjust); + if (!bCollapse && (!bAdjustInsignificant || aSet.GetRegister().GetValue())) return false; const SvxLineSpacingItem &rSpacing = aSet.GetLineSpacing(); if( !bCollapse && ( SvxLineSpaceRule::Min == rSpacing.GetLineSpaceRule() || diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 067c0e8a8043..2d3a4f139f4d 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -5230,7 +5230,7 @@ void DocxAttributeOutput::OutputDefaultItem(const SfxPoolItem& rHt) bMustWrite = rHt.StaticWhichCast(RES_PARATR_LINESPACING).GetInterLineSpaceRule() != SvxInterLineSpaceRule::Off; break; case RES_PARATR_ADJUST: - bMustWrite = rHt.StaticWhichCast(RES_PARATR_ADJUST).GetAdjust() != SvxAdjust::Left; + bMustWrite = rHt.StaticWhichCast(RES_PARATR_ADJUST).GetAdjust() != SvxAdjust::ParaStart; break; case RES_PARATR_SPLIT: bMustWrite = !rHt.StaticWhichCast(RES_PARATR_SPLIT).GetValue(); @@ -9124,6 +9124,12 @@ void DocxAttributeOutput::ParaAdjust( const SvxAdjustItem& rAdjust ) switch ( rAdjust.GetAdjust() ) { + case SvxAdjust::ParaStart: + pAdjustString = bEcma ? "left" : "start"; + break; + case SvxAdjust::ParaEnd: + pAdjustString = bEcma ? "right" : "end"; + break; case SvxAdjust::Left: if ( bEcma ) { diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 7a67175f7310..ce80de64cb4c 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -5267,6 +5267,14 @@ void WW8AttributeOutput::ParaAdjust( const SvxAdjustItem& rAdjust ) sal_uInt8 nAdjBiDi; switch ( rAdjust.GetAdjust() ) { + case SvxAdjust::ParaStart: + nAdj = 0; + nAdjBiDi = 0; + break; + case SvxAdjust::ParaEnd: + nAdj = 2; + nAdjBiDi = 2; + break; case SvxAdjust::Left: nAdj = 0; nAdjBiDi = 2; diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index 92ec2141ac79..39bb94fb3a65 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -395,10 +395,7 @@ void SwWW8ImplReader::Read_ParaBiDi(sal_uInt16, const sal_uInt8* pData, short nL if ( !pItem ) { // no previous adjust: set appropriate default - if ( eDir == SvxFrameDirection::Horizontal_LR_TB ) - NewAttr( SvxAdjustItem( SvxAdjust::Left, RES_PARATR_ADJUST ) ); - else - NewAttr( SvxAdjustItem( SvxAdjust::Right, RES_PARATR_ADJUST ) ); + NewAttr( SvxAdjustItem( SvxAdjust::ParaStart, RES_PARATR_ADJUST ) ); } else { @@ -4801,7 +4798,10 @@ void SwWW8ImplReader::Read_Justify( sal_uInt16 nId, const sal_uInt8* pData, shor return; } - SvxAdjust eAdjust(SvxAdjust::Left); + // tdf#121110: Jc80 justify is absolute, not bidi-relative. + // Handle this with left/right adjustment instead of start/end. + bool bIsJc80 = (nId == NS_sprm::PJc80::val); + SvxAdjust eAdjust = bIsJc80 ? SvxAdjust::Left : SvxAdjust::ParaStart; bool bDistributed = false; switch (*pData) { @@ -4812,7 +4812,7 @@ void SwWW8ImplReader::Read_Justify( sal_uInt16 nId, const sal_uInt8* pData, shor eAdjust = SvxAdjust::Center; break; case 2: - eAdjust = SvxAdjust::Right; + eAdjust = bIsJc80 ? SvxAdjust::Right : SvxAdjust::ParaEnd; break; case 3: eAdjust = SvxAdjust::Block; @@ -4861,7 +4861,10 @@ void SwWW8ImplReader::Read_RTLJustify( sal_uInt16 nId, const sal_uInt8* pData, s Read_Justify(nId, pData, nLen); else { - SvxAdjust eAdjust(SvxAdjust::Right); + // tdf#121110: Jc80 justify is absolute, not bidi-relative. + // Handle this with left/right adjustment instead of start/end. + bool bIsJc80 = (nId == NS_sprm::PJc80::val); + SvxAdjust eAdjust = bIsJc80 ? SvxAdjust::Left : SvxAdjust::ParaStart; bool bDistributed = false; switch (*pData) { @@ -4872,7 +4875,7 @@ void SwWW8ImplReader::Read_RTLJustify( sal_uInt16 nId, const sal_uInt8* pData, s eAdjust = SvxAdjust::Center; break; case 2: - eAdjust = SvxAdjust::Left; + eAdjust = bIsJc80 ? SvxAdjust::Right : SvxAdjust::ParaEnd; break; case 3: eAdjust = SvxAdjust::Block; diff --git a/sw/source/writerfilter/dmapper/DomainMapper.cxx b/sw/source/writerfilter/dmapper/DomainMapper.cxx index c43a0965882a..2079d2ddff33 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper.cxx +++ b/sw/source/writerfilter/dmapper/DomainMapper.cxx @@ -1764,7 +1764,8 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext ) case NS_ooxml::LN_CT_PPrBase_jc: { bool bExchangeLeftRight = !IsRTFImport() && !m_pImpl->IsInComments() && ExchangeLeftRight(rContext, *m_pImpl); - handleParaJustification(nIntValue, rContext, bExchangeLeftRight); + bool bUseLiteralDirection = IsRTFImport() || m_pImpl->IsInComments(); + handleParaJustification(nIntValue, rContext, bExchangeLeftRight, bUseLiteralDirection); break; } case NS_ooxml::LN_CT_PPrBase_keepLines: @@ -2141,8 +2142,8 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext ) // 2. no adjust property exists yet if ( !(m_pImpl->GetAnyProperty(PROP_PARA_ADJUST, rContext) >>= eAdjust) ) { - // RTL defaults to right adjust - eAdjust = nIntValue ? style::ParagraphAdjust_RIGHT : style::ParagraphAdjust_LEFT; + // Both directions default to start adjust + eAdjust = style::ParagraphAdjust_START; rContext->Insert(PROP_PARA_ADJUST, uno::Any( eAdjust ), /*bOverwrite=*/false); } // 3,4. existing adjust: if RTL, then swap. If LTR, but previous was RTL, also swap. @@ -4472,9 +4473,14 @@ void DomainMapper::ResetStyleProperties() pContext->Insert(ePropertyId, uno::Any(sal_Int32(0))); break; case PROP_PARA_LAST_LINE_ADJUST: - case PROP_PARA_ADJUST: pContext->Insert(ePropertyId, uno::Any(style::ParagraphAdjust_LEFT)); break; + case PROP_PARA_ADJUST: + pContext->Insert(ePropertyId, + uno::Any(IsRTFImport() + ? style::ParagraphAdjust_LEFT + : style::ParagraphAdjust_START)); + break; case PROP_PARA_TAB_STOPS: pContext->Insert(ePropertyId, uno::Any(uno::Sequence< style::TabStop >())); break; @@ -5044,9 +5050,13 @@ void DomainMapper::handleUnderlineType(const Id nId, const ::tools::SvRef<Proper rContext->Insert(PROP_CHAR_UNDERLINE, uno::Any(nUnderline)); } -void DomainMapper::handleParaJustification(const sal_Int32 nIntValue, const ::tools::SvRef<PropertyMap>& rContext, const bool bExchangeLeftRight) +void DomainMapper::handleParaJustification(const sal_Int32 nIntValue, + const ::tools::SvRef<PropertyMap>& rContext, + const bool bExchangeLeftRight, + const bool bUseLiteralDirection) { - style::ParagraphAdjust nAdjust = style::ParagraphAdjust_LEFT; + style::ParagraphAdjust nAdjust + = bUseLiteralDirection ? style::ParagraphAdjust_LEFT : style::ParagraphAdjust_START; style::ParagraphAdjust nLastLineAdjust = style::ParagraphAdjust_LEFT; OUString aStringValue = u"left"_ustr; sal_uInt16 nWordSpacing = 100; @@ -5058,7 +5068,15 @@ void DomainMapper::handleParaJustification(const sal_Int32 nIntValue, const ::to break; case NS_ooxml::LN_Value_ST_Jc_right: case NS_ooxml::LN_Value_ST_Jc_end: - nAdjust = bExchangeLeftRight ? style::ParagraphAdjust_LEFT : style::ParagraphAdjust_RIGHT; + if (bUseLiteralDirection) + { + nAdjust + = bExchangeLeftRight ? style::ParagraphAdjust_LEFT : style::ParagraphAdjust_RIGHT; + } + else + { + nAdjust = style::ParagraphAdjust_END; + } aStringValue = "right"; break; case NS_ooxml::LN_Value_ST_Jc_distribute: @@ -5092,7 +5110,15 @@ void DomainMapper::handleParaJustification(const sal_Int32 nIntValue, const ::to case NS_ooxml::LN_Value_ST_Jc_left: case NS_ooxml::LN_Value_ST_Jc_start: default: - nAdjust = bExchangeLeftRight ? style::ParagraphAdjust_RIGHT : style::ParagraphAdjust_LEFT; + if (bUseLiteralDirection) + { + nAdjust + = bExchangeLeftRight ? style::ParagraphAdjust_RIGHT : style::ParagraphAdjust_LEFT; + } + else + { + nAdjust = style::ParagraphAdjust_START; + } break; } rContext->Insert( PROP_PARA_ADJUST, uno::Any( nAdjust ) ); diff --git a/sw/source/writerfilter/dmapper/DomainMapper.hxx b/sw/source/writerfilter/dmapper/DomainMapper.hxx index f5d5c7a1a91c..5711713a1964 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper.hxx +++ b/sw/source/writerfilter/dmapper/DomainMapper.hxx @@ -185,7 +185,9 @@ private: void finishParagraph(const bool bRemove = false, const bool bNoNumbering = false); static void handleUnderlineType(const Id nId, const ::tools::SvRef<PropertyMap>& rContext); - void handleParaJustification(const sal_Int32 nIntValue, const ::tools::SvRef<PropertyMap>& rContext, const bool bExchangeLeftRight); + void handleParaJustification(const sal_Int32 nIntValue, + const ::tools::SvRef<PropertyMap>& rContext, + const bool bExchangeLeftRight, const bool bUseLiteralDirection); void HandleFramedParagraphPageBreak(PropertyMapPtr pContext); static bool getColorFromId(const Id, sal_Int32 &nColor); static sal_Int16 getEmphasisValue(const sal_Int32 nIntValue); diff --git a/sw/source/writerfilter/dmapper/DomainMapperTableHandler.cxx b/sw/source/writerfilter/dmapper/DomainMapperTableHandler.cxx index 8452e6993e83..81a698785006 100644 --- a/sw/source/writerfilter/dmapper/DomainMapperTableHandler.cxx +++ b/sw/source/writerfilter/dmapper/DomainMapperTableHandler.cxx @@ -1275,7 +1275,8 @@ void DomainMapperTableHandler::ApplyParagraphPropertiesFromTableStyle(TableParag { style::ParagraphAdjust eAdjust(style::ParagraphAdjust_CENTER); aParaStyle >>= eAdjust; - bCompatOverride = eAdjust == style::ParagraphAdjust_LEFT; + bCompatOverride = (eAdjust == style::ParagraphAdjust_START) + || (eAdjust == style::ParagraphAdjust_LEFT); } // The wording is confusing here. Normally, the paragraph style DOES override the table-style. diff --git a/sw/source/writerfilter/dmapper/StyleSheetTable.cxx b/sw/source/writerfilter/dmapper/StyleSheetTable.cxx index 8cbc5e92e6cf..252d6eb79d4b 100644 --- a/sw/source/writerfilter/dmapper/StyleSheetTable.cxx +++ b/sw/source/writerfilter/dmapper/StyleSheetTable.cxx @@ -2128,7 +2128,7 @@ void StyleSheetTable::applyDefaults(bool bParaProperties) { // tdf#87533 LO will have different defaults here, depending on the locale. Import with documented defaults SetDefaultParaProps(PROP_WRITING_MODE, uno::Any(sal_Int16(text::WritingMode_LR_TB))); - SetDefaultParaProps(PROP_PARA_ADJUST, uno::Any(sal_Int16(style::ParagraphAdjust_LEFT))); + SetDefaultParaProps(PROP_PARA_ADJUST, uno::Any(sal_Int16(style::ParagraphAdjust_START))); // Widow/Orphan -> set both to two if not already set uno::Any aTwo(sal_Int8(2)); diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index 7711277424ff..135503d8cf35 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -1599,7 +1599,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf156685) int nPageObjectCount = pPage->getObjectCount(); - CPPUNIT_ASSERT_EQUAL(9, nPageObjectCount); + CPPUNIT_ASSERT_EQUAL(11, nPageObjectCount); auto pTextPage = pPage->getTextPage();
