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 <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
(cherry picked from commit 726b133fd8c823c7f05a30c1995de26db372174d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167454
Tested-by: Jenkins
Reviewed-by: Pranam Lashkari <lpranam@collabora.com>
diff --git a/sc/source/ui/undo/undobase.cxx b/sc/source/ui/undo/undobase.cxx
index 8ce66d9..a99dec9 100644
--- a/sc/source/ui/undo/undobase.cxx
+++ b/sc/source/ui/undo/undobase.cxx
@@ -36,6 +36,7 @@
#include <sortparam.hxx>
#include <columnspanset.hxx>
#include <undomanager.hxx>
#include <sizedev.hxx>
ScSimpleUndo::ScSimpleUndo( ScDocShell* pDocSh ) :
@@ -285,18 +286,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
{
@@ -305,7 +314,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);