sc/source/ui/view/tabview.cxx |   22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

New commits:
commit e6bc90aa8a959e08abf4b5c10d793ff9a549efe4
Author:     Justin Luth <jl...@mail.com>
AuthorDate: Tue Nov 1 19:33:33 2022 -0400
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Mon Nov 7 22:22:33 2022 +0100

    tdf#112641 sc: always allow freezing at cell A1
    
    For some good reasons, freezing rows and columns
    doesn't work unless that cell is currently visible,
    and that is almost guaranteed anyway since the
    hisorical way of doing it was at the cursor.
    
    However, since LO 5.2 there are menu and UNO commands
    to freeze the first row and the first column.
    It would be nice if these would work regardless
    of where you are in the spreadsheet
    (and keep you at that position too).
    
    [If there is already a SPLIT (not freeze),
     then the bottom right quadrant is still
     the "position" that is maintained.]
    
    [This "works" if the first row/column is hidden.
     When unhidden, the freeze will be in effect.
     I assume that is reasonable and doesn't need
     to be avoided for any reason.]
    
    Change-Id: Iddc5d63adaad7ecfe6b5fb9b60ff3ec6274b0756
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142128
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>
    Reviewed-by: Eike Rathke <er...@redhat.com>

diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index 0371b9f40940..94a9aa144ad6 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -1932,6 +1932,7 @@ void ScTabView::FreezeSplitters( bool bFreeze, 
SplitMethod eSplitMethod, SCCOLRO
     vcl::Window* pWin = pGridWin[ePos];
 
     bool bLayoutRTL = aViewData.GetDocument().IsLayoutRTL( 
aViewData.GetTabNo() );
+    bool bUpdateFix = false;
 
     if ( bFreeze )
     {
@@ -2015,6 +2016,15 @@ void ScTabView::FreezeSplitters( bool bFreeze, 
SplitMethod eSplitMethod, SCCOLRO
                 aViewData.SetPosY(SC_SPLIT_TOP, nTopPos);
                 aViewData.SetPosY(SC_SPLIT_BOTTOM, nBottomPos);
             }
+            else if (nPosY == 1 && eSplitMethod == SC_SPLIT_METHOD_ROW)
+            {
+                // Freeze first row, but row 1 is not visible on screen now == 
special handling
+                aViewData.SetVSplitMode(SC_SPLIT_FIX);
+                aViewData.SetFixPosY(nPosY);
+
+                aViewData.SetPosY(SC_SPLIT_TOP, 0);
+                bUpdateFix = true;
+            }
             else
                 aViewData.SetVSplitMode(SC_SPLIT_NONE);
         }
@@ -2040,6 +2050,16 @@ void ScTabView::FreezeSplitters( bool bFreeze, 
SplitMethod eSplitMethod, SCCOLRO
                 aViewData.SetPosX(SC_SPLIT_LEFT, nLeftPos);
                 aViewData.SetPosX(SC_SPLIT_RIGHT, nRightPos);
             }
+            else if (nPosX == 1 && eSplitMethod == SC_SPLIT_METHOD_COL)
+            {
+                // Freeze first column, but col A is not visible on screen now 
== special handling
+                aViewData.SetHSplitMode(SC_SPLIT_FIX);
+                aViewData.SetFixPosX(nPosX);
+
+                aViewData.SetPosX(SC_SPLIT_RIGHT, 
aViewData.GetPosX(SC_SPLIT_LEFT));
+                aViewData.SetPosX(SC_SPLIT_LEFT, 0);
+                bUpdateFix = true;
+            }
             else
                 aViewData.SetHSplitMode( SC_SPLIT_NONE );
         }
@@ -2059,7 +2079,7 @@ void ScTabView::FreezeSplitters( bool bFreeze, 
SplitMethod eSplitMethod, SCCOLRO
             p->SetMapMode( p->GetDrawMapMode() );
     SetNewVisArea();
 
-    RepeatResize(false);
+    RepeatResize(bUpdateFix);
 
     UpdateShow();
     PaintLeft();

Reply via email to