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 <heiko.tietze@documentfoundation.org>
This commit is contained in:
Rafael Lima 2023-02-19 20:37:51 -03:00
parent 9da4a2518e
commit 11c69c57f0
8 changed files with 142 additions and 1 deletions

View file

@ -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;

View file

@ -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));

View file

@ -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); }

View file

@ -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<ModulWindowLayout*>(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<ModulWindowLayout*>(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<ModulWindowLayout*>(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<ModulWindowLayout*>(pLayout.get()))
rSet.DisableItem(nWh);
}
else
rSet.Put(SfxVisibilityItem(nWh, false));
}
break;
case SID_BASICIDE_SHOWSBX:
case SID_BASICIDE_CREATEMACRO:
case SID_BASICIDE_EDITMACRO:

View file

@ -69,6 +69,8 @@
<menu:menuitem menu:id=".uno:ShowLines"/>
<menu:menuitem menu:id=".uno:ShowPropBrowser"/>
<menu:menuitem menu:id=".uno:ObjectCatalog"/>
<menu:menuitem menu:id=".uno:WatchWindow"/>
<menu:menuitem menu:id=".uno:StackWindow"/>
<menu:menuseparator/>
<menu:menuitem menu:id=".uno:FullScreen"/>
</menu:menupopup>

View file

@ -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 --------------------------------------------------------

View file

@ -1563,6 +1563,22 @@ bit 3 (0x8): #define UICOMMANDDESCRIPTION_PROPERTIES_TOGGLEBUTTON 8
<value>1</value>
</prop>
</node>
<node oor:name=".uno:WatchWindow" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Watched Expressions</value>
</prop>
<prop oor:name="Properties" oor:type="xs:int">
<value>1</value>
</prop>
</node>
<node oor:name=".uno:StackWindow" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Call Stack</value>
</prop>
<prop oor:name="Properties" oor:type="xs:int">
<value>1</value>
</prop>
</node>
<node oor:name=".uno:OutlineFont" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Outline Font Effect</value>

View file

@ -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)
[