summaryrefslogtreecommitdiff
path: root/sc/qa
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2013-11-15 15:21:18 -0500
committerKohei Yoshida <kohei.yoshida@collabora.com>2013-11-18 17:25:38 -0500
commit24ddf0d93879cfa0d92b2144685960eed26116fb (patch)
tree87cc5919651c7a91b4260b74429ffd6fd9a0516f /sc/qa
parentb73b5750ed51acbb5076bc51159a2d6c87c69cbf (diff)
Handle named database ranges in CreateString().
Change-Id: I6904b9de0f7d711252797bb2e33ba4c462476b2d
Diffstat (limited to 'sc/qa')
-rw-r--r--sc/qa/unit/ucalc_formula.cxx29
1 files changed, 28 insertions, 1 deletions
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 43e0d1d0ab41..35a35996db7e 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -23,6 +23,7 @@
#include "docfunc.hxx"
#include "paramisc.hxx"
#include "tokenstringcontext.hxx"
+#include "dbdata.hxx"
#include "formula/vectortoken.hxx"
@@ -65,6 +66,31 @@ void Test::testFormulaCreateStringFromTokens()
CPPUNIT_ASSERT_MESSAGE("Failed to insert a new name.", bInserted);
}
+ // Insert DB ranges.
+ struct {
+ const char* pName;
+ SCTAB nTab;
+ SCCOL nCol1;
+ SCROW nRow1;
+ SCCOL nCol2;
+ SCROW nRow2;
+ } aDBs[] = {
+ { "Table1", 0, 0, 0, 10, 10 },
+ { "Table2", 1, 0, 0, 10, 10 },
+ { "Table3", 2, 0, 0, 10, 10 }
+ };
+
+ ScDBCollection* pDBs = m_pDoc->GetDBCollection();
+ CPPUNIT_ASSERT_MESSAGE("Failed to fetch DB collection object.", pDBs);
+
+ for (size_t i = 0, n = SAL_N_ELEMENTS(aDBs); i < n; ++i)
+ {
+ ScDBData* pData = new ScDBData(
+ OUString::createFromAscii(
+ aDBs[i].pName), aDBs[i].nTab, aDBs[i].nCol1, aDBs[i].nRow1, aDBs[i].nCol2,aDBs[i].nRow2);
+ pDBs->getNamedDBs().insert(pData);
+ }
+
const char* aTests[] = {
"1+2",
"SUM(A1:A10;B1:B10;C5;D6)",
@@ -72,7 +98,8 @@ void Test::testFormulaCreateStringFromTokens()
"AVERAGE('2013'.B10:C20)",
"'Kevin''s Data'.B10",
"'Past Data'.B1+'2013'.B2*(1+'Kevin''s Data'.C10)",
- "x+y*z"
+ "x+y*z", // named ranges
+ "MAX(Table1)+MIN(Table2)*SUM(Table3)" // database ranges
};
boost::scoped_ptr<ScTokenArray> pArray;