summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPallavi Jadhav <pallavi.jadhav@synerzip.com>2014-02-06 13:58:03 +0530
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-02-26 10:50:08 +0100
commita31fbb53dba76736b37213b98b64937f05929a67 (patch)
tree40c56bf856289c50415fa2c469946e5c72fef974
parentc4399bcd13cbe1cfa89c782e6667906c0b8bbb89 (diff)
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
-rw-r--r--sw/qa/extras/ooxmlexport/data/fdo74566.docxbin0 -> 12675 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx20
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx5
-rw-r--r--sw/source/filter/ww8/wrtww8.hxx2
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx17
5 files changed, 31 insertions, 13 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/fdo74566.docx b/sw/qa/extras/ooxmlexport/data/fdo74566.docx
new file mode 100644
index 000000000000..b197b946a4a8
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/fdo74566.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 194b7c6d582b..73d3393d8f2d 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -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();
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index b27aadc8c433..46258f94593e 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -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() )
{
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index 755e36e5217f..fb63531bb2ee 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -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.
///
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 7f5f64e0359b..7178b96cd16d 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -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;