summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2011-05-12 16:26:26 -0400
committerKohei Yoshida <kyoshida@novell.com>2011-05-13 22:54:10 -0400
commit08bd050a71e1cb1bbdd2b70de0c82b13446b9ce0 (patch)
treee5839466853cc1f417a4799d26145589e69d1c84
parent248f73a3115be1fccfc1a8c240ef2d24b356b778 (diff)
Fixed the fallout of the changes in ScDBCollection.
-rw-r--r--sc/inc/arealink.hxx16
-rw-r--r--sc/inc/compiler.hxx4
-rw-r--r--sc/inc/datauno.hxx2
-rw-r--r--sc/inc/dbcolect.hxx12
-rw-r--r--sc/inc/document.hxx11
-rw-r--r--sc/inc/rangeutl.hxx10
-rw-r--r--sc/source/core/data/documen3.cxx105
-rw-r--r--sc/source/core/data/document.cxx20
-rw-r--r--sc/source/core/data/table2.cxx2
-rw-r--r--sc/source/core/data/validat.cxx10
-rw-r--r--sc/source/core/tool/compiler.cxx39
-rw-r--r--sc/source/core/tool/dbcolect.cxx96
-rw-r--r--sc/source/core/tool/interpr4.cxx3
-rw-r--r--sc/source/core/tool/rangeutl.cxx36
-rw-r--r--sc/source/filter/starcalc/scflt.cxx2
-rw-r--r--sc/source/filter/xml/XMLExportDatabaseRanges.cxx155
-rw-r--r--sc/source/filter/xml/XMLExportDatabaseRanges.hxx2
-rw-r--r--sc/source/filter/xml/xmldrani.cxx206
-rw-r--r--sc/source/filter/xml/xmlexprt.cxx2
-rw-r--r--sc/source/ui/app/inputwin.cxx40
-rw-r--r--sc/source/ui/dbgui/consdlg.cxx8
-rw-r--r--sc/source/ui/dbgui/dbnamdlg.cxx101
-rw-r--r--sc/source/ui/dbgui/foptmgr.cxx6
-rw-r--r--sc/source/ui/docshell/arealink.cxx16
-rw-r--r--sc/source/ui/docshell/dbdocfun.cxx115
-rw-r--r--sc/source/ui/docshell/dbdocimp.cxx14
-rw-r--r--sc/source/ui/docshell/docsh4.cxx37
-rw-r--r--sc/source/ui/docshell/docsh5.cxx10
-rw-r--r--sc/source/ui/inc/consdlg.hxx2
-rw-r--r--sc/source/ui/inc/dbdocfun.hxx27
-rw-r--r--sc/source/ui/inc/dbfunc.hxx2
-rw-r--r--sc/source/ui/inc/dbnamdlg.hxx1
-rw-r--r--sc/source/ui/inc/inputwin.hxx2
-rw-r--r--sc/source/ui/inc/undodat.hxx8
-rw-r--r--sc/source/ui/navipi/content.cxx44
-rw-r--r--sc/source/ui/undo/undodat.cxx27
-rw-r--r--sc/source/ui/unoobj/datauno.cxx68
-rw-r--r--sc/source/ui/view/cellsh2.cxx25
-rw-r--r--sc/source/ui/view/dbfunc.cxx43
-rw-r--r--sc/source/ui/view/dbfunc3.cxx4
-rw-r--r--sc/source/ui/view/tabvwsh4.cxx16
41 files changed, 584 insertions, 765 deletions
diff --git a/sc/inc/arealink.hxx b/sc/inc/arealink.hxx
index 38efaaab8..80ecc7037 100644
--- a/sc/inc/arealink.hxx
+++ b/sc/inc/arealink.hxx
@@ -49,10 +49,10 @@ private:
String aOptions;
String aSourceArea;
ScRange aDestArea;
- sal_Bool bAddUndo;
- sal_Bool bInCreate;
- sal_Bool bDoInsert; // is set to FALSE for first update
- sal_Bool FindExtRange( ScRange& rRange, ScDocument* pSrcDoc, const String& rAreaName );
+ bool bAddUndo;
+ bool bInCreate;
+ bool bDoInsert; // is set to FALSE for first update
+ bool FindExtRange( ScRange& rRange, ScDocument* pSrcDoc, const String& rAreaName );
public:
TYPEINFO();
@@ -70,14 +70,14 @@ public:
sal_Bool Refresh( const String& rNewFile, const String& rNewFilter,
const String& rNewArea, sal_uLong nNewRefresh );
- void SetInCreate(sal_Bool bSet) { bInCreate = bSet; }
- void SetDoInsert(sal_Bool bSet) { bDoInsert = bSet; }
+ void SetInCreate(bool bSet) { bInCreate = bSet; }
+ void SetDoInsert(bool bSet) { bDoInsert = bSet; }
void SetDestArea(const ScRange& rNew);
void SetSource(const String& rDoc, const String& rFlt, const String& rOpt,
const String& rArea);
- sal_Bool IsEqual( const String& rFile, const String& rFilter, const String& rOpt,
- const String& rSource, const ScRange& rDest ) const;
+ bool IsEqual( const String& rFile, const String& rFilter, const String& rOpt,
+ const String& rSource, const ScRange& rDest ) const;
const String& GetFile() const { return aFileName; }
const String& GetFilter() const { return aFilterName; }
diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index 5fcc6dc8f..407b58076 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -346,7 +346,7 @@ private:
sal_Bool IsMacro( const String& );
sal_Bool IsNamedRange( const String& );
bool IsExternalNamedRange( const String& rSymbol );
- sal_Bool IsDBRange( const String& );
+ bool IsDBRange( const String& );
sal_Bool IsColRowName( const String& );
sal_Bool IsBoolean( const String& );
void AutoCorrectParsedSymbol();
@@ -448,7 +448,7 @@ public:
ScRangeData* UpdateDeleteTab(SCTAB nTable, sal_Bool bIsMove, sal_Bool bIsName, sal_Bool& bCompile);
ScRangeData* UpdateMoveTab(SCTAB nOldPos, SCTAB nNewPos, sal_Bool bIsName );
- sal_Bool HasModifiedRange();
+ bool HasModifiedRange();
/** If the character is allowed as first character in sheet names or
references, includes '$' and '?'. */
diff --git a/sc/inc/datauno.hxx b/sc/inc/datauno.hxx
index 7d43e4fef..53457bf4c 100644
--- a/sc/inc/datauno.hxx
+++ b/sc/inc/datauno.hxx
@@ -615,7 +615,7 @@ class ScDatabaseRangesObj : public cppu::WeakImplHelper4<
private:
ScDocShell* pDocShell;
- ScDatabaseRangeObj* GetObjectByIndex_Impl(sal_uInt16 nIndex);
+ ScDatabaseRangeObj* GetObjectByIndex_Impl(size_t nIndex);
ScDatabaseRangeObj* GetObjectByName_Impl(const ::rtl::OUString& aName);
public:
diff --git a/sc/inc/dbcolect.hxx b/sc/inc/dbcolect.hxx
index 5dfc8e068..71a1e49ea 100644
--- a/sc/inc/dbcolect.hxx
+++ b/sc/inc/dbcolect.hxx
@@ -54,7 +54,7 @@ private:
ScImportParam maImportParam;
// DBParam
- ::rtl::OUString aName;
+ const ::rtl::OUString aName;
SCTAB nTable;
SCCOL nStartCol;
SCROW nStartRow;
@@ -89,6 +89,7 @@ public:
SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
bool bByR = true, bool bHasH = true);
ScDBData(const ScDBData& rData);
+ ScDBData(const ::rtl::OUString& rName, const ScDBData& rData);
~ScDBData();
ScDBData& operator= (const ScDBData& rData);
@@ -97,7 +98,6 @@ public:
SCTAB GetTable() const;
const ::rtl::OUString& GetName() const { return aName; }
- void SetName(const ::rtl::OUString& rName) { aName = rName; }
void GetArea(SCTAB& rTab, SCCOL& rCol1, SCROW& rRow1, SCCOL& rCol2, SCROW& rRow2) const;
SC_DLLPUBLIC void GetArea(ScRange& rRange) const;
void SetArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
@@ -185,8 +185,10 @@ public:
ScDBData* findByName(const ::rtl::OUString& rName);
bool insert(ScDBData* p);
void erase(iterator itr);
+ void erase(const ScDBData& r);
bool empty() const;
size_t size() const;
+ bool operator== (const NamedDBs& r) const;
};
private:
@@ -201,9 +203,12 @@ public:
ScDBCollection(const ScDBCollection& r);
NamedDBs& getNamedDBs();
+ const NamedDBs& getNamedDBs() const;
const ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Bool bStartOnly) const;
+ ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Bool bStartOnly);
const ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const;
+ ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
const ScDBData* GetFilterDBAtTable(SCTAB nTab) const;
ScDBData* GetDBNearCursor(SCCOL nCol, SCROW nRow, SCTAB nTab );
@@ -227,6 +232,9 @@ public:
void insertAnonRange(ScDBData* pData);
const AnonDBsType& getAnonRanges() const;
+
+ bool empty() const;
+ bool operator== (const ScDBCollection& r) const;
};
#endif
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 4c7202b05..a7f445240 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -481,10 +481,11 @@ public:
SC_DLLPUBLIC ScDBCollection* GetDBCollection() const;
void SetDBCollection( ScDBCollection* pNewDBCollection,
sal_Bool bRemoveAutoFilter = false );
- ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab,
- sal_Bool bStartOnly = false) const;
- ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const;
- ScDBData* GetFilterDBAtTable(SCTAB nTab) const;
+ const ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly = false) const;
+ ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly = false);
+ const ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const;
+ ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
+ const ScDBData* GetFilterDBAtTable(SCTAB nTab) const;
SC_DLLPUBLIC const ScRangeData* GetRangeAtBlock( const ScRange& rBlock, String* pName=NULL ) const;
@@ -1475,7 +1476,7 @@ public:
TypedScStrCollection& rStrings, sal_Bool bLimit = false );
sal_Bool GetFormulaEntries( TypedScStrCollection& rStrings );
- sal_Bool HasAutoFilter( SCCOL nCol, SCROW nRow, SCTAB nTab );
+ bool HasAutoFilter( SCCOL nCol, SCROW nRow, SCTAB nTab );
SC_DLLPUBLIC sal_Bool HasColHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
SCTAB nTab );
diff --git a/sc/inc/rangeutl.hxx b/sc/inc/rangeutl.hxx
index 9db1155e8..41fd294bb 100644
--- a/sc/inc/rangeutl.hxx
+++ b/sc/inc/rangeutl.hxx
@@ -33,6 +33,7 @@
#include "address.hxx"
#include "rangenam.hxx"
+#include "dbcolect.hxx"
#include "scdllapi.h"
#include <com/sun/star/table/CellAddress.hpp>
@@ -305,18 +306,19 @@ class SC_DLLPUBLIC ScAreaNameIterator
{
private:
ScRangeName* pRangeName;
+ ScDBCollection* pDBCollection;
ScRangeName::const_iterator maRNPos;
ScRangeName::const_iterator maRNEnd;
- ScDBCollection* pDBCollection;
+ ScDBCollection::NamedDBs::const_iterator maDBPos;
+ ScDBCollection::NamedDBs::const_iterator maDBEnd;
bool bFirstPass;
- size_t nPos;
public:
ScAreaNameIterator( ScDocument* pDoc );
~ScAreaNameIterator() {}
- sal_Bool Next( String& rName, ScRange& rRange );
- sal_Bool WasDBName() const { return !bFirstPass; }
+ bool Next( String& rName, ScRange& rRange );
+ bool WasDBName() const { return !bFirstPass; }
};
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index 8da2976d1..bbd8f2cc6 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -173,56 +173,56 @@ ScDBCollection* ScDocument::GetDBCollection() const
void ScDocument::SetDBCollection( ScDBCollection* pNewDBCollection, sal_Bool bRemoveAutoFilter )
{
- if ( bRemoveAutoFilter )
+ if (pDBCollection && bRemoveAutoFilter)
{
// remove auto filter attribute if new db data don't contain auto filter flag
// start position is also compared, so bRemoveAutoFilter must not be set from ref-undo!
- if ( pDBCollection )
+ ScDBCollection::NamedDBs& rNamedDBs = pDBCollection->getNamedDBs();
+ ScDBCollection::NamedDBs::const_iterator itr = rNamedDBs.begin(), itrEnd = rNamedDBs.end();
+ for (; itr != itrEnd; ++itr)
{
- size_t nOldCount = pDBCollection->size();
- for (size_t nOld = 0; nOld < nOldCount; ++nOld)
- {
- ScDBData* pOldData = (*pDBCollection)[nOld];
- if ( pOldData->HasAutoFilter() )
- {
- ScRange aOldRange;
- pOldData->GetArea( aOldRange );
+ const ScDBData& rOldData = *itr;
+ if (!rOldData.HasAutoFilter())
+ continue;
- sal_Bool bFound = false;
- sal_uInt16 nNewIndex = 0;
- if ( pNewDBCollection &&
- pNewDBCollection->SearchName( pOldData->GetName(), nNewIndex ) )
- {
- ScDBData* pNewData = (*pNewDBCollection)[nNewIndex];
- if ( pNewData->HasAutoFilter() )
- {
- ScRange aNewRange;
- pNewData->GetArea( aNewRange );
- if ( aOldRange.aStart == aNewRange.aStart )
- bFound = sal_True;
- }
- }
+ ScRange aOldRange;
+ rOldData.GetArea(aOldRange);
- if ( !bFound )
+ bool bFound = false;
+ if (pNewDBCollection)
+ {
+ ScDBData* pNewData = pNewDBCollection->getNamedDBs().findByName(rOldData.GetName());
+ if (pNewData)
+ {
+ if (pNewData->HasAutoFilter())
{
- aOldRange.aEnd.SetRow( aOldRange.aStart.Row() );
- RemoveFlagsTab( aOldRange.aStart.Col(), aOldRange.aStart.Row(),
- aOldRange.aEnd.Col(), aOldRange.aEnd.Row(),
- aOldRange.aStart.Tab(), SC_MF_AUTO );
- RepaintRange( aOldRange );
+ ScRange aNewRange;
+ pNewData->GetArea(aNewRange);
+ if (aOldRange.aStart == aNewRange.aStart)
+ bFound = true;
}
}
}
+
+ if (!bFound)
+ {
+ aOldRange.aEnd.SetRow(aOldRange.aStart.Row());
+ RemoveFlagsTab( aOldRange.aStart.Col(), aOldRange.aStart.Row(),
+ aOldRange.aEnd.Col(), aOldRange.aEnd.Row(),
+ aOldRange.aStart.Tab(), SC_MF_AUTO );
+ RepaintRange( aOldRange );
+ }
}
}
if (pDBCollection)
delete pDBCollection;
+
pDBCollection = pNewDBCollection;
}
-ScDBData* ScDocument::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Bool bStartOnly) const
+const ScDBData* ScDocument::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly) const
{
if (pDBCollection)
return pDBCollection->GetDBAtCursor(nCol, nRow, nTab, bStartOnly);
@@ -230,7 +230,23 @@ ScDBData* ScDocument::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Bool
return NULL;
}
-ScDBData* ScDocument::GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const
+ScDBData* ScDocument::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly)
+{
+ if (pDBCollection)
+ return pDBCollection->GetDBAtCursor(nCol, nRow, nTab, bStartOnly);
+ else
+ return NULL;
+}
+
+const ScDBData* ScDocument::GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const
+{
+ if (pDBCollection)
+ return pDBCollection->GetDBAtArea(nTab, nCol1, nRow1, nCol2, nRow2);
+ else
+ return NULL;
+}
+
+ScDBData* ScDocument::GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
{
if (pDBCollection)
return pDBCollection->GetDBAtArea(nTab, nCol1, nRow1, nCol2, nRow2);
@@ -238,12 +254,12 @@ ScDBData* ScDocument::GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nC
return NULL;
}
-ScDBData* ScDocument::GetFilterDBAtTable(SCTAB nTab) const
+const ScDBData* ScDocument::GetFilterDBAtTable(SCTAB nTab) const
{
if (pDBCollection)
return pDBCollection->GetFilterDBAtTable(nTab);
else
- return NULL;
+ return NULL;
}
ScDPCollection* ScDocument::GetDPCollection()
@@ -1298,10 +1314,10 @@ sal_Bool ScDocument::CreateQueryParam(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCR
return false;
}
-sal_Bool ScDocument::HasAutoFilter( SCCOL nCurCol, SCROW nCurRow, SCTAB nCurTab )
+bool ScDocument::HasAutoFilter( SCCOL nCurCol, SCROW nCurRow, SCTAB nCurTab )
{
- ScDBData* pDBData = GetDBAtCursor( nCurCol, nCurRow, nCurTab );
- sal_Bool bHasAutoFilter = ( pDBData != NULL );
+ const ScDBData* pDBData = GetDBAtCursor( nCurCol, nCurRow, nCurTab );
+ bool bHasAutoFilter = (pDBData != NULL);
if ( pDBData )
{
@@ -1474,16 +1490,13 @@ sal_Bool ScDocument::GetFormulaEntries( TypedScStrCollection& rStrings )
if ( pDBCollection )
{
- sal_uInt16 nDBCount = pDBCollection->GetCount();
- for ( sal_uInt16 i=0; i<nDBCount; i++ )
+ const ScDBCollection::NamedDBs& rDBs = pDBCollection->getNamedDBs();
+ ScDBCollection::NamedDBs::const_iterator itr = rDBs.begin(), itrEnd = rDBs.end();
+ for (; itr != itrEnd; ++itr)
{
- ScDBData* pData = (*pDBCollection)[i];
- if (pData)
- {
- TypedStrData* pNew = new TypedStrData( pData->GetName(), 0.0, SC_STRTYPE_DBNAMES );
- if ( !rStrings.Insert(pNew) )
- delete pNew;
- }
+ TypedStrData* pNew = new TypedStrData(itr->GetName(), 0.0, SC_STRTYPE_DBNAMES);
+ if ( !rStrings.Insert(pNew) )
+ delete pNew;
}
}
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 3e86a758c..a40ee81c5 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -4823,9 +4823,6 @@ sal_Bool ScDocument::ExtendOverlapped( ScRange& rRange )
sal_Bool ScDocument::RefreshAutoFilter( SCCOL nStartCol, SCROW nStartRow,
SCCOL nEndCol, SCROW nEndRow, SCTAB nTab )
{
- sal_uInt16 nCount = pDBCollection->GetCount();
- sal_uInt16 i;
- ScDBData* pData;
SCTAB nDBTab;
SCCOL nDBStartCol;
SCROW nDBStartRow;
@@ -4834,22 +4831,25 @@ sal_Bool ScDocument::RefreshAutoFilter( SCCOL nStartCol, SCROW nStartRow,
// Autofilter loeschen
- sal_Bool bChange = RemoveFlagsTab( nStartCol,nStartRow, nEndCol,nEndRow, nTab, SC_MF_AUTO );
+ bool bChange = RemoveFlagsTab( nStartCol,nStartRow, nEndCol,nEndRow, nTab, SC_MF_AUTO );
// Autofilter setzen
- for (i=0; i<nCount; i++)
+ const ScDBData* pData = NULL;
+ ScDBCollection::NamedDBs& rDBs = pDBCollection->getNamedDBs();
+ ScDBCollection::NamedDBs::const_iterator itr = rDBs.begin(), itrEnd = rDBs.end();
+ for (; itr != itrEnd; ++itr)
{
- pData = (*pDBCollection)[i];
- if (pData->HasAutoFilter())
+ pData = &(*itr);
+ if (itr->HasAutoFilter())
{
- pData->GetArea( nDBTab, nDBStartCol,nDBStartRow, nDBEndCol,nDBEndRow );
+ itr->GetArea( nDBTab, nDBStartCol,nDBStartRow, nDBEndCol,nDBEndRow );
if ( nDBTab==nTab && nDBStartRow<=nEndRow && nDBEndRow>=nStartRow &&
nDBStartCol<=nEndCol && nDBEndCol>=nStartCol )
{
if (ApplyFlagsTab( nDBStartCol,nDBStartRow, nDBEndCol,nDBStartRow,
nDBTab, SC_MF_AUTO ))
- bChange = sal_True;
+ bChange = true;
}
}
}
@@ -4867,7 +4867,7 @@ sal_Bool ScDocument::RefreshAutoFilter( SCCOL nStartCol, SCROW nStartRow,
{
if (ApplyFlagsTab( nDBStartCol,nDBStartRow, nDBEndCol,nDBStartRow,
nDBTab, SC_MF_AUTO ))
- bChange = sal_True;
+ bChange = true;
}
}
}
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 53b14615b..3e8c2c5ba 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -2638,7 +2638,7 @@ void ScTable::ShowRows(SCROW nRow1, SCROW nRow2, bool bShow)
bool ScTable::IsDataFiltered() const
{
bool bAnyQuery = false;
- ScDBData* pDBData = pDocument->GetFilterDBAtTable(nTab);
+ const ScDBData* pDBData = pDocument->GetFilterDBAtTable(nTab);
if ( pDBData )
{
ScQueryParam aParam;
diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx
index fd6903978..99dbd2a6b 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -681,7 +681,7 @@ bool ScValidationData::GetSelectionFromFormula( TypedScStrCollection* pStrings,
SCSIZE nCol, nRow, nCols, nRows, n = 0;
pValues->GetDimensions( nCols, nRows );
- sal_Bool bRef = false;
+ bool bRef = false;
ScRange aRange;
ScTokenArray* pArr = (ScTokenArray*) &rTokArr;
@@ -691,10 +691,10 @@ bool ScValidationData::GetSelectionFromFormula( TypedScStrCollection* pStrings,
{
if (t->GetOpCode() == ocDBArea)
{
- if( ScDBData* pDBData = pDocument->GetDBCollection()->FindIndex( t->GetIndex() ) )
+ if (const ScDBData* pDBData = pDocument->GetDBCollection()->getNamedDBs().findByIndex(t->GetIndex()))
{
pDBData->GetArea(aRange);
- bRef = sal_True;
+ bRef = true;
}
}
else if (t->GetOpCode() == ocName)
@@ -702,7 +702,7 @@ bool ScValidationData::GetSelectionFromFormula( TypedScStrCollection* pStrings,
ScRangeData* pName = pDocument->GetRangeName()->findByIndex( t->GetIndex() );
if (pName && pName->IsReference(aRange))
{
- bRef = sal_True;
+ bRef = true;
}
}
else if (t->GetType() != svIndex)
@@ -710,7 +710,7 @@ bool ScValidationData::GetSelectionFromFormula( TypedScStrCollection* pStrings,
t->CalcAbsIfRel(rPos);
if (pArr->IsValidReference(aRange))
{
- bRef = sal_True;
+ bRef = true;
}
}
}
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 7ebcb9f57..2b8bab711 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -2949,21 +2949,18 @@ bool ScCompiler::IsExternalNamedRange( const String& rSymbol )
return true;
}
-sal_Bool ScCompiler::IsDBRange( const String& rName )
+bool ScCompiler::IsDBRange( const String& rName )
{
- sal_uInt16 n;
- ScDBCollection* pDBColl = pDoc->GetDBCollection();
- if (pDBColl->SearchName( rName, n ) )
- {
- ScDBData* pData = (*pDBColl)[n];
- ScRawToken aToken;
- aToken.SetName(true, pData->GetIndex()); // DB range is always global.
- aToken.eOp = ocDBArea;
- pRawToken = aToken.Clone();
- return sal_True;
- }
- else
+ ScDBCollection::NamedDBs& rDBs = pDoc->GetDBCollection()->getNamedDBs();
+ const ScDBData* p = rDBs.findByName(rName);
+ if (!p)
return false;
+
+ ScRawToken aToken;
+ aToken.SetName(true, p->GetIndex()); // DB range is always global.
+ aToken.eOp = ocDBArea;
+ pRawToken = aToken.Clone();
+ return true;
}
sal_Bool ScCompiler::IsColRowName( const String& rName )
@@ -4026,7 +4023,7 @@ sal_Bool ScCompiler::HandleExternalReference(const FormulaToken& _aToken)
//-----------------------------------------------------------------------------
-sal_Bool ScCompiler::HasModifiedRange()
+bool ScCompiler::HasModifiedRange()
{
pArr->Reset();
for ( FormulaToken* t = pArr->Next(); t; t = pArr->Next() )
@@ -4034,17 +4031,15 @@ sal_Bool ScCompiler::HasModifiedRange()
OpCode eOpCode = t->GetOpCode();
if ( eOpCode == ocName )
{
- ScRangeData* pRangeData = pDoc->GetRangeName()->findByIndex(t->GetIndex());
-
+ ScRangeData* pRangeData = pDoc->GetRangeName()->findByIndex(t->GetIndex());
if (pRangeData && pRangeData->IsModified())
- return sal_True;
+ return true;
}
else if ( eOpCode == ocDBArea )
{
- ScDBData* pDBData = pDoc->GetDBCollection()->FindIndex(t->GetIndex());
-
+ ScDBData* pDBData = pDoc->GetDBCollection()->getNamedDBs().findByIndex(t->GetIndex());
if (pDBData && pDBData->IsModified())
- return sal_True;
+ return true;
}
}
return false;
@@ -5102,7 +5097,7 @@ void ScCompiler::CreateStringFromIndex(rtl::OUStringBuffer& rBuffer,FormulaToken
break;
case ocDBArea:
{
- ScDBData* pDBData = pDoc->GetDBCollection()->FindIndex(_pTokenP->GetIndex());
+ ScDBData* pDBData = pDoc->GetDBCollection()->getNamedDBs().findByIndex(_pTokenP->GetIndex());
if (pDBData)
aBuffer.append(pDBData->GetName());
}
@@ -5395,7 +5390,7 @@ sal_Bool ScCompiler::HandleSingleRef()
// -----------------------------------------------------------------------------
sal_Bool ScCompiler::HandleDbData()
{
- ScDBData* pDBData = pDoc->GetDBCollection()->FindIndex( pToken->GetIndex() );
+ ScDBData* pDBData = pDoc->GetDBCollection()->getNamedDBs().findByIndex(pToken->GetIndex());
if ( !pDBData )
SetError(errNoName);
else if ( !bCompileForFAP )
diff --git a/sc/source/core/tool/dbcolect.cxx b/sc/source/core/tool/dbcolect.cxx
index d8b55f893..64e055c5e 100644
--- a/sc/source/core/tool/dbcolect.cxx
+++ b/sc/source/core/tool/dbcolect.cxx
@@ -115,14 +115,41 @@ ScDBData::ScDBData( const ScDBData& rData ) :
{
}
+ScDBData::ScDBData( const ::rtl::OUString& rName, const ScDBData& rData ) :
+ ScRefreshTimer ( rData ),
+ maSortParam (rData.maSortParam),
+ maQueryParam (rData.maQueryParam),
+ maSubTotal (rData.maSubTotal),
+ maImportParam (rData.maImportParam),
+ aName (rName),
+ nTable (rData.nTable),
+ nStartCol (rData.nStartCol),
+ nStartRow (rData.nStartRow),
+ nEndCol (rData.nEndCol),
+ nEndRow (rData.nEndRow),
+ bByRow (rData.bByRow),
+ bHasHeader (rData.bHasHeader),
+ bDoSize (rData.bDoSize),
+ bKeepFmt (rData.bKeepFmt),
+ bStripData (rData.bStripData),
+ bIsAdvanced (rData.bIsAdvanced),
+ aAdvSource (rData.aAdvSource),
+ bDBSelection (rData.bDBSelection),
+ nIndex (rData.nIndex),
+ bAutoFilter (rData.bAutoFilter),
+ bModified (rData.bModified)
+{
+}
+
ScDBData& ScDBData::operator= (const ScDBData& rData)
{
+ // Don't modify the name. The name is not mutable as it is used as a key
+ // in the container to keep the db ranges sorted by the name.
ScRefreshTimer::operator=( rData );
maSortParam = rData.maSortParam;
maQueryParam = rData.maQueryParam;
maSubTotal = rData.maSubTotal;
maImportParam = rData.maImportParam;
- aName = rData.aName;
nTable = rData.nTable;
nStartCol = rData.nStartCol;
nStartRow = rData.nStartRow;
@@ -697,6 +724,11 @@ void ScDBCollection::NamedDBs::erase(iterator itr)
maDBs.erase(itr);
}
+void ScDBCollection::NamedDBs::erase(const ScDBData& r)
+{
+ maDBs.erase(r);
+}
+
bool ScDBCollection::NamedDBs::empty() const
{
return maDBs.empty();
@@ -707,6 +739,11 @@ size_t ScDBCollection::NamedDBs::size() const
return maDBs.size();
}
+bool ScDBCollection::NamedDBs::operator== (const NamedDBs& r) const
+{
+ return maDBs == r.maDBs;
+}
+
ScDBCollection::ScDBCollection(ScDocument* pDocument) :
pDoc(pDocument), nEntryIndex(SC_START_INDEX_DB_COLL), maNamedDBs(*this, *pDocument) {}
@@ -718,6 +755,11 @@ ScDBCollection::NamedDBs& ScDBCollection::getNamedDBs()
return maNamedDBs;
}
+const ScDBCollection::NamedDBs& ScDBCollection::getNamedDBs() const
+{
+ return maNamedDBs;
+}
+
const ScDBData* ScDBCollection::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Bool bStartOnly) const
{
// First, search the global named db ranges.
@@ -740,6 +782,28 @@ const ScDBData* ScDBCollection::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab
return NULL;
}
+ScDBData* ScDBCollection::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Bool bStartOnly)
+{
+ // First, search the global named db ranges.
+ NamedDBs::DBsType::iterator itr = find_if(
+ maNamedDBs.begin(), maNamedDBs.end(), FindByCursor(nCol, nRow, nTab, bStartOnly));
+ if (itr != maNamedDBs.end())
+ return &(*itr);
+
+ // Check for the sheet-local anonymous db range.
+ ScDBData* pNoNameData = pDoc->GetAnonymousDBData(nTab);
+ if (pNoNameData)
+ if (pNoNameData->IsDBAtCursor(nCol,nRow,nTab,bStartOnly))
+ return pNoNameData;
+
+ // Check the global anonymous db ranges.
+ const ScDBData* pData = findAnonAtCursor(nCol, nRow, nTab, bStartOnly);
+ if (pData)
+ return const_cast<ScDBData*>(pData);
+
+ return NULL;
+}
+
const ScDBData* ScDBCollection::GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const
{
// First, search the global named db ranges.
@@ -756,6 +820,25 @@ const ScDBData* ScDBCollection::GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1
return pNoNameData;
// Lastly, check the global anonymous db ranges.
+ return findAnonByRange(aRange);
+}
+
+ScDBData* ScDBCollection::GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
+{
+ // First, search the global named db ranges.
+ ScRange aRange(nCol1, nRow1, nTab, nCol2, nRow2, nTab);
+ NamedDBs::DBsType::iterator itr = find_if(
+ maNamedDBs.begin(), maNamedDBs.end(), FindByRange(aRange));
+ if (itr != maNamedDBs.end())
+ return &(*itr);
+
+ // Check for the sheet-local anonymous db range.
+ ScDBData* pNoNameData = pDoc->GetAnonymousDBData(nTab);
+ if (pNoNameData)
+ if (pNoNameData->IsDBAtArea(nTab, nCol1, nRow1, nCol2, nRow2))
+ return pNoNameData;
+
+ // Lastly, check the global anonymous db ranges.
const ScDBData* pData = findAnonByRange(aRange);
if (pData)
return const_cast<ScDBData*>(pData);
@@ -895,4 +978,15 @@ const ScDBCollection::AnonDBsType& ScDBCollection::getAnonRanges() const
return maAnonDBs;
}
+bool ScDBCollection::empty() const
+{
+ return maNamedDBs.empty() && maAnonDBs.empty();
+}
+
+bool ScDBCollection::operator== (const ScDBCollection& r) const
+{
+ return maNamedDBs == r.maNamedDBs && maAnonDBs == r.maAnonDBs &&
+ nEntryIndex == r.nEntryIndex && pDoc == r.pDoc && aRefreshHandler == r.aRefreshHandler;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index bfe5b6b63..9abbcb1b8 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -3493,8 +3493,7 @@ void ScInterpreter::ScTableOp()
void ScInterpreter::ScDBArea()
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScDBArea" );
- ScDBData* pDBData = pDok->GetDBCollection()->FindIndex( pCur->GetIndex());
+ ScDBData* pDBData = pDok->GetDBCollection()->getNamedDBs().findByIndex(pCur->GetIndex());
if (pDBData)
{
ScComplexRefData aRefData;
diff --git a/sc/source/core/tool/rangeutl.cxx b/sc/source/core/tool/rangeutl.cxx
index dc3e93f2f..ff8866b87 100644
--- a/sc/source/core/tool/rangeutl.cxx
+++ b/sc/source/core/tool/rangeutl.cxx
@@ -325,16 +325,12 @@ sal_Bool ScRangeUtil::MakeRangeFromName (
}
else if( eScope==RUTL_DBASE )
{
- ScDBCollection& rDbNames = *(pDoc->GetDBCollection());
- sal_uInt16 nAt = 0;
-
- if ( rDbNames.SearchName( rName, nAt ) )
+ ScDBCollection::NamedDBs& rDbNames = pDoc->GetDBCollection()->getNamedDBs();
+ ScDBData* pData = rDbNames.findByName(rName);
+ if (pData)
{
- ScDBData* pData = rDbNames[nAt];
-
- pData->GetArea( nTab, nColStart, nRowStart,
- nColEnd, nRowEnd );
- bResult = sal_True;
+ pData->GetArea(nTab, nColStart, nRowStart, nColEnd, nRowEnd);
+ bResult = true;
}
}
else
@@ -1042,8 +1038,7 @@ sal_Bool ScArea::operator==( const ScArea& r ) const
ScAreaNameIterator::ScAreaNameIterator( ScDocument* pDoc ) :
pRangeName(pDoc->GetRangeName()),
pDBCollection(pDoc->GetDBCollection()),
- bFirstPass(true),
- nPos(0)
+ bFirstPass(true)
{
if (pRangeName)
{
@@ -1052,7 +1047,7 @@ ScAreaNameIterator::ScAreaNameIterator( ScDocument* pDoc ) :
}
}
-sal_Bool ScAreaNameIterator::Next( String& rName, ScRange& rRange )
+bool ScAreaNameIterator::Next( String& rName, ScRange& rRange )
{
for (;;)
{
@@ -1072,18 +1067,23 @@ sal_Bool ScAreaNameIterator::Next( String& rName, ScRange& rRange )
else
{
bFirstPass = false;
- nPos = 0;
+ if (pDBCollection)
+ {
+ const ScDBCollection::NamedDBs& rDBs = pDBCollection->getNamedDBs();
+ maDBPos = rDBs.begin();
+ maDBEnd = rDBs.end();
+ }
}
}
if ( !bFirstPass ) // dann DB-Bereiche
{
- if ( pDBCollection && nPos < pDBCollection->GetCount() )
+ if (pDBCollection && maDBPos != maDBEnd)
{
- ScDBData* pData = (*pDBCollection)[nPos++];
- pData->GetArea( rRange );
- rName = pData->GetName();
- return sal_True; // gefunden
+ const ScDBData& rData = *maDBPos;
+ rData.GetArea(rRange);
+ rName = rData.GetName();
+ return true; // gefunden
}
else
return false; // gibt nichts mehr
diff --git a/sc/source/filter/starcalc/scflt.cxx b/sc/source/filter/starcalc/scflt.cxx
index e01e3bd11..2abcbe2c1 100644
--- a/sc/source/filter/starcalc/scflt.cxx
+++ b/sc/source/filter/starcalc/scflt.cxx
@@ -1370,7 +1370,7 @@ void Sc10Import::LoadDataBaseCollection()
( SCROW ) pOldData->DataBaseRec.Block.y2,
sal_True,
( sal_Bool) pOldData->DataBaseRec.RowHeader );
- pDoc->GetDBCollection()->Insert( pNewData );
+ pDoc->GetDBCollection()->getNamedDBs().insert(pNewData);
}
}
diff --git a/sc/source/filter/xml/XMLExportDatabaseRanges.cxx b/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
index 2b5ae66ff..7d3608fcc 100644
--- a/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
+++ b/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
@@ -304,9 +304,7 @@ void ScXMLExportDatabaseRanges::WriteFilterDescriptor(const uno::Reference <shee
}
}
ScDBCollection* pDBCollection = pDoc->GetDBCollection();
- sal_uInt16 nIndex;
- pDBCollection->SearchName(sDatabaseRangeName, nIndex);
- ScDBData* pDBData = (*pDBCollection)[nIndex];
+ ScDBData* pDBData = pDBCollection->getNamedDBs().findByName(sDatabaseRangeName);
ScRange aAdvSource;
if (pDBData->GetAdvancedQuerySource(aAdvSource))
{
@@ -531,9 +529,7 @@ void ScXMLExportDatabaseRanges::WriteSubTotalDescriptor(const com::sun::star::un
rExport.CheckAttrList();
{
ScDBCollection* pDBCollection = pDoc->GetDBCollection();
- sal_uInt16 nIndex;
- pDBCollection->SearchName(sDatabaseRangeName, nIndex);
- ScDBData* pDBData = (*pDBCollection)[nIndex];
+ ScDBData* pDBData = pDBCollection->getNamedDBs().findByName(sDatabaseRangeName);
ScSubTotalParam aSubTotalParam;
pDBData->GetSubTotalParam(aSubTotalParam);
if (aSubTotalParam.bDoSort)
@@ -1088,136 +1084,55 @@ private:
}
-void ScXMLExportDatabaseRanges::WriteDatabaseRanges(const com::sun::star::uno::Reference <com::sun::star::sheet::XSpreadsheetDocument>& xSpreadDoc)
+void ScXMLExportDatabaseRanges::WriteDatabaseRanges()
{
typedef ::std::map<SCTAB, const ScDBData*> SheetLocalDBs;
pDoc = rExport.GetDocument();
- if (pDoc)
+ if (!pDoc)
+ return;
+
+ // Get sheet-local anonymous ranges.
+ SCTAB nTabCount = pDoc->GetTableCount();
+ SheetLocalDBs aSheetDBs;
+ for (SCTAB i = 0; i < nTabCount; ++i)
{
- // Get sheet-local anonymous ranges.
- SCTAB nTabCount = pDoc->GetTableCount();
- SheetLocalDBs aSheetDBs;
- for (SCTAB i = 0; i < nTabCount; ++i)
- {
- const ScDBData* p = pDoc->GetAnonymousDBData(i);
- if (p)
- aSheetDBs.insert(SheetLocalDBs::value_type(i, p));
- }
+ const ScDBData* p = pDoc->GetAnonymousDBData(i);
+ if (p)
+ aSheetDBs.insert(SheetLocalDBs::value_type(i, p));
+ }
- bool bHasRanges = !aSheetDBs.empty();
+ bool bHasRanges = !aSheetDBs.empty();
- // See if we have global ranges.
- ScDBCollection* pDBCollection = pDoc->GetDBCollection();
- if (pDBCollection)
- if (pDBCollection->GetCount() > 0 || !pDBCollection->getAnonRanges().empty())
- bHasRanges = true;
+ // See if we have global ranges.
+ ScDBCollection* pDBCollection = pDoc->GetDBCollection();
+ if (pDBCollection)
+ {
+ if (!pDBCollection->getNamedDBs().empty() || !pDBCollection->getAnonRanges().empty())
+ bHasRanges = true;
+ }
- if (!bHasRanges)
- // No ranges to export. Bail out.
- return;
+ if (!bHasRanges)
+ // No ranges to export. Bail out.
+ return;
- SvXMLElementExport aElemDRs(rExport, XML_NAMESPACE_TABLE, XML_DATABASE_RANGES, sal_True, sal_True);
- uno::Reference <beans::XPropertySet> xPropertySet (xSpreadDoc, uno::UNO_QUERY);
- if (xPropertySet.is())
- {
- uno::Reference <sheet::XDatabaseRanges> xDatabaseRanges(xPropertySet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DATABASERNG))), uno::UNO_QUERY);
- rExport.CheckAttrList();
- if (xDatabaseRanges.is())
- {
- uno::Sequence <rtl::OUString> aRanges(xDatabaseRanges->getElementNames());
- sal_Int32 nDatabaseRangesCount = aRanges.getLength();
- if (nDatabaseRangesCount > 0)
- {
- for (sal_Int32 i = 0; i < nDatabaseRangesCount; ++i)
- {
- rtl::OUString sDatabaseRangeName(aRanges[i]);
- uno::Reference <sheet::XDatabaseRange> xDatabaseRange(xDatabaseRanges->getByName(sDatabaseRangeName), uno::UNO_QUERY);
- if (xDatabaseRange.is())
- {
- rtl::OUString sOUUnbenannt (ScGlobal::GetRscString(STR_DB_NONAME));
- if (sOUUnbenannt != sDatabaseRangeName)
- rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NAME, sDatabaseRangeName);
- table::CellRangeAddress aRangeAddress(xDatabaseRange->getDataArea());
- rtl::OUString sOUAddress;
- ScRangeStringConverter::GetStringFromRange( sOUAddress, aRangeAddress, pDoc, ::formula::FormulaGrammar::CONV_OOO );
- rExport.AddAttribute (XML_NAMESPACE_TABLE, XML_TARGET_RANGE_ADDRESS, sOUAddress);
- sal_uInt16 nIndex;
- pDBCollection->SearchName(sDatabaseRangeName, nIndex);
- ScDBData* pDBData = (*pDBCollection)[nIndex];
- if (pDBData->HasImportSelection())
- rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_IS_SELECTION, XML_TRUE);
- if (pDBData->HasAutoFilter())
- rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY_FILTER_BUTTONS, XML_TRUE);
- uno::Reference <beans::XPropertySet> xPropertySetDatabaseRange (xDatabaseRange, uno::UNO_QUERY);
- if (xPropertySetDatabaseRange.is())
- {
- if (::cppu::any2bool(xPropertySetDatabaseRange->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_KEEPFORM)))))
- rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ON_UPDATE_KEEP_STYLES, XML_TRUE);
- if (::cppu::any2bool(xPropertySetDatabaseRange->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_MOVCELLS)))))
- rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ON_UPDATE_KEEP_SIZE, XML_FALSE);
- if (::cppu::any2bool(xPropertySetDatabaseRange->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_STRIPDAT)))))
- rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_HAS_PERSISTENT_DATA, XML_FALSE);
- }
-
- uno::Reference< sheet::XSheetFilterDescriptor2 > xSheetFilterDescriptor(
- xDatabaseRange->getFilterDescriptor(), uno::UNO_QUERY );
- uno::Sequence <beans::PropertyValue> aSortProperties(xDatabaseRange->getSortDescriptor());
- if (xSheetFilterDescriptor.is())
- {
- uno::Reference <beans::XPropertySet> xFilterProperties (xSheetFilterDescriptor, uno::UNO_QUERY);
- if (xFilterProperties.is())
- {
- if (!::cppu::any2bool(xFilterProperties->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_CONTHDR)))))
- rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CONTAINS_HEADER, XML_FALSE);
-
- sal_Bool bSortColumns(sal_True);
- sal_Bool bFound(false);
- sal_Int32 nProperty(0);
- while (!bFound && (nProperty < aSortProperties.getLength()))
- {
- if (aSortProperties[nProperty].Name.compareToAscii(SC_UNONAME_ISSORTCOLUMNS) == 0)
- {
- bSortColumns = ::cppu::any2bool(aSortProperties[nProperty].Value);
- bFound = sal_True;
- }
- else
- ++nProperty;
- }
-
- if (bSortColumns)
- rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ORIENTATION, XML_COLUMN);
- }
- }
- sal_Int32 nRefresh( pDBData->GetRefreshDelay() );
- if( nRefresh )
- {
- rtl::OUStringBuffer sBuffer;
- SvXMLUnitConverter::convertTime( sBuffer, (double)nRefresh / 86400 );
- rExport.AddAttribute( XML_NAMESPACE_TABLE, XML_REFRESH_DELAY, sBuffer.makeStringAndClear() );
- }
- SvXMLElementExport aElemDR(rExport, XML_NAMESPACE_TABLE, XML_DATABASE_RANGE, sal_True, sal_True);
- rExport.CheckAttrList();
- WriteImportDescriptor(xDatabaseRange->getImportDescriptor());
- if (xSheetFilterDescriptor.is())
- WriteFilterDescriptor(xSheetFilterDescriptor, sDatabaseRangeName);
- WriteSortDescriptor(aSortProperties);
- WriteSubTotalDescriptor(xDatabaseRange->getSubTotalDescriptor(), sDatabaseRangeName);
- }
- }
- }
- }
- }
+ SvXMLElementExport aElemDRs(rExport, XML_NAMESPACE_TABLE, XML_DATABASE_RANGES, sal_True, sal_True);
- WriteDatabaseRange func(rExport, pDoc);
+ WriteDatabaseRange func(rExport, pDoc);
- // Write sheet-local ranges.
- ::std::for_each(aSheetDBs.begin(), aSheetDBs.end(), func);
+ if (pDBCollection)
+ {
+ // Write global named ranges.
+ const ScDBCollection::NamedDBs& rNamedDBs = pDBCollection->getNamedDBs();
+ ::std::for_each(rNamedDBs.begin(), rNamedDBs.end(), func);
// Add global anonymous DB ranges.
const ScDBCollection::AnonDBsType& rAnonDBs = pDBCollection->getAnonRanges();
::std::for_each(rAnonDBs.begin(), rAnonDBs.end(), func);
}
+
+ // Write sheet-local ranges.
+ ::std::for_each(aSheetDBs.begin(), aSheetDBs.end(), func);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/xml/XMLExportDatabaseRanges.hxx b/sc/source/filter/xml/XMLExportDatabaseRanges.hxx
index e4d7813e8..bb726ddc3 100644
--- a/sc/source/filter/xml/XMLExportDatabaseRanges.hxx
+++ b/sc/source/filter/xml/XMLExportDatabaseRanges.hxx
@@ -56,7 +56,7 @@ public:
ScXMLExportDatabaseRanges(ScXMLExport& rExport);
~ScXMLExportDatabaseRanges();
ScMyEmptyDatabaseRangesContainer GetEmptyDatabaseRanges();
- void WriteDatabaseRanges(const com::sun::star::uno::Reference <com::sun::star::sheet::XSpreadsheetDocument>& xSpreadDoc);
+ void WriteDatabaseRanges();
};
#endif
diff --git a/sc/source/filter/xml/xmldrani.cxx b/sc/source/filter/xml/xmldrani.cxx
index 7e91218ee..741032c14 100644
--- a/sc/source/filter/xml/xmldrani.cxx
+++ b/sc/source/filter/xml/xmldrani.cxx
@@ -453,6 +453,23 @@ ScDBData* ScXMLDatabaseRangeContext::ConvertToDBData(const OUString& rName)
return pData.release();
}
+namespace {
+
+void setAutoFilterFlags(ScDocument& rDoc, const ScDBData& rData)
+{
+ if (!rData.HasAutoFilter())
+ return;
+
+ // Set autofilter flags so that the buttons get displayed.
+ ScRange aRange;
+ rData.GetArea(aRange);
+ rDoc.ApplyFlagsTab(
+ aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aStart.Row(),
+ aRange.aStart.Tab(), SC_MF_AUTO);
+}
+
+}
+
void ScXMLDatabaseRangeContext::EndElement()
{
ScDocument* pDoc = GetScImport().GetDocument();
@@ -469,17 +486,7 @@ void ScXMLDatabaseRangeContext::EndElement()
// Infer sheet index from the name.
OUString aStrNum = sDatabaseRangeName.copy(aName.getLength());
SCTAB nTab = static_cast<SCTAB>(aStrNum.toInt32());
-
- if (pData->HasAutoFilter())
- {
- // Set autofilter flags so that the buttons get displayed.
- ScRange aRange;
- pData->GetArea(aRange);
- pDoc->ApplyFlagsTab(
- aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aStart.Row(),
- aRange.aStart.Tab(), SC_MF_AUTO);
- }
-
+ setAutoFilterFlags(*pDoc, *pData);
pDoc->SetAnonymousDBData(nTab, pData.release());
}
return;
@@ -491,182 +498,19 @@ void ScXMLDatabaseRangeContext::EndElement()
if (pData.get())
{
- if (pData->HasAutoFilter())
- {
- // Set autofilter flags so that the buttons get displayed.
- ScRange aRange;
- pData->GetArea(aRange);
- pDoc->ApplyFlagsTab(
- aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aStart.Row(),
- aRange.aStart.Tab(), SC_MF_AUTO);
- }
-
+ setAutoFilterFlags(*pDoc, *pData);
pDoc->GetDBCollection()->insertAnonRange(pData.release());
}
return;
}
-
- if (GetScImport().GetModel().is())
+ else if (meRangeType == GlobalNamed)
{
- uno::Reference <beans::XPropertySet> xPropertySet( GetScImport().GetModel(), uno::UNO_QUERY );
- if (xPropertySet.is())
+ ::std::auto_ptr<ScDBData> pData(ConvertToDBData(sDatabaseRangeName));
+
+ if (pData.get())
{
- uno::Reference <sheet::XDatabaseRanges> xDatabaseRanges(xPropertySet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DATABASERNG))), uno::UNO_QUERY);
- if (xDatabaseRanges.is())
- {
- table::CellRangeAddress aCellRangeAddress;
- sal_Int32 nOffset(0);
- if (ScRangeStringConverter::GetRangeFromString( aCellRangeAddress, sRangeAddress, pDoc, ::formula::FormulaGrammar::CONV_OOO, nOffset ))
- {
- sal_Bool bInsert(sal_True);
- try
- {
- xDatabaseRanges->addNewByName(sDatabaseRangeName, aCellRangeAddress);
- }
- catch ( uno::RuntimeException& rRuntimeException )
- {
- bInsert = false;
- rtl::OUString sErrorMessage(RTL_CONSTASCII_USTRINGPARAM("DatabaseRange "));
- sErrorMessage += sDatabaseRangeName;
- sErrorMessage += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" could not be created with the range "));
- sErrorMessage += sRangeAddress;
- uno::Sequence<rtl::OUString> aSeq(1);
- aSeq[0] = sErrorMessage;
- uno::Reference<xml::sax::XLocator> xLocator;
- GetScImport().SetError(XMLERROR_API | XMLERROR_FLAG_ERROR, aSeq, rRuntimeException.Message, xLocator);
- }
- if (bInsert)
- {
- uno::Reference <sheet::XDatabaseRange> xDatabaseRange(xDatabaseRanges->getByName(sDatabaseRangeName), uno::UNO_QUERY);
- if (xDatabaseRange.is())
- {
- uno::Reference <beans::XPropertySet> xDatabaseRangePropertySet (xDatabaseRange, uno::UNO_QUERY);
- if (xDatabaseRangePropertySet.is())
- {
- xDatabaseRangePropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_KEEPFORM)), uno::makeAny(bKeepFormats));
- xDatabaseRangePropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_MOVCELLS)), uno::makeAny(bMoveCells));
- xDatabaseRangePropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_STRIPDAT)), uno::makeAny(bStripData));
- }
- uno::Sequence <beans::PropertyValue> aImportDescriptor(xDatabaseRange->getImportDescriptor());
- sal_Int32 nImportProperties = aImportDescriptor.getLength();
- for (sal_Int16 i = 0; i < nImportProperties; ++i)
- {
- if (aImportDescriptor[i].Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_DBNAME)))
- {
- if (sDatabaseName.getLength())
- {
- aImportDescriptor[i].Value <<= sDatabaseName;
- }
- else
- {
- aImportDescriptor[i].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_CONRES));
- aImportDescriptor[i].Value <<= sConnectionRessource;
- }
- }
- else if (aImportDescriptor[i].Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_SRCOBJ)))
- aImportDescriptor[i].Value <<= sSourceObject;
- else if (aImportDescriptor[i].Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_SRCTYPE)))
- aImportDescriptor[i].Value <<= nSourceType;
- else if (aImportDescriptor[i].Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ISNATIVE)))
- aImportDescriptor[i].Value <<= bNative;
- }
- ScDBCollection* pDBCollection = pDoc->GetDBCollection();
- sal_uInt16 nIndex;
- pDBCollection->SearchName(sDatabaseRangeName, nIndex);
- ScDBData* pDBData = (*pDBCollection)[nIndex];
- pDBData->SetImportSelection(bIsSelection);
- pDBData->SetAutoFilter(bAutoFilter);
- if (bAutoFilter)
- pDoc->ApplyFlagsTab( static_cast<SCCOL>(aCellRangeAddress.StartColumn), static_cast<SCROW>(aCellRangeAddress.StartRow),
- static_cast<SCCOL>(aCellRangeAddress.EndColumn), static_cast<SCROW>(aCellRangeAddress.StartRow),
- aCellRangeAddress.Sheet, SC_MF_AUTO );
- ScImportParam aImportParam;
- ScImportDescriptor::FillImportParam(aImportParam, aImportDescriptor);
- pDBData->SetImportParam(aImportParam);
- if (bContainsSort)
- {
- sal_uInt32 nOldSize(aSortSequence.getLength());
- aSortSequence.realloc(nOldSize + 1);
- beans::PropertyValue aProperty;
- aProperty.Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ORIENT));
- aProperty.Value <<= eOrientation;
- aSortSequence[nOldSize] = aProperty;
- ScSortParam aSortParam;
- ScSortDescriptor::FillSortParam(aSortParam, aSortSequence);
-
- //#98317#; until now the Fields are relative to the left top edge of the range, but the
- // core wants to have the absolute position (column/row)
- SCCOLROW nFieldStart = aSortParam.bByRow ? static_cast<SCCOLROW>(aCellRangeAddress.StartColumn) : static_cast<SCCOLROW>(aCellRangeAddress.StartRow);
- for (sal_uInt16 i = 0; i < MAXSORT; ++i)
- {
- if (aSortParam.bDoSort[i])
- aSortParam.nField[i] += nFieldStart;
- }
-
- pDBData->SetSortParam(aSortParam);
- }
- uno::Reference< sheet::XSheetFilterDescriptor2 > xSheetFilterDescriptor(
- xDatabaseRange->getFilterDescriptor(), uno::UNO_QUERY );
- if (xSheetFilterDescriptor.is())
- {
- uno::Reference <beans::XPropertySet> xFilterPropertySet (xSheetFilterDescriptor, uno::UNO_QUERY);
- if (xFilterPropertySet.is())
- {
- sal_Bool bOrientation(table::TableOrientation_COLUMNS == eOrientation);
- xFilterPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ORIENT)), uno::makeAny(bOrientation));
- xFilterPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_CONTHDR)), uno::makeAny(bContainsHeader));
- xFilterPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_COPYOUT)), uno::makeAny(bFilterCopyOutputData));
- xFilterPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ISCASE)), uno::makeAny(bFilterIsCaseSensitive));
- xFilterPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_SKIPDUP)), uno::makeAny(bFilterSkipDuplicates));
- xFilterPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_USEREGEX)), uno::makeAny(bFilterUseRegularExpressions));
- xFilterPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_OUTPOS)), uno::makeAny(aFilterOutputPosition));
- }
- xSheetFilterDescriptor->setFilterFields2(aFilterFields);
- if (bFilterConditionSourceRange)
- {
- ScRange aAdvSource;
- ScUnoConversion::FillScRange( aAdvSource, aFilterConditionSourceRangeAddress );
- pDBData->SetAdvancedQuerySource(&aAdvSource);
- }
- }
- if (bContainsSubTotal)
- {
- uno::Reference <sheet::XSubTotalDescriptor> xSubTotalDescriptor(xDatabaseRange->getSubTotalDescriptor());
- if (xSubTotalDescriptor.is())
- {
- uno::Reference <beans::XPropertySet> xSubTotalPropertySet (xSubTotalDescriptor, uno::UNO_QUERY);
- if( xSubTotalPropertySet.is())
- {
- xSubTotalPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_BINDFMT)), uno::makeAny(bSubTotalsBindFormatsToContent));
- xSubTotalPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ENABLEUSERSORTLIST)), uno::makeAny(bSubTotalsEnabledUserList));
- xSubTotalPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_USERSORTLISTINDEX)), uno::makeAny(nSubTotalsUserListIndex));
- xSubTotalPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_INSBRK)), uno::makeAny(bSubTotalsInsertPageBreaks));
- xSubTotalPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ISCASE)), uno::makeAny(bSubTotalsIsCaseSensitive));
- }
- ScSubTotalParam aSubTotalParam;
- aSubTotalParam.bDoSort = bSubTotalsSortGroups;
- aSubTotalParam.bAscending = bSubTotalsAscending;
- aSubTotalParam.bUserDef = bSubTotalsEnabledUserList;
- aSubTotalParam.nUserIndex = nSubTotalsUserListIndex;
- pDBData->SetSubTotalParam(aSubTotalParam);
- std::vector < ScSubTotalRule >::iterator aItr(aSubTotalRules.begin());
- while (!aSubTotalRules.empty())
- {
- xSubTotalDescriptor->addNew(aItr->aSubTotalColumns, aItr->nSubTotalRuleGroupFieldNumber);
- aItr = aSubTotalRules.erase(aItr);
- }
- }
- }
- if ( pDBData->HasImportParam() && !pDBData->HasImportSelection() )
- {
- pDBData->SetRefreshDelay( nRefresh );
- pDBData->SetRefreshHandler( pDBCollection->GetRefreshHandler() );
- pDBData->SetRefreshControl( pDoc->GetRefreshTimerControlAddress() );
- }
- }
- }
- }
- }
+ setAutoFilterFlags(*pDoc, *pData);
+ pDoc->GetDBCollection()->getNamedDBs().insert(pData.release());
}
}
}
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 4a5eecb25..c9597964a 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -1729,7 +1729,7 @@ void ScXMLExport::_ExportContent()
}
WriteExternalRefCaches();
WriteNamedExpressions(xSpreadDoc);
- aExportDatabaseRanges.WriteDatabaseRanges(xSpreadDoc);
+ aExportDatabaseRanges.WriteDatabaseRanges();
ScXMLExportDataPilot aExportDataPilot(*this);
aExportDataPilot.WriteDataPilots(xSpreadDoc);
WriteConsolidation();
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index a293c222c..de047920d 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -262,9 +262,9 @@ void ScInputWindow::SetInputHandler( ScInputHandler* pNew )
}
}
-sal_Bool ScInputWindow::UseSubTotal(ScRangeList* pRangeList) const
+bool ScInputWindow::UseSubTotal(ScRangeList* pRangeList) const
{
- sal_Bool bSubTotal(false);
+ bool bSubTotal = false;
ScTabViewShell* pViewSh = PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
if ( pViewSh )
{
@@ -285,7 +285,7 @@ sal_Bool ScInputWindow::UseSubTotal(ScRangeList* pRangeList) const
while (!bSubTotal && nRow <= nRowEnd)
{
if (pDoc->RowFiltered(nRow, nTab))
- bSubTotal = sal_True;
+ bSubTotal = true;
else
++nRow;
}
@@ -295,29 +295,27 @@ sal_Bool ScInputWindow::UseSubTotal(ScRangeList* pRangeList) const
++nRangeIndex;
}
- ScDBCollection* pDBCollection = pDoc->GetDBCollection();
- sal_uInt16 nDBCount (pDBCollection->GetCount());
- sal_uInt16 nDBIndex (0);
- while (!bSubTotal && nDBIndex < nDBCount)
+ const ScDBCollection::NamedDBs& rDBs = pDoc->GetDBCollection()->getNamedDBs();
+ ScDBCollection::NamedDBs::const_iterator itr = rDBs.begin(), itrEnd = rDBs.end();
+ for (; !bSubTotal && itr != itrEnd; ++itr)
{
- ScDBData* pDB = (*pDBCollection)[nDBIndex];
- if (pDB && pDB->HasAutoFilter())
+ const ScDBData& rDB = *itr;
+ if (!rDB.HasAutoFilter())
+ continue;
+
+ nRangeIndex = 0;
+ while (!bSubTotal && nRangeIndex < nRangeCount)
{
- nRangeIndex = 0;
- while (!bSubTotal && nRangeIndex < nRangeCount)
+ const ScRange* pRange = (*pRangeList)[nRangeIndex];
+ if( pRange )
{
- const ScRange* pRange = (*pRangeList)[nRangeIndex];
- if( pRange )
- {
- ScRange aDBArea;
- pDB->GetArea(aDBArea);
- if (aDBArea.Intersects(*pRange))
- bSubTotal = sal_True;
- }
- ++nRangeIndex;
+ ScRange aDBArea;
+ rDB.GetArea(aDBArea);
+ if (aDBArea.Intersects(*pRange))
+ bSubTotal = true;
}
+ ++nRangeIndex;
}
- ++nDBIndex;
}
}
return bSubTotal;
diff --git a/sc/source/ui/dbgui/consdlg.cxx b/sc/source/ui/dbgui/consdlg.cxx
index f07ed1247..571caede4 100644
--- a/sc/source/ui/dbgui/consdlg.cxx
+++ b/sc/source/ui/dbgui/consdlg.cxx
@@ -222,8 +222,8 @@ void ScConsolidateDlg::Init()
ScRangeName* pRangeNames = pDoc->GetRangeName();
ScDBCollection* pDbNames = pDoc->GetDBCollection();
- const sal_uInt16 nRangeCount = pRangeNames ? pRangeNames->size() : 0;
- const sal_uInt16 nDbCount = pDbNames ? pDbNames ->GetCount() : 0;
+ size_t nRangeCount = pRangeNames ? pRangeNames->size() : 0;
+ size_t nDbCount = pDbNames ? pDbNames->getNamedDBs().size() : 0;
nAreaDataCount = nRangeCount+nDbCount;
pAreaData = NULL;
@@ -269,7 +269,7 @@ void ScConsolidateDlg::FillAreaLists()
{
String aString;
- for ( sal_uInt16 i=0;
+ for ( size_t i=0;
(i<nAreaDataCount) && (pAreaData[i].aStrName.Len()>0);
i++ )
{
@@ -558,7 +558,7 @@ IMPL_LINK( ScConsolidateDlg, SelectHdl, ListBox*, pLb )
&& (nAreaDataCount > 0)
&& (pAreaData != NULL) )
{
- if ( nSelPos <= nAreaDataCount )
+ if ( static_cast<size_t>(nSelPos) <= nAreaDataCount )
{
String aString( pAreaData[nSelPos-1].aStrArea );
diff --git a/sc/source/ui/dbgui/dbnamdlg.cxx b/sc/source/ui/dbgui/dbnamdlg.cxx
index 695b83490..09fd53633 100644
--- a/sc/source/ui/dbgui/dbnamdlg.cxx
+++ b/sc/source/ui/dbgui/dbnamdlg.cxx
@@ -66,7 +66,6 @@ class DBSaveData;
static DBSaveData* pSaveObj = NULL;
#define ERRORBOX(s) ErrorBox(this,WinBits(WB_OK|WB_DEF_OK),s).Execute()
-#define QUERYBOX(m) QueryBox(this,WinBits(WB_YES_NO|WB_DEF_YES),m).Execute()
//============================================================================
// class DBSaveData
@@ -166,7 +165,6 @@ ScDbNameDlg::ScDbNameDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
aStrAdd ( ScResId( STR_ADD ) ),
aStrModify ( ScResId( STR_MODIFY ) ),
- aStrNoName ( RTL_CONSTASCII_USTRINGPARAM(STR_DB_LOCAL_NONAME)),
aStrInvalid ( ScResId( STR_DB_INVALID ) ),
//
pViewData ( ptrViewData ),
@@ -272,11 +270,8 @@ void ScDbNameDlg::Init()
&& (rStart.Col() == nCol1) && (rStart.Row() == nRow1)
&& (rEnd.Col() == nCol2) && (rEnd.Row() == nRow2 ) )
{
- theDbName = pDBData->GetName();
- if ( !theDbName.equals(aStrNoName) )
- aEdName.SetText( theDbName );
- else
- aEdName.SetText( EMPTY_STRING );
+ aEdName.SetText(pDBData->GetName());
+
aBtnHeader.Check( pDBData->HasHeader() );
aBtnDoSize.Check( pDBData->IsDoSize() );
aBtnKeepFmt.Check( pDBData->IsKeepFmt() );
@@ -369,28 +364,20 @@ void ScDbNameDlg::SetActive()
void ScDbNameDlg::UpdateNames()
{
- sal_uInt16 nNameCount = aLocalDbCol.GetCount();
+ typedef ScDBCollection::NamedDBs DBsType;
+
+ const DBsType& rDBs = aLocalDbCol.getNamedDBs();
aEdName.SetUpdateMode( false );
//-----------------------------------------------------------
aEdName.Clear();
aEdAssign.SetText( EMPTY_STRING );
- if ( nNameCount > 0 )
+ if (!rDBs.empty())
{
- ScDBData* pDbData = NULL;
- ::rtl::OUString aString;
-
- for ( sal_uInt16 i=0; i<nNameCount; i++ )
- {
- pDbData = (ScDBData*)(aLocalDbCol.At( i ));
- if ( pDbData )
- {
- aString = pDbData->GetName();
- if (!aString.equals(aStrNoName))
- aEdName.InsertEntry( aString );
- }
- }
+ DBsType::const_iterator itr = rDBs.begin(), itrEnd = rDBs.end();
+ for (; itr != itrEnd; ++itr)
+ aEdName.InsertEntry(itr->GetName());
}
else
{
@@ -407,12 +394,8 @@ void ScDbNameDlg::UpdateNames()
void ScDbNameDlg::UpdateDBData( const String& rStrName )
{
- String theArea;
- sal_uInt16 nAt;
- ScDBData* pData;
- aLocalDbCol.SearchName( rStrName, nAt );
- pData = (ScDBData*)(aLocalDbCol.At( nAt ));
+ const ScDBData* pData = aLocalDbCol.getNamedDBs().findByName(rStrName);
if ( pData )
{
@@ -425,6 +408,7 @@ void ScDbNameDlg::UpdateDBData( const String& rStrName )
pData->GetArea( nTab, nColStart, nRowStart, nColEnd, nRowEnd );
theCurArea = ScRange( ScAddress( nColStart, nRowStart, nTab ),
ScAddress( nColEnd, nRowEnd, nTab ) );
+ ::rtl::OUString theArea;
theCurArea.Format( theArea, ABS_DREF3D, pDoc, aAddrDetails );
aEdAssign.SetText( theArea );
aBtnAdd.SetText( aStrModify );
@@ -505,10 +489,7 @@ IMPL_LINK( ScDbNameDlg, AddBtnHdl, void *, EMPTYARG )
ScAddress aStart = theCurArea.aStart;
ScAddress aEnd = theCurArea.aEnd;
- ScDBData* pOldEntry = NULL;
- sal_uInt16 nFoundAt = 0;
- if ( aLocalDbCol.SearchName( aNewName, nFoundAt ) )
- pOldEntry = aLocalDbCol[nFoundAt];
+ ScDBData* pOldEntry = aLocalDbCol.getNamedDBs().findByName(aNewName);
if (pOldEntry)
{
// Bereich veraendern
@@ -533,8 +514,7 @@ IMPL_LINK( ScDbNameDlg, AddBtnHdl, void *, EMPTYARG )
pNewEntry->SetKeepFmt( aBtnKeepFmt.IsChecked() );
pNewEntry->SetStripData( aBtnStripData.IsChecked() );
- if ( !aLocalDbCol.Insert( pNewEntry ) )
- delete pNewEntry;
+ aLocalDbCol.getNamedDBs().insert(pNewEntry);
}
UpdateNames();
@@ -572,36 +552,49 @@ IMPL_LINK( ScDbNameDlg, AddBtnHdl, void *, EMPTYARG )
return 0;
}
-//------------------------------------------------------------------------
+namespace {
+
+class FindByName : public ::std::unary_function<ScDBData, bool>
+{
+ const ::rtl::OUString& mrName;
+public:
+ FindByName(const ::rtl::OUString& rName) : mrName(rName) {}
+ bool operator() (const ScDBData& r) const
+ {
+ return r.GetName().equals(mrName);
+ }
+};
+
+}
IMPL_LINK( ScDbNameDlg, RemoveBtnHdl, void *, EMPTYARG )
{
- sal_uInt16 nRemoveAt = 0;
- const String aStrEntry = aEdName.GetText();
+ ::rtl::OUString aStrEntry = aEdName.GetText();
+ ScDBCollection::NamedDBs& rDBs = aLocalDbCol.getNamedDBs();
+ ScDBCollection::NamedDBs::iterator itr =
+ ::std::find_if(rDBs.begin(), rDBs.end(), FindByName(aStrEntry));
- if ( aLocalDbCol.SearchName( aStrEntry, nRemoveAt ) )
+ if (itr != rDBs.end())
{
String aStrDelMsg = ScGlobal::GetRscString( STR_QUERY_DELENTRY );
- String aMsg = aStrDelMsg.GetToken( 0, '#' );
- aMsg += aStrEntry;
- aMsg += aStrDelMsg.GetToken( 1, '#' );
+ ::rtl::OUStringBuffer aBuf;
+ aBuf.append(aStrDelMsg.GetToken(0, '#'));
+ aBuf.append(aStrEntry);
+ aBuf.append(aStrDelMsg.GetToken(1, '#'));
+ QueryBox aBox(this, WinBits(WB_YES_NO|WB_DEF_YES), aBuf.makeStringAndClear());
- if ( RET_YES == QUERYBOX(aMsg) )
+ if (RET_YES == aBox.Execute())
{
- ScDBData* pEntry = (ScDBData*)aLocalDbCol.At(nRemoveAt);
-
- if ( pEntry )
- {
- SCTAB nTab;
- SCCOL nColStart, nColEnd;
- SCROW nRowStart, nRowEnd;
- pEntry->GetArea( nTab, nColStart, nRowStart, nColEnd, nRowEnd );
- aRemoveList.Insert(
- new ScRange( ScAddress( nColStart, nRowStart, nTab ),
- ScAddress( nColEnd, nRowEnd, nTab ) ) );
- }
- aLocalDbCol.AtFree( nRemoveAt );
+ SCTAB nTab;
+ SCCOL nColStart, nColEnd;
+ SCROW nRowStart, nRowEnd;
+ itr->GetArea( nTab, nColStart, nRowStart, nColEnd, nRowEnd );
+ aRemoveList.Insert(
+ new ScRange( ScAddress( nColStart, nRowStart, nTab ),
+ ScAddress( nColEnd, nRowEnd, nTab ) ) );
+
+ rDBs.erase(itr);
UpdateNames();
diff --git a/sc/source/ui/dbgui/foptmgr.cxx b/sc/source/ui/dbgui/foptmgr.cxx
index a6bc3f6db..ce2abded2 100644
--- a/sc/source/ui/dbgui/foptmgr.cxx
+++ b/sc/source/ui/dbgui/foptmgr.cxx
@@ -184,9 +184,9 @@ void ScFilterOptionsMgr::Init()
{
ScAddress& rStart = theCurArea.aStart;
ScAddress& rEnd = theCurArea.aEnd;
- ScDBData* pDBData = pDBColl->GetDBAtArea( rStart.Tab(),
- rStart.Col(), rStart.Row(),
- rEnd.Col(), rEnd.Row() );
+ const ScDBData* pDBData = pDBColl->GetDBAtArea(
+ rStart.Tab(), rStart.Col(), rStart.Row(), rEnd.Col(), rEnd.Row());
+
if ( pDBData )
{
rBtnHeader.Check( pDBData->HasHeader() );
diff --git a/sc/source/ui/docshell/arealink.cxx b/sc/source/ui/docshell/arealink.cxx
index e2be816a9..5bada6b9a 100644
--- a/sc/source/ui/docshell/arealink.cxx
+++ b/sc/source/ui/docshell/arealink.cxx
@@ -86,9 +86,9 @@ ScAreaLink::ScAreaLink( SfxObjectShell* pShell, const String& rFile,
aOptions (rOpt),
aSourceArea (rArea),
aDestArea (rDest),
- bAddUndo (sal_True),
+ bAddUndo (true),
bInCreate (false),
- bDoInsert (sal_True)
+ bDoInsert (true)
{
DBG_ASSERT(pShell->ISA(ScDocShell), "ScAreaLink mit falscher ObjectShell");
pImpl->m_pDocSh = static_cast< ScDocShell* >( pShell );
@@ -195,7 +195,7 @@ void ScAreaLink::SetSource(const String& rDoc, const String& rFlt, const String&
SetName( aNewLinkName );
}
-sal_Bool ScAreaLink::IsEqual( const String& rFile, const String& rFilter, const String& rOpt,
+bool ScAreaLink::IsEqual( const String& rFile, const String& rFilter, const String& rOpt,
const String& rSource, const ScRange& rDest ) const
{
return aFileName == rFile && aFilterName == rFilter && aOptions == rOpt &&
@@ -203,11 +203,10 @@ sal_Bool ScAreaLink::IsEqual( const String& rFile, const String& rFilter, const
}
// find a range with name >rAreaName< in >pSrcDoc<, return it in >rRange<
-sal_Bool ScAreaLink::FindExtRange( ScRange& rRange, ScDocument* pSrcDoc, const String& rAreaName )
+bool ScAreaLink::FindExtRange( ScRange& rRange, ScDocument* pSrcDoc, const String& rAreaName )
{
bool bFound = false;
ScRangeName* pNames = pSrcDoc->GetRangeName();
- sal_uInt16 nPos;
if (pNames) // benannte Bereiche
{
const ScRangeData* p = pNames->findByName(rAreaName);
@@ -218,15 +217,18 @@ sal_Bool ScAreaLink::FindExtRange( ScRange& rRange, ScDocument* pSrcDoc, const S
{
ScDBCollection* pDBColl = pSrcDoc->GetDBCollection();
if (pDBColl)
- if (pDBColl->SearchName( rAreaName, nPos ))
+ {
+ const ScDBData* pDB = pDBColl->getNamedDBs().findByName(rAreaName);
+ if (pDB)
{
SCTAB nTab;
SCCOL nCol1, nCol2;
SCROW nRow1, nRow2;
- (*pDBColl)[nPos]->GetArea(nTab,nCol1,nRow1,nCol2,nRow2);
+ pDB->GetArea(nTab,nCol1,nRow1,nCol2,nRow2);
rRange = ScRange( nCol1,nRow1,nTab, nCol2,nRow2,nTab );
bFound = true;
}
+ }
}
if (!bFound) // direct reference (range or cell)
{
diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx
index be8b2fc06..741e22637 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -62,7 +62,7 @@
// -----------------------------------------------------------------
-sal_Bool ScDBDocFunc::AddDBRange( const String& rName, const ScRange& rRange, sal_Bool /* bApi */ )
+bool ScDBDocFunc::AddDBRange( const ::rtl::OUString& rName, const ScRange& rRange, sal_Bool /* bApi */ )
{
ScDocShellModificator aModificator( rDocShell );
@@ -82,8 +82,8 @@ sal_Bool ScDBDocFunc::AddDBRange( const String& rName, const ScRange& rRange, sa
// #i55926# While loading XML, formula cells only have a single string token,
// so CompileDBFormula would never find any name (index) tokens, and would
// unnecessarily loop through all cells.
- sal_Bool bCompile = !pDoc->IsImportingXML();
- sal_Bool bOk;
+ bool bCompile = !pDoc->IsImportingXML();
+ bool bOk;
if ( bCompile )
pDoc->CompileDBFormula( sal_True ); // CreateFormulaString
if (rtl::OUString(rName)==rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(STR_DB_LOCAL_NONAME)))
@@ -93,7 +93,7 @@ sal_Bool ScDBDocFunc::AddDBRange( const String& rName, const ScRange& rRange, sa
}
else
{
- bOk = pDocColl->Insert( pNew );
+ bOk = pDocColl->getNamedDBs().insert(pNew);
}
if ( bCompile )
pDoc->CompileDBFormula( false ); // CompileFormulaString
@@ -114,18 +114,19 @@ sal_Bool ScDBDocFunc::AddDBRange( const String& rName, const ScRange& rRange, sa
aModificator.SetDocumentModified();
SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) );
- return sal_True;
+ return true;
}
-sal_Bool ScDBDocFunc::DeleteDBRange( const String& rName, sal_Bool /* bApi */ )
+bool ScDBDocFunc::DeleteDBRange(const ::rtl::OUString& rName)
{
- sal_Bool bDone = false;
+ bool bDone = false;
ScDocument* pDoc = rDocShell.GetDocument();
ScDBCollection* pDocColl = pDoc->GetDBCollection();
- sal_Bool bUndo (pDoc->IsUndoEnabled());
+ bool bUndo = pDoc->IsUndoEnabled();
- sal_uInt16 nPos = 0;
- if (pDocColl->SearchName( rName, nPos ))
+ ScDBCollection::NamedDBs& rDBs = pDocColl->getNamedDBs();
+ const ScDBData* p = rDBs.findByName(rName);
+ if (p)
{
ScDocShellModificator aModificator( rDocShell );
@@ -133,8 +134,8 @@ sal_Bool ScDBDocFunc::DeleteDBRange( const String& rName, sal_Bool /* bApi */ )
if (bUndo)
pUndoColl = new ScDBCollection( *pDocColl );
- pDoc->CompileDBFormula( sal_True ); // CreateFormulaString
- pDocColl->AtFree( nPos );
+ pDoc->CompileDBFormula( true ); // CreateFormulaString
+ rDBs.erase(*p);
pDoc->CompileDBFormula( false ); // CompileFormulaString
if (bUndo)
@@ -146,40 +147,35 @@ sal_Bool ScDBDocFunc::DeleteDBRange( const String& rName, sal_Bool /* bApi */ )
aModificator.SetDocumentModified();
SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) );
- bDone = sal_True;
+ bDone = true;
}
return bDone;
}
-sal_Bool ScDBDocFunc::RenameDBRange( const String& rOld, const String& rNew, sal_Bool /* bApi */ )
+bool ScDBDocFunc::RenameDBRange( const String& rOld, const String& rNew )
{
- sal_Bool bDone = false;
+ bool bDone = false;
ScDocument* pDoc = rDocShell.GetDocument();
ScDBCollection* pDocColl = pDoc->GetDBCollection();
- sal_Bool bUndo (pDoc->IsUndoEnabled());
-
- sal_uInt16 nPos = 0;
- sal_uInt16 nDummy = 0;
- if ( pDocColl->SearchName( rOld, nPos ) &&
- !pDocColl->SearchName( rNew, nDummy ) )
+ bool bUndo = pDoc->IsUndoEnabled();
+ ScDBCollection::NamedDBs& rDBs = pDocColl->getNamedDBs();
+ const ScDBData* pOld = rDBs.findByName(rOld);
+ const ScDBData* pNew = rDBs.findByName(rNew);
+ if (pOld && !pNew)
{
ScDocShellModificator aModificator( rDocShell );
- ScDBData* pData = (*pDocColl)[nPos];
- ScDBData* pNewData = new ScDBData(*pData);
- pNewData->SetName(rNew);
+ ScDBData* pNewData = new ScDBData(rNew, *pOld);
ScDBCollection* pUndoColl = new ScDBCollection( *pDocColl );
- pDoc->CompileDBFormula( sal_True ); // CreateFormulaString
- pDocColl->AtFree( nPos );
- sal_Bool bInserted = pDocColl->Insert( pNewData );
+ pDoc->CompileDBFormula(true); // CreateFormulaString
+ rDBs.erase(*pOld);
+ bool bInserted = rDBs.insert(pNewData);
if (!bInserted) // Fehler -> alten Zustand wiederherstellen
- {
- delete pNewData;
- pDoc->SetDBCollection( pUndoColl ); // gehoert dann dem Dokument
- }
+ pDoc->SetDBCollection(pUndoColl); // gehoert dann dem Dokument
+ //
pDoc->CompileDBFormula( false ); // CompileFormulaString
if (bInserted) // Einfuegen hat geklappt
@@ -195,19 +191,19 @@ sal_Bool ScDBDocFunc::RenameDBRange( const String& rOld, const String& rNew, sal
aModificator.SetDocumentModified();
SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) );
- bDone = sal_True;
+ bDone = true;
}
}
return bDone;
}
-sal_Bool ScDBDocFunc::ModifyDBData( const ScDBData& rNewData, sal_Bool /* bApi */ )
+bool ScDBDocFunc::ModifyDBData( const ScDBData& rNewData )
{
- sal_Bool bDone = false;
+ bool bDone = false;
ScDocument* pDoc = rDocShell.GetDocument();
ScDBCollection* pDocColl = pDoc->GetDBCollection();
- sal_Bool bUndo (pDoc->IsUndoEnabled());
+ bool bUndo = pDoc->IsUndoEnabled();
ScDBData* pData = NULL;
if (rtl::OUString(rNewData.GetName())==rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(STR_DB_LOCAL_NONAME)))
@@ -218,18 +214,15 @@ sal_Bool ScDBDocFunc::ModifyDBData( const ScDBData& rNewData, sal_Bool /* bApi *
pData = pDoc->GetAnonymousDBData(nTab);
}
else
- {
- sal_uInt16 nPos = 0;
- if (pDocColl->SearchName( rNewData.GetName(), nPos ))
- pData = (*pDocColl)[nPos];
- }
+ pData = pDocColl->getNamedDBs().findByName(rNewData.GetName());
+
if (pData)
{
ScDocShellModificator aModificator( rDocShell );
ScRange aOldRange, aNewRange;
pData->GetArea(aOldRange);
rNewData.GetArea(aNewRange);
- sal_Bool bAreaChanged = ( aOldRange != aNewRange ); // dann muss neu compiliert werden
+ bool bAreaChanged = ( aOldRange != aNewRange ); // dann muss neu compiliert werden
ScDBCollection* pUndoColl = NULL;
if (bUndo)
@@ -247,7 +240,7 @@ sal_Bool ScDBDocFunc::ModifyDBData( const ScDBData& rNewData, sal_Bool /* bApi *
}
aModificator.SetDocumentModified();
- bDone = sal_True;
+ bDone = true;
}
return bDone;
@@ -255,11 +248,11 @@ sal_Bool ScDBDocFunc::ModifyDBData( const ScDBData& rNewData, sal_Bool /* bApi *
// -----------------------------------------------------------------
-sal_Bool ScDBDocFunc::RepeatDB( const String& rDBName, sal_Bool bRecord, sal_Bool bApi, bool bIsUnnamed, SCTAB aTab )
+bool ScDBDocFunc::RepeatDB( const ::rtl::OUString& rDBName, bool bRecord, bool bApi, bool bIsUnnamed, SCTAB aTab )
{
//! auch fuer ScDBFunc::RepeatDB benutzen!
- sal_Bool bDone = false;
+ bool bDone = false;
ScDocument* pDoc = rDocShell.GetDocument();
if (bRecord && !pDoc->IsUndoEnabled())
bRecord = false;
@@ -270,10 +263,9 @@ sal_Bool ScDBDocFunc::RepeatDB( const String& rDBName, sal_Bool bRecord, sal_Boo
}
else
{
- sal_uInt16 nIndex;
ScDBCollection* pColl = pDoc->GetDBCollection();
- if ( pColl && pColl->SearchName( rDBName, nIndex ) )
- pDBData = (*pColl)[nIndex];
+ if (pColl)
+ pDBData = pColl->getNamedDBs().findByName(rDBName);
}
if ( pDBData )
@@ -357,7 +349,7 @@ sal_Bool ScDBDocFunc::RepeatDB( const String& rDBName, sal_Bool bRecord, sal_Boo
if (!pDocRange->empty())
pUndoRange = new ScRangeName( *pDocRange );
ScDBCollection* pDocDB = pDoc->GetDBCollection();
- if (pDocDB->GetCount())
+ if (!pDocDB->empty())
pUndoDB = new ScDBCollection( *pDocDB );
}
@@ -563,7 +555,7 @@ sal_Bool ScDBDocFunc::Sort( SCTAB nTab, const ScSortParam& rSortParam,
ScDBCollection* pUndoDB = NULL;
ScDBCollection* pDocDB = pDoc->GetDBCollection();
- if (pDocDB->GetCount())
+ if (!pDocDB->empty())
pUndoDB = new ScDBCollection( *pDocDB );
pUndoAction = new ScUndoSort( &rDocShell, nTab, rSortParam, bRepeatQuery, pUndoDoc, pUndoDB, pR );
@@ -823,7 +815,7 @@ sal_Bool ScDBDocFunc::Query( SCTAB nTab, const ScQueryParam& rQueryParam,
}
ScDBCollection* pDocDB = pDoc->GetDBCollection();
- if (pDocDB->GetCount())
+ if (!pDocDB->empty())
pUndoDB = new ScDBCollection( *pDocDB );
pDoc->BeginDrawUndo();
@@ -1109,7 +1101,7 @@ sal_Bool ScDBDocFunc::DoSubTotals( SCTAB nTab, const ScSubTotalParam& rParam,
if (!pDocRange->empty())
pUndoRange = new ScRangeName( *pDocRange );
ScDBCollection* pDocDB = pDoc->GetDBCollection();
- if (pDocDB->GetCount())
+ if (!pDocDB->empty())
pUndoDB = new ScDBCollection( *pDocDB );
}
@@ -1461,7 +1453,7 @@ sal_Bool ScDBDocFunc::DataPilotUpdate( ScDPObject* pOldObj, const ScDPObject* pN
// Datenbank-Import...
void ScDBDocFunc::UpdateImport( const String& rTarget, const String& rDBName,
- const String& rTableName, const String& rStatement, sal_Bool bNative,
+ const String& rTableName, const String& rStatement, bool bNative,
sal_uInt8 nType, const ::com::sun::star::uno::Reference<
::com::sun::star::sdbc::XResultSet >& xResultSet,
const SbaSelectionList* pSelection )
@@ -1470,17 +1462,8 @@ void ScDBDocFunc::UpdateImport( const String& rTarget, const String& rDBName,
ScDocument* pDoc = rDocShell.GetDocument();
ScDBCollection& rDBColl = *pDoc->GetDBCollection();
- ScDBData* pData = NULL;
- ScImportParam aImportParam;
- bool bFound = false;
- sal_uInt16 nCount = rDBColl.GetCount();
- for (sal_uInt16 i=0; i<nCount && !bFound; i++)
- {
- pData = rDBColl[i];
- if (pData->GetName().equals(rTarget))
- bFound = true;
- }
- if (!bFound)
+ const ScDBData* pData = rDBColl.getNamedDBs().findByName(rTarget);
+ if (!pData)
{
InfoBox aInfoBox(rDocShell.GetActiveDialogParent(),
ScGlobal::GetRscString( STR_TARGETNOTFOUND ) );
@@ -1492,9 +1475,11 @@ void ScDBDocFunc::UpdateImport( const String& rTarget, const String& rDBName,
SCCOL nDummyCol;
SCROW nDummyRow;
pData->GetArea( nTab, nDummyCol,nDummyRow,nDummyCol,nDummyRow );
+
+ ScImportParam aImportParam;
pData->GetImportParam( aImportParam );
- sal_Bool bSql = ( rStatement.Len() != 0 );
+ bool bSql = (rStatement.Len() != 0);
aImportParam.aDBName = rDBName;
aImportParam.bSql = bSql;
@@ -1502,7 +1487,7 @@ void ScDBDocFunc::UpdateImport( const String& rTarget, const String& rDBName,
aImportParam.bNative = bNative;
aImportParam.nType = nType;
aImportParam.bImport = true;
- sal_Bool bContinue = DoImport( nTab, aImportParam, xResultSet, pSelection, sal_True );
+ bool bContinue = DoImport( nTab, aImportParam, xResultSet, pSelection, sal_True );
// DB-Operationen wiederholen
diff --git a/sc/source/ui/docshell/dbdocimp.cxx b/sc/source/ui/docshell/dbdocimp.cxx
index 1b376645c..64cf97d24 100644
--- a/sc/source/ui/docshell/dbdocimp.cxx
+++ b/sc/source/ui/docshell/dbdocimp.cxx
@@ -119,10 +119,10 @@ void ScDBDocFunc::ShowInBeamer( const ScImportParam& rParam, SfxViewFrame* pFram
// -----------------------------------------------------------------
-sal_Bool ScDBDocFunc::DoImportUno( const ScAddress& rPos,
+bool ScDBDocFunc::DoImportUno( const ScAddress& rPos,
const uno::Sequence<beans::PropertyValue>& aArgs )
{
- sal_Bool bDone = false;
+ bool bDone = false;
ScImportParam aImParam;
aImParam.nCol1 = aImParam.nCol2 = rPos.Col();
@@ -180,7 +180,7 @@ sal_Bool ScDBDocFunc::DoImportUno( const ScAddress& rPos,
aList.Insert( (void*)(sal_IntPtr)nEntry, LIST_APPEND );
}
- sal_Bool bAddrInsert = false; //!???
+ bool bAddrInsert = false; //!???
if ( bAddrInsert )
{
bDone = DoImport( rPos.Tab(), aImParam, xResSet, &aList, sal_True, bAddrInsert );
@@ -204,7 +204,7 @@ sal_Bool ScDBDocFunc::DoImportUno( const ScAddress& rPos,
UpdateImport( sTarget, aImParam.aDBName, aTableName, aStatement,
aImParam.bNative, aImParam.nType, xResSet, &aList );
- bDone = sal_True;
+ bDone = true;
}
return bDone;
@@ -212,9 +212,9 @@ sal_Bool ScDBDocFunc::DoImportUno( const ScAddress& rPos,
// -----------------------------------------------------------------
-sal_Bool ScDBDocFunc::DoImport( SCTAB nTab, const ScImportParam& rParam,
+bool ScDBDocFunc::DoImport( SCTAB nTab, const ScImportParam& rParam,
const uno::Reference< sdbc::XResultSet >& xResultSet,
- const SbaSelectionList* pSelection, sal_Bool bRecord, sal_Bool bAddrInsert )
+ const SbaSelectionList* pSelection, bool bRecord, bool bAddrInsert )
{
ScDocument* pDoc = rDocShell.GetDocument();
ScChangeTrack *pChangeTrack = NULL;
@@ -223,7 +223,7 @@ sal_Bool ScDBDocFunc::DoImport( SCTAB nTab, const ScImportParam& rParam,
if (bRecord && !pDoc->IsUndoEnabled())
bRecord = false;
- ScDBData* pDBData = 0;
+ ScDBData* pDBData = NULL;
if ( !bAddrInsert )
{
pDBData = pDoc->GetDBAtArea( nTab, rParam.nCol1, rParam.nRow1,
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index 0d8ea68f5..e4aa32c19 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -243,17 +243,16 @@ void ScDocShell::Execute( SfxRequest& rReq )
}
// bei Bedarf neuen Datenbankbereich anlegen
- sal_Bool bMakeArea = false;
+ bool bMakeArea = false;
if (bIsNewArea)
{
ScDBCollection* pDBColl = aDocument.GetDBCollection();
- sal_uInt16 nDummy;
- if ( !pDBColl || !pDBColl->SearchName( sTarget, nDummy ) )
+ if ( !pDBColl || !pDBColl->getNamedDBs().findByName(sTarget) )
{
ScAddress aPos;
if ( aPos.Parse( sTarget, &aDocument, aDocument.GetAddressConvention() ) & SCA_VALID )
{
- bMakeArea = sal_True;
+ bMakeArea = true;
if (bUndo)
{
String aStrImport = ScGlobal::GetRscString( STR_UNDO_IMPORTDATA );
@@ -268,7 +267,7 @@ void ScDocShell::Execute( SfxRequest& rReq )
}
// nachfragen, bevor alter DB-Bereich ueberschrieben wird
- sal_Bool bDo = sal_True;
+ bool bDo = true;
if (!bIsNewArea)
{
String aTemplate = ScGlobal::GetRscString( STR_IMPORT_REPLACE );
@@ -283,7 +282,7 @@ void ScDocShell::Execute( SfxRequest& rReq )
if (bDo)
{
ScDBDocFunc(*this).UpdateImport( sTarget, sDBName,
- sDBTable, sDBSql, sal_True, nType, xResultSet,
+ sDBTable, sDBSql, true, nType, xResultSet,
pSelectionList );
rReq.Done();
@@ -525,33 +524,35 @@ void ScDocShell::Execute( SfxRequest& rReq )
ScGlobal::GetRscString(STR_REIMPORT_AFTER_LOAD) );
if (aBox.Execute() == RET_YES)
{
- for (sal_uInt16 i=0; i<pDBColl->GetCount(); i++)
+ ScDBCollection::NamedDBs& rDBs = pDBColl->getNamedDBs();
+ ScDBCollection::NamedDBs::iterator itr = rDBs.begin(), itrEnd = rDBs.end();
+ for (; itr != itrEnd; ++itr)
{
- ScDBData* pDBData = (*pDBColl)[i];
- if ( pDBData->IsStripData() &&
- pDBData->HasImportParam() && !pDBData->HasImportSelection() )
+ ScDBData& rDBData = *itr;
+ if ( rDBData.IsStripData() &&
+ rDBData.HasImportParam() && !rDBData.HasImportSelection() )
{
- pDBData->GetArea(aRange);
+ rDBData.GetArea(aRange);
pViewSh->MarkRange(aRange);
// Import und interne Operationen wie SID_REFRESH_DBAREA
// (Abfrage auf Import hier nicht noetig)
ScImportParam aImportParam;
- pDBData->GetImportParam( aImportParam );
- sal_Bool bContinue = pViewSh->ImportData( aImportParam );
- pDBData->SetImportParam( aImportParam );
+ rDBData.GetImportParam( aImportParam );
+ bool bContinue = pViewSh->ImportData( aImportParam );
+ rDBData.SetImportParam( aImportParam );
// markieren (Groesse kann sich geaendert haben)
- pDBData->GetArea(aRange);
+ rDBData.GetArea(aRange);
pViewSh->MarkRange(aRange);
if ( bContinue ) // Fehler beim Import -> Abbruch
{
// interne Operationen, wenn welche gespeichert
- if ( pDBData->HasQueryParam() || pDBData->HasSortParam() ||
- pDBData->HasSubTotalParam() )
+ if ( rDBData.HasQueryParam() || rDBData.HasSortParam() ||
+ rDBData.HasSubTotalParam() )
pViewSh->RepeatDB();
// Pivottabellen die den Bereich als Quelldaten haben
@@ -560,7 +561,7 @@ void ScDocShell::Execute( SfxRequest& rReq )
}
}
}
- bDone = sal_True;
+ bDone = true;
}
}
}
diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx
index 3e7a4ee90..7d1c26103 100644
--- a/sc/source/ui/docshell/docsh5.cxx
+++ b/sc/source/ui/docshell/docsh5.cxx
@@ -285,18 +285,20 @@ ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGe
String aImport = ScGlobal::GetRscString( STR_DBNAME_IMPORT );
long nCount = 0;
- sal_uInt16 nDummy;
+ const ScDBData* pDummy = NULL;
+ ScDBCollection::NamedDBs& rDBs = pColl->getNamedDBs();
do
{
++nCount;
aNewName = aImport;
aNewName += String::CreateFromInt32( nCount );
+ pDummy = rDBs.findByName(aNewName);
}
- while (pColl->SearchName( aNewName, nDummy ));
+ while (pDummy);
pNoNameData = new ScDBData( aNewName, nTab,
nStartCol,nStartRow, nEndCol,nEndRow,
sal_True, bHasHeader );
- pColl->Insert( pNoNameData );
+ rDBs.insert(pNoNameData);
}
else
{
@@ -533,7 +535,7 @@ void ScDocShell::DoConsolidate( const ScConsolidateParam& rParam, sal_Bool bReco
ScDocShellModificator aModificator( *this );
ScRange aOldDest;
- ScDBData* pDestData = aDocument.GetDBAtCursor( rParam.nCol, rParam.nRow, rParam.nTab, sal_True );
+ ScDBData* pDestData = aDocument.GetDBAtCursor( rParam.nCol, rParam.nRow, rParam.nTab, true );
if (pDestData)
pDestData->GetArea(aOldDest);
diff --git a/sc/source/ui/inc/consdlg.hxx b/sc/source/ui/inc/consdlg.hxx
index 9386fe00f..a45a49974 100644
--- a/sc/source/ui/inc/consdlg.hxx
+++ b/sc/source/ui/inc/consdlg.hxx
@@ -100,7 +100,7 @@ private:
ScDocument* pDoc;
ScRangeUtil* pRangeUtil;
ScAreaData* pAreaData;
- sal_uInt16 nAreaDataCount;
+ size_t nAreaDataCount;
sal_uInt16 nWhichCons;
formula::RefEdit* pRefInputEdit;
diff --git a/sc/source/ui/inc/dbdocfun.hxx b/sc/source/ui/inc/dbdocfun.hxx
index 35986627c..be99ee518 100644
--- a/sc/source/ui/inc/dbdocfun.hxx
+++ b/sc/source/ui/inc/dbdocfun.hxx
@@ -82,20 +82,19 @@ public:
void UpdateImport( const String& rTarget, const String& rDBName,
const String& rTableName, const String& rStatement,
- sal_Bool bNative, sal_uInt8 nType,
+ bool bNative, sal_uInt8 nType,
const ::com::sun::star::uno::Reference<
::com::sun::star::sdbc::XResultSet >& xResultSet,
const SbaSelectionList* pSelection );
- sal_Bool DoImport( SCTAB nTab, const ScImportParam& rParam,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::sdbc::XResultSet >& xResultSet,
- const SbaSelectionList* pSelection, sal_Bool bRecord,
- sal_Bool bAddrInsert = false );
+ bool DoImport( SCTAB nTab, const ScImportParam& rParam,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >& xResultSet,
+ const SbaSelectionList* pSelection, bool bRecord,
+ bool bAddrInsert = false );
- sal_Bool DoImportUno( const ScAddress& rPos,
- const com::sun::star::uno::Sequence<
- com::sun::star::beans::PropertyValue>& aArgs );
+ bool DoImportUno( const ScAddress& rPos,
+ const com::sun::star::uno::Sequence<
+ com::sun::star::beans::PropertyValue>& aArgs );
static void ShowInBeamer( const ScImportParam& rParam, SfxViewFrame* pFrame );
@@ -109,12 +108,12 @@ public:
const ScSortParam* pForceNewSort,
sal_Bool bRecord, sal_Bool bApi );
- sal_Bool AddDBRange( const String& rName, const ScRange& rRange, sal_Bool bApi );
- sal_Bool DeleteDBRange( const String& rName, sal_Bool bApi );
- sal_Bool RenameDBRange( const String& rOld, const String& rNew, sal_Bool bApi );
- sal_Bool ModifyDBData( const ScDBData& rNewData, sal_Bool bApi ); // Name unveraendert
+ bool AddDBRange( const ::rtl::OUString& rName, const ScRange& rRange, sal_Bool bApi );
+ bool DeleteDBRange( const ::rtl::OUString& rName );
+ bool RenameDBRange( const String& rOld, const String& rNew );
+ bool ModifyDBData( const ScDBData& rNewData ); // Name unveraendert
- sal_Bool RepeatDB( const String& rDBName, sal_Bool bRecord, sal_Bool bApi, bool bIsUnnamed=false, SCTAB aTab = 0);
+ bool RepeatDB( const ::rtl::OUString& rDBName, bool bRecord, bool bApi, bool bIsUnnamed=false, SCTAB aTab = 0);
sal_Bool DataPilotUpdate( ScDPObject* pOldObj, const ScDPObject* pNewObj,
sal_Bool bRecord, sal_Bool bApi, sal_Bool bAllowMove = false );
diff --git a/sc/source/ui/inc/dbfunc.hxx b/sc/source/ui/inc/dbfunc.hxx
index 820105027..abdfe137e 100644
--- a/sc/source/ui/inc/dbfunc.hxx
+++ b/sc/source/ui/inc/dbfunc.hxx
@@ -75,7 +75,7 @@ public:
sal_Bool ImportData( const ScImportParam& rParam, sal_Bool bRecord = sal_True );
- void GotoDBArea( const String& rDBName );
+ void GotoDBArea( const ::rtl::OUString& rDBName );
// DB-Bereich vom Cursor
ScDBData* GetDBData( bool bMarkArea = true, ScGetDBMode eMode = SC_DB_MAKE, ScGetDBSelection eSel = SC_DBSEL_KEEP);
diff --git a/sc/source/ui/inc/dbnamdlg.hxx b/sc/source/ui/inc/dbnamdlg.hxx
index c6a16f257..e74b8f7a2 100644
--- a/sc/source/ui/inc/dbnamdlg.hxx
+++ b/sc/source/ui/inc/dbnamdlg.hxx
@@ -85,7 +85,6 @@ private:
const String aStrAdd; // "Hinzufuegen"
const String aStrModify; // "Aendern"
- const String aStrNoName; // "unbenannt"
const String aStrInvalid;
String aStrSource;
diff --git a/sc/source/ui/inc/inputwin.hxx b/sc/source/ui/inc/inputwin.hxx
index 6c3785d16..3dd1f2798 100644
--- a/sc/source/ui/inc/inputwin.hxx
+++ b/sc/source/ui/inc/inputwin.hxx
@@ -195,7 +195,7 @@ protected:
virtual void SetText( const String& rString );
virtual String GetText() const;
- sal_Bool UseSubTotal( ScRangeList* pRangeList ) const;
+ bool UseSubTotal( ScRangeList* pRangeList ) const;
private:
ScPosWnd aWndPos;
diff --git a/sc/source/ui/inc/undodat.hxx b/sc/source/ui/inc/undodat.hxx
index c9142a3c9..09bfd2e52 100644
--- a/sc/source/ui/inc/undodat.hxx
+++ b/sc/source/ui/inc/undodat.hxx
@@ -302,15 +302,15 @@ private:
class ScUndoAutoFilter: public ScDBFuncUndo
{
private:
- String aDBName;
- sal_Bool bFilterSet;
+ ::rtl::OUString aDBName;
+ bool bFilterSet;
- void DoChange( sal_Bool bUndo );
+ void DoChange( bool bUndo );
public:
TYPEINFO();
ScUndoAutoFilter( ScDocShell* pNewDocShell, const ScRange& rRange,
- const String& rName, sal_Bool bSet );
+ const ::rtl::OUString& rName, bool bSet );
virtual ~ScUndoAutoFilter();
virtual void Undo();
diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx
index dcd0aa92b..a21e6157c 100644
--- a/sc/source/ui/navipi/content.cxx
+++ b/sc/source/ui/navipi/content.cxx
@@ -268,17 +268,12 @@ String lcl_GetDBAreaRange( ScDocument* pDoc, const String& rDBName )
if (pDoc)
{
ScDBCollection* pDbNames = pDoc->GetDBCollection();
- sal_uInt16 nCount = pDbNames->GetCount();
- for ( sal_uInt16 i=0; i<nCount; i++ )
+ const ScDBData* pData = pDbNames->getNamedDBs().findByName(rDBName);
+ if (pData)
{
- ScDBData* pData = (*pDbNames)[i];
- if ( pData->GetName().equals(rDBName) )
- {
- ScRange aRange;
- pData->GetArea(aRange);
- aRange.Format( aRet, SCR_ABS_3D, pDoc );
- break;
- }
+ ScRange aRange;
+ pData->GetArea(aRange);
+ aRange.Format(aRet, SCR_ABS_3D, pDoc);
}
}
return aRet;
@@ -705,15 +700,12 @@ void ScContentTree::GetDbNames()
return;
ScDBCollection* pDbNames = pDoc->GetDBCollection();
- sal_uInt16 nCount = pDbNames->GetCount();
- if ( nCount > 0 )
+ const ScDBCollection::NamedDBs& rDBs = pDbNames->getNamedDBs();
+ ScDBCollection::NamedDBs::const_iterator itr = rDBs.begin(), itrEnd = rDBs.end();
+ for (; itr != itrEnd; ++itr)
{
- for ( sal_uInt16 i=0; i<nCount; i++ )
- {
- ScDBData* pData = (*pDbNames)[i];
- String aStrName = pData->GetName();
- InsertContent( SC_CONTENT_DBAREA, aStrName );
- }
+ const::rtl::OUString& aStrName = itr->GetName();
+ InsertContent(SC_CONTENT_DBAREA, aStrName);
}
}
@@ -995,10 +987,9 @@ sal_Bool ScContentTree::DrawNamesChanged( sal_uInt16 nType )
return !bEqual;
}
-sal_Bool lcl_GetRange( ScDocument* pDoc, sal_uInt16 nType, const String& rName, ScRange& rRange )
+bool lcl_GetRange( ScDocument* pDoc, sal_uInt16 nType, const String& rName, ScRange& rRange )
{
- sal_Bool bFound = false;
- sal_uInt16 nPos;
+ bool bFound = false;
if ( nType == SC_CONTENT_RANGENAME )
{
@@ -1014,15 +1005,18 @@ sal_Bool lcl_GetRange( ScDocument* pDoc, sal_uInt16 nType, const String& rName,
{
ScDBCollection* pList = pDoc->GetDBCollection();
if (pList)
- if (pList->SearchName( rName, nPos ))
+ {
+ const ScDBData* p = pList->getNamedDBs().findByName(rName);
+ if (p)
{
SCTAB nTab;
SCCOL nCol1, nCol2;
SCROW nRow1, nRow2;
- (*pList)[nPos]->GetArea(nTab,nCol1,nRow1,nCol2,nRow2);
- rRange = ScRange( nCol1,nRow1,nTab, nCol2,nRow2,nTab );
- bFound = sal_True;
+ p->GetArea(nTab, nCol1, nRow1, nCol2, nRow2);
+ rRange = ScRange(nCol1, nRow1, nTab, nCol2, nRow2, nTab);
+ bFound = true;
}
+ }
}
return bFound;
diff --git a/sc/source/ui/undo/undodat.cxx b/sc/source/ui/undo/undodat.cxx
index 8b8f56d18..3241b8b0a 100644
--- a/sc/source/ui/undo/undodat.cxx
+++ b/sc/source/ui/undo/undodat.cxx
@@ -1090,7 +1090,7 @@ sal_Bool ScUndoQuery::CanRepeat(SfxRepeatTarget& /* rTarget */) const
//
ScUndoAutoFilter::ScUndoAutoFilter( ScDocShell* pNewDocShell, const ScRange& rRange,
- const String& rName, sal_Bool bSet ) :
+ const ::rtl::OUString& rName, bool bSet ) :
ScDBFuncUndo( pNewDocShell, rRange ),
aDBName( rName ),
bFilterSet( bSet )
@@ -1106,14 +1106,13 @@ String ScUndoAutoFilter::GetComment() const
return ScGlobal::GetRscString( STR_UNDO_QUERY ); // same as ScUndoQuery
}
-void ScUndoAutoFilter::DoChange( sal_Bool bUndo )
+void ScUndoAutoFilter::DoChange( bool bUndo )
{
- sal_Bool bNewFilter = bUndo ? !bFilterSet : bFilterSet;
+ bool bNewFilter = bUndo ? !bFilterSet : bFilterSet;
- sal_uInt16 nIndex;
ScDocument* pDoc = pDocShell->GetDocument();
ScDBData* pDBData=NULL;
- if (rtl::OUString(aDBName) == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(STR_DB_LOCAL_NONAME)))
+ if (aDBName.equalsAscii(STR_DB_LOCAL_NONAME))
{
SCTAB nTab = aOriginalRange.aStart.Tab();
pDBData = pDoc->GetAnonymousDBData(nTab);
@@ -1121,11 +1120,9 @@ void ScUndoAutoFilter::DoChange( sal_Bool bUndo )
else
{
ScDBCollection* pColl = pDoc->GetDBCollection();
- if (pColl->SearchName( aDBName, nIndex ))
- pDBData = (*pColl)[nIndex];
+ pDBData = pColl->getNamedDBs().findByName(aDBName);
}
-
if ( pDBData )
{
pDBData->SetAutoFilter( bNewFilter );
@@ -1901,17 +1898,9 @@ void ScUndoConsolidate::Undo()
ScDBCollection* pColl = pDoc->GetDBCollection();
if (pColl)
{
- sal_uInt16 nIndex;
- if (pColl->SearchName( pUndoData->GetName(), nIndex ))
- {
- ScDBData* pDocData = (*pColl)[nIndex];
- if (pDocData)
- *pDocData = *pUndoData;
- }
- else
- {
- OSL_FAIL("alte DB-Daten nicht gefunden");
- }
+ ScDBData* pDocData = pColl->getNamedDBs().findByName(pUndoData->GetName());
+ if (pDocData)
+ *pDocData = *pUndoData;
}
}
diff --git a/sc/source/ui/unoobj/datauno.cxx b/sc/source/ui/unoobj/datauno.cxx
index 0e7fcfaf4..59ede6d81 100644
--- a/sc/source/ui/unoobj/datauno.cxx
+++ b/sc/source/ui/unoobj/datauno.cxx
@@ -67,6 +67,8 @@
#include <comphelper/servicehelper.hxx>
#include <svx/dataaccessdescriptor.hxx>
+#include <limits>
+
using namespace com::sun::star;
SV_IMPL_PTRARR( XDBRefreshListenerArr_Impl, XDBRefreshListenerPtr );
@@ -1657,9 +1659,9 @@ ScDBData* ScDatabaseRangeObj::GetDBData_Impl() const
ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection();
if (pNames)
{
- sal_uInt16 nPos = 0;
- if (pNames->SearchName( aName, nPos ))
- pRet = (*pNames)[nPos];
+ ScDBData* p = pNames->getNamedDBs().findByName(aName);
+ if (p)
+ pRet = p;
}
}
}
@@ -1682,7 +1684,7 @@ void SAL_CALL ScDatabaseRangeObj::setName( const rtl::OUString& aNewName )
{
ScDBDocFunc aFunc(*pDocShell);
String aNewStr(aNewName);
- sal_Bool bOk = aFunc.RenameDBRange( aName, aNewStr, sal_True );
+ sal_Bool bOk = aFunc.RenameDBRange( aName, aNewStr );
if (bOk)
aName = aNewStr;
}
@@ -1720,7 +1722,7 @@ void SAL_CALL ScDatabaseRangeObj::setDataArea( const table::CellRangeAddress& aD
aNewData.SetArea( aDataArea.Sheet, (SCCOL)aDataArea.StartColumn, (SCROW)aDataArea.StartRow,
(SCCOL)aDataArea.EndColumn, (SCROW)aDataArea.EndRow );
ScDBDocFunc aFunc(*pDocShell);
- aFunc.ModifyDBData(aNewData, sal_True);
+ aFunc.ModifyDBData(aNewData);
}
}
@@ -1792,7 +1794,7 @@ void ScDatabaseRangeObj::SetQueryParam(const ScQueryParam& rQueryParam)
aNewData.SetQueryParam(aParam);
aNewData.SetHeader(aParam.bHasHeader); // not in ScDBData::SetQueryParam
ScDBDocFunc aFunc(*pDocShell);
- aFunc.ModifyDBData(aNewData, sal_True);
+ aFunc.ModifyDBData(aNewData);
}
}
@@ -1852,7 +1854,7 @@ void ScDatabaseRangeObj::SetSubTotalParam(const ScSubTotalParam& rSubTotalParam)
ScDBData aNewData( *pData );
aNewData.SetSubTotalParam(aParam);
ScDBDocFunc aFunc(*pDocShell);
- aFunc.ModifyDBData(aNewData, sal_True);
+ aFunc.ModifyDBData(aNewData);
}
}
@@ -2068,7 +2070,7 @@ void SAL_CALL ScDatabaseRangeObj::setPropertyValue(
if (bDo)
{
ScDBDocFunc aFunc(*pDocShell);
- aFunc.ModifyDBData(aNewData, sal_True);
+ aFunc.ModifyDBData(aNewData);
}
}
}
@@ -2199,15 +2201,22 @@ void ScDatabaseRangesObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
// XDatabaseRanges
-ScDatabaseRangeObj* ScDatabaseRangesObj::GetObjectByIndex_Impl(sal_uInt16 nIndex)
+ScDatabaseRangeObj* ScDatabaseRangesObj::GetObjectByIndex_Impl(size_t nIndex)
{
- if (pDocShell)
- {
- ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection();
- if (pNames && nIndex < pNames->GetCount())
- return new ScDatabaseRangeObj( pDocShell, (*pNames)[nIndex]->GetName() );
- }
- return NULL;
+ if (!pDocShell)
+ return NULL;
+
+ ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection();
+ if (!pNames)
+ return NULL;
+
+ const ScDBCollection::NamedDBs& rDBs = pNames->getNamedDBs();
+ if (rDBs.empty() || nIndex >= rDBs.size())
+ return NULL;
+
+ ScDBCollection::NamedDBs::const_iterator itr = rDBs.begin();
+ ::std::advance(itr, nIndex); // boundary check is done above.
+ return new ScDatabaseRangeObj(pDocShell, itr->GetName());
}
ScDatabaseRangeObj* ScDatabaseRangesObj::GetObjectByName_Impl(const rtl::OUString& aName)
@@ -2249,7 +2258,7 @@ void SAL_CALL ScDatabaseRangesObj::removeByName( const rtl::OUString& aName )
{
ScDBDocFunc aFunc(*pDocShell);
String aString(aName);
- bDone = aFunc.DeleteDBRange( aString, sal_True );
+ bDone = aFunc.DeleteDBRange( aString );
}
if (!bDone)
throw uno::RuntimeException(); // no other exceptions specified
@@ -2276,7 +2285,7 @@ sal_Int32 SAL_CALL ScDatabaseRangesObj::getCount() throw(uno::RuntimeException)
{
ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection();
if (pNames)
- return pNames->GetCount();
+ return static_cast<sal_Int32>(pNames->getNamedDBs().size());
}
return 0;
}
@@ -2286,7 +2295,10 @@ uno::Any SAL_CALL ScDatabaseRangesObj::getByIndex( sal_Int32 nIndex )
lang::WrappedTargetException, uno::RuntimeException)
{
SolarMutexGuard aGuard;
- uno::Reference<sheet::XDatabaseRange> xRange(GetObjectByIndex_Impl((sal_uInt16)nIndex));
+ if (nIndex < 0 || nIndex > ::std::numeric_limits<size_t>::max())
+ throw lang::IndexOutOfBoundsException();
+
+ uno::Reference<sheet::XDatabaseRange> xRange(GetObjectByIndex_Impl(static_cast<size_t>(nIndex)));
if (xRange.is())
return uno::makeAny(xRange);
else
@@ -2332,12 +2344,11 @@ uno::Sequence<rtl::OUString> SAL_CALL ScDatabaseRangesObj::getElementNames()
ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection();
if (pNames)
{
- sal_uInt16 nCount = pNames->GetCount();
- String aName;
- uno::Sequence<rtl::OUString> aSeq(nCount);
- rtl::OUString* pAry = aSeq.getArray();
- for (sal_uInt16 i=0; i<nCount; i++)
- pAry[i] = (*pNames)[i]->GetName();
+ const ScDBCollection::NamedDBs& rDBs = pNames->getNamedDBs();
+ uno::Sequence<rtl::OUString> aSeq(rDBs.size());
+ ScDBCollection::NamedDBs::const_iterator itr = rDBs.begin(), itrEnd = rDBs.end();
+ for (size_t i = 0; itr != itrEnd; ++itr, ++i)
+ aSeq[i] = itr->GetName();
return aSeq;
}
@@ -2356,12 +2367,7 @@ sal_Bool SAL_CALL ScDatabaseRangesObj::hasByName( const rtl::OUString& aName )
{
ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection();
if (pNames)
- {
- String aString(aName);
- sal_uInt16 nPos = 0;
- if (pNames->SearchName( aString, nPos ))
- return sal_True;
- }
+ return pNames->getNamedDBs().findByName(aName) != NULL;
}
return false;
}
diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx
index 64fc2a391..91a48beca 100644
--- a/sc/source/ui/view/cellsh2.cxx
+++ b/sc/source/ui/view/cellsh2.cxx
@@ -723,26 +723,11 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
if ( pDBCol )
{
- const String aStrNoName( RTL_CONSTASCII_USTRINGPARAM(STR_DB_LOCAL_NONAME) );
- List aList;
- sal_uInt16 nDBCount = pDBCol->GetCount();
- ScDBData* pDbData = NULL;
- String* pDBName = NULL;
-
- for ( sal_uInt16 i=0; i < nDBCount; i++ )
- {
- pDbData = (ScDBData*)(pDBCol->At( i ));
- if ( pDbData )
- {
- pDBName = new String;
- *pDBName = pDbData->GetName();
-
- if ( *pDBName != aStrNoName )
- aList.Insert( pDBName );
- else
- DELETEZ(pDBName);
- }
- }
+ List aList;
+ const ScDBCollection::NamedDBs& rDBs = pDBCol->getNamedDBs();
+ ScDBCollection::NamedDBs::const_iterator itr = rDBs.begin(), itrEnd = rDBs.end();
+ for (; itr != itrEnd; ++itr)
+ aList.Insert(new String(itr->GetName()));
ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
diff --git a/sc/source/ui/view/dbfunc.cxx b/sc/source/ui/view/dbfunc.cxx
index 96530c9e2..2d2889bbe 100644
--- a/sc/source/ui/view/dbfunc.cxx
+++ b/sc/source/ui/view/dbfunc.cxx
@@ -66,35 +66,28 @@ ScDBFunc::~ScDBFunc()
// Hilfsfunktionen
//
-void ScDBFunc::GotoDBArea( const String& rDBName )
+void ScDBFunc::GotoDBArea( const ::rtl::OUString& rDBName )
{
ScDocument* pDoc = GetViewData()->GetDocument();
ScDBCollection* pDBCol = pDoc->GetDBCollection();
-
- sal_uInt16 nFoundAt = 0;
- if ( pDBCol->SearchName( rDBName, nFoundAt ) )
+ ScDBData* pData = pDBCol->getNamedDBs().findByName(rDBName);
+ if (pData)
{
- ScDBData* pData = (*pDBCol)[nFoundAt];
- DBG_ASSERT( pData, "GotoDBArea: Datenbankbereich nicht gefunden!" );
-
- if ( pData )
- {
- SCTAB nTab = 0;
- SCCOL nStartCol = 0;
- SCROW nStartRow = 0;
- SCCOL nEndCol = 0;
- SCROW nEndRow = 0;
-
- pData->GetArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow );
- SetTabNo( nTab );
-
- MoveCursorAbs( nStartCol, nStartRow, ScFollowMode( SC_FOLLOW_JUMP ),
- false, false ); // bShift,bControl
- DoneBlockMode();
- InitBlockMode( nStartCol, nStartRow, nTab );
- MarkCursor( nEndCol, nEndRow, nTab );
- SelectionChanged();
- }
+ SCTAB nTab = 0;
+ SCCOL nStartCol = 0;
+ SCROW nStartRow = 0;
+ SCCOL nEndCol = 0;
+ SCROW nEndRow = 0;
+
+ pData->GetArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow );
+ SetTabNo( nTab );
+
+ MoveCursorAbs( nStartCol, nStartRow, ScFollowMode( SC_FOLLOW_JUMP ),
+ false, false ); // bShift,bControl
+ DoneBlockMode();
+ InitBlockMode( nStartCol, nStartRow, nTab );
+ MarkCursor( nEndCol, nEndRow, nTab );
+ SelectionChanged();
}
}
diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx
index 5f427a80c..b9c43a833 100644
--- a/sc/source/ui/view/dbfunc3.cxx
+++ b/sc/source/ui/view/dbfunc3.cxx
@@ -492,7 +492,7 @@ void ScDBFunc::DoSubTotals( const ScSubTotalParam& rParam, sal_Bool bRecord,
if (!pDocRange->empty())
pUndoRange = new ScRangeName( *pDocRange );
ScDBCollection* pDocDB = pDoc->GetDBCollection();
- if (pDocDB->GetCount())
+ if (!pDocDB->empty())
pUndoDB = new ScDBCollection( *pDocDB );
}
@@ -2277,7 +2277,7 @@ void ScDBFunc::RepeatDB( sal_Bool bRecord )
if (!pDocRange->empty())
pUndoRange = new ScRangeName( *pDocRange );
ScDBCollection* pDocDB = pDoc->GetDBCollection();
- if (pDocDB->GetCount())
+ if (!pDocDB->empty())
pUndoDB = new ScDBCollection( *pDocDB );
}
diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
index fdc39f5bd..994fb56eb 100644
--- a/sc/source/ui/view/tabvwsh4.cxx
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -1642,17 +1642,19 @@ void ScTabViewShell::Construct( sal_uInt8 nForceDesignMode )
}
}
- sal_Bool bReImport = false; // importierte Daten aktualisieren
+ bool bReImport = false; // importierte Daten aktualisieren
ScDBCollection* pDBColl = pDoc->GetDBCollection();
if ( pDBColl )
{
- sal_uInt16 nCount = pDBColl->GetCount();
- for (sal_uInt16 i=0; i<nCount && !bReImport; i++)
+ const ScDBCollection::NamedDBs& rDBs = pDBColl->getNamedDBs();
+ ScDBCollection::NamedDBs::const_iterator itr = rDBs.begin(), itrEnd = rDBs.end();
+ for (; itr != itrEnd; ++itr)
{
- ScDBData* pData = (*pDBColl)[i];
- if ( pData->IsStripData() &&
- pData->HasImportParam() && !pData->HasImportSelection() )
- bReImport = sal_True;
+ if (itr->IsStripData() && itr->HasImportParam() && !itr->HasImportSelection())
+ {
+ bReImport = true;
+ break;
+ }
}
}
if (bReImport)