summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@suse.com>2012-02-02 12:27:17 -0500
committerKohei Yoshida <kohei.yoshida@suse.com>2012-02-03 00:02:43 -0500
commit2ee44cdce813e5389c9bb7338647c1b0da620459 (patch)
treef35fa58da073ed799958fb34c4b286e7d649ad0d
parent0dbda27fb81bc063c865a6829fb035322fd77035 (diff)
Moved the names of non-OLE charts out of ScDocument.
-rw-r--r--sc/inc/chartlis.hxx4
-rw-r--r--sc/inc/document.hxx1
-rw-r--r--sc/source/core/data/documen2.cxx2
-rw-r--r--sc/source/core/data/documen5.cxx20
-rw-r--r--sc/source/core/tool/chartlis.cxx5
5 files changed, 21 insertions, 11 deletions
diff --git a/sc/inc/chartlis.hxx b/sc/inc/chartlis.hxx
index e710d1f1062b..9707971910c1 100644
--- a/sc/inc/chartlis.hxx
+++ b/sc/inc/chartlis.hxx
@@ -158,10 +158,11 @@ public:
};
typedef boost::ptr_map<rtl::OUString, ScChartListener> ListenersType;
-
+ typedef boost::unordered_set<rtl::OUString, rtl::OUStringHash> StringSetType;
private:
ListenersType maListeners;
::std::list<RangeListenerItem> maHiddenListeners;
+ StringSetType maNonOleObjectNames;
Timer aTimer;
ScDocument* pDoc;
@@ -186,6 +187,7 @@ public:
const ListenersType& getListeners() const;
ListenersType& getListeners();
+ StringSetType& getNonOleObjectNames();
/**
* Create a unique name that's not taken by any existing chart listener
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 7cbebcc3395a..86b2febfbe9d 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -255,7 +255,6 @@ private:
ScFormulaCell* pEOFormulaTrack; // BrodcastTrack (end), last cell
ScBroadcastAreaSlotMachine* pBASM; // BroadcastAreas
ScChartListenerCollection* pChartListenerCollection;
- ScStrCollection* pOtherObjects; // non-chart OLE objects
SvMemoryStream* pClipData;
ScDetOpList* pDetOpList;
ScChangeTrack* pChangeTrack;
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 5917db0add8c..d79e52d11ee7 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -145,7 +145,6 @@ ScDocument::ScDocument( ScDocumentMode eMode,
pEOFormulaTree( NULL ),
pFormulaTrack( NULL ),
pEOFormulaTrack( NULL ),
- pOtherObjects( NULL ),
pClipData( NULL ),
pDetOpList(NULL),
pChangeTrack( NULL ),
@@ -450,7 +449,6 @@ ScDocument::~ScDocument()
xPoolHelper.clear();
delete pScriptTypeData;
- delete pOtherObjects;
delete pRecursionHelper;
OSL_POSTCOND( !pAutoNameCache, "AutoNameCache still set in dtor" );
diff --git a/sc/source/core/data/documen5.cxx b/sc/source/core/data/documen5.cxx
index d09b87b6e6b8..6abefd7952c6 100644
--- a/sc/source/core/data/documen5.cxx
+++ b/sc/source/core/data/documen5.cxx
@@ -692,6 +692,8 @@ bool lcl_StringInCollection( const ScStrCollection* pColl, const rtl::OUString&
void ScDocument::UpdateChartListenerCollection()
{
+ OSL_ASSERT(pChartListenerCollection);
+
bChartListenerCollectionNeedsUpdate = false;
if (!pDrawLayer)
return;
@@ -708,6 +710,9 @@ void ScDocument::UpdateChartListenerCollection()
continue;
SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
+ ScChartListenerCollection::StringSetType& rNonOleObjects =
+ pChartListenerCollection->getNonOleObjectNames();
+
for (SdrObject* pObject = aIter.Next(); pObject; pObject = aIter.Next())
{
if ( pObject->GetObjIdentifier() != OBJ_OLE2 )
@@ -715,9 +720,10 @@ void ScDocument::UpdateChartListenerCollection()
rtl::OUString aObjName = ((SdrOle2Obj*)pObject)->GetPersistName();
ScChartListener* pListener = pChartListenerCollection->findByName(aObjName);
+
if (pListener)
pListener->SetUsed(true);
- else if ( lcl_StringInCollection( pOtherObjects, aObjName ) )
+ else if (rNonOleObjects.count(aObjName) > 0)
{
// non-chart OLE object -> don't touch
}
@@ -756,9 +762,7 @@ void ScDocument::UpdateChartListenerCollection()
//! remove names when objects are no longer there?
// (object names aren't used again before reloading the document)
- if (!pOtherObjects)
- pOtherObjects = new ScStrCollection;
- pOtherObjects->Insert( new StrData( aObjName ) );
+ rNonOleObjects.insert(aObjName);
}
}
}
@@ -769,9 +773,11 @@ void ScDocument::UpdateChartListenerCollection()
void ScDocument::AddOLEObjectToCollection(const rtl::OUString& rName)
{
- if (!pOtherObjects)
- pOtherObjects = new ScStrCollection;
- pOtherObjects->Insert( new StrData( rName ) );
+ OSL_ASSERT(pChartListenerCollection);
+ ScChartListenerCollection::StringSetType& rNonOleObjects =
+ pChartListenerCollection->getNonOleObjectNames();
+
+ rNonOleObjects.insert(rName);
}
diff --git a/sc/source/core/tool/chartlis.cxx b/sc/source/core/tool/chartlis.cxx
index 49d67a407bca..28f2a86f9eb7 100644
--- a/sc/source/core/tool/chartlis.cxx
+++ b/sc/source/core/tool/chartlis.cxx
@@ -535,6 +535,11 @@ ScChartListenerCollection::ListenersType& ScChartListenerCollection::getListener
return maListeners;
}
+ScChartListenerCollection::StringSetType& ScChartListenerCollection::getNonOleObjectNames()
+{
+ return maNonOleObjectNames;
+}
+
rtl::OUString ScChartListenerCollection::getUniqueName(const rtl::OUString& rPrefix) const
{
for (sal_Int32 nNum = 1; nNum < 10000; ++nNum) // arbitrary limit to prevent infinite loop.