sc/source/core/data/table2.cxx |   15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

New commits:
commit ada399e8a3c5d5f3c9425cae0da486fed90175e6
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Wed Feb 16 09:54:54 2022 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Thu Feb 17 10:29:36 2022 +0100

    for unallocated columns check default column attributes (tdf#132057)
    
    The problem was that this was returning false for the protected
    attribute just because a column was not allocated, but the default
    attributes had the flag set (so if the column had been allocated
    first it would have the flag set too).
    
    Change-Id: I2ef1ef40cafb7e8fc6f7b561c0a376af63f2ad26
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129984
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>
    (cherry picked from commit a717029e217621482ef799731f945090c6d6be4b)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130015
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    (cherry picked from commit 5bdf7c93abd15dc422586228186e822096ce1517)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130018

diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 7ed03187b4b4..f5f4b8723ab1 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -2211,15 +2211,12 @@ const ScPatternAttr* ScTable::GetMostUsedPattern( SCCOL 
nCol, SCROW nStartRow, S
 
 bool ScTable::HasAttrib( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, 
HasAttrFlags nMask ) const
 {
-    if ( nCol1 >= aCol.size() )
-         return false;
-    if ( nCol2 >= aCol.size() )
-         nCol2 = aCol.size() - 1; // Rows above range, doesn't contains flags
-
-    bool bFound = false;
-    for (SCCOL i=nCol1; i<=nCol2 && !bFound; i++)
-        bFound |= aCol[i].HasAttrib( nRow1, nRow2, nMask );
-    return bFound;
+    for(SCCOL nCol = nCol1; nCol <= nCol2 && nCol < aCol.size(); ++nCol )
+        if( aCol[nCol].HasAttrib( nRow1, nRow2, nMask ))
+            return true;
+    if( nCol2 >= aCol.size())
+         return aDefaultColAttrArray.HasAttrib( nRow1, nRow2, nMask );
+    return false;
 }
 
 bool ScTable::HasAttribSelection( const ScMarkData& rMark, HasAttrFlags nMask 
) const

Reply via email to