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 | |
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')
-rw-r--r-- | sc/inc/detdata.hxx | 18 | ||||
-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 |
4 files changed, 32 insertions, 25 deletions
diff --git a/sc/inc/detdata.hxx b/sc/inc/detdata.hxx index 811dde8cd217..891c803d8b18 100644 --- a/sc/inc/detdata.hxx +++ b/sc/inc/detdata.hxx @@ -31,14 +31,10 @@ #include <svl/svarray.hxx> #include "global.hxx" -#include "address.hxx" +#include "boost/ptr_container/ptr_vector.hpp" //------------------------------------------------------------------------ - -#define SC_DETOP_GROW 4 - -//------------------------------------------------------------------------ enum ScDetOpType { SCDETOP_ADDSUCC, @@ -78,13 +74,12 @@ public: // list of operators // -typedef ScDetOpData* ScDetOpDataPtr; - -SV_DECL_PTRARR_DEL(ScDetOpArr_Impl, ScDetOpDataPtr, SC_DETOP_GROW) +typedef boost::ptr_vector<ScDetOpData> ScDetOpDataVector; -class ScDetOpList : public ScDetOpArr_Impl +class ScDetOpList { sal_Bool bHasAddError; // updated in append + ScDetOpDataVector aDetOpDataVector; public: ScDetOpList() : bHasAddError(false) {} @@ -97,9 +92,12 @@ public: sal_Bool operator==( const ScDetOpList& r ) const; // for ref-undo - void Append( ScDetOpData* pData ); + void Append( ScDetOpData* pData ); + ScDetOpData* GetObject(int i); + void DeleteAndDestroy(int i); sal_Bool HasAddError() const { return bHasAddError; } + int Count() const { return aDetOpDataVector.size(); } }; 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"); |