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 a383d7afa4e82bea728ecddf1bc44bbd9fd0eddb Author: Mike Kaganski <[email protected]> AuthorDate: Thu Feb 13 15:51:54 2025 +0500 Commit: Mike Kaganski <[email protected]> CommitDate: Thu Feb 13 13:44:22 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]> diff --git a/include/svx/svdpagv.hxx b/include/svx/svdpagv.hxx index 88b6cab3ee8a..3b8c2f080db6 100644 --- a/include/svx/svdpagv.hxx +++ b/include/svx/svdpagv.hxx @@ -248,6 +248,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 f456712b616f..232c1d0bc9d1 100644 --- a/sc/source/ui/inc/gridwin.hxx +++ b/sc/source/ui/inc/gridwin.hxx @@ -509,6 +509,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 eed37d2dd8c5..7511d9fce378 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 b0c5e396322e..ca8ac4b29f1e 100644 --- a/sc/source/ui/view/drawview.cxx +++ b/sc/source/ui/view/drawview.cxx @@ -964,26 +964,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 7a13917fd917..2ede73ce874f 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -1500,6 +1500,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 8b1f837a6301..1ce89406a18c 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: */
