diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-07-09 15:29:46 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-07-09 15:32:44 -0400 |
commit | 2e92df040ee02f32ee42ebe6a33e716444a64480 (patch) | |
tree | b033c7e389f9df27fda0b43ce261b6cf228fa5db /svx | |
parent | af4aaa22622e432cc0c899e019dfe819a360c567 (diff) |
Scope reduction.
Change-Id: Ibc9314320c7b22f676978bb8b8157844a12c9bf8
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/svdraw/svdetc.cxx | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/svx/source/svdraw/svdetc.cxx b/svx/source/svdraw/svdetc.cxx index 592ffce45be2..9df632976158 100644 --- a/svx/source/svdraw/svdetc.cxx +++ b/svx/source/svdraw/svdetc.cxx @@ -115,51 +115,51 @@ OLEObjCache::~OLEObjCache() void OLEObjCache::UnloadOnDemand() { - if (nSize < maObjs.size()) + if (nSize >= maObjs.size()) + return; + + // more objects than configured cache size try to remove objects + // of course not the freshly inserted one at nIndex=0 + size_t nCount2 = maObjs.size(); + size_t nIndex = nCount2-1; + while( nIndex && nCount2 > nSize ) { - // more objects than configured cache size try to remove objects - // of course not the freshly inserted one at nIndex=0 - size_t nCount2 = maObjs.size(); - size_t nIndex = nCount2-1; - while( nIndex && nCount2 > nSize ) + SdrOle2Obj* pUnloadObj = maObjs[nIndex--]; + if (!pUnloadObj) + continue; + + try { - SdrOle2Obj* pUnloadObj = maObjs[nIndex--]; - if ( pUnloadObj ) - { - try - { - // it is important to get object without reinitialization to avoid reentrance - uno::Reference< embed::XEmbeddedObject > xUnloadObj = pUnloadObj->GetObjRef_NoInit(); + // it is important to get object without reinitialization to avoid reentrance + uno::Reference< embed::XEmbeddedObject > xUnloadObj = pUnloadObj->GetObjRef_NoInit(); - bool bUnload = SdrOle2Obj::CanUnloadRunningObj( xUnloadObj, pUnloadObj->GetAspect() ); + bool bUnload = SdrOle2Obj::CanUnloadRunningObj( xUnloadObj, pUnloadObj->GetAspect() ); - // check whether the object can be unloaded before looking for the parent objects - if ( xUnloadObj.is() && bUnload ) + // check whether the object can be unloaded before looking for the parent objects + if ( xUnloadObj.is() && bUnload ) + { + uno::Reference< frame::XModel > xUnloadModel( xUnloadObj->getComponent(), uno::UNO_QUERY ); + if ( xUnloadModel.is() ) + { + for (size_t nCheckInd = 0; nCheckInd < maObjs.size(); nCheckInd++) { - uno::Reference< frame::XModel > xUnloadModel( xUnloadObj->getComponent(), uno::UNO_QUERY ); - if ( xUnloadModel.is() ) + SdrOle2Obj* pCacheObj = maObjs[nCheckInd]; + if ( pCacheObj && pCacheObj != pUnloadObj ) { - for (size_t nCheckInd = 0; nCheckInd < maObjs.size(); nCheckInd++) - { - SdrOle2Obj* pCacheObj = maObjs[nCheckInd]; - if ( pCacheObj && pCacheObj != pUnloadObj ) - { - uno::Reference< frame::XModel > xParentModel = pCacheObj->GetParentXModel(); - if ( xUnloadModel == xParentModel ) - bUnload = false; // the object has running embedded objects - } - } + uno::Reference< frame::XModel > xParentModel = pCacheObj->GetParentXModel(); + if ( xUnloadModel == xParentModel ) + bUnload = false; // the object has running embedded objects } } - - if ( bUnload && UnloadObj(pUnloadObj) ) - // object was successfully unloaded - nCount2--; } - catch( uno::Exception& ) - {} } + + if ( bUnload && UnloadObj(pUnloadObj) ) + // object was successfully unloaded + nCount2--; } + catch( uno::Exception& ) + {} } } |