summaryrefslogtreecommitdiff
path: root/sc/source/core
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2013-10-03 14:24:28 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2013-10-04 19:15:24 -0400
commit875f47cb5a20e2ce6ed54d88fd5bbf1d6128a47d (patch)
treed052055b297e3c8de85390a85482202349731976 /sc/source/core
parentf6ec66727379fef56f0972e2a6181e39ab6d4ec1 (diff)
Add methods to turn cell strings into numeric IDs for comparison.
Both in case sensitive and case insensitive comparisons. Change-Id: I356a655273f0f37157810c86e1cf3f87ea2afa09
Diffstat (limited to 'sc/source/core')
-rw-r--r--sc/source/core/data/column3.cxx58
-rw-r--r--sc/source/core/data/documen2.cxx5
-rw-r--r--sc/source/core/data/document.cxx16
-rw-r--r--sc/source/core/data/table2.cxx16
4 files changed, 95 insertions, 0 deletions
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index f5eccae3daea..6c964ca060c6 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1732,6 +1732,64 @@ bool ScColumn::SetGroupFormulaCell( SCROW nRow, ScFormulaCell* pCell )
return true;
}
+sal_uIntPtr ScColumn::GetCellStringID( SCROW nRow ) const
+{
+ sc::CellStoreType::const_position_type aPos = maCells.position(nRow);
+ switch (aPos.first->type)
+ {
+ case sc::element_type_string:
+ {
+ const OUString& rStr = sc::string_block::at(*aPos.first->data, aPos.second);
+ return pDocument->GetCellStringPool().getIdentifier(rStr);
+ }
+ break;
+ case sc::element_type_edittext:
+ {
+ std::vector<sal_uIntPtr> aIDs;
+ const EditTextObject* pObj = sc::edittext_block::at(*aPos.first->data, aPos.second);
+ pObj->GetStringIDs(pDocument->GetCellStringPool(), aIDs);
+ if (aIDs.size() != 1)
+ // We don't handle multiline content for now.
+ return 0;
+
+ return aIDs[0];
+ }
+ break;
+ default:
+ ;
+ }
+ return 0;
+}
+
+sal_uIntPtr ScColumn::GetCellStringIDIgnoreCase( SCROW nRow ) const
+{
+ sc::CellStoreType::const_position_type aPos = maCells.position(nRow);
+ switch (aPos.first->type)
+ {
+ case sc::element_type_string:
+ {
+ const OUString& rStr = sc::string_block::at(*aPos.first->data, aPos.second);
+ return pDocument->GetCellStringPool().getIdentifierIgnoreCase(rStr);
+ }
+ break;
+ case sc::element_type_edittext:
+ {
+ std::vector<sal_uIntPtr> aIDs;
+ const EditTextObject* pObj = sc::edittext_block::at(*aPos.first->data, aPos.second);
+ pObj->GetStringIDsIgnoreCase(pDocument->GetCellStringPool(), aIDs);
+ if (aIDs.size() != 1)
+ // We don't handle multiline content for now.
+ return 0;
+
+ return aIDs[0];
+ }
+ break;
+ default:
+ ;
+ }
+ return 0;
+}
+
namespace {
class FilterEntriesHandler
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 9f640903d7a4..ea00606ea08d 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -605,6 +605,11 @@ svl::StringPool& ScDocument::GetCellStringPool()
return *mpCellStringPool;
}
+const svl::StringPool& ScDocument::GetCellStringPool() const
+{
+ return *mpCellStringPool;
+}
+
bool ScDocument::GetPrintArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow,
bool bNotes ) const
{
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index dc7db440e954..9b91290ba911 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -3221,6 +3221,22 @@ double* ScDocument::GetValueCell( const ScAddress& rPos )
return maTabs[rPos.Tab()]->GetValueCell(rPos.Col(), rPos.Row());
}
+sal_uIntPtr ScDocument::GetCellStringID( const ScAddress& rPos ) const
+{
+ if (!TableExists(rPos.Tab()))
+ return 0;
+
+ return maTabs[rPos.Tab()]->GetCellStringID(rPos.Col(), rPos.Row());
+}
+
+sal_uIntPtr ScDocument::GetCellStringIDIgnoreCase( const ScAddress& rPos ) const
+{
+ if (!TableExists(rPos.Tab()))
+ return 0;
+
+ return maTabs[rPos.Tab()]->GetCellStringIDIgnoreCase(rPos.Col(), rPos.Row());
+}
+
void ScDocument::GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab, OUString& rString )
{
if ( ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] )
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 24fc92be08a7..9ec6977d9636 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1505,6 +1505,22 @@ bool ScTable::SetGroupFormulaCell( SCCOL nCol, SCROW nRow, ScFormulaCell* pCell
return aCol[nCol].SetGroupFormulaCell(nRow, pCell);
}
+sal_uIntPtr ScTable::GetCellStringID( SCCOL nCol, SCROW nRow ) const
+{
+ if (!ValidColRow(nCol, nRow))
+ return 0;
+
+ return aCol[nCol].GetCellStringID(nRow);
+}
+
+sal_uIntPtr ScTable::GetCellStringIDIgnoreCase( SCCOL nCol, SCROW nRow ) const
+{
+ if (!ValidColRow(nCol, nRow))
+ return 0;
+
+ return aCol[nCol].GetCellStringIDIgnoreCase(nRow);
+}
+
void ScTable::SetValue( SCCOL nCol, SCROW nRow, const double& rVal )
{
if (ValidColRow(nCol, nRow))