[Libreoffice-commits] core.git: 2 commits - writerfilter/source
Michael Stahl
mstahl at redhat.com
Wed Feb 20 07:43:11 PST 2013
writerfilter/source/dmapper/DomainMapper_Impl.cxx | 51 +++++++++++++---------
1 file changed, 31 insertions(+), 20 deletions(-)
New commits:
commit 6145c6efa4f346287ed9693c9d00038d829d5a35
Author: Michael Stahl <mstahl at redhat.com>
Date: Wed Feb 20 16:32:59 2013 +0100
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
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index f5bc486..28ad154 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -2035,10 +2035,7 @@ void DomainMapper_Impl::PushFieldContext()
uno::Reference< text::XTextRange > xStart;
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() );
- xCrsr->goLeft( 1, false );
xStart = xCrsr->getStart();
}
m_aFieldStack.push( FieldContextPtr( new FieldContext( xStart ) ) );
@@ -3312,9 +3309,6 @@ void DomainMapper_Impl::PopFieldContext()
try
{
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 );
if( xToInsert.is() )
{
commit 4c165c708ce852b4d52527422b327b2f6ad73685
Author: Michael Stahl <mstahl at redhat.com>
Date: Wed Feb 20 16:29:40 2013 +0100
fdo#60789: writerfilter: continue the import if comment insertion fails
Catch exceptions in DomainMapper_Impl::PopFieldContext().
Change-Id: Ia60857a5f773c9d89217991d481a5f20d0de3151
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index fe100ff..f5bc486 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1576,23 +1576,40 @@ void DomainMapper_Impl::PopAnnotation()
m_aTextAppendStack.pop();
- // See if the annotation will be a single position or a range.
- if (!m_aAnnotationPosition.m_xStart.is() || !m_aAnnotationPosition.m_xEnd.is())
+ try
{
- uno::Sequence< beans::PropertyValue > aEmptyProperties;
- appendTextContent( uno::Reference< text::XTextContent >( m_xAnnotationField, uno::UNO_QUERY_THROW ), aEmptyProperties );
+ // See if the annotation will be a single position or a range.
+ if (!m_aAnnotationPosition.m_xStart.is() ||
+ !m_aAnnotationPosition.m_xEnd.is())
+ {
+ uno::Sequence< beans::PropertyValue > aEmptyProperties;
+ appendTextContent(uno::Reference<text::XTextContent>(
+ m_xAnnotationField, uno::UNO_QUERY_THROW), aEmptyProperties);
+ }
+ else
+ {
+ // Create a range that points to the annotation start/end.
+ uno::Reference<text::XText> const xText =
+ m_aAnnotationPosition.m_xStart->getText();
+ uno::Reference<text::XTextCursor> const xCursor =
+ xText->createTextCursorByRange(m_aAnnotationPosition.m_xStart);
+ xCursor->gotoRange(m_aAnnotationPosition.m_xEnd, true);
+ uno::Reference<text::XTextRange> const xTextRange(
+ xCursor, uno::UNO_QUERY_THROW);
+
+ // Attach the annotation to the range.
+ uno::Reference<text::XTextAppend> const xTextAppend =
+ m_aTextAppendStack.top().xTextAppend;
+ xTextAppend->insertTextContent(xTextRange,
+ uno::Reference<text::XTextContent>(m_xAnnotationField,
+ uno::UNO_QUERY_THROW),
+ !xCursor->isCollapsed());
+ }
}
- else
+ catch (uno::Exception const& e)
{
- // Create a range that points to the annotation start/end.
- uno::Reference<text::XText> xText = m_aAnnotationPosition.m_xStart->getText();
- uno::Reference<text::XTextCursor> xCursor = xText->createTextCursorByRange(m_aAnnotationPosition.m_xStart);
- xCursor->gotoRange(m_aAnnotationPosition.m_xEnd, true);
- uno::Reference<text::XTextRange> xTextRange(xCursor, uno::UNO_QUERY_THROW);
-
- // Attach the annotation to the range.
- uno::Reference<text::XTextAppend> xTextAppend = m_aTextAppendStack.top().xTextAppend;
- xTextAppend->insertTextContent(xTextRange, uno::Reference<text::XTextContent>(m_xAnnotationField, uno::UNO_QUERY_THROW), !xCursor->isCollapsed());
+ SAL_WARN("writerfilter",
+ "Cannot insert annotation field: exception: " << e.Message);
}
m_aAnnotationPosition.m_xStart.clear();
More information about the Libreoffice-commits
mailing list