diff options
author | László Németh <laszlo.nemeth@collabora.com> | 2015-02-19 15:36:26 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2015-02-21 01:35:21 +0000 |
commit | 4bc49565331c931f0efb3590db76267a5c911053 (patch) | |
tree | 9b51b29659425d645d6e61d04db03d818fe5033d /sc/qa | |
parent | c8a3a730c5c1430ea40ad1495ac2c8ff7303a200 (diff) |
tdf#89436 fix ScHorizontalAttrIterator performance
(cherry picked from master:
d619d23a1f641fc910723cc32c4d8c8d9a8f3681 add unit test
8e9540d3d4909c6dd45c9efa294f565d9735a0d9 fix indices
dd4bd0ee74fae3d7e3a16e018021da173152571b fix condition + cleanup
a5ab0e3a8b1cb7c06072229e1c4d956eb81fa002 handle skipping empty rows
4de4f1fd1125bc8cf6059cf143bb76d1ab212434 fix ScHorizontalAttrIterator performance)
Change-Id: Ieda6f3171c5e81d1029746fedd320d7caa7db676
Reviewed-on: https://gerrit.libreoffice.org/14526
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc/qa')
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 34 | ||||
-rw-r--r-- | sc/qa/unit/ucalc.hxx | 2 |
2 files changed, 36 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 49027cf34383..ce5efc2daf11 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -1223,6 +1223,40 @@ void Test::testValueIterator() m_pDoc->DeleteTab(0); } +void Test::testHorizontalAttrIterator() +{ + m_pDoc->InsertTab(0, "Test"); + + // Set the background color of B2:C3 to blue + ScPatternAttr aCellBackColor(m_pDoc->GetPool()); + aCellBackColor.GetItemSet().Put(SvxBrushItem(COL_BLUE, ATTR_BACKGROUND)); + m_pDoc->ApplyPatternAreaTab(1, 1, 2, 2, 0, aCellBackColor); + + // some numeric data + for (SCCOL i = 1; i <= 4; ++i) + for (SCROW j = 1; j <= 4; ++j) + m_pDoc->SetValue(ScAddress(i,j,0), i*10+j); + + { + const int aChecks[][3] = { {1, 2, 1}, {1, 2, 2} }; + size_t nCheckLen = SAL_N_ELEMENTS(aChecks); + + ScHorizontalAttrIterator aIter(m_pDoc, 0, 0, 0, 3, 3); + SCCOL nCol1, nCol2; + SCROW nRow; + size_t nCheckPos = 0; + for (const ScPatternAttr* pAttr = aIter.GetNext(nCol1, nCol2, nRow); pAttr; pAttr = aIter.GetNext(nCol1, nCol2, nRow), ++nCheckPos) + { + CPPUNIT_ASSERT_MESSAGE("Iteration longer than expected.", nCheckPos < nCheckLen); + CPPUNIT_ASSERT_EQUAL(aChecks[nCheckPos][0], static_cast<int>(nCol1)); + CPPUNIT_ASSERT_EQUAL(aChecks[nCheckPos][1], static_cast<int>(nCol2)); + CPPUNIT_ASSERT_EQUAL(aChecks[nCheckPos][2], static_cast<int>(nRow)); + } + } + + m_pDoc->DeleteTab(0); +} + namespace { bool broadcasterShifted(const ScDocument& rDoc, const ScAddress& rFrom, const ScAddress& rTo) diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index 19b3b5f31952..28e0e013d33e 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -184,6 +184,7 @@ public: void testHorizontalIterator(); void testValueIterator(); + void testHorizontalAttrIterator(); /** * Basic test for formula dependency tracking. @@ -486,6 +487,7 @@ public: CPPUNIT_TEST(testFuncNOW); CPPUNIT_TEST(testHorizontalIterator); CPPUNIT_TEST(testValueIterator); + CPPUNIT_TEST(testHorizontalAttrIterator); CPPUNIT_TEST(testFormulaDepTracking); CPPUNIT_TEST(testFormulaDepTracking2); CPPUNIT_TEST(testFormulaDepTracking3); |