summaryrefslogtreecommitdiff
path: root/sc/source/core/data
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2011-03-04 22:30:39 -0500
committerKohei Yoshida <kyoshida@novell.com>2011-03-05 15:21:08 -0500
commit726a7d3893d49214ca5ef955beb30dcd49b67dd0 (patch)
tree5a987b7544125138cd24d8d490a41837dfe1e58b /sc/source/core/data
parente40df3cb083c365d542395b4b48f575ff287b277 (diff)
More on adjusting for ScRangeName's new API.
Diffstat (limited to 'sc/source/core/data')
-rw-r--r--sc/source/core/data/cell2.cxx6
-rw-r--r--sc/source/core/data/column.cxx2
-rw-r--r--sc/source/core/data/documen2.cxx58
-rw-r--r--sc/source/core/data/documen3.cxx14
-rw-r--r--sc/source/core/data/document.cxx13
-rw-r--r--sc/source/core/data/table1.cxx2
6 files changed, 49 insertions, 46 deletions
diff --git a/sc/source/core/data/cell2.cxx b/sc/source/core/data/cell2.cxx
index a5cd0d7e9fc2..3a7f22808efc 100644
--- a/sc/source/core/data/cell2.cxx
+++ b/sc/source/core/data/cell2.cxx
@@ -1508,13 +1508,13 @@ void ScFormulaCell::UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY
StartListeningTo( pDocument ); // Listener wie vorher
}
-BOOL lcl_IsRangeNameInUse(USHORT nIndex, ScTokenArray* pCode, ScRangeName* pNames)
+BOOL lcl_IsRangeNameInUse(size_t nIndex, ScTokenArray* pCode, ScRangeName* pNames)
{
for (FormulaToken* p = pCode->First(); p; p = pCode->Next())
{
if (p->GetOpCode() == ocName)
{
- if (p->GetIndex() == nIndex)
+ if (p->GetIndex() == static_cast<USHORT>(nIndex))
return TRUE;
else
{
@@ -1529,7 +1529,7 @@ BOOL lcl_IsRangeNameInUse(USHORT nIndex, ScTokenArray* pCode, ScRangeName* pName
return FALSE;
}
-BOOL ScFormulaCell::IsRangeNameInUse(USHORT nIndex) const
+BOOL ScFormulaCell::IsRangeNameInUse(size_t nIndex) const
{
return lcl_IsRangeNameInUse( nIndex, pCode, pDocument->GetRangeName() );
}
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index de0e8ed5cb22..286ed8fc2f9b 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1841,7 +1841,7 @@ void ScColumn::SetTabNo(SCTAB nNewTab)
}
-bool ScColumn::IsRangeNameInUse(SCROW nRow1, SCROW nRow2, sal_uInt16 nIndex) const
+bool ScColumn::IsRangeNameInUse(SCROW nRow1, SCROW nRow2, size_t nIndex) const
{
bool bInUse = false;
if (pItems)
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index eedbd5434e0d..04b81d918213 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -962,6 +962,8 @@ ULONG ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos,
if ( !bResultsOnly )
{
+#if NEW_RANGE_NAME
+#else
BOOL bNamesLost = FALSE;
size_t nSrcRangeNames = pSrcDoc->pRangeName->size();
// array containing range names which might need update of indices
@@ -1058,6 +1060,7 @@ ULONG ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos,
// message: duplicate names
}
pTab[nDestPos]->CompileAll();
+#endif
}
SetNoListening( FALSE );
@@ -1127,35 +1130,42 @@ void ScDocument::SetError( SCCOL nCol, SCROW nRow, SCTAB nTab, const USHORT nErr
pTab[nTab]->SetError( nCol, nRow, nError );
}
-void ScDocument::EraseNonUsedSharedNames(USHORT nLevel)
+namespace {
+
+bool eraseUnusedSharedName(ScRangeName* pRangeName, ScTable* pTab[])
{
-#if NEW_RANGE_NAME
-#else
- for (size_t i = 0; i < pRangeName->size(); i++)
+ ScRangeName::const_iterator itr = pRangeName->begin(), itrEnd = pRangeName->end();
+ for (; itr != itrEnd; ++itr)
{
- ScRangeData* pRangeData = (*pRangeName)[i];
- if (pRangeData && pRangeData->HasType(RT_SHARED))
+ if (!itr->HasType(RT_SHARED))
+ continue;
+
+ size_t nIndex;
+ if (!pRangeName->getIndex(*itr, nIndex))
+ // index not found.
+ continue;
+
+ bool bInUse = false;
+ for (SCTAB j = 0; !bInUse && (j <= MAXTAB); ++j)
{
- String aName;
- pRangeData->GetName(aName);
- aName.Erase(0, 6); // !!! vgl. Table4, FillFormula !!
- USHORT nInd = (USHORT) aName.ToInt32();
- if (nInd <= nLevel)
- {
- USHORT nIndex = pRangeData->GetIndex();
- BOOL bInUse = FALSE;
- for (SCTAB j = 0; !bInUse && (j <= MAXTAB); j++)
- {
- if (pTab[j])
- bInUse = pTab[j]->IsRangeNameInUse(0, 0, MAXCOL-1, MAXROW-1,
- nIndex);
- }
- if (!bInUse)
- pRangeName->AtFree(i);
- }
+ if (pTab[j])
+ bInUse = pTab[j]->IsRangeNameInUse(0, 0, MAXCOL-1, MAXROW-1, nIndex);
+ }
+ if (!bInUse)
+ {
+ pRangeName->erase(itr);
+ return true;
}
}
-#endif
+ return false;
+}
+
+}
+
+void ScDocument::EraseNonUsedSharedNames()
+{
+ while (eraseUnusedSharedName(pRangeName, pTab))
+ ;
}
// ----------------------------------------------------------------------------
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index 9ee61b635f8b..fdc99683bcca 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -1403,16 +1403,12 @@ BOOL ScDocument::GetFormulaEntries( TypedScStrCollection& rStrings )
if ( pRangeName )
{
- size_t nRangeCount = pRangeName->size();
- for ( size_t i = 0; i < nRangeCount; i++ )
+ ScRangeName::const_iterator itr = pRangeName->begin(), itrEnd = pRangeName->end();
+ for (; itr != itrEnd; ++itr)
{
- ScRangeData* pData = (*pRangeName)[i];
- if (pData)
- {
- TypedStrData* pNew = new TypedStrData( pData->GetName(), 0.0, SC_STRTYPE_NAMES );
- if ( !rStrings.Insert(pNew) )
- delete pNew;
- }
+ TypedStrData* pNew = new TypedStrData(itr->GetName(), 0.0, SC_STRTYPE_NAMES);
+ if (!rStrings.Insert(pNew))
+ delete pNew;
}
}
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index c7afd2682b39..222930028a5c 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1707,18 +1707,15 @@ void ScDocument::TransposeClip( ScDocument* pTransClip, USHORT nFlags, BOOL bAsL
// Bereiche uebernehmen
pTransClip->pRangeName->clear();
-#if NEW_RANGE_NAME
-#else
- for (USHORT i = 0; i < pRangeName->GetCount(); i++) //! DB-Bereiche Pivot-Bereiche auch !!!
+ ScRangeName::const_iterator itr = pRangeName->begin(), itrEnd = pRangeName->end();
+ for (; itr != itrEnd; ++itr)
{
- USHORT nIndex = ((ScRangeData*)((*pRangeName)[i]))->GetIndex();
- ScRangeData* pData = new ScRangeData(*((*pRangeName)[i]));
- if (!pTransClip->pRangeName->Insert(pData))
+ ScRangeData* pData = new ScRangeData(*itr);
+ if (!pTransClip->pRangeName->insert(pData))
delete pData;
else
- pData->SetIndex(nIndex);
+ pData->SetIndex(0);
}
-#endif
// The data
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index b950b9bc75f8..2903be085cb6 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -1446,7 +1446,7 @@ void ScTable::SetTabNo(SCTAB nNewTab)
}
BOOL ScTable::IsRangeNameInUse(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
- USHORT nIndex) const
+ size_t nIndex) const
{
BOOL bInUse = FALSE;
for (SCCOL i = nCol1; !bInUse && (i <= nCol2) && (ValidCol(i)); i++)