sw/qa/extras/ooxmlimport/data/SimpleFirst.docx          |binary
 sw/qa/extras/ooxmlimport/data/SimpleFirst.odt           |binary
 sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.docx |binary
 sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.odt  |binary
 sw/qa/extras/ooxmlimport/data/SimpleLeftRight.docx      |binary
 sw/qa/extras/ooxmlimport/data/SimpleLeftRight.odt       |binary
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx               |  214 ++++++++++++++++
 7 files changed, 214 insertions(+)

New commits:
commit b82a2a6b7694d07cb12b46f70312e142a107631e
Author:     Tomaž Vajngerl <[email protected]>
AuthorDate: Wed Oct 11 22:46:03 2023 +0900
Commit:     Miklos Vajna <[email protected]>
CommitDate: Thu Nov 30 10:58:42 2023 +0100

    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 <[email protected]>
    (cherry picked from commit 955ca0eba5c9ec22fbae0fc3e6220914ec3d69be)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160134
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>

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
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/SimpleFirst.docx 
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
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/SimpleFirst.odt 
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
Binary files /dev/null and 
b/sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.docx 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
Binary files /dev/null and 
b/sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.odt 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
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/SimpleLeftRight.docx 
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
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/SimpleLeftRight.odt 
differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
index dfda91089b40..5c050982a0d6 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")
     {
@@ -1197,6 +1201,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();

Reply via email to