[Libreoffice-commits] core.git: sw/qa sw/source

Miklos Vajna vmiklos at collabora.co.uk
Sun May 28 12:20:55 UTC 2017


 sw/qa/extras/ooxmlexport/data/tdf107837.odt  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx    |    8 ++++++++
 sw/source/filter/ww8/docxattributeoutput.cxx |   18 +++++++++++++++++-
 sw/source/filter/ww8/wrtww8.cxx              |    5 ++++-
 4 files changed, 29 insertions(+), 2 deletions(-)

New commits:
commit 2d13a00bfa17dd610979b5d89b4f159f2e548d3d
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Sun May 28 11:22:44 2017 +0200

    tdf#107837 DOCX export: fix balanced multi-col section at doc end
    
    For one, commit f6eb92406bd366c557bc07810649e7ab3d1db614 (fdo#77812
    :FILESAVE :DOCX : Extra Section Break gets added in file, 2014-04-29)
    made the mistake of always preventing an empty section at the end of the
    document, while having that is a feature for the case of balanced Writer
    sections with multiple columns. Word can't have balanced columns at the
    end of the document otherwise.
    
    For another, commit b6e62dc0dc2b284c825f1182a67bb2f9259a30ce (tdf#106492
    DOCX export: fix duplicated section break at doc end, 2017-03-21) made
    the same mistake when it wanted to eliminate an unexpected additional
    section break.
    
    Fix these by restricting these changes to the case when we don't hit the
    "multiple columns + they are balanced" situation.
    
    Change-Id: I742097eb813da6d94a9669328c6a049da7a491ee
    Reviewed-on: https://gerrit.libreoffice.org/38104
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf107837.odt b/sw/qa/extras/ooxmlexport/data/tdf107837.odt
new file mode 100644
index 000000000000..a31a70c523ca
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf107837.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index d2f4aad276aa..6ef5dd2db10b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -573,6 +573,14 @@ DECLARE_OOXMLEXPORT_TEST(testTdf107889, "tdf107889.docx")
 }
 #endif
 
+DECLARE_OOXMLEXPORT_TEST(testTdf107837, "tdf107837.odt")
+{
+    uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xTextSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY);
+    // This was true, a balanced section from ODF turned into a non-balanced one after OOXML roundtrip.
+    CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xTextSections->getByIndex(0), "DontBalanceTextColumns"));
+}
+
 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 4c44fce688e4..eef2c8a2e59e 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -117,6 +117,7 @@
 #include <fmtautofmt.hxx>
 #include <docsh.hxx>
 #include <docary.hxx>
+#include <fmtclbl.hxx>
 #include <IDocumentSettingAccess.hxx>
 #include <IDocumentStylePoolAccess.hxx>
 #include <IDocumentRedlineAccess.hxx>
@@ -5495,9 +5496,24 @@ void DocxAttributeOutput::SectionBreak( sal_uInt8 nC, const WW8_SepInfo* pSectio
                 SwNodeIndex aCurrentNode(m_rExport.m_pCurPam->GetNode());
                 SwNodeIndex aLastNode(m_rExport.m_pDoc->GetNodes().GetEndOfContent(), -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)
+                {
+                    if (pFormat != reinterpret_cast<SwSectionFormat*>(sal_IntPtr(-1)))
+                    {
+                        nColumns = pFormat->GetCol().GetNumCols();
+                        const SwFormatNoBalancedColumns& rNoBalanced = pFormat->GetBalancedColumns();
+                        bBalance = !rNoBalanced.GetValue();
+                    }
+                }
+
                 // don't add section properties if this will be the first
                 // paragraph in the document
-                if ( !m_bParagraphOpened && !m_bIsFirstParagraph && aCurrentNode != aLastNode)
+                if ( !m_bParagraphOpened && !m_bIsFirstParagraph && (aCurrentNode != aLastNode || (nColumns > 1 && bBalance)))
                 {
                     // Create a dummy paragraph if needed
                     m_pSerializer->startElementNS( XML_w, XML_p, FSEND );
diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index 2d6320387f09..8315e3d7af62 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -118,6 +118,7 @@
 #include "numrule.hxx"
 #include "fmtclds.hxx"
 #include "rdfhelper.hxx"
+#include "fmtclbl.hxx"
 
 using namespace css;
 using namespace sw::util;
@@ -2709,7 +2710,9 @@ void MSWordExportBase::WriteText()
                     const SwFrameFormat* pPgFormat = rSect.GetFormat();
                     const SwFormatCol& rCol = pPgFormat->GetCol();
                     sal_uInt16 nColumnCount = rCol.GetNumCols();
-                    if(nColumnCount > 1)
+                    const SwFormatNoBalancedColumns& rNoBalanced = pPgFormat->GetBalancedColumns();
+                    // Prevent the additional section break only for non-balanced columns.
+                    if (nColumnCount > 1 && rNoBalanced.GetValue())
                     {
                         bNeedExportBreakHere = false;
                     }


More information about the Libreoffice-commits mailing list