[Libreoffice-commits] .: 24 commits - sc/inc sc/qa sc/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Sat Mar 5 13:12:10 PST 2011
sc/inc/address.hxx | 3
sc/inc/clipparam.hxx | 2
sc/inc/document.hxx | 2
sc/inc/rangenam.hxx | 87 +++++-----
sc/inc/rangeutl.hxx | 13 +
sc/qa/unit/ucalc.cxx | 2
sc/source/core/data/cell.cxx | 2
sc/source/core/data/cell2.cxx | 12 -
sc/source/core/data/conditio.cxx | 2
sc/source/core/data/documen2.cxx | 102 ++++++------
sc/source/core/data/documen3.cxx | 20 --
sc/source/core/data/document.cxx | 105 +++++-------
sc/source/core/data/dpshttab.cxx | 5
sc/source/core/data/validat.cxx | 2
sc/source/core/tool/address.cxx | 11 +
sc/source/core/tool/compiler.cxx | 25 +-
sc/source/core/tool/interpr1.cxx | 12 -
sc/source/core/tool/rangenam.cxx | 260 ++++++++++++++++++++-----------
sc/source/core/tool/rangeutl.cxx | 38 ++--
sc/source/filter/excel/namebuff.cxx | 2
sc/source/filter/excel/xecontent.cxx | 2
sc/source/filter/excel/xename.cxx | 11 -
sc/source/filter/excel/xiname.cxx | 5
sc/source/filter/excel/xlformula.cxx | 2
sc/source/filter/html/htmlimp.cxx | 17 --
sc/source/filter/lotus/tool.cxx | 6
sc/source/filter/rtf/eeimpars.cxx | 5
sc/source/filter/starcalc/scflt.cxx | 6
sc/source/filter/xml/xmlexprt.cxx | 5
sc/source/ui/app/inputwin.cxx | 40 +---
sc/source/ui/dbgui/consdlg.cxx | 2
sc/source/ui/dbgui/pvlaydlg.cxx | 6
sc/source/ui/dbgui/sfiltdlg.cxx | 38 +---
sc/source/ui/docshell/arealink.cxx | 12 -
sc/source/ui/docshell/dbdocfun.cxx | 4
sc/source/ui/docshell/docfunc.cxx | 34 +---
sc/source/ui/docshell/docsh4.cxx | 5
sc/source/ui/docshell/externalrefmgr.cxx | 19 --
sc/source/ui/docshell/impex.cxx | 5
sc/source/ui/docshell/servobj.cxx | 5
sc/source/ui/inc/namedlg.hxx | 2
sc/source/ui/miscdlgs/namepast.cxx | 19 --
sc/source/ui/namedlg/namedlg.cxx | 88 +++-------
sc/source/ui/navipi/content.cxx | 43 ++---
sc/source/ui/pagedlg/areasdlg.cxx | 88 +++++-----
sc/source/ui/undo/undoblk3.cxx | 41 +++-
sc/source/ui/unoobj/nameuno.cxx | 194 ++++++++++-------------
sc/source/ui/vba/vbarange.cxx | 15 -
sc/source/ui/view/cellsh1.cxx | 13 -
sc/source/ui/view/dbfunc3.cxx | 4
sc/source/ui/view/viewfunc.cxx | 10 -
51 files changed, 730 insertions(+), 723 deletions(-)
New commits:
commit 9c66eed7a8876b24018c1453ea4c4edd8a05d4a6
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Sat Mar 5 16:02:19 2011 -0500
GetRangeAtBlock() to findByRange(), favor std::find_if over manual loop.
diff --git a/sc/inc/rangenam.hxx b/sc/inc/rangenam.hxx
index 9802d5a..d434f2c 100644
--- a/sc/inc/rangenam.hxx
+++ b/sc/inc/rangenam.hxx
@@ -190,7 +190,7 @@ public:
ScRangeName(ScDocument* pDoc = NULL);
ScRangeName(const ScRangeName& r);
- SC_DLLPUBLIC const ScRangeData* GetRangeAtBlock(const ScRange& rRange) const;
+ SC_DLLPUBLIC const ScRangeData* findByRange(const ScRange& rRange) const;
SC_DLLPUBLIC ScRangeData* findByName(const rtl::OUString& rName);
SC_DLLPUBLIC const ScRangeData* findByName(const rtl::OUString& rName) const;
ScRangeData* findByUpperName(const rtl::OUString& rName);
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index 13ddba7..51906fd 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -108,7 +108,7 @@ const ScRangeData* ScDocument::GetRangeAtBlock( const ScRange& rBlock, String* p
const ScRangeData* pData = NULL;
if ( pRangeName )
{
- pData = pRangeName->GetRangeAtBlock( rBlock );
+ pData = pRangeName->findByRange( rBlock );
if (pData && pName)
*pName = pData->GetName();
}
diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index b64b094..1166297 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -50,6 +50,7 @@
using namespace formula;
using ::std::pair;
+using ::std::unary_function;
using ::rtl::OUString;
//========================================================================
@@ -662,69 +663,103 @@ bool operator<(const ScRangeData& left, const ScRangeData& right)
return left.GetName() < right.GetName();
}
+namespace {
+
+/**
+ * Predicate to check if the name references the specified range.
+ */
+class MatchByRange : public unary_function<ScRangeData, bool>
+{
+ const ScRange& mrRange;
+public:
+ MatchByRange(const ScRange& rRange) : mrRange(rRange) {}
+ bool operator() (const ScRangeData& r) const
+ {
+ return r.IsRangeAtBlock(mrRange);
+ }
+};
+
+class MatchByName : public unary_function<ScRangeData, bool>
+{
+ const OUString& mrName;
+public:
+ MatchByName(const OUString& rName) : mrName(rName) {}
+ bool operator() (const ScRangeData& r) const
+ {
+ return mrName.equals(r.GetName());
+ }
+};
+
+class MatchByUpperName : public unary_function<ScRangeData, bool>
+{
+ const OUString& mrName;
+public:
+ MatchByUpperName(const OUString& rName) : mrName(rName) {}
+ bool operator() (const ScRangeData& r) const
+ {
+ return mrName.equals(r.GetUpperName());
+ }
+};
+
+class MatchByIndex : public unary_function<ScRangeData, bool>
+{
+ USHORT mnIndex;
+public:
+ MatchByIndex(USHORT nIndex) : mnIndex(nIndex) {}
+ bool operator() (const ScRangeData& r) const
+ {
+ return mnIndex == r.GetIndex();
+ }
+};
+
+}
+
ScRangeName::ScRangeName(ScDocument* pDoc) :
mpDoc(pDoc) {}
ScRangeName::ScRangeName(const ScRangeName& r) :
maData(r.maData), mpDoc(r.mpDoc), mnSharedMaxIndex(r.mnSharedMaxIndex) {}
-const ScRangeData* ScRangeName::GetRangeAtBlock(const ScRange& rRange) const
+const ScRangeData* ScRangeName::findByRange(const ScRange& rRange) const
{
- DataType::const_iterator itr = maData.begin(), itrEnd = maData.end();
- for (; itr != itrEnd; ++itr)
- {
- if (itr->IsRangeAtBlock(rRange))
- return &(*itr);
- }
- return NULL;
+ DataType::const_iterator itr = std::find_if(
+ maData.begin(), maData.end(), MatchByRange(rRange));
+ return itr == maData.end() ? NULL : &(*itr);
}
ScRangeData* ScRangeName::findByName(const OUString& rName)
{
- DataType::iterator itr = maData.begin(), itrEnd = maData.end();
- for (; itr != itrEnd; ++itr)
- {
- String aName;
- itr->GetName(aName);
- if (rName.equals(aName))
- return &(*itr);
- }
- return NULL;
+ DataType::iterator itr = std::find_if(
+ maData.begin(), maData.end(), MatchByName(rName));
+ return itr == maData.end() ? NULL : &(*itr);
}
const ScRangeData* ScRangeName::findByName(const OUString& rName) const
{
- DataType::const_iterator itr = maData.begin(), itrEnd = maData.end();
- for (; itr != itrEnd; ++itr)
- {
- String aName;
- itr->GetName(aName);
- if (rName.equals(aName))
- return &(*itr);
- }
- return NULL;
+ DataType::const_iterator itr = std::find_if(
+ maData.begin(), maData.end(), MatchByName(rName));
+ return itr == maData.end() ? NULL : &(*itr);
}
ScRangeData* ScRangeName::findByUpperName(const OUString& rName)
{
- DataType::iterator itr = maData.begin(), itrEnd = maData.end();
- for (; itr != itrEnd; ++itr)
- {
- if (rName.equals(itr->GetUpperName()))
- return &(*itr);
- }
- return NULL;
+ DataType::iterator itr = std::find_if(
+ maData.begin(), maData.end(), MatchByUpperName(rName));
+ return itr == maData.end() ? NULL : &(*itr);
}
const ScRangeData* ScRangeName::findByUpperName(const OUString& rName) const
{
- DataType::const_iterator itr = maData.begin(), itrEnd = maData.end();
- for (; itr != itrEnd; ++itr)
- {
- if (rName.equals(itr->GetUpperName()))
- return &(*itr);
- }
- return NULL;
+ DataType::const_iterator itr = std::find_if(
+ maData.begin(), maData.end(), MatchByUpperName(rName));
+ return itr == maData.end() ? NULL : &(*itr);
+}
+
+ScRangeData* ScRangeName::findByIndex(USHORT i)
+{
+ DataType::iterator itr = std::find_if(
+ maData.begin(), maData.end(), MatchByIndex(i));
+ return itr == maData.end() ? NULL : &(*itr);
}
void ScRangeName::UpdateReference(
@@ -756,15 +791,6 @@ void ScRangeName::UpdateGrow(const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY)
itr->UpdateGrow(rArea, nGrowX, nGrowY);
}
-ScRangeData* ScRangeName::findByIndex(USHORT i)
-{
- DataType::iterator itr = maData.begin(), itrEnd = maData.end();
- for (; itr != itrEnd; ++itr)
- if (itr->GetIndex() == i)
- return &(*itr);
- return NULL;
-}
-
sal_uInt16 ScRangeName::GetSharedMaxIndex()
{
return mnSharedMaxIndex;
diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx
index 60b42bc..eaec8e0 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -1466,7 +1466,7 @@ XclExpWebQueryBuffer::XclExpWebQueryBuffer( const XclExpRoot& rRoot )
String aRangeName;
ScRange aScDestRange;
ScUnoConversion::FillScRange( aScDestRange, aDestRange );
- if( const ScRangeData* pRangeData = rRoot.GetNamedRanges().GetRangeAtBlock( aScDestRange ) )
+ if( const ScRangeData* pRangeData = rRoot.GetNamedRanges().findByRange( aScDestRange ) )
{
aRangeName = pRangeData->GetName();
}
commit c0fe1adf4688d0b384976990de6409cb5f3adff5
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Sat Mar 5 15:32:27 2011 -0500
Fixed a build breakage.
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 8e850e3..f4e71bd 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,
- size_t nIndex) const
+ USHORT nIndex) const
{
BOOL bInUse = FALSE;
for (SCCOL i = nCol1; !bInUse && (i <= nCol2) && (ValidCol(i)); i++)
commit 1b45c153f1712a839bb962e000b5bb147c95ca8a
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Sat Mar 5 14:47:31 2011 -0500
Changed ScRangeData's index back to USHORT for now.
diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx
index 4b7d657..110c848 100644
--- a/sc/inc/cell.hxx
+++ b/sc/inc/cell.hxx
@@ -459,7 +459,7 @@ public:
void UpdateRenameTab(SCTAB nTable, const String& rName);
BOOL TestTabRefAbs(SCTAB nTable);
void UpdateCompile( BOOL bForceIfNameInUse = FALSE );
- BOOL IsRangeNameInUse(size_t nIndex) const;
+ BOOL IsRangeNameInUse(USHORT nIndex) const;
void FindRangeNamesInUse(std::set<USHORT>& rIndexes) const;
void ReplaceRangeNamesInUse( const ScRangeData::IndexMap& rMap );
BOOL IsSubTotal() const { return bSubTotal; }
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index b6260f3..35d26b0 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -299,7 +299,7 @@ public:
void UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY );
void SetTabNo(SCTAB nNewTab);
- bool IsRangeNameInUse(SCROW nRow1, SCROW nRow2, size_t nIndex) const;
+ bool IsRangeNameInUse(SCROW nRow1, SCROW nRow2, sal_uInt16 nIndex) const;
void FindRangeNamesInUse(SCROW nRow1, SCROW nRow2, std::set<sal_uInt16>& rIndexes) const;
void ReplaceRangeNamesInUse( SCROW nRow1, SCROW nRow2, const ScRangeData::IndexMap& rMap );
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index ce0809b..25d423a 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -479,7 +479,7 @@ public:
void UpdateCompile( BOOL bForceIfNameInUse = FALSE );
void SetTabNo(SCTAB nNewTab);
BOOL IsRangeNameInUse(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
- size_t nIndex) const;
+ USHORT nIndex) const;
void FindRangeNamesInUse(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
std::set<USHORT>& rIndexes) const;
void ReplaceRangeNamesInUse(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
diff --git a/sc/source/core/data/cell2.cxx b/sc/source/core/data/cell2.cxx
index 9db1d64..42a3b6a 100644
--- a/sc/source/core/data/cell2.cxx
+++ b/sc/source/core/data/cell2.cxx
@@ -1529,7 +1529,7 @@ BOOL lcl_IsRangeNameInUse(size_t nIndex, ScTokenArray* pCode, ScRangeName* pName
return FALSE;
}
-BOOL ScFormulaCell::IsRangeNameInUse(size_t nIndex) const
+BOOL ScFormulaCell::IsRangeNameInUse(USHORT 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 6f47ee5..9e13354 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, size_t nIndex) const
+bool ScColumn::IsRangeNameInUse(SCROW nRow1, SCROW nRow2, sal_uInt16 nIndex) const
{
bool bInUse = false;
if (pItems)
commit f6988dcce4e8da9c95741d3750d66be520162642
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Sat Mar 5 14:21:56 2011 -0500
Renamed FindIndex to findByIndex to be consistent with findByName.
diff --git a/sc/inc/rangenam.hxx b/sc/inc/rangenam.hxx
index 85e64fa..9802d5a 100644
--- a/sc/inc/rangenam.hxx
+++ b/sc/inc/rangenam.hxx
@@ -195,12 +195,12 @@ public:
SC_DLLPUBLIC const ScRangeData* findByName(const rtl::OUString& rName) const;
ScRangeData* findByUpperName(const rtl::OUString& rName);
const ScRangeData* findByUpperName(const rtl::OUString& rName) const;
+ SC_DLLPUBLIC ScRangeData* findByIndex(USHORT i);
void UpdateReference(UpdateRefMode eUpdateRefMode, const ScRange& rRange,
SCsCOL nDx, SCsROW nDy, SCsTAB nDz);
void UpdateTabRef(SCTAB nTable, sal_uInt16 nFlag, SCTAB nNewTable = 0);
void UpdateTranspose(const ScRange& rSource, const ScAddress& rDest);
void UpdateGrow(const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY);
- SC_DLLPUBLIC ScRangeData* FindIndex(USHORT i);
sal_uInt16 GetSharedMaxIndex();
void SetSharedMaxIndex(sal_uInt16 nInd);
diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx
index 0e9e9d6..0089d62 100644
--- a/sc/source/core/data/cell.cxx
+++ b/sc/source/core/data/cell.cxx
@@ -784,7 +784,7 @@ ScFormulaCell::ScFormulaCell( const ScFormulaCell& rCell, ScDocument& rDoc, cons
}
else if ( t->GetType() == svIndex )
{
- ScRangeData* pRangeData = rDoc.GetRangeName()->FindIndex( t->GetIndex() );
+ ScRangeData* pRangeData = rDoc.GetRangeName()->findByIndex( t->GetIndex() );
if( pRangeData )
{
if( pRangeData->HasReferences() )
diff --git a/sc/source/core/data/cell2.cxx b/sc/source/core/data/cell2.cxx
index 2c71c3a..9db1d64 100644
--- a/sc/source/core/data/cell2.cxx
+++ b/sc/source/core/data/cell2.cxx
@@ -1361,7 +1361,7 @@ void ScFormulaCell::UpdateTranspose( const ScRange& rSource, const ScAddress& rD
{
if( t->GetOpCode() == ocName )
{
- ScRangeData* pName = pDocument->GetRangeName()->FindIndex( t->GetIndex() );
+ ScRangeData* pName = pDocument->GetRangeName()->findByIndex( t->GetIndex() );
if (pName)
{
if (pName->IsModified())
@@ -1446,7 +1446,7 @@ void ScFormulaCell::UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY
{
if( t->GetOpCode() == ocName )
{
- ScRangeData* pName = pDocument->GetRangeName()->FindIndex( t->GetIndex() );
+ ScRangeData* pName = pDocument->GetRangeName()->findByIndex( t->GetIndex() );
if (pName)
{
if (pName->IsModified())
@@ -1519,7 +1519,7 @@ BOOL lcl_IsRangeNameInUse(size_t nIndex, ScTokenArray* pCode, ScRangeName* pName
else
{
// RangeData kann Null sein in bestimmten Excel-Dateien
- ScRangeData* pSubName = pNames->FindIndex(p->GetIndex());
+ ScRangeData* pSubName = pNames->findByIndex(p->GetIndex());
if (pSubName && lcl_IsRangeNameInUse(nIndex,
pSubName->GetCode(), pNames))
return TRUE;
@@ -1543,7 +1543,7 @@ void lcl_FindRangeNamesInUse(std::set<USHORT>& rIndexes, ScTokenArray* pCode, Sc
USHORT nTokenIndex = p->GetIndex();
rIndexes.insert( nTokenIndex );
- ScRangeData* pSubName = pNames->FindIndex(p->GetIndex());
+ ScRangeData* pSubName = pNames->findByIndex(p->GetIndex());
if (pSubName)
lcl_FindRangeNamesInUse(rIndexes, pSubName->GetCode(), pNames);
}
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 272090a..c2a3f5f 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -84,7 +84,7 @@ BOOL lcl_HasRelRef( ScDocument* pDoc, ScTokenArray* pFormula, USHORT nRecursion
case svIndex:
{
if( t->GetOpCode() == ocName ) // DB areas always absolute
- if( ScRangeData* pRangeData = pDoc->GetRangeName()->FindIndex( t->GetIndex() ) )
+ if( ScRangeData* pRangeData = pDoc->GetRangeName()->findByIndex( t->GetIndex() ) )
if( (nRecursion < 42) && lcl_HasRelRef( pDoc, pRangeData->GetCode(), nRecursion + 1 ) )
return TRUE;
}
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index a98e207..385af19 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -1003,7 +1003,7 @@ ULONG ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos,
{
ScRangeData* pData = new ScRangeData( *itr );
pData->SetDocument(this);
- if ( pRangeName->FindIndex( pData->GetIndex() ) )
+ if ( pRangeName->findByIndex( pData->GetIndex() ) )
pData->SetIndex(0); // need new index, done in Insert
if (!pRangeName->insert(pData))
{
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index d8e5bc3..99779db 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1864,7 +1864,7 @@ void ScDocument::CopyRangeNamesFromClip(ScDocument* pClipDoc, ScClipRangeNameDat
{
ScRangeData* pData = new ScRangeData( *itr );
pData->SetDocument(this);
- if ( pRangeName->FindIndex( pData->GetIndex() ) )
+ if ( pRangeName->findByIndex( pData->GetIndex() ) )
pData->SetIndex(0); // need new index, done in Insert
if ( pRangeName->insert(pData) )
{
diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx
index d762c8c..08cb3cc 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -702,7 +702,7 @@ bool ScValidationData::GetSelectionFromFormula( TypedScStrCollection* pStrings,
}
else if (t->GetOpCode() == ocName)
{
- ScRangeData* pName = pDocument->GetRangeName()->FindIndex( t->GetIndex() );
+ ScRangeData* pName = pDocument->GetRangeName()->findByIndex( t->GetIndex() );
if (pName && pName->IsReference(aRange))
{
bRef = TRUE;
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 64a50a5..71beebc 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -3887,7 +3887,7 @@ ScTokenArray* ScCompiler::CompileString( const String& rFormula, const String& r
BOOL ScCompiler::HandleRange()
{
- ScRangeData* pRangeData = pDoc->GetRangeName()->FindIndex( pToken->GetIndex() );
+ ScRangeData* pRangeData = pDoc->GetRangeName()->findByIndex( pToken->GetIndex() );
if (pRangeData)
{
USHORT nErr = pRangeData->GetErrCode();
@@ -4012,7 +4012,7 @@ BOOL ScCompiler::HasModifiedRange()
OpCode eOpCode = t->GetOpCode();
if ( eOpCode == ocName )
{
- ScRangeData* pRangeData = pDoc->GetRangeName()->FindIndex(t->GetIndex());
+ ScRangeData* pRangeData = pDoc->GetRangeName()->findByIndex(t->GetIndex());
if (pRangeData && pRangeData->IsModified())
return TRUE;
@@ -4135,7 +4135,7 @@ ScRangeData* ScCompiler::UpdateReference(UpdateRefMode eUpdateRefMode,
{
if( j->GetOpCode() == ocName )
{
- ScRangeData* pName = pDoc->GetRangeName()->FindIndex( j->GetIndex() );
+ ScRangeData* pName = pDoc->GetRangeName()->findByIndex( j->GetIndex() );
if (pName && pName->HasType(RT_SHARED))
pRangeData = pName;
}
@@ -4188,7 +4188,7 @@ ScRangeData* ScCompiler::UpdateReference(UpdateRefMode eUpdateRefMode,
{
if( t->GetOpCode() == ocName )
{
- ScRangeData* pName = pDoc->GetRangeName()->FindIndex( t->GetIndex() );
+ ScRangeData* pName = pDoc->GetRangeName()->findByIndex( t->GetIndex() );
if (pName && pName->HasType(RT_SHAREDMOD))
{
pRangeData = pName; // maybe need a replacement of shared with own code
@@ -4481,7 +4481,7 @@ ScRangeData* ScCompiler::UpdateInsertTab( SCTAB nTable, BOOL bIsName )
{
if (!bIsName)
{
- ScRangeData* pName = pDoc->GetRangeName()->FindIndex(t->GetIndex());
+ ScRangeData* pName = pDoc->GetRangeName()->findByIndex(t->GetIndex());
if (pName && pName->HasType(RT_SHAREDMOD))
pRangeData = pName;
}
@@ -4592,7 +4592,7 @@ ScRangeData* ScCompiler::UpdateDeleteTab(SCTAB nTable, BOOL /* bIsMove */, BOOL
{
if (!bIsName)
{
- ScRangeData* pName = pDoc->GetRangeName()->FindIndex(t->GetIndex());
+ ScRangeData* pName = pDoc->GetRangeName()->findByIndex(t->GetIndex());
if (pName && pName->HasType(RT_SHAREDMOD))
pRangeData = pName;
}
@@ -4802,7 +4802,7 @@ ScRangeData* ScCompiler::UpdateMoveTab( SCTAB nOldTab, SCTAB nNewTab,
{
if (!bIsName)
{
- ScRangeData* pName = pDoc->GetRangeName()->FindIndex(t->GetIndex());
+ ScRangeData* pName = pDoc->GetRangeName()->findByIndex(t->GetIndex());
if (pName && pName->HasType(RT_SHAREDMOD))
pRangeData = pName;
}
@@ -5056,7 +5056,7 @@ void ScCompiler::CreateStringFromIndex(rtl::OUStringBuffer& rBuffer,FormulaToken
{
case ocName:
{
- ScRangeData* pData = pDoc->GetRangeName()->FindIndex(_pTokenP->GetIndex());
+ ScRangeData* pData = pDoc->GetRangeName()->findByIndex(_pTokenP->GetIndex());
if (pData)
{
if (pData->HasType(RT_SHARED))
diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index a36d523..b64b094 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -666,7 +666,7 @@ ScRangeName::ScRangeName(ScDocument* pDoc) :
mpDoc(pDoc) {}
ScRangeName::ScRangeName(const ScRangeName& r) :
- maData(r.maData), mpDoc(r.mpDoc) {}
+ maData(r.maData), mpDoc(r.mpDoc), mnSharedMaxIndex(r.mnSharedMaxIndex) {}
const ScRangeData* ScRangeName::GetRangeAtBlock(const ScRange& rRange) const
{
@@ -756,7 +756,7 @@ void ScRangeName::UpdateGrow(const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY)
itr->UpdateGrow(rArea, nGrowX, nGrowY);
}
-ScRangeData* ScRangeName::FindIndex(USHORT i)
+ScRangeData* ScRangeName::findByIndex(USHORT i)
{
DataType::iterator itr = maData.begin(), itrEnd = maData.end();
for (; itr != itrEnd; ++itr)
@@ -845,7 +845,7 @@ void ScRangeName::clear()
bool ScRangeName::operator== (const ScRangeName& r) const
{
- return maData == r.maData;
+ return maData == r.maData && mpDoc == r.mpDoc && mnSharedMaxIndex == r.mnSharedMaxIndex;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/excel/xename.cxx b/sc/source/filter/excel/xename.cxx
index f9e9327..e60983b 100644
--- a/sc/source/filter/excel/xename.cxx
+++ b/sc/source/filter/excel/xename.cxx
@@ -382,7 +382,7 @@ sal_uInt16 XclExpNameManagerImpl::InsertName( USHORT nScNameIdx )
{
sal_uInt16 nNameIdx = FindNameIdx( maNameMap, nScNameIdx );
if( nNameIdx == 0 )
- if( const ScRangeData* pRangeData = GetNamedRanges().FindIndex( nScNameIdx ) )
+ if( const ScRangeData* pRangeData = GetNamedRanges().findByIndex( nScNameIdx ) )
nNameIdx = CreateName( *pRangeData );
return nNameIdx;
}
diff --git a/sc/source/filter/excel/xlformula.cxx b/sc/source/filter/excel/xlformula.cxx
index 78a2b90..b814d02 100644
--- a/sc/source/filter/excel/xlformula.cxx
+++ b/sc/source/filter/excel/xlformula.cxx
@@ -699,7 +699,7 @@ const ScTokenArray* XclTokenArrayHelper::GetSharedFormula( const XclRoot& rRoot,
if( rScTokArr.GetLen() == 1 )
if( const FormulaToken* pScToken = rScTokArr.GetArray()[ 0 ] )
if( pScToken->GetOpCode() == ocName )
- if( ScRangeData* pData = rRoot.GetNamedRanges().FindIndex( pScToken->GetIndex() ) )
+ if( ScRangeData* pData = rRoot.GetNamedRanges().findByIndex( pScToken->GetIndex() ) )
if( pData->HasType( RT_SHARED ) )
return pData->GetCode();
return 0;
commit 187336c1bf1de45b4739e24cc1484ea5eb9c89c2
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Sat Mar 5 14:07:14 2011 -0500
Removed the Insert() method; let's use insert() across the board.
diff --git a/sc/inc/rangenam.hxx b/sc/inc/rangenam.hxx
index a343607..85e64fa 100644
--- a/sc/inc/rangenam.hxx
+++ b/sc/inc/rangenam.hxx
@@ -84,7 +84,6 @@ private:
SCROW mnMaxRow;
SCCOL mnMaxCol;
- friend class ScRangeName;
ScRangeData( USHORT nIndex );
public:
typedef ::std::map<sal_uInt16, sal_uInt16> IndexMap;
@@ -212,7 +211,6 @@ public:
SC_DLLPUBLIC size_t size() const;
bool empty() const;
SC_DLLPUBLIC bool insert(ScRangeData* p);
- SC_DLLPUBLIC bool Insert(ScRangeData* p);
void erase(const ScRangeData& r);
void erase(const iterator& itr);
void clear();
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 7c19673..57b64c3 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -417,7 +417,7 @@ void Test::testNamedRange()
ScRangeData* pNew = new ScRangeData(m_pDoc,
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Divisor")),
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("$Sheet1.$A$1:$A$1048576")), aA1, 0, formula::FormulaGrammar::GRAM_PODF_A1);
- bool bSuccess = pNewRanges->Insert(pNew);
+ bool bSuccess = pNewRanges->insert(pNew);
CPPUNIT_ASSERT_MESSAGE ("insertion failed", bSuccess);
m_pDoc->SetRangeName(pNewRanges);
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 7b8e91d..a98e207 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -1005,7 +1005,7 @@ ULONG ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos,
pData->SetDocument(this);
if ( pRangeName->FindIndex( pData->GetIndex() ) )
pData->SetIndex(0); // need new index, done in Insert
- if (!pRangeName->Insert(pData))
+ if (!pRangeName->insert(pData))
{
OSL_FAIL("can't insert name"); // shouldn't happen
delete pData;
diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index 6d1a013..a36d523 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -828,11 +828,6 @@ bool ScRangeName::insert(ScRangeData* p)
return r.second;
}
-bool ScRangeName::Insert(ScRangeData* p)
-{
- return insert(p);
-}
-
void ScRangeName::erase(const ScRangeData& r)
{
maData.erase(r);
diff --git a/sc/source/filter/excel/namebuff.cxx b/sc/source/filter/excel/namebuff.cxx
index 72a6b8b..46fbafb 100644
--- a/sc/source/filter/excel/namebuff.cxx
+++ b/sc/source/filter/excel/namebuff.cxx
@@ -129,7 +129,7 @@ void ShrfmlaBuffer::Store( const ScRange& rRange, const ScTokenArray& rToken )
pData->SetMaxCol(rMaxPos.Col());
pData->SetMaxRow(rMaxPos.Row());
pData->SetIndex( static_cast< USHORT >( mnCurrIdx ) );
- pExcRoot->pIR->GetNamedRanges().Insert( pData );
+ pExcRoot->pIR->GetNamedRanges().insert( pData );
index_hash[rRange.aStart] = static_cast< USHORT >( mnCurrIdx );
index_list.push_front (rRange);
++mnCurrIdx;
diff --git a/sc/source/filter/excel/xiname.cxx b/sc/source/filter/excel/xiname.cxx
index d0d7e0d..03a49ac 100644
--- a/sc/source/filter/excel/xiname.cxx
+++ b/sc/source/filter/excel/xiname.cxx
@@ -222,7 +222,7 @@ XclImpName::XclImpName( XclImpStream& rStrm, sal_uInt16 nXclNameIdx ) :
ScRangeData* pData = new ScRangeData( GetDocPtr(), maScName, *pTokArr, ScAddress(), nNameType );
pData->GuessPosition(); // calculate base position for relative refs
pData->SetIndex( nXclNameIdx ); // used as unique identifier in formulas
- rRangeNames.Insert( pData ); // takes ownership of pData
+ rRangeNames.insert( pData ); // takes ownership of pData
if( nXclTab != EXC_NAME_GLOBAL )
{
if (GetBiff() == EXC_BIFF8)
diff --git a/sc/source/filter/html/htmlimp.cxx b/sc/source/filter/html/htmlimp.cxx
index f2080cb..b717b50 100644
--- a/sc/source/filter/html/htmlimp.cxx
+++ b/sc/source/filter/html/htmlimp.cxx
@@ -132,7 +132,7 @@ void ScHTMLImport::InsertRangeName( ScDocument* pDoc, const String& rName, const
ScTokenArray aTokArray;
aTokArray.AddDoubleReference( aRefData );
ScRangeData* pRangeData = new ScRangeData( pDoc, rName, aTokArray );
- if( !pDoc->GetRangeName()->Insert( pRangeData ) )
+ if( !pDoc->GetRangeName()->insert( pRangeData ) )
delete pRangeData;
}
diff --git a/sc/source/filter/lotus/tool.cxx b/sc/source/filter/lotus/tool.cxx
index 970e247..76c7f51 100644
--- a/sc/source/filter/lotus/tool.cxx
+++ b/sc/source/filter/lotus/tool.cxx
@@ -513,7 +513,7 @@ void LotusRangeList::Append( LotusRange* pLR, const String& rName )
ScRangeData* pData = new ScRangeData(
pLotusRoot->pDoc, rName, aTokArray );
- pLotusRoot->pScRangeName->Insert( pData );
+ pLotusRoot->pScRangeName->insert( pData );
pLR->SetId( nIdCnt );
@@ -575,7 +575,7 @@ void RangeNameBufferWK3::Add( const String& rOrgName, const ScComplexRefData& rC
pData->SetIndex( nIntCount );
nIntCount++;
- pLotusRoot->pScRangeName->Insert( pData );
+ pLotusRoot->pScRangeName->insert( pData );
}
@@ -639,7 +639,7 @@ BOOL RangeNameBufferWK3::FindAbs( const String& rRef, UINT16& rIndex )
pData->SetIndex( rIndex );
nIntCount++;
- pLotusRoot->pScRangeName->Insert( pData );
+ pLotusRoot->pScRangeName->insert( pData );
}
return TRUE;
diff --git a/sc/source/filter/rtf/eeimpars.cxx b/sc/source/filter/rtf/eeimpars.cxx
index b518df4..70a2df1 100644
--- a/sc/source/filter/rtf/eeimpars.cxx
+++ b/sc/source/filter/rtf/eeimpars.cxx
@@ -408,7 +408,7 @@ void ScEEImport::WriteToDocument( BOOL bSizeColsRows, double nOutputFactor, SvNu
{
ScRangeData* pData = new ScRangeData( mpDoc, *pE->pName,
ScAddress( nCol, nRow, nTab ) );
- pRangeNames->Insert( pData );
+ pRangeNames->insert( pData );
}
}
}
diff --git a/sc/source/filter/starcalc/scflt.cxx b/sc/source/filter/starcalc/scflt.cxx
index 54970f5..f0f79c2 100644
--- a/sc/source/filter/starcalc/scflt.cxx
+++ b/sc/source/filter/starcalc/scflt.cxx
@@ -1112,9 +1112,9 @@ void Sc10Import::ImportNameCollection()
for (USHORT i = 0; i < pNameCollection->GetCount(); i++)
{
Sc10NameData* pName = pNameCollection->At( i );
- pRN->Insert( new ScRangeData( pDoc,
- SC10TOSTRING( pName->Name ),
- SC10TOSTRING( pName->Reference ) ) );
+ pRN->insert(
+ new ScRangeData(
+ pDoc, SC10TOSTRING(pName->Name), SC10TOSTRING(pName->Reference)));
}
}
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 7cd88f7..0ab3980 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -1678,7 +1678,7 @@ void ScPosWnd::DoEnter()
String aContent;
aSelection.Format( aContent, SCR_ABS_3D, pDoc, pDoc->GetAddressConvention() );
ScRangeData* pNew = new ScRangeData( pDoc, aText, aContent, aCursor );
- if ( aNewRanges.Insert(pNew) )
+ if ( aNewRanges.insert(pNew) )
{
ScDocFunc aFunc(*pDocShell);
aFunc.ModifyRangeNames( aNewRanges );
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index e251ceb..e9de219 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -4581,7 +4581,7 @@ void ScDocFunc::CreateOneName( ScRangeName& rList,
{
ScRangeData* pData = new ScRangeData( pDoc, aName, aContent,
ScAddress( nPosX, nPosY, nTab));
- if (!rList.Insert(pData))
+ if (!rList.insert(pData))
{
OSL_FAIL("nanu?");
delete pData;
diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx
index 21db698..b467ab8 100644
--- a/sc/source/ui/namedlg/namedlg.cxx
+++ b/sc/source/ui/namedlg/namedlg.cxx
@@ -440,7 +440,7 @@ IMPL_LINK( ScNameDlg, AddBtnHdl, void *, EMPTYARG )
else
pSaveObj->Clear();
- if ( !aLocalRangeName.Insert( pNewEntry ) )
+ if ( !aLocalRangeName.insert( pNewEntry ) )
delete pNewEntry;
UpdateNames();
diff --git a/sc/source/ui/unoobj/nameuno.cxx b/sc/source/ui/unoobj/nameuno.cxx
index bec356b..0632a5d 100644
--- a/sc/source/ui/unoobj/nameuno.cxx
+++ b/sc/source/ui/unoobj/nameuno.cxx
@@ -569,7 +569,7 @@ void SAL_CALL ScNamedRangesObj::addNewByName( const rtl::OUString& aName,
// GRAM_PODF_A1 for API compatibility.
ScRangeData* pNew = new ScRangeData( pDoc, aName, aContent,
aPos, nNewType,formula::FormulaGrammar::GRAM_PODF_A1 );
- if ( pNewRanges->Insert(pNew) )
+ if ( pNewRanges->insert(pNew) )
{
ScDocFunc aFunc(*pDocShell);
aFunc.SetNewRangeNames(pNewRanges, mbModifyAndBroadcast);
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index b5ea95d..db3c302 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -2941,7 +2941,7 @@ BOOL ScViewFunc::InsertName( const String& rName, const String& rSymbol,
pList->erase(*pData);
}
- if ( pList->Insert( pNewEntry ) )
+ if ( pList->insert( pNewEntry ) )
{
pNewEntry = NULL; // nicht loeschen
bOk = TRUE;
commit 8bc312adf347ea3b18512034bdc8db270c4c3e46
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Sat Mar 5 13:50:54 2011 -0500
Finally removed the old ScRangeName code for good!
Plus some build breakage fix.
diff --git a/sc/inc/rangenam.hxx b/sc/inc/rangenam.hxx
index 0abb705..a343607 100644
--- a/sc/inc/rangenam.hxx
+++ b/sc/inc/rangenam.hxx
@@ -67,7 +67,7 @@ typedef USHORT RangeType;
class ScTokenArray;
-class ScRangeData : public ScDataObject
+class ScRangeData
{
private:
String aName;
@@ -106,10 +106,7 @@ public:
// rTarget is ABSPOS jump label
ScRangeData(const ScRangeData& rScRangeData);
- SC_DLLPUBLIC virtual ~ScRangeData();
-
-
- virtual ScDataObject* Clone() const;
+ SC_DLLPUBLIC ~ScRangeData();
BOOL operator== (const ScRangeData& rData) const;
@@ -177,12 +174,8 @@ extern "C" int SAL_CALL ScRangeData_QsortNameCompare( const void*, const void* )
{ return ScRangeData_QsortNameCompare(a,b); }
#endif
-#define NEW_RANGE_NAME 1
-
bool operator< (const ScRangeData& left, const ScRangeData& right);
-#if NEW_RANGE_NAME
-
class ScRangeName
{
private:
@@ -226,52 +219,6 @@ public:
bool operator== (const ScRangeName& r) const;
};
-#else
-
-class ScRangeName : public ScSortedCollection
-{
-private:
- ScDocument* pDoc;
- USHORT nSharedMaxIndex;
-
- using ScSortedCollection::Clone; // calcwarnings: shouldn't be used
-
-public:
- ScRangeName(USHORT nLim = 4, USHORT nDel = 4, BOOL bDup = FALSE,
- ScDocument* pDocument = NULL) :
- ScSortedCollection ( nLim, nDel, bDup ),
- pDoc ( pDocument ),
- nSharedMaxIndex ( 1 ) {} // must not be 0!!
-
- ScRangeName(const ScRangeName& rScRangeName, ScDocument* pDocument);
-
- virtual ScDataObject* Clone(ScDocument* pDocP) const
- { return new ScRangeName(*this, pDocP); }
- ScRangeData* operator[]( const USHORT nIndex) const
- { return (ScRangeData*)At(nIndex); }
- virtual short Compare(ScDataObject* pKey1, ScDataObject* pKey2) const;
- virtual BOOL IsEqual(ScDataObject* pKey1, ScDataObject* pKey2) const;
-
- SC_DLLPUBLIC ScRangeData* GetRangeAtBlock( const ScRange& ) const;
-
- SC_DLLPUBLIC BOOL SearchName( const String& rName, USHORT& rPos ) const;
- // SearchNameUpper must be called with an upper-case search string
- BOOL SearchNameUpper( const String& rUpperName, USHORT& rPos ) const;
- void UpdateReference(UpdateRefMode eUpdateRefMode,
- const ScRange& rRange,
- SCsCOL nDx, SCsROW nDy, SCsTAB nDz );
- void UpdateTabRef(SCTAB nTable, USHORT nFlag, SCTAB nNewTable = 0);
- void UpdateTranspose( const ScRange& rSource, const ScAddress& rDest );
- void UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY );
- virtual BOOL Insert(ScDataObject* pScDataObject);
- SC_DLLPUBLIC ScRangeData* FindIndex(USHORT nIndex);
- USHORT GetSharedMaxIndex() { return nSharedMaxIndex; }
- void SetSharedMaxIndex(USHORT nInd) { nSharedMaxIndex = nInd; }
- USHORT GetEntryIndex();
-};
-
-#endif
-
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 9435b2e..d8e5bc3 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1838,7 +1838,6 @@ void ScDocument::MergeNumberFormatter(ScDocument* pSrcDoc)
void ScDocument::CopyRangeNamesFromClip(ScDocument* pClipDoc, ScClipRangeNameData& rRangeNames)
{
- sal_uInt16 nClipRangeNameCount = pClipDoc->pRangeName->GetCount();
ScClipRangeNameData aClipRangeNames;
ScRangeName::const_iterator itr = pClipDoc->pRangeName->begin();
@@ -1852,12 +1851,11 @@ void ScDocument::CopyRangeNamesFromClip(ScDocument* pClipDoc, ScClipRangeNameDat
A proper solution would ask the user how to proceed.
The adjustment of the indices in the formulas is done later.
*/
- ScRangeData* pClipRangeData = (*pClipDoc->pRangeName)[i];
- USHORT k;
- if ( pRangeName->SearchName( itr->GetName(), k ) )
+ const ScRangeData* pExistingData = pRangeName->findByName(itr->GetName());
+ if (pExistingData)
{
USHORT nOldIndex = itr->GetIndex();
- USHORT nNewIndex = ((*pRangeName)[k])->GetIndex();
+ USHORT nNewIndex = pExistingData->GetIndex();
aClipRangeNames.insert(nOldIndex, nNewIndex);
if ( !aClipRangeNames.mbReplace )
aClipRangeNames.mbReplace = ( nOldIndex != nNewIndex );
diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index 09ec3b1..6d1a013 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -167,7 +167,6 @@ ScRangeData::ScRangeData( ScDocument* pDok,
}
ScRangeData::ScRangeData(const ScRangeData& rScRangeData) :
- ScDataObject(),
aName (rScRangeData.aName),
aUpperName (rScRangeData.aUpperName),
pCode (rScRangeData.pCode ? rScRangeData.pCode->Clone() : new ScTokenArray()), // echte Kopie erzeugen (nicht copy-ctor)
@@ -185,11 +184,6 @@ ScRangeData::~ScRangeData()
delete pCode;
}
-ScDataObject* ScRangeData::Clone() const
-{
- return new ScRangeData(*this);
-}
-
void ScRangeData::GuessPosition()
{
// setzt eine Position, mit der alle relative Referenzen bei CalcAbsIfRel
@@ -663,8 +657,6 @@ ScRangeData_QsortNameCompare( const void* p1, const void* p2 )
(*(const ScRangeData**)p2)->GetName() );
}
-#if NEW_RANGE_NAME
-
bool operator<(const ScRangeData& left, const ScRangeData& right)
{
return left.GetName() < right.GetName();
@@ -861,134 +853,4 @@ bool ScRangeName::operator== (const ScRangeName& r) const
return maData == r.maData;
}
-#else
-
-ScRangeName::ScRangeName(const ScRangeName& rScRangeName, ScDocument* pDocument) :
- ScSortedCollection ( rScRangeName ),
- pDoc ( pDocument ),
- nSharedMaxIndex (rScRangeName.nSharedMaxIndex)
-{
- for (USHORT i = 0; i < nCount; i++)
- {
- ((ScRangeData*)At(i))->SetDocument(pDocument);
- ((ScRangeData*)At(i))->SetIndex(((ScRangeData*)rScRangeName.At(i))->GetIndex());
- }
-}
-
-short ScRangeName::Compare(ScDataObject* pKey1, ScDataObject* pKey2) const
-{
- USHORT i1 = ((ScRangeData*)pKey1)->GetIndex();
- USHORT i2 = ((ScRangeData*)pKey2)->GetIndex();
- return (short) i1 - (short) i2;
-}
-
-BOOL ScRangeName::SearchNameUpper( const String& rUpperName, USHORT& rIndex ) const
-{
- // SearchNameUpper must be called with an upper-case search string
-
- USHORT i = 0;
- while (i < nCount)
- {
- if ( ((*this)[i])->GetUpperName() == rUpperName )
- {
- rIndex = i;
- return TRUE;
- }
- i++;
- }
- return FALSE;
-}
-
-BOOL ScRangeName::SearchName( const String& rName, USHORT& rIndex ) const
-{
- if ( nCount > 0 )
- return SearchNameUpper( ScGlobal::pCharClass->upper( rName ), rIndex );
- else
- return FALSE;
-}
-
-void ScRangeName::UpdateReference( UpdateRefMode eUpdateRefMode,
- const ScRange& rRange,
- SCsCOL nDx, SCsROW nDy, SCsTAB nDz )
-{
- for (USHORT i=0; i<nCount; i++)
- ((ScRangeData*)pItems[i])->UpdateReference(eUpdateRefMode, rRange,
- nDx, nDy, nDz);
-}
-
-void ScRangeName::UpdateTranspose( const ScRange& rSource, const ScAddress& rDest )
-{
- for (USHORT i=0; i<nCount; i++)
- ((ScRangeData*)pItems[i])->UpdateTranspose( rSource, rDest );
-}
-
-void ScRangeName::UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY )
-{
- for (USHORT i=0; i<nCount; i++)
- ((ScRangeData*)pItems[i])->UpdateGrow( rArea, nGrowX, nGrowY );
-}
-
-BOOL ScRangeName::IsEqual(ScDataObject* pKey1, ScDataObject* pKey2) const
-{
- return *(ScRangeData*)pKey1 == *(ScRangeData*)pKey2;
-}
-
-BOOL ScRangeName::Insert(ScDataObject* pScDataObject)
-{
- if (!((ScRangeData*)pScDataObject)->GetIndex()) // schon gesetzt?
- {
- ((ScRangeData*)pScDataObject)->SetIndex( GetEntryIndex() );
- }
-
- return ScSortedCollection::Insert(pScDataObject);
-}
-
-// Suche nach einem freien Index
-
-USHORT ScRangeName::GetEntryIndex()
-{
- USHORT nLast = 0;
- for ( USHORT i = 0; i < nCount; i++ )
- {
- USHORT nIdx = ((ScRangeData*)pItems[i])->GetIndex();
- if( nIdx > nLast )
- {
- nLast = nIdx;
- }
- }
- return nLast + 1;
-}
-
-ScRangeData* ScRangeName::FindIndex( USHORT nIndex )
-{
- ScRangeData aDataObj( nIndex );
- USHORT n;
- if( Search( &aDataObj, n ) )
- return (*this)[ n ];
- else
- return NULL;
-}
-
-
-ScRangeData* ScRangeName::GetRangeAtBlock( const ScRange& rBlock ) const
-{
- if ( pItems )
- {
- for ( USHORT i = 0; i < nCount; i++ )
- if ( ((ScRangeData*)pItems[i])->IsRangeAtBlock( rBlock ) )
- return (ScRangeData*)pItems[i];
- }
- return NULL;
-}
-
-void ScRangeName::UpdateTabRef(SCTAB nOldTable, USHORT nFlag, SCTAB nNewTable)
-{
- for (USHORT i=0; i<nCount; i++)
- ((ScRangeData*)pItems[i])->UpdateTabRef(nOldTable, nFlag, nNewTable);
-}
-
-#endif
-
-
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 86cd65c85a74b2524a7de82d4b40277cd6846581
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Sat Mar 5 13:34:00 2011 -0500
Adjusted ScDocument::CopyRangeNamesFromClip() for the ScRangeName change.
diff --git a/sc/inc/clipparam.hxx b/sc/inc/clipparam.hxx
index 883f17b..aa73901 100644
--- a/sc/inc/clipparam.hxx
+++ b/sc/inc/clipparam.hxx
@@ -78,7 +78,7 @@ struct ScClipParam
struct ScClipRangeNameData
{
ScRangeData::IndexMap maRangeMap;
- ::std::vector<ScRangeData*> mpRangeNames;
+ ::std::vector<ScRangeData*> mpRangeNames; // Don't insert NULL pointers.
bool mbReplace;
ScClipRangeNameData();
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index ddbdad0..9435b2e 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1838,15 +1838,12 @@ void ScDocument::MergeNumberFormatter(ScDocument* pSrcDoc)
void ScDocument::CopyRangeNamesFromClip(ScDocument* pClipDoc, ScClipRangeNameData& rRangeNames)
{
-#if NEW_RANGE_NAME
-#else
sal_uInt16 nClipRangeNameCount = pClipDoc->pRangeName->GetCount();
ScClipRangeNameData aClipRangeNames;
- // array containing range names which might need update of indices
- aClipRangeNames.mpRangeNames.resize(nClipRangeNameCount, NULL);
-
- for (sal_uInt16 i = 0; i < nClipRangeNameCount; ++i) //! DB-Bereiche Pivot-Bereiche auch
+ ScRangeName::const_iterator itr = pClipDoc->pRangeName->begin();
+ ScRangeName::const_iterator itrEnd = pClipDoc->pRangeName->end();
+ for (; itr != itrEnd; ++itr) //! DB-Bereiche Pivot-Bereiche auch
{
/* Copy only if the name doesn't exist in this document.
If it exists we use the already existing name instead,
@@ -1857,10 +1854,9 @@ void ScDocument::CopyRangeNamesFromClip(ScDocument* pClipDoc, ScClipRangeNameDat
*/
ScRangeData* pClipRangeData = (*pClipDoc->pRangeName)[i];
USHORT k;
- if ( pRangeName->SearchName( pClipRangeData->GetName(), k ) )
+ if ( pRangeName->SearchName( itr->GetName(), k ) )
{
- aClipRangeNames.mpRangeNames[i] = NULL; // range name not inserted
- USHORT nOldIndex = pClipRangeData->GetIndex();
+ USHORT nOldIndex = itr->GetIndex();
USHORT nNewIndex = ((*pRangeName)[k])->GetIndex();
aClipRangeNames.insert(nOldIndex, nNewIndex);
if ( !aClipRangeNames.mbReplace )
@@ -1868,14 +1864,14 @@ void ScDocument::CopyRangeNamesFromClip(ScDocument* pClipDoc, ScClipRangeNameDat
}
else
{
- ScRangeData* pData = new ScRangeData( *pClipRangeData );
+ ScRangeData* pData = new ScRangeData( *itr );
pData->SetDocument(this);
if ( pRangeName->FindIndex( pData->GetIndex() ) )
pData->SetIndex(0); // need new index, done in Insert
- if ( pRangeName->Insert( pData ) )
+ if ( pRangeName->insert(pData) )
{
- aClipRangeNames.mpRangeNames[i] = pData;
- USHORT nOldIndex = pClipRangeData->GetIndex();
+ aClipRangeNames.mpRangeNames.push_back(pData);
+ USHORT nOldIndex = itr->GetIndex();
USHORT nNewIndex = pData->GetIndex();
aClipRangeNames.insert(nOldIndex, nNewIndex);
if ( !aClipRangeNames.mbReplace )
@@ -1884,14 +1880,12 @@ void ScDocument::CopyRangeNamesFromClip(ScDocument* pClipDoc, ScClipRangeNameDat
else
{ // must be an overflow
delete pData;
- aClipRangeNames.mpRangeNames[i] = NULL;
- aClipRangeNames.insert(pClipRangeData->GetIndex(), 0);
+ aClipRangeNames.insert(itr->GetIndex(), 0);
aClipRangeNames.mbReplace = true;
}
}
}
rRangeNames = aClipRangeNames;
-#endif
}
void ScDocument::UpdateRangeNamesInFormulas(
@@ -1906,11 +1900,9 @@ void ScDocument::UpdateRangeNamesInFormulas(
// first update all inserted named formulas if they contain other
// range names and used indices changed
- size_t nRangeNameCount = rRangeNames.mpRangeNames.size();
- for (size_t i = 0; i < nRangeNameCount; ++i) //! DB-Bereiche Pivot-Bereiche auch
+ for (size_t i = 0, n = rRangeNames.mpRangeNames.size(); i < n; ++i) //! DB-Bereiche Pivot-Bereiche auch
{
- if ( rRangeNames.mpRangeNames[i] )
- rRangeNames.mpRangeNames[i]->ReplaceRangeNamesInUse(rRangeNames.maRangeMap);
+ rRangeNames.mpRangeNames[i]->ReplaceRangeNamesInUse(rRangeNames.maRangeMap);
}
// then update the formulas, they might need just the updated range names
for ( size_t nRange = 0, n = rDestRanges.size(); nRange < n; ++nRange )
commit 5b67ac86c0636772e8c8aa2b70ecdbbc33ab6cbb
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Sat Mar 5 12:52:56 2011 -0500
Extracted duplicated code blocks into a separate method.
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index f25645f..ddbdad0 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1762,6 +1762,29 @@ void ScDocument::TransposeClip( ScDocument* pTransClip, USHORT nFlags, BOOL bAsL
GetClipParam().mbCutMode = false;
}
+namespace {
+
+void copyUsedNamesToClip(ScRangeName* pClipRangeName, ScRangeName* pRangeName, const std::set<USHORT>& rUsedNames)
+{
+ pClipRangeName->clear();
+ ScRangeName::const_iterator itr = pRangeName->begin(), itrEnd = pRangeName->end();
+ for (; itr != itrEnd; ++itr) //! DB-Bereiche Pivot-Bereiche auch !!!
+ {
+ USHORT nIndex = itr->GetIndex();
+ bool bInUse = (rUsedNames.count(nIndex) > 0);
+ if (!bInUse)
+ continue;
+
+ ScRangeData* pData = new ScRangeData(*itr);
+ if (!pClipRangeName->insert(pData))
+ delete pData;
+ else
+ pData->SetIndex(nIndex);
+ }
+}
+
+}
+
void ScDocument::CopyRangeNamesToClip(ScDocument* pClipDoc, const ScRange& rClipRange, const ScMarkData* pMarks, bool bAllTabs)
{
std::set<USHORT> aUsedNames; // indexes of named ranges that are used in the copied cells
@@ -1772,21 +1795,7 @@ void ScDocument::CopyRangeNamesToClip(ScDocument* pClipDoc, const ScRange& rClip
rClipRange.aStart.Col(), rClipRange.aStart.Row(),
rClipRange.aEnd.Col(), rClipRange.aEnd.Row(), aUsedNames);
- pClipDoc->pRangeName->clear();
- ScRangeName::const_iterator itr = pRangeName->begin(), itrEnd = pRangeName->end();
- for (; itr != itrEnd; ++itr) //! DB-Bereiche Pivot-Bereiche auch !!!
- {
- USHORT nIndex = itr->GetIndex();
- bool bInUse = (aUsedNames.count(nIndex) > 0);
- if (bInUse)
- {
- ScRangeData* pData = new ScRangeData(*itr);
- if (!pClipDoc->pRangeName->insert(pData))
- delete pData;
- else
- pData->SetIndex(nIndex);
- }
- }
+ copyUsedNamesToClip(pClipDoc->pRangeName, pRangeName, aUsedNames);
}
void ScDocument::CopyRangeNamesToClip(ScDocument* pClipDoc, const ScRange& rClipRange, SCTAB nTab)
@@ -1800,21 +1809,7 @@ void ScDocument::CopyRangeNamesToClip(ScDocument* pClipDoc, const ScRange& rClip
rClipRange.aEnd.Col(), rClipRange.aEnd.Row(), aUsedNames );
}
- pClipDoc->pRangeName->clear();
- ScRangeName::const_iterator itr = pRangeName->begin(), itrEnd = pRangeName->end();
- for (; itr != itrEnd; ++itr)
- {
- USHORT nIndex = itr->GetIndex();
- bool bInUse = (aUsedNames.count(nIndex) > 0);
- if (bInUse)
- {
- ScRangeData* pData = new ScRangeData(*itr);
- if (!pClipDoc->pRangeName->insert(pData))
- delete pData;
- else
- pData->SetIndex(nIndex);
- }
- }
+ copyUsedNamesToClip(pClipDoc->pRangeName, pRangeName, aUsedNames);
}
ScDocument::NumFmtMergeHandler::NumFmtMergeHandler(ScDocument* pDoc, ScDocument* pSrcDoc) :
commit ca3474ac7e2d849aabf03bac6d13de657bd6127d
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Sat Mar 5 12:39:31 2011 -0500
Adjusted ScDocument::CopyRangeNamesToClip() for the ScRangeName change.
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 1b13a62..f25645f 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1764,8 +1764,6 @@ void ScDocument::TransposeClip( ScDocument* pTransClip, USHORT nFlags, BOOL bAsL
void ScDocument::CopyRangeNamesToClip(ScDocument* pClipDoc, const ScRange& rClipRange, const ScMarkData* pMarks, bool bAllTabs)
{
-#if NEW_RANGE_NAME
-#else
std::set<USHORT> aUsedNames; // indexes of named ranges that are used in the copied cells
for (SCTAB i = 0; i <= MAXTAB; ++i)
if (pTab[i] && pClipDoc->pTab[i])
@@ -1774,49 +1772,49 @@ void ScDocument::CopyRangeNamesToClip(ScDocument* pClipDoc, const ScRange& rClip
rClipRange.aStart.Col(), rClipRange.aStart.Row(),
rClipRange.aEnd.Col(), rClipRange.aEnd.Row(), aUsedNames);
- pClipDoc->pRangeName->FreeAll();
- for (USHORT i = 0; i < pRangeName->GetCount(); i++) //! DB-Bereiche Pivot-Bereiche auch !!!
+ pClipDoc->pRangeName->clear();
+ ScRangeName::const_iterator itr = pRangeName->begin(), itrEnd = pRangeName->end();
+ for (; itr != itrEnd; ++itr) //! DB-Bereiche Pivot-Bereiche auch !!!
{
- USHORT nIndex = ((ScRangeData*)((*pRangeName)[i]))->GetIndex();
- bool bInUse = ( aUsedNames.find(nIndex) != aUsedNames.end() );
+ USHORT nIndex = itr->GetIndex();
+ bool bInUse = (aUsedNames.count(nIndex) > 0);
if (bInUse)
{
- ScRangeData* pData = new ScRangeData(*((*pRangeName)[i]));
- if (!pClipDoc->pRangeName->Insert(pData))
+ ScRangeData* pData = new ScRangeData(*itr);
+ if (!pClipDoc->pRangeName->insert(pData))
delete pData;
else
pData->SetIndex(nIndex);
}
}
-#endif
}
void ScDocument::CopyRangeNamesToClip(ScDocument* pClipDoc, const ScRange& rClipRange, SCTAB nTab)
{
-#if NEW_RANGE_NAME
-#else
// Indexes of named ranges that are used in the copied cells
std::set<USHORT> aUsedNames;
if ( pTab[nTab] && pClipDoc->pTab[nTab] )
{
- pTab[nTab]->FindRangeNamesInUse( rClipRange.aStart.Col(), rClipRange.aStart.Row(), rClipRange.aEnd.Col(), rClipRange.aEnd.Row(), aUsedNames );
+ pTab[nTab]->FindRangeNamesInUse(
+ rClipRange.aStart.Col(), rClipRange.aStart.Row(),
+ rClipRange.aEnd.Col(), rClipRange.aEnd.Row(), aUsedNames );
}
- pClipDoc->pRangeName->FreeAll();
- for ( USHORT i = 0; i < pRangeName->GetCount(); i++ )
+ pClipDoc->pRangeName->clear();
+ ScRangeName::const_iterator itr = pRangeName->begin(), itrEnd = pRangeName->end();
+ for (; itr != itrEnd; ++itr)
{
- USHORT nIndex = ((ScRangeData*)((*pRangeName)[i]))->GetIndex();
- bool bInUse = ( aUsedNames.find(nIndex) != aUsedNames.end() );
- if ( bInUse )
+ USHORT nIndex = itr->GetIndex();
+ bool bInUse = (aUsedNames.count(nIndex) > 0);
+ if (bInUse)
{
- ScRangeData* pData = new ScRangeData(*((*pRangeName)[i]));
- if ( !pClipDoc->pRangeName->Insert(pData) )
+ ScRangeData* pData = new ScRangeData(*itr);
+ if (!pClipDoc->pRangeName->insert(pData))
delete pData;
else
pData->SetIndex(nIndex);
}
}
-#endif
}
ScDocument::NumFmtMergeHandler::NumFmtMergeHandler(ScDocument* pDoc, ScDocument* pSrcDoc) :
commit eb194b212acbe665fa44403943caa29578511d08
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Sat Mar 5 11:48:27 2011 -0500
Adjusted ScDocument::TransferTab() for the ScRangeName change.
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index d3ed1a4..7b8e91d 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -962,12 +962,13 @@ 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
- ScRangeData** pSrcRangeNames = nSrcRangeNames ? new ScRangeData* [nSrcRangeNames] : NULL;
+ // array containing range names which might need update of indices.
+ // The instances inserted into this vector are managed by the
+ // range name container of this document, so no need to delete
+ // them afterward.
+ ::std::vector<ScRangeData*> aSrcRangeNames;
+
// the index mapping thereof
ScRangeData::IndexMap aSrcRangeMap;
BOOL bRangeNameReplace = FALSE;
@@ -976,14 +977,14 @@ ULONG ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos,
std::set<USHORT> aUsedNames;
pSrcDoc->pTab[nSrcPos]->FindRangeNamesInUse( 0, 0, MAXCOL, MAXROW, aUsedNames );
- for (size_t i = 0; i < nSrcRangeNames; i++) //! DB-Bereiche Pivot-Bereiche auch !!!
+ ScRangeName::const_iterator itr = pSrcDoc->pRangeName->begin(), itrEnd = pSrcDoc->pRangeName->end();
+ for (; itr != itrEnd; ++itr) //! DB-Bereiche Pivot-Bereiche auch !!!
{
- ScRangeData* pSrcData = (*pSrcDoc->pRangeName)[i];
- USHORT nOldIndex = pSrcData->GetIndex();
+ USHORT nOldIndex = itr->GetIndex();
bool bInUse = ( aUsedNames.find(nOldIndex) != aUsedNames.end() );
if (bInUse)
{
- const ScRangeData* pExistingData = pRangeName->findByName(pSrcData->GetName());
+ const ScRangeData* pExistingData = pRangeName->findByName(itr->GetName());
if (pExistingData)
{
// the name exists already in the destination document
@@ -992,7 +993,7 @@ ULONG ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos,
USHORT nExistingIndex = pExistingData->GetIndex();
- pSrcRangeNames[i] = NULL; // don't modify the named range
+ // don't modify the named range
aSrcRangeMap.insert(
ScRangeData::IndexMap::value_type(nOldIndex, nExistingIndex));
bRangeNameReplace = TRUE;
@@ -1000,7 +1001,7 @@ ULONG ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos,
}
else
{
- ScRangeData* pData = new ScRangeData( *pSrcData );
+ ScRangeData* pData = new ScRangeData( *itr );
pData->SetDocument(this);
if ( pRangeName->FindIndex( pData->GetIndex() ) )
pData->SetIndex(0); // need new index, done in Insert
@@ -1012,7 +1013,7 @@ ULONG ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos,
else
{
pData->TransferTabRef( nSrcPos, nDestPos );
- pSrcRangeNames[i] = pData;
+ aSrcRangeNames.push_back(pData);
USHORT nNewIndex = pData->GetIndex();
aSrcRangeMap.insert(
ScRangeData::IndexMap::value_type(nOldIndex, nNewIndex));
@@ -1021,25 +1022,17 @@ ULONG ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos,
}
}
}
- else
- {
- pSrcRangeNames[i] = NULL;
- }
}
if ( bRangeNameReplace )
{
// first update all inserted named formulas if they contain other
// range names and used indices changed
- for (USHORT i = 0; i < nSrcRangeNames; i++) //! DB-Bereiche Pivot-Bereiche auch
- {
- if ( pSrcRangeNames[i] )
- pSrcRangeNames[i]->ReplaceRangeNamesInUse( aSrcRangeMap );
- }
+ for (size_t i = 0, n = aSrcRangeNames.size(); i < n; ++i) //! DB-Bereiche Pivot-Bereiche auch
+ aSrcRangeNames[i]->ReplaceRangeNamesInUse( aSrcRangeMap );
+
// then update the formulas, they might need the just updated range names
pTab[nDestPos]->ReplaceRangeNamesInUse( 0, 0, MAXCOL, MAXROW, aSrcRangeMap );
}
- if ( pSrcRangeNames )
- delete [] pSrcRangeNames;
SCsTAB nDz = ((SCsTAB)nDestPos) - (SCsTAB)nSrcPos;
pTab[nDestPos]->UpdateReference(URM_COPY, 0, 0, nDestPos,
@@ -1060,7 +1053,6 @@ ULONG ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos,
// message: duplicate names
}
pTab[nDestPos]->CompileAll();
-#endif
}
SetNoListening( FALSE );
commit 5df2c05c6723e2065976591c2b6fe726c16296e4
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Sat Mar 5 03:01:22 2011 -0500
Adjusted the excel export code.
diff --git a/sc/source/filter/excel/xename.cxx b/sc/source/filter/excel/xename.cxx
index 12c3e2e..f9e9327 100644
--- a/sc/source/filter/excel/xename.cxx
+++ b/sc/source/filter/excel/xename.cxx
@@ -671,24 +671,14 @@ void XclExpNameManagerImpl::CreateBuiltInNames()
void XclExpNameManagerImpl::CreateUserNames()
{
-#if NEW_RANGE_NAME
const ScRangeName& rNamedRanges = GetNamedRanges();
ScRangeName::const_iterator itr = rNamedRanges.begin(), itrEnd = rNamedRanges.end();
for (; itr != itrEnd; ++itr)
{
- // TODO: re-implement maNameMap to map name to excel index.
- }
-#else
- const ScRangeName& rNamedRanges = GetNamedRanges();
- for( USHORT nNameIdx = 0, nNameCount = rNamedRanges.GetCount(); nNameIdx < nNameCount; ++nNameIdx )
- {
- const ScRangeData* pRangeData = rNamedRanges[ nNameIdx ];
- DBG_ASSERT( rNamedRanges[ nNameIdx ], "XclExpNameManagerImpl::CreateUserNames - missing defined name" );
// skip definitions of shared formulas
- if( pRangeData && !pRangeData->HasType( RT_SHARED ) && !FindNameIdx( maNameMap, pRangeData->GetIndex() ) )
- CreateName( *pRangeData );
+ if (!itr->HasType(RT_SHARED) && !FindNameIdx(maNameMap, itr->GetIndex()))
+ CreateName(*itr);
}
-#endif
}
void XclExpNameManagerImpl::CreateDatabaseNames()
commit 37c0dd039ca8a8d3e49028590a0611ff4d5428a1
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Sat Mar 5 02:55:07 2011 -0500
Reverted on index handling of range name objects.
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 6c61390..b51f95a 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1479,7 +1479,7 @@ public:
VirtualDevice* GetVirtualDevice_100th_mm();
SC_DLLPUBLIC OutputDevice* GetRefDevice(); // WYSIWYG: Printer, otherwise VirtualDevice...
- void EraseNonUsedSharedNames();
+ void EraseNonUsedSharedNames(USHORT nLevel);
BOOL GetNextSpellingCell(SCCOL& nCol, SCROW& nRow, SCTAB nTab,
BOOL bInSel, const ScMarkData& rMark) const;
diff --git a/sc/inc/rangenam.hxx b/sc/inc/rangenam.hxx
index 88a8329..0abb705 100644
--- a/sc/inc/rangenam.hxx
+++ b/sc/inc/rangenam.hxx
@@ -203,13 +203,12 @@ public:
SC_DLLPUBLIC const ScRangeData* findByName(const rtl::OUString& rName) const;
ScRangeData* findByUpperName(const rtl::OUString& rName);
const ScRangeData* findByUpperName(const rtl::OUString& rName) const;
- bool getIndex(const ScRangeData& rData, size_t& rIndex) const;
void UpdateReference(UpdateRefMode eUpdateRefMode, const ScRange& rRange,
SCsCOL nDx, SCsROW nDy, SCsTAB nDz);
void UpdateTabRef(SCTAB nTable, sal_uInt16 nFlag, SCTAB nNewTable = 0);
void UpdateTranspose(const ScRange& rSource, const ScAddress& rDest);
void UpdateGrow(const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY);
- SC_DLLPUBLIC ScRangeData* FindIndex(size_t i);
+ SC_DLLPUBLIC ScRangeData* FindIndex(USHORT i);
sal_uInt16 GetSharedMaxIndex();
void SetSharedMaxIndex(sal_uInt16 nInd);
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index ea4015f..d3ed1a4 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -1132,7 +1132,7 @@ void ScDocument::SetError( SCCOL nCol, SCROW nRow, SCTAB nTab, const USHORT nErr
namespace {
-bool eraseUnusedSharedName(ScRangeName* pRangeName, ScTable* pTab[])
+bool eraseUnusedSharedName(ScRangeName* pRangeName, ScTable* pTab[], USHORT nLevel)
{
ScRangeName::const_iterator itr = pRangeName->begin(), itrEnd = pRangeName->end();
for (; itr != itrEnd; ++itr)
@@ -1140,11 +1140,15 @@ bool eraseUnusedSharedName(ScRangeName* pRangeName, ScTable* pTab[])
if (!itr->HasType(RT_SHARED))
continue;
- size_t nIndex;
- if (!pRangeName->getIndex(*itr, nIndex))
- // index not found.
+ String aName;
+ itr->GetName(aName);
+ aName.Erase(0, 6); // !!! vgl. Table4, FillFormula !!
+ USHORT nInd = static_cast<USHORT>(aName.ToInt32());
+ if (nInd > nLevel)
continue;
+ USHORT nIndex = itr->GetIndex();
+
bool bInUse = false;
for (SCTAB j = 0; !bInUse && (j <= MAXTAB); ++j)
{
@@ -1162,9 +1166,9 @@ bool eraseUnusedSharedName(ScRangeName* pRangeName, ScTable* pTab[])
}
-void ScDocument::EraseNonUsedSharedNames()
+void ScDocument::EraseNonUsedSharedNames(USHORT nLevel)
{
- while (eraseUnusedSharedName(pRangeName, pTab))
+ while (eraseUnusedSharedName(pRangeName, pTab, nLevel))
;
}
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 4399097..1b13a62 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1710,11 +1710,12 @@ void ScDocument::TransposeClip( ScDocument* pTransClip, USHORT nFlags, BOOL bAsL
ScRangeName::const_iterator itr = pRangeName->begin(), itrEnd = pRangeName->end();
for (; itr != itrEnd; ++itr)
{
+ USHORT nIndex = itr->GetIndex();
ScRangeData* pData = new ScRangeData(*itr);
if (!pTransClip->pRangeName->insert(pData))
delete pData;
else
- pData->SetIndex(0);
+ pData->SetIndex(nIndex);
}
// The data
diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index 2758be0..09ec3b1 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -724,16 +724,6 @@ ScRangeData* ScRangeName::findByUpperName(const OUString& rName)
return NULL;
}
-bool ScRangeName::getIndex(const ScRangeData& rData, size_t& rIndex) const
-{
- DataType::const_iterator itr = maData.find(rData);
- if (itr == maData.end())
- return false;
-
- rIndex = std::distance(maData.begin(), itr);
- return true;
-}
-
const ScRangeData* ScRangeName::findByUpperName(const OUString& rName) const
{
DataType::const_iterator itr = maData.begin(), itrEnd = maData.end();
@@ -774,14 +764,13 @@ void ScRangeName::UpdateGrow(const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY)
itr->UpdateGrow(rArea, nGrowX, nGrowY);
}
-ScRangeData* ScRangeName::FindIndex(size_t i)
+ScRangeData* ScRangeName::FindIndex(USHORT i)
{
- if (i >= maData.size())
- return NULL;
-
- DataType::iterator itr = maData.begin();
- ::std::advance(itr, i);
- return &(*itr);
+ DataType::iterator itr = maData.begin(), itrEnd = maData.end();
+ for (; itr != itrEnd; ++itr)
+ if (itr->GetIndex() == i)
+ return &(*itr);
+ return NULL;
}
sal_uInt16 ScRangeName::GetSharedMaxIndex()
@@ -829,6 +818,20 @@ bool ScRangeName::insert(ScRangeData* p)
if (!p)
return false;
+ if (!p->GetIndex())
+ {
+ // Assign a new index. An index must be unique.
+ USHORT nHigh = 0;
+ DataType::const_iterator itr = maData.begin(), itrEnd = maData.end();
+ for (; itr != itrEnd; ++itr)
+ {
+ USHORT n = itr->GetIndex();
+ if (n > nHigh)
+ nHigh = n;
+ }
+ p->SetIndex(nHigh + 1);
+ }
+
pair<DataType::iterator, bool> r = maData.insert(p);
return r.second;
}
diff --git a/sc/source/ui/undo/undoblk3.cxx b/sc/source/ui/undo/undoblk3.cxx
index 6a691ab..d63281b 100644
--- a/sc/source/ui/undo/undoblk3.cxx
+++ b/sc/source/ui/undo/undoblk3.cxx
@@ -629,7 +629,7 @@ ScUndoAutoFill::ScUndoAutoFill( ScDocShell* pNewDocShell,
ScUndoAutoFill::~ScUndoAutoFill()
{
- pDocShell->GetDocument()->EraseNonUsedSharedNames();
+ pDocShell->GetDocument()->EraseNonUsedSharedNames(nMaxSharedIndex);
delete pUndoDoc;
}
commit a79a67e074f7b908d8404b774261e93dece287ab
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Sat Mar 5 00:36:23 2011 -0500
Adjusted ScSpecialFilterDlg for the ScRangeName change.
diff --git a/sc/source/ui/dbgui/sfiltdlg.cxx b/sc/source/ui/dbgui/sfiltdlg.cxx
index f53e334..536785d 100644
--- a/sc/source/ui/dbgui/sfiltdlg.cxx
+++ b/sc/source/ui/dbgui/sfiltdlg.cxx
@@ -149,42 +149,25 @@ void ScSpecialFilterDlg::Init( const SfxItemSet& rArgSet )
{
if(pDoc->GetChangeTrack()!=NULL) aBtnCopyResult.Disable();
- ScRangeName* pRangeNames = pDoc->GetRangeName();
-#if NEW_RANGE_NAME
-#else
- const USHORT nCount = pRangeNames ? pRangeNames->GetCount() : 0;
-
- /*
- * Aus den RangeNames des Dokumentes werden nun die
- * gemerkt, bei denen es sich um Filter-Bereiche handelt
- */
-
+ ScRangeName* pRangeNames = pDoc->GetRangeName();
aLbFilterArea.Clear();
aLbFilterArea.InsertEntry( aStrUndefined, 0 );
- if ( nCount > 0 )
+ if (!pRangeNames->empty())
{
- String aString;
- ScRangeData* pData = NULL;
- USHORT nInsert = 0;
-
- for ( USHORT i=0; i<nCount; i++ )
+ ScRangeName::const_iterator itr = pRangeNames->begin(), itrEnd = pRangeNames->end();
+ USHORT nInsert = 0;
+ for (; itr != itrEnd; ++itr)
{
- pData = (ScRangeData*)(pRangeNames->At( i ));
- if ( pData )
- {
- if ( pData->HasType( RT_CRITERIA ) )
- {
- pData->GetName( aString );
- nInsert = aLbFilterArea.InsertEntry( aString );
- pData->GetSymbol( aString );
- aLbFilterArea.SetEntryData( nInsert,
- new String( aString ) );
- }
- }
+ if (!itr->HasType(RT_CRITERIA))
+ continue;
+
+ nInsert = aLbFilterArea.InsertEntry(itr->GetName());
+ rtl::OUString aSymbol;
+ itr->GetSymbol(aSymbol);
+ aLbFilterArea.SetEntryData(nInsert, new String(aSymbol));
}
}
-#endif
// is there a stored source range?
commit e2aeda6ccfafafb386ba07e5b937fbfab906745c
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Sat Mar 5 00:25:55 2011 -0500
Adjusted ScNamedRangeObj for the ScRangeName change.
diff --git a/sc/source/ui/unoobj/nameuno.cxx b/sc/source/ui/unoobj/nameuno.cxx
index 429d89e..bec356b 100644
--- a/sc/source/ui/unoobj/nameuno.cxx
+++ b/sc/source/ui/unoobj/nameuno.cxx
@@ -143,58 +143,58 @@ void ScNamedRangeObj::Modify_Impl( const String* pNewName, const ScTokenArray* p
const ScAddress* pNewPos, const sal_uInt16* pNewType,
const formula::FormulaGrammar::Grammar eGrammar )
{
-#if NEW_RANGE_NAME
-#else
- if (pDocShell)
- {
- ScDocument* pDoc = pDocShell->GetDocument();
- ScRangeName* pNames = pDoc->GetRangeName();
- if (pNames)
- {
- sal_uInt16 nPos = 0;
- if (pNames->SearchName( aName, nPos ))
- {
- ScRangeName* pNewRanges = new ScRangeName( *pNames );
- ScRangeData* pOld = (*pNames)[nPos];
-
- String aInsName(pOld->GetName());
- if (pNewName)
- aInsName = *pNewName;
- String aContent; // Content string based =>
- pOld->GetSymbol( aContent, eGrammar); // no problems with changed positions and such.
- if (pNewContent)
- aContent = *pNewContent;
- ScAddress aPos(pOld->GetPos());
- if (pNewPos)
- aPos = *pNewPos;
- sal_uInt16 nType = pOld->GetType();
- if (pNewType)
- nType = *pNewType;
-
- ScRangeData* pNew = NULL;
- if ( pNewTokens )
- pNew = new ScRangeData( pDoc, aInsName, *pNewTokens, aPos, nType );
- else
- pNew = new ScRangeData( pDoc, aInsName, aContent, aPos, nType, eGrammar );
- pNew->SetIndex( pOld->GetIndex() );
+ if (!pDocShell)
+ return;
- pNewRanges->AtFree( nPos );
- if ( pNewRanges->Insert(pNew) )
- {
- ScDocFunc aFunc(*pDocShell);
- aFunc.SetNewRangeNames( pNewRanges, mpParent->IsModifyAndBroadcast());
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScRangeName* pNames = pDoc->GetRangeName();
+ if (!pNames)
+ return;
- aName = aInsName; //! broadcast?
- }
- else
- {
- delete pNew; //! uno::Exception/Fehler oder so
- delete pNewRanges;
- }
- }
- }
+ const ScRangeData* pOld = pNames->findByName(aName);
+ if (!pOld)
+ return;
+
+ ScRangeName* pNewRanges = new ScRangeName(*pNames);
+
+ String aInsName = pOld->GetName();
+ if (pNewName)
+ aInsName = *pNewName;
+
+ String aContent; // Content string based =>
+ pOld->GetSymbol( aContent, eGrammar); // no problems with changed positions and such.
+ if (pNewContent)
+ aContent = *pNewContent;
+
+ ScAddress aPos = pOld->GetPos();
+ if (pNewPos)
+ aPos = *pNewPos;
+
+ sal_uInt16 nType = pOld->GetType();
+ if (pNewType)
+ nType = *pNewType;
+
+ ScRangeData* pNew = NULL;
+ if (pNewTokens)
+ pNew = new ScRangeData( pDoc, aInsName, *pNewTokens, aPos, nType );
+ else
+ pNew = new ScRangeData( pDoc, aInsName, aContent, aPos, nType, eGrammar );
+
+ pNew->SetIndex( pOld->GetIndex() );
+
+ pNewRanges->erase(*pOld);
+ if (pNewRanges->insert(pNew))
+ {
+ ScDocFunc aFunc(*pDocShell);
+ aFunc.SetNewRangeNames(pNewRanges, mpParent->IsModifyAndBroadcast());
+
+ aName = aInsName; //! broadcast?
+ }
+ else
+ {
+ delete pNew; //! uno::Exception/Fehler oder so
+ delete pNewRanges;
}
-#endif
}
commit 37436287dbe797f9137cc81aa34b2660014e9cd8
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Sat Mar 5 00:11:56 2011 -0500
Adjusted ScAreaNameIterator for the ScRangeName change.
diff --git a/sc/inc/rangeutl.hxx b/sc/inc/rangeutl.hxx
index 48aae61..8faac6e 100644
--- a/sc/inc/rangeutl.hxx
+++ b/sc/inc/rangeutl.hxx
@@ -29,9 +29,12 @@
#ifndef SC_RANGEUTL_HXX
#define SC_RANGEUTL_HXX
-#include "address.hxx"
#include <tools/string.hxx>
+
+#include "address.hxx"
+#include "rangenam.hxx"
#include "scdllapi.h"
+
#include <com/sun/star/table/CellAddress.hpp>
#include <com/sun/star/table/CellRangeAddress.hpp>
#include <com/sun/star/uno/Sequence.hxx>
@@ -303,11 +306,13 @@ public:
class SC_DLLPUBLIC ScAreaNameIterator
{
private:
+ String aStrNoName;
ScRangeName* pRangeName;
+ ScRangeName::const_iterator maRNPos;
+ ScRangeName::const_iterator maRNEnd;
ScDBCollection* pDBCollection;
- BOOL bFirstPass;
- USHORT nPos;
- String aStrNoName;
+ bool bFirstPass;
+ size_t nPos;
public:
ScAreaNameIterator( ScDocument* pDoc );
diff --git a/sc/source/core/tool/rangeutl.cxx b/sc/source/core/tool/rangeutl.cxx
index a97f8aa..f747135 100644
--- a/sc/source/core/tool/rangeutl.cxx
+++ b/sc/source/core/tool/rangeutl.cxx
@@ -1037,38 +1037,43 @@ BOOL ScArea::operator==( const ScArea& r ) const
//------------------------------------------------------------------------
ScAreaNameIterator::ScAreaNameIterator( ScDocument* pDoc ) :
- aStrNoName( ScGlobal::GetRscString(STR_DB_NONAME) )
+ aStrNoName(ScGlobal::GetRscString(STR_DB_NONAME)),
+ pRangeName(pDoc->GetRangeName()),
+ pDBCollection(pDoc->GetDBCollection()),
+ bFirstPass(true),
+ nPos(0)
{
- pRangeName = pDoc->GetRangeName();
- pDBCollection = pDoc->GetDBCollection();
- nPos = 0;
- bFirstPass = TRUE;
+ if (pRangeName)
+ {
+ maRNPos = pRangeName->begin();
+ maRNEnd = pRangeName->end();
+ }
}
BOOL ScAreaNameIterator::Next( String& rName, ScRange& rRange )
{
for (;;)
{
-#if NEW_RANGE_NAME
-#else
if ( bFirstPass ) // erst Bereichsnamen
{
- if ( pRangeName && nPos < pRangeName->GetCount() )
+ if ( pRangeName && maRNPos != maRNEnd )
{
- ScRangeData* pData = (*pRangeName)[nPos++];
- if ( pData && pData->IsValidReference(rRange) )
+ const ScRangeData& rData = *maRNPos;
+ ++maRNPos;
+ bool bValid = rData.IsValidReference(rRange);
+ if (bValid)
{
- rName = pData->GetName();
- return TRUE; // gefunden
+ rName = rData.GetName();
+ return true; // gefunden
}
}
else
{
- bFirstPass = FALSE;
+ bFirstPass = false;
nPos = 0;
}
}
-#endif
+
if ( !bFirstPass ) // dann DB-Bereiche
{
if ( pDBCollection && nPos < pDBCollection->GetCount() )
commit aad4f1164a3f66a56bb1c2a821181b2e6eb201ac
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Fri Mar 4 23:48:33 2011 -0500
More on adjusting for ScRangeName API change.
diff --git a/sc/inc/address.hxx b/sc/inc/address.hxx
index 2e160c6..cf4ed99 100644
--- a/sc/inc/address.hxx
+++ b/sc/inc/address.hxx
@@ -527,6 +527,9 @@ public:
SC_DLLPUBLIC void Format( String&, USHORT = 0, ScDocument* = NULL,
const ScAddress::Details& rDetails = ScAddress::detailsOOOa1 ) const;
+ SC_DLLPUBLIC void Format( rtl::OUString&, USHORT = 0, ScDocument* = NULL,
+ const ScAddress::Details& rDetails = ScAddress::detailsOOOa1 ) const;
+
inline void GetVars( SCCOL& nCol1, SCROW& nRow1, SCTAB& nTab1,
SCCOL& nCol2, SCROW& nRow2, SCTAB& nTab2 ) const;
// The document for the maximum defined sheet number
diff --git a/sc/inc/rangenam.hxx b/sc/inc/rangenam.hxx
index 5a94f3d..88a8329 100644
--- a/sc/inc/rangenam.hxx
+++ b/sc/inc/rangenam.hxx
@@ -130,7 +130,8 @@ public:
void AddType( RangeType nType ) { eType = eType|nType; }
RangeType GetType() const { return eType; }
BOOL HasType( RangeType nType ) const;
- SC_DLLPUBLIC void GetSymbol( String& rSymbol, const formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_DEFAULT ) const;
+ SC_DLLPUBLIC void GetSymbol( String& rSymbol, const formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_DEFAULT ) const;
+ SC_DLLPUBLIC void GetSymbol( rtl::OUString& rSymbol, const formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_DEFAULT ) const;
void UpdateSymbol( rtl::OUStringBuffer& rBuffer, const ScAddress&,
const formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_DEFAULT );
void UpdateReference( UpdateRefMode eUpdateRefMode,
diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx
index 5c777e7..1d6ecf9 100644
--- a/sc/source/core/tool/address.cxx
+++ b/sc/source/core/tool/address.cxx
@@ -44,9 +44,10 @@
#include <com/sun/star/sheet/ExternalLinkType.hpp>
#include <sfx2/objsh.hxx>
#include <tools/urlobj.hxx>
+
using namespace ::com::sun::star;
+using ::rtl::OUString;
-////////////////////////////////////////////////////////////////////////////
const ScAddress::Details ScAddress::detailsOOOa1( formula::FormulaGrammar::CONV_OOO, 0, 0 );
ScAddress::Details::Details ( const ScDocument* pDoc,
@@ -1874,6 +1875,14 @@ void ScRange::Format( String& r, USHORT nFlags, ScDocument* pDoc,
#undef absrel_differ
}
+void ScRange::Format( OUString& r, USHORT nFlags, ScDocument* pDoc,
+ const ScAddress::Details& rDetails ) const
+{
+ String aStr;
+ Format(aStr, nFlags, pDoc, rDetails);
+ r = aStr;
+}
+
bool ScAddress::Move( SCsCOL dx, SCsROW dy, SCsTAB dz, ScDocument* pDoc )
{
SCsTAB nMaxTab = pDoc ? pDoc->GetTableCount() : MAXTAB+1;
diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index 30ef741..2758be0 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -235,6 +235,13 @@ void ScRangeData::GetSymbol( String& rSymbol, const FormulaGrammar::Grammar eGra
aComp.CreateStringFromTokenArray( rSymbol );
}
+void ScRangeData::GetSymbol( OUString& rSymbol, const FormulaGrammar::Grammar eGrammar ) const
+{
+ String aStr;
+ GetSymbol(aStr, eGrammar);
+ rSymbol = aStr;
+}
+
void ScRangeData::UpdateSymbol( rtl::OUStringBuffer& rBuffer, const ScAddress& rPos,
const FormulaGrammar::Grammar eGrammar )
{
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 8698fe8..7cd88f7 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -1411,43 +1411,31 @@ void ScPosWnd::FillRangeNames()
// per Hand sortieren, weil Funktionen nicht sortiert werden:
ScRangeName* pRangeNames = pDoc->GetRangeName();
-#if NEW_RANGE_NAME
-#else
- USHORT nCount = pRangeNames->GetCount();
- if ( nCount > 0 )
+ if (!pRangeNames->empty())
{
- USHORT nValidCount = 0;
ScRange aDummy;
- USHORT i;
- for ( i=0; i<nCount; i++ )
+ std::vector<const ScRangeData*> aSortArray;
+ ScRangeName::const_iterator itr = pRangeNames->begin(), itrEnd = pRangeNames->end();
+ for (; itr != itrEnd; ++itr)
{
- ScRangeData* pData = (*pRangeNames)[i];
- if (pData->IsValidReference(aDummy))
- nValidCount++;
+ if (itr->IsValidReference(aDummy))
+ aSortArray.push_back(&(*itr));
}
- if ( nValidCount )
+
+ if (!aSortArray.empty())
{
- ScRangeData** ppSortArray = new ScRangeData* [ nValidCount ];
- USHORT j;
- for ( i=0, j=0; i<nCount; i++ )
- {
- ScRangeData* pData = (*pRangeNames)[i];
- if (pData->IsValidReference(aDummy))
- ppSortArray[j++] = pData;
- }
#ifndef ICC
- qsort( (void*)ppSortArray, nValidCount, sizeof(ScRangeData*),
+ size_t n = aSortArray.size();
+ qsort( (void*)&aSortArray[0], n, sizeof(ScRangeData*),
&ScRangeData_QsortNameCompare );
#else
- qsort( (void*)ppSortArray, nValidCount, sizeof(ScRangeData*),
+ qsort( (void*)&aSortArray[0], n, sizeof(ScRangeData*),
ICCQsortNameCompare );
#endif
- for ( j=0; j<nValidCount; j++ )
- InsertEntry( ppSortArray[j]->GetName() );
- delete [] ppSortArray;
+ for (size_t i = 0; i < n; ++i)
+ InsertEntry(aSortArray[i]->GetName());
}
}
-#endif
}
SetText(aPosStr);
}
diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx
index 5ac5726..6374268 100644
--- a/sc/source/ui/navipi/content.cxx
+++ b/sc/source/ui/navipi/content.cxx
@@ -666,43 +666,31 @@ void ScContentTree::GetAreaNames()
return;
ScRangeName* pRangeNames = pDoc->GetRangeName();
-#if NEW_RANGE_NAME
-#else
- USHORT nCount = pRangeNames->GetCount();
- if ( nCount > 0 )
+ if (!pRangeNames->empty())
{
- USHORT nValidCount = 0;
ScRange aDummy;
- USHORT i;
- for ( i=0; i<nCount; i++ )
+ ScRangeName::const_iterator itrBeg = pRangeNames->begin(), itrEnd = pRangeNames->end();
+ std::vector<const ScRangeData*> aSortArray;
+ for (ScRangeName::const_iterator itr = itrBeg; itr != itrEnd; ++itr)
{
- ScRangeData* pData = (*pRangeNames)[i];
- if (pData->IsValidReference(aDummy))
- nValidCount++;
+ if (itr->IsValidReference(aDummy))
+ aSortArray.push_back(&(*itr));
}
- if ( nValidCount )
+
+ if (!aSortArray.empty())
{
- ScRangeData** ppSortArray = new ScRangeData* [ nValidCount ];
- USHORT j;
- for ( i=0, j=0; i<nCount; i++ )
- {
- ScRangeData* pData = (*pRangeNames)[i];
- if (pData->IsValidReference(aDummy))
- ppSortArray[j++] = pData;
- }
#ifndef ICC
- qsort( (void*)ppSortArray, nValidCount, sizeof(ScRangeData*),
+ size_t n = aSortArray.size();
+ qsort( (void*)&aSortArray[0], n, sizeof(ScRangeData*),
&ScRangeData_QsortNameCompare );
#else
- qsort( (void*)ppSortArray, nValidCount, sizeof(ScRangeData*),
+ qsort( (void*)&aSortArray[0], n, sizeof(ScRangeData*),
ICCQsortNameCompare );
#endif
- for ( j=0; j<nValidCount; j++ )
- InsertContent( SC_CONTENT_RANGENAME, ppSortArray[j]->GetName() );
- delete [] ppSortArray;
+ for (size_t i = 0; i < n; ++i)
+ InsertContent(SC_CONTENT_RANGENAME, aSortArray[i]->GetName());
}
}
-#endif
}
void ScContentTree::GetDbNames()
diff --git a/sc/source/ui/pagedlg/areasdlg.cxx b/sc/source/ui/pagedlg/areasdlg.cxx
index 008e3fe..f998f1d 100644
--- a/sc/source/ui/pagedlg/areasdlg.cxx
+++ b/sc/source/ui/pagedlg/areasdlg.cxx
@@ -69,6 +69,8 @@ const USHORT SC_AREASDLG_RR_OFFSET = 2;
//============================================================================
+using ::rtl::OUString;
+
#define HDL(hdl) LINK( this, ScPrintAreasDlg, hdl )
#define ERRORBOX(nId) ErrorBox( this, WinBits(WB_OK|WB_DEF_OK), \
ScGlobal::GetRscString( nId ) ).Execute()
@@ -76,8 +78,14 @@ const USHORT SC_AREASDLG_RR_OFFSET = 2;
// globale Funktionen (->am Ende der Datei):
-bool lcl_CheckRepeatString( const String& rStr, ScDocument* pDoc, bool bIsRow, ScRange* pRange );
-void lcl_GetRepeatRangeString( const ScRange* pRange, ScDocument* pDoc, bool bIsRow, String& rStr );
+bool lcl_CheckRepeatString( const String& rStr, ScDocument* pDoc, bool bIsRow, ScRange* pRange );
+void lcl_GetRepeatRangeString( const ScRange* pRange, ScDocument* pDoc, bool bIsRow, String& rStr );
+void lcl_GetRepeatRangeString( const ScRange* pRange, ScDocument* pDoc, bool bIsRow, OUString& rStr )
+{
+ String aStr;
+ lcl_GetRepeatRangeString(pRange, pDoc, bIsRow, aStr);
+ rStr = aStr;
+}
#if 0
// this method is useful when debugging address flags.
@@ -466,58 +474,48 @@ void ScPrintAreasDlg::Impl_FillLists()
//------------------------------------------------------
// Ranges holen und in ListBoxen merken
//------------------------------------------------------
- ScRangeName* pRangeNames = pDoc->GetRangeName();
- size_t nCount = pRangeNames ? pRangeNames->size() : 0;
-#if NEW_RANGE_NAME
-#else
- if ( nCount > 0 )
+ ScRangeName* pRangeNames = pDoc->GetRangeName();
+
+ if (!pRangeNames || pRangeNames->empty())
+ // No range names to process.
+ return;
+
+ ScRangeName::const_iterator itr = pRangeNames->begin(), itrEnd = pRangeNames->end();
+ for (; itr != itrEnd; ++itr)
{
- String aName;
- String aSymbol;
- ScRangeData* pData = NULL;
+ if (!itr->HasType(RT_ABSAREA) && !itr->HasType(RT_REFAREA) && !itr->HasType(RT_ABSPOS))
+ continue;
- for ( USHORT i=0; i<nCount; i++ )
+ OUString aName = itr->GetName();
+ OUString aSymbol;
+ itr->GetSymbol(aSymbol);
+ if (aRange.ParseAny(aSymbol, pDoc, eConv) & SCA_VALID)
{
- pData = (ScRangeData*)(pRangeNames->At( i ));
- if ( pData )
+ if (itr->HasType(RT_PRINTAREA))
{
- if ( pData->HasType( RT_ABSAREA )
- || pData->HasType( RT_REFAREA )
- || pData->HasType( RT_ABSPOS ) )
- {
- pData->GetName( aName );
- pData->GetSymbol( aSymbol );
- if ( aRange.ParseAny( aSymbol, pDoc, eConv ) & SCA_VALID )
- {
- if ( pData->HasType( RT_PRINTAREA ) )
- {
- aRange.Format( aSymbol, SCR_ABS, pDoc, eConv );
- aLbPrintArea.SetEntryData(
- aLbPrintArea.InsertEntry( aName ),
- new String( aSymbol ) );
- }
-
- if ( pData->HasType( RT_ROWHEADER ) )
- {
- lcl_GetRepeatRangeString(&aRange, pDoc, true, aSymbol);
- aLbRepeatRow.SetEntryData(
- aLbRepeatRow.InsertEntry( aName ),
- new String( aSymbol ) );
- }
-
- if ( pData->HasType( RT_COLHEADER ) )
- {
- lcl_GetRepeatRangeString(&aRange, pDoc, false, aSymbol);
- aLbRepeatCol.SetEntryData(
- aLbRepeatCol.InsertEntry( aName ),
- new String( aSymbol ) );
- }
- }
- }
+ aRange.Format(aSymbol, SCR_ABS, pDoc, eConv);
+ aLbPrintArea.SetEntryData(
+ aLbPrintArea.InsertEntry(aName),
+ new String(aSymbol) );
+ }
+
+ if (itr->HasType(RT_ROWHEADER))
+ {
+ lcl_GetRepeatRangeString(&aRange, pDoc, true, aSymbol);
+ aLbRepeatRow.SetEntryData(
+ aLbRepeatRow.InsertEntry(aName),
+ new String(aSymbol) );
+ }
+
+ if (itr->HasType(RT_COLHEADER))
+ {
+ lcl_GetRepeatRangeString(&aRange, pDoc, false, aSymbol);
+ aLbRepeatCol.SetEntryData(
+ aLbRepeatCol.InsertEntry(aName),
+ new String(aSymbol));
}
}
}
-#endif
}
diff --git a/sc/source/ui/unoobj/nameuno.cxx b/sc/source/ui/unoobj/nameuno.cxx
index a9dfe58..429d89e 100644
--- a/sc/source/ui/unoobj/nameuno.cxx
+++ b/sc/source/ui/unoobj/nameuno.cxx
@@ -90,24 +90,13 @@ SC_SIMPLE_SERVICE_INFO( ScLabelRangeObj, "ScLabelRangeObj", "com.sun.star.sheet.
SC_SIMPLE_SERVICE_INFO( ScLabelRangesObj, "ScLabelRangesObj", "com.sun.star.sheet.LabelRanges" )
SC_SIMPLE_SERVICE_INFO( ScNamedRangesObj, "ScNamedRangesObj", "com.sun.star.sheet.NamedRanges" )
-//------------------------------------------------------------------------
-
-sal_Bool lcl_UserVisibleName( const ScRangeData* pData )
-{
- //! als Methode an ScRangeData
-
- return ( pData && !pData->HasType( RT_DATABASE ) && !pData->HasType( RT_SHARED ) );
-}
-
-bool lcl_UserVisibleName( const ScRangeData& rData )
+bool lcl_UserVisibleName(const ScRangeData& rData)
{
//! als Methode an ScRangeData
return !rData.HasType(RT_DATABASE) && !rData.HasType(RT_SHARED);
}
-//------------------------------------------------------------------------
-
ScNamedRangeObj::ScNamedRangeObj(ScNamedRangesObj* pParent, ScDocShell* pDocSh, const String& rNm) :
mpParent(pParent),
pDocShell( pDocSh ),
@@ -636,7 +625,7 @@ void SAL_CALL ScNamedRangesObj::removeByName( const rtl::OUString& aName )
if (pNames)
{
const ScRangeData* pData = pNames->findByName(aName);
- if (pData && lcl_UserVisibleName(pData))
+ if (pData && lcl_UserVisibleName(*pData))
{
ScRangeName* pNewRanges = new ScRangeName(*pNames);
pNewRanges->erase(*pData);
@@ -683,13 +672,9 @@ sal_Int32 SAL_CALL ScNamedRangesObj::getCount() throw(uno::RuntimeException)
ScRangeName* pNames = pDocShell->GetDocument()->GetRangeName();
if (pNames)
{
-#if NEW_RANGE_NAME
-#else
- sal_uInt16 nCount = pNames->GetCount();
- for (sal_uInt16 i=0; i<nCount; i++)
- if (lcl_UserVisibleName( (*pNames)[i] )) // interne weglassen
- ++nRet;
-#endif
+ ScRangeName::const_iterator itr = pNames->begin(), itrEnd = pNames->end();
+ if (lcl_UserVisibleName(*itr))
+ ++nRet;
}
}
return nRet;
@@ -778,17 +763,13 @@ uno::Sequence<rtl::OUString> SAL_CALL ScNamedRangesObj::getElementNames()
long nVisCount = getCount(); // Namen mit lcl_UserVisibleName
uno::Sequence<rtl::OUString> aSeq(nVisCount);
rtl::OUString* pAry = aSeq.getArray();
-#if NEW_RANGE_NAME
-#else
- sal_uInt16 nCount = pNames->GetCount();
sal_uInt16 nVisPos = 0;
- for (sal_uInt16 i=0; i<nCount; i++)
+ ScRangeName::const_iterator itr = pNames->begin(), itrEnd = pNames->end();
+ for (; itr != itrEnd; ++itr)
{
- ScRangeData* pData = (*pNames)[i];
- if ( lcl_UserVisibleName(pData) )
- pAry[nVisPos++] = pData->GetName();
+ if (lcl_UserVisibleName(*itr))
+ pAry[nVisPos++] = itr->GetName();
}
-#endif
return aSeq;
}
}
@@ -805,7 +786,7 @@ sal_Bool SAL_CALL ScNamedRangesObj::hasByName( const rtl::OUString& aName )
if (pNames)
{
const ScRangeData* pData = pNames->findByName(aName);
- if (pData && lcl_UserVisibleName(pData))
+ if (pData && lcl_UserVisibleName(*pData))
return sal_True;
}
}
commit 45b851e763affdd1031f7a04f131757ea0e9b656
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Fri Mar 4 22:30:39 2011 -0500
More on adjusting for ScRangeName's new API.
diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx
index 110c848..4b7d657 100644
--- a/sc/inc/cell.hxx
+++ b/sc/inc/cell.hxx
@@ -459,7 +459,7 @@ public:
void UpdateRenameTab(SCTAB nTable, const String& rName);
BOOL TestTabRefAbs(SCTAB nTable);
void UpdateCompile( BOOL bForceIfNameInUse = FALSE );
- BOOL IsRangeNameInUse(USHORT nIndex) const;
+ BOOL IsRangeNameInUse(size_t nIndex) const;
void FindRangeNamesInUse(std::set<USHORT>& rIndexes) const;
void ReplaceRangeNamesInUse( const ScRangeData::IndexMap& rMap );
BOOL IsSubTotal() const { return bSubTotal; }
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 35d26b0..b6260f3 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -299,7 +299,7 @@ public:
void UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY );
void SetTabNo(SCTAB nNewTab);
- bool IsRangeNameInUse(SCROW nRow1, SCROW nRow2, sal_uInt16 nIndex) const;
+ bool IsRangeNameInUse(SCROW nRow1, SCROW nRow2, size_t nIndex) const;
void FindRangeNamesInUse(SCROW nRow1, SCROW nRow2, std::set<sal_uInt16>& rIndexes) const;
void ReplaceRangeNamesInUse( SCROW nRow1, SCROW nRow2, const ScRangeData::IndexMap& rMap );
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index b51f95a..6c61390 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1479,7 +1479,7 @@ public:
VirtualDevice* GetVirtualDevice_100th_mm();
SC_DLLPUBLIC OutputDevice* GetRefDevice(); // WYSIWYG: Printer, otherwise VirtualDevice...
- void EraseNonUsedSharedNames(USHORT nLevel);
+ void EraseNonUsedSharedNames();
BOOL GetNextSpellingCell(SCCOL& nCol, SCROW& nRow, SCTAB nTab,
BOOL bInSel, const ScMarkData& rMark) const;
diff --git a/sc/inc/rangenam.hxx b/sc/inc/rangenam.hxx
index 953184d..5a94f3d 100644
--- a/sc/inc/rangenam.hxx
+++ b/sc/inc/rangenam.hxx
@@ -192,17 +192,17 @@ private:
sal_uInt16 mnSharedMaxIndex;
public:
typedef DataType::const_iterator const_iterator;
+ typedef DataType::iterator iterator;
ScRangeName(ScDocument* pDoc = NULL);
ScRangeName(const ScRangeName& r);
- SC_DLLPUBLIC ScRangeData* operator[](sal_uInt16 nIndex);
- SC_DLLPUBLIC const ScRangeData* operator[](sal_uInt16 nIndex) const;
SC_DLLPUBLIC const ScRangeData* GetRangeAtBlock(const ScRange& rRange) const;
SC_DLLPUBLIC ScRangeData* findByName(const rtl::OUString& rName);
SC_DLLPUBLIC const ScRangeData* findByName(const rtl::OUString& rName) const;
ScRangeData* findByUpperName(const rtl::OUString& rName);
const ScRangeData* findByUpperName(const rtl::OUString& rName) const;
+ bool getIndex(const ScRangeData& rData, size_t& rIndex) const;
void UpdateReference(UpdateRefMode eUpdateRefMode, const ScRange& rRange,
SCsCOL nDx, SCsROW nDy, SCsTAB nDz);
void UpdateTabRef(SCTAB nTable, sal_uInt16 nFlag, SCTAB nNewTable = 0);
@@ -212,12 +212,16 @@ public:
sal_uInt16 GetSharedMaxIndex();
void SetSharedMaxIndex(sal_uInt16 nInd);
- const_iterator begin() const;
- const_iterator end() const;
+ SC_DLLPUBLIC const_iterator begin() const;
+ SC_DLLPUBLIC const_iterator end() const;
+ SC_DLLPUBLIC iterator begin();
+ SC_DLLPUBLIC iterator end();
SC_DLLPUBLIC size_t size() const;
bool empty() const;
+ SC_DLLPUBLIC bool insert(ScRangeData* p);
SC_DLLPUBLIC bool Insert(ScRangeData* p);
void erase(const ScRangeData& r);
+ void erase(const iterator& itr);
void clear();
bool operator== (const ScRangeName& r) const;
};
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 25d423a..ce0809b 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -479,7 +479,7 @@ public:
void UpdateCompile( BOOL bForceIfNameInUse = FALSE );
void SetTabNo(SCTAB nNewTab);
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list