sc/source/ui/inc/viewdata.hxx  |    4 
 sc/source/ui/view/viewdata.cxx |  210 ++++++++++++++++++++---------------------
 2 files changed, 108 insertions(+), 106 deletions(-)

New commits:
commit 9a32747b6bde5fecc2872103c2a8123c9c0d3364
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Mon Jul 7 23:44:53 2025 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Tue Aug 19 08:21:57 2025 +0200

    sc: prefix nTabNo in ViewData to mnTabNumber
    
    Also change access to use GetTabNo() instead (if it makes sense).
    
    Change-Id: I9249c4539a851e34b64d56faa1928d1fb3b8705a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187507
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    (cherry picked from commit 1db00cdb007d300df41ce1170c987224ccab47b5)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189323
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx
index 54134243dfd6..ea9b1260ac54 100644
--- a/sc/source/ui/inc/viewdata.hxx
+++ b/sc/source/ui/inc/viewdata.hxx
@@ -297,7 +297,7 @@ private:
 
     ScRefType           eRefType;
 
-    SCTAB               nTabNo;                     // displayed sheet
+    SCTAB mnTabNumber; // displayed sheet
     SCTAB               nRefTabNo;                  // sheet which contains 
RefInput
     SCCOL               nRefStartX;
     SCROW               nRefStartY;
@@ -397,7 +397,7 @@ public:
     SCTAB           GetRefTabNo() const                     { return 
nRefTabNo; }
     void            SetRefTabNo( SCTAB nNewTab )            { nRefTabNo = 
nNewTab; }
 
-    SCTAB           GetTabNo() const                        { return nTabNo; }
+    SCTAB GetTabNo() const { return mnTabNumber; }
     SCCOL           MaxCol() const                          { return 
mrDoc.MaxCol(); }
     SCROW           MaxRow() const                          { return 
mrDoc.MaxRow(); }
     ScSplitPos      GetActivePart() const                   { return 
pThisTab->eWhichActive; }
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index 1352bea51040..b25646f181e8 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -809,7 +809,7 @@ ScViewData::ScViewData(ScDocument* pDoc, ScDocShell* 
pDocSh, ScTabViewShell* pVi
         aDefPageZoomX( 3,5 ),
         aDefPageZoomY( 3,5 ),
         eRefType    ( SC_REFTYPE_NONE ),
-        nTabNo      ( 0 ),
+        mnTabNumber(0),
         nRefTabNo   ( 0 ),
         nRefStartX(0),
         nRefStartY(0),
@@ -840,25 +840,25 @@ ScViewData::ScViewData(ScDocument* pDoc, ScDocShell* 
pDocSh, ScTabViewShell* pVi
     maMarkData.SelectOneTable(0); // Sync with nTabNo
 
     aScrSize = Size( o3tl::convert(STD_COL_WIDTH * OLE_STD_CELLS_X, 
o3tl::Length::twip, o3tl::Length::px),
-                    o3tl::convert(mrDoc.GetSheetOptimalMinRowHeight(nTabNo) * 
OLE_STD_CELLS_Y,
+                    
o3tl::convert(mrDoc.GetSheetOptimalMinRowHeight(mnTabNumber) * OLE_STD_CELLS_Y,
                                   o3tl::Length::twip, o3tl::Length::px));
     maTabData.emplace_back( new ScViewDataTable(nullptr) );
-    pThisTab = maTabData[nTabNo].get();
+    pThisTab = maTabData[mnTabNumber].get();
 
     nEditEndCol = nEditStartCol = nEditCol = 0;
     nEditEndRow = nEditRow = 0;
     nTabStartCol = SC_TABSTART_NONE;
 
     // don't show hidden tables
-    if (!mrDoc.IsVisible(nTabNo))
+    if (!mrDoc.IsVisible(mnTabNumber))
     {
-        while (!mrDoc.IsVisible(nTabNo) && mrDoc.HasTable(nTabNo + 1))
+        while (!mrDoc.IsVisible(mnTabNumber) && mrDoc.HasTable(mnTabNumber + 
1))
         {
-            ++nTabNo;
+            ++mnTabNumber;
             maTabData.emplace_back(nullptr);
         }
-        maTabData[nTabNo].reset( new ScViewDataTable(nullptr) );
-        pThisTab = maTabData[nTabNo].get();
+        maTabData[mnTabNumber].reset( new ScViewDataTable(nullptr) );
+        pThisTab = maTabData[mnTabNumber].get();
     }
 
     SCTAB nTableCount = mrDoc.GetTableCount();
@@ -882,12 +882,12 @@ ScDBFunc* ScViewData::GetView() const { return pView; }
 
 void ScViewData::UpdateCurrentTab()
 {
-    assert(0 <= nTabNo && o3tl::make_unsigned(nTabNo) < maTabData.size());
-    pThisTab = maTabData[nTabNo].get();
+    assert(0 <= mnTabNumber && o3tl::make_unsigned(mnTabNumber) < 
maTabData.size());
+    pThisTab = maTabData[mnTabNumber].get();
     while (!pThisTab)
     {
-        if (nTabNo > 0)
-            pThisTab = maTabData[--nTabNo].get();
+        if (mnTabNumber > 0)
+            pThisTab = maTabData[--mnTabNumber].get();
         else
         {
             maTabData[0].reset(new ScViewDataTable(&mrDoc));
@@ -934,10 +934,10 @@ void ScViewData::DeleteTab( SCTAB nTab )
     assert(nTab < static_cast<SCTAB>(maTabData.size()));
     maTabData.erase(maTabData.begin() + nTab);
 
-    if (o3tl::make_unsigned(nTabNo) >= maTabData.size())
+    if (o3tl::make_unsigned(GetTabNo()) >= maTabData.size())
     {
         EnsureTabDataSize(1);
-        nTabNo = maTabData.size() - 1;
+        mnTabNumber = maTabData.size() - 1;
     }
     UpdateCurrentTab();
     maMarkData.DeleteTab(nTab);
@@ -950,10 +950,10 @@ void ScViewData::DeleteTabs( SCTAB nTab, SCTAB nSheets )
         maMarkData.DeleteTab(nTab + i);
     }
     maTabData.erase(maTabData.begin() + nTab, maTabData.begin()+ nTab+nSheets);
-    if (o3tl::make_unsigned(nTabNo) >= maTabData.size())
+    if (o3tl::make_unsigned(GetTabNo()) >= maTabData.size())
     {
         EnsureTabDataSize(1);
-        nTabNo = maTabData.size() - 1;
+        mnTabNumber = maTabData.size() - 1;
     }
     UpdateCurrentTab();
 }
@@ -1127,14 +1127,14 @@ void ScViewData::SetZoom( const Fraction& rNewX, const 
Fraction& rNewY, bool bAl
 void ScViewData::SetShowGrid( bool bShow )
 {
     CreateSelectedTabData();
-    maTabData[nTabNo]->bShowGrid = bShow;
+    maTabData[GetTabNo()]->bShowGrid = bShow;
 }
 
 bool ScViewData::GetPrintGrid() const
 {
     bool bPrintGrid;
     ScStyleSheetPool* pStylePool = mrDoc.GetStyleSheetPool();
-    SfxStyleSheetBase* pStyleSheet = pStylePool->Find( mrDoc.GetPageStyle( 
nTabNo ), SfxStyleFamily::Page );
+    SfxStyleSheetBase* pStyleSheet = pStylePool->Find( mrDoc.GetPageStyle( 
GetTabNo() ), SfxStyleFamily::Page );
     if (pStyleSheet)
     {
         SfxItemSet& rSet = pStyleSheet->GetItemSet();
@@ -1151,7 +1151,7 @@ bool ScViewData::GetPrintGrid() const
 void ScViewData::SetPrintGrid( bool bPrintGrid )
 {
     ScStyleSheetPool* pStylePool = mrDoc.GetStyleSheetPool();
-    SfxStyleSheetBase* pStyleSheet = pStylePool->Find( mrDoc.GetPageStyle( 
nTabNo ), SfxStyleFamily::Page );
+    SfxStyleSheetBase* pStyleSheet = pStylePool->Find( mrDoc.GetPageStyle( 
GetTabNo() ), SfxStyleFamily::Page );
     if (pStyleSheet)
     {
         SfxItemSet& rSet = pStyleSheet->GetItemSet();
@@ -1163,7 +1163,7 @@ void ScViewData::SetPrintGrid( bool bPrintGrid )
         else
             rSet.Put(SfxBoolItem(ATTR_PAGE_GRID, bPrintGrid));
 
-        mrDoc.PageStyleModified(nTabNo, pStyleSheet->GetName());
+        mrDoc.PageStyleModified(GetTabNo(), pStyleSheet->GetName());
     }
     else
     {
@@ -1576,7 +1576,7 @@ tools::Rectangle ScViewData::GetEditArea( ScSplitPos 
eWhich, SCCOL nPosX, SCROW
 {
     Point aCellTopLeft = bInPrintTwips ?
             GetPrintTwipsPos(nPosX, nPosY) : GetScrPos(nPosX, nPosY, eWhich, 
true);
-    return ScEditUtil(&mrDoc, nPosX, nPosY, nTabNo, aCellTopLeft,
+    return ScEditUtil(&mrDoc, nPosX, nPosY, GetTabNo(), aCellTopLeft,
                         pWin->GetOutDev(), nPPTX, nPPTY, GetZoomX(), 
GetZoomY(), bInPrintTwips ).
                             GetEditArea( pPattern, bForceToTop );
 }
@@ -1601,7 +1601,7 @@ void ScViewData::SetEditEngine( ScSplitPos eWhich,
                                 ScEditEngineDefaulter* pNewEngine,
                                 vcl::Window* pWin, SCCOL nNewX, SCROW nNewY )
 {
-    bool bLayoutRTL = mrDoc.IsLayoutRTL(nTabNo);
+    bool bLayoutRTL = mrDoc.IsLayoutRTL(GetTabNo());
     ScHSplitPos eHWhich = WhichH(eWhich);
     ScVSplitPos eVWhich = WhichV(eWhich);
     bool bLOKActive = comphelper::LibreOfficeKit::isActive();
@@ -1669,10 +1669,10 @@ void ScViewData::SetEditEngine( ScSplitPos eWhich,
 
     bEditActive[eWhich] = true;
 
-    const ScPatternAttr* pPattern = mrDoc.GetPattern(nNewX, nNewY, nTabNo);
+    const ScPatternAttr* pPattern = mrDoc.GetPattern(nNewX, nNewY, GetTabNo());
     if (!pPattern)
     {
-        SAL_WARN("sc.viewdata", "No Pattern Found for: Col: " << nNewX << ", 
Row: " << nNewY << ", Tab: " << nTabNo);
+        SAL_WARN("sc.viewdata", "No Pattern Found for: Col: " << nNewX << ", 
Row: " << nNewY << ", Tab: " << GetTabNo());
         pPattern = &mrDoc.getCellAttributeHelper().getDefaultCellAttribute();
     }
     SvxCellHorJustify eJust = pPattern->GetItem( ATTR_HOR_JUSTIFY ).GetValue();
@@ -1682,14 +1682,14 @@ void ScViewData::SetEditEngine( ScSplitPos eWhich,
 
     bool bAsianVertical = pNewEngine->IsEffectivelyVertical();     // set by 
InputHandler
 
-    tools::Rectangle aPixRect = ScEditUtil(&mrDoc, nNewX, nNewY, nTabNo, 
GetScrPos(nNewX, nNewY, eWhich),
+    tools::Rectangle aPixRect = ScEditUtil(&mrDoc, nNewX, nNewY, GetTabNo(), 
GetScrPos(nNewX, nNewY, eWhich),
                                         pWin->GetOutDev(), 
nPPTX,nPPTY,GetZoomX(),GetZoomY() ).
                                             GetEditArea( pPattern, true );
 
     tools::Rectangle aPTwipsRect;
     if (bLOKPrintTwips)
     {
-        aPTwipsRect = ScEditUtil(&mrDoc, nNewX, nNewY, nTabNo, 
GetPrintTwipsPos(nNewX, nNewY),
+        aPTwipsRect = ScEditUtil(&mrDoc, nNewX, nNewY, GetTabNo(), 
GetPrintTwipsPos(nNewX, nNewY),
                                  pWin->GetOutDev(), nPPTX, nPPTY, GetZoomX(), 
GetZoomY(), true /* bInPrintTwips */).
                                         GetEditArea(pPattern, true);
     }
@@ -1829,7 +1829,7 @@ void ScViewData::SetEditEngine( ScSplitPos eWhich,
 
             Fraction aFract(1,1);
             constexpr auto HMM_PER_TWIPS = o3tl::convert(1.0, 
o3tl::Length::twip, o3tl::Length::mm100);
-            tools::Rectangle aUtilRect = ScEditUtil(&mrDoc, nNewX, nNewY, 
nTabNo, Point(0, 0), pWin->GetOutDev(),
+            tools::Rectangle aUtilRect = ScEditUtil(&mrDoc, nNewX, nNewY, 
GetTabNo(), Point(0, 0), pWin->GetOutDev(),
                                     HMM_PER_TWIPS, HMM_PER_TWIPS, aFract, 
aFract ).GetEditArea( pPattern, false );
             aPaperSize.setWidth( aUtilRect.GetWidth() );
             if (bLOKPrintTwips)
@@ -1958,7 +1958,8 @@ void ScViewData::EditGrowX()
     if ( !pCurView || !bEditActive[eWhich])
         return;
 
-    bool bLayoutRTL = rLocalDoc.IsLayoutRTL( nTabNo );
+    SCTAB nCurrentTab = GetTabNo();
+    bool bLayoutRTL = rLocalDoc.IsLayoutRTL(nCurrentTab);
 
     ScEditEngineDefaulter* pEngine = 
static_cast<ScEditEngineDefaulter*>(&pCurView->getEditEngine());
     vcl::Window* pWin = pCurView->GetWindow();
@@ -1986,10 +1987,10 @@ void ScViewData::EditGrowX()
     bool bAsianVertical = pEngine->IsEffectivelyVertical();
 
     //  get bGrow... variables the same way as in SetEditEngine
-    const ScPatternAttr* pPattern = rLocalDoc.GetPattern( nEditCol, nEditRow, 
nTabNo );
+    const ScPatternAttr* pPattern = rLocalDoc.GetPattern( nEditCol, nEditRow, 
nCurrentTab);
     if (!pPattern)
     {
-        SAL_WARN("sc.viewdata", "No Pattern Found for: Col: " << nEditCol << 
", Row: " << nEditRow << ", Tab: " << nTabNo);
+        SAL_WARN("sc.viewdata", "No Pattern Found for: Col: " << nEditCol << 
", Row: " << nEditRow << ", Tab: " << nCurrentTab);
         pPattern = 
&rLocalDoc.getCellAttributeHelper().getDefaultCellAttribute();
     }
     SvxCellHorJustify eJust = pPattern->GetItem( ATTR_HOR_JUSTIFY ).GetValue();
@@ -2011,7 +2012,7 @@ void ScViewData::EditGrowX()
             if ( nEditStartCol > nLeft )
             {
                 --nEditStartCol;
-                tools::Long nColWidth = rLocalDoc.GetColWidth( nEditStartCol, 
nTabNo );
+                tools::Long nColWidth = rLocalDoc.GetColWidth(nEditStartCol, 
nCurrentTab);
                 tools::Long nLeftPix = ToPixel( nColWidth, nPPTX );
                 nLogicLeft = pWin->PixelToLogic(Size(nLeftPix,0)).Width();
                 if (bLOKPrintTwips)
@@ -2022,7 +2023,7 @@ void ScViewData::EditGrowX()
             if ( nEditEndCol < nRight )
             {
                 ++nEditEndCol;
-                tools::Long nColWidth = rLocalDoc.GetColWidth( nEditEndCol, 
nTabNo );
+                tools::Long nColWidth = rLocalDoc.GetColWidth(nEditEndCol, 
nCurrentTab);
                 tools::Long nRightPix = ToPixel( nColWidth, nPPTX );
                 nLogicRight = pWin->PixelToLogic(Size(nRightPix,0)).Width();
                 if (bLOKPrintTwips)
@@ -2063,7 +2064,7 @@ void ScViewData::EditGrowX()
         while (aArea.GetWidth() + 0 < nTextWidth && nEditStartCol > nLeft)
         {
             --nEditStartCol;
-            tools::Long nColWidth = rLocalDoc.GetColWidth( nEditStartCol, 
nTabNo );
+            tools::Long nColWidth = rLocalDoc.GetColWidth(nEditStartCol, 
nCurrentTab);
             tools::Long nPix = ToPixel( nColWidth, nPPTX );
             tools::Long nLogicWidth = pWin->PixelToLogic(Size(nPix,0)).Width();
             tools::Long& nLogicWidthPTwips = nColWidth;
@@ -2105,7 +2106,7 @@ void ScViewData::EditGrowX()
         while (aArea.GetWidth() + 0 < nTextWidth && nEditEndCol < nRight)
         {
             ++nEditEndCol;
-            tools::Long nColWidth = rLocalDoc.GetColWidth( nEditEndCol, nTabNo 
);
+            tools::Long nColWidth = rLocalDoc.GetColWidth(nEditEndCol, 
nCurrentTab);
             tools::Long nPix = ToPixel( nColWidth, nPPTX );
             tools::Long nLogicWidth = pWin->PixelToLogic(Size(nPix,0)).Width();
             tools::Long& nLogicWidthPTwips = nColWidth;
@@ -2283,7 +2284,7 @@ void ScViewData::EditGrowY( bool bInitial )
     //  to be clipped before extending to following rows, to avoid obscuring 
cells for
     //  reference input (next row is likely to be useful in formulas).
     tools::Long nAllowedExtra = SC_GROWY_SMALL_EXTRA;
-    if (nEditEndRow == nEditRow && !(mrDoc.GetRowFlags(nEditRow, nTabNo) & 
CRFlags::ManualSize) &&
+    if (nEditEndRow == nEditRow && !(mrDoc.GetRowFlags(nEditRow, GetTabNo()) & 
CRFlags::ManualSize) &&
             rEngine.GetParagraphCount() <= 1 )
     {
         //  If the (only) paragraph starts with a '=', it's a formula.
@@ -2302,7 +2303,7 @@ void ScViewData::EditGrowY( bool bInitial )
     {
         ++nEditEndRow;
         ScDocument& rLocalDoc = GetDocument();
-        tools::Long nRowHeight = rLocalDoc.GetRowHeight( nEditEndRow, nTabNo );
+        tools::Long nRowHeight = rLocalDoc.GetRowHeight(nEditEndRow, 
GetTabNo());
         tools::Long nPix = ToPixel( nRowHeight, nPPTY );
         aArea.AdjustBottom(pWin->PixelToLogic(Size(0,nPix)).Height() );
         if (bLOKPrintTwips)
@@ -2425,9 +2426,9 @@ void ScViewData::SetTabNo( SCTAB nNewTab )
         return;
     }
 
-    nTabNo = nNewTab;
-    CreateTabData(nTabNo);
-    pThisTab = maTabData[nTabNo].get();
+    mnTabNumber = nNewTab;
+    CreateTabData(mnTabNumber);
+    pThisTab = maTabData[mnTabNumber].get();
 
     CalcPPT();          //  for common column width correction
     RecalcPixPos();     //! not always needed!
@@ -2504,12 +2505,12 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW 
nWhereY, ScSplitPos eWhich,
     }
 
     if (nForTab == -1)
-        nForTab = nTabNo;
-    bool bForCurTab = (nForTab == nTabNo);
+        nForTab = GetTabNo();
+    bool bForCurTab = (nForTab == GetTabNo());
     if (!bForCurTab && (!ValidTab(nForTab) || (nForTab >= 
static_cast<SCTAB>(maTabData.size()))))
     {
         SAL_WARN("sc.viewdata", "ScViewData::GetScrPos :  invalid nForTab = " 
<< nForTab);
-        nForTab = nTabNo;
+        nForTab = GetTabNo();
         bForCurTab = true;
     }
 
@@ -2606,7 +2607,7 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW 
nWhereY, ScSplitPos eWhich,
                     nScrPosY = 0x7FFFFFFF;
                 else
                 {
-                    nTSize = mrDoc.GetRowHeight( nY, nTabNo );
+                    nTSize = mrDoc.GetRowHeight( nY, mnTabNumber );
                     if (nTSize)
                     {
                         tools::Long nSizeYPix = ToPixel( nTSize, nPPTY );
@@ -2615,7 +2616,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(), nTabNo);
+                        SCROW nNext = mrDoc.FirstVisibleRow(nY + 1, 
mrDoc.MaxRow(), mnTabNumber);
                         if ( nNext > mrDoc.MaxRow() )
                             nY = mrDoc.MaxRow();
                         else
@@ -2658,9 +2659,9 @@ Point ScViewData::GetPrintTwipsPos(SCCOL nCol, SCROW 
nRow) const
 {
     // hidden ones are given 0 sizes by these by default.
     // TODO: rewrite this to loop over spans (matters for jumbosheets).
-    tools::Long nPosX = nCol ? mrDoc.GetColWidth(0, nCol - 1, nTabNo) : 0;
+    tools::Long nPosX = nCol ? mrDoc.GetColWidth(0, nCol - 1, GetTabNo()) : 0;
     // This is now fast as it loops over spans.
-    tools::Long nPosY = nRow ? mrDoc.GetRowHeight(0, nRow - 1, nTabNo) : 0;
+    tools::Long nPosY = nRow ? mrDoc.GetRowHeight(0, nRow - 1, GetTabNo()) : 0;
     // TODO: adjust for RTL layout case.
 
     return Point(nPosX, nPosY);
@@ -2757,7 +2758,7 @@ SCCOL ScViewData::CellsAtX( SCCOL nPosX, SCCOL nDir, 
ScHSplitPos eWhichX, tools:
             bOut = true;
         else
         {
-            sal_uInt16 nTSize = mrDoc.GetColWidth(nColNo, nTabNo);
+            sal_uInt16 nTSize = mrDoc.GetColWidth(nColNo, GetTabNo());
             if (nTSize)
             {
                 tools::Long nSizeXPix = ToPixel( nTSize, nPPTX );
@@ -2792,7 +2793,7 @@ SCROW ScViewData::CellsAtY( SCROW nPosY, SCROW nDir, 
ScVSplitPos eWhichY, tools:
         // forward
         nY = nPosY;
         tools::Long nScrPosY = 0;
-        AddPixelsWhile(nScrPosY, nScrSizeY, nY, mrDoc.MaxRow(), nPPTY, &mrDoc, 
nTabNo);
+        AddPixelsWhile(nScrPosY, nScrSizeY, nY, mrDoc.MaxRow(), nPPTY, &mrDoc, 
GetTabNo());
         // Original loop ended on last evaluated +1 or if that was MaxRow even 
on MaxRow+2.
         nY += (nY == mrDoc.MaxRow() ? 2 : 1);
         nY -= nPosY;
@@ -2802,7 +2803,7 @@ SCROW ScViewData::CellsAtY( SCROW nPosY, SCROW nDir, 
ScVSplitPos eWhichY, tools:
         // backward
         nY = nPosY-1;
         tools::Long nScrPosY = 0;
-        AddPixelsWhileBackward(nScrPosY, nScrSizeY, nY, 0, nPPTY, &mrDoc, 
nTabNo);
+        AddPixelsWhileBackward(nScrPosY, nScrSizeY, nY, 0, nPPTY, &mrDoc, 
GetTabNo());
         // Original loop ended on last evaluated -1 or if that was 0 even on 
-2.
         nY -= (nY == 0 ? 2 : 1);
         nY = (nPosY-1)-nY;
@@ -2834,26 +2835,27 @@ SCROW ScViewData::PrevCellsY( ScVSplitPos eWhichY ) 
const
 
 bool ScViewData::GetMergeSizePixel( SCCOL nX, SCROW nY, tools::Long& 
rSizeXPix, tools::Long& rSizeYPix ) const
 {
-    const ScMergeAttr* pMerge = mrDoc.GetAttr(nX, nY, nTabNo, ATTR_MERGE);
+    SCTAB nCurrentTab = GetTabNo();
+    const ScMergeAttr* pMerge = mrDoc.GetAttr(nX, nY, nCurrentTab, ATTR_MERGE);
     if ( pMerge->GetColMerge() > 1 || pMerge->GetRowMerge() > 1 )
     {
         tools::Long nOutWidth = 0;
         tools::Long nOutHeight = 0;
         SCCOL nCountX = pMerge->GetColMerge();
         for (SCCOL i=0; i<nCountX; i++)
-            nOutWidth += ToPixel(mrDoc.GetColWidth(nX + i, nTabNo), nPPTX);
+            nOutWidth += ToPixel(mrDoc.GetColWidth(nX + i, nCurrentTab), 
nPPTX);
         SCROW nCountY = pMerge->GetRowMerge();
 
         for (SCROW nRow = nY; nRow <= nY+nCountY-1; ++nRow)
         {
             SCROW nLastRow = nRow;
-            if (mrDoc.RowHidden(nRow, nTabNo, nullptr, &nLastRow))
+            if (mrDoc.RowHidden(nRow, nCurrentTab, nullptr, &nLastRow))
             {
                 nRow = nLastRow;
                 continue;
             }
 
-            sal_uInt16 nHeight = mrDoc.GetRowHeight(nRow, nTabNo);
+            sal_uInt16 nHeight = mrDoc.GetRowHeight(nRow, nCurrentTab);
             nOutHeight += ToPixel(nHeight, nPPTY);
         }
 
@@ -2863,24 +2865,25 @@ bool ScViewData::GetMergeSizePixel( SCCOL nX, SCROW nY, 
tools::Long& rSizeXPix,
     }
     else
     {
-        rSizeXPix = ToPixel(mrDoc.GetColWidth(nX, nTabNo), nPPTX);
-        rSizeYPix = ToPixel(mrDoc.GetRowHeight(nY, nTabNo), nPPTY);
+        rSizeXPix = ToPixel(mrDoc.GetColWidth(nX, nCurrentTab), nPPTX);
+        rSizeYPix = ToPixel(mrDoc.GetRowHeight(nY, nCurrentTab), nPPTY);
         return false;
     }
 }
 
 bool ScViewData::GetMergeSizePrintTwips(SCCOL nX, SCROW nY, tools::Long& 
rSizeXTwips, tools::Long& rSizeYTwips) const
 {
-    const ScMergeAttr* pMerge = mrDoc.GetAttr(nX, nY, nTabNo, ATTR_MERGE);
+    SCTAB nCurrentTab = GetTabNo();
+    const ScMergeAttr* pMerge = mrDoc.GetAttr(nX, nY, nCurrentTab, ATTR_MERGE);
     SCCOL nCountX = pMerge->GetColMerge();
     if (!nCountX)
         nCountX = 1;
-    rSizeXTwips = mrDoc.GetColWidth(nX, nX + nCountX - 1, nTabNo);
+    rSizeXTwips = mrDoc.GetColWidth(nX, nX + nCountX - 1, nCurrentTab);
 
     SCROW nCountY = pMerge->GetRowMerge();
     if (!nCountY)
         nCountY = 1;
-    rSizeYTwips = mrDoc.GetRowHeight(nY, nY + nCountY - 1, nTabNo);
+    rSizeYTwips = mrDoc.GetRowHeight(nY, nY + nCountY - 1, nCurrentTab);
 
     return (nCountX > 1 || nCountY > 1);
 }
@@ -2890,14 +2893,14 @@ void ScViewData::GetPosFromPixel( tools::Long nClickX, 
tools::Long nClickY, ScSp
                                         bool bTestMerge, bool bRepair, SCTAB 
nForTab )
 {
     //  special handling of 0 is now in ScViewFunctionSet::SetCursorAtPoint
-
+    SCTAB nCurrentTab = GetTabNo();
     if (nForTab == -1)
-        nForTab = nTabNo;
-    bool bForCurTab = (nForTab == nTabNo);
+        nForTab = nCurrentTab;
+    bool bForCurTab = (nForTab == nCurrentTab);
     if (!bForCurTab && (!ValidTab(nForTab) || (nForTab >= 
static_cast<SCTAB>(maTabData.size()))))
     {
         SAL_WARN("sc.viewdata", "ScViewData::GetPosFromPixel :  invalid 
nForTab = " << nForTab);
-        nForTab = nTabNo;
+        nForTab = nCurrentTab;
         bForCurTab = true;
     }
 
@@ -2977,25 +2980,25 @@ void ScViewData::GetPosFromPixel( tools::Long nClickX, 
tools::Long nClickY, ScSp
     // public method to adapt position
     SCCOL nOrigX = rPosX;
     SCROW nOrigY = rPosY;
-    mrDoc.SkipOverlapped(rPosX, rPosY, nTabNo);
+    mrDoc.SkipOverlapped(rPosX, rPosY, nCurrentTab);
     bool bHOver = (nOrigX != rPosX);
     bool bVOver = (nOrigY != rPosY);
 
     if ( !(bRepair && ( bHOver || bVOver )) )
         return;
 
-    const ScMergeAttr* pMerge = mrDoc.GetAttr(rPosX, rPosY, nTabNo, 
ATTR_MERGE);
+    const ScMergeAttr* pMerge = mrDoc.GetAttr(rPosX, rPosY, nCurrentTab, 
ATTR_MERGE);
     if ( ( bHOver && pMerge->GetColMerge() <= 1 ) ||
          ( bVOver && pMerge->GetRowMerge() <= 1 ) )
     {
         OSL_FAIL("merge error found");
 
-        mrDoc.RemoveFlagsTab(0, 0, mrDoc.MaxCol(), mrDoc.MaxRow(), nTabNo, 
ScMF::Hor | ScMF::Ver);
+        mrDoc.RemoveFlagsTab(0, 0, mrDoc.MaxCol(), mrDoc.MaxRow(), 
nCurrentTab, ScMF::Hor | ScMF::Ver);
         SCCOL nEndCol = mrDoc.MaxCol();
         SCROW nEndRow = mrDoc.MaxRow();
-        mrDoc.ExtendMerge(0, 0, nEndCol, nEndRow, nTabNo, true);
+        mrDoc.ExtendMerge(0, 0, nEndCol, nEndRow, nCurrentTab, true);
         if (pDocShell)
-            pDocShell->PostPaint(ScRange(0, 0, nTabNo, mrDoc.MaxCol(), 
mrDoc.MaxRow(), nTabNo),
+            pDocShell->PostPaint(ScRange(0, 0, nCurrentTab, mrDoc.MaxCol(), 
mrDoc.MaxRow(), nCurrentTab),
                                  PaintPartFlags::Grid);
     }
 }
@@ -3003,7 +3006,7 @@ void ScViewData::GetPosFromPixel( tools::Long nClickX, 
tools::Long nClickY, ScSp
 void ScViewData::GetMouseQuadrant( const Point& rClickPos, ScSplitPos eWhich,
                                         SCCOL nPosX, SCROW nPosY, bool& rLeft, 
bool& rTop )
 {
-    bool bLayoutRTL = mrDoc.IsLayoutRTL(nTabNo);
+    bool bLayoutRTL = mrDoc.IsLayoutRTL(GetTabNo());
     tools::Long nLayoutSign = bLayoutRTL ? -1 : 1;
 
     Point aCellStart = GetScrPos( nPosX, nPosY, eWhich, true );
@@ -3027,14 +3030,14 @@ void ScViewData::SetPosX( ScHSplitPos eWhich, SCCOL 
nNewPosX )
         if ( nNewPosX > nOldPosX )
             for ( i=nOldPosX; i<nNewPosX; i++ )
             {
-                tools::Long nThis = mrDoc.GetColWidth(i, nTabNo);
+                tools::Long nThis = mrDoc.GetColWidth(i, GetTabNo());
                 nTPosX -= nThis;
                 nPixPosX -= ToPixel(sal::static_int_cast<sal_uInt16>(nThis), 
nPPTX);
             }
         else
             for ( i=nNewPosX; i<nOldPosX; i++ )
             {
-                tools::Long nThis = mrDoc.GetColWidth(i, nTabNo);
+                tools::Long nThis = mrDoc.GetColWidth(i, GetTabNo());
                 nTPosX += nThis;
                 nPixPosX += ToPixel(sal::static_int_cast<sal_uInt16>(nThis), 
nPPTX);
             }
@@ -3066,7 +3069,7 @@ void ScViewData::SetPosY( ScVSplitPos eWhich, SCROW 
nNewPosY )
         if ( nNewPosY > nOldPosY )
             for ( i=nOldPosY; i<nNewPosY; i++ )
             {
-                tools::Long nThis = mrDoc.GetRowHeight(i, nTabNo, nullptr, 
&nHeightEndRow);
+                tools::Long nThis = mrDoc.GetRowHeight(i, GetTabNo(), nullptr, 
&nHeightEndRow);
                 SCROW nRows = std::min( nNewPosY, nHeightEndRow + 1) - i;
                 i = nHeightEndRow;
                 nTPosY -= nThis * nRows;
@@ -3075,7 +3078,7 @@ void ScViewData::SetPosY( ScVSplitPos eWhich, SCROW 
nNewPosY )
         else
             for ( i=nNewPosY; i<nOldPosY; i++ )
             {
-                tools::Long nThis = mrDoc.GetRowHeight(i, nTabNo, nullptr, 
&nHeightEndRow);
+                tools::Long nThis = mrDoc.GetRowHeight(i, GetTabNo(), nullptr, 
&nHeightEndRow);
                 SCROW nRows = std::min( nOldPosY, nHeightEndRow + 1) - i;
                 i = nHeightEndRow;
                 nTPosY += nThis * nRows;
@@ -3103,7 +3106,7 @@ void ScViewData::RecalcPixPos()             // after zoom 
changes
         tools::Long nPixPosX = 0;
         SCCOL nPosX = pThisTab->nPosX[eWhich];
         for (SCCOL i=0; i<nPosX; i++)
-            nPixPosX -= ToPixel(mrDoc.GetColWidth(i, nTabNo), nPPTX);
+            nPixPosX -= ToPixel(mrDoc.GetColWidth(i, GetTabNo()), nPPTX);
         pThisTab->nPixPosX[eWhich] = nPixPosX;
 
         tools::Long nPixPosY = 0;
@@ -3113,7 +3116,7 @@ void ScViewData::RecalcPixPos()             // after zoom 
changes
         for (SCROW j=0; j<nPosY; j++)
         {
             if(nLastSameHeightRow < j)
-                nRowHeight = ToPixel(mrDoc.GetRowHeight(j, nTabNo, nullptr, 
&nLastSameHeightRow), nPPTY);
+                nRowHeight = ToPixel(mrDoc.GetRowHeight(j, GetTabNo(), 
nullptr, &nLastSameHeightRow), nPPTY);
             nPixPosY -= nRowHeight;
         }
         pThisTab->nPixPosY[eWhich] = nPixPosY;
@@ -3148,7 +3151,7 @@ void ScViewData::SetScreen( SCCOL nCol1, SCROW nRow1, 
SCCOL nCol2, SCROW nRow2 )
 
     for (nCol=nCol1; nCol<=nCol2; nCol++)
     {
-        nTSize = mrDoc.GetColWidth(nCol, nTabNo);
+        nTSize = mrDoc.GetColWidth(nCol, GetTabNo());
         if (nTSize)
         {
             nSizePix = ToPixel( nTSize, nPPTX );
@@ -3158,7 +3161,7 @@ void ScViewData::SetScreen( SCCOL nCol1, SCROW nRow1, 
SCCOL nCol2, SCROW nRow2 )
 
     for (nRow=nRow1; nRow<=nRow2; nRow++)
     {
-        nTSize = mrDoc.GetRowHeight(nRow, nTabNo);
+        nTSize = mrDoc.GetRowHeight(nRow, GetTabNo());
         if (nTSize)
         {
             nSizePix = ToPixel( nTSize, nPPTY );
@@ -3178,13 +3181,13 @@ void ScViewData::SetScreenPos( const Point& 
rVisAreaStart )
 
     nSize = 0;
     nTwips = o3tl::convert(rVisAreaStart.X(), o3tl::Length::mm100, 
o3tl::Length::twip);
-    if (mrDoc.IsLayoutRTL(nTabNo))
+    if (mrDoc.IsLayoutRTL(GetTabNo()))
         nTwips = -nTwips;
     SCCOL nX1 = 0;
     bEnd = false;
     while (!bEnd)
     {
-        nAdd = static_cast<tools::Long>(mrDoc.GetColWidth(nX1, nTabNo));
+        nAdd = static_cast<tools::Long>(mrDoc.GetColWidth(nX1, GetTabNo()));
         if (nSize + nAdd <= nTwips + 1 && nX1 < mrDoc.MaxCol())
         {
             nSize += nAdd;
@@ -3200,7 +3203,7 @@ void ScViewData::SetScreenPos( const Point& rVisAreaStart 
)
     bEnd = false;
     while (!bEnd)
     {
-        nAdd = static_cast<tools::Long>(mrDoc.GetRowHeight(nY1, nTabNo));
+        nAdd = static_cast<tools::Long>(mrDoc.GetRowHeight(nY1, GetTabNo()));
         if (nSize + nAdd <= nTwips + 1 && nY1 < mrDoc.MaxRow())
         {
             nSize += nAdd;
@@ -3323,16 +3326,17 @@ void ScViewData::CalcPPT()
     //  try to adjust horizontal scale so the most common column width has 
minimal rounding errors,
     //  to avoid differences between cell and drawing layer output
 
-    if (mrDoc.HasDetectiveObjects(nTabNo))
+    SCTAB nCurrentTab = GetTabNo();
+    if (mrDoc.HasDetectiveObjects(nCurrentTab))
     {
         SCCOL nEndCol = 0;
         SCROW nDummy = 0;
-        mrDoc.GetTableArea(nTabNo, nEndCol, nDummy);
+        mrDoc.GetTableArea(nCurrentTab, nEndCol, nDummy);
         if (nEndCol<20)
             nEndCol = 20;           // same end position as when determining 
draw scale
 
-        sal_uInt16 nTwips = mrDoc.GetCommonWidth(nEndCol, nTabNo);
-        if ( nTwips )
+        sal_uInt16 nTwips = mrDoc.GetCommonWidth(nEndCol, nCurrentTab);
+        if (nTwips)
         {
             double fOriginal = nTwips * nPPTX;
             if ( fOriginal < static_cast<double>(nEndCol) )
@@ -3394,8 +3398,7 @@ void ScViewData::WriteUserData(OUString& rData)
     else
         rData += "0";
 
-    rData += ";" + OUString::number( nTabNo ) + ";" + TAG_TABBARWIDTH +
-             OUString::number( pView->GetTabBarWidth() );
+    rData += ";" + OUString::number(GetTabNo()) + ";" + TAG_TABBARWIDTH + 
OUString::number( pView->GetTabBarWidth() );
 
     SCTAB nTabCount = mrDoc.GetTableCount();
     for (SCTAB i=0; i<nTabCount; i++)
@@ -3838,7 +3841,7 @@ void ScViewData::WriteUserDataSequence(uno::Sequence 
<beans::PropertyValue>& rSe
     pSettings[SC_TABLE_VIEWSETTINGS].Value <<= xNameContainer;
 
     OUString sName;
-    GetDocument().GetName( nTabNo, sName );
+    GetDocument().GetName( GetTabNo(), sName );
     pSettings[SC_ACTIVE_TABLE].Name = SC_ACTIVETABLE;
     pSettings[SC_ACTIVE_TABLE].Value <<= sName;
     pSettings[SC_HORIZONTAL_SCROLL_BAR_WIDTH].Name = 
SC_HORIZONTALSCROLLBARWIDTH;
@@ -3950,7 +3953,7 @@ void ScViewData::ReadUserDataSequence(const uno::Sequence 
<beans::PropertyValue>
             {
                 SCTAB nTab(0);
                 if (GetDocument().GetTable(sTabName, nTab))
-                    nTabNo = nTab;
+                    mnTabNumber = nTab;
             }
         }
         else if (sName == SC_HORIZONTALSCROLLBARWIDTH)
@@ -4127,10 +4130,10 @@ bool ScViewData::IsOle() const
     return pDocShell && pDocShell->IsOle();
 }
 
-bool ScViewData::UpdateFixX( SCTAB nTab )                   // true = value 
changed
+bool ScViewData::UpdateFixX( SCTAB nTab ) // true = value changed
 {
-    if (!ValidTab(nTab))        // Default
-        nTab=nTabNo;            // current table
+    if (!ValidTab(nTab)) // Default
+        nTab = GetTabNo(); // current table
 
     if (!pView || maTabData[nTab]->eHSplitMode != SC_SPLIT_FIX)
         return false;
@@ -4154,7 +4157,7 @@ bool ScViewData::UpdateFixX( SCTAB nTab )                 
  // true = value chan
     if (nNewPos != maTabData[nTab]->nHSplitPos)
     {
         maTabData[nTab]->nHSplitPos = nNewPos;
-        if (nTab == nTabNo)
+        if (nTab == GetTabNo())
             RecalcPixPos();                 // should not be needed
         return true;
     }
@@ -4162,10 +4165,10 @@ bool ScViewData::UpdateFixX( SCTAB nTab )               
    // true = value chan
     return false;
 }
 
-bool ScViewData::UpdateFixY( SCTAB nTab )               // true = value changed
+bool ScViewData::UpdateFixY( SCTAB nTab ) // true = value changed
 {
-    if (!ValidTab(nTab))        // Default
-        nTab=nTabNo;        // current table
+    if (!ValidTab(nTab)) // Default
+        nTab = GetTabNo(); // current table
 
     if (!pView || maTabData[nTab]->eVSplitMode != SC_SPLIT_FIX)
         return false;
@@ -4189,7 +4192,7 @@ bool ScViewData::UpdateFixY( SCTAB nTab )               
// true = value changed
     if (nNewPos != maTabData[nTab]->nVSplitPos)
     {
         maTabData[nTab]->nVSplitPos = nNewPos;
-        if (nTab == nTabNo)
+        if (nTab == GetTabNo())
             RecalcPixPos();                 // should not be needed
         return true;
     }
@@ -4225,8 +4228,7 @@ void ScViewData::UpdateOutlinerFlags( Outliner& rOutl ) 
const
         rOutl.SetSpeller( xXSpellChecker1 );
     }
 
-    rOutl.SetDefaultHorizontalTextDirection(
-        rLocalDoc.GetEditTextDirection( nTabNo ) );
+    
rOutl.SetDefaultHorizontalTextDirection(rLocalDoc.GetEditTextDirection(GetTabNo()));
 }
 
 ScAddress ScViewData::GetCurPos() const
@@ -4245,18 +4247,18 @@ void ScViewData::SetRefEnd( SCCOL nNewX, SCROW nNewY, 
SCTAB nNewZ )
 }
 
 void ScViewData::AddPixelsWhile( tools::Long & rScrY, tools::Long nEndPixels, 
SCROW & rPosY,
-        SCROW nEndRow, double nPPTY, const ScDocument * pDoc, SCTAB nTabNo )
+        SCROW nEndRow, double nPPTY, const ScDocument * pDoc, SCTAB nTab)
 {
     SCROW nRow = rPosY;
     while (rScrY <= nEndPixels && nRow <= nEndRow)
     {
         SCROW nHeightEndRow;
-        sal_uInt16 nHeight = pDoc->GetRowHeight( nRow, nTabNo, nullptr, 
&nHeightEndRow);
+        sal_uInt16 nHeight = pDoc->GetRowHeight( nRow, nTab, nullptr, 
&nHeightEndRow);
         if (nHeightEndRow > nEndRow)
             nHeightEndRow = nEndRow;
         if (!nHeight)
         {
-            if (ValidTab(nTabNo) && nTabNo <= pDoc->GetMaxTableNumber())
+            if (ValidTab(nTab) && nTab <= pDoc->GetMaxTableNumber())
                 nRow = nHeightEndRow + 1;
             else
                 break;
@@ -4289,13 +4291,13 @@ void ScViewData::AddPixelsWhile( tools::Long & rScrY, 
tools::Long nEndPixels, SC
 
 void ScViewData::AddPixelsWhileBackward( tools::Long & rScrY, tools::Long 
nEndPixels,
         SCROW & rPosY, SCROW nStartRow, double nPPTY, const ScDocument * pDoc,
-        SCTAB nTabNo )
+        SCTAB nTab )
 {
     SCROW nRow = rPosY;
     while (rScrY <= nEndPixels && nRow >= nStartRow)
     {
         SCROW nHeightStartRow;
-        sal_uInt16 nHeight = pDoc->GetRowHeight( nRow, nTabNo, 
&nHeightStartRow, nullptr);
+        sal_uInt16 nHeight = pDoc->GetRowHeight(nRow, nTab, &nHeightStartRow, 
nullptr);
         if (nHeightStartRow < nStartRow)
             nHeightStartRow = nStartRow;
         if (!nHeight)
@@ -4328,7 +4330,7 @@ void ScViewData::AddPixelsWhileBackward( tools::Long & 
rScrY, tools::Long nEndPi
 
 SCCOLROW ScViewData::GetLOKSheetFreezeIndex(bool bIsCol) const
 {
-    SCCOLROW nFreezeIndex = bIsCol ? mrDoc.GetLOKFreezeCol(nTabNo) : 
mrDoc.GetLOKFreezeRow(nTabNo);
+    SCCOLROW nFreezeIndex = bIsCol ? mrDoc.GetLOKFreezeCol(GetTabNo()) : 
mrDoc.GetLOKFreezeRow(GetTabNo());
     return nFreezeIndex >= 0 ? nFreezeIndex : 0;
 }
 
@@ -4336,7 +4338,7 @@ bool ScViewData::SetLOKSheetFreezeIndex(const SCCOLROW 
nFreezeIndex, bool bIsCol
 {
     if (nForTab == -1)
     {
-        nForTab = nTabNo;
+        nForTab = GetTabNo();
     }
     else if (!ValidTab(nForTab) || (nForTab >= 
static_cast<SCTAB>(maTabData.size())))
     {

Reply via email to