fdo#74566:DOCX: Preservation <w:br> tag for Break to Next Page
Issue : 'Break to Next Page' gets converted to 'Page Break Before' in RT. XML diffrenece : - LO exports <w:br> as <w:pageBreakBefore /> in document.xml - The page break is written into wrong paragraph. Implementation : 1] Removed implementation to export <w:pageBreakBefore />. 2] Added a check to write <w:br> in correct paragraph. 3] Modified code to handle SectionBreak() even if Text node has no string. It is required when DOCX contains a PageBreak with footer. 4] Written Export Unit Test case. Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport.cxx Reviewed on: https://gerrit.libreoffice.org/7891 Change-Id: I237b9c5fdd3083b441f6e81cd8442f458eccf1a0
This commit is contained in:
parent
c4399bcd13
commit
a31fbb53db
BIN
sw/qa/extras/ooxmlexport/data/fdo74566.docx
Normal file
BIN
sw/qa/extras/ooxmlexport/data/fdo74566.docx
Normal file
Binary file not shown.
@ -3641,6 +3641,26 @@ DECLARE_OOXMLEXPORT_TEST(testFooterContainHyperlink,"footer-contain-hyperlink.do
|
||||
// Check the value of Target which is http://www.google.com/.
|
||||
assertXPath(pXmlRels,"/rels:Relationships/rels:Relationship","Target","http://www.google.com/");
|
||||
}
|
||||
|
||||
DECLARE_OOXMLEXPORT_TEST(testPageBreak,"fdo74566.docx")
|
||||
{
|
||||
/* Break to next page was written into wrong paragraph as <w:pageBreakBefore />.
|
||||
* LO was not preserving Page Break as <w:br w:type="page" />.
|
||||
* Now after fix , LO writes Page Break as the new paragraph and also
|
||||
* preserves the xml tag <w:br>.
|
||||
*/
|
||||
xmlDocPtr pXmlDoc = parseExport("word/document.xml");
|
||||
if (!pXmlDoc)
|
||||
return;
|
||||
|
||||
uno::Reference<text::XTextRange> xParagraph2 = getParagraph(2);
|
||||
uno::Reference<text::XTextRange> xParagraph4 = getParagraph(4);
|
||||
|
||||
getRun(xParagraph2, 1, "First Page Second Line");
|
||||
assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r[2]/w:br","type","page");
|
||||
getRun(xParagraph4, 1, "Second Page First line after Page Break");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||
|
@ -399,10 +399,7 @@ void DocxAttributeOutput::SectionBreaks(const SwTxtNode& rNode)
|
||||
if ( aNextIndex.GetNode().IsTxtNode() )
|
||||
{
|
||||
const SwTxtNode* pTxtNode = static_cast< SwTxtNode* >( &aNextIndex.GetNode() );
|
||||
// If next node has no string - it is an empty node, so no need to output the section break
|
||||
|
||||
if (!pTxtNode->GetTxt().isEmpty())
|
||||
m_rExport.OutputSectionBreaks( pTxtNode->GetpSwAttrSet(), *pTxtNode, m_tableReference->m_bTableCellOpen );
|
||||
m_rExport.OutputSectionBreaks( pTxtNode->GetpSwAttrSet(), *pTxtNode, m_tableReference->m_bTableCellOpen, pTxtNode->GetTxt().isEmpty() );
|
||||
}
|
||||
else if ( aNextIndex.GetNode().IsTableNode() )
|
||||
{
|
||||
|
@ -699,7 +699,7 @@ public:
|
||||
sal_uLong GetSectionLineNo( const SfxItemSet* pSet, const SwNode& rNd ) const;
|
||||
|
||||
/// Start new section.
|
||||
void OutputSectionBreaks( const SfxItemSet *pSet, const SwNode& rNd, bool isCellOpen = false);
|
||||
void OutputSectionBreaks( const SfxItemSet *pSet, const SwNode& rNd, bool isCellOpen = false, bool isTextNodeEmpty = false);
|
||||
|
||||
/// Write section properties.
|
||||
///
|
||||
|
@ -398,7 +398,7 @@ bool MSWordExportBase::SetAktPageDescFromNode(const SwNode &rNd)
|
||||
// Es duerfen nur Funktionen gerufen werden, die nicht in den
|
||||
// Ausgabebereich pO schreiben, da dieser nur einmal fuer CHP und PAP existiert
|
||||
// und damit im falschen landen wuerden.
|
||||
void MSWordExportBase::OutputSectionBreaks( const SfxItemSet *pSet, const SwNode& rNd, bool isCellOpen)
|
||||
void MSWordExportBase::OutputSectionBreaks( const SfxItemSet *pSet, const SwNode& rNd, bool isCellOpen, bool isTextNodeEmpty)
|
||||
{
|
||||
if ( bStyDef || bOutKF || bInWriteEscher || bOutPageDescs )
|
||||
return;
|
||||
@ -419,9 +419,11 @@ void MSWordExportBase::OutputSectionBreaks( const SfxItemSet *pSet, const SwNode
|
||||
// Even if pAktPageDesc != pPageDesc ,it might be because of the different header & footer types.
|
||||
if (pAktPageDesc != pPageDesc)
|
||||
{
|
||||
if (isCellOpen && (pAktPageDesc->GetName() != pPageDesc->GetName()))
|
||||
if ( (isCellOpen && (pAktPageDesc->GetName() != pPageDesc->GetName())) || isTextNodeEmpty )
|
||||
{
|
||||
// Table cell is open and page header types are different,so do not output section break.
|
||||
// Table cell is open and page header types are different,so do not output section break OR
|
||||
// PageBreak is present but text node has no string - it is an empty node, do not prepare
|
||||
// new page descriptor i.e. bNewPageDesc should be false.
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -486,6 +488,8 @@ void MSWordExportBase::OutputSectionBreaks( const SfxItemSet *pSet, const SwNode
|
||||
{
|
||||
bNewPageDesc |= SetAktPageDescFromNode( rNd );
|
||||
}
|
||||
if( isTextNodeEmpty )
|
||||
bNewPageDesc = false;
|
||||
}
|
||||
if ( !bNewPageDesc )
|
||||
AttrOutput().OutputItem( *pItem );
|
||||
@ -3643,10 +3647,6 @@ void AttributeOutputBase::FormatBreak( const SvxFmtBreakItem& rBreak )
|
||||
// From now on(fix for #i77900#) we prefer to save a page break as
|
||||
// paragraph attribute, this has to be done after the export of the
|
||||
// paragraph ( => !GetExport().bBreakBefore )
|
||||
if ( !GetExport().bBreakBefore )
|
||||
PageBreakBefore( true );
|
||||
break;
|
||||
|
||||
case SVX_BREAK_PAGE_AFTER:
|
||||
case SVX_BREAK_PAGE_BOTH:
|
||||
nC = msword::PageBreak;
|
||||
@ -3663,7 +3663,8 @@ void AttributeOutputBase::FormatBreak( const SvxFmtBreakItem& rBreak )
|
||||
break;
|
||||
}
|
||||
|
||||
if ( ( bBefore == GetExport().bBreakBefore ) && nC )
|
||||
if ( (( bBefore != GetExport().bBreakBefore ) && ( nC == msword::PageBreak)) ||
|
||||
(( bBefore == GetExport().bBreakBefore ) && ( nC == msword::ColumnBreak)) )
|
||||
{
|
||||
// #i76300#
|
||||
bool bFollowPageDescWritten = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user