summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2016-07-09 07:53:32 +0300
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-07-11 07:31:01 +0000
commit07fb94655f4745eb4e80bf6e8d4cdd95371f23bb (patch)
treee5d5910e73e4923cfa0041e9059e39055523ec1b
parentc0ca75f1af9a94dccfd1011eac8821bb1a316d6b (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. Change-Id: Ie7f629869aab0f3d2405660a033c3f23bbd6baca 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>
-rwxr-xr-xsw/qa/extras/ooxmlexport/data/tdf99090_pgbrkAfterTable.docxbin0 -> 14726 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport4.cxx7
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx16
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.hxx4
4 files changed, 26 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf99090_pgbrkAfterTable.docx b/sw/qa/extras/ooxmlexport/data/tdf99090_pgbrkAfterTable.docx
new file mode 100755
index 000000000000..c914f350ea6f
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf99090_pgbrkAfterTable.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
index c4ab555cde6a..b837ae299803 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
@@ -965,6 +965,13 @@ DECLARE_OOXMLEXPORT_TEST(testTdf92521, "tdf92521.odt")
assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:pPr/w:sectPr", 1);
}
+DECLARE_OOXMLEXPORT_TEST(testTdf99090_pgbrkAfterTable, "tdf99090_pgbrkAfterTable.docx")
+{
+ if (xmlDocPtr pXmlDoc = parseExport("word/document.xml"))
+ // There should be a regular page break that's in the middle of the document: right after the table.
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:br", 1);
+}
+
DECLARE_OOXMLEXPORT_TEST(testTdf96750_landscapeFollow, "tdf96750_landscapeFollow.docx")
{
uno::Reference<beans::XPropertySet> xStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY);
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index f4d2c8168410..84b6c74c5f39 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);
@@ -5417,13 +5427,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 );
@@ -8456,6 +8469,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 ab0a43aced06..6c17e76c5038 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;