diff options
author | Michael Stahl <mstahl@redhat.com> | 2013-02-20 16:29:40 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2013-02-21 08:22:34 +0000 |
commit | a09865cc0f177a28622330866b3ad5baf4b99bd6 (patch) | |
tree | 06b13dd0fe83f5f6182d148a18807bc2b957eee8 | |
parent | 216257e8777c5cd2fe2ef68bfa6a1a953eb923be (diff) |
fdo#60789: writerfilter: continue the import if comment insertion fails
Catch exceptions in DomainMapper_Impl::PopFieldContext().
Change-Id: Ia60857a5f773c9d89217991d481a5f20d0de3151
(cherry picked from commit 4c165c708ce852b4d52527422b327b2f6ad73685)
Reviewed-on: https://gerrit.libreoffice.org/2294
Reviewed-by: Miklos Vajna <vmiklos@suse.cz>
Tested-by: Miklos Vajna <vmiklos@suse.cz>
-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 68449a094633..695a0f33de18 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -1574,23 +1574,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(); |