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

Justin Luth justin_luth at sil.org
Tue Jul 12 19:19:51 UTC 2016


 sw/source/filter/ww8/docxattributeoutput.cxx |   16 +++++++++++++++-
 sw/source/filter/ww8/docxattributeoutput.hxx |    4 ++++
 2 files changed, 19 insertions(+), 1 deletion(-)

New commits:
commit 28ded9c98837d6b6eefff73f396353b61b6b4017
Author: Justin Luth <justin_luth at sil.org>
Date:   Mon Jul 11 18:07:32 2016 +0300

    tdf#99090 docx export page-break only inside a paragraph
    
    If a paragraph hadn't been started yet, a w:r was being written directly in
    the /document/body which caused MSWord to complain about a corrupt document.
    
    Reviewed-on: https://gerrit.libreoffice.org/26771
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Justin Luth <justin_luth at sil.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    (cherry picked from commit 07fb94655f4745eb4e80bf6e8d4cdd95371f23bb)
    
    Change-Id: Ie7f629869aab0f3d2405660a033c3f23bbd6baca
    Reviewed-on: https://gerrit.libreoffice.org/27121
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 5638632..df4f658 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1045,6 +1045,16 @@ void DocxAttributeOutput::EndParagraphProperties(const SfxItemSet& rParagraphMar
         m_nColBreakStatus = COLBRK_NONE;
     }
 
+    if ( m_bPostponedPageBreak )
+    {
+        m_pSerializer->startElementNS( XML_w, XML_r, FSEND );
+        m_pSerializer->singleElementNS( XML_w, XML_br,
+                FSNS( XML_w, XML_type ), "page", FSEND );
+        m_pSerializer->endElementNS( XML_w, XML_r );
+
+        m_bPostponedPageBreak = false;
+    }
+
     // merge the properties _before_ the run (strictly speaking, just
     // after the start of the paragraph)
     m_pSerializer->mergeTopMarks(Tag_StartParagraphProperties, sax_fastparser::MergeMarks::PREPEND);
@@ -5395,13 +5405,16 @@ void DocxAttributeOutput::SectionBreak( sal_uInt8 nC, const WW8_SepInfo* pSectio
                     m_pSectionInfo.reset( new WW8_SepInfo( *pSectionInfo ));
                 }
             }
-            else
+            else if ( m_bParagraphOpened )
             {
                 m_pSerializer->startElementNS( XML_w, XML_r, FSEND );
                 m_pSerializer->singleElementNS( XML_w, XML_br,
                         FSNS( XML_w, XML_type ), "page", FSEND );
                 m_pSerializer->endElementNS( XML_w, XML_r );
             }
+            else
+                m_bPostponedPageBreak = true;
+
             break;
         default:
             OSL_TRACE( "Unknown section break to write: %d", nC );
@@ -8446,6 +8459,7 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, FSHelperPtr pSeri
       m_bAlternateContentChoiceOpen( false ),
       m_bPostponedProcessingFly( false ),
       m_nColBreakStatus( COLBRK_NONE ),
+      m_bPostponedPageBreak( false ),
       m_nTextFrameLevel( 0 ),
       m_closeHyperlinkInThisRun( false ),
       m_closeHyperlinkInPreviousRun( false ),
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index 4089d29..0b2d4ad 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -810,6 +810,10 @@ private:
     // beginning of the next paragraph
     DocxColBreakStatus m_nColBreakStatus;
 
+    // Remember that a page break has to be opened at the
+    // beginning of the next paragraph
+    bool m_bPostponedPageBreak;
+
     std::vector<ww8::Frame> m_aFramesOfParagraph;
     sal_Int32 m_nTextFrameLevel;
 


More information about the Libreoffice-commits mailing list