summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-10-26 12:53:05 +0100
committerMichael Stahl <mstahl@redhat.com>2014-11-04 12:33:56 +0000
commitdb8cc3a1c481bd1f97b2688ff85a00eec8b25926 (patch)
tree529e2c703f52cbc03d4425634c8e76b8dc88ac31
parentbe7e9d72f4ca87476fbeda5bed48732244dc588b (diff)
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@redhat.com> Tested-by: Michael Stahl <mstahl@redhat.com>
-rw-r--r--sw/qa/extras/rtfimport/data/fdo82076.rtf13
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx11
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx19
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.hxx3
4 files changed, 44 insertions, 2 deletions
diff --git a/sw/qa/extras/rtfimport/data/fdo82076.rtf b/sw/qa/extras/rtfimport/data/fdo82076.rtf
new file mode 100644
index 000000000000..20b33e9385af
--- /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 520beee85586..1c3ed00a34ba 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 9339c5111f57..145fd4a3d67f 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 98a5523c3152..3cc9c51383a6 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