summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-10-26 12:53:05 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-10-26 15:17:31 +0100
commit956c3ff3d43e1b181f7c91518edee1c7c4dc2a0a (patch)
tree7fe2c011b6f54fdc5e6bc3ec03cd1c906020d08b
parent89a04240222ff6909d37debcbf5dce614c4dd1c8 (diff)
fdo#82076 RTF import: handle footnote in table cell
Change-Id: I69def7936c320e93db5d4504922d52346caaf9cf
-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 6ecd7a398247..90ae2eff8bf2 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -1996,6 +1996,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 8dbf3b0d47f5..cfba3804793a 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1488,6 +1488,14 @@ void RTFDocumentImpl::replayBuffer(RTFBuffer_t& rBuffer,
m_pSdrImport->resolve(boost::get<1>(aTuple)->getShape(), false, 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);
}
@@ -1707,7 +1715,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 2f342991f162..85af01fdb90d 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -56,7 +56,8 @@ enum RTFBufferTypes
BUFFER_ENDRUN,
BUFFER_PAR,
BUFFER_STARTSHAPE,
- BUFFER_ENDSHAPE
+ BUFFER_ENDSHAPE,
+ BUFFER_RESOLVESUBSTREAM
};
/// Form field types