summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2013-01-15 09:58:48 +0100
committerNoel Power <noel.power@suse.com>2013-01-15 12:02:08 +0000
commit2ad8c6c786d7d07130ee6968d89f0be8e7bd7165 (patch)
treef6ca956ce48e60817a50336e70e80c6175dcd625 /sw
parent371983fb8252356b36f8d424dbceba318c14609d (diff)
fdo#59338 fix RTF paste into footnote
(cherry picked from commit b6a2083b9dfe5aceb0900315363ef41e2f3abef5) Change-Id: I89501f267fd4256eb3b1316ef41a0f9b0786e0f0 Reviewed-on: https://gerrit.libreoffice.org/1691 Reviewed-by: Noel Power <noel.power@suse.com> Tested-by: Noel Power <noel.power@suse.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/rtfimport/data/copypaste-footnote-paste.rtf3
-rw-r--r--sw/qa/extras/rtfimport/data/copypaste-footnote.rtf6
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx27
3 files changed, 36 insertions, 0 deletions
diff --git a/sw/qa/extras/rtfimport/data/copypaste-footnote-paste.rtf b/sw/qa/extras/rtfimport/data/copypaste-footnote-paste.rtf
new file mode 100644
index 000000000000..1f4a75e44629
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/copypaste-footnote-paste.rtf
@@ -0,0 +1,3 @@
+{\rtf1
+bbb
+\par }
diff --git a/sw/qa/extras/rtfimport/data/copypaste-footnote.rtf b/sw/qa/extras/rtfimport/data/copypaste-footnote.rtf
new file mode 100644
index 000000000000..93e4613397e5
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/copypaste-footnote.rtf
@@ -0,0 +1,6 @@
+{\rtf1
+aaa
+{\super \chftn
+{\*\footnote \chftn\pard\plain \li339\fi-339 \par}
+}
+\par }
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 68b7aa5c6144..3dc2f1b6908b 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -117,6 +117,7 @@ public:
void testFdo52475();
void testFdo55493();
void testCopyPastePageStyle();
+ void testCopyPasteFootnote();
void testShptxtPard();
void testDoDhgt();
void testDplinehollow();
@@ -202,6 +203,7 @@ void Test::run()
{"fdo52475.rtf", &Test::testFdo52475},
{"fdo55493.rtf", &Test::testFdo55493},
{"copypaste-pagestyle.rtf", &Test::testCopyPastePageStyle},
+ {"copypaste-footnote.rtf", &Test::testCopyPasteFootnote},
{"shptxt-pard.rtf", &Test::testShptxtPard},
{"do-dhgt.rtf", &Test::testDoDhgt},
{"dplinehollow.rtf", &Test::testDplinehollow},
@@ -861,6 +863,31 @@ void Test::testCopyPastePageStyle()
CPPUNIT_ASSERT_EQUAL(sal_Int32(21001), getProperty<sal_Int32>(xPropertySet, "Width")); // Was letter, i.e. 21590
}
+void Test::testCopyPasteFootnote()
+{
+ // The RTF import did not handle the case when the position wasn't the main document XText, but something different, e.g. a 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);
+
+ uno::Reference<uno::XInterface> xInterface(m_xSFactory->createInstance("com.sun.star.comp.Writer.RtfFilter"), uno::UNO_QUERY_THROW);
+ uno::Reference<document::XImporter> xImporter(xInterface, uno::UNO_QUERY_THROW);
+ xImporter->setTargetDocument(mxComponent);
+ uno::Reference<document::XFilter> xFilter(xInterface, uno::UNO_QUERY_THROW);
+ uno::Sequence<beans::PropertyValue> aDescriptor(3);
+ aDescriptor[0].Name = "InputStream";
+ SvStream* pStream = utl::UcbStreamHelper::CreateStream(getURLFromSrc("/sw/qa/extras/rtfimport/data/") + "copypaste-footnote-paste.rtf", STREAM_WRITE);
+ uno::Reference<io::XStream> xStream(new utl::OStreamWrapper(*pStream));
+ aDescriptor[0].Value <<= xStream;
+ aDescriptor[1].Name = "IsNewDoc";
+ aDescriptor[1].Value <<= sal_False;
+ aDescriptor[2].Name = "TextInsertModeRange";
+ aDescriptor[2].Value <<= xTextRange;
+ xFilter->filter(aDescriptor);
+
+ CPPUNIT_ASSERT_EQUAL(OUString("bbb"), xTextRange->getString());
+}
+
void Test::testShptxtPard()
{
// The problem was that \pard inside \shptxt caused loss of shape text