summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2013-08-12 11:53:45 +0200
committerTor Lillqvist <tml@iki.fi>2013-08-12 12:52:43 +0000
commiteb27a889d5c3f20dc6c1eecf7f588e54fa08a9f7 (patch)
tree0e3bd6840488cc81203d62d0b5be0d9880ae9b94 /sw
parent885858677b3e6d4c379837ca8305869e94e9f31a (diff)
fdo#63428 writerfilter: fix paste of commented text ranges
There were multiple problems here: - xFoo->createTextCursorByRange() got a text range argument, where the text range wasn't from the xFoo text - it was assumed that all XText implements text::XParagraphCursor as well, but this is not true for e.g. comment text - commented text ranges were pasted as normal comments (once again, the insert position wasn't passed around) (cherry picked from commit c73b8072a1732f829d3d6ba6c1172d96d55b1c4f) Change-Id: I9a975a08b08a7f32b1ee71e42f58736cc0dbb09d Reviewed-on: https://gerrit.libreoffice.org/5368 Reviewed-by: Tor Lillqvist <tml@iki.fi> Tested-by: Tor Lillqvist <tml@iki.fi>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/rtfimport/data/fdo63428.rtf8
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx15
2 files changed, 23 insertions, 0 deletions
diff --git a/sw/qa/extras/rtfimport/data/fdo63428.rtf b/sw/qa/extras/rtfimport/data/fdo63428.rtf
new file mode 100644
index 000000000000..826d4ca063e2
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo63428.rtf
@@ -0,0 +1,8 @@
+{\rtf1\ansi\ansicpg1252\cocoartf1187\cocoasubrtf390
+\stshfdbch0{\fonttbl\f0\fnil\fcharset0 Verdana;}
+{\colortbl;\red255\green255\blue255;}
+\paperw12240\paperh15840\margl1800\margr1800\margt1440\margb1440\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\fi360\sl288\slmult1\pardirnatural
+
+\f0\fs28 \cf0 {\*\atrfstart 1}\f0\fs28\b0\i0\ul0 hello{\*\atrfend 1}\f0\fs28\b0\i0\ul0 {\chatn{\*\annotation{\*\atnref 1}\pard\plain\f0\fs28\b0\i0\ul0
+\fs20 crash
+\fs28 }}\f0\fs28\b0 \i0 \ul0 } \ No newline at end of file
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 0a56525d14e4..fc276f646aa0 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -155,6 +155,7 @@ public:
void testFdo47440();
void testPoshPosv();
void testFdo53556();
+ void testFdo63428();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -294,6 +295,7 @@ void Test::run()
{"fdo47440.rtf", &Test::testFdo47440},
{"posh-posv.rtf", &Test::testPoshPosv},
{"fdo53556.rtf", &Test::testFdo53556},
+ {"hello.rtf", &Test::testFdo63428},
};
header();
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@@ -1417,6 +1419,19 @@ void Test::testFdo53556()
CPPUNIT_ASSERT_EQUAL(OUString("FrameShape"), xShapeDescriptor->getShapeType());
}
+void Test::testFdo63428()
+{
+ // Pasting content that contained an annotation caused a crash.
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xText(xTextDocument->getText(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xEnd = xText->getEnd();
+ paste("fdo63428.rtf", xEnd);
+
+ // Additionally, commented range was imported as a normal comment.
+ CPPUNIT_ASSERT_EQUAL(OUString("TextFieldStart"), getProperty<OUString>(getRun(getParagraph(1), 2), "TextPortionType"));
+ CPPUNIT_ASSERT_EQUAL(OUString("TextFieldEnd"), getProperty<OUString>(getRun(getParagraph(1), 4), "TextPortionType"));
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();