[Libreoffice-commits] core.git: 2 commits - sc/inc sc/source sw/inc sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Jul 24 06:35:30 UTC 2018


 sc/inc/document.hxx                |    6 +++---
 sc/inc/validat.hxx                 |    8 ++++----
 sc/source/core/data/documen2.cxx   |   20 ++++----------------
 sc/source/core/data/documen4.cxx   |    8 ++++----
 sc/source/core/data/validat.cxx    |    6 +++---
 sw/inc/modcfg.hxx                  |    4 ++--
 sw/source/uibase/config/modcfg.cxx |   12 ++++++------
 7 files changed, 26 insertions(+), 38 deletions(-)

New commits:
commit 257b099bc4d904ebd4fae0ccd668de5ce7570d18
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Jul 23 15:20:38 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Jul 24 08:35:16 2018 +0200

    loplugin:useuniqueptr in SwInsertConfig
    
    Change-Id: I5f39956e529b98f4114139b8c3ba1391e45440ef
    Reviewed-on: https://gerrit.libreoffice.org/57876
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sw/inc/modcfg.hxx b/sw/inc/modcfg.hxx
index f4d82aaf2be3..cfdd94814231 100644
--- a/sw/inc/modcfg.hxx
+++ b/sw/inc/modcfg.hxx
@@ -118,8 +118,8 @@ class SwInsertConfig : public utl::ConfigItem
 {
     friend class SwModuleOptions;
 
-    InsCaptionOptArr*   pCapOptions;
-    InsCaptionOpt*      pOLEMiscOpt;
+    std::unique_ptr<InsCaptionOptArr> pCapOptions;
+    std::unique_ptr<InsCaptionOpt>    pOLEMiscOpt;
 
     SvGlobalName        aGlobalNames[5];
 
diff --git a/sw/source/uibase/config/modcfg.cxx b/sw/source/uibase/config/modcfg.cxx
index 3d73202fdb70..3a0b41f3a1b9 100644
--- a/sw/source/uibase/config/modcfg.cxx
+++ b/sw/source/uibase/config/modcfg.cxx
@@ -77,7 +77,7 @@ const InsCaptionOpt* SwModuleOptions::GetCapOption(
             for( sal_uInt16 nId = 0; nId <= GLOB_NAME_CHART && !bFound; nId++)
                 bFound = *pOleId == aInsertConfig.aGlobalNames[nId  ];
             if(!bFound)
-                return aInsertConfig.pOLEMiscOpt;
+                return aInsertConfig.pOLEMiscOpt.get();
         }
         return aInsertConfig.pCapOptions->Find(eType, pOleId);
     }
@@ -103,7 +103,7 @@ bool SwModuleOptions::SetCapOption(bool bHTML, const InsCaptionOpt* pOpt)
                 if(aInsertConfig.pOLEMiscOpt)
                     *aInsertConfig.pOLEMiscOpt = *pOpt;
                 else
-                    aInsertConfig.pOLEMiscOpt = new InsCaptionOpt(*pOpt);
+                    aInsertConfig.pOLEMiscOpt.reset(new InsCaptionOpt(*pOpt));
             }
         }
 
@@ -596,15 +596,15 @@ SwInsertConfig::SwInsertConfig(bool bWeb) :
     aGlobalNames[GLOB_NAME_MATH   ] = SvGlobalName(SO3_SM_CLASSID);
     aGlobalNames[GLOB_NAME_CHART  ] = SvGlobalName(SO3_SCH_CLASSID);
     if(!bIsWeb)
-        pCapOptions = new InsCaptionOptArr;
+        pCapOptions.reset(new InsCaptionOptArr);
 
     Load();
 }
 
 SwInsertConfig::~SwInsertConfig()
 {
-    delete pCapOptions;
-    delete pOLEMiscOpt;
+    pCapOptions.reset();
+    pOLEMiscOpt.reset();
 }
 
 static void lcl_WriteOpt(const InsCaptionOpt& rOpt, Any* pValues, sal_Int32 nProp, sal_Int32 nOffset)
@@ -1072,7 +1072,7 @@ void SwInsertConfig::Load()
                 case INS_PROP_CAP_OBJECT_OLEMISC_APPLYATTRIBUTES:
                     if(!pOLEMiscOpt)
                     {
-                        pOLEMiscOpt = new InsCaptionOpt(OLE_CAP);
+                        pOLEMiscOpt.reset(new InsCaptionOpt(OLE_CAP));
                     }
                     lcl_ReadOpt(*pOLEMiscOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_OLEMISC_ENABLE);
                 break;
commit 63ba8ffa5c390c04e22a74015a64cefc2bf228ea
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Jul 23 14:22:30 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Jul 24 08:35:05 2018 +0200

    loplugin:useuniqueptr in ScValidationDataList
    
    Change-Id: Icbf8eb814e7d3bd57e78d2d1a97eb44bbfd2a432
    Reviewed-on: https://gerrit.libreoffice.org/57874
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 4fcee74748ca..7d34bd38a6a4 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -357,7 +357,7 @@ private:
     VclPtr<VirtualDevice> mpVirtualDevice_100th_mm;
     std::unique_ptr<ScDrawLayer> mpDrawLayer;           // SdrModel
     rtl::Reference<XColorList> pColorList;
-    ScValidationDataList* pValidationList;              // validity
+    std::unique_ptr<ScValidationDataList> pValidationList;              // validity
     SvNumberFormatterIndexTable* pFormatExchangeList;    // for application of number formats
     TableContainer maTabs;
     std::vector<OUString> maTabNames;               // for undo document, we need the information tab name <-> index
@@ -1703,8 +1703,8 @@ public:
 
     SC_DLLPUBLIC ScConditionalFormatList*   GetCondFormList( SCTAB nTab ) const;
 
-    const ScValidationDataList*             GetValidationList() const { return pValidationList;}
-    ScValidationDataList*                   GetValidationList() { return pValidationList;}
+    const ScValidationDataList*             GetValidationList() const { return pValidationList.get();}
+    ScValidationDataList*                   GetValidationList() { return pValidationList.get();}
 
     SC_DLLPUBLIC void           ApplyAttr( SCCOL nCol, SCROW nRow, SCTAB nTab,
                                            const SfxPoolItem& rAttr );
diff --git a/sc/inc/validat.hxx b/sc/inc/validat.hxx
index dc694069fca0..945cd9e6bc0e 100644
--- a/sc/inc/validat.hxx
+++ b/sc/inc/validat.hxx
@@ -190,13 +190,13 @@ private:
 
 struct CompareScValidationDataPtr
 {
-  bool operator()( ScValidationData* const& lhs, ScValidationData* const& rhs ) const { return (*lhs)<(*rhs); }
+  bool operator()( std::unique_ptr<ScValidationData> const& lhs, std::unique_ptr<ScValidationData> const& rhs ) const { return (*lhs)<(*rhs); }
 };
 
 class ScValidationDataList
 {
 private:
-    typedef std::set<ScValidationData*, CompareScValidationDataPtr> ScValidationDataListDataType;
+    typedef std::set<std::unique_ptr<ScValidationData>, CompareScValidationDataPtr> ScValidationDataListDataType;
     ScValidationDataListDataType maData;
 
 public:
@@ -212,8 +212,8 @@ public:
     iterator end();
     const_iterator end() const;
 
-    void InsertNew( ScValidationData* pNew )
-                { if (!maData.insert(pNew).second) delete pNew; }
+    void InsertNew( std::unique_ptr<ScValidationData> pNew )
+                { maData.insert(std::move(pNew)); }
 
     ScValidationData* GetData( sal_uInt32 nKey );
 
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index f3f63f2811f3..082a5e164532 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -405,13 +405,7 @@ ScDocument::~ScDocument()
 
     Clear( true );              // true = from destructor (needed for SdrModel::ClearModel)
 
-    if (pValidationList)
-    {
-        for( ScValidationDataList::iterator it = pValidationList->begin(); it != pValidationList->end(); ++it )
-            delete *it;
-        pValidationList->clear();
-        DELETEZ(pValidationList);
-    }
+    pValidationList.reset();
     pRangeName.reset();
     pDBCollection.reset();
     pSelectionAttr.reset();
@@ -455,13 +449,7 @@ void ScDocument::InitClipPtrs( ScDocument* pSourceDoc )
 
     ScMutationGuard aGuard(this, ScMutationGuardFlags::CORE);
 
-    if (pValidationList)
-    {
-        for(ScValidationDataList::iterator it = pValidationList->begin(); it != pValidationList->end(); ++it )
-            delete *it;
-        pValidationList->clear();
-        DELETEZ(pValidationList);
-    }
+    pValidationList.reset();
 
     Clear();
 
@@ -469,9 +457,9 @@ void ScDocument::InitClipPtrs( ScDocument* pSourceDoc )
 
     //  conditional Formats / validations
     // TODO: Copy Templates?
-    const ScValidationDataList* pSourceValid = pSourceDoc->pValidationList;
+    const ScValidationDataList* pSourceValid = pSourceDoc->pValidationList.get();
     if ( pSourceValid )
-        pValidationList = new ScValidationDataList(this, *pSourceValid);
+        pValidationList.reset(new ScValidationDataList(this, *pSourceValid));
 
     // store Links in Stream
     pClipData.reset();
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index 3c1dab1ff103..7e7372a40b9d 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -744,13 +744,13 @@ sal_uLong ScDocument::AddValidationEntry( const ScValidationData& rNew )
     if (!pValidationList)
     {
         ScMutationGuard aGuard(this, ScMutationGuardFlags::CORE);
-        pValidationList = new ScValidationDataList;
+        pValidationList.reset(new ScValidationDataList);
     }
 
     sal_uLong nMax = 0;
     for( ScValidationDataList::iterator it = pValidationList->begin(); it != pValidationList->end(); ++it )
     {
-        const ScValidationData* pData = *it;
+        const ScValidationData* pData = it->get();
         sal_uLong nKey = pData->GetKey();
         if ( pData->EqualEntries( rNew ) )
             return nKey;
@@ -761,10 +761,10 @@ sal_uLong ScDocument::AddValidationEntry( const ScValidationData& rNew )
     // might be called from ScPatternAttr::PutInPool; thus clone (real copy)
 
     sal_uLong nNewKey = nMax + 1;
-    ScValidationData* pInsert = rNew.Clone(this);
+    std::unique_ptr<ScValidationData> pInsert(rNew.Clone(this));
     pInsert->SetKey( nNewKey );
     ScMutationGuard aGuard(this, ScMutationGuardFlags::CORE);
-    pValidationList->InsertNew( pInsert );
+    pValidationList->InsertNew( std::move(pInsert) );
     return nNewKey;
 }
 
diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx
index 97c9effbb954..9736d74ac00a 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -966,7 +966,7 @@ ScValidationDataList::ScValidationDataList(const ScValidationDataList& rList)
 
     for (const_iterator it = rList.begin(); it != rList.end(); ++it)
     {
-        InsertNew( (*it)->Clone() );
+        InsertNew( std::unique_ptr<ScValidationData>((*it)->Clone()) );
     }
 
     //TODO: faster insert for sorted entries from rList ???
@@ -979,7 +979,7 @@ ScValidationDataList::ScValidationDataList(ScDocument* pNewDoc,
 
     for (const_iterator it = rList.begin(); it != rList.end(); ++it)
     {
-        InsertNew( (*it)->Clone(pNewDoc) );
+        InsertNew( std::unique_ptr<ScValidationData>((*it)->Clone(pNewDoc)) );
     }
 
     //TODO: faster insert for sorted entries from rList ???
@@ -991,7 +991,7 @@ ScValidationData* ScValidationDataList::GetData( sal_uInt32 nKey )
 
     for( iterator it = begin(); it != end(); ++it )
         if( (*it)->GetKey() == nKey )
-            return *it;
+            return it->get();
 
     OSL_FAIL("ScValidationDataList: Entry not found");
     return nullptr;


More information about the Libreoffice-commits mailing list