toolkit/source/awt/vclxdevice.cxx                             |   47 ++----
 toolkit/source/awt/vclxmenu.cxx                               |   70 ++++------
 toolkit/source/awt/vclxtoolkit.cxx                            |   18 +-
 toolkit/source/controls/table/AccessibleGridControlHeader.cxx |    7 -
 4 files changed, 65 insertions(+), 77 deletions(-)

New commits:
commit 49323ab5e73a3c92a28d4c9fe386dcf5e78d2968
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Mon Mar 10 10:54:21 2025 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Mar 10 11:37:23 2025 +0100

    use more concrete UNO classes in toolkit
    
    Change-Id: Ief7941e0abbc111c6e0932b8bed84a626b9a744d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182720
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/toolkit/source/awt/vclxdevice.cxx 
b/toolkit/source/awt/vclxdevice.cxx
index 96f2967b4a1e..1da0957d77aa 100644
--- a/toolkit/source/awt/vclxdevice.cxx
+++ b/toolkit/source/awt/vclxdevice.cxx
@@ -63,16 +63,14 @@ css::uno::Reference< css::awt::XDevice > 
VCLXDevice::createDevice( sal_Int32 nWi
 {
     SolarMutexGuard aGuard;
 
-    css::uno::Reference< css::awt::XDevice >  xRef;
-    if ( GetOutputDevice() )
-    {
-        rtl::Reference<VCLXVirtualDevice> pVDev = new VCLXVirtualDevice;
-        VclPtrInstance<VirtualDevice> pVclVDev( *GetOutputDevice() );
-        pVclVDev->SetOutputSizePixel( Size( nWidth, nHeight ) );
-        pVDev->SetVirtualDevice( pVclVDev );
-        xRef = pVDev;
-    }
-    return xRef;
+    if ( !GetOutputDevice() )
+        return nullptr;
+
+    rtl::Reference<VCLXVirtualDevice> pVDev = new VCLXVirtualDevice;
+    VclPtrInstance<VirtualDevice> pVclVDev( *GetOutputDevice() );
+    pVclVDev->SetOutputSizePixel( Size( nWidth, nHeight ) );
+    pVDev->SetVirtualDevice( pVclVDev );
+    return pVDev;
 }
 
 css::awt::DeviceInfo VCLXDevice::getInfo()
@@ -110,30 +108,25 @@ css::uno::Reference< css::awt::XFont > 
VCLXDevice::getFont( const css::awt::Font
 {
     SolarMutexGuard aGuard;
 
-    css::uno::Reference< css::awt::XFont >  xRef;
-    if( mpOutputDevice )
-    {
-        rtl::Reference<VCLXFont> pMetric
-            = new VCLXFont(*this, VCLUnoHelper::CreateFont(rDescriptor, 
mpOutputDevice->GetFont()));
-        xRef = pMetric;
-    }
-    return xRef;
+    if( !mpOutputDevice )
+        return nullptr;
+
+    rtl::Reference<VCLXFont> pMetric
+        = new VCLXFont(*this, VCLUnoHelper::CreateFont(rDescriptor, 
mpOutputDevice->GetFont()));
+    return pMetric;
 }
 
 css::uno::Reference< css::awt::XBitmap > VCLXDevice::createBitmap( sal_Int32 
nX, sal_Int32 nY, sal_Int32 nWidth, sal_Int32 nHeight )
 {
     SolarMutexGuard aGuard;
 
-    css::uno::Reference< css::awt::XBitmap >  xBmp;
-    if( mpOutputDevice )
-    {
-        BitmapEx aBmp = mpOutputDevice->GetBitmapEx( Point( nX, nY ), Size( 
nWidth, nHeight ) );
+    if( !mpOutputDevice )
+        return nullptr;
 
-        rtl::Reference<VCLXBitmap> pBmp = new VCLXBitmap;
-        pBmp->SetBitmap( aBmp );
-        xBmp = pBmp;
-    }
-    return xBmp;
+    BitmapEx aBmp = mpOutputDevice->GetBitmapEx( Point( nX, nY ), Size( 
nWidth, nHeight ) );
+    rtl::Reference<VCLXBitmap> pBmp = new VCLXBitmap;
+    pBmp->SetBitmap( aBmp );
+    return pBmp;
 }
 
 css::uno::Reference< css::awt::XDisplayBitmap > 
VCLXDevice::createDisplayBitmap( const css::uno::Reference< css::awt::XBitmap 
>& rxBitmap )
diff --git a/toolkit/source/awt/vclxmenu.cxx b/toolkit/source/awt/vclxmenu.cxx
index fb12c14180b6..10abaa0e9876 100644
--- a/toolkit/source/awt/vclxmenu.cxx
+++ b/toolkit/source/awt/vclxmenu.cxx
@@ -399,46 +399,44 @@ css::uno::Reference< css::awt::XPopupMenu > 
VCLXMenu::getPopupMenu(
     SolarMutexGuard aSolarGuard;
     std::unique_lock aGuard( maMutex );
 
-    css::uno::Reference< css::awt::XPopupMenu >  aRef;
-    Menu* pMenu = mpMenu ? mpMenu->GetPopupMenu( nItemId ) : nullptr;
-    if ( pMenu )
+    if ( !mpMenu )
+        return nullptr;
+    Menu* pMenu = mpMenu->GetPopupMenu( nItemId );
+    if ( !pMenu )
+        return nullptr;
+
+    for ( size_t n = maPopupMenuRefs.size(); n; )
     {
-        for ( size_t n = maPopupMenuRefs.size(); n; )
-        {
-            css::uno::Reference< css::awt::XPopupMenu >& rRef = 
maPopupMenuRefs[ --n ];
-            Menu* pM = static_cast<VCLXMenu*>(rRef.get())->GetMenu();
-            if ( pM == pMenu )
-            {
-                aRef = rRef;
-                break;
-            }
-        }
-        /*
-           If the popup menu is not inserted via setPopupMenu then
-           maPopupMenuRefs won't have an entry for it, so create an XPopupMenu
-           for it now.
-
-           This means that this vcl PopupMenu "pMenu" either existed as a child
-           of the vcl Menu "mpMenu" before the VCLXMenu was created for that or
-           it was added directly via vcl.
-        */
-        if( !aRef.is() )
+        css::uno::Reference< css::awt::XPopupMenu >& rRef = maPopupMenuRefs[ 
--n ];
+        Menu* pM = static_cast<VCLXMenu*>(rRef.get())->GetMenu();
+        if ( pM == pMenu )
         {
-            aRef = new VCLXPopupMenu( static_cast<PopupMenu*>(pMenu) );
-            /*
-               In any case, the VCLXMenu has ownership of "mpMenu" and will
-               destroy it in the VCLXMenu dtor.
-
-               Similarly because VCLXPopupMenu takes ownership of the vcl
-               PopupMenu "pMenu", the underlying vcl popup will be destroyed
-               when VCLXPopupMenu is, so we should add it now to
-               maPopupMenuRefs to ensure its lifecycle is at least bound to
-               the VCLXMenu that owns the parent "mpMenu" similarly to
-               PopupMenus added via the more conventional setPopupMenu.
-            */
-            maPopupMenuRefs.push_back( aRef );
+            return rRef;
         }
     }
+
+    /*
+       If the popup menu is not inserted via setPopupMenu then
+       maPopupMenuRefs won't have an entry for it, so create an XPopupMenu
+       for it now.
+
+       This means that this vcl PopupMenu "pMenu" either existed as a child
+       of the vcl Menu "mpMenu" before the VCLXMenu was created for that or
+       it was added directly via vcl.
+    */
+    rtl::Reference< VCLXPopupMenu > aRef = new VCLXPopupMenu( 
static_cast<PopupMenu*>(pMenu) );
+    /*
+       In any case, the VCLXMenu has ownership of "mpMenu" and will
+       destroy it in the VCLXMenu dtor.
+
+       Similarly because VCLXPopupMenu takes ownership of the vcl
+       PopupMenu "pMenu", the underlying vcl popup will be destroyed
+       when VCLXPopupMenu is, so we should add it now to
+       maPopupMenuRefs to ensure its lifecycle is at least bound to
+       the VCLXMenu that owns the parent "mpMenu" similarly to
+       PopupMenus added via the more conventional setPopupMenu.
+    */
+    maPopupMenuRefs.push_back( aRef );
     return aRef;
 }
 
diff --git a/toolkit/source/awt/vclxtoolkit.cxx 
b/toolkit/source/awt/vclxtoolkit.cxx
index c25a17ed5490..ff441c07d7a8 100644
--- a/toolkit/source/awt/vclxtoolkit.cxx
+++ b/toolkit/source/awt/vclxtoolkit.cxx
@@ -1980,17 +1980,15 @@ css::uno::Reference< css::awt::XWindowPeer > 
VCLXToolkit::createSystemChild( con
         pChildWindow.reset(VclPtr<WorkWindow>::Create(nullptr, Parent));
     }
 
-    css::uno::Reference< css::awt::XVclWindowPeer > xPeer;
-    if ( pChildWindow )
-    {
-        rtl::Reference<VCLXTopWindow> pPeer = new VCLXTopWindow;
-        SolarMutexGuard aGuard;
-        pPeer->SetWindow( pChildWindow );
-        xPeer = pPeer;
-        pChildWindow->SetWindowPeer(xPeer, pPeer.get());
-    }
+    if ( !pChildWindow )
+        return nullptr;
+
+    rtl::Reference<VCLXTopWindow> pPeer = new VCLXTopWindow;
+    SolarMutexGuard aGuard;
+    pPeer->SetWindow( pChildWindow );
+    pChildWindow->SetWindowPeer(pPeer, pPeer.get());
 
-    return xPeer;
+    return pPeer;
 }
 
 // css::awt::XMessageBoxFactory
diff --git a/toolkit/source/controls/table/AccessibleGridControlHeader.cxx 
b/toolkit/source/controls/table/AccessibleGridControlHeader.cxx
index 36606111424e..bf96d2af9064 100644
--- a/toolkit/source/controls/table/AccessibleGridControlHeader.cxx
+++ b/toolkit/source/controls/table/AccessibleGridControlHeader.cxx
@@ -193,20 +193,19 @@ AbsoluteScreenPixelRectangle 
AccessibleGridControlHeader::implGetBoundingBoxOnSc
 Reference< XAccessible > AccessibleGridControlHeader::implGetChild(
         sal_Int32 nRow, sal_uInt32 nColumnPos )
 {
-    Reference< XAccessible > xChild;
     if (m_eObjType == AccessibleTableControlObjType::COLUMNHEADERBAR)
     {
         rtl::Reference<AccessibleGridControlHeaderCell> pColHeaderCell = new 
AccessibleGridControlHeaderCell(nColumnPos, this, m_aTable,
                                                                                
                              AccessibleTableControlObjType::COLUMNHEADERCELL);
-        xChild = pColHeaderCell;
+        return pColHeaderCell;
     }
     else if (m_eObjType == AccessibleTableControlObjType::ROWHEADERBAR)
     {
         rtl::Reference<AccessibleGridControlHeaderCell> pRowHeaderCell = new 
AccessibleGridControlHeaderCell(nRow, this, m_aTable,
                                                                                
                              AccessibleTableControlObjType::ROWHEADERCELL);
-        xChild = pRowHeaderCell;
+        return pRowHeaderCell;
     }
-    return xChild;
+    return nullptr;
 }
 
 } // namespace accessibility

Reply via email to