summaryrefslogtreecommitdiff
path: root/sw/qa/extras/ooxmlimport
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2023-10-11 22:46:03 +0900
committerTomaž Vajngerl <quikee@gmail.com>2023-10-12 06:44:26 +0200
commit955ca0eba5c9ec22fbae0fc3e6220914ec3d69be (patch)
tree286e813c74377863a0c09d7d5ee7f994a3bb0509 /sw/qa/extras/ooxmlimport
parent4fd6b125751897923428523336a768310a58b36e (diff)
sw: prepare tests cases for first, left, right headers and variants
This prepares the test case for first, left, right headers, only first and non-first headers, only left and right (no first) headers and make them run for ODF, where they should work as expected. In a follow up commit, the OOXML implementation should be fixed so that the same tests pass for OOXML documents. Change-Id: I1e7f610324c14dd9eb285ff9d46829610de5b1b3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157838 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sw/qa/extras/ooxmlimport')
-rw-r--r--sw/qa/extras/ooxmlimport/data/SimpleFirst.docxbin0 -> 5543 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/data/SimpleFirst.odtbin0 -> 9468 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.docxbin0 -> 6820 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.odtbin0 -> 10118 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/data/SimpleLeftRight.docxbin0 -> 5531 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/data/SimpleLeftRight.odtbin0 -> 9601 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport2.cxx214
7 files changed, 214 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/SimpleFirst.docx b/sw/qa/extras/ooxmlimport/data/SimpleFirst.docx
new file mode 100644
index 000000000000..1641a2d084ed
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/SimpleFirst.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/data/SimpleFirst.odt b/sw/qa/extras/ooxmlimport/data/SimpleFirst.odt
new file mode 100644
index 000000000000..fc165e966f85
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/SimpleFirst.odt
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.docx b/sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.docx
new file mode 100644
index 000000000000..2b530a5e324f
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.odt b/sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.odt
new file mode 100644
index 000000000000..d5035ac8f581
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.odt
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/data/SimpleLeftRight.docx b/sw/qa/extras/ooxmlimport/data/SimpleLeftRight.docx
new file mode 100644
index 000000000000..80dbda0420d7
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/SimpleLeftRight.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/data/SimpleLeftRight.odt b/sw/qa/extras/ooxmlimport/data/SimpleLeftRight.odt
new file mode 100644
index 000000000000..61302944da30
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/SimpleLeftRight.odt
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
index 76210cd2ef20..6b4054c4e38f 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
@@ -48,6 +48,10 @@
class Test : public SwModelTestBase
{
public:
+ void checkFirstLeftRightHeaderPageStyles();
+ void checkFirstRestHeaderPageStyles();
+ void checkLeftRightHeaderPageStyles();
+
Test()
: SwModelTestBase("/sw/qa/extras/ooxmlimport/data/", "Office Open XML Text")
{
@@ -1194,6 +1198,216 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf141969)
CPPUNIT_ASSERT_EQUAL(8.0f, getProperty<float>(xRun, "CharHeight"));
}
+void Test::checkFirstLeftRightHeaderPageStyles()
+{
+ // Page 1
+ {
+ OUString pageStyle;
+ uno::Reference<beans::XPropertySet> xPropertySet(getParagraphOrTable(1), uno::UNO_QUERY);
+
+ uno::Reference<text::XTextRange> xTextRange(xPropertySet, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("Para 1"), xTextRange->getString());
+
+ xPropertySet->getPropertyValue("PageStyleName") >>= pageStyle;
+ CPPUNIT_ASSERT_EQUAL(OUString("Standard"), pageStyle);
+ }
+
+ // Page 2
+ {
+ OUString pageStyle;
+ uno::Reference<beans::XPropertySet> xPropertySet(getParagraphOrTable(2), uno::UNO_QUERY);
+
+ uno::Reference<text::XTextRange> xTextRange(xPropertySet, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("Para 2"), xTextRange->getString());
+
+ xPropertySet->getPropertyValue("PageStyleName") >>= pageStyle;
+ CPPUNIT_ASSERT_EQUAL(OUString("Standard"), pageStyle);
+ }
+
+ // Page 3
+ {
+ OUString pageStyle;
+ uno::Reference<beans::XPropertySet> xPropertySet(getParagraphOrTable(3), uno::UNO_QUERY);
+
+ uno::Reference<text::XTextRange> xTextRange(xPropertySet, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("Para 3"), xTextRange->getString());
+
+ xPropertySet->getPropertyValue("PageStyleName") >>= pageStyle;
+ CPPUNIT_ASSERT_EQUAL(OUString("Standard"), pageStyle);
+ }
+}
+
+void Test::checkFirstRestHeaderPageStyles()
+{
+ // Page 1
+ {
+ OUString pageStyle;
+ uno::Reference<beans::XPropertySet> xPropertySet(getParagraphOrTable(1), uno::UNO_QUERY);
+
+ uno::Reference<text::XTextRange> xTextRange(xPropertySet, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("P1"), xTextRange->getString());
+
+ xPropertySet->getPropertyValue("PageStyleName") >>= pageStyle;
+ CPPUNIT_ASSERT_EQUAL(OUString("Standard"), pageStyle);
+ }
+
+ // Page 2
+ {
+ OUString pageStyle;
+ uno::Reference<beans::XPropertySet> xPropertySet(getParagraphOrTable(2), uno::UNO_QUERY);
+
+ uno::Reference<text::XTextRange> xTextRange(xPropertySet, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("P2"), xTextRange->getString());
+
+ xPropertySet->getPropertyValue("PageStyleName") >>= pageStyle;
+ CPPUNIT_ASSERT_EQUAL(OUString("Standard"), pageStyle);
+ }
+
+ // Page 3
+ {
+ OUString pageStyle;
+ uno::Reference<beans::XPropertySet> xPropertySet(getParagraphOrTable(3), uno::UNO_QUERY);
+
+ uno::Reference<text::XTextRange> xTextRange(xPropertySet, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("P3"), xTextRange->getString());
+
+ xPropertySet->getPropertyValue("PageStyleName") >>= pageStyle;
+ CPPUNIT_ASSERT_EQUAL(OUString("Standard"), pageStyle);
+ }
+
+ // Check Default Style
+ {
+ uno::Reference<beans::XPropertySet> xPageStyle(
+ getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY);
+
+ bool bHeader = getProperty<bool>(xPageStyle, "HeaderIsOn");
+ CPPUNIT_ASSERT_EQUAL(true, bHeader);
+
+ bool bHeaderIsShared = getProperty<bool>(xPageStyle, "HeaderIsShared");
+ CPPUNIT_ASSERT_EQUAL(true, bHeaderIsShared);
+
+ bool bFirstIsShared = getProperty<bool>(xPageStyle, "FirstIsShared");
+ CPPUNIT_ASSERT_EQUAL(false, bFirstIsShared);
+
+ auto xHeaderTextLeft
+ = getProperty<uno::Reference<text::XText>>(xPageStyle, "HeaderTextFirst");
+ //CPPUNIT_ASSERT_EQUAL(OUString("FIRST"), xHeaderTextLeft->getString());
+
+ auto xHeaderTextRight = getProperty<uno::Reference<text::XText>>(xPageStyle, "HeaderText");
+ CPPUNIT_ASSERT_EQUAL(OUString("NON-FIRST"), xHeaderTextRight->getString());
+ }
+}
+
+void Test::checkLeftRightHeaderPageStyles()
+{
+ // Page 1
+ {
+ OUString aPageStyleName;
+ uno::Reference<beans::XPropertySet> xPropertySet(getParagraphOrTable(1), uno::UNO_QUERY);
+
+ uno::Reference<text::XTextRange> xTextRange(xPropertySet, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("P1"), xTextRange->getString());
+
+ xPropertySet->getPropertyValue("PageStyleName") >>= aPageStyleName;
+ CPPUNIT_ASSERT_EQUAL(OUString("Standard"), aPageStyleName);
+ }
+
+ // Page 2
+ {
+ OUString pageStyle;
+ uno::Reference<beans::XPropertySet> xPropertySet(getParagraphOrTable(2), uno::UNO_QUERY);
+
+ uno::Reference<text::XTextRange> xTextRange(xPropertySet, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("P2"), xTextRange->getString());
+
+ xPropertySet->getPropertyValue("PageStyleName") >>= pageStyle;
+ CPPUNIT_ASSERT_EQUAL(OUString("Standard"), pageStyle);
+ }
+
+ // Page 3
+ {
+ OUString pageStyle;
+ uno::Reference<beans::XPropertySet> xPropertySet(getParagraphOrTable(3), uno::UNO_QUERY);
+
+ uno::Reference<text::XTextRange> xTextRange(xPropertySet, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("P3"), xTextRange->getString());
+
+ xPropertySet->getPropertyValue("PageStyleName") >>= pageStyle;
+ CPPUNIT_ASSERT_EQUAL(OUString("Standard"), pageStyle);
+ }
+
+ // Page 3
+ {
+ OUString pageStyle;
+ uno::Reference<beans::XPropertySet> xPropertySet(getParagraphOrTable(4), uno::UNO_QUERY);
+
+ uno::Reference<text::XTextRange> xTextRange(xPropertySet, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("P4"), xTextRange->getString());
+
+ xPropertySet->getPropertyValue("PageStyleName") >>= pageStyle;
+ CPPUNIT_ASSERT_EQUAL(OUString("Standard"), pageStyle);
+ }
+
+ // Check Default Style
+ {
+ uno::Reference<beans::XPropertySet> xPageStyle(
+ getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY);
+
+ bool bHeader = getProperty<bool>(xPageStyle, "HeaderIsOn");
+ CPPUNIT_ASSERT_EQUAL(true, bHeader);
+
+ bool bHeaderIsShared = getProperty<bool>(xPageStyle, "HeaderIsShared");
+ CPPUNIT_ASSERT_EQUAL(false, bHeaderIsShared);
+
+ bool bFirstIsShared = getProperty<bool>(xPageStyle, "FirstIsShared");
+ CPPUNIT_ASSERT_EQUAL(true, bFirstIsShared);
+
+ auto xHeaderTextLeft
+ = getProperty<uno::Reference<text::XText>>(xPageStyle, "HeaderTextLeft");
+ CPPUNIT_ASSERT_EQUAL(OUString("LEFT"), xHeaderTextLeft->getString());
+
+ auto xHeaderTextRight
+ = getProperty<uno::Reference<text::XText>>(xPageStyle, "HeaderTextRight");
+ CPPUNIT_ASSERT_EQUAL(OUString("RIGHT"), xHeaderTextRight->getString());
+ }
+}
+
+CPPUNIT_TEST_FIXTURE(Test, testFirstLeftRightHeaderPageStyles_ODF)
+{
+ createSwDoc("SimpleFirstLeftRight.odt");
+ checkFirstLeftRightHeaderPageStyles();
+}
+
+CPPUNIT_TEST_FIXTURE(Test, testFirstLeftRightHeaderPageStyles_OOXML)
+{
+ //createSwDoc("SimpleFirstLeftRight.docx");
+ //checkFirstLeftRightHeaderPageStyles();
+}
+
+CPPUNIT_TEST_FIXTURE(Test, testFirstRestHeaderPageStyles_ODF)
+{
+ createSwDoc("SimpleFirst.odt");
+ checkFirstRestHeaderPageStyles();
+}
+
+CPPUNIT_TEST_FIXTURE(Test, testFirstRestHeaderPageStyles_OOXML)
+{
+ //createSwDoc("SimpleFirst.docx");
+ //checkFirstRestHeaderPageStyles();
+}
+
+CPPUNIT_TEST_FIXTURE(Test, testLeftRightHeaderPageStyles_ODF)
+{
+ createSwDoc("SimpleLeftRight.odt");
+ checkLeftRightHeaderPageStyles();
+}
+
+CPPUNIT_TEST_FIXTURE(Test, testLeftRightHeaderPageStyles_OOXML)
+{
+ //createSwDoc("SimpleLeftRight.docx");
+ //checkLeftRightHeaderPageStyles();
+}
+
// tests should only be added to ooxmlIMPORT *if* they fail round-tripping in ooxmlEXPORT
CPPUNIT_PLUGIN_IMPLEMENT();