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

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Tue May 19 19:58:45 UTC 2020


 sw/qa/extras/ooxmlexport/ooxmlexport6.cxx    |    4 ++--
 sw/qa/extras/ooxmlimport/data/tdf127778.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx    |   12 ++++++++++++
 sw/source/filter/ww8/docxattributeoutput.cxx |   11 +++++++++++
 sw/source/filter/ww8/wrtw8sty.cxx            |   12 ++++++++++++
 sw/source/filter/ww8/wrtww8.hxx              |    1 +
 writerfilter/source/dmapper/PropertyMap.cxx  |    9 ---------
 7 files changed, 38 insertions(+), 11 deletions(-)

New commits:
commit a2b8ede5b45101c45291d1e1e96e7fa1ad47dd2b
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon May 11 21:08:35 2020 +0200
Commit:     Xisco Faulí <xiscofauli at libreoffice.org>
CommitDate: Tue May 19 21:58:12 2020 +0200

    tdf#127778 DOCX import: fix unexpected heading on non-first page ...
    
    ... when the first page has a heading
    
    Regression from commit 17e51f427b3f0cec74ac8e0a1b3f51189006ae6f (DOCX
    import: first page header should always set default headers as well,
    2014-11-21), the problem is around how to split a first + follow page
    style on import, and then do the opposite on export.
    
    This is described using a single section in OOXML, but Writer has 2 page
    styles for this (unlike in case of the DOC filter). This means the
    header margin has to be taken from one of these page styles. The above
    commit tweaked the import, so the follow page style has the wanted
    header margin, but this leads to incorrect layout.
    
    Fix the problem by tweaking the export instead: it has random access to
    the doc model, so it can take the header margin from the first page
    style if needed, and then the import side can be reverted, leading to
    correct layout.
    
    Also remove some leftover debug code in test/, which was added in commit
    5352d45dd4a04f8f02cf7f6ad4169126d3b3586a (convert AnimationImport to
    fast-parser APIs, 2020-02-18).
    
    (cherry picked from commit 51534ac2b9747975945acb6a1e1ba5cc6d73f5c2)
    
    Conflicts:
            sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
    
    Change-Id: I4bbf7271f3a437e8432399bd1e32e9d24190a501
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94193
    Tested-by: Jenkins
    Reviewed-by: Xisco Faulí <xiscofauli at libreoffice.org>

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
index a459e8a57f27..a8fe7ac73ea0 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
@@ -510,7 +510,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"));
@@ -520,7 +520,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/sw/qa/extras/ooxmlimport/data/tdf127778.docx b/sw/qa/extras/ooxmlimport/data/tdf127778.docx
new file mode 100644
index 000000000000..a706d575763f
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf127778.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
index 7688e1927acb..a14b97aec66a 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
@@ -271,6 +271,18 @@ DECLARE_OOXMLIMPORT_TEST(testTdf43017, "tdf43017.docx")
                                  getProperty<sal_Int32>(xText, "CharColor"));
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf127778)
+{
+    load(mpTestDocumentPath, "tdf127778.docx");
+    xmlDocPtr pLayout = parseLayoutDump();
+    // Without the accompanying fix in place, this test would have failed with:
+    // equality assertion failed
+    // - Expected: 0
+    // - Actual  : 1
+    // i.e. the 2nd page had an unexpected header.
+    assertXPath(pLayout, "//page[2]/header", 0);
+}
+
 // related tdf#43017
 DECLARE_OOXMLIMPORT_TEST(testTdf124754, "tdf124754.docx")
 {
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 432c7f919039..478179cf8d0a 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -8249,6 +8249,17 @@ void DocxAttributeOutput::FormatULSpace( const SvxULSpaceItem& rULSpace )
         sal_Int32 nHeader = 0;
         if ( aDistances.HasHeader() )
             nHeader = sal_Int32( aDistances.dyaHdrTop );
+        else if (m_rExport.m_pFirstPageFormat)
+        {
+            HdFtDistanceGlue aFirstPageDistances(m_rExport.m_pFirstPageFormat->GetAttrSet());
+            if (aFirstPageDistances.HasHeader())
+            {
+                // The follow page style has no header, but the first page style has. In Word terms,
+                // this means that the header margin of "the" section is coming from the first page
+                // style.
+                nHeader = sal_Int32(aFirstPageDistances.dyaHdrTop);
+            }
+        }
 
         // Page top
         m_pageMargins.nTop = aDistances.dyaTop;
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
index d04cfeb8e6f8..eb06b97195bb 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -1700,7 +1700,19 @@ void MSWordExportBase::SectionProperties( const WW8_SepInfo& rSepInfo, WW8_PdAtt
 
         m_pISet = &pPdFormat->GetAttrSet();
         if (!bOutputStyleItemSet)
+        {
+            if (titlePage)
+            {
+                m_pFirstPageFormat = pPdFirstPgFormat;
+            }
+
             AttrOutput().OutputStyleItemSet( pPdFormat->GetAttrSet(), false );
+
+            if (titlePage)
+            {
+                m_pFirstPageFormat = nullptr;
+            }
+        }
         AttrOutput().SectionPageBorders( pPdFormat, pPdFirstPgFormat );
         m_pISet = pOldI;
 
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index 45c444c1f0b3..3f64071e2120 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -458,6 +458,7 @@ public:
     OUString const m_aMainStg;
     std::vector<const SwTOXType*> m_aTOXArr;
     const SfxItemSet* m_pISet;    // for double attributes
+    const SwFrameFormat* m_pFirstPageFormat = nullptr;
     WW8_WrPct*  m_pPiece;         // Pointer to Piece-Table
     std::unique_ptr<SwNumRuleTable> m_pUsedNumTable;  // all used NumRules
     /// overriding numdef index -> (existing numdef index, abstractnumdef index)
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index fbc471415b4c..f0fc0229d7d6 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -928,15 +928,6 @@ void SectionPropertyMap::CopyLastHeaderFooter( bool bFirstPage, DomainMapper_Imp
 void SectionPropertyMap::PrepareHeaderFooterProperties( bool bFirstPage )
 {
     bool bCopyFirstToFollow = bFirstPage && m_bTitlePage && m_aFollowPageStyle.is();
-    if (bCopyFirstToFollow)
-    {
-        // 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;


More information about the Libreoffice-commits mailing list