[Libreoffice-commits] core.git: Branch 'private/kohei/formula-opencl-work' - sc/inc sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Tue Sep 10 08:15:30 PDT 2013
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 b68f673ffdd820fd6f359c904bc2f5690ef46a80
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
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 ba79c23..6d09ad1 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -184,6 +184,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 4cbf06a..6993abb 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1028,11 +1028,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.
+ *
+ * <p>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.</p>
*/
- 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 9bf3f90..fc8ae3a 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -469,7 +469,7 @@ public:
bool ShrinkToUsedDataArea( 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 42c5469..eda83ff 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1255,6 +1255,19 @@ SCROW ScColumn::GetLastDataPos() const
return MAXROW - static_cast<SCROW>(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<SCROW>(aPos.first->position - 1);
+}
+
bool ScColumn::GetPrevDataPos(SCROW& rRow) const
{
std::pair<sc::CellStoreType::const_iterator,size_t> aPos = maCells.position(rRow);
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 7bda1da..dc7db44 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 91e91dc..48a534b 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -3362,7 +3362,8 @@ class GroupTokenConverter
SCROW trimLength(SCTAB nTab, SCCOL nCol1, SCCOL nCol2, SCROW nRow, SCROW nRowLen)
{
- SCROW nLastRow = mrDoc.GetLastDataRow(nTab, nCol1, nCol2);
+ SCROW nLastRow = nRow + nRowLen - 1; // current last row.
+ nLastRow = mrDoc.GetLastDataRow(nTab, nCol1, nCol2, nLastRow);
if (nLastRow < (nRow + nRowLen - 1))
nRowLen = nLastRow - nRow + 1;
else if (nLastRow == 0)
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 9af12d6..f827cc9 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -987,20 +987,20 @@ bool ScTable::ShrinkToUsedDataArea( bool& o_bShrunk, SCCOL& rStartCol, SCROW& rS
(rStartRow != rEndRow || aCol[rStartCol].HasDataAt( rStartRow)));
}
-SCROW ScTable::GetLastDataRow( SCCOL nCol1, SCCOL nCol2 ) const
+SCROW ScTable::GetLastDataRow( SCCOL nCol1, SCCOL nCol2, SCROW nLastRow ) const
{
if (!ValidCol(nCol1) || !ValidCol(nCol2))
return -1;
- SCROW nLastRow = 0;
+ SCROW nNewLastRow = 0;
for (SCCOL i = nCol1; i <= nCol2; ++i)
{
- SCROW nThis = aCol[i].GetLastDataPos();
- if (nLastRow < nThis)
- nLastRow = nThis;
+ SCROW nThis = aCol[i].GetLastDataPos(nLastRow);
+ if (nNewLastRow < nThis)
+ nNewLastRow = nThis;
}
- return nLastRow;
+ return nNewLastRow;
}
SCSIZE ScTable::GetEmptyLinesInBlock( SCCOL nStartCol, SCROW nStartRow,
More information about the Libreoffice-commits
mailing list