[Libreoffice-commits] core.git: Branch 'libreoffice-6-0' - sw/qa writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Wed Feb 21 20:33:20 UTC 2018


 sw/qa/extras/ooxmlexport/data/tdf112694.docx      |binary
 sw/qa/extras/ooxmlexport/ooxmlexport11.cxx        |    8 ++++++++
 sw/qa/extras/ooxmlexport/ooxmlexport6.cxx         |    4 ++--
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   11 -----------
 writerfilter/source/dmapper/PropertyMap.cxx       |   10 ++++++++++
 5 files changed, 20 insertions(+), 13 deletions(-)

New commits:
commit 055aae14063773bdac9ea43b3207f1d7d6ca6b4c
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Feb 19 22:37:58 2018 +0100

    tdf#112694 DOCX import: handle <w:titlePg> when turning on follow style header
    
    Commit 17e51f427b3f0cec74ac8e0a1b3f51189006ae6f (DOCX import: first page
    header should always set default headers as well, 2014-11-21) turned on
    header/footer of follow page styles of first page styles when the first
    page style had the header/footer turned on, but failed to consider if
    <w:titlePg> is present or not. When it's not present, the first page
    header/footer should be ignored.
    
    An additional problem is that by the time
    DomainMapper_Impl::PushPageHeaderFooter() is called, <w:titlePg> is not
    parsed yet, so we can't act accordingly.
    
    Fix the problem by moving the check to
    SectionPropertyMap::PrepareHeaderFooterProperties(), which runs at the
    end of the section properties, where all required info is available,
    there we can just check for m_bTitlePage.
    
    This allows reverting the two changes to existing testcases in
    CppunitTest_sw_ooxmlexport6 from the original commit as a side-effect.
    
    (cherry picked from commit a16275a3647a2fba9913ed23e8329e45b02123b4)
    
    Change-Id: Ic628adab99a4b148fcfd66ca39d0cf81eb7dd9f1
    Reviewed-on: https://gerrit.libreoffice.org/50027
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf112694.docx b/sw/qa/extras/ooxmlexport/data/tdf112694.docx
new file mode 100644
index 000000000000..f629a388e3cb
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf112694.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index 91697a80f920..0fd64733e700 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -73,6 +73,14 @@ DECLARE_OOXMLEXPORT_TEST(testTdf82065_Ind_start_strict, "tdf82065_Ind_start_stri
     CPPUNIT_ASSERT_EQUAL_MESSAGE("IndentAt defined", true, bFoundIndentAt);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf112694, "tdf112694.docx")
+{
+    uno::Any aPageStyle = getStyles("PageStyles")->getByName("Standard");
+    // Header was on when header for file was for explicit first pages only
+    // (marked via <w:titlePg>).
+    CPPUNIT_ASSERT(!getProperty<bool>(aPageStyle, "HeaderIsOn"));
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf67207_MERGEFIELD, "mailmerge.docx")
 {
     uno::Reference<beans::XPropertySet> xTextField = getProperty< uno::Reference<beans::XPropertySet> >(getRun(getParagraph(1), 2), "TextField");
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
index 880d05aafbb6..dbed9fc22384 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
@@ -454,7 +454,7 @@ DECLARE_OOXMLEXPORT_TEST(testVMLData, "TestVMLData.docx")
 {
     // The problem was exporter was exporting vml data for shape in w:rPr element.
     // vml data should not come under w:rPr element.
-    xmlDocPtr pXmlDoc = parseExport("word/header2.xml");
+    xmlDocPtr pXmlDoc = parseExport("word/header1.xml");
     if (!pXmlDoc)
         return;
     CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:hdr/w:p/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:shape", "stroked").match("f"));
@@ -464,7 +464,7 @@ DECLARE_OOXMLEXPORT_TEST(testImageData, "image_data.docx")
 {
     // The problem was exporter was exporting v:imagedata data for shape in w:pict as v:fill w element.
 
-    xmlDocPtr pXmlDoc = parseExport("word/header2.xml");
+    xmlDocPtr pXmlDoc = parseExport("word/header1.xml");
     if (!pXmlDoc)
         return;
     CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:hdr/w:p/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:shape/v:imagedata", "detectmouseclick").match("t"));
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index de2a959f019d..3791a7c44295 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1660,17 +1660,6 @@ void DomainMapper_Impl::PushPageHeaderFooter(bool bHeader, SectionPropertyMap::P
                         getPropertyName(ePropIsOn),
                         uno::makeAny(true));
 
-                if (bFirst)
-                {
-                    OUString aFollowStyle = xPageStyle->getPropertyValue("FollowStyle").get<OUString>();
-                    if (GetPageStyles()->hasByName(aFollowStyle))
-                    {
-                        // This is a first page and has a follow style, then enable the header/footer there as well to be consistent.
-                        uno::Reference<beans::XPropertySet> xFollowStyle(GetPageStyles()->getByName(aFollowStyle), uno::UNO_QUERY);
-                        xFollowStyle->setPropertyValue(getPropertyName(ePropIsOn), uno::makeAny(true));
-                    }
-                }
-
                 // If the 'Different Even & Odd Pages' flag is turned on - do not ignore it
                 // Even if the 'Even' header/footer is blank - the flag should be imported (so it would look in LO like in Word)
                 if (!bFirst && GetSettingsTable()->GetEvenAndOddHeaders())
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index 84625c073d57..db2f20980bb3 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -901,6 +901,16 @@ void SectionPropertyMap::CopyLastHeaderFooter( bool bFirstPage, DomainMapper_Imp
 
 void SectionPropertyMap::PrepareHeaderFooterProperties( bool bFirstPage )
 {
+    if (bFirstPage && m_bTitlePage && m_aFollowPageStyle.is())
+    {
+        // This is a first page and has a follow style, then enable the
+        // header/footer there as well to be consistent.
+        if (HasHeader(/*bFirstPage=*/true))
+            m_aFollowPageStyle->setPropertyValue("HeaderIsOn", uno::makeAny(true));
+        if (HasFooter(/*bFirstPage=*/true))
+            m_aFollowPageStyle->setPropertyValue("FooterIsOn", uno::makeAny(true));
+    }
+
     sal_Int32 nTopMargin = m_nTopMargin;
     sal_Int32 nHeaderTop = m_nHeaderTop;
     if ( HasHeader( bFirstPage ) )


More information about the Libreoffice-commits mailing list