diff options
author | rafaelhlima <rafael.palma.lima@gmail.com> | 2022-02-05 20:36:19 -0300 |
---|---|---|
committer | Rafael Lima <rafael.palma.lima@gmail.com> | 2022-02-15 13:37:31 +0100 |
commit | d519cbe89268ff24e2b8b05ba5124dca98f22b79 (patch) | |
tree | 6a834532a004ce039fb5c74043b3ca766279968d | |
parent | 7b24b2f2a346bf65c9c997926ecddd1dc5aa05d5 (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>
-rw-r--r-- | officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu | 8 | ||||
-rw-r--r-- | sc/inc/sc.hrc | 1 | ||||
-rw-r--r-- | sc/sdi/docsh.sdi | 1 | ||||
-rw-r--r-- | sc/sdi/scalc.sdi | 17 | ||||
-rw-r--r-- | sc/source/ui/view/tabcont.cxx | 1 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwshf.cxx | 43 | ||||
-rw-r--r-- | sc/uiconfig/scalc/menubar/menubar.xml | 1 | ||||
-rw-r--r-- | sc/uiconfig/scalc/popupmenu/sheettab.xml | 1 |
8 files changed, 73 insertions, 0 deletions
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu index 7098b111308f..c7bfe5e55577 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu @@ -14,6 +14,14 @@ <value>1</value> </prop> </node> + <node oor:name=".uno:DuplicateSheet" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">Duplicate Sheet</value> + </prop> + <prop oor:name="Properties" oor:type="xs:int"> + <value>1</value> + </prop> + </node> <node oor:name=".uno:ObjectMirrorVertical" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> <value xml:lang="en-US">Flip Vertically</value> diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc index 7e80324416af..c87effa212fe 100644 --- a/sc/inc/sc.hrc +++ b/sc/inc/sc.hrc @@ -385,6 +385,7 @@ class SvxZoomSliderItem; #define FID_TAB_MENU_SET_TAB_BG_COLOR (TAB_POPUP_START + 8) #define FID_TAB_SET_TAB_BG_COLOR (TAB_POPUP_START + 9) #define FID_TAB_EVENTS (TAB_POPUP_START+10) +#define FID_TAB_DUPLICATE (TAB_POPUP_START+11) #define TAB_POPUP_END (TAB_POPUP_START + 20) diff --git a/sc/sdi/docsh.sdi b/sc/sdi/docsh.sdi index 4b7e2fe7fdd5..b4a8a04326d8 100644 --- a/sc/sdi/docsh.sdi +++ b/sc/sdi/docsh.sdi @@ -35,6 +35,7 @@ interface TableSelection SID_DETECTIVE_DEL_ALL [ ExecMethod = Execute; StateMethod = GetState; ] FID_TABLE_VISIBLE [ ExecMethod = ExecuteTable; StateMethod = GetStateTable; ] FID_TAB_MOVE [ ExecMethod = ExecuteTable; StateMethod = GetStateTable; ] + FID_TAB_DUPLICATE [ ExecMethod = ExecuteTable; StateMethod = GetStateTable; ] FID_DELETE_TABLE [ ExecMethod = ExecuteTable; StateMethod = GetStateTable; ] FID_TAB_RENAME [ ExecMethod = ExecuteTable; StateMethod = GetStateTable; ] FID_TAB_RTL [ ExecMethod = ExecuteTable; StateMethod = GetStateTable; ] diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi index 861c76768d3b..8457654946fd 100644 --- a/sc/sdi/scalc.sdi +++ b/sc/sdi/scalc.sdi @@ -3428,6 +3428,23 @@ SfxVoidItem Move FID_TAB_MOVE GroupId = SfxGroupId::Edit; ] +SfxVoidItem DuplicateSheet FID_TAB_DUPLICATE +() +[ + AutoUpdate = FALSE, + FastCall = FALSE, + ReadOnlyDoc = TRUE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + + AccelConfig = TRUE, + MenuConfig = TRUE, + ToolBoxConfig = FALSE, + GroupId = SfxGroupId::Edit; +] + SfxVoidItem Name FID_TAB_RENAME (SfxStringItem Name FID_TAB_RENAME,SfxUInt16Item Index FN_PARAM_1) 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 diff --git a/sc/uiconfig/scalc/menubar/menubar.xml b/sc/uiconfig/scalc/menubar/menubar.xml index 00254f69aca4..01710700db98 100644 --- a/sc/uiconfig/scalc/menubar/menubar.xml +++ b/sc/uiconfig/scalc/menubar/menubar.xml @@ -578,6 +578,7 @@ <menu:menuitem menu:id=".uno:Show" menu:style="text"/> <menu:menuseparator/> <menu:menuitem menu:id=".uno:Move"/> + <menu:menuitem menu:id=".uno:DuplicateSheet"/> <menu:menu menu:id=".uno:NavigateMenu"> <menu:menupopup> <menu:menuitem menu:id=".uno:JumpToPrevTable"/> diff --git a/sc/uiconfig/scalc/popupmenu/sheettab.xml b/sc/uiconfig/scalc/popupmenu/sheettab.xml index 4bfaf376552f..94f667a236bc 100644 --- a/sc/uiconfig/scalc/popupmenu/sheettab.xml +++ b/sc/uiconfig/scalc/popupmenu/sheettab.xml @@ -11,6 +11,7 @@ <menu:menuitem menu:id=".uno:Insert"/> <menu:menuitem menu:id=".uno:Remove"/> <menu:menuitem menu:id=".uno:RenameTable"/> + <menu:menuitem menu:id=".uno:DuplicateSheet"/> <menu:menuitem menu:id=".uno:Move"/> <menu:menuitem menu:id=".uno:TableSelectAll"/> <menu:menuitem menu:id=".uno:TableDeselectAll"/> |