diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-11-15 10:37:26 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-11-18 17:25:37 -0500 |
commit | b8d4d3a59d022ee56b37a835ddb3a282344814e6 (patch) | |
tree | 8412075a484fd589b30a35bfd741094bf877ca75 /sc/qa | |
parent | b7fd06bf98fea63aab368b4d0968811bdec395c6 (diff) |
Handle global range names and use CreateString() during xlsx import.
This makes the load speed slightly faster.
Change-Id: I64e4d4b8c42a68577350539f3812cafdc0433f96
Diffstat (limited to 'sc/qa')
-rw-r--r-- | sc/qa/unit/ucalc_formula.cxx | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index 1f867f172ed7..43e0d1d0ab41 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -32,6 +32,7 @@ using namespace formula; void Test::testFormulaCreateStringFromTokens() { + // Insert sheets. OUString aTabName1("Test"); OUString aTabName2("Kevin's Data"); OUString aTabName3("Past Data"); @@ -41,19 +42,42 @@ void Test::testFormulaCreateStringFromTokens() m_pDoc->InsertTab(2, aTabName3); m_pDoc->InsertTab(3, aTabName4); + // Insert named ranges. + struct { + const char* pName; + const char* pExpr; + } aNames[] = { + { "x", "Test.H1" }, + { "y", "Test.H2" }, + { "z", "Test.H3" } + }; + + ScRangeName* pGlobalNames = m_pDoc->GetRangeName(); + CPPUNIT_ASSERT_MESSAGE("Failed to obtain global named expression object.", pGlobalNames); + + for (size_t i = 0, n = SAL_N_ELEMENTS(aNames); i < n; ++i) + { + ScRangeData* pName = new ScRangeData( + m_pDoc, OUString::createFromAscii(aNames[i].pName), OUString::createFromAscii(aNames[i].pExpr), + ScAddress(0,0,0), RT_NAME, formula::FormulaGrammar::GRAM_NATIVE); + + bool bInserted = pGlobalNames->insert(pName); + CPPUNIT_ASSERT_MESSAGE("Failed to insert a new name.", bInserted); + } + const char* aTests[] = { "1+2", "SUM(A1:A10;B1:B10;C5;D6)", "IF(Test.B10<>10;\"Good\";\"Bad\")", "AVERAGE('2013'.B10:C20)", "'Kevin''s Data'.B10", - "'Past Data'.B1+'2013'.B2*(1+'Kevin''s Data'.C10)" + "'Past Data'.B1+'2013'.B2*(1+'Kevin''s Data'.C10)", + "x+y*z" }; boost::scoped_ptr<ScTokenArray> pArray; - sc::TokenStringContext aCxt(formula::FormulaGrammar::GRAM_ENGLISH); - aCxt.maTabNames = m_pDoc->GetAllTableNames(); + sc::TokenStringContext aCxt(m_pDoc, formula::FormulaGrammar::GRAM_ENGLISH); ScAddress aPos(0,0,0); for (size_t i = 0, n = SAL_N_ELEMENTS(aTests); i < n; ++i) |