sc/source/ui/undo/undobase.cxx  |    6 +++---
 sc/source/ui/undo/undotab.cxx   |    2 +-
 sc/source/ui/undo/undoutil.cxx  |    2 +-
 sc/source/ui/unoobj/viewuno.cxx |   24 ++++++++++++------------
 sc/source/ui/view/dbfunc3.cxx   |    2 +-
 sc/source/ui/view/tabview3.cxx  |    4 ++--
 sc/source/ui/view/tabvwsh3.cxx  |   10 +++++-----
 sc/source/ui/view/tabvwsh4.cxx  |    2 +-
 sc/source/ui/view/tabvwsha.cxx  |    4 ++--
 sc/source/ui/view/tabvwshf.cxx  |   35 ++++++++++++++++++-----------------
 sc/source/ui/view/viewdata.cxx  |    9 ++++++---
 sc/source/ui/view/viewfun3.cxx  |    2 +-
 sc/source/ui/view/viewfunc.cxx  |    4 ++--
 13 files changed, 55 insertions(+), 51 deletions(-)

New commits:
commit e02c35585f8454eb8ec92b1d93ce0c8eefab4fe3
Author:     Tomaž Vajngerl <[email protected]>
AuthorDate: Thu Feb 19 13:49:28 2026 +0900
Commit:     Miklos Vajna <[email protected]>
CommitDate: Fri Feb 20 13:58:49 2026 +0100

    sc: Fix some more places where default sheet tab should be used
    
    Change-Id: I4c9ab77f78394f8fb6a3b4b19eb1d52c528f4108
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199680
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>

diff --git a/sc/source/ui/undo/undobase.cxx b/sc/source/ui/undo/undobase.cxx
index e6d0f32c05e6..24ef9bc7e5bd 100644
--- a/sc/source/ui/undo/undobase.cxx
+++ b/sc/source/ui/undo/undobase.cxx
@@ -235,7 +235,7 @@ void ScSimpleUndo::ShowTable( const ScRange& rRange )
     {
         SCTAB nStart = rRange.aStart.Tab();
         SCTAB nEnd   = rRange.aEnd.Tab();
-        SCTAB nTab = pViewShell->GetViewData().CurrentTabForData();
+        SCTAB nTab = pViewShell->GetViewData().GetTabNumber();
         if ( nTab < nStart || nTab > nEnd )                     // if not in 
range:
             pViewShell->SetTabNo( nStart );                     // at 
beginning of the range
     }
@@ -346,7 +346,7 @@ void ScBlockUndo::ShowBlock()
     ShowTable( aBlockRange );       // with multiple sheets in range each of 
them is good
     pViewShell->MoveCursorAbs( aBlockRange.aStart.Col(), 
aBlockRange.aStart.Row(),
                                SC_FOLLOW_JUMP, false, false );
-    SCTAB nTab = pViewShell->GetViewData().CurrentTabForData();
+    SCTAB nTab = pViewShell->GetViewData().GetTabNumber();
     ScRange aRange = aBlockRange;
     aRange.aStart.SetTab( nTab );
     aRange.aEnd.SetTab( nTab );
@@ -406,7 +406,7 @@ void ScMultiBlockUndo::ShowBlock()
     ShowTable(aRange);
     pViewShell->MoveCursorAbs(
         aRange.aStart.Col(), aRange.aStart.Row(), SC_FOLLOW_JUMP, false, 
false);
-    SCTAB nTab = pViewShell->GetViewData().CurrentTabForData();
+    SCTAB nTab = pViewShell->GetViewData().GetTabNumber();
     aRange.aStart.SetTab(nTab);
     aRange.aEnd.SetTab(nTab);
     pViewShell->MarkRange(aRange, false);
diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx
index 3d9c768185e6..59c190925af5 100644
--- a/sc/source/ui/undo/undotab.cxx
+++ b/sc/source/ui/undo/undotab.cxx
@@ -506,7 +506,7 @@ void ScUndoDeleteTab::Repeat(SfxRepeatTarget& rTarget)
     if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
     {
         ScTabViewShell* pViewShell = pViewTarget->GetViewShell();
-        pViewShell->DeleteTable( pViewShell->GetViewData().CurrentTabForData() 
);
+        pViewShell->DeleteTable( pViewShell->GetViewData().GetTabNumber() );
     }
 }
 
diff --git a/sc/source/ui/undo/undoutil.cxx b/sc/source/ui/undo/undoutil.cxx
index 38bf22641ee0..62efe37403f3 100644
--- a/sc/source/ui/undo/undoutil.cxx
+++ b/sc/source/ui/undo/undoutil.cxx
@@ -39,7 +39,7 @@ void ScUndoUtil::MarkSimpleBlock( const ScDocShell* pDocShell,
     if (!pViewShell)
         return;
 
-    SCTAB nViewTab = pViewShell->GetViewData().CurrentTabForData();
+    SCTAB nViewTab = pViewShell->GetViewData().GetTabNumber();
     if ( nViewTab < nStartZ || nViewTab > nEndZ )
         pViewShell->SetTabNo( nStartZ );
 
diff --git a/sc/source/ui/unoobj/viewuno.cxx b/sc/source/ui/unoobj/viewuno.cxx
index 97bb4aa6c613..115aaf83eb31 100644
--- a/sc/source/ui/unoobj/viewuno.cxx
+++ b/sc/source/ui/unoobj/viewuno.cxx
@@ -270,7 +270,7 @@ table::CellRangeAddress SAL_CALL 
ScViewPaneBase::getVisibleRange()
         SCROW nVisY = rViewData.VisibleCellsY( eWhichV );
         if (!nVisX) nVisX = 1;  // there has to be something in the range
         if (!nVisY) nVisY = 1;
-        aAdr.Sheet       = rViewData.CurrentTabForData();
+        aAdr.Sheet       = rViewData.GetTabNumber();
         aAdr.StartColumn = rViewData.GetPosX( eWhichH );
         aAdr.StartRow    = rViewData.GetPosY( eWhichV );
         aAdr.EndColumn   = aAdr.StartColumn + nVisX - 1;
@@ -397,7 +397,7 @@ awt::Rectangle ScViewPaneBase::GetVisArea() const
                                     SC_SPLIT_TOP : SC_SPLIT_BOTTOM;
             ScAddress aCell(pViewShell->GetViewData().GetPosX(eWhichH),
                 pViewShell->GetViewData().GetPosY(eWhichV),
-                pViewShell->GetViewData().CurrentTabForData());
+                pViewShell->GetViewData().GetTabNumber());
             tools::Rectangle aCellRect( rDoc.GetMMRect( aCell.Col(), 
aCell.Row(), aCell.Col(), aCell.Row(), aCell.Tab() ) );
             Size aVisSize( pWindow->PixelToLogic( pWindow->GetSizePixel(), 
pWindow->GetDrawMapMode( true ) ) );
             Point aVisPos( aCellRect.TopLeft() );
@@ -456,7 +456,7 @@ ScTabViewObj::ScTabViewObj( ScTabViewShell* pViewSh ) :
     mbLeftMousePressed(false)
 {
     if (pViewSh)
-        nPreviousTab = pViewSh->GetViewData().CurrentTabForData();
+        nPreviousTab = pViewSh->GetViewData().GetTabNumber();
 }
 
 ScTabViewObj::~ScTabViewObj()
@@ -557,7 +557,7 @@ void ScTabViewObj::SheetChanged( bool bSameTabButMoved )
         sheet::ActivationEvent aEvent;
         uno::Reference< sheet::XSpreadsheetView > xView(this);
         aEvent.Source.set(xView, uno::UNO_QUERY);
-        aEvent.ActiveSheet = new ScTableSheetObj(pDocSh, 
rViewData.CurrentTabForData());
+        aEvent.ActiveSheet = new ScTableSheetObj(pDocSh, 
rViewData.GetTabNumber());
         // Listener's handler may remove it from the listeners list
         for (size_t i = aActivationListeners.size(); i > 0; --i)
         {
@@ -574,7 +574,7 @@ void ScTabViewObj::SheetChanged( bool bSameTabButMoved )
 
     /*  Handle sheet events, but do not trigger event handlers, if the old
         active sheet gets re-activated after inserting/deleting/moving a 
sheet. */
-    SCTAB nNewTab = rViewData.CurrentTabForData();
+    SCTAB nNewTab = rViewData.GetTabNumber();
     if ( !bSameTabButMoved && (nNewTab != nPreviousTab) )
     {
         lcl_CallActivate( pDocSh, nPreviousTab, ScSheetEventId::UNFOCUS );
@@ -736,7 +736,7 @@ sal_Bool SAL_CALL ScTabViewObj::select( const uno::Any& 
aSelection )
                 // multiselection
 
                 const ScRange & rFirst = rRanges[ 0 ];
-                if ( !lcl_TabInRanges( rViewData.CurrentTabForData(), rRanges 
) )
+                if ( !lcl_TabInRanges( rViewData.GetTabNumber(), rRanges ) )
                     pViewSh->SetTabNo( rFirst.aStart.Tab() );
                 pViewSh->DoneBlockMode();
                 pViewSh->InitOwnBlockMode( rFirst );    /* TODO: or even the 
overall range? */
@@ -1088,7 +1088,7 @@ uno::Reference<sheet::XSpreadsheet> SAL_CALL 
ScTabViewObj::getActiveSheet()
     if (pViewSh)
     {
         ScViewData& rViewData = pViewSh->GetViewData();
-        SCTAB nTab = rViewData.CurrentTabForData();
+        SCTAB nTab = rViewData.GetTabNumber();
         return new ScTableSheetObj( rViewData.GetDocShell(), nTab );
     }
     return nullptr;
@@ -1128,7 +1128,7 @@ uno::Reference< uno::XInterface > 
ScTabViewObj::GetClickedObject(const Point& rP
         SCROW nY;
         ScViewData& rData = GetViewShell()->GetViewData();
         ScSplitPos eSplitMode = rData.GetActivePart();
-        SCTAB nTab(rData.CurrentTabForData());
+        SCTAB nTab(rData.GetTabNumber());
         rData.GetPosFromPixel( rPoint.X(), rPoint.Y(), eSplitMode, nX, nY);
 
         ScAddress aCellPos (nX, nY, nTab);
@@ -1174,7 +1174,7 @@ bool ScTabViewObj::IsMouseListening() const
     // also include sheet events, because MousePressed must be called for them
     ScViewData& rViewData = GetViewShell()->GetViewData();
     ScDocument& rDoc = rViewData.GetDocument();
-    SCTAB nTab = rViewData.CurrentTabForData();
+    SCTAB nTab = rViewData.GetTabNumber();
     return
         rDoc.HasSheetEventScript( nTab, ScSheetEventId::RIGHTCLICK, true ) ||
         rDoc.HasSheetEventScript( nTab, ScSheetEventId::DOUBLECLICK, true ) ||
@@ -1227,7 +1227,7 @@ bool ScTabViewObj::MousePressed( const awt::MouseEvent& e 
)
         ScViewData& rViewData = pViewSh->GetViewData();
         ScDocShell* pDocSh = rViewData.GetDocShell();
         ScDocument& rDoc = pDocSh->GetDocument();
-        SCTAB nTab = rViewData.CurrentTabForData();
+        SCTAB nTab = rViewData.GetTabNumber();
         const ScSheetEvents* pEvents = rDoc.GetSheetEvents(nTab);
         if (pEvents)
         {
@@ -1702,7 +1702,7 @@ void ScTabViewObj::SelectionChanged()
     ScViewData& rViewData = pViewSh->GetViewData();
     ScDocShell* pDocSh = rViewData.GetDocShell();
     ScDocument& rDoc = pDocSh->GetDocument();
-    SCTAB nTab = rViewData.CurrentTabForData();
+    SCTAB nTab = rViewData.GetTabNumber();
     const ScSheetEvents* pEvents = rDoc.GetSheetEvents(nTab);
     if (pEvents)
     {
@@ -2198,7 +2198,7 @@ uno::Sequence<sal_Int32> ScTabViewObj::getSelectedSheets()
     if (pExtOpt && pExtOpt->IsChanged())
     {
         pViewSh->GetViewData().ReadExtOptions(*pExtOpt);        // Excel view 
settings
-        pViewSh->SetTabNo(pViewSh->GetViewData().CurrentTabForData(), true);
+        pViewSh->SetTabNo(pViewSh->GetViewData().GetTabNumber(), true);
         pExtOpt->SetChanged(false);
     }
 
diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx
index 64b43582e9f7..52c7cc38d9de 100644
--- a/sc/source/ui/view/dbfunc3.cxx
+++ b/sc/source/ui/view/dbfunc3.cxx
@@ -2392,7 +2392,7 @@ void ScDBFunc::OnLOKShowHideColRow(bool bColumns, 
SCCOLROW nStart)
     if (!comphelper::LibreOfficeKit::isActive())
         return;
 
-    SCTAB nCurrentTabIndex = GetViewData().CurrentTabForData();
+    SCTAB nCurrentTabIndex = GetViewData().GetTabNumber();
     SfxViewShell* pThisViewShell = GetViewData().GetViewShell();
     SfxViewShell* pViewShell = SfxViewShell::GetFirst();
     while (pViewShell)
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index 728e323f5039..9e91839e4458 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -2152,11 +2152,11 @@ void ScTabView::OnLibreOfficeKitTabChanged()
         return;
 
     ScTabViewShell* pThisViewShell = aViewData.GetViewShell();
-    SCTAB nThisTabNo = pThisViewShell->GetViewData().CurrentTabForData();
+    SCTAB nThisTabNo = pThisViewShell->GetViewData().GetTabNumber();
     auto lTabSwitch = [pThisViewShell, nThisTabNo] (ScTabViewShell* 
pOtherViewShell)
     {
         ScViewData& rOtherViewData = pOtherViewShell->GetViewData();
-        SCTAB nOtherTabNo = rOtherViewData.CurrentTabForData();
+        SCTAB nOtherTabNo = rOtherViewData.GetTabNumber();
         if (nThisTabNo == nOtherTabNo)
         {
             for (int i = 0; i < 4; ++i)
diff --git a/sc/source/ui/view/tabvwsh3.cxx b/sc/source/ui/view/tabvwsh3.cxx
index d1682ec6ddaf..3fce5f2718fc 100644
--- a/sc/source/ui/view/tabvwsh3.cxx
+++ b/sc/source/ui/view/tabvwsh3.cxx
@@ -258,7 +258,7 @@ void ScTabViewShell::ExecProtectTable( SfxRequest& rReq )
     ScModule* pScMod = ScModule::get();
     const SfxItemSet*   pReqArgs    = rReq.GetArgs();
     ScDocument&         rDoc = GetViewData().GetDocument();
-    SCTAB               nTab = GetViewData().CurrentTabForData();
+    SCTAB               nTab = GetViewData().GetTabNumber();
     bool                bOldProtection = rDoc.IsTabProtected(nTab);
 
     if( pReqArgs )
@@ -1367,7 +1367,7 @@ void ScTabViewShell::Execute( SfxRequest& rReq )
                 else
                 {
                     ScViewData& rViewData = GetViewData();
-                    SCTAB nThisTab = rViewData.CurrentTabForData();
+                    SCTAB nThisTab = rViewData.GetTabNumber();
                     bool bChangedX = false, bChangedY = false;
                     if (rViewData.GetLOKSheetFreezeIndex(true) > 0 ||
                         rViewData.GetLOKSheetFreezeIndex(false) > 0 )          
                   // remove freeze
@@ -1389,7 +1389,7 @@ void ScTabViewShell::Execute( SfxRequest& rReq )
                         // Invalidate the slot for all views on the same tab 
of the document.
                         SfxLokHelper::forEachOtherView(this, 
[nThisTab](ScTabViewShell* pOther) {
                             ScViewData& rOtherViewData = pOther->GetViewData();
-                            if (rOtherViewData.CurrentTabForData() != nThisTab)
+                            if (rOtherViewData.GetTabNumber() != nThisTab)
                                 return;
 
                             SfxBindings& rOtherBind = 
rOtherViewData.GetBindings();
@@ -1419,7 +1419,7 @@ void ScTabViewShell::Execute( SfxRequest& rReq )
                 if (comphelper::LibreOfficeKit::isActive())
                 {
                     ScViewData& rViewData = GetViewData();
-                    SCTAB nThisTab = rViewData.CurrentTabForData();
+                    SCTAB nThisTab = rViewData.GetTabNumber();
                     bool bChanged = 
rViewData.SetLOKSheetFreezeIndex(nFreezeIndex, bIsCol);
                     rReq.Done();
                     if (bChanged)
@@ -1429,7 +1429,7 @@ void ScTabViewShell::Execute( SfxRequest& rReq )
                         // Invalidate the slot for all views on the same tab 
of the document.
                         SfxLokHelper::forEachOtherView(this, [nSlot, 
nThisTab](ScTabViewShell* pOther) {
                             ScViewData& rOtherViewData = pOther->GetViewData();
-                            if (rOtherViewData.CurrentTabForData() != nThisTab)
+                            if (rOtherViewData.GetTabNumber() != nThisTab)
                                 return;
 
                             SfxBindings& rOtherBind = 
rOtherViewData.GetBindings();
diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
index eaf1198b7c0f..f63442bec759 100644
--- a/sc/source/ui/view/tabvwsh4.cxx
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -2317,7 +2317,7 @@ void ScTabViewShell::FillFieldData( ScHeaderFieldData& 
rData )
 {
     ScDocShell* pDocShell = GetViewData().GetDocShell();
     ScDocument& rDoc = pDocShell->GetDocument();
-    SCTAB nTab = GetViewData().CurrentTabForData();
+    SCTAB nTab = GetViewData().GetTabNumber();
     OUString aTmp;
     rDoc.GetName(nTab, aTmp);
     rData.aTabName = aTmp;
diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx
index d02d0baac128..4797ee18dcc5 100644
--- a/sc/source/ui/view/tabvwsha.cxx
+++ b/sc/source/ui/view/tabvwsha.cxx
@@ -272,7 +272,7 @@ void ScTabViewShell::GetState( SfxItemSet& rSet )
 
             case SID_CURRENTTAB:
                 // Table for Basic is 1-based
-                rSet.Put( SfxUInt16Item( nWhich, 
static_cast<sal_uInt16>(GetViewData().CurrentTabForData()) + 1 ) );
+                rSet.Put( SfxUInt16Item( nWhich, 
static_cast<sal_uInt16>(GetViewData().GetTabNumber()) + 1 ) );
                 break;
 
             case SID_CURRENTDOC:
@@ -504,7 +504,7 @@ void ScTabViewShell::GetState( SfxItemSet& rSet )
                     Point aPos;
                     bool bIsCol = (nWhich == SID_WINDOW_FIX_COL);
                     aPos.setX(rViewData.GetLOKSheetFreezeIndex(bIsCol));
-                    aPos.setY(rViewData.CurrentTabForData());
+                    aPos.setY(rViewData.GetTabNumber());
                     rSet.Put(SfxPointItem(nWhich, aPos));
                 }
                 break;
diff --git a/sc/source/ui/view/tabvwshf.cxx b/sc/source/ui/view/tabvwshf.cxx
index 6ec5cfd7b5ef..97c2314410e7 100644
--- a/sc/source/ui/view/tabvwshf.cxx
+++ b/sc/source/ui/view/tabvwshf.cxx
@@ -64,8 +64,9 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
     ScViewData& rViewData   = GetViewData();
     ScDocument& rDoc        = rViewData.GetDocument();
 
-    SCTAB       nCurrentTab = rViewData.CurrentTabForData();
-    SCTAB       nTabCount   = rDoc.GetTableCount();
+    SCTAB nCurrentTab = rViewData.GetTabNumber();
+
+    SCTAB nTabCount   = rDoc.GetTableCount();
     sal_uInt16  nSlot       = rReq.GetSlot();
     const SfxItemSet* pReqArgs = rReq.GetArgs();
 
@@ -120,7 +121,7 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
                             if (it == rMark.GetSelectedTabs().end())
                             {
                                 // No it doesn't, so we won't shift the 
selected tab. Let's remember its position.
-                                nActiveTab = GetViewData().CurrentTabForData();
+                                nActiveTab = GetViewData().GetTabNumber();
                             }
                             rMark.SelectOneTable(nTabNumber);
                         }
@@ -212,7 +213,7 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
         case FID_TAB_DUPLICATE:
             {
                 // Get info about current document and selected tab
-                SCTAB nTab = rViewData.CurrentTabForData();
+                SCTAB nTab = rViewData.GetTabNumber();
                 OUString aDocName = 
GetViewData().GetDocShell()->GetTitle(SFX_TITLE_FULLNAME);
                 sal_uInt16 nDoc = 0;
                 bool bCpy = true;
@@ -394,7 +395,7 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
             {
                 ScDocShell* pDocSh = rViewData.GetDocShell();
                 ScDocFunc &rFunc = pDocSh->GetDocFunc();
-                bool bSet = !rDoc.IsLayoutRTL( nCurrentTab );
+                bool bSet = !rDoc.IsLayoutRTL(nCurrentTab);
 
                 const ScMarkData& rMark = rViewData.GetMarkData();
                 if ( rMark.GetSelectCount() != 0 )
@@ -411,7 +412,7 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
                     pUndoManager->LeaveListAction();
                 }
                 else
-                    rFunc.SetLayoutRTL( nCurrentTab, bSet );
+                    rFunc.SetLayoutRTL(nCurrentTab, bSet);
             }
             break;
 
@@ -479,7 +480,7 @@ void ScTabViewShell::GetStateTable( SfxItemSet& rSet )
     ScDocument& rDoc        = rViewData.GetDocument();
     ScDocShell* pDocShell   = rViewData.GetDocShell();
     ScMarkData& rMark       = GetViewData().GetMarkData();
-    SCTAB       nTab        = rViewData.CurrentTabForData();
+    SCTAB       nTab        = rViewData.GetTabNumber();
 
     SCTAB nTabCount = rDoc.GetTableCount();
     SCTAB nTabSelCount = rMark.GetSelectCount();
@@ -625,7 +626,7 @@ void ScTabViewShell::ExecuteMoveTable( SfxRequest& rReq )
 
     bool   bDoIt = false;
     sal_uInt16 nDoc = 0;
-    SCTAB nTab = rViewData.CurrentTabForData();
+    SCTAB nTab = rViewData.GetTabNumber();
     SCTAB nContextMenuTab = -1;
     bool bFromContextMenu = false;
     bool bFromMoveOrCopySheetDialog = false; // FN_PARAM_6
@@ -798,7 +799,7 @@ void ScTabViewShell::ExecuteMoveTable( SfxRequest& rReq )
     else
     {
         OUString aDefaultName;
-        rDoc.GetName( rViewData.CurrentTabForData(), aDefaultName );
+        rDoc.GetName( rViewData.GetTabNumber(), aDefaultName );
 
         ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
 
@@ -850,7 +851,7 @@ void ScTabViewShell::ExecuteInsertTable(SfxRequest& rReq)
     ScDocument& rDoc        = rViewData.GetDocument();
     const SfxItemSet* pReqArgs = rReq.GetArgs();
     sal_uInt16  nSlot       = rReq.GetSlot();
-    SCTAB       nCurrentTab = rViewData.CurrentTabForData();
+    SCTAB       nCurrentTab = rViewData.GetTabNumber();
     SCTAB       nTabCount   = rDoc.GetTableCount();
     ScMarkData& rMark    = rViewData.GetMarkData();
     SCTAB   nTabSelCount = rMark.GetSelectCount();
@@ -914,7 +915,7 @@ void ScTabViewShell::DoInsertTableFromDialog(SfxRequest& 
rReq, const VclPtr<Abst
 {
     ScViewData& rViewData   = GetViewData();
     ScDocument& rDoc        = rViewData.GetDocument();
-    SCTAB       nCurrentTab = rViewData.CurrentTabForData();
+    SCTAB       nCurrentTab = rViewData.GetTabNumber();
     SCTAB       nTabNr      = nCurrentTab;
     SCTAB       nTabCount   = rDoc.GetTableCount();
     ScMarkData& rMark    = rViewData.GetMarkData();
@@ -1058,7 +1059,7 @@ void 
ScTabViewShell::ExecuteAppendOrRenameTable(SfxRequest& rReq)
     if ( nSlot == FID_TAB_MENU_RENAME )
         nSlot = FID_TAB_RENAME;             // equal execute
 
-    SCTAB nTabNr = rViewData.CurrentTabForData();
+    SCTAB nTabNr = rViewData.GetTabNumber();
     ScMarkData& rMark = rViewData.GetMarkData();
     SCTAB nTabSelCount = rMark.GetSelectCount();
 
@@ -1126,7 +1127,7 @@ void 
ScTabViewShell::ExecuteAppendOrRenameTable(SfxRequest& rReq)
 
             case FID_TAB_RENAME:
                 aDlgTitle = ScResId(SCSTR_RENAMETAB);
-                rDoc.GetName( rViewData.CurrentTabForData(), aName );
+                rDoc.GetName( rViewData.GetTabNumber(), aName );
                 sHelpId = HID_SC_RENAME_NAME;
                 break;
         }
@@ -1167,7 +1168,7 @@ bool 
ScTabViewShell::DoAppendOrRenameTableDialog(sal_Int32 nResult, const VclPtr
         return false;
 
     ScViewData& rViewData   = GetViewData();
-    SCTAB nTabNr = rViewData.CurrentTabForData();
+    SCTAB nTabNr = rViewData.GetTabNumber();
     bool     bDone   = false;
 
     OUString aName = pDlg->GetInputString();
@@ -1217,10 +1218,10 @@ void 
ScTabViewShell::ExecuteSetTableBackgroundCol(SfxRequest& rReq)
     const SfxItemSet* pReqArgs = rReq.GetArgs();
     if ( nSlot == FID_TAB_MENU_SET_TAB_BG_COLOR )
         nSlot = FID_TAB_SET_TAB_BG_COLOR;
-    SCTAB nTabNr = rViewData.CurrentTabForData();
+    SCTAB nTabNr = rViewData.GetTabNumber();
     ScMarkData& rMark = rViewData.GetMarkData();
     SCTAB nTabSelCount = rMark.GetSelectCount();
-    SCTAB nCurrentTab = rViewData.CurrentTabForData();
+    SCTAB nCurrentTab = rViewData.GetTabNumber();
 
     if ( !rDoc.IsDocEditable() )
         return;
@@ -1302,7 +1303,7 @@ bool ScTabViewShell::DoTableBackgroundDialog(sal_Int32 
nResult, const VclPtr<Abs
     ScViewData& rViewData   = GetViewData();
     ScDocument& rDoc        = rViewData.GetDocument();
     ScMarkData& rMark = rViewData.GetMarkData();
-    SCTAB nCurrentTab = rViewData.CurrentTabForData();
+    SCTAB nCurrentTab = rViewData.GetTabNumber();
     SCTAB nTabSelCount = rMark.GetSelectCount();
     bool bDone   = false; /// temp
     Color aSelectedColor;
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index 12bc4022a18c..b2f408454f44 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -3411,11 +3411,14 @@ void ScViewData::WriteUserData(OUString& rData)
     else
         rData += "0";
 
-    rData += ";" + OUString::number(CurrentTabForData()) + ";" + 
TAG_TABBARWIDTH + OUString::number( pView->GetTabBarWidth() );
+    rData += ";" + OUString::number(GetTabNumber()) + ";" + TAG_TABBARWIDTH + 
OUString::number( pView->GetTabBarWidth() );
 
     SCTAB nTabCount = mrDoc.GetTableCount();
     for (SCTAB i=0; i<nTabCount; i++)
     {
+        if (mrDoc.IsSheetViewHolder(i))
+            continue;
+
         rData += ";";                   // Numbering must not get mixed up 
under any circumstances
         if (i < static_cast<SCTAB>(maTabData.size()) && maTabData[i])
         {
@@ -3556,7 +3559,7 @@ void ScViewData::WriteExtOptions( ScExtDocOptions& 
rDocOpt ) const
     ScExtDocSettings& rDocSett = rDocOpt.GetDocSettings();
 
     // displayed sheet
-    rDocSett.mnDisplTab = CurrentTabForData();
+    rDocSett.mnDisplTab = GetTabNumber();
 
     // width of the tabbar, relative to frame window width
     rDocSett.mfTabBarWidth = pView->GetPendingRelTabBarWidth();
@@ -3855,7 +3858,7 @@ void ScViewData::WriteUserDataSequence(uno::Sequence 
<beans::PropertyValue>& rSe
     pSettings[SC_TABLE_VIEWSETTINGS].Value <<= xNameContainer;
 
     OUString sName;
-    GetDocument().GetName( CurrentTabForData(), sName );
+    GetDocument().GetName( GetTabNumber(), sName );
     pSettings[SC_ACTIVE_TABLE].Name = SC_ACTIVETABLE;
     pSettings[SC_ACTIVE_TABLE].Value <<= sName;
     pSettings[SC_HORIZONTAL_SCROLL_BAR_WIDTH].Name = 
SC_HORIZONTALSCROLLBARWIDTH;
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index 32edd74d3b18..70ea7dcad657 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -774,7 +774,7 @@ bool ScViewFunc::PasteFromSystem( SotClipboardFormatId 
nFormatId, bool bApi )
             pTabViewShell->OnLOKSetWidthOrHeight(rViewData.GetCurY(), false);
 
             ScTabViewShell::notifyAllViewsSheetGeomInvalidation(pTabViewShell, 
true /* bColumns */, true /* bRows */,
-                true /* bSizes */, false /* bHidden */, false /* bFiltered */, 
false /* bGroups */, rViewData.CurrentTabForData());
+                true /* bSizes */, false /* bHidden */, false /* bFiltered */, 
false /* bGroups */, rViewData.GetTabNumber());
         }
     }
     return bRet;
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index bc6145d5ad0b..deeca51a42c2 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -1689,7 +1689,7 @@ void ScViewFunc::OnLOKInsertDeleteColumn(SCCOL nStartCol, 
tools::Long nOffset)
     if (!comphelper::LibreOfficeKit::isActive() || nOffset == 0)
         return;
 
-    SCTAB nCurrentTabIndex = GetViewData().CurrentTabForData();
+    SCTAB nCurrentTabIndex = GetViewData().GetTabNumber();
     SfxViewShell* pCurrentViewShell = GetViewData().GetViewShell();
     SfxViewShell* pViewShell = SfxViewShell::GetFirst();
     while (pViewShell)
@@ -1752,7 +1752,7 @@ void ScViewFunc::OnLOKInsertDeleteRow(SCROW nStartRow, 
tools::Long nOffset)
     if (!comphelper::LibreOfficeKit::isActive() || nOffset == 0)
         return;
 
-    SCTAB nCurrentTabIndex = GetViewData().CurrentTabForData();
+    SCTAB nCurrentTabIndex = GetViewData().GetTabNumber();
     SfxViewShell* pCurrentViewShell = GetViewData().GetViewShell();
     SfxViewShell* pViewShell = SfxViewShell::GetFirst();
     while (pViewShell)

Reply via email to