summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-04-25 15:43:32 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-04-30 13:10:40 -0400
commitf32534cedd414e57790782794cacdd0f0f4adb7c (patch)
tree4a70d41e1a6467f9ed9e63f1d018f0c389f79967 /sc
parentec42c8b689f47a05aaf9d2dcbf77e6d412c32847 (diff)
Not yet used, but a hook to retrieve a vector reference value.
Will be used in the next iteration. Change-Id: Iff875e7e8a48df849d6df4dfb1418a024c9f7c06
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/column.hxx6
-rw-r--r--sc/inc/document.hxx11
-rw-r--r--sc/inc/formulacell.hxx6
-rw-r--r--sc/inc/table.hxx1
-rw-r--r--sc/source/core/data/column.cxx5
-rw-r--r--sc/source/core/data/column2.cxx27
-rw-r--r--sc/source/core/data/document.cxx9
-rw-r--r--sc/source/core/data/table1.cxx11
8 files changed, 72 insertions, 4 deletions
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 8e076eed0608..866fce3bf113 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 c8431cfe87f5..052b81d208e9 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1940,7 +1940,16 @@ public:
ScFormulaVectorState GetFormulaVectorState( const ScAddress& rPos ) const;
-private:
+ /**
+ * 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
/**
* Use this class as a locale variable to merge number formatter from
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index 3e6814439e67..e6239e3f2226 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 d46a44755b29..eb5f7561a1ef 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 8ecb82e212f0..0c3e630e3a0c 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 d0d53eadece5..e95dcf93a6c4 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 9d86d45b05f7..6a00d36d0b6e 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 9c52585df5d2..7ae3c66ea8d7 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))