diff options
author | Noel Grandin <noel@peralex.com> | 2012-08-14 14:47:34 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-08-16 15:14:56 +0200 |
commit | 028b34d93be5b794a195df518741ed67f9afdc09 (patch) | |
tree | c4c01c0eecb3d28f0b5a5ac2cc47f7b2e4305541 /svx/source/svdraw | |
parent | 0aafccd61ee557ab35c3b0ead22f90a633ef80b8 (diff) |
Convert OLEObjCache class from Container to std::vector
Change-Id: Id1cbbfb2b8436a28647a528db3ae7ed46d32da83
Diffstat (limited to 'svx/source/svdraw')
-rw-r--r-- | svx/source/svdraw/svdetc.cxx | 30 | ||||
-rw-r--r-- | svx/source/svdraw/svdoole2.cxx | 4 |
2 files changed, 19 insertions, 15 deletions
diff --git a/svx/source/svdraw/svdetc.cxx b/svx/source/svdraw/svdetc.cxx index 7cab83dc4e1b..e43b55b0269f 100644 --- a/svx/source/svdraw/svdetc.cxx +++ b/svx/source/svdraw/svdetc.cxx @@ -103,7 +103,7 @@ const LocaleDataWrapper* SdrGlobalData::GetLocaleData() //////////////////////////////////////////////////////////////////////////////////////////////////// OLEObjCache::OLEObjCache() -: Container( 0 ) +: std::vector<SdrOle2Obj*>() { nSize = officecfg::Office::Common::Cache::DrawingEngine::OLE_Objects::get(); pTimer = new AutoTimer(); @@ -124,15 +124,15 @@ OLEObjCache::~OLEObjCache() void OLEObjCache::UnloadOnDemand() { - if ( nSize < Count() ) + if ( nSize < size() ) { // more objects than configured cache size try to remove objects // of course not the freshly inserted one at nIndex=0 - sal_uIntPtr nCount2 = Count(); + sal_uIntPtr nCount2 = size(); sal_uIntPtr nIndex = nCount2-1; while( nIndex && nCount2 > nSize ) { - SdrOle2Obj* pUnloadObj = (SdrOle2Obj*) GetObject(nIndex--); + SdrOle2Obj* pUnloadObj = (*this)[nIndex--]; if ( pUnloadObj ) { try @@ -148,9 +148,9 @@ void OLEObjCache::UnloadOnDemand() uno::Reference< frame::XModel > xUnloadModel( xUnloadObj->getComponent(), uno::UNO_QUERY ); if ( xUnloadModel.is() ) { - for ( sal_uIntPtr nCheckInd = 0; nCheckInd < Count(); nCheckInd++ ) + for ( sal_uIntPtr nCheckInd = 0; nCheckInd < size(); nCheckInd++ ) { - SdrOle2Obj* pCacheObj = (SdrOle2Obj*) GetObject(nCheckInd); + SdrOle2Obj* pCacheObj = (*this)[nCheckInd]; if ( pCacheObj && pCacheObj != pUnloadObj ) { uno::Reference< frame::XModel > xParentModel = pCacheObj->GetParentXModel(); @@ -174,22 +174,24 @@ void OLEObjCache::UnloadOnDemand() void OLEObjCache::InsertObj(SdrOle2Obj* pObj) { - if ( Count() ) + if ( !empty() ) { - SdrOle2Obj* pExistingObj = (SdrOle2Obj*)GetObject( 0 ); + SdrOle2Obj* pExistingObj = front(); if ( pObj == pExistingObj ) // the object is already on the top, nothing has to be changed return; } // get the old position of the object to know whether it is already in container - sal_uIntPtr nOldPos = GetPos( pObj ); + iterator it = std::find( begin(), end(), pObj ); + bool bFound = it != end(); + if( it != end() ) + erase( it ); // insert object into first position - Remove( nOldPos ); - Insert(pObj, (sal_uIntPtr) 0L); + insert(begin(), pObj); - if ( nOldPos == CONTAINER_ENTRY_NOTFOUND ) + if ( !bFound ) { // a new object was inserted, recalculate the cache UnloadOnDemand(); @@ -198,7 +200,9 @@ void OLEObjCache::InsertObj(SdrOle2Obj* pObj) void OLEObjCache::RemoveObj(SdrOle2Obj* pObj) { - Remove(pObj); + iterator it = std::find( begin(), end(), pObj ); + if( it != end() ) + erase( it ); } sal_Bool OLEObjCache::UnloadObj(SdrOle2Obj* pObj) diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx index 8c111dce9133..9c5c8f89d4e6 100644 --- a/svx/source/svdraw/svdoole2.cxx +++ b/svx/source/svdraw/svdoole2.cxx @@ -391,10 +391,10 @@ void SAL_CALL SdrLightEmbeddedClient_Impl::activatingUI() xParentFrame->setActiveFrame( xOwnFrame ); OLEObjCache& rObjCache = GetSdrGlobalData().GetOLEObjCache(); - const sal_uIntPtr nCount = rObjCache.Count(); + const sal_uIntPtr nCount = rObjCache.size(); for(sal_Int32 i = nCount-1 ; i >= 0;--i) { - SdrOle2Obj* pObj = reinterpret_cast<SdrOle2Obj*>(rObjCache.GetObject(i)); + SdrOle2Obj* pObj = rObjCache[i]; if ( pObj != mpObj ) { // only deactivate ole objects which belongs to the same frame |