From 4bc49565331c931f0efb3590db76267a5c911053 Mon Sep 17 00:00:00 2001 From: László Németh Date: Thu, 19 Feb 2015 15:36:26 +0100 Subject: 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 Tested-by: Eike Rathke --- sc/qa/unit/ucalc.cxx | 34 ++++++++++++++++++++++++++++++++++ sc/qa/unit/ucalc.hxx | 2 ++ 2 files changed, 36 insertions(+) (limited to 'sc/qa') 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(nCol1)); + CPPUNIT_ASSERT_EQUAL(aChecks[nCheckPos][1], static_cast(nCol2)); + CPPUNIT_ASSERT_EQUAL(aChecks[nCheckPos][2], static_cast(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); -- cgit v1.2.3