summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/qa/extras/rtfimport/data/fdo63428.rtf8
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx15
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx13
3 files changed, 32 insertions, 4 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 c258d7cc5ae3..4e9e8818abc7 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -162,6 +162,7 @@ public:
void testFdo67498();
void testFdo47440();
void testFdo53556();
+ void testFdo63428();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -308,6 +309,7 @@ void Test::run()
{"fdo67498.rtf", &Test::testFdo67498},
{"fdo47440.rtf", &Test::testFdo47440},
{"fdo53556.rtf", &Test::testFdo53556},
+ {"hello.rtf", &Test::testFdo63428},
};
header();
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@@ -1505,6 +1507,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();
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index eb8fd3ce749e..56c476580591 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -290,7 +290,7 @@ void DomainMapper_Impl::RemoveLastParagraph( )
uno::Reference<lang::XComponent> xParagraph(xEnumeration->nextElement(), uno::UNO_QUERY);
xParagraph->dispose();
}
- else
+ else if (xCursor.is())
{
xCursor->goLeft( 1, true );
// If this is a text on a shape, possibly the text has the trailing
@@ -1603,7 +1603,7 @@ void DomainMapper_Impl::PushAnnotation()
uno::Reference< text::XText > xAnnotationText;
m_xAnnotationField->getPropertyValue("TextRange") >>= xAnnotationText;
m_aTextAppendStack.push(TextAppendContext(uno::Reference< text::XTextAppend >( xAnnotationText, uno::UNO_QUERY_THROW ),
- m_bIsNewDoc ? uno::Reference<text::XTextCursor>() : m_xBodyText->createTextCursorByRange(xAnnotationText->getStart())));
+ m_bIsNewDoc ? uno::Reference<text::XTextCursor>() : xAnnotationText->createTextCursorByRange(xAnnotationText->getStart())));
}
catch( const uno::Exception& rException)
{
@@ -3626,8 +3626,13 @@ void DomainMapper_Impl::AddAnnotationPosition(const bool bStart)
uno::Reference<text::XTextRange> xCurrent;
if (xTextAppend.is())
{
- uno::Reference<text::XTextCursor> xCursor = xTextAppend->createTextCursorByRange(xTextAppend->getEnd());
- xCurrent = xCursor->getStart();
+ uno::Reference<text::XTextCursor> xCursor;
+ if (m_bIsNewDoc)
+ xCursor = xTextAppend->createTextCursorByRange(xTextAppend->getEnd());
+ else
+ xCursor = m_aTextAppendStack.top().xCursor;
+ if (xCursor.is())
+ xCurrent = xCursor->getStart();
}
// And save it, to be used by PopAnnotation() later.