[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - sw/qa writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Wed Mar 9 10:01:24 UTC 2016


 sw/qa/extras/rtfimport/data/tdf87034.rtf       |   13 +++++++++++++
 sw/qa/extras/rtfimport/rtfimport.cxx           |    7 +++++++
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |    6 +-----
 writerfilter/source/rtftok/rtfdocumentimpl.hxx |    1 -
 4 files changed, 21 insertions(+), 6 deletions(-)

New commits:
commit 23498672666312dcda769567f818853ce7810a2e
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Feb 10 08:59:01 2016 +0100

    tdf#87034 RTF import: fix multiple superscripts after footnote ...
    
    ... in the same paragraph. The intention was to avoid replaying the
    supertext buffer and using its contents as a custom footnote mark at the
    same time. However, it's enough to check if the buffer is empty to do
    so, and that avoids the mis-import of the bugdoc as well.
    
    Change-Id: I1e3b0c7f0c6d8eb8250d8b1d0d7d196039c40e79
    (cherry picked from commit 93faf178195ca974747849879266783884ae27c5)
    Reviewed-on: https://gerrit.libreoffice.org/22815
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/qa/extras/rtfimport/data/tdf87034.rtf b/sw/qa/extras/rtfimport/data/tdf87034.rtf
new file mode 100644
index 0000000..16f322c
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/tdf87034.rtf
@@ -0,0 +1,13 @@
+{\rtf1
+\pard\plain A
+{\chftn
+{\footnote\chftn F
+}
+}
+B
+{\super 3}
+C
+{\super 4}
+D
+\par
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 565d535..e95ada6 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -2473,6 +2473,13 @@ DECLARE_RTFIMPORT_TEST(testTdf96308Tabpos, "tdf96308-tabpos.rtf")
     CPPUNIT_ASSERT(!aTabStops.hasElements());
 }
 
+DECLARE_RTFIMPORT_TEST(testTdf87034, "tdf87034.rtf")
+{
+    // This was A1BC34D, i.e. the first "super" text portion was mis-imported,
+    // and was inserted instead right before the second "super" text portion.
+    CPPUNIT_ASSERT_EQUAL(OUString("A1B3C4D"), getParagraph(1)->getString());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 92ba692..4c4c080 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -240,7 +240,6 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x
       m_nBackupTopLevelCurrentCellX(0),
       m_aTableBufferStack(1), // create top-level buffer already
       m_aSuperBuffer(),
-      m_bHasFootnote(false),
       m_pSuperstream(nullptr),
       m_nStreamType(0),
       m_nHeaderFooterPositions(),
@@ -1701,7 +1700,6 @@ RTFError RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
                 if (aKeyword.equals("\\ftnalt"))
                     nId = NS_ooxml::LN_endnote;
 
-                m_bHasFootnote = true;
                 if (m_aStates.top().pCurrentBuffer == &m_aSuperBuffer)
                     m_aStates.top().pCurrentBuffer = nullptr;
                 bool bCustomMark = false;
@@ -6091,10 +6089,8 @@ RTFError RTFDocumentImpl::popState()
     {
         OSL_ASSERT(!m_aStates.empty() && m_aStates.top().pCurrentBuffer == nullptr);
 
-        if (!m_bHasFootnote)
+        if (!m_aSuperBuffer.empty())
             replayBuffer(m_aSuperBuffer, nullptr, nullptr);
-
-        m_bHasFootnote = false;
     }
 
     return RTFError::OK;
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 7ef2b4f..de1486d 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -523,7 +523,6 @@ private:
     /// Buffered superscript, till footnote is reached (or not).
     RTFBuffer_t m_aSuperBuffer;
 
-    bool m_bHasFootnote;
     /// Superstream of this substream.
     RTFDocumentImpl* m_pSuperstream;
     /// Type of the stream: header, footer, footnote, etc.


More information about the Libreoffice-commits mailing list