[Libreoffice-commits] core.git: sc/source

Dennis Francis dennisfrancis.in at gmail.com
Mon Jun 12 15:57:15 UTC 2017


 sc/source/core/data/table1.cxx |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

New commits:
commit 637f7b50e4e8fbb56b4c552e28058bbdfcf85d5a
Author: Dennis Francis <dennisfrancis.in at gmail.com>
Date:   Fri Jun 9 14:46:58 2017 +0530

    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 at libreoffice.org>
    Reviewed-by: Eike Rathke <erack at redhat.com>

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
 }
 


More information about the Libreoffice-commits mailing list