sc/source/ui/inc/viewdata.hxx | 5 +---- sc/source/ui/unoobj/docuno.cxx | 8 ++++++-- sc/source/ui/view/viewdata.cxx | 18 +++++++++++++----- sc/source/ui/view/viewfun3.cxx | 10 +++++++++- 4 files changed, 29 insertions(+), 12 deletions(-)
New commits: commit 4d34981d2081fea5a4bac648dcb59b901327cc4f Author: Tomaž Vajngerl <[email protected]> AuthorDate: Fri Oct 17 16:05:52 2025 +0900 Commit: Miklos Vajna <[email protected]> CommitDate: Mon Oct 20 09:33:37 2025 +0200 sc: Fix issues with tile invalidation Include sheet view in a view render state, so we get the correct tiles for our current view. Also use CurrentTabForData to get the anything connected to the size of columns and rows. We need to get that from the holder sheet if we hide, show, change the size, of columns and rows. Change-Id: I9431488d43920f5bb492c4bdcbc83dd24db0d89f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192568 Reviewed-by: Miklos Vajna <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx index 74858604b3dc..9d848697172c 100644 --- a/sc/source/ui/inc/viewdata.hxx +++ b/sc/source/ui/inc/viewdata.hxx @@ -414,10 +414,7 @@ public: */ SC_DLLPUBLIC SCTAB CurrentTabForData() const; - void SetSheetViewID(sc::SheetViewID nID) - { - pThisTab->mnSheetViewID = nID; - } + void SetSheetViewID(sc::SheetViewID nID); sc::SheetViewID GetSheetViewID() const { diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index 2b96bc70d4fd..b78e8c581527 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -521,6 +521,10 @@ static OString getTabViewRenderState(ScTabViewShell& rTabViewShell) OString aThemeName = OUStringToOString(rViewRenderingOptions.GetColorSchemeName(), RTL_TEXTENCODING_UTF8); aState.append(aThemeName); + sc::SheetViewID nSheetViewID = rTabViewShell.GetViewData().GetSheetViewID(); + if (nSheetViewID >= 0) + aState.append(";VS:" + OString::number(nSheetViewID)); + return aState.makeStringAndClear(); } @@ -544,7 +548,7 @@ static ScViewData* lcl_getViewMatchingDocZoomTab(const Fraction& rZoomX, continue; ScViewData& rData = pTabViewShell->GetViewData(); - if (rData.CurrentTabForData() == nTab && rData.GetZoomX() == rZoomX && rData.GetZoomY() == rZoomY && + if (rData.GetTabNumber() == nTab && rData.GetZoomX() == rZoomX && rData.GetZoomY() == rZoomY && getTabViewRenderState(*pTabViewShell) == rViewRenderState) { return &rData; @@ -573,7 +577,7 @@ void ScModelObj::paintTile( VirtualDevice& rDevice, // first few shells. This is to avoid switching of zooms in ScGridWindow::PaintTile // and hence avoid grid-offset recomputation on all shapes which is not cheap. ScViewData* pViewData = lcl_getViewMatchingDocZoomTab(aFracX, aFracY, - pActiveViewData->CurrentTabForData(), pViewShell->GetDocId(), + pActiveViewData->GetTabNumber(), pViewShell->GetDocId(), getTabViewRenderState(*pViewShell)); if (!pViewData) pViewData = pActiveViewData; diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index e8426bdfae32..bd0255c884a4 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -2512,12 +2512,12 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, } if (nForTab == -1) - nForTab = GetTabNumber(); - bool bForCurTab = (nForTab == GetTabNumber()); + nForTab = CurrentTabForData(); + bool bForCurTab = (nForTab == CurrentTabForData()); if (!bForCurTab && (!ValidTab(nForTab) || (nForTab >= static_cast<SCTAB>(maTabData.size())))) { SAL_WARN("sc.viewdata", "ScViewData::GetScrPos : invalid nForTab = " << nForTab); - nForTab = GetTabNumber(); + nForTab = CurrentTabForData(); bForCurTab = true; } @@ -2614,7 +2614,7 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, nScrPosY = 0x7FFFFFFF; else { - nTSize = mrDoc.GetRowHeight( nY, mnTabNumber ); + nTSize = mrDoc.GetRowHeight( nY, CurrentTabForData() ); if (nTSize) { tools::Long nSizeYPix = ToPixel( nTSize, nPPTY ); @@ -2623,7 +2623,7 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, else if ( nY < mrDoc.MaxRow() ) { // skip multiple hidden rows (forward only for now) - SCROW nNext = mrDoc.FirstVisibleRow(nY + 1, mrDoc.MaxRow(), mnTabNumber); + SCROW nNext = mrDoc.FirstVisibleRow(nY + 1, mrDoc.MaxRow(), CurrentTabForData()); if ( nNext > mrDoc.MaxRow() ) nY = mrDoc.MaxRow(); else @@ -4502,6 +4502,14 @@ SCTAB ScViewData::CurrentTabForData() const return GetTabNumber(); } +void ScViewData::SetSheetViewID(sc::SheetViewID nID) +{ + pThisTab->mnSheetViewID = nID; + + CalcPPT(); + RecalcPixPos(); +} + sc::SheetViewID ScViewData::GetSheetViewIDForSheet(SCTAB nTab) const { if (!IsValidTabNumber(nTab)) diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx index 591f30722076..558078c5a86d 100644 --- a/sc/source/ui/view/viewfun3.cxx +++ b/sc/source/ui/view/viewfun3.cxx @@ -66,6 +66,8 @@ #include <SheetViewManager.hxx> #include <uiitems.hxx> #include <com/sun/star/util/XCloneable.hpp> +#include <sfx2/lokhelper.hxx> + using namespace com::sun::star; @@ -2067,7 +2069,13 @@ void ScViewFunc::SheetViewChanged() { ScDocShell& rDocSh = *GetViewData().GetDocShell(); ScDocument& rDocument = GetViewData().GetDocument(); - rDocSh.PostPaint(0,0,0, rDocument.MaxCol(), rDocument.MaxRow(), MAXTAB, PaintPartFlags::All); + rDocSh.PostPaint(0, 0, 0, rDocument.MaxCol(), rDocument.MaxRow(), MAXTAB, PaintPartFlags::All); + + if (ScTabViewShell* pViewShell = GetViewData().GetViewShell()) + { + ScModelObj* pModel = comphelper::getFromUnoTunnel<ScModelObj>(pViewShell->GetCurrentDocument()); + SfxLokHelper::notifyViewRenderState(pViewShell, pModel); + } } void ScViewFunc::MakeNewSheetView()
