diff options
author | gokaysatir <gokaysatir@collabora.com> | 2020-09-30 15:48:44 +0300 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2020-10-07 10:20:05 +0200 |
commit | 273ec24d802a896d13043c6235afcb6084341cf6 (patch) | |
tree | 12b961a243778fcfff4a57fe88dbc3c58515ed66 | |
parent | 7a061d5c8778fee58f966eee7f95917a5a74123e (diff) |
Online: Hide right clicked sheet.
On core side, if user clicks on a tab with right mouse button, clicked tab is selected.
So, for core side, if this feature will be desired, some more modification will be needed.
Change-Id: Ic4755b27b8ba98d3a6aa086b2e0a3566d095ba16
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103685
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
-rw-r--r-- | sc/sdi/scalc.sdi | 2 | ||||
-rw-r--r-- | sc/source/ui/inc/viewfunc.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwshf.cxx | 20 | ||||
-rw-r--r-- | sc/source/ui/view/viewfun2.cxx | 8 |
4 files changed, 28 insertions, 4 deletions
diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi index 93a6b67be6e5..86ae80497a77 100644 --- a/sc/sdi/scalc.sdi +++ b/sc/sdi/scalc.sdi @@ -2593,7 +2593,7 @@ SfxVoidItem GoUpToStartOfDataSel SID_CURSORBLKUP_SEL SfxVoidItem Hide FID_TABLE_HIDE -(SfxStringItem aTableName FID_TABLE_HIDE) +(SfxInt16Item nTabNumber FID_TABLE_HIDE) [ AutoUpdate = FALSE, FastCall = FALSE, diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx index fd1e05fa1a67..a22575e48971 100644 --- a/sc/source/ui/inc/viewfunc.hxx +++ b/sc/source/ui/inc/viewfunc.hxx @@ -283,7 +283,7 @@ public: const OUString& rSource ); void ShowTable( const std::vector<OUString>& rNames ); - void HideTable( const ScMarkData& rMark ); + void HideTable( const ScMarkData& rMark, SCTAB nTabToSelect = -1); void MakeScenario(const OUString& rName, const OUString& rComment, const Color& rColor, ScScenarioFlags nFlags); diff --git a/sc/source/ui/view/tabvwshf.cxx b/sc/source/ui/view/tabvwshf.cxx index 00f85a151662..7fcf4f5b7bf6 100644 --- a/sc/source/ui/view/tabvwshf.cxx +++ b/sc/source/ui/view/tabvwshf.cxx @@ -107,7 +107,25 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq ) if ( pDoc->IsDocEditable() ) { ScMarkData& rMark = rViewData.GetMarkData(); - HideTable( rMark ); + SCTAB nActiveTab = -1; + // For the cases when user right clicks on a non-active tab and hides it. This case is possible for Online. + if (pReqArgs) + { + const SfxPoolItem *pItem; + if( pReqArgs->HasItem( FID_TABLE_HIDE, &pItem ) ) + { + SCTAB nTabNumber = static_cast<const SfxInt16Item*>(pItem)->GetValue(); + // Does selected sheets (tabs) list include the sheet to be hidden? + std::set<SCTAB>::iterator it = rMark.GetSelectedTabs().find(nTabNumber); + if (it == rMark.GetSelectedTabs().end()) + { + // No it doesn't, so we won't shift the selected tab. Let's remember its position. + nActiveTab = GetViewData().GetTabNo(); + } + rMark.SelectOneTable(nTabNumber); + } + } + HideTable( rMark, nActiveTab ); } } break; diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx index 6085d74d7bb9..d675e3dca9a7 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -3137,7 +3137,7 @@ void ScViewFunc::ShowTable( const std::vector<OUString>& rNames ) } } -void ScViewFunc::HideTable( const ScMarkData& rMark ) +void ScViewFunc::HideTable( const ScMarkData& rMark, SCTAB nTabToSelect ) { ScDocShell* pDocSh = GetViewData().GetDocShell(); ScDocument& rDoc = pDocSh->GetDocument(); @@ -3171,6 +3171,12 @@ void ScViewFunc::HideTable( const ScMarkData& rMark ) undoTabs.push_back(nTab); } } + + if (nTabToSelect != -1) + { + SetTabNo(nTabToSelect); + } + if (bUndo) { pDocSh->GetUndoManager()->AddUndoAction( std::make_unique<ScUndoShowHideTab>( pDocSh, undoTabs, false ) ); |