summaryrefslogtreecommitdiff
path: root/sw/qa
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2020-06-12 11:11:16 +0200
committerLászló Németh <nemeth@numbertext.org>2020-06-12 17:42:00 +0200
commit2128d59ab91da853652305390d56b3287bcb67b1 (patch)
treea770ca02c32e0eec92abe7b44aec2e73e498e275 /sw/qa
parenta7b12e23bf9ac8e394405a1de5835e18e40c27c2 (diff)
tdf#76817: DOCX import: fix chapter numbering
Imported headings got also redundant custom direct numbering, resulting broken automatic chapter numbering: applying standard Heading styles on paragraphs using the associated toolbar menu, Manage Styles dialog window or Ctrl-1–Ctrl-4 shortcut keys, it didn't result continuous numbering. Co-authored-by: Justin Luth <justin_luth@sil.org> Change-Id: Ic1ba5070fa4c387ad527aec05234a4da90fab751 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96198 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/qa')
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx15
-rw-r--r--sw/qa/extras/uiwriter/data2/num-parent-style.docxbin0 -> 14002 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter2.cxx78
3 files changed, 90 insertions, 3 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index ac4bf4cd2053..5ff581743ccd 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -771,9 +771,18 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testOOxmlOutlineNumberTypes, "outline-number
DECLARE_OOXMLEXPORT_TEST(testNumParentStyle, "num-parent-style.docx")
{
-//reverting tdf#76817 hard-codes the numbering style on the paragraph, preventing RT of "Outline" style
-//I think this unit test is wrong, but I will revert to its original claim.
- CPPUNIT_ASSERT(getProperty<OUString>(getParagraph(4), "NumberingStyleName").startsWith("WWNum"));
+ 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(static_cast<sal_Int32>(2),
+ getProperty<sal_Int32>(getParagraph(2), "OutlineLevel"));
+ CPPUNIT_ASSERT_EQUAL(OUString("1.1"), getProperty<OUString>(getParagraph(2), "ListLabelString"));
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1),
+ getProperty<sal_Int32>(getParagraph(3), "OutlineLevel"));
+ CPPUNIT_ASSERT_EQUAL(OUString("2"), getProperty<OUString>(getParagraph(3), "ListLabelString"));
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2),
+ getProperty<sal_Int32>(getParagraph(4), "OutlineLevel"));
+ CPPUNIT_ASSERT_EQUAL(OUString("2.1"), getProperty<OUString>(getParagraph(4), "ListLabelString"));
}
DECLARE_OOXMLEXPORT_TEST(testNumOverrideLvltext, "num-override-lvltext.docx")
diff --git a/sw/qa/extras/uiwriter/data2/num-parent-style.docx b/sw/qa/extras/uiwriter/data2/num-parent-style.docx
new file mode 100644
index 000000000000..4b8c657afa3f
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data2/num-parent-style.docx
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 99f573b139e6..27ed40c0d265 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -1147,6 +1147,84 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf105413)
getProperty<OUString>(getParagraph(1), "ParaStyleName"));
}
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf76817)
+{
+ load(DATA_DIRECTORY, "num-parent-style.docx");
+
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+
+ 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"));
+ 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"));
+ 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"));
+ // This was "1 Heading" instead of "2 Heading"
+ 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 was "2.1 Heading"
+ CPPUNIT_ASSERT_EQUAL(OUString("3.1"),
+ getProperty<OUString>(getParagraph(4), "ListLabelString"));
+
+ // set Heading 1 style of paragraph 3 to Heading 2
+
+ pWrtShell->Down(/*bSelect=*/false);
+
+ CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"),
+ getProperty<OUString>(getParagraph(3), "ParaStyleName"));
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1),
+ getProperty<sal_Int32>(getParagraph(3), "OutlineLevel"));
+ CPPUNIT_ASSERT_EQUAL(OUString("3"), getProperty<OUString>(getParagraph(3), "ListLabelString"));
+
+ uno::Sequence<beans::PropertyValue> aPropertyValues2 = comphelper::InitPropertySequence({
+ { "Style", uno::makeAny(OUString("Heading 2")) },
+ { "FamilyName", uno::makeAny(OUString("ParagraphStyles")) },
+ });
+ dispatchCommand(mxComponent, ".uno:StyleApply", aPropertyValues2);
+
+ CPPUNIT_ASSERT_EQUAL(OUString("Heading 2"),
+ getProperty<OUString>(getParagraph(3), "ParaStyleName"));
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2),
+ getProperty<sal_Int32>(getParagraph(3), "OutlineLevel"));
+ CPPUNIT_ASSERT_EQUAL(OUString("2.1"),
+ getProperty<OUString>(getParagraph(3), "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"));
+ CPPUNIT_ASSERT_EQUAL(OUString("2.2"),
+ getProperty<OUString>(getParagraph(4), "ListLabelString"));
+}
+
CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf123102)
{
createDoc("tdf123102.odt");