sw/qa/extras/ooxmlexport/data/first-header-footerB.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx               |   18 +++++++++++++++++
 sw/source/filter/ww8/wrtw8sty.cxx                      |   10 +++++----
 3 files changed, 24 insertions(+), 4 deletions(-)

New commits:
commit f5c618f4e5d3ef2a33301d5f20035bb8bc213a38
Author:     Justin Luth <justin_l...@sil.org>
AuthorDate: Tue Oct 26 12:33:32 2021 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Tue Nov 2 09:58:02 2021 +0100

    tdf#145317 sw ms export: handle First Page with a first header
    
    partial revert of LO 5.2.4's tdf#101814.
    
    Just because the page style has a first doesn't mean that it
    should not check if it is also a first-follow that could be
    merged into a single ww8section.
    
    In this case, the follow page-style's H/F definitions were
    lost, because only the First Page style was considered.
    
    No existing unit tests matched these conditions.
    
    I did test bug 101814's CAFCA - Modèle feuille A4 - v2015-2.odt
    and it still shows the same H/F.
    
    Change-Id: I7389f8d85ba24a3f9c6487efe4acd27d96b0869c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124213
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <justin_l...@sil.org>
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sw/qa/extras/ooxmlexport/data/first-header-footerB.odt 
b/sw/qa/extras/ooxmlexport/data/first-header-footerB.odt
new file mode 100644
index 000000000000..0ae1992ed7e1
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/first-header-footerB.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index ce5092e01585..9f8ba44e6a2b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -226,6 +226,24 @@ DECLARE_OOXMLEXPORT_TEST(testFirstHeaderFooter, 
"first-header-footer.docx")
     CPPUNIT_ASSERT_EQUAL(OUString("Even page footer 2"),  
parseDump("/root/page[6]/footer/txt/text()"));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testFirstHeaderFooterB, "first-header-footerB.odt")
+{
+    CPPUNIT_ASSERT_EQUAL( 6, getPages() );
+
+    CPPUNIT_ASSERT_EQUAL(OUString("First page header"),  
parseDump("/root/page[1]/header/txt/text()"));
+    CPPUNIT_ASSERT_EQUAL(OUString("First page footer"),  
parseDump("/root/page[1]/footer/txt/text()"));
+    CPPUNIT_ASSERT_EQUAL(OUString("Even page header"),   
parseDump("/root/page[2]/header/txt/text()"));
+    CPPUNIT_ASSERT_EQUAL(OUString("Even page footer"),   
parseDump("/root/page[2]/footer/txt/text()"));
+    CPPUNIT_ASSERT_EQUAL(OUString("Odd page header"),  
parseDump("/root/page[3]/header/txt/text()"));
+    CPPUNIT_ASSERT_EQUAL(OUString("Odd page footer"),  
parseDump("/root/page[3]/footer/txt/text()"));
+    CPPUNIT_ASSERT_EQUAL(OUString("First page header2"), 
parseDump("/root/page[4]/header/txt/text()"));
+    CPPUNIT_ASSERT_EQUAL(OUString("First page footer 2"), 
parseDump("/root/page[4]/footer/txt/text()"));
+    CPPUNIT_ASSERT_EQUAL(OUString("Odd page header 2"), 
parseDump("/root/page[5]/header/txt/text()"));
+    CPPUNIT_ASSERT_EQUAL(OUString("Odd page footer 2"), 
parseDump("/root/page[5]/footer/txt/text()"));
+    CPPUNIT_ASSERT_EQUAL(OUString("Even page header 2"),  
parseDump("/root/page[6]/header/txt/text()"));
+    CPPUNIT_ASSERT_EQUAL(OUString("Even page footer 2"),  
parseDump("/root/page[6]/footer/txt/text()"));
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testFDO83044)
 {
     loadAndSave("fdo83044.docx");
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx 
b/sw/source/filter/ww8/wrtw8sty.cxx
index 9a5441d366aa..72c171bacdff 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -1736,9 +1736,7 @@ void MSWordExportBase::SectionProperties( const 
WW8_SepInfo& rSepInfo, WW8_PdAtt
         // it as title page.
         // With Left/Right changes it's different - we have to detect where
         // the change of pages is, but here it's too late for that!
-        // tdf#101814 if there is already an explicit first-page, no point
-        // in checking heuristics here.
-        if ( !titlePage && pPd->GetFollow() && pPd != pPd->GetFollow() &&
+        if ( pPd->GetFollow() && pPd != pPd->GetFollow() &&
              pPd->GetFollow()->GetFollow() == pPd->GetFollow() &&
              pPd->IsHeaderShared() && pPd->IsFooterShared() &&
              ( !rSepInfo.pPDNd || pPd->IsFollowNextPageOfNode( *rSepInfo.pPDNd 
) ) )
@@ -1747,7 +1745,11 @@ void MSWordExportBase::SectionProperties( const 
WW8_SepInfo& rSepInfo, WW8_PdAtt
             const SwFrameFormat& rFollowFormat = pFollow->GetMaster();
             if (sw::util::IsPlausableSingleWordSection(*pPdFirstPgFormat, 
rFollowFormat))
             {
-                if (rSepInfo.pPDNd)
+                if (titlePage)
+                {
+                    // Do nothing. First format is already set.
+                }
+                else if (rSepInfo.pPDNd)
                     pPdFirstPgFormat = pPd->GetPageFormatOfNode( 
*rSepInfo.pPDNd );
                 else
                     pPdFirstPgFormat = &pPd->GetMaster();

Reply via email to