dbaccess/source/core/api/RowSet.cxx                                |   19 
+++----
 dbaccess/source/core/api/RowSetCache.cxx                           |    4 -
 dbaccess/source/core/api/SingleSelectQueryComposer.cxx             |    2 
 dbaccess/source/core/api/TableDeco.cxx                             |    8 +--
 dbaccess/source/core/api/preparedstatement.cxx                     |    4 -
 dbaccess/source/core/api/query.cxx                                 |    9 +--
 dbaccess/source/core/api/query.hxx                                 |    2 
 dbaccess/source/core/api/querycontainer.cxx                        |    2 
 dbaccess/source/core/api/querydescriptor.cxx                       |    2 
 dbaccess/source/core/api/querydescriptor.hxx                       |    2 
 dbaccess/source/core/api/resultset.cxx                             |    4 -
 dbaccess/source/core/api/table.cxx                                 |    8 ---
 dbaccess/source/core/api/tablecontainer.cxx                        |    8 +--
 dbaccess/source/core/dataaccess/ComponentDefinition.cxx            |    2 
 dbaccess/source/core/dataaccess/ComponentDefinition.hxx            |    2 
 dbaccess/source/core/dataaccess/databasedocument.cxx               |    8 +--
 dbaccess/source/core/dataaccess/datasource.cxx                     |   15 
+++---
 dbaccess/source/core/dataaccess/documentdefinition.cxx             |   24 
++++------
 dbaccess/source/core/inc/TableDeco.hxx                             |    2 
 dbaccess/source/core/inc/column.hxx                                |    2 
 dbaccess/source/core/inc/table.hxx                                 |    2 
 dbaccess/source/filter/xml/xmlExport.cxx                           |   10 +---
 dbaccess/source/ui/browser/brwctrlr.cxx                            |   21 
+++-----
 dbaccess/source/ui/browser/exsrcbrw.cxx                            |    1 
 dbaccess/source/ui/browser/genericcontroller.cxx                   |    4 -
 dbaccess/source/ui/browser/sbagrid.cxx                             |    2 
 dbaccess/source/ui/dlg/CollectionView.cxx                          |    7 +-
 dbaccess/source/ui/dlg/ConnectionHelper.cxx                        |    2 
 dbaccess/source/ui/dlg/DbAdminImpl.cxx                             |    5 --
 dbaccess/source/ui/dlg/dbwizsetup.cxx                              |   10 +---
 dbaccess/source/ui/inc/JoinTableView.hxx                           |    2 
 dbaccess/source/ui/inc/brwctrlr.hxx                                |    3 -
 dbaccess/source/ui/inc/exsrcbrw.hxx                                |    2 
 dbaccess/source/ui/misc/TableCopyHelper.cxx                        |    4 -
 dbaccess/source/ui/querydesign/JoinTableView.cxx                   |    1 
 dbaccess/source/ui/querydesign/QueryDesignView.cxx                 |    2 
 dbaccess/source/ui/uno/ColumnControl.cxx                           |    2 
 drawinglayer/source/primitive2d/PolyPolygonGradientPrimitive2D.cxx |    6 +-
 drawinglayer/source/primitive2d/PolyPolygonHatchPrimitive2D.cxx    |    6 +-
 drawinglayer/source/primitive2d/helplineprimitive2d.cxx            |    9 +--
 drawinglayer/source/primitive3d/polygontubeprimitive3d.cxx         |   15 
++----
 drawinglayer/source/primitive3d/sdrdecompositiontools3d.cxx        |    3 -
 drawinglayer/source/processor3d/shadow3dextractor.cxx              |    6 +-
 drawinglayer/source/tools/emfphelperdata.cxx                       |    4 -
 drawinglayer/source/tools/wmfemfhelper.cxx                         |    4 -
 45 files changed, 118 insertions(+), 144 deletions(-)

New commits:
commit eac1daddf376f44b55b5d592cdada2b7775f2910
Author:     Noel <noel.gran...@collabora.co.uk>
AuthorDate: Sun Feb 21 20:03:52 2021 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Feb 22 08:08:40 2021 +0100

    loplugin:refcounting in dbaccess
    
    Change-Id: I8d8b33b5488dd1568f0105425d033da42578b4e3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111289
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/dbaccess/source/core/api/RowSet.cxx 
b/dbaccess/source/core/api/RowSet.cxx
index 80e5206b4dd6..613a69fdecb2 100644
--- a/dbaccess/source/core/api/RowSet.cxx
+++ b/dbaccess/source/core/api/RowSet.cxx
@@ -1853,7 +1853,7 @@ void 
ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi
                             }
                             sName = sAlias;
                         }
-                        ORowSetDataColumn* pColumn = new ORowSetDataColumn( 
getMetaData(),
+                        rtl::Reference<ORowSetDataColumn> pColumn = new 
ORowSetDataColumn( getMetaData(),
                                                                             
this,
                                                                             
this,
                                                                             
i+1,
@@ -1867,7 +1867,7 @@ void 
ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi
                         aColumns->emplace_back(pColumn);
                         pColumn->setName(sName);
                         aNames.push_back(sName);
-                        m_aDataColumns.push_back(pColumn);
+                        m_aDataColumns.push_back(pColumn.get());
 
                         
pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ISREADONLY,makeAny(rKeyColumns.find(i+1)
 != rKeyColumns.end()));
 
@@ -1957,7 +1957,7 @@ void 
ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi
                     {
                         xColumn->getPropertyValue(PROPERTY_LABEL) >>= 
sParseLabel;
                     }
-                    ORowSetDataColumn* pColumn = new ORowSetDataColumn( 
getMetaData(),
+                    rtl::Reference<ORowSetDataColumn> pColumn = new 
ORowSetDataColumn( getMetaData(),
                                                                         this,
                                                                         this,
                                                                         i,
@@ -1980,7 +1980,7 @@ void 
ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi
                     }
                     pColumn->setName(sColumnLabel);
                     aNames.push_back(sColumnLabel);
-                    m_aDataColumns.push_back(pColumn);
+                    m_aDataColumns.push_back(pColumn.get());
 
                     if ( xColumn.is() )
                         impl_initializeColumnSettings_nothrow( xColumn, 
pColumn );
@@ -2066,10 +2066,9 @@ Reference< XResultSet > SAL_CALL 
ORowSet::createResultSet(  )
 
     if(m_xStatement.is())
     {
-        ORowSetClone* pClone = new ORowSetClone( m_aContext, *this, m_pMutex );
-        Reference< XResultSet > xRet(pClone);
-        m_aClones.emplace_back(xRet);
-        return xRet;
+        rtl::Reference<ORowSetClone> pClone = new ORowSetClone( m_aContext, 
*this, m_pMutex );
+        m_aClones.emplace_back(static_cast<cppu::OWeakObject*>(pClone.get()));
+        return pClone;
     }
     return Reference< XResultSet >();
 }
@@ -2775,7 +2774,7 @@ ORowSetClone::ORowSetClone( const 
Reference<XComponentContext>& _rContext, ORowS
 
             OUString sParseLabel;
             xColumn->getPropertyValue(PROPERTY_LABEL) >>= sParseLabel;
-            ORowSetColumn* pColumn = new ORowSetColumn( rParent.getMetaData(),
+            rtl::Reference<ORowSetColumn> pColumn = new ORowSetColumn( 
rParent.getMetaData(),
                                                                 this,
                                                                 i,
                                                                 
rParent.m_xActiveConnection->getMetaData(),
@@ -2787,7 +2786,7 @@ ORowSetClone::ORowSetClone( const 
Reference<XComponentContext>& _rContext, ORowS
             aColumns->emplace_back(pColumn);
             pColumn->setName(*pIter);
             aNames.push_back(*pIter);
-            m_aDataColumns.push_back(pColumn);
+            m_aDataColumns.push_back(pColumn.get());
 
             
pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ALIGN,xColumn->getPropertyValue(PROPERTY_ALIGN));
             sal_Int32 nFormatKey = 0;
diff --git a/dbaccess/source/core/api/RowSetCache.cxx 
b/dbaccess/source/core/api/RowSetCache.cxx
index c80c04594786..a939cc1e48a4 100644
--- a/dbaccess/source/core/api/RowSetCache.cxx
+++ b/dbaccess/source/core/api/RowSetCache.cxx
@@ -165,7 +165,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& 
_xRs,
             if ( aTableNames.getLength() > 1 && _rUpdateTableName.isEmpty() && 
bNeedKeySet )
             {// here we have a join or union and nobody told us which table to 
update, so we update them all
                 m_nPrivileges = 
Privilege::SELECT|Privilege::DELETE|Privilege::INSERT|Privilege::UPDATE;
-                OptimisticSet* pCursor = new 
OptimisticSet(m_aContext,xConnection,_xAnalyzer,_aParameterValueForCache,i_nMaxRows,m_nRowCount);
+                rtl::Reference<OptimisticSet> pCursor = new 
OptimisticSet(m_aContext,xConnection,_xAnalyzer,_aParameterValueForCache,i_nMaxRows,m_nRowCount);
                 m_xCacheSet = pCursor;
                 try
                 {
@@ -302,7 +302,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& 
_xRs,
                 }
             }
 
-            OKeySet* pKeySet = new OKeySet(m_aUpdateTable, aUpdateTableName 
,_xAnalyzer,_aParameterValueForCache,i_nMaxRows,m_nRowCount);
+            rtl::Reference<OKeySet> pKeySet = new OKeySet(m_aUpdateTable, 
aUpdateTableName ,_xAnalyzer,_aParameterValueForCache,i_nMaxRows,m_nRowCount);
             try
             {
                 m_xCacheSet = pKeySet;
diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx 
b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
index 6439941912dc..6c19bcc204fe 100644
--- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
+++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
@@ -890,7 +890,7 @@ Reference< XNameAccess > SAL_CALL 
OSingleSelectQueryComposer::getColumns(  )
                 if ( !xProp.is() || 
!xProp->getPropertySetInfo()->hasPropertyByName( PROPERTY_REALNAME ) )
                     continue;
 
-                ::connectivity::parse::OParseColumn* pColumn = new 
::connectivity::parse::OParseColumn(xProp,bCase);
+                rtl::Reference<::connectivity::parse::OParseColumn> pColumn = 
new ::connectivity::parse::OParseColumn(xProp,bCase);
                 
pColumn->setFunction(::comphelper::getBOOL(xProp->getPropertyValue("Function")));
                 
pColumn->setAggregateFunction(::comphelper::getBOOL(xProp->getPropertyValue("AggregateFunction")));
 
diff --git a/dbaccess/source/core/api/TableDeco.cxx 
b/dbaccess/source/core/api/TableDeco.cxx
index 702723676c97..d4b0582db83f 100644
--- a/dbaccess/source/core/api/TableDeco.cxx
+++ b/dbaccess/source/core/api/TableDeco.cxx
@@ -549,18 +549,18 @@ void ODBTableDecorator::refreshColumns()
                                     m_xMetaData.is() && 
m_xMetaData->supportsAlterTableWithDropColumn());
 
         pCol->setParent(*this);
-        OContainerMediator* pMediator = new OContainerMediator( pCol, 
m_xColumnDefinitions );
+        rtl::Reference<OContainerMediator> pMediator = new OContainerMediator( 
pCol, m_xColumnDefinitions );
         m_xColumnMediator = pMediator;
-        pCol->setMediator( pMediator );
+        pCol->setMediator( pMediator.get() );
         m_pColumns.reset(pCol);
     }
     else
         m_pColumns->reFill(aVector);
 }
 
-OColumn* ODBTableDecorator::createColumn(const OUString& _rName) const
+rtl::Reference<OColumn> ODBTableDecorator::createColumn(const OUString& 
_rName) const
 {
-    OColumn* pReturn = nullptr;
+    rtl::Reference<OColumn> pReturn;
 
     Reference<XNameAccess> xNames;
     if ( m_xTable.is() )
diff --git a/dbaccess/source/core/api/preparedstatement.cxx 
b/dbaccess/source/core/api/preparedstatement.cxx
index d65ea616d8c7..cdd8aa79ae1d 100644
--- a/dbaccess/source/core/api/preparedstatement.cxx
+++ b/dbaccess/source/core/api/preparedstatement.cxx
@@ -151,14 +151,14 @@ Reference< css::container::XNameAccess > 
OPreparedStatement::getColumns()
             {
                 // retrieve the name of the column
                 OUString aName = xMetaData->getColumnName(i + 1);
-                OResultColumn* pColumn = new OResultColumn(xMetaData, i + 1, 
xDBMeta);
+                rtl::Reference<OResultColumn> pColumn = new 
OResultColumn(xMetaData, i + 1, xDBMeta);
                 // don't silently assume that the name is unique - 
preparedStatement implementations
                 // are allowed to return duplicate names, but we are required 
to have
                 // unique column names
                 if ( m_pColumns->hasByName( aName ) )
                     aName = ::dbtools::createUniqueName( m_pColumns.get(), 
aName );
 
-                m_pColumns->append(aName, pColumn);
+                m_pColumns->append(aName, pColumn.get());
             }
         }
         catch (const SQLException& )
diff --git a/dbaccess/source/core/api/query.cxx 
b/dbaccess/source/core/api/query.cxx
index 051c11148075..cc5e7753b262 100644
--- a/dbaccess/source/core/api/query.cxx
+++ b/dbaccess/source/core/api/query.cxx
@@ -173,11 +173,10 @@ void OQuery::rebuildColumns()
                 Reference<XPropertySet> 
xCommandColumn(xColumnDefinitions->getByName( rName ),UNO_QUERY);
                 xCommandColumn->getPropertyValue(PROPERTY_LABEL) >>= sLabel;
             }
-            OQueryColumn* pColumn = new OQueryColumn( xSource, m_xConnection, 
sLabel);
-            Reference< XChild > xChild( *pColumn, UNO_QUERY_THROW );
-            xChild->setParent( *this );
+            rtl::Reference<OQueryColumn> pColumn = new OQueryColumn( xSource, 
m_xConnection, sLabel);
+            pColumn->setParent( *this );
 
-            implAppendColumn( rName, pColumn );
+            implAppendColumn( rName, pColumn.get() );
             Reference< XPropertySet > xDest( *pColumn, UNO_QUERY_THROW );
             if ( m_pColumnMediator.is() )
                 m_pColumnMediator->notifyElementCreated( rName, xDest );
@@ -309,7 +308,7 @@ Reference< XPropertySetInfo > SAL_CALL 
OQuery::getPropertySetInfo(  )
     return new ::cppu::OPropertyArrayHelper(aProps);
 }
 
-OColumn* OQuery::createColumn(const OUString& /*_rName*/) const
+rtl::Reference<OColumn> OQuery::createColumn(const OUString& /*_rName*/) const
 {
     return nullptr;
 }
diff --git a/dbaccess/source/core/api/query.hxx 
b/dbaccess/source/core/api/query.hxx
index 7c25dc43086f..fefcb94b47e7 100644
--- a/dbaccess/source/core/api/query.hxx
+++ b/dbaccess/source/core/api/query.hxx
@@ -131,7 +131,7 @@ public:
 protected:
     virtual void SAL_CALL disposing() override;
 
-    virtual OColumn* createColumn(const OUString& _rName) const override;
+    virtual rtl::Reference<OColumn> createColumn(const OUString& _rName) const 
override;
 
     virtual void rebuildColumns( ) override;
 
diff --git a/dbaccess/source/core/api/querycontainer.cxx 
b/dbaccess/source/core/api/querycontainer.cxx
index 27ecf51ef5c1..cebb70cf1cb2 100644
--- a/dbaccess/source/core/api/querycontainer.cxx
+++ b/dbaccess/source/core/api/querycontainer.cxx
@@ -352,7 +352,7 @@ Reference< XContent > 
OQueryContainer::implCreateWrapper(const Reference< XConte
     }
     else
     {
-        OQuery* pNewObject = new OQuery( Reference< XPropertySet >( 
_rxCommandDesc, UNO_QUERY ), m_xConnection, m_aContext );
+        rtl::Reference<OQuery> pNewObject = new OQuery( Reference< 
XPropertySet >( _rxCommandDesc, UNO_QUERY ), m_xConnection, m_aContext );
         xReturn = pNewObject;
 
         pNewObject->setWarningsContainer( m_pWarnings );
diff --git a/dbaccess/source/core/api/querydescriptor.cxx 
b/dbaccess/source/core/api/querydescriptor.cxx
index c52febb5db6c..2ba824d0afbd 100644
--- a/dbaccess/source/core/api/querydescriptor.cxx
+++ b/dbaccess/source/core/api/querydescriptor.cxx
@@ -255,7 +255,7 @@ void OQueryDescriptor_Base::refreshColumns()
     rebuildColumns();
 }
 
-OColumn* OQueryDescriptor_Base::createColumn( const OUString& /*_rName*/ ) 
const
+rtl::Reference<OColumn> OQueryDescriptor_Base::createColumn( const OUString& 
/*_rName*/ ) const
 {
     // creating a column/descriptor for a query/descriptor does not make sense 
at all
     return nullptr;
diff --git a/dbaccess/source/core/api/querydescriptor.hxx 
b/dbaccess/source/core/api/querydescriptor.hxx
index 0266a82f1436..e0930c8335a3 100644
--- a/dbaccess/source/core/api/querydescriptor.hxx
+++ b/dbaccess/source/core/api/querydescriptor.hxx
@@ -89,7 +89,7 @@ public:
 protected:
 
 // IColumnFactory
-    virtual OColumn*    createColumn(const OUString& _rName) const override;
+    virtual rtl::Reference<OColumn> createColumn(const OUString& _rName) const 
override;
     virtual css::uno::Reference< css::beans::XPropertySet > 
createColumnDescriptor() override;
     virtual void columnAppended( const css::uno::Reference< 
css::beans::XPropertySet >& _rxSourceDescriptor ) override;
     virtual void columnDropped(const OUString& _sName) override;
diff --git a/dbaccess/source/core/api/resultset.cxx 
b/dbaccess/source/core/api/resultset.cxx
index ee93aa42ac53..ab3071dfbb00 100644
--- a/dbaccess/source/core/api/resultset.cxx
+++ b/dbaccess/source/core/api/resultset.cxx
@@ -330,7 +330,7 @@ Reference< css::container::XNameAccess > 
OResultSet::getColumns()
             {
                 // retrieve the name of the column
                 OUString sName = xMetaData->getColumnName(i + 1);
-                ODataColumn* pColumn = new ODataColumn(xMetaData, 
m_xDelegatorRow, m_xDelegatorRowUpdate, i + 1, xDBMetaData);
+                rtl::Reference<ODataColumn> pColumn = new 
ODataColumn(xMetaData, m_xDelegatorRow, m_xDelegatorRowUpdate, i + 1, 
xDBMetaData);
 
                 // don't silently assume that the name is unique - result set 
implementations
                 // are allowed to return duplicate names, but we are required 
to have
@@ -338,7 +338,7 @@ Reference< css::container::XNameAccess > 
OResultSet::getColumns()
                 if ( m_pColumns->hasByName( sName ) )
                     sName = ::dbtools::createUniqueName( m_pColumns.get(), 
sName );
 
-                m_pColumns->append( sName, pColumn );
+                m_pColumns->append( sName, pColumn.get() );
             }
         }
         catch ( const SQLException& )
diff --git a/dbaccess/source/core/api/table.cxx 
b/dbaccess/source/core/api/table.cxx
index 1fb27cd87fea..054c1de241cb 100644
--- a/dbaccess/source/core/api/table.cxx
+++ b/dbaccess/source/core/api/table.cxx
@@ -85,10 +85,8 @@ ODBTable::~ODBTable()
 {
 }
 
-OColumn* ODBTable::createColumn(const OUString& _rName) const
+rtl::Reference<OColumn> ODBTable::createColumn(const OUString& _rName) const
 {
-    OColumn* pReturn = nullptr;
-
     Reference<XPropertySet> xProp;
     if ( m_xDriverColumns.is() && m_xDriverColumns->hasByName(_rName) )
     {
@@ -103,9 +101,7 @@ OColumn* ODBTable::createColumn(const OUString& _rName) 
const
     Reference<XPropertySet> xColumnDefinition;
     if ( m_xColumnDefinitions.is() && m_xColumnDefinitions->hasByName(_rName) )
         
xColumnDefinition.set(m_xColumnDefinitions->getByName(_rName),UNO_QUERY);
-    pReturn = new OTableColumnWrapper( xProp, xColumnDefinition, false );
-
-    return pReturn;
+    return new OTableColumnWrapper( xProp, xColumnDefinition, false );
 }
 
 void ODBTable::columnAppended( const Reference< XPropertySet >& 
/*_rxSourceDescriptor*/ )
diff --git a/dbaccess/source/core/api/tablecontainer.cxx 
b/dbaccess/source/core/api/tablecontainer.cxx
index e734729f7589..51ef6df327d7 100644
--- a/dbaccess/source/core/api/tablecontainer.cxx
+++ b/dbaccess/source/core/api/tablecontainer.cxx
@@ -165,7 +165,7 @@ connectivity::sdbcx::ObjectType 
OTableContainer::createObject(const OUString& _r
 
         if ( xSup.is() )
         {
-            ODBTableDecorator* pTable = new ODBTableDecorator( m_xConnection, 
xSup, ::dbtools::getNumberFormats( m_xConnection ) ,xColumnDefinitions);
+            rtl::Reference<ODBTableDecorator> pTable = new ODBTableDecorator( 
m_xConnection, xSup, ::dbtools::getNumberFormats( m_xConnection ) 
,xColumnDefinitions);
             xRet = pTable;
             pTable->construct();
         }
@@ -198,7 +198,7 @@ connectivity::sdbcx::ObjectType 
OTableContainer::createObject(const OUString& _r
                 }
             }
             ::comphelper::disposeComponent(xRes);
-            ODBTable* pTable = new ODBTable(this
+            rtl::Reference<ODBTable> pTable = new ODBTable(this
                                 ,m_xConnection
                                 ,sCatalog
                                 ,sSchema
@@ -234,13 +234,13 @@ Reference< XPropertySet > 
OTableContainer::createDescriptor()
     if ( xDataFactory.is() && m_xMetaData.is() )
     {
         xMasterColumnsSup.set( xDataFactory->createDataDescriptor(), UNO_QUERY 
);
-        ODBTableDecorator* pTable = new ODBTableDecorator( m_xConnection, 
xMasterColumnsSup, ::dbtools::getNumberFormats( m_xConnection ) ,nullptr);
+        rtl::Reference<ODBTableDecorator> pTable = new ODBTableDecorator( 
m_xConnection, xMasterColumnsSup, ::dbtools::getNumberFormats( m_xConnection ) 
,nullptr);
         xRet = pTable;
         pTable->construct();
     }
     else
     {
-        ODBTable* pTable = new ODBTable(this, m_xConnection);
+        rtl::Reference<ODBTable> pTable = new ODBTable(this, m_xConnection);
         xRet = pTable;
         pTable->construct();
     }
diff --git a/dbaccess/source/core/dataaccess/ComponentDefinition.cxx 
b/dbaccess/source/core/dataaccess/ComponentDefinition.cxx
index 688f22204c73..629727930859 100644
--- a/dbaccess/source/core/dataaccess/ComponentDefinition.cxx
+++ b/dbaccess/source/core/dataaccess/ComponentDefinition.cxx
@@ -213,7 +213,7 @@ Reference< XNameAccess> OComponentDefinition::getColumns()
     return m_pColumns.get();
 }
 
-OColumn* OComponentDefinition::createColumn(const OUString& _rName) const
+rtl::Reference<OColumn> OComponentDefinition::createColumn(const OUString& 
_rName) const
 {
     const OComponentDefinition_Impl& rDefinition( getDefinition() );
     OComponentDefinition_Impl::const_iterator aFind = rDefinition.find( _rName 
);
diff --git a/dbaccess/source/core/dataaccess/ComponentDefinition.hxx 
b/dbaccess/source/core/dataaccess/ComponentDefinition.hxx
index 014bafb0fa1a..4c10a5354b30 100644
--- a/dbaccess/source/core/dataaccess/ComponentDefinition.hxx
+++ b/dbaccess/source/core/dataaccess/ComponentDefinition.hxx
@@ -133,7 +133,7 @@ public:
     virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override;
 
     // IColumnFactory
-    virtual OColumn*    createColumn(const OUString& _rName) const override;
+    virtual rtl::Reference<OColumn> createColumn(const OUString& _rName) const 
override;
     virtual css::uno::Reference< css::beans::XPropertySet > 
createColumnDescriptor() override;
     virtual void columnAppended( const css::uno::Reference< 
css::beans::XPropertySet >& _rxSourceDescriptor ) override;
     virtual void columnDropped(const OUString& _sName) override;
diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx 
b/dbaccess/source/core/dataaccess/databasedocument.cxx
index 21d0d3012077..4f13919ed091 100644
--- a/dbaccess/source/core/dataaccess/databasedocument.cxx
+++ b/dbaccess/source/core/dataaccess/databasedocument.cxx
@@ -2086,8 +2086,8 @@ Reference< XTitle > const & 
ODatabaseDocument::impl_getTitleHelper_throw()
         Reference< XUntitledNumbers >  
xDesktop(Desktop::create(m_pImpl->m_aContext), uno::UNO_QUERY_THROW);
         Reference< frame::XModel >     xThis   (getThis(), 
uno::UNO_QUERY_THROW);
 
-        ::framework::TitleHelper* pHelper = new 
::framework::TitleHelper(m_pImpl->m_aContext);
-        m_xTitleHelper.set(static_cast< ::cppu::OWeakObject* >(pHelper), 
uno::UNO_QUERY_THROW);
+        rtl::Reference<::framework::TitleHelper> pHelper = new 
::framework::TitleHelper(m_pImpl->m_aContext);
+        m_xTitleHelper = pHelper;
         pHelper->setOwner                   (xThis   );
         pHelper->connectWithUntitledNumbers (xDesktop);
     }
@@ -2114,8 +2114,8 @@ uno::Reference< frame::XUntitledNumbers > 
ODatabaseDocument::impl_getUntitledHel
     if ( aFind == m_aNumberedControllers.end() )
     {
         uno::Reference< frame::XModel > xThis(static_cast< frame::XModel* 
>(this), uno::UNO_QUERY_THROW);
-        ::comphelper::NumberedCollection* pHelper = new 
::comphelper::NumberedCollection();
-        xNumberedControllers.set(static_cast< ::cppu::OWeakObject* >(pHelper), 
uno::UNO_QUERY_THROW);
+        rtl::Reference<::comphelper::NumberedCollection> pHelper = new 
::comphelper::NumberedCollection();
+        xNumberedControllers = pHelper;
 
         pHelper->setOwner          (xThis);
 
diff --git a/dbaccess/source/core/dataaccess/datasource.cxx 
b/dbaccess/source/core/dataaccess/datasource.cxx
index 1e45eace1f28..e4f449d8ff32 100644
--- a/dbaccess/source/core/dataaccess/datasource.cxx
+++ b/dbaccess/source/core/dataaccess/datasource.cxx
@@ -1137,8 +1137,8 @@ Reference< XConnection > 
ODatabaseSource::connectWithCompletion( const Reference
 
         // build an interaction request
         // two continuations (Ok and Cancel)
-        OInteractionAbort* pAbort = new OInteractionAbort;
-        OAuthenticationContinuation* pAuthenticate = new 
OAuthenticationContinuation;
+        rtl::Reference<OInteractionAbort> pAbort = new OInteractionAbort;
+        rtl::Reference<OAuthenticationContinuation> pAuthenticate = new 
OAuthenticationContinuation;
 
         // the name which should be referred in the login dialog
         OUString sServerName( m_pImpl->m_sName );
@@ -1153,8 +1153,7 @@ Reference< XConnection > 
ODatabaseSource::connectWithCompletion( const Reference
         aRequest.HasUserName = aRequest.HasPassword = true;
         aRequest.UserName = m_pImpl->m_sUser;
         aRequest.Password = m_pImpl->m_sFailedPassword.isEmpty() ?  
m_pImpl->m_aPassword : m_pImpl->m_sFailedPassword;
-        OInteractionRequest* pRequest = new 
OInteractionRequest(makeAny(aRequest));
-        Reference< XInteractionRequest > xRequest(pRequest);
+        rtl::Reference<OInteractionRequest> pRequest = new 
OInteractionRequest(makeAny(aRequest));
         // some knittings
         pRequest->addContinuation(pAbort);
         pRequest->addContinuation(pAuthenticate);
@@ -1162,7 +1161,7 @@ Reference< XConnection > 
ODatabaseSource::connectWithCompletion( const Reference
         // handle the request
         try
         {
-            _rxHandler->handle(xRequest);
+            _rxHandler->handle(pRequest);
         }
         catch(Exception&)
         {
@@ -1229,7 +1228,11 @@ Reference< XConnection > 
ODatabaseSource::getConnection(const OUString& user, co
     { // create a new proxy for the connection
         if ( !m_pImpl->m_xSharedConnectionManager.is() )
         {
-            m_pImpl->m_pSharedConnectionManager = new 
OSharedConnectionManager( m_pImpl->m_aContext );
+            // TODO ideally we could just have one field, but to make that work
+            // we'd need to move OSharedConnectionManager into its own file 
and header
+            rtl::Reference<OSharedConnectionManager> manager =
+                new OSharedConnectionManager( m_pImpl->m_aContext );
+            m_pImpl->m_pSharedConnectionManager = manager.get();
             m_pImpl->m_xSharedConnectionManager = 
m_pImpl->m_pSharedConnectionManager;
         }
         xConn = m_pImpl->m_pSharedConnectionManager->getConnection(
diff --git a/dbaccess/source/core/dataaccess/documentdefinition.cxx 
b/dbaccess/source/core/dataaccess/documentdefinition.cxx
index e3b015adff0d..58047bb31101 100644
--- a/dbaccess/source/core/dataaccess/documentdefinition.cxx
+++ b/dbaccess/source/core/dataaccess/documentdefinition.cxx
@@ -1224,11 +1224,10 @@ bool ODocumentDefinition::save(bool _bApprove, const 
css::uno::Reference<css::aw
             }
 
             aRequest.Content.set(m_xParentContainer,UNO_QUERY);
-            OInteractionRequest* pRequest = new 
OInteractionRequest(makeAny(aRequest));
-            Reference< XInteractionRequest > xRequest(pRequest);
+            rtl::Reference<OInteractionRequest> pRequest = new 
OInteractionRequest(makeAny(aRequest));
             // some knittings
             // two continuations allowed: OK and Cancel
-            ODocumentSaveContinuation* pDocuSave = nullptr;
+            rtl::Reference<ODocumentSaveContinuation> pDocuSave;
 
             if ( m_pImpl->m_aProps.aTitle.isEmpty() )
             {
@@ -1237,21 +1236,21 @@ bool ODocumentDefinition::save(bool _bApprove, const 
css::uno::Reference<css::aw
             }
             if ( _bApprove )
             {
-                OInteraction< XInteractionApprove >* pApprove = new 
OInteraction< XInteractionApprove >;
+                rtl::Reference<OInteraction< XInteractionApprove >> pApprove = 
new OInteraction< XInteractionApprove >;
                 pRequest->addContinuation(pApprove);
             }
 
-            OInteraction< XInteractionDisapprove >* pDisApprove = new 
OInteraction< XInteractionDisapprove >;
+            rtl::Reference<OInteraction< XInteractionDisapprove >> pDisApprove 
= new OInteraction< XInteractionDisapprove >;
             pRequest->addContinuation(pDisApprove);
 
-            OInteractionAbort* pAbort = new OInteractionAbort;
+            rtl::Reference<OInteractionAbort> pAbort = new OInteractionAbort;
             pRequest->addContinuation(pAbort);
 
             Reference<XWindow> xDialogParent(rDialogParent, UNO_QUERY);
 
             // create the handler, let it handle the request
             Reference<XInteractionHandler2> 
xHandler(InteractionHandler::createWithParent(m_aContext, xDialogParent));
-            xHandler->handle(xRequest);
+            xHandler->handle(pRequest);
 
             if ( pAbort->wasSelected() )
                 return false;
@@ -1311,20 +1310,19 @@ void ODocumentDefinition::saveAs()
         aRequest.Name = m_pImpl->m_aProps.aTitle;
 
         aRequest.Content.set(m_xParentContainer,UNO_QUERY);
-        OInteractionRequest* pRequest = new 
OInteractionRequest(makeAny(aRequest));
-        Reference< XInteractionRequest > xRequest(pRequest);
+        rtl::Reference<OInteractionRequest> pRequest = new 
OInteractionRequest(makeAny(aRequest));
         // some knittings
         // two continuations allowed: OK and Cancel
-        ODocumentSaveContinuation* pDocuSave = new ODocumentSaveContinuation;
+        rtl::Reference<ODocumentSaveContinuation> pDocuSave = new 
ODocumentSaveContinuation;
         pRequest->addContinuation(pDocuSave);
-        OInteraction< XInteractionDisapprove >* pDisApprove = new 
OInteraction< XInteractionDisapprove >;
+        rtl::Reference<OInteraction< XInteractionDisapprove >> pDisApprove = 
new OInteraction< XInteractionDisapprove >;
         pRequest->addContinuation(pDisApprove);
-        OInteractionAbort* pAbort = new OInteractionAbort;
+        rtl::Reference<OInteractionAbort> pAbort = new OInteractionAbort;
         pRequest->addContinuation(pAbort);
 
         // create the handler, let it handle the request
         Reference< XInteractionHandler2 > xHandler( 
InteractionHandler::createWithParent(m_aContext, nullptr) );
-        xHandler->handle(xRequest);
+        xHandler->handle(pRequest);
 
         if ( pAbort->wasSelected() )
             return;
diff --git a/dbaccess/source/core/inc/TableDeco.hxx 
b/dbaccess/source/core/inc/TableDeco.hxx
index 002423908e29..3901230e78f5 100644
--- a/dbaccess/source/core/inc/TableDeco.hxx
+++ b/dbaccess/source/core/inc/TableDeco.hxx
@@ -76,7 +76,7 @@ namespace dbaccess
         std::unique_ptr<::connectivity::sdbcx::OCollection>       m_pColumns;
 
         // IColumnFactory
-        virtual OColumn*    createColumn(const OUString& _rName) const 
override;
+        virtual rtl::Reference<OColumn> createColumn(const OUString& _rName) 
const override;
         virtual css::uno::Reference< css::beans::XPropertySet > 
createColumnDescriptor() override;
         virtual void columnAppended( const css::uno::Reference< 
css::beans::XPropertySet >& _rxSourceDescriptor ) override;
         virtual void columnDropped(const OUString& _sName) override;
diff --git a/dbaccess/source/core/inc/column.hxx 
b/dbaccess/source/core/inc/column.hxx
index 9c4e20153f06..d7471cd8a867 100644
--- a/dbaccess/source/core/inc/column.hxx
+++ b/dbaccess/source/core/inc/column.hxx
@@ -97,7 +97,7 @@ namespace dbaccess
     public:
         /** creates an OColumn object which should represent the column with a 
given name
         */
-        virtual OColumn*
+        virtual rtl::Reference<OColumn>
             createColumn( const OUString& _rName ) const = 0;
 
         /** creates a column descriptor object.
diff --git a/dbaccess/source/core/inc/table.hxx 
b/dbaccess/source/core/inc/table.hxx
index 8962e13d5024..069579c632e3 100644
--- a/dbaccess/source/core/inc/table.hxx
+++ b/dbaccess/source/core/inc/table.hxx
@@ -56,7 +56,7 @@ namespace dbaccess
         virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() 
override;
 
         // IColumnFactory
-        virtual OColumn*    createColumn(const OUString& _rName) const 
override;
+        virtual rtl::Reference<OColumn> createColumn(const OUString& _rName) 
const override;
         virtual css::uno::Reference< css::beans::XPropertySet > 
createColumnDescriptor() override;
         virtual void columnAppended( const css::uno::Reference< 
css::beans::XPropertySet >& _rxSourceDescriptor ) override;
         virtual void columnDropped(const OUString& _sName) override;
diff --git a/dbaccess/source/filter/xml/xmlExport.cxx 
b/dbaccess/source/filter/xml/xmlExport.cxx
index 4bf8a063afed..9668dcbd4e38 100644
--- a/dbaccess/source/filter/xml/xmlExport.cxx
+++ b/dbaccess/source/filter/xml/xmlExport.cxx
@@ -910,10 +910,9 @@ void ODBExport::exportColumns(const 
Reference<XColumnsSupplier>& _xColSup)
             if ( aFind != m_aTableDummyColumns.end() )
             {
                 SvXMLElementExport aColumns(*this,XML_NAMESPACE_DB, 
XML_COLUMNS, true, true);
-                SvXMLAttributeList* pAtt = new SvXMLAttributeList;
-                Reference<XAttributeList> xAtt = pAtt;
+                rtl::Reference<SvXMLAttributeList> pAtt = new 
SvXMLAttributeList;
                 exportStyleName(aFind->second.get(),*pAtt);
-                AddAttributeList(xAtt);
+                AddAttributeList(pAtt);
                 SvXMLElementExport aColumn(*this,XML_NAMESPACE_DB, XML_COLUMN, 
true, true);
 
             }
@@ -929,8 +928,7 @@ void ODBExport::exportColumns(const 
Reference<XColumnsSupplier>& _xColSup)
             Reference<XPropertySet> 
xProp(xNameAccess->getByName(*pIter),UNO_QUERY);
             if ( xProp.is() )
             {
-                SvXMLAttributeList* pAtt = new SvXMLAttributeList;
-                Reference<XAttributeList> xAtt = pAtt;
+                rtl::Reference<SvXMLAttributeList> pAtt = new 
SvXMLAttributeList;
                 exportStyleName(xProp.get(),*pAtt);
 
                 bool bHidden = 
getBOOL(xProp->getPropertyValue(PROPERTY_HIDDEN));
@@ -958,7 +956,7 @@ void ODBExport::exportColumns(const 
Reference<XColumnsSupplier>& _xColSup)
                     }
 
                     if ( pAtt->getLength() )
-                        AddAttributeList(xAtt);
+                        AddAttributeList(pAtt);
                 }
 
                 if ( GetAttrList().getLength() )
diff --git a/dbaccess/source/ui/browser/brwctrlr.cxx 
b/dbaccess/source/ui/browser/brwctrlr.cxx
index c2e175020b4e..e799ab9c30e6 100644
--- a/dbaccess/source/ui/browser/brwctrlr.cxx
+++ b/dbaccess/source/ui/browser/brwctrlr.cxx
@@ -500,7 +500,7 @@ Sequence< Type > SAL_CALL 
SbaXDataBrowserController::getTypes(  )
 {
     return ::comphelper::concatSequences(
         SbaXDataBrowserController_Base::getTypes(),
-        m_pFormControllerImpl->getTypes()
+        m_xFormControllerImpl->getTypes()
     );
 }
 
@@ -530,7 +530,6 @@ SbaXDataBrowserController::SbaXDataBrowserController(const 
Reference< css::uno::
     ,m_sStateSaveRecord(DBA_RES(RID_STR_SAVE_CURRENT_RECORD))
     ,m_sStateUndoRecord(DBA_RES(RID_STR_UNDO_MODIFY_RECORD))
     ,m_sModuleIdentifier( OUString( "com.sun.star.sdb.DataSourceBrowser" ) )
-    ,m_pFormControllerImpl(nullptr)
     ,m_nFormActionNestingLevel(0)
     ,m_bLoadCanceled( false )
     ,m_bCannotSelectUnfiltered( true )
@@ -538,8 +537,7 @@ SbaXDataBrowserController::SbaXDataBrowserController(const 
Reference< css::uno::
     // create the form controller aggregate
     osl_atomic_increment(&m_refCount);
     {
-        m_pFormControllerImpl = new FormControllerImpl(this);
-        m_xFormControllerImpl = m_pFormControllerImpl;
+        m_xFormControllerImpl = new FormControllerImpl(this);
         m_xFormControllerImpl->setDelegator(*this);
     }
     osl_atomic_decrement(&m_refCount);
@@ -925,7 +923,7 @@ void SAL_CALL SbaXDataBrowserController::focusGained(const 
FocusEvent& /*e*/)
 {
     // notify our activate listeners (registered on the form controller 
aggregate)
     EventObject aEvt(*this);
-    ::comphelper::OInterfaceIteratorHelper2 
aIter(m_pFormControllerImpl->m_aActivateListeners);
+    ::comphelper::OInterfaceIteratorHelper2 
aIter(m_xFormControllerImpl->m_aActivateListeners);
     while (aIter.hasMoreElements())
         
static_cast<XFormControllerListener*>(aIter.next())->formActivated(aEvt);
 }
@@ -951,7 +949,7 @@ void SAL_CALL SbaXDataBrowserController::focusLost(const 
FocusEvent& e)
 
     // notify the listeners that the "form" we represent has been deactivated
     EventObject aEvt(*this);
-    ::comphelper::OInterfaceIteratorHelper2 
aIter(m_pFormControllerImpl->m_aActivateListeners);
+    ::comphelper::OInterfaceIteratorHelper2 
aIter(m_xFormControllerImpl->m_aActivateListeners);
     while (aIter.hasMoreElements())
         
static_cast<XFormControllerListener*>(aIter.next())->formDeactivated(aEvt);
 
@@ -998,7 +996,7 @@ void SbaXDataBrowserController::disposingColumnModel(const 
css::lang::EventObjec
 void SbaXDataBrowserController::disposing(const EventObject& Source)
 {
     // if it's a component other than our aggregate, forward it to the 
aggregate
-    if ( m_xFormControllerImpl != Source.Source )
+    if ( 
uno::Reference<XInterface>(static_cast<cppu::OWeakObject*>(m_xFormControllerImpl.get()),
 UNO_QUERY) != Source.Source )
     {
         Reference< XEventListener > xAggListener;
         m_xFormControllerImpl->queryAggregation( 
cppu::UnoType<decltype(xAggListener)>::get() ) >>= xAggListener;
@@ -1291,21 +1289,20 @@ sal_Bool 
SbaXDataBrowserController::approveParameter(const css::form::DatabasePa
     try
     {
         // 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 = xParameters;
         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);
 
         // create the handler, let it handle the request
         Reference< XInteractionHandler2 > 
xHandler(InteractionHandler::createWithParent(getORB(), getComponentWindow()));
-        xHandler->handle(xParamRequest);
+        xHandler->handle(pParamRequest);
 
         if (!pParamValues->wasSelected())
         {   // canceled
diff --git a/dbaccess/source/ui/browser/exsrcbrw.cxx 
b/dbaccess/source/ui/browser/exsrcbrw.cxx
index b4da55e02ffc..e837f6b05439 100644
--- a/dbaccess/source/ui/browser/exsrcbrw.cxx
+++ b/dbaccess/source/ui/browser/exsrcbrw.cxx
@@ -61,7 +61,6 @@ Any SAL_CALL SbaExternalSourceBrowser::queryInterface(const 
Type& _rType)
 SbaExternalSourceBrowser::SbaExternalSourceBrowser(const Reference< 
css::uno::XComponentContext >& _rM)
     :SbaXDataBrowserController(_rM)
     ,m_aModifyListeners(getMutex())
-    ,m_pDataSourceImpl(nullptr)
     ,m_bInQueryDispatch( false )
 {
 
diff --git a/dbaccess/source/ui/browser/genericcontroller.cxx 
b/dbaccess/source/ui/browser/genericcontroller.cxx
index 43ac31842b59..cb7957556ecb 100644
--- a/dbaccess/source/ui/browser/genericcontroller.cxx
+++ b/dbaccess/source/ui/browser/genericcontroller.cxx
@@ -1069,8 +1069,8 @@ Reference< XTitle > 
OGenericUnoController::impl_getTitleHelper_throw()
         Reference< XUntitledNumbers > xUntitledProvider(getPrivateModel(), 
UNO_QUERY      );
         Reference< XController >      xThis(static_cast< XController* >(this), 
UNO_QUERY_THROW);
 
-        ::framework::TitleHelper* pHelper = new ::framework::TitleHelper( 
m_xContext );
-        m_xTitleHelper.set( static_cast< ::cppu::OWeakObject* >(pHelper), 
UNO_QUERY_THROW);
+        rtl::Reference<::framework::TitleHelper> pHelper = new 
::framework::TitleHelper( m_xContext );
+        m_xTitleHelper = pHelper;
 
         pHelper->setOwner                   (xThis            );
         pHelper->connectWithUntitledNumbers (xUntitledProvider);
diff --git a/dbaccess/source/ui/browser/sbagrid.cxx 
b/dbaccess/source/ui/browser/sbagrid.cxx
index f10ee9ccb0df..9e379b3e5b49 100644
--- a/dbaccess/source/ui/browser/sbagrid.cxx
+++ b/dbaccess/source/ui/browser/sbagrid.cxx
@@ -110,7 +110,7 @@ SbaXGridControl::~SbaXGridControl()
 
 rtl::Reference<FmXGridPeer> SbaXGridControl::imp_CreatePeer(vcl::Window* 
pParent)
 {
-    FmXGridPeer* pReturn = new SbaXGridPeer(m_xContext);
+    rtl::Reference<FmXGridPeer> pReturn = new SbaXGridPeer(m_xContext);
 
     // translate properties into WinBits
     WinBits nStyle = WB_TABSTOP;
diff --git a/dbaccess/source/ui/dlg/CollectionView.cxx 
b/dbaccess/source/ui/dlg/CollectionView.cxx
index 6b978bc301c4..77dd170785b2 100644
--- a/dbaccess/source/ui/dlg/CollectionView.cxx
+++ b/dbaccess/source/ui/dlg/CollectionView.cxx
@@ -141,12 +141,11 @@ IMPL_LINK_NOARG(OCollectionView, Save_Click, 
weld::Button&, void)
 
                     Reference<XInteractionHandler2> xHandler(
                         InteractionHandler::createWithParent(m_xContext, 
m_xDialog->GetXWindow()));
-                    OInteractionRequest* pRequest = new 
OInteractionRequest(makeAny(aException));
-                    Reference< XInteractionRequest > xRequest(pRequest);
+                    rtl::Reference<OInteractionRequest> pRequest = new 
OInteractionRequest(makeAny(aException));
 
-                    OInteractionApprove* pApprove = new OInteractionApprove;
+                    rtl::Reference<OInteractionApprove> pApprove = new 
OInteractionApprove;
                     pRequest->addContinuation(pApprove);
-                    xHandler->handle(xRequest);
+                    xHandler->handle(pRequest);
 
                     return;
                 }
diff --git a/dbaccess/source/ui/dlg/ConnectionHelper.cxx 
b/dbaccess/source/ui/dlg/ConnectionHelper.cxx
index 5ab0d0b850e3..4339d3bc3e08 100644
--- a/dbaccess/source/ui/dlg/ConnectionHelper.cxx
+++ b/dbaccess/source/ui/dlg/ConnectionHelper.cxx
@@ -533,7 +533,7 @@ namespace dbaui
         IS_PATH_EXIST eExists = PATH_NOT_EXIST;
         Reference< css::task::XInteractionHandler > xInteractionHandler =
             task::InteractionHandler::createWithParent(m_xORB, nullptr);
-        OFilePickerInteractionHandler* pHandler = new 
OFilePickerInteractionHandler(xInteractionHandler);
+        rtl::Reference<OFilePickerInteractionHandler> pHandler = new 
OFilePickerInteractionHandler(xInteractionHandler);
         xInteractionHandler = pHandler;
 
         Reference< XCommandEnvironment > xCmdEnv = new 
::ucbhelper::CommandEnvironment( xInteractionHandler, Reference< 
XProgressHandler >() );
diff --git a/dbaccess/source/ui/dlg/DbAdminImpl.cxx 
b/dbaccess/source/ui/dlg/DbAdminImpl.cxx
index 6b924e0bb846..fe25fa3f6f2c 100644
--- a/dbaccess/source/ui/dlg/DbAdminImpl.cxx
+++ b/dbaccess/source/ui/dlg/DbAdminImpl.cxx
@@ -261,8 +261,7 @@ bool 
ODbDataSourceAdministrationHelper::getCurrentSettings(Sequence< PropertyVal
             aRequest.HasAccount  = false;
             // aRequest.Account
 
-            comphelper::OInteractionRequest* pRequest = new 
comphelper::OInteractionRequest(makeAny(aRequest));
-            uno::Reference< XInteractionRequest > xRequest(pRequest);
+            rtl::Reference<comphelper::OInteractionRequest> pRequest = new 
comphelper::OInteractionRequest(makeAny(aRequest));
 
             // build an interaction request
             // two continuations (Ok and Cancel)
@@ -280,7 +279,7 @@ bool 
ODbDataSourceAdministrationHelper::getCurrentSettings(Sequence< PropertyVal
             {
                 SolarMutexGuard aSolarGuard;
                 // release the mutex when calling the handler, it may need to 
lock the SolarMutex
-                xHandler->handle(xRequest);
+                xHandler->handle(pRequest);
             }
             catch(Exception&)
             {
diff --git a/dbaccess/source/ui/dlg/dbwizsetup.cxx 
b/dbaccess/source/ui/dlg/dbwizsetup.cxx
index 88fd1151bfef..d4e7171b448f 100644
--- a/dbaccess/source/ui/dlg/dbwizsetup.cxx
+++ b/dbaccess/source/ui/dlg/dbwizsetup.cxx
@@ -646,12 +646,11 @@ namespace
 {
     bool lcl_handle( const Reference< XInteractionHandler2 >& _rxHandler, 
const Any& _rRequest )
     {
-        OInteractionRequest* pRequest = new OInteractionRequest( _rRequest );
-        Reference < XInteractionRequest > xRequest( pRequest );
-        OInteractionAbort* pAbort = new OInteractionAbort;
+        rtl::Reference<OInteractionRequest> pRequest = new 
OInteractionRequest( _rRequest );
+        rtl::Reference<OInteractionAbort> pAbort = new OInteractionAbort;
         pRequest->addContinuation( pAbort );
 
-        return _rxHandler->handleInteractionRequest( xRequest );
+        return _rxHandler->handleInteractionRequest( pRequest );
     }
 }
 
@@ -969,8 +968,7 @@ bool ODbTypeWizDialogSetup::SaveDatabaseDocument()
 
             try
             {
-                AsyncLoader* pAsyncLoader = new AsyncLoader( getORB(), 
m_pGeneralPage->GetSelectedDocumentURL() );
-                ::rtl::Reference< AsyncLoader > xKeepAlive( pAsyncLoader );
+                rtl::Reference<AsyncLoader> pAsyncLoader = new AsyncLoader( 
getORB(), m_pGeneralPage->GetSelectedDocumentURL() );
                 pAsyncLoader->doLoadAsync();
             }
             catch( const Exception& )
diff --git a/dbaccess/source/ui/inc/JoinTableView.hxx 
b/dbaccess/source/ui/inc/JoinTableView.hxx
index ec2c6e420080..80de958ea627 100644
--- a/dbaccess/source/ui/inc/JoinTableView.hxx
+++ b/dbaccess/source/ui/inc/JoinTableView.hxx
@@ -105,7 +105,7 @@ namespace dbaui
     protected:
         VclPtr<OTableWindow>               m_pLastFocusTabWin;
         VclPtr<OJoinDesignView>            m_pView;
-        OJoinDesignViewAccess*      m_pAccessible;
+        rtl::Reference<OJoinDesignViewAccess> m_pAccessible;
 
     public:
         OJoinTableView( vcl::Window* pParent, OJoinDesignView* pView );
diff --git a/dbaccess/source/ui/inc/brwctrlr.hxx 
b/dbaccess/source/ui/inc/brwctrlr.hxx
index d4f2d5787ec0..e5e1db401a6a 100644
--- a/dbaccess/source/ui/inc/brwctrlr.hxx
+++ b/dbaccess/source/ui/inc/brwctrlr.hxx
@@ -79,7 +79,6 @@ namespace dbaui
         css::uno::Reference< css::form::XLoadable >           m_xLoadable;     
   // queried from the rowset member as well
         css::uno::Reference< css::form::XFormComponent >      m_xGridModel;   
// the model of our grid
         css::uno::Reference< css::util::XNumberFormatter >    m_xFormatter;   
// a number formatter working with the connection's NumberFormatsSupplier
-        css::uno::Reference< css::uno::XAggregation >         
m_xFormControllerImpl;
         mutable css::uno::Reference< css::sdb::XSingleSelectQueryComposer >
                                                               m_xParser;      
// for sorting 'n filtering
 
@@ -100,7 +99,7 @@ namespace dbaui
         OUString                m_sModuleIdentifier;
 
         // members for asynchronous load operations
-        FormControllerImpl*     m_pFormControllerImpl;  // implementing the 
XFormController
+        rtl::Reference<FormControllerImpl> m_xFormControllerImpl;  // 
implementing the XFormController
 
         sal_uInt16              m_nFormActionNestingLevel;      // see 
enter-/leaveFormAction
 
diff --git a/dbaccess/source/ui/inc/exsrcbrw.hxx 
b/dbaccess/source/ui/inc/exsrcbrw.hxx
index 5b510d0fb8be..eaeb56e336bd 100644
--- a/dbaccess/source/ui/inc/exsrcbrw.hxx
+++ b/dbaccess/source/ui/inc/exsrcbrw.hxx
@@ -34,7 +34,7 @@ namespace dbaui
     {
         ::comphelper::OInterfaceContainerHelper2   m_aModifyListeners;
             // for multiplexing the modify events
-        SbaXFormAdapter*                    m_pDataSourceImpl;
+        rtl::Reference<SbaXFormAdapter>            m_pDataSourceImpl;
         bool                            m_bInQueryDispatch;
             // our queryDispatch will ask our frame, which first will ask our 
queryDispatch, so we need to protect against
             // recursion
diff --git a/dbaccess/source/ui/misc/TableCopyHelper.cxx 
b/dbaccess/source/ui/misc/TableCopyHelper.cxx
index e5c3f529b4a1..b61718f3da71 100644
--- a/dbaccess/source/ui/misc/TableCopyHelper.cxx
+++ b/dbaccess/source/ui/misc/TableCopyHelper.cxx
@@ -221,14 +221,12 @@ void OTableCopyHelper::pasteTable( const 
TransferableDataHelper& _rTransData
 
 bool OTableCopyHelper::copyTagTable(OTableCopyHelper::DropDescriptor const & 
_rDesc, bool _bCheck, const SharedConnection& _xConnection)
 {
-    Reference<XEventListener> xEvt;
-    ODatabaseImportExport* pImport = nullptr;
+    rtl::Reference<ODatabaseImportExport> pImport;
     if ( _rDesc.bHtml )
         pImport = new 
OHTMLImportExport(_xConnection,getNumberFormatter(_xConnection, 
m_pController->getORB()),m_pController->getORB());
     else
         pImport = new 
ORTFImportExport(_xConnection,getNumberFormatter(_xConnection, 
m_pController->getORB()),m_pController->getORB());
 
-    xEvt = pImport;
     SvStream* pStream = _rDesc.aHtmlRtfStorage.get();
     if ( _bCheck )
         pImport->enableCheckOnly();
diff --git a/dbaccess/source/ui/querydesign/JoinTableView.cxx 
b/dbaccess/source/ui/querydesign/JoinTableView.cxx
index 84a4f1549e34..2111cf0232dc 100644
--- a/dbaccess/source/ui/querydesign/JoinTableView.cxx
+++ b/dbaccess/source/ui/querydesign/JoinTableView.cxx
@@ -169,7 +169,6 @@ OJoinTableView::OJoinTableView( vcl::Window* pParent, 
OJoinDesignView* pView )
     ,m_pSelectedConn( nullptr )
     ,m_pLastFocusTabWin(nullptr)
     ,m_pView( pView )
-    ,m_pAccessible(nullptr)
 {
     SetSizePixel( Size(1000, 1000) );
 
diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx 
b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
index e2f338b30737..66544b40264c 100644
--- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx
+++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
@@ -2944,7 +2944,7 @@ std::unique_ptr<OSQLParseNode> 
OQueryDesignView::getPredicateTreeFromEntry(const
         }
 
         Reference<XDatabaseMetaData> xMeta = xConnection->getMetaData();
-        parse::OParseColumn* pColumn = new parse::OParseColumn( 
pEntry->GetField(),
+        rtl::Reference<parse::OParseColumn> pColumn = new parse::OParseColumn( 
pEntry->GetField(),
                                                                 OUString(),
                                                                 OUString(),
                                                                 OUString(),
diff --git a/dbaccess/source/ui/uno/ColumnControl.cxx 
b/dbaccess/source/ui/uno/ColumnControl.cxx
index 08e0b25045c3..6cf6e248e55e 100644
--- a/dbaccess/source/ui/uno/ColumnControl.cxx
+++ b/dbaccess/source/ui/uno/ColumnControl.cxx
@@ -73,7 +73,7 @@ void SAL_CALL OColumnControl::createPeer(const Reference< 
XToolkit >& /*rToolkit
             pParentWin = pParent->GetWindow();
     }
 
-    OColumnPeer* pPeer = new OColumnPeer( pParentWin, m_xContext );
+    rtl::Reference<OColumnPeer> pPeer = new OColumnPeer( pParentWin, 
m_xContext );
     OSL_ENSURE(pPeer != nullptr, "FmXGridControl::createPeer : imp_CreatePeer 
didn't return a peer !");
     setPeer( pPeer );
 
commit 21d76782b39cf83130985d27138f61308f572151
Author:     Noel <noel.gran...@collabora.co.uk>
AuthorDate: Sun Feb 21 20:03:39 2021 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Feb 22 08:08:27 2021 +0100

    loplugin:refcounting in drawinglayer
    
    Change-Id: Ia7bf3a4811a47180ce2a92852a01b613ff16279a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111288
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/drawinglayer/source/primitive2d/PolyPolygonGradientPrimitive2D.cxx 
b/drawinglayer/source/primitive2d/PolyPolygonGradientPrimitive2D.cxx
index 076436b40655..cbf9e8902bb0 100644
--- a/drawinglayer/source/primitive2d/PolyPolygonGradientPrimitive2D.cxx
+++ b/drawinglayer/source/primitive2d/PolyPolygonGradientPrimitive2D.cxx
@@ -22,6 +22,7 @@
 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
 #include <drawinglayer/primitive2d/fillgradientprimitive2d.hxx>
 #include <drawinglayer/primitive2d/maskprimitive2d.hxx>
+#include <rtl/ref.hxx>
 
 using namespace com::sun::star;
 
@@ -34,10 +35,9 @@ void PolyPolygonGradientPrimitive2D::create2DDecomposition(
     {
         // create SubSequence with FillGradientPrimitive2D
         const basegfx::B2DRange 
aPolyPolygonRange(getB2DPolyPolygon().getB2DRange());
-        FillGradientPrimitive2D* pNewGradient = new FillGradientPrimitive2D(
+        rtl::Reference<FillGradientPrimitive2D> pNewGradient = new 
FillGradientPrimitive2D(
             aPolyPolygonRange, getDefinitionRange(), getFillGradient());
-        const Primitive2DReference xSubRef(pNewGradient);
-        const Primitive2DContainer aSubSequence{ xSubRef };
+        const Primitive2DContainer aSubSequence{ pNewGradient };
 
         // create mask primitive
         rContainer.push_back(new MaskPrimitive2D(getB2DPolyPolygon(), 
aSubSequence));
diff --git a/drawinglayer/source/primitive2d/PolyPolygonHatchPrimitive2D.cxx 
b/drawinglayer/source/primitive2d/PolyPolygonHatchPrimitive2D.cxx
index ad85c02f22c1..dd0495739fec 100644
--- a/drawinglayer/source/primitive2d/PolyPolygonHatchPrimitive2D.cxx
+++ b/drawinglayer/source/primitive2d/PolyPolygonHatchPrimitive2D.cxx
@@ -22,6 +22,7 @@
 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
 #include <drawinglayer/primitive2d/maskprimitive2d.hxx>
 #include <drawinglayer/primitive2d/fillhatchprimitive2d.hxx>
+#include <rtl/ref.hxx>
 
 using namespace com::sun::star;
 
@@ -34,10 +35,9 @@ void PolyPolygonHatchPrimitive2D::create2DDecomposition(
     {
         // create SubSequence with FillHatchPrimitive2D
         const basegfx::B2DRange 
aPolyPolygonRange(getB2DPolyPolygon().getB2DRange());
-        FillHatchPrimitive2D* pNewHatch = new FillHatchPrimitive2D(
+        rtl::Reference<FillHatchPrimitive2D> pNewHatch = new 
FillHatchPrimitive2D(
             aPolyPolygonRange, getDefinitionRange(), getBackgroundColor(), 
getFillHatch());
-        const Primitive2DReference xSubRef(pNewHatch);
-        const Primitive2DContainer aSubSequence{ xSubRef };
+        const Primitive2DContainer aSubSequence{ pNewHatch };
 
         // create mask primitive
         rContainer.push_back(new MaskPrimitive2D(getB2DPolyPolygon(), 
aSubSequence));
diff --git a/drawinglayer/source/primitive2d/helplineprimitive2d.cxx 
b/drawinglayer/source/primitive2d/helplineprimitive2d.cxx
index 86c3b88ca6d5..e4c6ccbf1c3e 100644
--- a/drawinglayer/source/primitive2d/helplineprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/helplineprimitive2d.cxx
@@ -52,8 +52,7 @@ namespace drawinglayer::primitive2d
                     aLineA.append(aStartA);
                     aLineA.append(aEndA);
                     
aLineA.transform(rViewInformation.getInverseObjectToViewTransformation());
-                    PolygonMarkerPrimitive2D* pNewA = new 
PolygonMarkerPrimitive2D(aLineA, getRGBColA(), getRGBColB(), 
getDiscreteDashLength());
-                    rContainer.push_back(pNewA);
+                    rContainer.push_back(new PolygonMarkerPrimitive2D(aLineA, 
getRGBColA(), getRGBColB(), getDiscreteDashLength()));
 
                     const basegfx::B2DVector 
aPerpendicularNormalizedDirection(basegfx::getPerpendicular(aNormalizedDirection));
                     const basegfx::B2DPoint aStartB(aViewPosition - 
aPerpendicularNormalizedDirection);
@@ -62,8 +61,7 @@ namespace drawinglayer::primitive2d
                     aLineB.append(aStartB);
                     aLineB.append(aEndB);
                     
aLineB.transform(rViewInformation.getInverseObjectToViewTransformation());
-                    PolygonMarkerPrimitive2D* pNewB = new 
PolygonMarkerPrimitive2D(aLineB, getRGBColA(), getRGBColB(), 
getDiscreteDashLength());
-                    rContainer.push_back(pNewB);
+                    rContainer.push_back(new PolygonMarkerPrimitive2D(aLineB, 
getRGBColA(), getRGBColB(), getDiscreteDashLength()));
 
                     break;
                 }
@@ -113,8 +111,7 @@ namespace drawinglayer::primitive2d
                         {
                             basegfx::B2DPolygon 
aPart(aResult.getB2DPolygon(a));
                             
aPart.transform(rViewInformation.getInverseObjectToViewTransformation());
-                            PolygonMarkerPrimitive2D* pNew = new 
PolygonMarkerPrimitive2D(aPart, getRGBColA(), getRGBColB(), 
getDiscreteDashLength());
-                            rContainer.push_back(pNew);
+                            rContainer.push_back(new 
PolygonMarkerPrimitive2D(aPart, getRGBColA(), getRGBColB(), 
getDiscreteDashLength()));
                         }
                     }
 
diff --git a/drawinglayer/source/primitive3d/polygontubeprimitive3d.cxx 
b/drawinglayer/source/primitive3d/polygontubeprimitive3d.cxx
index 177d829ef4fc..ff00b91050f6 100644
--- a/drawinglayer/source/primitive3d/polygontubeprimitive3d.cxx
+++ b/drawinglayer/source/primitive3d/polygontubeprimitive3d.cxx
@@ -318,8 +318,7 @@ namespace drawinglayer::primitive3d
                             {
                                 const basegfx::B3DPolygon& 
aPartPolygon(aSphere.getB3DPolygon(a));
                                 const basegfx::B3DPolyPolygon 
aPartPolyPolygon(aPartPolygon);
-                                BasePrimitive3D* pNew = new 
PolyPolygonMaterialPrimitive3D(aPartPolyPolygon, rMaterial, false);
-                                aResultVector.push_back(pNew);
+                                aResultVector.push_back(new 
PolyPolygonMaterialPrimitive3D(aPartPolyPolygon, rMaterial, false));
                             }
                         }
                         else
@@ -466,8 +465,7 @@ namespace drawinglayer::primitive3d
                             if(aNewPolygon.count())
                             {
                                 const basegfx::B3DPolyPolygon 
aNewPolyPolygon(aNewPolygon);
-                                BasePrimitive3D* pNew = new 
PolyPolygonMaterialPrimitive3D(aNewPolyPolygon, rMaterial, false);
-                                aResultVector.push_back(pNew);
+                                aResultVector.push_back(new 
PolyPolygonMaterialPrimitive3D(aNewPolyPolygon, rMaterial, false));
                             }
 
                             if(bMiter && aMiterPolygon.count())
@@ -480,8 +478,7 @@ namespace drawinglayer::primitive3d
 
                                 // create primitive
                                 const basegfx::B3DPolyPolygon 
aMiterPolyPolygon(aMiterPolygon);
-                                BasePrimitive3D* pNew = new 
PolyPolygonMaterialPrimitive3D(aMiterPolyPolygon, rMaterial, false);
-                                aResultVector.push_back(pNew);
+                                aResultVector.push_back(new 
PolyPolygonMaterialPrimitive3D(aMiterPolyPolygon, rMaterial, false));
                             }
 
                             // prepare next step
@@ -615,8 +612,7 @@ using namespace com::sun::star;
                                     aSequence = getLineCapSegments(nSegments, 
aMaterial);
                                 }
 
-                                TransformPrimitive3D* pNewTransformedA = new 
TransformPrimitive3D(aCapTrans, aSequence);
-                                aResultVector.push_back(pNewTransformedA);
+                                aResultVector.push_back(new 
TransformPrimitive3D(aCapTrans, aSequence));
                             }
                             else
                             {
@@ -717,8 +713,7 @@ using namespace com::sun::star;
                 else
                 {
                     // create hairline
-                    PolygonHairlinePrimitive3D* pNew = new 
PolygonHairlinePrimitive3D(getB3DPolygon(), getBColor());
-                    aResultVector.push_back(pNew);
+                    aResultVector.push_back(new 
PolygonHairlinePrimitive3D(getB3DPolygon(), getBColor()));
                 }
             }
 
diff --git a/drawinglayer/source/primitive3d/sdrdecompositiontools3d.cxx 
b/drawinglayer/source/primitive3d/sdrdecompositiontools3d.cxx
index 826583b1404c..e8d197e1a1e9 100644
--- a/drawinglayer/source/primitive3d/sdrdecompositiontools3d.cxx
+++ b/drawinglayer/source/primitive3d/sdrdecompositiontools3d.cxx
@@ -36,6 +36,7 @@
 #include <drawinglayer/attribute/sdrfillattribute.hxx>
 #include <drawinglayer/attribute/sdrshadowattribute.hxx>
 #include <primitive3d/hiddengeometryprimitive3d.hxx>
+#include <rtl/ref.hxx>
 
 
 namespace drawinglayer::primitive3d
@@ -197,7 +198,7 @@ namespace drawinglayer::primitive3d
                 {
                     bool bModulate(css::drawing::TextureMode_MODULATE == 
aSdr3DObjectAttribute.getTextureMode());
                     bool bFilter(aSdr3DObjectAttribute.getTextureFilter());
-                    BasePrimitive3D* pNewTexturePrimitive3D = nullptr;
+                    rtl::Reference<BasePrimitive3D> pNewTexturePrimitive3D;
 
                     if(!rFill.getGradient().isDefault())
                     {
diff --git a/drawinglayer/source/processor3d/shadow3dextractor.cxx 
b/drawinglayer/source/processor3d/shadow3dextractor.cxx
index 0b653236eb1b..db3a14cc92f3 100644
--- a/drawinglayer/source/processor3d/shadow3dextractor.cxx
+++ b/drawinglayer/source/processor3d/shadow3dextractor.cxx
@@ -29,6 +29,7 @@
 #include <basegfx/polygon/b2dpolypolygontools.hxx>
 #include <drawinglayer/primitive2d/PolyPolygonColorPrimitive2D.hxx>
 #include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx>
+#include <rtl/ref.hxx>
 
 
 using namespace com::sun::star;
@@ -71,7 +72,7 @@ namespace drawinglayer::processor3d
 
                     // create 2d shadow primitive with result. This also 
fetches all entries
                     // from aNewSubList, so there is no need to delete them
-                    primitive2d::BasePrimitive2D* pNew = new 
primitive2d::ShadowPrimitive2D(
+                    rtl::Reference<primitive2d::BasePrimitive2D> pNew = new 
primitive2d::ShadowPrimitive2D(
                         rPrimitive.getShadowTransform(),
                         rPrimitive.getShadowColor(),
                         0,  // shadow3d doesn't have 
rPrimitive.getShadowBlur() yet.
@@ -80,8 +81,7 @@ namespace drawinglayer::processor3d
                     
if(basegfx::fTools::more(rPrimitive.getShadowTransparence(), 0.0))
                     {
                         // create simpleTransparencePrimitive, add created 
primitives
-                        const primitive2d::Primitive2DReference xRef(pNew);
-                        const primitive2d::Primitive2DContainer 
aNewTransPrimitiveVector { xRef };
+                        const primitive2d::Primitive2DContainer 
aNewTransPrimitiveVector { pNew };
 
                         pNew = new primitive2d::UnifiedTransparencePrimitive2D(
                             aNewTransPrimitiveVector,
diff --git a/drawinglayer/source/tools/emfphelperdata.cxx 
b/drawinglayer/source/tools/emfphelperdata.cxx
index e92e3e58ef27..76d36529a48a 100644
--- a/drawinglayer/source/tools/emfphelperdata.cxx
+++ b/drawinglayer/source/tools/emfphelperdata.cxx
@@ -1633,7 +1633,7 @@ namespace emfplushelper
                             if (color.GetAlpha() > 0)
                             {
                                 std::vector<double> emptyVector;
-                                drawinglayer::primitive2d::BasePrimitive2D* 
pBaseText = nullptr;
+                                
rtl::Reference<drawinglayer::primitive2d::BasePrimitive2D> pBaseText;
                                 if (font->Underline() || font->Strikeout())
                                 {
                                     pBaseText = new 
drawinglayer::primitive2d::TextDecoratedPortionPrimitive2D(
@@ -2118,7 +2118,7 @@ namespace emfplushelper
                                     transformMatrix *= transform;
                                 if (color.GetAlpha() > 0)
                                 {
-                                    
drawinglayer::primitive2d::BasePrimitive2D* pBaseText = nullptr;
+                                    
rtl::Reference<drawinglayer::primitive2d::BasePrimitive2D> pBaseText;
                                     if (font->Underline() || font->Strikeout())
                                     {
                                         pBaseText = new 
drawinglayer::primitive2d::TextDecoratedPortionPrimitive2D(
diff --git a/drawinglayer/source/tools/wmfemfhelper.cxx 
b/drawinglayer/source/tools/wmfemfhelper.cxx
index f287e2a4e23c..2d600f2e7681 100644
--- a/drawinglayer/source/tools/wmfemfhelper.cxx
+++ b/drawinglayer/source/tools/wmfemfhelper.cxx
@@ -1024,7 +1024,7 @@ namespace wmfemfhelper
             aWallpaperRange = 
vcl::unotools::b2DRectangleFromRectangle(rWallpaper.GetRect());
         }
 
-        drawinglayer::primitive2d::BasePrimitive2D* pBitmapWallpaperFill =
+        rtl::Reference<drawinglayer::primitive2d::BasePrimitive2D> 
pBitmapWallpaperFill =
             new drawinglayer::primitive2d::WallpaperBitmapPrimitive2D(
                 aWallpaperRange,
                 aBitmapEx,
@@ -1114,7 +1114,7 @@ namespace wmfemfhelper
         TargetHolder& rTarget,
         PropertyHolder const & rProperty)
     {
-        drawinglayer::primitive2d::BasePrimitive2D* pResult = nullptr;
+        rtl::Reference<drawinglayer::primitive2d::BasePrimitive2D> pResult;
         const vcl::Font& rFont = rProperty.getFont();
         basegfx::B2DVector aAlignmentOffset(0.0, 0.0);
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to