diff options
author | László Németh <nemeth@numbertext.org> | 2020-06-12 13:14:51 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2020-06-12 17:42:18 +0200 |
commit | de1b634a151c198584dc152676183f519c50a2da (patch) | |
tree | 8a7d0bdc8cfc87e81c5f81622b60269bb85f2abb /sw/qa | |
parent | 2128d59ab91da853652305390d56b3287bcb67b1 (diff) |
tdf#76817: DOCX import: fix custom chapter numbering
When one of the parents of the default Heading style
has got custom paragraph style instead of the
default Heading 1 – Heading 10, apply direct numbering
again to avoid bad or missing numbering.
Change-Id: I7e94600b5ac2cbf593a95eda6c0d6cd9d731dd75
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96199
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/extras/uiwriter/data2/tdf76817.docx | bin | 0 -> 18584 bytes | |||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter2.cxx | 55 |
2 files changed, 55 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/data2/tdf76817.docx b/sw/qa/extras/uiwriter/data2/tdf76817.docx Binary files differnew file mode 100644 index 000000000000..20478778a0d3 --- /dev/null +++ b/sw/qa/extras/uiwriter/data2/tdf76817.docx diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 27ed40c0d265..68470cecdc72 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -1225,6 +1225,61 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf76817) getProperty<OUString>(getParagraph(4), "ListLabelString")); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf76817_custom_outline) +{ + load(DATA_DIRECTORY, "tdf76817.docx"); + + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"), + getProperty<OUString>(getParagraph(1), "ParaStyleName")); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), + getProperty<sal_Int32>(getParagraph(1), "OutlineLevel")); + CPPUNIT_ASSERT_EQUAL(OUString("1"), getProperty<OUString>(getParagraph(1), "ListLabelString")); + + CPPUNIT_ASSERT_EQUAL(OUString("Heading 2"), + getProperty<OUString>(getParagraph(2), "ParaStyleName")); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), + getProperty<sal_Int32>(getParagraph(2), "OutlineLevel")); + // This wasn't numbered + CPPUNIT_ASSERT_EQUAL(OUString("1.1"), + getProperty<OUString>(getParagraph(2), "ListLabelString")); + + CPPUNIT_ASSERT_EQUAL(OUString("Heading 2"), + getProperty<OUString>(getParagraph(4), "ParaStyleName")); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), + getProperty<sal_Int32>(getParagraph(4), "OutlineLevel")); + // This wasn't numbered + CPPUNIT_ASSERT_EQUAL(OUString("2.1"), + getProperty<OUString>(getParagraph(4), "ListLabelString")); + + // set Heading 2 style of paragraph 2 to Heading 1 + + SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell(); + pWrtShell->Down(/*bSelect=*/false); + + uno::Sequence<beans::PropertyValue> aPropertyValues = comphelper::InitPropertySequence({ + { "Style", uno::makeAny(OUString("Heading 1")) }, + { "FamilyName", uno::makeAny(OUString("ParagraphStyles")) }, + }); + dispatchCommand(mxComponent, ".uno:StyleApply", aPropertyValues); + + CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"), + getProperty<OUString>(getParagraph(2), "ParaStyleName")); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), + getProperty<sal_Int32>(getParagraph(2), "OutlineLevel")); + CPPUNIT_ASSERT_EQUAL(OUString("2"), getProperty<OUString>(getParagraph(2), "ListLabelString")); + + CPPUNIT_ASSERT_EQUAL(OUString("Heading 2"), + getProperty<OUString>(getParagraph(4), "ParaStyleName")); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), + getProperty<sal_Int32>(getParagraph(4), "OutlineLevel")); + // This wasn't numbered + CPPUNIT_ASSERT_EQUAL(OUString("3.1"), + getProperty<OUString>(getParagraph(4), "ListLabelString")); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf123102) { createDoc("tdf123102.odt"); |