diff options
author | László Németh <nemeth@numbertext.org> | 2019-11-15 10:37:42 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-03-05 10:50:20 +0100 |
commit | 1b6a7ca11869f0a80c08df4a7d1caac0c3ff02e5 (patch) | |
tree | 44e1ec025c3a285a9089bf43c74a0d3caa481c91 | |
parent | related tdf#99602 writerfilter TODO: subscript - use CharStyle fontsize (diff) | |
download | core-1b6a7ca11869f0a80c08df4a7d1caac0c3ff02e5.tar.gz core-1b6a7ca11869f0a80c08df4a7d1caac0c3ff02e5.zip |
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.
(cherry picked from commit d8f3f8ecd9e6304f3a98ab03fae6bc545893f782)
Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
writerfilter/source/dmapper/DomainMapper_Impl.hxx
Change-Id: Ib7f5f80dd2485a0fd4ab8e0645b7d730a7ec3c5c
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf128752.docx | bin | 0 -> 13621 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport6.cxx | 9 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapperTableHandler.cxx | 5 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 13 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.hxx | 5 |
5 files changed, 29 insertions, 3 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf128752.docx b/sw/qa/extras/ooxmlexport/data/tdf128752.docx Binary files differnew file mode 100644 index 000000000000..0e49291414d7 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf128752.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx index 94121b7e22b4..910b14b00bb9 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx @@ -451,6 +451,15 @@ DECLARE_OOXMLEXPORT_TEST(testTableFloatingMargins, "table-floating-margins.docx" assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:p/w:pPr/w:spacing", "after", "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 67f33911f1c4..61e088bfa4c1 100644 --- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx @@ -1135,6 +1135,10 @@ void DomainMapperTableHandler::endTable(unsigned int nestedTableLevel, bool bTab uno::Reference<table::XCellRange> xCellRange(xTable, uno::UNO_QUERY); uno::Any aBottomMargin = aTableInfo.aTableProperties[i].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]; @@ -1224,6 +1228,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 DEBUG_WRITERFILTER TagLogger::getInstance().endElement(); diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index ceb6d3fba0f3..9de2d6f46e69 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -704,9 +704,9 @@ const 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) { @@ -1546,7 +1546,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 258398255fb1..c07bda028d86 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -709,7 +709,7 @@ public: const 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 @@ -1005,6 +1005,9 @@ public: /// start/end node. void ClearPreviousParagraph(); + /// 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 ; |