summaryrefslogtreecommitdiff
path: root/sc/source/ui/view/tabvwshf.cxx
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2016-01-13 11:12:12 +0100
committerJan Holesovsky <kendy@collabora.com>2016-01-13 15:03:09 +0100
commitb70b579b7cc27a6bd2a348acf474b2c2e3fd7e9a (patch)
treeb0898495ef678ee08576b18bbe8248b7d3c4d6ea /sc/source/ui/view/tabvwshf.cxx
parent6dc3dbcf91c2ac63651e0494951e090953c96cb5 (diff)
sc: Make .uno:Insert (inserting a new sheet) always succeed.
Also, when provided with '0' as the sheet number, treat it as adding at the end - which I think is the usual use case one wants to target. Change-Id: I9e1a1733c2310b8c6bb7ff239351e88bbef09ac7
Diffstat (limited to 'sc/source/ui/view/tabvwshf.cxx')
-rw-r--r--sc/source/ui/view/tabvwshf.cxx12
1 files changed, 9 insertions, 3 deletions
diff --git a/sc/source/ui/view/tabvwshf.cxx b/sc/source/ui/view/tabvwshf.cxx
index 0f31469e1528..2b838bf69b04 100644
--- a/sc/source/ui/view/tabvwshf.cxx
+++ b/sc/source/ui/view/tabvwshf.cxx
@@ -177,15 +177,21 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
bool bOk = false;
const SfxPoolItem* pTabItem;
const SfxPoolItem* pNameItem;
- OUString aName;
if ( pReqArgs->HasItem( FN_PARAM_1, &pTabItem ) &&
pReqArgs->HasItem( nSlot, &pNameItem ) )
{
+ OUString aName = static_cast<const SfxStringItem*>(pNameItem)->GetValue();
+ pDoc->CreateValidTabName(aName);
+
// sheet number from basic: 1-based
+ // 0 is special, means adding at the end
+ nTabNr = static_cast<const SfxUInt16Item*>(pTabItem)->GetValue();
+ if (nTabNr == 0)
+ nTabNr = nTabCount;
+ else
+ --nTabNr;
- aName = static_cast<const SfxStringItem*>(pNameItem)->GetValue();
- nTabNr = static_cast<const SfxUInt16Item*>(pTabItem)->GetValue() - 1;
if ( nTabNr <= nTabCount )
bOk = InsertTable( aName, nTabNr );
}