sc/source/core/data/table4.cxx |   20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

New commits:
commit 99191703b528d8d7b0b9c5d84d76a6fdebbf5191
Author:     Justin Luth <justin_l...@sil.org>
AuthorDate: Wed Feb 9 14:33:05 2022 +0200
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Wed Feb 16 12:03:02 2022 +0100

    tdf#113785 sc FillAutoSimple: also optimize in negative direction
    
    By only coding the optimization for the downward autofill,
    it totally broke an upward autofill.
    So this patch simply fixes the LO 4.3ish regression
    from commit a995462e6855061816c6529c366f20ace2b45868.
    
    This fix means that the non-hidden cells get the auto-value
    instead of being erased.
    
    However, the hidden cells are still erased
    (which is the topic of tdf#119957).
    
    I'm not going to bother with a unit test for this
    portion. If I can solve bug 119957 as well,
    then the unit test for that can cover both situations.
    
    Change-Id: If6320ccf87fa8893ca6766c265b7760cc46ed7d8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129723
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>
    (cherry picked from commit 618084819babc839510860b74b36631749093c4c)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129753
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    (cherry picked from commit f3035cdb6a8d3ef56180640ef9d04031012250b9)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129760
    Reviewed-by: Eike Rathke <er...@redhat.com>

diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index 0f1f7193fe59..73ad750d35c1 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -1782,16 +1782,28 @@ void ScTable::FillAutoSimple(
     bool bIsOrdinalSuffix = false;
 
     bool bColHidden = false, bRowHidden = false;
+    SCCOL nColHiddenFirst = rDocument.MaxCol();
     SCCOL nColHiddenLast = -1;
+    SCROW nRowHiddenFirst = rDocument.MaxRow();
     SCROW nRowHiddenLast = -1;
 
     rInner = nIStart;
     while (true)        // #i53728# with "for (;;)" old solaris/x86 compiler 
mis-optimizes
     {
-        if (rCol > nColHiddenLast)
-            bColHidden = ColHidden(rCol, nullptr, &nColHiddenLast);
-        if (rRow > nRowHiddenLast)
-            bRowHidden = RowHidden(rRow, nullptr, &nRowHiddenLast);
+        if (bPositive)
+        {
+            if (rCol > nColHiddenLast)
+                bColHidden = ColHidden(rCol, nullptr, &nColHiddenLast);
+            if (rRow > nRowHiddenLast)
+                bRowHidden = RowHidden(rRow, nullptr, &nRowHiddenLast);
+        }
+        else
+        {
+            if (rCol < nColHiddenFirst)
+                bColHidden = ColHidden(rCol, &nColHiddenFirst);
+            if (rRow < nRowHiddenFirst)
+                bRowHidden = RowHidden(rRow, &nRowHiddenFirst);
+        }
 
         if (!bColHidden && !bRowHidden)
         {

Reply via email to