diff options
author | Jean-Pierre Ledure <jp@ledure.be> | 2023-05-18 13:01:52 +0200 |
---|---|---|
committer | Jean-Pierre Ledure <jp@ledure.be> | 2023-05-20 12:56:41 +0200 |
commit | f692b5c5e4e9c57fb69d0054c654486a737d19bd (patch) | |
tree | 316c5b0fd1b48ae6c997e5a706d9611a24268ec5 /wizards/source/sfdialogs | |
parent | 82816547ccda994acfa6ec63a98f561f615efcfa (diff) |
ScriptForge New method dialog.CreateHyperlink()
Method (Dialog service)
CreateHyperlink(controlname, place, border, multiline,
align, verticalalign)
completes the set of available methods for
dynamic DialogControl creation.
Cfr. https://gerrit.libreoffice.org/c/core/+/151896
Change-Id: I162075ea39efdd2e1189fe8b16ac05316e6a13ff
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151954
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Diffstat (limited to 'wizards/source/sfdialogs')
-rw-r--r-- | wizards/source/sfdialogs/SF_Dialog.xba | 71 | ||||
-rw-r--r-- | wizards/source/sfdialogs/SF_DialogControl.xba | 2 |
2 files changed, 69 insertions, 4 deletions
diff --git a/wizards/source/sfdialogs/SF_Dialog.xba b/wizards/source/sfdialogs/SF_Dialog.xba index b50e22aebeb3..20f1e81dc650 100644 --- a/wizards/source/sfdialogs/SF_Dialog.xba +++ b/wizards/source/sfdialogs/SF_Dialog.xba @@ -1142,6 +1142,70 @@ Catch: 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 + 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("UnoControlFixedHyperlinkModel", ControlName, Place, vPropNames, vPropValues) + +Finally: + Set CreateHyperlink = oControl + ScriptForge.SF_Utils._ExitFunction(cstThisSub) + Exit Function +End Function ' SFDialogs.SF_Dialog.CreateHyperlink + +REM ----------------------------------------------------------------------------- Public Function CreateImageControl(Optional ByVal ControlName As Variant _ , Optional ByRef Place As Variant _ , Optional ByVal Border As Variant _ @@ -1528,8 +1592,8 @@ Public Function CreateTableControl(Optional ByVal ControlName As Variant _ ''' To fill the table with data, use the SetTableData() method ''' Specific args: ''' Border: "3D" (default) or "FLAT" or "NONE" -''' RowHeaders: when True (default), the row Headers are shown -''' ColumnHeaders: when True (default), the column Headers are shown +''' RowHeaders: when True (default), the row headers are shown +''' ColumnHeaders: when True (default), the column headers are shown ''' ScrollBars: H[orizontal] or V[ertical] or B[oth] or N[one] (default) ''' Note that scrollbars always appear dynamically when they are needed ''' GridLines: when True (default = False) horizontal and vertical lines are painted between the grid cells @@ -1989,6 +2053,7 @@ Public Function Methods() As Variant , "CreateFixedText" _ , "CreateFormattedField" _ , "CreateGroupBox" _ + , "CreateHyperlink" _ , "CreateImageControl" _ , "CreateListBox" _ , "CreateNumericField" _ @@ -2878,4 +2943,4 @@ Private Function _Repr() As String End Function ' SFDialogs.SF_Dialog._Repr REM ============================================ END OF SFDIALOGS.SF_DIALOG -</script:module> +</script:module>
\ No newline at end of file diff --git a/wizards/source/sfdialogs/SF_DialogControl.xba b/wizards/source/sfdialogs/SF_DialogControl.xba index 133d942a8c32..2cef9ad5e7ef 100644 --- a/wizards/source/sfdialogs/SF_DialogControl.xba +++ b/wizards/source/sfdialogs/SF_DialogControl.xba @@ -2512,4 +2512,4 @@ Private Function _Repr() As String End Function ' SFDialogs.SF_DialogControl._Repr REM ============================================ END OF SFDIALOGS.SF_DIALOGCONTROL -</script:module> +</script:module>
\ No newline at end of file |