toolkit/source/awt/vclxmenu.cxx                       |    8 +-
 toolkit/source/awt/vclxtoolkit.cxx                    |    8 +-
 toolkit/source/awt/vclxwindow.cxx                     |   44 +++++++-------
 toolkit/source/awt/vclxwindows.cxx                    |   54 +++++++++---------
 toolkit/source/controls/controlmodelcontainerbase.cxx |    5 -
 toolkit/source/controls/dialogcontrol.cxx             |    4 -
 toolkit/source/controls/geometrycontrolmodel.cxx      |    4 -
 toolkit/source/controls/grid/gridcolumn.cxx           |    2 
 toolkit/source/controls/grid/gridcolumn.hxx           |    2 
 toolkit/source/controls/grid/gridcontrol.cxx          |    2 
 toolkit/source/controls/roadmapcontrol.cxx            |   10 +--
 toolkit/source/controls/svtxgridcontrol.cxx           |    4 -
 toolkit/source/controls/tabpagecontainer.cxx          |    6 +-
 toolkit/source/controls/tkscrollbar.cxx               |    2 
 toolkit/source/controls/tree/treecontrol.cxx          |    2 
 toolkit/source/controls/tree/treecontrolpeer.cxx      |    8 +-
 toolkit/source/controls/tree/treedatamodel.cxx        |    4 -
 toolkit/source/controls/unocontrolmodel.cxx           |    2 
 toolkit/source/controls/unocontrols.cxx               |   14 ++--
 toolkit/source/hatchwindow/documentcloser.cxx         |    2 
 20 files changed, 91 insertions(+), 96 deletions(-)

New commits:
commit 367891c40ec683767d91ddeaf566c396f22b9035
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Sun Apr 23 20:15:14 2023 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Fri Oct 20 12:22:18 2023 +0200

    Use getXWeak in toolkit
    
    Change-Id: I44a0ddd386ea6d262d6102b40f3e9837655068ed
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150877
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/toolkit/source/awt/vclxmenu.cxx b/toolkit/source/awt/vclxmenu.cxx
index 86c3e87c5b6a..37785849c551 100644
--- a/toolkit/source/awt/vclxmenu.cxx
+++ b/toolkit/source/awt/vclxmenu.cxx
@@ -98,7 +98,7 @@ IMPL_LINK( VCLXMenu, MenuEventListener, VclMenuEvent&, 
rMenuEvent, void )
             if ( maMenuListeners.getLength() )
             {
                 css::awt::MenuEvent aEvent;
-                aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                aEvent.Source = getXWeak();
                 aEvent.MenuId = mpMenu->GetCurItemId();
                 maMenuListeners.itemSelected( aEvent );
             }
@@ -114,7 +114,7 @@ IMPL_LINK( VCLXMenu, MenuEventListener, VclMenuEvent&, 
rMenuEvent, void )
             if ( maMenuListeners.getLength() )
             {
                 css::awt::MenuEvent aEvent;
-                aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                aEvent.Source = getXWeak();
                 aEvent.MenuId = mpMenu->GetCurItemId();
                 maMenuListeners.itemHighlighted( aEvent );
             }
@@ -125,7 +125,7 @@ IMPL_LINK( VCLXMenu, MenuEventListener, VclMenuEvent&, 
rMenuEvent, void )
             if ( maMenuListeners.getLength() )
             {
                 css::awt::MenuEvent aEvent;
-                aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                aEvent.Source = getXWeak();
                 aEvent.MenuId = mpMenu->GetCurItemId();
                 maMenuListeners.itemActivated( aEvent );
             }
@@ -136,7 +136,7 @@ IMPL_LINK( VCLXMenu, MenuEventListener, VclMenuEvent&, 
rMenuEvent, void )
             if ( maMenuListeners.getLength() )
             {
                 css::awt::MenuEvent aEvent;
-                aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                aEvent.Source = getXWeak();
                 aEvent.MenuId = mpMenu->GetCurItemId();
                 maMenuListeners.itemDeactivated( aEvent );
             }
diff --git a/toolkit/source/awt/vclxtoolkit.cxx 
b/toolkit/source/awt/vclxtoolkit.cxx
index a5e3f71386b1..7ae9cda1b6ff 100644
--- a/toolkit/source/awt/vclxtoolkit.cxx
+++ b/toolkit/source/awt/vclxtoolkit.cxx
@@ -972,7 +972,7 @@ void SAL_CALL VCLXToolkit::disposing()
         m_bKeyListener = false;
     }
     css::lang::EventObject aEvent(
-        static_cast< ::cppu::OWeakObject * >(this));
+        getXWeak());
     m_aTopWindowListeners.disposeAndClear(aEvent);
     m_aKeyHandlers.disposeAndClear(aEvent);
     m_aFocusListeners.disposeAndClear(aEvent);
@@ -2189,7 +2189,7 @@ void SAL_CALL VCLXToolkit::addTopWindowListener(
         aGuard.clear();
         rListener->disposing(
             css::lang::EventObject(
-                static_cast< ::cppu::OWeakObject * >(this)));
+                getXWeak()));
     }
     else if (m_aTopWindowListeners.addInterface(rListener) == 1
              && !m_bEventListener)
@@ -2224,7 +2224,7 @@ void SAL_CALL VCLXToolkit::addKeyHandler(
         aGuard.clear();
         rHandler->disposing(
             css::lang::EventObject(
-                static_cast< ::cppu::OWeakObject * >(this)));
+                getXWeak()));
     }
     else if (m_aKeyHandlers.addInterface(rHandler) == 1 && !m_bKeyListener)
     {
@@ -2257,7 +2257,7 @@ void SAL_CALL VCLXToolkit::addFocusListener(
         aGuard.clear();
         rListener->disposing(
             css::lang::EventObject(
-                static_cast< ::cppu::OWeakObject * >(this)));
+                getXWeak()));
     }
     else if (m_aFocusListeners.addInterface(rListener) == 1
              && !m_bEventListener)
diff --git a/toolkit/source/awt/vclxwindow.cxx 
b/toolkit/source/awt/vclxwindow.cxx
index 930d8fe4eaee..5f061e6bd5a9 100644
--- a/toolkit/source/awt/vclxwindow.cxx
+++ b/toolkit/source/awt/vclxwindow.cxx
@@ -427,7 +427,7 @@ void VCLXWindow::ProcessWindowEvent( const VclWindowEvent& 
rVclWindowEvent )
 {
     if (mpImpl->mbDisposing)
         return;
-    css::uno::Reference< css::uno::XInterface > xThis( 
static_cast<cppu::OWeakObject*>(this) );
+    css::uno::Reference< css::uno::XInterface > xThis( getXWeak() );
 
     switch ( rVclWindowEvent.GetId() )
     {
@@ -448,7 +448,7 @@ void VCLXWindow::ProcessWindowEvent( const VclWindowEvent& 
rVclWindowEvent )
             if ( mpImpl->getPaintListeners().getLength() )
             {
                 css::awt::PaintEvent aEvent;
-                aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                aEvent.Source = getXWeak();
                 aEvent.UpdateRect = AWTRectangle( 
*static_cast<tools::Rectangle*>(rVclWindowEvent.GetData()) );
                 aEvent.Count = 0;
                 mpImpl->getPaintListeners().windowPaint( aEvent );
@@ -460,7 +460,7 @@ void VCLXWindow::ProcessWindowEvent( const VclWindowEvent& 
rVclWindowEvent )
             if ( mpImpl->getWindowListeners().getLength() )
             {
                 css::awt::WindowEvent aEvent;
-                aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                aEvent.Source = getXWeak();
                 ImplInitWindowEvent( aEvent, rVclWindowEvent.GetWindow() );
                 mpImpl->getWindowListeners().windowMoved( aEvent );
             }
@@ -471,7 +471,7 @@ void VCLXWindow::ProcessWindowEvent( const VclWindowEvent& 
rVclWindowEvent )
             if ( mpImpl->getWindowListeners().getLength() )
             {
                 css::awt::WindowEvent aEvent;
-                aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                aEvent.Source = getXWeak();
                 ImplInitWindowEvent( aEvent, rVclWindowEvent.GetWindow() );
                 mpImpl->getWindowListeners().windowResized( aEvent );
             }
@@ -482,7 +482,7 @@ void VCLXWindow::ProcessWindowEvent( const VclWindowEvent& 
rVclWindowEvent )
             if ( mpImpl->getWindowListeners().getLength() )
             {
                 css::awt::WindowEvent aEvent;
-                aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                aEvent.Source = getXWeak();
                 ImplInitWindowEvent( aEvent, rVclWindowEvent.GetWindow() );
                 mpImpl->getWindowListeners().windowShown( aEvent );
             }
@@ -491,7 +491,7 @@ void VCLXWindow::ProcessWindowEvent( const VclWindowEvent& 
rVclWindowEvent )
             if ( mpImpl->getTopWindowListeners().getLength() )
             {
                 css::lang::EventObject aEvent;
-                aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                aEvent.Source = getXWeak();
                 mpImpl->getTopWindowListeners().windowOpened( aEvent );
             }
         }
@@ -501,7 +501,7 @@ void VCLXWindow::ProcessWindowEvent( const VclWindowEvent& 
rVclWindowEvent )
             if ( mpImpl->getWindowListeners().getLength() )
             {
                 css::awt::WindowEvent aEvent;
-                aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                aEvent.Source = getXWeak();
                 ImplInitWindowEvent( aEvent, rVclWindowEvent.GetWindow() );
                 mpImpl->getWindowListeners().windowHidden( aEvent );
             }
@@ -510,7 +510,7 @@ void VCLXWindow::ProcessWindowEvent( const VclWindowEvent& 
rVclWindowEvent )
             if ( mpImpl->getTopWindowListeners().getLength() )
             {
                 css::lang::EventObject aEvent;
-                aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                aEvent.Source = getXWeak();
                 mpImpl->getTopWindowListeners().windowClosed( aEvent );
             }
         }
@@ -548,7 +548,7 @@ void VCLXWindow::ProcessWindowEvent( const VclWindowEvent& 
rVclWindowEvent )
             }
 
             css::lang::EventObject aEvent;
-            aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+            aEvent.Source = getXWeak();
             if (rVclWindowEvent.GetId() == VclEventId::WindowActivate)
                 mpImpl->getTopWindowListeners().windowActivated( aEvent );
             else
@@ -560,13 +560,13 @@ void VCLXWindow::ProcessWindowEvent( const 
VclWindowEvent& rVclWindowEvent )
             if ( mpImpl->getDockableWindowListeners().getLength() )
             {
                 css::lang::EventObject aEvent;
-                aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                aEvent.Source = getXWeak();
                 mpImpl->getDockableWindowListeners().notifyEach( 
&XDockableWindowListener::closed, aEvent );
             }
             if ( mpImpl->getTopWindowListeners().getLength() )
             {
                 css::lang::EventObject aEvent;
-                aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                aEvent.Source = getXWeak();
                 mpImpl->getTopWindowListeners().windowClosing( aEvent );
             }
         }
@@ -585,7 +585,7 @@ void VCLXWindow::ProcessWindowEvent( const VclWindowEvent& 
rVclWindowEvent )
                 if ( mpImpl->getFocusListeners().getLength() )
                 {
                     css::awt::FocusEvent aEvent;
-                    aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                    aEvent.Source = getXWeak();
                     aEvent.FocusFlags = 
static_cast<sal_Int16>(rVclWindowEvent.GetWindow()->GetGetFocusFlags());
                     aEvent.Temporary = false;
                     mpImpl->getFocusListeners().focusGained( aEvent );
@@ -607,7 +607,7 @@ void VCLXWindow::ProcessWindowEvent( const VclWindowEvent& 
rVclWindowEvent )
                 if ( mpImpl->getFocusListeners().getLength() )
                 {
                     css::awt::FocusEvent aEvent;
-                    aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                    aEvent.Source = getXWeak();
                     aEvent.FocusFlags = 
static_cast<sal_Int16>(rVclWindowEvent.GetWindow()->GetGetFocusFlags());
                     aEvent.Temporary = false;
 
@@ -622,7 +622,7 @@ void VCLXWindow::ProcessWindowEvent( const VclWindowEvent& 
rVclWindowEvent )
                             pNext = pNextC;
 
                         pNext->GetComponentInterface();
-                        aEvent.NextFocus = 
static_cast<cppu::OWeakObject*>(pNext->GetWindowPeer());
+                        aEvent.NextFocus = 
cppu::getXWeak(pNext->GetWindowPeer());
                     }
                     mpImpl->getFocusListeners().focusLost( aEvent );
                 }
@@ -634,7 +634,7 @@ void VCLXWindow::ProcessWindowEvent( const VclWindowEvent& 
rVclWindowEvent )
             if ( mpImpl->getTopWindowListeners().getLength() )
             {
                 css::lang::EventObject aEvent;
-                aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                aEvent.Source = getXWeak();
                 mpImpl->getTopWindowListeners().windowMinimized( aEvent );
             }
         }
@@ -644,7 +644,7 @@ void VCLXWindow::ProcessWindowEvent( const VclWindowEvent& 
rVclWindowEvent )
             if ( mpImpl->getTopWindowListeners().getLength() )
             {
                 css::lang::EventObject aEvent;
-                aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                aEvent.Source = getXWeak();
                 mpImpl->getTopWindowListeners().windowNormalized( aEvent );
             }
         }
@@ -756,7 +756,7 @@ void VCLXWindow::ProcessWindowEvent( const VclWindowEvent& 
rVclWindowEvent )
                 if( pData )
                 {
                     css::awt::DockingEvent aEvent;
-                    aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                    aEvent.Source = getXWeak();
                     aEvent.TrackingRectangle = AWTRectangle( 
pData->maTrackRect );
                     aEvent.MousePos.X = pData->maMousePos.X();
                     aEvent.MousePos.Y = pData->maMousePos.Y();
@@ -777,7 +777,7 @@ void VCLXWindow::ProcessWindowEvent( const VclWindowEvent& 
rVclWindowEvent )
                 if( pData )
                 {
                     css::awt::DockingEvent aEvent;
-                    aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                    aEvent.Source = getXWeak();
                     aEvent.TrackingRectangle = AWTRectangle( 
pData->maTrackRect );
                     aEvent.MousePos.X = pData->maMousePos.X();
                     aEvent.MousePos.Y = pData->maMousePos.Y();
@@ -808,7 +808,7 @@ void VCLXWindow::ProcessWindowEvent( const VclWindowEvent& 
rVclWindowEvent )
                 if( pData )
                 {
                     css::awt::EndDockingEvent aEvent;
-                    aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                    aEvent.Source = getXWeak();
                     aEvent.WindowRectangle = AWTRectangle( pData->maWindowRect 
);
                     aEvent.bFloating = pData->mbFloating;
                     aEvent.bCancelled = pData->mbCancelled;
@@ -824,7 +824,7 @@ void VCLXWindow::ProcessWindowEvent( const VclWindowEvent& 
rVclWindowEvent )
                 sal_Bool *p_bFloating = 
static_cast<sal_Bool*>(rVclWindowEvent.GetData());
 
                 css::lang::EventObject aEvent;
-                aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                aEvent.Source = getXWeak();
 
                 Reference< XDockableWindowListener > xFirstListener;
                 ::comphelper::OInterfaceIteratorHelper3 aIter( 
mpImpl->getDockableWindowListeners() );
@@ -842,7 +842,7 @@ void VCLXWindow::ProcessWindowEvent( const VclWindowEvent& 
rVclWindowEvent )
             if ( mpImpl->getDockableWindowListeners().getLength() )
             {
                 css::lang::EventObject aEvent;
-                aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                aEvent.Source = getXWeak();
                 mpImpl->getDockableWindowListeners().notifyEach( 
&XDockableWindowListener::toggleFloatingMode, aEvent );
             }
         }
@@ -856,7 +856,7 @@ void VCLXWindow::ProcessWindowEvent( const VclWindowEvent& 
rVclWindowEvent )
                 if( pData )
                 {
                     css::awt::EndPopupModeEvent aEvent;
-                    aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                    aEvent.Source = getXWeak();
                     aEvent.FloatingPosition.X = pData->maFloatingPos.X();
                     aEvent.FloatingPosition.Y = pData->maFloatingPos.Y();
                     aEvent.bTearoff = pData->mbTearoff;
diff --git a/toolkit/source/awt/vclxwindows.cxx 
b/toolkit/source/awt/vclxwindows.cxx
index 8c6652ca8548..d6ba5e48a6e8 100644
--- a/toolkit/source/awt/vclxwindows.cxx
+++ b/toolkit/source/awt/vclxwindows.cxx
@@ -388,7 +388,7 @@ void VCLXButton::dispose()
     SolarMutexGuard aGuard;
 
     css::lang::EventObject aObj;
-    aObj.Source = static_cast<cppu::OWeakObject*>(this);
+    aObj.Source = getXWeak();
     maActionListeners.disposeAndClear( aObj );
     maItemListeners.disposeAndClear( aObj );
     VCLXGraphicControl::dispose();
@@ -581,7 +581,7 @@ void VCLXButton::ProcessWindowEvent( const VclWindowEvent& 
rVclWindowEvent )
             if ( maActionListeners.getLength() )
             {
                 css::awt::ActionEvent aEvent;
-                aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                aEvent.Source = getXWeak();
                 aEvent.ActionCommand = maActionCommand;
 
                 Callback aCallback = [ this, aEvent ]()
@@ -600,7 +600,7 @@ void VCLXButton::ProcessWindowEvent( const VclWindowEvent& 
rVclWindowEvent )
             if ( maItemListeners.getLength() )
             {
                 css::awt::ItemEvent aEvent;
-                aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                aEvent.Source = getXWeak();
                 aEvent.Selected = ( rButton.GetState() == TRISTATE_TRUE ) ? 1 
: 0;
                 maItemListeners.itemStateChanged( aEvent );
             }
@@ -789,7 +789,7 @@ void VCLXCheckBox::dispose()
     SolarMutexGuard aGuard;
 
     css::lang::EventObject aObj;
-    aObj.Source = static_cast<cppu::OWeakObject*>(this);
+    aObj.Source = getXWeak();
     maItemListeners.disposeAndClear( aObj );
     VCLXGraphicControl::dispose();
 }
@@ -1005,7 +1005,7 @@ void VCLXCheckBox::ProcessWindowEvent( const 
VclWindowEvent& rVclWindowEvent )
                 if ( maItemListeners.getLength() )
                 {
                     css::awt::ItemEvent aEvent;
-                    aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                    aEvent.Source = getXWeak();
                     aEvent.Highlighted = 0;
                     aEvent.Selected = pCheckBox->GetState();
                     maItemListeners.itemStateChanged( aEvent );
@@ -1013,7 +1013,7 @@ void VCLXCheckBox::ProcessWindowEvent( const 
VclWindowEvent& rVclWindowEvent )
                 if ( !IsSynthesizingVCLEvent() && 
maActionListeners.getLength() )
                 {
                     css::awt::ActionEvent aEvent;
-                    aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                    aEvent.Source = getXWeak();
                     aEvent.ActionCommand = maActionCommand;
                     maActionListeners.actionPerformed( aEvent );
                 }
@@ -1073,7 +1073,7 @@ void VCLXRadioButton::dispose()
     SolarMutexGuard aGuard;
 
     css::lang::EventObject aObj;
-    aObj.Source = static_cast<cppu::OWeakObject*>(this);
+    aObj.Source = getXWeak();
     maItemListeners.disposeAndClear( aObj );
     VCLXGraphicControl::dispose();
 }
@@ -1261,7 +1261,7 @@ void VCLXRadioButton::ProcessWindowEvent( const 
VclWindowEvent& rVclWindowEvent
             if ( !IsSynthesizingVCLEvent() && maActionListeners.getLength() )
             {
                 css::awt::ActionEvent aEvent;
-                aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                aEvent.Source = getXWeak();
                 aEvent.ActionCommand = maActionCommand;
                 maActionListeners.actionPerformed( aEvent );
             }
@@ -1286,7 +1286,7 @@ void VCLXRadioButton::ImplClickedOrToggled( bool bToggled 
)
     if ( pRadioButton && ( pRadioButton->IsRadioCheckEnabled() == bToggled ) 
&& ( bToggled || pRadioButton->IsStateChanged() ) && 
maItemListeners.getLength() )
     {
         css::awt::ItemEvent aEvent;
-        aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+        aEvent.Source = getXWeak();
         aEvent.Highlighted = 0;
         aEvent.Selected = pRadioButton->IsChecked() ? 1 : 0;
         maItemListeners.itemStateChanged( aEvent );
@@ -1388,7 +1388,7 @@ void VCLXSpinField::ProcessWindowEvent( const 
VclWindowEvent& rVclWindowEvent )
             if ( maSpinListeners.getLength() )
             {
                 css::awt::SpinEvent aEvent;
-                aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                aEvent.Source = getXWeak();
                 switch ( rVclWindowEvent.GetId() )
                 {
                     case VclEventId::SpinfieldUp:     maSpinListeners.up( 
aEvent );
@@ -1460,7 +1460,7 @@ void VCLXListBox::dispose()
     SolarMutexGuard aGuard;
 
     css::lang::EventObject aObj;
-    aObj.Source = static_cast<cppu::OWeakObject*>(this);
+    aObj.Source = getXWeak();
     maItemListeners.disposeAndClear( aObj );
     maActionListeners.disposeAndClear( aObj );
     VCLXWindow::dispose();
@@ -1753,7 +1753,7 @@ void VCLXListBox::ProcessWindowEvent( const 
VclWindowEvent& rVclWindowEvent )
                 {
                     // Call ActionListener on DropDown event
                     css::awt::ActionEvent aEvent;
-                    aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                    aEvent.Source = getXWeak();
                     aEvent.ActionCommand = pListBox->GetSelectedEntry();
                     maActionListeners.actionPerformed( aEvent );
                 }
@@ -1770,7 +1770,7 @@ void VCLXListBox::ProcessWindowEvent( const 
VclWindowEvent& rVclWindowEvent )
             if ( GetWindow() && maActionListeners.getLength() )
             {
                 css::awt::ActionEvent aEvent;
-                aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                aEvent.Source = getXWeak();
                 aEvent.ActionCommand = GetAs<ListBox>()->GetSelectedEntry();
                 maActionListeners.actionPerformed( aEvent );
             }
@@ -2014,7 +2014,7 @@ void VCLXListBox::ImplCallItemListeners()
     if ( pListBox && maItemListeners.getLength() )
     {
         css::awt::ItemEvent aEvent;
-        aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+        aEvent.Source = getXWeak();
         aEvent.Highlighted = 0;
 
         // Set to 0xFFFF on multiple selection, selected entry ID otherwise
@@ -2403,7 +2403,7 @@ void SAL_CALL VCLXMultiPage::dispose()
     SolarMutexGuard aGuard;
 
     css::lang::EventObject aObj;
-    aObj.Source = static_cast<cppu::OWeakObject*>(this);
+    aObj.Source = getXWeak();
     maTabListeners.disposeAndClear( aObj );
     VCLXContainer::dispose();
 }
@@ -2747,7 +2747,7 @@ void VCLXFixedHyperlink::dispose()
         SolarMutexGuard aGuard;
 
         css::lang::EventObject aObj;
-        aObj.Source = static_cast<cppu::OWeakObject*>(this);
+        aObj.Source = getXWeak();
         maActionListeners.disposeAndClear( aObj );
         VCLXWindow::dispose();
 }
@@ -2761,7 +2761,7 @@ void VCLXFixedHyperlink::ProcessWindowEvent( const 
VclWindowEvent& rVclWindowEve
             if ( maActionListeners.getLength() )
             {
                 css::awt::ActionEvent aEvent;
-                aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                aEvent.Source = getXWeak();
                 maActionListeners.actionPerformed( aEvent );
             }
             [[fallthrough]];
@@ -3161,7 +3161,7 @@ void VCLXScrollBar::dispose()
     SolarMutexGuard aGuard;
 
     css::lang::EventObject aObj;
-    aObj.Source = static_cast<cppu::OWeakObject*>(this);
+    aObj.Source = getXWeak();
     maAdjustmentListeners.disposeAndClear( aObj );
     VCLXWindow::dispose();
 }
@@ -3534,7 +3534,7 @@ void VCLXScrollBar::ProcessWindowEvent( const 
VclWindowEvent& rVclWindowEvent )
                 if( pScrollBar )
                 {
                     css::awt::AdjustmentEvent aEvent;
-                    aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                    aEvent.Source = getXWeak();
                     aEvent.Value = pScrollBar->GetThumbPos();
 
                     // set adjustment type
@@ -3630,7 +3630,7 @@ void VCLXEdit::dispose()
     SolarMutexGuard aGuard;
 
     css::lang::EventObject aObj;
-    aObj.Source = static_cast<cppu::OWeakObject*>(this);
+    aObj.Source = getXWeak();
     maTextListeners.disposeAndClear( aObj );
     VCLXWindow::dispose();
 }
@@ -3924,7 +3924,7 @@ void VCLXEdit::ProcessWindowEvent( const VclWindowEvent& 
rVclWindowEvent )
             if ( GetTextListeners().getLength() )
             {
                 css::awt::TextEvent aEvent;
-                aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                aEvent.Source = getXWeak();
                 GetTextListeners().textChanged( aEvent );
             }
         }
@@ -3998,7 +3998,7 @@ void VCLXComboBox::dispose()
     SolarMutexGuard aGuard;
 
     css::lang::EventObject aObj;
-    aObj.Source = static_cast<cppu::OWeakObject*>(this);
+    aObj.Source = getXWeak();
     maItemListeners.disposeAndClear( aObj );
     maActionListeners.disposeAndClear( aObj );
     VCLXEdit::dispose();
@@ -4275,7 +4275,7 @@ void VCLXComboBox::ProcessWindowEvent( const 
VclWindowEvent& rVclWindowEvent )
                     if ( !pComboBox->IsTravelSelect() )
                     {
                         css::awt::ItemEvent aEvent;
-                        aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                        aEvent.Source = getXWeak();
                         aEvent.Highlighted = 0;
 
                         // Set to 0xFFFF on multiple selection, selected entry 
ID otherwise
@@ -4291,7 +4291,7 @@ void VCLXComboBox::ProcessWindowEvent( const 
VclWindowEvent& rVclWindowEvent )
             if ( maActionListeners.getLength() )
             {
                 css::awt::ActionEvent aEvent;
-                aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                aEvent.Source = getXWeak();
 //              aEvent.ActionCommand = ...;
                 maActionListeners.actionPerformed( aEvent );
             }
@@ -6435,7 +6435,7 @@ IMPL_LINK_NOARG(VCLXFileControl, ModifyHdl, Edit&, void)
 void VCLXFileControl::ModifyHdl()
 {
     css::awt::TextEvent aEvent;
-    aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+    aEvent.Source = getXWeak();
     maTextListeners.textChanged( aEvent );
 }
 
@@ -7055,7 +7055,7 @@ void SVTXFormattedField::NotifyTextListeners()
     if ( GetTextListeners().getLength() )
     {
         css::awt::TextEvent aEvent;
-        aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+        aEvent.Source = getXWeak();
         GetTextListeners().textChanged( aEvent );
     }
 }
@@ -7731,7 +7731,7 @@ void VCLXMultiLineEdit::ProcessWindowEvent( const 
VclWindowEvent& rVclWindowEven
             if ( maTextListeners.getLength() )
             {
                 css::awt::TextEvent aEvent;
-                aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+                aEvent.Source = getXWeak();
                 maTextListeners.textChanged( aEvent );
             }
         }
diff --git a/toolkit/source/controls/controlmodelcontainerbase.cxx 
b/toolkit/source/controls/controlmodelcontainerbase.cxx
index 8714b5ad64d4..c6292cd1e21b 100644
--- a/toolkit/source/controls/controlmodelcontainerbase.cxx
+++ b/toolkit/source/controls/controlmodelcontainerbase.cxx
@@ -329,8 +329,7 @@ Reference< XInterface > 
ControlModelContainerBase::createInstance( const OUStrin
         }
     }
 
-    Reference< XInterface > xNewModel = 
static_cast<cppu::OWeakObject*>(pNewModel.get());
-    return xNewModel;
+    return cppu::getXWeak(pNewModel.get());
 }
 
 Reference< XInterface > 
ControlModelContainerBase::createInstanceWithArguments( const OUString& 
ServiceSpecifier, const Sequence< Any >& i_arguments )
@@ -1342,7 +1341,7 @@ void ControlContainerBase::ImplSetPosSize( Reference< 
XControl >& rxCtrl )
 void ControlContainerBase::dispose()
 {
     EventObject aEvt;
-    aEvt.Source = static_cast< ::cppu::OWeakObject* >( this );
+    aEvt.Source = getXWeak();
     // Notify our listener helper about dispose
     // --- SAFE ---
 
diff --git a/toolkit/source/controls/dialogcontrol.cxx 
b/toolkit/source/controls/dialogcontrol.cxx
index 940e60691468..ba954a15412a 100644
--- a/toolkit/source/controls/dialogcontrol.cxx
+++ b/toolkit/source/controls/dialogcontrol.cxx
@@ -331,7 +331,7 @@ void UnoDialogControl::dispose()
     SolarMutexGuard aGuard;
 
     EventObject aEvt;
-    aEvt.Source = static_cast< ::cppu::OWeakObject* >( this );
+    aEvt.Source = getXWeak();
     maTopWindowListeners.disposeAndClear( aEvt );
     ControlContainerBase::dispose();
 }
@@ -689,7 +689,7 @@ void SAL_CALL UnoMultiPageControl::disposing(const 
EventObject&)
 void SAL_CALL UnoMultiPageControl::dispose()
 {
     lang::EventObject aEvt;
-    aEvt.Source = static_cast<cppu::OWeakObject*>(this);
+    aEvt.Source = getXWeak();
     maTabListeners.disposeAndClear( aEvt );
     ControlContainerBase::dispose();
 }
diff --git a/toolkit/source/controls/geometrycontrolmodel.cxx 
b/toolkit/source/controls/geometrycontrolmodel.cxx
index 646e4e58be3a..70e8817da217 100644
--- a/toolkit/source/controls/geometrycontrolmodel.cxx
+++ b/toolkit/source/controls/geometrycontrolmodel.cxx
@@ -92,7 +92,7 @@ constexpr OUStringLiteral GCM_PROPERTY_RESOURCERESOLVER = 
u"ResourceResolver";
             }
 
             setAggregation(m_xAggregate);
-            m_xAggregate->setDelegator(static_cast< XWeak* >(this));
+            m_xAggregate->setDelegator(getXWeak());
         }
         osl_atomic_decrement(&m_refCount);
 
@@ -125,7 +125,7 @@ constexpr OUStringLiteral GCM_PROPERTY_RESOURCERESOLVER = 
u"ResourceResolver";
             // now it should be the 1 we need here ...
 
             setAggregation(m_xAggregate);
-            m_xAggregate->setDelegator(static_cast< XWeak* >(this));
+            m_xAggregate->setDelegator(getXWeak());
         }
         osl_atomic_decrement(&m_refCount);
 
diff --git a/toolkit/source/controls/grid/gridcolumn.cxx 
b/toolkit/source/controls/grid/gridcolumn.cxx
index 9a0b515b6229..92d28ce9c822 100644
--- a/toolkit/source/controls/grid/gridcolumn.cxx
+++ b/toolkit/source/controls/grid/gridcolumn.cxx
@@ -75,7 +75,7 @@ namespace toolkit
     void GridColumn::broadcast_changed( char const * const 
i_asciiAttributeName, const Any& i_oldValue, const Any& i_newValue,
         std::unique_lock<std::mutex>& i_Guard )
     {
-        Reference< XInterface > const xSource( static_cast< 
::cppu::OWeakObject* >( this ) );
+        Reference< XInterface > const xSource( getXWeak() );
         GridColumnEvent const aEvent(
             xSource, OUString::createFromAscii( i_asciiAttributeName ),
             i_oldValue, i_newValue, m_nIndex
diff --git a/toolkit/source/controls/grid/gridcolumn.hxx 
b/toolkit/source/controls/grid/gridcolumn.hxx
index 9d79e85f14ed..13c87922715b 100644
--- a/toolkit/source/controls/grid/gridcolumn.hxx
+++ b/toolkit/source/controls/grid/gridcolumn.hxx
@@ -92,7 +92,7 @@ private:
     {
         std::unique_lock aGuard(m_aMutex);
         if (m_bDisposed)
-            throw css::lang::DisposedException( OUString(), 
static_cast<cppu::OWeakObject*>(this) );
+            throw css::lang::DisposedException( OUString(), getXWeak() );
         if ( io_attribute == i_newValue )
             return;
 
diff --git a/toolkit/source/controls/grid/gridcontrol.cxx 
b/toolkit/source/controls/grid/gridcontrol.cxx
index c60051e5612b..39f4abf531df 100644
--- a/toolkit/source/controls/grid/gridcontrol.cxx
+++ b/toolkit/source/controls/grid/gridcontrol.cxx
@@ -288,7 +288,7 @@ OUString UnoGridControl::GetComponentServiceName() const
 void SAL_CALL UnoGridControl::dispose(  )
 {
     lang::EventObject aEvt;
-    aEvt.Source = static_cast<cppu::OWeakObject*>(this);
+    aEvt.Source = getXWeak();
     m_aSelectionListeners.disposeAndClear( aEvt );
     UnoControl::dispose();
 }
diff --git a/toolkit/source/controls/roadmapcontrol.cxx 
b/toolkit/source/controls/roadmapcontrol.cxx
index 6d73514e7bc4..e46a607ef3ae 100644
--- a/toolkit/source/controls/roadmapcontrol.cxx
+++ b/toolkit/source/controls/roadmapcontrol.cxx
@@ -116,18 +116,14 @@ namespace toolkit
 
     Reference< XInterface > SAL_CALL UnoControlRoadmapModel::createInstance(  )
     {
-        rtl::Reference<ORoadmapEntry> pRoadmapItem = new ORoadmapEntry();
-        Reference< XInterface > xNewRoadmapItem = 
static_cast<cppu::OWeakObject*>(pRoadmapItem.get());
-        return xNewRoadmapItem;
+        return cppu::getXWeak(new ORoadmapEntry());
     }
 
 
     Reference< XInterface > SAL_CALL 
UnoControlRoadmapModel::createInstanceWithArguments( const Sequence< Any >& 
/*aArguments*/ )
     {
         // Todo: implementation of the arguments handling
-        rtl::Reference<ORoadmapEntry> pRoadmapItem = new ORoadmapEntry();
-        Reference< XInterface > xNewRoadmapItem = 
static_cast<cppu::OWeakObject*>(pRoadmapItem.get());
-        return xNewRoadmapItem;
+        return cppu::getXWeak(new ORoadmapEntry());
     }
 
 
@@ -385,7 +381,7 @@ sal_Bool SAL_CALL UnoRoadmapControl::setModel(const 
Reference< XControlModel >&
     void UnoRoadmapControl::dispose()
     {
         EventObject aEvt;
-        aEvt.Source = static_cast<cppu::OWeakObject*>(this);
+        aEvt.Source = getXWeak();
         maItemListeners.disposeAndClear( aEvt );
         UnoControl::dispose();
     }
diff --git a/toolkit/source/controls/svtxgridcontrol.cxx 
b/toolkit/source/controls/svtxgridcontrol.cxx
index 0180231f92da..1ca789db9a1f 100644
--- a/toolkit/source/controls/svtxgridcontrol.cxx
+++ b/toolkit/source/controls/svtxgridcontrol.cxx
@@ -761,7 +761,7 @@ sal_Bool SAL_CALL SVTXGridControl::isRowSelected( 
::sal_Int32 index )
 void SVTXGridControl::dispose()
 {
     EventObject aObj;
-    aObj.Source = static_cast<cppu::OWeakObject*>(this);
+    aObj.Source = getXWeak();
     m_aSelectionListeners.disposeAndClear( aObj );
     VCLXWindow::dispose();
 }
@@ -869,7 +869,7 @@ void SVTXGridControl::ImplCallItemListeners()
     if ( m_aSelectionListeners.getLength() )
     {
         GridSelectionEvent aEvent;
-        aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+        aEvent.Source = getXWeak();
 
         sal_Int32 const nSelectedRowCount( pTable->GetSelectedRowCount() );
         aEvent.SelectedRowIndexes.realloc( nSelectedRowCount );
diff --git a/toolkit/source/controls/tabpagecontainer.cxx 
b/toolkit/source/controls/tabpagecontainer.cxx
index 509c2f12d248..367b5c4f2211 100644
--- a/toolkit/source/controls/tabpagecontainer.cxx
+++ b/toolkit/source/controls/tabpagecontainer.cxx
@@ -139,7 +139,7 @@ void SAL_CALL 
UnoControlTabPageContainerModel::insertByIndex( ::sal_Int32 nIndex
     SolarMutexGuard aSolarGuard;
     uno::Reference < XTabPageModel > xTabPageModel;
     if(!(aElement >>= xTabPageModel))
-        throw IllegalArgumentException( WRONG_TYPE_EXCEPTION, 
static_cast<OWeakObject *>(this), 2 );
+        throw IllegalArgumentException( WRONG_TYPE_EXCEPTION, getXWeak(), 2 );
 
     if ( sal_Int32( m_aTabPageVector.size()) ==nIndex )
         m_aTabPageVector.push_back( xTabPageModel );
@@ -150,7 +150,7 @@ void SAL_CALL 
UnoControlTabPageContainerModel::insertByIndex( ::sal_Int32 nIndex
         m_aTabPageVector.insert( aIter, xTabPageModel );
     }
     else
-        throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject 
*>(this) );
+        throw IndexOutOfBoundsException( OUString(), getXWeak() );
     ContainerEvent aEvent;
     aEvent.Source = *this;
     aEvent.Element = aElement;
@@ -220,7 +220,7 @@ OUString 
UnoControlTabPageContainer::GetComponentServiceName() const
 void SAL_CALL UnoControlTabPageContainer::dispose(  )
 {
     lang::EventObject aEvt;
-    aEvt.Source = static_cast<cppu::OWeakObject*>(this);
+    aEvt.Source = getXWeak();
     m_aTabPageListeners.disposeAndClear( aEvt );
     UnoControl::dispose();
 }
diff --git a/toolkit/source/controls/tkscrollbar.cxx 
b/toolkit/source/controls/tkscrollbar.cxx
index 5a32214454b2..ff2c8cd623f7 100644
--- a/toolkit/source/controls/tkscrollbar.cxx
+++ b/toolkit/source/controls/tkscrollbar.cxx
@@ -132,7 +132,7 @@ namespace toolkit
     void UnoScrollBarControl::dispose()
     {
         lang::EventObject aEvt;
-        aEvt.Source = static_cast<cppu::OWeakObject*>(this);
+        aEvt.Source = getXWeak();
         maAdjustmentListeners.disposeAndClear( aEvt );
         UnoControl::dispose();
     }
diff --git a/toolkit/source/controls/tree/treecontrol.cxx 
b/toolkit/source/controls/tree/treecontrol.cxx
index 59ece9ee4b63..c696220001f7 100644
--- a/toolkit/source/controls/tree/treecontrol.cxx
+++ b/toolkit/source/controls/tree/treecontrol.cxx
@@ -430,7 +430,7 @@ void SAL_CALL UnoTreeControl::removeTreeEditListener( const 
Reference< XTreeEdit
 void SAL_CALL UnoTreeControl::dispose(  )
 {
     lang::EventObject aEvt;
-    aEvt.Source = static_cast< ::cppu::OWeakObject* >(this);
+    aEvt.Source = getXWeak();
     maSelectionListeners.disposeAndClear( aEvt );
     maTreeExpansionListeners.disposeAndClear( aEvt );
     UnoControl::dispose();
diff --git a/toolkit/source/controls/tree/treecontrolpeer.cxx 
b/toolkit/source/controls/tree/treecontrolpeer.cxx
index 9dd5c83a1503..c05650f972fb 100644
--- a/toolkit/source/controls/tree/treecontrolpeer.cxx
+++ b/toolkit/source/controls/tree/treecontrolpeer.cxx
@@ -321,7 +321,7 @@ void TreeControlPeer::updateEntry( UnoTreeListEntry* pEntry 
)
 
 void TreeControlPeer::onSelectionChanged()
 {
-    Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this 
) );
+    Reference< XInterface > xSource( getXWeak() );
     EventObject aEvent( xSource );
     maSelectionListeners.selectionChanged( aEvent );
 }
@@ -331,7 +331,7 @@ void TreeControlPeer::onRequestChildNodes( const Reference< 
XTreeNode >& xNode )
 {
     try
     {
-        Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( 
this ) );
+        Reference< XInterface > xSource( getXWeak() );
         TreeExpansionEvent aEvent( xSource, xNode );
         maTreeExpansionListeners.requestChildNodes( aEvent );
     }
@@ -345,7 +345,7 @@ bool TreeControlPeer::onExpanding( const Reference< 
XTreeNode >& xNode, bool bEx
 {
     try
     {
-        Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( 
this ) );
+        Reference< XInterface > xSource( getXWeak() );
         TreeExpansionEvent aEvent( xSource, xNode );
         if( bExpanding )
         {
@@ -368,7 +368,7 @@ void TreeControlPeer::onExpanded( const Reference< 
XTreeNode >& xNode, bool bExp
 {
     try
     {
-        Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( 
this ) );
+        Reference< XInterface > xSource( getXWeak() );
         TreeExpansionEvent aEvent( xSource, xNode );
 
         if( bExpanding )
diff --git a/toolkit/source/controls/tree/treedatamodel.cxx 
b/toolkit/source/controls/tree/treedatamodel.cxx
index 970f59416f3a..eca39d94f86b 100644
--- a/toolkit/source/controls/tree/treedatamodel.cxx
+++ b/toolkit/source/controls/tree/treedatamodel.cxx
@@ -152,7 +152,7 @@ void MutableTreeDataModel::broadcastImpl( 
std::unique_lock<std::mutex>& rGuard,
     if( !maTreeDataModelListeners.getLength(rGuard) )
         return;
 
-    Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this 
) );
+    Reference< XInterface > xSource( getXWeak() );
     const Sequence< Reference< XTreeNode > > aNodes { rNode };
     TreeDataModelEvent aEvent( xSource, aNodes, xParentNode );
 
@@ -229,7 +229,7 @@ void SAL_CALL MutableTreeDataModel::dispose()
     {
         mbDisposed = true;
         css::lang::EventObject aEvent;
-        aEvent.Source.set( static_cast< ::cppu::OWeakObject* >( this ) );
+        aEvent.Source.set( getXWeak() );
         maTreeDataModelListeners.disposeAndClear( aGuard, aEvent );
         maEventListeners.disposeAndClear( aGuard, aEvent );
     }
diff --git a/toolkit/source/controls/unocontrolmodel.cxx 
b/toolkit/source/controls/unocontrolmodel.cxx
index edd79e687640..76bee95cf2ac 100644
--- a/toolkit/source/controls/unocontrolmodel.cxx
+++ b/toolkit/source/controls/unocontrolmodel.cxx
@@ -1259,7 +1259,7 @@ void UnoControlModel::setPropertyValuesImpl( 
std::unique_lock<std::mutex>& rGuar
     sal_Int32 nProps = rPropertyNames.getLength();
     if (nProps != Values.getLength())
         throw css::lang::IllegalArgumentException("lengths do not match",
-                                                  
static_cast<cppu::OWeakObject*>(this), -1);
+                                                  getXWeak(), -1);
 
 //  sal_Int32* pHandles = new sal_Int32[nProps];
         // don't do this - it leaks in case of an exception
diff --git a/toolkit/source/controls/unocontrols.cxx 
b/toolkit/source/controls/unocontrols.cxx
index 7ce4b471c80c..d9bc55f8cb45 100644
--- a/toolkit/source/controls/unocontrols.cxx
+++ b/toolkit/source/controls/unocontrols.cxx
@@ -758,7 +758,7 @@ OUString UnoButtonControl::GetComponentServiceName() const
 void UnoButtonControl::dispose()
 {
     lang::EventObject aEvt;
-    aEvt.Source = static_cast<cppu::OWeakObject*>(this);
+    aEvt.Source = getXWeak();
     maActionListeners.disposeAndClear( aEvt );
     maItemListeners.disposeAndClear( aEvt );
     UnoControlBase::dispose();
@@ -1006,7 +1006,7 @@ OUString 
UnoImageControlControl::GetComponentServiceName() const
 void UnoImageControlControl::dispose()
 {
     lang::EventObject aEvt;
-    aEvt.Source = static_cast<cppu::OWeakObject*>(this);
+    aEvt.Source = getXWeak();
     maActionListeners.disposeAndClear( aEvt );
     UnoControl::dispose();
 }
@@ -1133,7 +1133,7 @@ OUString UnoRadioButtonControl::GetComponentServiceName() 
const
 void UnoRadioButtonControl::dispose()
 {
     lang::EventObject aEvt;
-    aEvt.Source = static_cast<cppu::OWeakObject*>(this);
+    aEvt.Source = getXWeak();
     maItemListeners.disposeAndClear( aEvt );
     UnoControlBase::dispose();
 }
@@ -1364,7 +1364,7 @@ OUString UnoCheckBoxControl::GetComponentServiceName() 
const
 void UnoCheckBoxControl::dispose()
 {
     lang::EventObject aEvt;
-    aEvt.Source = static_cast<cppu::OWeakObject*>(this);
+    aEvt.Source = getXWeak();
     maItemListeners.disposeAndClear( aEvt );
     UnoControlBase::dispose();
 }
@@ -1641,7 +1641,7 @@ awt::Size UnoFixedHyperlinkControl::calcAdjustedSize( 
const awt::Size& rNewSize
 void UnoFixedHyperlinkControl::dispose()
 {
     lang::EventObject aEvt;
-    aEvt.Source = static_cast<cppu::OWeakObject*>(this);
+    aEvt.Source = getXWeak();
     maActionListeners.disposeAndClear( aEvt );
     UnoControlBase::dispose();
 }
@@ -2518,7 +2518,7 @@ css::uno::Sequence<OUString> 
UnoListBoxControl::getSupportedServiceNames()
 void UnoListBoxControl::dispose()
 {
     lang::EventObject aEvt;
-    aEvt.Source = static_cast<cppu::OWeakObject*>(this);
+    aEvt.Source = getXWeak();
     maActionListeners.disposeAndClear( aEvt );
     maItemListeners.disposeAndClear( aEvt );
     UnoControl::dispose();
@@ -3014,7 +3014,7 @@ OUString UnoComboBoxControl::GetComponentServiceName() 
const
 void UnoComboBoxControl::dispose()
 {
     lang::EventObject aEvt;
-    aEvt.Source = static_cast<cppu::OWeakObject*>(this);
+    aEvt.Source = getXWeak();
     maActionListeners.disposeAndClear( aEvt );
     maItemListeners.disposeAndClear( aEvt );
     UnoControl::dispose();
diff --git a/toolkit/source/hatchwindow/documentcloser.cxx 
b/toolkit/source/hatchwindow/documentcloser.cxx
index 6ef68a6a8845..70171d7308e8 100644
--- a/toolkit/source/hatchwindow/documentcloser.cxx
+++ b/toolkit/source/hatchwindow/documentcloser.cxx
@@ -169,7 +169,7 @@ void SAL_CALL ODocumentCloser::dispose()
     if ( m_bDisposed )
         return;
 
-    lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >(this) );
+    lang::EventObject aSource( getXWeak() );
     m_aListenersContainer.disposeAndClear( aGuard, aSource );
 
     // TODO: trigger a main thread execution to close the frame

Reply via email to