diff options
author | Noel Grandin <noel@peralex.com> | 2012-02-10 13:47:22 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2012-02-10 17:27:27 +0100 |
commit | d4a31e6ae28825a42cb8b1935fdfd777cda41e8f (patch) | |
tree | 47bb5d5002e23f9fb21e06539d74e2fa004034c6 /sc/source | |
parent | 90d1c9ff829c41c8384d66dfd2f6e90660517088 (diff) |
convert detdata.cxx in SC module to boost:ptr_vector
converts usage of SV_DECL_PTRARR_DEL in sc/inc/detdata.hxx and associated code
to boost::ptr_vector
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/core/tool/detdata.cxx | 33 | ||||
-rw-r--r-- | sc/source/ui/docshell/docfunc.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/undo/undocell.cxx | 4 |
3 files changed, 24 insertions, 15 deletions
diff --git a/sc/source/core/tool/detdata.cxx b/sc/source/core/tool/detdata.cxx index 17f6e32c69ef..d23208c22cc3 100644 --- a/sc/source/core/tool/detdata.cxx +++ b/sc/source/core/tool/detdata.cxx @@ -37,18 +37,13 @@ //------------------------------------------------------------------------ -SV_IMPL_PTRARR( ScDetOpArr_Impl, ScDetOpDataPtr ); - -//------------------------------------------------------------------------ - ScDetOpList::ScDetOpList(const ScDetOpList& rList) : - ScDetOpArr_Impl(), bHasAddError( false ) { sal_uInt16 nCount = rList.Count(); for (sal_uInt16 i=0; i<nCount; i++) - Append( new ScDetOpData(*rList[i]) ); + Append( new ScDetOpData(rList.aDetOpDataVector[i]) ); } void ScDetOpList::DeleteOnTab( SCTAB nTab ) @@ -58,8 +53,8 @@ void ScDetOpList::DeleteOnTab( SCTAB nTab ) { // look for operations on the deleted sheet - if ( (*this)[nPos]->GetPos().Tab() == nTab ) - Remove(nPos); + if ( GetObject(nPos)->GetPos().Tab() == nTab ) + DeleteAndDestroy(nPos); else ++nPos; } @@ -71,7 +66,7 @@ void ScDetOpList::UpdateReference( ScDocument* pDoc, UpdateRefMode eUpdateRefMod sal_uInt16 nCount = Count(); for (sal_uInt16 i=0; i<nCount; i++) { - ScAddress aPos = (*this)[i]->GetPos(); + ScAddress aPos = GetObject(i)->GetPos(); SCCOL nCol1 = aPos.Col(); SCROW nRow1 = aPos.Row(); SCTAB nTab1 = aPos.Tab(); @@ -85,7 +80,7 @@ void ScDetOpList::UpdateReference( ScDocument* pDoc, UpdateRefMode eUpdateRefMod rRange.aEnd.Col(), rRange.aEnd.Row(), rRange.aEnd.Tab(), nDx, nDy, nDz, nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 ); if ( eRes != UR_NOTHING ) - (*this)[i]->SetPos( ScAddress( nCol1, nRow1, nTab1 ) ); + GetObject(i)->SetPos( ScAddress( nCol1, nRow1, nTab1 ) ); } } @@ -94,7 +89,7 @@ void ScDetOpList::Append( ScDetOpData* pDetOpData ) if ( pDetOpData->GetOperation() == SCDETOP_ADDERROR ) bHasAddError = sal_True; - Insert( pDetOpData, Count() ); + aDetOpDataVector.push_back( pDetOpData ); } @@ -105,12 +100,26 @@ sal_Bool ScDetOpList::operator==( const ScDetOpList& r ) const sal_uInt16 nCount = Count(); sal_Bool bEqual = ( nCount == r.Count() ); for (sal_uInt16 i=0; i<nCount && bEqual; i++) // Reihenfolge muss auch gleich sein - if ( !(*(*this)[i] == *r[i]) ) // Eintraege unterschiedlich ? + if ( !(aDetOpDataVector[i] == r.aDetOpDataVector[i]) ) // Eintraege unterschiedlich ? bEqual = false; return bEqual; } +ScDetOpData* ScDetOpList::GetObject(int i) +{ + return &aDetOpDataVector[i]; +} + +void ScDetOpList::DeleteAndDestroy(int i) +{ + const ScDetOpData* p = &aDetOpDataVector[i]; + if (p != NULL) + { + delete p; + aDetOpDataVector.erase(aDetOpDataVector.begin() + i); + } +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index a211534b0c9f..ffc4730ceb74 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -493,7 +493,7 @@ sal_Bool ScDocFunc::DetectiveRefresh( sal_Bool bAutomatic ) sal_uInt16 nCount = pList->Count(); for (sal_uInt16 i=0; i<nCount; i++) { - ScDetOpData* pData = (*pList)[i]; + ScDetOpData* pData = pList->GetObject(i); if (pData) { ScAddress aPos = pData->GetPos(); diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx index d0d85ca2707d..321cf789bf68 100644 --- a/sc/source/ui/undo/undocell.cxx +++ b/sc/source/ui/undo/undocell.cxx @@ -1029,9 +1029,9 @@ void ScUndoDetective::Undo() if (pList && pList->Count()) { sal_uInt16 nPos = pList->Count() - 1; - ScDetOpData* pData = (*pList)[nPos]; + ScDetOpData* pData = pList->GetObject(nPos); if ( pData->GetOperation() == (ScDetOpType) nAction && pData->GetPos() == aPos ) - pList->DeleteAndDestroy( nPos, 1 ); + pList->DeleteAndDestroy( nPos ); else { OSL_FAIL("Detektiv-Eintrag in der Liste nicht gefunden"); |