From 726b133fd8c823c7f05a30c1995de26db372174d Mon Sep 17 00:00:00 2001 From: Pranam Lashkari Date: Fri, 10 May 2024 02:02:18 +0300 Subject: sc: undo: unify height adjust logic in undo with regular logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Caolán McNamara --- sc/source/ui/undo/undobase.cxx | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) 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 #include #include +#include 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); -- cgit