summaryrefslogtreecommitdiff
path: root/sw/source/filter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-09-21 07:31:33 +0200
committerCaolán McNamara <caolanm@redhat.com>2015-10-01 09:22:00 +0000
commitf624559bbfa2cfb8cc2a081174be2ac6b0ed9dcb (patch)
tree1791c39357c87004284cf7f93c4bbf8a880137ba /sw/source/filter
parent950cfbd75a216527d850351e4b3e0be4f8870a7d (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.) (cherry picked from commit c916152d8562cab868d4c522748ac30029fad179) Conflicts: sw/source/filter/ww8/attributeoutputbase.hxx sw/source/filter/ww8/docxattributeoutput.cxx sw/source/filter/ww8/docxattributeoutput.hxx sw/source/filter/ww8/rtfattributeoutput.cxx sw/source/filter/ww8/rtfattributeoutput.hxx sw/source/filter/ww8/ww8attributeoutput.hxx Change-Id: Ie8a1575374a207399351635bda8c0c076ce7268d Reviewed-on: https://gerrit.libreoffice.org/18901 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/source/filter')
-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 1dffa6340def..84a1d707c19a 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 SwTxtNode& 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 4cba42779c80..ade163e0514c 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -750,7 +750,7 @@ void DocxAttributeOutput::EmptyParagraph()
m_pSerializer->singleElementNS( XML_w, XML_p, FSEND );
}
-void DocxAttributeOutput::SectionBreaks(const SwTxtNode& 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
@@ -758,16 +758,31 @@ void DocxAttributeOutput::SectionBreaks(const SwTxtNode& 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().IsTxtNode() )
+
+ if (rNode.IsTxtNode())
{
- const SwTxtNode* pTxtNode = static_cast< SwTxtNode* >( &aNextIndex.GetNode() );
- m_rExport.OutputSectionBreaks( pTxtNode->GetpSwAttrSet(), *pTxtNode, m_tableReference->m_bTableCellOpen, pTxtNode->GetTxt().isEmpty() );
+ if (aNextIndex.GetNode().IsTxtNode())
+ {
+ const SwTxtNode* pTxtNode = static_cast<SwTxtNode*>(&aNextIndex.GetNode());
+ m_rExport.OutputSectionBreaks(pTxtNode->GetpSwAttrSet(), *pTxtNode, m_tableReference->m_bTableCellOpen, pTxtNode->GetTxt().isEmpty());
+ }
+ else if (aNextIndex.GetNode().IsTableNode())
+ {
+ const SwTableNode* pTableNode = static_cast<SwTableNode*>(&aNextIndex.GetNode());
+ const SwFrmFmt *pFmt = pTableNode->GetTable().GetFrmFmt();
+ m_rExport.OutputSectionBreaks(&(pFmt->GetAttrSet()), *pTableNode);
+ }
}
- else if ( aNextIndex.GetNode().IsTableNode() )
+ else if (rNode.IsEndNode())
{
- const SwTableNode* pTableNode = static_cast< SwTableNode* >( &aNextIndex.GetNode() );
- const SwFrmFmt *pFmt = pTableNode->GetTable().GetFrmFmt();
- m_rExport.OutputSectionBreaks( &(pFmt->GetAttrSet()), *pTableNode );
+ // End of something: make sure that it's the end of a table.
+ assert(rNode.StartOfSectionNode()->IsTableNode());
+ if (aNextIndex.GetNode().IsTxtNode())
+ {
+ // Handle section break between a table and a text node following it.
+ const SwTxtNode* pTxtNode = aNextIndex.GetNode().GetTxtNode();
+ m_rExport.OutputSectionBreaks(pTxtNode->GetpSwAttrSet(), *pTxtNode, m_tableReference->m_bTableCellOpen, pTxtNode->GetTxt().isEmpty());
+ }
}
}
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index f8ae6267b4bc..4206b88dedce 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -155,7 +155,7 @@ public:
virtual void EmptyParagraph() SAL_OVERRIDE;
/// Called in order to output section breaks.
- virtual void SectionBreaks(const SwTxtNode& 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 5b4c38193e3d..0e1d1d187696 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -501,6 +501,9 @@ void DocxExport::OutputEndNode( const SwEndNode& rEndNode )
m_pSections->AppendSection( pAktPageDesc, pParentFmt, nRstLnNum );
}
}
+ else if (TXT_MAINTEXT == nTxtTyp && rEndNode.StartOfSectionNode()->IsTableNode())
+ // End node of a table: see if a section break should be written after the table.
+ AttrOutput().SectionBreaks(rEndNode);
}
void DocxExport::OutputTableNode( const SwTableNode& )
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index d9550c051d8e..e0019561890b 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -324,33 +324,36 @@ void RtfAttributeOutput::EmptyParagraph()
m_rExport.Strm().WriteCharPtr(SAL_NEWLINE_STRING).WriteCharPtr(OOO_STRING_SVTOOLS_RTF_PAR).WriteChar(' ');
}
-void RtfAttributeOutput::SectionBreaks(const SwTxtNode& rNode)
+void RtfAttributeOutput::SectionBreaks(const SwNode& rNode)
{
- OSL_ENSURE(m_aStyles.getLength() == 0, "m_aStyles is not empty");
+ if (rNode.IsTxtNode())
+ {
+ 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().IsTxtNode())
- {
- const SwTxtNode* pTxtNode = static_cast< SwTxtNode* >(&aNextIndex.GetNode());
- m_rExport.OutputSectionBreaks(pTxtNode->GetpSwAttrSet(), *pTxtNode);
- // Save the current page description for now, so later we will be able to access the previous one.
- m_pPrevPageDesc = pTxtNode->FindPageDesc(false);
- }
- else if (aNextIndex.GetNode().IsTableNode())
- {
- const SwTableNode* pTableNode = static_cast< SwTableNode* >(&aNextIndex.GetNode());
- const SwFrmFmt* pFmt = pTableNode->GetTable().GetFrmFmt();
- m_rExport.OutputSectionBreaks(&(pFmt->GetAttrSet()), *pTableNode);
+ if (aNextIndex.GetNode().IsTxtNode())
+ {
+ const SwTxtNode* pTxtNode = static_cast< SwTxtNode* >(&aNextIndex.GetNode());
+ m_rExport.OutputSectionBreaks(pTxtNode->GetpSwAttrSet(), *pTxtNode);
+ // Save the current page description for now, so later we will be able to access the previous one.
+ m_pPrevPageDesc = pTxtNode->FindPageDesc(false);
+ }
+ else if (aNextIndex.GetNode().IsTableNode())
+ {
+ const SwTableNode* pTableNode = static_cast< SwTableNode* >(&aNextIndex.GetNode());
+ const SwFrmFmt* pFmt = pTableNode->GetTable().GetFrmFmt();
+ m_rExport.OutputSectionBreaks(&(pFmt->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 72d07cc44410..812dcba7b7a5 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 SwTxtNode& 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 8e7041bafdb5..e49100507cd1 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 SwTxtNode& /*rNode*/) SAL_OVERRIDE {}
+ virtual void SectionBreaks(const SwNode& /*rNode*/) SAL_OVERRIDE {}
/// Called before we start outputting the attributes.
virtual void StartParagraphProperties() SAL_OVERRIDE {}