Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/LibreOffice/wizards/source/sfdialogs/   (Office von Apache Version 25.8.3.2©)  Datei vom 5.10.2025 mit Größe 162 kB image not shown  

Quelle  SF_Dialog.xba   Sprache: unbekannt

 
Untersuchungsergebnis.xba Download desUnknown {[0] [0] [0]}zum Wurzelverzeichnis wechseln

<?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_Dialog" 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 Compatible
Option ClassModule

Option Explicit

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''' SF_Dialog
''' =========
'''  Management of dialogs. They may be defined with the Basic IDE or built from scratch
'''  Each instance of the current class represents a single dialog box displayed to the user
'''
'''  A dialog box can be displayed in modal or in non-modal modes
'''
'''   In modal mode, the box is displayed and the execution of the macro process is suspended
'''   until one of the OK or Cancel buttons is pressed. In the meantime, other user actions
'''   executed on the box can trigger specific actions.
'''
'''   In non-modal mode, the dialog box is "floating" on the user desktop and the execution
'''   of the macro process continues normally
'''   A dialog box disappears from memory after its explicit termination.
'''
'''  Service invocation and usage:
'''
'''  1) when the dialog exists in some dialog libraries (= pre-defined with the Basic IDE):
'''   Dim myDialog As Object, lButton As Long
'''    Set myDialog = CreateScriptService("SFDialogs.Dialog", Container, Library, DialogName)
'''     ' Args:
'''     '  Container: "GlobalScope" for preinstalled libraries
'''     '     A window name (see its definition in the ScriptForge.UI service)
'''     '     "" (default) = the current document
'''     '  Library: The (case-sensitive) name of a library contained in the container
'''     '     Default = "Standard"
'''     '  DialogName: a case-sensitive string designating the dialog where it is about
'''    ' ... Initialize controls ...
'''    lButton = myDialog.Execute() ' Default mode = Modal
'''    If lButton = myDialog.OKBUTTON Then
'''     ' ... Process controls and do what is needed
'''    End If
'''    myDialog.Terminate()
'''
'''  2) when the dialog is fully defined by code:
'''   Dim myDialog As Object, oButton As Object lExec As Long
'''    Set myDialog = CreateScriptService("SFDialogs.NewDialog", DialogName, Place)
'''     ' Args:
'''     '  DialogName: a case-sensitive string designating the dialog
'''       Place: either
'''       - an array with 4 elements: (X, Y, Width, Height)
'''       - a com.sun.star.awt.Rectangle [X, Y, Width, Height]
'''         (All elements are expressed in "Map AppFont" units).
'''    ' ... Create controls with the CreateXXX(...) methods ..., e.g.
'''    Set oButton = myDialog.CreateButton("OKButton", Place := Array(100, 100, 20, 10), Push := "OK")
'''    lExec = myDialog.Execute() ' Default mode = Modal
'''    If lExec = myDialog.OKBUTTON Then
'''     ' ... Process controls and do what is needed
'''    End If
'''    myDialog.Terminate()
'''
'''
'''  Detailed user documentation:
'''   https://help.libreoffice.org/latest/en-US/text/sbasic/shared/03/sf_dialog.html?DbPAR=BASIC
'''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

REM ================================================================== EXCEPTIONS

Private Const DIALOGDEADERROR  = "DIALOGDEADERROR"
Private Const PAGEMANAGERERROR  = "PAGEMANAGERERROR"
Private Const DUPLICATECONTROLERROR = "DUPLICATECONTROLERROR"

REM ============================================================= PRIVATE MEMBERS

Private [Me]    As Object
Private [_Parent]   As Object
Private ObjectType   As String  ' Must be DIALOG
Private ServiceName   As String

' Dialog location
Private _Container   As String
Private _Library   As String
Private _BuiltFromScratch As Boolean  ' When True, dialog is not stored in a library
Private _BuiltInPython  As Boolean  ' Used only when _BuiltFromScratch = True
Private _Name    As String
Private _CacheIndex   As Long   ' Index in cache storage

' Dialog UNO references
Private _DialogProvider  As Object  ' com.sun.star.io.XInputStreamProvider
Private _DialogControl  As Object  ' com.sun.star.awt.XControl - stardiv.Toolkit.UnoDialogControl
Private _DialogModel  As Object  ' com.sun.star.awt.XControlModel - stardiv.Toolkit.UnoControlDialogModel

' Dialog attributes
Private _Displayed   As Boolean  ' True after Execute()
Private _Modal    As Boolean  ' Set by Execute()

' Dialog initial position and dimensions in APPFONT units
Private _Left    As Long
Private _Top    As Long
Private _Width    As Long
Private _Height    As Long

' Page management
Type _PageManager
 ControlName As String     ' Case-sensitive name of control involved in page management
 PageMgtType As Integer     ' One of the PILOTCONTROL, TABCONTROL, NEXTCONTROL, BACKCONTROL constants
 PageNumber As Long      ' When > 0, the page to activate for tab controls
 ListenerType As Integer     ' One of the ITEMSTATECHANGED, ACTIONPERFORMED or TABSELECTED constants
End Type

Private _PageManagement  As Variant  ' Array of _PageManager objects, one entry by involved control
Private _TabPageContainer As String  ' The name of the unique tab page container control
Private _ItemListener  As Object  ' com.sun.star.awt.XItemListener
Private _ActionListener  As Object  ' com.sun.star.awt.XActionListener
Private _TabPageContainerListener As Object
           ' com.sun.star.awt.tab.XTabPageContainerListener
Private _LastPage   As Long   ' When > 0, the last page in a tabbed dialog

' Updatable events
'  Next identifiers MUST be identical in both SF_Dialog and SF_DialogControl class modules
Private _FocusListener  As Object  ' com.sun.star.awt.XFocusListener
Private _OnFocusGained  As String  ' Script to invoke when dialog gets focus
Private _OnFocusLost  As String  ' Script to invoke when dialog loses focus
Private _FocusCounter  As Integer  ' Counts the number of events set on the listener
' ---
Private _KeyListener  As Object  ' com.sun.star.awt.XKeyListener
Private _OnKeyPressed  As String  ' Script to invoke when Key clicked in dialog
Private _OnKeyReleased  As String  ' Script to invoke when Key released in dialog
Private _KeyCounter   As Integer  ' Counts the number of events set on the listener
' ---
Private _MouseListener  As Object  ' com.sun.star.awt.XMouseListener
Private _OnMouseEntered  As String  ' Script to invoke when mouse enters dialog
Private _OnMouseExited  As String  ' Script to invoke when mouse leaves dialog
Private _OnMousePressed  As String  ' Script to invoke when mouse clicked in dialog
Private _OnMouseReleased As String  ' Script to invoke when mouse released in dialog
Private _MouseCounter  As Integer  ' Counts the number of events set on the listener
' ---
Private _MouseMotionListener As Object  ' com.sun.star.awt.XMouseMotionListener
Private _OnMouseDragged  As String  ' Script to invoke when mouse is dragged from the dialog
Private _OnMouseMoved  As String  ' Script to invoke when mouse is moved across the dialog
Private _MouseMotionCounter As Integer  ' Counts the number of events set on the listener
' ---
Private _TopWindowListener As Object  ' com.sun.star.awt.XTopWindowListener

' Persistent storage for controls
Private _ControlCache  As Variant  ' Array of control objects sorted like ElementNames of the Dialog model

REM ============================================================ MODULE CONSTANTS

' Dialog usual buttons
Private Const cstOKBUTTON  = 1
Private Const cstCANCELBUTTON = 0

' Page management
Private Const PILOTCONTROL  = 1
Private Const TABCONTROL  = 2
Private Const BACKCONTROL  = 3
Private Const NEXTCONTROL  = 4
Private Const TABPAGE   = 5
Private Const ITEMSTATECHANGED = 1
Private Const ACTIONPERFORMED = 2
Private Const TABSELECTED  = 3

REM ====================================================== CONSTRUCTOR/DESTRUCTOR

REM -----------------------------------------------------------------------------
Private Sub Class_Initialize()
 Set [Me] = Nothing
 Set [_Parent] = Nothing
 ObjectType = "DIALOG"
 ServiceName = "SFDialogs.Dialog"
 _Container = ""
 _Library = ""
 _BuiltFromScratch = False
 _BuiltInPython = False
 _Name = ""
 _CacheIndex = -1
 Set _DialogProvider = Nothing
 Set _DialogControl = Nothing
 Set _DialogModel = Nothing
 _Displayed = False
 _Modal = True

 _Left = SF_DialogUtils.MINPOSITION
 _Top = SF_DialogUtils.MINPOSITION
 _Width = -1
 _Height = -1

 _PageManagement = Array()
 _TabPageContainer = ""
 Set _ItemListener = Nothing
 Set _ActionListener = Nothing
 Set _TabPageContainerListener = Nothing
 _LastPage = 0

 Set _FocusListener = Nothing
 _OnFocusGained = ""
 _OnFocusLost = ""
 _FocusCounter = 0
 Set _KeyListener = Nothing
 _OnKeyPressed = ""
 _OnKeyReleased = ""
 _KeyCounter = 0
 Set _MouseListener = Nothing
 _OnMouseEntered = ""
 _OnMouseExited = ""
 _OnMousePressed = ""
 _OnMouseReleased = ""
 _MouseCounter = 0
 Set _MouseMotionListener = Nothing
 _OnMouseDragged = ""
 _OnMouseMoved = ""
 _MouseMotionCounter = 0
 _ControlCache = Array()
End Sub  ' SFDialogs.SF_Dialog Constructor

REM -----------------------------------------------------------------------------
Private Sub Class_Terminate()
 Call Class_Initialize()
End Sub  ' SFDialogs.SF_Dialog Destructor

REM -----------------------------------------------------------------------------
Public Function Dispose() As Variant
 If _CacheIndex >= 0 Then Terminate()
 Call Class_Terminate()
 Set Dispose = Nothing
End Function ' SFDialogs.SF_Dialog Explicit Destructor

REM ================================================================== PROPERTIES

REM -----------------------------------------------------------------------------
Property Get CANCELBUTTON() As Variant
 CANCELBUTTON = cstCANCELBUTTON
End Property ' SFDialogs.SF_Dialog.CANCELBUTTON (get)

REM -----------------------------------------------------------------------------
Property Get Caption() As Variant
''' The Caption property refers to the title of the dialog
 Caption = _PropertyGet("Caption")
End Property ' SFDialogs.SF_Dialog.Caption (get)

REM -----------------------------------------------------------------------------
Property Let Caption(Optional ByVal pvCaption As Variant)
''' Set the updatable property Caption
 _PropertySet("Caption", pvCaption)
End Property ' SFDialogs.SF_Dialog.Caption (let)

REM -----------------------------------------------------------------------------
Property Get Height() As Variant
''' The Height property refers to the height of the dialog box
 Height = _PropertyGet("Height")
End Property ' SFDialogs.SF_Dialog.Height (get)

REM -----------------------------------------------------------------------------
Property Let Height(Optional ByVal pvHeight As Variant)
''' Set the updatable property Height
 _PropertySet("Height", pvHeight)
End Property ' SFDialogs.SF_Dialog.Height (let)

REM -----------------------------------------------------------------------------
Property Get IsAlive() As Boolean
''' Returns True when the dialog has not been closed by the user
 IsAlive = _PropertyGet("IsAlive")
End Property ' SFDocuments.SF_Dialog.IsAlive

REM -----------------------------------------------------------------------------
Property Get Modal() As Boolean
''' The Modal property specifies if the dialog box has been executed in modal mode
 Modal = _PropertyGet("Modal")
End Property ' SFDialogs.SF_Dialog.Modal (get)

REM -----------------------------------------------------------------------------
Property Get Name() As String
''' Return the name of the actual dialog
 Name = _PropertyGet("Name")
End Property ' SFDialogs.SF_Dialog.Name

REM -----------------------------------------------------------------------------
Property Get OKBUTTON() As Variant
 OKBUTTON = cstOKBUTTON
End Property ' SFDialogs.SF_Dialog.OKBUTTON (get)

REM -----------------------------------------------------------------------------
Property Get OnFocusGained() As Variant
''' Get the script associated with the OnFocusGained event
 OnFocusGained = _PropertyGet("OnFocusGained")
End Property ' SFDialogs.SF_Dialog.OnFocusGained (get)

REM -----------------------------------------------------------------------------
Property Let OnFocusGained(Optional ByVal pvOnFocusGained As Variant)
''' Set the updatable property OnFocusGained
 _PropertySet("OnFocusGained", pvOnFocusGained)
End Property ' SFDialogs.SF_Dialog.OnFocusGained (let)

REM -----------------------------------------------------------------------------
Property Get OnFocusLost() As Variant
''' Get the script associated with the OnFocusLost event
 OnFocusLost = _PropertyGet("OnFocusLost")
End Property ' SFDialogs.SF_Dialog.OnFocusLost (get)

REM -----------------------------------------------------------------------------
Property Let OnFocusLost(Optional ByVal pvOnFocusLost As Variant)
''' Set the updatable property OnFocusLost
 _PropertySet("OnFocusLost", pvOnFocusLost)
End Property ' SFDialogs.SF_Dialog.OnFocusLost (let)

REM -----------------------------------------------------------------------------
Property Get OnKeyPressed() As Variant
''' Get the script associated with the OnKeyPressed event
 OnKeyPressed = _PropertyGet("OnKeyPressed")
End Property ' SFDialogs.SF_Dialog.OnKeyPressed (get)

REM -----------------------------------------------------------------------------
Property Let OnKeyPressed(Optional ByVal pvOnKeyPressed As Variant)
''' Set the updatable property OnKeyPressed
 _PropertySet("OnKeyPressed", pvOnKeyPressed)
End Property ' SFDialogs.SF_Dialog.OnKeyPressed (let)

REM -----------------------------------------------------------------------------
Property Get OnKeyReleased() As Variant
''' Get the script associated with the OnKeyReleased event
 OnKeyReleased = _PropertyGet("OnKeyReleased")
End Property ' SFDialogs.SF_Dialog.OnKeyReleased (get)

REM -----------------------------------------------------------------------------
Property Let OnKeyReleased(Optional ByVal pvOnKeyReleased As Variant)
''' Set the updatable property OnKeyReleased
 _PropertySet("OnKeyReleased", pvOnKeyReleased)
End Property ' SFDialogs.SF_Dialog.OnKeyReleased (let)

REM -----------------------------------------------------------------------------
Property Get OnMouseDragged() As Variant
''' Get the script associated with the OnMouseDragged event
 OnMouseDragged = _PropertyGet("OnMouseDragged")
End Property ' SFDialogs.SF_Dialog.OnMouseDragged (get)

REM -----------------------------------------------------------------------------
Property Let OnMouseDragged(Optional ByVal pvOnMouseDragged As Variant)
''' Set the updatable property OnMouseDragged
 _PropertySet("OnMouseDragged", pvOnMouseDragged)
End Property ' SFDialogs.SF_Dialog.OnMouseDragged (let)

REM -----------------------------------------------------------------------------
Property Get OnMouseEntered() As Variant
''' Get the script associated with the OnMouseEntered event
 OnMouseEntered = _PropertyGet("OnMouseEntered")
End Property ' SFDialogs.SF_Dialog.OnMouseEntered (get)

REM -----------------------------------------------------------------------------
Property Let OnMouseEntered(Optional ByVal pvOnMouseEntered As Variant)
''' Set the updatable property OnMouseEntered
 _PropertySet("OnMouseEntered", pvOnMouseEntered)
End Property ' SFDialogs.SF_Dialog.OnMouseEntered (let)

REM -----------------------------------------------------------------------------
Property Get OnMouseExited() As Variant
''' Get the script associated with the OnMouseExited event
 OnMouseExited = _PropertyGet("OnMouseExited")
End Property ' SFDialogs.SF_Dialog.OnMouseExited (get)

REM -----------------------------------------------------------------------------
Property Let OnMouseExited(Optional ByVal pvOnMouseExited As Variant)
''' Set the updatable property OnMouseExited
 _PropertySet("OnMouseExited", pvOnMouseExited)
End Property ' SFDialogs.SF_Dialog.OnMouseExited (let)

REM -----------------------------------------------------------------------------
Property Get OnMouseMoved() As Variant
''' Get the script associated with the OnMouseMoved event
 OnMouseMoved = _PropertyGet("OnMouseMoved")
End Property ' SFDialogs.SF_Dialog.OnMouseMoved (get)

REM -----------------------------------------------------------------------------
Property Let OnMouseMoved(Optional ByVal pvOnMouseMoved As Variant)
''' Set the updatable property OnMouseMoved
 _PropertySet("OnMouseMoved", pvOnMouseMoved)
End Property ' SFDialogs.SF_Dialog.OnMouseMoved (let)

REM -----------------------------------------------------------------------------
Property Get OnMousePressed() As Variant
''' Get the script associated with the OnMousePressed event
 OnMousePressed = _PropertyGet("OnMousePressed")
End Property ' SFDialogs.SF_Dialog.OnMousePressed (get)

REM -----------------------------------------------------------------------------
Property Let OnMousePressed(Optional ByVal pvOnMousePressed As Variant)
''' Set the updatable property OnMousePressed
 _PropertySet("OnMousePressed", pvOnMousePressed)
End Property ' SFDialogs.SF_Dialog.OnMousePressed (let)

REM -----------------------------------------------------------------------------
Property Get OnMouseReleased() As Variant
''' Get the script associated with the OnMouseReleased event
 OnMouseReleased = _PropertyGet("OnMouseReleased")
End Property ' SFDialogs.SF_Dialog.OnMouseReleased (get)

REM -----------------------------------------------------------------------------
Property Let OnMouseReleased(Optional ByVal pvOnMouseReleased As Variant)
''' Set the updatable property OnMouseReleased
 _PropertySet("OnMouseReleased", pvOnMouseReleased)
End Property ' SFDialogs.SF_Dialog.OnMouseReleased (let)

REM -----------------------------------------------------------------------------
Property Get Page() As Variant
''' A dialog may have several pages that can be traversed by the user step by step.
''' The Page property of the Dialog object defines which page of the dialog is active.
''' The Page property of a control defines the page of the dialog on which the control is visible.
''' For example, if a control has a page value of 1, it is only visible on page 1 of the dialog.
''' If the page value of the dialog is increased from 1 to 2, then all controls with a page value of 1 disappear
''' and all controls with a page value of 2 become visible.
 Page = _PropertyGet("Page")
End Property ' SFDialogs.SF_Dialog.Page (get)

REM -----------------------------------------------------------------------------
Property Let Page(Optional ByVal pvPage As Variant)
''' Set the updatable property Page
 _PropertySet("Page", pvPage)
End Property ' SFDialogs.SF_Dialog.Page (let)

REM -----------------------------------------------------------------------------
Property Get Visible() As Variant
''' The Visible property is False before the Execute() statement
 Visible = _PropertyGet("Visible")
End Property ' SFDialogs.SF_Dialog.Visible (get)

REM -----------------------------------------------------------------------------
Property Let Visible(Optional ByVal pvVisible As Variant)
''' Set the updatable property Visible
 _PropertySet("Visible", pvVisible)
End Property ' SFDialogs.SF_Dialog.Visible (let)

REM -----------------------------------------------------------------------------
Property Get Width() As Variant
''' The Width property refers to the Width of the dialog box
 Width = _PropertyGet("Width")
End Property ' SFDialogs.SF_Dialog.Width (get)

REM -----------------------------------------------------------------------------
Property Let Width(Optional ByVal pvWidth As Variant)
''' Set the updatable property Width
 _PropertySet("Width", pvWidth)
End Property ' SFDialogs.SF_Dialog.Width (let)

REM -----------------------------------------------------------------------------
Property Get XDialogModel() As Object
''' The XDialogModel property returns the model UNO object of the dialog
 XDialogModel = _PropertyGet("XDialogModel")
End Property ' SFDialogs.SF_Dialog.XDialogModel (get)

REM -----------------------------------------------------------------------------
Property Get XDialogView() As Object
''' The XDialogView property returns the view UNO object of the dialog
 XDialogView = _PropertyGet("XDialogView")
End Property ' SFDialogs.SF_Dialog.XDialogView (get)

REM ===================================================================== METHODS

REM -----------------------------------------------------------------------------
Public Function Activate() As Boolean
''' Set the focus on the current dialog instance
''' Probably called from after an event occurrence or to focus on a non-modal dialog
''' Args:
''' Returns:
'''  True if focusing is successful
''' Example:
'''  Dim oDlg As Object
'''   Set oDlg = CreateScriptService(,, "myDialog") ' Dialog stored in current document's standard library
'''   oDlg.Activate()

Dim bActivate As Boolean  ' Return value
Const cstThisSub = "SFDialogs.Dialog.Activate"
Const cstSubArgs = ""

 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
 bActivate = False

Check:
 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
  If Not _IsStillAlive() Then GoTo Finally
 End If
Try:
 If Not IsNull(_DialogControl) Then
  _DialogControl.setVisible(True)
  _DialogControl.setFocus()
  bActivate = True
 End If

Finally:
 Activate = bActivate
 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
 Exit Function
Catch:
 GoTo Finally
End Function ' SFDialogs.SF_Dialog.Activate

REM -----------------------------------------------------------------------------
Public Function Center(Optional ByRef Parent As Variant) As Boolean
''' Center the actual dialog instance in the middle of a parent window
''' Without arguments, the method centers the dialog in the middle of the current window
''' Args:
'''  Parent: an object, either
'''   - a ScriptForge dialog object
'''   - a ScriptForge document (Calc, Base, ...) object
''' Returns:
'''  True when successful
''' Examples:
'''  Sub TriggerEvent(oEvent As Object)
'''  Dim oDialog1 As Object, oDialog2 As Object, lExec As Long
'''  Set oDialog1 = CreateScriptService("DialogEvent", oEvent) ' The dialog having caused the event
'''  Set oDialog2 = CreateScriptService("Dialog", ...)   ' Open a second dialog
'''  oDialog2.Center(oDialog1)
'''  lExec = oDialog2.Execute()
'''  Select Case lExec
'''   ...
'''  End Sub

Dim bCenter As Boolean    ' Return value
Dim oUi As Object     ' ScriptForge.SF_UI
Dim oObjDesc As Object    ' _ObjectDescriptor type
Dim sObjectType As String   ' Can be uno or sf object type
Dim oParent As Object    ' UNO alias of parent
Dim oParentPosSize As Object  ' Parent com.sun.star.awt.Rectangle
Dim lParentX As Long    ' X position of parent dialog
Dim lParentY As Long    ' Y position of parent dialog
Dim oPosSize As Object    ' Dialog com.sun.star.awt.Rectangle
Const cstThisSub = "SFDialogs.Dialog.Center"
Const cstSubArgs = "[Parent]"

 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
 bCenter = False

Check:
 If IsMissing(Parent) Or IsEmpty(Parent) Then Set Parent = Nothing
 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
  If Not ScriptForge.SF_Utils._Validate(Parent, "Parent", ScriptForge.V_OBJECT) Then GoTo Finally
 End If

 Set oParentPosSize = Nothing
 lParentX = 0 : lParentY = 0
 If IsNull(Parent) Then
  Set oUi = CreateScriptService("UI")
  Set oParentPosSize = oUi._PosSize() ' Return the position and dimensions of the active window
 Else
  ' Determine the object type
  Set oObjDesc = ScriptForge.SF_Utils._VarTypeObj(Parent)
  If oObjDesc.iVarType = ScriptForge.V_SFOBJECT Then  ' ScriptForge object
   sObjectType = oObjDesc.sObjectType
   ' Document or dialog ?
   If Not ScriptForge.SF_Array.Contains(Array("BASE", "CALC", "DIALOG", "DOCUMENT", "WRITER"), sObjectType, CaseSensitive := True) Then GoTo Finally
   If sObjectType = "DIALOG" Then
    Set oParent = Parent._DialogControl
    Set oParentPosSize = oParent.getPosSize()
    lParentX = oParentPosSize.X
    lParentY = oParentPosSize.Y
   Else
    Set oParent = Parent._Component.getCurrentController().Frame.getComponentWindow()
    Set oParentPosSize = oParent.getPosSize()
   End If
  Else
   GoTo Finally  ' UNO object, do nothing
  End If
 End If
 If IsNull(oParentPosSize) Then GoTo Finally

Try:
 Set oPosSize = _DialogControl.getPosSize()
 With oPosSize
  _DialogControl.setPosSize( _
     lParentX + CLng((oParentPosSize.Width - .Width) \ 2) _
     , lParentY + CLng((oParentPosSize.Height - .Height) \ 2) _
     , .Width _
     , .Height _
     , com.sun.star.awt.PosSize.POSSIZE)
 End With
 bCenter = True

Finally:
 Center = bCenter
 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
 Exit Function
Catch:
 GoTo Finally
End Function ' SF_Documents.SF_Dialog.Center

REM -----------------------------------------------------------------------------
Public Function CloneControl(Optional ByVal SourceName As Variant _
        , Optional ByVal ControlName As Variant _
        , Optional ByVal Left As Variant _
        , Optional ByVal Top As Variant _
        ) As Object
''' Duplicate an existing control of any type in the actual dialog.
''' The duplicated control is left unchanged. The new control can be relocated.
''' Specific args:
'''  SourceName: the name of the control to duplicate
'''  ControlName: the name of the new control. It must not exist yet
'''  Left, Top: the coordinates of the new control expressed in "Map AppFont" units
''' Returns:
'''  an instance of the SF_DialogControl class or Nothing
''' Example:
'''  Set myButton2 = dialog.CloneControl("Button1", "Button2", 30, 30)

Dim oControl As Object   ' Return value
Dim oSourceModel As Object  ' com.sun.star.awt.XControlModel of the source
Dim oControlModel As Object  ' com.sun.star.awt.XControlModel of the new control
Const cstThisSub = "SFDialogs.Dialog.CloneControl"
Const cstSubArgs = "SourceName, ControlName, [Left=1], [Top=1]"

Check:
 Set oControl = Nothing

 If IsMissing(Left) Or IsEmpty(Left) Then Left = 1
 If IsMissing(Top) Or IsEmpty(Top) Then Top = 1

 If Not _CheckNewControl(cstThisSub, cstSubArgs, ControlName, Place := Null) Then GoTo Finally

 If Not ScriptForge.SF_Utils._Validate(SourceName, "SourceName", V_STRING, _DialogModel.getElementNames(), True) Then GoTo Finally
 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

Try:
 ' All control types are presumed cloneable
 Set oSourceModel = _DialogModel.getByName(SourceName)
 Set oControlModel = oSourceModel.createClone()
 oControlModel.Name = ControlName

 ' Create the control
 Set oControl = _CreateNewControl(oControlModel, ControlName, Array(Left, Top))

Finally:
 Set CloneControl = oControl
 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
 Exit Function
Catch:
 GoTo Finally
End Function ' SFDialogs.SF_Dialog.CloneControl

REM -----------------------------------------------------------------------------
Public Function Controls(Optional ByVal ControlName As Variant) As Variant
''' Return either
'''  - the list of the controls contained in the dialog
'''  - a dialog control object based on its name
''' Args:
'''  ControlName: a valid control name as a case-sensitive string. If absent the list is returned
''' Returns:
'''  A zero-base array of strings if ControlName is absent
'''  An instance of the SF_DialogControl class if ControlName exists
''' Exceptions:
'''  ControlName is invalid
''' Example:
'''   Dim myDialog As Object, myList As Variant, myControl As Object
'''    Set myDialog = CreateScriptService("SFDialogs.Dialog", Container, Library, DialogName)
'''    myList = myDialog.Controls()
'''    Set myControl = myDialog.Controls("myTextBox")

Dim oControl As Object    ' The new control class instance
Dim lIndexOfNames As Long   ' Index in ElementNames array. Used to access _ControlCache
Dim vControl As Variant    ' Alias of _ControlCache entry
Const cstThisSub = "SFDialogs.Dialog.Controls"
Const cstSubArgs = "[ControlName]"

 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch

Check:
 If IsMissing(ControlName) Or IsEmpty(ControlName) Then ControlName = ""
 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
  If Not _IsStillAlive() Then GoTo Finally
  If Not ScriptForge.SF_Utils._Validate(ControlName, "ControlName", V_STRING) Then GoTo Finally
 End If

Try:
 If Len(ControlName) = 0 Then
  Controls = _DialogModel.getElementNames()
 Else
  If Not _DialogModel.hasByName(ControlName) Then GoTo CatchNotFound
  lIndexOfNames = ScriptForge.IndexOf(_DialogModel.getElementNames(), ControlName, CaseSensitive := True)
  ' Reuse cache when relevant
  vControl = _ControlCache(lIndexOfNames)
  If IsEmpty(vControl) Then
   ' Create the new dialog control class instance
   Set oControl = New SF_DialogControl
   With oControl
    ._Name = ControlName
    Set .[Me] = oControl
    Set .[_Parent] = [Me]
    ._IndexOfNames = ScriptForge.IndexOf(_DialogModel.getElementNames(), ControlName, CaseSensitive := True)
    ._DialogName = _Name
    Set ._ControlModel = _DialogModel.getByName(ControlName)
    Set ._ControlView = _DialogControl.getControl(ControlName)
    ._ControlView.setModel(._ControlModel)
    ._Initialize()
   End With
  Else
   Set oControl = vControl
  End If
  Set Controls = oControl
 End If

Finally:
 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
 Exit Function
Catch:
 GoTo Finally
CatchNotFound:
 ScriptForge.SF_Utils._Validate(ControlName, "ControlName", V_STRING, _DialogModel.getElementNames(), True)
 GoTo Finally
End Function ' SFDialogs.SF_Dialog.Controls

''' CreateXXX functions:
''' -------------------
'''  Common arguments:
'''   ControlName: the name of the new control. It must not exist yet.
'''   Place: either
'''    - an array with 4 elements: (X, Y, Width, Height)
'''    - a com.sun.star.awt.Rectangle [X, Y, Width, Height]
'''    All elements are expressed in "Map AppFont" units.

REM -----------------------------------------------------------------------------
Public Function CreateButton(Optional ByVal ControlName As Variant _
        , Optional ByRef Place As Variant _
        , Optional ByVal Toggle As Variant _
        , Optional ByVal Push As Variant _
        ) As Object
''' Create a new control of type Button in the actual dialog.
''' Specific args:
'''  Toggle: when True a Toggle button is created. Default = False
'''  Push: "OK", "CANCEL" or "" (default)
''' Returns:
'''  an instance of the SF_DialogControl class or Nothing
''' Example:
'''  Set myButton = dialog.CreateButton("Button1", Array(20, 20, 60, 15))

Dim oControl As Object   ' Return value
Dim iPush As Integer   ' Alias of Push
Dim vPropNames As Variant  ' Array of names of specific arguments
Dim vPropValues As Variant  ' Array of values of specific arguments
Const cstThisSub = "SFDialogs.Dialog.CreateButton"
Const cstSubArgs = "ControlName, Place, [Toggle=False], [Push=""""|""OK""|""CANCEL""]"

Check:
 Set oControl = Nothing
 If Not _CheckNewControl(cstThisSub, cstSubArgs, ControlName, Place) Then GoTo Finally

 If IsMissing(Toggle) Or IsEmpty(Toggle) Then Toggle = False
 If IsMissing(Push) Or IsEmpty(Push) Then Push = ""
 If Not ScriptForge.SF_Utils._Validate(Toggle, "Toggle", ScriptForge.V_BOOLEAN) Then GoTo Finally
 If Not ScriptForge.SF_Utils._Validate(Push, "Push", V_STRING, Array("", "OK", "CANCEL")) Then GoTo Finally

Try:
 ' Handle specific arguments
 Select Case UCase(Push)
  Case ""   : iPush = com.sun.star.awt.PushButtonType.STANDARD
  Case "OK"  : iPush = com.sun.star.awt.PushButtonType.OK
  Case "CANCEL" : iPush = com.sun.star.awt.PushButtonType.CANCEL
 End Select
 vPropNames = Array("Toggle", "PushButtonType")
 vPropValues = Array(CBool(Toggle), iPush)

 ' Create the control
 Set oControl = _CreateNewControl("UnoControlButtonModel", ControlName, Place, vPropNames, vPropValues)

Finally:
 Set CreateButton = oControl
 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
 Exit Function
End Function ' SFDialogs.SF_Dialog.CreateButton

REM -----------------------------------------------------------------------------
Public Function CreateCheckBox(Optional ByVal ControlName As Variant _
        , Optional ByRef Place As Variant _
        , Optional ByVal MultiLine As Variant _
        ) As Object
''' Create a new control of type CheckBox in the actual dialog.
''' Specific args:
'''  MultiLine: When True (default = False), the caption may be displayed on more than one line
''' Returns:
'''  an instance of the SF_DialogControl class or Nothing
''' Example:
'''  Set myCheckBox = dialog.CreateCheckBox("CheckBox1", Array(20, 20, 60, 15), MultiLine := True)

Dim oControl As Object   ' Return value
Dim vPropNames As Variant  ' Array of names of specific arguments
Dim vPropValues As Variant  ' Array of values of specific arguments
Const cstThisSub = "SFDialogs.Dialog.CreateCheckBox"
Const cstSubArgs = "ControlName, Place, [MultiLine=False]"

Check:
 Set oControl = Nothing
 If Not _CheckNewControl(cstThisSub, cstSubArgs, ControlName, Place) Then GoTo Finally

 If IsMissing(MultiLine) Or IsEmpty(MultiLine) Then MultiLine = False
 If Not ScriptForge.SF_Utils._Validate(MultiLine, "MultiLine", ScriptForge.V_BOOLEAN) Then GoTo Finally

Try:
 ' Manage specific properties
 vPropNames = Array("VisualEffect", "MultiLine")
 vPropValues = Array(1, CBool(MultiLine))

 ' Create the control
 Set oControl = _CreateNewControl("UnoControlCheckBoxModel", ControlName, Place, vPropNames, vPropValues)

Finally:
 Set CreateCheckBox = oControl
 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
 Exit Function
End Function ' SFDialogs.SF_Dialog.CreateCheckBox

REM -----------------------------------------------------------------------------
Public Function CreateComboBox(Optional ByVal ControlName As Variant _
        , Optional ByRef Place As Variant _
        , Optional ByVal Border As Variant _
        , Optional ByVal Dropdown As Variant _
        , Optional ByVal LineCount As Variant _
        ) As Object
''' Create a new control of type ComboBox in the actual dialog.
''' Specific args:
'''  Border: "3D" (default) or "FLAT" or "NONE"
'''  Dropdown: When True (default), a drop down button is displayed
'''  LineCount: Specifies the maximum line count displayed in the drop down (default = 5)
''' Returns:
'''  an instance of the SF_DialogControl class or Nothing
''' Example:
'''  Set myComboBox = dialog.CreateComboBox("ComboBox1", Array(20, 20, 60, 15), Dropdown := True)

Dim oControl As Object   ' Return value
Dim iBorder As Integer   ' Alias of border
Dim vPropNames As Variant  ' Array of names of specific arguments
Dim vPropValues As Variant  ' Array of values of specific arguments
Const cstThisSub = "SFDialogs.Dialog.CreateComboBox"
Const cstSubArgs = "ControlName, Place, [Border=""3D""|""FLAT""|""NONE""], [Dropdown=True], [LineCount=5]"

Check:
 Set oControl = Nothing
 If Not _CheckNewControl(cstThisSub, cstSubArgs, ControlName, Place) Then GoTo Finally

 If IsMissing(Border) Or IsEmpty(Border) Then Border = "3D"
 If IsMissing(Dropdown) Or IsEmpty(Dropdown) Then Dropdown = True
 If IsMissing(LineCount) Or IsEmpty(LineCount) Then LineCount = 5

 If Not ScriptForge.SF_Utils._Validate(Border, "Border", V_STRING, Array("3D", "FLAT", "NONE")) Then GoTo Finally
 If Not ScriptForge.SF_Utils._Validate(Dropdown, "Dropdown", ScriptForge.V_BOOLEAN) Then GoTo Finally
 If Not ScriptForge.SF_Utils._Validate(LineCount, "LineCount", ScriptForge.V_NUMERIC) Then GoTo Finally

Try:
 ' Manage specific properties
 iBorder = ScriptForge.SF_Array.IndexOf(Array("NONE", "3D", "FLAT"), Border)
 vPropNames = Array("Border", "Dropdown", "LineCount")
 vPropValues = Array(iBorder, CBool(Dropdown), CInt(LineCount))

 ' Create the control
 Set oControl = _CreateNewControl("UnoControlComboBoxModel", ControlName, Place, vPropNames, vPropValues)

Finally:
 Set CreateComboBox = oControl
 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
 Exit Function
End Function ' SFDialogs.SF_Dialog.CreateComboBox

REM -----------------------------------------------------------------------------
Public Function CreateCurrencyField(Optional ByVal ControlName As Variant _
        , Optional ByRef Place As Variant _
        , Optional ByVal Border As Variant _
        , Optional ByVal SpinButton As Variant _
        , Optional ByVal MinValue As Variant _
        , Optional ByVal MaxValue As Variant _
        , Optional ByVal Increment As Variant _
        , Optional ByVal Accuracy As Variant _
        ) As Object
''' Create a new control of type CurrencyField in the actual dialog.
''' Specific args:
'''  Border: "3D" (default) or "FLAT" or "NONE"
'''  SpinButton:: when True (default = False), a spin button is present
'''  MinValue: the smallest value that can be entered in the control. Default = -1000000
'''  MaxValue: the largest value that can be entered in the control. Default = +1000000
'''  Increment: the step when the spin button is pressed. Default = 1
'''  Accuracy: specifies the decimal accuracy. Default = 2 decimal digits
''' Returns:
'''  an instance of the SF_DialogControl class or Nothing
''' Example:
'''  Set myCurrencyField = dialog.CreateCurrencyField("CurrencyField1", Array(20, 20, 60, 15), SpinButton := True)

Dim oControl As Object   ' Return value
Dim iBorder As Integer   ' Alias of border
Dim vPropNames As Variant  ' Array of names of specific arguments
Dim vPropValues As Variant  ' Array of values of specific arguments
Const cstThisSub = "SFDialogs.Dialog.CreateCurrencyField"
Const cstSubArgs = "ControlName, Place, [Border=""3D""|""FLAT""|""NONE""], [Dropdown=False], [SpinButton=False]" _
      & ", [MinValue=-1000000], MaxValue=+1000000], [Increment=1], [Accuracy=2]"

Check:
 Set oControl = Nothing
 If Not _CheckNewControl(cstThisSub, cstSubArgs, ControlName, Place) Then GoTo Finally

 If IsMissing(Border) Or IsEmpty(Border) Then Border = "3D"
 If IsMissing(SpinButton) Or IsEmpty(SpinButton) Then SpinButton = False
 If IsMissing(MinValue) Or IsEmpty(MinValue) Then MinValue = -1000000.00
 If IsMissing(MaxValue) Or IsEmpty(MaxValue) Then MaxValue = +1000000.00
 If IsMissing(Increment) Or IsEmpty(Increment) Then Increment = 1.00
 If IsMissing(Accuracy) Or IsEmpty(Accuracy) Then Accuracy = 2
 
 If Not ScriptForge.SF_Utils._Validate(Border, "Border", V_STRING, Array("3D", "FLAT", "NONE")) Then GoTo Finally
 If Not ScriptForge.SF_Utils._Validate(SpinButton, "SpinButton", ScriptForge.V_BOOLEAN) Then GoTo Finally
 If Not ScriptForge.SF_Utils._Validate(MinValue, "MinValue", ScriptForge.V_NUMERIC) Then GoTo Finally
 If Not ScriptForge.SF_Utils._Validate(MaxValue, "MaxValue", ScriptForge.V_NUMERIC) Then GoTo Finally
 If Not ScriptForge.SF_Utils._Validate(Increment, "Increment", ScriptForge.V_NUMERIC) Then GoTo Finally
 If Not ScriptForge.SF_Utils._Validate(Accuracy, "Accuracy", ScriptForge.V_NUMERIC) Then GoTo Finally

Try:
 ' Manage specific properties
 iBorder = ScriptForge.SF_Array.IndexOf(Array("NONE", "3D", "FLAT"), Border)
 vPropNames = Array("Border", "Spin", "ValueMin", "ValueMax", "ValueStep", "DecimalAccuracy")
 vPropValues = Array(iBorder, CBool(SpinButton), CDbl(MinValue), CDbl(MaxValue), CDbl(Increment), CInt(Accuracy))

 ' Create the control
 Set oControl = _CreateNewControl("UnoControlCurrencyFieldModel", ControlName, Place, vPropNames, vPropValues)

Finally:
 Set CreateCurrencyField = oControl
 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
 Exit Function
End Function ' SFDialogs.SF_Dialog.CreateCurrencyField

REM -----------------------------------------------------------------------------
Public Function CreateDateField(Optional ByVal ControlName As Variant _
        , Optional ByRef Place As Variant _
        , Optional ByVal Border As Variant _
        , Optional ByVal Dropdown As Variant _
        , Optional ByVal MinDate As Variant _
        , Optional ByVal MaxDate As Variant _
        ) As Object
''' Create a new control of type DateField in the actual dialog.
''' Specific args:
'''  Border: "3D" (default) or "FLAT" or "NONE"
'''  Dropdown:: when True (default = False), a dropdown button is shown
'''  MinDate: the smallest date that can be entered in the control. Default = 1900-01-01
'''  MaxDate: the largest Date that can be entered in the control. Default = 2200-12-31
''' Returns:
'''  an instance of the SF_DialogControl class or Nothing
''' Example:
'''  Set myDateField = dialog.CreateDateField("DateField1", Array(20, 20, 60, 15), Dropdown := True)

Dim oControl As Object   ' Return Date
Dim iBorder As Integer   ' Alias of border
Dim oMinDate As New com.sun.star.util.Date
Dim oMaxDate As New com.sun.star.util.Date
Dim vFormats As Variant   ' List of available date formats
Dim vPropNames As Variant  ' Array of names of specific arguments
Dim vPropValues As Variant  ' Array of values of specific arguments
Const cstThisSub = "SFDialogs.Dialog.CreateDateField"
Const cstSubArgs = "ControlName, Place, [Border=""3D""|""FLAT""|""NONE""], [Dropdown=False]" _
      & ", [MinDate=DateSerial(1900, 1, 1)], [MaxDate=DateSerial(2200, 12, 31)]"

Check:
 Set oControl = Nothing
 If Not _CheckNewControl(cstThisSub, cstSubArgs, ControlName, Place) Then GoTo Finally

 If IsMissing(Border) Or IsEmpty(Border) Then Border = "3D"
 If IsMissing(Dropdown) Or IsEmpty(Dropdown) Then Dropdown = False
 If IsMissing(MinDate) Or IsEmpty(MinDate) Then MinDate = DateSerial(1900, 1, 1)
 If IsMissing(MaxDate) Or IsEmpty(MaxDate) Then MaxDate = DateSerial(2200, 12, 31)
 
 If Not ScriptForge.SF_Utils._Validate(Border, "Border", V_STRING, Array("3D", "FLAT", "NONE")) Then GoTo Finally
 If Not ScriptForge.SF_Utils._Validate(Dropdown, "Dropdown", ScriptForge.V_BOOLEAN) Then GoTo Finally
 If Not ScriptForge.SF_Utils._Validate(MinDate, "MinDate", ScriptForge.V_DATE) Then GoTo Finally
 If Not ScriptForge.SF_Utils._Validate(MaxDate, "MaxDate", ScriptForge.V_DATE) Then GoTo Finally
 vFormats = SF_DialogUtils._FormatsList("DateField")

Try:
 ' Manage specific properties
 iBorder = ScriptForge.SF_Array.IndexOf(Array("NONE", "3D", "FLAT"), Border)
 With oMinDate
  .Year = Year(MinDate) : .Month = Month(MinDate) : .Day = Day(MinDate)
 End With
 With oMaxDate
  .Year = Year(MaxDate) : .Month = Month(MaxDate) : .Day = Day(MaxDate)
 End With
 vPropNames = Array("Border", "Dropdown", "DateMin", "DateMax", "DateFormat")
 vPropValues = Array(iBorder, CBool(Dropdown), oMinDate, oMaxDate, CInt(ScriptForge.SF_Array.IndexOf(vFormats(), "Standard (short)")))

 ' Create the control
 Set oControl = _CreateNewControl("UnoControlDateFieldModel", ControlName, Place, vPropNames, vPropValues)

Finally:
 Set CreateDateField = oControl
 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
 Exit Function
End Function ' SFDialogs.SF_Dialog.CreateDateField

REM -----------------------------------------------------------------------------
Public Function CreateFileControl(Optional ByVal ControlName As Variant _
        , Optional ByRef Place As Variant _
        , Optional ByVal Border As Variant _
        ) As Object
''' Create a new control of type FileControl in the actual dialog.
''' Specific args:
'''  Border: "3D" (default) or "FLAT" or "NONE"
''' Returns:
'''  an instance of the SF_DialogControl class or Nothing
''' Example:
'''  Set myFileControl = dialog.CreateFileControl("FileControl1", Array(20, 20, 60, 15))

Dim oControl As Object   ' Return value
Dim iBorder As Integer   ' Alias of border
Dim vPropNames As Variant  ' Array of names of specific arguments
Dim vPropValues As Variant  ' Array of values of specific arguments
Const cstThisSub = "SFDialogs.Dialog.CreateFileControl"
Const cstSubArgs = "ControlName, Place, [Border=""3D""|""FLAT""|""NONE""]"

Check:
 Set oControl = Nothing
 If Not _CheckNewControl(cstThisSub, cstSubArgs, ControlName, Place) Then GoTo Finally

 If IsMissing(Border) Or IsEmpty(Border) Then Border = "3D"
 If Not ScriptForge.SF_Utils._Validate(Border, "Border", V_STRING, Array("3D", "FLAT", "NONE")) Then GoTo Finally

Try:
 ' Manage specific properties
 iBorder = ScriptForge.SF_Array.IndexOf(Array("NONE", "3D", "FLAT"), Border)
 vPropNames = Array("Border")
 vPropValues = Array(iBorder)

 ' Create the control
 Set oControl = _CreateNewControl("UnoControlFileControlModel", ControlName, Place, vPropNames, vPropValues)

Finally:
 Set CreateFileControl = oControl
 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
 Exit Function
Catch:
 GoTo Finally
End Function ' SFDialogs.SF_Dialog.CreateFileControl

REM -----------------------------------------------------------------------------
Public Function CreateFixedLine(Optional ByVal ControlName As Variant _
        , Optional ByRef Place As Variant _
        , Optional ByVal Orientation As Variant _
        ) As Object
''' Create a new control of type FixedLine in the actual dialog.
''' Specific args:
'''  Orientation: "H[orizontal]" or "V[ertical]".
''' Returns:
'''  an instance of the SF_DialogControl class or Nothing
''' Example:
'''  Set myFixedLine = dialog.CreateFixedLine("FixedLine1", Array(20, 20, 60, 15), Orientation := "vertical")

Dim oControl As Object   ' Return value
Dim vPropNames As Variant  ' Array of names of specific arguments
Dim vPropValues As Variant  ' Array of values of specific arguments
Const cstThisSub = "SFDialogs.Dialog.CreateFixedLine"
Const cstSubArgs = "ControlName, Place, Orientation=""H""|""Horizontal""|""V""|""Vertical"""

Check:
 Set oControl = Nothing
 If Not _CheckNewControl(cstThisSub, cstSubArgs, ControlName, Place) Then GoTo Finally

 If Not ScriptForge.SF_Utils._Validate(Orientation, "Orientation", V_STRING, Array("H", "Horizontal", "V", "Vertical")) Then GoTo Finally

Try:
 ' Manage specific properties
 vPropNames = Array("Orientation")
 vPropValues = Array(CLng(Iif(Left(UCase(Orientation), 1) = "V", 1, 0)))

 ' Create the control
 Set oControl = _CreateNewControl("UnoControlFixedLineModel", ControlName, Place, vPropNames, vPropValues)

Finally:
 Set CreateFixedLine = oControl
 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
 Exit Function
End Function ' SFDialogs.SF_Dialog.CreateFixedLine

REM -----------------------------------------------------------------------------
Public Function CreateFixedText(Optional ByVal ControlName As Variant _
        , Optional ByRef Place As Variant _
        , Optional ByVal Border As Variant _
        , Optional ByVal MultiLine As Variant _
        , Optional ByVal Align As Variant _
        , Optional ByVal VerticalAlign As Variant _
        ) As Object
''' Create a new control of type FixedText in the actual dialog.
''' Specific args:
'''  Border: "NONE" (default) or "FLAT" or "3D"
'''  MultiLine: When True (default = False), the caption may be displayed on more than one line
'''  Align: horizontal alignment, "LEFT" (default) or "CENTER" or "RIGHT"
'''  VerticalAlign: vertical alignment, "TOP" (default) or "MIDDLE" or "BOTTOM"
''' Returns:
'''  an instance of the SF_DialogControl class or Nothing
''' Example:
'''  Set myFixedText = dialog.CreateFixedText("FixedText1", Array(20, 20, 60, 15), MultiLine := True)

Dim oControl As Object   ' Return value
Dim iBorder As Integer   ' Alias of border
Dim iAlign As Integer   ' Alias of Align
Dim iVerticalAlign As Integer ' Alias of VerticalAlign
Dim vPropNames As Variant  ' Array of names of specific arguments
Dim vPropValues As Variant  ' Array of values of specific arguments
Const cstThisSub = "SFDialogs.Dialog.CreateFixedText"
Const cstSubArgs = "ControlName, Place, [MultiLine=False], [Border=""NONE""|""FLAT""|""3D""]" _
      & ", [Align=""LEFT""|""CENTER""|""RIGHT""], [VerticalAlign=""TOP""|""MIDDLE""|""BOTTOM""]"

Check:
 Set oControl = Nothing
 If Not _CheckNewControl(cstThisSub, cstSubArgs, ControlName, Place) Then GoTo Finally

 If IsMissing(Border) Or IsEmpty(Border) Then Border = "NONE"
 If IsMissing(MultiLine) Or IsEmpty(MultiLine) Then MultiLine = False
 If IsMissing(Align) Or IsEmpty(Align) Then Align = "LEFT"
 If IsMissing(VerticalAlign) Or IsEmpty(VerticalAlign) Then VerticalAlign = "TOP"

 If Not ScriptForge.SF_Utils._Validate(Border, "Border", V_STRING, Array("3D", "FLAT", "NONE")) Then GoTo Finally
 If Not ScriptForge.SF_Utils._Validate(MultiLine, "MultiLine", ScriptForge.V_BOOLEAN) Then GoTo Finally
 If Not ScriptForge.SF_Utils._Validate(Align, "Align", V_STRING, Array("LEFT", "CENTER", "RIGHT")) Then GoTo Finally
 If Not ScriptForge.SF_Utils._Validate(VerticalAlign, "VerticalAlign", V_STRING, Array("TOP", "MIDDLE", "BOTTOM")) Then GoTo Finally

Try:
 ' Manage specific properties
 iBorder = ScriptForge.SF_Array.IndexOf(Array("NONE", "3D", "FLAT"), Border)
 iAlign = ScriptForge.SF_Array.IndexOf(Array("LEFT", "CENTER", "BOTTOM"), Align)
 Select Case UCase(VerticalAlign)
  Case "TOP"  : iVerticalAlign = com.sun.star.style.VerticalAlignment.TOP
  Case "MIDDLE" : iVerticalAlign = com.sun.star.style.VerticalAlignment.MIDDLE
  Case "BOTTOM" : iVerticalAlign = com.sun.star.style.VerticalAlignment.BOTTOM
 End Select
 vPropNames = Array("Border", "MultiLine", "Align", "VerticalAlign")
 vPropValues = Array(iBorder, CBool(MultiLine), iAlign, iVerticalAlign)

 ' Create the control
 Set oControl = _CreateNewControl("UnoControlFixedTextModel", ControlName, Place, vPropNames, vPropValues)

Finally:
 Set CreateFixedText = oControl
 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
 Exit Function
End Function ' SFDialogs.SF_Dialog.CreateFixedText

REM -----------------------------------------------------------------------------
Public Function CreateFormattedField(Optional ByVal ControlName As Variant _
        , Optional ByRef Place As Variant _
        , Optional ByVal Border As Variant _
        , Optional ByVal SpinButton As Variant _
        , Optional ByVal MinValue As Variant _
        , Optional ByVal MaxValue As Variant _
        ) As Object
''' Create a new control of type FormattedField in the actual dialog.
''' Specific args:
'''  Border: "3D" (default) or "FLAT" or "NONE"
'''  SpinButton:: when True (default = False), a spin button is present
'''  MinValue: the smallest value that can be entered in the control. Default = -1000000
'''  MaxValue: the largest value that can be entered in the control. Default = +1000000
''' Returns:
'''  an instance of the SF_DialogControl class or Nothing
''' Example:
'''  Set myFormattedField = dialog.CreateFormattedField("FormattedField1", Array(20, 20, 60, 15), SpinButton := True)
'''  myFormattedField.Format = "##0,00E+00"

Dim oControl As Object   ' Return value
Dim iBorder As Integer   ' Alias of border
Dim vPropNames As Variant  ' Array of names of specific arguments
Dim vPropValues As Variant  ' Array of values of specific arguments
Const cstThisSub = "SFDialogs.Dialog.CreateFormattedField"
Const cstSubArgs = "ControlName, Place, [Border=""3D""|""FLAT""|""NONE""], [SpinButton=False]" _
      & ", [MinValue=-1000000], MaxValue=+1000000]"

Check:
 Set oControl = Nothing
 If Not _CheckNewControl(cstThisSub, cstSubArgs, ControlName, Place) Then GoTo Finally

 If IsMissing(Border) Or IsEmpty(Border) Then Border = "3D"
 If IsMissing(SpinButton) Or IsEmpty(SpinButton) Then SpinButton = False
 If IsMissing(MinValue) Or IsEmpty(MinValue) Then MinValue = -1000000.00
 If IsMissing(MaxValue) Or IsEmpty(MaxValue) Then MaxValue = +1000000.00
 
 If Not ScriptForge.SF_Utils._Validate(Border, "Border", V_STRING, Array("3D", "FLAT", "NONE")) Then GoTo Finally
 If Not ScriptForge.SF_Utils._Validate(SpinButton, "SpinButton", ScriptForge.V_BOOLEAN) Then GoTo Finally
 If Not ScriptForge.SF_Utils._Validate(MinValue, "MinValue", ScriptForge.V_NUMERIC) Then GoTo Finally
 If Not ScriptForge.SF_Utils._Validate(MaxValue, "MaxValue", ScriptForge.V_NUMERIC) Then GoTo Finally

Try:
 ' Manage specific properties
 iBorder = ScriptForge.SF_Array.IndexOf(Array("NONE", "3D", "FLAT"), Border)
 vPropNames = Array("FormatsSupplier", "Border", "Spin", "EffectiveMin", "EffectiveMax")
 vPropValues = Array(CreateUnoService("com.sun.star.util.NumberFormatsSupplier") _
      , iBorder, CBool(SpinButton), CDbl(MinValue), CDbl(MaxValue))

 ' Create the control
 Set oControl = _CreateNewControl("UnoControlFormattedFieldModel", ControlName, Place, vPropNames, vPropValues)

Finally:
 Set CreateFormattedField = oControl
 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
 Exit Function
Catch:
 GoTo Finally
End Function ' SFDialogs.SF_Dialog.CreateFormattedField

REM -----------------------------------------------------------------------------
Public Function CreateGroupBox(Optional ByVal ControlName As Variant _
        , Optional ByRef Place As Variant _
        ) As Object
''' Create a new control of type GroupBox in the actual dialog.
''' Specific args:
'''  Orientation: "H[orizontal]" or "V[ertical]"
''' Returns:
'''  an instance of the SF_DialogControl class or Nothing
''' Example:
'''  Set myGroupBox = dialog.CreateGroupBox("GroupBox1", Array(20, 20, 60, 15))

Dim oControl As Object   ' Return value
Dim vPropNames As Variant  ' Array of names of specific arguments
Dim vPropValues As Variant  ' Array of values of specific arguments
Const cstThisSub = "SFDialogs.Dialog.CreateGroupBox"
Const cstSubArgs = "ControlName, Place"

Check:
 Set oControl = Nothing
 If Not _CheckNewControl(cstThisSub, cstSubArgs, ControlName, Place) Then GoTo Finally

Try:
 ' Manage specific properties
 vPropNames = Array()
 vPropValues = Array()

 ' Create the control
 Set oControl = _CreateNewControl("UnoControlGroupBoxModel", ControlName, Place, vPropNames, vPropValues)

Finally:
 Set CreateGroupBox = oControl
 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
 Exit Function
Catch:
 GoTo Finally
End Function ' SFDialogs.SF_Dialog.CreateGroupBox

REM -----------------------------------------------------------------------------
Public Function CreateHyperlink(Optional ByVal ControlName As Variant _
        , Optional ByRef Place As Variant _
        , Optional ByVal Border As Variant _
        , Optional ByVal MultiLine As Variant _
        , Optional ByVal Align As Variant _
        , Optional ByVal VerticalAlign As Variant _
        ) As Object
''' Create a new control of type Hyperlink in the actual dialog.
''' Specific args:
'''  Border: "NONE" (default) or "FLAT" or "3D"
'''  MultiLine: When True (default = False), the caption may be displayed on more than one line
'''  Align: horizontal alignment, "LEFT" (default) or "CENTER" or "RIGHT"
'''  VerticalAlign: vertical alignment, "TOP" (default) or "MIDDLE" or "BOTTOM"
''' Returns:
'''  an instance of the SF_DialogControl class or Nothing
''' Example:
'''  Set myHyperlink = dialog.CreateHyperlink("Hyperlink1", Array(20, 20, 60, 15), MultiLine := True)

Dim oControl As Object   ' Return value
Dim iBorder As Integer   ' Alias of border
Dim iAlign As Integer   ' Alias of Align
Dim iVerticalAlign As Integer ' Alias of VerticalAlign
Dim vPropNames As Variant  ' Array of names of specific arguments
Dim vPropValues As Variant  ' Array of values of specific arguments
Const cstThisSub = "SFDialogs.Dialog.CreateHyperlink"
Const cstSubArgs = "ControlName, Place, [MultiLine=False], [Border=""NONE""|""FLAT""|""3D""]" _
      & ", [Align=""LEFT""|""CENTER""|""RIGHT""], [VerticalAlign=""TOP""|""MIDDLE""|""BOTTOM""]"

Check:
 Set oControl = Nothing
 If Not _CheckNewControl(cstThisSub, cstSubArgs, ControlName, Place) Then GoTo Finally

 If IsMissing(Border) Or IsEmpty(Border) Then Border = "NONE"
 If IsMissing(MultiLine) Or IsEmpty(MultiLine) Then MultiLine = False
--> --------------------

--> maximum size reached

--> --------------------

[ zur Elbe Produktseite wechseln0.89Quellennavigators  ]