From 9cca15204af9cc44a8a9528ccf2f36616fb70e69 Mon Sep 17 00:00:00 2001 From: László Németh Date: Wed, 20 May 2020 16:24:38 +0200 Subject: tdf#133052: DOCX import: fix top auto margin of subitems MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (nested lists) and other items of lists, when auto margin is defined by paragraph style, and list items have got w:numPr. Follow-up of commit 162d74ae7a53eb1cde738f0a7558f297b8162f7a (tdf#132807 DOCX import: fix top auto margin in lists). Change-Id: I4cf470173fa367ac07e15dc901b0e202178c9fc4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94588 Tested-by: Jenkins Tested-by: László Németh Reviewed-by: László Németh --- sw/qa/extras/ooxmlexport/data/tdf133052.docx | Bin 0 -> 13891 bytes sw/qa/extras/ooxmlexport/ooxmlexport9.cxx | 13 +++++++++++++ writerfilter/source/dmapper/DomainMapper_Impl.cxx | 12 +++--------- 3 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 sw/qa/extras/ooxmlexport/data/tdf133052.docx diff --git a/sw/qa/extras/ooxmlexport/data/tdf133052.docx b/sw/qa/extras/ooxmlexport/data/tdf133052.docx new file mode 100644 index 000000000000..937554facde6 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf133052.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx index 85376af95392..8847b6413a54 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx @@ -223,6 +223,19 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf132807, "tdf132807.docx") assertXPath(pXmlDoc, "/w:document/w:body/w:p[5]/w:pPr/w:spacing", "before", "280"); } +DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf133052, "tdf133052.docx") +{ + xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); + // These were 240 (top auto spacing of list subitems are zero) + assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:pPr/w:spacing", "before", "0"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[5]/w:pPr/w:spacing", "before", "0"); + // in tables, too + assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc/w:p[2]/w:pPr/w:spacing", "before", "0"); + assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc/w:p[3]/w:pPr/w:spacing", "before", "0"); + assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc/w:p[4]/w:pPr/w:spacing", "before", "0"); + assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc/w:p[5]/w:pPr/w:spacing", "before", "0"); +} + DECLARE_OOXMLEXPORT_TEST(testTdf129575_directBefore, "tdf129575-directBefore.docx") { uno::Reference xTablesSupplier(mxComponent, uno::UNO_QUERY); diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index c570562d5e12..4b7b3ccd45ef 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -1656,18 +1656,12 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con uno::Sequence aPrevPropertiesSeq; m_xPreviousParagraph->getPropertyValue("ParaInteropGrabBag") >>= aPrevPropertiesSeq; auto aPrevProperties = comphelper::sequenceToContainer< std::vector >(aPrevPropertiesSeq); - bool bPrevParaAutoBefore; - if (isNumberingViaRule) - bPrevParaAutoBefore = false; - else + bool bParaAutoBefore = m_bParaAutoBefore || std::any_of(aPrevProperties.begin(), aPrevProperties.end(), [](const beans::PropertyValue& rValue) { - bPrevParaAutoBefore = std::any_of(aPrevProperties.begin(), aPrevProperties.end(), [](const beans::PropertyValue& rValue) - { return rValue.Name == "ParaTopMarginBeforeAutoSpacing"; - }); - } + }); // There was a previous textnode and it had the same numbering. - if (m_bParaAutoBefore || bPrevParaAutoBefore) + if (bParaAutoBefore) { // This before spacing is set to auto, set before space to 0. auto itParaTopMargin = std::find_if(aProperties.begin(), aProperties.end(), [](const beans::PropertyValue& rValue) -- cgit v1.2.3