summaryrefslogtreecommitdiff
path: root/toolkit
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-05-12 15:07:37 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-05-12 19:57:24 +0200
commitf7a86c5cdf4323c99d26512bf78de7f7c380667d (patch)
treef299cbf4ca27b5db0e81a90cc6551469fa280e63 /toolkit
parentc5e5467f6a13aba68b4706a4d7feb130e824bcc6 (diff)
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 <noel.grandin@collabora.co.uk>
Diffstat (limited to 'toolkit')
-rw-r--r--toolkit/inc/controls/svmedit.hxx2
-rw-r--r--toolkit/inc/helper/unowrapper.hxx4
-rw-r--r--toolkit/source/awt/vclxaccessiblecomponent.cxx2
-rw-r--r--toolkit/source/awt/vclxtoolkit.cxx6
-rw-r--r--toolkit/source/awt/vclxwindow.cxx2
-rw-r--r--toolkit/source/controls/svmedit.cxx7
-rw-r--r--toolkit/source/helper/unowrapper.cxx22
7 files changed, 21 insertions, 24 deletions
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<VCLXWindow> GetWindowInterface( vcl::Window* pWindow ) override;
+ virtual void SetWindowInterface( vcl::Window* pWindow, VCLXWindow* pIFace ) override;
virtual VclPtr<vcl::Window> GetWindow(const css::uno::Reference<css::awt::XWindow>& 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<vcl::Window> pWindow = GetWindow();
if ( pWindow )
{
- uno::Reference< awt::XDevice > xDev( pWindow->GetComponentInterface(), uno::UNO_QUERY );
+ auto xDev = pWindow->GetComponentInterfaceAs<awt::XDevice>();
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<cppu::OWeakObject*>(pFocus->GetComponentInterface());
css::awt::FocusEvent aAwtEvent(
static_cast< css::awt::XWindow * >(pWindow->GetWindowPeer()),
static_cast<sal_Int16>(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<OutputDevice> 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<css::awt::XWindowPeer> MultiLineEdit::GetComponentInterface(bool bCreate)
+VCLXWindow* MultiLineEdit::GetComponentInterface(bool bCreate)
{
- css::uno::Reference<css::awt::XWindowPeer> xPeer(
- VclMultiLineEdit::GetComponentInterface(false));
- if (!xPeer.is() && bCreate)
+ VCLXWindow* xPeer = VclMultiLineEdit::GetComponentInterface(false);
+ if (!xPeer && bCreate)
{
rtl::Reference<VCLXMultiLineEdit> 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<VCLXWindow> 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<VCLXWindow> UnoWrapper::GetWindowInterface( vcl::Window* pWindow )
{
- css::uno::Reference< css::awt::XWindowPeer> xPeer = pWindow->GetWindowPeer();
+ rtl::Reference<VCLXWindow> xPeer = pWindow->GetWindowPeer();
if ( !xPeer.is() )
{
xPeer = CreateXWindow( pWindow );
- SetWindowInterface( pWindow, xPeer );
+ SetWindowInterface( pWindow, xPeer.get() );
}
return xPeer;
}
@@ -161,10 +161,8 @@ VclPtr<vcl::Window> UnoWrapper::GetWindow(const css::uno::Reference<css::awt::XW
return VCLUnoHelper::GetWindow(rWindow);
}
-void UnoWrapper::SetWindowInterface( vcl::Window* pWindow, css::uno::Reference< css::awt::XWindowPeer> xIFace )
+void UnoWrapper::SetWindowInterface( vcl::Window* pWindow, VCLXWindow* pVCLXWindow )
{
- VCLXWindow* pVCLXWindow = comphelper::getUnoTunnelImplementation<VCLXWindow>( 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<css::awt::XPopupMenu> 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<VCLXWindow> 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<VCLXWindow> 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<VCLXWindow> 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();