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 ' com.sun.star.awt.XControlModel - stardiv
Private _Displayed As Boolean ' True after Execute()
Private _Modal As Boolean ' Set by Execute()
-' Dialog position and dimensions in pixels
+' 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 = ""
_OnFocusLost = ""
@@ -682,6 +685,8 @@ Try:
If Modal Then
_Modal = True
_Displayed = True
+ ' 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
-''' Move the top-left corner of a dialog to new coordinates and/or modify its dimensions
-''' All distances are expressed in pixels.
+''' Move the top-left corner of the dialog to new coordinates and/or modify its dimensions
''' Without arguments, the method resets the initial dimensions
+''' Attributes denoting the position and size of a dialog are expressed in "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.
+''' The dialog editor (= the Basic IDE) also uses Map AppFont units.
''' Args:
-''' Left : the horizontal distance from the top-left corner
-''' Top : the vertical distance from the top-left corner
-''' Width : the horizontal width of the rectangle containing the Dialog
-''' Height : the vertical height of the rectangle containing the Dialog
-''' Negative or missing arguments are left unchanged
+''' Left : the horizontal distance from the top-left corner. It may be negative.
+''' Top : the vertical distance from the top-left corner. It may be negative.
+''' Width : the horizontal width of the rectangle containing the Dialog. It must be positive.
+''' Height : the vertical height of the rectangle containing the Dialog. It must be positive.
+''' Missing arguments are left unchanged.
''' Returns:
''' True when successful
''' Examples:
-''' oDialog.Resize(1000, 2000, Height := 6000) ' Width is not changed
-
-Dim bResize As Boolean ' Return value
-Dim oPosSize As Object ' com.sun.star.awt.Rectangle
-Dim iFlags As Integer ' com.sun.star.awt.PosSize constants
-Const cstThisSub = "SFDialogs.Dialog.Resize"
-Const cstSubArgs = "[Left], [Top], [Width], [Height]"
-
- 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, "Left", ScriptForge.V_NUMERIC) Then GoTo Finally
- If Not ScriptForge.SF_Utils._Validate(Top, "Top", ScriptForge.V_NUMERIC) Then GoTo Finally
- If Not ScriptForge.SF_Utils._Validate(Width, "Width", ScriptForge.V_NUMERIC) Then GoTo Finally
- If Not ScriptForge.SF_Utils._Validate(Height, "Height", ScriptForge.V_NUMERIC) Then GoTo Finally
- End If
+''' oDialog.Resize(100, 200, Height := 600) ' Width is not changed
Try:
- With _DialogControl
- Set oPosSize = .getPosSize()
- ' Reset factory settings
- If Left = -1 And Top = -1 And Width = -1 And Height = -1 Then
- 'Left = _Left ' Initial positions determination is unstable
- 'Top = _Top
- Width = _Width
- Height = _Height
- End If
- ' Trace the elements to change
- iFlags = 0
- With com.sun.star.awt.PosSize
- If CLng(Left) >= 0 Then iFlags = iFlags + .X Else Left = oPosSize.X
- If CLng(Top) >= 0 Then iFlags = iFlags + .Y Else Top = oPosSize.Y
- If CLng(Width) > 0 Then iFlags = iFlags + .WIDTH Else Width = oPosSize.Width
- If CLng(Height) > 0 Then iFlags = iFlags + .HEIGHT Else Height = oPosSize.Height
- End With
- ' Rewrite
- If iFlags > 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 ' SFDialogss.SF_Dialog.Resize
REM -----------------------------------------------------------------------------
@@ -1252,17 +1213,14 @@ Public Sub _Initialize()
''' - Addition of the new object in the Dialogs buffer
''' - Initialisation of persistent storage for controls
-Dim oPosSize As Object ' com.sun.star.awt.Rectangle
-
Try:
' Keep reference to model
Set _DialogModel = _DialogControl.Model
' 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
''' psProperty: the name of the property
Static oSession As Object ' Alias of SF_Session
+Dim oPosSize As Object ' com.sun.star.awt.Rectangle
Dim oDialogEvents As Object ' com.sun.star.container.XNameContainer
Dim sEventName As String ' Internal event name
Dim cstThisSub As String
@@ -1386,7 +1345,11 @@ Const cstSubArgs = ""
Case UCase("Caption")
If oSession.HasUNOProperty(_DialogModel, "Title") Then _PropertyGet = _DialogModel.Title
Case UCase("Height")
- If oSession.HasUNOMethod(_DialogControl, "getPosSize") Then _PropertyGet = _DialogControl.getPosSize().Height
+ If _Displayed Then ' Convert PosSize view property from pixels to APPFONT units
+ _PropertyGet = SF_DialogUtils._ConvertToAppFont(_DialogControl, False).Height
+ Else
+ If oSession.HasUNOProperty(_DialogModel, "Height") Then _PropertyGet = _DialogModel.Height
+ End If
Case UCase("Modal")
_PropertyGet = _Modal
Case UCase("Name")
@@ -1420,7 +1383,11 @@ Const cstSubArgs = ""
Case UCase("Visible")
If oSession.HasUnoMethod(_DialogControl, "isVisible") Then _PropertyGet = CBool(_DialogControl.isVisible())
Case UCase("Width")
- If oSession.HasUNOMethod(_DialogControl, "getPosSize") Then _PropertyGet = _DialogControl.getPosSize().Width
+ If _Displayed Then ' Convert PosSize view property from pixels to APPFONT units
+ _PropertyGet = SF_DialogUtils._ConvertToAppFont(_DialogControl, False).Width
+ Else
+ If oSession.HasUNOProperty(_DialogModel, "Width") Then _PropertyGet = _DialogModel.Width
+ End If
Case UCase("XDialogModel")
Set _PropertyGet = _DialogModel
Case UCase("XDialogView")
@@ -1467,7 +1434,7 @@ Const cstSubArgs = "Value"
If oSession.HasUNOProperty(_DialogModel, "Title") Then _DialogModel.Title = pvValue
Case UCase("Height")
If Not ScriptForge.SF_Utils._Validate(pvValue, "Height", ScriptForge.V_NUMERIC) Then GoTo Catch
- If oSession.HasUnoMethod(_DialogControl, "setPosSize") Then _DialogControl.setPosSize(-1, -1, -1, CLng(pvValue), com.sun.star.awt.PosSize.HEIGHT)
+ bSet = Resize(Height := pvValue)
Case UCase("OnFocusGained"), UCase("OnFocusLost"), UCase("OnKeyPressed"), UCase("OnKeyReleased") _
, UCase("OnMouseDragged"), UCase("OnMouseEntered"), UCase("OnMouseExited"), UCase("OnMouseMoved") _
, UCase("OnMousePressed"), UCase("OnMouseReleased")
@@ -1485,7 +1452,7 @@ Const cstSubArgs = "Value"
If oSession.HasUnoMethod(_DialogControl, "setVisible") Then _DialogControl.setVisible(pvValue)
Case UCase("Width")
If Not ScriptForge.SF_Utils._Validate(pvValue, "Width", ScriptForge.V_NUMERIC) Then GoTo Catch
- If oSession.HasUnoMethod(_DialogControl, "setPosSize") 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 ' com.sun.star.awt.grid.XGridDataModel
Private _ImplementationName As String
Private _ControlType As String ' One of the CTLxxx constants
-' Control position and dimensions
+' 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 = ""
_ControlType = ""
- _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
-''' Move the top-left corner of a dialog control to new coordinates and/or modify its dimensions
-''' All distances are expressed in pixels and are measured from the top-left corner of the parent dialog.
-''' Without arguments, the method resets the initial dimensions.
+''' Move the top-left corner of the control to new coordinates and/or modify its dimensions
+''' Without arguments, the method resets the initial dimensions and position
+''' Attributes denoting the position and size of a control are expressed in "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.
+''' The dialog editor (= the Basic IDE) also uses Map AppFont units.
''' Args:
-''' Left : the horizontal distance from the top-left corner
-''' Top : the vertical distance from the top-left corner
-''' Width : the horizontal width of the rectangle containing the control
-''' Height : the vertical height of the rectangle containing the control
-''' Negative or missing arguments are left unchanged
+''' Left : the horizontal distance from the top-left corner. It may be negative.
+''' Top : the vertical distance from the top-left corner. It may be negative.
+''' Width : the horizontal width of the rectangle containing the Dialog. It must be positive.
+''' Height : the vertical height of the rectangle containing the Dialog. It must be positive.
+''' Missing arguments are left unchanged.
''' Returns:
''' True when successful
''' Examples:
-''' oControl.Resize(100, 200, Height := 6000) ' Width is not changed
-
-Dim bResize As Boolean ' Return value
-Dim oPosSize As Object ' com.sun.star.awt.Rectangle
-Dim iFlags As Integer ' com.sun.star.awt.PosSize constants
-Const cstThisSub = "SFDialogs.DialogControl.Resize"
-Const cstSubArgs = "[Left], [Top], [Width], [Height]"
-
- 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, "Left", ScriptForge.V_NUMERIC) Then GoTo Finally
- If Not ScriptForge.SF_Utils._Validate(Top, "Top", ScriptForge.V_NUMERIC) Then GoTo Finally
- If Not ScriptForge.SF_Utils._Validate(Width, "Width", ScriptForge.V_NUMERIC) Then GoTo Finally
- If Not ScriptForge.SF_Utils._Validate(Height, "Height", ScriptForge.V_NUMERIC) Then GoTo Finally
- End If
+''' myControl.Resize(100, 200, Height := 600) ' Width is not changed
Try:
- With _ControlView
- Set oPosSize = .getPosSize()
- ' 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
- ' Trace the elements to change
- iFlags = 0
- With com.sun.star.awt.PosSize
- If CLng(Left) >= 0 Then iFlags = iFlags + .X Else Left = oPosSize.X
- If CLng(Top) >= 0 Then iFlags = iFlags + .Y Else Top = oPosSize.Y
- If CLng(Width) > 0 Then iFlags = iFlags + .WIDTH Else Width = oPosSize.Width
- If CLng(Height) > 0 Then iFlags = iFlags + .HEIGHT Else Height = oPosSize.Height
- End With
- ' Rewrite
- If iFlags > 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 ' SF_Documents.SF_DialogControl.Resize
+End Function ' SFDialogss.SF_Dialog.Resize
REM -----------------------------------------------------------------------------
Public Function SetFocus() As Boolean
@@ -1776,6 +1732,7 @@ Dim lIndex As Long ' Index in StringItemList
Dim sItem As String ' A single item
Dim vDate As Variant ' com.sun.star.util.Date or com.sun.star.util.Time
Dim vValues As Variant ' Array of listbox values
+Dim oPosSize As Object ' com.sun.star.awt.Rectangle
Dim oControlEvents As Object ' com.sun.star.container.XNameContainer
Dim sEventName As String ' Internal event name
Dim i As Long
@@ -1844,7 +1801,11 @@ Const cstSubArgs = ""
Case Else : GoTo CatchType
End Select
Case UCase("Height")
- If oSession.HasUNOMethod(_ControlView, "getPosSize") Then _PropertyGet = _ControlView.getPosSize().Height
+ If [_parent]._Displayed Then ' Convert PosSize view property from pixels to APPFONT units
+ _PropertyGet = SF_DialogUtils._ConvertToAppFont(_ControlView, False).Height
+ Else
+ If oSession.HasUNOProperty(_ControlModel, "Height") Then _PropertyGet = _ControlModel.Height
+ End If
Case UCase("ListCount")
Select Case _ControlType
Case CTLCOMBOBOX, CTLLISTBOX
@@ -2059,11 +2020,23 @@ Const cstSubArgs = ""
Case UCase("Visible")
If oSession.HasUnoMethod(_ControlView, "isVisible") Then _PropertyGet = CBool(_ControlView.isVisible())
Case UCase("Width")
- If oSession.HasUNOMethod(_ControlView, "getPosSize") Then _PropertyGet = _ControlView.getPosSize().Width
+ If [_parent]._Displayed Then ' Convert PosSize view property from pixels to APPFONT units
+ _PropertyGet = SF_DialogUtils._ConvertToAppFont(_ControlView, False).Width
+ Else
+ If oSession.HasUNOProperty(_ControlModel, "Width") Then _PropertyGet = _ControlModel.Width
+ End If
Case UCase("X")
- If oSession.HasUNOMethod(_ControlView, "getPosSize") Then _PropertyGet = _ControlView.getPosSize().X
+ If [_parent]._Displayed Then ' Convert PosSize view property from pixels to APPFONT units
+ _PropertyGet = SF_DialogUtils._ConvertToAppFont(_ControlView, True).X
+ Else
+ If oSession.HasUNOProperty(_ControlModel, "PoistionX") Then _PropertyGet = _ControlModel.PositionX
+ End If
Case UCase("Y")
- If oSession.HasUNOMethod(_ControlView, "getPosSize") Then _PropertyGet = _ControlView.getPosSize().Y
+ If [_parent]._Displayed Then ' Convert PosSize view property from piYels to APPFONT units
+ _PropertyGet = SF_DialogUtils._ConvertToAppFont(_ControlView, True).Y
+ Else
+ If oSession.HasUNOProperty(_ControlModel, "PoistionY") Then _PropertyGet = _ControlModel.PositionY
+ End If
Case UCase("XControlModel")
Set _PropertyGet = _ControlModel
Case UCase("XControlView")
@@ -2178,8 +2151,8 @@ Const cstSubArgs = "Value"
Case Else : GoTo CatchType
End Select
Case UCase("Height")
- If Not ScriptForge.SF_Utils._Validate(pvValue, "Height", ScriptForge.V_NUMERIC) Then GoTo Finally
- If oSession.HasUnoMethod(_ControlView, "setPosSize") Then _ControlView.setPosSize(-1, -1, -1, CLng(pvValue), com.sun.star.awt.PosSize.HEIGHT)
+ If Not ScriptForge.SF_Utils._Validate(pvValue, "Height", ScriptForge.V_NUMERIC) Then GoTo Catch
+ bSet = Resize(Height := pvValue)
Case UCase("ListIndex")
If Not ScriptForge.SF_Utils._Validate(pvValue, "ListIndex", ScriptForge.V_NUMERIC) Then GoTo Finally
Select Case _ControlType
@@ -2408,14 +2381,14 @@ Const cstSubArgs = "Value"
_ControlView.setVisible(pvValue)
End If
Case UCase("Width")
- If Not ScriptForge.SF_Utils._Validate(pvValue, "Width", ScriptForge.V_NUMERIC) Then GoTo Finally
- If oSession.HasUnoMethod(_ControlView, "setPosSize") Then _ControlView.setPosSize(-1, -1, CLng(pvValue), -1, com.sun.star.awt.PosSize.WIDTH)
+ If Not ScriptForge.SF_Utils._Validate(pvValue, "Width", ScriptForge.V_NUMERIC) Then GoTo Catch
+ bSet = Resize(Width := pvValue)
Case "X"
- If Not ScriptForge.SF_Utils._Validate(pvValue, "X", ScriptForge.V_NUMERIC) Then GoTo Finally
- If oSession.HasUnoMethod(_ControlView, "setPosSize") Then _ControlView.setPosSize(CLng(pvValue), -1, -1, -1, com.sun.star.awt.PosSize.X)
+ If Not ScriptForge.SF_Utils._Validate(pvValue, "Width", ScriptForge.V_NUMERIC) Then GoTo Catch
+ bSet = Resize(Left := pvValue)
Case "Y"
- If Not ScriptForge.SF_Utils._Validate(pvValue, "Y", ScriptForge.V_NUMERIC) Then GoTo Finally
- If oSession.HasUnoMethod(_ControlView, "setPosSize") Then _ControlView.setPosSize(-1, CLng(pvValue), -1, -1, com.sun.star.awt.PosSize.Y)
+ If Not ScriptForge.SF_Utils._Validate(pvValue, "Width", 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 @@
+
+
+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
+
+'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+''' SF_DialogUtils
+''' ========
+''' FOR INTERNAL USE ONLY
+''' Groups private functions that are common to the SF_Dialog and SF_DialogControl class modules
+'''
+''' Topics where SF_DiaogUtils matters:
+''' - resizing dialog and dialog controls
+'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+
+REM ================================================================== EXCEPTIONS
+
+REM ============================================================ MODULE CONSTANTS
+
+Public Const MINPOSITION = -99999 ' Conventionally indicates "do not change position"
+
+REM =========================================pvA================= PRIVATE METHODS
+
+REM -----------------------------------------------------------------------------
+Public Function _ConvertPointToAppFont(ByRef poView As Object _
+ , ByVal plX As Long _
+ , ByVal plY As Long _
+ ) As Object
+''' Convert the X, Y position expressed in pixels to a Point expressed in "Map APPFONT"
+''' Args:
+''' poView: a com.sun.star.awt.XControl - stardiv.Toolkit.UnoDialogControl
+''' plX, plY : the horizontal and vertical coordinates of the top-left corner of the control
+''' Returns:
+''' a com.sun.star.awt.Point object
+
+Dim oPoint As New com.sun.star.awt.Point ' The input Point
+Dim oReturn As Object ' 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 ' SFDialogs.SF_DialogUtils._ConvertPointToAppFont
+
+REM -----------------------------------------------------------------------------
+Public Function _ConvertPointToPixel(ByRef poView As Object _
+ , ByVal plX As Long _
+ , ByVal plY As Long _
+ ) As Object
+''' Convert the X, Y coordinates expressed in "Map APPFONT" units to a point expressed in pixels
+''' Args:
+''' poView: a com.sun.star.awt.XControl - stardiv.Toolkit.UnoDialogControl
+''' plX, plY : the horizontal and vertical coordinates of the top-left corner of the control
+''' Returns:
+''' a com.sun.star.awt.Point object
+
+Dim oPoint As New com.sun.star.awt.Point ' The input point
+Dim oReturn As Object ' 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 ' SFDialogs.SF_DialogUtils._ConvertPointToPixel
+
+REM -----------------------------------------------------------------------------
+Public Function _ConvertSizeToAppFont(ByRef poView As Object _
+ , ByVal plWidth As Long _
+ , ByVal plHeight As Long _
+ ) As Object
+''' Convert the Width, Height dimensions expressed in pixels to a Size expressed in "Map APPFONT"
+''' Args:
+''' poView: a com.sun.star.awt.XControl - stardiv.Toolkit.UnoDialogControl
+''' plWidth, plHeight : the horizontal and vertical dimensions of the control
+''' Returns:
+''' a com.sun.star.awt.Size object
+
+Dim oSize As New com.sun.star.awt.Size ' The input size
+Dim oReturn As Object ' 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 ' SFDialogs.SF_DialogUtils._ConvertSizeToAppFont
+
+REM -----------------------------------------------------------------------------
+Public Function _ConvertSizeToPixel(ByRef poView As Object _
+ , ByVal plWidth As Long _
+ , ByVal plHeight As Long _
+ ) As Object
+''' Convert the Width, Height dimensions expressed in "Map APPFONT" units to a Size expressed in pixels
+''' Args:
+''' poView: a com.sun.star.awt.XControl - stardiv.Toolkit.UnoDialogControl
+''' plWidth, plHeight : the horizontal and vertical dimensions of the control
+''' Returns:
+''' a com.sun.star.awt.Size object
+
+Dim oSize As New com.sun.star.awt.Size ' The input size
+Dim oReturn As Object ' 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 ' SFDialogs.SF_DialogUtils._ConvertSizeToPixel
+
+REM -----------------------------------------------------------------------------
+Public Function _ConvertToAppFont(ByRef poView As Object _
+ , ByVal pbPoint As Boolean _
+ ) As Object
+''' Switch between the _ConvertPointToAppFont and the _ConvertSizeToAppFont routines
+''' Args:
+''' poView: a com.sun.star.awt.XControl - stardiv.Toolkit.UnoDialogControl
+''' pbPoint: when True return a Point, otherwise return a Size
+''' Returns:
+''' a com.sun.star.awt.Point or a com.sun.star.awt.Size object
+
+Static oSession As Object ' Alias of SF_Session
+Dim oPosSize As Object ' com.sun.star.awt.Rectangle
+
+Try:
+ If IsNull(oSession) Then Set oSession = ScriptForge.SF_Services.CreateScriptService("Session")
+ If oSession.HasUNOMethod(poView, "getPosSize") Then
+ Set oPosSize =poView.getPosSize()
+ Else ' Should not happen
+ Set oPosSize = New com.sun.star.awt.Rectangle
+ End If
+
+ If pbPoint Then
+ _ConvertToAppFont = _ConvertPointToAppFont(poView, oPosSize.X, oPosSize.Y) ' com.sun.star.awt.Point
+ Else
+ _ConvertToAppFont = _ConvertSizeToAppFont(poView, oPosSize.Width, oPosSize.Height) ' com.sun.star.awt.Size
+ End If
+
+End Function ' 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
+''' Move the top-left corner of a dialog or a diaog control to new coordinates and/or modify its dimensions
+''' Without arguments, the method resets the initial dimensions
+''' Attributes denoting the position and size of a dialog are expressed in "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.
+''' The dialog editor (= the Basic IDE) also uses Map AppFont units.
+''' Args:
+''' Control: a SF_Dialog or SF_DialogControl class instance
+''' Left : the horizontal distance from the top-left corner
+''' Top : the vertical distance from the top-left corner
+''' Width : the horizontal width of the rectangle containing the Dialog[Control]
+''' Height : the vertical height of the rectangle containing the Dialog[Control]
+''' Negative or missing arguments are left unchanged.
+''' Returns:
+''' True when successful
+
+Dim bResize As Boolean ' Return value
+Dim oModel As Object ' Model of Control object
+Dim oView As Object ' View of Control object
+Dim Displayed As Boolean ' When Trs, the dialog is currently active
+Dim oSize As Object ' com.sun.star.awt.Size
+Dim oPoint As Object ' com.sun.star.awt.Point
+Dim iFlags As Integer ' com.sun.star.awt.PosSize constants
+Dim cstThisSub As String
+Const cstSubArgs = "[Left], [Top], [Width], [Height]"
+
+ 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, "Left", ScriptForge.V_NUMERIC) Then GoTo Finally
+ If Not ScriptForge.SF_Utils._Validate(Top, "Top", ScriptForge.V_NUMERIC) Then GoTo Finally
+ If Not ScriptForge.SF_Utils._Validate(Width, "Width", ScriptForge.V_NUMERIC) Then GoTo Finally
+ If Not ScriptForge.SF_Utils._Validate(Height, "Height", ScriptForge.V_NUMERIC) Then GoTo Finally
+ End If
+
+Try:
+ With Control
+ ' Initialize local variables depending on caller
+ Select Case .ObjectType
+ Case "DIALOG"
+ cstThisSub = "SFDialogs.Dialog.Resize"
+ Set oModel = ._DialogModel
+ Set oView = ._DialogControl
+ Displayed = ._Displayed
+ Case "DIALOGCONTROL"
+ cstThisSub = "SFDialogs.DialogControl.Resize"
+ Set oModel = ._ControlModel
+ Set oView = ._ControlView
+ Displayed = .[Parent]._Displayed
+ Case Else
+ End Select
+ ' 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
+
+ ' Model sizes are in APPFONTs, View sizes are in pixels. Use view.convertSizeToPixel() to convert
+ ' For dynamic dialogs: convertSizeToPixel() is available only as from the dialog is made visible
+ ' => When the dialog is visible, positions and sizes are updated in view
+ ' When the dialog is not visible, positions and sizes adapted on model
+ If Displayed Then
+ With oView
+ ' Trace the elements to change
+ iFlags = 0
+ With com.sun.star.awt.PosSize
+ If Left > MINPOSITION Then iFlags = iFlags + .X Else Left = 0
+ If Top > MINPOSITION Then iFlags = iFlags + .Y Else Top = 0
+ If Width > 0 Then iFlags = iFlags + .WIDTH Else Width = 0
+ If Height > 0 Then iFlags = iFlags + .HEIGHT Else Height = 0
+ End With
+ ' 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))
+ ' Rewrite
+ If iFlags > 0 Then .setPosSize(oPoint.X, oPoint.Y, oSize.Width, oSize.Height, iFlags)
+ End With
+ Else
+ With oModel
+ ' Store position and dimensions in APPFONT units
+ If Left > MINPOSITION Then .PositionX = CLng(Left)
+ If Top > MINPOSITION Then .PositionY = CLng(Top)
+ If Width > 0 Then .Width = CLng(Width)
+ If Height > 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 ' SFDialogss.SF_DialogUtils._Resize
+
+REM ============================================= END OF SFDIALOGS.SF_DIALOGUTILS
+
+
\ 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 @@
+
\ No newline at end of file