sw/qa/extras/ooxmlexport/data/fdo72560e.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport10.cxx | 13 ++++++- writerfilter/source/dmapper/StyleSheetTable.cxx | 42 +++++------------------- 3 files changed, 21 insertions(+), 34 deletions(-)
New commits: commit ea6aef691cbc663b423c2075297581eb21e93031 Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Mon Jul 30 12:34:17 2018 +0300 Commit: Miklos Vajna <vmik...@collabora.co.uk> CommitDate: Mon Aug 13 17:50:07 2018 +0200 cleanup tdf#72560 writerfilter: set in defaults, not styles These "unspecified" defaults are best set in document defaults, not in the style itself. Otherwise things like table styles don't know whether they can override that property. Most of the existing logic was no longer necessary, since a more generic fix ensured that all parentless styles inherited all docDefaults. Change-Id: I0ae0ccc4d69c784611fd762b5aed6e924196caf1 Reviewed-on: https://gerrit.libreoffice.org/58829 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_l...@sil.org> Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> diff --git a/sw/qa/extras/ooxmlexport/data/fdo72560e.docx b/sw/qa/extras/ooxmlexport/data/fdo72560e.docx new file mode 100644 index 000000000000..7c3e89fb3347 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo72560e.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx index 9e8d8c9d5df5..4db28720e0fa 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx @@ -310,7 +310,18 @@ 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), "ParaAdjust" )); - CPPUNIT_ASSERT_EQUAL( sal_Int32(style::ParagraphAdjust_RIGHT), getProperty< sal_Int32 >( getParagraph(1), "ParaAdjust" )); + CPPUNIT_ASSERT_EQUAL( sal_Int32(style::ParagraphAdjust_RIGHT), getProperty< sal_Int32 >( getParagraph(2), "ParaAdjust" )); +} + +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), "WritingMode" )); + CPPUNIT_ASSERT_EQUAL(sal_Int32(style::ParagraphAdjust_LEFT), getProperty<sal_Int32>( getParagraph(2), "ParaAdjust" )); + + // widow/orphan control is on when never specified. + CPPUNIT_ASSERT_EQUAL(sal_Int8(2), getProperty<sal_Int8>( getParagraph(2), "ParaWidows" )); } DECLARE_OOXMLEXPORT_TEST(testRPrChangeClosed, "rprchange_closed.docx") diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx index 63659ffbc8ff..cb188909461a 100644 --- a/writerfilter/source/dmapper/StyleSheetTable.cxx +++ b/writerfilter/source/dmapper/StyleSheetTable.cxx @@ -1052,39 +1052,6 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable ) pEntry->pProperties->Insert(PROP_CHAR_HEIGHT_COMPLEX, aTwoHundredFortyTwip, false); } } - - // Widow/Orphan -> set both to two if not already set - uno::Any aTwo = uno::makeAny(sal_Int8(2)); - pEntry->pProperties->Insert(PROP_PARA_WIDOWS, aTwo, false); - pEntry->pProperties->Insert(PROP_PARA_ORPHANS, aTwo, false); - - // tdf#87533 explicitly set writing mode value based on default paragraph properties - // specified inside styles.xml: <w:docDefaults><w:pPrDefault><w:pPr><w:bidi> - { - const PropertyMapPtr & propertyMap = m_pImpl->m_pDefaultParaProps; - - boost::optional<PropertyMap::Property> writingMode; - if (propertyMap && (writingMode = propertyMap->getProperty(PROP_WRITING_MODE))) - { - pEntry->pProperties->Insert(PROP_WRITING_MODE, writingMode->second, false); - } - else - { - // Left-to-right direction if not already set - pEntry->pProperties->Insert(PROP_WRITING_MODE, uno::makeAny(sal_Int16(text::WritingMode_LR_TB)), false); - } - - boost::optional<PropertyMap::Property> paraAdjust; - if (propertyMap && (paraAdjust = propertyMap->getProperty(PROP_PARA_ADJUST))) - { - pEntry->pProperties->Insert(PROP_PARA_ADJUST, paraAdjust->second, false); - } - else - { - // Left alignment if not already set - pEntry->pProperties->Insert(PROP_PARA_ADJUST, uno::makeAny(sal_Int16(style::ParagraphAdjust_LEFT)), false); - } - } } auto aPropValues = comphelper::sequenceToContainer< std::vector<beans::PropertyValue> >(pEntry->pProperties->GetPropertyValues()); @@ -1522,6 +1489,15 @@ void StyleSheetTable::applyDefaults(bool bParaProperties) } if( bParaProperties && m_pImpl->m_pDefaultParaProps.get()) { + // tdf#87533 LO will have different defaults here, depending on the locale. Import with documented defaults + m_pImpl->m_pDefaultParaProps->Insert(PROP_WRITING_MODE, uno::makeAny(sal_Int16(text::WritingMode_LR_TB)), /*bOverwrite=*/false); + m_pImpl->m_pDefaultParaProps->Insert(PROP_PARA_ADJUST, uno::makeAny(sal_Int16(style::ParagraphAdjust_LEFT)), false); + + // Widow/Orphan -> set both to two if not already set + uno::Any aTwo = uno::makeAny(sal_Int8(2)); + m_pImpl->m_pDefaultParaProps->Insert(PROP_PARA_WIDOWS, aTwo, /*bOverwrite=*/false); + m_pImpl->m_pDefaultParaProps->Insert(PROP_PARA_ORPHANS, aTwo, false); + uno::Reference<style::XStyleFamiliesSupplier> xStylesSupplier(m_pImpl->m_xTextDocument, uno::UNO_QUERY); uno::Reference<container::XNameAccess> xStyleFamilies = xStylesSupplier->getStyleFamilies(); uno::Reference<container::XNameAccess> xParagraphStyles; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits