summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2020-05-11 16:36:01 +0200
committerLászló Németh <nemeth@numbertext.org>2020-05-12 11:16:24 +0200
commit99b2d53346d4b01b491cd1f7fae3304ac0572e12 (patch)
tree9b3aa9c533aeab8d9b82925b8fa613e518440fdc
parentf5636817e7677a3081263df9004940a7d5ac54af (diff)
tdf#132802 DOCX import: fix list bottom auto margins
of the last list item, when its numbering based on the paragraph style. Before tables, table rows and before paragraphs without numbering or with different numbering list items got a regression from commit 9a132c8fab7d4d70b91e5ed92429c70a0466afcb (tdf#122342 DOCX import: fix bottom auto margin in lists) Change-Id: I23c73d94569e785ec780d708d983764534e356c2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93973 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf132802.docxbin0 -> 12960 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport9.cxx19
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx53
3 files changed, 44 insertions, 28 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf132802.docx b/sw/qa/extras/ooxmlexport/data/tdf132802.docx
new file mode 100644
index 000000000000..c4c2d9a1e268
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf132802.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 4227765975de..88e081898622 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -188,7 +188,24 @@ DECLARE_OOXMLEXPORT_TEST(testTdf122342, "tdf122342.docx")
// TODO fix for ParaTopMargin, too.
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraph(1), "ParaBottomMargin"));
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraph(2), "ParaBottomMargin"));
- CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraph(3), "ParaBottomMargin"));
+ // last list item
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(494), getProperty<sal_Int32>(getParagraph(3), "ParaBottomMargin"));
+}
+
+DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf132802, "tdf132802.docx")
+{
+ xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:spacing", "after", "0");
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:pPr/w:spacing", "after", "0");
+ // This was 0 (list auto spacing is not zero before tables)
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:pPr/w:spacing", "after", "280");
+ assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc/w:p[1]/w:pPr/w:spacing", "after", "0");
+ // This was 0 (list auto spacing is not zero at the end of table cells)
+ assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc/w:p[2]/w:pPr/w:spacing", "after", "280");
+ assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:tc/w:p[1]/w:pPr/w:spacing", "after", "280");
+ assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[3]/w:tc/w:p[1]/w:pPr/w:spacing", "after", "280");
+ // This was 0 (list auto spacing is not zero at list end)
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:pPr/w:spacing", "after", "280");
}
DECLARE_OOXMLEXPORT_TEST(testTdf129575_directBefore, "tdf129575-directBefore.docx")
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 05adcea8b9ba..fde30248f6d1 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1625,23 +1625,36 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
{
return rValue.Name == "NumberingRules";
});
- if (itNumberingRules != aProperties.end())
+
+ bool isNumberingViaRule = (itNumberingRules != aProperties.end());
+ if (m_xPreviousParagraph.is() && (isNumberingViaRule || isNumberingViaStyle))
{
// This textnode has numbering. Look up the numbering style name of the current and previous paragraph.
- OUString aCurrentNumberingRuleName;
- uno::Reference<container::XNamed> xCurrentNumberingRules(itNumberingRules->Value, uno::UNO_QUERY);
- if (xCurrentNumberingRules.is())
- aCurrentNumberingRuleName = xCurrentNumberingRules->getName();
- OUString aPreviousNumberingRuleName;
- if (m_xPreviousParagraph.is())
+ OUString aCurrentNumberingName;
+ OUString aPreviousNumberingName;
+ if (isNumberingViaRule)
+ {
+ uno::Reference<container::XNamed> xCurrentNumberingRules(itNumberingRules->Value, uno::UNO_QUERY);
+ if (xCurrentNumberingRules.is())
+ aCurrentNumberingName = xCurrentNumberingRules->getName();
+ if (m_xPreviousParagraph.is())
+ {
+ uno::Reference<container::XNamed> xPreviousNumberingRules(m_xPreviousParagraph->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
+ if (xPreviousNumberingRules.is())
+ aPreviousNumberingName = xPreviousNumberingRules->getName();
+ }
+ }
+ else if ( m_xPreviousParagraph->getPropertySetInfo()->hasPropertyByName("NumberingStyleName") &&
+ // don't update before tables
+ (m_nTableDepth == 0 || !m_bFirstParagraphInCell))
{
- uno::Reference<container::XNamed> xPreviousNumberingRules(m_xPreviousParagraph->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
- if (xPreviousNumberingRules.is())
- aPreviousNumberingRuleName = xPreviousNumberingRules->getName();
+ aCurrentNumberingName = GetListStyleName(nListId);
+ m_xPreviousParagraph->getPropertyValue("NumberingStyleName") >>= aPreviousNumberingName;
}
- if (!aPreviousNumberingRuleName.isEmpty() && aCurrentNumberingRuleName == aPreviousNumberingRuleName)
+ if (!aPreviousNumberingName.isEmpty() && aCurrentNumberingName == aPreviousNumberingName)
{
+
// There was a previous textnode and it had the same numbering.
if (m_bParaAutoBefore)
{
@@ -1655,6 +1668,7 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
else
aProperties.push_back(comphelper::makePropertyValue("ParaTopMargin", static_cast<sal_Int32>(0)));
}
+
uno::Sequence<beans::PropertyValue> aPrevPropertiesSeq;
m_xPreviousParagraph->getPropertyValue("ParaInteropGrabBag") >>= aPrevPropertiesSeq;
auto aPrevProperties = comphelper::sequenceToContainer< std::vector<beans::PropertyValue> >(aPrevPropertiesSeq);
@@ -1674,7 +1688,7 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
m_xPreviousParagraph.set(xTextRange, uno::UNO_QUERY);
if (m_xPreviousParagraph.is() && // null for SvxUnoTextBase
- (isNumberingViaStyle || itNumberingRules != aProperties.end()))
+ (isNumberingViaStyle || isNumberingViaRule))
{
assert(dynamic_cast<ParagraphPropertyMap*>(pPropertyMap.get()));
// Use lcl_getListId(), so we find the list ID in parent styles as well.
@@ -1698,21 +1712,6 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
{
m_xPreviousParagraph->setPropertyValue("ListId", uno::makeAny(listId));
}
- else if (isNumberingViaStyle)
- {
- uno::Sequence<beans::PropertyValue> aPrevPropertiesSeq;
- m_xPreviousParagraph->getPropertyValue("ParaInteropGrabBag") >>= aPrevPropertiesSeq;
- auto aPrevProperties = comphelper::sequenceToContainer< std::vector<beans::PropertyValue> >(aPrevPropertiesSeq);
- bool bPrevParaAutoAfter = std::any_of(aPrevProperties.begin(), aPrevProperties.end(), [](const beans::PropertyValue& rValue)
- {
- return rValue.Name == "ParaBottomMarginAfterAutoSpacing";
- });
- if (bPrevParaAutoAfter)
- {
- // Previous after spacing is set to auto, set previous after space to 0.
- m_xPreviousParagraph->setPropertyValue("ParaBottomMargin", uno::makeAny(static_cast<sal_Int32>(0)));
- }
- }
}
if (pList->GetCurrentLevel())
{