summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-09-21 07:31:33 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-09-21 07:32:32 +0200
commitc916152d8562cab868d4c522748ac30029fad179 (patch)
tree5cc3bc0b9b007749c28e97b505823b96b1483b5f /sw/source
parent32f419fee5f9df4facb7a9b3ec910471d2a20247 (diff)
tdf#92521 DOCX export: handle section break right after a table
DocxAttributeOutput::SectionBreaks() previously only handled the text-text and text-table node transitions; implement support for table-text to avoid loosing a page break on export for the bugdoc. (View this commit with whitespace ignored to filter out the noise about SectionBreaks() now accepting non-text nodes, too.) Change-Id: Ie8a1575374a207399351635bda8c0c076ce7268d
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/filter/ww8/attributeoutputbase.hxx2
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx31
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.hxx2
-rw-r--r--sw/source/filter/ww8/docxexport.cxx3
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.cxx47
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.hxx2
-rw-r--r--sw/source/filter/ww8/ww8attributeoutput.hxx2
7 files changed, 55 insertions, 34 deletions
diff --git a/sw/source/filter/ww8/attributeoutputbase.hxx b/sw/source/filter/ww8/attributeoutputbase.hxx
index 457839c60526..a180564719fb 100644
--- a/sw/source/filter/ww8/attributeoutputbase.hxx
+++ b/sw/source/filter/ww8/attributeoutputbase.hxx
@@ -156,7 +156,7 @@ public:
virtual void EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner ) = 0;
/// Called in order to output section breaks.
- virtual void SectionBreaks(const SwTextNode& rNode) = 0;
+ virtual void SectionBreaks(const SwNode& rNode) = 0;
/// Called before we start outputting the attributes.
virtual void StartParagraphProperties() = 0;
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 58ae8c6ca9a3..f28b7297f643 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -794,7 +794,7 @@ void DocxAttributeOutput::EmptyParagraph()
m_pSerializer->singleElementNS( XML_w, XML_p, FSEND );
}
-void DocxAttributeOutput::SectionBreaks(const SwTextNode& rNode)
+void DocxAttributeOutput::SectionBreaks(const SwNode& rNode)
{
// output page/section breaks
// Writer can have them at the beginning of a paragraph, or at the end, but
@@ -802,16 +802,31 @@ void DocxAttributeOutput::SectionBreaks(const SwTextNode& rNode)
// paragraph in a section. To get it right, we have to switch to the next
// paragraph, and detect the section breaks there.
SwNodeIndex aNextIndex( rNode, 1 );
- if ( aNextIndex.GetNode().IsTextNode() )
+
+ if (rNode.IsTextNode())
{
- const SwTextNode* pTextNode = static_cast< SwTextNode* >( &aNextIndex.GetNode() );
- m_rExport.OutputSectionBreaks( pTextNode->GetpSwAttrSet(), *pTextNode, m_tableReference->m_bTableCellOpen, pTextNode->GetText().isEmpty() );
+ if (aNextIndex.GetNode().IsTextNode())
+ {
+ const SwTextNode* pTextNode = static_cast<SwTextNode*>(&aNextIndex.GetNode());
+ m_rExport.OutputSectionBreaks(pTextNode->GetpSwAttrSet(), *pTextNode, m_tableReference->m_bTableCellOpen, pTextNode->GetText().isEmpty());
+ }
+ else if (aNextIndex.GetNode().IsTableNode())
+ {
+ const SwTableNode* pTableNode = static_cast<SwTableNode*>(&aNextIndex.GetNode());
+ const SwFrameFormat *pFormat = pTableNode->GetTable().GetFrameFormat();
+ m_rExport.OutputSectionBreaks(&(pFormat->GetAttrSet()), *pTableNode);
+ }
}
- else if ( aNextIndex.GetNode().IsTableNode() )
+ else if (rNode.IsEndNode())
{
- const SwTableNode* pTableNode = static_cast< SwTableNode* >( &aNextIndex.GetNode() );
- const SwFrameFormat *pFormat = pTableNode->GetTable().GetFrameFormat();
- m_rExport.OutputSectionBreaks( &(pFormat->GetAttrSet()), *pTableNode );
+ // End of something: make sure that it's the end of a table.
+ assert(rNode.StartOfSectionNode()->IsTableNode());
+ if (aNextIndex.GetNode().IsTextNode())
+ {
+ // Handle section break between a table and a text node following it.
+ const SwTextNode* pTextNode = aNextIndex.GetNode().GetTextNode();
+ m_rExport.OutputSectionBreaks(pTextNode->GetpSwAttrSet(), *pTextNode, m_tableReference->m_bTableCellOpen, pTextNode->GetText().isEmpty());
+ }
}
}
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index cc68dcb12fad..0bc904d2dda2 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -154,7 +154,7 @@ public:
virtual void EmptyParagraph() SAL_OVERRIDE;
/// Called in order to output section breaks.
- virtual void SectionBreaks(const SwTextNode& rNode) SAL_OVERRIDE;
+ virtual void SectionBreaks(const SwNode& rNode) SAL_OVERRIDE;
/// Called before we start outputting the attributes.
virtual void StartParagraphProperties() SAL_OVERRIDE;
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index 8fe0344feb2e..e7fa7693692a 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -499,6 +499,9 @@ void DocxExport::OutputEndNode( const SwEndNode& rEndNode )
m_pSections->AppendSection( m_pAktPageDesc, pParentFormat, nRstLnNum );
}
}
+ else if (TXT_MAINTEXT == m_nTextTyp && rEndNode.StartOfSectionNode()->IsTableNode())
+ // End node of a table: see if a section break should be written after the table.
+ AttrOutput().SectionBreaks(rEndNode);
}
void DocxExport::OutputGrfNode( const SwGrfNode& )
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index c1ac77ee1f55..83219e973ced 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -314,33 +314,36 @@ void RtfAttributeOutput::EmptyParagraph()
m_rExport.Strm().WriteCharPtr(SAL_NEWLINE_STRING).WriteCharPtr(OOO_STRING_SVTOOLS_RTF_PAR).WriteChar(' ');
}
-void RtfAttributeOutput::SectionBreaks(const SwTextNode& rNode)
+void RtfAttributeOutput::SectionBreaks(const SwNode& rNode)
{
- OSL_ENSURE(m_aStyles.getLength() == 0, "m_aStyles is not empty");
+ if (rNode.IsTextNode())
+ {
+ OSL_ENSURE(m_aStyles.getLength() == 0, "m_aStyles is not empty");
- // output page/section breaks
- SwNodeIndex aNextIndex(rNode, 1);
- m_rExport.Strm().WriteCharPtr(m_aSectionBreaks.makeStringAndClear().getStr());
- m_bBufferSectionBreaks = true;
+ // output page/section breaks
+ SwNodeIndex aNextIndex(rNode, 1);
+ m_rExport.Strm().WriteCharPtr(m_aSectionBreaks.makeStringAndClear().getStr());
+ m_bBufferSectionBreaks = true;
- // output section headers / footers
- if (!m_bBufferSectionHeaders)
- m_rExport.Strm().WriteCharPtr(m_aSectionHeaders.makeStringAndClear().getStr());
+ // output section headers / footers
+ if (!m_bBufferSectionHeaders)
+ m_rExport.Strm().WriteCharPtr(m_aSectionHeaders.makeStringAndClear().getStr());
- if (aNextIndex.GetNode().IsTextNode())
- {
- const SwTextNode* pTextNode = static_cast< SwTextNode* >(&aNextIndex.GetNode());
- m_rExport.OutputSectionBreaks(pTextNode->GetpSwAttrSet(), *pTextNode);
- // Save the current page description for now, so later we will be able to access the previous one.
- m_pPrevPageDesc = pTextNode->FindPageDesc(false);
- }
- else if (aNextIndex.GetNode().IsTableNode())
- {
- const SwTableNode* pTableNode = static_cast< SwTableNode* >(&aNextIndex.GetNode());
- const SwFrameFormat* pFormat = pTableNode->GetTable().GetFrameFormat();
- m_rExport.OutputSectionBreaks(&(pFormat->GetAttrSet()), *pTableNode);
+ if (aNextIndex.GetNode().IsTextNode())
+ {
+ const SwTextNode* pTextNode = static_cast< SwTextNode* >(&aNextIndex.GetNode());
+ m_rExport.OutputSectionBreaks(pTextNode->GetpSwAttrSet(), *pTextNode);
+ // Save the current page description for now, so later we will be able to access the previous one.
+ m_pPrevPageDesc = pTextNode->FindPageDesc(false);
+ }
+ else if (aNextIndex.GetNode().IsTableNode())
+ {
+ const SwTableNode* pTableNode = static_cast< SwTableNode* >(&aNextIndex.GetNode());
+ const SwFrameFormat* pFormat = pTableNode->GetTable().GetFrameFormat();
+ m_rExport.OutputSectionBreaks(&(pFormat->GetAttrSet()), *pTableNode);
+ }
+ m_bBufferSectionBreaks = false;
}
- m_bBufferSectionBreaks = false;
}
void RtfAttributeOutput::StartParagraphProperties()
diff --git a/sw/source/filter/ww8/rtfattributeoutput.hxx b/sw/source/filter/ww8/rtfattributeoutput.hxx
index 9407fefb573c..abc8e2d63c00 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.hxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.hxx
@@ -53,7 +53,7 @@ public:
virtual void EmptyParagraph() SAL_OVERRIDE;
/// Called in order to output section breaks.
- virtual void SectionBreaks(const SwTextNode& rNode) SAL_OVERRIDE;
+ virtual void SectionBreaks(const SwNode& rNode) SAL_OVERRIDE;
/// Called before we start outputting the attributes.
virtual void StartParagraphProperties() SAL_OVERRIDE;
diff --git a/sw/source/filter/ww8/ww8attributeoutput.hxx b/sw/source/filter/ww8/ww8attributeoutput.hxx
index 0b8765e2809f..25e3308cde75 100644
--- a/sw/source/filter/ww8/ww8attributeoutput.hxx
+++ b/sw/source/filter/ww8/ww8attributeoutput.hxx
@@ -36,7 +36,7 @@ public:
virtual void EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner ) SAL_OVERRIDE;
/// Called in order to output section breaks.
- virtual void SectionBreaks(const SwTextNode& /*rNode*/) SAL_OVERRIDE {}
+ virtual void SectionBreaks(const SwNode& /*rNode*/) SAL_OVERRIDE {}
/// Called before we start outputting the attributes.
virtual void StartParagraphProperties() SAL_OVERRIDE {}