sw/qa/extras/ooxmlexport/data/tdf128752.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport6.cxx | 9 +++++++++ writerfilter/source/dmapper/DomainMapperTableHandler.cxx | 5 +++++ writerfilter/source/dmapper/DomainMapper_Impl.cxx | 13 +++++++++++-- writerfilter/source/dmapper/DomainMapper_Impl.hxx | 5 ++++- 5 files changed, 29 insertions(+), 3 deletions(-)
New commits: commit d8f3f8ecd9e6304f3a98ab03fae6bc545893f782 Author: László Németh <nem...@numbertext.org> AuthorDate: Fri Nov 15 10:37:42 2019 +0100 Commit: László Németh <nem...@numbertext.org> CommitDate: Fri Nov 15 14:26:12 2019 +0100 tdf#128752 DOCX: fix partial direct paragraph spacing in tables When direct formatting of a table paragraph set only top margin, but not the bottom margin, also there was no paragraph style setting for the bottom margin, the paragraph was imported using docDefault bottom spacing instead of the table style bottom spacing. Change-Id: Ib7f5f80dd2485a0fd4ab8e0645b7d730a7ec3c5c Reviewed-on: https://gerrit.libreoffice.org/82771 Tested-by: Jenkins Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/sw/qa/extras/ooxmlexport/data/tdf128752.docx b/sw/qa/extras/ooxmlexport/data/tdf128752.docx new file mode 100644 index 000000000000..0e49291414d7 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf128752.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx index bd80a537e12a..9e0859f028e7 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx @@ -459,6 +459,15 @@ DECLARE_OOXMLEXPORT_TEST(testTdf127814, "tdf127814.docx") assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:p/w:pPr/w:spacing", "before", "0"); } +DECLARE_OOXMLEXPORT_TEST(testTdf128752, "tdf128752.docx") +{ + // Paragraph bottom margin was 200, docDefault instead of table style setting + xmlDocPtr pXmlDoc = parseExport(); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:p[1]/w:pPr/w:spacing", "after", "0"); +} + DECLARE_OOXMLEXPORT_TEST(testFdo69636, "fdo69636.docx") { /* diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx index be87c2c3785f..efbaf3a0ffc3 100644 --- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx @@ -1099,6 +1099,10 @@ void DomainMapperTableHandler::endTable(unsigned int nestedTableLevel, bool bTab uno::Reference<table::XCellRange> xCellRange(xTable, uno::UNO_QUERY); uno::Any aBottomMargin = pTableProp->Value; sal_Int32 nRows = aCellProperties.getLength(); + + for (const auto& rParaProp : m_rDMapper_Impl.m_aPendingParaProp ) + rParaProp->setPropertyValue("ParaBottomMargin", aBottomMargin ); + for (sal_Int32 nRow = 0; nRow < nRows; ++nRow) { const uno::Sequence< beans::PropertyValues > aCurrentRow = aCellProperties[nRow]; @@ -1184,6 +1188,7 @@ void DomainMapperTableHandler::endTable(unsigned int nestedTableLevel, bool bTab m_aCellProperties.clear(); m_aRowProperties.clear(); m_bHadFootOrEndnote = false; + m_rDMapper_Impl.m_aPendingParaProp.clear(); #ifdef DBG_UTIL TagLogger::getInstance().endElement(); diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 0ba1c83673d1..52a0418abd92 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -792,9 +792,9 @@ OUString DomainMapper_Impl::GetDefaultParaStyleName() return m_sDefaultParaStyleName; } -uno::Any DomainMapper_Impl::GetPropertyFromStyleSheet(PropertyIds eId, StyleSheetEntryPtr pEntry, const bool bDocDefaults, const bool bPara) +uno::Any DomainMapper_Impl::GetPropertyFromStyleSheet(PropertyIds eId, StyleSheetEntryPtr pEntry, const bool bDocDefaults, const bool bPara, const bool bStyles) { - while(pEntry.get( ) ) + while( bStyles && pEntry.get( ) ) { if(pEntry->pProperties) { @@ -1722,7 +1722,16 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con { uno::Any aMargin = GetPropertyFromParaStyleSheet(PROP_PARA_BOTTOM_MARGIN); if ( aMargin != uno::Any() ) + { xParaProps->setPropertyValue("ParaBottomMargin", aMargin); + + // table style has got bigger precedence than docDefault style + // collect these pending paragraph properties to process in endTable() + // TODO check the case, when two parent styles modify the docDefault and the last one set back the docDefault value + uno::Any aMarginDocDefault = GetPropertyFromStyleSheet(PROP_PARA_BOTTOM_MARGIN, nullptr, true, true, false); + if ( m_nTableDepth > 0 && aMargin == aMarginDocDefault ) + m_aPendingParaProp.push_back(xParaProps); + } } if ( !bContextSet ) { diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index b3b85cde08c2..e21ed16a2d52 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -726,7 +726,7 @@ public: OUString GetDefaultParaStyleName(); // specified style - including inherited properties. Indicate whether paragraph defaults should be checked. - css::uno::Any GetPropertyFromStyleSheet(PropertyIds eId, StyleSheetEntryPtr pEntry, const bool bDocDefaults, const bool bPara); + css::uno::Any GetPropertyFromStyleSheet(PropertyIds eId, StyleSheetEntryPtr pEntry, const bool bDocDefaults, const bool bPara, const bool bStyles = true); // current paragraph style - including inherited properties css::uno::Any GetPropertyFromParaStyleSheet(PropertyIds eId); // context's character style - including inherited properties @@ -1035,6 +1035,9 @@ public: bool m_bIsActualParagraphFramed; std::vector<css::uno::Any> aFramedRedlines; + /// Table paragraph properties may need style update based on table style + std::vector<css::uno::Reference<css::beans::XPropertySet>> m_aPendingParaProp; + private: void PushPageHeaderFooter(bool bHeader, SectionPropertyMap::PageType eType); std::vector<css::uno::Reference< css::drawing::XShape > > m_vTextFramesForChaining ; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits