summaryrefslogtreecommitdiff
path: root/sc/source/core
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2015-09-02 15:58:07 +0200
committerEike Rathke <erack@redhat.com>2015-09-02 16:10:34 +0200
commit26e84b3852bbb9585fab76e8d3dba5dcd77f0357 (patch)
tree809407dc6eba799715c69b56f757cc431ec24a94 /sc/source/core
parentc4afb5d19342d249fae841c24575a5f9ecacdfe2 (diff)
TableRef: introduce ScDBDataPortion enum
... to replace * bool bStartonly=false with ScDBDataPortion::AREA * bool bStartonly=true with ScDBDataPortion::TOP_LEFT and provide means to look at header row only with ScDBDataPortion::HEADER as needed for TableRef. Change-Id: I9f6affd04c15a6204193687b2379160eb975f56e
Diffstat (limited to 'sc/source/core')
-rw-r--r--sc/source/core/data/documen3.cxx12
-rw-r--r--sc/source/core/tool/compiler.cxx2
-rw-r--r--sc/source/core/tool/dbdata.cxx45
3 files changed, 32 insertions, 27 deletions
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index 2b8dc9afa57c..32791dab34d1 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -281,18 +281,18 @@ void ScDocument::SetDBCollection( ScDBCollection* pNewDBCollection, bool bRemove
pDBCollection = pNewDBCollection;
}
-const ScDBData* ScDocument::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly) const
+const ScDBData* ScDocument::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion ePortion) const
{
if (pDBCollection)
- return pDBCollection->GetDBAtCursor(nCol, nRow, nTab, bStartOnly);
+ return pDBCollection->GetDBAtCursor(nCol, nRow, nTab, ePortion);
else
return NULL;
}
-ScDBData* ScDocument::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly)
+ScDBData* ScDocument::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion ePortion)
{
if (pDBCollection)
- return pDBCollection->GetDBAtCursor(nCol, nRow, nTab, bStartOnly);
+ return pDBCollection->GetDBAtCursor(nCol, nRow, nTab, ePortion);
else
return NULL;
}
@@ -1413,7 +1413,7 @@ bool ScDocument::CreateQueryParam(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW n
bool ScDocument::HasAutoFilter( SCCOL nCurCol, SCROW nCurRow, SCTAB nCurTab )
{
- const ScDBData* pDBData = GetDBAtCursor( nCurCol, nCurRow, nCurTab );
+ const ScDBData* pDBData = GetDBAtCursor( nCurCol, nCurRow, nCurTab, ScDBDataPortion::AREA );
bool bHasAutoFilter = (pDBData != NULL);
if ( pDBData )
@@ -1465,7 +1465,7 @@ bool ScDocument::GetFilterEntries(
{
if ( ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] && pDBCollection )
{
- ScDBData* pDBData = pDBCollection->GetDBAtCursor(nCol, nRow, nTab, false); //!??
+ ScDBData* pDBData = pDBCollection->GetDBAtCursor(nCol, nRow, nTab, ScDBDataPortion::AREA); //!??
if (pDBData)
{
pDBData->ExtendDataArea(this);
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index a166a41a5807..67cf1d7c11e2 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -4705,7 +4705,7 @@ void ScCompiler::CreateStringFromSingleRef( OUStringBuffer& rBuffer, const Formu
if (aStr.isEmpty())
{
// Hope that there's still the original column name available.
- const ScDBData* pData = pDoc->GetDBAtCursor( aAbs.Col(), aAbs.Row(), aAbs.Tab());
+ const ScDBData* pData = pDoc->GetDBAtCursor( aAbs.Col(), aAbs.Row(), aAbs.Tab(), ScDBDataPortion::HEADER);
if (pData)
aStr = pData->GetTableColumnName( aAbs.Col());
}
diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx
index f9c69b20d338..825e6ca51124 100644
--- a/sc/source/core/tool/dbdata.cxx
+++ b/sc/source/core/tool/dbdata.cxx
@@ -430,15 +430,19 @@ void ScDBData::SetImportParam(const ScImportParam& rImportParam)
mpImportParam.reset(new ScImportParam(rImportParam));
}
-bool ScDBData::IsDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly) const
+bool ScDBData::IsDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion ePortion) const
{
if (nTab == nTable)
{
- if ( bStartOnly )
- return ( nCol == nStartCol && nRow == nStartRow );
- else
- return ( nCol >= nStartCol && nCol <= nEndCol &&
- nRow >= nStartRow && nRow <= nEndRow );
+ switch (ePortion)
+ {
+ case ScDBDataPortion::TOP_LEFT:
+ return nCol == nStartCol && nRow == nStartRow;
+ case ScDBDataPortion::HEADER:
+ return HasHeader() && nRow == nStartRow && nCol >= nStartCol && nCol <= nEndCol;
+ case ScDBDataPortion::AREA:
+ return nCol >= nStartCol && nCol <= nEndCol && nRow >= nStartRow && nRow <= nEndRow;
+ }
}
return false;
@@ -812,14 +816,14 @@ class FindByCursor : public unary_function<std::unique_ptr<ScDBData>, bool>
SCCOL mnCol;
SCROW mnRow;
SCTAB mnTab;
- bool mbStartOnly;
+ ScDBDataPortion mePortion;
public:
- FindByCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly) :
- mnCol(nCol), mnRow(nRow), mnTab(nTab), mbStartOnly(bStartOnly) {}
+ FindByCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion ePortion) :
+ mnCol(nCol), mnRow(nRow), mnTab(nTab), mePortion(ePortion) {}
bool operator() (std::unique_ptr<ScDBData> const& p)
{
- return p->IsDBAtCursor(mnCol, mnRow, mnTab, mbStartOnly);
+ return p->IsDBAtCursor(mnCol, mnRow, mnTab, mePortion);
}
};
@@ -980,10 +984,11 @@ ScDBCollection::AnonDBs::const_iterator ScDBCollection::AnonDBs::end() const
return m_DBs.end();
}
-const ScDBData* ScDBCollection::AnonDBs::findAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly) const
+const ScDBData* ScDBCollection::AnonDBs::findAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab,
+ ScDBDataPortion ePortion) const
{
DBsType::const_iterator itr = find_if(
- m_DBs.begin(), m_DBs.end(), FindByCursor(nCol, nRow, nTab, bStartOnly));
+ m_DBs.begin(), m_DBs.end(), FindByCursor(nCol, nRow, nTab, ePortion));
return itr == m_DBs.end() ? nullptr : itr->get();
}
@@ -1062,22 +1067,22 @@ ScDBCollection::ScDBCollection(ScDocument* pDocument) :
ScDBCollection::ScDBCollection(const ScDBCollection& r) :
pDoc(r.pDoc), nEntryIndex(r.nEntryIndex), maNamedDBs(r.maNamedDBs), maAnonDBs(r.maAnonDBs) {}
-const ScDBData* ScDBCollection::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly) const
+const ScDBData* ScDBCollection::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion ePortion) const
{
// First, search the global named db ranges.
NamedDBs::DBsType::const_iterator itr = find_if(
- maNamedDBs.begin(), maNamedDBs.end(), FindByCursor(nCol, nRow, nTab, bStartOnly));
+ maNamedDBs.begin(), maNamedDBs.end(), FindByCursor(nCol, nRow, nTab, ePortion));
if (itr != maNamedDBs.end())
return itr->get();
// Check for the sheet-local anonymous db range.
const ScDBData* pNoNameData = pDoc->GetAnonymousDBData(nTab);
if (pNoNameData)
- if (pNoNameData->IsDBAtCursor(nCol,nRow,nTab,bStartOnly))
+ if (pNoNameData->IsDBAtCursor(nCol,nRow,nTab,ePortion))
return pNoNameData;
// Check the global anonymous db ranges.
- const ScDBData* pData = getAnonDBs().findAtCursor(nCol, nRow, nTab, bStartOnly);
+ const ScDBData* pData = getAnonDBs().findAtCursor(nCol, nRow, nTab, ePortion);
if (pData)
return pData;
@@ -1086,22 +1091,22 @@ const ScDBData* ScDBCollection::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab
return NULL;
}
-ScDBData* ScDBCollection::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly)
+ScDBData* ScDBCollection::GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion ePortion)
{
// First, search the global named db ranges.
NamedDBs::DBsType::iterator itr = find_if(
- maNamedDBs.begin(), maNamedDBs.end(), FindByCursor(nCol, nRow, nTab, bStartOnly));
+ maNamedDBs.begin(), maNamedDBs.end(), FindByCursor(nCol, nRow, nTab, ePortion));
if (itr != maNamedDBs.end())
return itr->get();
// Check for the sheet-local anonymous db range.
ScDBData* pNoNameData = pDoc->GetAnonymousDBData(nTab);
if (pNoNameData)
- if (pNoNameData->IsDBAtCursor(nCol,nRow,nTab,bStartOnly))
+ if (pNoNameData->IsDBAtCursor(nCol,nRow,nTab,ePortion))
return pNoNameData;
// Check the global anonymous db ranges.
- const ScDBData* pData = getAnonDBs().findAtCursor(nCol, nRow, nTab, bStartOnly);
+ const ScDBData* pData = getAnonDBs().findAtCursor(nCol, nRow, nTab, ePortion);
if (pData)
return const_cast<ScDBData*>(pData);