Kaydet (Commit) 3f806959 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

More on eliminating ScStrCollection.

üst cac7f1d4
......@@ -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;
}
//------------------------------------------------------------------------
......
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