sc/inc/dbdata.hxx                                       |    2 +-
 sc/qa/unit/dataproviders_test.cxx                       |    8 ++++----
 sc/qa/unit/ucalc_formula.cxx                            |   14 +++++++-------
 sc/qa/unit/ucalc_sharedformula.cxx                      |    8 ++++----
 sc/source/core/data/formulacell.cxx                     |    2 +-
 sc/source/core/tool/dbdata.cxx                          |    4 ++--
 sc/source/filter/xml/xmldrani.cxx                       |    2 +-
 sc/source/ui/Accessibility/AccessiblePageHeaderArea.cxx |    2 +-
 sc/source/ui/dbgui/dbnamdlg.cxx                         |    6 +++---
 sc/source/ui/docshell/dbdocfun.cxx                      |    6 +++---
 sc/source/ui/docshell/docsh5.cxx                        |    2 +-
 sc/source/ui/miscdlgs/dataproviderdlg.cxx               |    2 +-
 12 files changed, 29 insertions(+), 29 deletions(-)

New commits:
commit 98dd271c7228a4cf03a995d98eba8a1d64ad92f8
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Fri Oct 5 12:18:05 2018 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Oct 8 11:58:00 2018 +0200

    use more std::unique_ptr in ScDBCollection::NamedDBs
    
    Change-Id: I5825208435fd179e9515e731a24a6e5bf1c94431
    Reviewed-on: https://gerrit.libreoffice.org/61436
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sc/inc/dbdata.hxx b/sc/inc/dbdata.hxx
index ab0cf85b9cb4..9a260b4e8390 100644
--- a/sc/inc/dbdata.hxx
+++ b/sc/inc/dbdata.hxx
@@ -262,7 +262,7 @@ public:
             Deletes p if it could not be inserted, i.e. duplicate name.
             @return <TRUE/> if inserted, else <FALSE/>.
          */
-        bool insert(ScDBData* p);
+        bool insert(std::unique_ptr<ScDBData> p);
 
         void erase(const iterator& itr);
         bool empty() const;
diff --git a/sc/qa/unit/dataproviders_test.cxx 
b/sc/qa/unit/dataproviders_test.cxx
index e8da21fa0b2d..ceb682e3091f 100644
--- a/sc/qa/unit/dataproviders_test.cxx
+++ b/sc/qa/unit/dataproviders_test.cxx
@@ -49,7 +49,7 @@ private:
 void ScDataProvidersTest::testCSVImport()
 {
     ScDBData* pDBData = new ScDBData("testDB", 0, 0, 0, 10, 10);
-    bool bInserted = m_pDoc->GetDBCollection()->getNamedDBs().insert(pDBData);
+    bool bInserted = 
m_pDoc->GetDBCollection()->getNamedDBs().insert(std::unique_ptr<ScDBData>(pDBData));
     CPPUNIT_ASSERT(bInserted);
 
     OUString aFileURL;
@@ -77,7 +77,7 @@ void ScDataProvidersTest::testCSVImport()
 void ScDataProvidersTest::testDataLargerThanDB()
 {
     ScDBData* pDBData = new ScDBData("testDB", 0, 0, 0, 1, 1);
-    bool bInserted = m_pDoc->GetDBCollection()->getNamedDBs().insert(pDBData);
+    bool bInserted = 
m_pDoc->GetDBCollection()->getNamedDBs().insert(std::unique_ptr<ScDBData>(pDBData));
     CPPUNIT_ASSERT(bInserted);
 
     OUString aFileURL;
@@ -105,7 +105,7 @@ void ScDataProvidersTest::testDataLargerThanDB()
 void ScDataProvidersTest::testHTMLImport()
 {
     ScDBData* pDBData = new ScDBData("testDB", 0, 0, 0, 10, 10);
-    bool bInserted = m_pDoc->GetDBCollection()->getNamedDBs().insert(pDBData);
+    bool bInserted = 
m_pDoc->GetDBCollection()->getNamedDBs().insert(std::unique_ptr<ScDBData>(pDBData));
     CPPUNIT_ASSERT(bInserted);
 
     OUString aFileURL;
@@ -145,7 +145,7 @@ void ScDataProvidersTest::testHTMLImport()
 void ScDataProvidersTest::testXMLImport()
 {
     ScDBData* pDBData = new ScDBData("testDB", 0, 0, 0, 10, 10);
-    bool bInserted = m_pDoc->GetDBCollection()->getNamedDBs().insert(pDBData);
+    bool bInserted = 
m_pDoc->GetDBCollection()->getNamedDBs().insert(std::unique_ptr<ScDBData>(pDBData));
     CPPUNIT_ASSERT(bInserted);
 
     OUString aFileURL;
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 96e94f2d42f4..7c5004ca7660 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -155,10 +155,10 @@ void Test::testFormulaCreateStringFromTokens()
 
     for (size_t i = 0; i < SAL_N_ELEMENTS(aDBs); ++i)
     {
-        ScDBData* pData = new ScDBData(
+        std::unique_ptr<ScDBData> pData( new ScDBData(
             OUString::createFromAscii(
-                aDBs[i].pName), aDBs[i].nTab, aDBs[i].nCol1, aDBs[i].nRow1, 
aDBs[i].nCol2,aDBs[i].nRow2);
-        bool bInserted = pDBs->getNamedDBs().insert(pData);
+                aDBs[i].pName), aDBs[i].nTab, aDBs[i].nCol1, aDBs[i].nRow1, 
aDBs[i].nCol2,aDBs[i].nRow2) );
+        bool bInserted = pDBs->getNamedDBs().insert(std::move(pData));
         CPPUNIT_ASSERT_MESSAGE(
             OString(
                 "Failed to insert \"" + OString(aDBs[i].pName) + 
"\"").getStr(),
@@ -6792,8 +6792,8 @@ void Test::testFuncTableRef()
 
         // Insert "table" database range definition for A1:B4, with default
         // HasHeader=true and HasTotals=false.
-        ScDBData* pData = new ScDBData( "table", 0,0,0, 1,3);
-        bool bInserted = pDBs->getNamedDBs().insert(pData);
+        std::unique_ptr<ScDBData> pData(new ScDBData( "table", 0,0,0, 1,3));
+        bool bInserted = pDBs->getNamedDBs().insert(std::move(pData));
         CPPUNIT_ASSERT_MESSAGE( "Failed to insert \"table\" database range.", 
bInserted);
     }
 
@@ -6970,8 +6970,8 @@ void Test::testFuncTableRef()
         CPPUNIT_ASSERT_MESSAGE("Failed to fetch DB collection object.", pDBs);
 
         // Insert "headerless" database range definition for E10:F12, without 
headers.
-        ScDBData* pData = new ScDBData( "hltable", 0, 4,9, 5,11, true, false);
-        bool bInserted = pDBs->getNamedDBs().insert(pData);
+        std::unique_ptr<ScDBData> pData(new ScDBData( "hltable", 0, 4,9, 5,11, 
true, false));
+        bool bInserted = pDBs->getNamedDBs().insert(std::move(pData));
         CPPUNIT_ASSERT_MESSAGE( "Failed to insert \"hltable\" database 
range.", bInserted);
     }
 
diff --git a/sc/qa/unit/ucalc_sharedformula.cxx 
b/sc/qa/unit/ucalc_sharedformula.cxx
index 033f79ca8fdf..f05929e570cb 100644
--- a/sc/qa/unit/ucalc_sharedformula.cxx
+++ b/sc/qa/unit/ucalc_sharedformula.cxx
@@ -1579,8 +1579,8 @@ void Test::testSharedFormulaUpdateOnDBChange()
     CPPUNIT_ASSERT_MESSAGE("Failed to fetch DB collection object.", pDBs);
 
     // Define database range 'MyRange' for A1:A2.
-    ScDBData* pData = new ScDBData("MyRange", 0, 0, 0, 0, 1);
-    bool bInserted = pDBs->getNamedDBs().insert(pData);
+    std::unique_ptr<ScDBData> pData(new ScDBData("MyRange", 0, 0, 0, 0, 1));
+    bool bInserted = pDBs->getNamedDBs().insert(std::move(pData));
     CPPUNIT_ASSERT_MESSAGE("Failed to insert a new database range.", 
bInserted);
 
     // Insert in C2:C4 a group of formula cells that reference MyRange.
@@ -1602,8 +1602,8 @@ void Test::testSharedFormulaUpdateOnDBChange()
 
     // Change the range referenced by MyRange to A1:A4.
     ScDBCollection aNewDBs(m_pDoc);
-    ScDBData* pNewData = new ScDBData("MyRange", 0, 0, 0, 0, 3);
-    bInserted = aNewDBs.getNamedDBs().insert(pNewData);
+    std::unique_ptr<ScDBData> pNewData(new ScDBData("MyRange", 0, 0, 0, 0, 3));
+    bInserted = aNewDBs.getNamedDBs().insert(std::move(pNewData));
     CPPUNIT_ASSERT_MESSAGE("Failed to insert a new database range.", 
bInserted);
 
     std::vector<ScRange> aDeleted;
diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index 9ad6d4b9cb86..1684c0023759 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -469,7 +469,7 @@ void adjustDBRange(formula::FormulaToken* pToken, 
ScDocument& rNewDoc, const ScD
     if (!pNewDBData)
     {
         pNewDBData = new ScDBData(*pDBData);
-        bool ins = aNewNamedDBs.insert(pNewDBData);
+        bool ins = aNewNamedDBs.insert(std::unique_ptr<ScDBData>(pNewDBData));
         assert(ins); (void)ins;
     }
     pToken->SetIndex(pNewDBData->GetIndex());
diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx
index 5fa7728c261c..e10135278e0a 100644
--- a/sc/source/core/tool/dbdata.cxx
+++ b/sc/source/core/tool/dbdata.cxx
@@ -1152,9 +1152,9 @@ auto ScDBCollection::NamedDBs::findByUpperName2(const 
OUString& rName) -> iterat
         m_DBs.begin(), m_DBs.end(), FindByUpperName(rName));
 }
 
-bool ScDBCollection::NamedDBs::insert(ScDBData* p)
+bool ScDBCollection::NamedDBs::insert(std::unique_ptr<ScDBData> pData)
 {
-    unique_ptr<ScDBData> pData(p);
+    auto p = pData.get();
     if (!pData->GetIndex())
         pData->SetIndex(mrParent.nEntryIndex++);
 
diff --git a/sc/source/filter/xml/xmldrani.cxx 
b/sc/source/filter/xml/xmldrani.cxx
index 4a90fca5366d..0861a23c7853 100644
--- a/sc/source/filter/xml/xmldrani.cxx
+++ b/sc/source/filter/xml/xmldrani.cxx
@@ -442,7 +442,7 @@ void SAL_CALL ScXMLDatabaseRangeContext::endFastElement( 
sal_Int32 /*nElement*/
         if (pData.get())
         {
             setAutoFilterFlags(*pDoc, *pData);
-            
(void)pDoc->GetDBCollection()->getNamedDBs().insert(pData.release());
+            
(void)pDoc->GetDBCollection()->getNamedDBs().insert(std::move(pData));
         }
     }
 }
diff --git a/sc/source/ui/Accessibility/AccessiblePageHeaderArea.cxx 
b/sc/source/ui/Accessibility/AccessiblePageHeaderArea.cxx
index c68232e2081f..1e4c6af2728c 100644
--- a/sc/source/ui/Accessibility/AccessiblePageHeaderArea.cxx
+++ b/sc/source/ui/Accessibility/AccessiblePageHeaderArea.cxx
@@ -51,7 +51,7 @@ ScAccessiblePageHeaderArea::ScAccessiblePageHeaderArea(
         const EditTextObject* pEditObj,
         SvxAdjust eAdjust)
         : ScAccessibleContextBase(rxParent, AccessibleRole::TEXT),
-        mpEditObj(pEditObj->Clone().release()),
+        mpEditObj(pEditObj->Clone()),
         mpViewShell(pViewShell),
         meAdjust(eAdjust)
 {
diff --git a/sc/source/ui/dbgui/dbnamdlg.cxx b/sc/source/ui/dbgui/dbnamdlg.cxx
index 935ec57cd5e1..7eda996e841d 100644
--- a/sc/source/ui/dbgui/dbnamdlg.cxx
+++ b/sc/source/ui/dbgui/dbnamdlg.cxx
@@ -455,16 +455,16 @@ IMPL_LINK_NOARG(ScDbNameDlg, AddBtnHdl, Button*, void)
                 {
                     //  insert new area
 
-                    ScDBData* pNewEntry = new ScDBData( aNewName, aStart.Tab(),
+                    std::unique_ptr<ScDBData> pNewEntry(new ScDBData( 
aNewName, aStart.Tab(),
                                                         aStart.Col(), 
aStart.Row(),
                                                         aEnd.Col(), aEnd.Row(),
                                                         true, 
m_pBtnHeader->IsChecked(),
-                                                        
m_pBtnTotals->IsChecked() );
+                                                        
m_pBtnTotals->IsChecked() ));
                     pNewEntry->SetDoSize( m_pBtnDoSize->IsChecked() );
                     pNewEntry->SetKeepFmt( m_pBtnKeepFmt->IsChecked() );
                     pNewEntry->SetStripData( m_pBtnStripData->IsChecked() );
 
-                    bool ins = aLocalDbCol.getNamedDBs().insert(pNewEntry);
+                    bool ins = 
aLocalDbCol.getNamedDBs().insert(std::move(pNewEntry));
                     assert(ins); (void)ins;
                 }
 
diff --git a/sc/source/ui/docshell/dbdocfun.cxx 
b/sc/source/ui/docshell/dbdocfun.cxx
index f1441235e229..d82ce8b2ca39 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -93,7 +93,7 @@ bool ScDBDocFunc::AddDBRange( const OUString& rName, const 
ScRange& rRange )
     }
     else
     {
-        bOk = pDocColl->getNamedDBs().insert(pNew.release());
+        bOk = pDocColl->getNamedDBs().insert(std::move(pNew));
     }
     if ( bCompile )
         rDoc.CompileHybridFormula();
@@ -164,13 +164,13 @@ bool ScDBDocFunc::RenameDBRange( const OUString& rOld, 
const OUString& rNew )
     {
         ScDocShellModificator aModificator( rDocShell );
 
-        ScDBData* pNewData = new ScDBData(rNew, **iterOld);
+        std::unique_ptr<ScDBData> pNewData(new ScDBData(rNew, **iterOld));
 
         std::unique_ptr<ScDBCollection> pUndoColl( new ScDBCollection( 
*pDocColl ) );
 
         rDoc.PreprocessDBDataUpdate();
         rDBs.erase(iterOld);
-        bool bInserted = rDBs.insert(pNewData);
+        bool bInserted = rDBs.insert(std::move(pNewData));
         if (!bInserted)                             // error -> restore old 
state
         {
             rDoc.SetDBCollection(std::move(pUndoColl));       // belongs to 
the document then
diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx
index 79710f264618..f94be4468f18 100644
--- a/sc/source/ui/docshell/docsh5.cxx
+++ b/sc/source/ui/docshell/docsh5.cxx
@@ -309,7 +309,7 @@ ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, 
ScGetDBMode eMode, ScGe
                 pNoNameData = new ScDBData( aNewName, nTab,
                                 nStartCol,nStartRow, nEndCol,nEndRow,
                                 true, bHasHeader );
-                bool ins = rDBs.insert(pNoNameData);
+                bool ins = rDBs.insert(std::unique_ptr<ScDBData>(pNoNameData));
                 assert(ins); (void)ins;
             }
             else
diff --git a/sc/source/ui/miscdlgs/dataproviderdlg.cxx 
b/sc/source/ui/miscdlgs/dataproviderdlg.cxx
index 145d276a1bf5..8686a16a468d 100644
--- a/sc/source/ui/miscdlgs/dataproviderdlg.cxx
+++ b/sc/source/ui/miscdlgs/dataproviderdlg.cxx
@@ -966,7 +966,7 @@ ScDataProviderDlg::ScDataProviderDlg(vcl::Window* pParent, 
std::shared_ptr<ScDoc
     mpList->addEntry(mpDataProviderCtrl);
     mpIndex++;
     pDBData = new ScDBData("data", 0, 0, 0, MAXCOL, MAXROW);
-    bool bSuccess = mpDoc->GetDBCollection()->getNamedDBs().insert(pDBData);
+    bool bSuccess = 
mpDoc->GetDBCollection()->getNamedDBs().insert(std::unique_ptr<ScDBData>(pDBData));
     SAL_WARN_IF(!bSuccess, "sc", "temporary warning");
 
     InitMenu();
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to