sc/source/ui/inc/tabvwsh.hxx | 1 + sc/source/ui/view/tabview3.cxx | 18 +----------------- sc/source/ui/view/tabvwsh4.cxx | 22 ++++++++++++++++++++++ sc/source/ui/view/tabvwsh5.cxx | 4 ++++ 4 files changed, 28 insertions(+), 17 deletions(-)
New commits: commit 6d63732812eacdfeda31217ce14fa5157f01b345 Author: Mohit Marathe <[email protected]> AuthorDate: Mon Feb 16 13:07:49 2026 +0530 Commit: Mohit Marathe <[email protected]> CommitDate: Mon Feb 16 14:05:03 2026 +0100 sc: update table shell when table is inserted at cursor position This allows us to notify client about context change (SfxLokHelper::notifyContextChange) which was only done for cursor position change. When a table is inserted, this is how context change is notified: 0 SfxLokHelper::notifyContextChange (rEvent=...) at /home/mohitm/work/libreoffice/co-25.04/sfx2/source/view/lokhelper.cxx:935 1 0x00007217edb12801 in sfx2::sidebar::ContextChangeBroadcaster::BroadcastContextChange (this=0x7217a8002078, rxFrame=uno::Reference to ((anonymous namespace)::XFrameImpl *) 0x5b91a420a520, rsModuleName="com.sun.star.sheet.SpreadsheetDocument", rsContextName="Cell") at /home/mohitm/work/libreoffice/co-25.04/sfx2/source/sidebar/ContextChangeBroadcaster.cxx:98 2 0x00007217edb1261c in sfx2::sidebar::ContextChangeBroadcaster::Activate (this=0x7217a8002078, rxFrame=uno::Reference to ((anonymous namespace)::XFrameImpl *) 0x5b91a420a520) at /home/mohitm/work/libreoffice/co-25.04/sfx2/source/sidebar/ContextChangeBroadcaster.cxx:53 3 0x00007217ed6c41be in SfxShell::BroadcastContextForActivation (this=0x5b91a4429980, bIsActivated=true) at /home/mohitm/work/libreoffice/co-25.04/sfx2/source/control/shell.cxx:723 4 0x00007217ed6c2997 in SfxShell::Activate (this=0x5b91a4429980) at /home/mohitm/work/libreoffice/co-25.04/sfx2/source/control/shell.cxx:373 5 0x00007217ed6c24c3 in SfxShell::DoActivate_Impl (this=0x5b91a4429980, pFrame=0x5b91a43174c0, bMDI=true) at /home/mohitm/work/libreoffice/co-25.04/sfx2/source/control/shell.cxx:326 6 0x00007217ed681797 in SfxDispatcher::FlushImpl (this=0x5b91a4532bc0) at /home/mohitm/work/libreoffice/co-25.04/sfx2/source/control/dispatch.cxx:1406 7 0x00007217ed6809ef in SfxDispatcher::Flush (this=0x5b91a4532bc0) at /home/mohitm/work/libreoffice/co-25.04/sfx2/source/control/dispatch.cxx:158 8 0x00007217edc3bbea in SfxViewShell::AddSubShell (this=0x5b91a45f3be0, rShell=...) at /home/mohitm/work/libreoffice/co-25.04/sfx2/source/view/viewsh.cxx:3033 9 0x00007217d3106387 in ScTabViewShell::SetCurSubShell (this=0x5b91a45f3be0, eOST=OST_Table, bForce=false) at /home/mohitm/work/libreoffice/co-25.04/sc/source/ui/view/tabvwsh4.cxx:1074 10 0x00007217d3106aff in ScTabViewShell::SetTableShell (this=0x5b91a45f3be0, bActive=true) at /home/mohitm/work/libreoffice/co-25.04/sc/source/ui/view/tabvwsh4.cxx:771 11 0x00007217d3106c55 in ScTabViewShell::UpdateContextShells (this=0x5b91a45f3be0) at /home/mohitm/work/libreoffice/co-25.04/sc/source/ui/view/tabvwsh4.cxx:792 Signed-off-by: Mohit Marathe <[email protected]> Change-Id: I6f9c643b08f5e2a5f5915627f7ee7cb6bc8cc7a0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199447 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Balazs Varga <[email protected]> (cherry picked from commit 0675868b3d1ab2e556b914f0e43fb90369277b98) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199481 Reviewed-by: Michael Stahl <[email protected]> diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx index b9597ccedb21..c0ad6d7a4ff8 100644 --- a/sc/source/ui/inc/tabvwsh.hxx +++ b/sc/source/ui/inc/tabvwsh.hxx @@ -338,6 +338,7 @@ public: void SetPivotShell( bool bActive ); void SetSparklineShell(bool bActive); void SetTableShell(bool bActive); + void UpdateContextShells(); void SetDialogDPObject( std::unique_ptr<ScDPObject> pObj ); const ScDPObject* GetDialogDPObject() const { return pDialogDPObject.get(); } diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx index 4d73ec5d6e66..2685352c0967 100644 --- a/sc/source/ui/view/tabview3.cxx +++ b/sc/source/ui/view/tabview3.cxx @@ -670,23 +670,7 @@ void ScTabView::CursorPosChanged() // Broadcast, so that other Views of the document also switch - ScDocument& rDocument = aViewData.GetDocument(); - bool bDataPilot = rDocument.HasDataPilotAtPosition(aViewData.GetCurPos()); - aViewData.GetViewShell()->SetPivotShell(bDataPilot); - - if (!bDataPilot) - { - const ScAddress rAddr = aViewData.GetCurPos(); - bool bSparkline = rDocument.HasSparkline(rAddr); - aViewData.GetViewShell()->SetSparklineShell(bSparkline); - if (!bSparkline) - { - if (rDocument.GetTableDBAtCursor(rAddr.Col(), rAddr.Row(), rAddr.Tab(), ScDBDataPortion::AREA)) - aViewData.GetViewShell()->SetTableShell(true); - else - aViewData.GetViewShell()->SetTableShell(false); - } - } + aViewData.GetViewShell()->UpdateContextShells(); // UpdateInputHandler now in CellContentChanged diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx index dfdb9cd95e64..36d15e890ab2 100644 --- a/sc/source/ui/view/tabvwsh4.cxx +++ b/sc/source/ui/view/tabvwsh4.cxx @@ -737,6 +737,28 @@ void ScTabViewShell::SetTableShell(bool bActive) SetCurSubShell(OST_Cell); } +void ScTabViewShell::UpdateContextShells() +{ + ScDocument& rDoc = GetViewData().GetDocument(); + bool bDataPilot = rDoc.HasDataPilotAtPosition(GetViewData().GetCurPos()); + SetPivotShell(bDataPilot); + + if (!bDataPilot) + { + const ScAddress rAddr = GetViewData().GetCurPos(); + bool bSparkline = rDoc.HasSparkline(rAddr); + SetSparklineShell(bSparkline); + if (!bSparkline) + { + if (rDoc.GetTableDBAtCursor(rAddr.Col(), rAddr.Row(), rAddr.Tab(), + ScDBDataPortion::AREA)) + SetTableShell(true); + else + SetTableShell(false); + } + } +} + void ScTabViewShell::SetAuditShell( bool bActive ) { if ( bActive ) diff --git a/sc/source/ui/view/tabvwsh5.cxx b/sc/source/ui/view/tabvwsh5.cxx index 68dd70a36ef0..4799465aa4b9 100644 --- a/sc/source/ui/view/tabvwsh5.cxx +++ b/sc/source/ui/view/tabvwsh5.cxx @@ -308,6 +308,10 @@ void ScTabViewShell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) } break; + case SfxHintId::ScDbAreasChanged: + UpdateContextShells(); + break; + default: break; }
