summaryrefslogtreecommitdiff
path: root/wizards
diff options
context:
space:
mode:
authorJean-Pierre Ledure <jp@ledure.be>2023-04-20 17:14:50 +0200
committerJean-Pierre Ledure <jp@ledure.be>2023-04-21 11:02:01 +0200
commit37a68d6ae3b32aa3d3c864f67a8c55b6eeb6964d (patch)
treedb9804f2430f645b0750912304f80dd3355aa59c /wizards
parentdd0b469af4b1ab49faf4b1688932da2370368e70 (diff)
ScriptForge (SFDialogs) dialogs and controls are sized in APPFONTs
Dimensioning a dialog in the Basic IDE is done by using "Map AppFont" units. Map AppFont units are device and resolution independent. One Map AppFont unit is equal to one eighth of the average character (Systemfont) height and one quarter of the average character width. A dialog or control model also uses AppFont units. While their views use pixels. This is confusing. It also complicates size prototyping with the Basic IDE. In ScriptForge, sizing and positioning a dialog or a control is done from now on in AppFont units as well. Additionally, X and Y positions accept now negative values. Compatibility with past is ensured: dynamic change or position and size is a new feature in 7.6. The change is valid both for Basic and Python user scripts. It requires a small change in the actual documentation (pixels => AppFontunits) Change-Id: Id80b0ccf473eb012b0a8c85d66f5a8ada9b26be5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150704 Tested-by: Jean-Pierre Ledure <jp@ledure.be> Reviewed-by: Jean-Pierre Ledure <jp@ledure.be> Tested-by: Jenkins
Diffstat (limited to 'wizards')
-rw-r--r--wizards/Package_sfdialogs.mk1
-rw-r--r--wizards/source/scriptforge/python/scriptforge.py4
-rw-r--r--wizards/source/sfdialogs/SF_Dialog.xba105
-rw-r--r--wizards/source/sfdialogs/SF_DialogControl.xba119
-rw-r--r--wizards/source/sfdialogs/SF_DialogUtils.xba275
-rw-r--r--wizards/source/sfdialogs/script.xlb1
6 files changed, 361 insertions, 144 deletions
diff --git a/wizards/Package_sfdialogs.mk b/wizards/Package_sfdialogs.mk
index 8a072225a356..f746cdd88514 100644
--- a/wizards/Package_sfdialogs.mk
+++ b/wizards/Package_sfdialogs.mk
@@ -23,6 +23,7 @@ $(eval $(call gb_Package_add_files,wizards_basicsrvsfdialogs,$(LIBO_SHARE_FOLDER
SF_Dialog.xba \
SF_DialogControl.xba \
SF_DialogListener.xba \
+ SF_DialogUtils.xba \
SF_Register.xba \
__License.xba \
dialog.xlb \
diff --git a/wizards/source/scriptforge/python/scriptforge.py b/wizards/source/scriptforge/python/scriptforge.py
index f61da2e3885b..09d796aa161c 100644
--- a/wizards/source/scriptforge/python/scriptforge.py
+++ b/wizards/source/scriptforge/python/scriptforge.py
@@ -1879,7 +1879,7 @@ class SFDialogs:
l10nobj = l10n.objectreference if isinstance(l10n, SFScriptForge.SF_L10N) else l10n
return self.ExecMethod(self.vbMethod + self.flgObject, 'GetTextsFromL10N', l10nobj)
- def Resize(self, left = -1, top = -1, width = -1, height = -1):
+ def Resize(self, left = -99999, top = -99999, width = -1, height = -1):
return self.ExecMethod(self.vbMethod + self.flgHardCode, 'Resize', left, top, width, height)
def SetPageManager(self, pilotcontrols = '', tabcontrols = '', wizardcontrols = '', lastpage = 0):
@@ -1938,7 +1938,7 @@ class SFDialogs:
def FindNode(self, displayvalue, datavalue = ScriptForge.cstSymEmpty, casesensitive = False):
return self.ExecMethod(self.vbMethod + self.flgUno, 'FindNode', displayvalue, datavalue, casesensitive)
- def Resize(self, left = -1, top = -1, width = -1, height = -1):
+ def Resize(self, left = -99999, top = -99999, width = -1, height = -1):
return self.ExecMethod(self.vbMethod, 'Resize', left, top, width, height)
def SetFocus(self):
diff --git a/wizards/source/sfdialogs/SF_Dialog.xba b/wizards/source/sfdialogs/SF_Dialog.xba
index 01c6d83cf982..c252838b6c4f 100644
--- a/wizards/source/sfdialogs/SF_Dialog.xba
+++ b/wizards/source/sfdialogs/SF_Dialog.xba
@@ -74,7 +74,7 @@ Private _DialogModel As Object &apos; com.sun.star.awt.XControlModel - stardiv
Private _Displayed As Boolean &apos; True after Execute()
Private _Modal As Boolean &apos; Set by Execute()
-&apos; Dialog position and dimensions in pixels
+&apos; Dialog initial position and dimensions in APPFONT units
Private _Left As Long
Private _Top As Long
Private _Width As Long
@@ -151,14 +151,17 @@ Private Sub Class_Initialize()
Set _DialogModel = Nothing
_Displayed = False
_Modal = True
- _Left = -1
- _Top = -1
+
+ _Left = SF_DialogUtils.MINPOSITION
+ _Top = SF_DialogUtils.MINPOSITION
_Width = -1
_Height = -1
+
_PageManagement = Array()
Set _ItemListener = Nothing
Set _ActionListener = Nothing
_LastPage = 0
+
Set _FocusListener = Nothing
_OnFocusGained = &quot;&quot;
_OnFocusLost = &quot;&quot;
@@ -682,6 +685,8 @@ Try:
If Modal Then
_Modal = True
_Displayed = True
+ &apos; In dynamic dialogs, injection of sizes and positions from model to view is done with setVisible()
+ _DialogControl.setVisible(True)
lExecute = _DialogControl.execute()
Select Case lExecute
Case 1 : lExecute = OKBUTTON
@@ -884,70 +889,26 @@ Public Function Resize(Optional ByVal Left As Variant _
, Optional ByVal Width As Variant _
, Optional ByVal Height As Variant _
) As Boolean
-&apos;&apos;&apos; Move the top-left corner of a dialog to new coordinates and/or modify its dimensions
-&apos;&apos;&apos; All distances are expressed in pixels.
+&apos;&apos;&apos; Move the top-left corner of the dialog to new coordinates and/or modify its dimensions
&apos;&apos;&apos; Without arguments, the method resets the initial dimensions
+&apos;&apos;&apos; Attributes denoting the position and size of a dialog are expressed in &quot;Map AppFont&quot; units.
+&apos;&apos;&apos; Map AppFont units are device and resolution independent.
+&apos;&apos;&apos; One Map AppFont unit is equal to one eighth of the average character (Systemfont) height and one quarter of the average character width.
+&apos;&apos;&apos; The dialog editor (= the Basic IDE) also uses Map AppFont units.
&apos;&apos;&apos; Args:
-&apos;&apos;&apos; Left : the horizontal distance from the top-left corner
-&apos;&apos;&apos; Top : the vertical distance from the top-left corner
-&apos;&apos;&apos; Width : the horizontal width of the rectangle containing the Dialog
-&apos;&apos;&apos; Height : the vertical height of the rectangle containing the Dialog
-&apos;&apos;&apos; Negative or missing arguments are left unchanged
+&apos;&apos;&apos; Left : the horizontal distance from the top-left corner. It may be negative.
+&apos;&apos;&apos; Top : the vertical distance from the top-left corner. It may be negative.
+&apos;&apos;&apos; Width : the horizontal width of the rectangle containing the Dialog. It must be positive.
+&apos;&apos;&apos; Height : the vertical height of the rectangle containing the Dialog. It must be positive.
+&apos;&apos;&apos; Missing arguments are left unchanged.
&apos;&apos;&apos; Returns:
&apos;&apos;&apos; True when successful
&apos;&apos;&apos; Examples:
-&apos;&apos;&apos; oDialog.Resize(1000, 2000, Height := 6000) &apos; Width is not changed
-
-Dim bResize As Boolean &apos; Return value
-Dim oPosSize As Object &apos; com.sun.star.awt.Rectangle
-Dim iFlags As Integer &apos; com.sun.star.awt.PosSize constants
-Const cstThisSub = &quot;SFDialogs.Dialog.Resize&quot;
-Const cstSubArgs = &quot;[Left], [Top], [Width], [Height]&quot;
-
- If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
- bResize = False
-
-Check:
- If IsMissing(Left) Or IsEmpty(Left) Then Left = -1
- If IsMissing(Top) Or IsEmpty(Top) Then Top = -1
- If IsMissing(Height) Or IsEmpty(Height) Then Height = -1
- If IsMissing(Width) Or IsEmpty(Width) Then Width = -1
- If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
- If Not ScriptForge.SF_Utils._Validate(Left, &quot;Left&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
- If Not ScriptForge.SF_Utils._Validate(Top, &quot;Top&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
- If Not ScriptForge.SF_Utils._Validate(Width, &quot;Width&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
- If Not ScriptForge.SF_Utils._Validate(Height, &quot;Height&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
- End If
+&apos;&apos;&apos; oDialog.Resize(100, 200, Height := 600) &apos; Width is not changed
Try:
- With _DialogControl
- Set oPosSize = .getPosSize()
- &apos; Reset factory settings
- If Left = -1 And Top = -1 And Width = -1 And Height = -1 Then
- &apos;Left = _Left &apos; Initial positions determination is unstable
- &apos;Top = _Top
- Width = _Width
- Height = _Height
- End If
- &apos; Trace the elements to change
- iFlags = 0
- With com.sun.star.awt.PosSize
- If CLng(Left) &gt;= 0 Then iFlags = iFlags + .X Else Left = oPosSize.X
- If CLng(Top) &gt;= 0 Then iFlags = iFlags + .Y Else Top = oPosSize.Y
- If CLng(Width) &gt; 0 Then iFlags = iFlags + .WIDTH Else Width = oPosSize.Width
- If CLng(Height) &gt; 0 Then iFlags = iFlags + .HEIGHT Else Height = oPosSize.Height
- End With
- &apos; Rewrite
- If iFlags &gt; 0 Then .setPosSize(CLng(Left), CLng(Top), CLng(Width), CLng(Height), iFlags)
- End With
- bResize = True
+ Resize = SF_DialogUtils._Resize([Me], Left, Top, Width, Height)
-Finally:
- Resize = bResize
- ScriptForge.SF_Utils._ExitFunction(cstThisSub)
- Exit Function
-Catch:
- GoTo Finally
End Function &apos; SFDialogss.SF_Dialog.Resize
REM -----------------------------------------------------------------------------
@@ -1252,17 +1213,14 @@ Public Sub _Initialize()
&apos;&apos;&apos; - Addition of the new object in the Dialogs buffer
&apos;&apos;&apos; - Initialisation of persistent storage for controls
-Dim oPosSize As Object &apos; com.sun.star.awt.Rectangle
-
Try:
&apos; Keep reference to model
Set _DialogModel = _DialogControl.Model
&apos; Store initial position and dimensions
- Set oPosSize = _DialogControl.getPosSize()
- With oPosSize
- _Left = .X
- _Top = .Y
+ With _DialogModel
+ _Left = .PositionX
+ _Top = .PositionY
_Width = .Width
_Height = .Height
End With
@@ -1370,6 +1328,7 @@ Private Function _PropertyGet(Optional ByVal psProperty As String) As Variant
&apos;&apos;&apos; psProperty: the name of the property
Static oSession As Object &apos; Alias of SF_Session
+Dim oPosSize As Object &apos; com.sun.star.awt.Rectangle
Dim oDialogEvents As Object &apos; com.sun.star.container.XNameContainer
Dim sEventName As String &apos; Internal event name
Dim cstThisSub As String
@@ -1386,7 +1345,11 @@ Const cstSubArgs = &quot;&quot;
Case UCase(&quot;Caption&quot;)
If oSession.HasUNOProperty(_DialogModel, &quot;Title&quot;) Then _PropertyGet = _DialogModel.Title
Case UCase(&quot;Height&quot;)
- If oSession.HasUNOMethod(_DialogControl, &quot;getPosSize&quot;) Then _PropertyGet = _DialogControl.getPosSize().Height
+ If _Displayed Then &apos; Convert PosSize view property from pixels to APPFONT units
+ _PropertyGet = SF_DialogUtils._ConvertToAppFont(_DialogControl, False).Height
+ Else
+ If oSession.HasUNOProperty(_DialogModel, &quot;Height&quot;) Then _PropertyGet = _DialogModel.Height
+ End If
Case UCase(&quot;Modal&quot;)
_PropertyGet = _Modal
Case UCase(&quot;Name&quot;)
@@ -1420,7 +1383,11 @@ Const cstSubArgs = &quot;&quot;
Case UCase(&quot;Visible&quot;)
If oSession.HasUnoMethod(_DialogControl, &quot;isVisible&quot;) Then _PropertyGet = CBool(_DialogControl.isVisible())
Case UCase(&quot;Width&quot;)
- If oSession.HasUNOMethod(_DialogControl, &quot;getPosSize&quot;) Then _PropertyGet = _DialogControl.getPosSize().Width
+ If _Displayed Then &apos; Convert PosSize view property from pixels to APPFONT units
+ _PropertyGet = SF_DialogUtils._ConvertToAppFont(_DialogControl, False).Width
+ Else
+ If oSession.HasUNOProperty(_DialogModel, &quot;Width&quot;) Then _PropertyGet = _DialogModel.Width
+ End If
Case UCase(&quot;XDialogModel&quot;)
Set _PropertyGet = _DialogModel
Case UCase(&quot;XDialogView&quot;)
@@ -1467,7 +1434,7 @@ Const cstSubArgs = &quot;Value&quot;
If oSession.HasUNOProperty(_DialogModel, &quot;Title&quot;) Then _DialogModel.Title = pvValue
Case UCase(&quot;Height&quot;)
If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Height&quot;, ScriptForge.V_NUMERIC) Then GoTo Catch
- If oSession.HasUnoMethod(_DialogControl, &quot;setPosSize&quot;) Then _DialogControl.setPosSize(-1, -1, -1, CLng(pvValue), com.sun.star.awt.PosSize.HEIGHT)
+ bSet = Resize(Height := pvValue)
Case UCase(&quot;OnFocusGained&quot;), UCase(&quot;OnFocusLost&quot;), UCase(&quot;OnKeyPressed&quot;), UCase(&quot;OnKeyReleased&quot;) _
, UCase(&quot;OnMouseDragged&quot;), UCase(&quot;OnMouseEntered&quot;), UCase(&quot;OnMouseExited&quot;), UCase(&quot;OnMouseMoved&quot;) _
, UCase(&quot;OnMousePressed&quot;), UCase(&quot;OnMouseReleased&quot;)
@@ -1485,7 +1452,7 @@ Const cstSubArgs = &quot;Value&quot;
If oSession.HasUnoMethod(_DialogControl, &quot;setVisible&quot;) Then _DialogControl.setVisible(pvValue)
Case UCase(&quot;Width&quot;)
If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Width&quot;, ScriptForge.V_NUMERIC) Then GoTo Catch
- If oSession.HasUnoMethod(_DialogControl, &quot;setPosSize&quot;) Then _DialogControl.setPosSize(-1, -1, CLng(pvValue), -1, com.sun.star.awt.PosSize.WIDTH)
+ bSet = Resize(Width := pvValue)
Case Else
bSet = False
End Select
diff --git a/wizards/source/sfdialogs/SF_DialogControl.xba b/wizards/source/sfdialogs/SF_DialogControl.xba
index da4d044f20d0..106c4f687687 100644
--- a/wizards/source/sfdialogs/SF_DialogControl.xba
+++ b/wizards/source/sfdialogs/SF_DialogControl.xba
@@ -75,7 +75,7 @@ Private _GridDataModel As Object &apos; com.sun.star.awt.grid.XGridDataModel
Private _ImplementationName As String
Private _ControlType As String &apos; One of the CTLxxx constants
-&apos; Control position and dimensions
+&apos; Control initial position and dimensions in APPFONT units
Private _Left As Long
Private _Top As Long
Private _Width As Long
@@ -173,8 +173,8 @@ Private Sub Class_Initialize()
_ImplementationName = &quot;&quot;
_ControlType = &quot;&quot;
- _Left = -1
- _Top = -1
+ _Left = SF_DialogUtils.MINPOSITION
+ _Top = SF_DialogUtils.MINPOSITION
_Width = -1
_Height = -1
@@ -1152,71 +1152,27 @@ Public Function Resize(Optional ByVal Left As Variant _
, Optional ByVal Width As Variant _
, Optional ByVal Height As Variant _
) As Boolean
-&apos;&apos;&apos; Move the top-left corner of a dialog control to new coordinates and/or modify its dimensions
-&apos;&apos;&apos; All distances are expressed in pixels and are measured from the top-left corner of the parent dialog.
-&apos;&apos;&apos; Without arguments, the method resets the initial dimensions.
+&apos;&apos;&apos; Move the top-left corner of the control to new coordinates and/or modify its dimensions
+&apos;&apos;&apos; Without arguments, the method resets the initial dimensions and position
+&apos;&apos;&apos; Attributes denoting the position and size of a control are expressed in &quot;Map AppFont&quot; units.
+&apos;&apos;&apos; Map AppFont units are device and resolution independent.
+&apos;&apos;&apos; One Map AppFont unit is equal to one eighth of the average character (Systemfont) height and one quarter of the average character width.
+&apos;&apos;&apos; The dialog editor (= the Basic IDE) also uses Map AppFont units.
&apos;&apos;&apos; Args:
-&apos;&apos;&apos; Left : the horizontal distance from the top-left corner
-&apos;&apos;&apos; Top : the vertical distance from the top-left corner
-&apos;&apos;&apos; Width : the horizontal width of the rectangle containing the control
-&apos;&apos;&apos; Height : the vertical height of the rectangle containing the control
-&apos;&apos;&apos; Negative or missing arguments are left unchanged
+&apos;&apos;&apos; Left : the horizontal distance from the top-left corner. It may be negative.
+&apos;&apos;&apos; Top : the vertical distance from the top-left corner. It may be negative.
+&apos;&apos;&apos; Width : the horizontal width of the rectangle containing the Dialog. It must be positive.
+&apos;&apos;&apos; Height : the vertical height of the rectangle containing the Dialog. It must be positive.
+&apos;&apos;&apos; Missing arguments are left unchanged.
&apos;&apos;&apos; Returns:
&apos;&apos;&apos; True when successful
&apos;&apos;&apos; Examples:
-&apos;&apos;&apos; oControl.Resize(100, 200, Height := 6000) &apos; Width is not changed
-
-Dim bResize As Boolean &apos; Return value
-Dim oPosSize As Object &apos; com.sun.star.awt.Rectangle
-Dim iFlags As Integer &apos; com.sun.star.awt.PosSize constants
-Const cstThisSub = &quot;SFDialogs.DialogControl.Resize&quot;
-Const cstSubArgs = &quot;[Left], [Top], [Width], [Height]&quot;
-
- If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
- bResize = False
-
-Check:
- If IsMissing(Left) Or IsEmpty(Left) Then Left = -1
- If IsMissing(Top) Or IsEmpty(Top) Then Top = -1
- If IsMissing(Height) Or IsEmpty(Height) Then Height = -1
- If IsMissing(Width) Or IsEmpty(Width) Then Width = -1
- If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
- If Not ScriptForge.SF_Utils._Validate(Left, &quot;Left&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
- If Not ScriptForge.SF_Utils._Validate(Top, &quot;Top&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
- If Not ScriptForge.SF_Utils._Validate(Width, &quot;Width&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
- If Not ScriptForge.SF_Utils._Validate(Height, &quot;Height&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
- End If
+&apos;&apos;&apos; myControl.Resize(100, 200, Height := 600) &apos; Width is not changed
Try:
- With _ControlView
- Set oPosSize = .getPosSize()
- &apos; Reset factory settings
- If Left = -1 And Top = -1 And Width = -1 And Height = -1 Then
- Left = _Left
- Top = _Top
- Width = _Width
- Height = _Height
- End If
- &apos; Trace the elements to change
- iFlags = 0
- With com.sun.star.awt.PosSize
- If CLng(Left) &gt;= 0 Then iFlags = iFlags + .X Else Left = oPosSize.X
- If CLng(Top) &gt;= 0 Then iFlags = iFlags + .Y Else Top = oPosSize.Y
- If CLng(Width) &gt; 0 Then iFlags = iFlags + .WIDTH Else Width = oPosSize.Width
- If CLng(Height) &gt; 0 Then iFlags = iFlags + .HEIGHT Else Height = oPosSize.Height
- End With
- &apos; Rewrite
- If iFlags &gt; 0 Then .setPosSize(CLng(Left), CLng(Top), CLng(Width), CLng(Height), iFlags)
- End With
- bResize = True
+ Resize = SF_DialogUtils._Resize([Me], Left, Top, Width, Height)
-Finally:
- Resize = bResize
- ScriptForge.SF_Utils._ExitFunction(cstThisSub)
- Exit Function
-Catch:
- GoTo Finally
-End Function &apos; SF_Documents.SF_DialogControl.Resize
+End Function &apos; SFDialogss.SF_Dialog.Resize
REM -----------------------------------------------------------------------------
Public Function SetFocus() As Boolean
@@ -1776,6 +1732,7 @@ Dim lIndex As Long &apos; Index in StringItemList
Dim sItem As String &apos; A single item
Dim vDate As Variant &apos; com.sun.star.util.Date or com.sun.star.util.Time
Dim vValues As Variant &apos; Array of listbox values
+Dim oPosSize As Object &apos; com.sun.star.awt.Rectangle
Dim oControlEvents As Object &apos; com.sun.star.container.XNameContainer
Dim sEventName As String &apos; Internal event name
Dim i As Long
@@ -1844,7 +1801,11 @@ Const cstSubArgs = &quot;&quot;
Case Else : GoTo CatchType
End Select
Case UCase(&quot;Height&quot;)
- If oSession.HasUNOMethod(_ControlView, &quot;getPosSize&quot;) Then _PropertyGet = _ControlView.getPosSize().Height
+ If [_parent]._Displayed Then &apos; Convert PosSize view property from pixels to APPFONT units
+ _PropertyGet = SF_DialogUtils._ConvertToAppFont(_ControlView, False).Height
+ Else
+ If oSession.HasUNOProperty(_ControlModel, &quot;Height&quot;) Then _PropertyGet = _ControlModel.Height
+ End If
Case UCase(&quot;ListCount&quot;)
Select Case _ControlType
Case CTLCOMBOBOX, CTLLISTBOX
@@ -2059,11 +2020,23 @@ Const cstSubArgs = &quot;&quot;
Case UCase(&quot;Visible&quot;)
If oSession.HasUnoMethod(_ControlView, &quot;isVisible&quot;) Then _PropertyGet = CBool(_ControlView.isVisible())
Case UCase(&quot;Width&quot;)
- If oSession.HasUNOMethod(_ControlView, &quot;getPosSize&quot;) Then _PropertyGet = _ControlView.getPosSize().Width
+ If [_parent]._Displayed Then &apos; Convert PosSize view property from pixels to APPFONT units
+ _PropertyGet = SF_DialogUtils._ConvertToAppFont(_ControlView, False).Width
+ Else
+ If oSession.HasUNOProperty(_ControlModel, &quot;Width&quot;) Then _PropertyGet = _ControlModel.Width
+ End If
Case UCase(&quot;X&quot;)
- If oSession.HasUNOMethod(_ControlView, &quot;getPosSize&quot;) Then _PropertyGet = _ControlView.getPosSize().X
+ If [_parent]._Displayed Then &apos; Convert PosSize view property from pixels to APPFONT units
+ _PropertyGet = SF_DialogUtils._ConvertToAppFont(_ControlView, True).X
+ Else
+ If oSession.HasUNOProperty(_ControlModel, &quot;PoistionX&quot;) Then _PropertyGet = _ControlModel.PositionX
+ End If
Case UCase(&quot;Y&quot;)
- If oSession.HasUNOMethod(_ControlView, &quot;getPosSize&quot;) Then _PropertyGet = _ControlView.getPosSize().Y
+ If [_parent]._Displayed Then &apos; Convert PosSize view property from piYels to APPFONT units
+ _PropertyGet = SF_DialogUtils._ConvertToAppFont(_ControlView, True).Y
+ Else
+ If oSession.HasUNOProperty(_ControlModel, &quot;PoistionY&quot;) Then _PropertyGet = _ControlModel.PositionY
+ End If
Case UCase(&quot;XControlModel&quot;)
Set _PropertyGet = _ControlModel
Case UCase(&quot;XControlView&quot;)
@@ -2178,8 +2151,8 @@ Const cstSubArgs = &quot;Value&quot;
Case Else : GoTo CatchType
End Select
Case UCase(&quot;Height&quot;)
- If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Height&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
- If oSession.HasUnoMethod(_ControlView, &quot;setPosSize&quot;) Then _ControlView.setPosSize(-1, -1, -1, CLng(pvValue), com.sun.star.awt.PosSize.HEIGHT)
+ If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Height&quot;, ScriptForge.V_NUMERIC) Then GoTo Catch
+ bSet = Resize(Height := pvValue)
Case UCase(&quot;ListIndex&quot;)
If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;ListIndex&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
Select Case _ControlType
@@ -2408,14 +2381,14 @@ Const cstSubArgs = &quot;Value&quot;
_ControlView.setVisible(pvValue)
End If
Case UCase(&quot;Width&quot;)
- If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Width&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
- If oSession.HasUnoMethod(_ControlView, &quot;setPosSize&quot;) Then _ControlView.setPosSize(-1, -1, CLng(pvValue), -1, com.sun.star.awt.PosSize.WIDTH)
+ If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Width&quot;, ScriptForge.V_NUMERIC) Then GoTo Catch
+ bSet = Resize(Width := pvValue)
Case &quot;X&quot;
- If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;X&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
- If oSession.HasUnoMethod(_ControlView, &quot;setPosSize&quot;) Then _ControlView.setPosSize(CLng(pvValue), -1, -1, -1, com.sun.star.awt.PosSize.X)
+ If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Width&quot;, ScriptForge.V_NUMERIC) Then GoTo Catch
+ bSet = Resize(Left := pvValue)
Case &quot;Y&quot;
- If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Y&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
- If oSession.HasUnoMethod(_ControlView, &quot;setPosSize&quot;) Then _ControlView.setPosSize(-1, CLng(pvValue), -1, -1, com.sun.star.awt.PosSize.Y)
+ If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Width&quot;, ScriptForge.V_NUMERIC) Then GoTo Catch
+ bSet = Resize(Top := pvValue)
Case Else
bSet = False
End Select
diff --git a/wizards/source/sfdialogs/SF_DialogUtils.xba b/wizards/source/sfdialogs/SF_DialogUtils.xba
new file mode 100644
index 000000000000..0dc706be60d0
--- /dev/null
+++ b/wizards/source/sfdialogs/SF_DialogUtils.xba
@@ -0,0 +1,275 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
+<script:module xmlns:script="http://openoffice.org/2000/script" script:name="SF_DialogUtils" script:language="StarBasic" script:moduleType="normal">REM =======================================================================================================================
+REM === The ScriptForge library and its associated libraries are part of the LibreOffice project. ===
+REM === The SFDialogs library is one of the associated libraries. ===
+REM === Full documentation is available on https://help.libreoffice.org/ ===
+REM =======================================================================================================================
+
+Option Explicit
+Option Private Module
+
+&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;
+&apos;&apos;&apos; SF_DialogUtils
+&apos;&apos;&apos; ========
+&apos;&apos;&apos; FOR INTERNAL USE ONLY
+&apos;&apos;&apos; Groups private functions that are common to the SF_Dialog and SF_DialogControl class modules
+&apos;&apos;&apos;
+&apos;&apos;&apos; Topics where SF_DiaogUtils matters:
+&apos;&apos;&apos; - resizing dialog and dialog controls
+&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;
+
+REM ================================================================== EXCEPTIONS
+
+REM ============================================================ MODULE CONSTANTS
+
+Public Const MINPOSITION = -99999 &apos; Conventionally indicates &quot;do not change position&quot;
+
+REM =========================================pvA================= PRIVATE METHODS
+
+REM -----------------------------------------------------------------------------
+Public Function _ConvertPointToAppFont(ByRef poView As Object _
+ , ByVal plX As Long _
+ , ByVal plY As Long _
+ ) As Object
+&apos;&apos;&apos; Convert the X, Y position expressed in pixels to a Point expressed in &quot;Map APPFONT&quot;
+&apos;&apos;&apos; Args:
+&apos;&apos;&apos; poView: a com.sun.star.awt.XControl - stardiv.Toolkit.UnoDialogControl
+&apos;&apos;&apos; plX, plY : the horizontal and vertical coordinates of the top-left corner of the control
+&apos;&apos;&apos; Returns:
+&apos;&apos;&apos; a com.sun.star.awt.Point object
+
+Dim oPoint As New com.sun.star.awt.Point &apos; The input Point
+Dim oReturn As Object &apos; Return value
+
+Try:
+ oPoint.X = plX
+ oPoint.Y = plY
+ Set oReturn = poView.convertPointToLogic(oPoint, com.sun.star.util.MeasureUnit.APPFONT)
+
+Finally:
+ Set _ConvertPointToAppFont = oReturn
+ Exit Function
+End Function &apos; SFDialogs.SF_DialogUtils._ConvertPointToAppFont
+
+REM -----------------------------------------------------------------------------
+Public Function _ConvertPointToPixel(ByRef poView As Object _
+ , ByVal plX As Long _
+ , ByVal plY As Long _
+ ) As Object
+&apos;&apos;&apos; Convert the X, Y coordinates expressed in &quot;Map APPFONT&quot; units to a point expressed in pixels
+&apos;&apos;&apos; Args:
+&apos;&apos;&apos; poView: a com.sun.star.awt.XControl - stardiv.Toolkit.UnoDialogControl
+&apos;&apos;&apos; plX, plY : the horizontal and vertical coordinates of the top-left corner of the control
+&apos;&apos;&apos; Returns:
+&apos;&apos;&apos; a com.sun.star.awt.Point object
+
+Dim oPoint As New com.sun.star.awt.Point &apos; The input point
+Dim oReturn As Object &apos; Return value
+
+Try:
+ oPoint.X = plX
+ oPoint.Y = plY
+ Set oReturn = poView.convertPointToPixel(oPoint, com.sun.star.util.MeasureUnit.APPFONT)
+
+Finally:
+ Set _ConvertPointToPixel = oReturn
+ Exit Function
+End Function &apos; SFDialogs.SF_DialogUtils._ConvertPointToPixel
+
+REM -----------------------------------------------------------------------------
+Public Function _ConvertSizeToAppFont(ByRef poView As Object _
+ , ByVal plWidth As Long _
+ , ByVal plHeight As Long _
+ ) As Object
+&apos;&apos;&apos; Convert the Width, Height dimensions expressed in pixels to a Size expressed in &quot;Map APPFONT&quot;
+&apos;&apos;&apos; Args:
+&apos;&apos;&apos; poView: a com.sun.star.awt.XControl - stardiv.Toolkit.UnoDialogControl
+&apos;&apos;&apos; plWidth, plHeight : the horizontal and vertical dimensions of the control
+&apos;&apos;&apos; Returns:
+&apos;&apos;&apos; a com.sun.star.awt.Size object
+
+Dim oSize As New com.sun.star.awt.Size &apos; The input size
+Dim oReturn As Object &apos; Return value
+
+Try:
+ oSize.Width = plWidth
+ oSize.Height = plHeight
+ Set oReturn = poView.convertSizeToLogic(oSize, com.sun.star.util.MeasureUnit.APPFONT)
+
+Finally:
+ Set _ConvertSizeToAppFont = oReturn
+ Exit Function
+End Function &apos; SFDialogs.SF_DialogUtils._ConvertSizeToAppFont
+
+REM -----------------------------------------------------------------------------
+Public Function _ConvertSizeToPixel(ByRef poView As Object _
+ , ByVal plWidth As Long _
+ , ByVal plHeight As Long _
+ ) As Object
+&apos;&apos;&apos; Convert the Width, Height dimensions expressed in &quot;Map APPFONT&quot; units to a Size expressed in pixels
+&apos;&apos;&apos; Args:
+&apos;&apos;&apos; poView: a com.sun.star.awt.XControl - stardiv.Toolkit.UnoDialogControl
+&apos;&apos;&apos; plWidth, plHeight : the horizontal and vertical dimensions of the control
+&apos;&apos;&apos; Returns:
+&apos;&apos;&apos; a com.sun.star.awt.Size object
+
+Dim oSize As New com.sun.star.awt.Size &apos; The input size
+Dim oReturn As Object &apos; Return value
+
+Try:
+ oSize.Width = plWidth
+ oSize.Height = plHeight
+ Set oReturn = poView.convertSizeToPixel(oSize, com.sun.star.util.MeasureUnit.APPFONT)
+
+Finally:
+ Set _ConvertSizeToPixel = oReturn
+ Exit Function
+End Function &apos; SFDialogs.SF_DialogUtils._ConvertSizeToPixel
+
+REM -----------------------------------------------------------------------------
+Public Function _ConvertToAppFont(ByRef poView As Object _
+ , ByVal pbPoint As Boolean _
+ ) As Object
+&apos;&apos;&apos; Switch between the _ConvertPointToAppFont and the _ConvertSizeToAppFont routines
+&apos;&apos;&apos; Args:
+&apos;&apos;&apos; poView: a com.sun.star.awt.XControl - stardiv.Toolkit.UnoDialogControl
+&apos;&apos;&apos; pbPoint: when True return a Point, otherwise return a Size
+&apos;&apos;&apos; Returns:
+&apos;&apos;&apos; a com.sun.star.awt.Point or a com.sun.star.awt.Size object
+
+Static oSession As Object &apos; Alias of SF_Session
+Dim oPosSize As Object &apos; com.sun.star.awt.Rectangle
+
+Try:
+ If IsNull(oSession) Then Set oSession = ScriptForge.SF_Services.CreateScriptService(&quot;Session&quot;)
+ If oSession.HasUNOMethod(poView, &quot;getPosSize&quot;) Then
+ Set oPosSize =poView.getPosSize()
+ Else &apos; Should not happen
+ Set oPosSize = New com.sun.star.awt.Rectangle
+ End If
+
+ If pbPoint Then
+ _ConvertToAppFont = _ConvertPointToAppFont(poView, oPosSize.X, oPosSize.Y) &apos; com.sun.star.awt.Point
+ Else
+ _ConvertToAppFont = _ConvertSizeToAppFont(poView, oPosSize.Width, oPosSize.Height) &apos; com.sun.star.awt.Size
+ End If
+
+End Function &apos; SFDialogs.SF_DialogUtils._ConvertToAppFont
+
+REM -----------------------------------------------------------------------------
+Public Function _Resize(ByRef Control As Object _
+ , Optional ByVal Left As Variant _
+ , Optional ByVal Top As Variant _
+ , Optional ByVal Width As Variant _
+ , Optional ByVal Height As Variant _
+ ) As Boolean
+&apos;&apos;&apos; Move the top-left corner of a dialog or a diaog control to new coordinates and/or modify its dimensions
+&apos;&apos;&apos; Without arguments, the method resets the initial dimensions
+&apos;&apos;&apos; Attributes denoting the position and size of a dialog are expressed in &quot;Map AppFont&quot; units.
+&apos;&apos;&apos; Map AppFont units are device and resolution independent.
+&apos;&apos;&apos; One Map AppFont unit is equal to one eighth of the average character (Systemfont) height and one quarter of the average character width.
+&apos;&apos;&apos; The dialog editor (= the Basic IDE) also uses Map AppFont units.
+&apos;&apos;&apos; Args:
+&apos;&apos;&apos; Control: a SF_Dialog or SF_DialogControl class instance
+&apos;&apos;&apos; Left : the horizontal distance from the top-left corner
+&apos;&apos;&apos; Top : the vertical distance from the top-left corner
+&apos;&apos;&apos; Width : the horizontal width of the rectangle containing the Dialog[Control]
+&apos;&apos;&apos; Height : the vertical height of the rectangle containing the Dialog[Control]
+&apos;&apos;&apos; Negative or missing arguments are left unchanged.
+&apos;&apos;&apos; Returns:
+&apos;&apos;&apos; True when successful
+
+Dim bResize As Boolean &apos; Return value
+Dim oModel As Object &apos; Model of Control object
+Dim oView As Object &apos; View of Control object
+Dim Displayed As Boolean &apos; When Trs, the dialog is currently active
+Dim oSize As Object &apos; com.sun.star.awt.Size
+Dim oPoint As Object &apos; com.sun.star.awt.Point
+Dim iFlags As Integer &apos; com.sun.star.awt.PosSize constants
+Dim cstThisSub As String
+Const cstSubArgs = &quot;[Left], [Top], [Width], [Height]&quot;
+
+ If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
+ bResize = False
+
+Check:
+ If IsNull(Control) Then GoTo Finally
+ If IsMissing(Left) Or IsEmpty(Left) Then Left = MINPOSITION
+ If IsMissing(Top) Or IsEmpty(Top) Then Top = MINPOSITION
+ If IsMissing(Height) Or IsEmpty(Height) Then Height = -1
+ If IsMissing(Width) Or IsEmpty(Width) Then Width = -1
+ If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
+ If Not ScriptForge.SF_Utils._Validate(Left, &quot;Left&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
+ If Not ScriptForge.SF_Utils._Validate(Top, &quot;Top&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
+ If Not ScriptForge.SF_Utils._Validate(Width, &quot;Width&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
+ If Not ScriptForge.SF_Utils._Validate(Height, &quot;Height&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
+ End If
+
+Try:
+ With Control
+ &apos; Initialize local variables depending on caller
+ Select Case .ObjectType
+ Case &quot;DIALOG&quot;
+ cstThisSub = &quot;SFDialogs.Dialog.Resize&quot;
+ Set oModel = ._DialogModel
+ Set oView = ._DialogControl
+ Displayed = ._Displayed
+ Case &quot;DIALOGCONTROL&quot;
+ cstThisSub = &quot;SFDialogs.DialogControl.Resize&quot;
+ Set oModel = ._ControlModel
+ Set oView = ._ControlView
+ Displayed = .[Parent]._Displayed
+ Case Else
+ End Select
+ &apos; Reset factory settings when relevant
+ If Left = MINPOSITION And Top = MINPOSITION And Width = -1 And Height = -1 Then
+ Left = ._Left
+ Top = ._Top
+ Width = ._Width
+ Height = ._Height
+ End If
+ End With
+
+ &apos; Model sizes are in APPFONTs, View sizes are in pixels. Use view.convertSizeToPixel() to convert
+ &apos; For dynamic dialogs: convertSizeToPixel() is available only as from the dialog is made visible
+ &apos; =&gt; When the dialog is visible, positions and sizes are updated in view
+ &apos; When the dialog is not visible, positions and sizes adapted on model
+ If Displayed Then
+ With oView
+ &apos; Trace the elements to change
+ iFlags = 0
+ With com.sun.star.awt.PosSize
+ If Left &gt; MINPOSITION Then iFlags = iFlags + .X Else Left = 0
+ If Top &gt; MINPOSITION Then iFlags = iFlags + .Y Else Top = 0
+ If Width &gt; 0 Then iFlags = iFlags + .WIDTH Else Width = 0
+ If Height &gt; 0 Then iFlags = iFlags + .HEIGHT Else Height = 0
+ End With
+ &apos; Convert APPFONT units to pixels
+ Set oPoint = SF_DialogUtils._ConvertPointToPixel(oView, CLng(Left), CLng(Top))
+ Set oSize = SF_DialogUtils._ConvertSizeToPixel(oView, CLng(Width), CLng(Height))
+ &apos; Rewrite
+ If iFlags &gt; 0 Then .setPosSize(oPoint.X, oPoint.Y, oSize.Width, oSize.Height, iFlags)
+ End With
+ Else
+ With oModel
+ &apos; Store position and dimensions in APPFONT units
+ If Left &gt; MINPOSITION Then .PositionX = CLng(Left)
+ If Top &gt; MINPOSITION Then .PositionY = CLng(Top)
+ If Width &gt; 0 Then .Width = CLng(Width)
+ If Height &gt; 0 Then .Height = CLng(Height)
+ End With
+ End If
+ bResize = True
+
+Finally:
+ _Resize = bResize
+ ScriptForge.SF_Utils._ExitFunction(cstThisSub)
+ Exit Function
+Catch:
+ GoTo Finally
+End Function &apos; SFDialogss.SF_DialogUtils._Resize
+
+REM ============================================= END OF SFDIALOGS.SF_DIALOGUTILS
+
+</script:module> \ No newline at end of file
diff --git a/wizards/source/sfdialogs/script.xlb b/wizards/source/sfdialogs/script.xlb
index 6dff54d872f5..59263472b3a1 100644
--- a/wizards/source/sfdialogs/script.xlb
+++ b/wizards/source/sfdialogs/script.xlb
@@ -6,4 +6,5 @@
<library:element library:name="SF_Dialog"/>
<library:element library:name="SF_DialogControl"/>
<library:element library:name="SF_DialogListener"/>
+ <library:element library:name="SF_DialogUtils"/>
</library:library> \ No newline at end of file