Kaydet (Commit) 6145c6ef authored tarafından Michael Stahl's avatar Michael Stahl

fdo#60789: writerfilter: do not insert a character at field start

The character inserted in DomainMapper_Impl::PushFieldContext() causes
problems in this bugdoc because there is a commentRangeStart immediately
before a text field and the call to delete it via setString("") disposes
the SwXTextRange that is stored in m_aAnnotationPosition.m_xStart,
which results in an exception when trying to insert the comment.

At least all the fields in the bugdoc import fine with this change.

Change-Id: I6c08d72fafb0529e8612f1e35b2c8b871edb5a52
üst 4c165c70
...@@ -2035,10 +2035,7 @@ void DomainMapper_Impl::PushFieldContext() ...@@ -2035,10 +2035,7 @@ void DomainMapper_Impl::PushFieldContext()
uno::Reference< text::XTextRange > xStart; uno::Reference< text::XTextRange > xStart;
if (xTextAppend.is()) if (xTextAppend.is())
{ {
//insert a dummy char to make sure the start range doesn't move together with the to-be-appended text
xTextAppend->appendTextPortion(OUString( '-' ), uno::Sequence< beans::PropertyValue >() );
uno::Reference< text::XTextCursor > xCrsr = xTextAppend->createTextCursorByRange( xTextAppend->getEnd() ); uno::Reference< text::XTextCursor > xCrsr = xTextAppend->createTextCursorByRange( xTextAppend->getEnd() );
xCrsr->goLeft( 1, false );
xStart = xCrsr->getStart(); xStart = xCrsr->getStart();
} }
m_aFieldStack.push( FieldContextPtr( new FieldContext( xStart ) ) ); m_aFieldStack.push( FieldContextPtr( new FieldContext( xStart ) ) );
...@@ -3312,9 +3309,6 @@ void DomainMapper_Impl::PopFieldContext() ...@@ -3312,9 +3309,6 @@ void DomainMapper_Impl::PopFieldContext()
try try
{ {
uno::Reference< text::XTextCursor > xCrsr = xTextAppend->createTextCursorByRange(pContext->GetStartRange()); uno::Reference< text::XTextCursor > xCrsr = xTextAppend->createTextCursorByRange(pContext->GetStartRange());
//remove the dummy character
xCrsr->goRight( 1, true );
xCrsr->setString( OUString() );
uno::Reference< text::XTextContent > xToInsert( pContext->GetTOC(), uno::UNO_QUERY ); uno::Reference< text::XTextContent > xToInsert( pContext->GetTOC(), uno::UNO_QUERY );
if( xToInsert.is() ) if( xToInsert.is() )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment