sc/qa/unit/tiledrendering/data/cell-edit-300zoom-settings.ods |binary sc/qa/unit/tiledrendering/tiledrendering.cxx | 36 ++++++++++ sc/source/ui/unoobj/docuno.cxx | 3 3 files changed, 39 insertions(+)
New commits: commit fa4a68dc3e62bb76bc29309e15741375f2663cb6 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 10:10:22 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/+/163389 Tested-by: Jenkins 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 d371d817ffa5..c9a005fd5136 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -3540,6 +3540,42 @@ 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& rEditEngine = pEditView->getEditEngine(); + // 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(), rEditEngine.GetRefMapMode().GetScaleX()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("EditEngine Ref Dev Zoom and ViewData Zoom should match", + pViewData->GetZoomY(), rEditEngine.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 b59167efef3c..bb36b29068ac 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -1081,6 +1081,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();