[Libreoffice-commits] core.git: dbaccess/source include/svx sd/source svx/source

Noel (via logerrit) logerrit at kemper.freedesktop.org
Sat Feb 20 10:39:42 UTC 2021


 dbaccess/source/ui/browser/sbagrid.cxx                    |    2 -
 dbaccess/source/ui/inc/sbagrid.hxx                        |    2 -
 include/svx/fmgridif.hxx                                  |    2 -
 include/svx/tbcontrl.hxx                                  |    3 -
 include/svx/unoapi.hxx                                    |    3 +
 include/svx/unopage.hxx                                   |    3 +
 sd/source/ui/unoidl/unomodel.cxx                          |    8 ++---
 svx/source/accessibility/AccessibleControlShape.cxx       |    5 +--
 svx/source/accessibility/AccessibleFrameSelector.cxx      |   10 ++----
 svx/source/accessibility/AccessibleShape.cxx              |    4 +-
 svx/source/accessibility/GraphCtlAccessibleContext.cxx    |    2 -
 svx/source/accessibility/charmapacc.cxx                   |    4 +-
 svx/source/accessibility/svxpixelctlaccessiblecontext.cxx |    7 +---
 svx/source/accessibility/svxrectctaccessiblecontext.cxx   |   12 +++----
 svx/source/dialog/charmap.cxx                             |    2 -
 svx/source/dialog/docrecovery.cxx                         |    6 +--
 svx/source/dialog/weldeditview.cxx                        |    7 +---
 svx/source/fmcomp/fmgridif.cxx                            |    6 +--
 svx/source/form/fmobj.cxx                                 |    2 -
 svx/source/form/formcontroller.cxx                        |   18 +++++------
 svx/source/gallery2/galtheme.cxx                          |    2 -
 svx/source/inc/StylesPreviewWindow.hxx                    |    3 -
 svx/source/sdr/overlay/overlaypolypolygon.cxx             |    7 +---
 svx/source/sdr/primitive2d/sdrdecompositiontools.cxx      |   13 +++-----
 svx/source/svdraw/svdobj.cxx                              |    3 +
 svx/source/svdraw/svdotextdecomposition.cxx               |   19 ++++++------
 svx/source/svdraw/svdotextpathdecomposition.cxx           |   22 +++++---------
 svx/source/table/accessibletableshape.cxx                 |    6 +--
 svx/source/tbxctrls/StylesPreviewWindow.cxx               |    7 +---
 svx/source/tbxctrls/tbcontrl.cxx                          |    9 +----
 svx/source/unodraw/UnoGraphicExporter.cxx                 |    3 -
 svx/source/unodraw/unomod.cxx                             |    5 +--
 svx/source/unodraw/unopage.cxx                            |    6 +--
 33 files changed, 94 insertions(+), 119 deletions(-)

New commits:
commit d8ed3bda462b351d2b98ec57cfdb879e0eec0010
Author:     Noel <noel.grandin at collabora.co.uk>
AuthorDate: Fri Feb 19 15:53:30 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sat Feb 20 11:38:55 2021 +0100

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

diff --git a/dbaccess/source/ui/browser/sbagrid.cxx b/dbaccess/source/ui/browser/sbagrid.cxx
index 093f243ca738..f10ee9ccb0df 100644
--- a/dbaccess/source/ui/browser/sbagrid.cxx
+++ b/dbaccess/source/ui/browser/sbagrid.cxx
@@ -108,7 +108,7 @@ SbaXGridControl::~SbaXGridControl()
 {
 }
 
-FmXGridPeer* SbaXGridControl::imp_CreatePeer(vcl::Window* pParent)
+rtl::Reference<FmXGridPeer> SbaXGridControl::imp_CreatePeer(vcl::Window* pParent)
 {
     FmXGridPeer* pReturn = new SbaXGridPeer(m_xContext);
 
diff --git a/dbaccess/source/ui/inc/sbagrid.hxx b/dbaccess/source/ui/inc/sbagrid.hxx
index 2bef1cfbbcd2..5bf7752311ba 100644
--- a/dbaccess/source/ui/inc/sbagrid.hxx
+++ b/dbaccess/source/ui/inc/sbagrid.hxx
@@ -83,7 +83,7 @@ namespace dbaui
         virtual void SAL_CALL createPeer(const css::uno::Reference< css::awt::XToolkit > & rToolkit, const css::uno::Reference< css::awt::XWindowPeer > & rParentPeer) override;
 
     protected:
-        virtual FmXGridPeer*    imp_CreatePeer(vcl::Window* pParent) override;
+        virtual rtl::Reference<FmXGridPeer> imp_CreatePeer(vcl::Window* pParent) override;
     };
 
     // SbaXGridPeer
diff --git a/include/svx/fmgridif.hxx b/include/svx/fmgridif.hxx
index 2703b6a016d7..8db610a77414 100644
--- a/include/svx/fmgridif.hxx
+++ b/include/svx/fmgridif.hxx
@@ -310,7 +310,7 @@ public:
     virtual void SAL_CALL setFocus() override;
 
 protected:
-    virtual FmXGridPeer*    imp_CreatePeer(vcl::Window* pParent);
+    virtual rtl::Reference<FmXGridPeer> imp_CreatePeer(vcl::Window* pParent);
         // ImplCreatePeer would be better, but doesn't work because it's not exported
 };
 
diff --git a/include/svx/tbcontrl.hxx b/include/svx/tbcontrl.hxx
index c020ccd52a8d..995bbb05a1cb 100644
--- a/include/svx/tbcontrl.hxx
+++ b/include/svx/tbcontrl.hxx
@@ -186,8 +186,7 @@ private:
 #define MAX_FAMILIES 5
 
     SfxStyleSheetBasePool* pStyleSheetPool;
-    SfxStyleControllerItem_Impl* pBoundItems[MAX_FAMILIES];
-    css::uno::Reference<css::lang::XComponent> m_xBoundItems[MAX_FAMILIES];
+    rtl::Reference<SfxStyleControllerItem_Impl> m_xBoundItems[MAX_FAMILIES];
     std::unique_ptr<SfxTemplateItem> pFamilyState[MAX_FAMILIES];
     sal_uInt16 nActFamily; // Id in the ToolBox = Position - 1
 
diff --git a/include/svx/unoapi.hxx b/include/svx/unoapi.hxx
index 693a15646497..3297eeaf6bba 100644
--- a/include/svx/unoapi.hxx
+++ b/include/svx/unoapi.hxx
@@ -22,6 +22,7 @@
 
 #include <com/sun/star/drawing/XShape.hpp>
 #include <com/sun/star/drawing/XDrawPage.hpp>
+#include <rtl/ref.hxx>
 #include <sal/types.h>
 #include <svx/svxdllapi.h>
 #include <tools/fldunit.hxx>
@@ -40,7 +41,7 @@ enum class SdrInventor : sal_uInt32;
  *
  * @throws css::uno::RuntimeException
  */
-SVXCORE_DLLPUBLIC SvxShape* CreateSvxShapeByTypeAndInventor(sal_uInt16 nType, SdrInventor nInventor, OUString const & referer);
+SVXCORE_DLLPUBLIC rtl::Reference<SvxShape> CreateSvxShapeByTypeAndInventor(sal_uInt16 nType, SdrInventor nInventor, OUString const & referer);
 
 /** Returns a StarOffice API wrapper for the given SdrObject */
 SVXCORE_DLLPUBLIC css::uno::Reference< css::drawing::XShape > GetXShapeForSdrObject( SdrObject* pObj ) throw ();
diff --git a/include/svx/unopage.hxx b/include/svx/unopage.hxx
index b3bf6bfe47d3..2308eb93ad06 100644
--- a/include/svx/unopage.hxx
+++ b/include/svx/unopage.hxx
@@ -30,6 +30,7 @@
 #include <cppuhelper/basemutex.hxx>
 #include <svx/svxdllapi.h>
 #include <svx/svdobjkind.hxx>
+#include <rtl/ref.hxx>
 
 #include <cppuhelper/implbase7.hxx>
 #include <comphelper/servicehelper.hxx>
@@ -87,7 +88,7 @@ class SVXCORE_DLLPUBLIC SvxDrawPage : protected cppu::BaseMutex,
     virtual SdrObject *CreateSdrObject_( const css::uno::Reference< css::drawing::XShape >& xShape );
 
     /// @throws css::uno::RuntimeException
-    static SvxShape* CreateShapeByTypeAndInventor( sal_uInt16 nType, SdrInventor nInventor, SdrObject *pObj, SvxDrawPage *pPage = nullptr, OUString const & referer = OUString() );
+    static rtl::Reference<SvxShape> CreateShapeByTypeAndInventor( sal_uInt16 nType, SdrInventor nInventor, SdrObject *pObj, SvxDrawPage *pPage = nullptr, OUString const & referer = OUString() );
 
     // The following method is called if a SvxShape object is to be created.
     // Derived classes can create a derivation or an SvxShape aggregating object.
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index f3e965c0d91f..6051e07fe8f3 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -953,7 +953,7 @@ css::uno::Reference<css::uno::XInterface> SdXImpressDocument::create(
     if( aServiceSpecifier.startsWith( "com.sun.star.presentation.") )
     {
         const OUString aType( aServiceSpecifier.copy(26) );
-        SvxShape* pShape = nullptr;
+        rtl::Reference<SvxShape> pShape;
 
         sal_uInt16 nType = OBJ_TEXT;
         // create a shape wrapper
@@ -1037,15 +1037,15 @@ css::uno::Reference<css::uno::XInterface> SdXImpressDocument::create(
         if( pShape && !mbClipBoard )
             pShape->SetShapeType(aServiceSpecifier);
 
-        xRet = static_cast<uno::XWeak*>(pShape);
+        xRet = static_cast<uno::XWeak*>(pShape.get());
     }
     else if ( aServiceSpecifier == "com.sun.star.drawing.TableShape" )
     {
-        SvxShape* pShape = CreateSvxShapeByTypeAndInventor( OBJ_TABLE, SdrInventor::Default, referer );
+        rtl::Reference<SvxShape> pShape = CreateSvxShapeByTypeAndInventor( OBJ_TABLE, SdrInventor::Default, referer );
         if( pShape && !mbClipBoard )
             pShape->SetShapeType(aServiceSpecifier);
 
-        xRet = static_cast<uno::XWeak*>(pShape);
+        xRet = static_cast<uno::XWeak*>(pShape.get());
     }
     else
     {
diff --git a/svx/source/accessibility/AccessibleControlShape.cxx b/svx/source/accessibility/AccessibleControlShape.cxx
index b5eda7f92891..60581f3d8342 100644
--- a/svx/source/accessibility/AccessibleControlShape.cxx
+++ b/svx/source/accessibility/AccessibleControlShape.cxx
@@ -557,7 +557,7 @@ Reference< XAccessible > SAL_CALL AccessibleControlShape::getAccessibleChild( sa
 
 Reference< XAccessibleRelationSet > SAL_CALL AccessibleControlShape::getAccessibleRelationSet(  )
 {
-    utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
+    rtl::Reference<utl::AccessibleRelationSetHelper> pRelationSetHelper = new utl::AccessibleRelationSetHelper;
     ensureControlModelAccess();
     AccessibleControlShape* pCtlAccShape = GetLabeledByControlShape();
     if(pCtlAccShape)
@@ -574,8 +574,7 @@ Reference< XAccessibleRelationSet > SAL_CALL AccessibleControlShape::getAccessib
             pRelationSetHelper->AddRelation( AccessibleRelation( AccessibleRelationType::LABELED_BY, aSequence ) );
         }
     }
-    Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
-    return xSet;
+    return pRelationSetHelper;
 }
 
 OUString AccessibleControlShape::CreateAccessibleName()
diff --git a/svx/source/accessibility/AccessibleFrameSelector.cxx b/svx/source/accessibility/AccessibleFrameSelector.cxx
index d367121e4bcf..3c3007fc0aff 100644
--- a/svx/source/accessibility/AccessibleFrameSelector.cxx
+++ b/svx/source/accessibility/AccessibleFrameSelector.cxx
@@ -110,8 +110,7 @@ Reference< XAccessibleRelationSet > AccFrameSelector::getAccessibleRelationSet(
 Reference< XAccessibleStateSet > AccFrameSelector::getAccessibleStateSet(  )
 {
     SolarMutexGuard aGuard;
-    utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
-    Reference< XAccessibleStateSet > xRet = pStateSetHelper;
+    rtl::Reference<utl::AccessibleStateSetHelper> pStateSetHelper = new utl::AccessibleStateSetHelper;
 
     if(!mpFrameSel)
         pStateSetHelper->AddState(AccessibleStateType::DEFUNC);
@@ -145,7 +144,7 @@ Reference< XAccessibleStateSet > AccFrameSelector::getAccessibleStateSet(  )
             pStateSetHelper->AddState(AccessibleStateType::SELECTED);
         }
     }
-    return xRet;
+    return pStateSetHelper;
 }
 
 Reference< XAccessible > AccFrameSelector::getAccessibleAtPoint(
@@ -279,8 +278,7 @@ Reference< XAccessibleRelationSet > AccFrameSelectorChild::getAccessibleRelation
 Reference< XAccessibleStateSet > AccFrameSelectorChild::getAccessibleStateSet(  )
 {
     SolarMutexGuard aGuard;
-    utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
-    Reference< XAccessibleStateSet > xRet = pStateSetHelper;
+    rtl::Reference<utl::AccessibleStateSetHelper> pStateSetHelper = new utl::AccessibleStateSetHelper;
 
     if(!mpFrameSel)
         pStateSetHelper->AddState(AccessibleStateType::DEFUNC);
@@ -314,7 +312,7 @@ Reference< XAccessibleStateSet > AccFrameSelectorChild::getAccessibleStateSet(
             pStateSetHelper->AddState(AccessibleStateType::SELECTED);
         }
     }
-    return xRet;
+    return pStateSetHelper;
 }
 
 Reference< XAccessible > AccFrameSelectorChild::getAccessibleAtPoint(
diff --git a/svx/source/accessibility/AccessibleShape.cxx b/svx/source/accessibility/AccessibleShape.cxx
index 074687dd6e0d..a319529b6422 100644
--- a/svx/source/accessibility/AccessibleShape.cxx
+++ b/svx/source/accessibility/AccessibleShape.cxx
@@ -362,7 +362,7 @@ uno::Reference<XAccessibleRelationSet> SAL_CALL
     if (mpParent == nullptr)
         return uno::Reference<XAccessibleRelationSet>();
 
-    ::utl::AccessibleRelationSetHelper* pRelationSet = new utl::AccessibleRelationSetHelper;
+    rtl::Reference<::utl::AccessibleRelationSetHelper> pRelationSet = new utl::AccessibleRelationSetHelper;
 
     //this mxshape is the captioned shape
     uno::Sequence< uno::Reference< uno::XInterface > > aSequence { mpParent->GetAccessibleCaption(mxShape) };
@@ -371,7 +371,7 @@ uno::Reference<XAccessibleRelationSet> SAL_CALL
         pRelationSet->AddRelation(
                                   AccessibleRelation( AccessibleRelationType::DESCRIBED_BY, aSequence ) );
     }
-    return uno::Reference<XAccessibleRelationSet>(pRelationSet);
+    return pRelationSet;
 }
 
 /** Return a copy of the state set.
diff --git a/svx/source/accessibility/GraphCtlAccessibleContext.cxx b/svx/source/accessibility/GraphCtlAccessibleContext.cxx
index 5553b4ae8fa3..f456a454dcdd 100644
--- a/svx/source/accessibility/GraphCtlAccessibleContext.cxx
+++ b/svx/source/accessibility/GraphCtlAccessibleContext.cxx
@@ -394,7 +394,7 @@ Reference< XAccessibleStateSet > SAL_CALL SvxGraphCtrlAccessibleContext::getAcce
 {
     ::SolarMutexGuard aGuard;
 
-    utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
+    rtl::Reference<utl::AccessibleStateSetHelper> pStateSetHelper = new utl::AccessibleStateSetHelper;
 
     if ( rBHelper.bDisposed || mbDisposed )
     {
diff --git a/svx/source/accessibility/charmapacc.cxx b/svx/source/accessibility/charmapacc.cxx
index 2325a4cede21..b70927a1c626 100644
--- a/svx/source/accessibility/charmapacc.cxx
+++ b/svx/source/accessibility/charmapacc.cxx
@@ -194,7 +194,7 @@ uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL SvxShowCharSe
 {
     OExternalLockGuard aGuard( this );
 
-    ::utl::AccessibleStateSetHelper*    pStateSet = new ::utl::AccessibleStateSetHelper;
+    rtl::Reference<::utl::AccessibleStateSetHelper> pStateSet = new ::utl::AccessibleStateSetHelper;
 
     if (m_pParent)
     {
@@ -470,7 +470,7 @@ uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL SvxShowCharSe
 {
     OExternalLockGuard aGuard( this );
 
-    ::utl::AccessibleStateSetHelper*    pStateSet = new ::utl::AccessibleStateSetHelper;
+    rtl::Reference<::utl::AccessibleStateSetHelper> pStateSet = new ::utl::AccessibleStateSetHelper;
 
     if( mpParent )
     {
diff --git a/svx/source/accessibility/svxpixelctlaccessiblecontext.cxx b/svx/source/accessibility/svxpixelctlaccessiblecontext.cxx
index 813efa3a5a30..4873b3cfe834 100644
--- a/svx/source/accessibility/svxpixelctlaccessiblecontext.cxx
+++ b/svx/source/accessibility/svxpixelctlaccessiblecontext.cxx
@@ -109,8 +109,7 @@ Reference< XAccessibleRelationSet > SAL_CALL SvxPixelCtlAccessible::getAccessibl
 uno::Reference< XAccessibleStateSet > SvxPixelCtlAccessible::getAccessibleStateSet(  )
 {
     ::osl::MutexGuard   aGuard( m_aMutex );
-    utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
-    uno::Reference< XAccessibleStateSet > xRet = pStateSetHelper;
+    rtl::Reference<utl::AccessibleStateSetHelper> pStateSetHelper = new utl::AccessibleStateSetHelper;
 
     if (mpPixelCtl)
     {
@@ -136,7 +135,7 @@ uno::Reference< XAccessibleStateSet > SvxPixelCtlAccessible::getAccessibleStateS
         pStateSetHelper->AddState(AccessibleStateType::MANAGES_DESCENDANTS);
     }
 
-    return xRet;
+    return pStateSetHelper;
 }
 
 uno::Reference<XAccessible > SAL_CALL SvxPixelCtlAccessible::getAccessibleAtPoint (
@@ -413,7 +412,7 @@ uno::Reference<XAccessibleRelationSet> SAL_CALL SvxPixelCtlAccessibleChild::getA
 uno::Reference< XAccessibleStateSet > SAL_CALL SvxPixelCtlAccessibleChild::getAccessibleStateSet()
 {
     ::osl::MutexGuard                       aGuard( m_aMutex );
-    utl::AccessibleStateSetHelper*          pStateSetHelper = new utl::AccessibleStateSetHelper;
+    rtl::Reference<utl::AccessibleStateSetHelper> pStateSetHelper = new utl::AccessibleStateSetHelper;
 
     if (!rBHelper.bDisposed)
     {
diff --git a/svx/source/accessibility/svxrectctaccessiblecontext.cxx b/svx/source/accessibility/svxrectctaccessiblecontext.cxx
index 0e1c8150063e..f12352f1c596 100644
--- a/svx/source/accessibility/svxrectctaccessiblecontext.cxx
+++ b/svx/source/accessibility/svxrectctaccessiblecontext.cxx
@@ -158,7 +158,7 @@ Reference< XAccessible > SAL_CALL SvxRectCtlAccessibleContext::getAccessibleChil
 
             tools::Rectangle       aFocusRect( mpRepr->CalculateFocusRectangle( p->ePoint ) );
 
-            SvxRectCtlChildAccessibleContext*   pChild = new SvxRectCtlChildAccessibleContext(this, aName,
+            rtl::Reference<SvxRectCtlChildAccessibleContext> pChild = new SvxRectCtlChildAccessibleContext(this, aName,
                     aDescr, aFocusRect, nIndex );
             mvChildren[ nIndex ] = pChild;
             xChild = pChild;
@@ -211,7 +211,7 @@ Reference< XAccessibleRelationSet > SAL_CALL SvxRectCtlAccessibleContext::getAcc
 Reference< XAccessibleStateSet > SAL_CALL SvxRectCtlAccessibleContext::getAccessibleStateSet()
 {
     ::osl::MutexGuard                       aGuard( m_aMutex );
-    utl::AccessibleStateSetHelper*          pStateSetHelper = new utl::AccessibleStateSetHelper;
+    rtl::Reference<utl::AccessibleStateSetHelper> pStateSetHelper = new utl::AccessibleStateSetHelper;
 
     if (mpRepr)
     {
@@ -486,22 +486,20 @@ OUString SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleName()
 */
 Reference<XAccessibleRelationSet> SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleRelationSet()
 {
-    utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
-    uno::Reference< css::accessibility::XAccessibleRelationSet > xSet = pRelationSetHelper;
+    rtl::Reference<utl::AccessibleRelationSetHelper> pRelationSetHelper = new utl::AccessibleRelationSetHelper;
     if( mxParent.is() )
       {
         uno::Sequence< uno::Reference< uno::XInterface > > aSequence { mxParent };
         pRelationSetHelper->AddRelation( css::accessibility::AccessibleRelation( css::accessibility::AccessibleRelationType::MEMBER_OF, aSequence ) );
-
     }
 
-    return xSet;
+    return pRelationSetHelper;
 }
 
 Reference< XAccessibleStateSet > SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleStateSet()
 {
     ::osl::MutexGuard                       aGuard( m_aMutex );
-    utl::AccessibleStateSetHelper*          pStateSetHelper = new utl::AccessibleStateSetHelper;
+    rtl::Reference<utl::AccessibleStateSetHelper>  pStateSetHelper = new utl::AccessibleStateSetHelper;
 
     if (!rBHelper.bDisposed)
     {
diff --git a/svx/source/dialog/charmap.cxx b/svx/source/dialog/charmap.cxx
index 253b744e3a0d..a31c1fff1b68 100644
--- a/svx/source/dialog/charmap.cxx
+++ b/svx/source/dialog/charmap.cxx
@@ -260,7 +260,7 @@ void SvxShowCharSet::CopyToClipboard(const OUString& rOUStr)
     if (!xClipboard.is())
         return;
 
-    TETextDataObject* pDataObj = new TETextDataObject(rOUStr);
+    rtl::Reference<TETextDataObject> pDataObj = new TETextDataObject(rOUStr);
 
     try
     {
diff --git a/svx/source/dialog/docrecovery.cxx b/svx/source/dialog/docrecovery.cxx
index f8f7c61fc2d1..1f40250ad065 100644
--- a/svx/source/dialog/docrecovery.cxx
+++ b/svx/source/dialog/docrecovery.cxx
@@ -580,8 +580,7 @@ SaveProgressDialog::SaveProgressDialog(weld::Window* pParent, RecoveryCore* pCor
     , m_xProgressBar(m_xBuilder->weld_progress_bar("progress"))
 {
     m_xProgressBar->set_size_request(m_xProgressBar->get_approximate_digit_width() * 50, -1);
-    PluginProgress* pProgress = new PluginProgress(m_xProgressBar.get());
-    m_xProgress.set(static_cast< css::task::XStatusIndicator* >(pProgress), css::uno::UNO_QUERY_THROW);
+    m_xProgress = new PluginProgress(m_xProgressBar.get());
 }
 
 SaveProgressDialog::~SaveProgressDialog()
@@ -655,8 +654,7 @@ RecoveryDialog::RecoveryDialog(weld::Window* pParent, RecoveryCore* pCore)
     const auto nWidth = m_xFileListLB->get_approximate_digit_width() * 70;
     m_xFileListLB->set_size_request(nWidth, m_xFileListLB->get_height_rows(10));
     m_xProgressBar->set_size_request(m_xProgressBar->get_approximate_digit_width() * 50, -1);
-    PluginProgress* pProgress = new PluginProgress(m_xProgressBar.get());
-    m_xProgress.set(static_cast< css::task::XStatusIndicator* >(pProgress), css::uno::UNO_QUERY_THROW);
+    m_xProgress = new PluginProgress(m_xProgressBar.get());
 
     std::vector<int> aWidths;
     aWidths.push_back(m_xFileListLB->get_checkbox_column_width());
diff --git a/svx/source/dialog/weldeditview.cxx b/svx/source/dialog/weldeditview.cxx
index 431e8e7c0486..379e53d32523 100644
--- a/svx/source/dialog/weldeditview.cxx
+++ b/svx/source/dialog/weldeditview.cxx
@@ -710,9 +710,8 @@ public:
         SAL_CALL getAccessibleStateSet() override
     {
         SolarMutexGuard aGuard;
-        ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper;
-
-        css::uno::Reference<css::accessibility::XAccessibleStateSet> xStateSet(pStateSet);
+        rtl::Reference<::utl::AccessibleStateSetHelper> pStateSet
+            = new ::utl::AccessibleStateSetHelper;
 
         if (!m_pController || !m_xTextHelper)
             pStateSet->AddState(css::accessibility::AccessibleStateType::DEFUNC);
@@ -735,7 +734,7 @@ public:
                 pStateSet->AddState(css::accessibility::AccessibleStateType::OPAQUE);
         }
 
-        return xStateSet;
+        return pStateSet;
     }
 
     virtual css::lang::Locale SAL_CALL getLocale() override
diff --git a/svx/source/fmcomp/fmgridif.cxx b/svx/source/fmcomp/fmgridif.cxx
index 96f6fc4c2526..1893479a5d1c 100644
--- a/svx/source/fmcomp/fmgridif.cxx
+++ b/svx/source/fmcomp/fmgridif.cxx
@@ -423,9 +423,9 @@ sal_Bool SAL_CALL FmXGridControl::setModel(const Reference< css::awt::XControlMo
 }
 
 
-FmXGridPeer* FmXGridControl::imp_CreatePeer(vcl::Window* pParent)
+rtl::Reference<FmXGridPeer> FmXGridControl::imp_CreatePeer(vcl::Window* pParent)
 {
-    FmXGridPeer* pReturn = new FmXGridPeer(m_xContext);
+    rtl::Reference<FmXGridPeer> pReturn = new FmXGridPeer(m_xContext);
 
     // translate properties into WinBits
     WinBits nStyle = WB_TABSTOP;
@@ -477,7 +477,7 @@ void SAL_CALL FmXGridControl::createPeer(const Reference< css::awt::XToolkit >&
             pParentWin = pParent->GetWindow();
     }
 
-    FmXGridPeer* pPeer = imp_CreatePeer(pParentWin);
+    rtl::Reference<FmXGridPeer> pPeer = imp_CreatePeer(pParentWin);
     DBG_ASSERT(pPeer != nullptr, "FmXGridControl::createPeer : imp_CreatePeer didn't return a peer !");
     setPeer( pPeer );
 
diff --git a/svx/source/form/fmobj.cxx b/svx/source/form/fmobj.cxx
index bd2d6186914a..e0b6d1c31ff4 100644
--- a/svx/source/form/fmobj.cxx
+++ b/svx/source/form/fmobj.cxx
@@ -163,7 +163,7 @@ void FmFormObj::impl_checkRefDevice_nothrow( bool _force )
         static constexpr OUStringLiteral sRefDevicePropName = u"ReferenceDevice";
         if ( xPropertyInfo->hasPropertyByName( sRefDevicePropName ) )
         {
-            VCLXDevice* pUnoRefDevice = new VCLXDevice;
+            rtl::Reference<VCLXDevice> pUnoRefDevice = new VCLXDevice;
             pUnoRefDevice->SetOutputDevice( m_pLastKnownRefDevice );
             Reference< XDevice > xRefDevice( pUnoRefDevice );
             xModelProps->setPropertyValue( sRefDevicePropName, makeAny( xRefDevice ) );
diff --git a/svx/source/form/formcontroller.cxx b/svx/source/form/formcontroller.cxx
index 5e2d36c61fb2..c1ee3954cdc4 100644
--- a/svx/source/form/formcontroller.cxx
+++ b/svx/source/form/formcontroller.cxx
@@ -3828,20 +3828,19 @@ sal_Bool SAL_CALL FormController::approveParameter(const DatabaseParameterEvent&
                 return false;
 
             // two continuations allowed: OK and Cancel
-            OParameterContinuation* pParamValues = new OParameterContinuation;
-            OInteractionAbort* pAbort = new OInteractionAbort;
+            rtl::Reference<OParameterContinuation> pParamValues = new OParameterContinuation;
+            rtl::Reference<OInteractionAbort> pAbort = new OInteractionAbort;
             // the request
             ParametersRequest aRequest;
             aRequest.Parameters = aEvent.Parameters;
             aRequest.Connection = getConnection(Reference< XRowSet >(aEvent.Source, UNO_QUERY));
-            OInteractionRequest* pParamRequest = new OInteractionRequest(makeAny(aRequest));
-            Reference< XInteractionRequest > xParamRequest(pParamRequest);
+            rtl::Reference<OInteractionRequest> pParamRequest = new OInteractionRequest(makeAny(aRequest));
             // some knittings
             pParamRequest->addContinuation(pParamValues);
             pParamRequest->addContinuation(pAbort);
 
             // handle the request
-            m_xInteractionHandler->handle(xParamRequest);
+            m_xInteractionHandler->handle(pParamRequest);
 
             if (!pParamValues->wasSelected())
                 // canceled
@@ -3933,8 +3932,8 @@ sal_Bool SAL_CALL FormController::confirmDelete(const RowChangeEvent& aEvent)
             return false;
 
         // two continuations allowed: Yes and No
-        OInteractionApprove* pApprove = new OInteractionApprove;
-        OInteractionDisapprove* pDisapprove = new OInteractionDisapprove;
+        rtl::Reference<OInteractionApprove> pApprove = new OInteractionApprove;
+        rtl::Reference<OInteractionDisapprove> pDisapprove = new OInteractionDisapprove;
 
         // the request
         SQLWarning aWarning;
@@ -3943,15 +3942,14 @@ sal_Bool SAL_CALL FormController::confirmDelete(const RowChangeEvent& aEvent)
         aDetails.Message = SvxResId(RID_STR_DELETECONFIRM);
         aWarning.NextException <<= aDetails;
 
-        OInteractionRequest* pRequest = new OInteractionRequest( makeAny( aWarning ) );
-        Reference< XInteractionRequest > xRequest( pRequest );
+        rtl::Reference<OInteractionRequest> pRequest = new OInteractionRequest( makeAny( aWarning ) );
 
         // some knittings
         pRequest->addContinuation( pApprove );
         pRequest->addContinuation( pDisapprove );
 
         // handle the request
-        m_xInteractionHandler->handle( xRequest );
+        m_xInteractionHandler->handle( pRequest );
 
         if ( pApprove->wasSelected() )
             return true;
diff --git a/svx/source/gallery2/galtheme.cxx b/svx/source/gallery2/galtheme.cxx
index 4ecc75567c82..07d5e529fbd0 100644
--- a/svx/source/gallery2/galtheme.cxx
+++ b/svx/source/gallery2/galtheme.cxx
@@ -627,7 +627,7 @@ bool GalleryTheme::InsertTransferable(const uno::Reference< datatransfer::XTrans
 
 void GalleryTheme::CopyToClipboard(sal_uInt32 nPos)
 {
-    GalleryTransferable* pTransferable = new GalleryTransferable( this, nPos, false );
+    rtl::Reference<GalleryTransferable> pTransferable = new GalleryTransferable( this, nPos, false );
     pTransferable->CopyToClipboard(GetSystemClipboard());
 }
 
diff --git a/svx/source/inc/StylesPreviewWindow.hxx b/svx/source/inc/StylesPreviewWindow.hxx
index 416c8a15a63f..7bdbefefe86e 100644
--- a/svx/source/inc/StylesPreviewWindow.hxx
+++ b/svx/source/inc/StylesPreviewWindow.hxx
@@ -74,8 +74,7 @@ protected:
 
     std::unique_ptr<weld::IconView> m_xStylesView;
 
-    StyleStatusListener* m_pStatusListener;
-    css::uno::Reference<css::lang::XComponent> m_xStatusListener;
+    rtl::Reference<StyleStatusListener> m_xStatusListener;
 
     std::vector<std::pair<OUString, OUString>> m_aDefaultStyles;
     std::vector<std::pair<OUString, OUString>> m_aAllStyles;
diff --git a/svx/source/sdr/overlay/overlaypolypolygon.cxx b/svx/source/sdr/overlay/overlaypolypolygon.cxx
index 5be533074a50..f71b664b7a06 100644
--- a/svx/source/sdr/overlay/overlaypolypolygon.cxx
+++ b/svx/source/sdr/overlay/overlaypolypolygon.cxx
@@ -50,13 +50,12 @@ namespace sdr::overlay
             {
                 const drawinglayer::attribute::LineAttribute aLineAttribute(getBaseColor().getBColor(), mfLineWidth);
 
-                auto aLine(new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D(maLinePolyPolygon, aLineAttribute));
+                aReturnContainer = drawinglayer::primitive2d::Primitive2DContainer {
+                    new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D(maLinePolyPolygon, aLineAttribute) };
 
-                aReturnContainer = drawinglayer::primitive2d::Primitive2DContainer { aLine };
                 if (maFillColor.GetAlpha() != 0)
                 {
-                    auto aFill(new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(maLinePolyPolygon, maFillColor.getBColor()));
-                    aReturnContainer.push_back(aFill);
+                    aReturnContainer.push_back(new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(maLinePolyPolygon, maFillColor.getBColor()));
                 }
 
                 sal_uInt8 nTransparency = 255 - getBaseColor().GetAlpha();
diff --git a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx
index e1bd4d2a026a..35e410b8fbfd 100644
--- a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx
+++ b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx
@@ -87,7 +87,7 @@ namespace drawinglayer::primitive2d
             }
 
             // prepare fully scaled polygon
-            BasePrimitive2D* pNewFillPrimitive = nullptr;
+            rtl::Reference<BasePrimitive2D> pNewFillPrimitive;
 
             if(!rFill.getGradient().isDefault())
             {
@@ -121,15 +121,13 @@ namespace drawinglayer::primitive2d
             if(0.0 != rFill.getTransparence())
             {
                 // create simpleTransparencePrimitive, add created fill primitive
-                const Primitive2DReference xRefA(pNewFillPrimitive);
-                const Primitive2DContainer aContent { xRefA };
+                const Primitive2DContainer aContent { pNewFillPrimitive };
                 return Primitive2DReference(new UnifiedTransparencePrimitive2D(aContent, rFill.getTransparence()));
             }
             else if(!rFillGradient.isDefault())
             {
                 // create sequence with created fill primitive
-                const Primitive2DReference xRefA(pNewFillPrimitive);
-                const Primitive2DContainer aContent { xRefA };
+                const Primitive2DContainer aContent { pNewFillPrimitive };
 
                 // create FillGradientPrimitive2D for transparence and add to new sequence
                 // fillGradientPrimitive is enough here (compared to PolyPolygonGradientPrimitive2D) since float transparence will be masked anyways
@@ -159,7 +157,7 @@ namespace drawinglayer::primitive2d
             // create line and stroke attribute
             const attribute::LineAttribute aLineAttribute(rLine.getColor(), rLine.getWidth(), rLine.getJoin(), rLine.getCap());
             const attribute::StrokeAttribute aStrokeAttribute(rLine.getDotDashArray(), rLine.getFullDotDashLen());
-            BasePrimitive2D* pNewLinePrimitive = nullptr;
+            rtl::Reference<BasePrimitive2D> pNewLinePrimitive;
 
             if(!rPolygon.isClosed() && !rStroke.isDefault())
             {
@@ -178,8 +176,7 @@ namespace drawinglayer::primitive2d
             if(0.0 != rLine.getTransparence())
             {
                 // create simpleTransparencePrimitive, add created fill primitive
-                const Primitive2DReference xRefA(pNewLinePrimitive);
-                const Primitive2DContainer aContent { xRefA };
+                const Primitive2DContainer aContent { pNewLinePrimitive };
                 return Primitive2DReference(new UnifiedTransparencePrimitive2D(aContent, rLine.getTransparence()));
             }
             else
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index dad689840f04..c68c952b8f54 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -2885,7 +2885,8 @@ css::uno::Reference< css::uno::XInterface > SdrObject::getUnoShape()
             // the most basic stuff like SdrInventor::E3d and SdrInventor::Default. All
             // the other SdrInventor enum entries are from overloads and are *not accessible*
             // using this fallback (!) - what a bad trap
-            mpSvxShape = SvxDrawPage::CreateShapeByTypeAndInventor( GetObjIdentifier(), GetObjInventor(), this );
+            rtl::Reference<SvxShape> xNewShape = SvxDrawPage::CreateShapeByTypeAndInventor( GetObjIdentifier(), GetObjInventor(), this );
+            mpSvxShape = xNewShape.get();
             maWeakUnoShape = xShape = static_cast< ::cppu::OWeakObject* >( mpSvxShape );
         }
     }
diff --git a/svx/source/svdraw/svdotextdecomposition.cxx b/svx/source/svdraw/svdotextdecomposition.cxx
index fd53bf0e9d3d..9c8c419873e9 100644
--- a/svx/source/svdraw/svdotextdecomposition.cxx
+++ b/svx/source/svdraw/svdotextdecomposition.cxx
@@ -94,7 +94,7 @@ namespace
         DECL_LINK(decomposeStretchBulletPrimitive, DrawBulletInfo*, void);
 
         void impCreateTextPortionPrimitive(const DrawPortionInfo& rInfo);
-        static drawinglayer::primitive2d::BasePrimitive2D* impCheckFieldPrimitive(drawinglayer::primitive2d::BasePrimitive2D* pPrimitive, const DrawPortionInfo& rInfo);
+        static rtl::Reference<drawinglayer::primitive2d::BasePrimitive2D> impCheckFieldPrimitive(drawinglayer::primitive2d::BasePrimitive2D* pPrimitive, const DrawPortionInfo& rInfo);
         void impFlushTextPortionPrimitivesToLinePrimitives();
         void impFlushLinePrimitivesToParagraphPrimitives(sal_Int32 nPara);
         void impHandleDrawPortionInfo(const DrawPortionInfo& rInfo);
@@ -252,7 +252,7 @@ namespace
         const bool bWordLineMode(rInfo.mrFont.IsWordLineMode() && !rInfo.mbEndOfBullet);
 
         // prepare new primitive
-        drawinglayer::primitive2d::BasePrimitive2D* pNewPrimitive = nullptr;
+        rtl::Reference<drawinglayer::primitive2d::BasePrimitive2D> pNewPrimitive;
         const bool bDecoratedIsNeeded(
                LINESTYLE_NONE != rInfo.mrFont.GetOverline()
             || LINESTYLE_NONE != rInfo.mrFont.GetUnderline()
@@ -376,7 +376,7 @@ namespace
 
         if(rInfo.mpFieldData)
         {
-            pNewPrimitive = impCheckFieldPrimitive(pNewPrimitive, rInfo);
+            pNewPrimitive = impCheckFieldPrimitive(pNewPrimitive.get(), rInfo);
         }
 
         maTextPortionPrimitives.push_back(pNewPrimitive);
@@ -444,8 +444,9 @@ namespace
         }
     }
 
-    drawinglayer::primitive2d::BasePrimitive2D* impTextBreakupHandler::impCheckFieldPrimitive(drawinglayer::primitive2d::BasePrimitive2D* pPrimitive, const DrawPortionInfo& rInfo)
+    rtl::Reference<drawinglayer::primitive2d::BasePrimitive2D> impTextBreakupHandler::impCheckFieldPrimitive(drawinglayer::primitive2d::BasePrimitive2D* pPrimitive, const DrawPortionInfo& rInfo)
     {
+        rtl::Reference<drawinglayer::primitive2d::BasePrimitive2D> xRet = pPrimitive;
         if(rInfo.mpFieldData)
         {
             // Support for FIELD_SEQ_BEGIN, FIELD_SEQ_END. If used, create a TextHierarchyFieldPrimitive2D
@@ -471,19 +472,19 @@ namespace
                 meValues.emplace_back("Representation", pURLField->GetRepresentation());
                 meValues.emplace_back("TargetFrame", pURLField->GetTargetFrame());
                 meValues.emplace_back("SvxURLFormat", OUString::number(static_cast<sal_uInt16>(pURLField->GetFormat())));
-                pPrimitive = new drawinglayer::primitive2d::TextHierarchyFieldPrimitive2D(aSequence, drawinglayer::primitive2d::FIELD_TYPE_URL, &meValues);
+                xRet = new drawinglayer::primitive2d::TextHierarchyFieldPrimitive2D(aSequence, drawinglayer::primitive2d::FIELD_TYPE_URL, &meValues);
             }
             else if(pPageField)
             {
-                pPrimitive = new drawinglayer::primitive2d::TextHierarchyFieldPrimitive2D(aSequence, drawinglayer::primitive2d::FIELD_TYPE_PAGE);
+                xRet = new drawinglayer::primitive2d::TextHierarchyFieldPrimitive2D(aSequence, drawinglayer::primitive2d::FIELD_TYPE_PAGE);
             }
             else
             {
-                pPrimitive = new drawinglayer::primitive2d::TextHierarchyFieldPrimitive2D(aSequence, drawinglayer::primitive2d::FIELD_TYPE_COMMON);
+                xRet = new drawinglayer::primitive2d::TextHierarchyFieldPrimitive2D(aSequence, drawinglayer::primitive2d::FIELD_TYPE_COMMON);
             }
         }
 
-        return pPrimitive;
+        return xRet;
     }
 
     void impTextBreakupHandler::impFlushTextPortionPrimitivesToLinePrimitives()
@@ -557,7 +558,7 @@ namespace
 
         // embed in TextHierarchyBulletPrimitive2D
         const drawinglayer::primitive2d::Primitive2DContainer aNewSequence { aNewReference };
-        drawinglayer::primitive2d::BasePrimitive2D* pNewPrimitive = new drawinglayer::primitive2d::TextHierarchyBulletPrimitive2D(aNewSequence);
+        rtl::Reference<drawinglayer::primitive2d::BasePrimitive2D> pNewPrimitive = new drawinglayer::primitive2d::TextHierarchyBulletPrimitive2D(aNewSequence);
 
         // add to output
         maTextPortionPrimitives.push_back(pNewPrimitive);
diff --git a/svx/source/svdraw/svdotextpathdecomposition.cxx b/svx/source/svdraw/svdotextpathdecomposition.cxx
index a607d05c7800..44f72ec8de07 100644
--- a/svx/source/svdraw/svdotextpathdecomposition.cxx
+++ b/svx/source/svdraw/svdotextpathdecomposition.cxx
@@ -497,7 +497,7 @@ namespace
                                 const Color aShadowColor(maSdrFormTextAttribute.getFormTextShdwColor());
                                 const basegfx::BColor aRGBShadowColor(aShadowColor.getBColor());
 
-                                drawinglayer::primitive2d::TextSimplePortionPrimitive2D* pNew =
+                                mrShadowDecomposition.push_back(
                                     new drawinglayer::primitive2d::TextSimplePortionPrimitive2D(
                                         aNewTransformB * aNewShadowTransform * aNewTransformA,
                                         pCandidate->getText(),
@@ -506,9 +506,7 @@ namespace
                                         aNewDXArray,
                                         aCandidateFontAttribute,
                                         pCandidate->getLocale(),
-                                        aRGBShadowColor);
-
-                                mrShadowDecomposition.push_back(pNew);
+                                        aRGBShadowColor) );
                             }
 
                             {
@@ -516,7 +514,7 @@ namespace
                                 const Color aColor(pCandidate->getFont().GetColor());
                                 const basegfx::BColor aRGBColor(aColor.getBColor());
 
-                                drawinglayer::primitive2d::TextSimplePortionPrimitive2D* pNew =
+                                mrDecomposition.push_back(
                                     new drawinglayer::primitive2d::TextSimplePortionPrimitive2D(
                                         aNewTransformB * aNewTransformA,
                                         pCandidate->getText(),
@@ -525,9 +523,7 @@ namespace
                                         aNewDXArray,
                                         aCandidateFontAttribute,
                                         pCandidate->getLocale(),
-                                        aRGBColor);
-
-                                mrDecomposition.push_back(pNew);
+                                        aRGBColor) );
                             }
                         }
 
@@ -564,10 +560,9 @@ namespace
             for(auto const& rPolygon : aB2DPolyPolygon)
             {
                 // create one primitive per polygon
-                drawinglayer::primitive2d::PolygonStrokePrimitive2D* pNew =
+                rTarget.push_back(
                     new drawinglayer::primitive2d::PolygonStrokePrimitive2D(
-                        rPolygon, rLineAttribute, rStrokeAttribute);
-                rTarget.push_back(pNew);
+                        rPolygon, rLineAttribute, rStrokeAttribute) );
             }
         }
     }
@@ -614,11 +609,10 @@ namespace
                                 aStrokePrimitiveSequence[b] = drawinglayer::primitive2d::Primitive2DReference(aStrokePrimitives[b]);
                             }
 
-                            drawinglayer::primitive2d::UnifiedTransparencePrimitive2D* pNew2 =
+                            aNewPrimitives.push_back(
                                 new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D(
                                     aStrokePrimitiveSequence,
-                                    static_cast<double>(rOutlineAttribute.getTransparence()) / 100.0);
-                            aNewPrimitives.push_back(pNew2);
+                                    static_cast<double>(rOutlineAttribute.getTransparence()) / 100.0) );
                         }
                         else
                         {
diff --git a/svx/source/table/accessibletableshape.cxx b/svx/source/table/accessibletableshape.cxx
index 248fbcdc534b..ed06757341c0 100644
--- a/svx/source/table/accessibletableshape.cxx
+++ b/svx/source/table/accessibletableshape.cxx
@@ -505,8 +505,7 @@ Reference< XAccessibleTable > SAL_CALL AccessibleTableShape::getAccessibleRowHea
     {
         if( pController->isRowHeader() )
         {
-            AccessibleTableHeaderShape* pTableHeader = new AccessibleTableHeaderShape( this, true );
-            xRet.set( pTableHeader );
+            xRet = new AccessibleTableHeaderShape( this, true );
         }
     }
     return xRet;
@@ -521,8 +520,7 @@ Reference< XAccessibleTable > SAL_CALL AccessibleTableShape::getAccessibleColumn
     {
         if( pController->isColumnHeader() )
         {
-            AccessibleTableHeaderShape* pTableHeader = new AccessibleTableHeaderShape( this, false );
-            xRet.set( pTableHeader );
+            xRet = new AccessibleTableHeaderShape( this, false );
         }
     }
     return xRet;
diff --git a/svx/source/tbxctrls/StylesPreviewWindow.cxx b/svx/source/tbxctrls/StylesPreviewWindow.cxx
index 141a02dfc847..6acfda335cb4 100644
--- a/svx/source/tbxctrls/StylesPreviewWindow.cxx
+++ b/svx/source/tbxctrls/StylesPreviewWindow.cxx
@@ -346,8 +346,7 @@ StylesPreviewWindow_Base::StylesPreviewWindow_Base(
     m_xStylesView->connect_item_activated(LINK(this, StylesPreviewWindow_Base, DoubleClick));
     m_xStylesView->connect_command(LINK(this, StylesPreviewWindow_Base, DoCommand));
 
-    m_pStatusListener = new StyleStatusListener(this, xDispatchProvider);
-    m_xStatusListener.set(static_cast<cppu::OWeakObject*>(m_pStatusListener), css::uno::UNO_QUERY);
+    m_xStatusListener = new StyleStatusListener(this, xDispatchProvider);
 
     Update();
 }
@@ -387,7 +386,7 @@ IMPL_LINK(StylesPreviewWindow_Base, DoCommand, const CommandEvent&, rPos, bool)
 
 StylesPreviewWindow_Base::~StylesPreviewWindow_Base()
 {
-    m_pStatusListener->UnBind();
+    m_xStatusListener->UnBind();
 
     try
     {
@@ -397,7 +396,7 @@ StylesPreviewWindow_Base::~StylesPreviewWindow_Base()
     {
     }
 
-    m_pStatusListener = nullptr;
+    m_xStatusListener = nullptr;
 }
 
 void StylesPreviewWindow_Base::Select(const OUString& rStyleName)
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 82d12985486a..c2765155c3b8 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -2646,7 +2646,6 @@ SvxStyleToolBoxControl::SvxStyleToolBoxControl()
 {
     for (sal_uInt16 i = 0; i < MAX_FAMILIES; ++i)
     {
-        pBoundItems[i] = nullptr;
         m_xBoundItems[i].clear();
         pFamilyState[i]  = nullptr;
     }
@@ -2669,11 +2668,10 @@ void SAL_CALL SvxStyleToolBoxControl::initialize(const Sequence<Any>& rArguments
     Reference< XDispatchProvider > xDispatchProvider( m_xFrame->getController(), UNO_QUERY );
     for ( sal_uInt16 i=0; i<MAX_FAMILIES; i++ )
     {
-        pBoundItems[i]   = new SfxStyleControllerItem_Impl( xDispatchProvider,
+        m_xBoundItems[i] = new SfxStyleControllerItem_Impl( xDispatchProvider,
                                                             SID_STYLE_FAMILY_START + i,
                                                             OUString::createFromAscii( StyleSlotToStyleCommand[i] ),
                                                             *this );
-        m_xBoundItems[i].set( static_cast< OWeakObject* >( pBoundItems[i] ), UNO_QUERY );
         pFamilyState[i]  = nullptr;
     }
 }
@@ -2688,7 +2686,7 @@ void SAL_CALL SvxStyleToolBoxControl::dispose()
     pImpl->m_xWeldBox.reset();
     pImpl->m_pBox = nullptr;
 
-    for (SfxStyleControllerItem_Impl* pBoundItem : pBoundItems)
+    for (rtl::Reference<SfxStyleControllerItem_Impl>& pBoundItem : m_xBoundItems)
     {
         if (!pBoundItem)
             continue;
@@ -2709,7 +2707,6 @@ void SAL_CALL SvxStyleToolBoxControl::dispose()
             }
 
             m_xBoundItems[i].clear();
-            pBoundItems[i] = nullptr;
         }
         pFamilyState[i].reset();
     }
@@ -2742,7 +2739,7 @@ com_sun_star_comp_svx_StyleToolBoxControl_get_implementation(
 
 void SAL_CALL SvxStyleToolBoxControl::update()
 {
-    for (SfxStyleControllerItem_Impl* pBoundItem : pBoundItems)
+    for (rtl::Reference<SfxStyleControllerItem_Impl>& pBoundItem : m_xBoundItems)
         pBoundItem->ReBind();
     bindListener();
 }
diff --git a/svx/source/unodraw/UnoGraphicExporter.cxx b/svx/source/unodraw/UnoGraphicExporter.cxx
index e53f3a7cf0df..fcf9a39e4ca3 100644
--- a/svx/source/unodraw/UnoGraphicExporter.cxx
+++ b/svx/source/unodraw/UnoGraphicExporter.cxx
@@ -1077,8 +1077,7 @@ sal_Bool SAL_CALL GraphicExporter::filter( const Sequence< PropertyValue >& aDes
     {
         Any aInteraction;
         Sequence< css::uno::Reference< css::task::XInteractionContinuation > > lContinuations(1);
-        ::comphelper::OInteractionApprove* pApprove = new ::comphelper::OInteractionApprove();
-        lContinuations[0].set(static_cast< XInteractionContinuation* >(pApprove), UNO_QUERY);
+        lContinuations[0] = new ::comphelper::OInteractionApprove();
 
         GraphicFilterRequest aErrorCode;
         aErrorCode.ErrCode = sal_uInt32(nStatus);
diff --git a/svx/source/unodraw/unomod.cxx b/svx/source/unodraw/unomod.cxx
index eb80ab186deb..d90dcf60dd3c 100644
--- a/svx/source/unodraw/unomod.cxx
+++ b/svx/source/unodraw/unomod.cxx
@@ -173,7 +173,7 @@ css::uno::Reference<css::uno::XInterface> create(
             sal_uInt16 nT = static_cast<sal_uInt16>(nType & ~E3D_INVENTOR_FLAG);
             SdrInventor nI = (nType & E3D_INVENTOR_FLAG) ? SdrInventor::E3d : SdrInventor::Default;
 
-            return uno::Reference< uno::XInterface >( static_cast<drawing::XShape*>(SvxDrawPage::CreateShapeByTypeAndInventor( nT, nI, nullptr, nullptr, referer )) );
+            return uno::Reference< uno::XInterface >( static_cast<drawing::XShape*>(SvxDrawPage::CreateShapeByTypeAndInventor( nT, nI, nullptr, nullptr, referer ).get()) );
         }
     }
     else if (rServiceSpecifier == "com.sun.star.document.ImportGraphicStorageHandler")
@@ -455,7 +455,8 @@ uno::Reference< uno::XInterface > SAL_CALL SvxUnoDrawingModel::createInstance( c
         }
 
         // create the API wrapper
-        pShape = CreateSvxShapeByTypeAndInventor( nType, SdrInventor::Default, "" );
+        rtl::Reference<SvxShape> xNewShape = CreateSvxShapeByTypeAndInventor( nType, SdrInventor::Default, "" );
+        pShape = xNewShape.get();
 
         // set shape type
         if( pShape )
diff --git a/svx/source/unodraw/unopage.cxx b/svx/source/unodraw/unopage.cxx
index d35b7cc51714..e282234e10e3 100644
--- a/svx/source/unodraw/unopage.cxx
+++ b/svx/source/unodraw/unopage.cxx
@@ -599,9 +599,9 @@ void SvxDrawPage::GetTypeAndInventor( SdrObjKind& rType, SdrInventor& rInventor,
     }
 }
 
-SvxShape* SvxDrawPage::CreateShapeByTypeAndInventor( sal_uInt16 nType, SdrInventor nInventor, SdrObject *pObj, SvxDrawPage *mpPage, OUString const & referer )
+rtl::Reference<SvxShape> SvxDrawPage::CreateShapeByTypeAndInventor( sal_uInt16 nType, SdrInventor nInventor, SdrObject *pObj, SvxDrawPage *mpPage, OUString const & referer )
 {
-    SvxShape* pRet = nullptr;
+    rtl::Reference<SvxShape> pRet;
 
     switch( nInventor )
     {
@@ -856,7 +856,7 @@ uno::Sequence< OUString > SAL_CALL SvxDrawPage::getSupportedServiceNames()
     return aSeq;
 }
 
-SvxShape* CreateSvxShapeByTypeAndInventor(sal_uInt16 nType, SdrInventor nInventor, OUString const & referer)
+rtl::Reference<SvxShape> CreateSvxShapeByTypeAndInventor(sal_uInt16 nType, SdrInventor nInventor, OUString const & referer)
 {
     return SvxDrawPage::CreateShapeByTypeAndInventor( nType, nInventor, nullptr, nullptr, referer );
 }


More information about the Libreoffice-commits mailing list