diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-08-25 11:30:42 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-08-25 14:15:56 +0200 |
commit | 87db52ab1e9c39ad8319aaf9c0c59d4435b6ffb5 (patch) | |
tree | 64795c67bc154c4d5bcf4287139d1db7e11c9a6c /vbahelper | |
parent | 139cffc531277b57bae8e272fef13af00ace5366 (diff) |
Revert "use more Reference::query instead of UNO_QUERY_THROW"
This reverts commit 7fc6063914432d58d86cfcbd728d967e7c86ebfd.
sberg noticed that there is a difference now:
there's a subtle difference now, in that if y was null originally, it would have thrown a (caught) exception, whereas now it will crash in the y.query<X>() call.
Change-Id: Idbb5a08d635d15b5ca63f4822eddf05fb0a5afa0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156002
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vbahelper')
-rw-r--r-- | vbahelper/source/msforms/vbauserform.cxx | 6 | ||||
-rw-r--r-- | vbahelper/source/vbahelper/vbacolorformat.cxx | 8 | ||||
-rw-r--r-- | vbahelper/source/vbahelper/vbadocumentbase.cxx | 13 | ||||
-rw-r--r-- | vbahelper/source/vbahelper/vbadocumentsbase.cxx | 31 |
4 files changed, 37 insertions, 21 deletions
diff --git a/vbahelper/source/msforms/vbauserform.cxx b/vbahelper/source/msforms/vbauserform.cxx index 50ba5a39ad90..66aa6eff7198 100644 --- a/vbahelper/source/msforms/vbauserform.cxx +++ b/vbahelper/source/msforms/vbauserform.cxx @@ -88,12 +88,16 @@ ScVbaUserForm::Show( ) if ( !mbDispose ) return; - if (auto xComp = m_xDialog.query<lang::XComponent>() ) + try { + 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 8f0ad989c197..56180a98fb6a 100644 --- a/vbahelper/source/vbahelper/vbacolorformat.cxx +++ b/vbahelper/source/vbahelper/vbacolorformat.cxx @@ -43,10 +43,14 @@ ScVbaColorFormat::ScVbaColorFormat( const uno::Reference< XHelperInterface >& xP { m_xPropertySet.set( xShape, uno::UNO_QUERY_THROW ); m_nFillFormatBackColor = 0; - if (auto xFillFormat = xInternalParent.query<ov::msforms::XFillFormat>() ) + try + { + uno::Reference< ov::msforms::XFillFormat > xFillFormat( xInternalParent, uno::UNO_QUERY_THROW ); m_pFillFormat = static_cast<ScVbaFillFormat*>( xFillFormat.get() ); - else + }catch ( uno::RuntimeException& ) + { m_pFillFormat = nullptr; + } } // Attribute diff --git a/vbahelper/source/vbahelper/vbadocumentbase.cxx b/vbahelper/source/vbahelper/vbadocumentbase.cxx index 5231a1497135..0a2cc5b8705b 100644 --- a/vbahelper/source/vbahelper/vbadocumentbase.cxx +++ b/vbahelper/source/vbahelper/vbadocumentbase.cxx @@ -192,11 +192,16 @@ VbaDocumentBase::Close( const uno::Any &rSaveArg, const uno::Any &rFileArg, if (bCloseable) return; - // 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>() ) + 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 ); xDisposable->dispose(); + } + catch(const uno::Exception&) + { + } } void diff --git a/vbahelper/source/vbahelper/vbadocumentsbase.cxx b/vbahelper/source/vbahelper/vbadocumentsbase.cxx index d35b4e3f83ed..6db5b5a4cac0 100644 --- a/vbahelper/source/vbahelper/vbadocumentsbase.cxx +++ b/vbahelper/source/vbahelper/vbadocumentsbase.cxx @@ -198,21 +198,24 @@ namespace { void lclSetupComponent( const uno::Reference< lang::XComponent >& rxComponent, bool bScreenUpdating, bool bInteractive ) { - auto xModel = rxComponent.query<frame::XModel>(); - if( !bScreenUpdating && xModel ) - xModel->lockControllers(); + if( !bScreenUpdating ) try + { + uno::Reference< frame::XModel >( rxComponent, uno::UNO_QUERY_THROW )->lockControllers(); + } + 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& ) - { - } + 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& ) + { + } } } // namespace |