Kaydet (Commit) 07fb9465 authored tarafından Justin Luth's avatar Justin Luth Kaydeden (comit) Miklos Vajna

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/26771Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarJustin Luth <justin_luth@sil.org>
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst c0ca75f1
......@@ -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);
......
......@@ -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 ),
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment