diff options
author | Tor Lillqvist <tml@collabora.com> | 2021-01-29 16:03:29 +0200 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2021-02-01 13:26:42 +0100 |
commit | dca0374fb1edbd9bdeeaadda3f1866ce66b3a778 (patch) | |
tree | 7e3ae407800a074547605703207c43257a494c84 | |
parent | f32b0e54c4993ebfba3e55ccc75a034736645fe2 (diff) |
Don't bother shrinking row height when changing just one row interactively
I.e. when manually entering a new value.
This used to happen at least for a sample document in .xlsx format for
cells with automatic wrap turned on. After entering a value, the row
height was annoyingly shrunk by a few pixels, which looked weird and
pointless, and caused unnecessary invalidation thrash in the online
collaborative editing context.
Change-Id: I3c77f7fb4e575f02e1dd7cdc18f2919f5eb3426e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110243
Tested-by: Jenkins
Reviewed-by: Tor Lillqvist <tml@collabora.com>
-rw-r--r-- | sc/inc/global.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/table2.cxx | 13 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin.cxx | 5 |
3 files changed, 17 insertions, 3 deletions
diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx index f1a3559aa6ad..320edbad54d1 100644 --- a/sc/inc/global.hxx +++ b/sc/inc/global.hxx @@ -813,6 +813,8 @@ public: /// Calc's threaded group calculation is in progress. SC_DLLPUBLIC static bool bThreadedGroupCalcInProgress; + + SC_DLLPUBLIC static bool bKeyInputInProgress; }; // maybe move to dbdata.hxx (?): diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index 0d8ccaac55ce..b21c29f11ba8 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ /* * This file is part of the LibreOffice project. * @@ -3024,7 +3024,11 @@ bool lcl_pixelSizeChanged( if (nHeight != nNewHeight) { - bool bChanged = (nNewPix != static_cast<tools::Long>(nHeight * nPPTY)); + tools::Long nOldPix = static_cast<tools::Long>(nHeight * nPPTY); + + // Heuristic: Don't bother when handling interactive input, if changing just one row and + // the height will shrink. + bool bChanged = (nNewPix != nOldPix) && (!ScGlobal::bKeyInputInProgress || nEndRow - nStartRow > 0 || nNewPix > nOldPix); if (bChanged) return true; } @@ -3065,14 +3069,17 @@ bool ScTable::SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, sal_uInt16 nNew } } + // No idea why 20 is used here if (!bSingle || nEndRow - nStartRow < 20) { bChanged = lcl_pixelSizeChanged(*mpRowHeights, nStartRow, nEndRow, nNewHeight, nPPTY); - mpRowHeights->setValue(nStartRow, nEndRow, nNewHeight); + if (bChanged) + mpRowHeights->setValue(nStartRow, nEndRow, nNewHeight); } else { SCROW nMid = (nStartRow + nEndRow) / 2; + // No idea why nPPTY is ignored in these recursive calls and instead 1.0 is used if (SetRowHeightRange(nStartRow, nMid, nNewHeight, 1.0)) bChanged = true; if (SetRowHeightRange(nMid + 1, nEndRow, nNewHeight, 1.0)) diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 37bc1ea211e6..56f02c91ce3b 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -44,6 +44,7 @@ #include <vcl/settings.hxx> #include <sot/formats.hxx> #include <comphelper/classids.hxx> +#include <comphelper/flagguard.hxx> #include <svx/svdview.hxx> #include <editeng/outliner.hxx> @@ -3191,8 +3192,12 @@ void ScGridWindow::SelectForContextMenu( const Point& rPosPixel, SCCOL nCellX, S } } +bool ScGlobal::bKeyInputInProgress = false; + void ScGridWindow::KeyInput(const KeyEvent& rKEvt) { + comphelper::FlagGuard aResetFlag(ScGlobal::bKeyInputInProgress); + // Cursor control for ref input dialog const vcl::KeyCode& rKeyCode = rKEvt.GetKeyCode(); |