sc/inc/column.hxx | 6 ++++++ sc/inc/document.hxx | 9 +++++++++ sc/inc/formulacell.hxx | 6 +++--- sc/inc/table.hxx | 1 + sc/source/core/data/column.cxx | 5 +++++ sc/source/core/data/column2.cxx | 27 +++++++++++++++++++++++++++ sc/source/core/data/document.cxx | 9 +++++++++ sc/source/core/data/table1.cxx | 11 +++++++++++ 8 files changed, 71 insertions(+), 3 deletions(-)
New commits: commit fe7eede8274500d8c45aa886fc5bbe38e518a0c4 Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Thu Apr 25 15:43:32 2013 -0400 Not yet used, but a hook to retrieve a vector reference value. Will be used in the next iteration. Change-Id: Iff875e7e8a48df849d6df4dfb1418a024c9f7c06 diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index 8e076ee..866fce3 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -93,6 +93,11 @@ struct ColEntry { SCROW nRow; ScBaseCell* pCell; + + struct Less : std::binary_function<ColEntry, ColEntry, bool> + { + bool operator() (const ColEntry& r1, const ColEntry& r2) const; + }; }; struct ColDoubleEntry @@ -443,6 +448,7 @@ public: size_t GetFormulaHash( SCROW nRow ) const; ScFormulaVectorState GetFormulaVectorState( SCROW nRow ) const; + bool ResolveVectorReference( SCROW nRow1, SCROW nRow2 ); ScRefCellValue GetRefCellValue( SCROW ); diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index afdd493..71d76ad 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -1940,6 +1940,15 @@ public: ScFormulaVectorState GetFormulaVectorState( const ScAddress& rPos ) const; + /** + * Check if the range contains any "dirty" formula cells. In the future + * we'll use this function to interpret those "dirty" formula cells on + * demand. + * + * @return true if the range is totally clean, false otherwise. + */ + bool ResolveVectorReference( const ScAddress& rPos, SCROW nEndRow ); + private: // CLOOK-Impl-methods /** diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx index 3e68144..e6239e3 100644 --- a/sc/inc/formulacell.hxx +++ b/sc/inc/formulacell.hxx @@ -33,9 +33,9 @@ struct ScSimilarFormulaDelta; struct SC_DLLPUBLIC ScFormulaCellGroup { - sal_Int32 mnRefCount; - sal_Int32 mnStart; // Start offset of that cell - sal_Int32 mnLength; // How many of these do we have ? + sal_Int32 mnRefCount; + SCROW mnStart; // Start offset of that cell + SCROW mnLength; // How many of these do we have ? bool mbInvariant; ScFormulaCellGroup(); diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index d46a447..eb5f756 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -819,6 +819,7 @@ public: size_t GetFormulaHash( SCCOL nCol, SCROW nRow ) const; ScFormulaVectorState GetFormulaVectorState( SCCOL nCol, SCROW nRow ) const; + bool ResolveVectorReference( SCCOL nCol, SCROW nRow1, SCROW nRow2 ); ScRefCellValue GetRefCellValue( SCCOL nCol, SCROW nRow ); diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index 8ecb82e..0c3e630 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -45,6 +45,11 @@ using ::editeng::SvxBorderLine; using namespace formula; +bool ColEntry::Less::operator() (const ColEntry& r1, const ColEntry& r2) const +{ + return r1.nRow < r2.nRow; +} + namespace { inline bool IsAmbiguousScriptNonZero( sal_uInt8 nScript ) diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 82f03cc..00f900b 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -1589,6 +1589,33 @@ ScFormulaVectorState ScColumn::GetFormulaVectorState( SCROW nRow ) const return pCell ? pCell->GetVectorState() : FormulaVectorUnknown; } +bool ScColumn::ResolveVectorReference( SCROW nRow1, SCROW nRow2 ) +{ + std::vector<ColEntry>::iterator itEnd = maItems.end(); + // Find first cell whose position is equal or greater than nRow1. + ColEntry aBound; + aBound.nRow = nRow1; + std::vector<ColEntry>::iterator it = + std::lower_bound(maItems.begin(), itEnd, aBound, ColEntry::Less()); + + if (it == itEnd) + return false; + + for (; it != itEnd && it->nRow <= nRow2; ++it) + { + if (it->pCell->GetCellType() != CELLTYPE_FORMULA) + // Non-formula cells are fine. + continue; + + ScFormulaCell* pFC = static_cast<ScFormulaCell*>(it->pCell); + if (pFC->GetDirty()) + // Dirty formula cells are not supported yet. + return false; + } + + return true; +} + ScRefCellValue ScColumn::GetRefCellValue( SCROW nRow ) { ScRefCellValue aCell; // start empty diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 9d86d45..6a00d36 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -1574,6 +1574,15 @@ ScFormulaVectorState ScDocument::GetFormulaVectorState( const ScAddress& rPos ) return maTabs[nTab]->GetFormulaVectorState(rPos.Col(), rPos.Row()); } +bool ScDocument::ResolveVectorReference( const ScAddress& rPos, SCROW nEndRow ) +{ + SCTAB nTab = rPos.Tab(); + if (!TableExists(nTab)) + return false; + + return maTabs[nTab]->ResolveVectorReference(rPos.Col(), rPos.Row(), nEndRow); +} + bool ScDocument::CanFitBlock( const ScRange& rOld, const ScRange& rNew ) { if ( rOld == rNew ) diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index 9c52585..7ae3c66 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -2113,6 +2113,17 @@ ScFormulaVectorState ScTable::GetFormulaVectorState( SCCOL nCol, SCROW nRow ) co return aCol[nCol].GetFormulaVectorState(nRow); } +bool ScTable::ResolveVectorReference( SCCOL nCol, SCROW nRow1, SCROW nRow2 ) +{ + if (!ValidCol(nCol) || !ValidRow(nRow1) || !ValidRow(nRow2)) + return false; + + if (!aCol[nCol].ResolveVectorReference(nRow1, nRow2)) + return false; + + return true; +} + ScRefCellValue ScTable::GetRefCellValue( SCCOL nCol, SCROW nRow ) { if (!ValidColRow(nCol, nRow)) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits