Kaydet (Commit) 2e92df04 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Scope reduction.

Change-Id: Ibc9314320c7b22f676978bb8b8157844a12c9bf8
üst af4aaa22
......@@ -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& )
{}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment