summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@suse.com>2012-02-01 16:13:39 -0500
committerKohei Yoshida <kohei.yoshida@suse.com>2012-02-01 20:21:05 -0500
commite0917855f80eb64b3eacce13152810d8b8932517 (patch)
tree93dad7820a8a7a2abc7e90615f3b440cae0623bf
parent9ad6925552b6c6a366bd8a349a3bd78eb2d4bb92 (diff)
Always look up chart objects by name, change method names' casing.
The old container always perform lookups by name only.
-rw-r--r--sc/inc/chartlis.hxx14
-rw-r--r--sc/source/core/data/documen5.cxx10
-rw-r--r--sc/source/core/data/documen8.cxx2
-rw-r--r--sc/source/core/data/document.cxx2
-rw-r--r--sc/source/core/tool/charthelper.cxx10
-rw-r--r--sc/source/core/tool/chartlis.cxx45
-rw-r--r--sc/source/filter/excel/xichart.cxx2
-rw-r--r--sc/source/filter/xml/XMLTableShapeResizer.cxx2
-rw-r--r--sc/source/filter/xml/xmlexprt.cxx4
-rw-r--r--sc/source/ui/docshell/docsh4.cxx2
-rw-r--r--sc/source/ui/unoobj/cellsuno.cxx8
-rw-r--r--sc/source/ui/unoobj/chartuno.cxx6
12 files changed, 40 insertions, 67 deletions
diff --git a/sc/inc/chartlis.hxx b/sc/inc/chartlis.hxx
index b08af31f77f0..8e8f7391a75a 100644
--- a/sc/inc/chartlis.hxx
+++ b/sc/inc/chartlis.hxx
@@ -179,15 +179,15 @@ public:
// only needed after copy-ctor, if newly added to doc
void StartAllListeners();
- SC_DLLPUBLIC void Insert(ScChartListener* pListener);
- ScChartListener* Find(const ScChartListener& rListener);
- const ScChartListener* Find(const ScChartListener& rListener) const;
- bool HasListeners() const;
+ SC_DLLPUBLIC void insert(ScChartListener* pListener);
+ ScChartListener* findByName(const rtl::OUString& rName);
+ const ScChartListener* findByName(const rtl::OUString& rName) const;
+ bool hasListeners() const;
- const ListenersType& GetListeners() const;
- ListenersType& GetListeners();
+ const ListenersType& getListeners() const;
+ ListenersType& getListeners();
- rtl::OUString GetUniqueName(const rtl::OUString& rPrefix) const;
+ rtl::OUString getUniqueName(const rtl::OUString& rPrefix) const;
void ChangeListening( const String& rName,
const ScRangeListRef& rRangeListRef,
diff --git a/sc/source/core/data/documen5.cxx b/sc/source/core/data/documen5.cxx
index e5101d8611ce..d09b87b6e6b8 100644
--- a/sc/source/core/data/documen5.cxx
+++ b/sc/source/core/data/documen5.cxx
@@ -188,7 +188,7 @@ void ScDocument::UpdateAllCharts()
ScChartListener* pCL = new ScChartListener(
aIPName, this, pChartObj->GetRangeList() );
- pChartListenerCollection->Insert( pCL );
+ pChartListenerCollection->insert( pCL );
pCL->StartListeningTo();
}
}
@@ -503,7 +503,7 @@ void ScDocument::UpdateChartRef( UpdateRefMode eUpdateRefMode,
if (!pDrawLayer)
return;
- ScChartListenerCollection::ListenersType& rListeners = pChartListenerCollection->GetListeners();
+ ScChartListenerCollection::ListenersType& rListeners = pChartListenerCollection->getListeners();
ScChartListenerCollection::ListenersType::iterator it = rListeners.begin(), itEnd = rListeners.end();
for (; it != itEnd; ++it)
{
@@ -696,9 +696,6 @@ void ScDocument::UpdateChartListenerCollection()
if (!pDrawLayer)
return;
- ScRange aRange;
- // Range for searching is not important
- ScChartListener aCLSearcher( EMPTY_STRING, this, aRange );
for (SCTAB nTab=0; nTab< static_cast<SCTAB>(maTabs.size()); nTab++)
{
if (!maTabs[nTab])
@@ -717,8 +714,7 @@ void ScDocument::UpdateChartListenerCollection()
continue;
rtl::OUString aObjName = ((SdrOle2Obj*)pObject)->GetPersistName();
- aCLSearcher.SetName(aObjName);
- ScChartListener* pListener = pChartListenerCollection->Find(aCLSearcher);
+ ScChartListener* pListener = pChartListenerCollection->findByName(aObjName);
if (pListener)
pListener->SetUsed(true);
else if ( lcl_StringInCollection( pOtherObjects, aObjName ) )
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index 08db4fcef5ee..021274554ecc 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -1464,7 +1464,7 @@ void ScDocument::UpdateRefAreaLinks( UpdateRefMode eUpdateRefMode,
// TimerDelays etc.
void ScDocument::KeyInput( const KeyEvent& )
{
- if ( pChartListenerCollection->HasListeners() )
+ if ( pChartListenerCollection->hasListeners() )
pChartListenerCollection->StartTimer();
if( apTemporaryChartLock.get() )
apTemporaryChartLock->StartOrContinueLocking();
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 6d238250351f..22ec123221b2 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -3485,7 +3485,7 @@ void ScDocument::CalcAfterLoad()
// similar to ScMyShapeResizer::CreateChartListener for loading own files (i104899).
if (pChartListenerCollection)
{
- const ScChartListenerCollection::ListenersType& rListeners = pChartListenerCollection->GetListeners();
+ const ScChartListenerCollection::ListenersType& rListeners = pChartListenerCollection->getListeners();
ScChartListenerCollection::ListenersType::const_iterator it = rListeners.begin(), itEnd = rListeners.end();
for (; it != itEnd; ++it)
{
diff --git a/sc/source/core/tool/charthelper.cxx b/sc/source/core/tool/charthelper.cxx
index 180c0018ecfb..a5522f33d803 100644
--- a/sc/source/core/tool/charthelper.cxx
+++ b/sc/source/core/tool/charthelper.cxx
@@ -305,9 +305,7 @@ void ScChartHelper::AddRangesIfProtectedChart( ScRangeListVector& rRangesVector,
if (pCollection)
{
::rtl::OUString aChartName = pSdrOle2Obj->GetPersistName();
- ScRange aEmptyRange;
- ScChartListener aSearcher( aChartName, pDocument, aEmptyRange );
- const ScChartListener* pListener = pCollection->Find(aSearcher);
+ const ScChartListener* pListener = pCollection->findByName(aChartName);
if (pListener)
{
const ScRangeListRef& rRangeList = pListener->GetRangeList();
@@ -395,15 +393,13 @@ void ScChartHelper::CreateProtectedChartListenersAndNotify( ScDocument* pDoc, Sd
{
if ( bSameDoc )
{
- ScRange aEmptyRange;
- ScChartListener aSearcher( aChartName, pDoc, aEmptyRange );
ScChartListenerCollection* pCollection = pDoc->GetChartListenerCollection();
- if (pCollection && !pCollection->Find(aSearcher))
+ if (pCollection && !pCollection->findByName(aChartName))
{
ScRangeList aRangeList( rRangesVector[ nRangeList++ ] );
ScRangeListRef rRangeList( new ScRangeList( aRangeList ) );
ScChartListener* pChartListener = new ScChartListener( aChartName, pDoc, rRangeList );
- pCollection->Insert( pChartListener );
+ pCollection->insert( pChartListener );
pChartListener->StartListeningTo();
}
}
diff --git a/sc/source/core/tool/chartlis.cxx b/sc/source/core/tool/chartlis.cxx
index f8afb8123357..49d67a407bca 100644
--- a/sc/source/core/tool/chartlis.cxx
+++ b/sc/source/core/tool/chartlis.cxx
@@ -502,54 +502,40 @@ void ScChartListenerCollection::StartAllListeners()
it->second->StartListeningTo();
}
-void ScChartListenerCollection::Insert(ScChartListener* pListener)
+void ScChartListenerCollection::insert(ScChartListener* pListener)
{
rtl::OUString aName = pListener->GetName();
maListeners.insert(aName, pListener);
}
-ScChartListener* ScChartListenerCollection::Find(const ScChartListener& rListener)
+ScChartListener* ScChartListenerCollection::findByName(const rtl::OUString& rName)
{
- ListenersType::iterator it = maListeners.begin(), itEnd = maListeners.end();
- for (; it != itEnd; ++it)
- {
- ScChartListener* p = it->second;
- OSL_ASSERT(p);
- if (*p == rListener)
- return p;
- }
- return NULL;
+ ListenersType::iterator it = maListeners.find(rName);
+ return it == maListeners.end() ? NULL : it->second;
}
-const ScChartListener* ScChartListenerCollection::Find(const ScChartListener& rListener) const
+const ScChartListener* ScChartListenerCollection::findByName(const rtl::OUString& rName) const
{
- ListenersType::const_iterator it = maListeners.begin(), itEnd = maListeners.end();
- for (; it != itEnd; ++it)
- {
- const ScChartListener* p = it->second;
- OSL_ASSERT(p);
- if (*p == rListener)
- return p;
- }
- return NULL;
+ ListenersType::const_iterator it = maListeners.find(rName);
+ return it == maListeners.end() ? NULL : it->second;
}
-bool ScChartListenerCollection::HasListeners() const
+bool ScChartListenerCollection::hasListeners() const
{
return !maListeners.empty();
}
-const ScChartListenerCollection::ListenersType& ScChartListenerCollection::GetListeners() const
+const ScChartListenerCollection::ListenersType& ScChartListenerCollection::getListeners() const
{
return maListeners;
}
-ScChartListenerCollection::ListenersType& ScChartListenerCollection::GetListeners()
+ScChartListenerCollection::ListenersType& ScChartListenerCollection::getListeners()
{
return maListeners;
}
-rtl::OUString ScChartListenerCollection::GetUniqueName(const rtl::OUString& rPrefix) const
+rtl::OUString ScChartListenerCollection::getUniqueName(const rtl::OUString& rPrefix) const
{
for (sal_Int32 nNum = 1; nNum < 10000; ++nNum) // arbitrary limit to prevent infinite loop.
{
@@ -565,8 +551,7 @@ rtl::OUString ScChartListenerCollection::GetUniqueName(const rtl::OUString& rPre
void ScChartListenerCollection::ChangeListening( const String& rName,
const ScRangeListRef& rRangeListRef, bool bDirty )
{
- ScChartListener aCLSearcher( rName, pDoc, rRangeListRef );
- ScChartListener* pCL = Find(aCLSearcher);
+ ScChartListener* pCL = findByName(rName);
if (pCL)
{
pCL->EndListeningTo();
@@ -574,8 +559,8 @@ void ScChartListenerCollection::ChangeListening( const String& rName,
}
else
{
- pCL = new ScChartListener( aCLSearcher );
- Insert( pCL );
+ pCL = new ScChartListener(rName, pDoc, rRangeListRef);
+ insert(pCL);
}
pCL->StartListeningTo();
if ( bDirty )
@@ -716,7 +701,7 @@ void ScChartListenerCollection::SetDiffDirty(
{
ScChartListener* pCL = it->second;
OSL_ASSERT(pCL);
- const ScChartListener* pCLCmp = rCmp.Find(*pCL);
+ const ScChartListener* pCLCmp = rCmp.findByName(pCL->GetName());
if (!pCLCmp || *pCL != *pCLCmp)
{
if ( bSetChartRangeLists )
diff --git a/sc/source/filter/excel/xichart.cxx b/sc/source/filter/excel/xichart.cxx
index d02cecf484b2..6caf627db6af 100644
--- a/sc/source/filter/excel/xichart.cxx
+++ b/sc/source/filter/excel/xichart.cxx
@@ -4013,7 +4013,7 @@ void XclImpChChart::Convert( const Reference<XChartDocument>& xChartDoc,
SAL_WNODEPRECATED_DECLARATIONS_POP
xListener->SetUsed( true );
xListener->StartListeningTo();
- pChartCollection->Insert( xListener.release() );
+ pChartCollection->insert( xListener.release() );
}
}
}
diff --git a/sc/source/filter/xml/XMLTableShapeResizer.cxx b/sc/source/filter/xml/XMLTableShapeResizer.cxx
index 8bbc6b843c17..61b686a69067 100644
--- a/sc/source/filter/xml/XMLTableShapeResizer.cxx
+++ b/sc/source/filter/xml/XMLTableShapeResizer.cxx
@@ -114,7 +114,7 @@ void ScMyOLEFixer::CreateChartListener(ScDocument* pDoc,
pDoc->InterpretDirtyCells( *pCL->GetRangeList() );
}
- pCollection->Insert( pCL );
+ pCollection->insert( pCL );
pCL->StartListeningTo();
}
}
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 2d6dbad36ae4..5e92182207b9 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -3060,12 +3060,10 @@ void ScXMLExport::ExportShape(const uno::Reference < drawing::XShape >& xShape,
{
::rtl::OUString aChartName;
xShapeProps->getPropertyValue( sPersistName ) >>= aChartName;
- ScRange aEmptyRange;
- ScChartListener aSearcher( aChartName, pDoc, aEmptyRange );
ScChartListenerCollection* pCollection = pDoc->GetChartListenerCollection();
if (pCollection)
{
- ScChartListener* pListener = pCollection->Find(aSearcher);
+ ScChartListener* pListener = pCollection->findByName(aChartName);
if (pListener)
{
const ScRangeListRef& rRangeList = pListener->GetRangeList();
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index 40c35f983c5e..7e5f39512bed 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -1223,7 +1223,7 @@ void ScDocShell::DoRecalc( bool bApi )
// doppelt gepainted werden.
ScChartListenerCollection* pCharts = aDocument.GetChartListenerCollection();
- if ( pCharts && pCharts->HasListeners() )
+ if ( pCharts && pCharts->hasListeners() )
PostPaintGridAll();
else
PostDataChanged();
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index a19091e17b3a..1bddc21671ce 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -1113,7 +1113,7 @@ sal_Bool lcl_PutDataArray( ScDocShell& rDocShell, const ScRange& rRange,
using XCellRangeData::setDataArray() significantly. */
bool bDoubleAlloc = ScColumn::bDoubleAlloc;
ScColumn::bDoubleAlloc = true;
-
+
sal_Bool bError = false;
SCROW nDocRow = nStartRow;
for (long nRow=0; nRow<nRows; nRow++)
@@ -3253,7 +3253,7 @@ void ScCellRangesBase::ForceChartListener_Impl()
if (!pColl)
return;
- ScChartListenerCollection::ListenersType& rListeners = pColl->GetListeners();
+ ScChartListenerCollection::ListenersType& rListeners = pColl->getListeners();
ScChartListenerCollection::ListenersType::iterator it = rListeners.begin(), itEnd = rListeners.end();
for (; it != itEnd; ++it)
{
@@ -3276,14 +3276,14 @@ void SAL_CALL ScCellRangesBase::addChartDataChangeEventListener( const uno::Refe
ScDocument* pDoc = pDocShell->GetDocument();
ScRangeListRef aRangesRef( new ScRangeList(aRanges) );
ScChartListenerCollection* pColl = pDoc->GetChartListenerCollection();
- rtl::OUString aName = pColl->GetUniqueName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("__Uno")));
+ rtl::OUString aName = pColl->getUniqueName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("__Uno")));
if (aName.isEmpty())
// failed to create unique name.
return;
ScChartListener* pListener = new ScChartListener( aName, pDoc, aRangesRef );
pListener->SetUno( aListener, this );
- pColl->Insert( pListener );
+ pColl->insert( pListener );
pListener->StartListeningTo();
}
}
diff --git a/sc/source/ui/unoobj/chartuno.cxx b/sc/source/ui/unoobj/chartuno.cxx
index f2218b99ffc6..8eac2405e7e3 100644
--- a/sc/source/ui/unoobj/chartuno.cxx
+++ b/sc/source/ui/unoobj/chartuno.cxx
@@ -287,7 +287,7 @@ void SAL_CALL ScChartsObj::addNewByName( const rtl::OUString& aName,
ScChartListener* pChartListener =
new ScChartListener( aObjName, pDoc, xNewRanges );
- pDoc->GetChartListenerCollection()->Insert( pChartListener );
+ pDoc->GetChartListenerCollection()->insert( pChartListener );
pChartListener->StartListeningTo();
SdrOle2Obj* pObj = new SdrOle2Obj( ::svt::EmbeddedObjectRef( xObj, embed::Aspects::MSOLE_CONTENT ), aObjName, aInsRect );
@@ -607,13 +607,11 @@ void ScChartObj::getFastPropertyValue( uno::Any& rValue, sal_Int32 nHandle ) con
if (!pDoc)
break;
- ScRange aEmptyRange;
ScChartListenerCollection* pCollection = pDoc->GetChartListenerCollection();
if (!pCollection)
break;
- ScChartListener aSearcher(aChartName, pDoc, aEmptyRange);
- ScChartListener* pListener = pCollection->Find(aSearcher);
+ ScChartListener* pListener = pCollection->findByName(aChartName);
if (!pListener)
break;