diff options
author | Jan Holesovsky <kendy@collabora.com> | 2016-01-21 00:02:16 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2016-01-21 08:53:30 +0100 |
commit | 8a79692a73dc598b7b3bf1fea744ca771aa93e3f (patch) | |
tree | 9e49d129cf71efdc765957a1910765d9b594b8a3 /sc/source/ui/view/tabvwshf.cxx | |
parent | 4d2034803646bf88b76ed8a3b897edd7209ce30a (diff) |
sc lok: Fix .uno:Remove (removing sheets) to accept a parameter.
.sdi annouces that, but it was never implemented...
Change-Id: I7abfbdc88f055eeb993617a5a51371af0f825d34
Diffstat (limited to 'sc/source/ui/view/tabvwshf.cxx')
-rw-r--r-- | sc/source/ui/view/tabvwshf.cxx | 65 |
1 files changed, 44 insertions, 21 deletions
diff --git a/sc/source/ui/view/tabvwshf.cxx b/sc/source/ui/view/tabvwshf.cxx index 8ed4937c1f8c..d22ece2095b1 100644 --- a/sc/source/ui/view/tabvwshf.cxx +++ b/sc/source/ui/view/tabvwshf.cxx @@ -567,37 +567,60 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq ) case FID_DELETE_TABLE: { - // unnecessary parameter -> method depends on table + bool bHasIndex = (pReqArgs != nullptr); - bool bDoIt = rReq.IsAPI(); - if( !bDoIt ) + // allow removing via the Index/FID_DELETE_TABLE parameter + SCTAB nIndexTab = nCurrentTab; + if (bHasIndex) { - // source isn't basic -> ask again + const SfxPoolItem* pItem; + if (pReqArgs->HasItem(FID_DELETE_TABLE, &pItem)) + nIndexTab = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); + } - bDoIt = ( RET_YES == - ScopedVclPtr<QueryBox>::Create( GetDialogParent(), - WinBits( WB_YES_NO | WB_DEF_YES ), - ScGlobal::GetRscString(STR_QUERY_DELTAB) - )->Execute() ); + bool bDoIt = bHasIndex; + if (!bDoIt) + { + // no parameter given, ask for confirmation + bDoIt = ( RET_YES == + ScopedVclPtr<QueryBox>::Create( GetDialogParent(), + WinBits( WB_YES_NO | WB_DEF_YES ), + ScGlobal::GetRscString(STR_QUERY_DELTAB) + )->Execute() ); } - if( bDoIt ) + + if (bDoIt) { - SCTAB nNewTab = nCurrentTab; - SCTAB nFirstTab=0; - bool bTabFlag=false; - ScMarkData& rMark = rViewData.GetMarkData(); + SCTAB nNewTab = nCurrentTab; std::vector<SCTAB> TheTabs; - for(SCTAB i=0;i<nTabCount;i++) + + if (bHasIndex) { - if(rMark.GetTableSelect(i) &&!pDoc->IsTabProtected(i)) + // sheet no. provided by the parameter + TheTabs.push_back(nIndexTab); + if (nNewTab > nIndexTab && nNewTab > 0) + --nNewTab; + } + else + { + SCTAB nFirstTab = 0; + bool bTabFlag = false; + ScMarkData& rMark = rViewData.GetMarkData(); + for (SCTAB i = 0; i < nTabCount; i++) { - TheTabs.push_back(i); - bTabFlag=true; - if(nNewTab==i) nNewTab++; + if (rMark.GetTableSelect(i) && !pDoc->IsTabProtected(i)) + { + TheTabs.push_back(i); + bTabFlag = true; + if (nNewTab == i) + nNewTab++; + } + if (!bTabFlag) + nFirstTab = i; } - if(!bTabFlag) nFirstTab=i; + if (nNewTab >= nTabCount) + nNewTab = nFirstTab; } - if(nNewTab>=nTabCount) nNewTab=nFirstTab; rViewData.SetTabNo(nNewTab); DeleteTables(TheTabs); |