sc/qa/unit/tiledrendering/data/cell-edit-300zoom-settings.ods |binary sc/qa/unit/tiledrendering/tiledrendering.cxx | 37 ++++++++++ sc/source/ui/unoobj/docuno.cxx | 3 3 files changed, 40 insertions(+)
New commits: commit 344ca009d0340dae87176f37c3dbbe42881792ac Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Tue Feb 13 17:19:59 2024 +0000 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Wed Feb 28 11:57:01 2024 +0100 sync InputHandler zoom on setClientZoom analogous to what SetZoom and ScTabViewShell::Activate do. Otherwise the InputHandler editengine ref device used for cell editing stays at the MapMode stored in the document and doesn't update to stay in sync with the desired rendering so there is a visible mismatch between normal rendering and cell editing rendering. Change-Id: Ifd9b21ab15cc123e0747fcebfdd55f2ddc44bd31 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163388 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sc/qa/unit/tiledrendering/data/cell-edit-300zoom-settings.ods b/sc/qa/unit/tiledrendering/data/cell-edit-300zoom-settings.ods new file mode 100644 index 000000000000..8cfbc4d227bc Binary files /dev/null and b/sc/qa/unit/tiledrendering/data/cell-edit-300zoom-settings.ods differ diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index 853827e6ffe4..5330743b3ce4 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -3540,6 +3540,43 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testCellInvalidationDocWithExistingZo 50); } +CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testInputHandlerSyncedZoom) +{ + ScModelObj* pModelObj = createDoc("cell-edit-300zoom-settings.ods"); + + // Set View #1 to initial 150% + pModelObj->setClientVisibleArea(tools::Rectangle(0, 0, 17933, 4853)); + // Before the fix, this zoom would leave the EditEngine reference device + // at the zoom level stored in the document, so normal rendering and + // editing rendering happened with different MapModes + pModelObj->setClientZoom(256, 256, 1333, 1333); + + ScTabViewShell* pView = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current()); + CPPUNIT_ASSERT(pView); + pView->SetCursor(0, 4); // A5 + + Scheduler::ProcessEventsToIdle(); + + // Activate edit mode in that A5 cell + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::F2); + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::F2); + Scheduler::ProcessEventsToIdle(); + + const ScViewData* pViewData = ScDocShell::GetViewData(); + CPPUNIT_ASSERT(pViewData); + + // Get that active EditView + EditView* pEditView = pViewData->GetEditView(SC_SPLIT_BOTTOMLEFT); + CPPUNIT_ASSERT(pEditView); + EditEngine* pEditEngine = pEditView->GetEditEngine(); + CPPUNIT_ASSERT(pEditEngine); + // These must match, if they don't then text will have a different width in edit and view modes + CPPUNIT_ASSERT_EQUAL_MESSAGE("EditEngine Ref Dev Zoom and ViewData Zoom should match", + pViewData->GetZoomX(), pEditEngine->GetRefMapMode().GetScaleX()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("EditEngine Ref Dev Zoom and ViewData Zoom should match", + pViewData->GetZoomY(), pEditEngine->GetRefMapMode().GetScaleY()); +} + CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testStatusBarLocale) { // Given 2 views, the second's locale is set to German: diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index 007e6735b96d..b3b64a0bb0d0 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -1068,6 +1068,9 @@ void ScModelObj::setClientZoom(int nTilePixelWidth_, int nTilePixelHeight_, int pViewData->SetZoom(newZoomX, newZoomY, true); if (ScTabViewShell* pViewShell = pViewData->GetViewShell()) pViewShell->SyncGridWindowMapModeFromDrawMapMode(); + // sync zoom to Input Handler like ScTabViewShell::Activate does + if (ScInputHandler* pHdl = SC_MOD()->GetInputHdl()) + pHdl->SetRefScale(pViewData->GetZoomX(), pViewData->GetZoomY()); // refresh our view's take on other view's cursors & selections pViewData->GetActiveWin()->updateKitOtherCursors();