diff options
author | Justin Luth <justin_luth@sil.org> | 2016-07-11 18:02:37 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-07-14 08:15:09 +0000 |
commit | 620c00bf2279ccedf3fadefecc68186e25827b59 (patch) | |
tree | f2d1d9f2c9321909c586561266a7323b7cb1c0c9 | |
parent | 7aeadecc76e583a802d17b27d241c356e4e1bdc7 (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/27116
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-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 1678188120aa..9c1d832e2689 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 1190d3aa8a45..41f9189391d1 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; |