writerfilter/source/dmapper/DomainMapper_Impl.cxx | 45 +++++++++++++++------- 1 file changed, 31 insertions(+), 14 deletions(-)
New commits: commit a09865cc0f177a28622330866b3ad5baf4b99bd6 Author: Michael Stahl <mst...@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 (cherry picked from commit 4c165c708ce852b4d52527422b327b2f6ad73685) Reviewed-on: https://gerrit.libreoffice.org/2294 Reviewed-by: Miklos Vajna <vmik...@suse.cz> Tested-by: Miklos Vajna <vmik...@suse.cz> diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 68449a0..695a0f3 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(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits