summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-02-10 21:04:32 +0100
committerMiklos Vajna <vmiklos@collabora.com>2020-02-11 09:07:34 +0100
commit63d3ac37865460ff51348a6e792bbacf2f7c4653 (patch)
treeb48a9d8f03adfb9040e78088a7d8e8b3b34932ae
parent5d00a1c9c6e85f3d7a3e05ab485da79980c38d44 (diff)
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 <vmiklos@collabora.com>
-rw-r--r--writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx30
-rw-r--r--writerfilter/qa/cppunittests/dmapper/data/num-restart-style-parent.docxbin0 -> 12336 bytes
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx4
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
new file mode 100644
index 000000000000..f908d94b56fe
--- /dev/null
+++ b/writerfilter/qa/cppunittests/dmapper/data/num-restart-style-parent.docx
Binary files 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...