diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-08-17 15:42:01 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-08-18 11:03:02 +0200 |
commit | 7fc6063914432d58d86cfcbd728d967e7c86ebfd (patch) | |
tree | f71fe9f99edaa4e896c78cdf32e34b516194d748 /sw/source | |
parent | db83c41d460103df5d80f5bd99816575c4ead5cd (diff) |
use more Reference::query instead of UNO_QUERY_THROW
since querying with exceptions is consideably more expensive
Change-Id: I968a9a40766b2abb0d3058549b0ed44011fd5716
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155791
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/ole/ndole.cxx | 10 | ||||
-rw-r--r-- | sw/source/core/swg/SwXMLTextBlocks.cxx | 8 | ||||
-rw-r--r-- | sw/source/core/unocore/unochart.cxx | 9 | ||||
-rw-r--r-- | sw/source/filter/xml/wrtxml.cxx | 5 |
4 files changed, 14 insertions, 18 deletions
diff --git a/sw/source/core/ole/ndole.cxx b/sw/source/core/ole/ndole.cxx index de94986797f3..a3cb985d5c85 100644 --- a/sw/source/core/ole/ndole.cxx +++ b/sw/source/core/ole/ndole.cxx @@ -623,10 +623,12 @@ void SwOLENode::BreakFileLink_Impl() try { - uno::Reference< embed::XLinkageSupport > xLinkSupport( maOLEObj.GetOleRef(), uno::UNO_QUERY_THROW ); - xLinkSupport->breakLink( xStorage, maOLEObj.GetCurrentPersistName() ); - DisconnectFileLink_Impl(); - maLinkURL.clear(); + if (auto xLinkSupport = maOLEObj.GetOleRef().query<embed::XLinkageSupport>() ) + { + xLinkSupport->breakLink( xStorage, maOLEObj.GetCurrentPersistName() ); + DisconnectFileLink_Impl(); + maLinkURL.clear(); + } } catch( uno::Exception& ) { diff --git a/sw/source/core/swg/SwXMLTextBlocks.cxx b/sw/source/core/swg/SwXMLTextBlocks.cxx index 3bb108cbf22e..e264548e3c37 100644 --- a/sw/source/core/swg/SwXMLTextBlocks.cxx +++ b/sw/source/core/swg/SwXMLTextBlocks.cxx @@ -295,9 +295,11 @@ ErrCode SwXMLTextBlocks::StartPutBlock( const OUString& rShort, const OUString& { m_xRoot = m_xBlkRoot->openStorageElement( rPackageName, embed::ElementModes::READWRITE ); - uno::Reference< beans::XPropertySet > xRootProps( m_xRoot, uno::UNO_QUERY_THROW ); - OUString aMime( SotExchange::GetFormatMimeType( SotClipboardFormatId::STARWRITER_8 ) ); - xRootProps->setPropertyValue( "MediaType", uno::Any( aMime ) ); + if (auto xRootProps = m_xRoot.query<beans::XPropertySet>() ) + { + OUString aMime( SotExchange::GetFormatMimeType( SotClipboardFormatId::STARWRITER_8 ) ); + xRootProps->setPropertyValue( "MediaType", uno::Any( aMime ) ); + } } catch (const uno::Exception&) { diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx index e5265acc4fec..d14a58badb60 100644 --- a/sw/source/core/unocore/unochart.cxx +++ b/sw/source/core/unocore/unochart.cxx @@ -69,15 +69,8 @@ void SwChartHelper::DoUpdateAllCharts( SwDoc* pDoc ) uno::Reference < embed::XEmbeddedObject > xIP = pONd->GetOLEObj().GetOleRef(); if ( svt::EmbeddedObjectRef::TryRunningState( xIP ) ) { - try - { - uno::Reference< util::XModifiable > xModif( xIP->getComponent(), uno::UNO_QUERY_THROW ); + if (auto xModif = xIP->getComponent().query<util::XModifiable>() ) xModif->setModified( true ); - } - catch ( uno::Exception& ) - { - } - } } aIdx.Assign( *pStNd->EndOfSectionNode(), + 1 ); diff --git a/sw/source/filter/xml/wrtxml.cxx b/sw/source/filter/xml/wrtxml.cxx index a5b0560c1c5a..b302c91c9388 100644 --- a/sw/source/filter/xml/wrtxml.cxx +++ b/sw/source/filter/xml/wrtxml.cxx @@ -307,9 +307,8 @@ ErrCode SwXMLWriter::Write_(const SfxItemSet* pMediumItemSet) && Version != ODFVER_010_TEXT && Version != ODFVER_011_TEXT) { - const uno::Reference<rdf::XDocumentMetadataAccess> xDMA( - xModelComp, uno::UNO_QUERY_THROW); - xDMA->storeMetadataToStorage(m_xStg); + if (auto xDMA = xModelComp.query<rdf::XDocumentMetadataAccess>()) + xDMA->storeMetadataToStorage(m_xStg); } } catch (beans::UnknownPropertyException &) |