[Libreoffice-commits] core.git: sc/inc sc/source
Noel Grandin
noel.grandin at collabora.co.uk
Thu Jul 5 09:43:53 UTC 2018
sc/inc/document.hxx | 2
sc/source/core/data/documen2.cxx | 32 ++++------
sc/source/core/data/documen3.cxx | 12 +--
sc/source/core/data/documen8.cxx | 4 -
sc/source/core/data/documen9.cxx | 4 -
sc/source/core/data/document.cxx | 105 ++++++++++++++-------------------
sc/source/core/data/document10.cxx | 12 +--
sc/source/core/data/documentimport.cxx | 2
8 files changed, 75 insertions(+), 98 deletions(-)
New commits:
commit b8335d6b5b6b0184ed7c5d141c6a956187bcf9cf
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Wed Jul 4 15:35:54 2018 +0200
use std::unique_ptr for ScTable in ScDocument
Change-Id: Ic817fbd7953afe9007f9ec6071f53c8beca6dd18
Reviewed-on: https://gerrit.libreoffice.org/56949
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 4d106792c290..07e16a8388de 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -326,7 +326,7 @@ friend class sc::TableColumnBlockPositionSet;
friend struct ScMutationGuard;
friend struct ScMutationDisable;
- typedef std::vector<ScTable*> TableContainer;
+ typedef std::vector<std::unique_ptr<ScTable>> TableContainer;
public:
enum class HardRecalcState
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 378d97e7ddbd..81ce2170d02d 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -544,16 +544,16 @@ void ScDocument::ResetClip( ScDocument* pSourceDoc, const ScMarkData* pMarks )
pSourceDoc->maTabs[i]->GetName(aString);
if ( i < static_cast<SCTAB>(maTabs.size()) )
{
- maTabs[i] = new ScTable(this, i, aString);
+ maTabs[i].reset( new ScTable(this, i, aString) );
}
else
{
if( i > static_cast<SCTAB>(maTabs.size()) )
{
- maTabs.resize(i, nullptr );
+ maTabs.resize(i);
}
- maTabs.push_back(new ScTable(this, i, aString));
+ maTabs.emplace_back(new ScTable(this, i, aString));
}
maTabs[i]->SetLayoutRTL( pSourceDoc->maTabs[i]->IsLayoutRTL() );
}
@@ -571,9 +571,9 @@ void ScDocument::ResetClip( ScDocument* pSourceDoc, SCTAB nTab )
InitClipPtrs(pSourceDoc);
if (nTab >= static_cast<SCTAB>(maTabs.size()))
{
- maTabs.resize(nTab+1, nullptr );
+ maTabs.resize(nTab+1);
}
- maTabs[nTab] = new ScTable(this, nTab, "baeh");
+ maTabs[nTab].reset( new ScTable(this, nTab, "baeh") );
if (nTab < static_cast<SCTAB>(pSourceDoc->maTabs.size()) && pSourceDoc->maTabs[nTab])
maTabs[nTab]->SetLayoutRTL( pSourceDoc->maTabs[nTab]->IsLayoutRTL() );
}
@@ -587,10 +587,10 @@ void ScDocument::EnsureTable( SCTAB nTab )
{
bool bExtras = !bIsUndo; // Column-Widths, Row-Heights, Flags
if (static_cast<size_t>(nTab) >= maTabs.size())
- maTabs.resize(nTab+1, nullptr);
+ maTabs.resize(nTab+1);
if (!maTabs[nTab])
- maTabs[nTab] = new ScTable(this, nTab, "temp", bExtras, bExtras);
+ maTabs[nTab].reset( new ScTable(this, nTab, "temp", bExtras, bExtras) );
}
ScRefCellValue ScDocument::GetRefCellValue( const ScAddress& rPos )
@@ -779,9 +779,9 @@ bool ScDocument::MoveTab( SCTAB nOldPos, SCTAB nNewPos, ScProgress* pProgress )
pUnoBroadcaster->Broadcast( ScUpdateRefHint( URM_REORDER,
aSourceRange, 0,0,nDz ) );
- ScTable* pSaveTab = maTabs[nOldPos];
+ std::unique_ptr<ScTable> pSaveTab = std::move(maTabs[nOldPos]);
maTabs.erase(maTabs.begin()+nOldPos);
- maTabs.insert(maTabs.begin()+nNewPos, pSaveTab);
+ maTabs.insert(maTabs.begin()+nNewPos, std::move(pSaveTab));
TableContainer::iterator it = maTabs.begin();
for (SCTAB i = 0; i < nTabCount; i++)
if (maTabs[i])
@@ -833,7 +833,7 @@ bool ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, const ScMarkData* pOnlyM
if (nNewPos >= static_cast<SCTAB>(maTabs.size()))
{
nNewPos = static_cast<SCTAB>(maTabs.size());
- maTabs.push_back(new ScTable(this, nNewPos, aName));
+ maTabs.emplace_back(new ScTable(this, nNewPos, aName));
}
else
{
@@ -858,16 +858,12 @@ bool ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, const ScMarkData* pOnlyM
if ( pUnoBroadcaster )
pUnoBroadcaster->Broadcast( ScUpdateRefHint( URM_INSDEL, aRange, 0,0,1 ) );
- SCTAB i;
for (TableContainer::iterator it = maTabs.begin(); it != maTabs.end(); ++it)
if (*it && it != (maTabs.begin() + nOldPos))
(*it)->UpdateInsertTab(aCxt);
- maTabs.push_back(nullptr);
- for (i = static_cast<SCTAB>(maTabs.size())-1; i > nNewPos; i--)
- maTabs[i] = maTabs[i - 1];
if (nNewPos <= nOldPos)
nOldPos++;
- maTabs[nNewPos] = new ScTable(this, nNewPos, aName);
+ maTabs.emplace(maTabs.begin() + nNewPos, new ScTable(this, nNewPos, aName));
bValid = true;
for (TableContainer::iterator it = maTabs.begin(); it != maTabs.end(); ++it)
if (*it && it != maTabs.begin()+nOldPos && it != maTabs.begin() + nNewPos)
@@ -899,7 +895,7 @@ bool ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, const ScMarkData* pOnlyM
sc::CopyToDocContext aCopyDocCxt(*this);
maTabs[nOldPos]->CopyToTable(aCopyDocCxt, 0, 0, MAXCOL, MAXROW, InsertDeleteFlags::ALL,
- (pOnlyMarked != nullptr), maTabs[nNewPos], pOnlyMarked,
+ (pOnlyMarked != nullptr), maTabs[nNewPos].get(), pOnlyMarked,
false /*bAsLink*/, true /*bColRowFlags*/, bGlobalNamesToLocal, false /*bCopyCaptions*/ );
maTabs[nNewPos]->SetTabBgColor(maTabs[nOldPos]->GetTabBgColor());
@@ -944,7 +940,7 @@ bool ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, const ScMarkData* pOnlyM
// 1. the updated source ScColumn::nTab members if nNewPos <= nOldPos
// 2. row heights and column widths of the destination
// 3. RTL settings of the destination
- maTabs[nOldPos]->CopyCaptionsToTable( 0, 0, MAXCOL, MAXROW, maTabs[nNewPos], true /*bCloneCaption*/);
+ maTabs[nOldPos]->CopyCaptionsToTable( 0, 0, MAXCOL, MAXROW, maTabs[nNewPos].get(), true /*bCloneCaption*/);
}
return bValid;
@@ -1021,7 +1017,7 @@ sal_uLong ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos,
}
pSrcDoc->maTabs[nSrcPos]->CopyToTable(aCxt, 0, 0, MAXCOL, MAXROW,
( bResultsOnly ? InsertDeleteFlags::ALL & ~InsertDeleteFlags::FORMULA : InsertDeleteFlags::ALL),
- false, maTabs[nDestPos] );
+ false, maTabs[nDestPos].get() );
}
}
maTabs[nDestPos]->SetTabNo(nDestPos);
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index 1b9629c34a9d..d3b912200788 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -796,7 +796,7 @@ void ScDocument::CopyUpdated( ScDocument* pPosDoc, ScDocument* pDestDoc )
SCTAB nCount = static_cast<SCTAB>(maTabs.size());
for (SCTAB nTab=0; nTab<nCount; nTab++)
if (maTabs[nTab] && pPosDoc->maTabs[nTab] && pDestDoc->maTabs[nTab])
- maTabs[nTab]->CopyUpdated( pPosDoc->maTabs[nTab], pDestDoc->maTabs[nTab] );
+ maTabs[nTab]->CopyUpdated( pPosDoc->maTabs[nTab].get(), pDestDoc->maTabs[nTab].get() );
}
void ScDocument::CopyScenario( SCTAB nSrcTab, SCTAB nDestTab, bool bNewScenario )
@@ -826,7 +826,7 @@ void ScDocument::CopyScenario( SCTAB nSrcTab, SCTAB nDestTab, bool bNewScenario
{
maTabs[nTab]->SetActiveScenario(false);
if ( maTabs[nTab]->GetScenarioFlags() & ScScenarioFlags::TwoWay )
- maTabs[nTab]->CopyScenarioFrom( maTabs[nDestTab] );
+ maTabs[nTab]->CopyScenarioFrom( maTabs[nDestTab].get() );
}
}
}
@@ -835,7 +835,7 @@ void ScDocument::CopyScenario( SCTAB nSrcTab, SCTAB nDestTab, bool bNewScenario
if (!bNewScenario) // Copy data from the selected scenario
{
sc::AutoCalcSwitch aACSwitch(*this, false);
- maTabs[nSrcTab]->CopyScenarioTo( maTabs[nDestTab] );
+ maTabs[nSrcTab]->CopyScenarioTo( maTabs[nDestTab].get() );
sc::SetFormulaDirtyContext aCxt;
SetAllFormulasDirty(aCxt);
@@ -883,7 +883,7 @@ bool ScDocument::TestCopyScenario( SCTAB nSrcTab, SCTAB nDestTab ) const
{
if (ValidTab(nSrcTab) && nSrcTab < static_cast<SCTAB>(maTabs.size())
&& nDestTab < static_cast<SCTAB>(maTabs.size())&& ValidTab(nDestTab))
- return maTabs[nSrcTab]->TestCopyScenarioTo( maTabs[nDestTab] );
+ return maTabs[nSrcTab]->TestCopyScenarioTo( maTabs[nDestTab].get() );
OSL_FAIL("wrong table at TestCopyScenario");
return false;
@@ -1679,7 +1679,7 @@ tools::Rectangle ScDocument::GetEmbeddedRect() const // 1/100 mm
tools::Rectangle aRect;
ScTable* pTable = nullptr;
if ( aEmbedRange.aStart.Tab() < static_cast<SCTAB>(maTabs.size()) )
- pTable = maTabs[aEmbedRange.aStart.Tab()];
+ pTable = maTabs[aEmbedRange.aStart.Tab()].get();
else
OSL_FAIL("table out of range");
if (!pTable)
@@ -1770,7 +1770,7 @@ ScRange ScDocument::GetRange( SCTAB nTab, const tools::Rectangle& rMMRect, bool
{
ScTable* pTable = nullptr;
if (nTab < static_cast<SCTAB>(maTabs.size()))
- pTable = maTabs[nTab];
+ pTable = maTabs[nTab].get();
else
OSL_FAIL("table out of range");
if (!pTable)
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index 32a1c2cd97cb..51f7c757c726 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -581,7 +581,7 @@ bool ScDocument::IdleCalcTextWidth() // true = try next again
if (!ValidTab(aScope.Tab()) || aScope.Tab() >= static_cast<SCTAB>(maTabs.size()) || !maTabs[aScope.Tab()])
aScope.setTab(0);
- ScTable* pTab = maTabs[aScope.Tab()];
+ ScTable* pTab = maTabs[aScope.Tab()].get();
ScStyleSheet* pStyle = static_cast<ScStyleSheet*>(aScope.getStylePool()->Find(pTab->aPageStyle, SfxStyleFamily::Page));
OSL_ENSURE( pStyle, "Missing StyleSheet :-/" );
@@ -668,7 +668,7 @@ bool ScDocument::IdleCalcTextWidth() // true = try next again
{
if ( bNewTab )
{
- pTab = maTabs[aScope.Tab()];
+ pTab = maTabs[aScope.Tab()].get();
pStyle = static_cast<ScStyleSheet*>(aScope.getStylePool()->Find(
pTab->aPageStyle, SfxStyleFamily::Page));
diff --git a/sc/source/core/data/documen9.cxx b/sc/source/core/data/documen9.cxx
index d342e49c6bbe..ee80e09a143a 100644
--- a/sc/source/core/data/documen9.cxx
+++ b/sc/source/core/data/documen9.cxx
@@ -510,10 +510,6 @@ void ScDocument::Clear( bool bFromDestructor )
if (*it)
(*it)->GetCondFormList()->clear();
- it = maTabs.begin();
- for (;it != maTabs.end(); ++it)
- delete *it;
-
maTabs.clear();
pSelectionAttr.reset();
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 37965d887f17..fd69d4b25e1f 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -123,7 +123,7 @@ using ::std::set;
namespace {
-std::pair<SCTAB,SCTAB> getMarkedTableRange(const std::vector<ScTable*>& rTables, const ScMarkData& rMark)
+std::pair<SCTAB,SCTAB> getMarkedTableRange(const std::vector<std::unique_ptr<ScTable>>& rTables, const ScMarkData& rMark)
{
SCTAB nTabStart = MAXTAB;
SCTAB nTabEnd = 0;
@@ -175,13 +175,13 @@ void ScDocument::MakeTable( SCTAB nTab,bool _bNeedsNameCheck )
CreateValidTabName( aString ); // no doubles
if (nTab < static_cast<SCTAB>(maTabs.size()))
{
- maTabs[nTab] = new ScTable(this, nTab, aString);
+ maTabs[nTab].reset( new ScTable(this, nTab, aString) );
}
else
{
while(nTab > static_cast<SCTAB>(maTabs.size()))
maTabs.push_back(nullptr);
- maTabs.push_back( new ScTable(this, nTab, aString) );
+ maTabs.emplace_back( new ScTable(this, nTab, aString) );
}
maTabs[nTab]->SetLoadingMedium(bLoadingMedium);
}
@@ -477,7 +477,7 @@ void ScDocument::AppendTabOnLoad(const OUString& rName)
OUString aName = rName;
CreateValidTabName(aName);
- maTabs.push_back( new ScTable(this, nTabCount, aName) );
+ maTabs.emplace_back( new ScTable(this, nTabCount, aName) );
}
void ScDocument::SetTabNameOnLoad(SCTAB nTab, const OUString& rName)
@@ -496,7 +496,7 @@ void ScDocument::InvalidateStreamOnSave()
TableContainer::iterator it = maTabs.begin(), itEnd = maTabs.end();
for (; it != itEnd; ++it)
{
- ScTable* pTab = *it;
+ ScTable* pTab = it->get();
if (pTab)
pTab->SetStreamValid(false);
}
@@ -514,7 +514,7 @@ bool ScDocument::InsertTab(
if (nPos == SC_TAB_APPEND || nPos >= nTabCount)
{
nPos = maTabs.size();
- maTabs.push_back( new ScTable(this, nTabCount, rName) );
+ maTabs.emplace_back( new ScTable(this, nTabCount, rName) );
if ( bExternalDocument )
maTabs[nTabCount]->SetVisible( false );
}
@@ -540,18 +540,11 @@ bool ScDocument::InsertTab(
if ( pUnoBroadcaster )
pUnoBroadcaster->Broadcast( ScUpdateRefHint( URM_INSDEL, aRange, 0,0,1 ) );
- SCTAB i;
TableContainer::iterator it = maTabs.begin();
for (; it != maTabs.end(); ++it)
if ( *it )
(*it)->UpdateInsertTab(aCxt);
- maTabs.push_back(nullptr);
- for (i = nTabCount; i > nPos; i--)
- {
- maTabs[i] = maTabs[i - 1];
- }
-
- maTabs[nPos] = new ScTable(this, nPos, rName);
+ maTabs.emplace(maTabs.begin() + nPos, new ScTable(this, nPos, rName));
// UpdateBroadcastAreas must be called between UpdateInsertTab,
// which ends listening, and StartAllListeners, to not modify
@@ -612,7 +605,7 @@ bool ScDocument::InsertTabs( SCTAB nPos, const std::vector<OUString>& rNames,
{
for ( SCTAB i = 0; i < nNewSheets; ++i )
{
- maTabs.push_back( new ScTable(this, nTabCount + i, rNames.at(i)) );
+ maTabs.emplace_back( new ScTable(this, nTabCount + i, rNames.at(i)) );
}
}
else
@@ -640,11 +633,9 @@ bool ScDocument::InsertTabs( SCTAB nPos, const std::vector<OUString>& rNames,
for (; it != maTabs.end(); ++it)
if ( *it )
(*it)->UpdateInsertTab(aCxt);
- it = maTabs.begin();
- maTabs.insert(it+nPos,nNewSheets, nullptr);
for (SCTAB i = 0; i < nNewSheets; ++i)
{
- maTabs[nPos + i] = new ScTable(this, nPos + i, rNames.at(i));
+ maTabs.emplace(maTabs.begin() + nPos + i, new ScTable(this, nPos + i, rNames.at(i)) );
}
// UpdateBroadcastAreas must be called between UpdateInsertTab,
@@ -733,18 +724,16 @@ bool ScDocument::DeleteTab( SCTAB nTab )
if ( pUnoBroadcaster )
pUnoBroadcaster->Broadcast( ScUpdateRefHint( URM_INSDEL, aRange, 0,0,-1 ) );
- for (ScTable* pTab : maTabs)
+ for (std::unique_ptr<ScTable> & pTab : maTabs)
if (pTab)
pTab->UpdateDeleteTab(aCxt);
- TableContainer::iterator it = maTabs.begin() + nTab;
- delete *it;
- maTabs.erase(it);
+ maTabs.erase(maTabs.begin() + nTab);
// UpdateBroadcastAreas must be called between UpdateDeleteTab,
// which ends listening, and StartAllListeners, to not modify
// areas that are to be inserted by starting listeners.
UpdateBroadcastAreas( URM_INSDEL, aRange, 0,0,-1);
- it = maTabs.begin();
+ TableContainer::iterator it = maTabs.begin();
for (; it != maTabs.end(); ++it)
if ( *it )
(*it)->UpdateCompile();
@@ -830,19 +819,16 @@ bool ScDocument::DeleteTabs( SCTAB nTab, SCTAB nSheets )
if ( pUnoBroadcaster )
pUnoBroadcaster->Broadcast( ScUpdateRefHint( URM_INSDEL, aRange, 0,0,-1*nSheets ) );
- for (ScTable* pTab : maTabs)
+ for (std::unique_ptr<ScTable> & pTab : maTabs)
if (pTab)
pTab->UpdateDeleteTab(aCxt);
- TableContainer::iterator it = maTabs.begin() + nTab;
- TableContainer::iterator itEnd = it + nSheets;
- std::for_each(it, itEnd, std::default_delete<ScTable>());
- maTabs.erase(it, itEnd);
+ maTabs.erase(maTabs.begin() + nTab, maTabs.begin() + nTab + nSheets);
// UpdateBroadcastAreas must be called between UpdateDeleteTab,
// which ends listening, and StartAllListeners, to not modify
// areas that are to be inserted by starting listeners.
UpdateBroadcastAreas( URM_INSDEL, aRange, 0,0,-1*nSheets);
- it = maTabs.begin();
+ TableContainer::iterator it = maTabs.begin();
for (; it != maTabs.end(); ++it)
if ( *it )
(*it)->UpdateCompile();
@@ -1226,7 +1212,7 @@ namespace {
struct SetDirtyIfPostponedHandler
{
- void operator() (ScTable* p)
+ void operator() (std::unique_ptr<ScTable> & p)
{
if (p)
p->SetDirtyIfPostponed();
@@ -1235,7 +1221,7 @@ struct SetDirtyIfPostponedHandler
struct BroadcastRecalcOnRefMoveHandler
{
- void operator() (ScTable* p)
+ void operator() (std::unique_ptr<ScTable> & p)
{
if (p)
p->BroadcastRecalcOnRefMove();
@@ -1972,11 +1958,11 @@ void ScDocument::InitUndoSelected( const ScDocument* pSrcDoc, const ScMarkData&
for (SCTAB nTab = 0; nTab <= rTabSelection.GetLastSelected(); nTab++)
if ( rTabSelection.GetTableSelect( nTab ) )
{
- ScTable* pTable = new ScTable(this, nTab, OUString(), bColInfo, bRowInfo);
+ std::unique_ptr<ScTable> pTable(new ScTable(this, nTab, OUString(), bColInfo, bRowInfo));
if (nTab < static_cast<SCTAB>(maTabs.size()))
- maTabs[nTab] = pTable;
+ maTabs[nTab] = std::move(pTable);
else
- maTabs.push_back(pTable);
+ maTabs.push_back(std::move(pTable));
}
else
{
@@ -2010,11 +1996,10 @@ void ScDocument::InitUndo( const ScDocument* pSrcDoc, SCTAB nTab1, SCTAB nTab2,
maFileURL = pSrcDoc->mpShell->GetMedium()->GetURLObject().GetMainURL(INetURLObject::DecodeMechanism::ToIUri);
if ( nTab2 >= static_cast<SCTAB>(maTabs.size()))
- maTabs.resize(nTab2 + 1, nullptr);
+ maTabs.resize(nTab2 + 1);
for (SCTAB nTab = nTab1; nTab <= nTab2; nTab++)
{
- ScTable* pTable = new ScTable(this, nTab, OUString(), bColInfo, bRowInfo);
- maTabs[nTab] = pTable;
+ maTabs[nTab].reset(new ScTable(this, nTab, OUString(), bColInfo, bRowInfo));
}
}
@@ -2028,13 +2013,13 @@ void ScDocument::AddUndoTab( SCTAB nTab1, SCTAB nTab2, bool bColInfo, bool bRowI
if (nTab2 >= static_cast<SCTAB>(maTabs.size()))
{
- maTabs.resize(nTab2+1,nullptr);
+ maTabs.resize(nTab2+1);
}
for (SCTAB nTab = nTab1; nTab <= nTab2; nTab++)
if (!maTabs[nTab])
{
- maTabs[nTab] = new ScTable(this, nTab, OUString(), bColInfo, bRowInfo);
+ maTabs[nTab].reset( new ScTable(this, nTab, OUString(), bColInfo, bRowInfo) );
}
}
@@ -2079,7 +2064,7 @@ void ScDocument::CopyToDocument(SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
{
if (maTabs[i] && rDestDoc.maTabs[i])
maTabs[i]->CopyToTable(aCxt, nCol1, nRow1, nCol2, nRow2, nFlags,
- bOnlyMarked, rDestDoc.maTabs[i], pMarks,
+ bOnlyMarked, rDestDoc.maTabs[i].get(), pMarks,
false, bColRowFlags );
}
rDestDoc.SetAutoCalc(bOldAutoCalc);
@@ -2106,7 +2091,7 @@ void ScDocument::UndoToDocument(SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
{
if (maTabs[i] && rDestDoc.maTabs[i])
maTabs[i]->UndoToTable(aCxt, nCol1, nRow1, nCol2, nRow2, nFlags,
- bOnlyMarked, rDestDoc.maTabs[i]);
+ bOnlyMarked, rDestDoc.maTabs[i].get());
}
if (nTab2 < MAXTAB)
@@ -2165,7 +2150,7 @@ void ScDocument::UndoToDocument(const ScRange& rRange,
if (maTabs[i] && rDestDoc.maTabs[i])
maTabs[i]->UndoToTable(aCxt, aNewRange.aStart.Col(), aNewRange.aStart.Row(),
aNewRange.aEnd.Col(), aNewRange.aEnd.Row(),
- nFlags, bOnlyMarked, rDestDoc.maTabs[i]);
+ nFlags, bOnlyMarked, rDestDoc.maTabs[i].get());
}
if (nTab2 < static_cast<SCTAB>(maTabs.size()))
@@ -2230,7 +2215,7 @@ void ScDocument::CopyToClip(const ScClipParam& rClipParam,
if ( pMarks && !pMarks->GetTableSelect(i) )
continue;
- maTabs[i]->CopyToClip(aCxt, rClipParam.maRanges, pClipDoc->maTabs[i]);
+ maTabs[i]->CopyToClip(aCxt, rClipParam.maRanges, pClipDoc->maTabs[i].get());
if (mpDrawLayer && bIncludeObjects)
{
@@ -2250,8 +2235,8 @@ void ScDocument::CopyStaticToDocument(const ScRange& rSrcRange, SCTAB nDestTab,
if (!pDestDoc)
return;
- ScTable* pSrcTab = rSrcRange.aStart.Tab() < static_cast<SCTAB>(maTabs.size()) ? maTabs[rSrcRange.aStart.Tab()] : nullptr;
- ScTable* pDestTab = nDestTab < static_cast<SCTAB>(pDestDoc->maTabs.size()) ? pDestDoc->maTabs[nDestTab] : nullptr;
+ ScTable* pSrcTab = rSrcRange.aStart.Tab() < static_cast<SCTAB>(maTabs.size()) ? maTabs[rSrcRange.aStart.Tab()].get() : nullptr;
+ ScTable* pDestTab = nDestTab < static_cast<SCTAB>(pDestDoc->maTabs.size()) ? pDestDoc->maTabs[nDestTab].get() : nullptr;
if (!pSrcTab || !pDestTab)
return;
@@ -2324,7 +2309,7 @@ void ScDocument::CopyTabToClip(SCCOL nCol1, SCROW nRow1,
sc::CopyToClipContext aCxt(*pClipDoc, false);
if (nTab < static_cast<SCTAB>(maTabs.size()) && nTab < static_cast<SCTAB>(pClipDoc->maTabs.size()))
if (maTabs[nTab] && pClipDoc->maTabs[nTab])
- maTabs[nTab]->CopyToClip(aCxt, nCol1, nRow1, nCol2, nRow2, pClipDoc->maTabs[nTab]);
+ maTabs[nTab]->CopyToClip(aCxt, nCol1, nRow1, nCol2, nRow2, pClipDoc->maTabs[nTab].get());
pClipDoc->GetClipParam().mbCutMode = false;
}
@@ -2366,7 +2351,7 @@ void ScDocument::TransposeClip( ScDocument* pTransClip, InsertDeleteFlags nFlags
OSL_ENSURE( pTransClip->maTabs[i], "TransposeClip: Table not there" );
maTabs[i]->TransposeClip( aClipRange.aStart.Col(), aClipRange.aStart.Row(),
aClipRange.aEnd.Col(), aClipRange.aEnd.Row(),
- pTransClip->maTabs[i], nFlags, bAsLink );
+ pTransClip->maTabs[i].get(), nFlags, bAsLink );
if ( mpDrawLayer && ( nFlags & InsertDeleteFlags::OBJECTS ) )
{
@@ -2514,7 +2499,7 @@ ScTable* ScDocument::FetchTable( SCTAB nTab )
if (!TableExists(nTab))
return nullptr;
- return maTabs[nTab];
+ return maTabs[nTab].get();
}
const ScTable* ScDocument::FetchTable( SCTAB nTab ) const
@@ -2522,7 +2507,7 @@ const ScTable* ScDocument::FetchTable( SCTAB nTab ) const
if (!TableExists(nTab))
return nullptr;
- return maTabs[nTab];
+ return maTabs[nTab].get();
}
ScColumnsRange ScDocument::GetColumnsRange( SCTAB nTab, SCCOL nColBegin, SCCOL nColEnd) const
@@ -2632,7 +2617,7 @@ void ScDocument::CopyBlockFromClip(
while (!rClipTabs[nClipTab]) nClipTab = (nClipTab+1) % static_cast<SCTAB>(rClipTabs.size());
maTabs[i]->CopyFromClip(
- rCxt, nCol1, nRow1, nCol2, nRow2, nDx, nDy, rClipTabs[nClipTab]);
+ rCxt, nCol1, nRow1, nCol2, nRow2, nDx, nDy, rClipTabs[nClipTab].get());
if (rCxt.getClipDoc()->mpDrawLayer && (rCxt.getInsertFlag() & InsertDeleteFlags::OBJECTS))
{
@@ -3270,15 +3255,15 @@ void ScDocument::FillTab( const ScRange& rSrcArea, const ScMarkData& rMark,
// context used for copying content to the temporary mix document.
sc::CopyToDocContext aMixCxt(*pMixDoc);
maTabs[i]->CopyToTable(aMixCxt, nStartCol,nStartRow, nEndCol,nEndRow,
- InsertDeleteFlags::CONTENTS, false, pMixDoc->maTabs[i] );
+ InsertDeleteFlags::CONTENTS, false, pMixDoc->maTabs[i].get() );
}
maTabs[i]->DeleteArea( nStartCol,nStartRow, nEndCol,nEndRow, nDelFlags);
maTabs[nSrcTab]->CopyToTable(aCxt, nStartCol,nStartRow, nEndCol,nEndRow,
- nFlags, false, maTabs[i], nullptr, bAsLink );
+ nFlags, false, maTabs[i].get(), nullptr, bAsLink );
if (bDoMix)
maTabs[i]->MixData(aMixDocCxt, nStartCol,nStartRow, nEndCol,nEndRow,
- nFunction, bSkipEmpty, pMixDoc->maTabs[i] );
+ nFunction, bSkipEmpty, pMixDoc->maTabs[i].get() );
}
SetAutoCalc( bOldAutoCalc );
@@ -3332,15 +3317,15 @@ void ScDocument::FillTabMarked( SCTAB nSrcTab, const ScMarkData& rMark,
sc::CopyToDocContext aMixCxt(*pMixDoc);
maTabs[i]->CopyToTable(aMixCxt, nStartCol,nStartRow, nEndCol,nEndRow,
- InsertDeleteFlags::CONTENTS, true, pMixDoc->maTabs[i], &rMark );
+ InsertDeleteFlags::CONTENTS, true, pMixDoc->maTabs[i].get(), &rMark );
}
maTabs[i]->DeleteSelection( nDelFlags, rMark );
maTabs[nSrcTab]->CopyToTable(aCxt, nStartCol,nStartRow, nEndCol,nEndRow,
- nFlags, true, maTabs[i], &rMark, bAsLink );
+ nFlags, true, maTabs[i].get(), &rMark, bAsLink );
if (bDoMix)
- maTabs[i]->MixMarked(aMixDocCxt, rMark, nFunction, bSkipEmpty, pMixDoc->maTabs[i]);
+ maTabs[i]->MixMarked(aMixDocCxt, rMark, nFunction, bSkipEmpty, pMixDoc->maTabs[i].get());
}
SetAutoCalc( bOldAutoCalc );
@@ -3991,7 +3976,7 @@ void ScDocument::CompileXML()
pRangeName->CompileUnresolvedXML(aCxt);
std::for_each(maTabs.begin(), maTabs.end(),
- [&](ScTable* pTab)
+ [&](std::unique_ptr<ScTable> & pTab)
{
if (pTab)
pTab->CompileXML(aCxt, aProgress);
@@ -4021,7 +4006,7 @@ bool ScDocument::CompileErrorCells(FormulaError nErrCode)
TableContainer::iterator it = maTabs.begin(), itEnd = maTabs.end();
for (; it != itEnd; ++it)
{
- ScTable* pTab = *it;
+ ScTable* pTab = it->get();
if (!pTab)
continue;
@@ -6558,7 +6543,7 @@ void ScDocument::CreateAllNoteCaptions()
TableContainer::iterator it = maTabs.begin(), itEnd = maTabs.end();
for (; it != itEnd; ++it)
{
- ScTable* p = *it;
+ ScTable* p = it->get();
if (p)
p->CreateAllNoteCaptions();
}
@@ -6681,7 +6666,7 @@ SCROW ScDocument::GetNotePosition( SCTAB nTab, SCCOL nCol, size_t nIndex ) const
void ScDocument::GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const
{
- for (ScTable* pTab : maTabs)
+ for (const std::unique_ptr<ScTable> & pTab : maTabs)
{
if (!pTab)
continue;
diff --git a/sc/source/core/data/document10.cxx b/sc/source/core/data/document10.cxx
index 2de34d272730..de1122d5297f 100644
--- a/sc/source/core/data/document10.cxx
+++ b/sc/source/core/data/document10.cxx
@@ -292,7 +292,7 @@ void ScDocument::PreprocessAllRangeNamesUpdate( const std::map<OUString, std::un
TableContainer::iterator it = maTabs.begin(), itEnd = maTabs.end();
for (; it != itEnd; ++it)
{
- ScTable* p = *it;
+ ScTable* p = it->get();
p->PreprocessRangeNameUpdate(aEndListenCxt, aCompileCxt);
}
}
@@ -305,7 +305,7 @@ void ScDocument::PreprocessRangeNameUpdate()
TableContainer::iterator it = maTabs.begin(), itEnd = maTabs.end();
for (; it != itEnd; ++it)
{
- ScTable* p = *it;
+ ScTable* p = it->get();
p->PreprocessRangeNameUpdate(aEndListenCxt, aCompileCxt);
}
}
@@ -318,7 +318,7 @@ void ScDocument::PreprocessDBDataUpdate()
TableContainer::iterator it = maTabs.begin(), itEnd = maTabs.end();
for (; it != itEnd; ++it)
{
- ScTable* p = *it;
+ ScTable* p = it->get();
p->PreprocessDBDataUpdate(aEndListenCxt, aCompileCxt);
}
}
@@ -330,7 +330,7 @@ void ScDocument::CompileHybridFormula()
TableContainer::iterator it = maTabs.begin(), itEnd = maTabs.end();
for (; it != itEnd; ++it)
{
- ScTable* p = *it;
+ ScTable* p = it->get();
p->CompileHybridFormula(aStartListenCxt, aCompileCxt);
}
}
@@ -477,7 +477,7 @@ public:
mpCxt->setColumnSet( rpColSet);
}
- void operator() (ScTable* p)
+ void operator() (std::unique_ptr<ScTable> & p)
{
if (p)
p->StartListeners(*mpCxt, false);
@@ -522,7 +522,7 @@ void ScDocument::finalizeOutlineImport()
TableContainer::iterator it = maTabs.begin(), itEnd = maTabs.end();
for (; it != itEnd; ++it)
{
- ScTable* p = *it;
+ ScTable* p = it->get();
p->finalizeOutlineImport();
}
}
diff --git a/sc/source/core/data/documentimport.cxx b/sc/source/core/data/documentimport.cxx
index d5788a0e2d03..c51acb900d81 100644
--- a/sc/source/core/data/documentimport.cxx
+++ b/sc/source/core/data/documentimport.cxx
@@ -161,7 +161,7 @@ bool ScDocumentImport::appendSheet(const OUString& rName)
if (!ValidTab(nTabCount))
return false;
- mpImpl->mrDoc.maTabs.push_back(new ScTable(&mpImpl->mrDoc, nTabCount, rName));
+ mpImpl->mrDoc.maTabs.emplace_back(new ScTable(&mpImpl->mrDoc, nTabCount, rName));
return true;
}
More information about the Libreoffice-commits
mailing list