diff options
author | Michael Stahl <mstahl@redhat.com> | 2013-02-20 16:29:40 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2013-02-20 16:39:58 +0100 |
commit | 4c165c708ce852b4d52527422b327b2f6ad73685 (patch) | |
tree | f81aa0c91774d1d415869f02d3382630798ca30f /writerfilter | |
parent | 83b4703137fdf49304e41202cc91a5574b2e53e7 (diff) |
fdo#60789: writerfilter: continue the import if comment insertion fails
Catch exceptions in DomainMapper_Impl::PopFieldContext().
Change-Id: Ia60857a5f773c9d89217991d481a5f20d0de3151
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index fe100ff154d8..f5bc4867a26b 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(); |