diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2023-01-05 18:07:03 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2023-01-06 20:46:30 +0000 |
commit | af920245710d1a51d98bba2c18b7002a32865e0b (patch) | |
tree | 61bfc29cc45a8d2ebf1cb0d05c79a432ca14c1ec /xmloff | |
parent | e073e4afe5eb460083944eb22dc8d87ad334877a (diff) |
tdf#152710 xmloff: ignore exception in XMLChangedRegionImportContext
The xOldCursor must be restored in all cases.
Also XMLParaContext triggers an exception which ends up aborting the
import.
Change-Id: I8f4785e0e9bde4c8c484954a4d66f3b82d6ca28c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145094
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
(cherry picked from commit e5b5d9c8d33b1dd87e5a50856ad02f21df59dc5b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145012
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/text/XMLChangedRegionImportContext.cxx | 11 | ||||
-rw-r--r-- | xmloff/source/text/txtparai.cxx | 17 |
2 files changed, 21 insertions, 7 deletions
diff --git a/xmloff/source/text/XMLChangedRegionImportContext.cxx b/xmloff/source/text/XMLChangedRegionImportContext.cxx index 4d43a8de3027..fe00c4a058b9 100644 --- a/xmloff/source/text/XMLChangedRegionImportContext.cxx +++ b/xmloff/source/text/XMLChangedRegionImportContext.cxx @@ -122,9 +122,14 @@ void XMLChangedRegionImportContext::endFastElement(sal_Int32 ) { // delete last paragraph // (one extra paragraph was inserted in the beginning) - rtl::Reference<XMLTextImportHelper> rHelper = - GetImport().GetTextImport(); - rHelper->DeleteParagraph(); + try + { + GetImport().GetTextImport()->DeleteParagraph(); + } + catch (uno::Exception const&) + { // cursor may be disposed - must reset to old cursor! + SAL_INFO("xmloff.text", "XMLChangedRegionImportContext: delete paragraph failed"); + } GetImport().GetTextImport()->SetCursor(xOldCursor); xOldCursor = nullptr; diff --git a/xmloff/source/text/txtparai.cxx b/xmloff/source/text/txtparai.cxx index 9844e2628c89..5fffc202612a 100644 --- a/xmloff/source/text/txtparai.cxx +++ b/xmloff/source/text/txtparai.cxx @@ -1688,10 +1688,19 @@ void XMLParaContext::endFastElement(sal_Int32 ) { rtl::Reference < XMLTextImportHelper > xTxtImport( GetImport().GetTextImport()); - Reference < XTextRange > xCrsrRange( xTxtImport->GetCursorAsRange() ); - if( !xCrsrRange.is() ) - return; // Robust (defective file) - Reference < XTextRange > xEnd(xCrsrRange->getStart()); + Reference<XTextRange> xEnd; + try + { + Reference<XTextRange> const xCrsrRange(xTxtImport->GetCursorAsRange()); + if (!xCrsrRange.is()) + return; // Robust (defective file) + xEnd = xCrsrRange->getStart(); + } + catch (uno::Exception const&) + { + SAL_INFO("xmloff.text", "XMLParaContext: cursor disposed?"); + return; + } // if we have an id set for this paragraph, get a cursor for this // paragraph and register it with the given identifier |