diff options
-rw-r--r-- | writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx | 30 | ||||
-rw-r--r-- | writerfilter/qa/cppunittests/dmapper/data/num-restart-style-parent.docx | bin | 0 -> 12336 bytes | |||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 4 |
3 files changed, 33 insertions, 1 deletions
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 Binary files differnew file mode 100644 index 000000000000..f908d94b56fe --- /dev/null +++ b/writerfilter/qa/cppunittests/dmapper/data/num-restart-style-parent.docx 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... |