summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Francis <dennisfrancis.in@gmail.com>2017-06-09 14:46:58 +0530
committerEike Rathke <erack@redhat.com>2017-06-12 17:56:53 +0200
commit637f7b50e4e8fbb56b4c552e28058bbdfcf85d5a (patch)
tree72e0c1159b44bc07daaa3d942edc78182dcecd77
parentaf2d5119c620947da59434c6367514925ec75bb2 (diff)
tdf#50916 : Refactor table1.cxx ScTable::GetNext*() methods
Refactored ScTable::GetNextPos() and ScTable::GetNextMarkedCell() methods in table1.cxx for dynamic column container. Change-Id: I5dfe9e5b2236e6ede68119f4e1252610990e498b Reviewed-on: https://gerrit.libreoffice.org/38599 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Eike Rathke <erack@redhat.com>
-rw-r--r--sc/source/core/data/table1.cxx11
1 files changed, 8 insertions, 3 deletions
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index bbb6d610a5ce..45f17c663b51 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -1401,6 +1401,7 @@ void ScTable::GetNextPos( SCCOL& rCol, SCROW& rRow, SCCOL nMovX, SCROW nMovY,
{
std::unique_ptr<SCROW[]> pNextRows(new SCROW[MAXCOL+1]);
SCCOL i;
+ const SCCOL nLastCol = aCol.size() - 1;
if ( nMovX > 0 ) // forward
{
@@ -1412,7 +1413,8 @@ void ScTable::GetNextPos( SCCOL& rCol, SCROW& rRow, SCCOL nMovX, SCROW nMovY,
if ( bMarked )
nNextRow = rMark.GetNextMarked( nCol, nNextRow, false );
if ( bUnprotected )
- nNextRow = aCol[nCol].GetNextUnprotected( nNextRow, false );
+ nNextRow = ( nCol <= nLastCol ) ? aCol[nCol].GetNextUnprotected( nNextRow, false ) :
+ aDefaultColAttrArray.GetNextUnprotected( nNextRow, false );
pNextRows[nCol] = nNextRow;
SCROW nMinRow = MAXROW+1;
@@ -1445,7 +1447,8 @@ void ScTable::GetNextPos( SCCOL& rCol, SCROW& rRow, SCCOL nMovX, SCROW nMovY,
if ( bMarked )
nNextRow = rMark.GetNextMarked( nCol, nNextRow, true );
if ( bUnprotected )
- nNextRow = aCol[nCol].GetNextUnprotected( nNextRow, true );
+ nNextRow = ( nCol <= nLastCol ) ? aCol[nCol].GetNextUnprotected( nNextRow, true ) :
+ aDefaultColAttrArray.GetNextUnprotected( nNextRow, true );
pNextRows[nCol] = nNextRow;
SCROW nMaxRow = -1;
@@ -1485,7 +1488,7 @@ bool ScTable::GetNextMarkedCell( SCCOL& rCol, SCROW& rRow, const ScMarkData& rMa
{
++rRow; // next row
- while ( rCol <= MAXCOL )
+ while ( rCol < aCol.size() )
{
ScMarkArray aArray( rMark.GetMarkArray( rCol ) );
while ( rRow <= MAXROW )
@@ -1528,6 +1531,8 @@ bool ScTable::GetNextMarkedCell( SCCOL& rCol, SCROW& rRow, const ScMarkData& rMa
++rCol; // test next column
}
+ // Though searched only the allocated columns, it is equivalent to a search till MAXCOL.
+ rCol = MAXCOL + 1;
return false; // Through all columns
}