[Libreoffice-commits] core.git: vbahelper/source

Noel (via logerrit) logerrit at kemper.freedesktop.org
Fri Feb 19 10:30:00 UTC 2021


 vbahelper/source/vbahelper/vbacommandbarcontrols.cxx |    7 ++++---
 vbahelper/source/vbahelper/vbashapes.cxx             |    9 +++++----
 2 files changed, 9 insertions(+), 7 deletions(-)

New commits:
commit 3f95cbcda193c2e87159ba3e8c137f8a12643c84
Author:     Noel <noel.grandin at collabora.co.uk>
AuthorDate: Fri Feb 19 11:25:58 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Feb 19 11:29:21 2021 +0100

    loplugin:refcounting in vbahelper
    
    Change-Id: I91c4ce6529e18a309e7b6d4432b612f7d38f817e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111197
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx b/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx
index 643c4aa71445..1b35964446b0 100644
--- a/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx
+++ b/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx
@@ -19,6 +19,7 @@
 #include "vbacommandbarcontrols.hxx"
 #include "vbacommandbarcontrol.hxx"
 #include <com/sun/star/lang/XSingleComponentFactory.hpp>
+#include <rtl/ref.hxx>
 
 using namespace com::sun::star;
 using namespace ooo::vba;
@@ -132,7 +133,7 @@ ScVbaCommandBarControls::createCollectionObject( const uno::Any& aSource )
     m_xIndexAccess->getByIndex( nPosition ) >>= aProps;
     uno::Reference< container::XIndexAccess > xSubMenu;
     getPropertyValue( aProps, ITEM_DESCRIPTOR_CONTAINER ) >>= xSubMenu;
-    ScVbaCommandBarControl* pNewCommandBarControl = nullptr;
+    rtl::Reference<ScVbaCommandBarControl> pNewCommandBarControl;
     if( xSubMenu.is() )
         pNewCommandBarControl = new ScVbaCommandBarPopup( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition );
     else
@@ -220,13 +221,13 @@ ScVbaCommandBarControls::Add( const uno::Any& Type, const uno::Any& Id, const un
 
     pCBarHelper->ApplyTempChange( m_sResourceUrl, m_xBarSettings );
 
-    ScVbaCommandBarControl* pNewCommandBarControl = nullptr;
+    rtl::Reference<ScVbaCommandBarControl> pNewCommandBarControl;
     if( nType == office::MsoControlType::msoControlPopup )
         pNewCommandBarControl = new ScVbaCommandBarPopup( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition );
     else
         pNewCommandBarControl = new ScVbaCommandBarButton( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition );
 
-    return uno::Reference< XCommandBarControl >( pNewCommandBarControl );
+    return pNewCommandBarControl;
 }
 
 // XHelperInterface
diff --git a/vbahelper/source/vbahelper/vbashapes.cxx b/vbahelper/source/vbahelper/vbashapes.cxx
index 118082fa9667..c14f81791f95 100644
--- a/vbahelper/source/vbahelper/vbashapes.cxx
+++ b/vbahelper/source/vbahelper/vbashapes.cxx
@@ -42,6 +42,7 @@
 #include <vbahelper/vbashape.hxx>
 #include <vbahelper/vbashapes.hxx>
 #include <vbahelper/vbashaperange.hxx>
+#include <rtl/ref.hxx>
 
 using namespace ::ooo::vba;
 using namespace ::com::sun::star;
@@ -238,7 +239,7 @@ ScVbaShapes::AddRectangle(sal_Int32 startX, sal_Int32 startY, sal_Int32 nLineWid
     size.Width = nWidth;
     xShape->setSize( size );
 
-    ScVbaShape *pScVbaShape = new ScVbaShape( getParent(), mxContext, xShape, m_xShapes, m_xModel, ScVbaShape::getType( xShape ) );
+    rtl::Reference<ScVbaShape> pScVbaShape = new ScVbaShape( getParent(), mxContext, xShape, m_xShapes, m_xModel, ScVbaShape::getType( xShape ) );
     return uno::makeAny( uno::Reference< msforms::XShape > ( pScVbaShape ) );
 }
 
@@ -280,7 +281,7 @@ ScVbaShapes::AddEllipse(sal_Int32 startX, sal_Int32 startY, sal_Int32 nLineWidth
     size.Width = nWidth;
     xShape->setSize(size);
 
-    ScVbaShape *pScVbaShape = new ScVbaShape( getParent(), mxContext, xShape, m_xShapes, m_xModel, ScVbaShape::getType( xShape ) );
+    rtl::Reference<ScVbaShape> pScVbaShape = new ScVbaShape( getParent(), mxContext, xShape, m_xShapes, m_xModel, ScVbaShape::getType( xShape ) );
     return uno::makeAny( uno::Reference< msforms::XShape > ( pScVbaShape ) );
 }
 
@@ -315,7 +316,7 @@ ScVbaShapes::AddLine( sal_Int32 StartX, sal_Int32 StartY, sal_Int32 endX, sal_In
     size.Width = nWidth;
     xShape->setSize(size);
 
-    ScVbaShape *pScVbaShape = new ScVbaShape( getParent(), mxContext, xShape, m_xShapes, m_xModel, ScVbaShape::getType( xShape ) );
+    rtl::Reference<ScVbaShape> pScVbaShape = new ScVbaShape( getParent(), mxContext, xShape, m_xShapes, m_xModel, ScVbaShape::getType( xShape ) );
     return uno::makeAny( uno::Reference< msforms::XShape > ( pScVbaShape ) );
 }
 
@@ -382,7 +383,7 @@ ScVbaShapes::AddTextboxInWriter( sal_Int32 _nLeft, sal_Int32 _nTop, sal_Int32 _n
     xShapeProps->setPropertyValue( "LayerName", uno::makeAny( OUString("Heaven") ) );
 
 
-    ScVbaShape *pScVbaShape = new ScVbaShape( getParent(), mxContext, xShape, m_xShapes, m_xModel, ScVbaShape::getType( xShape ) );
+    rtl::Reference<ScVbaShape> pScVbaShape = new ScVbaShape( getParent(), mxContext, xShape, m_xShapes, m_xModel, ScVbaShape::getType( xShape ) );
     return uno::makeAny( uno::Reference< msforms::XShape > ( pScVbaShape ) );
 }
 


More information about the Libreoffice-commits mailing list