diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-01-29 10:21:15 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-01-29 10:47:08 +0100 |
commit | 5e4d88a27802848ae23874a81592c2a6758d77e1 (patch) | |
tree | 8c96909d974988c5be0da730a0b02d6b2d87e69c /sc/source/core | |
parent | e7bd86b399e549ef51397e3ae46947d78852e9cc (diff) |
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@collabora.co.uk>
Diffstat (limited to 'sc/source/core')
-rw-r--r-- | sc/source/core/data/conditio.cxx | 10 | ||||
-rw-r--r-- | sc/source/core/data/documen4.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/data/table1.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/data/table2.cxx | 17 |
4 files changed, 17 insertions, 18 deletions
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() ); } } |