summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-07-24 14:40:53 +0200
committerAndras Timar <andras.timar@collabora.com>2015-09-28 10:06:42 +0200
commit5af4e8e37e187949724ac4f57573341429bdebf8 (patch)
tree5a127a9003e98d09eb7d112c6f19099fc235258a
parent3775e7ae5d36e85a9cee17e519925084fc327815 (diff)
tdf#90046: RTF import: ensure that a run is started before \footnote
Avoids crashing with empty context stacks. (cherry picked from commit a61fd02c819433a1206b3b3e61017ba2d0d3d467) Reviewed-on: https://gerrit.libreoffice.org/17333 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com> (cherry picked from commit 7e086276cd27bac93040bfd7ff5f5dbdfc0b9f86) Conflicts: writerfilter/source/rtftok/rtfdocumentimpl.cxx Change-Id: I0ee8b457fdbb19b55f5c15876b7253680cde6e23
-rw-r--r--sw/qa/extras/rtfimport/data/tdf90046.rtf8
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx9
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx1
3 files changed, 18 insertions, 0 deletions
diff --git a/sw/qa/extras/rtfimport/data/tdf90046.rtf b/sw/qa/extras/rtfimport/data/tdf90046.rtf
new file mode 100644
index 000000000000..656adb568358
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/tdf90046.rtf
@@ -0,0 +1,8 @@
+{\rtf1\ansi\deflang1035
+{\fonttbl {\f0\fcharset0 Arial;} }
+
+\pard\ltrpar\uc1\lang1035
+{\super \chftn
+{\footnote {\pard\plain\super \chftn }{\plain\ltrch\f0 \fs18 \cf1 \uc0\u77 \u97 }
+}}
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 1eb7ca6cbef0..79cfcefcdfc7 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -2066,6 +2066,15 @@ DECLARE_RTFIMPORT_TEST(testFdo85889pca, "fdo85889-pca.rtf")
CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString());
}
+DECLARE_RTFIMPORT_TEST(testTdf90046, "tdf90046.rtf")
+{
+ // this was crashing on importing the footnote
+ uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xTextRange(xFootnotes->getByIndex(0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("Ma"), xTextRange->getString());
+}
+
DECLARE_RTFIMPORT_TEST(testFdo85889mac, "fdo85889-mac.rtf")
{
uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1);
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index be1eae9052a4..0ba1af894778 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1657,6 +1657,7 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
}
break;
case RTF_FOOTNOTE:
+ checkFirstRun();
if (!m_pSuperstream)
{
Id nId = NS_ooxml::LN_footnote;