From 14b7b50701e3874034f7f98a73794ba8a79792bf Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 13 Aug 2024 13:29:23 +0200 Subject: use less exception throwing for flow control Change-Id: I289f1a2204af02576a585392b7f428a5dc65cf1a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171850 Reviewed-by: Noel Grandin Tested-by: Jenkins --- sw/source/ui/vba/vbadocument.cxx | 14 ++++++++++---- sw/source/ui/vba/vbarange.cxx | 5 +++-- 2 files changed, 13 insertions(+), 6 deletions(-) (limited to 'sw/source/ui/vba') diff --git a/sw/source/ui/vba/vbadocument.cxx b/sw/source/ui/vba/vbadocument.cxx index 2588c153788a..c7a110d016ef 100644 --- a/sw/source/ui/vba/vbadocument.cxx +++ b/sw/source/ui/vba/vbadocument.cxx @@ -692,13 +692,19 @@ SwVbaDocument::getFormControls() const uno::Reference< container::XNameAccess > xFormControls; try { - uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( mxTextDocument, uno::UNO_QUERY_THROW ); - uno::Reference< form::XFormsSupplier > xFormSupplier( xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY_THROW ); - uno::Reference< container::XIndexAccess > xIndexAccess( xFormSupplier->getForms(), uno::UNO_QUERY_THROW ); + uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( mxTextDocument, uno::UNO_QUERY ); + if (!xDrawPageSupplier) + return xFormControls; + uno::Reference< form::XFormsSupplier > xFormSupplier( xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY ); + if (!xFormSupplier) + return xFormControls; + uno::Reference< container::XIndexAccess > xIndexAccess( xFormSupplier->getForms(), uno::UNO_QUERY ); + if (!xIndexAccess) + return xFormControls; // get the www-standard container ( maybe we should access the // 'www-standard' by name rather than index, this seems an // implementation detail - xFormControls.set( xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW ); + xFormControls.set( xIndexAccess->getByIndex(0), uno::UNO_QUERY ); } catch(const uno::Exception&) { diff --git a/sw/source/ui/vba/vbarange.cxx b/sw/source/ui/vba/vbarange.cxx index 39d369c92144..722dcfce92b1 100644 --- a/sw/source/ui/vba/vbarange.cxx +++ b/sw/source/ui/vba/vbarange.cxx @@ -134,8 +134,9 @@ SwVbaRange::setText( const OUString& rText ) uno::Reference< text::XTextContent > xBookmark = SwVbaRangeHelper::findBookmarkByPosition( mxTextDocument, xRange->getStart() ); if( xBookmark.is() ) { - uno::Reference< container::XNamed > xNamed( xBookmark, uno::UNO_QUERY_THROW ); - sName = xNamed->getName(); + uno::Reference< container::XNamed > xNamed( xBookmark, uno::UNO_QUERY ); + if (xNamed) + sName = xNamed->getName(); } } catch (const uno::Exception&) -- cgit