[Libreoffice-commits] .: 7 commits - sc/inc sc/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Fri May 13 19:56:35 PDT 2011
sc/inc/arealink.hxx | 16
sc/inc/compiler.hxx | 4
sc/inc/datauno.hxx | 2
sc/inc/dbcolect.hxx | 257 ++++++-----
sc/inc/document.hxx | 11
sc/inc/rangeutl.hxx | 10
sc/source/core/data/documen2.cxx | 2
sc/source/core/data/documen3.cxx | 105 ++--
sc/source/core/data/document.cxx | 20
sc/source/core/data/table2.cxx | 2
sc/source/core/data/validat.cxx | 10
sc/source/core/tool/compiler.cxx | 39 -
sc/source/core/tool/dbcolect.cxx | 506 +++++++++++++++--------
sc/source/core/tool/interpr4.cxx | 3
sc/source/core/tool/rangeutl.cxx | 36 -
sc/source/filter/starcalc/scflt.cxx | 2
sc/source/filter/xml/XMLExportDatabaseRanges.cxx | 195 ++------
sc/source/filter/xml/XMLExportDatabaseRanges.hxx | 2
sc/source/filter/xml/xmldrani.cxx | 218 +--------
sc/source/filter/xml/xmldrani.hxx | 6
sc/source/filter/xml/xmlexprt.cxx | 2
sc/source/ui/app/inputwin.cxx | 40 -
sc/source/ui/dbgui/consdlg.cxx | 8
sc/source/ui/dbgui/dbnamdlg.cxx | 101 ++--
sc/source/ui/dbgui/foptmgr.cxx | 6
sc/source/ui/docshell/arealink.cxx | 16
sc/source/ui/docshell/dbdocfun.cxx | 115 ++---
sc/source/ui/docshell/dbdocimp.cxx | 14
sc/source/ui/docshell/docsh4.cxx | 37 -
sc/source/ui/docshell/docsh5.cxx | 12
sc/source/ui/inc/consdlg.hxx | 2
sc/source/ui/inc/dbdocfun.hxx | 27 -
sc/source/ui/inc/dbfunc.hxx | 2
sc/source/ui/inc/dbnamdlg.hxx | 1
sc/source/ui/inc/inputwin.hxx | 2
sc/source/ui/inc/undodat.hxx | 8
sc/source/ui/navipi/content.cxx | 44 --
sc/source/ui/undo/undodat.cxx | 27 -
sc/source/ui/unoobj/datauno.cxx | 69 +--
sc/source/ui/view/cellsh2.cxx | 25 -
sc/source/ui/view/dbfunc.cxx | 43 -
sc/source/ui/view/dbfunc3.cxx | 4
sc/source/ui/view/tabvwsh4.cxx | 16
43 files changed, 1013 insertions(+), 1054 deletions(-)
New commits:
commit 5f43ea17a724aad3e3181d970d6f74057dbecc3b
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Fri May 13 21:55:11 2011 -0400
Fixed incorrect exporting of global named database ranges.
diff --git a/sc/inc/dbcolect.hxx b/sc/inc/dbcolect.hxx
index 280c59e..bf2a032 100644
--- a/sc/inc/dbcolect.hxx
+++ b/sc/inc/dbcolect.hxx
@@ -161,6 +161,8 @@ public:
class SC_DLLPUBLIC ScDBCollection
{
public:
+ enum RangeType { GlobalNamed, GlobalAnonymous, SheetAnonymous };
+
/**
* Stores global named database ranges.
*/
diff --git a/sc/source/filter/xml/XMLExportDatabaseRanges.cxx b/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
index 25fa489..b81f179 100644
--- a/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
+++ b/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
@@ -576,12 +576,25 @@ namespace {
class WriteDatabaseRange : public ::std::unary_function<ScDBData, void>
{
+ ScXMLExport& mrExport;
+ ScDocument* mpDoc;
+ sal_Int32 mnCounter;
+ ScDBCollection::RangeType meRangeType;
public:
+
WriteDatabaseRange(ScXMLExport& rExport, ScDocument* pDoc) :
- mrExport(rExport), mpDoc(pDoc), mnCounter(0) {}
+ mrExport(rExport), mpDoc(pDoc), mnCounter(0), meRangeType(ScDBCollection::GlobalNamed) {}
+
+ void setRangeType(ScDBCollection::RangeType eNew)
+ {
+ meRangeType = eNew;
+ }
void operator() (const ::std::pair<SCTAB, const ScDBData*>& r)
{
+ if (meRangeType != ScDBCollection::SheetAnonymous)
+ return;
+
// name
OUStringBuffer aBuf;
aBuf.appendAscii(STR_DB_LOCAL_NONAME);
@@ -592,12 +605,17 @@ public:
void operator() (const ScDBData& rData)
{
- // name
- OUStringBuffer aBuf;
- aBuf.appendAscii(STR_DB_GLOBAL_NONAME);
- aBuf.append(++mnCounter); // 1-based, for entirely arbitrary reasons. The numbers are ignored on import.
+ if (meRangeType == ScDBCollection::GlobalAnonymous)
+ {
+ // name
+ OUStringBuffer aBuf;
+ aBuf.appendAscii(STR_DB_GLOBAL_NONAME);
+ aBuf.append(++mnCounter); // 1-based, for entirely arbitrary reasons. The numbers are ignored on import.
- write(aBuf.makeStringAndClear(), rData);
+ write(aBuf.makeStringAndClear(), rData);
+ }
+ else if (meRangeType == ScDBCollection::GlobalNamed)
+ write(rData.GetName(), rData);
}
private:
@@ -1075,11 +1093,6 @@ private:
}
}
}
-
-private:
- ScXMLExport& mrExport;
- ScDocument* mpDoc;
- sal_Int32 mnCounter;
};
}
@@ -1123,15 +1136,18 @@ void ScXMLExportDatabaseRanges::WriteDatabaseRanges()
if (pDBCollection)
{
// Write global named ranges.
+ func.setRangeType(ScDBCollection::GlobalNamed);
const ScDBCollection::NamedDBs& rNamedDBs = pDBCollection->getNamedDBs();
::std::for_each(rNamedDBs.begin(), rNamedDBs.end(), func);
// Add global anonymous DB ranges.
+ func.setRangeType(ScDBCollection::GlobalAnonymous);
const ScDBCollection::AnonDBs& rAnonDBs = pDBCollection->getAnonDBs();
::std::for_each(rAnonDBs.begin(), rAnonDBs.end(), func);
}
// Write sheet-local ranges.
+ func.setRangeType(ScDBCollection::SheetAnonymous);
::std::for_each(aSheetDBs.begin(), aSheetDBs.end(), func);
}
diff --git a/sc/source/filter/xml/xmldrani.cxx b/sc/source/filter/xml/xmldrani.cxx
index b9cea6a..bef1205 100644
--- a/sc/source/filter/xml/xmldrani.cxx
+++ b/sc/source/filter/xml/xmldrani.cxx
@@ -151,7 +151,7 @@ ScXMLDatabaseRangeContext::ScXMLDatabaseRangeContext( ScXMLImport& rImport,
bFilterSkipDuplicates(false),
bFilterUseRegularExpressions(false),
bFilterConditionSourceRange(false),
- meRangeType(GlobalNamed)
+ meRangeType(ScDBCollection::GlobalNamed)
{
nSourceType = sheet::DataImportMode_NONE;
sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
@@ -223,9 +223,9 @@ ScXMLDatabaseRangeContext::ScXMLDatabaseRangeContext( ScXMLImport& rImport,
}
if (sDatabaseRangeName.matchAsciiL(STR_DB_LOCAL_NONAME, strlen(STR_DB_LOCAL_NONAME)))
- meRangeType = SheetAnonymous;
+ meRangeType = ScDBCollection::SheetAnonymous;
else if (sDatabaseRangeName.matchAsciiL(STR_DB_GLOBAL_NONAME, strlen(STR_DB_GLOBAL_NONAME)))
- meRangeType = GlobalAnonymous;
+ meRangeType = ScDBCollection::GlobalAnonymous;
}
ScXMLDatabaseRangeContext::~ScXMLDatabaseRangeContext()
@@ -476,7 +476,7 @@ void ScXMLDatabaseRangeContext::EndElement()
if (!pDoc)
return;
- if (meRangeType == SheetAnonymous)
+ if (meRangeType == ScDBCollection::SheetAnonymous)
{
OUString aName(RTL_CONSTASCII_USTRINGPARAM(STR_DB_LOCAL_NONAME));
::std::auto_ptr<ScDBData> pData(ConvertToDBData(aName));
@@ -491,7 +491,7 @@ void ScXMLDatabaseRangeContext::EndElement()
}
return;
}
- else if (meRangeType == GlobalAnonymous)
+ else if (meRangeType == ScDBCollection::GlobalAnonymous)
{
OUString aName(RTL_CONSTASCII_USTRINGPARAM(STR_DB_GLOBAL_NONAME));
::std::auto_ptr<ScDBData> pData(ConvertToDBData(aName));
@@ -503,7 +503,7 @@ void ScXMLDatabaseRangeContext::EndElement()
}
return;
}
- else if (meRangeType == GlobalNamed)
+ else if (meRangeType == ScDBCollection::GlobalNamed)
{
::std::auto_ptr<ScDBData> pData(ConvertToDBData(sDatabaseRangeName));
diff --git a/sc/source/filter/xml/xmldrani.hxx b/sc/source/filter/xml/xmldrani.hxx
index 80b6524..0f4d9c6 100644
--- a/sc/source/filter/xml/xmldrani.hxx
+++ b/sc/source/filter/xml/xmldrani.hxx
@@ -39,6 +39,8 @@
#include <com/sun/star/table/CellRangeAddress.hpp>
#include <com/sun/star/table/TableOrientation.hpp>
+#include "dbcolect.hxx"
+
class ScDBData;
class ScXMLImport;
@@ -72,8 +74,6 @@ struct ScSubTotalRule
class ScXMLDatabaseRangeContext : public SvXMLImportContext
{
- enum RangeType { GlobalNamed, GlobalAnonymous, SheetAnonymous };
-
rtl::OUString sDatabaseRangeName;
rtl::OUString sConnectionRessource;
rtl::OUString sRangeAddress;
@@ -109,7 +109,7 @@ class ScXMLDatabaseRangeContext : public SvXMLImportContext
sal_Bool bFilterSkipDuplicates;
sal_Bool bFilterUseRegularExpressions;
sal_Bool bFilterConditionSourceRange;
- RangeType meRangeType;
+ ScDBCollection::RangeType meRangeType;
const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
commit 3cf690afecdc1d8dde3457efc17121af69688b5d
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Fri May 13 21:08:27 2011 -0400
Fixed segfault.
Use the raw pointer after the auto_ptr has been inserted; as it
becomes invalid once the ownership moves to the container.
diff --git a/sc/source/core/tool/dbcolect.cxx b/sc/source/core/tool/dbcolect.cxx
index 135a88f..a7a5610 100644
--- a/sc/source/core/tool/dbcolect.cxx
+++ b/sc/source/core/tool/dbcolect.cxx
@@ -711,10 +711,10 @@ bool ScDBCollection::NamedDBs::insert(ScDBData* p)
pair<DBsType::iterator, bool> r = maDBs.insert(pData);
- if (r.second && pData->HasImportParam() && !pData->HasImportSelection())
+ if (r.second && p->HasImportParam() && !p->HasImportSelection())
{
- pData->SetRefreshHandler(mrParent.GetRefreshHandler());
- pData->SetRefreshControl(mrDoc.GetRefreshTimerControlAddress());
+ p->SetRefreshHandler(mrParent.GetRefreshHandler());
+ p->SetRefreshControl(mrDoc.GetRefreshTimerControlAddress());
}
return r.second;
}
commit 33e3b16a5adbbc95b13f37482fa6723d8466215f
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Fri May 13 19:08:09 2011 -0400
Refactored global anonymous db storage.
This is more in line with the way the global named db ranges are
stored.
diff --git a/sc/inc/dbcolect.hxx b/sc/inc/dbcolect.hxx
index c766793..280c59e 100644
--- a/sc/inc/dbcolect.hxx
+++ b/sc/inc/dbcolect.hxx
@@ -161,8 +161,9 @@ public:
class SC_DLLPUBLIC ScDBCollection
{
public:
- typedef ::boost::ptr_vector<ScDBData> AnonDBsType;
-
+ /**
+ * Stores global named database ranges.
+ */
class NamedDBs
{
friend class ScDBCollection;
@@ -191,12 +192,37 @@ public:
bool operator== (const NamedDBs& r) const;
};
+ /**
+ * Stores global anonymous database ranges.
+ */
+ class AnonDBs
+ {
+ typedef ::boost::ptr_vector<ScDBData> DBsType;
+ DBsType maDBs;
+ public:
+ typedef DBsType::iterator iterator;
+ typedef DBsType::const_iterator const_iterator;
+
+ iterator begin();
+ iterator end();
+ const_iterator begin() const;
+ const_iterator end() const;
+ const ScDBData* findAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly) const;
+ const ScDBData* findByRange(const ScRange& rRange) const;
+ ScDBData* getByRange(const ScRange& rRange);
+ void insert(ScDBData* p);
+ void erase(iterator itr);
+ bool empty() const;
+ size_t size() const;
+ bool operator== (const AnonDBs& r) const;
+ };
+
private:
Link aRefreshHandler;
ScDocument* pDoc;
sal_uInt16 nEntryIndex; // counter for unique indices
NamedDBs maNamedDBs;
- AnonDBsType maAnonDBs;
+ AnonDBs maAnonDBs;
public:
ScDBCollection(ScDocument* pDocument);
@@ -205,6 +231,9 @@ public:
NamedDBs& getNamedDBs();
const NamedDBs& getNamedDBs() const;
+ AnonDBs& getAnonDBs();
+ const AnonDBs& getAnonDBs() 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;
@@ -226,13 +255,6 @@ public:
{ aRefreshHandler = rLink; }
const Link& GetRefreshHandler() const { return aRefreshHandler; }
- const ScDBData* findAnonAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly) const;
- const ScDBData* findAnonByRange(const ScRange& rRange) const;
- ScDBData* getAnonByRange(const ScRange& rRange);
- void insertAnonRange(ScDBData* pData);
-
- const AnonDBsType& getAnonRanges() const;
-
bool empty() const;
bool operator== (const ScDBCollection& r) const;
};
diff --git a/sc/source/core/tool/dbcolect.cxx b/sc/source/core/tool/dbcolect.cxx
index 64e055c..135a88f 100644
--- a/sc/source/core/tool/dbcolect.cxx
+++ b/sc/source/core/tool/dbcolect.cxx
@@ -744,6 +744,83 @@ bool ScDBCollection::NamedDBs::operator== (const NamedDBs& r) const
return maDBs == r.maDBs;
}
+ScDBCollection::AnonDBs::iterator ScDBCollection::AnonDBs::begin()
+{
+ return maDBs.begin();
+}
+
+ScDBCollection::AnonDBs::iterator ScDBCollection::AnonDBs::end()
+{
+ return maDBs.end();
+}
+
+ScDBCollection::AnonDBs::const_iterator ScDBCollection::AnonDBs::begin() const
+{
+ return maDBs.begin();
+}
+
+ScDBCollection::AnonDBs::const_iterator ScDBCollection::AnonDBs::end() const
+{
+ return maDBs.end();
+}
+
+const ScDBData* ScDBCollection::AnonDBs::findAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly) const
+{
+ DBsType::const_iterator itr = find_if(
+ maDBs.begin(), maDBs.end(), FindByCursor(nCol, nRow, nTab, bStartOnly));
+ return itr == maDBs.end() ? NULL : &(*itr);
+}
+
+const ScDBData* ScDBCollection::AnonDBs::findByRange(const ScRange& rRange) const
+{
+ DBsType::const_iterator itr = find_if(
+ maDBs.begin(), maDBs.end(), FindByRange(rRange));
+ return itr == maDBs.end() ? NULL : &(*itr);
+}
+
+ScDBData* ScDBCollection::AnonDBs::getByRange(const ScRange& rRange)
+{
+ const ScDBData* pData = findByRange(rRange);
+ if (!pData)
+ {
+ // Insert a new db data. They all have identical names.
+ rtl::OUString aName(RTL_CONSTASCII_USTRINGPARAM(STR_DB_GLOBAL_NONAME));
+ ::std::auto_ptr<ScDBData> pNew(new ScDBData(
+ aName, rRange.aStart.Tab(), rRange.aStart.Col(), rRange.aStart.Row(),
+ rRange.aEnd.Col(), rRange.aEnd.Row(), true, false));
+ pData = pNew.get();
+ maDBs.push_back(pNew);
+ }
+ return const_cast<ScDBData*>(pData);
+}
+
+void ScDBCollection::AnonDBs::insert(ScDBData* p)
+{
+ rtl::OUString aName(RTL_CONSTASCII_USTRINGPARAM(STR_DB_GLOBAL_NONAME));
+ ::std::auto_ptr<ScDBData> pNew(p);
+ maDBs.push_back(pNew);
+}
+
+void ScDBCollection::AnonDBs::erase(iterator itr)
+{
+ maDBs.erase(itr);
+}
+
+bool ScDBCollection::AnonDBs::empty() const
+{
+ return maDBs.empty();
+}
+
+size_t ScDBCollection::AnonDBs::size() const
+{
+ return maDBs.size();
+}
+
+bool ScDBCollection::AnonDBs::operator== (const AnonDBs& r) const
+{
+ return maDBs == r.maDBs;
+}
+
ScDBCollection::ScDBCollection(ScDocument* pDocument) :
pDoc(pDocument), nEntryIndex(SC_START_INDEX_DB_COLL), maNamedDBs(*this, *pDocument) {}
@@ -760,6 +837,16 @@ const ScDBCollection::NamedDBs& ScDBCollection::getNamedDBs() const
return maNamedDBs;
}
+ScDBCollection::AnonDBs& ScDBCollection::getAnonDBs()
+{
+ return maAnonDBs;
+}
+
+const ScDBCollection::AnonDBs& ScDBCollection::getAnonDBs() const
+{
+ return maAnonDBs;
+}
+
const ScDBData* ScDBCollection::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Bool bStartOnly) const
{
// First, search the global named db ranges.
@@ -775,7 +862,7 @@ const ScDBData* ScDBCollection::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab
return pNoNameData;
// Check the global anonymous db ranges.
- const ScDBData* pData = findAnonAtCursor(nCol, nRow, nTab, bStartOnly);
+ const ScDBData* pData = getAnonDBs().findAtCursor(nCol, nRow, nTab, bStartOnly);
if (pData)
return pData;
@@ -797,7 +884,7 @@ ScDBData* ScDBCollection::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_
return pNoNameData;
// Check the global anonymous db ranges.
- const ScDBData* pData = findAnonAtCursor(nCol, nRow, nTab, bStartOnly);
+ const ScDBData* pData = getAnonDBs().findAtCursor(nCol, nRow, nTab, bStartOnly);
if (pData)
return const_cast<ScDBData*>(pData);
@@ -820,7 +907,7 @@ const ScDBData* ScDBCollection::GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1
return pNoNameData;
// Lastly, check the global anonymous db ranges.
- return findAnonByRange(aRange);
+ return maAnonDBs.findByRange(aRange);
}
ScDBData* ScDBCollection::GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
@@ -839,7 +926,7 @@ ScDBData* ScDBCollection::GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCO
return pNoNameData;
// Lastly, check the global anonymous db ranges.
- const ScDBData* pData = findAnonByRange(aRange);
+ const ScDBData* pData = getAnonDBs().findByRange(aRange);
if (pData)
return const_cast<ScDBData*>(pData);
@@ -936,48 +1023,6 @@ ScDBData* ScDBCollection::GetDBNearCursor(SCCOL nCol, SCROW nRow, SCTAB nTab )
return pDoc->GetAnonymousDBData(nTab); // "unbenannt" nur zurueck, wenn sonst nichts gefunden
}
-const ScDBData* ScDBCollection::findAnonAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly) const
-{
- AnonDBsType::const_iterator itr = find_if(
- maAnonDBs.begin(), maAnonDBs.end(), FindByCursor(nCol, nRow, nTab, bStartOnly));
- return itr == maAnonDBs.end() ? NULL : &(*itr);
-}
-
-const ScDBData* ScDBCollection::findAnonByRange(const ScRange& rRange) const
-{
- AnonDBsType::const_iterator itr = find_if(
- maAnonDBs.begin(), maAnonDBs.end(), FindByRange(rRange));
- return itr == maAnonDBs.end() ? NULL : &(*itr);
-}
-
-ScDBData* ScDBCollection::getAnonByRange(const ScRange& rRange)
-{
- const ScDBData* pData = findAnonByRange(rRange);
- if (!pData)
- {
- // Insert a new db data. They all have identical names.
- rtl::OUString aName(RTL_CONSTASCII_USTRINGPARAM(STR_DB_GLOBAL_NONAME));
- ::std::auto_ptr<ScDBData> pNew(new ScDBData(
- aName, rRange.aStart.Tab(), rRange.aStart.Col(), rRange.aStart.Row(),
- rRange.aEnd.Col(), rRange.aEnd.Row(), true, false));
- pData = pNew.get();
- maAnonDBs.push_back(pNew);
- }
- return const_cast<ScDBData*>(pData);
-}
-
-void ScDBCollection::insertAnonRange(ScDBData* pData)
-{
- rtl::OUString aName(RTL_CONSTASCII_USTRINGPARAM(STR_DB_GLOBAL_NONAME));
- ::std::auto_ptr<ScDBData> pNew(pData);
- maAnonDBs.push_back(pNew);
-}
-
-const ScDBCollection::AnonDBsType& ScDBCollection::getAnonRanges() const
-{
- return maAnonDBs;
-}
-
bool ScDBCollection::empty() const
{
return maNamedDBs.empty() && maAnonDBs.empty();
diff --git a/sc/source/filter/xml/XMLExportDatabaseRanges.cxx b/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
index 7d3608f..25fa489 100644
--- a/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
+++ b/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
@@ -1108,7 +1108,7 @@ void ScXMLExportDatabaseRanges::WriteDatabaseRanges()
ScDBCollection* pDBCollection = pDoc->GetDBCollection();
if (pDBCollection)
{
- if (!pDBCollection->getNamedDBs().empty() || !pDBCollection->getAnonRanges().empty())
+ if (!pDBCollection->getNamedDBs().empty() || !pDBCollection->getAnonDBs().empty())
bHasRanges = true;
}
@@ -1127,7 +1127,7 @@ void ScXMLExportDatabaseRanges::WriteDatabaseRanges()
::std::for_each(rNamedDBs.begin(), rNamedDBs.end(), func);
// Add global anonymous DB ranges.
- const ScDBCollection::AnonDBsType& rAnonDBs = pDBCollection->getAnonRanges();
+ const ScDBCollection::AnonDBs& rAnonDBs = pDBCollection->getAnonDBs();
::std::for_each(rAnonDBs.begin(), rAnonDBs.end(), func);
}
diff --git a/sc/source/filter/xml/xmldrani.cxx b/sc/source/filter/xml/xmldrani.cxx
index 741032c..b9cea6a 100644
--- a/sc/source/filter/xml/xmldrani.cxx
+++ b/sc/source/filter/xml/xmldrani.cxx
@@ -499,7 +499,7 @@ void ScXMLDatabaseRangeContext::EndElement()
if (pData.get())
{
setAutoFilterFlags(*pDoc, *pData);
- pDoc->GetDBCollection()->insertAnonRange(pData.release());
+ pDoc->GetDBCollection()->getAnonDBs().insert(pData.release());
}
return;
}
diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx
index 7d1c261..46da786 100644
--- a/sc/source/ui/docshell/docsh5.cxx
+++ b/sc/source/ui/docshell/docsh5.cxx
@@ -340,7 +340,7 @@ ScDBData* ScDocShell::GetAnonymousDBData(const ScRange& rRange)
if (!pColl)
return NULL;
- ScDBData* pData = pColl->getAnonByRange(rRange);
+ ScDBData* pData = pColl->getAnonDBs().getByRange(rRange);
if (!pData)
return NULL;
diff --git a/sc/source/ui/unoobj/datauno.cxx b/sc/source/ui/unoobj/datauno.cxx
index 59ede6d..8da9833 100644
--- a/sc/source/ui/unoobj/datauno.cxx
+++ b/sc/source/ui/unoobj/datauno.cxx
@@ -2295,7 +2295,8 @@ uno::Any SAL_CALL ScDatabaseRangesObj::getByIndex( sal_Int32 nIndex )
lang::WrappedTargetException, uno::RuntimeException)
{
SolarMutexGuard aGuard;
- if (nIndex < 0 || nIndex > ::std::numeric_limits<size_t>::max())
+ sal_Int32 nUpper = ::std::numeric_limits<size_t>::max();
+ if (nIndex < 0 || nIndex > nUpper)
throw lang::IndexOutOfBoundsException();
uno::Reference<sheet::XDatabaseRange> xRange(GetObjectByIndex_Impl(static_cast<size_t>(nIndex)));
commit 0f7a6212c97af6f3638a7042e648328ebd893d99
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Fri May 13 18:19:51 2011 -0400
Shift method declarations to the left.
Horizontal space is precious. Let's not waste it.
diff --git a/sc/inc/dbcolect.hxx b/sc/inc/dbcolect.hxx
index 71a1e49..c766793 100644
--- a/sc/inc/dbcolect.hxx
+++ b/sc/inc/dbcolect.hxx
@@ -84,78 +84,78 @@ public:
bool operator() (const ScDBData& left, const ScDBData& right) const;
};
- SC_DLLPUBLIC ScDBData(const ::rtl::OUString& rName,
- SCTAB nTab,
- 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);
-
- bool operator== (const ScDBData& rData) const;
-
- SCTAB GetTable() const;
- const ::rtl::OUString& GetName() const { return aName; }
- 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);
- void MoveTo(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
- bool IsByRow() const { return bByRow; }
- void SetByRow(bool bByR) { bByRow = bByR; }
- bool HasHeader() const { return bHasHeader; }
- void SetHeader(bool bHasH) { bHasHeader = bHasH; }
- void SetIndex(sal_uInt16 nInd) { nIndex = nInd; }
- sal_uInt16 GetIndex() const { return nIndex; }
- bool IsDoSize() const { return bDoSize; }
- void SetDoSize(bool bSet) { bDoSize = bSet; }
- bool IsKeepFmt() const { return bKeepFmt; }
- void SetKeepFmt(bool bSet) { bKeepFmt = bSet; }
- bool IsStripData() const { return bStripData; }
- void SetStripData(bool bSet) { bStripData = bSet; }
-
- ::rtl::OUString GetSourceString() const;
- ::rtl::OUString GetOperations() const;
-
- void GetSortParam(ScSortParam& rSortParam) const;
- void SetSortParam(const ScSortParam& rSortParam);
-
- SC_DLLPUBLIC void GetQueryParam(ScQueryParam& rQueryParam) const;
- SC_DLLPUBLIC void SetQueryParam(const ScQueryParam& rQueryParam);
- SC_DLLPUBLIC bool GetAdvancedQuerySource(ScRange& rSource) const;
- SC_DLLPUBLIC void SetAdvancedQuerySource(const ScRange* pSource);
-
- void GetSubTotalParam(ScSubTotalParam& rSubTotalParam) const;
- void SetSubTotalParam(const ScSubTotalParam& rSubTotalParam);
-
- void GetImportParam(ScImportParam& rImportParam) const;
- void SetImportParam(const ScImportParam& rImportParam);
-
- bool IsDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly) const;
- bool IsDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const;
-
- bool HasImportParam() const { return maImportParam.bImport; }
- SC_DLLPUBLIC bool HasQueryParam() const;
- bool HasSortParam() const { return maSortParam.bDoSort[0]; }
- bool HasSubTotalParam() const { return maSubTotal.bGroupActive[0]; }
-
- bool HasImportSelection() const { return bDBSelection; }
- void SetImportSelection(bool bSet) { bDBSelection = bSet; }
-
- bool HasAutoFilter() const { return bAutoFilter; }
- void SetAutoFilter(bool bSet) { bAutoFilter = bSet; }
-
- bool IsModified() const { return bModified; }
- void SetModified(bool bMod) { bModified = bMod; }
-
- void UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos );
- void UpdateReference(ScDocument* pDoc, UpdateRefMode eUpdateRefMode,
- SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
- SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
- SCsCOL nDx, SCsROW nDy, SCsTAB nDz);
+ SC_DLLPUBLIC ScDBData(const ::rtl::OUString& rName,
+ SCTAB nTab,
+ 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);
+
+ bool operator== (const ScDBData& rData) const;
+
+ SCTAB GetTable() const;
+ const ::rtl::OUString& GetName() const { return aName; }
+ 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);
+ void MoveTo(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
+ bool IsByRow() const { return bByRow; }
+ void SetByRow(bool bByR) { bByRow = bByR; }
+ bool HasHeader() const { return bHasHeader; }
+ void SetHeader(bool bHasH) { bHasHeader = bHasH; }
+ void SetIndex(sal_uInt16 nInd) { nIndex = nInd; }
+ sal_uInt16 GetIndex() const { return nIndex; }
+ bool IsDoSize() const { return bDoSize; }
+ void SetDoSize(bool bSet) { bDoSize = bSet; }
+ bool IsKeepFmt() const { return bKeepFmt; }
+ void SetKeepFmt(bool bSet) { bKeepFmt = bSet; }
+ bool IsStripData() const { return bStripData; }
+ void SetStripData(bool bSet) { bStripData = bSet; }
+
+ ::rtl::OUString GetSourceString() const;
+ ::rtl::OUString GetOperations() const;
+
+ void GetSortParam(ScSortParam& rSortParam) const;
+ void SetSortParam(const ScSortParam& rSortParam);
+
+ SC_DLLPUBLIC void GetQueryParam(ScQueryParam& rQueryParam) const;
+ SC_DLLPUBLIC void SetQueryParam(const ScQueryParam& rQueryParam);
+ SC_DLLPUBLIC bool GetAdvancedQuerySource(ScRange& rSource) const;
+ SC_DLLPUBLIC void SetAdvancedQuerySource(const ScRange* pSource);
+
+ void GetSubTotalParam(ScSubTotalParam& rSubTotalParam) const;
+ void SetSubTotalParam(const ScSubTotalParam& rSubTotalParam);
+
+ void GetImportParam(ScImportParam& rImportParam) const;
+ void SetImportParam(const ScImportParam& rImportParam);
+
+ bool IsDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly) const;
+ bool IsDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const;
+
+ bool HasImportParam() const { return maImportParam.bImport; }
+ SC_DLLPUBLIC bool HasQueryParam() const;
+ bool HasSortParam() const { return maSortParam.bDoSort[0]; }
+ bool HasSubTotalParam() const { return maSubTotal.bGroupActive[0]; }
+
+ bool HasImportSelection() const { return bDBSelection; }
+ void SetImportSelection(bool bSet) { bDBSelection = bSet; }
+
+ bool HasAutoFilter() const { return bAutoFilter; }
+ void SetAutoFilter(bool bSet) { bAutoFilter = bSet; }
+
+ bool IsModified() const { return bModified; }
+ void SetModified(bool bMod) { bModified = bMod; }
+
+ void UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos );
+ void UpdateReference(ScDocument* pDoc, UpdateRefMode eUpdateRefMode,
+ SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
+ SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
+ SCsCOL nDx, SCsROW nDy, SCsTAB nDz);
- void ExtendDataArea(ScDocument* pDoc);
+ void ExtendDataArea(ScDocument* pDoc);
};
class SC_DLLPUBLIC ScDBCollection
commit 08bd050a71e1cb1bbdd2b70de0c82b13446b9ce0
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Thu May 12 16:26:26 2011 -0400
Fixed the fallout of the changes in ScDBCollection.
diff --git a/sc/inc/arealink.hxx b/sc/inc/arealink.hxx
index 38efaaa..80ecc70 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 5fcc6dc..407b580 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 7d43e4f..53457bf 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 5dfc8e0..71a1e49 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 4c7202b..a7f4452 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 9db1155..41fd294 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 8da2976..bbd8f2c 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 3e86a75..a40ee81 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 53b1461..3e8c2c5 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 fd69039..99dbd2a 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 7ebcb9f..2b8bab7 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 d8b55f8..64e055c 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 bfe5b6b..9abbcb1 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 dc3e93f..ff8866b 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 e01e3bd..2abcbe2 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 2b5ae66..7d3608f 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 e4d7813..bb726dd 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 7e91218..741032c 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 4a5eecb..c959796 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 a293c22..de04792 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 f07ed12..571caed 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 695b834..09fd536 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 a6bc3f6..ce2abde 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;
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list