writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx | 30 ++++++++++ writerfilter/qa/cppunittests/dmapper/data/num-restart-style-parent.docx |binary writerfilter/source/dmapper/DomainMapper_Impl.cxx | 4 + 3 files changed, 33 insertions(+), 1 deletion(-)
New commits: commit 63d3ac37865460ff51348a6e792bbacf2f7c4653 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Mon Feb 10 21:04:32 2020 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Tue Feb 11 09:07:34 2020 +0100 tdf#129221 DOCX import: fix missing restart of numbering Regression from e49d2b31fb2020d065b4ad940d1031d07b10f32b (fdo#78939 [DOCX] Hang while opening due to incorrect modification of Style, 2014-06-06), the problem was that the 2nd sub-list of the bugdoc was not restarted in Writer, while it was in Word. The PR2 paragraph style inherits from the PR1 one and only that sets the numId; tweaking the bugdoc to state the numId directly in PR2 would work around the problem. Fix the issue by improving DomainMapper_Impl::finishParagraph(), so that it uses lcl_getListId() rather than calling pStyleSheetProperties->GetListId() directly; since the previous knows how to walk up the parent chain if needed. Change-Id: I1c460919b0389d5b053b4ca1c9210279d6cd183c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88413 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx b/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx index 3b1d75cbcfba..e5f8c09cd640 100644 --- a/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx @@ -78,6 +78,36 @@ CPPUNIT_TEST_FIXTURE(Test, testPageBreakFooterTable) // i.e. there was no page break before the last paragraph. CPPUNIT_ASSERT_EQUAL(style::BreakType_PAGE_BEFORE, eType); } + +CPPUNIT_TEST_FIXTURE(Test, testNumberingRestartStyleParent) +{ + OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "num-restart-style-parent.docx"; + getComponent() = loadFromDesktop(aURL); + + // The paragraphs are A 1 2 B 1 2. + uno::Reference<text::XTextDocument> xTextDocument(getComponent(), uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), + uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); + uno::Reference<beans::XPropertySet> xPara; + OUStringLiteral aProp("ListLabelString"); + xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("A."), xPara->getPropertyValue(aProp).get<OUString>()); + xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("1."), xPara->getPropertyValue(aProp).get<OUString>()); + xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("2."), xPara->getPropertyValue(aProp).get<OUString>()); + xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("B."), xPara->getPropertyValue(aProp).get<OUString>()); + xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1. + // - Actual : 3. + // i.e. the numbering was not restarted after B. + CPPUNIT_ASSERT_EQUAL(OUString("1."), xPara->getPropertyValue(aProp).get<OUString>()); + xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("2."), xPara->getPropertyValue(aProp).get<OUString>()); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/qa/cppunittests/dmapper/data/num-restart-style-parent.docx b/writerfilter/qa/cppunittests/dmapper/data/num-restart-style-parent.docx new file mode 100644 index 000000000000..f908d94b56fe Binary files /dev/null and b/writerfilter/qa/cppunittests/dmapper/data/num-restart-style-parent.docx differ diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index fa4e089192d9..2c0472adb068 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -1654,8 +1654,10 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con (isNumberingViaStyle || itNumberingRules != aProperties.end())) { assert(dynamic_cast<ParagraphPropertyMap*>(pPropertyMap.get())); + // Use lcl_getListId(), so we find the list ID in parent styles as well. + bool bNumberingFromBaseStyle = false; sal_Int32 const nListId( isNumberingViaStyle - ? pStyleSheetProperties->GetListId() + ? lcl_getListId(pEntry, GetStyleSheetTable(), bNumberingFromBaseStyle) : static_cast<ParagraphPropertyMap*>(pPropertyMap.get())->GetListId()); if (ListDef::Pointer const& pList = m_pListTable->GetList(nListId)) { // styles could refer to non-existing lists... _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits