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

Miklos Vajna vmiklos at collabora.co.uk
Tue Nov 4 04:34:23 PST 2014


 sw/qa/extras/rtfimport/data/fdo82076.rtf       |   13 +++++++++++++
 sw/qa/extras/rtfimport/rtfimport.cxx           |   11 +++++++++++
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |   19 ++++++++++++++++++-
 writerfilter/source/rtftok/rtfdocumentimpl.hxx |    3 ++-
 4 files changed, 44 insertions(+), 2 deletions(-)

New commits:
commit db8cc3a1c481bd1f97b2688ff85a00eec8b25926
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Sun Oct 26 12:53:05 2014 +0100

    fdo#82076 RTF import: handle footnote in table cell
    
    (cherry picked from commit 956c3ff3d43e1b181f7c91518edee1c7c4dc2a0a)
    
    Change-Id: I69def7936c320e93db5d4504922d52346caaf9cf
    Reviewed-on: https://gerrit.libreoffice.org/12242
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    Tested-by: Michael Stahl <mstahl at redhat.com>

diff --git a/sw/qa/extras/rtfimport/data/fdo82076.rtf b/sw/qa/extras/rtfimport/data/fdo82076.rtf
new file mode 100644
index 0000000..20b33e9
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo82076.rtf
@@ -0,0 +1,13 @@
+{\rtf1
+\pard\plain
+Before
+\par
+\trowd \cellx4000\cellx8000
+A1\cell
+B1
+{\chftn
+{\footnote Footnote}
+}
+\cell\row
+\pard After\par
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 520beee..1c3ed00 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -1920,6 +1920,17 @@ DECLARE_RTFIMPORT_TEST(testFdo82859, "fdo82859.rtf")
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(-1), getProperty<sal_Int32>(getShape(1), "BackColor"));
 }
 
+DECLARE_RTFIMPORT_TEST(testFdo82076, "fdo82076.rtf")
+{
+    // Footnote position was wrong: should be at the end of the B1 cell.
+    uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
+    uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
+    uno::Reference<text::XTextRange> xCell(xTable->getCellByName("B1"), uno::UNO_QUERY);
+    // This resulted in container::NoSuchElementException: the footnote was at the start of the A1 cell.
+    CPPUNIT_ASSERT_EQUAL(OUString("Footnote"), getProperty<OUString>(getRun(getParagraphOfText(1, xCell->getText()), 2), "TextPortionType"));
+}
+
 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 9339c51..145fd4a 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1452,6 +1452,14 @@ void RTFDocumentImpl::replayBuffer(RTFBuffer_t& rBuffer,
                     RTFSdrImport::SHAPE);
         else if (boost::get<0>(aTuple) == BUFFER_ENDSHAPE)
             m_pSdrImport->close();
+        else if (boost::get<0>(aTuple) == BUFFER_RESOLVESUBSTREAM)
+        {
+            RTFSprms& rAttributes = boost::get<1>(aTuple)->getAttributes();
+            sal_Size nPos = rAttributes.find(0)->getInt();
+            Id nId = rAttributes.find(1)->getInt();
+            OUString aCustomMark = rAttributes.find(2)->getString();
+            resolveSubstream(nPos, nId, aCustomMark);
+        }
         else
             assert(false);
     }
@@ -1668,7 +1676,16 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
             m_aStates.top().nDestinationState = DESTINATION_FOOTNOTE;
             if (bCustomMark)
                 Mapper().startCharacterGroup();
-            resolveSubstream(m_nGroupStartPos - 1, nId, aCustomMark);
+                if (!m_aStates.top().pCurrentBuffer)
+                    resolveSubstream(m_nGroupStartPos - 1, nId, aCustomMark);
+                else
+                {
+                    RTFSprms aAttributes;
+                    aAttributes.set(Id(0), RTFValue::Pointer_t(new RTFValue(m_nGroupStartPos - 1)));
+                    aAttributes.set(Id(1), RTFValue::Pointer_t(new RTFValue(nId)));
+                    aAttributes.set(Id(2), RTFValue::Pointer_t(new RTFValue(aCustomMark)));
+                    m_aStates.top().pCurrentBuffer->push_back(Buf_t(BUFFER_RESOLVESUBSTREAM, RTFValue::Pointer_t(new RTFValue(aAttributes))));
+                }
             if (bCustomMark)
             {
                 m_aStates.top().aCharacterAttributes.clear();
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 98a5523..3cc9c51 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -55,7 +55,8 @@ enum RTFBufferTypes
     BUFFER_ENDRUN,
     BUFFER_PAR,
     BUFFER_STARTSHAPE,
-    BUFFER_ENDSHAPE
+    BUFFER_ENDSHAPE,
+    BUFFER_RESOLVESUBSTREAM
 };
 
 /// Form field types


More information about the Libreoffice-commits mailing list