include/svx/svdpagv.hxx | 2 ++ sc/source/ui/inc/gridwin.hxx | 1 + sc/source/ui/unoobj/docuno.cxx | 8 +++++--- sc/source/ui/view/drawview.cxx | 22 ++-------------------- sc/source/ui/view/gridwin4.cxx | 7 +++++++ svx/source/svdraw/svdpagv.cxx | 18 ++++++++++++++++++ 6 files changed, 35 insertions(+), 23 deletions(-)
New commits: commit 43cf86c7cb423f134f51aa0a1430da8759b0b6cb Author: Mike Kaganski <[email protected]> AuthorDate: Thu Feb 13 15:51:54 2025 +0500 Commit: Miklos Vajna <[email protected]> CommitDate: Thu Feb 13 14:38:32 2025 +0100 Setting zoom must also reset offsets in LOK cached view The problem was, that having a spreadsheet with objects, e.g. rectangles, drawn e.g. over M15:O31, and zooming the spreadsheet in Online, the object was painted with substantial offset from the actual placement (it could be three rows below, and some millimeters to the right). The problem was, that respective ViewObjectContact did not reset its maGridOffset upon changing zoom, because it belonged to a view cached in ScGridWindow. It is different from what GetSdrPageView will return in ScDrawView::resetGridOffsetsForAllSdrPageViews; we need to handle that in ScModelObj::setClientZoom, or zooming in Calc would paint drawing objects in wrong positions. The sizes of the objects are still painted incorrectly. Change-Id: Ie2f90568f0570bc0492b614a5fa9128c3e5e9a1b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181611 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> (cherry picked from commit a383d7afa4e82bea728ecddf1bc44bbd9fd0eddb) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181618 Reviewed-by: Miklos Vajna <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> diff --git a/include/svx/svdpagv.hxx b/include/svx/svdpagv.hxx index 58354a3d8d50..2b9355b9ed3d 100644 --- a/include/svx/svdpagv.hxx +++ b/include/svx/svdpagv.hxx @@ -253,6 +253,8 @@ public: // #103911# Set/Get document color for svx at SdrPageViews void SetApplicationDocumentColor(Color aDocumentColor); const Color& GetApplicationDocumentColor() const { return maDocumentColor;} + + void resetGridOffsetsOfAllPageWindows() const; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx index b0c6128f3031..5a8c777b1749 100644 --- a/sc/source/ui/inc/gridwin.hxx +++ b/sc/source/ui/inc/gridwin.hxx @@ -499,6 +499,7 @@ public: /// notify this view with new positions for other view's cursors (after zoom) void updateKitOtherCursors() const; void updateOtherKitSelections() const; + void resetCachedViewGridOffsets() const; void notifyKitCellFollowJump() const; diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index d08ef82fda24..d7b41ab67f17 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -1103,9 +1103,11 @@ void ScModelObj::setClientZoom(int nTilePixelWidth_, int nTilePixelHeight_, int pHdl->SetRefScale(pViewData->GetZoomX(), pViewData->GetZoomY()); // refresh our view's take on other view's cursors & selections - pViewData->GetActiveWin()->UpdateEditViewPos(); - pViewData->GetActiveWin()->updateKitOtherCursors(); - pViewData->GetActiveWin()->updateOtherKitSelections(); + ScGridWindow* pGridWindow = pViewData->GetActiveWin(); + pGridWindow->UpdateEditViewPos(); + pGridWindow->updateKitOtherCursors(); + pGridWindow->updateOtherKitSelections(); + pGridWindow->resetCachedViewGridOffsets(); if (ScDrawView* pDrawView = pViewData->GetScDrawView()) pDrawView->resetGridOffsetsForAllSdrPageViews(); diff --git a/sc/source/ui/view/drawview.cxx b/sc/source/ui/view/drawview.cxx index c1a48dc6df12..44300141f6f8 100644 --- a/sc/source/ui/view/drawview.cxx +++ b/sc/source/ui/view/drawview.cxx @@ -962,26 +962,8 @@ void ScDrawView::SyncForGrid( SdrObject* pObj ) void ScDrawView::resetGridOffsetsForAllSdrPageViews() { - SdrPageView* pPageView(GetSdrPageView()); - - if(nullptr == pPageView) - return; - - for(sal_uInt32 a(0); a < pPageView->PageWindowCount(); a++) - { - SdrPageWindow* pPageWindow(pPageView->GetPageWindow(a)); - assert(pPageWindow && "SdrView::SetMasterPagePaintCaching: Corrupt SdrPageWindow list (!)"); - - if(nullptr != pPageWindow) - { - sdr::contact::ObjectContact& rObjectContact(pPageWindow->GetObjectContact()); - - if(rObjectContact.supportsGridOffsets()) - { - rObjectContact.resetAllGridOffsets(); - } - } - } + if (SdrPageView* pPageView = GetSdrPageView()) + pPageView->resetGridOffsetsOfAllPageWindows(); } bool ScDrawView::calculateGridOffsetForSdrObject( diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index a9a8d843281d..e7b29901de78 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -1468,6 +1468,13 @@ namespace }; } // anonymous namespace +void ScGridWindow::resetCachedViewGridOffsets() const +{ + if (mpLOKDrawView) + if (SdrPageView* pPageView = mpLOKDrawView->GetSdrPageView()) + pPageView->resetGridOffsetsOfAllPageWindows(); +} + void ScGridWindow::PaintTile( VirtualDevice& rDevice, int nOutputWidth, int nOutputHeight, int nTilePosX, int nTilePosY, diff --git a/svx/source/svdraw/svdpagv.cxx b/svx/source/svdraw/svdpagv.cxx index 4e5d7a47286c..80252d91b7e4 100644 --- a/svx/source/svdraw/svdpagv.cxx +++ b/svx/source/svdraw/svdpagv.cxx @@ -25,6 +25,7 @@ #include <svx/svdogrp.hxx> #include <svx/svdtypes.hxx> +#include <svx/sdr/contact/objectcontact.hxx> #include <svx/sdr/contact/viewobjectcontactredirector.hxx> #include <algorithm> @@ -898,5 +899,22 @@ void SdrPageView::SetApplicationDocumentColor(Color aDocumentColor) maDocumentColor = aDocumentColor; } +void SdrPageView::resetGridOffsetsOfAllPageWindows() const +{ + for (auto& pPageWindow : maPageWindows) + { + assert(pPageWindow && "SdrView::SetMasterPagePaintCaching: Corrupt SdrPageWindow list (!)"); + + if (pPageWindow) + { + sdr::contact::ObjectContact& rObjectContact(pPageWindow->GetObjectContact()); + + if (rObjectContact.supportsGridOffsets()) + { + rObjectContact.resetAllGridOffsets(); + } + } + } +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
