From f7b3352424bd3dc934a233eeb5f3c6cff05ac8ee Mon Sep 17 00:00:00 2001 From: Kevin Kettinger Date: Wed, 17 Jun 2026 11:59:31 +0000 Subject: [PATCH 1/5] sc: implement pixel-level smooth scrolling in Calc (tdf#40917) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduces sub-cell pixel offset fields (nPixOffsetX/Y) to ScViewDataTable so the view can scroll by individual pixels rather than snapping to full row/column boundaries. Key changes: - ScViewData: add nPixOffsetX/Y[2] fields, SetPixOffsetX/Y, GetPixOffsetX/Y; propagate into GetLogicMode() (origin shift) and GetScrPos() (accumulator initialised to sub-cell offset inside the visible-range guard only, so off-screen sentinels are unaffected); reset on SetPosX/Y and RecalcPixPos. - ScTabView: add SmoothScrollY/X() that accumulate pixel deltas, advance or retreat rows/columns as boundaries are crossed, and blit via ScrollPixel(). ScrollCommand() routes trackpad/pixel-delta wheel events directly to SmoothScrollY; GesturePanCommand() tracks cumulative pan offset. - Vertical scrollbar precision (SC_VSCROLL_PRECISION = 100): UpdateScrollBars scales the vertical scrollbar range ×100 so each scrollbar unit is ~1% of a row height; SetLineSize(P) keeps arrow-button clicks at exactly one full row. ScrollHdl default case reconstructs the precision-unit delta from the thumb position and converts it to pixels for SmoothScrollY, avoiding any ScrollY cell-snap fallback. nPrevDragPos is initialised in precision units on the first Drag event so the anti-jitter guard compares like-for-like. - ScHeaderControl: virtual GetScrollPixelOffset() hook (overridden by ScRowBar/ScColBar) feeds nPixOffsetY/X into the row/column bar GetScrPos() and Paint() accumulators, keeping header labels aligned with cell content during sub-row scrolling. Co-Authored-By: Claude Sonnet 4.6 Change-Id: I241c34f2583800a8661b46adb675491c14d0760c --- sc/source/ui/inc/colrowba.hxx | 2 + sc/source/ui/inc/hdrcont.hxx | 3 + sc/source/ui/inc/tabview.hxx | 11 + sc/source/ui/inc/viewdata.hxx | 6 + sc/source/ui/view/colrowba.cxx | 10 + sc/source/ui/view/gridwin4.cxx | 3 + sc/source/ui/view/hdrcont.cxx | 4 +- sc/source/ui/view/tabview.cxx | 465 ++++++++++++++++++++++++++++++++- sc/source/ui/view/tabview4.cxx | 29 +- sc/source/ui/view/viewdata.cxx | 69 ++++- 10 files changed, 581 insertions(+), 21 deletions(-) diff --git a/sc/source/ui/inc/colrowba.hxx b/sc/source/ui/inc/colrowba.hxx index 57c6204e88dcb..5e72b27250d29 100644 --- a/sc/source/ui/inc/colrowba.hxx +++ b/sc/source/ui/inc/colrowba.hxx @@ -54,6 +54,7 @@ public: virtual void DrawInvert( tools::Long nDragPos ) override; virtual OUString GetDragHelp( tools::Long nVal ) override; + virtual tools::Long GetScrollPixelOffset() const override; }; class ScRowBar : public ScHeaderControl @@ -84,6 +85,7 @@ public: virtual void DrawInvert( tools::Long nDragPos ) override; virtual OUString GetDragHelp( tools::Long nVal ) override; + virtual tools::Long GetScrollPixelOffset() const override; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/hdrcont.hxx b/sc/source/ui/inc/hdrcont.hxx index 5fed6c190a8e5..f775fbf9a9408 100644 --- a/sc/source/ui/inc/hdrcont.hxx +++ b/sc/source/ui/inc/hdrcont.hxx @@ -115,6 +115,9 @@ protected: virtual void Command( const CommandEvent& rCEvt ) override; virtual void dispose() override; + // Sub-cell scroll pixel offset (always <= 0). Overridden by ScRowBar/ScColBar. + virtual tools::Long GetScrollPixelOffset() const { return 0; } + public: ScHeaderControl( vcl::Window* pParent, SelectionEngine* pSelectionEngine, SCCOLROW nNewSize, bool bNewVertical, ScTabView* pTab ); diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx index 7b7248032ac75..06c47e7a351a8 100644 --- a/sc/source/ui/inc/tabview.hxx +++ b/sc/source/ui/inc/tabview.hxx @@ -108,6 +108,10 @@ private: int nTotalWindows; }; +// Precision factor for vertical scrollbar: 1 scrollbar unit = 1/SC_VSCROLL_PRECISION of a row. +// This enables sub-row thumb positions during dragging for pixel-level smooth scrolling. +inline constexpr tools::Long SC_VSCROLL_PRECISION = 100; + class ScTabView { private: @@ -217,6 +221,13 @@ private: tools::Long mnPendingaHScrollLeftDelta = 0; tools::Long mnPendingaHScrollRightDelta = 0; + // Smooth scrolling: cumulative pan gesture offsets (for delta computation per Update event) + double mfPreviousPanOffsetX = 0.0; + double mfPreviousPanOffsetY = 0.0; + + void SmoothScrollX( tools::Long nPixelDelta, ScHSplitPos eWhich ); + void SmoothScrollY( tools::Long nPixelDelta, ScVSplitPos eWhich ); + void Init(); void DoAddWin( ScGridWindow* pWin ); diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx index aa3f755297c73..65edabcfb85d0 100644 --- a/sc/source/ui/inc/viewdata.hxx +++ b/sc/source/ui/inc/viewdata.hxx @@ -219,6 +219,8 @@ private: tools::Long nMPosY[2]; tools::Long nPixPosX[2]; // Offset in Pixels tools::Long nPixPosY[2]; + tools::Long nPixOffsetX[2]; // Sub-cell pixel offset for smooth scrolling (<=0) + tools::Long nPixOffsetY[2]; // Sub-cell pixel offset for smooth scrolling (<=0) tools::Long nHSplitPos; tools::Long nVSplitPos; @@ -462,6 +464,10 @@ public: void SetPosX( ScHSplitPos eWhich, SCCOL nNewPosX ); void SetPosY( ScVSplitPos eWhich, SCROW nNewPosY ); + void SetPixOffsetX( ScHSplitPos eWhich, tools::Long nOffsetPixels ); + void SetPixOffsetY( ScVSplitPos eWhich, tools::Long nOffsetPixels ); + tools::Long GetPixOffsetX( ScHSplitPos eWhich ) const { return pThisTab->nPixOffsetX[eWhich]; } + tools::Long GetPixOffsetY( ScVSplitPos eWhich ) const { return pThisTab->nPixOffsetY[eWhich]; } void SetCurX( SCCOL nNewCurX ) { pThisTab->nCurX = nNewCurX; } void SetCurY( SCROW nNewCurY ) { pThisTab->nCurY = nNewCurY; } void SetCurXForTab( SCCOL nNewCurX, SCTAB nTabIndex ); diff --git a/sc/source/ui/view/colrowba.cxx b/sc/source/ui/view/colrowba.cxx index b6653cdb86e5c..078acc1ac28b2 100644 --- a/sc/source/ui/view/colrowba.cxx +++ b/sc/source/ui/view/colrowba.cxx @@ -372,4 +372,14 @@ SCCOLROW ScRowBar::GetHiddenCount( SCCOLROW nEntryNo ) const // override only fo return rDoc.GetHiddenRowCount( nEntryNo, nTab ); } +tools::Long ScRowBar::GetScrollPixelOffset() const +{ + return pTabView->GetViewData().GetPixOffsetY(meWhich); +} + +tools::Long ScColBar::GetScrollPixelOffset() const +{ + return pTabView->GetViewData().GetPixOffsetX(meWhich); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index 70caf85056b7f..5d56094de87be 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -509,6 +509,9 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod tools::Long nScrX = aScrPos.X(); tools::Long nScrY = aScrPos.Y(); + fprintf(stderr, "DBG Draw: nY1=%d nScrY=%ld\n", + static_cast(nY1), static_cast(nScrY)); + fflush(stderr); SCCOL nCurX = mrViewData.GetCurX(); SCROW nCurY = mrViewData.GetCurY(); diff --git a/sc/source/ui/view/hdrcont.cxx b/sc/source/ui/view/hdrcont.cxx index 3748bf71c0fe8..52fcd8fe514cc 100644 --- a/sc/source/ui/view/hdrcont.cxx +++ b/sc/source/ui/view/hdrcont.cxx @@ -213,7 +213,7 @@ tools::Long ScHeaderControl::GetScrPos( SCCOLROW nEntryNo ) const nScrPos = nMax; else { - nScrPos = 0; + nScrPos = GetScrollPixelOffset(); for (SCCOLROW i=GetPos(); i #include #include +#include #include #include #include @@ -980,6 +981,13 @@ bool ScTabView::ScrollCommand( const CommandEvent& rCEvt, ScSplitPos ePos ) bool bDone = false; const CommandWheelData* pData = rCEvt.GetWheelData(); + fprintf(stderr, "DBG ScrollCommand: pData=%p cmd=%d mode=%d isDeltaPx=%d delta=%ld\n", + static_cast(pData), + static_cast(rCEvt.GetCommand()), + pData ? static_cast(pData->GetMode()) : -1, + pData ? (int)pData->IsDeltaPixel() : -1, + pData ? static_cast(pData->GetDelta()) : 0L); + fflush(stderr); if (pData && pData->GetMode() == CommandWheelMode::ZOOM) { if ( !aViewData.GetViewShell()->GetViewFrame().GetFrame().IsInPlace() ) @@ -1002,6 +1010,69 @@ bool ScTabView::ScrollCommand( const CommandEvent& rCEvt, ScSplitPos ePos ) bDone = true; } } + else if (pData && pData->GetMode() == CommandWheelMode::SCROLL + && !comphelper::LibreOfficeKit::isActive()) + { + ScHSplitPos eHPos = WhichH(ePos); + ScVSplitPos eVPos = WhichV(ePos); + ScDocument& rDoc = aViewData.GetDocument(); + SCTAB nTab = aViewData.CurrentTabForData(); + + SAL_INFO("sc.smooth", "ScrollCommand SCROLL: IsDeltaPixel=" << pData->IsDeltaPixel() + << " IsHorz=" << pData->IsHorz() + << " Delta=" << pData->GetDelta() + << " NotchDelta=" << pData->GetNotchDelta() + << " ScrollLines=" << pData->GetScrollLines()); + + if (pData->IsDeltaPixel()) + { + // macOS / Linux smooth-scroll devices: delta is already in pixels. + tools::Long nDelta = pData->GetDelta(); + SAL_INFO("sc.smooth", " -> IsDeltaPixel path, nDelta=" << nDelta); + if (pData->IsHorz()) + SmoothScrollX(nDelta, eHPos); + else + SmoothScrollY(nDelta, eVPos); + } + else + { + double nScrollLines = pData->GetScrollLines(); + tools::Long nNotchDelta = pData->GetNotchDelta(); // ±1 per notch + + if (nScrollLines == COMMAND_WHEEL_PAGESCROLL) + { + tools::Long nPagePx = aViewData.GetView()->GetGridHeight(eVPos); + SAL_INFO("sc.smooth", " -> PageScroll path, nPagePx=" << nPagePx); + SmoothScrollY(nNotchDelta > 0 ? nPagePx : -nPagePx, eVPos); + } + else + { + if (pData->IsHorz()) + { + // Use a fixed pixel-per-line value so the total is not an + // exact multiple of the column width (which would mean zero + // sub-cell offset and no visible smooth-scroll effect). + constexpr tools::Long nFixedLinePx = 40; + SAL_INFO("sc.smooth", " -> Notch-horiz path, totalPx=" + << nNotchDelta * static_cast(nScrollLines) * nFixedLinePx); + SmoothScrollX(nNotchDelta * static_cast(nScrollLines) * nFixedLinePx, + eHPos); + } + else + { + // Same: use a fixed 40 px per scroll line instead of the + // actual row height, so the delta is generally not an exact + // multiple of the row height and a sub-cell offset is produced. + constexpr tools::Long nFixedLinePx = 40; + SAL_INFO("sc.smooth", " -> Notch-vert path, totalPx=" + << nNotchDelta * static_cast(nScrollLines) * nFixedLinePx); + SmoothScrollY(nNotchDelta * static_cast(nScrollLines) * nFixedLinePx, + eVPos); + } + } + } + bDone = true; + } else { ScHSplitPos eHPos = WhichH(ePos); @@ -1018,7 +1089,6 @@ bool ScTabView::GesturePanCommand(const CommandEvent& rCEvt) { HideNoteOverlay(); - bool bDone = false; const CommandGesturePanData* pData = rCEvt.GetGesturePanData(); if (!pData) return false; @@ -1026,15 +1096,46 @@ bool ScTabView::GesturePanCommand(const CommandEvent& rCEvt) if (aViewData.GetViewShell()->GetViewFrame().GetFrame().IsInPlace()) return false; + if (comphelper::LibreOfficeKit::isActive()) + return false; + ScSplitPos ePos = aViewData.GetActivePart(); ScHSplitPos eHPos = WhichH(ePos); ScVSplitPos eVPos = WhichV(ePos); - ScrollAdaptor* pHScroll = (eHPos == SC_SPLIT_LEFT) ? aHScrollLeft.get() : aHScrollRight.get(); - ScrollAdaptor* pVScroll = (eVPos == SC_SPLIT_TOP) ? aVScrollTop.get() : aVScrollBottom.get(); - if (pGridWin[ePos]) - bDone = pGridWin[ePos]->HandleScrollCommand(rCEvt, pHScroll, pVScroll); - return bDone; + if (pData->meEventType == GestureEventPanType::Begin) + { + mfPreviousPanOffsetX = mfPreviousPanOffsetY = 0.0; + return true; + } + + if (pData->meEventType == GestureEventPanType::Update) + { + if (pData->meOrientation == PanningOrientation::Vertical) + { + // mfOffset is the cumulative displacement since Begin; positive = finger moved down. + tools::Long nDelta = static_cast(pData->mfOffset - mfPreviousPanOffsetY); + mfPreviousPanOffsetY = pData->mfOffset; + if (nDelta != 0) + SmoothScrollY(-nDelta, eVPos); + } + else + { + tools::Long nDelta = static_cast(pData->mfOffset - mfPreviousPanOffsetX); + mfPreviousPanOffsetX = pData->mfOffset; + if (nDelta != 0) + SmoothScrollX(-nDelta, eHPos); + } + return true; + } + + if (pData->meEventType == GestureEventPanType::End) + { + mfPreviousPanOffsetX = mfPreviousPanOffsetY = 0.0; + return true; + } + + return false; } bool ScTabView::GestureZoomCommand(const CommandEvent& rCEvt) @@ -1130,7 +1231,28 @@ void ScTabView::ScrollHdl(ScrollAdaptor* pScroll) if (!bDragging) { bDragging = true; - nPrevDragPos = nViewPos; + // For vertical scrollbars, nPrevDragPos must be in precision units + // so the anti-jitter in the default case compares like-for-like. + if (!bHoriz && (pScroll == aVScrollBottom.get() || pScroll == aVScrollTop.get())) + { + ScVSplitPos eVPInit = (pScroll == aVScrollTop.get()) ? SC_SPLIT_TOP : SC_SPLIT_BOTTOM; + tools::Long nScrollMinInit = 0; + if (aViewData.GetVSplitMode() == SC_SPLIT_FIX && pScroll == aVScrollBottom.get()) + nScrollMinInit = aViewData.GetFixPosY(); + SCROW nCurPosInit = aViewData.GetPosY(eVPInit); + tools::Long nOffInit = aViewData.GetPixOffsetY(eVPInit); + SCTAB nTabInit = aViewData.CurrentTabForData(); + tools::Long nRowPxInit = std::max(1L, aViewData.ToPixel( + aViewData.GetDocument().GetRowHeight(nCurPosInit, nTabInit), + aViewData.GetPPTY())); + tools::Long nSubInit = nOffInit == 0 ? 0 + : (-nOffInit * SC_VSCROLL_PRECISION + nRowPxInit / 2) / nRowPxInit; + nPrevDragPos = (nCurPosInit - nScrollMinInit) * SC_VSCROLL_PRECISION + nSubInit; + } + else + { + nPrevDragPos = nViewPos; + } } // show scroll position @@ -1160,7 +1282,11 @@ void ScTabView::ScrollHdl(ScrollAdaptor* pScroll) nScrollMin = aViewData.GetFixPosX(); if ( aViewData.GetVSplitMode()==SC_SPLIT_FIX && pScroll == aVScrollBottom.get() ) nScrollMin = aViewData.GetFixPosY(); - tools::Long nScrollPos = GetScrollBarPos( *pScroll, bLayoutRTL ) + nScrollMin; + tools::Long nScrollPos = GetScrollBarPos( *pScroll, bLayoutRTL ); + if (!bHoriz) + nScrollPos = nScrollPos / SC_VSCROLL_PRECISION + nScrollMin; // precision → row + else + nScrollPos += nScrollMin; OUString aHelpStr; tools::Rectangle aRect; @@ -1212,6 +1338,9 @@ void ScTabView::ScrollHdl(ScrollAdaptor* pScroll) } tools::Long nDelta(0); + // true → nDelta is in row/col units (LineUp/Down/Page) + // false → nDelta is in SC_VSCROLL_PRECISION units (vertical drag via default case) + bool bDeltaIsRows = true; switch ( eType ) { case ScrollType::LineUp: @@ -1243,6 +1372,39 @@ void ScTabView::ScrollHdl(ScrollAdaptor* pScroll) if ( aViewData.GetVSplitMode()==SC_SPLIT_FIX && pScroll == aVScrollBottom.get() ) nScrollMin = aViewData.GetFixPosY(); + if (!bHoriz) + { + // Vertical scrollbar uses SC_VSCROLL_PRECISION units per row. + // Compute the delta in those precision units directly from the thumb. + constexpr tools::Long P = SC_VSCROLL_PRECISION; + ScVSplitPos eVPLocal = (pScroll == aVScrollTop.get()) ? SC_SPLIT_TOP : SC_SPLIT_BOTTOM; + SCTAB nTabV = aViewData.CurrentTabForData(); + ScDocument& rDocV = aViewData.GetDocument(); + + tools::Long nNewThumb = pScroll->GetThumbPos(); // relative precision units + + // Reconstruct current thumb from view state + SCROW nCurPosY = aViewData.GetPosY(eVPLocal); + tools::Long nCurOff = aViewData.GetPixOffsetY(eVPLocal); + tools::Long nCurRowPx = std::max(1L, aViewData.ToPixel( + rDocV.GetRowHeight(nCurPosY, nTabV), aViewData.GetPPTY())); + tools::Long nCurSubRow = nCurOff == 0 ? 0 + : (-nCurOff * P + nCurRowPx / 2) / nCurRowPx; + tools::Long nOldThumb = (nCurPosY - nScrollMin) * P + nCurSubRow; + + nDelta = nNewThumb - nOldThumb; // precision units + bDeltaIsRows = false; + + if (eType == ScrollType::Drag) + { + if (nNewThumb > nPrevDragPos && nDelta < 0) nDelta = 0; + else if (nNewThumb < nPrevDragPos && nDelta > 0) nDelta = 0; + else if (nNewThumb == nPrevDragPos) nDelta = 0; + } + nPrevDragPos = nNewThumb; + break; // skip horizontal default logic + } + tools::Long nScrollPos = GetScrollBarPos( *pScroll, bLayoutRTL ) + nScrollMin; nDelta = nScrollPos - nViewPos; @@ -1343,9 +1505,37 @@ void ScTabView::ScrollHdl(ScrollAdaptor* pScroll) { bool bUpdate = ( eType != ScrollType::Drag ); // don't alter the ranges while dragging if ( bHoriz ) + { ScrollX( nDelta, (pScroll == aHScrollLeft.get()) ? SC_SPLIT_LEFT : SC_SPLIT_RIGHT, bUpdate ); + } else - ScrollY( nDelta, (pScroll == aVScrollTop.get()) ? SC_SPLIT_TOP : SC_SPLIT_BOTTOM, bUpdate ); + { + ScVSplitPos eVPFinal = (pScroll == aVScrollTop.get()) ? SC_SPLIT_TOP : SC_SPLIT_BOTTOM; + if (!bDeltaIsRows) + { + // nDelta is in SC_VSCROLL_PRECISION units; convert to pixels and smooth-scroll. + constexpr tools::Long P = SC_VSCROLL_PRECISION; + SCTAB nTabFinal = aViewData.CurrentTabForData(); + tools::Long nRowPxFinal = std::max(1L, aViewData.ToPixel( + aViewData.GetDocument().GetRowHeight(aViewData.GetPosY(eVPFinal), nTabFinal), + aViewData.GetPPTY())); + tools::Long nPixFinal = nDelta * nRowPxFinal / P; + if (nPixFinal != 0) + SmoothScrollY(nPixFinal, eVPFinal); + // else: sub-pixel precision delta — skip to avoid row-snap + } + else + { + // nDelta in rows (LineUp/Down/Page): convert to pixels for smooth blit. + SCTAB nTabFinal = aViewData.CurrentTabForData(); + tools::Long nRowPxFinal = std::max(1L, aViewData.ToPixel( + aViewData.GetDocument().GetRowHeight(aViewData.GetPosY(eVPFinal), nTabFinal), + aViewData.GetPPTY())); + tools::Long nPixFinal = nDelta * nRowPxFinal; + if (nPixFinal != 0) + SmoothScrollY(nPixFinal, eVPFinal); + } + } } // tdf#161945 update horizontal scrollbar position to match tab view @@ -1534,6 +1724,263 @@ void ScTabView::ScrollLines( tools::Long nDeltaX, tools::Long nDeltaY ) ScrollY(nDeltaY,WhichV(eWhich)); } +void ScTabView::SmoothScrollY( tools::Long nPixelDelta, ScVSplitPos eWhich ) +{ + fprintf(stderr, "DBG SmoothScrollY: nPixelDelta=%ld\n", static_cast(nPixelDelta)); + fflush(stderr); + SAL_INFO("sc.smooth", "SmoothScrollY: nPixelDelta=" << nPixelDelta << " eWhich=" << static_cast(eWhich)); + + // Fall back to cell-granular scrolling in tiled rendering mode. + if (comphelper::LibreOfficeKit::isActive()) + { + SAL_INFO("sc.smooth", " -> LOK fallback"); + ScrollY(nPixelDelta > 0 ? 1 : -1, eWhich); + return; + } + // The frozen top pane does not scroll. + if (aViewData.GetVSplitMode() == SC_SPLIT_FIX && eWhich == SC_SPLIT_TOP) + { + SAL_INFO("sc.smooth", " -> frozen top pane, skip"); + return; + } + + ScDocument& rDoc = aViewData.GetDocument(); + SCTAB nTab = aViewData.CurrentTabForData(); + double nPPTY = aViewData.GetPPTY(); + + tools::Long nCurrentOffset = aViewData.GetPixOffsetY(eWhich); + SCROW nPosY = aViewData.GetPosY(eWhich); + SAL_INFO("sc.smooth", " currentOffset=" << nCurrentOffset << " posY=" << nPosY << " nPPTY=" << nPPTY); + + // nNewOffset = current sub-cell offset minus delta. + // Positive nPixelDelta = scroll down (content moves up), offset becomes more negative. + tools::Long nNewOffset = nCurrentOffset - nPixelDelta; + + // Track how many pixels we actually crossed row boundaries for the blit. + tools::Long nRowsCrossedPx = 0; + + // Advance rows: nNewOffset went negative past the end of the current top row. + while (nNewOffset < 0 && nPosY < rDoc.MaxRow()) + { + // Skip hidden rows. + while (nPosY < rDoc.MaxRow() && rDoc.RowHidden(nPosY, nTab)) + ++nPosY; + if (rDoc.RowHidden(nPosY, nTab)) + break; + + tools::Long nRowPx = ScViewData::ToPixel( + sal::static_int_cast(rDoc.GetRowHeight(nPosY, nTab)), nPPTY); + if (nRowPx == 0) + { + ++nPosY; + continue; + } + if (-nNewOffset < nRowPx) + break; // offset fits within this row + + nRowsCrossedPx += nRowPx; + nNewOffset += nRowPx; + ++nPosY; + } + + // Retreat rows: nNewOffset is positive, scroll up past cell boundary. + while (nNewOffset > 0 && nPosY > 0) + { + --nPosY; + while (nPosY > 0 && rDoc.RowHidden(nPosY, nTab)) + --nPosY; + + tools::Long nRowPx = ScViewData::ToPixel( + sal::static_int_cast(rDoc.GetRowHeight(nPosY, nTab)), nPPTY); + nRowsCrossedPx -= nRowPx; + nNewOffset -= nRowPx; + } + + // Clamp at document top. + if (nPosY <= 0 && nNewOffset > 0) + nNewOffset = 0; + if (nNewOffset > 0) + nNewOffset = 0; + // Clamp at document bottom. + if (nPosY >= rDoc.MaxRow()) + { + nPosY = rDoc.MaxRow(); + if (nNewOffset < 0) + nNewOffset = 0; + } + + // Actual blit distance (positive = content moves up). + // By construction this equals nPixelDelta when unclamped; + // when clamped at an edge, it reflects the achievable movement. + tools::Long nBlitDelta = nRowsCrossedPx + (nCurrentOffset - nNewOffset); + + fprintf(stderr, "DBG SmoothScrollY result: newOffset=%ld newPosY=%d rowsCrossedPx=%ld blitDelta=%ld\n", + static_cast(nNewOffset), static_cast(nPosY), + static_cast(nRowsCrossedPx), static_cast(nBlitDelta)); + fflush(stderr); + + if (nBlitDelta == 0 && nPosY == aViewData.GetPosY(eWhich)) + { + fprintf(stderr, "DBG SmoothScrollY: no movement, early return\n"); + fflush(stderr); + return; + } + + HideAllCursors(); + + if (nPosY != aViewData.GetPosY(eWhich)) + { + SCROW nUNew = nPosY; + UpdateHeaderWidth(&eWhich, &nUNew); + if (pRowBar[eWhich]) + pRowBar[eWhich]->PaintImmediately(); + aViewData.SetPosY(eWhich, nPosY); // resets nPixOffsetY to 0 + } + + aViewData.SetPixOffsetY(eWhich, nNewOffset); + + if (eWhich == SC_SPLIT_BOTTOM) + { + pGridWin[SC_SPLIT_BOTTOMLEFT]->ScrollPixel(0, -nBlitDelta); + if (aViewData.GetHSplitMode() != SC_SPLIT_NONE) + pGridWin[SC_SPLIT_BOTTOMRIGHT]->ScrollPixel(0, -nBlitDelta); + } + else + { + pGridWin[SC_SPLIT_TOPLEFT]->ScrollPixel(0, -nBlitDelta); + if (aViewData.GetHSplitMode() != SC_SPLIT_NONE) + pGridWin[SC_SPLIT_TOPRIGHT]->ScrollPixel(0, -nBlitDelta); + } + if (pRowBar[eWhich]) + { + pRowBar[eWhich]->Scroll(0, -nBlitDelta); + pRowBar[eWhich]->PaintImmediately(); + } + if (pRowOutline[eWhich]) + pRowOutline[eWhich]->ScrollPixel(-nBlitDelta); + + UpdateScrollBars(ROW_HEADER); + ShowAllCursors(); + SetNewVisArea(); + TestHintWindow(); +} + +void ScTabView::SmoothScrollX( tools::Long nPixelDelta, ScHSplitPos eWhich ) +{ + if (comphelper::LibreOfficeKit::isActive()) + { + ScrollX(nPixelDelta > 0 ? 1 : -1, eWhich); + return; + } + // The frozen left pane does not scroll. + if (aViewData.GetHSplitMode() == SC_SPLIT_FIX && eWhich == SC_SPLIT_LEFT) + return; + + ScDocument& rDoc = aViewData.GetDocument(); + SCTAB nTab = aViewData.CurrentTabForData(); + double nPPTX = aViewData.GetPPTX(); + bool bLayoutRTL = rDoc.IsLayoutRTL(nTab); + + tools::Long nCurrentOffset = aViewData.GetPixOffsetX(eWhich); + SCCOL nPosX = aViewData.GetPosX(eWhich); + // In fixed-split right pane, never scroll left of the freeze position. + SCCOL nMinPosX = (aViewData.GetHSplitMode() == SC_SPLIT_FIX && eWhich == SC_SPLIT_RIGHT) + ? aViewData.GetFixPosX() : 0; + + tools::Long nEffDelta = bLayoutRTL ? -nPixelDelta : nPixelDelta; + tools::Long nNewOffset = nCurrentOffset - nEffDelta; + tools::Long nColsCrossedPx = 0; + + // Advance columns. + while (nNewOffset < 0 && nPosX < rDoc.MaxCol()) + { + while (nPosX < rDoc.MaxCol() && rDoc.ColHidden(nPosX, nTab)) + ++nPosX; + if (rDoc.ColHidden(nPosX, nTab)) + break; + + tools::Long nColPx = ScViewData::ToPixel( + sal::static_int_cast(rDoc.GetColWidth(nPosX, nTab)), nPPTX); + if (nColPx == 0) + { + ++nPosX; + continue; + } + if (-nNewOffset < nColPx) + break; + + nColsCrossedPx += nColPx; + nNewOffset += nColPx; + ++nPosX; + } + + // Retreat columns. + while (nNewOffset > 0 && nPosX > nMinPosX) + { + --nPosX; + while (nPosX > nMinPosX && rDoc.ColHidden(nPosX, nTab)) + --nPosX; + + tools::Long nColPx = ScViewData::ToPixel( + sal::static_int_cast(rDoc.GetColWidth(nPosX, nTab)), nPPTX); + nColsCrossedPx -= nColPx; + nNewOffset -= nColPx; + } + + if (nPosX <= nMinPosX && nNewOffset > 0) + nNewOffset = 0; + if (nNewOffset > 0) + nNewOffset = 0; + if (nPosX >= rDoc.MaxCol()) + { + nPosX = rDoc.MaxCol(); + if (nNewOffset < 0) + nNewOffset = 0; + } + + tools::Long nBlitDelta = nColsCrossedPx + (nCurrentOffset - nNewOffset); + tools::Long nBlitX = bLayoutRTL ? nBlitDelta : -nBlitDelta; + + if (nBlitDelta == 0 && nPosX == aViewData.GetPosX(eWhich)) + return; + + HideAllCursors(); + + if (nPosX != aViewData.GetPosX(eWhich)) + { + if (pColBar[eWhich]) + pColBar[eWhich]->PaintImmediately(); + aViewData.SetPosX(eWhich, nPosX); // resets nPixOffsetX to 0 + } + + aViewData.SetPixOffsetX(eWhich, nNewOffset); + + if (eWhich == SC_SPLIT_LEFT) + { + pGridWin[SC_SPLIT_BOTTOMLEFT]->ScrollPixel(nBlitX, 0); + if (aViewData.GetVSplitMode() != SC_SPLIT_NONE) + pGridWin[SC_SPLIT_TOPLEFT]->ScrollPixel(nBlitX, 0); + } + else + { + pGridWin[SC_SPLIT_BOTTOMRIGHT]->ScrollPixel(nBlitX, 0); + if (aViewData.GetVSplitMode() != SC_SPLIT_NONE) + pGridWin[SC_SPLIT_TOPRIGHT]->ScrollPixel(nBlitX, 0); + } + if (pColBar[eWhich]) + { + pColBar[eWhich]->Scroll(nBlitX, 0); + pColBar[eWhich]->PaintImmediately(); + } + if (pColOutline[eWhich]) + pColOutline[eWhich]->ScrollPixel(nBlitX); + + UpdateScrollBars(COLUMN_HEADER); + ShowAllCursors(); + SetNewVisArea(); + TestHintWindow(); +} + namespace { diff --git a/sc/source/ui/view/tabview4.cxx b/sc/source/ui/view/tabview4.cxx index a7a4d7f64524f..60d4b2ba4d328 100644 --- a/sc/source/ui/view/tabview4.cxx +++ b/sc/source/ui/view/tabview4.cxx @@ -499,7 +499,19 @@ void ScTabView::UpdateScrollBars( HeaderType eHeaderType ) nVisYB = aViewData.VisibleCellsY( SC_SPLIT_BOTTOM ); tools::Long nMaxYB = lcl_GetScrollRange( nUsedY, aViewData.GetPosY(SC_SPLIT_BOTTOM), nVisYB, rDoc.MaxRow(), nStartY ); - SetScrollBar( *aVScrollBottom, nMaxYB, nVisYB, aViewData.GetPosY( SC_SPLIT_BOTTOM ) - nStartY, false ); + { + // Scale vertical scrollbar by SC_VSCROLL_PRECISION for sub-row smooth dragging. + constexpr tools::Long P = SC_VSCROLL_PRECISION; + SCROW nPosYB = aViewData.GetPosY(SC_SPLIT_BOTTOM); + tools::Long nOffYB = aViewData.GetPixOffsetY(SC_SPLIT_BOTTOM); + tools::Long nRowPxB = std::max(1L, aViewData.ToPixel( + rDoc.GetRowHeight(nPosYB, nTab), aViewData.GetPPTY())); + // Sub-row fraction: 0..(P-1) units of the current top row already scrolled + tools::Long nSubRowB = nOffYB == 0 ? 0 : (-nOffYB * P + nRowPxB / 2) / nRowPxB; + tools::Long nThumbB = (nPosYB - nStartY) * P + nSubRowB; + SetScrollBar(*aVScrollBottom, nMaxYB * P, nVisYB * P, nThumbB, false); + aVScrollBottom->SetLineSize(P); // 1 arrow click = 1 full row = P precision units + } if (bRight) { @@ -525,8 +537,19 @@ void ScTabView::UpdateScrollBars( HeaderType eHeaderType ) if (nDiff) ScrollX( nDiff, SC_SPLIT_RIGHT ); } - nDiff = lcl_UpdateBar( *aVScrollBottom, nVisYB ); - if (nDiff) ScrollY( nDiff, SC_SPLIT_BOTTOM ); + { + constexpr tools::Long P = SC_VSCROLL_PRECISION; + nDiff = lcl_UpdateBar(*aVScrollBottom, nVisYB * P); + if (nDiff) + { + SCROW nPosYB2 = aViewData.GetPosY(SC_SPLIT_BOTTOM); + tools::Long nRowPxB2 = std::max(1L, aViewData.ToPixel( + rDoc.GetRowHeight(nPosYB2, nTab), aViewData.GetPPTY())); + tools::Long nPxDiff = (nDiff * nRowPxB2 + (nDiff > 0 ? P/2 : -P/2)) / P; // round + if (nPxDiff != 0) + SmoothScrollY(nPxDiff, SC_SPLIT_BOTTOM); + } + } if (bTop) { nDiff = lcl_UpdateBar( *aVScrollTop, nVisYT ); diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index cdf852a7fab01..b317dc4ba59bd 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -523,6 +523,8 @@ ScViewDataTable::ScViewDataTable(const ScDocument& rDoc) : nMPosY[0]=nMPosY[1]=0; nPixPosX[0]=nPixPosX[1]=0; nPixPosY[0]=nPixPosY[1]=0; + nPixOffsetX[0]=nPixOffsetX[1]=0; + nPixOffsetY[0]=nPixOffsetY[1]=0; } void ScViewDataTable::WriteUserDataSequence(uno::Sequence & rSettings, const ScViewData& rViewData, SCTAB nTab) const @@ -2624,7 +2626,7 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, bool bIsTiledRendering = comphelper::LibreOfficeKit::isActive(); SCCOL nPosX = GetPosX(eWhichX, nForTab); - tools::Long nScrPosX = 0; + tools::Long nScrPosX = 0; // 0 for off-screen (nWhereX < nPosX && !bAllowNeg) if (bAllowNeg || nWhereX >= nPosX) { @@ -2636,6 +2638,10 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, nStartPosX = rNearest.first + 1; nScrPosX = rNearest.second; } + else + { + nScrPosX = pViewTable->nPixOffsetX[eWhichX]; + } if (nWhereX >= nStartPosX) { @@ -2684,7 +2690,7 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, SCROW nPosY = GetPosY(eWhichY, nForTab); - tools::Long nScrPosY = 0; + tools::Long nScrPosY = 0; // 0 for off-screen (nWhereY < nPosY && !bAllowNeg) if (bAllowNeg || nWhereY >= nPosY) { @@ -2696,6 +2702,10 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, nStartPosY = rNearest.first + 1; nScrPosY = rNearest.second; } + else + { + nScrPosY = pViewTable->nPixOffsetY[eWhichY]; + } if (nWhereY >= nStartPosY) { @@ -2705,7 +2715,7 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, if ( nStartPosY > mrDoc.MaxRow() ) nScrPosY = 0x7FFFFFFF; else - nScrPosY = mrDoc.GetScaledRowHeight(nStartPosY, nWhereY - 1, CurrentTabForData(), nPPTY); + nScrPosY += mrDoc.GetScaledRowHeight(nStartPosY, nWhereY - 1, CurrentTabForData(), nPPTY); } else { @@ -3031,8 +3041,9 @@ void ScViewData::GetPosFromPixel( tools::Long nClickX, tools::Long nClickY, ScSp SCROW nStartPosY = GetPosY(eVWhich, nForTab); rPosX = nStartPosX; rPosY = nStartPosY; - tools::Long nScrX = 0; - tools::Long nScrY = 0; + bool bIsTiledRenderingForPixel = comphelper::LibreOfficeKit::isActive(); + tools::Long nScrX = bIsTiledRenderingForPixel ? 0 : pThisTab->nPixOffsetX[eHWhich]; + tools::Long nScrY = bIsTiledRenderingForPixel ? 0 : pThisTab->nPixOffsetY[eVWhich]; if (nClickX > 0) { @@ -3163,10 +3174,18 @@ void ScViewData::SetPosX( ScHSplitPos eWhich, SCCOL nNewPosX ) pThisTab->nMPosX[eWhich] = pThisTab->nPosX[eWhich] = 0; } + // Cell-granular scroll always snaps to a cell boundary; reset sub-cell offset. + pThisTab->nPixOffsetX[eWhich] = 0; } void ScViewData::SetPosY( ScVSplitPos eWhich, SCROW nNewPosY ) { + fprintf(stderr, "DBG SetPosY: eWhich=%d nNewPosY=%d (was=%d offset=%ld) caller=%p\n", + static_cast(eWhich), static_cast(nNewPosY), + static_cast(pThisTab->nPosY[eWhich]), + static_cast(pThisTab->nPixOffsetY[eWhich]), + static_cast(__builtin_return_address(0))); + fflush(stderr); // in the tiled rendering case, nPosY [the topmost visible row] must be 0 bool bIsTiledRendering = comphelper::LibreOfficeKit::isActive(); if (nNewPosY != 0 && !bIsTiledRendering) @@ -3206,6 +3225,8 @@ void ScViewData::SetPosY( ScVSplitPos eWhich, SCROW nNewPosY ) pThisTab->nMPosY[eWhich] = pThisTab->nPosY[eWhich] = 0; } + // Cell-granular scroll always snaps to a cell boundary; reset sub-cell offset. + pThisTab->nPixOffsetY[eWhich] = 0; } void ScViewData::RecalcPixPos() // after zoom changes @@ -3229,13 +3250,47 @@ void ScViewData::RecalcPixPos() // after zoom changes nPixPosY -= nRowHeight; } pThisTab->nPixPosY[eWhich] = nPixPosY; + // Reset sub-cell offsets on zoom change so rendering is cell-aligned. + pThisTab->nPixOffsetX[eWhich] = 0; + pThisTab->nPixOffsetY[eWhich] = 0; } } +void ScViewData::SetPixOffsetX( ScHSplitPos eWhich, tools::Long nOffsetPixels ) +{ + // Guard: tiled rendering keeps nPosX == 0 and uses no sub-cell offset. + if (comphelper::LibreOfficeKit::isActive()) + return; + OSL_ENSURE(nOffsetPixels <= 0, "ScViewData::SetPixOffsetX: offset must be <= 0"); + pThisTab->nPixOffsetX[eWhich] = nOffsetPixels; + // nMPosX/nTPosX remain at cell boundary; GetLogicMode() applies the offset on the fly. +} + +void ScViewData::SetPixOffsetY( ScVSplitPos eWhich, tools::Long nOffsetPixels ) +{ + if (comphelper::LibreOfficeKit::isActive()) + return; + OSL_ENSURE(nOffsetPixels <= 0, "ScViewData::SetPixOffsetY: offset must be <= 0"); + pThisTab->nPixOffsetY[eWhich] = nOffsetPixels; +} + const MapMode& ScViewData::GetLogicMode( ScSplitPos eWhich ) { - aLogicMode.SetOrigin( Point( pThisTab->nMPosX[WhichH(eWhich)], - pThisTab->nMPosY[WhichV(eWhich)] ) ); + ScHSplitPos eH = WhichH(eWhich); + ScVSplitPos eV = WhichV(eWhich); + tools::Long nMOffX = pThisTab->nMPosX[eH]; + tools::Long nMOffY = pThisTab->nMPosY[eV]; + // Apply sub-cell pixel offset (pixels -> twips -> 1/100 mm) for smooth scrolling. + // nPixOffsetX/Y are <= 0, so this shifts the origin further negative (content left/up). + if (pThisTab->nPixOffsetX[eH] != 0) + nMOffX += static_cast( + o3tl::convert(pThisTab->nPixOffsetX[eH] / nPPTX, + o3tl::Length::twip, o3tl::Length::mm100)); + if (pThisTab->nPixOffsetY[eV] != 0) + nMOffY += static_cast( + o3tl::convert(pThisTab->nPixOffsetY[eV] / nPPTY, + o3tl::Length::twip, o3tl::Length::mm100)); + aLogicMode.SetOrigin( Point(nMOffX, nMOffY) ); return aLogicMode; } From aa111b3addfabbbf8438089720f5c5671bae94ba Mon Sep 17 00:00:00 2001 From: Kevin Kettinger Date: Wed, 17 Jun 2026 12:26:00 +0000 Subject: [PATCH 2/5] sc: fix scroll artifacts in smooth-scroll Calc (tdf#40917 follow-up) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two rendering bugs caused gray artifact lines during sub-cell scrolling: 1. ScGridWindow::Paint() initialized AddPixelsWhile from nScrY=0, treating the top row as if it always starts at y=0. With nPixOffsetY<0 the post-loop nScrY was too large, so the nY2 range check fired too early and the exposed strip was clipped short by one row — leaving a thin unpainted gray strip on every upward scroll event that accumulated into wider bands after subsequent downward blits. Fix: initialize nScrY from GetPixOffsetY(eVWhich) so AddPixelsWhile correctly resolves which rows cover the clip rectangle. 2. SmoothScrollY used ScrollPixel (blit + DrawAfterScroll). ScrollPixel sets the mm100 MapMode — which embeds a fractional nPixOffsetY origin — before calling PaintImmediately. VCL then delivers the paint rect in mm100 logical units; the LogicToPixel round-trip could drop ±1 px from the clip rect, leaving a 1-pixel artifact line. Fix: replace ScrollPixel with Invalidate + PaintImmediately, which does a full pixel-exact repaint via the compositor's double-buffering and is artifact-free. Co-Authored-By: Claude Sonnet 4.6 Change-Id: I49f3cff0742c8b947cd9985a55f40bc9807f519e --- sc/source/ui/view/gridwin4.cxx | 6 +++++- sc/source/ui/view/tabview.cxx | 29 +++++++++++++++++++++++------ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index 5d56094de87be..790ecb3f7aa5c 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -427,7 +427,11 @@ void ScGridWindow::Paint( vcl::RenderContext& /*rRenderContext*/, const tools::R nScrX += ScViewData::ToPixel( rDoc.GetColWidth( nX2, nTab ), nPPTX ); } - tools::Long nScrY = 0; + // Start accumulation from the sub-cell pixel offset so AddPixelsWhile + // correctly identifies which rows cover any given clip rectangle. + // Without this, when nPixOffsetY < 0 the post-loop nScrY is too large, + // the nY2 range check fires too early, and the exposed strip is clipped short. + tools::Long nScrY = mrViewData.GetPixOffsetY(eVWhich); ScViewData::AddPixelsWhile( nScrY, aPixRect.Top(), nY1, rDoc.MaxRow(), nPPTY, &rDoc, nTab); SCROW nY2 = nY1; if (nScrY <= aPixRect.Bottom() && nY2 < rDoc.MaxRow()) diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx index 769950591448e..fb217be6ec268 100644 --- a/sc/source/ui/view/tabview.cxx +++ b/sc/source/ui/view/tabview.cxx @@ -1839,25 +1839,42 @@ void ScTabView::SmoothScrollY( tools::Long nPixelDelta, ScVSplitPos eWhich ) aViewData.SetPixOffsetY(eWhich, nNewOffset); + // Invalidate + PaintImmediately instead of ScrollPixel blit. + // ScrollPixel sets the mm100 MapMode (with fractional nPixOffsetY origin) before + // DrawAfterScroll, so Paint() receives rRect in mm100 logical units; the LogicToPixel + // round-trip can drop ±1 px from the clip rect, leaving a thin artifact line. + // A full invalidate+repaint costs one extra full-paint but is pixel-exact and + // artifact-free; the compositor's double-buffering keeps scrolling smooth. if (eWhich == SC_SPLIT_BOTTOM) { - pGridWin[SC_SPLIT_BOTTOMLEFT]->ScrollPixel(0, -nBlitDelta); + pGridWin[SC_SPLIT_BOTTOMLEFT]->Invalidate(); + pGridWin[SC_SPLIT_BOTTOMLEFT]->PaintImmediately(); if (aViewData.GetHSplitMode() != SC_SPLIT_NONE) - pGridWin[SC_SPLIT_BOTTOMRIGHT]->ScrollPixel(0, -nBlitDelta); + { + pGridWin[SC_SPLIT_BOTTOMRIGHT]->Invalidate(); + pGridWin[SC_SPLIT_BOTTOMRIGHT]->PaintImmediately(); + } } else { - pGridWin[SC_SPLIT_TOPLEFT]->ScrollPixel(0, -nBlitDelta); + pGridWin[SC_SPLIT_TOPLEFT]->Invalidate(); + pGridWin[SC_SPLIT_TOPLEFT]->PaintImmediately(); if (aViewData.GetHSplitMode() != SC_SPLIT_NONE) - pGridWin[SC_SPLIT_TOPRIGHT]->ScrollPixel(0, -nBlitDelta); + { + pGridWin[SC_SPLIT_TOPRIGHT]->Invalidate(); + pGridWin[SC_SPLIT_TOPRIGHT]->PaintImmediately(); + } } if (pRowBar[eWhich]) { - pRowBar[eWhich]->Scroll(0, -nBlitDelta); + pRowBar[eWhich]->Invalidate(); pRowBar[eWhich]->PaintImmediately(); } if (pRowOutline[eWhich]) - pRowOutline[eWhich]->ScrollPixel(-nBlitDelta); + { + pRowOutline[eWhich]->Invalidate(); + pRowOutline[eWhich]->PaintImmediately(); + } UpdateScrollBars(ROW_HEADER); ShowAllCursors(); From b2b53fce323caf6d4db2b14976fa21355cf19ffa Mon Sep 17 00:00:00 2001 From: Kevin Kettinger Date: Wed, 17 Jun 2026 12:31:17 +0000 Subject: [PATCH 3/5] sc: fix snap-to-row on large cells during scrollbar drag (tdf#40917) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The scrollbar drag handler computed the pixel scroll distance as: nPixFinal = nDelta_precision_units * currentTopRow_height / P This used the CURRENT top row's height as the conversion factor. When the drag crosses into a row with a different height (e.g. a tall merged cell), the factor is wrong: the pixel delta under-shoots, so the view never smoothly transits through the large cell and instead jumps to its boundary — reverting to old snap-to-row behaviour. Fix: instead of computing a relative precision-unit delta and scaling by the current row height, derive the target (row, sub-row offset) directly from the absolute scrollbar thumb position and compute the exact pixel distance by summing the actual heights of every row between the current and target positions. This is correct for any mixture of row heights. Co-Authored-By: Claude Sonnet 4.6 Change-Id: I603072e5ea858eb5cde3081dd83d05046015732c --- sc/source/ui/view/tabview.cxx | 97 ++++++++++++++++++++--------------- 1 file changed, 55 insertions(+), 42 deletions(-) diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx index fb217be6ec268..00ac42959d927 100644 --- a/sc/source/ui/view/tabview.cxx +++ b/sc/source/ui/view/tabview.cxx @@ -1338,9 +1338,6 @@ void ScTabView::ScrollHdl(ScrollAdaptor* pScroll) } tools::Long nDelta(0); - // true → nDelta is in row/col units (LineUp/Down/Page) - // false → nDelta is in SC_VSCROLL_PRECISION units (vertical drag via default case) - bool bDeltaIsRows = true; switch ( eType ) { case ScrollType::LineUp: @@ -1374,35 +1371,65 @@ void ScTabView::ScrollHdl(ScrollAdaptor* pScroll) if (!bHoriz) { - // Vertical scrollbar uses SC_VSCROLL_PRECISION units per row. - // Compute the delta in those precision units directly from the thumb. + // Vertical scrollbar: derive the pixel delta directly from the absolute + // thumb value using actual per-row heights. The old approach multiplied + // a precision-unit delta by the CURRENT top row's height, which gave the + // wrong result when crossing into a row with a different height (large + // cells snapped instead of scrolling smoothly through). constexpr tools::Long P = SC_VSCROLL_PRECISION; ScVSplitPos eVPLocal = (pScroll == aVScrollTop.get()) ? SC_SPLIT_TOP : SC_SPLIT_BOTTOM; SCTAB nTabV = aViewData.CurrentTabForData(); ScDocument& rDocV = aViewData.GetDocument(); - tools::Long nNewThumb = pScroll->GetThumbPos(); // relative precision units + tools::Long nNewThumb = pScroll->GetThumbPos(); - // Reconstruct current thumb from view state + // Compute target (row, sub-row offset) from absolute thumb position. + SCROW nTargetRow = static_cast(nNewThumb / P) + + static_cast(nScrollMin); + tools::Long nSubFrac = nNewThumb % P; // 0..P-1 within target row + nTargetRow = std::clamp(nTargetRow, + static_cast(nScrollMin), rDocV.MaxRow()); + + // Target pixel offset within the target row (≤ 0), using that row's + // actual height — not the current top row's height. + tools::Long nTargetRowPx = std::max(1L, aViewData.ToPixel( + rDocV.GetRowHeight(nTargetRow, nTabV), aViewData.GetPPTY())); + tools::Long nTargetOffset = -(nSubFrac * nTargetRowPx) / P; + + // Current position SCROW nCurPosY = aViewData.GetPosY(eVPLocal); tools::Long nCurOff = aViewData.GetPixOffsetY(eVPLocal); - tools::Long nCurRowPx = std::max(1L, aViewData.ToPixel( - rDocV.GetRowHeight(nCurPosY, nTabV), aViewData.GetPPTY())); - tools::Long nCurSubRow = nCurOff == 0 ? 0 - : (-nCurOff * P + nCurRowPx / 2) / nCurRowPx; - tools::Long nOldThumb = (nCurPosY - nScrollMin) * P + nCurSubRow; - nDelta = nNewThumb - nOldThumb; // precision units - bDeltaIsRows = false; + // Pixel delta = docY(target) − docY(current) + // = Σ row heights [nCurPosY..nTargetRow) + nCurOff − nTargetOffset + // Positive → scroll down (content moves up). + tools::Long nPixDelta = nCurOff - nTargetOffset; + if (nTargetRow > nCurPosY) + { + for (SCROW r = nCurPosY; r < nTargetRow; ++r) + nPixDelta += std::max(1L, aViewData.ToPixel( + rDocV.GetRowHeight(r, nTabV), aViewData.GetPPTY())); + } + else if (nTargetRow < nCurPosY) + { + for (SCROW r = nTargetRow; r < nCurPosY; ++r) + nPixDelta -= std::max(1L, aViewData.ToPixel( + rDocV.GetRowHeight(r, nTabV), aViewData.GetPPTY())); + } + // Anti-jitter: suppress direction reversal during drag. if (eType == ScrollType::Drag) { - if (nNewThumb > nPrevDragPos && nDelta < 0) nDelta = 0; - else if (nNewThumb < nPrevDragPos && nDelta > 0) nDelta = 0; - else if (nNewThumb == nPrevDragPos) nDelta = 0; + if (nNewThumb > nPrevDragPos && nPixDelta < 0) nPixDelta = 0; + else if (nNewThumb < nPrevDragPos && nPixDelta > 0) nPixDelta = 0; } nPrevDragPos = nNewThumb; - break; // skip horizontal default logic + + if (nPixDelta != 0) + SmoothScrollY(nPixDelta, eVPLocal); + + nDelta = 0; // handled above — skip outer if(nDelta) block + break; } tools::Long nScrollPos = GetScrollBarPos( *pScroll, bLayoutRTL ) + nScrollMin; @@ -1510,31 +1537,17 @@ void ScTabView::ScrollHdl(ScrollAdaptor* pScroll) } else { + // nDelta is in rows (LineUp/Down/Page). The vertical drag case + // (default:) resolves directly to pixels and sets nDelta=0, so it + // never reaches here. ScVSplitPos eVPFinal = (pScroll == aVScrollTop.get()) ? SC_SPLIT_TOP : SC_SPLIT_BOTTOM; - if (!bDeltaIsRows) - { - // nDelta is in SC_VSCROLL_PRECISION units; convert to pixels and smooth-scroll. - constexpr tools::Long P = SC_VSCROLL_PRECISION; - SCTAB nTabFinal = aViewData.CurrentTabForData(); - tools::Long nRowPxFinal = std::max(1L, aViewData.ToPixel( - aViewData.GetDocument().GetRowHeight(aViewData.GetPosY(eVPFinal), nTabFinal), - aViewData.GetPPTY())); - tools::Long nPixFinal = nDelta * nRowPxFinal / P; - if (nPixFinal != 0) - SmoothScrollY(nPixFinal, eVPFinal); - // else: sub-pixel precision delta — skip to avoid row-snap - } - else - { - // nDelta in rows (LineUp/Down/Page): convert to pixels for smooth blit. - SCTAB nTabFinal = aViewData.CurrentTabForData(); - tools::Long nRowPxFinal = std::max(1L, aViewData.ToPixel( - aViewData.GetDocument().GetRowHeight(aViewData.GetPosY(eVPFinal), nTabFinal), - aViewData.GetPPTY())); - tools::Long nPixFinal = nDelta * nRowPxFinal; - if (nPixFinal != 0) - SmoothScrollY(nPixFinal, eVPFinal); - } + SCTAB nTabFinal = aViewData.CurrentTabForData(); + tools::Long nRowPxFinal = std::max(1L, aViewData.ToPixel( + aViewData.GetDocument().GetRowHeight(aViewData.GetPosY(eVPFinal), nTabFinal), + aViewData.GetPPTY())); + tools::Long nPixFinal = nDelta * nRowPxFinal; + if (nPixFinal != 0) + SmoothScrollY(nPixFinal, eVPFinal); } } From 6b30c314c0e3f44f0d896c9797201f5be4ef1655 Mon Sep 17 00:00:00 2001 From: Kevin Kettinger Date: Wed, 17 Jun 2026 15:15:00 +0000 Subject: [PATCH 4/5] sc: pixel-proportional vertical scrollbar for smooth scroll (tdf#40917) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace the SC_VSCROLL_PRECISION (100 units/row) scrollbar with a fully pixel-proportional one where 1 thumb unit = 1 document pixel. Previously every row occupied 100 thumb units regardless of height, so the pixel movement per unit of thumb travel was proportional to the current row height — large cells scrolled faster than small ones. With the new design each row occupies thumb range equal to its pixel height, giving uniform scroll speed across all row sizes. The thumb delta during drag is now just: nPixDelta = nNewThumb − GetScaledRowHeight(nScrollMin, nCurPosY−1) − (−nPixOffsetY) with no row-height conversion factor at all. The visible page size is taken from the actual grid window height instead of nVisYB×currentRowHeight; the latter ballooned when a large row was at the top, clamping the thumb via lcl_UpdateBar and triggering a spurious scroll-back. Co-Authored-By: Claude Sonnet 4.6 Change-Id: I4a8a6ebeaa0585b2b9be15a2e28fe8f5be6150f7 --- sc/source/ui/inc/tabview.hxx | 4 -- sc/source/ui/view/tabview.cxx | 86 ++++++++++++---------------------- sc/source/ui/view/tabview4.cxx | 52 ++++++++++++++------ 3 files changed, 67 insertions(+), 75 deletions(-) diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx index 06c47e7a351a8..200933320b893 100644 --- a/sc/source/ui/inc/tabview.hxx +++ b/sc/source/ui/inc/tabview.hxx @@ -108,10 +108,6 @@ private: int nTotalWindows; }; -// Precision factor for vertical scrollbar: 1 scrollbar unit = 1/SC_VSCROLL_PRECISION of a row. -// This enables sub-row thumb positions during dragging for pixel-level smooth scrolling. -inline constexpr tools::Long SC_VSCROLL_PRECISION = 100; - class ScTabView { private: diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx index 00ac42959d927..9d2ea52b86997 100644 --- a/sc/source/ui/view/tabview.cxx +++ b/sc/source/ui/view/tabview.cxx @@ -1231,28 +1231,12 @@ void ScTabView::ScrollHdl(ScrollAdaptor* pScroll) if (!bDragging) { bDragging = true; - // For vertical scrollbars, nPrevDragPos must be in precision units - // so the anti-jitter in the default case compares like-for-like. + // Seed nPrevDragPos from the scrollbar's current thumb so the + // first drag event compares like-for-like (pixel units for vertical). if (!bHoriz && (pScroll == aVScrollBottom.get() || pScroll == aVScrollTop.get())) - { - ScVSplitPos eVPInit = (pScroll == aVScrollTop.get()) ? SC_SPLIT_TOP : SC_SPLIT_BOTTOM; - tools::Long nScrollMinInit = 0; - if (aViewData.GetVSplitMode() == SC_SPLIT_FIX && pScroll == aVScrollBottom.get()) - nScrollMinInit = aViewData.GetFixPosY(); - SCROW nCurPosInit = aViewData.GetPosY(eVPInit); - tools::Long nOffInit = aViewData.GetPixOffsetY(eVPInit); - SCTAB nTabInit = aViewData.CurrentTabForData(); - tools::Long nRowPxInit = std::max(1L, aViewData.ToPixel( - aViewData.GetDocument().GetRowHeight(nCurPosInit, nTabInit), - aViewData.GetPPTY())); - tools::Long nSubInit = nOffInit == 0 ? 0 - : (-nOffInit * SC_VSCROLL_PRECISION + nRowPxInit / 2) / nRowPxInit; - nPrevDragPos = (nCurPosInit - nScrollMinInit) * SC_VSCROLL_PRECISION + nSubInit; - } + nPrevDragPos = pScroll->GetThumbPos(); else - { nPrevDragPos = nViewPos; - } } // show scroll position @@ -1284,7 +1268,21 @@ void ScTabView::ScrollHdl(ScrollAdaptor* pScroll) nScrollMin = aViewData.GetFixPosY(); tools::Long nScrollPos = GetScrollBarPos( *pScroll, bLayoutRTL ); if (!bHoriz) - nScrollPos = nScrollPos / SC_VSCROLL_PRECISION + nScrollMin; // precision → row + { + // Thumb is in pixel units; binary-search for the corresponding row. + SCTAB nTabQH = aViewData.CurrentTabForData(); + ScDocument& rDocQH = aViewData.GetDocument(); + SCROW loQH = static_cast(nScrollMin), hiQH = rDocQH.MaxRow(); + while (loQH < hiQH) + { + SCROW midQH = loQH + (hiQH - loQH) / 2; + tools::Long cumH = rDocQH.GetScaledRowHeight( + static_cast(nScrollMin), midQH, nTabQH, aViewData.GetPPTY()); + if (cumH <= nScrollPos) loQH = midQH + 1; + else hiQH = midQH; + } + nScrollPos = loQH; // 0-based row index + } else nScrollPos += nScrollMin; @@ -1371,51 +1369,25 @@ void ScTabView::ScrollHdl(ScrollAdaptor* pScroll) if (!bHoriz) { - // Vertical scrollbar: derive the pixel delta directly from the absolute - // thumb value using actual per-row heights. The old approach multiplied - // a precision-unit delta by the CURRENT top row's height, which gave the - // wrong result when crossing into a row with a different height (large - // cells snapped instead of scrolling smoothly through). - constexpr tools::Long P = SC_VSCROLL_PRECISION; + // Vertical scrollbar is in pixel units (1 unit = 1 document pixel). + // The pixel delta is simply the thumb difference — no row-height + // conversion needed, giving uniform scroll speed across all row heights. ScVSplitPos eVPLocal = (pScroll == aVScrollTop.get()) ? SC_SPLIT_TOP : SC_SPLIT_BOTTOM; SCTAB nTabV = aViewData.CurrentTabForData(); ScDocument& rDocV = aViewData.GetDocument(); - tools::Long nNewThumb = pScroll->GetThumbPos(); - - // Compute target (row, sub-row offset) from absolute thumb position. - SCROW nTargetRow = static_cast(nNewThumb / P) - + static_cast(nScrollMin); - tools::Long nSubFrac = nNewThumb % P; // 0..P-1 within target row - nTargetRow = std::clamp(nTargetRow, - static_cast(nScrollMin), rDocV.MaxRow()); + tools::Long nNewThumb = pScroll->GetThumbPos(); // pixels from nScrollMin - // Target pixel offset within the target row (≤ 0), using that row's - // actual height — not the current top row's height. - tools::Long nTargetRowPx = std::max(1L, aViewData.ToPixel( - rDocV.GetRowHeight(nTargetRow, nTabV), aViewData.GetPPTY())); - tools::Long nTargetOffset = -(nSubFrac * nTargetRowPx) / P; - - // Current position + // Reconstruct current pixel position from nScrollMin. SCROW nCurPosY = aViewData.GetPosY(eVPLocal); tools::Long nCurOff = aViewData.GetPixOffsetY(eVPLocal); + tools::Long nCurThumb = (nCurPosY > static_cast(nScrollMin)) + ? rDocV.GetScaledRowHeight(static_cast(nScrollMin), + nCurPosY - 1, nTabV, aViewData.GetPPTY()) + : 0; + nCurThumb += (-nCurOff); // nCurOff ≤ 0 - // Pixel delta = docY(target) − docY(current) - // = Σ row heights [nCurPosY..nTargetRow) + nCurOff − nTargetOffset - // Positive → scroll down (content moves up). - tools::Long nPixDelta = nCurOff - nTargetOffset; - if (nTargetRow > nCurPosY) - { - for (SCROW r = nCurPosY; r < nTargetRow; ++r) - nPixDelta += std::max(1L, aViewData.ToPixel( - rDocV.GetRowHeight(r, nTabV), aViewData.GetPPTY())); - } - else if (nTargetRow < nCurPosY) - { - for (SCROW r = nTargetRow; r < nCurPosY; ++r) - nPixDelta -= std::max(1L, aViewData.ToPixel( - rDocV.GetRowHeight(r, nTabV), aViewData.GetPPTY())); - } + tools::Long nPixDelta = nNewThumb - nCurThumb; // Anti-jitter: suppress direction reversal during drag. if (eType == ScrollType::Drag) diff --git a/sc/source/ui/view/tabview4.cxx b/sc/source/ui/view/tabview4.cxx index 60d4b2ba4d328..6225d7985255f 100644 --- a/sc/source/ui/view/tabview4.cxx +++ b/sc/source/ui/view/tabview4.cxx @@ -498,19 +498,40 @@ void ScTabView::UpdateScrollBars( HeaderType eHeaderType ) SetScrollBar( *aHScrollLeft, nMaxXL, nVisXL, aViewData.GetPosX( SC_SPLIT_LEFT ), bLayoutRTL ); nVisYB = aViewData.VisibleCellsY( SC_SPLIT_BOTTOM ); - tools::Long nMaxYB = lcl_GetScrollRange( nUsedY, aViewData.GetPosY(SC_SPLIT_BOTTOM), nVisYB, rDoc.MaxRow(), nStartY ); { - // Scale vertical scrollbar by SC_VSCROLL_PRECISION for sub-row smooth dragging. - constexpr tools::Long P = SC_VSCROLL_PRECISION; + // Pixel-proportional vertical scrollbar: 1 thumb unit = 1 pixel of document height. + // Large rows occupy proportionally more thumb range → uniform scroll speed. SCROW nPosYB = aViewData.GetPosY(SC_SPLIT_BOTTOM); tools::Long nOffYB = aViewData.GetPixOffsetY(SC_SPLIT_BOTTOM); tools::Long nRowPxB = std::max(1L, aViewData.ToPixel( rDoc.GetRowHeight(nPosYB, nTab), aViewData.GetPPTY())); - // Sub-row fraction: 0..(P-1) units of the current top row already scrolled - tools::Long nSubRowB = nOffYB == 0 ? 0 : (-nOffYB * P + nRowPxB / 2) / nRowPxB; - tools::Long nThumbB = (nPosYB - nStartY) * P + nSubRowB; - SetScrollBar(*aVScrollBottom, nMaxYB * P, nVisYB * P, nThumbB, false); - aVScrollBottom->SetLineSize(P); // 1 arrow click = 1 full row = P precision units + + // Limit range to used rows + buffer (mirrors lcl_GetScrollRange logic in pixels + // so the thumb stays a usable size on sheets with little data). + SCROW nScrollEndY = std::min( + std::max(static_cast(nUsedY + nVisYB + 2), + static_cast(nPosYB + nVisYB + 2)), + rDoc.MaxRow()); + tools::Long nTotalPxB = rDoc.GetScaledRowHeight(nStartY, nScrollEndY, nTab, + aViewData.GetPPTY()); + + // Thumb = cumulative pixel height from nStartY to top-of-viewport. + tools::Long nThumbB = (nPosYB > nStartY) + ? rDoc.GetScaledRowHeight(nStartY, nPosYB - 1, nTab, aViewData.GetPPTY()) + : 0; + nThumbB += (-nOffYB); // nOffYB ≤ 0 + + // Visible page size = actual grid window height. Using nVisYB×currentRowHeight + // balloons when a large row is at the top, clamping the thumb and causing + // lcl_UpdateBar to fire a spurious scroll-back via SmoothScrollY. + tools::Long nVisPixB = 0; + if (pGridWin[SC_SPLIT_BOTTOMLEFT]) + nVisPixB = pGridWin[SC_SPLIT_BOTTOMLEFT]->GetOutputSizePixel().Height(); + if (nVisPixB <= 0) + nVisPixB = nVisYB * nRowPxB; // fallback during early init + + SetScrollBar(*aVScrollBottom, nTotalPxB, nVisPixB, nThumbB, false); + aVScrollBottom->SetLineSize(nRowPxB); } if (bRight) @@ -538,17 +559,20 @@ void ScTabView::UpdateScrollBars( HeaderType eHeaderType ) } { - constexpr tools::Long P = SC_VSCROLL_PRECISION; - nDiff = lcl_UpdateBar(*aVScrollBottom, nVisYB * P); - if (nDiff) + // Same actual-height page size as in the SetScrollBar call above. + tools::Long nVisPixB2 = 0; + if (pGridWin[SC_SPLIT_BOTTOMLEFT]) + nVisPixB2 = pGridWin[SC_SPLIT_BOTTOMLEFT]->GetOutputSizePixel().Height(); + if (nVisPixB2 <= 0) { SCROW nPosYB2 = aViewData.GetPosY(SC_SPLIT_BOTTOM); tools::Long nRowPxB2 = std::max(1L, aViewData.ToPixel( rDoc.GetRowHeight(nPosYB2, nTab), aViewData.GetPPTY())); - tools::Long nPxDiff = (nDiff * nRowPxB2 + (nDiff > 0 ? P/2 : -P/2)) / P; // round - if (nPxDiff != 0) - SmoothScrollY(nPxDiff, SC_SPLIT_BOTTOM); + nVisPixB2 = nVisYB * nRowPxB2; } + nDiff = lcl_UpdateBar(*aVScrollBottom, nVisPixB2); + if (nDiff != 0) + SmoothScrollY(nDiff, SC_SPLIT_BOTTOM); } if (bTop) { From 240a63782db1d6475897c68f8f64aea5ee34abd4 Mon Sep 17 00:00:00 2001 From: Kevin Kettinger Date: Wed, 17 Jun 2026 15:16:07 +0000 Subject: [PATCH 5/5] sc: remove debug fprintf/fflush traces from smooth-scroll code (tdf#40917) Co-Authored-By: Claude Sonnet 4.6 Change-Id: I10c6ce452830262137265316279eadc919efa721 --- sc/source/ui/view/gridwin4.cxx | 4 ---- sc/source/ui/view/tabview.cxx | 18 ------------------ sc/source/ui/view/viewdata.cxx | 6 ------ 3 files changed, 28 deletions(-) diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index 790ecb3f7aa5c..0818469f2130c 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -513,10 +513,6 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod tools::Long nScrX = aScrPos.X(); tools::Long nScrY = aScrPos.Y(); - fprintf(stderr, "DBG Draw: nY1=%d nScrY=%ld\n", - static_cast(nY1), static_cast(nScrY)); - fflush(stderr); - SCCOL nCurX = mrViewData.GetCurX(); SCROW nCurY = mrViewData.GetCurY(); SCCOL nCurEndX = nCurX; diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx index 9d2ea52b86997..a6803e3409cfd 100644 --- a/sc/source/ui/view/tabview.cxx +++ b/sc/source/ui/view/tabview.cxx @@ -981,13 +981,6 @@ bool ScTabView::ScrollCommand( const CommandEvent& rCEvt, ScSplitPos ePos ) bool bDone = false; const CommandWheelData* pData = rCEvt.GetWheelData(); - fprintf(stderr, "DBG ScrollCommand: pData=%p cmd=%d mode=%d isDeltaPx=%d delta=%ld\n", - static_cast(pData), - static_cast(rCEvt.GetCommand()), - pData ? static_cast(pData->GetMode()) : -1, - pData ? (int)pData->IsDeltaPixel() : -1, - pData ? static_cast(pData->GetDelta()) : 0L); - fflush(stderr); if (pData && pData->GetMode() == CommandWheelMode::ZOOM) { if ( !aViewData.GetViewShell()->GetViewFrame().GetFrame().IsInPlace() ) @@ -1711,8 +1704,6 @@ void ScTabView::ScrollLines( tools::Long nDeltaX, tools::Long nDeltaY ) void ScTabView::SmoothScrollY( tools::Long nPixelDelta, ScVSplitPos eWhich ) { - fprintf(stderr, "DBG SmoothScrollY: nPixelDelta=%ld\n", static_cast(nPixelDelta)); - fflush(stderr); SAL_INFO("sc.smooth", "SmoothScrollY: nPixelDelta=" << nPixelDelta << " eWhich=" << static_cast(eWhich)); // Fall back to cell-granular scrolling in tiled rendering mode. @@ -1799,17 +1790,8 @@ void ScTabView::SmoothScrollY( tools::Long nPixelDelta, ScVSplitPos eWhich ) // when clamped at an edge, it reflects the achievable movement. tools::Long nBlitDelta = nRowsCrossedPx + (nCurrentOffset - nNewOffset); - fprintf(stderr, "DBG SmoothScrollY result: newOffset=%ld newPosY=%d rowsCrossedPx=%ld blitDelta=%ld\n", - static_cast(nNewOffset), static_cast(nPosY), - static_cast(nRowsCrossedPx), static_cast(nBlitDelta)); - fflush(stderr); - if (nBlitDelta == 0 && nPosY == aViewData.GetPosY(eWhich)) - { - fprintf(stderr, "DBG SmoothScrollY: no movement, early return\n"); - fflush(stderr); return; - } HideAllCursors(); diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index b317dc4ba59bd..0a9be2729d24d 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -3180,12 +3180,6 @@ void ScViewData::SetPosX( ScHSplitPos eWhich, SCCOL nNewPosX ) void ScViewData::SetPosY( ScVSplitPos eWhich, SCROW nNewPosY ) { - fprintf(stderr, "DBG SetPosY: eWhich=%d nNewPosY=%d (was=%d offset=%ld) caller=%p\n", - static_cast(eWhich), static_cast(nNewPosY), - static_cast(pThisTab->nPosY[eWhich]), - static_cast(pThisTab->nPixOffsetY[eWhich]), - static_cast(__builtin_return_address(0))); - fflush(stderr); // in the tiled rendering case, nPosY [the topmost visible row] must be 0 bool bIsTiledRendering = comphelper::LibreOfficeKit::isActive(); if (nNewPosY != 0 && !bIsTiledRendering)