[Libreoffice-commits] core.git: 2 commits - include/svx svx/source
Kohei Yoshida
kohei.yoshida at collabora.com
Wed Jul 9 12:32:55 PDT 2014
include/svx/svdetc.hxx | 10 +++-
svx/source/svdraw/svdetc.cxx | 104 ++++++++++++++++++++++++-------------------
2 files changed, 67 insertions(+), 47 deletions(-)
New commits:
commit 2e92df040ee02f32ee42ebe6a33e716444a64480
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Wed Jul 9 15:29:46 2014 -0400
Scope reduction.
Change-Id: Ibc9314320c7b22f676978bb8b8157844a12c9bf8
diff --git a/svx/source/svdraw/svdetc.cxx b/svx/source/svdraw/svdetc.cxx
index 592ffce..9df6329 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& )
+ {}
}
}
commit af4aaa22622e432cc0c899e019dfe819a360c567
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Wed Jul 9 15:27:36 2014 -0400
Let's not derive from std::vector.
Change-Id: I512d97d36c344df097cc5a1ac90aa9d3d219c1e9
diff --git a/include/svx/svdetc.hxx b/include/svx/svdetc.hxx
index 918205e..6212aab 100644
--- a/include/svx/svdetc.hxx
+++ b/include/svx/svdetc.hxx
@@ -195,9 +195,11 @@ SdrLinkList& ImpGetUserMakeObjUserDataHdl();
class SdrOle2Obj;
class AutoTimer;
-class OLEObjCache : public std::vector<SdrOle2Obj*>
+class OLEObjCache
{
- sal_uIntPtr nSize;
+ std::vector<SdrOle2Obj*> maObjs;
+
+ size_t nSize;
AutoTimer* pTimer;
void UnloadOnDemand();
@@ -210,6 +212,10 @@ public:
void InsertObj(SdrOle2Obj* pObj);
void RemoveObj(SdrOle2Obj* pObj);
+
+ size_t size() const;
+ SdrOle2Obj* operator[](size_t nPos);
+ const SdrOle2Obj* operator[](size_t nPos) const;
};
diff --git a/svx/source/svdraw/svdetc.cxx b/svx/source/svdraw/svdetc.cxx
index a9cb949..592ffce 100644
--- a/svx/source/svdraw/svdetc.cxx
+++ b/svx/source/svdraw/svdetc.cxx
@@ -95,7 +95,6 @@ const LocaleDataWrapper* SdrGlobalData::GetLocaleData()
OLEObjCache::OLEObjCache()
-: std::vector<SdrOle2Obj*>()
{
nSize = officecfg::Office::Common::Cache::DrawingEngine::OLE_Objects::get();
pTimer = new AutoTimer();
@@ -116,15 +115,15 @@ OLEObjCache::~OLEObjCache()
void OLEObjCache::UnloadOnDemand()
{
- if ( nSize < size() )
+ if (nSize < maObjs.size())
{
// more objects than configured cache size try to remove objects
// of course not the freshly inserted one at nIndex=0
- sal_uIntPtr nCount2 = size();
- sal_uIntPtr nIndex = nCount2-1;
+ size_t nCount2 = maObjs.size();
+ size_t nIndex = nCount2-1;
while( nIndex && nCount2 > nSize )
{
- SdrOle2Obj* pUnloadObj = (*this)[nIndex--];
+ SdrOle2Obj* pUnloadObj = maObjs[nIndex--];
if ( pUnloadObj )
{
try
@@ -140,9 +139,9 @@ void OLEObjCache::UnloadOnDemand()
uno::Reference< frame::XModel > xUnloadModel( xUnloadObj->getComponent(), uno::UNO_QUERY );
if ( xUnloadModel.is() )
{
- for ( sal_uIntPtr nCheckInd = 0; nCheckInd < size(); nCheckInd++ )
+ for (size_t nCheckInd = 0; nCheckInd < maObjs.size(); nCheckInd++)
{
- SdrOle2Obj* pCacheObj = (*this)[nCheckInd];
+ SdrOle2Obj* pCacheObj = maObjs[nCheckInd];
if ( pCacheObj && pCacheObj != pUnloadObj )
{
uno::Reference< frame::XModel > xParentModel = pCacheObj->GetParentXModel();
@@ -166,22 +165,22 @@ void OLEObjCache::UnloadOnDemand()
void OLEObjCache::InsertObj(SdrOle2Obj* pObj)
{
- if ( !empty() )
+ if (!maObjs.empty())
{
- SdrOle2Obj* pExistingObj = front();
+ SdrOle2Obj* pExistingObj = maObjs.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
- iterator it = std::find( begin(), end(), pObj );
- bool bFound = it != end();
+ std::vector<SdrOle2Obj*>::iterator it = std::find(maObjs.begin(), maObjs.end(), pObj);
+ bool bFound = it != maObjs.end();
- if( it != end() )
- erase( it );
+ if (bFound)
+ maObjs.erase(it);
// insert object into first position
- insert(begin(), pObj);
+ maObjs.insert(maObjs.begin(), pObj);
if ( !bFound )
{
@@ -192,9 +191,24 @@ void OLEObjCache::InsertObj(SdrOle2Obj* pObj)
void OLEObjCache::RemoveObj(SdrOle2Obj* pObj)
{
- iterator it = std::find( begin(), end(), pObj );
- if( it != end() )
- erase( it );
+ std::vector<SdrOle2Obj*>::iterator it = std::find(maObjs.begin(), maObjs.end(), pObj);
+ if (it != maObjs.end())
+ maObjs.erase(it);
+}
+
+size_t OLEObjCache::size() const
+{
+ return maObjs.size();
+}
+
+SdrOle2Obj* OLEObjCache::operator[](size_t nPos)
+{
+ return maObjs[nPos];
+}
+
+const SdrOle2Obj* OLEObjCache::operator[](size_t nPos) const
+{
+ return maObjs[nPos];
}
bool OLEObjCache::UnloadObj(SdrOle2Obj* pObj)
More information about the Libreoffice-commits
mailing list