From 11c69c57f045f364dd7466f49d9de5408b6a02b4 Mon Sep 17 00:00:00 2001 From: Rafael Lima Date: Sun, 19 Feb 2023 20:37:51 -0300 Subject: [PATCH] tdf#146518 Implement commands to toggle Watch/Stack windows This patch implements the new .uno:WatchWindow and .uno:StackWindow commands in the Basic IDE to allow the user to toggle the Watch/Stack windows. Change-Id: I0778b9fe8efcafbbf57da3cc437e6b156306021d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147305 Tested-by: Jenkins Reviewed-by: Heiko Tietze --- basctl/sdi/baside.sdi | 12 ++++ basctl/source/basicide/baside2.cxx | 12 ++++ basctl/source/basicide/baside2.hxx | 4 ++ basctl/source/basicide/basides1.cxx | 58 ++++++++++++++++++- basctl/uiconfig/basicide/menubar/menubar.xml | 2 + include/sfx2/sfxsids.hrc | 2 + .../openoffice/Office/UI/GenericCommands.xcu | 16 +++++ sfx2/sdi/sfx.sdi | 37 ++++++++++++ 8 files changed, 142 insertions(+), 1 deletion(-) diff --git a/basctl/sdi/baside.sdi b/basctl/sdi/baside.sdi index 0d32339fc833..9e7229ca9712 100644 --- a/basctl/sdi/baside.sdi +++ b/basctl/sdi/baside.sdi @@ -248,6 +248,18 @@ shell basctl_Shell StateMethod = GetState; ] + SID_BASICIDE_WATCH + [ + ExecMethod = ExecuteGlobal; + StateMethod = GetState; + ] + + SID_BASICIDE_STACK + [ + ExecMethod = ExecuteGlobal; + StateMethod = GetState; + ] + SID_BASICIDE_CREATEMACRO [ ExecMethod = ExecuteGlobal; diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx index ad1dd3682b22..1df230f9bd92 100644 --- a/basctl/source/basicide/baside2.cxx +++ b/basctl/source/basicide/baside2.cxx @@ -1511,6 +1511,18 @@ void ModulWindowLayout::BasicRemoveWatch () aWatchWindow->RemoveSelectedWatch(); } +void ModulWindowLayout::ShowWatchWindow(bool bVisible) +{ + aWatchWindow->Show(bVisible); + ArrangeWindows(); +} + +void ModulWindowLayout::ShowStackWindow(bool bVisible) +{ + aStackWindow->Show(bVisible); + ArrangeWindows(); +} + void ModulWindowLayout::OnFirstSize (tools::Long const nWidth, tools::Long const nHeight) { AddToLeft(&rObjectCatalog, Size(nWidth * 0.20, nHeight * 0.75)); diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx index 9a8700aecf3a..73b98ef7412e 100644 --- a/basctl/source/basicide/baside2.hxx +++ b/basctl/source/basicide/baside2.hxx @@ -409,6 +409,10 @@ public: public: void BasicAddWatch (OUString const&); void BasicRemoveWatch (); + void ShowWatchWindow(bool bVisible); + void ShowStackWindow(bool bVisible); + bool IsWatchWindowVisible() { return aWatchWindow->IsVisible(); } + bool IsStackWindowVisible() { return aStackWindow->IsVisible(); } Color const & GetSyntaxBackgroundColor () const { return aSyntaxColors.GetBackgroundColor(); } Color const & GetFontColor () const { return aSyntaxColors.GetFontColor(); } Color const & GetSyntaxColor (TokenType eType) const { return aSyntaxColors.GetColor(eType); } diff --git a/basctl/source/basicide/basides1.cxx b/basctl/source/basicide/basides1.cxx index 5e985211aa42..66820cd21881 100644 --- a/basctl/source/basicide/basides1.cxx +++ b/basctl/source/basicide/basides1.cxx @@ -430,6 +430,30 @@ void Shell::ExecuteGlobal( SfxRequest& rReq ) pBindings->Invalidate(SID_BASICIDE_OBJCAT); break; + case SID_BASICIDE_WATCH: + { + // Toggling the watch window can only be done from a ModulWindow + if (!dynamic_cast(pLayout.get())) + return; + + pModulLayout->ShowWatchWindow(!pModulLayout->IsWatchWindowVisible()); + if (SfxBindings* pBindings = GetBindingsPtr()) + pBindings->Invalidate(SID_BASICIDE_WATCH); + } + break; + + case SID_BASICIDE_STACK: + { + // Toggling the stack window can only be done from a ModulWindow + if (!dynamic_cast(pLayout.get())) + return; + + pModulLayout->ShowStackWindow(!pModulLayout->IsStackWindowVisible()); + if (SfxBindings* pBindings = GetBindingsPtr()) + pBindings->Invalidate(SID_BASICIDE_STACK); + } + break; + case SID_BASICIDE_NAMECHANGEDONTAB: { DBG_ASSERT( rReq.GetArgs(), "arguments expected" ); @@ -875,12 +899,44 @@ void Shell::GetState(SfxItemSet &rSet) rSet.DisableItem( nWh ); } break; + case SID_BASICIDE_OBJCAT: + { if (pLayout) rSet.Put(SfxBoolItem(nWh, aObjectCatalog->IsVisible())); else rSet.Put(SfxVisibilityItem(nWh, false)); - break; + } + break; + + case SID_BASICIDE_WATCH: + { + if (pLayout) + { + rSet.Put(SfxBoolItem(nWh, pModulLayout->IsWatchWindowVisible())); + // Disable command if the visible window is not a ModulWindow + if (!dynamic_cast(pLayout.get())) + rSet.DisableItem(nWh); + } + else + rSet.Put(SfxVisibilityItem(nWh, false)); + } + break; + + case SID_BASICIDE_STACK: + { + if (pLayout) + { + rSet.Put(SfxBoolItem(nWh, pModulLayout->IsStackWindowVisible())); + // Disable command if the visible window is not a ModulWindow + if (!dynamic_cast(pLayout.get())) + rSet.DisableItem(nWh); + } + else + rSet.Put(SfxVisibilityItem(nWh, false)); + } + break; + case SID_BASICIDE_SHOWSBX: case SID_BASICIDE_CREATEMACRO: case SID_BASICIDE_EDITMACRO: diff --git a/basctl/uiconfig/basicide/menubar/menubar.xml b/basctl/uiconfig/basicide/menubar/menubar.xml index ac59065c9daf..fc510571e2fe 100644 --- a/basctl/uiconfig/basicide/menubar/menubar.xml +++ b/basctl/uiconfig/basicide/menubar/menubar.xml @@ -69,6 +69,8 @@ + + diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc index 4fb5892ba84b..d63a5b2d3ae8 100644 --- a/include/sfx2/sfxsids.hrc +++ b/include/sfx2/sfxsids.hrc @@ -664,6 +664,8 @@ class SvxZoomItem; #define SID_BASICIDE_MANAGE_LANG ( SID_BASICIDE_START + 52 ) #define SID_BASICIDE_CURRENT_LANG ( SID_BASICIDE_START + 53 ) #define SID_BASICIDE_CURRENT_ZOOM ( SID_BASICIDE_START + 54 ) +#define SID_BASICIDE_WATCH ( SID_BASICIDE_START + 55 ) +#define SID_BASICIDE_STACK ( SID_BASICIDE_START + 56 ) #define SID_OPTIONS_TREEDIALOG ( SID_BASICIDE_START + 862) // SlotIds for Apps -------------------------------------------------------- diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu index 5c101a168464..8b4fb89e1b2e 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu @@ -1563,6 +1563,22 @@ bit 3 (0x8): #define UICOMMANDDESCRIPTION_PROPERTIES_TOGGLEBUTTON 8 1 + + + Watched Expressions + + + 1 + + + + + Call Stack + + + 1 + + Outline Font Effect diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index 400746d8d77a..4cf84ac12462 100644 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -2757,6 +2757,43 @@ SfxVoidItem ObjectCatalog SID_BASICIDE_OBJCAT ] +SfxVoidItem WatchWindow SID_BASICIDE_WATCH +() +[ + AutoUpdate = FALSE, + FastCall = FALSE, + ReadOnlyDoc = TRUE, + Toggle = FALSE, + Container = TRUE, + RecordAbsolute = FALSE, + RecordPerSet; + Asynchron; + + AccelConfig = TRUE, + MenuConfig = TRUE, + ToolBoxConfig = TRUE, + GroupId = SfxGroupId::Macro; +] + + +SfxVoidItem StackWindow SID_BASICIDE_STACK +() +[ + AutoUpdate = FALSE, + FastCall = FALSE, + ReadOnlyDoc = TRUE, + Toggle = FALSE, + Container = TRUE, + RecordAbsolute = FALSE, + RecordPerSet; + Asynchron; + + AccelConfig = TRUE, + MenuConfig = TRUE, + ToolBoxConfig = TRUE, + GroupId = SfxGroupId::Macro; +] + SfxVoidItem ObjectMenue SID_OBJECT (SfxInt16Item VerbID SID_OBJECT) [