summaryrefslogtreecommitdiff
path: root/vbahelper
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2023-08-17 15:42:01 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-08-18 11:03:02 +0200
commit7fc6063914432d58d86cfcbd728d967e7c86ebfd (patch)
treef71fe9f99edaa4e896c78cdf32e34b516194d748 /vbahelper
parentdb83c41d460103df5d80f5bd99816575c4ead5cd (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 'vbahelper')
-rw-r--r--vbahelper/source/msforms/vbauserform.cxx6
-rw-r--r--vbahelper/source/vbahelper/vbacolorformat.cxx8
-rw-r--r--vbahelper/source/vbahelper/vbadocumentbase.cxx13
-rw-r--r--vbahelper/source/vbahelper/vbadocumentsbase.cxx31
4 files changed, 21 insertions, 37 deletions
diff --git a/vbahelper/source/msforms/vbauserform.cxx b/vbahelper/source/msforms/vbauserform.cxx
index 66aa6eff7198..50ba5a39ad90 100644
--- a/vbahelper/source/msforms/vbauserform.cxx
+++ b/vbahelper/source/msforms/vbauserform.cxx
@@ -88,16 +88,12 @@ ScVbaUserForm::Show( )
if ( !mbDispose )
return;
- try
+ if (auto xComp = m_xDialog.query<lang::XComponent>() )
{
- uno::Reference< lang::XComponent > xComp( m_xDialog, uno::UNO_QUERY_THROW );
m_xDialog = nullptr;
xComp->dispose();
mbDispose = false;
}
- catch( uno::Exception& )
- {
- }
}
OUString SAL_CALL
diff --git a/vbahelper/source/vbahelper/vbacolorformat.cxx b/vbahelper/source/vbahelper/vbacolorformat.cxx
index 56180a98fb6a..8f0ad989c197 100644
--- a/vbahelper/source/vbahelper/vbacolorformat.cxx
+++ b/vbahelper/source/vbahelper/vbacolorformat.cxx
@@ -43,14 +43,10 @@ ScVbaColorFormat::ScVbaColorFormat( const uno::Reference< XHelperInterface >& xP
{
m_xPropertySet.set( xShape, uno::UNO_QUERY_THROW );
m_nFillFormatBackColor = 0;
- try
- {
- uno::Reference< ov::msforms::XFillFormat > xFillFormat( xInternalParent, uno::UNO_QUERY_THROW );
+ if (auto xFillFormat = xInternalParent.query<ov::msforms::XFillFormat>() )
m_pFillFormat = static_cast<ScVbaFillFormat*>( xFillFormat.get() );
- }catch ( uno::RuntimeException& )
- {
+ else
m_pFillFormat = nullptr;
- }
}
// Attribute
diff --git a/vbahelper/source/vbahelper/vbadocumentbase.cxx b/vbahelper/source/vbahelper/vbadocumentbase.cxx
index 0a2cc5b8705b..5231a1497135 100644
--- a/vbahelper/source/vbahelper/vbadocumentbase.cxx
+++ b/vbahelper/source/vbahelper/vbadocumentbase.cxx
@@ -192,16 +192,11 @@ VbaDocumentBase::Close( const uno::Any &rSaveArg, const uno::Any &rFileArg,
if (bCloseable)
return;
- try {
- // If close is not supported by this model - try to dispose it.
- // But if the model disagree with a reset request for the modify state
- // we shouldn't do so. Otherwise some strange things can happen.
- uno::Reference< lang::XComponent > xDisposable ( xModel, uno::UNO_QUERY_THROW );
+ // If close is not supported by this model - try to dispose it.
+ // But if the model disagree with a reset request for the modify state
+ // we shouldn't do so. Otherwise some strange things can happen.
+ if (auto xDisposable = xModel.query<lang::XComponent>() )
xDisposable->dispose();
- }
- catch(const uno::Exception&)
- {
- }
}
void
diff --git a/vbahelper/source/vbahelper/vbadocumentsbase.cxx b/vbahelper/source/vbahelper/vbadocumentsbase.cxx
index 6db5b5a4cac0..d35b4e3f83ed 100644
--- a/vbahelper/source/vbahelper/vbadocumentsbase.cxx
+++ b/vbahelper/source/vbahelper/vbadocumentsbase.cxx
@@ -198,24 +198,21 @@ namespace {
void lclSetupComponent( const uno::Reference< lang::XComponent >& rxComponent, bool bScreenUpdating, bool bInteractive )
{
- if( !bScreenUpdating ) try
- {
- uno::Reference< frame::XModel >( rxComponent, uno::UNO_QUERY_THROW )->lockControllers();
- }
- catch( uno::Exception& )
- {
- }
+ auto xModel = rxComponent.query<frame::XModel>();
+ if( !bScreenUpdating && xModel )
+ xModel->lockControllers();
- if( !bInteractive ) try
- {
- uno::Reference< frame::XModel > xModel( rxComponent, uno::UNO_QUERY_THROW );
- uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_SET_THROW );
- uno::Reference< frame::XFrame > xFrame( xController->getFrame(), uno::UNO_SET_THROW );
- uno::Reference< awt::XWindow >( xFrame->getContainerWindow(), uno::UNO_SET_THROW )->setEnable( false );
- }
- catch( uno::Exception& )
- {
- }
+ if( !bInteractive )
+ try
+ {
+ if (auto xController = xModel->getCurrentController().query<frame::XController>() )
+ if (auto xFrame = xController->getFrame().query<frame::XFrame>() )
+ if (auto xWindow = xFrame->getContainerWindow().query<awt::XWindow>() )
+ xWindow->setEnable( false );
+ }
+ catch( uno::Exception& )
+ {
+ }
}
} // namespace