summaryrefslogtreecommitdiff
path: root/sc/source/ui/view
diff options
context:
space:
mode:
authorrafaelhlima <rafael.palma.lima@gmail.com>2022-02-05 20:36:19 -0300
committerRafael Lima <rafael.palma.lima@gmail.com>2022-02-15 13:37:31 +0100
commitd519cbe89268ff24e2b8b05ba5124dca98f22b79 (patch)
tree6a834532a004ce039fb5c74043b3ca766279968d /sc/source/ui/view
parent7b24b2f2a346bf65c9c997926ecddd1dc5aa05d5 (diff)
tdf#145745 Create uno:DuplicateSheet command
Change-Id: Ic8d37f02d45c6f958bf6133c27997adea9bc8c7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129541 Tested-by: Jenkins Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Diffstat (limited to 'sc/source/ui/view')
-rw-r--r--sc/source/ui/view/tabcont.cxx1
-rw-r--r--sc/source/ui/view/tabvwshf.cxx43
2 files changed, 44 insertions, 0 deletions
diff --git a/sc/source/ui/view/tabcont.cxx b/sc/source/ui/view/tabcont.cxx
index f4ad32ba8ac5..a95df55b98d8 100644
--- a/sc/source/ui/view/tabcont.cxx
+++ b/sc/source/ui/view/tabcont.cxx
@@ -300,6 +300,7 @@ void ScTabControl::Select()
rBind.Invalidate( FID_INS_TABLE );
rBind.Invalidate( FID_TAB_APPEND );
rBind.Invalidate( FID_TAB_MOVE );
+ rBind.Invalidate( FID_TAB_DUPLICATE );
rBind.Invalidate( FID_TAB_RENAME );
rBind.Invalidate( FID_DELETE_TABLE );
rBind.Invalidate( FID_TABLE_SHOW );
diff --git a/sc/source/ui/view/tabvwshf.cxx b/sc/source/ui/view/tabvwshf.cxx
index e6de1564995e..b3db07466984 100644
--- a/sc/source/ui/view/tabvwshf.cxx
+++ b/sc/source/ui/view/tabvwshf.cxx
@@ -595,6 +595,42 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
}
break;
+ case FID_TAB_DUPLICATE:
+ {
+ // Get info about current document and selected tab
+ SCTAB nTab = rViewData.GetTabNo();
+ OUString aDocName = GetViewData().GetDocShell()->GetTitle();
+ sal_uInt16 nDoc = 0;
+ bool bCpy = true;
+
+ SfxObjectShell* pSh = SfxObjectShell::GetFirst();
+ ScDocShell* pScSh = nullptr;
+ sal_uInt16 i = 0;
+
+ // Determine the index of the current document
+ while ( pSh )
+ {
+ pScSh = dynamic_cast<ScDocShell*>( pSh );
+
+ if( pScSh )
+ {
+ pScSh->GetTitle();
+
+ if (aDocName == pScSh->GetTitle())
+ {
+ nDoc = i;
+ break;
+ }
+ // Only count ScDocShell
+ i++;
+ }
+ pSh = SfxObjectShell::GetNext( *pSh );
+ }
+
+ MoveTable( nDoc, nTab + 1, bCpy );
+ }
+ break;
+
case FID_DELETE_TABLE:
{
bool bHasIndex = (pReqArgs != nullptr);
@@ -956,6 +992,13 @@ void ScTabViewShell::GetStateTable( SfxItemSet& rSet )
rSet.DisableItem( nWhich );
break;
+ case FID_TAB_DUPLICATE:
+ if ( !rDoc.IsDocEditable()
+ || rDoc.GetChangeTrack() != nullptr
+ || nTabCount > MAXTAB)
+ rSet.DisableItem( nWhich );
+ break;
+
// FID_TAB_MENU_RENAME - "rename" from Menu
// FID_TAB_RENAME - "name"-property for Basic