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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Dec 13 10:33:22 UTC 2018


 chart2/source/controller/itemsetwrapper/GraphicPropertyItemConverter.cxx |    8 -
 chart2/source/controller/sidebar/ChartAreaPanel.cxx                      |    5 -
 include/svx/xbtmpit.hxx                                                  |    2 
 include/svx/xflftrit.hxx                                                 |    2 
 include/svx/xflgrit.hxx                                                  |    2 
 include/svx/xflhtit.hxx                                                  |    2 
 include/svx/xlndsit.hxx                                                  |    2 
 include/svx/xlnedit.hxx                                                  |    2 
 include/svx/xlnstit.hxx                                                  |    2 
 sd/source/ui/func/futempl.cxx                                            |   21 +----
 svx/source/sdr/properties/attributeproperties.cxx                        |    4 
 svx/source/svdraw/svdmodel.cxx                                           |    4 
 svx/source/xoutdev/xattr.cxx                                             |   42 +++++-----
 svx/source/xoutdev/xattrbmp.cxx                                          |    5 -
 sw/source/core/doc/docfly.cxx                                            |    3 
 15 files changed, 49 insertions(+), 57 deletions(-)

New commits:
commit b586bfcff288151082f7d247b392c5640ae5c951
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Dec 12 15:11:48 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Dec 13 11:32:56 2018 +0100

    use unique_ptr in checkForUniqueItem
    
    fixing a memory leak in chart2
    
    Change-Id: Idddb6a46b1bde5c1a11148c03bbdaac20ac78e13
    Reviewed-on: https://gerrit.libreoffice.org/65031
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/chart2/source/controller/itemsetwrapper/GraphicPropertyItemConverter.cxx b/chart2/source/controller/itemsetwrapper/GraphicPropertyItemConverter.cxx
index 494aee798ac9..fa7a0d319b04 100644
--- a/chart2/source/controller/itemsetwrapper/GraphicPropertyItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/GraphicPropertyItemConverter.cxx
@@ -297,7 +297,7 @@ void GraphicPropertyItemConverter::FillSpecialItem(
 
             // translate model name to UI-name for predefined entries, so
             // that the correct entry is chosen in the list of UI-names
-            XLineDashItem* pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel );
+            std::unique_ptr<XLineDashItem> pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel );
 
             if(pItemToPut)
                  rOutItemSet.Put( *pItemToPut );
@@ -323,7 +323,7 @@ void GraphicPropertyItemConverter::FillSpecialItem(
 
                 // translate model name to UI-name for predefined entries, so
                 // that the correct entry is chosen in the list of UI-names
-                XFillGradientItem* pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel );
+                std::unique_ptr<XFillGradientItem> pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel );
 
                 if(pItemToPut)
                     rOutItemSet.Put( *pItemToPut );
@@ -349,7 +349,7 @@ void GraphicPropertyItemConverter::FillSpecialItem(
 
                 // translate model name to UI-name for predefined entries, so
                 // that the correct entry is chosen in the list of UI-names
-                XFillHatchItem* pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel );
+                std::unique_ptr<XFillHatchItem> pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel );
 
                 if(pItemToPut)
                     rOutItemSet.Put( *pItemToPut );
@@ -370,7 +370,7 @@ void GraphicPropertyItemConverter::FillSpecialItem(
 
                 // translate model name to UI-name for predefined entries, so
                 // that the correct entry is chosen in the list of UI-names
-                XFillBitmapItem* pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel );
+                std::unique_ptr<XFillBitmapItem> pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel );
 
                 if(pItemToPut)
                     rOutItemSet.Put( *pItemToPut );
diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.cxx b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
index 023d14127922..0dd4d3e2de5c 100644
--- a/chart2/source/controller/sidebar/ChartAreaPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
@@ -458,7 +458,7 @@ void ChartAreaPanel::updateData()
         xPropSet->getPropertyValue("FillBitmapName") >>= aBitmapName;
         GraphicObject aBitmap = getXBitmapFromName(mxModel, aBitmapName);
         XFillBitmapItem aBitmapItem(aBitmapName, aBitmap);
-        XFillBitmapItem* pBitmapItem = nullptr;
+        std::unique_ptr<XFillBitmapItem> pBitmapItem;
         DrawModelWrapper* pModelWrapper = nullptr;
         try
         {
@@ -471,8 +471,7 @@ void ChartAreaPanel::updateData()
         catch (...)
         {
         }
-        updateFillBitmap(false, true, pBitmapItem ? pBitmapItem : &aBitmapItem);
-        delete pBitmapItem;
+        updateFillBitmap(false, true, pBitmapItem ? pBitmapItem.get() : &aBitmapItem);
     }
 
     if (xInfo->hasPropertyByName("FillTransparenceGradientName"))
diff --git a/include/svx/xbtmpit.hxx b/include/svx/xbtmpit.hxx
index 218985c077d6..ae5047bd8ae7 100644
--- a/include/svx/xbtmpit.hxx
+++ b/include/svx/xbtmpit.hxx
@@ -59,7 +59,7 @@ public:
     bool isPattern() const;
 
     static bool CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 );
-    XFillBitmapItem* checkForUniqueItem( SdrModel* pModel ) const;
+    std::unique_ptr<XFillBitmapItem> checkForUniqueItem( SdrModel* pModel ) const;
 
     virtual void dumpAsXml(struct _xmlTextWriter* pWriter) const override;
 };
diff --git a/include/svx/xflftrit.hxx b/include/svx/xflftrit.hxx
index b8c4ed88c30a..95b29045631d 100644
--- a/include/svx/xflftrit.hxx
+++ b/include/svx/xflftrit.hxx
@@ -54,7 +54,7 @@ public:
     void                    SetEnabled( bool bEnable ) { bEnabled = bEnable; }
 
     static bool CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 );
-    XFillFloatTransparenceItem* checkForUniqueItem( SdrModel* pModel ) const;
+    std::unique_ptr<XFillFloatTransparenceItem> checkForUniqueItem( SdrModel* pModel ) const;
 };
 
 #endif
diff --git a/include/svx/xflgrit.hxx b/include/svx/xflgrit.hxx
index 70abe25edb3b..8f0424d23a74 100644
--- a/include/svx/xflgrit.hxx
+++ b/include/svx/xflgrit.hxx
@@ -55,7 +55,7 @@ public:
     void                    SetGradientValue(const XGradient& rNew) { aGradient = rNew; Detach(); } // SetValue -> SetGradientValue
 
     static bool CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 );
-    XFillGradientItem* checkForUniqueItem( SdrModel* pModel ) const;
+    std::unique_ptr<XFillGradientItem> checkForUniqueItem( SdrModel* pModel ) const;
 };
 
 #endif
diff --git a/include/svx/xflhtit.hxx b/include/svx/xflhtit.hxx
index f6717d9b47d1..a81e7232abfa 100644
--- a/include/svx/xflhtit.hxx
+++ b/include/svx/xflhtit.hxx
@@ -55,7 +55,7 @@ public:
     const XHatch&           GetHatchValue() const { return aHatch;} // GetValue -> GetHatchValue
 
     static bool CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 );
-    XFillHatchItem* checkForUniqueItem( SdrModel* pModel ) const;
+    std::unique_ptr<XFillHatchItem> checkForUniqueItem( SdrModel* pModel ) const;
 };
 
 #endif
diff --git a/include/svx/xlndsit.hxx b/include/svx/xlndsit.hxx
index 53a757f7951e..a19e50608d15 100644
--- a/include/svx/xlndsit.hxx
+++ b/include/svx/xlndsit.hxx
@@ -58,7 +58,7 @@ public:
     void                    SetDashValue(const XDash& rNew)   { aDash = rNew; Detach(); } // SetValue -> SetDashValue
 
     static bool CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 );
-    XLineDashItem* checkForUniqueItem( SdrModel* pModel ) const;
+    std::unique_ptr<XLineDashItem> checkForUniqueItem( SdrModel* pModel ) const;
 };
 
 #endif
diff --git a/include/svx/xlnedit.hxx b/include/svx/xlnedit.hxx
index ac835deff32c..b24d4825946f 100644
--- a/include/svx/xlnedit.hxx
+++ b/include/svx/xlnedit.hxx
@@ -54,7 +54,7 @@ public:
     const basegfx::B2DPolyPolygon& GetLineEndValue() const { return maPolyPolygon;}
     void SetLineEndValue(const basegfx::B2DPolyPolygon& rPolyPolygon) { maPolyPolygon = rPolyPolygon; Detach(); }
 
-    XLineEndItem* checkForUniqueItem( SdrModel* pModel ) const;
+    std::unique_ptr<XLineEndItem> checkForUniqueItem( SdrModel* pModel ) const;
 };
 
 #endif
diff --git a/include/svx/xlnstit.hxx b/include/svx/xlnstit.hxx
index 5155ab6873f7..3e9c402e8bb9 100644
--- a/include/svx/xlnstit.hxx
+++ b/include/svx/xlnstit.hxx
@@ -54,7 +54,7 @@ public:
     const basegfx::B2DPolyPolygon& GetLineStartValue() const { return maPolyPolygon;}
     void SetLineStartValue(const basegfx::B2DPolyPolygon& rPolyPolygon) { maPolyPolygon = rPolyPolygon; Detach(); }
 
-    XLineStartItem* checkForUniqueItem( SdrModel* pModel ) const;
+    std::unique_ptr<XLineStartItem> checkForUniqueItem( SdrModel* pModel ) const;
 };
 
 #endif
diff --git a/sd/source/ui/func/futempl.cxx b/sd/source/ui/func/futempl.cxx
index 3f281141c908..df2a92a8e415 100644
--- a/sd/source/ui/func/futempl.cxx
+++ b/sd/source/ui/func/futempl.cxx
@@ -439,71 +439,64 @@ void FuTemplate::DoExecute( SfxRequest& rReq )
                         if( rAttr.GetItemState( XATTR_FILLBITMAP ) == SfxItemState::SET )
                         {
                             const SfxPoolItem* pOldItem = rAttr.GetItem( XATTR_FILLBITMAP );
-                            SfxPoolItem* pNewItem = static_cast<const XFillBitmapItem*>(pOldItem)->checkForUniqueItem( mpDoc );
+                            std::unique_ptr<SfxPoolItem> pNewItem = static_cast<const XFillBitmapItem*>(pOldItem)->checkForUniqueItem( mpDoc );
                             if( pNewItem )
                             {
                                 rAttr.Put( *pNewItem );
-                                delete pNewItem;
                             }
                         }
                         if( rAttr.GetItemState( XATTR_LINEDASH ) == SfxItemState::SET )
                         {
                             const SfxPoolItem* pOldItem = rAttr.GetItem( XATTR_LINEDASH );
-                            SfxPoolItem* pNewItem = static_cast<const XLineDashItem*>(pOldItem)->checkForUniqueItem( mpDoc );
+                            std::unique_ptr<SfxPoolItem> pNewItem = static_cast<const XLineDashItem*>(pOldItem)->checkForUniqueItem( mpDoc );
                             if( pNewItem )
                             {
                                 rAttr.Put( *pNewItem );
-                                delete pNewItem;
                             }
                         }
                         if( rAttr.GetItemState( XATTR_LINESTART ) == SfxItemState::SET )
                         {
                             const SfxPoolItem* pOldItem = rAttr.GetItem( XATTR_LINESTART );
-                            SfxPoolItem* pNewItem = static_cast<const XLineStartItem*>(pOldItem)->checkForUniqueItem( mpDoc );
+                            std::unique_ptr<SfxPoolItem> pNewItem = static_cast<const XLineStartItem*>(pOldItem)->checkForUniqueItem( mpDoc );
                             if( pNewItem )
                             {
                                 rAttr.Put( *pNewItem );
-                                delete pNewItem;
                             }
                         }
                         if( rAttr.GetItemState( XATTR_LINEEND ) == SfxItemState::SET )
                         {
                             const SfxPoolItem* pOldItem = rAttr.GetItem( XATTR_LINEEND );
-                            SfxPoolItem* pNewItem = static_cast<const XLineEndItem*>(pOldItem)->checkForUniqueItem( mpDoc );
+                            std::unique_ptr<SfxPoolItem> pNewItem = static_cast<const XLineEndItem*>(pOldItem)->checkForUniqueItem( mpDoc );
                             if( pNewItem )
                             {
                                 rAttr.Put( *pNewItem );
-                                delete pNewItem;
                             }
                         }
                         if( rAttr.GetItemState( XATTR_FILLGRADIENT ) == SfxItemState::SET )
                         {
                             const SfxPoolItem* pOldItem = rAttr.GetItem( XATTR_FILLGRADIENT );
-                            SfxPoolItem* pNewItem = static_cast<const XFillGradientItem*>(pOldItem)->checkForUniqueItem( mpDoc );
+                            std::unique_ptr<SfxPoolItem> pNewItem = static_cast<const XFillGradientItem*>(pOldItem)->checkForUniqueItem( mpDoc );
                             if( pNewItem )
                             {
                                 rAttr.Put( *pNewItem );
-                                delete pNewItem;
                             }
                         }
                         if( rAttr.GetItemState( XATTR_FILLFLOATTRANSPARENCE ) == SfxItemState::SET )
                         {
                             const SfxPoolItem* pOldItem = rAttr.GetItem( XATTR_FILLFLOATTRANSPARENCE );
-                            SfxPoolItem* pNewItem = static_cast<const XFillFloatTransparenceItem*>(pOldItem)->checkForUniqueItem( mpDoc );
+                            std::unique_ptr<SfxPoolItem> pNewItem = static_cast<const XFillFloatTransparenceItem*>(pOldItem)->checkForUniqueItem( mpDoc );
                             if( pNewItem )
                             {
                                 rAttr.Put( *pNewItem );
-                                delete pNewItem;
                             }
                         }
                         if( rAttr.GetItemState( XATTR_FILLHATCH ) == SfxItemState::SET )
                         {
                             const SfxPoolItem* pOldItem = rAttr.GetItem( XATTR_FILLHATCH );
-                            SfxPoolItem* pNewItem = static_cast<const XFillHatchItem*>(pOldItem)->checkForUniqueItem( mpDoc );
+                            std::unique_ptr<SfxPoolItem> pNewItem = static_cast<const XFillHatchItem*>(pOldItem)->checkForUniqueItem( mpDoc );
                             if( pNewItem )
                             {
                                 rAttr.Put( *pNewItem );
-                                delete pNewItem;
                             }
                         }
 
diff --git a/svx/source/sdr/properties/attributeproperties.cxx b/svx/source/sdr/properties/attributeproperties.cxx
index ae498d03803c..6a706aca8c24 100644
--- a/svx/source/sdr/properties/attributeproperties.cxx
+++ b/svx/source/sdr/properties/attributeproperties.cxx
@@ -298,7 +298,7 @@ namespace sdr
         {
             if(pNewItem)
             {
-                const SfxPoolItem* pResultItem = nullptr;
+                std::unique_ptr<SfxPoolItem> pResultItem;
                 SdrModel& rModel(GetSdrObject().getSdrModelFromSdrObject());
 
                 switch( nWhich )
@@ -351,7 +351,7 @@ namespace sdr
                     mpItemSet->Put(*pResultItem);
 
                     // delete item if it was a generated one
-                    delete pResultItem;
+                    pResultItem.reset();
                 }
                 else
                 {
diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx
index f9b7b8d08c2b..72b947ffb80d 100644
--- a/svx/source/svdraw/svdmodel.cxx
+++ b/svx/source/svdraw/svdmodel.cxx
@@ -1748,7 +1748,7 @@ void SdrModel::MigrateItemSet( const SfxItemSet* pSourceSet, SfxItemSet* pDestSe
         {
             if(SfxItemState::SET == pSourceSet->GetItemState(nWhich, false, &pPoolItem))
             {
-                const SfxPoolItem* pResultItem = nullptr;
+                std::unique_ptr<SfxPoolItem> pResultItem;
 
                 switch( nWhich )
                 {
@@ -1780,7 +1780,7 @@ void SdrModel::MigrateItemSet( const SfxItemSet* pSourceSet, SfxItemSet* pDestSe
                 if( pResultItem )
                 {
                     pDestSet->Put(*pResultItem);
-                    delete pResultItem;
+                    pResultItem.reset();
                 }
                 else
                     pDestSet->Put(*pPoolItem);
diff --git a/svx/source/xoutdev/xattr.cxx b/svx/source/xoutdev/xattr.cxx
index 9f9fed843981..15975dd9cc79 100644
--- a/svx/source/xoutdev/xattr.cxx
+++ b/svx/source/xoutdev/xattr.cxx
@@ -855,7 +855,7 @@ bool XLineDashItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex*
     return static_cast<const XLineDashItem*>(p1)->GetDashValue() == static_cast<const XLineDashItem*>(p2)->GetDashValue();
 }
 
-XLineDashItem* XLineDashItem::checkForUniqueItem( SdrModel* pModel ) const
+std::unique_ptr<XLineDashItem> XLineDashItem::checkForUniqueItem( SdrModel* pModel ) const
 {
     if( pModel )
     {
@@ -866,7 +866,7 @@ XLineDashItem* XLineDashItem::checkForUniqueItem( SdrModel* pModel ) const
 
         // if the given name is not valid, replace it!
         if( aUniqueName != GetName() )
-            return new XLineDashItem( aUniqueName, aDash );
+            return o3tl::make_unique<XLineDashItem>( aUniqueName, aDash );
     }
 
     return nullptr;
@@ -1062,11 +1062,11 @@ bool XLineStartItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
 /** this function searches in both the models pool and the styles pool for XLineStartItem
     and XLineEndItem with the same value or name and returns an item with the value of
     this item and a unique name for an item with this value. */
-XLineStartItem* XLineStartItem::checkForUniqueItem( SdrModel* pModel ) const
+std::unique_ptr<XLineStartItem> XLineStartItem::checkForUniqueItem( SdrModel* pModel ) const
 {
     if( pModel )
     {
-        XLineStartItem* pTempItem = nullptr;
+        std::unique_ptr<XLineStartItem> pTempItem;
         const XLineStartItem* pLineStartItem = this;
 
         OUString aUniqueName( GetName() );
@@ -1078,7 +1078,7 @@ XLineStartItem* XLineStartItem::checkForUniqueItem( SdrModel* pModel ) const
                 return nullptr;
 
             // force empty name for empty polygons
-            return new XLineStartItem( "", maPolyPolygon );
+            return o3tl::make_unique<XLineStartItem>( "", maPolyPolygon );
         }
 
         if( maPolyPolygon.count() > 1 )
@@ -1089,8 +1089,8 @@ XLineStartItem* XLineStartItem::checkForUniqueItem( SdrModel* pModel ) const
                 // force a closed polygon
                 basegfx::B2DPolyPolygon aNew(maPolyPolygon);
                 aNew.setClosed(true);
-                pTempItem = new XLineStartItem( aUniqueName, aNew );
-                pLineStartItem = pTempItem;
+                pTempItem.reset(new XLineStartItem( aUniqueName, aNew ));
+                pLineStartItem = pTempItem.get();
             }
         }
 
@@ -1266,7 +1266,7 @@ XLineStartItem* XLineStartItem::checkForUniqueItem( SdrModel* pModel ) const
             }
             else
             {
-                return new XLineStartItem( aUniqueName, maPolyPolygon );
+                return o3tl::make_unique<XLineStartItem>( aUniqueName, maPolyPolygon );
             }
         }
     }
@@ -1313,11 +1313,11 @@ bool XLineEndItem::operator==(const SfxPoolItem& rItem) const
 /** this function searches in both the models pool and the styles pool for XLineStartItem
     and XLineEndItem with the same value or name and returns an item with the value of
     this item and a unique name for an item with this value. */
-XLineEndItem* XLineEndItem::checkForUniqueItem( SdrModel* pModel ) const
+std::unique_ptr<XLineEndItem> XLineEndItem::checkForUniqueItem( SdrModel* pModel ) const
 {
     if( pModel )
     {
-        XLineEndItem* pTempItem = nullptr;
+        std::unique_ptr<XLineEndItem> pTempItem;
         const XLineEndItem* pLineEndItem = this;
 
         OUString aUniqueName( GetName() );
@@ -1329,7 +1329,7 @@ XLineEndItem* XLineEndItem::checkForUniqueItem( SdrModel* pModel ) const
                 return nullptr;
 
             // force empty name for empty polygons
-            return new XLineEndItem( "", maPolyPolygon );
+            return o3tl::make_unique<XLineEndItem>( "", maPolyPolygon );
         }
 
         if( maPolyPolygon.count() > 1 )
@@ -1340,8 +1340,8 @@ XLineEndItem* XLineEndItem::checkForUniqueItem( SdrModel* pModel ) const
                 // force a closed polygon
                 basegfx::B2DPolyPolygon aNew(maPolyPolygon);
                 aNew.setClosed(true);
-                pTempItem = new XLineEndItem( aUniqueName, aNew );
-                pLineEndItem = pTempItem;
+                pTempItem.reset(new XLineEndItem( aUniqueName, aNew ));
+                pLineEndItem = pTempItem.get();
             }
         }
 
@@ -1517,7 +1517,7 @@ XLineEndItem* XLineEndItem::checkForUniqueItem( SdrModel* pModel ) const
             }
             else
             {
-                return new XLineEndItem( aUniqueName, maPolyPolygon );
+                return o3tl::make_unique<XLineEndItem>( aUniqueName, maPolyPolygon );
             }
         }
     }
@@ -2253,7 +2253,7 @@ bool XFillGradientItem::CompareValueFunc( const NameOrIndex* p1, const NameOrInd
     return static_cast<const XFillGradientItem*>(p1)->GetGradientValue() == static_cast<const XFillGradientItem*>(p2)->GetGradientValue();
 }
 
-XFillGradientItem* XFillGradientItem::checkForUniqueItem( SdrModel* pModel ) const
+std::unique_ptr<XFillGradientItem> XFillGradientItem::checkForUniqueItem( SdrModel* pModel ) const
 {
     if( pModel )
     {
@@ -2264,7 +2264,7 @@ XFillGradientItem* XFillGradientItem::checkForUniqueItem( SdrModel* pModel ) con
 
         // if the given name is not valid, replace it!
         if( aUniqueName != GetName() )
-            return new XFillGradientItem( aUniqueName, aGradient, Which() );
+            return o3tl::make_unique<XFillGradientItem>( aUniqueName, aGradient, Which() );
     }
 
     return nullptr;
@@ -2343,7 +2343,7 @@ bool XFillFloatTransparenceItem::CompareValueFunc( const NameOrIndex* p1, const
             static_cast<const XFillFloatTransparenceItem*>(p1)->GetGradientValue()  == static_cast<const XFillFloatTransparenceItem*>(p2)->GetGradientValue();
 }
 
-XFillFloatTransparenceItem* XFillFloatTransparenceItem::checkForUniqueItem( SdrModel* pModel ) const
+std::unique_ptr<XFillFloatTransparenceItem> XFillFloatTransparenceItem::checkForUniqueItem( SdrModel* pModel ) const
 {
     // #85953# unique name only necessary when enabled
     if(IsEnabled())
@@ -2360,7 +2360,7 @@ XFillFloatTransparenceItem* XFillFloatTransparenceItem::checkForUniqueItem( SdrM
             // if the given name is not valid, replace it!
             if( aUniqueName != GetName() )
             {
-                return new XFillFloatTransparenceItem( aUniqueName, GetGradientValue(), true );
+                return o3tl::make_unique<XFillFloatTransparenceItem>( aUniqueName, GetGradientValue(), true );
             }
         }
     }
@@ -2369,7 +2369,7 @@ XFillFloatTransparenceItem* XFillFloatTransparenceItem::checkForUniqueItem( SdrM
         // #85953# if disabled, force name to empty string
         if( !GetName().isEmpty() )
         {
-            return new XFillFloatTransparenceItem(OUString(), GetGradientValue(), false);
+            return o3tl::make_unique<XFillFloatTransparenceItem>(OUString(), GetGradientValue(), false);
         }
     }
 
@@ -2605,7 +2605,7 @@ bool XFillHatchItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex*
     return static_cast<const XFillHatchItem*>(p1)->GetHatchValue() == static_cast<const XFillHatchItem*>(p2)->GetHatchValue();
 }
 
-XFillHatchItem* XFillHatchItem::checkForUniqueItem( SdrModel* pModel ) const
+std::unique_ptr<XFillHatchItem> XFillHatchItem::checkForUniqueItem( SdrModel* pModel ) const
 {
     if( pModel )
     {
@@ -2616,7 +2616,7 @@ XFillHatchItem* XFillHatchItem::checkForUniqueItem( SdrModel* pModel ) const
 
         // if the given name is not valid, replace it!
         if( aUniqueName != GetName() )
-            return new XFillHatchItem( aUniqueName, aHatch );
+            return o3tl::make_unique<XFillHatchItem>( aUniqueName, aHatch );
     }
 
     return nullptr;
diff --git a/svx/source/xoutdev/xattrbmp.cxx b/svx/source/xoutdev/xattrbmp.cxx
index 262870a8ad8b..60865b03fcd9 100644
--- a/svx/source/xoutdev/xattrbmp.cxx
+++ b/svx/source/xoutdev/xattrbmp.cxx
@@ -19,6 +19,7 @@
 
 #include <com/sun/star/awt/XBitmap.hpp>
 #include <com/sun/star/graphic/XGraphic.hpp>
+#include <o3tl/make_unique.hxx>
 #include <tools/stream.hxx>
 #include <vcl/window.hxx>
 #include <vcl/virdev.hxx>
@@ -317,7 +318,7 @@ bool XFillBitmapItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex
     return aGraphicObjectA == aGraphicObjectB;
 }
 
-XFillBitmapItem* XFillBitmapItem::checkForUniqueItem( SdrModel* pModel ) const
+std::unique_ptr<XFillBitmapItem> XFillBitmapItem::checkForUniqueItem( SdrModel* pModel ) const
 {
     if( pModel )
     {
@@ -332,7 +333,7 @@ XFillBitmapItem* XFillBitmapItem::checkForUniqueItem( SdrModel* pModel ) const
         // if the given name is not valid, replace it!
         if( aUniqueName != GetName() )
         {
-            return new XFillBitmapItem(aUniqueName, maGraphicObject);
+            return o3tl::make_unique<XFillBitmapItem>(aUniqueName, maGraphicObject);
         }
     }
 
diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx
index cdd65c77f6e5..50e8594e4339 100644
--- a/sw/source/core/doc/docfly.cxx
+++ b/sw/source/core/doc/docfly.cxx
@@ -498,7 +498,7 @@ void SwDoc::CheckForUniqueItemForLineFillNameOrIndex(SfxItemSet& rSet)
     {
         if (IsInvalidItem(pItem))
             continue;
-        const SfxPoolItem* pResult = nullptr;
+        std::unique_ptr<SfxPoolItem> pResult;
 
         switch(pItem->Which())
         {
@@ -542,7 +542,6 @@ void SwDoc::CheckForUniqueItemForLineFillNameOrIndex(SfxItemSet& rSet)
         if(pResult)
         {
             rSet.Put(*pResult);
-            delete pResult;
         }
     }
 }


More information about the Libreoffice-commits mailing list