sc/source/ui/undo/undobase.cxx |   23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

New commits:
commit 726b133fd8c823c7f05a30c1995de26db372174d
Author:     Pranam Lashkari <lpra...@collabora.com>
AuthorDate: Fri May 10 02:02:18 2024 +0300
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Fri May 10 11:09:13 2024 +0200

    sc: undo: unify height adjust logic in undo with regular logic
    
    in ScBlockUndo::AdjustHeight now we use device like 
ScViewFunc::SetWidthOrHeight
    This provides unified behavior with user adjusting height or triggered it 
by undo
    
    problem:
    in online sometimes undoing would cause wrong selection due to incorrect 
height set
    steps to reproduce(happened in certain files only):
    1. autofill down a couple of cells
    2. undo it
    3. try to select the same cell again
    
    cell selection will act like auto filled cells are merged cells
    
    Change-Id: I81b798c4150284792ac3953caf822fefab0ccee2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167424
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sc/source/ui/undo/undobase.cxx b/sc/source/ui/undo/undobase.cxx
index c9a233604281..9c7f5571dd71 100644
--- a/sc/source/ui/undo/undobase.cxx
+++ b/sc/source/ui/undo/undobase.cxx
@@ -37,6 +37,7 @@
 #include <sortparam.hxx>
 #include <columnspanset.hxx>
 #include <undomanager.hxx>
+#include <sizedev.hxx>
 
 
 ScSimpleUndo::ScSimpleUndo( ScDocShell* pDocSh ) :
@@ -286,18 +287,26 @@ bool ScBlockUndo::AdjustHeight()
 {
     ScDocument& rDoc = pDocShell->GetDocument();
 
-    ScopedVclPtrInstance< VirtualDevice > pVirtDev;
+    ScSizeDeviceProvider aProv(pDocShell);
     Fraction aZoomX( 1, 1 );
     Fraction aZoomY = aZoomX;
     double nPPTX, nPPTY;
     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
     if (pViewShell)
     {
-        ScViewData& rData = pViewShell->GetViewData();
-        nPPTX = rData.GetPPTX();
-        nPPTY = rData.GetPPTY();
-        aZoomX = rData.GetZoomX();
-        aZoomY = rData.GetZoomY();
+        if (aProv.IsPrinter())
+        {
+            nPPTX = aProv.GetPPTX();
+            nPPTY = aProv.GetPPTY();
+        }
+        else
+        {
+            ScViewData& rData = pViewShell->GetViewData();
+            nPPTX = rData.GetPPTX();
+            nPPTY = rData.GetPPTY();
+            aZoomX = rData.GetZoomX();
+            aZoomY = rData.GetZoomY();
+        }
     }
     else
     {
@@ -306,7 +315,7 @@ bool ScBlockUndo::AdjustHeight()
         nPPTY = ScGlobal::nScreenPPTY;
     }
 
-    sc::RowHeightContext aCxt(rDoc.MaxRow(), nPPTX, nPPTY, aZoomX, aZoomY, 
pVirtDev);
+    sc::RowHeightContext aCxt(rDoc.MaxRow(), nPPTX, nPPTY, aZoomX, aZoomY, 
aProv.GetDevice());
     bool bRet = rDoc.SetOptimalHeight(
         aCxt, aBlockRange.aStart.Row(), aBlockRange.aEnd.Row(), 
aBlockRange.aStart.Tab(), true);
 

Reply via email to