summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@suse.com>2012-02-03 12:43:04 -0500
committerKohei Yoshida <kohei.yoshida@suse.com>2012-02-04 00:25:50 -0500
commit3f80695906fd4d9af0ff7126a6b0b12461268694 (patch)
tree05281aabe25835fb61d2416b28f6e994975ea096 /sc
parentcac7f1d4b524949811589d99093e3bba0e3601d8 (diff)
More on eliminating ScStrCollection.
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/unoobj/linkuno.cxx115
1 files changed, 58 insertions, 57 deletions
diff --git a/sc/source/ui/unoobj/linkuno.cxx b/sc/source/ui/unoobj/linkuno.cxx
index e5f56c4e486e..6ba1bddbd21d 100644
--- a/sc/source/ui/unoobj/linkuno.cxx
+++ b/sc/source/ui/unoobj/linkuno.cxx
@@ -418,27 +418,29 @@ void ScSheetLinksObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
ScSheetLinkObj* ScSheetLinksObj::GetObjectByIndex_Impl(sal_Int32 nIndex)
{
- if (pDocShell)
+ if (!pDocShell)
+ return NULL;
+
+ typedef boost::unordered_set<rtl::OUString, rtl::OUStringHash> StrSetType;
+ StrSetType aNames;
+ ScDocument* pDoc = pDocShell->GetDocument();
+ SCTAB nTabCount = pDoc->GetTableCount();
+ sal_Int32 nCount = 0;
+ for (SCTAB nTab = 0; nTab < nTabCount; ++nTab)
{
- sal_Int32 nCount = 0;
- ScStrCollection aNames; // um doppelte wegzulassen
- ScDocument* pDoc = pDocShell->GetDocument();
- SCTAB nTabCount = pDoc->GetTableCount();
- for (SCTAB nTab=0; nTab<nTabCount; nTab++)
- if (pDoc->IsLinked(nTab))
- {
- String aLinkDoc = pDoc->GetLinkDoc( nTab );
- StrData* pData = new StrData(aLinkDoc);
- if (aNames.Insert(pData))
- {
- if ( nCount == nIndex )
- return new ScSheetLinkObj( pDocShell, aLinkDoc );
- ++nCount;
- }
- else
- delete pData;
- }
+ if (!pDoc->IsLinked(nTab))
+ continue;
+
+ rtl::OUString aLinkDoc = pDoc->GetLinkDoc(nTab);
+ if (aNames.insert(aLinkDoc).second)
+ {
+ // unique document name.
+ if (nCount == nIndex)
+ return new ScSheetLinkObj( pDocShell, aLinkDoc );
+ ++nCount;
+ }
}
+
return NULL; // kein Dokument oder Index zu gross
}
@@ -478,23 +480,25 @@ uno::Reference<container::XEnumeration> SAL_CALL ScSheetLinksObj::createEnumerat
sal_Int32 SAL_CALL ScSheetLinksObj::getCount() throw(uno::RuntimeException)
{
+ typedef boost::unordered_set<rtl::OUString, rtl::OUStringHash> StrSetType;
+
SolarMutexGuard aGuard;
+ if (!pDocShell)
+ return 0;
+
sal_Int32 nCount = 0;
- if (pDocShell)
+
+ StrSetType aNames;
+ ScDocument* pDoc = pDocShell->GetDocument();
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB nTab = 0; nTab < nTabCount; ++nTab)
{
- ScStrCollection aNames; // um doppelte wegzulassen
- ScDocument* pDoc = pDocShell->GetDocument();
- SCTAB nTabCount = pDoc->GetTableCount();
- for (SCTAB nTab=0; nTab<nTabCount; nTab++)
- if (pDoc->IsLinked(nTab))
- {
- String aLinkDoc(pDoc->GetLinkDoc( nTab ));
- StrData* pData = new StrData(aLinkDoc);
- if (aNames.Insert(pData))
- ++nCount;
- else
- delete pData;
- }
+ if (!pDoc->IsLinked(nTab))
+ continue;
+
+ rtl::OUString aLinkDoc = pDoc->GetLinkDoc(nTab);
+ if (aNames.insert(aLinkDoc).second)
+ ++nCount;
}
return nCount;
}
@@ -562,36 +566,33 @@ sal_Bool SAL_CALL ScSheetLinksObj::hasByName( const rtl::OUString& aName )
uno::Sequence<rtl::OUString> SAL_CALL ScSheetLinksObj::getElementNames() throw(uno::RuntimeException)
{
+ typedef boost::unordered_set<rtl::OUString, rtl::OUStringHash> StrSetType;
+
SolarMutexGuard aGuard;
// Name ist der Dateiname
- if (pDocShell)
+ if (!pDocShell)
+ return uno::Sequence<rtl::OUString>();
+
+ StrSetType aNames;
+ ScDocument* pDoc = pDocShell->GetDocument();
+ SCTAB nTabCount = pDoc->GetTableCount();
+
+ sal_Int32 nLinkCount = getCount();
+ uno::Sequence<rtl::OUString> aSeq(nLinkCount);
+ rtl::OUString* pAry = aSeq.getArray();
+ sal_uInt16 nPos = 0;
+ for (SCTAB nTab = 0; nTab < nTabCount; ++nTab)
{
- ScStrCollection aNames; // um doppelte wegzulassen
- ScDocument* pDoc = pDocShell->GetDocument();
- SCTAB nTabCount = pDoc->GetTableCount();
- String aName;
+ if (!pDoc->IsLinked(nTab))
+ continue;
- sal_Int32 nLinkCount = getCount();
- uno::Sequence<rtl::OUString> aSeq(nLinkCount);
- rtl::OUString* pAry = aSeq.getArray();
- sal_uInt16 nPos = 0;
- for (SCTAB nTab=0; nTab<nTabCount; nTab++)
- {
- if (pDoc->IsLinked(nTab))
- {
- String aLinkDoc(pDoc->GetLinkDoc( nTab ));
- StrData* pData = new StrData(aLinkDoc);
- if (aNames.Insert(pData))
- pAry[nPos++] = aLinkDoc;
- else
- delete pData;
- }
- }
- OSL_ENSURE( nPos==nLinkCount, "verzaehlt" );
- return aSeq;
+ rtl::OUString aLinkDoc = pDoc->GetLinkDoc(nTab);
+ if (aNames.insert(aLinkDoc).second)
+ pAry[nPos++] = aLinkDoc;
}
- return uno::Sequence<rtl::OUString>();
+ OSL_ENSURE( nPos==nLinkCount, "verzaehlt" );
+ return aSeq;
}
//------------------------------------------------------------------------