summaryrefslogtreecommitdiff
path: root/sc/source/ui/view/tabvwshf.cxx
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2016-01-21 00:42:59 +0100
committerJan Holesovsky <kendy@collabora.com>2016-01-21 08:53:30 +0100
commit77c677a41d4bc9a2cd71ea1cc17e6c836387a6c5 (patch)
treef8c4d4461876d373d3726be006213f968735876c /sc/source/ui/view/tabvwshf.cxx
parent8a79692a73dc598b7b3bf1fea744ca771aa93e3f (diff)
sc lok: Implement unit test for .uno:{Insert,Name,Remove} for sheets.
And fix indexing when at that - the inserting is 1-based, so let's be consistent in the .uno:Name and .uno:Remove too. Change-Id: Ib854e81551ae0a39d3ba7c68512e81ea227e9eb1
Diffstat (limited to 'sc/source/ui/view/tabvwshf.cxx')
-rw-r--r--sc/source/ui/view/tabvwshf.cxx20
1 files changed, 16 insertions, 4 deletions
diff --git a/sc/source/ui/view/tabvwshf.cxx b/sc/source/ui/view/tabvwshf.cxx
index d22ece2095b1..8a56bfd526b7 100644
--- a/sc/source/ui/view/tabvwshf.cxx
+++ b/sc/source/ui/view/tabvwshf.cxx
@@ -332,8 +332,14 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
OUString aName;
if( pReqArgs->HasItem( FN_PARAM_1, &pItem ) )
+ {
nTabNr = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
+ // inserting is 1-based, let's be consistent
+ if (nTabNr > 0)
+ --nTabNr;
+ }
+
if( pReqArgs->HasItem( nSlot, &pItem ) )
aName = static_cast<const SfxStringItem*>(pItem)->GetValue();
@@ -570,12 +576,18 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
bool bHasIndex = (pReqArgs != nullptr);
// allow removing via the Index/FID_DELETE_TABLE parameter
- SCTAB nIndexTab = nCurrentTab;
+ SCTAB nTabNr = nCurrentTab;
if (bHasIndex)
{
const SfxPoolItem* pItem;
if (pReqArgs->HasItem(FID_DELETE_TABLE, &pItem))
- nIndexTab = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
+ {
+ nTabNr = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
+
+ // inserting is 1-based, let's be consistent
+ if (nTabNr > 0)
+ --nTabNr;
+ }
}
bool bDoIt = bHasIndex;
@@ -597,8 +609,8 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
if (bHasIndex)
{
// sheet no. provided by the parameter
- TheTabs.push_back(nIndexTab);
- if (nNewTab > nIndexTab && nNewTab > 0)
+ TheTabs.push_back(nTabNr);
+ if (nNewTab > nTabNr && nNewTab > 0)
--nNewTab;
}
else