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

Miklos Vajna vmiklos at collabora.co.uk
Wed Jun 14 07:07:20 UTC 2017


 sw/qa/extras/ooxmlexport/data/tdf107618.doc  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx    |    7 ++++
 sw/source/filter/ww8/docxattributeoutput.cxx |   41 +++++++++++++++++++--------
 3 files changed, 37 insertions(+), 11 deletions(-)

New commits:
commit 378b97e8f071485ee1086b66f1ab94fedb8b8d49
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Jun 13 09:05:06 2017 +0200

    tdf#107618 DOCX export: fix missing header when doc ends with section
    
    See commit b6e62dc0dc2b284c825f1182a67bb2f9259a30ce (tdf#106492 DOCX
    export: fix duplicated section break at doc end, 2017-03-21) for the
    context, this is one more case where it's not OK to suppress the two
    section breaks at the end of a document, since the suppressed section
    break is the one that provides the headers / footers.
    
    (cherry picked from commit 2a73e7d88c19cab69733a4f6433d8576856285ac)
    
    Change-Id: I4abd7895436e4d2e08fd7b7ff4aabbac8d65f7fb
    Reviewed-on: https://gerrit.libreoffice.org/38742
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf107618.doc b/sw/qa/extras/ooxmlexport/data/tdf107618.doc
new file mode 100644
index 000000000000..8a6972f45b8e
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf107618.doc differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 38582f9f93f0..d63a6183c5ba 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -581,6 +581,13 @@ DECLARE_OOXMLEXPORT_TEST(testTdf107684, "tdf107684.odt")
         assertXPath(pXmlDoc, "//w:style[@w:styleId='Heading1']/w:pPr/w:outlineLvl", 1);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf107618, "tdf107618.doc")
+{
+    // This was false, header was lost on export.
+    uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xPageStyle, "HeaderIsOn"));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 89597ef3baf6..b42aa62f47db 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -118,6 +118,7 @@
 #include <docsh.hxx>
 #include <docary.hxx>
 #include <fmtclbl.hxx>
+#include <fmthdft.hxx>
 #include <IDocumentSettingAccess.hxx>
 #include <IDocumentStylePoolAccess.hxx>
 #include <IDocumentRedlineAccess.hxx>
@@ -5495,25 +5496,43 @@ void DocxAttributeOutput::SectionBreak( sal_uInt8 nC, const WW8_SepInfo* pSectio
                 // DocxExport::WriteMainText(), don't duplicate that here.
                 SwNodeIndex aCurrentNode(m_rExport.m_pCurPam->GetNode());
                 SwNodeIndex aLastNode(m_rExport.m_pDoc->GetNodes().GetEndOfContent(), -1);
+                bool bEmit = aCurrentNode != aLastNode;
 
-                // Need to still emit an empty section at the end of the
-                // document in case balanced columns are wanted, since the last
-                // section in Word is always balanced.
-                sal_uInt16 nColumns = 1;
-                bool bBalance = false;
-                if (const SwSectionFormat* pFormat = pSectionInfo->pSectionFormat)
+                if (!bEmit)
                 {
-                    if (pFormat != reinterpret_cast<SwSectionFormat*>(sal_IntPtr(-1)))
+                    // Need to still emit an empty section at the end of the
+                    // document in case balanced columns are wanted, since the last
+                    // section in Word is always balanced.
+                    sal_uInt16 nColumns = 1;
+                    bool bBalance = false;
+                    if (const SwSectionFormat* pFormat = pSectionInfo->pSectionFormat)
                     {
-                        nColumns = pFormat->GetCol().GetNumCols();
-                        const SwFormatNoBalancedColumns& rNoBalanced = pFormat->GetBalancedColumns();
-                        bBalance = !rNoBalanced.GetValue();
+                        if (pFormat != reinterpret_cast<SwSectionFormat*>(sal_IntPtr(-1)))
+                        {
+                            nColumns = pFormat->GetCol().GetNumCols();
+                            const SwFormatNoBalancedColumns& rNoBalanced = pFormat->GetBalancedColumns();
+                            bBalance = !rNoBalanced.GetValue();
+                        }
+                    }
+                    bEmit = (nColumns > 1 && bBalance);
+                }
+
+                if (!bEmit)
+                {
+                    // Also need to emit if the page desc contains a header or
+                    // footer, otherwise we go with the properties of the
+                    // section (and not the page style), which never has
+                    // headers/footers.
+                    if (const SwPageDesc* pPageDesc = pSectionInfo->pPageDesc)
+                    {
+                        const auto& rMaster = pPageDesc->GetMaster();
+                        bEmit = rMaster.GetHeader().IsActive() || rMaster.GetFooter().IsActive();
                     }
                 }
 
                 // don't add section properties if this will be the first
                 // paragraph in the document
-                if ( !m_bParagraphOpened && !m_bIsFirstParagraph && (aCurrentNode != aLastNode || (nColumns > 1 && bBalance)))
+                if ( !m_bParagraphOpened && !m_bIsFirstParagraph && bEmit )
                 {
                     // Create a dummy paragraph if needed
                     m_pSerializer->startElementNS( XML_w, XML_p, FSEND );


More information about the Libreoffice-commits mailing list