summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-07-21 10:36:23 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-07-21 11:39:48 +0200
commit4f974eceb0e49f5e8cdbc8b9990a74811feb1927 (patch)
tree2878630e4d7b1cd75528a601c7d0950230427747
parentad4e6f8c8f3d9d96586967f8e9a813bf29c3033a (diff)
flatten ScDetOpList vector
Change-Id: I08256d2e4631fe4a2134da37892a50f8b0579834 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119308 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sc/inc/detdata.hxx7
-rw-r--r--sc/source/core/data/documen4.cxx2
-rw-r--r--sc/source/core/tool/detdata.cxx25
-rw-r--r--sc/source/ui/undo/undocell.cxx2
4 files changed, 15 insertions, 21 deletions
diff --git a/sc/inc/detdata.hxx b/sc/inc/detdata.hxx
index 927ad29a4b5e..db8e2f6cc4e9 100644
--- a/sc/inc/detdata.hxx
+++ b/sc/inc/detdata.hxx
@@ -42,9 +42,6 @@ public:
ScDetOpData( const ScAddress& rP, ScDetOpType eOp ) :
aPos(rP), eOperation(eOp) {}
- ScDetOpData( const ScDetOpData& rData ) :
- aPos(rData.aPos), eOperation(rData.eOperation) {}
-
const ScAddress& GetPos() const { return aPos; }
ScDetOpType GetOperation() const { return eOperation; }
@@ -57,7 +54,7 @@ public:
// list of operators
-typedef std::vector<std::unique_ptr<ScDetOpData>> ScDetOpDataVector;
+typedef std::vector<ScDetOpData> ScDetOpDataVector;
class ScDetOpList
{
@@ -74,7 +71,7 @@ public:
bool operator==( const ScDetOpList& r ) const; // for ref-undo
- void Append( ScDetOpData* pData );
+ void Append( const ScDetOpData& );
ScDetOpDataVector& GetDataVector() { return aDetOpDataVector; }
const ScDetOpData& GetObject( size_t nPos ) const;
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index aa3b6f69f74d..50bbb874481f 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -893,7 +893,7 @@ void ScDocument::AddDetectiveOperation( const ScDetOpData& rData )
if (!pDetOpList)
pDetOpList.reset(new ScDetOpList);
- pDetOpList->Append( new ScDetOpData( rData ) );
+ pDetOpList->Append( rData );
}
void ScDocument::ClearDetectiveOperations()
diff --git a/sc/source/core/tool/detdata.cxx b/sc/source/core/tool/detdata.cxx
index feacceca6e28..b232a4dddab4 100644
--- a/sc/source/core/tool/detdata.cxx
+++ b/sc/source/core/tool/detdata.cxx
@@ -23,19 +23,16 @@
#include <refupdat.hxx>
ScDetOpList::ScDetOpList(const ScDetOpList& rList) :
- bHasAddError( false )
+ bHasAddError( false ),
+ aDetOpDataVector( rList.aDetOpDataVector )
{
- size_t nCount = rList.Count();
-
- for (size_t i=0; i<nCount; i++)
- Append( new ScDetOpData( *rList.aDetOpDataVector[i] ) );
}
void ScDetOpList::DeleteOnTab( SCTAB nTab )
{
aDetOpDataVector.erase(std::remove_if(aDetOpDataVector.begin(), aDetOpDataVector.end(),
- [&nTab](const std::unique_ptr<ScDetOpData>& rxDetOpData) {
- return rxDetOpData->GetPos().Tab() == nTab; // look for operations on the deleted sheet
+ [&nTab](const ScDetOpData& rxDetOpData) {
+ return rxDetOpData.GetPos().Tab() == nTab; // look for operations on the deleted sheet
}),
aDetOpDataVector.end());
}
@@ -45,7 +42,7 @@ void ScDetOpList::UpdateReference( const ScDocument* pDoc, UpdateRefMode eUpdate
{
for (auto& rxDetOpData : aDetOpDataVector )
{
- ScAddress aPos = rxDetOpData->GetPos();
+ ScAddress aPos = rxDetOpData.GetPos();
SCCOL nCol1 = aPos.Col();
SCROW nRow1 = aPos.Row();
SCTAB nTab1 = aPos.Tab();
@@ -59,16 +56,16 @@ void ScDetOpList::UpdateReference( const ScDocument* pDoc, UpdateRefMode eUpdate
rRange.aEnd.Col(), rRange.aEnd.Row(), rRange.aEnd.Tab(), nDx, nDy, nDz,
nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
if ( eRes != UR_NOTHING )
- rxDetOpData->SetPos( ScAddress( nCol1, nRow1, nTab1 ) );
+ rxDetOpData.SetPos( ScAddress( nCol1, nRow1, nTab1 ) );
}
}
-void ScDetOpList::Append( ScDetOpData* pDetOpData )
+void ScDetOpList::Append( const ScDetOpData& rDetOpData )
{
- if ( pDetOpData->GetOperation() == SCDETOP_ADDERROR )
+ if ( rDetOpData.GetOperation() == SCDETOP_ADDERROR )
bHasAddError = true;
- aDetOpDataVector.push_back( std::unique_ptr<ScDetOpData>(pDetOpData) );
+ aDetOpDataVector.push_back( rDetOpData );
}
bool ScDetOpList::operator==( const ScDetOpList& r ) const
@@ -78,7 +75,7 @@ bool ScDetOpList::operator==( const ScDetOpList& r ) const
size_t nCount = Count();
bool bEqual = ( nCount == r.Count() );
for (size_t i=0; i<nCount && bEqual; i++) // order has to be the same
- if ( !(*aDetOpDataVector[i] == *r.aDetOpDataVector[i]) ) // entries are different ?
+ if ( !(aDetOpDataVector[i] == r.aDetOpDataVector[i]) ) // entries are different ?
bEqual = false;
return bEqual;
@@ -86,7 +83,7 @@ bool ScDetOpList::operator==( const ScDetOpList& r ) const
const ScDetOpData& ScDetOpList::GetObject( size_t nPos ) const
{
- return *aDetOpDataVector[nPos];
+ return aDetOpDataVector[nPos];
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx
index ce503934fe70..583e2dd4e832 100644
--- a/sc/source/ui/undo/undocell.cxx
+++ b/sc/source/ui/undo/undocell.cxx
@@ -928,7 +928,7 @@ void ScUndoDetective::Undo()
{
ScDetOpDataVector& rVec = pList->GetDataVector();
ScDetOpDataVector::iterator it = rVec.begin() + rVec.size() - 1;
- if ( (*it)->GetOperation() == static_cast<ScDetOpType>(nAction) && (*it)->GetPos() == aPos )
+ if ( it->GetOperation() == static_cast<ScDetOpType>(nAction) && it->GetPos() == aPos )
rVec.erase( it);
else
{