summaryrefslogtreecommitdiff
path: root/sc/source/core
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-03-23 15:57:41 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-03-28 08:39:21 +0200
commitb2e8bbeafa35c15d168961de711e4970eb0985cb (patch)
tree1d8259893caa4ff0c74a0e271c641c4f326ea8e2 /sc/source/core
parentc4170e4bcba61865425d03a1292b9aea39dc1e6d (diff)
loplugin:useuniqueptr in ScColumn
Change-Id: Iff6c68a29b9e7660132cbe4e556802b0f63706f0 Reviewed-on: https://gerrit.libreoffice.org/51904 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/source/core')
-rw-r--r--sc/source/core/data/documen3.cxx14
-rw-r--r--sc/source/core/data/document.cxx12
-rw-r--r--sc/source/core/data/table1.cxx68
-rw-r--r--sc/source/core/data/table2.cxx44
-rw-r--r--sc/source/core/data/table5.cxx4
-rw-r--r--sc/source/core/data/table6.cxx5
6 files changed, 62 insertions, 85 deletions
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index 4dc59a8127e7..5ef81ccde30e 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -114,7 +114,7 @@ void ScDocument::GetAllTabRangeNames(ScRangeName::TabNameCopyMap& rNames) const
// no more tables to iterate through.
break;
- const ScRangeName* p = maTabs[i]->mpRangeName;
+ const ScRangeName* p = maTabs[i]->mpRangeName.get();
if (!p || p->empty())
// ignore empty ones.
continue;
@@ -145,7 +145,7 @@ void ScDocument::SetAllRangeNames(const std::map<OUString, std::unique_ptr<ScRan
if (pName->empty())
SetRangeName( nTab, nullptr );
else
- SetRangeName( nTab, new ScRangeName( *pName ) );
+ SetRangeName( nTab, std::unique_ptr<ScRangeName>(new ScRangeName( *pName )) );
}
}
}
@@ -160,7 +160,7 @@ void ScDocument::GetRangeNameMap(std::map<OUString, ScRangeName*>& aRangeNameMap
if (!p )
{
p = new ScRangeName();
- SetRangeName(i, p);
+ SetRangeName(i, std::unique_ptr<ScRangeName>(p));
}
OUString aTableName;
maTabs[i]->GetName(aTableName);
@@ -189,12 +189,12 @@ ScRangeName* ScDocument::GetRangeName() const
return pRangeName.get();
}
-void ScDocument::SetRangeName(SCTAB nTab, ScRangeName* pNew)
+void ScDocument::SetRangeName(SCTAB nTab, std::unique_ptr<ScRangeName> pNew)
{
if (!ValidTab(nTab) || nTab >= static_cast<SCTAB>(maTabs.size()) || !maTabs[nTab])
return;
- return maTabs[nTab]->SetRangeName(pNew);
+ return maTabs[nTab]->SetRangeName(std::move(pNew));
}
void ScDocument::SetRangeName( std::unique_ptr<ScRangeName> pNewRangeName )
@@ -654,10 +654,10 @@ const ScSheetEvents* ScDocument::GetSheetEvents( SCTAB nTab ) const
return nullptr;
}
-void ScDocument::SetSheetEvents( SCTAB nTab, const ScSheetEvents* pNew )
+void ScDocument::SetSheetEvents( SCTAB nTab, std::unique_ptr<ScSheetEvents> pNew )
{
if (ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab])
- maTabs[nTab]->SetSheetEvents( pNew );
+ maTabs[nTab]->SetSheetEvents( std::move(pNew) );
}
bool ScDocument::HasSheetEventScript( SCTAB nTab, ScSheetEventId nEvent, bool bWithVbaEvents ) const
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index f9de8433ed13..878887211ccb 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -313,10 +313,10 @@ SCTAB ScDocument::GetTableCount() const
return static_cast<SCTAB>(maTabs.size());
}
-void ScDocument::SetAnonymousDBData(SCTAB nTab, ScDBData* pDBData)
+void ScDocument::SetAnonymousDBData(SCTAB nTab, std::unique_ptr<ScDBData> pDBData)
{
if (ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab])
- maTabs[nTab]->SetAnonymousDBData(pDBData);
+ maTabs[nTab]->SetAnonymousDBData(std::move(pDBData));
}
void ScDocument::SetAnonymousDBData( std::unique_ptr<ScDBData> pDBData )
@@ -6256,16 +6256,16 @@ void ScDocument::SetPrintEntireSheet( SCTAB nTab )
maTabs[nTab]->SetPrintEntireSheet();
}
-void ScDocument::SetRepeatColRange( SCTAB nTab, const ScRange* pNew )
+void ScDocument::SetRepeatColRange( SCTAB nTab, std::unique_ptr<ScRange> pNew )
{
if (ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab])
- maTabs[nTab]->SetRepeatColRange( pNew );
+ maTabs[nTab]->SetRepeatColRange( std::move(pNew) );
}
-void ScDocument::SetRepeatRowRange( SCTAB nTab, const ScRange* pNew )
+void ScDocument::SetRepeatRowRange( SCTAB nTab, std::unique_ptr<ScRange> pNew )
{
if (ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab])
- maTabs[nTab]->SetRepeatRowRange( pNew );
+ maTabs[nTab]->SetRepeatRowRange( std::move(pNew) );
}
ScPrintRangeSaver* ScDocument::CreatePrintRangeSaver() const
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 3cb2301f2cc1..17f3b037166d 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -296,7 +296,7 @@ ScTable::ScTable( ScDocument* pDoc, SCTAB nNewTab, const OUString& rNewName,
if (bRowInfo)
{
mpRowHeights.reset(new ScFlatUInt16RowSegments(ScGlobal::nStdRowHeight));
- pRowFlags = new ScBitMaskCompressedArray<SCROW, CRFlags>( MAXROW, CRFlags::NONE);
+ pRowFlags.reset(new ScBitMaskCompressedArray<SCROW, CRFlags>( MAXROW, CRFlags::NONE));
}
if ( pDocument->IsDocVisible() )
@@ -339,15 +339,15 @@ ScTable::~ScTable() COVERITY_NOEXCEPT_FALSE
pDrawLayer->ScRemovePage( nTab );
}
- delete pRowFlags;
- delete pSheetEvents;
- delete pOutlineTable;
- delete pSearchText;
- delete pRepeatColRange;
- delete pRepeatRowRange;
- delete pScenarioRanges;
- delete mpRangeName;
- delete pDBDataNoName;
+ pRowFlags.reset();
+ pSheetEvents.reset();
+ pOutlineTable.reset();
+ pSearchText.reset();
+ pRepeatColRange.reset();
+ pRepeatRowRange.reset();
+ pScenarioRanges.reset();
+ mpRangeName.reset();
+ pDBDataNoName.reset();
DestroySortCollator();
}
@@ -488,7 +488,7 @@ bool ScTable::SetOptimalHeight(
rCxt.getHeightArray().enableTreeSearch(true);
SetRowHeightRangeFunc aFunc(this, rCxt.getPPTY());
- bool bChanged = SetOptimalHeightsToRows(rCxt, aFunc, pRowFlags, nStartRow, nEndRow);
+ bool bChanged = SetOptimalHeightsToRows(rCxt, aFunc, pRowFlags.get(), nStartRow, nEndRow);
if ( pProgress != pOuterProgress )
delete pProgress;
@@ -515,7 +515,7 @@ void ScTable::SetOptimalHeightOnly(
SetRowHeightOnlyFunc aFunc(this);
rCxt.getHeightArray().enableTreeSearch(true);
- SetOptimalHeightsToRows(rCxt, aFunc, pRowFlags, nStartRow, nEndRow);
+ SetOptimalHeightsToRows(rCxt, aFunc, pRowFlags.get(), nStartRow, nEndRow);
if ( pProgress != pOuterProgress )
delete pProgress;
@@ -2005,19 +2005,6 @@ public:
}
};
-void setPrintRange(ScRange*& pRange1, const ScRange* pRange2)
-{
- if (pRange2)
- {
- if (pRange1)
- *pRange1 = *pRange2;
- else
- pRange1 = new ScRange(*pRange2);
- }
- else
- DELETEZ(pRange1);
-}
-
}
void ScTable::CopyPrintRange(const ScTable& rTable)
@@ -2030,37 +2017,35 @@ void ScTable::CopyPrintRange(const ScTable& rTable)
bPrintEntireSheet = rTable.bPrintEntireSheet;
- delete pRepeatColRange;
- pRepeatColRange = nullptr;
+ pRepeatColRange.reset();
if (rTable.pRepeatColRange)
{
- pRepeatColRange = new ScRange(*rTable.pRepeatColRange);
+ pRepeatColRange.reset(new ScRange(*rTable.pRepeatColRange));
pRepeatColRange->aStart.SetTab(nTab);
pRepeatColRange->aEnd.SetTab(nTab);
}
- delete pRepeatRowRange;
- pRepeatRowRange = nullptr;
+ pRepeatRowRange.reset();
if (rTable.pRepeatRowRange)
{
- pRepeatRowRange = new ScRange(*rTable.pRepeatRowRange);
+ pRepeatRowRange.reset(new ScRange(*rTable.pRepeatRowRange));
pRepeatRowRange->aStart.SetTab(nTab);
pRepeatRowRange->aEnd.SetTab(nTab);
}
}
-void ScTable::SetRepeatColRange( const ScRange* pNew )
+void ScTable::SetRepeatColRange( std::unique_ptr<ScRange> pNew )
{
- setPrintRange( pRepeatColRange, pNew );
+ pRepeatColRange = std::move(pNew);
SetStreamValid(false);
InvalidatePageBreaks();
}
-void ScTable::SetRepeatRowRange( const ScRange* pNew )
+void ScTable::SetRepeatRowRange( std::unique_ptr<ScRange> pNew )
{
- setPrintRange( pRepeatRowRange, pNew );
+ pRepeatRowRange = std::move(pNew);
SetStreamValid(false);
@@ -2105,15 +2090,17 @@ const ScRange* ScTable::GetPrintRange(sal_uInt16 nPos) const
void ScTable::FillPrintSaver( ScPrintSaverTab& rSaveTab ) const
{
rSaveTab.SetAreas( aPrintRanges, bPrintEntireSheet );
- rSaveTab.SetRepeat( pRepeatColRange, pRepeatRowRange );
+ rSaveTab.SetRepeat( pRepeatColRange.get(), pRepeatRowRange.get() );
}
void ScTable::RestorePrintRanges( const ScPrintSaverTab& rSaveTab )
{
aPrintRanges = rSaveTab.GetPrintRanges();
bPrintEntireSheet = rSaveTab.IsEntireSheet();
- SetRepeatColRange( rSaveTab.GetRepeatCol() );
- SetRepeatRowRange( rSaveTab.GetRepeatRow() );
+ auto p = rSaveTab.GetRepeatCol();
+ SetRepeatColRange( std::unique_ptr<ScRange>(p ? new ScRange(*p) : nullptr) );
+ p = rSaveTab.GetRepeatRow();
+ SetRepeatRowRange( std::unique_ptr<ScRange>(p ? new ScRange(*p) : nullptr) );
InvalidatePageBreaks(); // #i117952# forget page breaks for an old print range
UpdatePageBreaks(nullptr);
@@ -2213,10 +2200,9 @@ ScRefCellValue ScTable::VisibleDataCellIterator::next()
return ScRefCellValue();
}
-void ScTable::SetAnonymousDBData(ScDBData* pDBData)
+void ScTable::SetAnonymousDBData(std::unique_ptr<ScDBData> pDBData)
{
- delete pDBDataNoName;
- pDBDataNoName = pDBData;
+ pDBDataNoName = std::move(pDBData);
}
sal_uLong ScTable::AddCondFormat( ScConditionalFormat* pNew )
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 4e51b19b345e..340e087bb927 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -101,17 +101,15 @@ bool ScTable::SetOutlineTable( const ScOutlineTable* pNewOutline )
{
nOldSizeX = pOutlineTable->GetColArray().GetDepth();
nOldSizeY = pOutlineTable->GetRowArray().GetDepth();
- delete pOutlineTable;
+ pOutlineTable.reset();
}
if (pNewOutline)
{
- pOutlineTable = new ScOutlineTable( *pNewOutline );
+ pOutlineTable.reset(new ScOutlineTable( *pNewOutline ));
nNewSizeX = pOutlineTable->GetColArray().GetDepth();
nNewSizeY = pOutlineTable->GetRowArray().GetDepth();
}
- else
- pOutlineTable = nullptr;
return ( nNewSizeX != nOldSizeX || nNewSizeY != nOldSizeY ); // changed size?
}
@@ -119,16 +117,12 @@ bool ScTable::SetOutlineTable( const ScOutlineTable* pNewOutline )
void ScTable::StartOutlineTable()
{
if (!pOutlineTable)
- pOutlineTable = new ScOutlineTable;
+ pOutlineTable.reset(new ScOutlineTable);
}
-void ScTable::SetSheetEvents( const ScSheetEvents* pNew )
+void ScTable::SetSheetEvents( std::unique_ptr<ScSheetEvents> pNew )
{
- delete pSheetEvents;
- if (pNew)
- pSheetEvents = new ScSheetEvents(*pNew);
- else
- pSheetEvents = nullptr;
+ pSheetEvents = std::move(pNew);
SetCalcNotification( false ); // discard notifications before the events were set
@@ -494,7 +488,7 @@ void ScTable::CopyToClip(
// copy content
//local range names need to be copied first for formula cells
if (!pTable->mpRangeName && mpRangeName)
- pTable->mpRangeName = new ScRangeName(*mpRangeName);
+ pTable->mpRangeName.reset( new ScRangeName(*mpRangeName) );
SCCOL i;
@@ -510,7 +504,7 @@ void ScTable::CopyToClip(
pTable->CopyColHidden(*this, 0, nCol2);
pTable->CopyColFiltered(*this, 0, nCol2);
if (pDBDataNoName)
- pTable->SetAnonymousDBData(new ScDBData(*pDBDataNoName));
+ pTable->SetAnonymousDBData(std::unique_ptr<ScDBData>(new ScDBData(*pDBDataNoName)));
if (pRowFlags && pTable->pRowFlags && mpRowHeights && pTable->mpRowHeights)
{
@@ -1150,13 +1144,13 @@ void ScTable::CopyToTable(
if (pDBDataNoName)
{
- ScDBData* pNewDBData = new ScDBData(*pDBDataNoName);
+ std::unique_ptr<ScDBData> pNewDBData(new ScDBData(*pDBDataNoName));
SCCOL aCol1, aCol2;
SCROW aRow1, aRow2;
SCTAB aTab;
pNewDBData->GetArea(aTab, aCol1, aRow1, aCol2, aRow2);
pNewDBData->MoveTo(pDestTab->nTab, aCol1, aRow1, aCol2, aRow2);
- pDestTab->SetAnonymousDBData(pNewDBData);
+ pDestTab->SetAnonymousDBData(std::move(pNewDBData));
}
// Charts have to be adjusted when hide/show
ScChartListenerCollection* pCharts = pDestTab->pDocument->GetChartListenerCollection();
@@ -1249,7 +1243,7 @@ void ScTable::CopyToTable(
}
if(nFlags & InsertDeleteFlags::OUTLINE) // also only when bColRowFlags
- pDestTab->SetOutlineTable( pOutlineTable );
+ pDestTab->SetOutlineTable( pOutlineTable.get() );
if (bCopyCaptions && (nFlags & (InsertDeleteFlags::NOTE | InsertDeleteFlags::ADDNOTES)))
{
@@ -1375,8 +1369,7 @@ bool ScTable::HasScenarioRange( const ScRange& rRange ) const
void ScTable::InvalidateScenarioRanges()
{
- delete pScenarioRanges;
- pScenarioRanges = nullptr;
+ pScenarioRanges.reset();
}
const ScRangeList* ScTable::GetScenarioRanges() const
@@ -1385,12 +1378,12 @@ const ScRangeList* ScTable::GetScenarioRanges() const
if (!pScenarioRanges)
{
- const_cast<ScTable*>(this)->pScenarioRanges = new ScRangeList;
+ const_cast<ScTable*>(this)->pScenarioRanges.reset(new ScRangeList);
ScMarkData aMark;
MarkScenarioIn( aMark, ScScenarioFlags::NONE ); // always
- aMark.FillRangeListWithMarks( pScenarioRanges, false );
+ aMark.FillRangeListWithMarks( pScenarioRanges.get(), false );
}
- return pScenarioRanges;
+ return pScenarioRanges.get();
}
bool ScTable::TestCopyScenarioTo( const ScTable* pDestTab ) const
@@ -3790,10 +3783,9 @@ void ScTable::SetDrawPageSize(bool bResetStreamValid, bool bUpdateNoteCaptionPos
SetStreamValid(false);
}
-void ScTable::SetRangeName(ScRangeName* pNew)
+void ScTable::SetRangeName(std::unique_ptr<ScRangeName> pNew)
{
- delete mpRangeName;
- mpRangeName = pNew;
+ mpRangeName = std::move(pNew);
//fdo#39792: mark stream as invalid, otherwise new ScRangeName will not be written to file
SetStreamValid(false);
@@ -3802,8 +3794,8 @@ void ScTable::SetRangeName(ScRangeName* pNew)
ScRangeName* ScTable::GetRangeName() const
{
if (!mpRangeName)
- mpRangeName = new ScRangeName;
- return mpRangeName;
+ mpRangeName.reset(new ScRangeName);
+ return mpRangeName.get();
}
sal_uLong ScTable::GetRowOffset( SCROW nRow, bool bHiddenAsZero ) const
diff --git a/sc/source/core/data/table5.cxx b/sc/source/core/data/table5.cxx
index c39fb3816c94..85f62b7ecc87 100644
--- a/sc/source/core/data/table5.cxx
+++ b/sc/source/core/data/table5.cxx
@@ -1033,8 +1033,8 @@ void ScTable::SyncColRowFlags()
}
// Hidden flags.
- lcl_syncFlags(*mpHiddenCols, *mpHiddenRows, mpColFlags.get(), pRowFlags, CRFlags::Hidden);
- lcl_syncFlags(*mpFilteredCols, *mpFilteredRows, mpColFlags.get(), pRowFlags, CRFlags::Filtered);
+ lcl_syncFlags(*mpHiddenCols, *mpHiddenRows, mpColFlags.get(), pRowFlags.get(), CRFlags::Hidden);
+ lcl_syncFlags(*mpFilteredCols, *mpFilteredRows, mpColFlags.get(), pRowFlags.get(), CRFlags::Filtered);
}
void ScTable::SetPageSize( const Size& rSize )
diff --git a/sc/source/core/data/table6.cxx b/sc/source/core/data/table6.cxx
index efdb51803935..5a4f36fe3d70 100644
--- a/sc/source/core/data/table6.cxx
+++ b/sc/source/core/data/table6.cxx
@@ -815,7 +815,7 @@ bool ScTable::SearchAndReplace(
( TransliterationFlags::IGNORE_CASE |
TransliterationFlags::IGNORE_WIDTH );
- pSearchText = new utl::TextSearch( aSearchOptions );
+ pSearchText.reset( new utl::TextSearch( aSearchOptions ) );
if (nCommand == SvxSearchCmd::FIND)
bFound = Search(rSearchItem, rCol, rRow, rMark, rUndoStr, pUndoDoc);
@@ -826,8 +826,7 @@ bool ScTable::SearchAndReplace(
else if (nCommand == SvxSearchCmd::REPLACE_ALL)
bFound = ReplaceAll(rSearchItem, rMark, rMatchedRanges, rUndoStr, pUndoDoc);
- delete pSearchText;
- pSearchText = nullptr;
+ pSearchText.reset();
}
}
return bFound;