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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Jan 29 09:47:32 UTC 2019


 sc/inc/conditio.hxx                       |    4 
 sc/inc/document.hxx                       |    2 
 sc/inc/table.hxx                          |    2 
 sc/qa/unit/ucalc_condformat.cxx           |  147 ++++++++++++++++--------------
 sc/source/core/data/conditio.cxx          |   10 +-
 sc/source/core/data/documen4.cxx          |    4 
 sc/source/core/data/table1.cxx            |    4 
 sc/source/core/data/table2.cxx            |   17 +--
 sc/source/filter/oox/condformatbuffer.cxx |    9 +
 sc/source/filter/xml/xmlcondformat.cxx    |    2 
 sc/source/filter/xml/xmlstyli.cxx         |    2 
 sc/source/ui/condformat/condformatdlg.cxx |   22 ++--
 sc/source/ui/docshell/docfunc.cxx         |    4 
 sc/source/ui/inc/condformatdlg.hxx        |    4 
 sc/source/ui/inc/docfunc.hxx              |    2 
 sc/source/ui/unoobj/cellsuno.cxx          |    4 
 sc/source/ui/unoobj/condformatuno.cxx     |    4 
 sc/source/ui/view/cellsh1.cxx             |    4 
 18 files changed, 130 insertions(+), 117 deletions(-)

New commits:
commit 5e4d88a27802848ae23874a81592c2a6758d77e1
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Jan 29 10:21:15 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Jan 29 10:47:08 2019 +0100

    pass ScConditionalFormat around by unique_ptr
    
    Change-Id: If15ac08d8334a386312870d3ebebb385cf55e5f6
    Reviewed-on: https://gerrit.libreoffice.org/67050
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index 3b0480e64d6d..36703a7d2017 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -543,7 +543,7 @@ public:
      const ScConditionalFormat& operator=(const ScConditionalFormat&) = delete;
 
     // true copy of formulas (for Ref-Undo / between documents)
-    ScConditionalFormat* Clone(ScDocument* pNewDoc = nullptr) const;
+    std::unique_ptr<ScConditionalFormat> Clone(ScDocument* pNewDoc = nullptr) const;
 
     void            AddEntry( ScFormatEntry* pNew );
     void RemoveEntry(size_t nIndex);
@@ -610,7 +610,7 @@ public:
     ScConditionalFormatList(const ScConditionalFormatList& rList);
     ScConditionalFormatList(ScDocument* pDoc, const ScConditionalFormatList& rList);
 
-    void    InsertNew( ScConditionalFormat* pNew );
+    void    InsertNew( std::unique_ptr<ScConditionalFormat> pNew );
 
     /**
      * Checks that all cond formats have a non empty range.
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 4e19792f2a2e..bed8003de16c 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1719,7 +1719,7 @@ public:
     void            ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark );
     void            ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark );
 
-    SC_DLLPUBLIC sal_uLong  AddCondFormat( ScConditionalFormat* pNew, SCTAB nTab );
+    SC_DLLPUBLIC sal_uLong  AddCondFormat( std::unique_ptr<ScConditionalFormat> pNew, SCTAB nTab );
     void                    DeleteConditionalFormat( sal_uLong nIndex, SCTAB nTab );
 
     void                                    SetCondFormList( ScConditionalFormatList* pList, SCTAB nTab );
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index d853c4072de1..38ea573ba120 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -979,7 +979,7 @@ public:
 
     void DeleteConditionalFormat(sal_uLong nOldIndex);
 
-    sal_uLong          AddCondFormat( ScConditionalFormat* pNew );
+    sal_uLong          AddCondFormat( std::unique_ptr<ScConditionalFormat> pNew );
 
     SvtScriptType GetScriptType( SCCOL nCol, SCROW nRow ) const;
     void SetScriptType( SCCOL nCol, SCROW nRow, SvtScriptType nType );
diff --git a/sc/qa/unit/ucalc_condformat.cxx b/sc/qa/unit/ucalc_condformat.cxx
index e3aa885211da..836f5bcfee65 100644
--- a/sc/qa/unit/ucalc_condformat.cxx
+++ b/sc/qa/unit/ucalc_condformat.cxx
@@ -46,9 +46,9 @@ void Test::testCopyPasteSkipEmptyConditionalFormatting()
     ScConditionalFormatList* pCondFormatList = new ScConditionalFormatList();
     m_pDoc->SetCondFormList(pCondFormatList, 0);
 
-    ScConditionalFormat* pFormat = new ScConditionalFormat(1, m_pDoc);
+    auto pFormat = std::make_unique<ScConditionalFormat>(1, m_pDoc);
     pFormat->SetRange(aDestRange);
-    sal_uLong nCondFormatKey = m_pDoc->AddCondFormat(pFormat, 0);
+    sal_uLong nCondFormatKey = m_pDoc->AddCondFormat(std::move(pFormat), 0);
 
     // Prepare a clipboard content interleaved with empty cells.
     ScDocument aClipDoc(SCDOCMODE_CLIP);
@@ -61,9 +61,9 @@ void Test::testCopyPasteSkipEmptyConditionalFormatting()
     aClipDoc.SetValue(3,5,0,2);
     aClipDoc.SetValue(4,5,0,2);
 
-    ScConditionalFormat* pClipFormat = new ScConditionalFormat(2, &aClipDoc);
+    auto pClipFormat = std::make_unique<ScConditionalFormat>(2, &aClipDoc);
     pClipFormat->SetRange(aSrcRange);
-    aClipDoc.AddCondFormat(pClipFormat, 0);
+    aClipDoc.AddCondFormat(std::move(pClipFormat), 0);
 
     // Create undo document.
     ScDocument* pUndoDoc = new ScDocument(SCDOCMODE_UNDO);
@@ -98,17 +98,18 @@ void Test::testCondFormatINSDEL()
     m_pDoc->InsertTab(0, "Test");
     ScConditionalFormatList* pList = m_pDoc->GetCondFormList(0);
 
-    ScConditionalFormat* pFormat = new ScConditionalFormat(1, m_pDoc);
+    auto pFormat = std::make_unique<ScConditionalFormat>(1, m_pDoc);
     ScRangeList aRangeList(ScRange(0,0,0,0,3,0));
     pFormat->SetRange(aRangeList);
     ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct,"=B2","",m_pDoc,ScAddress(0,0,0),ScResId(STR_STYLENAME_RESULT));
     pFormat->AddEntry(pEntry);
 
     m_pDoc->AddCondFormatData(pFormat->GetRange(), 0, 1);
-    pList->InsertNew(pFormat);
+    auto pFormatTmp = pFormat.get();
+    pList->InsertNew(std::move(pFormat));
 
     m_pDoc->InsertCol(0,0,MAXROW,0,0,2);
-    const ScRangeList& rRange = pFormat->GetRange();
+    const ScRangeList& rRange = pFormatTmp->GetRange();
     CPPUNIT_ASSERT_EQUAL(static_cast<const ScRangeList&>(ScRange(2,0,0,2,3,0)), rRange);
 
     OUString aExpr = pEntry->GetExpression(ScAddress(2,0,0), 0);
@@ -122,7 +123,7 @@ void Test::testCondFormatInsertCol()
     m_pDoc->InsertTab(0, "Test");
     ScConditionalFormatList* pList = m_pDoc->GetCondFormList(0);
 
-    ScConditionalFormat* pFormat = new ScConditionalFormat(1, m_pDoc);
+    auto pFormat = std::make_unique<ScConditionalFormat>(1, m_pDoc);
     ScRangeList aRangeList(ScRange(0,0,0,3,3,0));
     pFormat->SetRange(aRangeList);
 
@@ -130,10 +131,11 @@ void Test::testCondFormatInsertCol()
     pFormat->AddEntry(pEntry);
 
     m_pDoc->AddCondFormatData(pFormat->GetRange(), 0, 1);
-    pList->InsertNew(pFormat);
+    auto pFormatTmp = pFormat.get();
+    pList->InsertNew(std::move(pFormat));
 
     m_pDoc->InsertCol(0,0,MAXROW,0,4,2);
-    const ScRangeList& rRange = pFormat->GetRange();
+    const ScRangeList& rRange = pFormatTmp->GetRange();
     CPPUNIT_ASSERT_EQUAL(ScRangeList(ScRange(0,0,0,5,3,0)), rRange);
 
     m_pDoc->DeleteTab(0);
@@ -144,7 +146,7 @@ void Test::testCondFormatInsertRow()
     m_pDoc->InsertTab(0, "Test");
     ScConditionalFormatList* pList = m_pDoc->GetCondFormList(0);
 
-    ScConditionalFormat* pFormat = new ScConditionalFormat(1, m_pDoc);
+    auto pFormat = std::make_unique<ScConditionalFormat>(1, m_pDoc);
     ScRangeList aRangeList(ScRange(0,0,0,3,3,0));
     pFormat->SetRange(aRangeList);
 
@@ -152,10 +154,11 @@ void Test::testCondFormatInsertRow()
     pFormat->AddEntry(pEntry);
 
     m_pDoc->AddCondFormatData(pFormat->GetRange(), 0, 1);
-    pList->InsertNew(pFormat);
+    auto pFormatTmp = pFormat.get();
+    pList->InsertNew(std::move(pFormat));
 
     m_pDoc->InsertRow(0,0,MAXCOL,0,4,2);
-    const ScRangeList& rRange = pFormat->GetRange();
+    const ScRangeList& rRange = pFormatTmp->GetRange();
     CPPUNIT_ASSERT_EQUAL(ScRangeList(ScRange(0,0,0,3,5,0)), rRange);
 
     m_pDoc->DeleteTab(0);
@@ -166,24 +169,25 @@ void Test::testCondFormatInsertDeleteSheets()
     m_pDoc->InsertTab(0, "Test");
 
     // Add a conditional format to B2:B4.
-    ScConditionalFormat* pFormat = new ScConditionalFormat(1, m_pDoc);
+    auto pFormat = std::make_unique<ScConditionalFormat>(1, m_pDoc);
     pFormat->SetRange(ScRange(1,1,0,1,3,0));
 
-    sal_uLong nKey = m_pDoc->AddCondFormat(pFormat, 0);
+    auto pFormatTmp = pFormat.get();
+    sal_uLong nKey = m_pDoc->AddCondFormat(std::move(pFormat), 0);
 
     // Add condition in which if the value equals 2, set the "Result" style.
     ScCondFormatEntry* pEntry = new ScCondFormatEntry(
         ScConditionMode::Equal, "=2", "" , m_pDoc, ScAddress(0,0,0), ScResId(STR_STYLENAME_RESULT));
-    pFormat->AddEntry(pEntry);
+    pFormatTmp->AddEntry(pEntry);
 
     // Apply the format to the range.
-    m_pDoc->AddCondFormatData(pFormat->GetRange(), 0, nKey);
+    m_pDoc->AddCondFormatData(pFormatTmp->GetRange(), 0, nKey);
 
     // Make sure this conditional format entry is really there.
     ScConditionalFormatList* pList = m_pDoc->GetCondFormList(0);
     CPPUNIT_ASSERT(pList);
     const ScConditionalFormat* pCheck = pList->GetFormat(nKey);
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong conditional format instance.", pCheck, const_cast<const ScConditionalFormat*>(pFormat));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong conditional format instance.", pCheck, const_cast<const ScConditionalFormat*>(pFormatTmp));
 
     // ... and its range is B2:B4.
     ScRangeList aCheckRange = pCheck->GetRange();
@@ -271,14 +275,14 @@ void Test::testCondCopyPaste()
 {
     m_pDoc->InsertTab(0, "Test");
 
-    ScConditionalFormat* pFormat = new ScConditionalFormat(1, m_pDoc);
+    auto pFormat = std::make_unique<ScConditionalFormat>(1, m_pDoc);
     ScRange aCondFormatRange(0,0,0,3,3,0);
     ScRangeList aRangeList(aCondFormatRange);
     pFormat->SetRange(aRangeList);
 
     ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct,"=B2","",m_pDoc,ScAddress(0,0,0),ScResId(STR_STYLENAME_RESULT));
     pFormat->AddEntry(pEntry);
-    sal_uLong nIndex = m_pDoc->AddCondFormat(pFormat, 0);
+    sal_uLong nIndex = m_pDoc->AddCondFormat(std::move(pFormat), 0);
 
     ScDocument aClipDoc(SCDOCMODE_CLIP);
     copyToClip(m_pDoc, aCondFormatRange, &aClipDoc);
@@ -310,14 +314,14 @@ void Test::testCondCopyPasteSingleCell()
 {
     m_pDoc->InsertTab(0, "Test");
 
-    ScConditionalFormat* pFormat = new ScConditionalFormat(1, m_pDoc);
+    auto pFormat = std::make_unique<ScConditionalFormat>(1, m_pDoc);
     ScRange aCondFormatRange(0,0,0,3,3,0);
     ScRangeList aRangeList(aCondFormatRange);
     pFormat->SetRange(aRangeList);
 
     ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct,"=B2","",m_pDoc,ScAddress(0,0,0),ScResId(STR_STYLENAME_RESULT));
     pFormat->AddEntry(pEntry);
-    sal_uLong nIndex = m_pDoc->AddCondFormat(pFormat, 0);
+    sal_uLong nIndex = m_pDoc->AddCondFormat(std::move(pFormat), 0);
 
     ScDocument aClipDoc(SCDOCMODE_CLIP);
     copyToClip(m_pDoc, ScRange(0,0,0,0,0,0), &aClipDoc);
@@ -349,14 +353,14 @@ void Test::testCondCopyPasteSingleCellToRange()
 {
     m_pDoc->InsertTab(0, "Test");
 
-    ScConditionalFormat* pFormat = new ScConditionalFormat(1, m_pDoc);
+    auto pFormat = std::make_unique<ScConditionalFormat>(1, m_pDoc);
     ScRange aCondFormatRange(0,0,0,3,3,0);
     ScRangeList aRangeList(aCondFormatRange);
     pFormat->SetRange(aRangeList);
 
     ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct,"=B2","",m_pDoc,ScAddress(0,0,0),ScResId(STR_STYLENAME_RESULT));
     pFormat->AddEntry(pEntry);
-    sal_uLong nIndex = m_pDoc->AddCondFormat(pFormat, 0);
+    sal_uLong nIndex = m_pDoc->AddCondFormat(std::move(pFormat), 0);
 
     ScDocument aClipDoc(SCDOCMODE_CLIP);
     copyToClip(m_pDoc, ScRange(0,0,0,0,0,0), &aClipDoc);
@@ -394,14 +398,14 @@ void Test::testCondCopyPasteSingleCellIntoSameFormatRange()
 {
     m_pDoc->InsertTab(0, "Test");
 
-    ScConditionalFormat* pFormat = new ScConditionalFormat(1, m_pDoc);
+    auto pFormat = std::make_unique<ScConditionalFormat>(1, m_pDoc);
     ScRange aCondFormatRange(0, 0, 0, 3, 3, 0);
     ScRangeList aRangeList(aCondFormatRange);
     pFormat->SetRange(aRangeList);
 
     ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct, "=B2", "", m_pDoc, ScAddress(0, 0, 0), ScResId(STR_STYLENAME_RESULT));
     pFormat->AddEntry(pEntry);
-    sal_uLong nIndex = m_pDoc->AddCondFormat(pFormat, 0);
+    sal_uLong nIndex = m_pDoc->AddCondFormat(std::move(pFormat), 0);
 
     ScDocument aClipDoc(SCDOCMODE_CLIP);
     copyToClip(m_pDoc, ScRange(1, 1, 0, 1, 1, 0), &aClipDoc);
@@ -431,14 +435,15 @@ void Test::testCondCopyPasteSingleRowToRange()
 {
     m_pDoc->InsertTab(0, "Test");
 
-    ScConditionalFormat* pFormat = new ScConditionalFormat(1, m_pDoc);
+    auto pFormat = std::make_unique<ScConditionalFormat>(1, m_pDoc);
     ScRange aCondFormatRange(0,0,0,0,0,0);
     ScRangeList aRangeList(aCondFormatRange);
     pFormat->SetRange(aRangeList);
 
     ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct,"=B2","",m_pDoc,ScAddress(0,0,0),ScResId(STR_STYLENAME_RESULT));
     pFormat->AddEntry(pEntry);
-    m_pDoc->AddCondFormat(pFormat, 0);
+    auto pFormatTmp = pFormat.get();
+    m_pDoc->AddCondFormat(std::move(pFormat), 0);
 
     ScDocument aClipDoc(SCDOCMODE_CLIP);
     copyToClip(m_pDoc, ScRange(0,0,0,MAXCOL,0,0), &aClipDoc);
@@ -447,7 +452,7 @@ void Test::testCondCopyPasteSingleRowToRange()
 
     ScConditionalFormat* pNewFormat = m_pDoc->GetCondFormat(0, 4, 0);
     CPPUNIT_ASSERT(pNewFormat);
-    CPPUNIT_ASSERT_EQUAL(pNewFormat->GetKey(), pFormat->GetKey());
+    CPPUNIT_ASSERT_EQUAL(pNewFormat->GetKey(), pFormatTmp->GetKey());
 
     for (SCCOL nCol = 1; nCol <= MAXCOL; ++nCol)
     {
@@ -462,14 +467,14 @@ void Test::testCondCopyPasteSingleRowToRange2()
 {
     m_pDoc->InsertTab(0, "Test");
 
-    ScConditionalFormat* pFormat = new ScConditionalFormat(1, m_pDoc);
+    auto pFormat = std::make_unique<ScConditionalFormat>(1, m_pDoc);
     ScRange aCondFormatRange(0,0,0,0,0,0);
     ScRangeList aRangeList(aCondFormatRange);
     pFormat->SetRange(aRangeList);
 
     ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct,"=B2","",m_pDoc,ScAddress(0,0,0),ScResId(STR_STYLENAME_RESULT));
     pFormat->AddEntry(pEntry);
-    m_pDoc->AddCondFormat(pFormat, 0);
+    m_pDoc->AddCondFormat(std::move(pFormat), 0);
 
     ScDocument aClipDoc(SCDOCMODE_CLIP);
     copyToClip(m_pDoc, ScRange(0,0,0,3,0,0), &aClipDoc);
@@ -492,14 +497,14 @@ void Test::testCondCopyPasteSheetBetweenDoc()
 {
     m_pDoc->InsertTab(0, "Test");
 
-    ScConditionalFormat* pFormat = new ScConditionalFormat(1, m_pDoc);
+    auto pFormat = std::make_unique<ScConditionalFormat>(1, m_pDoc);
     ScRange aCondFormatRange(0,0,0,3,3,0);
     ScRangeList aRangeList(aCondFormatRange);
     pFormat->SetRange(aRangeList);
 
     ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct,"=B2","",m_pDoc,ScAddress(0,0,0),ScResId(STR_STYLENAME_RESULT));
     pFormat->AddEntry(pEntry);
-    m_pDoc->AddCondFormat(pFormat, 0);
+    m_pDoc->AddCondFormat(std::move(pFormat), 0);
 
     ScDocument aDoc;
     aDoc.TransferTab(m_pDoc, 0, 0);
@@ -514,14 +519,14 @@ void Test::testCondCopyPasteSheet()
 {
     m_pDoc->InsertTab(0, "Test");
 
-    ScConditionalFormat* pFormat = new ScConditionalFormat(1, m_pDoc);
+    auto pFormat = std::make_unique<ScConditionalFormat>(1, m_pDoc);
     ScRange aCondFormatRange(0,0,0,3,3,0);
     ScRangeList aRangeList(aCondFormatRange);
     pFormat->SetRange(aRangeList);
 
     ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct,"=B2","",m_pDoc,ScAddress(0,0,0),ScResId(STR_STYLENAME_RESULT));
     pFormat->AddEntry(pEntry);
-    m_pDoc->AddCondFormat(pFormat, 0);
+    m_pDoc->AddCondFormat(std::move(pFormat), 0);
 
     m_pDoc->CopyTab(0, SC_TAB_APPEND);
 
@@ -548,7 +553,7 @@ void Test::testIconSet()
     m_pDoc->InsertTab(0, "Test");
     ScConditionalFormatList* pList = m_pDoc->GetCondFormList(0);
 
-    ScConditionalFormat* pFormat = new ScConditionalFormat(1, m_pDoc);
+    auto pFormat = std::make_unique<ScConditionalFormat>(1, m_pDoc);
     ScRangeList aRangeList(ScRange(0,0,0,0,0,0));
     pFormat->SetRange(aRangeList);
 
@@ -560,7 +565,7 @@ void Test::testIconSet()
     pEntry->SetIconSetData(pData);
 
     m_pDoc->AddCondFormatData(pFormat->GetRange(), 0, 1);
-    pList->InsertNew(pFormat);
+    pList->InsertNew(std::move(pFormat));
 
     static struct {
         double nVal; sal_Int32 nIndex;
@@ -902,11 +907,12 @@ void Test::testCondFormatUpdateMoveTab()
 
     ScConditionEntry* pEntry = new ScConditionEntry(ScConditionMode::Equal, "A1", "", m_pDoc, ScAddress(10, 10, 0), "", "", formula::FormulaGrammar::GRAM_DEFAULT, formula::FormulaGrammar::GRAM_DEFAULT);
 
-    ScConditionalFormat* pFormat = new ScConditionalFormat(0, m_pDoc);
+    auto pFormat = std::make_unique<ScConditionalFormat>(0, m_pDoc);
     pFormat->SetRange(ScRange(10, 10, 0, 10, 12, 0));
-    m_pDoc->AddCondFormat(pFormat, 0);
+    auto pFormatTmp = pFormat.get();
+    m_pDoc->AddCondFormat(std::move(pFormat), 0);
 
-    pFormat->AddEntry(pEntry);
+    pFormatTmp->AddEntry(pEntry);
 
     // the conditional format should listen to A1:A3
     for (SCROW nRow = 0; nRow < 3; ++nRow)
@@ -937,11 +943,12 @@ void Test::testCondFormatUpdateInsertTab()
 
     ScConditionEntry* pEntry = new ScConditionEntry(ScConditionMode::Equal, "A1", "", m_pDoc, ScAddress(10, 10, 0), "", "", formula::FormulaGrammar::GRAM_DEFAULT, formula::FormulaGrammar::GRAM_DEFAULT);
 
-    ScConditionalFormat* pFormat = new ScConditionalFormat(0, m_pDoc);
+    auto pFormat = std::make_unique<ScConditionalFormat>(0, m_pDoc);
     pFormat->SetRange(ScRange(10, 10, 0, 10, 12, 0));
-    m_pDoc->AddCondFormat(pFormat, 0);
+    auto pFormatTmp = pFormat.get();
+    m_pDoc->AddCondFormat(std::move(pFormat), 0);
 
-    pFormat->AddEntry(pEntry);
+    pFormatTmp->AddEntry(pEntry);
 
     // the conditional format should listen to A1:A3
     for (SCROW nRow = 0; nRow < 3; ++nRow)
@@ -976,11 +983,12 @@ void Test::testCondFormatUpdateDeleteTab()
 
     ScConditionEntry* pEntry = new ScConditionEntry(ScConditionMode::Equal, "A1", "", m_pDoc, ScAddress(10, 10, 1), "", "", formula::FormulaGrammar::GRAM_DEFAULT, formula::FormulaGrammar::GRAM_DEFAULT);
 
-    ScConditionalFormat* pFormat = new ScConditionalFormat(0, m_pDoc);
+    auto pFormat = std::make_unique<ScConditionalFormat>(0, m_pDoc);
     pFormat->SetRange(ScRange(10, 10, 1, 10, 12, 1));
-    m_pDoc->AddCondFormat(pFormat, 1);
+    auto pFormatTmp = pFormat.get();
+    m_pDoc->AddCondFormat(std::move(pFormat), 1);
 
-    pFormat->AddEntry(pEntry);
+    pFormatTmp->AddEntry(pEntry);
 
     // the conditional format should listen to A1:A3 on the second sheet
     for (SCROW nRow = 0; nRow < 3; ++nRow)
@@ -1008,11 +1016,12 @@ void Test::testCondFormatUpdateReference()
 
     ScConditionEntry* pEntry = new ScConditionEntry(ScConditionMode::Equal, "A1", "", m_pDoc, ScAddress(10, 10, 0), "", "", formula::FormulaGrammar::GRAM_DEFAULT, formula::FormulaGrammar::GRAM_DEFAULT);
 
-    ScConditionalFormat* pFormat = new ScConditionalFormat(0, m_pDoc);
+    auto pFormat = std::make_unique<ScConditionalFormat>(0, m_pDoc);
     pFormat->SetRange(ScRange(10, 10, 0, 10, 12, 0));
-    m_pDoc->AddCondFormat(pFormat, 0);
+    auto pFormatTmp = pFormat.get();
+    m_pDoc->AddCondFormat(std::move(pFormat), 0);
 
-    pFormat->AddEntry(pEntry);
+    pFormatTmp->AddEntry(pEntry);
 
     // the conditional format should listen to A1:A3
     for (SCROW nRow = 0; nRow < 3; ++nRow)
@@ -1031,11 +1040,12 @@ void Test::testCondFormatUpdateReferenceDelRow()
 
     ScConditionEntry* pEntry = new ScConditionEntry(ScConditionMode::Equal, "B6", "", m_pDoc, ScAddress(0, 5, 0), "", "", formula::FormulaGrammar::GRAM_DEFAULT, formula::FormulaGrammar::GRAM_DEFAULT);
 
-    ScConditionalFormat* pFormat = new ScConditionalFormat(0, m_pDoc);
+    auto pFormat = std::make_unique<ScConditionalFormat>(0, m_pDoc);
     pFormat->SetRange(ScRange(0, 5, 0, 0, 5, 0));
-    m_pDoc->AddCondFormat(pFormat, 0);
+    auto pFormatTmp = pFormat.get();
+    m_pDoc->AddCondFormat(std::move(pFormat), 0);
 
-    pFormat->AddEntry(pEntry);
+    pFormatTmp->AddEntry(pEntry);
 
     m_pDoc->DeleteRow(0, 0, MAXCOL, 0, 4, 1);
 
@@ -1051,11 +1061,12 @@ void Test::testCondFormatUpdateReferenceInsRow()
 
     ScConditionEntry* pEntry = new ScConditionEntry(ScConditionMode::Equal, "B6", "", m_pDoc, ScAddress(0, 5, 0), "", "", formula::FormulaGrammar::GRAM_DEFAULT, formula::FormulaGrammar::GRAM_DEFAULT);
 
-    ScConditionalFormat* pFormat = new ScConditionalFormat(0, m_pDoc);
+    auto pFormat = std::make_unique<ScConditionalFormat>(0, m_pDoc);
     pFormat->SetRange(ScRange(0, 5, 0, 0, 5, 0));
-    m_pDoc->AddCondFormat(pFormat, 0);
+    auto pFormatTmp = pFormat.get();
+    m_pDoc->AddCondFormat(std::move(pFormat), 0);
 
-    pFormat->AddEntry(pEntry);
+    pFormatTmp->AddEntry(pEntry);
 
     m_pDoc->InsertRow(0, 0, MAXCOL, 0, 4, 1);
 
@@ -1071,11 +1082,12 @@ void Test::testCondFormatUndoList()
 
     ScConditionEntry* pEntry = new ScConditionEntry(ScConditionMode::Equal, "B6", "", m_pDoc, ScAddress(0, 5, 0), "", "", formula::FormulaGrammar::GRAM_DEFAULT, formula::FormulaGrammar::GRAM_DEFAULT);
 
-    ScConditionalFormat* pFormat = new ScConditionalFormat(0, m_pDoc);
+    auto pFormat = std::make_unique<ScConditionalFormat>(0, m_pDoc);
     pFormat->AddEntry(pEntry);
     pFormat->SetRange(ScRange(0, 0, 0, 0, 5, 0));
-    m_pDoc->AddCondFormat(pFormat, 0);
-    m_pDoc->AddCondFormatData(pFormat->GetRange(), 0, pFormat->GetKey());
+    auto pFormatTmp = pFormat.get();
+    m_pDoc->AddCondFormat(std::move(pFormat), 0);
+    m_pDoc->AddCondFormatData(pFormatTmp->GetRange(), 0, pFormatTmp->GetKey());
 
     ScDocFunc& rFunc = getDocShell().GetDocFunc();
 
@@ -1110,7 +1122,7 @@ namespace {
 
 sal_uInt32 addSingleCellCondFormat(ScDocument* pDoc, const ScAddress& rAddr, sal_uInt32 nKey, const OUString& rCondition)
 {
-    ScConditionalFormat* pFormat = new ScConditionalFormat(nKey, pDoc);
+    auto pFormat = std::make_unique<ScConditionalFormat>(nKey, pDoc);
     ScRange aCondFormatRange(rAddr);
     ScRangeList aRangeList(aCondFormatRange);
     pFormat->SetRange(aRangeList);
@@ -1118,7 +1130,7 @@ sal_uInt32 addSingleCellCondFormat(ScDocument* pDoc, const ScAddress& rAddr, sal
     ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct, rCondition, "",
             pDoc, ScAddress(0,0,0), ScResId(STR_STYLENAME_RESULT));
     pFormat->AddEntry(pEntry);
-    return pDoc->AddCondFormat(pFormat, 0);
+    return pDoc->AddCondFormat(std::move(pFormat), 0);
 }
 
 }
@@ -1193,7 +1205,7 @@ void Test::testCondFormatListenToOwnRange()
 
     ScConditionalFormatList* pList = m_pDoc->GetCondFormList(0);
 
-    ScConditionalFormat* pFormat = new ScConditionalFormat(1, m_pDoc);
+    auto pFormat = std::make_unique<ScConditionalFormat>(1, m_pDoc);
     ScRangeList aRangeList(ScRange(0,0,0,10,0,0));
     pFormat->SetRange(aRangeList);
 
@@ -1203,11 +1215,11 @@ void Test::testCondFormatListenToOwnRange()
     pData->m_Entries.push_back(std::make_unique<ScColorScaleEntry>(1, COL_GREEN));
     pData->m_Entries.push_back(std::make_unique<ScColorScaleEntry>(2, COL_RED));
     pEntry->SetIconSetData(pData);
-    pEntry->SetParent(pFormat);
+    pEntry->SetParent(pFormat.get());
 
     m_pDoc->AddCondFormatData(pFormat->GetRange(), 0, 1);
     pFormat->AddEntry(pEntry);
-    pList->InsertNew(pFormat);
+    pList->InsertNew(std::move(pFormat));
 
     bool bFirstCallbackCalled = false;
     bool bSecondCallbackCalled = false;
@@ -1233,16 +1245,17 @@ void Test::testCondFormatVolatileFunctionRecalc()
 
     ScConditionalFormatList* pList = m_pDoc->GetCondFormList(0);
 
-    ScConditionalFormat* pFormat = new ScConditionalFormat(1, m_pDoc);
+    auto pFormat = std::make_unique<ScConditionalFormat>(1, m_pDoc);
     ScRangeList aRangeList(ScRange(0,0,0,10,0,0));
     pFormat->SetRange(aRangeList);
 
     ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Greater,"RAND()","",m_pDoc,ScAddress(0,0,0),ScResId(STR_STYLENAME_RESULT));
-    pEntry->SetParent(pFormat);
+    pEntry->SetParent(pFormat.get());
 
     m_pDoc->AddCondFormatData(pFormat->GetRange(), 0, 1);
     pFormat->AddEntry(pEntry);
-    pList->InsertNew(pFormat);
+    auto pFormatTmp = pFormat.get();
+    pList->InsertNew(std::move(pFormat));
 
     ScRefCellValue aCell(*m_pDoc, ScAddress(0, 0, 0));
     bool bValid = pEntry->IsCellValid(aCell, ScAddress(0, 0, 0));
@@ -1251,7 +1264,7 @@ void Test::testCondFormatVolatileFunctionRecalc()
     // chance of a random failure is 0.5^100, anyone hitting that will get a beer from me
     for (size_t i = 0; i < 100; ++i)
     {
-        pFormat->CalcAll();
+        pFormatTmp->CalcAll();
         bNewValid = pEntry->IsCellValid(aCell, ScAddress(0, 0, 0));
 
         if (bValid != bNewValid)
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index e4c669052467..d5bb968d5d50 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -1702,20 +1702,20 @@ ScConditionalFormat::ScConditionalFormat(sal_uInt32 nNewKey, ScDocument* pDocume
 {
 }
 
-ScConditionalFormat* ScConditionalFormat::Clone(ScDocument* pNewDoc) const
+std::unique_ptr<ScConditionalFormat> ScConditionalFormat::Clone(ScDocument* pNewDoc) const
 {
     // Real copy of the formula (for Ref Undo/between documents)
     if (!pNewDoc)
         pNewDoc = pDoc;
 
-    ScConditionalFormat* pNew = new ScConditionalFormat(nKey, pNewDoc);
+    std::unique_ptr<ScConditionalFormat> pNew(new ScConditionalFormat(nKey, pNewDoc));
     pNew->SetRange( maRanges );     // prerequisite for listeners
 
     for (auto itr = maEntries.cbegin(); itr != maEntries.cend(); ++itr)
     {
         ScFormatEntry* pNewEntry = (*itr)->Clone(pNewDoc);
         pNew->maEntries.push_back( std::unique_ptr<ScFormatEntry>(pNewEntry) );
-        pNewEntry->SetParent(pNew);
+        pNewEntry->SetParent(pNew.get());
     }
 
     return pNew;
@@ -2045,9 +2045,9 @@ ScConditionalFormatList::ScConditionalFormatList(ScDocument* pDoc, const ScCondi
         InsertNew( (*itr)->Clone(pDoc) );
 }
 
-void ScConditionalFormatList::InsertNew( ScConditionalFormat* pNew )
+void ScConditionalFormatList::InsertNew( std::unique_ptr<ScConditionalFormat> pNew )
 {
-    m_ConditionalFormats.insert(std::unique_ptr<ScConditionalFormat>(pNew));
+    m_ConditionalFormats.insert(std::move(pNew));
 }
 
 ScConditionalFormat* ScConditionalFormatList::GetFormat( sal_uInt32 nKey )
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index f02e43f0bffc..e5a759cea8d3 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -692,13 +692,13 @@ double ScDocument::RoundValueAsShown( double fVal, sal_uInt32 nFormat, const ScI
 
 // conditional formats and validation ranges
 
-sal_uLong ScDocument::AddCondFormat( ScConditionalFormat* pNew, SCTAB nTab )
+sal_uLong ScDocument::AddCondFormat( std::unique_ptr<ScConditionalFormat> pNew, SCTAB nTab )
 {
     if(!pNew)
         return 0;
 
     if(ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab])
-        return maTabs[nTab]->AddCondFormat( pNew );
+        return maTabs[nTab]->AddCondFormat( std::move(pNew) );
 
     return 0;
 }
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 7e9fd9aa524a..dd9df5503fa6 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -2276,7 +2276,7 @@ void ScTable::SetAnonymousDBData(std::unique_ptr<ScDBData> pDBData)
     pDBDataNoName = std::move(pDBData);
 }
 
-sal_uLong ScTable::AddCondFormat( ScConditionalFormat* pNew )
+sal_uLong ScTable::AddCondFormat( std::unique_ptr<ScConditionalFormat> pNew )
 {
     if(!mpCondFormatList)
         mpCondFormatList.reset(new ScConditionalFormatList());
@@ -2284,7 +2284,7 @@ sal_uLong ScTable::AddCondFormat( ScConditionalFormat* pNew )
     sal_uInt32 nMax = mpCondFormatList->getMaxKey();
 
     pNew->SetKey(nMax+1);
-    mpCondFormatList->InsertNew(pNew);
+    mpCondFormatList->InsertNew(std::move(pNew));
 
     return nMax + 1;
 }
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 2ed72a208ae1..36c6b531ba46 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -594,7 +594,7 @@ void ScTable::CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCRO
             continue;
 
         ScRangeList aIntersectedRange = rCondFormatRange.GetIntersectedRange(aOldRange);
-        ScConditionalFormat* pNewFormat = (*itr)->Clone(pDocument);
+        std::unique_ptr<ScConditionalFormat> pNewFormat = (*itr)->Clone(pDocument);
 
         pNewFormat->SetRange(aIntersectedRange);
         sc::RefUpdateContext aRefCxt(*pDocument);
@@ -605,9 +605,8 @@ void ScTable::CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCRO
         aRefCxt.mnTabDelta = nTab - pTable->nTab;
         pNewFormat->UpdateReference(aRefCxt, true);
 
-        if (bSameDoc && pTable->nTab == nTab && CheckAndDeduplicateCondFormat(pDocument, mpCondFormatList->GetFormat((*itr)->GetKey()), pNewFormat, nTab))
+        if (bSameDoc && pTable->nTab == nTab && CheckAndDeduplicateCondFormat(pDocument, mpCondFormatList->GetFormat((*itr)->GetKey()), pNewFormat.get(), nTab))
         {
-            delete pNewFormat;
             continue;
         }
         sal_uLong nMax = 0;
@@ -617,7 +616,7 @@ void ScTable::CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCRO
         {
             // Check if there is the same format in the destination
             // If there is, then simply expand its range
-            if (CheckAndDeduplicateCondFormat(pDocument, (*itrCond).get(), pNewFormat, nTab))
+            if (CheckAndDeduplicateCondFormat(pDocument, (*itrCond).get(), pNewFormat.get(), nTab))
             {
                 bDuplicate = true;
                 break;
@@ -629,20 +628,20 @@ void ScTable::CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCRO
         // Do not add duplicate entries
         if (bDuplicate)
         {
-            delete pNewFormat;
             continue;
         }
 
         pNewFormat->SetKey(nMax + 1);
-        mpCondFormatList->InsertNew(pNewFormat);
+        auto pNewFormatTmp = pNewFormat.get();
+        mpCondFormatList->InsertNew(std::move(pNewFormat));
 
         if(!bSameDoc)
         {
-            for(size_t i = 0, n = pNewFormat->size();
+            for(size_t i = 0, n = pNewFormatTmp->size();
                     i < n; ++i)
             {
                 OUString aStyleName;
-                const ScFormatEntry* pEntry = pNewFormat->GetEntry(i);
+                const ScFormatEntry* pEntry = pNewFormatTmp->GetEntry(i);
                 if(pEntry->GetType() == ScFormatEntry::Type::Condition)
                     aStyleName = static_cast<const ScCondFormatEntry*>(pEntry)->GetStyle();
                 else if(pEntry->GetType() == ScFormatEntry::Type::Date)
@@ -659,7 +658,7 @@ void ScTable::CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCRO
             }
         }
 
-        pDocument->AddCondFormatData( pNewFormat->GetRange(), nTab, pNewFormat->GetKey() );
+        pDocument->AddCondFormatData( pNewFormatTmp->GetRange(), nTab, pNewFormatTmp->GetKey() );
     }
 }
 
diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx
index a189008afb76..b6392bed7a8d 100644
--- a/sc/source/filter/oox/condformatbuffer.cxx
+++ b/sc/source/filter/oox/condformatbuffer.cxx
@@ -1043,7 +1043,7 @@ void CondFormat::finalizeImport()
     mpFormat->SetRange(maModel.maRanges);
     maRules.forEachMem( &CondFormatRule::finalizeImport );
     SCTAB nTab = maModel.maRanges.GetTopLeftCorner().Tab();
-    sal_Int32 nIndex = getScDocument().AddCondFormat(mpFormat, nTab);
+    sal_Int32 nIndex = getScDocument().AddCondFormat(std::unique_ptr<ScConditionalFormat>(mpFormat), nTab);
 
     rDoc.AddCondFormatData( maModel.maRanges, nTab, nIndex );
 }
@@ -1115,9 +1115,10 @@ void CondFormatBuffer::finalizeImport()
         if (!pFormat)
         {
             // create new conditional format and insert it
-            pFormat = new ScConditionalFormat(0, pDoc);
-            pFormat->SetRange(rRange);
-            sal_uLong nKey = pDoc->AddCondFormat(pFormat, nTab);
+            auto pNewFormat = std::make_unique<ScConditionalFormat>(0, pDoc);
+            pFormat = pNewFormat.get();
+            pNewFormat->SetRange(rRange);
+            sal_uLong nKey = pDoc->AddCondFormat(std::move(pNewFormat), nTab);
             pDoc->AddCondFormatData(rRange, nTab, nKey);
         }
 
diff --git a/sc/source/filter/xml/xmlcondformat.cxx b/sc/source/filter/xml/xmlcondformat.cxx
index cc326dd621e7..8e35ab868443 100644
--- a/sc/source/filter/xml/xmlcondformat.cxx
+++ b/sc/source/filter/xml/xmlcondformat.cxx
@@ -337,7 +337,7 @@ void SAL_CALL ScXMLConditionalFormatContext::endFastElement( sal_Int32 /*nElemen
         }
     }
 
-    sal_uLong nIndex = pDoc->AddCondFormat(pFormat.release(), nTab);
+    sal_uLong nIndex = pDoc->AddCondFormat(std::move(pFormat), nTab);
     ScConditionalFormat* pInsertedFormat = pDoc->GetCondFormList(nTab)->GetFormat(nIndex);
     assert(pInsertedFormat && pInsertedFormat->GetKey() == nIndex);
 
diff --git a/sc/source/filter/xml/xmlstyli.cxx b/sc/source/filter/xml/xmlstyli.cxx
index 3d4d83db74f4..71f3aca3fa25 100644
--- a/sc/source/filter/xml/xmlstyli.cxx
+++ b/sc/source/filter/xml/xmlstyli.cxx
@@ -508,7 +508,7 @@ void XMLTableStyleContext::ApplyCondFormat( const uno::Sequence<table::CellRange
 
     if(mpCondFormat && mbDeleteCondFormat)
     {
-        sal_uLong nIndex = pDoc->AddCondFormat(mpCondFormat, nTab );
+        sal_uLong nIndex = pDoc->AddCondFormat(std::unique_ptr<ScConditionalFormat>(mpCondFormat), nTab );
         mpCondFormat->SetKey(nIndex);
         mpCondFormat->SetRange(aRangeList);
 
diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index a599a0ec5e2b..68fb6c4ee19f 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -178,12 +178,12 @@ void ScCondFormatList::queue_resize(StateChangedType eReason)
     RecalcAll();
 }
 
-ScConditionalFormat* ScCondFormatList::GetConditionalFormat() const
+std::unique_ptr<ScConditionalFormat> ScCondFormatList::GetConditionalFormat() const
 {
     if(maEntries.empty())
         return nullptr;
 
-    ScConditionalFormat* pFormat = new ScConditionalFormat(0, mpDoc);
+    std::unique_ptr<ScConditionalFormat> pFormat(new ScConditionalFormat(0, mpDoc));
     pFormat->SetRange(maRanges);
 
     for(auto & rEntry: maEntries)
@@ -676,7 +676,7 @@ void ScCondFormatDlg::SetReference(const ScRange& rRef, ScDocument*)
     }
 }
 
-ScConditionalFormat* ScCondFormatDlg::GetConditionalFormat() const
+std::unique_ptr<ScConditionalFormat> ScCondFormatDlg::GetConditionalFormat() const
 {
     OUString aRangeStr = mpEdRange->GetText();
     if(aRangeStr.isEmpty())
@@ -686,15 +686,12 @@ ScConditionalFormat* ScCondFormatDlg::GetConditionalFormat() const
     ScRefFlags nFlags = aRange.Parse(aRangeStr, mpViewData->GetDocument(),
         mpViewData->GetDocument()->GetAddressConvention(), maPos.Tab());
     mpCondFormList->SetRange(aRange);
-    ScConditionalFormat* pFormat = mpCondFormList->GetConditionalFormat();
+    std::unique_ptr<ScConditionalFormat> pFormat = mpCondFormList->GetConditionalFormat();
 
     if((nFlags & ScRefFlags::VALID) && !aRange.empty() && pFormat)
         pFormat->SetRange(aRange);
     else
-    {
-        delete pFormat;
-        pFormat = nullptr;
-    }
+        pFormat.reset();
 
     return pFormat;
 }
@@ -715,13 +712,16 @@ bool ScCondFormatDlg::Close()
 //
 void ScCondFormatDlg::OkPressed()
 {
-    ScConditionalFormat* pFormat = GetConditionalFormat();
+    std::unique_ptr<ScConditionalFormat> pFormat = GetConditionalFormat();
 
     if (!mpDlgItem->IsManaged())
     {
         if(pFormat)
+        {
+            auto& rRangeList = pFormat->GetRange();
             mpViewData->GetDocShell()->GetDocFunc().ReplaceConditionalFormat(mnKey,
-                    pFormat, maPos.Tab(), pFormat->GetRange());
+                    std::move(pFormat), maPos.Tab(), rRangeList);
+        }
         else
             mpViewData->GetDocShell()->GetDocFunc().ReplaceConditionalFormat(mnKey,
                     nullptr, maPos.Tab(), ScRangeList());
@@ -739,7 +739,7 @@ void ScCondFormatDlg::OkPressed()
         if (pFormat)
         {
             pFormat->SetKey(nKey);
-            pList->InsertNew(pFormat);
+            pList->InsertNew(std::move(pFormat));
         }
         mpViewData->GetViewShell()->GetPool().Put(*mpDlgItem);
 
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index d2c5b778ee32..cabb2472c358 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -5486,7 +5486,7 @@ void ScDocFunc::InsertAreaLink( const OUString& rFile, const OUString& rFilter,
     SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScAreaLinksChanged ) );     // Navigator
 }
 
-void ScDocFunc::ReplaceConditionalFormat( sal_uLong nOldFormat, ScConditionalFormat* pFormat, SCTAB nTab, const ScRangeList& rRanges )
+void ScDocFunc::ReplaceConditionalFormat( sal_uLong nOldFormat, std::unique_ptr<ScConditionalFormat> pFormat, SCTAB nTab, const ScRangeList& rRanges )
 {
     ScDocShellModificator aModificator(rDocShell);
     ScDocument& rDoc = rDocShell.GetDocument();
@@ -5538,7 +5538,7 @@ void ScDocFunc::ReplaceConditionalFormat( sal_uLong nOldFormat, ScConditionalFor
         else
             pRepaintRange.reset(new ScRange(aCombinedRange));
 
-        sal_uLong nIndex = rDoc.AddCondFormat(pFormat, nTab);
+        sal_uLong nIndex = rDoc.AddCondFormat(std::move(pFormat), nTab);
 
         rDoc.AddCondFormatData(rRanges, nTab, nIndex);
         rDoc.SetStreamValid(nTab, false);
diff --git a/sc/source/ui/inc/condformatdlg.hxx b/sc/source/ui/inc/condformatdlg.hxx
index 9c9706c19f25..1ec992b009cd 100644
--- a/sc/source/ui/inc/condformatdlg.hxx
+++ b/sc/source/ui/inc/condformatdlg.hxx
@@ -64,7 +64,7 @@ public:
     virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override;
     virtual void Resize() override;
 
-    ScConditionalFormat* GetConditionalFormat() const;
+    std::unique_ptr<ScConditionalFormat> GetConditionalFormat() const;
     void Freeze() { mbFrozen = true; }
     void Thaw() { mbFrozen = false; }
     void RecalcAll();
@@ -120,7 +120,7 @@ public:
     virtual ~ScCondFormatDlg() override;
     virtual void dispose() override;
 
-    SC_DLLPUBLIC ScConditionalFormat* GetConditionalFormat() const;
+    SC_DLLPUBLIC std::unique_ptr<ScConditionalFormat> GetConditionalFormat() const;
 
     virtual void SetReference(const ScRange&, ScDocument*) override;
     virtual bool IsRefInputMode() const override;
diff --git a/sc/source/ui/inc/docfunc.hxx b/sc/source/ui/inc/docfunc.hxx
index 00d572f47ce5..28da723907a3 100644
--- a/sc/source/ui/inc/docfunc.hxx
+++ b/sc/source/ui/inc/docfunc.hxx
@@ -216,7 +216,7 @@ public:
      * @param nOldIndex If 0 don't delete an old format
      * @param pFormat if NULL only delete an old format
      */
-    void ReplaceConditionalFormat( sal_uLong nOldIndex, ScConditionalFormat* pFormat, SCTAB nTab, const ScRangeList& rRanges );
+    void ReplaceConditionalFormat( sal_uLong nOldIndex, std::unique_ptr<ScConditionalFormat> pFormat, SCTAB nTab, const ScRangeList& rRanges );
 
     /**
      * Sets or replaces the conditional format list of a table
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index ae441efc365d..4afafe7c91fb 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -2388,10 +2388,10 @@ void ScCellRangesBase::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pE
                                 // Then we can apply new conditional format if there is one
                                 if (pFormat->getCount())
                                 {
-                                    ScConditionalFormat* pNew = new ScConditionalFormat( 0, &rDoc );    // Index will be set on inserting
+                                    auto pNew = std::make_unique<ScConditionalFormat>( 0, &rDoc );    // Index will be set on inserting
                                     pFormat->FillFormat( *pNew, &rDoc, eGrammar );
                                     pNew->SetRange( aRanges );
-                                    pDocShell->GetDocFunc().ReplaceConditionalFormat( 0, pNew, nTab, aRanges );
+                                    pDocShell->GetDocFunc().ReplaceConditionalFormat( 0, std::move(pNew), nTab, aRanges );
                                 }
 
                                 // and repaint
diff --git a/sc/source/ui/unoobj/condformatuno.cxx b/sc/source/ui/unoobj/condformatuno.cxx
index 8456a8fb84e5..4685fd0387c4 100644
--- a/sc/source/ui/unoobj/condformatuno.cxx
+++ b/sc/source/ui/unoobj/condformatuno.cxx
@@ -357,9 +357,9 @@ sal_Int32 ScCondFormatsObj::createByRange(const uno::Reference< sheet::XSheetCel
 
     SCTAB nTab = aCoreRange[0].aStart.Tab();
 
-    ScConditionalFormat* pNewFormat = new ScConditionalFormat(0, &mpDocShell->GetDocument());
+    auto pNewFormat = std::make_unique<ScConditionalFormat>(0, &mpDocShell->GetDocument());
     pNewFormat->SetRange(aCoreRange);
-    return mpDocShell->GetDocument().AddCondFormat(pNewFormat, nTab);
+    return mpDocShell->GetDocument().AddCondFormat(std::move(pNewFormat), nTab);
 }
 
 void ScCondFormatsObj::removeByID(const sal_Int32 nID)
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 290c28252d44..1e5e24b958d7 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -1988,7 +1988,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
                 const SfxInt16Item* pParam = rReq.GetArg<SfxInt16Item>(FN_PARAM_1);
                 if (pParam && nSlot == SID_OPENDLG_ICONSET)
                 {
-                    ScConditionalFormat* pFormat = new ScConditionalFormat(0, pDoc);
+                    auto pFormat = std::make_unique<ScConditionalFormat>(0, pDoc);
                     pFormat->SetRange(aRangeList);
 
                     ScIconSetType eIconSetType = limit_cast<ScIconSetType>(pParam->GetValue(), IconSet_3Arrows, IconSet_5Boxes);
@@ -2009,7 +2009,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
                     pFormat->AddEntry(pEntry);
 
                     // use the new conditional formatting
-                    GetViewData()->GetDocShell()->GetDocFunc().ReplaceConditionalFormat(nIndex, pFormat, aPos.Tab(), aRangeList);
+                    GetViewData()->GetDocShell()->GetDocFunc().ReplaceConditionalFormat(nIndex, std::move(pFormat), aPos.Tab(), aRangeList);
 
                     break;
                 }


More information about the Libreoffice-commits mailing list