[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-2' - sc/inc sc/source
sc/inc/column.hxx |1 + sc/inc/document.hxx | 13 + sc/inc/table.hxx|2 +- sc/source/core/data/column2.cxx | 13 + sc/source/core/data/document.cxx|4 ++-- sc/source/core/data/formulacell.cxx |3 ++- sc/source/core/data/table1.cxx | 12 ++-- 7 files changed, 34 insertions(+), 14 deletions(-) New commits: commit 70a6fc011edda68d84aeadf2f5c006ec616b7340 Author: Kohei Yoshida Date: Tue Sep 10 11:16:22 2013 -0400 Add ability to specify starting row when querying for last non-empty row. And it can only go upwards from there. Change-Id: I4c8037f687dfdd0b6c937463696d628e78e4a8bf diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index f1b53c3..5ea06c6 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -182,6 +182,7 @@ public: bool HasVisibleDataAt(SCROW nRow) const; SCROW GetFirstDataPos() const; SCROW GetLastDataPos() const; +SCROW GetLastDataPos( SCROW nLastRow ) const; bool GetPrevDataPos(SCROW& rRow) const; bool GetNextDataPos(SCROW& rRow) const; void FindDataAreaPos(SCROW& rRow, bool bDown) const; // (without Broadcaster) diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 29fe96c..f6bdb33 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -1024,11 +1024,16 @@ public: SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly ) const; /** - * Return the last non-empty row position in given columns, or 0 if the - * columns are empty. A negative value is returned if the given sheet or - * column positions are invalid. + * Return the last non-empty row position in given columns that's no + * greater than the initial last row position, or 0 if the columns are + * empty. A negative value is returned if the given sheet or column + * positions are invalid. + * + * It starts from the specified last row position, and finds the first + * non-empty row position in the upward direction if the start row + * position is empty. */ -SCROW GetLastDataRow( SCTAB nTab, SCCOL nCol1, SCCOL nCol2 ) const; +SCROW GetLastDataRow( SCTAB nTab, SCCOL nCol1, SCCOL nCol2, SCROW nLastRow ) const; SC_DLLPUBLIC void GetDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow, bool bIncludeOld, bool bOnlyDown ) const; diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index 205df2c..8429c3e 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -470,7 +470,7 @@ public: boolShrinkToUsedDataArea( bool& o_bShrunk, SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly ) const; -SCROW GetLastDataRow( SCCOL nCol1, SCCOL nCol2 ) const; +SCROW GetLastDataRow( SCCOL nCol1, SCCOL nCol2, SCROW nLastRow ) const; SCSIZE GetEmptyLinesInBlock( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScDirection eDir ) const; diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index c846d62..3ab5e64 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -1281,6 +1281,19 @@ SCROW ScColumn::GetLastDataPos() const return MAXROW - static_cast(it->size); } +SCROW ScColumn::GetLastDataPos( SCROW nLastRow ) const +{ +sc::CellStoreType::const_position_type aPos = maCells.position(nLastRow); +if (aPos.first->type != sc::element_type_empty) +return nLastRow; + +if (aPos.first == maCells.begin()) +// This is the first block, and is empty. +return 0; + +return static_cast(aPos.first->position - 1); +} + bool ScColumn::GetPrevDataPos(SCROW& rRow) const { std::pair aPos = maCells.position(rRow); diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index e6fa7c4..eb7672a 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -1018,13 +1018,13 @@ bool ScDocument::ShrinkToUsedDataArea( bool& o_bShrunk, SCTAB nTab, SCCOL& rStar return maTabs[nTab]->ShrinkToUsedDataArea( o_bShrunk, rStartCol, rStartRow, rEndCol, rEndRow, bColumnsOnly); } -SCROW ScDocument::GetLastDataRow( SCTAB nTab, SCCOL nCol1, SCCOL nCol2 ) const +SCROW ScDocument::GetLastDataRow( SCTAB nTab, SCCOL nCol1, SCCOL nCol2, SCROW nLastRow ) const { const ScTable* pTab = FetchTable(nTab); if (!pTab) return -1; -return pTab->GetLastDataRow(nCol1, nCol2); +return pTab->GetLastDataRow(nCol1, nCol2, nLastRow); } // connected area diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 0a66ddc..7aad148 100644 --- a/sc/source/core/data/fo
[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-2' - sc/inc sc/source
sc/inc/token.hxx |7 ++ sc/inc/types.hxx |2 sc/source/core/data/types.cxx|7 +- sc/source/core/inc/interpre.hxx |1 sc/source/core/tool/interpr1.cxx | 121 ++- sc/source/core/tool/interpr4.cxx | 61 +-- sc/source/core/tool/token.cxx|7 ++ 7 files changed, 85 insertions(+), 121 deletions(-) New commits: commit d5aaf6a40a3ca04498e35885c386f38e01f83d46 Author: Kohei Yoshida Date: Fri Sep 6 01:18:26 2013 -0400 Wrong place to apply implicit intersection. Do it at the very last. Change-Id: I4b1e9d136d45f169ad1c1efee2275bab7dfe0f49 diff --git a/sc/inc/token.hxx b/sc/inc/token.hxx index 32cdf5a..a852dd8 100644 --- a/sc/inc/token.hxx +++ b/sc/inc/token.hxx @@ -36,6 +36,12 @@ // Matrix token constants. #define MATRIX_TOKEN_HAS_RANGE 1 +namespace sc { + +struct RangeMatrix; + +} + class ScJumpMatrix; typedef ::std::vector< ScComplexRefData > ScRefList; @@ -190,6 +196,7 @@ class ScMatrixRangeToken : public ScToken ScComplexRefData maRef; public: ScMatrixRangeToken( const ScMatrixRef& p, const ScComplexRefData& rRef ); +ScMatrixRangeToken( const sc::RangeMatrix& rMat ); ScMatrixRangeToken( const ScMatrixRangeToken& r ); virtual sal_uInt8 GetByte() const; diff --git a/sc/inc/types.hxx b/sc/inc/types.hxx index f03ccc0..045d6b1 100644 --- a/sc/inc/types.hxx +++ b/sc/inc/types.hxx @@ -68,8 +68,10 @@ struct RangeMatrix ScMatrixRef mpMat; sal_Int32 mnCol1; sal_Int32 mnRow1; +sal_Int32 mnTab1; sal_Int32 mnCol2; sal_Int32 mnRow2; +sal_Int32 mnTab2; RangeMatrix(); diff --git a/sc/source/core/data/types.cxx b/sc/source/core/data/types.cxx index 566d088..b45a0b1 100644 --- a/sc/source/core/data/types.cxx +++ b/sc/source/core/data/types.cxx @@ -12,11 +12,14 @@ namespace sc { -RangeMatrix::RangeMatrix() : mpMat(NULL), mnCol1(-1), mnRow1(-1), mnCol2(-1), mnRow2(-1) {} +RangeMatrix::RangeMatrix() : +mpMat(NULL), mnCol1(-1), mnRow1(-1), mnTab1(-1), mnCol2(-1), mnRow2(-1), mnTab2(-1) {} bool RangeMatrix::isRangeValid() const { -return mnCol1 >= 0 && mnRow1 >= 0 && mnCol2 >= 0 && mnRow2 >= 0 && mnCol1 <= mnCol2 && mnRow1 <= mnRow2; +return mnCol1 >= 0 && mnRow1 >= 0 && mnTab1 >=0 && +mnCol2 >= 0 && mnRow2 >= 0 && mnTab2 >= 0 && +mnCol1 <= mnCol2 && mnRow1 <= mnRow2 && mnTab1 <= mnTab2; } } diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx index bb9f919..b615b34 100644 --- a/sc/source/core/inc/interpre.hxx +++ b/sc/source/core/inc/interpre.hxx @@ -319,6 +319,7 @@ void PushExternalSingleRef(sal_uInt16 nFileId, const String& rTabName, void PushExternalDoubleRef(sal_uInt16 nFileId, const String& rTabName, SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2); +void PushMatrix( const sc::RangeMatrix& rMat ); void PushMatrix(const ScMatrixRef& pMat); void PushError( sal_uInt16 nError ); /// Raw stack type without default replacements. diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index fd1d224..8708e7b 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -1195,8 +1195,10 @@ sc::RangeMatrix ScInterpreter::CompareMat( ScCompareOptions* pOptions ) aRes.mnCol1 = aMat[i].mnCol1; aRes.mnRow1 = aMat[i].mnRow1; +aRes.mnTab1 = aMat[i].mnTab1; aRes.mnCol2 = aMat[i].mnCol2; aRes.mnRow2 = aMat[i].mnRow2; +aRes.mnTab2 = aMat[i].mnTab2; for (SCSIZE j = 0; j < nC; ++j) { @@ -1270,29 +1272,6 @@ ScMatrixRef ScInterpreter::QueryMat( const ScMatrixRef& pMat, ScCompareOptions& return pResultMatrix; } -namespace { - -double applyImplicitIntersection(const sc::RangeMatrix& rMat, const ScAddress& rPos) -{ -if (rMat.mnRow1 <= rPos.Row() && rPos.Row() <= rMat.mnRow2 && rMat.mnCol1 == rMat.mnCol2) -{ -SCROW nOffset = rPos.Row() - rMat.mnRow1; -return rMat.mpMat->GetDouble(0, nOffset); -} - -if (rMat.mnCol1 <= rPos.Col() && rPos.Col() <= rMat.mnCol2 && rMat.mnRow1 == rMat.mnRow2) -{ -SCROW nOffset = rPos.Col() - rMat.mnCol1; -return rMat.mpMat->GetDouble(nOffset, 0); -} - -double fVal; -rtl::math::setNan(&fVal); -return fVal; -} - -} - void ScInterpreter::ScEqual() { if ( GetStackType(1) == svMatrix || GetStackType(2) == svMatrix ) @@ -1304,22 +1283,8 @@ void ScInterpreter::ScEqual() return; } -if (aMat.isRangeValid()) -{ -// This matrix represents a range reference. Apply implicit intersection. -double fVal = applyImplicitIntersection(aMat, aPos); -if (rtl::math::isNan(fVal)) -{ -PushError(errCellNoValue); -return; -