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

Miklos Vajna vmiklos at collabora.co.uk
Mon Nov 18 02:38:24 PST 2013


 sw/qa/extras/rtfexport/rtfexport.cxx        |    3 ++-
 sw/source/filter/ww8/rtfattributeoutput.cxx |   14 ++++++++++++--
 sw/source/filter/ww8/rtfexport.cxx          |    5 ++++-
 sw/source/filter/ww8/rtfexport.hxx          |    2 ++
 4 files changed, 20 insertions(+), 4 deletions(-)

New commits:
commit 8299924b750f74f799dc683134788a285b38bd72
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Nov 18 11:32:57 2013 +0100

    cp#1000018 RTF export: avoid additional paragraph at footnote end
    
    Change-Id: I430a7d705208f197050a7d521c9c20b267c33f26

diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index 58df4b5..b6084cb 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -341,10 +341,11 @@ DECLARE_RTFEXPORT_TEST(testFdo53113, "fdo53113.odt")
 DECLARE_RTFEXPORT_TEST(testFdo55939, "fdo55939.odt")
 {
     // The problem was that the exported RTF was invalid.
+    // Also, the 'Footnote text.' had an additional newline at its end.
     uno::Reference<text::XTextRange> xParagraph(getParagraph(1));
     getRun(xParagraph, 1, "Main text before footnote.");
     // Why the tab has to be removed here?
-    CPPUNIT_ASSERT_EQUAL(OUString("Footnote text.\n"),
+    CPPUNIT_ASSERT_EQUAL(OUString("Footnote text."),
             getProperty< uno::Reference<text::XTextRange> >(getRun(xParagraph, 2), "Footnote")->getText()->getString().replaceAll("\t", ""));
     getRun(xParagraph, 3, " Text after the footnote."); // However, this leading space is intentional and OK.
 }
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 1b466e6..3415be7 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -297,6 +297,12 @@ void RtfAttributeOutput::StartParagraph( ww8::WW8TableNodeInfo::Pointer_t pTextN
 void RtfAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner )
 {
     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
+    bool bLastPara = false;
+    if (m_rExport.nTxtTyp == TXT_FTN || m_rExport.nTxtTyp == TXT_EDN)
+    {
+        // We're ending a paragraph that is the last paragraph of a footnote or endnote.
+        bLastPara = m_rExport.m_nCurrentNodeIndex && m_rExport.m_nCurrentNodeIndex == m_rExport.pCurPam->End()->nNode.GetIndex();
+    }
 
     FinishTableRowCell( pTextNodeInfoInner );
 
@@ -309,8 +315,12 @@ void RtfAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTe
     else
     {
         aParagraph->append(SAL_NEWLINE_STRING);
-        aParagraph->append(OOO_STRING_SVTOOLS_RTF_PAR);
-        aParagraph->append(' ');
+        // RTF_PAR at the end of the footnote would cause an additional empty paragraph.
+        if (!bLastPara)
+        {
+            aParagraph->append(OOO_STRING_SVTOOLS_RTF_PAR);
+            aParagraph->append(' ');
+        }
     }
     if (m_nColBreakNeeded)
     {
diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx
index e061d1a..05647b9 100644
--- a/sw/source/filter/ww8/rtfexport.cxx
+++ b/sw/source/filter/ww8/rtfexport.cxx
@@ -765,8 +765,10 @@ void RtfExport::OutputLinkedOLE( const OUString& )
 
 void RtfExport::OutputTextNode( const SwTxtNode& rNode )
 {
+    m_nCurrentNodeIndex = rNode.GetIndex();
     if ( !m_bOutOutlineOnly || rNode.IsOutline( ) )
         MSWordExportBase::OutputTextNode( rNode );
+    m_nCurrentNodeIndex = 0;
 }
 
 void RtfExport::AppendSection( const SwPageDesc* pPageDesc, const SwSectionFmt* pFmt, sal_uLong nLnNum )
@@ -789,7 +791,8 @@ RtfExport::RtfExport( RtfExportFilter *pFilter, SwDoc *pDocument, SwPaM *pCurren
               rtl_getTextEncodingFromWindowsCharset(
                   sw::ms::rtl_TextEncodingToWinCharset(DEF_ENCODING))),
       eCurrentEncoding(eDefaultEncoding),
-      bRTFFlySyntax(false)
+      bRTFFlySyntax(false),
+      m_nCurrentNodeIndex(0)
 {
     mbExportModeRTF = true;
     // the attribute output for the document
diff --git a/sw/source/filter/ww8/rtfexport.hxx b/sw/source/filter/ww8/rtfexport.hxx
index 930c45a..e77adf9 100644
--- a/sw/source/filter/ww8/rtfexport.hxx
+++ b/sw/source/filter/ww8/rtfexport.hxx
@@ -148,6 +148,8 @@ public:
     rtl_TextEncoding eCurrentEncoding;
     /// This is used by OutputFlyFrame_Impl() to control the written syntax
     bool bRTFFlySyntax;
+    /// Index of the current SwTxtNode, if any.
+    sal_uLong m_nCurrentNodeIndex;
 
     SvStream& Strm();
     SvStream& OutULong( sal_uLong nVal );


More information about the Libreoffice-commits mailing list