diff options
author | László Németh <nemeth@numbertext.org> | 2020-05-11 16:36:01 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2020-05-12 11:16:24 +0200 |
commit | 99b2d53346d4b01b491cd1f7fae3304ac0572e12 (patch) | |
tree | 9b3aa9c533aeab8d9b82925b8fa613e518440fdc /writerfilter | |
parent | f5636817e7677a3081263df9004940a7d5ac54af (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>
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 53 |
1 files changed, 26 insertions, 27 deletions
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()) { |