summaryrefslogtreecommitdiff
path: root/wizards
diff options
context:
space:
mode:
authorJean-Pierre Ledure <jp@ledure.be>2022-03-12 15:57:52 +0100
committerJean-Pierre Ledure <jp@ledure.be>2022-03-13 16:11:07 +0100
commitae24ce8c633a85e06aa8701c839b100b3dd5b6bf (patch)
treecd1cf8e7310bead350de6491f9438447ec3777e6 /wizards
parentf2d07a3b17430d21d4567f7a01525a702544ed8d (diff)
ScriptForge - (UI) size and position of the active window
The UI service receives next 4 new properties: Height Width X Y They all return a Long value representing the size or position of the active window. The active window does not need to be a document, it may f.i. be the Basic IDE. Those properties are read-only. To modify the size or the position of the window, use the the Resize() method. They are implemented for use from Basic and Python scripts. Change-Id: I0021663e39612f411cefa5c7ec9ec594a4cb6f39 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131444 Tested-by: Jean-Pierre Ledure <jp@ledure.be> Tested-by: Jenkins Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Diffstat (limited to 'wizards')
-rw-r--r--wizards/source/scriptforge/SF_UI.xba63
-rw-r--r--wizards/source/scriptforge/python/scriptforge.py2
2 files changed, 64 insertions, 1 deletions
diff --git a/wizards/source/scriptforge/SF_UI.xba b/wizards/source/scriptforge/SF_UI.xba
index 8c511a35cc8d..c8a7f9a8f861 100644
--- a/wizards/source/scriptforge/SF_UI.xba
+++ b/wizards/source/scriptforge/SF_UI.xba
@@ -119,6 +119,14 @@ Dim oComp As Object &apos; com.sun.star.lang.XComponent
End Function &apos; ScriptForge.SF_UI.ActiveWindow
REM -----------------------------------------------------------------------------
+Property Get Height() As Long
+&apos;&apos;&apos; Returns the height of the active window
+Dim oPosSize As Object &apos; com.sun.star.awt.Rectangle
+ Set oPosSize = SF_UI._PosSize()
+ If Not IsNull(oPosSize) Then Height = oPosSize.Height Else Height = -1
+End Property &apos; ScriptForge.SF_UI.Height
+
+REM -----------------------------------------------------------------------------
Property Get MACROEXECALWAYS As Integer
&apos;&apos;&apos; Macros are always executed
MACROEXECALWAYS = cstMACROEXECALWAYS
@@ -148,6 +156,30 @@ Property Get ServiceName As String
ServiceName = &quot;ScriptForge.UI&quot;
End Property &apos; ScriptForge.SF_UI.ServiceName
+REM -----------------------------------------------------------------------------
+Property Get Width() As Long
+&apos;&apos;&apos; Returns the width of the active window
+Dim oPosSize As Object &apos; com.sun.star.awt.Rectangle
+ Set oPosSize = SF_UI._PosSize()
+ If Not IsNull(oPosSize) Then Width = oPosSize.Width Else Width = -1
+End Property &apos; ScriptForge.SF_UI.Width
+
+REM -----------------------------------------------------------------------------
+Property Get X() As Long
+&apos;&apos;&apos; Returns the X coordinate of the active window
+Dim oPosSize As Object &apos; com.sun.star.awt.Rectangle
+ Set oPosSize = SF_UI._PosSize()
+ If Not IsNull(oPosSize) Then X = oPosSize.X Else X = -1
+End Property &apos; ScriptForge.SF_UI.X
+
+REM -----------------------------------------------------------------------------
+Property Get Y() As Long
+&apos;&apos;&apos; Returns the Y coordinate of the active window
+Dim oPosSize As Object &apos; com.sun.star.awt.Rectangle
+ Set oPosSize = SF_UI._PosSize()
+ If Not IsNull(oPosSize) Then Y = oPosSize.Y Else Y = -1
+End Property &apos; ScriptForge.SF_UI.Y
+
REM ===================================================================== METHODS
REM -----------------------------------------------------------------------------
@@ -495,6 +527,11 @@ Check:
Try:
Select Case UCase(PropertyName)
Case &quot;ACTIVEWINDOW&quot; : GetProperty = ActiveWindow()
+ Case &quot;HEIGHT&quot; : GetProperty = SF_UI.Height
+ Case &quot;WIDTH&quot; : GetProperty = SF_UI.Width
+ Case &quot;X&quot; : GetProperty = SF_UI.X
+ Case &quot;Y&quot; : GetProperty = SF_UI.Y
+
Case Else
End Select
@@ -827,6 +864,10 @@ Public Function Properties() As Variant
Properties = Array( _
&quot;ActiveWindow&quot; _
+ , &quot;Height&quot; _
+ , &quot;Width&quot; _
+ , &quot;X&quot; _
+ , &quot;Y&quot; _
)
End Function &apos; ScriptForge.SF_UI.Properties
@@ -1273,6 +1314,28 @@ Catch:
End Function &apos; ScriptForge.SF_UI._IdentifyWindow
REM -----------------------------------------------------------------------------
+Public Function _PosSize() As Object
+&apos;&apos;&apos; Returns the PosSize structure of the active window
+
+Dim vWindow As Window &apos; A single component
+Dim oContainer As Object &apos; com.sun.star.awt.XWindow
+Dim oPosSize As Object &apos; com.sun.star.awt.Rectangle
+
+ Set oPosSize = Nothing
+
+Try:
+ vWindow = SF_UI._IdentifyWindow(StarDesktop.CurrentComponent)
+ If Not IsNull(vWindow.Frame) Then
+ Set oContainer = vWindow.Frame.ContainerWindow
+ Set oPosSize = oContainer.getPosSize()
+ End If
+
+Finally:
+ Set _PosSize = oPosSize
+ Exit Function
+End Function &apos; ScriptForge.SF_UI._PosSize
+
+REM -----------------------------------------------------------------------------
Private Function _Repr() As String
&apos;&apos;&apos; Convert the UI instance to a readable string, typically for debugging purposes (DebugPrint ...)
&apos;&apos;&apos; Args:
diff --git a/wizards/source/scriptforge/python/scriptforge.py b/wizards/source/scriptforge/python/scriptforge.py
index 8843d0627b63..4a0523dc3f1a 100644
--- a/wizards/source/scriptforge/python/scriptforge.py
+++ b/wizards/source/scriptforge/python/scriptforge.py
@@ -1511,7 +1511,7 @@ class SFScriptForge:
serviceimplementation = 'basic'
servicename = 'ScriptForge.UI'
servicesynonyms = ('ui', 'scriptforge.ui')
- serviceproperties = dict(ActiveWindow = False)
+ serviceproperties = dict(ActiveWindow = False, Height = False, Width = False, X = False, Y = False)
# Class constants
MACROEXECALWAYS, MACROEXECNEVER, MACROEXECNORMAL = 2, 1, 0