From 91fe6b97952aa6f7cef58327fd085a17db38ad95 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 11:44:47 +0200 Subject: Merging upstream version 4:24.2.2. Signed-off-by: Daniel Baumann --- sw/qa/extras/ooxmlexport/data/tdf158597.docx | Bin 0 -> 12719 bytes sw/qa/extras/ooxmlexport/ooxmlexport21.cxx | 258 +++++++++++++++++++++++++++ 2 files changed, 258 insertions(+) create mode 100644 sw/qa/extras/ooxmlexport/data/tdf158597.docx (limited to 'sw/qa/extras/ooxmlexport') diff --git a/sw/qa/extras/ooxmlexport/data/tdf158597.docx b/sw/qa/extras/ooxmlexport/data/tdf158597.docx new file mode 100644 index 0000000000..ad7924ce71 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf158597.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx index cdcdfe7785..e902f7a7b8 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx @@ -9,12 +9,15 @@ #include +#include #include #include #include #include #include +#include + #include #include #include @@ -30,6 +33,261 @@ public: } }; +DECLARE_OOXMLEXPORT_TEST(testTdf158597, "tdf158597.docx") +{ + // test with 2 properties: font size, italic (toggle) + { + uno::Reference xParagraph(getParagraph(1)); + CPPUNIT_ASSERT_EQUAL(OUString("No style"), xParagraph->getString()); + uno::Reference xProps(xParagraph, uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("List Paragraph"), + getProperty(xProps, "ParaStyleName")); + uno::Reference xRun(getRun(xParagraph, 1)); + CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty(xRun, "CharStyleName")); + CPPUNIT_ASSERT_EQUAL(11.f, getProperty(xRun, "CharHeight")); + CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE, getProperty(xRun, "CharPosture")); + CPPUNIT_ASSERT(!xProps->getPropertyValue("ListAutoFormat").hasValue()); + } + { + uno::Reference xParagraph(getParagraph(2)); + CPPUNIT_ASSERT_EQUAL(OUString("Char style mark"), xParagraph->getString()); + uno::Reference xProps(xParagraph, uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("List Paragraph"), + getProperty(xProps, "ParaStyleName")); + uno::Reference xRun(getRun(xParagraph, 1)); + CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty(xRun, "CharStyleName")); + CPPUNIT_ASSERT_EQUAL(11.f, getProperty(xRun, "CharHeight")); + CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE, getProperty(xRun, "CharPosture")); + comphelper::SequenceAsHashMap listAutoFormat(xProps->getPropertyValue("ListAutoFormat")); + CPPUNIT_ASSERT_EQUAL(OUString("Emphasis"), listAutoFormat["CharStyleName"].get()); + CPPUNIT_ASSERT(!listAutoFormat["CharHeight"].hasValue()); + CPPUNIT_ASSERT(!listAutoFormat["CharPosture"].hasValue()); + } + { + uno::Reference xParagraph(getParagraph(3)); + CPPUNIT_ASSERT_EQUAL(OUString("Char style mark and text"), xParagraph->getString()); + uno::Reference xProps(xParagraph, uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("List Paragraph"), + getProperty(xProps, "ParaStyleName")); + uno::Reference xRun(getRun(xParagraph, 1)); + CPPUNIT_ASSERT_EQUAL(OUString("Emphasis"), getProperty(xRun, "CharStyleName")); + CPPUNIT_ASSERT_EQUAL(16.f, getProperty(xRun, "CharHeight")); + CPPUNIT_ASSERT_EQUAL(awt::FontSlant_ITALIC, + getProperty(xRun, "CharPosture")); + comphelper::SequenceAsHashMap listAutoFormat(xProps->getPropertyValue("ListAutoFormat")); + CPPUNIT_ASSERT_EQUAL(OUString("Emphasis"), listAutoFormat["CharStyleName"].get()); + CPPUNIT_ASSERT(!listAutoFormat["CharHeight"].hasValue()); + CPPUNIT_ASSERT(!listAutoFormat["CharPosture"].hasValue()); + } + { + uno::Reference xParagraph(getParagraph(4)); + CPPUNIT_ASSERT_EQUAL(OUString("Char style text"), xParagraph->getString()); + uno::Reference xProps(xParagraph, uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("List Paragraph"), + getProperty(xProps, "ParaStyleName")); + uno::Reference xRun(getRun(xParagraph, 1)); + CPPUNIT_ASSERT_EQUAL(OUString("Emphasis"), getProperty(xRun, "CharStyleName")); + CPPUNIT_ASSERT_EQUAL(16.f, getProperty(xRun, "CharHeight")); + CPPUNIT_ASSERT_EQUAL(awt::FontSlant_ITALIC, + getProperty(xRun, "CharPosture")); + CPPUNIT_ASSERT(!xProps->getPropertyValue("ListAutoFormat").hasValue()); + } + + { + uno::Reference xParagraph(getParagraph(5)); + CPPUNIT_ASSERT_EQUAL(OUString("Para style"), xParagraph->getString()); + uno::Reference xProps(xParagraph, uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("List Paragraph E"), + getProperty(xProps, "ParaStyleName")); + uno::Reference xRun(getRun(xParagraph, 1)); + CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty(xRun, "CharStyleName")); + CPPUNIT_ASSERT_EQUAL(16.f, getProperty(xRun, "CharHeight")); + CPPUNIT_ASSERT_EQUAL(awt::FontSlant_ITALIC, + getProperty(xRun, "CharPosture")); + CPPUNIT_ASSERT(!xProps->getPropertyValue("ListAutoFormat").hasValue()); + } + { + uno::Reference xParagraph(getParagraph(6)); + CPPUNIT_ASSERT_EQUAL(OUString("Para style + Char style mark"), xParagraph->getString()); + uno::Reference xProps(xParagraph, uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("List Paragraph E"), + getProperty(xProps, "ParaStyleName")); + uno::Reference xRun(getRun(xParagraph, 1)); + CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty(xRun, "CharStyleName")); + CPPUNIT_ASSERT_EQUAL(16.f, getProperty(xRun, "CharHeight")); + CPPUNIT_ASSERT_EQUAL(awt::FontSlant_ITALIC, + getProperty(xRun, "CharPosture")); + comphelper::SequenceAsHashMap listAutoFormat(xProps->getPropertyValue("ListAutoFormat")); + CPPUNIT_ASSERT_EQUAL(OUString("Emphasis"), listAutoFormat["CharStyleName"].get()); + CPPUNIT_ASSERT(!listAutoFormat["CharHeight"].hasValue()); + // bug was that here the toggle property was not overwritten + CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE, + listAutoFormat["CharPosture"].get()); + } + { + uno::Reference xParagraph(getParagraph(7)); + CPPUNIT_ASSERT_EQUAL(OUString("Para style + Char style mark and text"), + xParagraph->getString()); + uno::Reference xProps(xParagraph, uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("List Paragraph E"), + getProperty(xProps, "ParaStyleName")); + uno::Reference xRun(getRun(xParagraph, 1)); + CPPUNIT_ASSERT_EQUAL(OUString("Emphasis"), getProperty(xRun, "CharStyleName")); + CPPUNIT_ASSERT_EQUAL(16.f, getProperty(xRun, "CharHeight")); + CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE, getProperty(xRun, "CharPosture")); + comphelper::SequenceAsHashMap listAutoFormat(xProps->getPropertyValue("ListAutoFormat")); + CPPUNIT_ASSERT_EQUAL(OUString("Emphasis"), listAutoFormat["CharStyleName"].get()); + CPPUNIT_ASSERT(!listAutoFormat["CharHeight"].hasValue()); + // bug was that here the toggle property was not overwritten + CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE, + listAutoFormat["CharPosture"].get()); + } + { + uno::Reference xParagraph(getParagraph(8)); + CPPUNIT_ASSERT_EQUAL(OUString("Para style + Char style text"), xParagraph->getString()); + uno::Reference xProps(xParagraph, uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("List Paragraph E"), + getProperty(xProps, "ParaStyleName")); + uno::Reference xRun(getRun(xParagraph, 1)); + CPPUNIT_ASSERT_EQUAL(OUString("Emphasis"), getProperty(xRun, "CharStyleName")); + CPPUNIT_ASSERT_EQUAL(16.f, getProperty(xRun, "CharHeight")); + CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE, getProperty(xRun, "CharPosture")); + CPPUNIT_ASSERT(!xProps->getPropertyValue("ListAutoFormat").hasValue()); + } + + { + uno::Reference xParagraph(getParagraph(9)); + CPPUNIT_ASSERT_EQUAL(OUString("No style + direct mark"), xParagraph->getString()); + uno::Reference xProps(xParagraph, uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("List Paragraph"), + getProperty(xProps, "ParaStyleName")); + uno::Reference xRun(getRun(xParagraph, 1)); + CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty(xRun, "CharStyleName")); + CPPUNIT_ASSERT_EQUAL(11.f, getProperty(xRun, "CharHeight")); + CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE, getProperty(xRun, "CharPosture")); + comphelper::SequenceAsHashMap listAutoFormat(xProps->getPropertyValue("ListAutoFormat")); + CPPUNIT_ASSERT(!listAutoFormat["CharStyleName"].hasValue()); + CPPUNIT_ASSERT_EQUAL(16.f, listAutoFormat["CharHeight"].get()); + CPPUNIT_ASSERT_EQUAL(awt::FontSlant_ITALIC, + listAutoFormat["CharPosture"].get()); + } + { + uno::Reference xParagraph(getParagraph(10)); + CPPUNIT_ASSERT_EQUAL(OUString("Char style + direct mark"), xParagraph->getString()); + uno::Reference xProps(xParagraph, uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("List Paragraph"), + getProperty(xProps, "ParaStyleName")); + uno::Reference xRun(getRun(xParagraph, 1)); + CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty(xRun, "CharStyleName")); + CPPUNIT_ASSERT_EQUAL(11.f, getProperty(xRun, "CharHeight")); + CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE, getProperty(xRun, "CharPosture")); + comphelper::SequenceAsHashMap listAutoFormat(xProps->getPropertyValue("ListAutoFormat")); + CPPUNIT_ASSERT_EQUAL(OUString("Emphasis"), listAutoFormat["CharStyleName"].get()); + CPPUNIT_ASSERT_EQUAL(16.f, listAutoFormat["CharHeight"].get()); + CPPUNIT_ASSERT_EQUAL(awt::FontSlant_ITALIC, + listAutoFormat["CharPosture"].get()); + } + { + uno::Reference xParagraph(getParagraph(11)); + CPPUNIT_ASSERT_EQUAL(OUString("Char style + direct mark and text"), + xParagraph->getString()); + uno::Reference xProps(xParagraph, uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("List Paragraph"), + getProperty(xProps, "ParaStyleName")); + uno::Reference xRun(getRun(xParagraph, 1)); + CPPUNIT_ASSERT_EQUAL(OUString("Emphasis"), getProperty(xRun, "CharStyleName")); + CPPUNIT_ASSERT_EQUAL(16.f, getProperty(xRun, "CharHeight")); + CPPUNIT_ASSERT_EQUAL(awt::FontSlant_ITALIC, + getProperty(xRun, "CharPosture")); + comphelper::SequenceAsHashMap listAutoFormat(xProps->getPropertyValue("ListAutoFormat")); + CPPUNIT_ASSERT_EQUAL(OUString("Emphasis"), listAutoFormat["CharStyleName"].get()); + CPPUNIT_ASSERT_EQUAL(16.f, listAutoFormat["CharHeight"].get()); + CPPUNIT_ASSERT_EQUAL(awt::FontSlant_ITALIC, + listAutoFormat["CharPosture"].get()); + } + { + uno::Reference xParagraph(getParagraph(12)); + CPPUNIT_ASSERT_EQUAL(OUString("Char style + direct text"), xParagraph->getString()); + uno::Reference xProps(xParagraph, uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("List Paragraph"), + getProperty(xProps, "ParaStyleName")); + uno::Reference xRun(getRun(xParagraph, 1)); + CPPUNIT_ASSERT_EQUAL(OUString("Emphasis"), getProperty(xRun, "CharStyleName")); + CPPUNIT_ASSERT_EQUAL(16.f, getProperty(xRun, "CharHeight")); + CPPUNIT_ASSERT_EQUAL(awt::FontSlant_ITALIC, + getProperty(xRun, "CharPosture")); + CPPUNIT_ASSERT(!xProps->getPropertyValue("ListAutoFormat").hasValue()); + } + + { + uno::Reference xParagraph(getParagraph(13)); + CPPUNIT_ASSERT_EQUAL(OUString("Para style + direct mark"), xParagraph->getString()); + uno::Reference xProps(xParagraph, uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("List Paragraph E"), + getProperty(xProps, "ParaStyleName")); + uno::Reference xRun(getRun(xParagraph, 1)); + CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty(xRun, "CharStyleName")); + CPPUNIT_ASSERT_EQUAL(16.f, getProperty(xRun, "CharHeight")); + CPPUNIT_ASSERT_EQUAL(awt::FontSlant_ITALIC, + getProperty(xRun, "CharPosture")); + comphelper::SequenceAsHashMap listAutoFormat(xProps->getPropertyValue("ListAutoFormat")); + CPPUNIT_ASSERT(!listAutoFormat["CharStyleName"].hasValue()); + CPPUNIT_ASSERT_EQUAL(16.f, listAutoFormat["CharHeight"].get()); + CPPUNIT_ASSERT_EQUAL(awt::FontSlant_ITALIC, + listAutoFormat["CharPosture"].get()); + } + { + uno::Reference xParagraph(getParagraph(14)); + CPPUNIT_ASSERT_EQUAL(OUString("Para style + Char style + direct mark"), + xParagraph->getString()); + uno::Reference xProps(xParagraph, uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("List Paragraph E"), + getProperty(xProps, "ParaStyleName")); + uno::Reference xRun(getRun(xParagraph, 1)); + CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty(xRun, "CharStyleName")); + CPPUNIT_ASSERT_EQUAL(16.f, getProperty(xRun, "CharHeight")); + CPPUNIT_ASSERT_EQUAL(awt::FontSlant_ITALIC, + getProperty(xRun, "CharPosture")); + comphelper::SequenceAsHashMap listAutoFormat(xProps->getPropertyValue("ListAutoFormat")); + CPPUNIT_ASSERT_EQUAL(OUString("Emphasis"), listAutoFormat["CharStyleName"].get()); + CPPUNIT_ASSERT_EQUAL(16.f, listAutoFormat["CharHeight"].get()); + CPPUNIT_ASSERT_EQUAL(awt::FontSlant_ITALIC, + listAutoFormat["CharPosture"].get()); + } + { + uno::Reference xParagraph(getParagraph(15)); + CPPUNIT_ASSERT_EQUAL(OUString("Para style + Char style + direct mark and text"), + xParagraph->getString()); + uno::Reference xProps(xParagraph, uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("List Paragraph E"), + getProperty(xProps, "ParaStyleName")); + uno::Reference xRun(getRun(xParagraph, 1)); + CPPUNIT_ASSERT_EQUAL(OUString("Emphasis"), getProperty(xRun, "CharStyleName")); + CPPUNIT_ASSERT_EQUAL(16.f, getProperty(xRun, "CharHeight")); + CPPUNIT_ASSERT_EQUAL(awt::FontSlant_ITALIC, + getProperty(xRun, "CharPosture")); + comphelper::SequenceAsHashMap listAutoFormat(xProps->getPropertyValue("ListAutoFormat")); + CPPUNIT_ASSERT_EQUAL(OUString("Emphasis"), listAutoFormat["CharStyleName"].get()); + CPPUNIT_ASSERT_EQUAL(16.f, listAutoFormat["CharHeight"].get()); + CPPUNIT_ASSERT_EQUAL(awt::FontSlant_ITALIC, + listAutoFormat["CharPosture"].get()); + } + { + uno::Reference xParagraph(getParagraph(16)); + CPPUNIT_ASSERT_EQUAL(OUString("Para style + Char style + direct text"), + xParagraph->getString()); + uno::Reference xProps(xParagraph, uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("List Paragraph E"), + getProperty(xProps, "ParaStyleName")); + uno::Reference xRun(getRun(xParagraph, 1)); + CPPUNIT_ASSERT_EQUAL(OUString("Emphasis"), getProperty(xRun, "CharStyleName")); + CPPUNIT_ASSERT_EQUAL(16.f, getProperty(xRun, "CharHeight")); + CPPUNIT_ASSERT_EQUAL(awt::FontSlant_ITALIC, + getProperty(xRun, "CharPosture")); + CPPUNIT_ASSERT(!xProps->getPropertyValue("ListAutoFormat").hasValue()); + } +} + DECLARE_OOXMLEXPORT_TEST(testTdf153909_followTextFlow, "tdf153909_followTextFlow.docx") { // Although MSO's UI reports "layoutInCell" for the rectangle, it isn't specified or honored -- cgit v1.2.3