SF_DialogControl.xba 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
  3. <script:module xmlns:script="http://openoffice.org/2000/script" script:name="SF_DialogControl" script:language="StarBasic" script:moduleType="normal">REM =======================================================================================================================
  4. REM === The ScriptForge library and its associated libraries are part of the LibreOffice project. ===
  5. REM === The SFDialogs library is one of the associated libraries. ===
  6. REM === Full documentation is available on https://help.libreoffice.org/ ===
  7. REM =======================================================================================================================
  8. Option Compatible
  9. Option ClassModule
  10. Option Explicit
  11. &apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;
  12. &apos;&apos;&apos; SF_DialogControl
  13. &apos;&apos;&apos; ================
  14. &apos;&apos;&apos; Manage the controls belonging to a dialog defined with the Basic IDE
  15. &apos;&apos;&apos; Each instance of the current class represents a single control within a dialog box
  16. &apos;&apos;&apos;
  17. &apos;&apos;&apos; The focus is clearly set on getting and setting the values displayed by the controls of the dialog box,
  18. &apos;&apos;&apos; not on their formatting. The latter is easily accessible via the XControlModel and XControlView
  19. &apos;&apos;&apos; UNO objects.
  20. &apos;&apos;&apos; Essentially a single property &quot;Value&quot; maps many alternative UNO properties depending each on
  21. &apos;&apos;&apos; the control type.
  22. &apos;&apos;&apos;
  23. &apos;&apos;&apos; Service invocation:
  24. &apos;&apos;&apos; Dim myDialog As Object, myControl As Object
  25. &apos;&apos;&apos; Set myDialog = CreateScriptService(&quot;SFDialogs.Dialog&quot;, &quot;GlobalScope&quot;, myLibrary, DialogName)
  26. &apos;&apos;&apos; Set myControl = myDialog.Controls(&quot;myTextBox&quot;)
  27. &apos;&apos;&apos; myControl.Value = &quot;Dialog started at &quot; &amp; Now()
  28. &apos;&apos;&apos; myDialog.Execute()
  29. &apos;&apos;&apos; &apos; ... process the controls actual values
  30. &apos;&apos;&apos; myDialog.Terminate()
  31. &apos;&apos;&apos;
  32. &apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;
  33. REM ================================================================== EXCEPTIONS
  34. Private Const CONTROLTYPEERROR = &quot;CONTROLTYPEERROR&quot;
  35. Private Const TEXTFIELDERROR = &quot;TEXTFIELDERROR&quot;
  36. REM ============================================================= PRIVATE MEMBERS
  37. Private [Me] As Object
  38. Private [_Parent] As Object
  39. Private ObjectType As String &apos; Must be DIALOGCONTROL
  40. Private ServiceName As String
  41. &apos; Control naming
  42. Private _Name As String
  43. Private _DialogName As String &apos; Parent dialog name
  44. &apos; Control UNO references
  45. Private _ControlModel As Object &apos; com.sun.star.awt.XControlModel
  46. Private _ControlView As Object &apos; com.sun.star.awt.XControl - stardiv.Toolkit.UnoDialogControl
  47. &apos; Control attributes
  48. Private _ImplementationName As String
  49. Private _ControlType As String &apos; One of the CTLxxx constants
  50. REM ============================================================ MODULE CONSTANTS
  51. Private Const CTLBUTTON = &quot;Button&quot;
  52. Private Const CTLCHECKBOX = &quot;CheckBox&quot;
  53. Private Const CTLCOMBOBOX = &quot;ComboBox&quot;
  54. Private Const CTLCURRENCYFIELD = &quot;CurrencyField&quot;
  55. Private Const CTLDATEFIELD = &quot;DateField&quot;
  56. Private Const CTLFILECONTROL = &quot;FileControl&quot;
  57. Private Const CTLFIXEDLINE = &quot;FixedLine&quot;
  58. Private Const CTLFIXEDTEXT = &quot;FixedText&quot;
  59. Private Const CTLFORMATTEDFIELD = &quot;FormattedField&quot;
  60. Private Const CTLGROUPBOX = &quot;GroupBox&quot;
  61. Private Const CTLIMAGECONTROL = &quot;ImageControl&quot;
  62. Private Const CTLLISTBOX = &quot;ListBox&quot;
  63. Private Const CTLNUMERICFIELD = &quot;NumericField&quot;
  64. Private Const CTLPATTERNFIELD = &quot;PatternField&quot;
  65. Private Const CTLPROGRESSBAR = &quot;ProgressBar&quot;
  66. Private Const CTLRADIOBUTTON = &quot;RadioButton&quot;
  67. Private Const CTLSCROLLBAR = &quot;ScrollBar&quot;
  68. Private Const CTLTEXTFIELD = &quot;TextField&quot;
  69. Private Const CTLTIMEFIELD = &quot;TimeField&quot;
  70. REM ===================================================== CONSTRUCTOR/DESTRUCTOR
  71. REM -----------------------------------------------------------------------------
  72. Private Sub Class_Initialize()
  73. Set [Me] = Nothing
  74. Set [_Parent] = Nothing
  75. ObjectType = &quot;DIALOGCONTROL&quot;
  76. ServiceName = &quot;SFDialogs.DialogControl&quot;
  77. _Name = &quot;&quot;
  78. _DialogName = &quot;&quot;
  79. Set _ControlModel = Nothing
  80. Set _ControlView = Nothing
  81. _ImplementationName = &quot;&quot;
  82. _ControlType = &quot;&quot;
  83. End Sub &apos; SFDialogs.SF_DialogControl Constructor
  84. REM -----------------------------------------------------------------------------
  85. Private Sub Class_Terminate()
  86. Call Class_Initialize()
  87. End Sub &apos; SFDialogs.SF_DialogControl Destructor
  88. REM -----------------------------------------------------------------------------
  89. Public Function Dispose() As Variant
  90. Call Class_Terminate()
  91. Set Dispose = Nothing
  92. End Function &apos; SFDialogs.SF_DialogControl Explicit Destructor
  93. REM ================================================================== PROPERTIES
  94. REM -----------------------------------------------------------------------------
  95. Property Get Cancel() As Variant
  96. &apos;&apos;&apos; The Cancel property specifies if a command button has or not the behaviour of a Cancel button.
  97. Cancel = _PropertyGet(&quot;Cancel&quot;, False)
  98. End Property &apos; SFDialogs.SF_DialogControl.Cancel (get)
  99. REM -----------------------------------------------------------------------------
  100. Property Let Cancel(Optional ByVal pvCancel As Variant)
  101. &apos;&apos;&apos; Set the updatable property Cancel
  102. _PropertySet(&quot;Cancel&quot;, pvCancel)
  103. End Property &apos; SFDialogs.SF_DialogControl.Cancel (let)
  104. REM -----------------------------------------------------------------------------
  105. Property Get Caption() As Variant
  106. &apos;&apos;&apos; The Caption property refers to the text associated with the control
  107. Caption = _PropertyGet(&quot;Caption&quot;, &quot;&quot;)
  108. End Property &apos; SFDialogs.SF_DialogControl.Caption (get)
  109. REM -----------------------------------------------------------------------------
  110. Property Let Caption(Optional ByVal pvCaption As Variant)
  111. &apos;&apos;&apos; Set the updatable property Caption
  112. _PropertySet(&quot;Caption&quot;, pvCaption)
  113. End Property &apos; SFDialogs.SF_DialogControl.Caption (let)
  114. REM -----------------------------------------------------------------------------
  115. Property Get ControlType() As String
  116. &apos;&apos;&apos; Return the type of the actual control: &quot;CheckBox&quot;, &quot;TextField&quot;, &quot;DateField&quot;, ...
  117. ControlType = _PropertyGet(&quot;ControlType&quot;)
  118. End Property &apos; SFDialogs.SF_DialogControl.ControlType
  119. REM -----------------------------------------------------------------------------
  120. Property Get Default() As Variant
  121. &apos;&apos;&apos; The Default property specifies whether a command button is the default (OK) button.
  122. Default = _PropertyGet(&quot;Default&quot;, False)
  123. End Property &apos; SFDialogs.SF_DialogControl.Default (get)
  124. REM -----------------------------------------------------------------------------
  125. Property Let Default(Optional ByVal pvDefault As Variant)
  126. &apos;&apos;&apos; Set the updatable property Default
  127. _PropertySet(&quot;Default&quot;, pvDefault)
  128. End Property &apos; SFDialogs.SF_DialogControl.Default (let)
  129. REM -----------------------------------------------------------------------------
  130. Property Get Enabled() As Variant
  131. &apos;&apos;&apos; The Enabled property specifies if the control is accessible with the cursor.
  132. Enabled = _PropertyGet(&quot;Enabled&quot;)
  133. End Property &apos; SFDialogs.SF_DialogControl.Enabled (get)
  134. REM -----------------------------------------------------------------------------
  135. Property Let Enabled(Optional ByVal pvEnabled As Variant)
  136. &apos;&apos;&apos; Set the updatable property Enabled
  137. _PropertySet(&quot;Enabled&quot;, pvEnabled)
  138. End Property &apos; SFDialogs.SF_DialogControl.Enabled (let)
  139. REM -----------------------------------------------------------------------------
  140. Property Get Format() As Variant
  141. &apos;&apos;&apos; The Format property specifies the format in which to display dates and times.
  142. Format = _PropertyGet(&quot;Format&quot;, &quot;&quot;)
  143. End Property &apos; SFDialogs.SF_DialogControl.Format (get)
  144. REM -----------------------------------------------------------------------------
  145. Property Let Format(Optional ByVal pvFormat As Variant)
  146. &apos;&apos;&apos; Set the updatable property Format
  147. &apos;&apos;&apos; NB: Format is read-only for formatted field controls
  148. _PropertySet(&quot;Format&quot;, pvFormat)
  149. End Property &apos; SFDialogs.SF_DialogControl.Format (let)
  150. REM -----------------------------------------------------------------------------
  151. Property Get ListCount() As Long
  152. &apos;&apos;&apos; The ListCount property specifies the number of rows in a list box or a combo box
  153. ListCount = _PropertyGet(&quot;ListCount&quot;, 0)
  154. End Property &apos; SFDialogs.SF_DialogControl.ListCount (get)
  155. REM -----------------------------------------------------------------------------
  156. Property Get ListIndex() As Variant
  157. &apos;&apos;&apos; The ListIndex property specifies which item is selected in a list box or combo box.
  158. &apos;&apos;&apos; In case of multiple selection, the index of the first one is returned or only one is set
  159. ListIndex = _PropertyGet(&quot;ListIndex&quot;, -1)
  160. End Property &apos; SFDialogs.SF_DialogControl.ListIndex (get)
  161. REM -----------------------------------------------------------------------------
  162. Property Let ListIndex(Optional ByVal pvListIndex As Variant)
  163. &apos;&apos;&apos; Set the updatable property ListIndex
  164. _PropertySet(&quot;ListIndex&quot;, pvListIndex)
  165. End Property &apos; SFDialogs.SF_DialogControl.ListIndex (let)
  166. REM -----------------------------------------------------------------------------
  167. Property Get Locked() As Variant
  168. &apos;&apos;&apos; The Locked property specifies if a control is read-only
  169. Locked = _PropertyGet(&quot;Locked&quot;, False)
  170. End Property &apos; SFDialogs.SF_DialogControl.Locked (get)
  171. REM -----------------------------------------------------------------------------
  172. Property Let Locked(Optional ByVal pvLocked As Variant)
  173. &apos;&apos;&apos; Set the updatable property Locked
  174. _PropertySet(&quot;Locked&quot;, pvLocked)
  175. End Property &apos; SFDialogs.SF_DialogControl.Locked (let)
  176. REM -----------------------------------------------------------------------------
  177. Property Get MultiSelect() As Variant
  178. &apos;&apos;&apos; The MultiSelect property specifies whether a user can make multiple selections in a listbox
  179. MultiSelect = _PropertyGet(&quot;MultiSelect&quot;, False)
  180. End Property &apos; SFDialogs.SF_DialogControl.MultiSelect (get)
  181. REM -----------------------------------------------------------------------------
  182. Property Let MultiSelect(Optional ByVal pvMultiSelect As Variant)
  183. &apos;&apos;&apos; Set the updatable property MultiSelect
  184. _PropertySet(&quot;MultiSelect&quot;, pvMultiSelect)
  185. End Property &apos; SFDialogs.SF_DialogControl.MultiSelect (let)
  186. REM -----------------------------------------------------------------------------
  187. Property Get Name() As String
  188. &apos;&apos;&apos; Return the name of the actual control
  189. Name = _PropertyGet(&quot;Name&quot;)
  190. End Property &apos; SFDialogs.SF_DialogControl.Name
  191. REM -----------------------------------------------------------------------------
  192. Property Get Page() As Variant
  193. &apos;&apos;&apos; 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.
  194. &apos;&apos;&apos; The Page property of a control defines the page of the dialog on which the control is visible.
  195. &apos;&apos;&apos; For example, if a control has a page value of 1, it is only visible on page 1 of the dialog.
  196. &apos;&apos;&apos; 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.
  197. Page = _PropertyGet(&quot;Page&quot;)
  198. End Property &apos; SFDialogs.SF_DialogControl.Page (get)
  199. REM -----------------------------------------------------------------------------
  200. Property Let Page(Optional ByVal pvPage As Variant)
  201. &apos;&apos;&apos; Set the updatable property Page
  202. _PropertySet(&quot;Page&quot;, pvPage)
  203. End Property &apos; SFDialogs.SF_DialogControl.Page (let)
  204. REM -----------------------------------------------------------------------------
  205. Property Get Parent() As Object
  206. &apos;&apos;&apos; Return the Parent dialog object of the actual control
  207. Parent = _PropertyGet(&quot;Parent&quot;, Nothing)
  208. End Property &apos; SFDialogs.SF_DialogControl.Parent
  209. REM -----------------------------------------------------------------------------
  210. Property Get Picture() As Variant
  211. &apos;&apos;&apos; The Picture property specifies a bitmap or other type of graphic to be displayed on the specified control
  212. Picture = _PropertyGet(&quot;Picture&quot;, &quot;&quot;)
  213. End Property &apos; SFDialogs.SF_DialogControl.Picture (get)
  214. REM -----------------------------------------------------------------------------
  215. Property Let Picture(Optional ByVal pvPicture As Variant)
  216. &apos;&apos;&apos; Set the updatable property Picture
  217. _PropertySet(&quot;Picture&quot;, pvPicture)
  218. End Property &apos; SFDialogs.SF_DialogControl.Picture (let)
  219. REM -----------------------------------------------------------------------------
  220. Property Get RowSource() As Variant
  221. &apos;&apos;&apos; The RowSource property specifies the data contained in a combobox or a listbox
  222. &apos;&apos;&apos; as a zero-based array of string values
  223. RowSource = _PropertyGet(&quot;RowSource&quot;, &quot;&quot;)
  224. End Property &apos; SFDialogs.SF_DialogControl.RowSource (get)
  225. REM -----------------------------------------------------------------------------
  226. Property Let RowSource(Optional ByVal pvRowSource As Variant)
  227. &apos;&apos;&apos; Set the updatable property RowSource
  228. _PropertySet(&quot;RowSource&quot;, pvRowSource)
  229. End Property &apos; SFDialogs.SF_DialogControl.RowSource (let)
  230. REM -----------------------------------------------------------------------------
  231. Property Get Text() As Variant
  232. &apos;&apos;&apos; The Text property specifies the actual content of the control like it is displayed on the screen
  233. Text = _PropertyGet(&quot;Text&quot;, &quot;&quot;)
  234. End Property &apos; SFDialogs.SF_DialogControl.Text (get)
  235. REM -----------------------------------------------------------------------------
  236. Property Get TipText() As Variant
  237. &apos;&apos;&apos; The TipText property specifies the text that appears in a screentip when you hold the mouse pointer over a control
  238. TipText = _PropertyGet(&quot;TipText&quot;, &quot;&quot;)
  239. End Property &apos; SFDialogs.SF_DialogControl.TipText (get)
  240. REM -----------------------------------------------------------------------------
  241. Property Let TipText(Optional ByVal pvTipText As Variant)
  242. &apos;&apos;&apos; Set the updatable property TipText
  243. _PropertySet(&quot;TipText&quot;, pvTipText)
  244. End Property &apos; SFDialogs.SF_DialogControl.TipText (let)
  245. REM -----------------------------------------------------------------------------
  246. Property Get TripleState() As Variant
  247. &apos;&apos;&apos; The TripleState property specifies how a check box will display Null values
  248. &apos;&apos;&apos; When True, the control will cycle through states for Yes, No, and Null values. The control appears dimmed (grayed) when its Value property is set to Null.
  249. &apos;&apos;&apos; When False, the control will cycle through states for Yes and No values. Null values display as if they were No values.
  250. TripleState = _PropertyGet(&quot;TripleState&quot;, False)
  251. End Property &apos; SFDialogs.SF_DialogControl.TripleState (get)
  252. REM -----------------------------------------------------------------------------
  253. Property Let TripleState(Optional ByVal pvTripleState As Variant)
  254. &apos;&apos;&apos; Set the updatable property TripleState
  255. _PropertySet(&quot;TripleState&quot;, pvTripleState)
  256. End Property &apos; SFDialogs.SF_DialogControl.TripleState (let)
  257. REM -----------------------------------------------------------------------------
  258. Property Get Value() As Variant
  259. &apos;&apos;&apos; The Value property specifies the data contained in the control
  260. Value = _PropertyGet(&quot;Value&quot;, Empty)
  261. End Property &apos; SFDialogs.SF_DialogControl.Value (get)
  262. REM -----------------------------------------------------------------------------
  263. Property Let Value(Optional ByVal pvValue As Variant)
  264. &apos;&apos;&apos; Set the updatable property Value
  265. _PropertySet(&quot;Value&quot;, pvValue)
  266. End Property &apos; SFDialogs.SF_DialogControl.Value (let)
  267. REM -----------------------------------------------------------------------------
  268. Property Get Visible() As Variant
  269. &apos;&apos;&apos; The Visible property specifies if the control is accessible with the cursor.
  270. Visible = _PropertyGet(&quot;Visible&quot;, True)
  271. End Property &apos; SFDialogs.SF_DialogControl.Visible (get)
  272. REM -----------------------------------------------------------------------------
  273. Property Let Visible(Optional ByVal pvVisible As Variant)
  274. &apos;&apos;&apos; Set the updatable property Visible
  275. _PropertySet(&quot;Visible&quot;, pvVisible)
  276. End Property &apos; SFDialogs.SF_DialogControl.Visible (let)
  277. REM -----------------------------------------------------------------------------
  278. Property Get XControlModel() As Object
  279. &apos;&apos;&apos; The XControlModel property returns the model UNO object of the control
  280. XControlModel = _PropertyGet(&quot;XControlModel&quot;, Nothing)
  281. End Property &apos; SFDialogs.SF_DialogControl.XControlModel (get)
  282. REM -----------------------------------------------------------------------------
  283. Property Get XControlView() As Object
  284. &apos;&apos;&apos; The XControlView property returns the view UNO object of the control
  285. XControlView = _PropertyGet(&quot;XControlView&quot;, Nothing)
  286. End Property &apos; SFDialogs.SF_DialogControl.XControlView (get)
  287. REM ===================================================================== METHODS
  288. REM -----------------------------------------------------------------------------
  289. Public Function GetProperty(Optional ByVal PropertyName As Variant) As Variant
  290. &apos;&apos;&apos; Return the actual value of the given property
  291. &apos;&apos;&apos; Args:
  292. &apos;&apos;&apos; PropertyName: the name of the property as a string
  293. &apos;&apos;&apos; Returns:
  294. &apos;&apos;&apos; The actual value of the property
  295. &apos;&apos;&apos; If the property does not exist, returns Null
  296. &apos;&apos;&apos; Exceptions:
  297. &apos;&apos;&apos; see the exceptions of the individual properties
  298. &apos;&apos;&apos; Examples:
  299. &apos;&apos;&apos; myModel.GetProperty(&quot;MyProperty&quot;)
  300. Const cstThisSub = &quot;SFDialogs.DialogControl.GetProperty&quot;
  301. Const cstSubArgs = &quot;&quot;
  302. If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
  303. GetProperty = Null
  304. Check:
  305. If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
  306. If Not ScriptForge.SF_Utils._Validate(PropertyName, &quot;PropertyName&quot;, V_STRING, Properties()) Then GoTo Catch
  307. End If
  308. Try:
  309. GetProperty = _PropertyGet(PropertyName)
  310. Finally:
  311. ScriptForge.SF_Utils._ExitFunction(cstThisSub)
  312. Exit Function
  313. Catch:
  314. GoTo Finally
  315. End Function &apos; SFDialogs.SF_DialogControl.GetProperty
  316. REM -----------------------------------------------------------------------------
  317. Public Function Methods() As Variant
  318. &apos;&apos;&apos; Return the list of public methods of the Model service as an array
  319. Methods = Array( _
  320. &quot;SetFocus&quot; _
  321. , &quot;WriteLine&quot; _
  322. )
  323. End Function &apos; SFDialogs.SF_DialogControl.Methods
  324. REM -----------------------------------------------------------------------------
  325. Public Function Properties() As Variant
  326. &apos;&apos;&apos; Return the list or properties of the Timer class as an array
  327. Properties = Array( _
  328. &quot;Cancel&quot; _
  329. , &quot;Caption&quot; _
  330. , &quot;ControlType&quot; _
  331. , &quot;Default&quot; _
  332. , &quot;Enabled&quot; _
  333. , &quot;Format&quot; _
  334. , &quot;ListCount&quot; _
  335. , &quot;ListIndex&quot; _
  336. , &quot;Locked&quot; _
  337. , &quot;MultiSelect&quot; _
  338. , &quot;Name&quot; _
  339. , &quot;Page&quot; _
  340. , &quot;Parent&quot; _
  341. , &quot;Picture&quot; _
  342. , &quot;RowSource&quot; _
  343. , &quot;Text&quot; _
  344. , &quot;TipText&quot; _
  345. , &quot;TripleState&quot; _
  346. , &quot;Value&quot; _
  347. , &quot;Visible&quot; _
  348. , &quot;XControlModel&quot; _
  349. , &quot;XControlView&quot; _
  350. )
  351. End Function &apos; SFDialogs.SF_DialogControl.Properties
  352. REM -----------------------------------------------------------------------------
  353. Public Function SetFocus() As Boolean
  354. &apos;&apos;&apos; Set the focus on the current Control instance
  355. &apos;&apos;&apos; Probably called from after an event occurrence
  356. &apos;&apos;&apos; Args:
  357. &apos;&apos;&apos; Returns:
  358. &apos;&apos;&apos; True if focusing is successful
  359. &apos;&apos;&apos; Example:
  360. &apos;&apos;&apos; Dim oDlg As Object, oControl As Object
  361. &apos;&apos;&apos; Set oDlg = CreateScriptService(,, &quot;myControl&quot;) &apos; Control stored in current document&apos;s standard library
  362. &apos;&apos;&apos; Set oControl = oDlg.Controls(&quot;thisControl&quot;)
  363. &apos;&apos;&apos; oControl.SetFocus()
  364. Dim bSetFocus As Boolean &apos; Return value
  365. Const cstThisSub = &quot;SFDialogs.DialogControl.SetFocus&quot;
  366. Const cstSubArgs = &quot;&quot;
  367. If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
  368. bSetFocus = False
  369. Check:
  370. If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
  371. If Not [_Parent]._IsStillAlive() Then GoTo Finally
  372. End If
  373. Try:
  374. If Not IsNull(_ControlView) Then
  375. _ControlView.setFocus()
  376. bSetFocus = True
  377. End If
  378. Finally:
  379. SetFocus = bSetFocus
  380. ScriptForge.SF_Utils._ExitFunction(cstThisSub)
  381. Exit Function
  382. Catch:
  383. GoTo Finally
  384. End Function &apos; SFControls.SF_DialogControl.SetFocus
  385. REM -----------------------------------------------------------------------------
  386. Public Function SetProperty(Optional ByVal PropertyName As Variant _
  387. , Optional ByRef Value As Variant _
  388. ) As Boolean
  389. &apos;&apos;&apos; Set a new value to the given property
  390. &apos;&apos;&apos; Args:
  391. &apos;&apos;&apos; PropertyName: the name of the property as a string
  392. &apos;&apos;&apos; Value: its new value
  393. &apos;&apos;&apos; Exceptions
  394. &apos;&apos;&apos; ARGUMENTERROR The property does not exist
  395. Const cstThisSub = &quot;SFDialogs.DialogControl.SetProperty&quot;
  396. Const cstSubArgs = &quot;PropertyName, Value&quot;
  397. If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
  398. SetProperty = False
  399. Check:
  400. If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
  401. If Not SF_Utils._Validate(PropertyName, &quot;PropertyName&quot;, V_STRING, Properties()) Then GoTo Catch
  402. End If
  403. Try:
  404. SetProperty = _PropertySet(PropertyName, Value)
  405. Finally:
  406. SF_Utils._ExitFunction(cstThisSub)
  407. Exit Function
  408. Catch:
  409. GoTo Finally
  410. End Function &apos; SFDialogs.SF_DialogControl.SetProperty
  411. REM -----------------------------------------------------------------------------
  412. Public Function WriteLine(Optional ByVal Line As Variant) As Boolean
  413. &apos;&apos;&apos; Add a new line to a multiline TextField control
  414. &apos;&apos;&apos; Args:
  415. &apos;&apos;&apos; Line: (default = &quot;&quot;) the line to insert at the end of the text box
  416. &apos;&apos;&apos; a newline character will be inserted before the line, if relevant
  417. &apos;&apos;&apos; Returns:
  418. &apos;&apos;&apos; True if insertion is successful
  419. &apos;&apos;&apos; Exceptions
  420. &apos;&apos;&apos; TEXTFIELDERROR Method applicable on multiline text fields only
  421. &apos;&apos;&apos; Example:
  422. &apos;&apos;&apos; Dim oDlg As Object, oControl As Object
  423. &apos;&apos;&apos; Set oDlg = CreateScriptService(,, &quot;myControl&quot;) &apos; Control stored in current document&apos;s standard library
  424. &apos;&apos;&apos; Set oControl = oDlg.Controls(&quot;thisControl&quot;)
  425. &apos;&apos;&apos; oControl.WriteLine(&quot;a new line&quot;)
  426. Dim bWriteLine As Boolean &apos; Return value
  427. Dim lTextLength As Long &apos; Actual length of text in box
  428. Dim oSelection As New com.sun.star.awt.Selection
  429. Dim sNewLine As String &apos; Newline character(s)
  430. Const cstThisSub = &quot;SFDialogs.DialogControl.WriteLine&quot;
  431. Const cstSubArgs = &quot;[Line=&quot;&quot;&quot;&quot;]&quot;
  432. If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
  433. bWriteLine = False
  434. Check:
  435. If IsMissing(Line) Or IsEmpty(Line) Then Line = &quot;&quot;
  436. If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
  437. If Not [_Parent]._IsStillAlive() Then GoTo Finally
  438. If Not ScriptForge.SF_Utils._Validate(Line, &quot;Line&quot;, V_STRING) Then GoTo Finally
  439. End If
  440. If ControlType &lt;&gt; CTLTEXTFIELD Then GoTo CatchField
  441. If _ControlModel.MultiLine = False Then GoTo CatchField
  442. Try:
  443. _ControlModel.HardLineBreaks = True
  444. sNewLine = ScriptForge.SF_String.sfNEWLINE
  445. With _ControlView
  446. lTextLength = Len(.getText())
  447. If lTextLength = 0 Then &apos; Text field is still empty
  448. oSelection.Min = 0 : oSelection.Max = 0
  449. .setText(Line)
  450. Else &apos; Put cursor at the end of the actual text
  451. oSelection.Min = lTextLength : oSelection.Max = lTextLength
  452. .insertText(oSelection, sNewLine &amp; Line)
  453. End If
  454. &apos; Put the cursor at the end of the inserted text
  455. oSelection.Max = oSelection.Max + Len(sNewLine) + Len(Line)
  456. oSelection.Min = oSelection.Max
  457. .setSelection(oSelection)
  458. End With
  459. bWriteLine = True
  460. Finally:
  461. WriteLine = bWriteLine
  462. ScriptForge.SF_Utils._ExitFunction(cstThisSub)
  463. Exit Function
  464. Catch:
  465. GoTo Finally
  466. CatchField:
  467. ScriptForge.SF_Exception.RaiseFatal(TEXTFIELDERROR, _Name, _DialogName)
  468. GoTo Finally
  469. End Function &apos; SFControls.SF_DialogControl.WriteLine
  470. REM =========================================================== PRIVATE FUNCTIONS
  471. REM -----------------------------------------------------------------------------
  472. Private Function _FormatsList() As Variant
  473. &apos;&apos;&apos; Return the allowed format entries as a zero-based array for Date and Time control types
  474. Dim vFormats() As Variant &apos; Return value
  475. Select Case _ControlType
  476. Case CTLDATEFIELD
  477. vFormats = Array( _
  478. &quot;Standard (short)&quot; _
  479. , &quot;Standard (short YY)&quot; _
  480. , &quot;Standard (short YYYY)&quot; _
  481. , &quot;Standard (long)&quot; _
  482. , &quot;DD/MM/YY&quot; _
  483. , &quot;MM/DD/YY&quot; _
  484. , &quot;YY/MM/DD&quot; _
  485. , &quot;DD/MM/YYYY&quot; _
  486. , &quot;MM/DD/YYYY&quot; _
  487. , &quot;YYYY/MM/DD&quot; _
  488. , &quot;YY-MM-DD&quot; _
  489. , &quot;YYYY-MM-DD&quot; _
  490. )
  491. Case CTLTIMEFIELD
  492. vFormats = Array( _
  493. &quot;24h short&quot; _
  494. , &quot;24h long&quot; _
  495. , &quot;12h short&quot; _
  496. , &quot;12h long&quot; _
  497. )
  498. Case Else
  499. vFormats = Array()
  500. End Select
  501. _FormatsList = vFormats
  502. End Function &apos; SFDialogs.SF_DialogControl._FormatsList
  503. REM -----------------------------------------------------------------------------
  504. Public Sub _Initialize()
  505. &apos;&apos;&apos; Complete the object creation process:
  506. &apos;&apos;&apos; - Initialization of private members
  507. &apos;&apos;&apos; - Collection of main attributes
  508. Dim vServiceName As Variant &apos; Splitted service name
  509. Dim sType As String &apos; Last component of service name
  510. Try:
  511. _ImplementationName = _ControlModel.getImplementationName()
  512. &apos; Identify the control type
  513. vServiceName = Split(_ControlModel.getServiceName(), &quot;.&quot;)
  514. sType = vServiceName(UBound(vServiceName))
  515. Select Case sType
  516. Case &quot;UnoControlSpinButtonModel&quot;, &quot;TreeControlModel&quot;
  517. _ControlType = &quot;&quot; &apos; Not supported
  518. Case &quot;Edit&quot; : _ControlType = CTLTEXTFIELD
  519. Case Else : _ControlType = sType
  520. End Select
  521. Finally:
  522. Exit Sub
  523. End Sub &apos; SFDialogs.SF_DialogControl._Initialize
  524. REM -----------------------------------------------------------------------------
  525. Private Function _PropertyGet(Optional ByVal psProperty As String _
  526. , Optional ByVal pvDefault As Variant _
  527. ) As Variant
  528. &apos;&apos;&apos; Return the value of the named property
  529. &apos;&apos;&apos; Args:
  530. &apos;&apos;&apos; psProperty: the name of the property
  531. &apos;&apos;&apos; pvDefault: the value returned when the property is not applicable on the control&apos;s type
  532. &apos;&apos;&apos; Getting a non-existing property for a specific control type should
  533. &apos;&apos;&apos; not generate an error to not disrupt the Basic IDE debugger
  534. Dim vGet As Variant &apos; Return value
  535. Static oSession As Object &apos; Alias of SF_Session
  536. Dim vSelection As Variant &apos; Alias of Model.SelectedItems
  537. Dim vList As Variant &apos; Alias of Model.StringItemList
  538. Dim lIndex As Long &apos; Index in StringItemList
  539. Dim sItem As String &apos; A single item
  540. Dim vDate As Variant &apos; com.sun.star.util.Date or com.sun.star.util.Time
  541. Dim vValues As Variant &apos; Array of listbox values
  542. Dim i As Long
  543. Dim cstThisSub As String
  544. Const cstSubArgs = &quot;&quot;
  545. cstThisSub = &quot;SFDialogs.DialogControl.get&quot; &amp; psProperty
  546. If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
  547. ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
  548. If Not [_Parent]._IsStillAlive() Then GoTo Finally
  549. If IsMissing(pvDefault) Then pvDefault = Null
  550. _PropertyGet = pvDefault
  551. If IsNull(oSession) Then Set oSession = ScriptForge.SF_Services.CreateScriptService(&quot;Session&quot;)
  552. Select Case psProperty
  553. Case &quot;Cancel&quot;
  554. Select Case _ControlType
  555. Case CTLBUTTON
  556. If oSession.HasUNOProperty(_ControlModel, &quot;PushButtonType&quot;) Then _PropertyGet = ( _ControlModel.PushButtonType = com.sun.star.awt.PushButtonType.CANCEL )
  557. Case Else : GoTo CatchType
  558. End Select
  559. Case &quot;Caption&quot;
  560. Select Case _ControlType
  561. Case CTLBUTTON, CTLCHECKBOX, CTLFIXEDLINE, CTLFIXEDTEXT, CTLGROUPBOX, CTLRADIOBUTTON
  562. If oSession.HasUNOProperty(_ControlModel, &quot;Label&quot;) Then _PropertyGet = _ControlModel.Label
  563. Case Else : GoTo CatchType
  564. End Select
  565. Case &quot;ControlType&quot;
  566. _PropertyGet = _ControlType
  567. Case &quot;Default&quot;
  568. Select Case _ControlType
  569. Case CTLBUTTON
  570. If oSession.HasUNOProperty(_ControlModel, &quot;DefaultButton&quot;) Then _PropertyGet = _ControlModel.DefaultButton
  571. Case Else : GoTo CatchType
  572. End Select
  573. Case &quot;Enabled&quot;
  574. If oSession.HasUnoProperty(_ControlModel, &quot;Enabled&quot;) Then _PropertyGet = _ControlModel.Enabled
  575. Case &quot;Format&quot;
  576. Select Case _ControlType
  577. Case CTLDATEFIELD
  578. If oSession.HasUNOProperty(_ControlModel, &quot;DateFormat&quot;) Then _PropertyGet = _FormatsList()(_ControlModel.DateFormat)
  579. Case CTLTIMEFIELD
  580. If oSession.HasUNOProperty(_ControlModel, &quot;TimeFormat&quot;) Then _PropertyGet = _FormatsList()(_ControlModel.TimeFormat)
  581. Case CTLFORMATTEDFIELD
  582. If oSession.HasUNOProperty(_ControlModel, &quot;FormatsSupplier&quot;) And oSession.HasUNOProperty(_ControlModel, &quot;FormatKey&quot;) Then
  583. _PropertyGet = _ControlModel.FormatsSupplier.getNumberFormats.getByKey(_ControlModel.FormatKey).FormatString
  584. End If
  585. Case Else : GoTo CatchType
  586. End Select
  587. Case &quot;ListCount&quot;
  588. Select Case _ControlType
  589. Case CTLCOMBOBOX, CTLLISTBOX
  590. If oSession.HasUNOProperty(_ControlModel, &quot;StringItemList&quot;) Then _PropertyGet = UBound(_ControlModel.StringItemList) + 1
  591. Case Else : GoTo CatchType
  592. End Select
  593. Case &quot;ListIndex&quot;
  594. Select Case _ControlType
  595. Case CTLCOMBOBOX
  596. _PropertyGet = -1 &apos; Not found, multiselection
  597. If oSession.HasUNOProperty(_ControlModel, &quot;Text&quot;) And oSession.HasUNOProperty(_ControlModel, &quot;StringItemList&quot;) Then
  598. _PropertyGet = ScriptForge.SF_Array.IndexOf(_ControlModel.StringItemList, _ControlModel.Text, CaseSensitive := True)
  599. End If
  600. Case CTLLISTBOX
  601. _PropertyGet = -1 &apos; Not found, multiselection
  602. If oSession.HasUNOProperty(_ControlModel, &quot;SelectedItems&quot;) And oSession.HasUNOProperty(_ControlModel, &quot;StringItemList&quot;) Then
  603. vSelection = _ControlModel.SelectedItems
  604. If UBound(vSelection) &gt;= 0 Then _PropertyGet = vSelection(0)
  605. End If
  606. Case Else : GoTo CatchType
  607. End Select
  608. Case &quot;Locked&quot;
  609. Select Case _ControlType
  610. Case CTLCOMBOBOX, CTLCURRENCYFIELD, CTLDATEFIELD, CTLFILECONTROL, CTLFORMATTEDFIELD, CTLLISTBOX _
  611. , CTLNUMERICFIELD, CTLPATTERNFIELD, CTLTEXTFIELD, CTLTIMEFIELD
  612. If oSession.HasUnoProperty(_ControlModel, &quot;ReadOnly&quot;) Then _PropertyGet = _ControlModel.ReadOnly
  613. Case Else : GoTo CatchType
  614. End Select
  615. Case &quot;MultiSelect&quot;
  616. Select Case _ControlType
  617. Case CTLLISTBOX
  618. If oSession.HasUnoProperty(_ControlModel, &quot;MultiSelection&quot;) Then
  619. _PropertyGet = _ControlModel.MultiSelection
  620. ElseIf oSession.HasUnoProperty(_ControlModel, &quot;MultiSelectionSimpleMode&quot;) Then &apos; Not documented: gridcontrols only TBC ??
  621. _PropertyGet = _ControlModel.MultiSelectionSimpleMode
  622. End If
  623. Case Else : GoTo CatchType
  624. End Select
  625. Case &quot;Name&quot;
  626. _PropertyGet = _Name
  627. Case &quot;Page&quot;
  628. If oSession.HasUnoProperty(_ControlModel, &quot;Step&quot;) Then _PropertyGet = _ControlModel.Step
  629. Case &quot;Parent&quot;
  630. Set _PropertyGet = [_Parent]
  631. Case &quot;Picture&quot;
  632. Select Case _ControlType
  633. Case CTLBUTTON, CTLIMAGECONTROL
  634. If oSession.HasUnoProperty(_ControlModel, &quot;ImageURL&quot;) Then _PropertyGet = ScriptForge.SF_FileSystem._ConvertFromUrl(_ControlModel.ImageURL)
  635. Case Else : GoTo CatchType
  636. End Select
  637. Case &quot;RowSource&quot;
  638. Select Case _ControlType
  639. Case CTLCOMBOBOX, CTLLISTBOX
  640. If oSession.HasUnoProperty(_ControlModel, &quot;StringItemList&quot;) Then
  641. If IsArray(_ControlModel.StringItemList) Then _PropertyGet = _ControlModel.StringItemList Else _PropertyGet = Array(_ControlModel.StringItemList)
  642. End If
  643. Case Else : GoTo CatchType
  644. End Select
  645. Case &quot;Text&quot;
  646. Select Case _ControlType
  647. Case CTLCOMBOBOX, CTLFILECONTROL, CTLFORMATTEDFIELD, CTLPATTERNFIELD, CTLTEXTFIELD
  648. If oSession.HasUnoProperty(_ControlModel, &quot;Text&quot;) Then _PropertyGet = _ControlModel.Text
  649. Case Else : GoTo CatchType
  650. End Select
  651. Case &quot;TipText&quot;
  652. If oSession.HasUnoProperty(_ControlModel, &quot;HelpText&quot;) Then _PropertyGet = _ControlModel.HelpText
  653. Case &quot;TripleState&quot;
  654. Select Case _ControlType
  655. Case CTLCHECKBOX
  656. If oSession.HasUnoProperty(_ControlModel, &quot;TriState&quot;) Then _PropertyGet = _ControlModel.TriState
  657. Case Else : GoTo CatchType
  658. End Select
  659. Case &quot;Value&quot; &apos; Default values are set here by control type, not in the 2nd argument
  660. vGet = pvDefault
  661. Select Case _ControlType
  662. Case CTLBUTTON &apos;Boolean, toggle buttons only
  663. vGet = False
  664. If oSession.HasUnoProperty(_ControlModel, &quot;Toggle&quot;) Then
  665. If oSession.HasUnoProperty(_ControlModel, &quot;State&quot;) Then vGet = ( _ControlModel.State = 1 )
  666. End If
  667. Case CTLCHECKBOX &apos;0 = Not checked, 1 = Checked, 2 = Don&apos;t know
  668. If oSession.HasUnoProperty(_ControlModel, &quot;State&quot;) Then vGet = _ControlModel.State Else vGet = 2
  669. Case CTLCOMBOBOX, CTLFILECONTROL, CTLPATTERNFIELD, CTLTEXTFIELD &apos;String
  670. If oSession.HasUnoProperty(_ControlModel, &quot;Text&quot;) Then vGet = _ControlModel.Text Else vGet = &quot;&quot;
  671. Case CTLCURRENCYFIELD, CTLNUMERICFIELD &apos;Numeric
  672. If oSession.HasUnoProperty(_ControlModel, &quot;Value&quot;) Then vGet = _ControlModel.Value Else vGet = 0
  673. Case CTLDATEFIELD &apos;Date
  674. vGet = CDate(1)
  675. If oSession.HasUnoProperty(_ControlModel, &quot;Date&quot;) Then
  676. If VarType(_ControlModel.Date) = ScriptForge.V_OBJECT Then &apos; com.sun.star.util.Date
  677. Set vDate = _ControlModel.Date
  678. vGet = DateSerial(vDate.Year, vDate.Month, vDate.Day)
  679. End If
  680. End If
  681. Case CTLFORMATTEDFIELD &apos;String or numeric
  682. If oSession.HasUnoProperty(_ControlModel, &quot;EffectiveValue&quot;) Then vGet = _ControlModel.EffectiveValue Else vGet = &quot;&quot;
  683. Case CTLLISTBOX &apos;String or array of strings depending on MultiSelection
  684. &apos; StringItemList is the list of the items displayed in the box
  685. &apos; SelectedItems is the list of the indexes in StringItemList of the selected items
  686. &apos; It can go beyond the limits of StringItemList
  687. &apos; It can contain multiple values even if the listbox is not multiselect
  688. If oSession.HasUnoProperty(_ControlModel, &quot;StringItemList&quot;) And oSession.HasUnoProperty(_ControlModel, &quot;SelectedItems&quot;) _
  689. And oSession.HasUnoProperty(_ControlModel, &quot;MultiSelection&quot;) Then
  690. vSelection = _ControlModel.SelectedItems
  691. vList = _ControlModel.StringItemList
  692. If _ControlModel.MultiSelection Then vValues = Array()
  693. For i = 0 To UBound(vSelection)
  694. lIndex = vSelection(i)
  695. If lIndex &gt;= 0 And lIndex &lt;= UBound(vList) Then
  696. If Not _ControlModel.MultiSelection Then
  697. vValues = vList(lIndex)
  698. Exit For
  699. End If
  700. vValues = ScriptForge.SF_Array.Append(vValues, vList(lIndex))
  701. End If
  702. Next i
  703. vGet = vValues
  704. Else
  705. vGet = &quot;&quot;
  706. End If
  707. Case CTLPROGRESSBAR &apos;Numeric
  708. If oSession.HasUnoProperty(_ControlModel, &quot;ProgressValue&quot;) Then vGet = _ControlModel.ProgressValue Else vGet = 0
  709. Case CTLRADIOBUTTON &apos;Boolean
  710. If oSession.HasUnoProperty(_ControlModel, &quot;State&quot;) Then vGet = ( _ControlModel.State = 1 ) Else vGet = False
  711. Case CTLSCROLLBAR &apos;Numeric
  712. If oSession.HasUnoProperty(_ControlModel, &quot;ScrollValue&quot;) Then vGet = _ControlModel.ScrollValue Else vGet = 0
  713. Case CTLTIMEFIELD
  714. vGet = CDate(0)
  715. If oSession.HasUnoProperty(_ControlModel, &quot;Time&quot;) Then
  716. If VarType(_ControlModel.Time) = ScriptForge.V_OBJECT Then &apos; com.sun.star.Util.Time
  717. Set vDate = _ControlModel.Time
  718. vGet = TimeSerial(vDate.Hours, vDate.Minutes, vDate.Seconds)
  719. End If
  720. End If
  721. Case Else : GoTo CatchType
  722. End Select
  723. _PropertyGet = vGet
  724. Case &quot;Visible&quot;
  725. If oSession.HasUnoMethod(_ControlView, &quot;isVisible&quot;) Then _PropertyGet = CBool(_ControlView.isVisible())
  726. Case &quot;XControlModel&quot;
  727. Set _PropertyGet = _ControlModel
  728. Case &quot;XControlView&quot;
  729. Set _PropertyGet = _ControlView
  730. Case Else
  731. _PropertyGet = Null
  732. End Select
  733. Finally:
  734. ScriptForge.SF_Utils._ExitFunction(cstThisSub)
  735. Exit Function
  736. Catch:
  737. GoTo Finally
  738. CatchType:
  739. GoTo Finally
  740. End Function &apos; SFDialogs.SF_DialogControl._PropertyGet
  741. REM -----------------------------------------------------------------------------
  742. Private Function _PropertySet(Optional ByVal psProperty As String _
  743. , Optional ByVal pvValue As Variant _
  744. ) As Boolean
  745. &apos;&apos;&apos; Set the new value of the named property
  746. &apos;&apos;&apos; Args:
  747. &apos;&apos;&apos; psProperty: the name of the property
  748. &apos;&apos;&apos; pvValue: the new value of the given property
  749. Dim bSet As Boolean &apos; Return value
  750. Static oSession As Object &apos; Alias of SF_Session
  751. Dim vSet As Variant &apos; Value to set in UNO model or view property
  752. Dim vFormats As Variant &apos; Format property: output of _FormatsList()
  753. Dim iFormat As Integer &apos; Format property: index in vFormats
  754. Dim vSelection As Variant &apos; Alias of Model.SelectedItems
  755. Dim vList As Variant &apos; Alias of Model.StringItemList
  756. Dim lIndex As Long &apos; Index in StringItemList
  757. Dim sItem As String &apos; A single item
  758. Dim i As Long
  759. Dim cstThisSub As String
  760. Const cstSubArgs = &quot;Value&quot;
  761. If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
  762. bSet = False
  763. cstThisSub = &quot;SFDialogs.DialogControl.set&quot; &amp; psProperty
  764. ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
  765. If Not [_Parent]._IsStillAlive() Then GoTo Finally
  766. If IsNull(oSession) Then Set oSession = ScriptForge.SF_Services.CreateScriptService(&quot;Session&quot;)
  767. bSet = True
  768. Select Case UCase(psProperty)
  769. Case UCase(&quot;Cancel&quot;)
  770. Select Case _ControlType
  771. Case CTLBUTTON
  772. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Cancel&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
  773. If oSession.HasUNOProperty(_ControlModel, &quot;PushButtonType&quot;) Then
  774. If pvValue Then vSet = com.sun.star.awt.PushButtonType.CANCEL Else vSet = com.sun.star.awt.PushButtonType.STANDARD
  775. _ControlModel.PushButtonType = vSet
  776. End If
  777. Case Else : GoTo CatchType
  778. End Select
  779. Case UCase(&quot;Caption&quot;)
  780. Select Case _ControlType
  781. Case CTLBUTTON, CTLCHECKBOX, CTLFIXEDLINE, CTLFIXEDTEXT, CTLGROUPBOX, CTLRADIOBUTTON
  782. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Caption&quot;, V_STRING) Then GoTo Finally
  783. If oSession.HasUNOProperty(_ControlModel, &quot;Label&quot;) Then _ControlModel.Label = pvValue
  784. Case Else : GoTo CatchType
  785. End Select
  786. Case UCase(&quot;Default&quot;)
  787. Select Case _ControlType
  788. Case CTLBUTTON
  789. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Default&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
  790. If oSession.HasUNOProperty(_ControlModel, &quot;DefaultButton&quot;) Then _ControlModel.DefaultButton = pvValue
  791. Case Else : GoTo CatchType
  792. End Select
  793. Case UCase(&quot;Enabled&quot;)
  794. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Enabled&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
  795. If oSession.HasUnoProperty(_ControlModel, &quot;Enabled&quot;) Then _ControlModel.Enabled = pvValue
  796. Case UCase(&quot;Format&quot;)
  797. Select Case _ControlType
  798. Case CTLDATEFIELD, CTLTIMEFIELD
  799. vFormats = _FormatsList()
  800. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Format&quot;, V_STRING, vFormats) Then GoTo Finally
  801. iFormat = ScriptForge.SF_Array.IndexOf(vFormats, pvValue, CaseSensitive := False)
  802. If oSession.HasUNOProperty(_ControlModel, &quot;DateFormat&quot;) Then
  803. _ControlModel.DateFormat = iFormat
  804. ElseIf oSession.HasUNOProperty(_ControlModel, &quot;TimeFormat&quot;) Then
  805. _ControlModel.TimeFormat = iFormat
  806. End If
  807. Case Else : GoTo CatchType
  808. End Select
  809. Case UCase(&quot;ListIndex&quot;)
  810. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;ListIndex&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
  811. Select Case _ControlType
  812. Case CTLCOMBOBOX
  813. If oSession.HasUNOProperty(_ControlModel, &quot;Text&quot;) And oSession.HasUNOProperty(_ControlModel, &quot;StringItemList&quot;) Then
  814. _ControlModel.Text = _ControlModel.StringItemList(CInt(pvValue))
  815. End If
  816. Case CTLLISTBOX
  817. If oSession.HasUNOProperty(_ControlModel, &quot;SelectedItems&quot;) Then _ControlModel.SelectedItems = Array(CInt(pvValue))
  818. Case Else : GoTo CatchType
  819. End Select
  820. Case UCase(&quot;Locked&quot;)
  821. Select Case _ControlType
  822. Case CTLCOMBOBOX, CTLCURRENCYFIELD, CTLDATEFIELD, CTLFILECONTROL, CTLFORMATTEDFIELD, CTLLISTBOX _
  823. , CTLNUMERICFIELD, CTLPATTERNFIELD, CTLTEXTFIELD, CTLTIMEFIELD
  824. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Locked&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
  825. If oSession.HasUnoProperty(_ControlModel, &quot;ReadOnly&quot;) Then _ControlModel.ReadOnly = pvValue
  826. Case Else : GoTo CatchType
  827. End Select
  828. Case UCase(&quot;MultiSelect&quot;)
  829. Select Case _ControlType
  830. Case CTLLISTBOX
  831. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;MultiSelect&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
  832. If oSession.HasUnoProperty(_ControlModel, &quot;MultiSelection&quot;) Then _ControlModel.MultiSelection = pvValue
  833. If oSession.HasUnoProperty(_ControlModel, &quot;MultiSelectionSimpleMode&quot;) Then _ControlModel.MultiSelectionSimpleMode = pvValue
  834. If oSession.HasUnoProperty(_ControlModel, &quot;SelectedItems&quot;) Then
  835. If Not pvValue And UBound(_ControlModel.SelectedItems) &gt; 0 Then &apos; Cancel selections when MultiSelect becomes False
  836. lIndex = _ControlModel.SelectedItems(0)
  837. _ControlModel.SelectedItems = Array(lIndex)
  838. End If
  839. End If
  840. Case Else : GoTo CatchType
  841. End Select
  842. Case UCase(&quot;Page&quot;)
  843. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Page&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
  844. If oSession.HasUnoProperty(_ControlModel, &quot;Step&quot;) Then _ControlModel.Step = CLng(pvValue)
  845. Case UCase(&quot;Picture&quot;)
  846. Select Case _ControlType
  847. Case CTLBUTTON, CTLIMAGECONTROL
  848. If Not ScriptForge.SF_Utils._ValidateFile(pvValue, &quot;Picture&quot;) Then GoTo Finally
  849. If oSession.HasUnoProperty(_ControlModel, &quot;ImageURL&quot;) Then _ControlModel.ImageURL = ScriptForge.SF_FileSystem._ConvertToUrl(pvValue)
  850. Case Else : GoTo CatchType
  851. End Select
  852. Case UCase(&quot;RowSource&quot;)
  853. Select Case _ControlType
  854. Case CTLCOMBOBOX, CTLLISTBOX
  855. If Not IsArray(pvValue) Then
  856. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;RowSource&quot;, V_STRING) Then GoTo Finally
  857. pvArray = Array(pvArray)
  858. ElseIf Not ScriptForge.SF_Utils._ValidateArray(pvValue, &quot;RowSource&quot;, 1, V_STRING, True) Then
  859. GoTo Finally
  860. End If
  861. If oSession.HasUnoProperty(_ControlModel, &quot;StringItemList&quot;) Then _ControlModel.StringItemList = pvValue
  862. Case Else : GoTo CatchType
  863. End Select
  864. Case UCase(&quot;TipText&quot;)
  865. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;TipText&quot;, V_STRING) Then GoTo Finally
  866. If oSession.HasUnoProperty(_ControlModel, &quot;HelpText&quot;) Then _ControlModel.HelpText = pvValue
  867. Case UCase(&quot;TripleState&quot;)
  868. Select Case _ControlType
  869. Case CTLCHECKBOX
  870. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;TripleState&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
  871. If oSession.HasUnoProperty(_ControlModel, &quot;TriState&quot;) Then _ControlModel.TriState = pvValue
  872. Case Else : GoTo CatchType
  873. End Select
  874. Case UCase(&quot;Value&quot;)
  875. Select Case _ControlType
  876. Case CTLBUTTON &apos;Boolean, toggle buttons only
  877. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Value&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
  878. If oSession.HasUnoProperty(_ControlModel, &quot;Toggle&quot;) And oSession.HasUnoProperty(_ControlModel, &quot;State&quot;) Then
  879. _ControlModel.State = Iif(pvValue, 1, 0)
  880. End If
  881. Case CTLCHECKBOX &apos;0 = Not checked, 1 = Checked, 2 = Don&apos;t know
  882. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Value&quot;, Array(ScriptForge.V_BOOLEAN, ScriptForge.V_NUMERIC), Array(0, 1, 2, True, False)) Then GoTo Finally
  883. If oSession.HasUnoProperty(_ControlModel, &quot;State&quot;) Then
  884. If VarType(pvValue) = ScriptForge.V_BOOLEAN Then pvValue = Iif(pvValue, 1, 0)
  885. _ControlModel.State = pvValue
  886. End If
  887. Case CTLCOMBOBOX, CTLFILECONTROL, CTLPATTERNFIELD, CTLTEXTFIELD &apos;String
  888. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Value&quot;, V_STRING) Then GoTo Finally
  889. If oSession.HasUnoProperty(_ControlModel, &quot;Text&quot;) Then _ControlModel.Text = pvValue
  890. Case CTLCURRENCYFIELD, CTLNUMERICFIELD &apos;Numeric
  891. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Value&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
  892. If oSession.HasUnoProperty(_ControlModel, &quot;Value&quot;) Then _ControlModel.Value = pvValue
  893. Case CTLDATEFIELD &apos;Date
  894. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Value&quot;, V_DATE) Then GoTo Finally
  895. If oSession.HasUnoProperty(_ControlModel, &quot;Date&quot;) Then
  896. Set vSet = New com.sun.star.util.Date
  897. vSet.Year = Year(pvValue)
  898. vSet.Month = Month(pvValue)
  899. vSet.Day = Day(pvValue)
  900. _ControlModel.Date = vSet
  901. End If
  902. Case CTLFORMATTEDFIELD &apos;String or numeric
  903. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Value&quot;, Array(V_STRING, ScriptForge.V_NUMERIC)) Then GoTo Finally
  904. If oSession.HasUnoProperty(_ControlModel, &quot;EffectiveValue&quot;) Then _ControlModel.EffectiveValue = pvValue
  905. Case CTLLISTBOX &apos;String or array of strings depending on MultiSelection
  906. &apos; StringItemList is the list of the items displayed in the box
  907. &apos; SelectedItems is the list of the indexes in StringItemList of the selected items
  908. &apos; It can go beyond the limits of StringItemList
  909. &apos; It can contain multiple values even if the listbox is not multiselect
  910. If oSession.HasUnoProperty(_ControlModel, &quot;StringItemList&quot;) And oSession.HasUnoProperty(_ControlModel, &quot;SelectedItems&quot;) _
  911. And oSession.HasUnoProperty(_ControlModel, &quot;MultiSelection&quot;) Then
  912. vSelection = Array()
  913. If _ControlModel.MultiSelection Then
  914. If Not ScriptForge.SF_Utils._ValidateArray(pvValue, &quot;Value&quot;, 1, V_STRING, True) Then GoTo Finally
  915. vList = _ControlModel.StringItemList
  916. For i = LBound(pvValue) To UBound(pvValue)
  917. sItem = pvValue(i)
  918. lIndex = ScriptForge.SF_Array.IndexOf(vList, sItem)
  919. If lIndex &gt;= 0 Then vSelection = ScriptForge.SF_Array.Append(vSelection, lIndex)
  920. Next i
  921. Else
  922. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Value&quot;, V_STRING) Then GoTo Finally
  923. lIndex = ScriptForge.SF_Array.IndexOf(_ControlModel.StringItemList, pvValue)
  924. If lIndex &gt;= 0 Then vSelection = Array(lIndex)
  925. End If
  926. _ControlModel.SelectedItems = vSelection
  927. End If
  928. Case CTLPROGRESSBAR &apos;Numeric
  929. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Value&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
  930. If oSession.HasUnoProperty(_ControlModel, &quot;ProgressValueMin&quot;) Then
  931. If pvValue &lt; _ControlModel.ProgressValueMin Then pvValue = _ControlModel.ProgressValueMin
  932. End If
  933. If oSession.HasUnoProperty(_ControlModel, &quot;ProgressValueMax&quot;) Then
  934. If pvValue &gt; _ControlModel.ProgressValueMax Then pvValue = _ControlModel.ProgressValueMax
  935. End If
  936. If oSession.HasUnoProperty(_ControlModel, &quot;ProgressValue&quot;) Then _ControlModel.ProgressValue = pvValue
  937. Case CTLRADIOBUTTON &apos;Boolean
  938. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Value&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
  939. If oSession.HasUnoProperty(_ControlModel, &quot;State&quot;) Then _ControlModel.State = Iif(pvValue, 1, 0)
  940. Case CTLSCROLLBAR &apos;Numeric
  941. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Value&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
  942. If oSession.HasUnoProperty(_ControlModel, &quot;ScrollValueMin&quot;) Then
  943. If pvValue &lt; _ControlModel.ScrollValueMin Then pvValue = _ControlModel.ScrollValueMin
  944. End If
  945. If oSession.HasUnoProperty(_ControlModel, &quot;ScrollValueMax&quot;) Then
  946. If pvValue &gt; _ControlModel.ScrollValueMax Then pvValue = _ControlModel.ScrollValueMax
  947. End If
  948. If oSession.HasUnoProperty(_ControlModel, &quot;ScrollValue&quot;) Then _ControlModel.ScrollValue = pvValue
  949. Case CTLTIMEFIELD
  950. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Value&quot;, V_DATE) Then GoTo Finally
  951. If oSession.HasUnoProperty(_ControlModel, &quot;Time&quot;) Then
  952. Set vSet = New com.sun.star.util.Time
  953. vSet.Hours = Hour(pvValue)
  954. vSet.Minutes = Minute(pvValue)
  955. vSet.Seconds = Second(pvValue)
  956. _ControlModel.Time = vSet
  957. End If
  958. Case Else : GoTo CatchType
  959. End Select
  960. Case UCase(&quot;Visible&quot;)
  961. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Visible&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
  962. If oSession.HasUnoMethod(_ControlView, &quot;setVisible&quot;) Then
  963. If pvValue Then _ControlModel.EnableVisible = True
  964. _ControlView.setVisible(pvValue)
  965. End If
  966. Case Else
  967. bSet = False
  968. End Select
  969. Finally:
  970. _PropertySet = bSet
  971. ScriptForge.SF_Utils._ExitFunction(cstThisSub)
  972. Exit Function
  973. Catch:
  974. GoTo Finally
  975. CatchType:
  976. ScriptForge.SF_Exception.RaiseFatal(CONTROLTYPEERROR, _Name, _DialogName, _ControlType, psProperty)
  977. GoTo Finally
  978. End Function &apos; SFDialogs.SF_DialogControl._PropertySet
  979. REM -----------------------------------------------------------------------------
  980. Private Function _Repr() As String
  981. &apos;&apos;&apos; Convert the Model instance to a readable string, typically for debugging purposes (DebugPrint ...)
  982. &apos;&apos;&apos; Args:
  983. &apos;&apos;&apos; Return:
  984. &apos;&apos;&apos; &quot;[DIALOGCONTROL]: Name, Type (dialogname)
  985. _Repr = &quot;[DIALOGCONTROL]: &quot; &amp; _Name &amp; &quot;, &quot; &amp; _ControlType &amp; &quot; (&quot; &amp; _DialogName &amp; &quot;)&quot;
  986. End Function &apos; SFDialogs.SF_DialogControl._Repr
  987. REM ============================================ END OF SFDIALOGS.SF_DIALOGCONTROL
  988. </script:module>