sc/inc/dpobject.hxx                           |   18 +++---
 sc/source/core/data/dpobject.cxx              |   67 +++++++++++---------------
 sd/source/ui/annotations/annotationwindow.cxx |   14 ++---
 sd/source/ui/annotations/annotationwindow.hxx |    8 +--
 4 files changed, 49 insertions(+), 58 deletions(-)

New commits:
commit 8ce072a7dcc14750cf50a76a5da49cd84412314c
Author: Noel Grandin <noel.gran...@collabora.co.uk>
Date:   Wed Jun 20 17:03:48 2018 +0200

    loplugin:useuniqueptr in ScDPObject
    
    Change-Id: I6e1f44d4e59ef15f08692e97ad90c3ffc23cdc8c
    Reviewed-on: https://gerrit.libreoffice.org/56200
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx
index 2e02ac88eed8..ee2efd74f00c 100644
--- a/sc/inc/dpobject.hxx
+++ b/sc/inc/dpobject.hxx
@@ -81,17 +81,17 @@ class SC_DLLPUBLIC ScDPObject
 private:
     ScDocument*             pDoc;
                                             // settings
-    ScDPSaveData*           pSaveData;
+    std::unique_ptr<ScDPSaveData> pSaveData;
     OUString aTableName;
     OUString aTableTag;
     ScRange                 aOutRange;
-    ScSheetSourceDesc*      pSheetDesc;     //  for sheet data
-    ScImportSourceDesc*     pImpDesc;       //  for database data
-    ScDPServiceDesc*        pServDesc;      //  for external service
+    std::unique_ptr<ScSheetSourceDesc>  pSheetDesc;     //  for sheet data
+    std::unique_ptr<ScImportSourceDesc> pImpDesc;       //  for database data
+    std::unique_ptr<ScDPServiceDesc> pServDesc;      //  for external service
     std::shared_ptr<ScDPTableData>  mpTableData;
                                             // cached data
     css::uno::Reference<css::sheet::XDimensionsSupplier> xSource;
-    ScDPOutput*             pOutput;
+    std::unique_ptr<ScDPOutput> pOutput;
     long                    nHeaderRows;    // page fields plus filter button
     bool                    mbHeaderLayout:1;  // true : grid, false : standard
     bool                    bAllowMove:1;
@@ -129,7 +129,7 @@ public:
     ScRange GetOutputRangeByType( sal_Int32 nType ) const;
 
     void                SetSaveData(const ScDPSaveData& rData);
-    ScDPSaveData*       GetSaveData() const     { return pSaveData; }
+    ScDPSaveData*       GetSaveData() const     { return pSaveData.get(); }
 
     void                SetOutRange(const ScRange& rRange);
     const ScRange&      GetOutRange() const;
@@ -144,9 +144,9 @@ public:
     void                WriteSourceDataTo( ScDPObject& rDest ) const;
     void                WriteTempDataTo( ScDPObject& rDest ) const;
 
-    const ScSheetSourceDesc* GetSheetDesc() const   { return pSheetDesc; }
-    const ScImportSourceDesc* GetImportSourceDesc() const   { return pImpDesc; 
}
-    const ScDPServiceDesc* GetDPServiceDesc() const { return pServDesc; }
+    const ScSheetSourceDesc* GetSheetDesc() const   { return pSheetDesc.get(); 
}
+    const ScImportSourceDesc* GetImportSourceDesc() const   { return 
pImpDesc.get(); }
+    const ScDPServiceDesc* GetDPServiceDesc() const { return pServDesc.get(); }
 
     css::uno::Reference<css::sheet::XDimensionsSupplier> const & GetSource();
 
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index eebe2f5f10ac..eaa827e837ac 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -340,13 +340,13 @@ ScDPObject::ScDPObject(const ScDPObject& r) :
     mbEnableGetPivotData(r.mbEnableGetPivotData)
 {
     if (r.pSaveData)
-        pSaveData = new ScDPSaveData(*r.pSaveData);
+        pSaveData.reset( new ScDPSaveData(*r.pSaveData) );
     if (r.pSheetDesc)
-        pSheetDesc = new ScSheetSourceDesc(*r.pSheetDesc);
+        pSheetDesc.reset( new ScSheetSourceDesc(*r.pSheetDesc) );
     if (r.pImpDesc)
-        pImpDesc = new ScImportSourceDesc(*r.pImpDesc);
+        pImpDesc.reset( new ScImportSourceDesc(*r.pImpDesc) );
     if (r.pServDesc)
-        pServDesc = new ScDPServiceDesc(*r.pServDesc);
+        pServDesc.reset( new ScDPServiceDesc(*r.pServDesc) );
     // xSource (and pOutput) is not copied
 }
 
@@ -370,13 +370,13 @@ ScDPObject& ScDPObject::operator= (const ScDPObject& r)
     mbEnableGetPivotData = r.mbEnableGetPivotData;
 
     if (r.pSaveData)
-        pSaveData = new ScDPSaveData(*r.pSaveData);
+        pSaveData.reset( new ScDPSaveData(*r.pSaveData) );
     if (r.pSheetDesc)
-        pSheetDesc = new ScSheetSourceDesc(*r.pSheetDesc);
+        pSheetDesc.reset( new ScSheetSourceDesc(*r.pSheetDesc) );
     if (r.pImpDesc)
-        pImpDesc = new ScImportSourceDesc(*r.pImpDesc);
+        pImpDesc.reset( new ScImportSourceDesc(*r.pImpDesc) );
     if (r.pServDesc)
-        pServDesc = new ScDPServiceDesc(*r.pServDesc);
+        pServDesc.reset( new ScDPServiceDesc(*r.pServDesc) );
 
     return *this;
 }
@@ -393,10 +393,9 @@ void ScDPObject::SetAllowMove(bool bSet)
 
 void ScDPObject::SetSaveData(const ScDPSaveData& rData)
 {
-    if ( pSaveData != &rData )      // API implementation modifies the 
original SaveData object
+    if ( pSaveData.get() != &rData )      // API implementation modifies the 
original SaveData object
     {
-        delete pSaveData;
-        pSaveData = new ScDPSaveData( rData );
+        pSaveData.reset( new ScDPSaveData( rData ) );
     }
 
     InvalidateData();       // re-init source from SaveData
@@ -425,11 +424,10 @@ void ScDPObject::SetSheetDesc(const ScSheetSourceDesc& 
rDesc)
     if ( pSheetDesc && rDesc == *pSheetDesc )
         return;             // nothing to do
 
-    DELETEZ( pImpDesc );
-    DELETEZ( pServDesc );
+    pImpDesc.reset();
+    pServDesc.reset();
 
-    delete pSheetDesc;
-    pSheetDesc = new ScSheetSourceDesc(rDesc);
+    pSheetDesc.reset( new ScSheetSourceDesc(rDesc) );
 
     //  make valid QueryParam
 
@@ -450,11 +448,10 @@ void ScDPObject::SetImportDesc(const ScImportSourceDesc& 
rDesc)
     if ( pImpDesc && rDesc == *pImpDesc )
         return;             // nothing to do
 
-    DELETEZ( pSheetDesc );
-    DELETEZ( pServDesc );
+    pSheetDesc.reset();
+    pServDesc.reset();
 
-    delete pImpDesc;
-    pImpDesc = new ScImportSourceDesc(rDesc);
+    pImpDesc.reset( new ScImportSourceDesc(rDesc) );
 
     ClearTableData();      // new source must be created
 }
@@ -464,11 +461,10 @@ void ScDPObject::SetServiceData(const ScDPServiceDesc& 
rDesc)
     if ( pServDesc && rDesc == *pServDesc )
         return;             // nothing to do
 
-    DELETEZ( pSheetDesc );
-    DELETEZ( pImpDesc );
+    pSheetDesc.reset();
+    pImpDesc.reset();
 
-    delete pServDesc;
-    pServDesc = new ScDPServiceDesc(rDesc);
+    pServDesc.reset( new ScDPServiceDesc(rDesc) );
 
     ClearTableData();      // new source must be created
 }
@@ -536,7 +532,7 @@ void ScDPObject::CreateOutput()
     if (!pOutput)
     {
         bool bFilterButton = IsSheetData() && pSaveData && 
pSaveData->GetFilterButton();
-        pOutput = new ScDPOutput( pDoc, xSource, aOutRange.aStart, 
bFilterButton );
+        pOutput.reset( new ScDPOutput( pDoc, xSource, aOutRange.aStart, 
bFilterButton ) );
         pOutput->SetHeaderLayout ( mbHeaderLayout );
 
         long nOldRows = nHeaderRows;
@@ -709,7 +705,7 @@ ScDPTableData* ScDPObject::GetTableData()
             if (!pSheetDesc)
             {
                 OSL_FAIL("no source descriptor");
-                pSheetDesc = new ScSheetSourceDesc(pDoc);     // dummy defaults
+                pSheetDesc.reset( new ScSheetSourceDesc(pDoc) );     // dummy 
defaults
             }
 
             {
@@ -744,7 +740,7 @@ void ScDPObject::CreateObjects()
 {
     if (!xSource.is())
     {
-        DELETEZ( pOutput );     // not valid when xSource is changed
+        pOutput.reset();     // not valid when xSource is changed
 
         if ( pServDesc )
         {
@@ -773,7 +769,7 @@ void ScDPObject::CreateObjects()
     }
     else if (bSettingsChanged)
     {
-        DELETEZ( pOutput );     // not valid when xSource is changed
+        pOutput.reset();     // not valid when xSource is changed
 
         uno::Reference<util::XRefreshable> xRef( xSource, uno::UNO_QUERY );
         if (xRef.is())
@@ -801,16 +797,11 @@ void ScDPObject::InvalidateData()
 
 void ScDPObject::Clear()
 {
-    delete pOutput;
-    delete pSaveData;
-    delete pSheetDesc;
-    delete pImpDesc;
-    delete pServDesc;
-    pOutput = nullptr;
-    pSaveData = nullptr;
-    pSheetDesc = nullptr;
-    pImpDesc = nullptr;
-    pServDesc = nullptr;
+    pOutput.reset();
+    pSaveData.reset();
+    pSheetDesc.reset();
+    pImpDesc.reset();
+    pServDesc.reset();
     ClearTableData();
 }
 
@@ -2094,7 +2085,7 @@ void ScDPObject::ToggleDetails(const 
DataPilotTableHeaderData& rElemDesc, ScDPOb
     //TODO: use Hierarchy and Level in SaveData !!!!
 
     //  modify pDestObj if set, this object otherwise
-    ScDPSaveData* pModifyData = pDestObj ? ( pDestObj->pSaveData ) : pSaveData;
+    ScDPSaveData* pModifyData = pDestObj ? ( pDestObj->pSaveData.get() ) : 
pSaveData.get();
     OSL_ENSURE( pModifyData, "no data?" );
     if ( pModifyData )
     {
commit 5652727f2bfa2bce77e83de718e3f599fe5eebcd
Author: Noel Grandin <noel.gran...@collabora.co.uk>
Date:   Wed Jun 20 16:39:07 2018 +0200

    loplugin:useuniqueptr in AnnotationWindow
    
    Change-Id: I3ea0b0ed28e85e7f8cf00e73b6698a5773c886ba
    Reviewed-on: https://gerrit.libreoffice.org/56197
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sd/source/ui/annotations/annotationwindow.cxx 
b/sd/source/ui/annotations/annotationwindow.cxx
index 78ed4d898651..186728414c66 100644
--- a/sd/source/ui/annotations/annotationwindow.cxx
+++ b/sd/source/ui/annotations/annotationwindow.cxx
@@ -285,8 +285,8 @@ AnnotationWindow::~AnnotationWindow()
 void AnnotationWindow::dispose()
 {
     mpMeta.disposeAndClear();
-    delete mpOutlinerView;
-    delete mpOutliner;
+    mpOutlinerView.reset();
+    mpOutliner.reset();
     mpOutliner = nullptr;
     mpVScrollbar.disposeAndClear();
     mpTextWindow.disposeAndClear();
@@ -316,8 +316,8 @@ void AnnotationWindow::InitControls()
     aSettings.SetStyleSettings(aStyleSettings);
     mpMeta->SetSettings(aSettings);
 
-    mpOutliner = new ::Outliner(GetAnnotationPool(),OutlinerMode::TextObject);
-    SdDrawDocument::SetCalcFieldValueHdl( mpOutliner );
+    mpOutliner.reset( new 
::Outliner(GetAnnotationPool(),OutlinerMode::TextObject) );
+    SdDrawDocument::SetCalcFieldValueHdl( mpOutliner.get() );
     mpOutliner->SetUpdateMode( true );
     Rescale();
 
@@ -328,9 +328,9 @@ void AnnotationWindow::InitControls()
     }
 
     mpTextWindow->EnableRTL( false );
-    mpOutlinerView = new OutlinerView ( mpOutliner, mpTextWindow );
-    mpOutliner->InsertView(mpOutlinerView );
-    mpTextWindow->SetOutlinerView(mpOutlinerView);
+    mpOutlinerView.reset( new OutlinerView ( mpOutliner.get(), mpTextWindow ) 
);
+    mpOutliner->InsertView(mpOutlinerView.get() );
+    mpTextWindow->SetOutlinerView(mpOutlinerView.get());
     mpOutlinerView->SetOutputArea( PixelToLogic( ::tools::Rectangle(0,0,1,1) ) 
);
 
     //create Scrollbars
diff --git a/sd/source/ui/annotations/annotationwindow.hxx 
b/sd/source/ui/annotations/annotationwindow.hxx
index 14f61f2d3520..1cc15f36b1e8 100644
--- a/sd/source/ui/annotations/annotationwindow.hxx
+++ b/sd/source/ui/annotations/annotationwindow.hxx
@@ -78,8 +78,8 @@ class AnnotationWindow : public FloatingWindow
         DrawDocShell*           mpDocShell;
         SdDrawDocument*         mpDoc;
 
-        OutlinerView*           mpOutlinerView;
-        ::Outliner*             mpOutliner;
+        std::unique_ptr<OutlinerView> mpOutlinerView;
+        std::unique_ptr<::Outliner>   mpOutliner;
         VclPtr<ScrollBar>       mpVScrollbar;
         css::uno::Reference< css::office::XAnnotation > mxAnnotation;
         bool                    mbReadonly;
@@ -105,8 +105,8 @@ class AnnotationWindow : public FloatingWindow
         void ExecuteSlot( sal_uInt16 nSID );
 
         DrawDocShell*           DocShell()      { return mpDocShell; }
-        OutlinerView*           getView()       { return mpOutlinerView; }
-        ::Outliner*             Engine()        { return mpOutliner; }
+        OutlinerView*           getView()       { return mpOutlinerView.get(); 
}
+        ::Outliner*             Engine()        { return mpOutliner.get(); }
         SdDrawDocument*         Doc()           { return mpDoc; }
 
         long            GetPostItTextHeight();
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to