diff options
author | Justin Luth <justin_luth@sil.org> | 2016-07-11 18:07:32 +0300 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2016-07-12 19:19:29 +0000 |
commit | 28ded9c98837d6b6eefff73f396353b61b6b4017 (patch) | |
tree | c0d143b236f9f03a6df8846d04b345efd68f9fd7 | |
parent | bda6bce91555861f604a74b8f3d6cc6cd35c11c4 (diff) |
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@libreoffice.org>
Reviewed-by: Justin Luth <justin_luth@sil.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
(cherry picked from commit 07fb94655f4745eb4e80bf6e8d4cdd95371f23bb)
Change-Id: Ie7f629869aab0f3d2405660a033c3f23bbd6baca
Reviewed-on: https://gerrit.libreoffice.org/27121
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 16 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.hxx | 4 |
2 files changed, 19 insertions, 1 deletions
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 5638632c0725..df4f65839e47 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 4089d295eb44..0b2d4ad64fdb 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; |