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

Justin Luth justin_luth at sil.org
Thu Jul 14 08:15:38 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 620c00bf2279ccedf3fadefecc68186e25827b59
Author: Justin Luth <justin_luth at sil.org>
Date:   Mon Jul 11 18:02:37 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/27116
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 1678188..9c1d832 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1065,6 +1065,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);
@@ -5423,13 +5433,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 );
@@ -8462,6 +8475,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 1190d3a..41f9189 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