diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2023-03-31 19:15:11 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-04-01 14:42:17 +0200 |
commit | bfdf5d290be3fccb631d50cfea52fbe43fff4dce (patch) | |
tree | 7b89956506092aa6ee68cc559a83b158170439e6 /vbahelper | |
parent | cd013e66711c056c52ffd0839e782f6ee9c2dabd (diff) |
use more XVclWindowPeer
Rather than using it's superclass XWindowPeer and implicitly relying on it being XVclWindowPeer and casting it everywhere.
Change-Id: Icfb46f3b920d00f4a167a31803a71bbb0368d05c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149894
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vbahelper')
-rw-r--r-- | vbahelper/source/msforms/vbacontrol.cxx | 34 | ||||
-rw-r--r-- | vbahelper/source/msforms/vbacontrol.hxx | 4 |
2 files changed, 21 insertions, 17 deletions
diff --git a/vbahelper/source/msforms/vbacontrol.cxx b/vbahelper/source/msforms/vbacontrol.cxx index 8dd5363d59d7..cb21c75a8be4 100644 --- a/vbahelper/source/msforms/vbacontrol.cxx +++ b/vbahelper/source/msforms/vbacontrol.cxx @@ -65,7 +65,7 @@ using namespace com::sun::star; using namespace ooo::vba; -uno::Reference< css::awt::XWindowPeer > +uno::Reference< css::awt::XVclWindowPeer > ScVbaControl::getWindowPeer() { uno::Reference< drawing::XControlShape > xControlShape( m_xControl, uno::UNO_QUERY ); @@ -76,23 +76,27 @@ ScVbaControl::getWindowPeer() { // would seem to be a Userform control uno::Reference< awt::XControl > xControl( m_xControl, uno::UNO_QUERY_THROW ); - xWinPeer = xControl->getPeer(); - return xWinPeer; + xWinPeer = xControl->getPeer(); } - // form control - xControlModel.set( xControlShape->getControl(), uno::UNO_SET_THROW ); - - uno::Reference< view::XControlAccess > xControlAccess( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW ); - try - { - uno::Reference< awt::XControl > xControl = xControlAccess->getControl( xControlModel ); - xWinPeer = xControl->getPeer(); - } - catch(const uno::Exception&) + else { - throw uno::RuntimeException( "The Control does not exist" ); + // form control + xControlModel.set( xControlShape->getControl(), uno::UNO_SET_THROW ); + + uno::Reference< view::XControlAccess > xControlAccess( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW ); + try + { + uno::Reference< awt::XControl > xControl = xControlAccess->getControl( xControlModel ); + xWinPeer = xControl->getPeer(); + } + catch(const uno::Exception&) + { + throw uno::RuntimeException( "The Control does not exist" ); + } } - return xWinPeer; + uno::Reference< css::awt::XVclWindowPeer > xVclWinPeer(xWinPeer, uno::UNO_QUERY); + assert(xVclWinPeer || !xWinPeer); + return xVclWinPeer; } namespace { diff --git a/vbahelper/source/msforms/vbacontrol.hxx b/vbahelper/source/msforms/vbacontrol.hxx index 033db5351733..7d0066112eb7 100644 --- a/vbahelper/source/msforms/vbacontrol.hxx +++ b/vbahelper/source/msforms/vbacontrol.hxx @@ -23,7 +23,7 @@ #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/drawing/XControlShape.hpp> #include <com/sun/star/awt/XControl.hpp> -#include <com/sun/star/awt/XWindowPeer.hpp> +#include <com/sun/star/awt/XVclWindowPeer.hpp> #include <com/sun/star/script/ScriptEvent.hpp> #include <ooo/vba/msforms/XControl.hpp> @@ -50,7 +50,7 @@ protected: css::uno::Reference< css::frame::XModel > m_xModel; /// @throws css::uno::RuntimeException - css::uno::Reference< css::awt::XWindowPeer > getWindowPeer(); + css::uno::Reference< css::awt::XVclWindowPeer > getWindowPeer(); void fireChangeEvent(); void fireClickEvent(); public: |