[Libreoffice-commits] core.git: sw/qa sw/source

Miklos Vajna vmiklos at collabora.co.uk
Wed Sep 23 22:41:26 PDT 2015


 sw/qa/extras/rtfexport/data/tdf92521.odt    |binary
 sw/qa/extras/rtfexport/rtfexport.cxx        |    7 +++++++
 sw/source/filter/ww8/rtfattributeoutput.cxx |   13 ++++++++++++-
 sw/source/filter/ww8/rtfexport.cxx          |    7 +++++++
 sw/source/filter/ww8/rtfexport.hxx          |    3 +++
 5 files changed, 29 insertions(+), 1 deletion(-)

New commits:
commit 0d7d6f242ef87c976095d22a7f5ebf751ba77ad8
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Sep 24 07:40:14 2015 +0200

    Related: tdf#92521 RTF export: handle section break right after a table
    
    Change-Id: Ibb6e612165ec6e5d771bdf9efa13a88a72233d6f

diff --git a/sw/qa/extras/rtfexport/data/tdf92521.odt b/sw/qa/extras/rtfexport/data/tdf92521.odt
new file mode 100644
index 0000000..8148e49
Binary files /dev/null and b/sw/qa/extras/rtfexport/data/tdf92521.odt differ
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index 4abea40..4371ef5 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -936,6 +936,13 @@ DECLARE_RTFEXPORT_TEST(testTdf90421, "tdf90421.fodt")
     }
 }
 
+DECLARE_RTFEXPORT_TEST(testTdf92521, "tdf92521.odt")
+{
+    // There should be a page break that's in the middle of the document: right after the table.
+    // But there wasn't, so this was 1.
+    CPPUNIT_ASSERT_EQUAL(2, getPages());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 83219e9..3c9c5b5 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -316,12 +316,12 @@ void RtfAttributeOutput::EmptyParagraph()
 
 void RtfAttributeOutput::SectionBreaks(const SwNode& rNode)
 {
+    SwNodeIndex aNextIndex(rNode, 1);
     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;
 
@@ -344,6 +344,17 @@ void RtfAttributeOutput::SectionBreaks(const SwNode& rNode)
         }
         m_bBufferSectionBreaks = false;
     }
+    else if (rNode.IsEndNode())
+    {
+        // 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);
+        }
+    }
 }
 
 void RtfAttributeOutput::StartParagraphProperties()
diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx
index 8fec63d..8d79e04 100644
--- a/sw/source/filter/ww8/rtfexport.cxx
+++ b/sw/source/filter/ww8/rtfexport.cxx
@@ -772,6 +772,13 @@ bool RtfExport::DisallowInheritingOutlineNumbering(const SwFormat& rFormat)
     return bRet;
 }
 
+void RtfExport::OutputEndNode(const SwEndNode& rEndNode)
+{
+    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 RtfExport::OutputGrfNode(const SwGrfNode&)
 {
     /* noop, see RtfAttributeOutput::FlyFrameGraphic */
diff --git a/sw/source/filter/ww8/rtfexport.hxx b/sw/source/filter/ww8/rtfexport.hxx
index 2103b65..b602d63 100644
--- a/sw/source/filter/ww8/rtfexport.hxx
+++ b/sw/source/filter/ww8/rtfexport.hxx
@@ -139,6 +139,9 @@ protected:
     /// Output SwTextNode is depending on outline export mode
     virtual void OutputTextNode(const SwTextNode&) SAL_OVERRIDE;
 
+    /// Output SwEndNode
+    virtual void OutputEndNode(const SwEndNode&) SAL_OVERRIDE;
+
     /// Output SwGrfNode
     virtual void OutputGrfNode(const SwGrfNode&) SAL_OVERRIDE;
 


More information about the Libreoffice-commits mailing list