[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - 3 commits - sc/inc sc/Module_sc.mk sc/qa sc/source
Kohei Yoshida
kohei.yoshida at gmail.com
Tue Jun 18 17:33:04 PDT 2013
sc/Module_sc.mk | 2 -
sc/inc/mtvcellfunc.hxx | 12 +++++++
sc/inc/mtvelements.hxx | 2 -
sc/qa/unit/ucalc.cxx | 60 +++++++++++++++++++++------------------
sc/source/core/data/column2.cxx | 3 +
sc/source/core/data/dociter.cxx | 2 -
sc/source/core/data/fillinfo.cxx | 8 ++++-
sc/source/core/tool/interpr1.cxx | 1
8 files changed, 57 insertions(+), 33 deletions(-)
New commits:
commit 814ef226e702ed02e0df8e75ffdaf5c8cff9d9f4
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Tue Jun 18 19:36:58 2013 -0400
Don't bail out on good condition.
It's a good thing to have found a table to work on.
Change-Id: I9b42ebb20041756b6086490dac4264d17369f83f
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 2d6a8eb..ab0035f 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -301,7 +301,7 @@ bool ScValueIterator::GetFirst(double& rValue, sal_uInt16& rErr)
mnTab = maStartPos.Tab();
ScTable* pTab = pDoc->FetchTable(mnTab);
- if (pTab)
+ if (!pTab)
return false;
nNumFormat = 0; // Initialized in GetNumberFormat
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 53db8dc..c03556f 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -3982,7 +3982,6 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero )
{
switch (GetStackType())
{
-
case svString:
{
if( eFunc == ifCOUNT )
commit c44e14e7d2595cba5017db798c46e3deda4870f7
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Tue Jun 18 19:18:17 2013 -0400
Leave the RowInfo's for empty cells unfilled.
Else empty cell regions would get skipped and the non-empty cells
would get displayed at incorrect row positions.
Change-Id: Ica8d1c654458e0ea508e8f00846180d89bfe8804
diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index 0b3970f..74888f0 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -37,8 +37,6 @@ endif
$(eval $(call gb_Module_add_check_targets,sc,\
CppunitTest_sc_ucalc \
- CppunitTest_sc_filters_test \
- CppunitTest_sc_rangelst_test \
))
$(eval $(call gb_Module_add_slowcheck_targets,sc, \
diff --git a/sc/inc/mtvcellfunc.hxx b/sc/inc/mtvcellfunc.hxx
index 9ce3c12..c54d02e 100644
--- a/sc/inc/mtvcellfunc.hxx
+++ b/sc/inc/mtvcellfunc.hxx
@@ -112,6 +112,18 @@ ParseAllNonEmpty(
itPos, rCells, nRow1, nRow2, rFunc, aElse);
}
+template<typename _FuncElem, typename _FuncElse>
+typename CellStoreType::const_iterator
+ParseAllNonEmpty(
+ const typename CellStoreType::const_iterator& itPos, const CellStoreType& rCells,
+ SCROW nRow1, SCROW nRow2, _FuncElem& rFuncElem, _FuncElse& rFuncElse)
+{
+ return ParseElements4<CellStoreType,
+ numeric_block, string_block, edittext_block, formula_block,
+ _FuncElem, _FuncElse>(
+ itPos, rCells, nRow1, nRow2, rFuncElem, rFuncElse);
+}
+
template<typename _Func>
typename CellStoreType::const_iterator
ParseFormulaNumeric(
diff --git a/sc/inc/mtvelements.hxx b/sc/inc/mtvelements.hxx
index 0ebf8be..2c58997 100644
--- a/sc/inc/mtvelements.hxx
+++ b/sc/inc/mtvelements.hxx
@@ -15,7 +15,7 @@
#include "svl/broadcast.hxx"
#include "editeng/editobj.hxx"
-#define DEBUG_COLUMN_STORAGE 0
+#define DEBUG_COLUMN_STORAGE 1
#if DEBUG_COLUMN_STORAGE
#ifdef NDEBUG
diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx
index c64a54d..7f73391 100644
--- a/sc/source/core/data/fillinfo.cxx
+++ b/sc/source/core/data/fillinfo.cxx
@@ -189,6 +189,12 @@ public:
if (!isHidden(nRow))
setInfo(ScRefCellValue(const_cast<ScFormulaCell*>(p)));
}
+
+ void operator() (mdds::mtv::element_t, size_t, size_t nDataSize)
+ {
+ // Skip all empty cells.
+ mrArrY += nDataSize;
+ }
};
}
@@ -430,7 +436,7 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX
// cells that are not hidden.
RowInfoFiller aFunc(*this, nTab, pRowInfo, nArrX, nArrY);
sc::ParseAllNonEmpty(
- pThisCol->maCells.begin(), pThisCol->maCells, nY1, nY2, aFunc);
+ pThisCol->maCells.begin(), pThisCol->maCells, nY1, nY2, aFunc, aFunc);
if (nX+1 >= nX1) // Attribute/Blockmarken ab nX1-1
{
commit 10b8123d4758c25d5abfd25092f4c31a7e48720b
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Tue Jun 18 18:57:16 2013 -0400
Fix a bug in the find area position code for the upward direction.
And a test to catch it.
Change-Id: I7582b5bca5309f247b44e8cbaa29feda838e6d99
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index fde5c16..76e5aa2 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -78,7 +78,7 @@
#include <vector>
#define CALC_DEBUG_OUTPUT 0
-#define CALC_TEST_PERF 1
+#define CALC_TEST_PERF 0
#include "helper/debughelper.hxx"
#include "helper/qahelper.hxx"
@@ -258,7 +258,7 @@ public:
void testCopyPasteFormulas();
void testCopyPasteFormulasExternalDoc();
- void testFindAreaPosRowDown();
+ void testFindAreaPosVertical();
void testFindAreaPosColRight();
void testSort();
void testSortWithFormulaRefs();
@@ -331,7 +331,7 @@ public:
CPPUNIT_TEST(testAutoFill);
CPPUNIT_TEST(testCopyPasteFormulas);
CPPUNIT_TEST(testCopyPasteFormulasExternalDoc);
- CPPUNIT_TEST(testFindAreaPosRowDown);
+ CPPUNIT_TEST(testFindAreaPosVertical);
CPPUNIT_TEST(testFindAreaPosColRight);
CPPUNIT_TEST(testSort);
CPPUNIT_TEST(testSortWithFormulaRefs);
@@ -6334,52 +6334,51 @@ void Test::testCopyPasteFormulasExternalDoc()
CPPUNIT_ASSERT_EQUAL(aFormula, OUString("=$ExtSheet2.$B$2"));
}
-void Test::testFindAreaPosRowDown()
+void Test::testFindAreaPosVertical()
{
- const char* aData[][2] = {
- { "", "1" },
- { "1", "" },
- { "1", "1" },
- { "", "1" },
- { "1", "1" },
- { "1", "" },
- { "1", "1" }, };
+ const char* aData[][3] = {
+ { 0, "1", "1" },
+ { "1", 0, "1" },
+ { "1", "1", "1" },
+ { 0, "1", "1" },
+ { "1", "1", "1" },
+ { "1", 0, "1" },
+ { "1", "1", "1" },
+ };
- ScDocument* pDoc = m_xDocShRef->GetDocument();
- OUString aTabName1("test1");
- pDoc->InsertTab(0, aTabName1);
- clearRange( pDoc, ScRange(0, 0, 0, 1, SAL_N_ELEMENTS(aData), 0));
+ m_pDoc->InsertTab(0, "Test1");
+ clearRange( m_pDoc, ScRange(0, 0, 0, 1, SAL_N_ELEMENTS(aData), 0));
ScAddress aPos(0,0,0);
- ScRange aDataRange = insertRangeData( pDoc, aPos, aData, SAL_N_ELEMENTS(aData));
+ ScRange aDataRange = insertRangeData( m_pDoc, aPos, aData, SAL_N_ELEMENTS(aData));
CPPUNIT_ASSERT_MESSAGE("failed to insert range data at correct position", aDataRange.aStart == aPos);
- pDoc->SetRowHidden(4,4,0,true);
- bool bHidden = pDoc->RowHidden(4,0);
+ m_pDoc->SetRowHidden(4,4,0,true);
+ bool bHidden = m_pDoc->RowHidden(4,0);
CPPUNIT_ASSERT(bHidden);
SCCOL nCol = 0;
SCROW nRow = 0;
- pDoc->FindAreaPos(nCol, nRow, 0, SC_MOVE_DOWN);
+ m_pDoc->FindAreaPos(nCol, nRow, 0, SC_MOVE_DOWN);
CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(1), nRow);
CPPUNIT_ASSERT_EQUAL(static_cast<SCCOL>(0), nCol);
- pDoc->FindAreaPos(nCol, nRow, 0, SC_MOVE_DOWN);
+ m_pDoc->FindAreaPos(nCol, nRow, 0, SC_MOVE_DOWN);
CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(2), nRow);
CPPUNIT_ASSERT_EQUAL(static_cast<SCCOL>(0), nCol);
- pDoc->FindAreaPos(nCol, nRow, 0, SC_MOVE_DOWN);
+ m_pDoc->FindAreaPos(nCol, nRow, 0, SC_MOVE_DOWN);
CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(5), nRow);
CPPUNIT_ASSERT_EQUAL(static_cast<SCCOL>(0), nCol);
- pDoc->FindAreaPos(nCol, nRow, 0, SC_MOVE_DOWN);
+ m_pDoc->FindAreaPos(nCol, nRow, 0, SC_MOVE_DOWN);
CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(6), nRow);
CPPUNIT_ASSERT_EQUAL(static_cast<SCCOL>(0), nCol);
- pDoc->FindAreaPos(nCol, nRow, 0, SC_MOVE_DOWN);
+ m_pDoc->FindAreaPos(nCol, nRow, 0, SC_MOVE_DOWN);
CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(MAXROW), nRow);
CPPUNIT_ASSERT_EQUAL(static_cast<SCCOL>(0), nCol);
@@ -6387,17 +6386,24 @@ void Test::testFindAreaPosRowDown()
nCol = 1;
nRow = 2;
- pDoc->FindAreaPos(nCol, nRow, 0, SC_MOVE_DOWN);
+ m_pDoc->FindAreaPos(nCol, nRow, 0, SC_MOVE_DOWN);
CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(3), nRow);
CPPUNIT_ASSERT_EQUAL(static_cast<SCCOL>(1), nCol);
- pDoc->FindAreaPos(nCol, nRow, 0, SC_MOVE_DOWN);
+ m_pDoc->FindAreaPos(nCol, nRow, 0, SC_MOVE_DOWN);
CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(6), nRow);
CPPUNIT_ASSERT_EQUAL(static_cast<SCCOL>(1), nCol);
- pDoc->DeleteTab(0);
+ nCol = 2;
+ nRow = 6;
+ m_pDoc->FindAreaPos(nCol, nRow, 0, SC_MOVE_UP);
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(0), nRow);
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCCOL>(2), nCol);
+
+
+ m_pDoc->DeleteTab(0);
}
void Test::testFindAreaPosColRight()
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 65b6b82..0a7deac 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1971,6 +1971,9 @@ void ScColumn::FindDataAreaPos(SCROW& rRow, bool bDown) const
do
{
nNextRow = FindNextVisibleRow(nLastRow, bDown);
+ if (nNextRow == nLastRow)
+ break;
+
aPos = maCells.position(it, nNextRow);
it = aPos.first;
if (it->type != sc::element_type_empty)
More information about the Libreoffice-commits
mailing list