From f7a86c5cdf4323c99d26512bf78de7f7c380667d Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 12 May 2021 15:07:37 +0200 Subject: simplify the vcl<->toolkit connection No need to store two different pointers and hide the underlying class behind an UNO interface Change-Id: I72c55e912caa9eae1cffa6c9d1b1d480e5668d40 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115496 Tested-by: Jenkins Reviewed-by: Noel Grandin --- accessibility/source/extended/accessibletabbar.cxx | 2 +- .../source/standard/accessiblemenucomponent.cxx | 2 +- .../accessibility/accessibledialogcontrolshape.cxx | 2 +- .../accessibility/accessibledialogwindow.cxx | 2 +- basctl/source/basicide/baside2.hxx | 2 +- basctl/source/basicide/baside2b.cxx | 9 +++--- basctl/source/basicide/textwindowpeer.cxx | 2 +- basctl/source/basicide/textwindowpeer.hxx | 9 ++---- chart2/source/controller/main/ChartController.cxx | 2 +- .../source/ui/querydesign/ConnectionLineAccess.cxx | 2 +- dbaccess/source/ui/querydesign/JAccess.cxx | 2 +- .../source/ui/querydesign/TableWindowAccess.cxx | 2 +- extensions/source/bibliography/bibload.cxx | 2 +- extensions/source/bibliography/framectr.cxx | 6 ++-- forms/source/richtext/richtextcontrol.cxx | 2 +- forms/source/solar/component/navbarcontrol.cxx | 2 +- include/vcl/toolkit/unowrap.hxx | 5 ++-- include/vcl/window.hxx | 12 +++++--- sc/source/ui/view/gridwin.cxx | 2 +- sd/source/ui/presenter/PresenterHelper.cxx | 2 +- sfx2/source/doc/iframe.cxx | 4 +-- sfx2/source/view/ipclient.cxx | 3 +- sfx2/source/view/sfxbasecontroller.cxx | 2 +- sfx2/source/view/userinputinterception.cxx | 4 +-- sw/source/uibase/docvw/AnnotationWin2.cxx | 2 +- toolkit/inc/controls/svmedit.hxx | 2 +- toolkit/inc/helper/unowrapper.hxx | 4 +-- toolkit/source/awt/vclxaccessiblecomponent.cxx | 2 +- toolkit/source/awt/vclxtoolkit.cxx | 6 ++-- toolkit/source/awt/vclxwindow.cxx | 2 +- toolkit/source/controls/svmedit.cxx | 7 ++--- toolkit/source/helper/unowrapper.cxx | 22 +++++++------- vcl/inc/window.h | 3 +- vcl/qa/cppunit/lifecycle.cxx | 2 +- vcl/source/app/salvtables.cxx | 7 ++--- vcl/source/control/fmtfield.cxx | 2 +- vcl/source/control/ivctrl.cxx | 3 +- vcl/source/treelist/treelistbox.cxx | 3 +- vcl/source/window/accessibility.cxx | 4 +-- vcl/source/window/dialog.cxx | 2 +- vcl/source/window/dockwin.cxx | 2 +- vcl/source/window/stacking.cxx | 3 +- vcl/source/window/syswin.cxx | 2 +- vcl/source/window/window.cxx | 34 ++++++++++------------ vcl/source/window/window2.cxx | 2 +- vcl/unx/gtk3/gtkinst.cxx | 3 +- 46 files changed, 98 insertions(+), 105 deletions(-) diff --git a/accessibility/source/extended/accessibletabbar.cxx b/accessibility/source/extended/accessibletabbar.cxx index 218ed1cab071..f450bfc526f0 100644 --- a/accessibility/source/extended/accessibletabbar.cxx +++ b/accessibility/source/extended/accessibletabbar.cxx @@ -458,7 +458,7 @@ namespace accessibility Reference< awt::XFont > xFont; if ( m_pTabBar ) { - Reference< awt::XDevice > xDev( m_pTabBar->GetComponentInterface(), UNO_QUERY ); + auto xDev = m_pTabBar->GetComponentInterfaceAs(); if ( xDev.is() ) { vcl::Font aFont; diff --git a/accessibility/source/standard/accessiblemenucomponent.cxx b/accessibility/source/standard/accessiblemenucomponent.cxx index be9b1e6f453e..e004c2b1942b 100644 --- a/accessibility/source/standard/accessiblemenucomponent.cxx +++ b/accessibility/source/standard/accessiblemenucomponent.cxx @@ -301,7 +301,7 @@ Reference< awt::XFont > OAccessibleMenuComponent::getFont( ) vcl::Window* pWindow = m_pMenu->GetWindow(); if ( pWindow ) { - Reference< awt::XDevice > xDev( pWindow->GetComponentInterface(), UNO_QUERY ); + auto xDev = pWindow->GetComponentInterfaceAs(); if ( xDev.is() ) { const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); diff --git a/basctl/source/accessibility/accessibledialogcontrolshape.cxx b/basctl/source/accessibility/accessibledialogcontrolshape.cxx index f885ff4bda1b..b61385f6671a 100644 --- a/basctl/source/accessibility/accessibledialogcontrolshape.cxx +++ b/basctl/source/accessibility/accessibledialogcontrolshape.cxx @@ -495,7 +495,7 @@ Reference< awt::XFont > AccessibleDialogControlShape::getFont( ) vcl::Window* pWindow = GetWindow(); if ( pWindow ) { - Reference< awt::XDevice > xDev( pWindow->GetComponentInterface(), UNO_QUERY ); + auto xDev = pWindow->GetComponentInterfaceAs(); if ( xDev.is() ) { vcl::Font aFont; diff --git a/basctl/source/accessibility/accessibledialogwindow.cxx b/basctl/source/accessibility/accessibledialogwindow.cxx index 0b641c8aca5e..b91e48262a73 100644 --- a/basctl/source/accessibility/accessibledialogwindow.cxx +++ b/basctl/source/accessibility/accessibledialogwindow.cxx @@ -790,7 +790,7 @@ Reference< awt::XFont > AccessibleDialogWindow::getFont( ) Reference< awt::XFont > xFont; if ( m_pDialogWindow ) { - Reference< awt::XDevice > xDev( m_pDialogWindow->GetComponentInterface(), UNO_QUERY ); + auto xDev = m_pDialogWindow->GetComponentInterfaceAs(); if ( xDev.is() ) { vcl::Font aFont; diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx index 06045356bccb..fd17b340ca54 100644 --- a/basctl/source/basicide/baside2.hxx +++ b/basctl/source/basicide/baside2.hxx @@ -100,7 +100,7 @@ private: bool bDoSyntaxHighlight; bool bDelayHighlight; - virtual css::uno::Reference< css::awt::XWindowPeer > GetComponentInterface(bool bCreate = true) override; + virtual VCLXWindow* GetComponentInterface(bool bCreate = true) override; CodeCompleteDataCache aCodeCompleteCache; VclPtr pCodeCompleteWnd; OUString GetActualSubName( sal_uLong nLine ); // gets the actual subroutine name according to line number diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index ecba2d5fa873..3168f5090532 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -2040,11 +2040,10 @@ void ComplexEditorWindow::SetLineNumberDisplay(bool b) Resize(); } -uno::Reference< awt::XWindowPeer > +VCLXWindow* EditorWindow::GetComponentInterface(bool bCreate) { - uno::Reference< awt::XWindowPeer > xPeer( - Window::GetComponentInterface(false)); + rtl::Reference< VCLXWindow > xPeer = Window::GetComponentInterface(false); if (!xPeer.is() && bCreate) { // Make sure edit engine and view are available: @@ -2052,9 +2051,9 @@ EditorWindow::GetComponentInterface(bool bCreate) CreateEditEngine(); xPeer = createTextWindowPeer(*GetEditView()); - SetComponentInterface(xPeer); + SetComponentInterface(xPeer.get()); } - return xPeer; + return xPeer.get(); } static sal_uInt32 getCorrectedPropCount(SbxArray* p) diff --git a/basctl/source/basicide/textwindowpeer.cxx b/basctl/source/basicide/textwindowpeer.cxx index fc458453778b..cbe9781fce90 100644 --- a/basctl/source/basicide/textwindowpeer.cxx +++ b/basctl/source/basicide/textwindowpeer.cxx @@ -62,7 +62,7 @@ TextWindowPeer::CreateAccessibleContext() { } -css::uno::Reference basctl::createTextWindowPeer( +rtl::Reference basctl::createTextWindowPeer( TextView & view) { return new TextWindowPeer(view); diff --git a/basctl/source/basicide/textwindowpeer.hxx b/basctl/source/basicide/textwindowpeer.hxx index 077ad32cd79f..701c134c3a5f 100644 --- a/basctl/source/basicide/textwindowpeer.hxx +++ b/basctl/source/basicide/textwindowpeer.hxx @@ -21,17 +21,14 @@ #include -#include +#include -namespace com::sun::star::awt -{ -class XWindowPeer; -} +class VCLXWindow; class TextView; namespace basctl { -css::uno::Reference createTextWindowPeer(TextView& view); +rtl::Reference createTextWindowPeer(TextView& view); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx index 08b8c65c31f7..544084306fdf 100644 --- a/chart2/source/controller/main/ChartController.cxx +++ b/chart2/source/controller/main/ChartController.cxx @@ -436,7 +436,7 @@ void SAL_CALL ChartController::attachFrame( SolarMutexGuard aSolarGuard; auto pChartWindow = VclPtr::Create(this,pParent,pParent?pParent->GetStyle():0); pChartWindow->SetBackground();//no Background - m_xViewWindow.set( pChartWindow->GetComponentInterface(), uno::UNO_QUERY ); + m_xViewWindow = pChartWindow->GetComponentInterfaceAs(); pChartWindow->Show(); m_apDropTargetHelper.reset( new ChartDropTargetHelper( pChartWindow->GetDropTarget(), diff --git a/dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx b/dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx index 763e53990276..8681775233d4 100644 --- a/dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx +++ b/dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx @@ -36,7 +36,7 @@ namespace dbaui using namespace ::com::sun::star; OConnectionLineAccess::OConnectionLineAccess(OTableConnection* _pLine) - : VCLXAccessibleComponent(_pLine->GetComponentInterface().is() ? _pLine->GetWindowPeer() : nullptr) + : VCLXAccessibleComponent(_pLine->GetComponentInterface() ? _pLine->GetWindowPeer() : nullptr) ,m_pLine(_pLine) { } diff --git a/dbaccess/source/ui/querydesign/JAccess.cxx b/dbaccess/source/ui/querydesign/JAccess.cxx index 8068f0fa7f21..9785708fe9da 100644 --- a/dbaccess/source/ui/querydesign/JAccess.cxx +++ b/dbaccess/source/ui/querydesign/JAccess.cxx @@ -33,7 +33,7 @@ namespace dbaui using namespace ::com::sun::star::lang; OJoinDesignViewAccess::OJoinDesignViewAccess(OJoinTableView* _pTableView) - :VCLXAccessibleComponent(_pTableView->GetComponentInterface().is() ? _pTableView->GetWindowPeer() : nullptr) + :VCLXAccessibleComponent(_pTableView->GetComponentInterface() ? _pTableView->GetWindowPeer() : nullptr) ,m_pTableView(_pTableView) { } diff --git a/dbaccess/source/ui/querydesign/TableWindowAccess.cxx b/dbaccess/source/ui/querydesign/TableWindowAccess.cxx index 1dc69e763d5d..d0201d8f6230 100644 --- a/dbaccess/source/ui/querydesign/TableWindowAccess.cxx +++ b/dbaccess/source/ui/querydesign/TableWindowAccess.cxx @@ -36,7 +36,7 @@ namespace dbaui using namespace ::com::sun::star; OTableWindowAccess::OTableWindowAccess(OTableWindow* _pTable) - :VCLXAccessibleComponent(_pTable->GetComponentInterface().is() ? _pTable->GetWindowPeer() : nullptr) + :VCLXAccessibleComponent(_pTable->GetComponentInterface() ? _pTable->GetWindowPeer() : nullptr) ,m_pTable(_pTable) { } diff --git a/extensions/source/bibliography/bibload.cxx b/extensions/source/bibliography/bibload.cxx index cb1edd54fef4..4d170744b687 100644 --- a/extensions/source/bibliography/bibload.cxx +++ b/extensions/source/bibliography/bibload.cxx @@ -227,7 +227,7 @@ void BibliographyLoader::loadView(const Reference< XFrame > & rFrame, pMyWindow->createBottomFrame(pView); - Reference< awt::XWindow > xWin ( pMyWindow->GetComponentInterface(), UNO_QUERY ); + auto xWin = pMyWindow->GetComponentInterfaceAs(); Reference< XController > xCtrRef( new BibFrameController_Impl( xWin, m_xDatMan.get() ) ); diff --git a/extensions/source/bibliography/framectr.cxx b/extensions/source/bibliography/framectr.cxx index e83580689435..8915012c4c71 100644 --- a/extensions/source/bibliography/framectr.cxx +++ b/extensions/source/bibliography/framectr.cxx @@ -661,7 +661,7 @@ void BibFrameController_Impl::addStatusListener( m_xLastQueriedFocusWin = lcl_GetFocusChild( VCLUnoHelper::GetWindow( m_xWindow ) ); if (m_xLastQueriedFocusWin) { - Reference xEdit(m_xLastQueriedFocusWin->GetComponentInterface(), css::uno::UNO_QUERY); + Reference xEdit = m_xLastQueriedFocusWin->GetComponentInterfaceAs(); aEvent.IsEnabled = xEdit && xEdit->isEditable() && !xEdit->getSelectedText().isEmpty(); } } @@ -670,7 +670,7 @@ void BibFrameController_Impl::addStatusListener( m_xLastQueriedFocusWin = lcl_GetFocusChild( VCLUnoHelper::GetWindow( m_xWindow ) ); if (m_xLastQueriedFocusWin) { - Reference xEdit(m_xLastQueriedFocusWin->GetComponentInterface(), css::uno::UNO_QUERY); + auto xEdit = m_xLastQueriedFocusWin->GetComponentInterfaceAs(); aEvent.IsEnabled = xEdit && !xEdit->getSelectedText().isEmpty(); } } @@ -680,7 +680,7 @@ void BibFrameController_Impl::addStatusListener( m_xLastQueriedFocusWin = lcl_GetFocusChild( VCLUnoHelper::GetWindow( m_xWindow ) ); if (m_xLastQueriedFocusWin) { - Reference xEdit(m_xLastQueriedFocusWin->GetComponentInterface(), css::uno::UNO_QUERY); + auto xEdit = m_xLastQueriedFocusWin->GetComponentInterfaceAs(); if (xEdit && !xEdit->isEditable()) { uno::Reference< datatransfer::clipboard::XClipboard > xClip = m_xLastQueriedFocusWin->GetClipboard(); diff --git a/forms/source/richtext/richtextcontrol.cxx b/forms/source/richtext/richtextcontrol.cxx index 45e898b8ed13..def1ea106bbf 100644 --- a/forms/source/richtext/richtextcontrol.cxx +++ b/forms/source/richtext/richtextcontrol.cxx @@ -272,7 +272,7 @@ namespace frm VclPtrInstance pRichTextControl( pEngine, _pParentWindow, _nStyle, nullptr, pPeer.get() ); // some knittings - pRichTextControl->SetComponentInterface( pPeer ); + pRichTextControl->SetComponentInterface( pPeer.get() ); // outta here return pPeer; diff --git a/forms/source/solar/component/navbarcontrol.cxx b/forms/source/solar/component/navbarcontrol.cxx index 14e9c27ce74f..5853ae148956 100644 --- a/forms/source/solar/component/navbarcontrol.cxx +++ b/forms/source/solar/component/navbarcontrol.cxx @@ -216,7 +216,7 @@ namespace frm // some knittings pNavBar->setDispatcher( pPeer.get() ); - pNavBar->SetComponentInterface( pPeer ); + pNavBar->SetComponentInterface( pPeer.get() ); // we want a faster repeating rate for the slots in this // toolbox diff --git a/include/vcl/toolkit/unowrap.hxx b/include/vcl/toolkit/unowrap.hxx index 46f1e0845cc0..66fc099819aa 100644 --- a/include/vcl/toolkit/unowrap.hxx +++ b/include/vcl/toolkit/unowrap.hxx @@ -27,6 +27,7 @@ #include #include #include +#include namespace vcl { class Window; } class Menu; @@ -56,8 +57,8 @@ public: virtual void ReleaseAllGraphics( OutputDevice* pOutDev ) = 0; // Window - virtual css::uno::Reference GetWindowInterface( vcl::Window* pWindow ) = 0; - virtual void SetWindowInterface( vcl::Window* pWindow, css::uno::Reference< css::awt::XWindowPeer > xIFace ) = 0; + virtual rtl::Reference GetWindowInterface( vcl::Window* pWindow ) = 0; + virtual void SetWindowInterface( vcl::Window* pWindow, VCLXWindow* pIFace ) = 0; virtual VclPtr GetWindow(const css::uno::Reference& rxWindow) = 0; // PopupMenu diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx index 17fbf4d876ed..5d3aed7c3ea3 100644 --- a/include/vcl/window.hxx +++ b/include/vcl/window.hxx @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -1129,10 +1130,13 @@ public: virtual const SystemEnvData* GetSystemData() const; // API to set/query the component interfaces - virtual css::uno::Reference< css::awt::XWindowPeer > - GetComponentInterface( bool bCreate = true ); + virtual VCLXWindow* GetComponentInterface( bool bCreate = true ); + void SetComponentInterface( VCLXWindow* pIFace ); + // Utility method to make the GetComponentInterface call sites less verbose + template + css::uno::Reference GetComponentInterfaceAs() + { return css::uno::Reference(static_cast(GetComponentInterface()), css::uno::UNO_QUERY); } - void SetComponentInterface( css::uno::Reference< css::awt::XWindowPeer > const & xIFace ); /// Interface to register for dialog / window tunneling. void SetLOKNotifier(const vcl::ILibreOfficeKitNotifier* pNotifier, bool bParent = false); @@ -1258,7 +1262,7 @@ public: // set and retrieve for Toolkit VCLXWindow* GetWindowPeer() const; - void SetWindowPeer( css::uno::Reference< css::awt::XWindowPeer > const & xPeer, VCLXWindow* pVCLXWindow ); + void SetWindowPeer( VCLXWindow* pVCLXWindow ); // remember if it was generated by Toolkit bool IsCreatedWithToolkit() const; diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index c6c1f5250bf3..36e7c7fe134b 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -2660,7 +2660,7 @@ bool ScGridWindow::PreNotify( NotifyEvent& rNEvt ) css::awt::MouseEvent aEvent; lcl_InitMouseEvent( aEvent, *rNEvt.GetMouseEvent() ); if ( rNEvt.GetWindow() ) - aEvent.Source = rNEvt.GetWindow()->GetComponentInterface(); + aEvent.Source = static_cast(rNEvt.GetWindow()->GetComponentInterface()); if ( nType == MouseNotifyEvent::MOUSEBUTTONDOWN) bDone = pImp->MousePressed( aEvent ); else diff --git a/sd/source/ui/presenter/PresenterHelper.cxx b/sd/source/ui/presenter/PresenterHelper.cxx index 7504e914e475..a319b9682847 100644 --- a/sd/source/ui/presenter/PresenterHelper.cxx +++ b/sd/source/ui/presenter/PresenterHelper.cxx @@ -76,7 +76,7 @@ Reference SAL_CALL PresenterHelper::createWindow ( { pWindow = VclPtr::Create(pParentWindow); } - Reference xWindow (pWindow->GetComponentInterface(), UNO_QUERY); + auto xWindow = pWindow->GetComponentInterfaceAs(); if (bEnableChildTransparentMode) { diff --git a/sfx2/source/doc/iframe.cxx b/sfx2/source/doc/iframe.cxx index eff4588b3b5f..578c6a071336 100644 --- a/sfx2/source/doc/iframe.cxx +++ b/sfx2/source/doc/iframe.cxx @@ -164,14 +164,14 @@ sal_Bool SAL_CALL IFrameObject::load( pWin->SetBackground(); pWin->Show(); - uno::Reference < awt::XWindow > xWindow( pWin->GetComponentInterface(), uno::UNO_QUERY ); + auto xWindow = pWin->GetComponentInterfaceAs(); xFrame->setComponent( xWindow, uno::Reference < frame::XController >() ); // we must destroy the IFrame before the parent is destroyed xWindow->addEventListener( this ); mxFrame = frame::Frame::create( mxContext ); - uno::Reference < awt::XWindow > xWin( pWin->GetComponentInterface(), uno::UNO_QUERY ); + auto xWin = pWin->GetComponentInterfaceAs(); mxFrame->initialize( xWin ); mxFrame->setName( maFrmDescr.GetName() ); diff --git a/sfx2/source/view/ipclient.cxx b/sfx2/source/view/ipclient.cxx index 3c40c7bdf4a6..d92771872fe8 100644 --- a/sfx2/source/view/ipclient.cxx +++ b/sfx2/source/view/ipclient.cxx @@ -567,8 +567,7 @@ uno::Reference< awt::XWindow > SAL_CALL SfxInPlaceClient_Impl::getWindow() if ( !m_pClient || !m_pClient->GetEditWin() ) throw uno::RuntimeException(); - uno::Reference< awt::XWindow > xWin( m_pClient->GetEditWin()->GetComponentInterface(), uno::UNO_QUERY ); - return xWin; + return m_pClient->GetEditWin()->GetComponentInterfaceAs(); } diff --git a/sfx2/source/view/sfxbasecontroller.cxx b/sfx2/source/view/sfxbasecontroller.cxx index 8f5bfddba32d..98462d587722 100644 --- a/sfx2/source/view/sfxbasecontroller.cxx +++ b/sfx2/source/view/sfxbasecontroller.cxx @@ -445,7 +445,7 @@ Reference< XWindow > SAL_CALL SfxBaseController::getComponentWindow() if ( !m_pData->m_pViewShell ) throw DisposedException(); - return Reference< XWindow >( GetViewFrame_Impl().GetFrame().GetWindow().GetComponentInterface(), UNO_QUERY_THROW ); + return GetViewFrame_Impl().GetFrame().GetWindow().GetComponentInterfaceAs(); } OUString SAL_CALL SfxBaseController::getViewControllerName() diff --git a/sfx2/source/view/userinputinterception.cxx b/sfx2/source/view/userinputinterception.cxx index ca1a1fd3f622..0f669fac7d66 100644 --- a/sfx2/source/view/userinputinterception.cxx +++ b/sfx2/source/view/userinputinterception.cxx @@ -184,7 +184,7 @@ namespace sfx2 KeyEvent aEvent; lcl_initKeyEvent( aEvent, *_rEvent.GetKeyEvent() ); if ( _rEvent.GetWindow() ) - aEvent.Source = _rEvent.GetWindow()->GetComponentInterface(); + aEvent.Source = static_cast(_rEvent.GetWindow()->GetComponentInterface()); ::comphelper::OInterfaceIteratorHelper2 aIterator( m_pData->m_aKeyHandlers ); while ( aIterator.hasMoreElements() ) @@ -222,7 +222,7 @@ namespace sfx2 MouseEvent aEvent; lcl_initMouseEvent( aEvent, *_rEvent.GetMouseEvent() ); if ( _rEvent.GetWindow() ) - aEvent.Source = _rEvent.GetWindow()->GetComponentInterface(); + aEvent.Source = static_cast(_rEvent.GetWindow()->GetComponentInterface()); ::comphelper::OInterfaceIteratorHelper2 aIterator( m_pData->m_aMouseClickHandlers ); while ( aIterator.hasMoreElements() ) diff --git a/sw/source/uibase/docvw/AnnotationWin2.cxx b/sw/source/uibase/docvw/AnnotationWin2.cxx index f463bf7597f1..7cd9dbf09b80 100644 --- a/sw/source/uibase/docvw/AnnotationWin2.cxx +++ b/sw/source/uibase/docvw/AnnotationWin2.cxx @@ -1392,7 +1392,7 @@ css::uno::Reference< css::accessibility::XAccessible > SwAnnotationWin::CreateAc rtl::Reference pAcc( new SidebarWinAccessible( *this, mrView.GetWrtShell(), mrSidebarItem ) ); - SetWindowPeer( pAcc, pAcc.get() ); + SetWindowPeer( pAcc.get() ); return pAcc; } diff --git a/toolkit/inc/controls/svmedit.hxx b/toolkit/inc/controls/svmedit.hxx index 33586c84f064..4b7f155dcc3c 100644 --- a/toolkit/inc/controls/svmedit.hxx +++ b/toolkit/inc/controls/svmedit.hxx @@ -26,7 +26,7 @@ class MultiLineEdit : public VclMultiLineEdit public: MultiLineEdit( vcl::Window* pParent, WinBits nWinStyle ); - virtual css::uno::Reference< css::awt::XWindowPeer > GetComponentInterface(bool bCreate = true) override; + virtual VCLXWindow* GetComponentInterface(bool bCreate = true) override; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/helper/unowrapper.hxx b/toolkit/inc/helper/unowrapper.hxx index 6e10e870506d..b606a7df70c5 100644 --- a/toolkit/inc/helper/unowrapper.hxx +++ b/toolkit/inc/helper/unowrapper.hxx @@ -51,8 +51,8 @@ public: virtual void ReleaseAllGraphics( OutputDevice* pOutDev ) override; // Window - virtual css::uno::Reference< css::awt::XWindowPeer> GetWindowInterface( vcl::Window* pWindow ) override; - virtual void SetWindowInterface( vcl::Window* pWindow, css::uno::Reference< css::awt::XWindowPeer> xIFace ) override; + virtual rtl::Reference GetWindowInterface( vcl::Window* pWindow ) override; + virtual void SetWindowInterface( vcl::Window* pWindow, VCLXWindow* pIFace ) override; virtual VclPtr GetWindow(const css::uno::Reference& rxWindow) override; // Menu diff --git a/toolkit/source/awt/vclxaccessiblecomponent.cxx b/toolkit/source/awt/vclxaccessiblecomponent.cxx index 101307bf1d96..46fad7979c9d 100644 --- a/toolkit/source/awt/vclxaccessiblecomponent.cxx +++ b/toolkit/source/awt/vclxaccessiblecomponent.cxx @@ -780,7 +780,7 @@ uno::Reference< awt::XFont > SAL_CALL VCLXAccessibleComponent::getFont( ) VclPtr pWindow = GetWindow(); if ( pWindow ) { - uno::Reference< awt::XDevice > xDev( pWindow->GetComponentInterface(), uno::UNO_QUERY ); + auto xDev = pWindow->GetComponentInterfaceAs(); if ( xDev.is() ) { vcl::Font aFont; diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx index 10eb7f8019e2..287dc93f9676 100644 --- a/toolkit/source/awt/vclxtoolkit.cxx +++ b/toolkit/source/awt/vclxtoolkit.cxx @@ -1946,9 +1946,9 @@ css::uno::Reference< css::awt::XWindowPeer > VCLXToolkit::ImplCreateWindow( else { xRef = pNewComp; - pNewWindow->SetComponentInterface( xRef ); + pNewWindow->SetComponentInterface( pNewComp.get() ); } - DBG_ASSERT( pNewWindow->GetComponentInterface( false ) == xRef, + DBG_ASSERT( pNewWindow->GetComponentInterface( false ) == pNewComp.get(), "VCLXToolkit::createWindow: did #133706# resurge?" ); if ( rDescriptor.WindowAttributes & css::awt::WindowAttribute::SHOW ) @@ -2502,7 +2502,7 @@ void VCLXToolkit::callFocusListeners(::VclSimpleEvent const * pEvent, break; } if (pFocus != nullptr) - xNext = pFocus->GetComponentInterface(); + xNext = static_cast(pFocus->GetComponentInterface()); css::awt::FocusEvent aAwtEvent( static_cast< css::awt::XWindow * >(pWindow->GetWindowPeer()), static_cast(pWindow->GetGetFocusFlags()), diff --git a/toolkit/source/awt/vclxwindow.cxx b/toolkit/source/awt/vclxwindow.cxx index dfc6ba8f7c00..d770b8570234 100644 --- a/toolkit/source/awt/vclxwindow.cxx +++ b/toolkit/source/awt/vclxwindow.cxx @@ -912,7 +912,7 @@ void VCLXWindow::dispose( ) if ( auto pWindow = GetWindow() ) { pWindow->RemoveEventListener( LINK( this, VCLXWindow, WindowEventListener ) ); - pWindow->SetWindowPeer( nullptr, nullptr ); + pWindow->SetWindowPeer( nullptr ); pWindow->SetAccessible( nullptr ); VclPtr pOutDev = GetOutputDevice(); diff --git a/toolkit/source/controls/svmedit.cxx b/toolkit/source/controls/svmedit.cxx index 383f2280412e..2abd5e4ebed2 100644 --- a/toolkit/source/controls/svmedit.cxx +++ b/toolkit/source/controls/svmedit.cxx @@ -26,11 +26,10 @@ MultiLineEdit::MultiLineEdit(vcl::Window* pParent, WinBits nWinStyle) } // virtual -css::uno::Reference MultiLineEdit::GetComponentInterface(bool bCreate) +VCLXWindow* MultiLineEdit::GetComponentInterface(bool bCreate) { - css::uno::Reference xPeer( - VclMultiLineEdit::GetComponentInterface(false)); - if (!xPeer.is() && bCreate) + VCLXWindow* xPeer = VclMultiLineEdit::GetComponentInterface(false); + if (!xPeer && bCreate) { rtl::Reference xVCLMEdit(new VCLXMultiLineEdit); xVCLMEdit->SetWindow(this); diff --git a/toolkit/source/helper/unowrapper.cxx b/toolkit/source/helper/unowrapper.cxx index ab7d28493c62..19b0822534a9 100644 --- a/toolkit/source/helper/unowrapper.cxx +++ b/toolkit/source/helper/unowrapper.cxx @@ -35,7 +35,7 @@ using namespace ::com::sun::star; -static css::uno::Reference< css::awt::XWindowPeer > CreateXWindow( vcl::Window const * pWindow ) +static rtl::Reference CreateXWindow( vcl::Window const * pWindow ) { switch ( pWindow->GetType() ) { @@ -145,13 +145,13 @@ css::uno::Reference< css::awt::XToolkit> UnoWrapper::GetVCLToolkit() return mxToolkit; } -css::uno::Reference< css::awt::XWindowPeer> UnoWrapper::GetWindowInterface( vcl::Window* pWindow ) +rtl::Reference UnoWrapper::GetWindowInterface( vcl::Window* pWindow ) { - css::uno::Reference< css::awt::XWindowPeer> xPeer = pWindow->GetWindowPeer(); + rtl::Reference xPeer = pWindow->GetWindowPeer(); if ( !xPeer.is() ) { xPeer = CreateXWindow( pWindow ); - SetWindowInterface( pWindow, xPeer ); + SetWindowInterface( pWindow, xPeer.get() ); } return xPeer; } @@ -161,10 +161,8 @@ VclPtr UnoWrapper::GetWindow(const css::uno::Reference xIFace ) +void UnoWrapper::SetWindowInterface( vcl::Window* pWindow, VCLXWindow* pVCLXWindow ) { - VCLXWindow* pVCLXWindow = comphelper::getUnoTunnelImplementation( xIFace ); - DBG_ASSERT( pVCLXWindow, "SetComponentInterface - unsupported type" ); if ( !pVCLXWindow ) return; @@ -178,7 +176,7 @@ void UnoWrapper::SetWindowInterface( vcl::Window* pWindow, css::uno::Reference< return; } pVCLXWindow->SetWindow( pWindow ); - pWindow->SetWindowPeer( xIFace, pVCLXWindow ); + pWindow->SetWindowPeer( pVCLXWindow ); } css::uno::Reference UnoWrapper::CreateMenuInterface( PopupMenu* pPopupMenu ) @@ -227,7 +225,7 @@ void UnoWrapper::WindowDestroyed( vcl::Window* pWindow ) VclPtr< vcl::Window > pClient = pChild->GetWindow( GetWindowType::Client ); if ( pClient && pClient->GetWindowPeer() ) { - css::uno::Reference< css::lang::XComponent > xComp = pClient->GetComponentInterface( false ); + rtl::Reference xComp = pClient->GetComponentInterface( false ); xComp->dispose(); } @@ -246,7 +244,7 @@ void UnoWrapper::WindowDestroyed( vcl::Window* pWindow ) if ( pClient && pClient->GetWindowPeer() && lcl_ImplIsParent( pWindow, pClient ) ) { - css::uno::Reference< css::lang::XComponent > xComp = pClient->GetComponentInterface( false ); + rtl::Reference xComp = pClient->GetComponentInterface( false ); xComp->dispose(); } @@ -261,13 +259,13 @@ void UnoWrapper::WindowDestroyed( vcl::Window* pWindow ) } VCLXWindow* pWindowPeer = pWindow->GetWindowPeer(); - uno::Reference< lang::XComponent > xWindowPeerComp = pWindow->GetComponentInterface( false ); + rtl::Reference xWindowPeerComp = pWindow->GetComponentInterface( false ); OSL_ENSURE( ( pWindowPeer != nullptr ) == xWindowPeerComp.is(), "UnoWrapper::WindowDestroyed: inconsistency in the window's peers!" ); if ( pWindowPeer ) { pWindowPeer->SetWindow( nullptr ); - pWindow->SetWindowPeer( nullptr, nullptr ); + pWindow->SetWindowPeer( nullptr ); } if ( xWindowPeerComp.is() ) xWindowPeerComp->dispose(); diff --git a/vcl/inc/window.h b/vcl/inc/window.h index 6ca9b9a37031..815586162202 100644 --- a/vcl/inc/window.h +++ b/vcl/inc/window.h @@ -270,12 +270,11 @@ public: OUString maQuickHelpText; OUString maID; InputContext maInputContext; - css::uno::Reference< css::awt::XWindowPeer > mxWindowPeer; css::uno::Reference< css::accessibility::XAccessible > mxAccessible; std::shared_ptr< VclSizeGroup > m_xSizeGroup; std::vector> m_aMnemonicLabels; std::unique_ptr mpAccessibleInfos; - VCLXWindow* mpVCLXWindow; + rtl::Reference mxVCLXWindow; // peer window object from toolkit vcl::Region maWinRegion; //< region to 'shape' the VCL window (frame coordinates) vcl::Region maWinClipRegion; //< the (clipping) region that finally corresponds to the VCL window (frame coordinates) vcl::Region maInvalidateRegion; //< region that has to be redrawn (frame coordinates) diff --git a/vcl/qa/cppunit/lifecycle.cxx b/vcl/qa/cppunit/lifecycle.cxx index ee706178bad2..412ce1006fe9 100644 --- a/vcl/qa/cppunit/lifecycle.cxx +++ b/vcl/qa/cppunit/lifecycle.cxx @@ -288,7 +288,7 @@ void LifecycleTest::testLeakage() void LifecycleTest::testToolkit() { LeakTestObject *pVclWin = LeakTestObject::Create(nullptr, WB_APP|WB_STDWORK); - css::uno::Reference xWindow(pVclWin->getRef()->GetComponentInterface(), css::uno::UNO_QUERY); + auto xWindow = pVclWin->getRef()->GetComponentInterfaceAs(); CPPUNIT_ASSERT(xWindow.is()); // test UNO dispose diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 4d4a418408c1..d31ea0f74b70 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -1236,8 +1236,7 @@ css::uno::Reference SalInstanceContainer::CreateChildFrame() auto xPage = VclPtr::Create(m_xContainer.get()); xPage->set_expand(true); xPage->Show(); - return css::uno::Reference(xPage->GetComponentInterface(), - css::uno::UNO_QUERY); + return xPage->GetComponentInterfaceAs(); } std::unique_ptr SalInstanceWidget::weld_parent() const @@ -1407,9 +1406,7 @@ OUString SalInstanceWindow::get_title() const { return m_xWindow->GetText(); } css::uno::Reference SalInstanceWindow::GetXWindow() { - css::uno::Reference xWindow(m_xWindow->GetComponentInterface(), - css::uno::UNO_QUERY); - return xWindow; + return m_xWindow->GetComponentInterfaceAs(); } void SalInstanceWindow::resize_to_request() diff --git a/vcl/source/control/fmtfield.cxx b/vcl/source/control/fmtfield.cxx index cb55d2ce158a..2895636122f0 100644 --- a/vcl/source/control/fmtfield.cxx +++ b/vcl/source/control/fmtfield.cxx @@ -910,7 +910,7 @@ namespace m_rSpinButton.SpinField::SetText(rText, rSel); } - virtual void SetEntryTextColor(const Color* pColor) override + virtual void SetEntryTextColor(const ::Color* pColor) override { if (pColor) m_rSpinButton.SetControlForeground(*pColor); diff --git a/vcl/source/control/ivctrl.cxx b/vcl/source/control/ivctrl.cxx index c96e133a506f..1a06d68fe48e 100644 --- a/vcl/source/control/ivctrl.cxx +++ b/vcl/source/control/ivctrl.cxx @@ -18,6 +18,7 @@ */ +#include #include #include "imivctl.hxx" #include @@ -421,7 +422,7 @@ css::uno::Reference< XAccessible > SvtIconChoiceCtrl::CreateAccessible() css::uno::Reference< XAccessible > xAccParent = pParent->GetAccessible(); if ( xAccParent.is() ) { - css::uno::Reference< css::awt::XWindowPeer > xHoldAlive(GetComponentInterface()); + rtl::Reference xHoldAlive(GetComponentInterface()); xAccessible = _pImpl->GetAccessibleFactory().createAccessibleIconChoiceCtrl( *this, xAccParent ); } } diff --git a/vcl/source/treelist/treelistbox.cxx b/vcl/source/treelist/treelistbox.cxx index 1fc5feaf21fc..a21e41969df0 100644 --- a/vcl/source/treelist/treelistbox.cxx +++ b/vcl/source/treelist/treelistbox.cxx @@ -23,6 +23,7 @@ - SelectAll( false ) => only repaint the deselected entries */ +#include #include #include #include @@ -3473,7 +3474,7 @@ css::uno::Reference< XAccessible > SvTreeListBox::CreateAccessible() if ( xAccParent.is() ) { // need to be done here to get the vclxwindow later on in the accessible - css::uno::Reference< css::awt::XWindowPeer > xHoldAlive(GetComponentInterface()); + rtl::Reference< VCLXWindow > xHoldAlive(GetComponentInterface()); xAccessible = pImpl->m_aFactoryAccess.getFactory().createAccessibleTreeListBox( *this, xAccParent ); } } diff --git a/vcl/source/window/accessibility.cxx b/vcl/source/window/accessibility.cxx index 4e3768286554..18e4ce23dac6 100644 --- a/vcl/source/window/accessibility.cxx +++ b/vcl/source/window/accessibility.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include #include #include #include @@ -77,8 +78,7 @@ css::uno::Reference< css::accessibility::XAccessible > Window::GetAccessible( bo css::uno::Reference< css::accessibility::XAccessible > Window::CreateAccessible() { - css::uno::Reference< css::accessibility::XAccessible > xAcc( GetComponentInterface(), css::uno::UNO_QUERY ); - return xAcc; + return GetComponentInterfaceAs(); } void Window::SetAccessible( const css::uno::Reference< css::accessibility::XAccessible >& x ) diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index 882d6c0e985b..7efb43b43aff 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -846,7 +846,7 @@ bool Dialog::Close() if ( xWindow->IsDisposed() ) return false; - if ( mpWindowImpl->mxWindowPeer.is() && IsCreatedWithToolkit() && !IsInExecute() ) + if ( mpWindowImpl->mxVCLXWindow.is() && IsCreatedWithToolkit() && !IsInExecute() ) return false; // If there's a cancel button with a custom handler, then always give it a chance to diff --git a/vcl/source/window/dockwin.cxx b/vcl/source/window/dockwin.cxx index 3b622cf1cd73..803ce85e8fc3 100644 --- a/vcl/source/window/dockwin.cxx +++ b/vcl/source/window/dockwin.cxx @@ -625,7 +625,7 @@ bool DockingWindow::Close() if ( xWindow->IsDisposed() ) return false; - if ( mpWindowImpl->mxWindowPeer.is() && IsCreatedWithToolkit() ) + if ( mpWindowImpl->mxVCLXWindow.is() && IsCreatedWithToolkit() ) return false; Show( false, ShowFlags::NoFocusChange ); diff --git a/vcl/source/window/stacking.cxx b/vcl/source/window/stacking.cxx index 60f7303f33bc..a8d58a086cbc 100644 --- a/vcl/source/window/stacking.cxx +++ b/vcl/source/window/stacking.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include #include #include #include @@ -619,7 +620,7 @@ bool Window::IsTopWindow() const { // #113722#, cache result of expensive queryInterface call vcl::Window *pThisWin = const_cast(this); - uno::Reference< XTopWindow > xTopWindow( pThisWin->GetComponentInterface(), UNO_QUERY ); + auto xTopWindow = pThisWin->GetComponentInterfaceAs(); pThisWin->mpWindowImpl->mpWinData->mnIsTopWindow = xTopWindow.is() ? 1 : 0; } return mpWindowImpl->mpWinData->mnIsTopWindow == 1; diff --git a/vcl/source/window/syswin.cxx b/vcl/source/window/syswin.cxx index ecba89c0aac1..18d664844402 100644 --- a/vcl/source/window/syswin.cxx +++ b/vcl/source/window/syswin.cxx @@ -270,7 +270,7 @@ bool SystemWindow::Close() if ( xWindow->IsDisposed() ) return false; - if ( mpWindowImpl->mxWindowPeer.is() && IsCreatedWithToolkit() ) + if ( mpWindowImpl->mxVCLXWindow.is() && IsCreatedWithToolkit() ) return false; // Is Window not closeable, ignore close diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index c0a9bf8b141b..6422d4add39c 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -547,8 +547,8 @@ void Window::dispose() mpWindowImpl->mpFrameData = nullptr; } - if (mpWindowImpl->mxWindowPeer) - mpWindowImpl->mxWindowPeer->dispose(); + if (mpWindowImpl->mxVCLXWindow) + mpWindowImpl->mxVCLXWindow->dispose(); // should be the last statements mpWindowImpl.reset(); @@ -612,7 +612,7 @@ WindowImpl::WindowImpl( WindowType nType ) mnChildEventListenersIteratingCount = 0; mpCursor = nullptr; // cursor maPointer = PointerStyle::Arrow; - mpVCLXWindow = nullptr; + mxVCLXWindow = nullptr; mpAccessibleInfos = nullptr; maControlForeground = COL_TRANSPARENT; // no foreground set maControlBackground = COL_TRANSPARENT; // no background set @@ -3105,39 +3105,37 @@ const OUString& Window::GetHelpText() const return mpWindowImpl->maHelpText; } -void Window::SetWindowPeer( Reference< css::awt::XWindowPeer > const & xPeer, VCLXWindow* pVCLXWindow ) +void Window::SetWindowPeer( VCLXWindow* pVCLXWindow ) { if (!mpWindowImpl || mpWindowImpl->mbInDispose) return; // be safe against re-entrance: first clear the old ref, then assign the new one - if (mpWindowImpl->mxWindowPeer) + if (mpWindowImpl->mxVCLXWindow) { - mpWindowImpl->mxWindowPeer->dispose(); - mpWindowImpl->mxWindowPeer.clear(); + mpWindowImpl->mxVCLXWindow->dispose(); + mpWindowImpl->mxVCLXWindow.clear(); } - mpWindowImpl->mxWindowPeer = xPeer; - - mpWindowImpl->mpVCLXWindow = pVCLXWindow; + mpWindowImpl->mxVCLXWindow = pVCLXWindow; } -Reference< css::awt::XWindowPeer > Window::GetComponentInterface( bool bCreate ) +VCLXWindow* Window::GetComponentInterface( bool bCreate ) { - if ( !mpWindowImpl->mxWindowPeer.is() && bCreate ) + if ( !mpWindowImpl->mxVCLXWindow.is() && bCreate ) { UnoWrapperBase* pWrapper = UnoWrapperBase::GetUnoWrapper(); if ( pWrapper ) - mpWindowImpl->mxWindowPeer = pWrapper->GetWindowInterface( this ); + mpWindowImpl->mxVCLXWindow = pWrapper->GetWindowInterface( this ); } - return mpWindowImpl->mxWindowPeer; + return mpWindowImpl->mxVCLXWindow.get(); } -void Window::SetComponentInterface( Reference< css::awt::XWindowPeer > const & xIFace ) +void Window::SetComponentInterface( VCLXWindow* pIFace ) { UnoWrapperBase* pWrapper = UnoWrapperBase::GetUnoWrapper(); SAL_WARN_IF( !pWrapper, "vcl.window", "SetComponentInterface: No Wrapper!" ); if ( pWrapper ) - pWrapper->SetWindowInterface( this, xIFace ); + pWrapper->SetWindowInterface( this, pIFace ); } typedef std::map> LOKWindowsMap; @@ -3689,9 +3687,7 @@ Reference< css::rendering::XCanvas > Window::ImplGetCanvas( bool bSpriteCanvas ) aArg[ 0 ] <<= reinterpret_cast(this); aArg[ 1 ] <<= css::awt::Rectangle( mnOutOffX, mnOutOffY, mnOutWidth, mnOutHeight ); aArg[ 2 ] <<= mpWindowImpl->mbAlwaysOnTop; - aArg[ 3 ] <<= Reference< css::awt::XWindow >( - const_cast(this)->GetComponentInterface(), - UNO_QUERY ); + aArg[ 3 ] <<= const_cast(this)->GetComponentInterfaceAs(); aArg[ 4 ] = GetSystemGfxDataAny(); Reference< XComponentContext > xContext = comphelper::getProcessComponentContext(); diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx index f52478299a9b..a0addf688e48 100644 --- a/vcl/source/window/window2.cxx +++ b/vcl/source/window/window2.cxx @@ -1250,7 +1250,7 @@ PointerStyle Window::GetPointer() const VCLXWindow* Window::GetWindowPeer() const { - return mpWindowImpl ? mpWindowImpl->mpVCLXWindow : nullptr; + return mpWindowImpl ? mpWindowImpl->mxVCLXWindow.get() : nullptr; } void Window::SetPosPixel( const Point& rNewPos ) diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index d76344d7c64d..ef313aaab927 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -4259,7 +4260,7 @@ public: // NoActivate otherwise Show grab focus to this widget xEmbedWindow->Show(true, ShowFlags::NoActivate); - css::uno::Reference xWindow(xEmbedWindow->GetComponentInterface(), css::uno::UNO_QUERY); + auto xWindow = xEmbedWindow->GetComponentInterfaceAs(); return xWindow; #else return nullptr; -- cgit v1.2.3