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 =======================================================================================================================
14 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
15 ''' SF_DialogControl
16 ''' ================
17 ''' Manage the controls belonging to a dialog defined with the Basic IDE
18 ''' Each instance of the current class represents a single control within a dialog box
20 ''' The focus is clearly set on getting and setting the values displayed by the controls of the dialog box,
21 ''' not on their formatting. The latter is easily accessible via the XControlModel and XControlView
22 ''' UNO objects.
23 ''' Essentially a single property
"Value
" maps many alternative UNO properties depending each on
24 ''' the control type.
26 ''' A special attention is given to controls with types TreeControl and TableControl
27 ''' It is easy with the API proposed in the current class to populate a tree, either
28 ''' - branch by branch (CreateRoot and AddSubNode), or
29 ''' - with a set of branches at once (AddSubtree)
30 ''' Additionally populating a TreeControl can be done statically or dynamically
32 ''' With the method SetTableData(), feed a tablecontrol with a sortable and selectable
33 ''' array of data. Columns and rows may receive a header. Column widths are adjusted manually by the user or
34 ''' with the same method. Alignments can be set as well by script.
36 ''' Service invocation:
37 ''' Dim myDialog As Object, myControl As Object
38 ''' Set myDialog = CreateScriptService(
"SFDialogs.Dialog
",
"GlobalScope
", myLibrary, DialogName)
39 ''' Set myControl = myDialog.Controls(
"myTextBox
")
40 ''' myControl.Value =
"Dialog started at
" & Now()
41 ''' myDialog.Execute()
42 ''' ' ... process the controls actual values
43 ''' myDialog.Terminate()
45 ''' Detailed user documentation:
46 ''' https://help.libreoffice.org/latest/en-US/text/sbasic/shared/
03/sf_dialogcontrol.html?DbPAR=BASIC
48 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
50 REM ================================================================== EXCEPTIONS
52 Private Const CONTROLTYPEERROR =
"CONTROLTYPEERROR
"
53 Private Const TEXTFIELDERROR =
"TEXTFIELDERROR
"
55 REM ============================================================= PRIVATE MEMBERS
57 Private [Me] As Object
58 Private [_Parent] As Object
59 Private ObjectType As String
' Must be DIALOGCONTROL
60 Private ServiceName As String
63 Private _Name As String
64 Private _IndexOfNames As Long
' Index in ElementNames array. Used to access SF_Dialog._ControlCache
65 Private _DialogName As String
' Parent dialog name
67 ' Control UNO references
68 Private _ControlModel As Object
' com.sun.star.awt.XControlModel
69 Private _ControlView As Object
' com.sun.star.awt.XControl - stardiv.Toolkit.UnoDialogControl
70 Private _TreeDataModel As Object
' com.sun.star.awt.tree.MutableTreeDataModel
71 Private _GridColumnModel As Object
' com.sun.star.awt.grid.XGridColumnModel
72 Private _GridDataModel As Object
' com.sun.star.awt.grid.XGridDataModel
74 ' Control attributes
75 Private _ImplementationName As String
76 Private _ControlType As String
' One of the CTLxxx constants
78 ' Tree control on-select and on-expand attributes
79 ' Tree controls may be associated with events not defined in the Basic IDE
80 Private _OnNodeSelected As String
' Script to invoke when a node is selected
81 Private _OnNodeExpanded As String
' Script to invoke when a node is expanded
82 Private _SelectListener As Object
' com.sun.star.view.XSelectionChangeListener
83 Private _ExpandListener As Object
' com.sun.star.awt.tree.XTreeExpansionListener
85 ' Table control attributes
86 Private _ColumnWidths As Variant
' Array of column widths
88 REM ============================================================ MODULE CONSTANTS
90 Private Const CTLBUTTON =
"Button
"
91 Private Const CTLCHECKBOX =
"CheckBox
"
92 Private Const CTLCOMBOBOX =
"ComboBox
"
93 Private Const CTLCURRENCYFIELD =
"CurrencyField
"
94 Private Const CTLDATEFIELD =
"DateField
"
95 Private Const CTLFILECONTROL =
"FileControl
"
96 Private Const CTLFIXEDLINE =
"FixedLine
"
97 Private Const CTLFIXEDTEXT =
"FixedText
"
98 Private Const CTLFORMATTEDFIELD =
"FormattedField
"
99 Private Const CTLGROUPBOX =
"GroupBox
"
100 Private Const CTLIMAGECONTROL =
"ImageControl
"
101 Private Const CTLLISTBOX =
"ListBox
"
102 Private Const CTLNUMERICFIELD =
"NumericField
"
103 Private Const CTLPATTERNFIELD =
"PatternField
"
104 Private Const CTLPROGRESSBAR =
"ProgressBar
"
105 Private Const CTLRADIOBUTTON =
"RadioButton
"
106 Private Const CTLSCROLLBAR =
"ScrollBar
"
107 Private Const CTLTABLECONTROL =
"TableControl
"
108 Private Const CTLTEXTFIELD =
"TextField
"
109 Private Const CTLTIMEFIELD =
"TimeField
"
110 Private Const CTLTREECONTROL =
"TreeControl
"
112 REM ====================================================== CONSTRUCTOR/DESTRUCTOR
114 REM -----------------------------------------------------------------------------
115 Private Sub Class_Initialize()
117 Set [_Parent] = Nothing
118 ObjectType =
"DIALOGCONTROL
"
119 ServiceName =
"SFDialogs.DialogControl
"
122 _DialogName =
""
123 Set _ControlModel = Nothing
124 Set _ControlView = Nothing
125 Set _TreeDataModel = Nothing
126 Set _GridColumnModel = Nothing
127 Set _GridDataModel = Nothing
128 _ImplementationName =
""
129 _ControlType =
""
130 _OnNodeSelected =
""
131 _OnNodeExpanded =
""
132 Set _SelectListener = Nothing
133 Set _ExpandListener = Nothing
134 _ColumnWidths = Array()
135 End Sub
' SFDialogs.SF_DialogControl Constructor
137 REM -----------------------------------------------------------------------------
138 Private Sub Class_Terminate()
139 Call Class_Initialize()
140 End Sub
' SFDialogs.SF_DialogControl Destructor
142 REM -----------------------------------------------------------------------------
143 Public Function Dispose() As Variant
144 Call Class_Terminate()
145 Set Dispose = Nothing
146 End Function
' SFDialogs.SF_DialogControl Explicit Destructor
148 REM ================================================================== PROPERTIES
150 REM -----------------------------------------------------------------------------
151 Property Get Cancel() As Variant
152 ''' The Cancel property specifies if a command button has or not the behaviour of a Cancel button.
153 Cancel = _PropertyGet(
"Cancel
", False)
154 End Property
' SFDialogs.SF_DialogControl.Cancel (get)
156 REM -----------------------------------------------------------------------------
157 Property Let Cancel(Optional ByVal pvCancel As Variant)
158 ''' Set the updatable property Cancel
159 _PropertySet(
"Cancel
", pvCancel)
160 End Property
' SFDialogs.SF_DialogControl.Cancel (let)
162 REM -----------------------------------------------------------------------------
163 Property Get Caption() As Variant
164 ''' The Caption property refers to the text associated with the control
165 Caption = _PropertyGet(
"Caption
",
"")
166 End Property
' SFDialogs.SF_DialogControl.Caption (get)
168 REM -----------------------------------------------------------------------------
169 Property Let Caption(Optional ByVal pvCaption As Variant)
170 ''' Set the updatable property Caption
171 _PropertySet(
"Caption
", pvCaption)
172 End Property
' SFDialogs.SF_DialogControl.Caption (let)
174 REM -----------------------------------------------------------------------------
175 Property Get ControlType() As String
176 ''' Return the type of the actual control:
"CheckBox
",
"TextField
",
"DateField
", ...
177 ControlType = _PropertyGet(
"ControlType
")
178 End Property
' SFDialogs.SF_DialogControl.ControlType
180 REM -----------------------------------------------------------------------------
181 Property Get CurrentNode() As Variant
182 ''' The CurrentNode property returns the currently selected node
183 ''' It returns Empty when there is no node selected
184 ''' When there are several selections, it returns the topmost node among the selected ones
185 CurrentNode = _PropertyGet(
"CurrentNode
",
"")
186 End Property
' SFDialogs.SF_DialogControl.CurrentNode (get)
188 REM -----------------------------------------------------------------------------
189 Property Let CurrentNode(Optional ByVal pvCurrentNode As Variant)
190 ''' Set a single selection in a tree control
191 _PropertySet(
"CurrentNode
", pvCurrentNode)
192 End Property
' SFDialogs.SF_DialogControl.CurrentNode (let)
194 REM -----------------------------------------------------------------------------
195 Property Get Default() As Variant
196 ''' The Default property specifies whether a command button is the default (OK) button.
197 Default = _PropertyGet(
"Default
", False)
198 End Property
' SFDialogs.SF_DialogControl.Default (get)
200 REM -----------------------------------------------------------------------------
201 Property Let Default(Optional ByVal pvDefault As Variant)
202 ''' Set the updatable property Default
203 _PropertySet(
"Default
", pvDefault)
204 End Property
' SFDialogs.SF_DialogControl.Default (let)
206 REM -----------------------------------------------------------------------------
207 Property Get Enabled() As Variant
208 ''' The Enabled property specifies if the control is accessible with the cursor.
209 Enabled = _PropertyGet(
"Enabled
")
210 End Property
' SFDialogs.SF_DialogControl.Enabled (get)
212 REM -----------------------------------------------------------------------------
213 Property Let Enabled(Optional ByVal pvEnabled As Variant)
214 ''' Set the updatable property Enabled
215 _PropertySet(
"Enabled
", pvEnabled)
216 End Property
' SFDialogs.SF_DialogControl.Enabled (let)
218 REM -----------------------------------------------------------------------------
219 Property Get Format() As Variant
220 ''' The Format property specifies the format in which to display dates and times.
221 Format = _PropertyGet(
"Format
",
"")
222 End Property
' SFDialogs.SF_DialogControl.Format (get)
224 REM -----------------------------------------------------------------------------
225 Property Let Format(Optional ByVal pvFormat As Variant)
226 ''' Set the updatable property Format
227 ''' NB: Format is read-only for formatted field controls
228 _PropertySet(
"Format
", pvFormat)
229 End Property
' SFDialogs.SF_DialogControl.Format (let)
231 REM -----------------------------------------------------------------------------
232 Property Get ListCount() As Long
233 ''' The ListCount property specifies the number of rows in a list box or a combo box
234 ListCount = _PropertyGet(
"ListCount
",
0)
235 End Property
' SFDialogs.SF_DialogControl.ListCount (get)
237 REM -----------------------------------------------------------------------------
238 Property Get ListIndex() As Variant
239 ''' The ListIndex property specifies which item is selected in a list box or combo box.
240 ''' In case of multiple selection, the index of the first one is returned or only one is set
241 ListIndex = _PropertyGet(
"ListIndex
", -
1)
242 End Property
' SFDialogs.SF_DialogControl.ListIndex (get)
244 REM -----------------------------------------------------------------------------
245 Property Let ListIndex(Optional ByVal pvListIndex As Variant)
246 ''' Set the updatable property ListIndex
247 _PropertySet(
"ListIndex
", pvListIndex)
248 End Property
' SFDialogs.SF_DialogControl.ListIndex (let)
250 REM -----------------------------------------------------------------------------
251 Property Get Locked() As Variant
252 ''' The Locked property specifies if a control is read-only
253 Locked = _PropertyGet(
"Locked
", False)
254 End Property
' SFDialogs.SF_DialogControl.Locked (get)
256 REM -----------------------------------------------------------------------------
257 Property Let Locked(Optional ByVal pvLocked As Variant)
258 ''' Set the updatable property Locked
259 _PropertySet(
"Locked
", pvLocked)
260 End Property
' SFDialogs.SF_DialogControl.Locked (let)
262 REM -----------------------------------------------------------------------------
263 Property Get MultiSelect() As Variant
264 ''' The MultiSelect property specifies whether a user can make multiple selections in a listbox
265 MultiSelect = _PropertyGet(
"MultiSelect
", False)
266 End Property
' SFDialogs.SF_DialogControl.MultiSelect (get)
268 REM -----------------------------------------------------------------------------
269 Property Let MultiSelect(Optional ByVal pvMultiSelect As Variant)
270 ''' Set the updatable property MultiSelect
271 _PropertySet(
"MultiSelect
", pvMultiSelect)
272 End Property
' SFDialogs.SF_DialogControl.MultiSelect (let)
274 REM -----------------------------------------------------------------------------
275 Property Get Name() As String
276 ''' Return the name of the actual control
277 Name = _PropertyGet(
"Name
")
278 End Property
' SFDialogs.SF_DialogControl.Name
280 REM -----------------------------------------------------------------------------
281 Property Get OnActionPerformed() As Variant
282 ''' Get the script associated with the OnActionPerformed event
283 OnActionPerformed = _PropertyGet(
"OnActionPerformed
")
284 End Property
' SFDialogs.SF_DialogControl.OnActionPerformed (get)
286 REM -----------------------------------------------------------------------------
287 Property Get OnAdjustmentValueChanged() As Variant
288 ''' Get the script associated with the OnAdjustmentValueChanged event
289 OnAdjustmentValueChanged = _PropertyGet(
"OnAdjustmentValueChanged
")
290 End Property
' SFDialogs.SF_DialogControl.OnAdjustmentValueChanged (get)
292 REM -----------------------------------------------------------------------------
293 Property Get OnFocusGained() As Variant
294 ''' Get the script associated with the OnFocusGained event
295 OnFocusGained = _PropertyGet(
"OnFocusGained
")
296 End Property
' SFDialogs.SF_DialogControl.OnFocusGained (get)
298 REM -----------------------------------------------------------------------------
299 Property Get OnFocusLost() As Variant
300 ''' Get the script associated with the OnFocusLost event
301 OnFocusLost = _PropertyGet(
"OnFocusLost
")
302 End Property
' SFDialogs.SF_DialogControl.OnFocusLost (get)
304 REM -----------------------------------------------------------------------------
305 Property Get OnItemStateChanged() As Variant
306 ''' Get the script associated with the OnItemStateChanged event
307 OnItemStateChanged = _PropertyGet(
"OnItemStateChanged
")
308 End Property
' SFDialogs.SF_DialogControl.OnItemStateChanged (get)
310 REM -----------------------------------------------------------------------------
311 Property Get OnKeyPressed() As Variant
312 ''' Get the script associated with the OnKeyPressed event
313 OnKeyPressed = _PropertyGet(
"OnKeyPressed
")
314 End Property
' SFDialogs.SF_DialogControl.OnKeyPressed (get)
316 REM -----------------------------------------------------------------------------
317 Property Get OnKeyReleased() As Variant
318 ''' Get the script associated with the OnKeyReleased event
319 OnKeyReleased = _PropertyGet(
"OnKeyReleased
")
320 End Property
' SFDialogs.SF_DialogControl.OnKeyReleased (get)
322 REM -----------------------------------------------------------------------------
323 Property Get OnMouseDragged() As Variant
324 ''' Get the script associated with the OnMouseDragged event
325 OnMouseDragged = _PropertyGet(
"OnMouseDragged
")
326 End Property
' SFDialogs.SF_DialogControl.OnMouseDragged (get)
328 REM -----------------------------------------------------------------------------
329 Property Get OnMouseEntered() As Variant
330 ''' Get the script associated with the OnMouseEntered event
331 OnMouseEntered = _PropertyGet(
"OnMouseEntered
")
332 End Property
' SFDialogs.SF_DialogControl.OnMouseEntered (get)
334 REM -----------------------------------------------------------------------------
335 Property Get OnMouseExited() As Variant
336 ''' Get the script associated with the OnMouseExited event
337 OnMouseExited = _PropertyGet(
"OnMouseExited
")
338 End Property
' SFDialogs.SF_DialogControl.OnMouseExited (get)
340 REM -----------------------------------------------------------------------------
341 Property Get OnMouseMoved() As Variant
342 ''' Get the script associated with the OnMouseMoved event
343 OnMouseMoved = _PropertyGet(
"OnMouseMoved
")
344 End Property
' SFDialogs.SF_DialogControl.OnMouseMoved (get)
346 REM -----------------------------------------------------------------------------
347 Property Get OnMousePressed() As Variant
348 ''' Get the script associated with the OnMousePressed event
349 OnMousePressed = _PropertyGet(
"OnMousePressed
")
350 End Property
' SFDialogs.SF_DialogControl.OnMousePressed (get)
352 REM -----------------------------------------------------------------------------
353 Property Get OnMouseReleased() As Variant
354 ''' Get the script associated with the OnMouseReleased event
355 OnMouseReleased = _PropertyGet(
"OnMouseReleased
")
356 End Property
' SFDialogs.SF_DialogControl.OnMouseReleased (get)
358 REM -----------------------------------------------------------------------------
359 Property Get OnNodeExpanded() As Variant
360 ''' Get the script associated with the OnNodeExpanded event
361 OnNodeExpanded = _PropertyGet(
"OnNodeExpanded
")
362 End Property
' SFDialogs.SF_DialogControl.OnNodeExpanded (get)
364 REM -----------------------------------------------------------------------------
365 Property Let OnNodeExpanded(Optional ByVal pvOnNodeExpanded As Variant)
366 ''' Set the updatable property OnNodeExpanded
367 _PropertySet(
"OnNodeExpanded
", pvOnNodeExpanded)
368 End Property
' SFDialogs.SF_DialogControl.OnNodeExpanded (let)
370 REM -----------------------------------------------------------------------------
371 Property Get OnNodeSelected() As Variant
372 ''' Get the script associated with the OnNodeSelected event
373 OnNodeSelected = _PropertyGet(
"OnNodeSelected
")
374 End Property
' SFDialogs.SF_DialogControl.OnNodeSelected (get)
376 REM -----------------------------------------------------------------------------
377 Property Let OnNodeSelected(Optional ByVal pvOnNodeSelected As Variant)
378 ''' Set the updatable property OnNodeSelected
379 _PropertySet(
"OnNodeSelected
", pvOnNodeSelected)
380 End Property
' SFDialogs.SF_DialogControl.OnNodeSelected (let)
382 REM -----------------------------------------------------------------------------
383 Property Get OnTextChanged() As Variant
384 ''' Get the script associated with the OnTextChanged event
385 OnTextChanged = _PropertyGet(
"OnTextChanged
")
386 End Property
' SFDialogs.SF_DialogControl.OnTextChanged (get)
388 REM -----------------------------------------------------------------------------
389 Property Get Page() As Variant
390 ''' 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.
391 ''' The Page property of a control defines the page of the dialog on which the control is visible.
392 ''' For example, if a control has a page value of
1, it is only visible on page
1 of the dialog.
393 ''' 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.
394 Page = _PropertyGet(
"Page
")
395 End Property
' SFDialogs.SF_DialogControl.Page (get)
397 REM -----------------------------------------------------------------------------
398 Property Let Page(Optional ByVal pvPage As Variant)
399 ''' Set the updatable property Page
400 _PropertySet(
"Page
", pvPage)
401 End Property
' SFDialogs.SF_DialogControl.Page (let)
403 REM -----------------------------------------------------------------------------
404 Property Get Parent() As Object
405 ''' Return the Parent dialog object of the actual control
406 Parent = _PropertyGet(
"Parent
", Nothing)
407 End Property
' SFDialogs.SF_DialogControl.Parent
409 REM -----------------------------------------------------------------------------
410 Property Get Picture() As Variant
411 ''' The Picture property specifies a bitmap or other type of graphic to be displayed on the specified control
412 Picture = _PropertyGet(
"Picture
",
"")
413 End Property
' SFDialogs.SF_DialogControl.Picture (get)
415 REM -----------------------------------------------------------------------------
416 Property Let Picture(Optional ByVal pvPicture As Variant)
417 ''' Set the updatable property Picture
418 _PropertySet(
"Picture
", pvPicture)
419 End Property
' SFDialogs.SF_DialogControl.Picture (let)
421 REM -----------------------------------------------------------------------------
422 Property Get RootNode() As Variant
423 ''' The RootNode property returns the last root node of a tree control
424 RootNode = _PropertyGet(
"RootNode
",
"")
425 End Property
' SFDialogs.SF_DialogControl.RootNode (get)
427 REM -----------------------------------------------------------------------------
428 Property Get RowSource() As Variant
429 ''' The RowSource property specifies the data contained in a combobox or a listbox
430 ''' as a zero-based array of string values
431 RowSource = _PropertyGet(
"RowSource
",
"")
432 End Property
' SFDialogs.SF_DialogControl.RowSource (get)
434 REM -----------------------------------------------------------------------------
435 Property Let RowSource(Optional ByVal pvRowSource As Variant)
436 ''' Set the updatable property RowSource
437 _PropertySet(
"RowSource
", pvRowSource)
438 End Property
' SFDialogs.SF_DialogControl.RowSource (let)
440 REM -----------------------------------------------------------------------------
441 Property Get Text() As Variant
442 ''' The Text property specifies the actual content of the control like it is displayed on the screen
443 Text = _PropertyGet(
"Text
",
"")
444 End Property
' SFDialogs.SF_DialogControl.Text (get)
446 REM -----------------------------------------------------------------------------
447 Property Get TipText() As Variant
448 ''' The TipText property specifies the text that appears in a screentip when you hold the mouse pointer over a control
449 TipText = _PropertyGet(
"TipText
",
"")
450 End Property
' SFDialogs.SF_DialogControl.TipText (get)
452 REM -----------------------------------------------------------------------------
453 Property Let TipText(Optional ByVal pvTipText As Variant)
454 ''' Set the updatable property TipText
455 _PropertySet(
"TipText
", pvTipText)
456 End Property
' SFDialogs.SF_DialogControl.TipText (let)
458 REM -----------------------------------------------------------------------------
459 Property Get TripleState() As Variant
460 ''' The TripleState property specifies how a check box will display Null values
461 ''' 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.
462 ''' When False, the control will cycle through states for Yes and No values. Null values display as if they were No values.
463 TripleState = _PropertyGet(
"TripleState
", False)
464 End Property
' SFDialogs.SF_DialogControl.TripleState (get)
466 REM -----------------------------------------------------------------------------
467 Property Let TripleState(Optional ByVal pvTripleState As Variant)
468 ''' Set the updatable property TripleState
469 _PropertySet(
"TripleState
", pvTripleState)
470 End Property
' SFDialogs.SF_DialogControl.TripleState (let)
472 REM -----------------------------------------------------------------------------
473 Property Get Value() As Variant
474 ''' The Value property specifies the data contained in the control
475 Value = _PropertyGet(
"Value
", Empty)
476 End Property
' SFDialogs.SF_DialogControl.Value (get)
478 REM -----------------------------------------------------------------------------
479 Property Let Value(Optional ByVal pvValue As Variant)
480 ''' Set the updatable property Value
481 _PropertySet(
"Value
", pvValue)
482 End Property
' SFDialogs.SF_DialogControl.Value (let)
484 REM -----------------------------------------------------------------------------
485 Property Get Visible() As Variant
486 ''' The Visible property specifies if the control is accessible with the cursor.
487 Visible = _PropertyGet(
"Visible
", True)
488 End Property
' SFDialogs.SF_DialogControl.Visible (get)
490 REM -----------------------------------------------------------------------------
491 Property Let Visible(Optional ByVal pvVisible As Variant)
492 ''' Set the updatable property Visible
493 _PropertySet(
"Visible
", pvVisible)
494 End Property
' SFDialogs.SF_DialogControl.Visible (let)
496 REM -----------------------------------------------------------------------------
497 Property Get XControlModel() As Object
498 ''' The XControlModel property returns the model UNO object of the control
499 XControlModel = _PropertyGet(
"XControlModel
", Nothing)
500 End Property
' SFDialogs.SF_DialogControl.XControlModel (get)
502 REM -----------------------------------------------------------------------------
503 Property Get XControlView() As Object
504 ''' The XControlView property returns the view UNO object of the control
505 XControlView = _PropertyGet(
"XControlView
", Nothing)
506 End Property
' SFDialogs.SF_DialogControl.XControlView (get)
508 REM -----------------------------------------------------------------------------
509 Property Get XGridColumnModel() As Object
510 ''' The XGridColumnModel property returns the mutable data model UNO object of the tree control
511 XGridColumnModel = _PropertyGet(
"XGridColumnModel
", Nothing)
512 End Property
' SFDialogs.SF_DialogControl.XGridColumnModel (get)
514 REM -----------------------------------------------------------------------------
515 Property Get XGridDataModel() As Object
516 ''' The XGridDataModel property returns the mutable data model UNO object of the tree control
517 XGridDataModel = _PropertyGet(
"XGridDataModel
", Nothing)
518 End Property
' SFDialogs.SF_DialogControl.XGridDataModel (get)
520 REM -----------------------------------------------------------------------------
521 Property Get XTreeDataModel() As Object
522 ''' The XTreeDataModel property returns the mutable data model UNO object of the tree control
523 XTreeDataModel = _PropertyGet(
"XTreeDataModel
", Nothing)
524 End Property
' SFDialogs.SF_DialogControl.XTreeDataModel (get)
526 REM ===================================================================== METHODS
528 REM -----------------------------------------------------------------------------
529 Public Function AddSubNode(Optional ByRef ParentNode As Variant _
530 , Optional ByVal DisplayValue As Variant _
531 , Optional ByRef DataValue As Variant _
533 ''' Return a new node of the tree control subordinate to a parent node
534 ''' Args:
535 ''' ParentNode: A node UNO object, of type com.sun.star.awt.tree.XMutableTreeNode
536 ''' DisplayValue: the text appearing in the control box
537 ''' DataValue: any value associated with the new node. Default = Empty
538 ''' Returns:
539 ''' The new node UNO object: com.sun.star.awt.tree.XMutableTreeNode
540 ''' Examples:
541 ''' Dim myTree As Object, myNode As Object, theRoot As Object
542 ''' Set myTree = myDialog.Controls(
"myTreeControl
")
543 ''' Set theRoot = myTree.CreateRoot(
"Tree top
")
544 ''' Set myNode = myTree.AddSubNode(theRoot,
"A branch ...
")
546 Dim oNode As Object
' Return value
547 Const cstThisSub =
"SFDialogs.DialogControl.AddSubNode
"
548 Const cstSubArgs =
"ParentNode, DisplayValue, [DataValue=Empty]
"
550 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
554 If IsMissing(DataValue) Then DataValue = Empty
555 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
556 If _ControlType
<> CTLTREECONTROL Then GoTo CatchType
557 If Not ScriptForge.SF_Utils._Validate(ParentNode,
"ParentNode
", V_OBJECT) Then GoTo Catch
558 If ScriptForge.SF_Session.UnoObjectType(ParentNode)
<> "toolkit.MutableTreeNode
" Then GoTo Catch
559 If Not ScriptForge.SF_Utils._Validate(DisplayValue,
"DisplayValue
", V_STRING) Then GoTo Catch
564 Set oNode = .createNode(DisplayValue, True)
565 oNode.DataValue = DataValue
566 ParentNode.appendChild(oNode)
570 Set AddSubNode = oNode
571 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
576 ScriptForge.SF_Exception.RaiseFatal(CONTROLTYPEERROR, _Name, _DialogName, _ControlType,
"AddSubNode
")
578 End Function
' SFDialogs.SF_DialogControl.AddSubNode
580 REM -----------------------------------------------------------------------------
581 Public Function AddSubTree(Optional ByRef ParentNode As Variant _
582 , Optional ByRef FlatTree As Variant _
583 , Optional ByVal WithDataValue As Variant _
585 ''' Return True when a subtree, subordinate to a parent node, could be inserted successfully in a tree control
586 ''' If the parent node had already child nodes before calling this method, the child nodes are erased
587 ''' Args:
588 ''' ParentNode: A node UNO object, of type com.sun.star.awt.tree.XMutableTreeNode
589 ''' FlatTree: a
2D array sorted on the columns containing the DisplayValues
590 ''' Flat tree
>>>> Resulting subtree
591 ''' A1 B1 C1 |__ A1
592 ''' A1 B1 C2 |__ B1
593 ''' A1 B2 C3 |__ C1
594 ''' A2 B3 C4 |__ C2
595 ''' A2 B3 C5 |__ B2
596 ''' A3 B4 C6 |__ C3
597 ''' |__ A2
598 ''' |__ B3
599 ''' |__ C4
600 ''' |__ C5
601 ''' |__ A3
602 ''' |__ B4
603 ''' |__ C6
604 ''' Typically, such an array can be issued by the GetRows method applied on the SFDatabases.Database service
605 ''' when an array item containing the text to be displayed is =
"" or is empty/null,
606 ''' no new subnode is created and the remainder of the row is skipped
607 ''' When AddSubTree() is called from a Python script, FlatTree may be an array of arrays
608 ''' WithDataValue:
609 ''' When False (default), every column of FlatTree contains the text to be displayed in the tree control
610 ''' When True, the texts to be displayed (DisplayValue) are in columns
0,
2,
4, ...
611 ''' while the DataValues are in columns
1,
3,
5, ...
612 ''' Returns:
613 ''' True when successful
614 ''' Examples:
615 ''' Dim myTree As Object, theRoot As Object, oDb As Object, vData As Variant
616 ''' Set myTree = myDialog.Controls(
"myTreeControl
")
617 ''' Set theRoot = myTree.CreateRoot(
"By product category
")
618 ''' Set oDb = CreateScriptService(
"SFDatabases.Database
",
"/home/.../mydatabase.odb
")
619 ''' vData = oDb.GetRows(
"SELECT [Category].[Name], [Category].[ID], [Product].[Name], [Product].[ID]
" _
620 ''' & "FROM [Category], [Product] WHERE [Product].[CategoryID] = [Category].[ID]
" _
621 ''' & "ORDER BY [Category].[Name], [Product].[Name]
")
622 ''' myTree.AddSubTree(theRoot, vData, WithDataValue := True)
624 Dim bSubTree As Boolean
' Return value
625 Dim oNode As Object
' com.sun.star.awt.tree.XMutableTreeNode
626 Dim oNewNode As Object
' com.sun.star.awt.tree.XMutableTreeNode
627 Dim lChildCount As Long
' Number of children nodes of a parent node
628 Dim iStep As Integer
' 1 when WithDataValue = False,
2 otherwise
629 Dim iDims As Integer
' Number of dimensions of FlatTree
630 Dim lMin1 As Long
' Lower bound (rows)
631 Dim lMin2 As Long
' Lower bounds (cols)
632 Dim lMax1 As Long
' Upper bound (rows)
633 Dim lMax2 As Long
' Upper bounds (cols)
634 Dim vFlatItem As Variant
' A single FlatTree item: FlatTree(i, j)
635 Dim vFlatItem2 As Variant
' A single FlatTree item
636 Dim bChange As Boolean
' When True, the item in FlatTree is different from the item above
637 Dim sValue As String
' Alias for display values
638 Dim i As Long, j As Long
639 Const cstThisSub =
"SFDialogs.DialogControl.AddSubTree
"
640 Const cstSubArgs =
"ParentNode, FlatTree, [WithDataValue=False]
"
642 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
646 If IsMissing(WithDataValue) Or IsEmpty(WithDataValue) Then WithDataValue = False
647 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
648 If _ControlType
<> CTLTREECONTROL Then GoTo CatchType
649 If Not ScriptForge.SF_Utils._Validate(ParentNode,
"ParentNode
", V_OBJECT) Then GoTo Catch
650 If ScriptForge.SF_Session.UnoObjectType(ParentNode)
<> "toolkit.MutableTreeNode
" Then GoTo Catch
651 If Not ScriptForge.SF_Utils._ValidateArray(FlatTree,
"FlatTree
") Then GoTo Catch
' Dimensions checked below
652 If Not ScriptForge.SF_Utils._Validate(WithDataValue,
"WithDataValue
", V_BOOLEAN) Then GoTo Catch
658 lChildCount = ParentNode.getChildCount()
659 For i =
1 To lChildCount
660 ParentNode.removeChildByIndex(
0)
' This cleans all subtrees too
663 ' Determine bounds
664 iDims = ScriptForge.SF_Array.CountDims(FlatTree)
666 Case -
1,
0 : GoTo Catch
667 Case
1 ' Called probably from Python
668 lMin1 = LBound(FlatTree,
1) : lMax1 = UBound(FlatTree,
1)
669 If Not IsArray(FlatTree(
0)) Then GoTo Catch
670 If UBound(FlatTree(
0))
< LBound(FlatTree(
0)) Then GoTo Catch
' No columns
671 lMin2 = LBound(FlatTree(
0)) : lMax2 = UBound(FlatTree(
0))
673 lMin1 = LBound(FlatTree,
1) : lMax1 = UBound(FlatTree,
1)
674 lMin2 = LBound(FlatTree,
2) : lMax2 = UBound(FlatTree,
2)
675 Case Else : GoTo Catch
678 ' Build a new subtree
679 iStep = Iif(WithDataValue,
2,
1)
680 For i = lMin1 To lMax1
682 ' Restart from the parent node at each i-iteration
683 Set oNode = ParentNode
684 For j = lMin2 To lMax2 Step iStep
' Array columns
685 If iDims =
1 Then vFlatItem = FlatTree(i)(j) Else vFlatItem = FlatTree(i, j)
686 If vFlatItem =
"" Or IsNull(vFlatItem) Or IsEmpty(vFlatItem) Then
688 Exit For
' Exit j-loop
691 If iDims =
1 Then vFlatItem2 = FlatTree(i -
1)(j) Else vFlatItem2 = FlatTree(i -
1, j)
692 bChange = ( vFlatItem
<> vFlatItem2 )
694 If bChange Then
' Create new subnode at tree depth = j
695 If VarType(vFlatItem) = V_STRING Then sValue = vFlatItem Else sValue = ScriptForge.SF_String.Represent(vFlatItem)
696 Set oNewNode = .createNode(sValue, True)
697 If WithDataValue Then
698 If iDims =
1 Then vFlatItem2 = FlatTree(i)(j +
1) Else vFlatItem2 = FlatTree(i, j +
1)
699 oNewNode.DataValue = vFlatItem2
701 oNode.appendChild(oNewNode)
704 ' Position next current node on last child of actual current node
705 lChildCount = oNode.getChildCount()
706 If lChildCount
> 0 Then Set oNode = oNode.getChildAt(lChildCount -
1) Else Set oNode = Nothing
714 AddSubTree = bSubTree
715 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
720 ScriptForge.SF_Exception.RaiseFatal(CONTROLTYPEERROR, _Name, _DialogName, _ControlType,
"AddSubTree
")
722 End Function
' SFDialogs.SF_DialogControl.AddSubTree
724 REM -----------------------------------------------------------------------------
725 Public Function CreateRoot(Optional ByVal DisplayValue As Variant _
726 , Optional ByRef DataValue As Variant _
728 ''' Return a new root node of the tree control. The new tree root is inserted below pre-existing root nodes
729 ''' Args:
730 ''' DisplayValue: the text appearing in the control box
731 ''' DataValue: any value associated with the root node. Default = Empty
732 ''' Returns:
733 ''' The new root node as a UNO object of type com.sun.star.awt.tree.XMutableTreeNode
734 ''' Examples:
735 ''' Dim myTree As Object, myNode As Object
736 ''' Set myTree = myDialog.Controls(
"myTreeControl
")
737 ''' Set myNode = myTree.CreateRoot(
"Tree starts here ...
")
739 Dim oRoot As Object
' Return value
740 Const cstThisSub =
"SFDialogs.DialogControl.CreateRoot
"
741 Const cstSubArgs =
"DisplayValue, [DataValue=Empty]
"
743 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
747 If IsMissing(DataValue) Then DataValue = Empty
748 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
749 If _ControlType
<> CTLTREECONTROL Then GoTo CatchType
750 If Not ScriptForge.SF_Utils._Validate(DisplayValue,
"DisplayValue
", V_STRING) Then GoTo Catch
755 Set oRoot = .createNode(DisplayValue, True)
756 oRoot.DataValue = DataValue
758 ' To be visible, a root must have contained at least
1 child. Create a fictive one and erase it.
759 ' This behaviour does not seem related to the RootDisplayed property ??
760 oRoot.appendChild(.createNode(
"Something
", False))
761 oRoot.removeChildByIndex(
0)
765 Set CreateRoot = oRoot
766 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
771 ScriptForge.SF_Exception.RaiseFatal(CONTROLTYPEERROR, _Name, _DialogName, _ControlType,
"CreateRoot
")
773 End Function
' SFDialogs.SF_DialogControl.CreateRoot
775 REM -----------------------------------------------------------------------------
776 Public Function FindNode(Optional ByVal DisplayValue As String _
777 , Optional ByRef DataValue As Variant _
778 , Optional ByVal CaseSensitive As Boolean _
780 ''' Traverses the tree and find recursively, starting from the root, a node meeting some criteria
781 ''' Either (
1 match is enough):
782 ''' having its DisplayValue like DisplayValue
783 ''' having its DataValue = DataValue
784 ''' Comparisons may be or not case-sensitive
785 ''' The first matching occurrence is returned
786 ''' Args:
787 ''' DisplayValue: the pattern to be matched
788 ''' DataValue: a string, a numeric value or a date or Empty (if not applicable)
789 ''' CaseSensitive: applicable on both criteria. Default = False
790 ''' Returns:
791 ''' The found node of type com.sun.star.awt.tree.XMutableTreeNode or Nothing if not found
792 ''' Examples:
793 ''' Dim myTree As Object, myNode As Object
794 ''' Set myTree = myDialog.Controls(
"myTreeControl
")
795 ''' Set myNode = myTree.FindNode(
"*Sophie*
", CaseSensitive := True)
798 Dim oNode As Object
' Return value
799 Const cstThisSub =
"SFDialogs.DialogControl.FindNode
"
800 Const cstSubArgs =
"[DisplayValue=
""""], [DataValue=Empty], [CaseSensitive=False]
"
802 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
806 If IsMissing(DisplayValue) Or IsEmpty(DisplayValue) Then DisplayValue =
""
807 If IsMissing(DataValue) Then DataValue = Empty
808 If IsMissing(CaseSensitive) Or IsEmpty(CaseSensitive) Then CaseSensitive = False
809 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
810 If _ControlType
<> CTLTREECONTROL Then GoTo CatchType
811 If Not ScriptForge.SF_Utils._Validate(DisplayValue,
"DisplayValue
", V_STRING) Then GoTo Catch
812 If Not ScriptForge.SF_Utils._Validate(CaseSensitive,
"CaseSensitive
", ScriptForge.V_BOOLEAN) Then GoTo Catch
816 Set oNode = _FindNode(_TreeDataModel.getRoot(), DisplayValue, DataValue, CaseSensitive)
820 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
825 ScriptForge.SF_Exception.RaiseFatal(CONTROLTYPEERROR, _Name, _DialogName, _ControlType,
"FindNode
")
827 End Function
' SFDialogs.SF_DialogControl.FindNode
829 REM -----------------------------------------------------------------------------
830 Public Function GetProperty(Optional ByVal PropertyName As Variant) As Variant
831 ''' Return the actual value of the given property
832 ''' Args:
833 ''' PropertyName: the name of the property as a string
834 ''' Returns:
835 ''' The actual value of the property
836 ''' If the property does not exist, returns Null
837 ''' Exceptions:
838 ''' see the exceptions of the individual properties
839 ''' Examples:
840 ''' myModel.GetProperty(
"MyProperty
")
842 Const cstThisSub =
"SFDialogs.DialogControl.GetProperty
"
843 Const cstSubArgs =
""
845 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
849 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
850 If Not ScriptForge.SF_Utils._Validate(PropertyName,
"PropertyName
", V_STRING, Properties()) Then GoTo Catch
854 GetProperty = _PropertyGet(PropertyName)
857 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
861 End Function
' SFDialogs.SF_DialogControl.GetProperty
863 REM -----------------------------------------------------------------------------
864 Public Function Methods() As Variant
865 ''' Return the list of public methods of the Model service as an array
868 "AddSubNode
" _
869 ,
"AddSubTree
" _
870 ,
"CreateRoot
" _
871 ,
"FindNode
" _
872 ,
"SetFocus
" _
873 ,
"WriteLine
" _
876 End Function
' SFDialogs.SF_DialogControl.Methods
878 REM -----------------------------------------------------------------------------
879 Public Function Properties() As Variant
880 ''' Return the list or properties of the Timer class as an array
882 Properties = Array( _
884 ,
"Caption
" _
885 ,
"ControlType
" _
886 ,
"CurrentNode
" _
887 ,
"Default
" _
888 ,
"Enabled
" _
889 ,
"Format
" _
890 ,
"ListCount
" _
891 ,
"ListIndex
" _
892 ,
"Locked
" _
893 ,
"MultiSelect
" _
895 ,
"OnActionPerformed
" _
896 ,
"OnAdjustmentValueChanged
" _
897 ,
"OnFocusGained
" _
898 ,
"OnFocusLost
" _
899 ,
"OnItemStateChanged
" _
900 ,
"OnKeyPressed
" _
901 ,
"OnKeyReleased
" _
902 ,
"OnMouseDragged
" _
903 ,
"OnMouseEntered
" _
904 ,
"OnMouseExited
" _
905 ,
"OnMouseMoved
" _
906 ,
"OnMousePressed
" _
907 ,
"OnMouseReleased
" _
908 ,
"OnNodeExpanded
" _
909 ,
"OnNodeSelected
" _
910 ,
"OnTextChanged
" _
912 ,
"Parent
" _
913 ,
"Picture
" _
914 ,
"RootNode
" _
915 ,
"RowSource
" _
917 ,
"TipText
" _
918 ,
"TripleState
" _
919 ,
"Value
" _
920 ,
"Visible
" _
921 ,
"XControlModel
" _
922 ,
"XControlView
" _
923 ,
"XGridColumnModel
" _
924 ,
"XGridDataModel
" _
925 ,
"XTreeDataModel
" _
928 End Function
' SFDialogs.SF_DialogControl.Properties
930 REM -----------------------------------------------------------------------------
931 Public Function SetFocus() As Boolean
932 ''' Set the focus on the current Control instance
933 ''' Probably called from after an event occurrence
934 ''' Args:
935 ''' Returns:
936 ''' True if focusing is successful
937 ''' Example:
938 ''' Dim oDlg As Object, oControl As Object
939 ''' Set oDlg = CreateScriptService(,,
"myControl
")
' Control stored in current document
's standard library
940 ''' Set oControl = oDlg.Controls(
"thisControl
")
941 ''' oControl.SetFocus()
943 Dim bSetFocus As Boolean
' Return value
944 Const cstThisSub =
"SFDialogs.DialogControl.SetFocus
"
945 Const cstSubArgs =
""
947 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
951 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
952 If Not [_Parent]._IsStillAlive() Then GoTo Finally
956 If Not IsNull(_ControlView) Then
957 _ControlView.setFocus()
963 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
967 End Function
' SFControls.SF_DialogControl.SetFocus
969 REM -----------------------------------------------------------------------------
970 Public Function SetProperty(Optional ByVal PropertyName As Variant _
971 , Optional ByRef Value As Variant _
973 ''' Set a new value to the given property
974 ''' Args:
975 ''' PropertyName: the name of the property as a string
976 ''' Value: its new value
977 ''' Exceptions
978 ''' ARGUMENTERROR The property does not exist
980 Const cstThisSub =
"SFDialogs.DialogControl.SetProperty
"
981 Const cstSubArgs =
"PropertyName, Value
"
983 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
987 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
988 If Not SF_Utils._Validate(PropertyName,
"PropertyName
", V_STRING, Properties()) Then GoTo Catch
992 SetProperty = _PropertySet(PropertyName, Value)
995 SF_Utils._ExitFunction(cstThisSub)
999 End Function
' SFDialogs.SF_DialogControl.SetProperty
1001 REM -----------------------------------------------------------------------------
1002 Public Function SetTableData(Optional ByRef DataArray As Variant _
1003 , Optional ByRef Widths As Variant _
1004 , Optional ByRef Alignments As Variant _
1006 ''' Fill a table control with the given data. Preexisting data is erased
1007 ''' The Basic IDE allows to define if the control has a row and/or a column header
1008 ''' When it is the case, the array in argument should contain those headers resp. in the first
1009 ''' column and/or in the first row
1010 ''' A column in the control shall be sortable when the data (headers excluded) in that column
1011 ''' is homogeneously filled either with numbers or with strings
1012 ''' Columns containing strings will be left-aligned, those with numbers will be right-aligned
1013 ''' Args:
1014 ''' DataArray: the set of data to display in the table control, including optional column/row headers
1015 ''' Is a
2D array in Basic, is a tuple of tuples when called from Python
1016 ''' Widths: the column
's relative widths as a
1D array, each element corresponding with a column
1017 ''' If the array is shorter than the number of columns, the last value is kept for the next columns.
1018 ''' Example:
1019 ''' Widths := Array(
1,
2)
1020 ''' means that the first column is half as wide as all the other columns
1021 ''' When the argument is absent, the columns are evenly spread over the control
1022 ''' Alignments: the column
's horizontal alignment as a string with length = number of columns.
1023 ''' Possible characters are:
1024 ''' L(EFT), C(ENTER), R(IGHT) or space (default behaviour)
1025 ''' Returns:
1026 ''' True when successful
1027 ''' Examples:
1028 ''' Dim myTable As Object, bSet As Boolean, vData As Variant
1029 ''' Set myTable = myDialog.Controls(
"myTableControl
")
' This control has only column headers
1030 ''' vData = Array(
"Col1
",
"Col2
",
"Col3
")
1031 ''' vData = SF_Array.AppendRow(vData, Array(
1,
2,
3))
1032 ''' vData = SF_Array.AppendRow(vData, Array(
4,
5,
6))
1033 ''' vData = SF_Array.AppendRow(vData, Array(
7,
8,
9))
1034 ''' bSet = myTable.SetTableData(vData, Alignments :=
" C
")
1036 Dim bData As Boolean
' Return value
1037 Dim iDims As Integer
' Number of dimensions of DataArray
1038 Dim lMin1 As Long
' LBound1 of input array
1039 Dim lMax1 As Long
' UBound1 of input array
1040 Dim lMin2 As Long
' LBound2 of input array
1041 Dim lMax2 As Long
' UBound2 of input array
1042 Dim lControlWidth As Long
' Width of the table control
1043 Dim lMinW As Long
' lBound of Widths
1044 Dim lMaxW As Long
' UBound of vWidths
1045 Dim lMinRow As Long
' Row index of effective data subarray
1046 Dim lMinCol As Long
' Column index of effective data subarray
1047 Dim vRowHeaders As Variant
' Array of row headers
1048 Dim sRowHeader As String
' A single row header
1049 Dim vColHeaders As Variant
' Array of column headers
1050 Dim oColumn As Object
' com.sun.star.awt.grid.XGridColumn
1051 Dim dWidth As Double
' A single item of Widths
1052 Dim dRelativeWidth As Double
' Sum of Widths up to the number of columns
1053 Dim dWidthFactor As Double
' Factor to apply to relative widths to get absolute column widths
1054 Dim vDataRow As Variant
' A single row content in the tablecontrol
1055 Dim vDataItem As Variant
' A single DataArray item
1056 Dim sAlign As String
' Column
's horizontal alignments (single chars: L, C, R, space)
1057 Dim lAlign As Long
' com.sun.star.style.HorizontalAlignment.XXX
1058 Dim i As Long, j As Long, k As Long
1060 Const cstRowHdrWidth =
12 ' Estimated width of the row header
1062 Const cstThisSub =
"SFDialogs.DialogControl.SetTableData
"
1063 Const cstSubArgs =
"DataArray, [Widths=Array(
1)], [Alignments=
""""]
"
1065 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
1069 If IsMissing(Widths) Or IsEmpty(Widths) Then Widths = Array(
1)
1070 If IsMissing(Alignments) Or IsEmpty(Alignments) Then Alignments =
""
1071 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
1072 If _ControlType
<> CTLTABLECONTROL Then GoTo CatchType
1073 If Not ScriptForge.SF_Utils._ValidateArray(DataArray,
"DataArray
") Then GoTo Catch
' Dimensions are checked below
1074 If Not ScriptForge.SF_Utils._ValidateArray(Widths,
"Widths
",
1, ScriptForge.V_NUMERIC, True) Then GoTo Catch
1075 If Not ScriptForge.SF_Utils._Validate(Alignments,
"Alignments
", V_STRING) Then GoTo Catch
1079 ' Erase any pre-existing data and columns
1080 _GridDataModel.removeAllRows()
1081 For i = _GridColumnModel.ColumnCount -
1 To
0 Step -
1
1082 _GridColumnModel.removeColumn(i)
1085 ' LBounds, UBounds - Basic or Pytho
1086 iDims = ScriptForge.SF_Array.CountDims(DataArray)
1088 Case -
1,
0 : GoTo Catch
1089 Case
1 ' Called probably from Python
1090 lMin1 = LBound(DataArray,
1) : lMax1 = UBound(DataArray,
1)
1091 If Not IsArray(DataArray(
0)) Then GoTo Catch
1092 If UBound(DataArray(
0))
< LBound(DataArray(
0)) Then GoTo Catch
' No columns
1093 lMin2 = LBound(DataArray(
0)) : lMax2 = UBound(DataArray(
0))
1095 lMin1 = LBound(DataArray,
1) : lMax1 = UBound(DataArray,
1)
1096 lMin2 = LBound(DataArray,
2) : lMax2 = UBound(DataArray,
2)
1097 Case Else : GoTo Catch
1100 ' Extract headers from data array
1101 lMinW = LBound(Widths) : lMaxW = UBound(Widths)
1103 If .ShowColumnHeader Then
1106 vColHeaders = DataArray(lMin1)
1108 vColHeaders = ScriptForge.SF_Array.ExtractRow(DataArray, lMin1)
1112 vColHeaders = Array()
1114 If .ShowRowHeader Then
1117 vRowHeaders = Array()
1118 ReDim vRowHeaders(lMin1 To lMax1)
1119 For i = lMin1 To lMax1
1120 vRowHeaders(i) = DataArray(i)(lMin2)
1123 vRowHeaders = ScriptForge.SF_Array.ExtractColumn(DataArray, lMin2)
1127 vRowHeaders = Array()
1131 ' Create the columns
1132 For j = lMinCol To lMax2
1133 Set oColumn = _GridColumnModel.createColumn()
1134 If _ControlModel.ShowColumnHeader Then oColumn.Title = vColHeaders(j)
1135 _GridColumnModel.addColumn(oColumn)
1137 ' Size the columns. Column sizing cannot be done before all the columns are added
1138 If lMaxW
>= lMinW Then
' There must be at least
1 width given as argument
1139 ' Size the columns proportionally with their relative widths
1140 dRelativeWidth =
0.0
1142 ' Compute the sum of the relative widths
1143 For j =
0 To lMax2 - lMinCol
1145 If i
>= lMinW And i
<= lMaxW Then dRelativeWidth = dRelativeWidth + Widths(i) Else dRelativeWidth = dRelativeWidth + Widths(lMaxW)
1147 ' Set absolute widths
1148 If dRelativeWidth
> 0.0 Then dWidthFactor = CDbl((_ControlModel.Width - cstRowHdrWidth) / dRelativeWidth) Else dWidthFactor =
1.0
1150 For j =
0 To lMax2 - lMinCol
1152 If i
>= lMinW And i
<= lMaxW Then dWidth = CDbl(Widths(i)) Else dWidth = CDbl(Widths(lMaxW))
1153 _GridColumnModel.Columns(j).ColumnWidth = CLng(dWidthFactor * dWidth)
1156 ' Size all columns evenly
1157 For j =
0 To lMax2 - lMinCol
1158 _GridColumnModel.Columns(j).ColumnWidth = (_ControlModel.Width - cstRowHdrWidth) / (lMax2 - lMonCol +
1)
1162 ' Initialize the column alignment
1163 If Len(Alignments)
>= lMax2 - lMinCol +
1 Then sAlign = Alignments Else sAlign = Alignments
& Space(lMax2 - lMinCol +
1 - Len(Alignments))
1165 ' Feed the table with data and define/confirm the column alignment
1167 For i = lMinRow To lMax1
1168 ReDim vDataRow(
0 To lMax2 - lMinCol)
1169 For j = lMinCol To lMax2
1170 If iDims =
1 Then vDataItem = DataArray(i)(j) Else vDataItem = DataArray(i, j)
1171 If VarType(vDataItem) = V_STRING Then
1172 ElseIf ScriptForge.SF_Utils._VarTypeExt(vDataItem) = ScriptForge.V_NUMERIC Then
1174 vDataItem = ScriptForge.SF_String.Represent(vDataItem)
1176 vDataRow(j - lMinCol) = vDataItem
1177 ' Store alignment while processing the first row of the array
1180 If Mid(sAlign, k,
1) =
" " Then Mid(sAlign, k,
1) = Iif(VarType(vDataItem) = V_STRING,
"L
",
"R
")
1183 If _ControlModel.ShowRowHeader Then sRowHeader = vRowHeaders(i) Else sRowHeader =
""
1184 _GridDataModel.addRow(sRowHeader, vDataRow)
1187 ' Determine alignments of each column
1188 For j =
0 To lMax2 - lMinCol
1189 Select Case Mid(sAlign, j +
1,
1)
1190 Case
"L
",
" " : lAlign = com.sun.star.style.HorizontalAlignment.LEFT
1191 Case
"R
" : lAlign = com.sun.star.style.HorizontalAlignment.RIGHT
1192 Case
"C
" : lAlign = com.sun.star.style.HorizontalAlignment.CENTER
1195 _GridColumnModel.Columns(j).HorizontalAlign = lAlign
1201 SetTableData = bData
1202 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
1207 ScriptForge.SF_Exception.RaiseFatal(CONTROLTYPEERROR, _Name, _DialogName, _ControlType,
"SetTableData
")
1209 End Function
' SFDialogs.SF_DialogControl.SetTableData
1211 REM -----------------------------------------------------------------------------
1212 Public Function WriteLine(Optional ByVal Line As Variant) As Boolean
1213 ''' Add a new line to a multiline TextField control
1214 ''' Args:
1215 ''' Line: (default =
"") the line to insert at the end of the text box
1216 ''' a newline character will be inserted before the line, if relevant
1217 ''' Returns:
1218 ''' True if insertion is successful
1219 ''' Exceptions
1220 ''' TEXTFIELDERROR Method applicable on multiline text fields only
1221 ''' Example:
1222 ''' Dim oDlg As Object, oControl As Object
1223 ''' Set oDlg = CreateScriptService(,,
"myControl
")
' Control stored in current document
's standard library
1224 ''' Set oControl = oDlg.Controls(
"thisControl
")
1225 ''' oControl.WriteLine(
"a new line
")
1227 Dim bWriteLine As Boolean
' Return value
1228 Dim lTextLength As Long
' Actual length of text in box
1229 Dim oSelection As New com.sun.star.awt.Selection
1230 Dim sNewLine As String
' Newline character(s)
1231 Const cstThisSub =
"SFDialogs.DialogControl.WriteLine
"
1232 Const cstSubArgs =
"[Line=
""""]
"
1234 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
1238 If IsMissing(Line) Or IsEmpty(Line) Then Line =
""
1239 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
1240 If Not [_Parent]._IsStillAlive() Then GoTo Finally
1241 If Not ScriptForge.SF_Utils._Validate(Line,
"Line
", V_STRING) Then GoTo Finally
1243 If ControlType
<> CTLTEXTFIELD Then GoTo CatchField
1244 If _ControlModel.MultiLine = False Then GoTo CatchField
1247 _ControlModel.HardLineBreaks = True
1248 sNewLine = ScriptForge.SF_String.sfNEWLINE
1250 lTextLength = Len(.getText())
1251 If lTextLength =
0 Then
' Text field is still empty
1252 oSelection.Min =
0 : oSelection.Max =
0
1254 Else
' Put cursor at the end of the actual text
1255 oSelection.Min = lTextLength : oSelection.Max = lTextLength
1256 .insertText(oSelection, sNewLine
& Line)
1258 ' Put the cursor at the end of the inserted text
1259 oSelection.Max = oSelection.Max + Len(sNewLine) + Len(Line)
1260 oSelection.Min = oSelection.Max
1261 .setSelection(oSelection)
1266 WriteLine = bWriteLine
1267 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
1272 ScriptForge.SF_Exception.RaiseFatal(TEXTFIELDERROR, _Name, _DialogName)
1274 End Function
' SFControls.SF_DialogControl.WriteLine
1276 REM =========================================================== PRIVATE FUNCTIONS
1278 REM -----------------------------------------------------------------------------
1279 Private Function _FindNode(ByRef poNode As Object _
1280 , ByVal psDisplayValue As String _
1281 , ByRef pvDataValue As Variant _
1282 , ByVal pbCaseSensitive As Boolean _
1284 ''' Traverses the tree and find recursively, starting from the root, a node meeting some criteria
1285 ''' Either (
1 match is enough):
1286 ''' having its DisplayValue like psDisplayValue
1287 ''' having its DataValue = pvDataValue
1288 ''' Comparisons may be or not case-sensitive
1289 ''' The first matching occurrence is returned
1290 ''' Args:
1291 ''' poNode: the current node, the root at
1st call
1292 ''' psDisplayValue: the pattern to be matched
1293 ''' pvDataValue: a string, a numeric value or a date or Empty (if not applicable)
1294 ''' pbCaseSensitive: applicable on both criteria
1295 ''' Returns:
1296 ''' The found node of type com.sun.star.awt.tree.XMutableTreeNode
1298 Dim oChild As Object
' Child node com.sun.star.awt.tree.XMutableTreeNode
1299 Dim oFind As Object
' Found node com.sun.star.awt.tree.XMutableTreeNode
1300 Dim lChildCount As Long
' Number of children of a node
1301 Dim bFound As Boolean
' True when node found
1304 Set _FindNode = Nothing
1305 On Local Error GoTo Finally
' Better not found than raise an error
1308 ' Does the actual node match the criteria ?
1310 If Len(psDisplayValue)
> 0 Then
1311 bFound = ScriptForge.SF_String.IsLike(poNode.DisplayValue, psDisplayValue, pbCaseSensitive)
1313 If Not bFound And Not IsEmpty(poNode.DataValue) Then
1314 If Not IsEmpty(pvdataValue) Then bFound = ( ScriptForge.SF_Array._ValCompare(poNode.DataValue, pvDataB-Value, pbCaseSensitive) =
0 )
1317 Set _FindNode = poNode
1322 ' Explore sub-branches
1323 lChildCount = poNode.getChildCount
1324 If lChildCount
> 0 Then
1325 For i =
0 To lChildCount -
1
1326 Set oChild = poNode.getChildAt(i)
1327 Set oFind = _FindNode(oChild, psDisplayValue, pvDataValue, pbCaseSensitive)
' Recursive call
1328 If Not IsNull(oFind) Then
1329 Set _FindNode = oFind
1337 End Function
' SFDialogs.SF_DialogControl._FindNode
1339 REM -----------------------------------------------------------------------------
1340 Private Function _FormatsList() As Variant
1341 ''' Return the allowed format entries as a zero-based array for Date and Time control types
1343 Dim vFormats() As Variant
' Return value
1345 Select Case _ControlType
1348 "Standard (short)
" _
1349 ,
"Standard (short YY)
" _
1350 ,
"Standard (short YYYY)
" _
1351 ,
"Standard (long)
" _
1352 ,
"DD/MM/YY
" _
1353 ,
"MM/DD/YY
" _
1354 ,
"YY/MM/DD
" _
1355 ,
"DD/MM/YYYY
" _
1356 ,
"MM/DD/YYYY
" _
1357 ,
"YYYY/MM/DD
" _
1358 ,
"YY-MM-DD
" _
1359 ,
"YYYY-MM-DD
" _
1363 "24h short
" _
1364 ,
"24h long
" _
1365 ,
"12h short
" _
1366 ,
"12h long
" _
1372 _FormatsList = vFormats
1374 End Function
' SFDialogs.SF_DialogControl._FormatsList
1376 REM -----------------------------------------------------------------------------
1377 Public Function _GetEventName(ByVal psProperty As String) As String
1378 ''' Return the LO internal event name derived from the SF property name
1379 ''' The SF property name is not case sensitive, while the LO name is case-sensitive
1380 ' Corrects the typo on ErrorOccur(r?)ed, if necessary
1382 Dim vProperties As Variant
' Array of class properties
1383 Dim sProperty As String
' Correctly cased property name
1385 vProperties = Properties()
1386 sProperty = vProperties(ScriptForge.SF_Array.IndexOf(vProperties, psProperty, SortOrder :=
"ASC
"))
1388 _GetEventName = LCase(Mid(sProperty,
3,
1))
& Right(sProperty, Len(sProperty) -
3)
1390 End Function
' SFDialogs.SF_DialogControl._GetEventName
1392 REM -----------------------------------------------------------------------------
1393 Private Function _GetListener(ByVal psEventName As String) As String
1394 ''' Getting/Setting macros triggered by events requires a Listener-EventName pair
1395 ''' Return the X...Listener corresponding with the event name in argument
1397 Select Case UCase(psEventName)
1398 Case UCase(
"OnActionPerformed
")
1399 _GetListener =
"XActionListener
"
1400 Case UCase(
"OnAdjustmentValueChanged
")
1401 _GetListener =
"XAdjustmentListener
"
1402 Case UCase(
"OnFocusGained
"), UCase(
"OnFocusLost
")
1403 _GetListener =
"XFocusListener
"
1404 Case UCase(
"OnItemStateChanged
")
1405 _GetListener =
"XItemListener
"
1406 Case UCase(
"OnKeyPressed
"), UCase(
"OnKeyReleased
")
1407 _GetListener =
"XKeyListener
"
1408 Case UCase(
"OnMouseDragged
"), UCase(
"OnMouseMoved
")
1409 _GetListener =
"XMouseMotionListener
"
1410 Case UCase(
"OnMouseEntered
"), UCase(
"OnMouseExited
"), UCase(
"OnMousePressed
"), UCase(
"OnMouseReleased
")
1411 _GetListener =
"XMouseListener
"
1412 Case UCase(
"OnTextChanged
")
1413 _GetListener =
"XTextListener
"
1415 _GetListener =
""
1418 End Function
' SFDialogs.SF_DialogControl._GetListener
1420 REM -----------------------------------------------------------------------------
1421 Public Sub _Initialize()
1422 ''' Complete the object creation process:
1423 ''' - Initialization of private members
1424 ''' - Collection of specific attributes
1425 ''' - synchronization with parent dialog instance
1427 Dim vServiceName As Variant
' Split service name
1428 Dim sType As String
' Last component of service name
1431 _ImplementationName = _ControlModel.getImplementationName()
1433 ' Identify the control type
1434 vServiceName = Split(_ControlModel.getServiceName(),
".
")
1435 sType = vServiceName(UBound(vServiceName))
1437 Case
"UnoControlSpinButtonModel
"
1438 _ControlType =
"" ' Not supported
1439 Case
"Edit
" : _ControlType = CTLTEXTFIELD
1440 Case
"TreeControlModel
"
1441 ' Initialize the data model
1442 _ControlType = CTLTREECONTROL
1443 Set _ControlModel.DataModel = CreateUnoService(
"com.sun.star.awt.tree.MutableTreeDataModel
")
1444 Set _TreeDataModel = _ControlModel.DataModel
1445 Case
"UnoControlGridModel
"
1446 _ControlType = CTLTABLECONTROL
1447 Set _GridColumnModel = _ControlModel.ColumnModel
1448 Set _GridDataModel = _ControlModel.GridDataModel
1449 Case Else : _ControlType = sType
1452 ' Store the SF_DialogControl object in the parent cache
1453 Set _Parent._ControlCache(_IndexOfNames) = [Me]
1457 End Sub
' SFDialogs.SF_DialogControl._Initialize
1459 REM -----------------------------------------------------------------------------
1460 Private Function _PropertyGet(Optional ByVal psProperty As String _
1461 , Optional ByVal pvDefault As Variant _
1463 ''' Return the value of the named property
1464 ''' Args:
1465 ''' psProperty: the name of the property
1466 ''' pvDefault: the value returned when the property is not applicable on the control
's type
1467 ''' Getting a non-existing property for a specific control type should
1468 ''' not generate an error to not disrupt the Basic IDE debugger
1470 Dim vGet As Variant
' Return value
1471 Static oSession As Object
' Alias of SF_Session
1472 Dim vSelection As Variant
' Alias of Model.SelectedItems or Model.Selection
1473 Dim vList As Variant
' Alias of Model.StringItemList
1474 Dim lIndex As Long
' Index in StringItemList
1475 Dim sItem As String
' A single item
1476 Dim vDate As Variant
' com.sun.star.util.Date or com.sun.star.util.Time
1477 Dim vValues As Variant
' Array of listbox values
1478 Dim oControlEvents As Object
' com.sun.star.container.XNameContainer
1479 Dim sEventName As String
' Internal event name
1481 Dim cstThisSub As String
1482 Const cstSubArgs =
""
1484 cstThisSub =
"SFDialogs.DialogControl.get
" & psProperty
1485 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
1487 ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
1488 If Not [_Parent]._IsStillAlive() Then GoTo Finally
1490 If IsMissing(pvDefault) Then pvDefault = Null
1491 _PropertyGet = pvDefault
1493 If IsNull(oSession) Then Set oSession = ScriptForge.SF_Services.CreateScriptService(
"Session
")
1494 Select Case UCase(psProperty)
1495 Case UCase(
"Cancel
")
1496 Select Case _ControlType
1498 If oSession.HasUNOProperty(_ControlModel,
"PushButtonType
") Then _PropertyGet = ( _ControlModel.PushButtonType = com.sun.star.awt.PushButtonType.CANCEL )
1499 Case Else : GoTo CatchType
1501 Case UCase(
"Caption
")
1502 Select Case _ControlType
1503 Case CTLBUTTON, CTLCHECKBOX, CTLFIXEDLINE, CTLFIXEDTEXT, CTLGROUPBOX, CTLRADIOBUTTON
1504 If oSession.HasUNOProperty(_ControlModel,
"Label
") Then _PropertyGet = _ControlModel.Label
1505 Case Else : GoTo CatchType
1507 Case UCase(
"ControlType
")
1508 _PropertyGet = _ControlType
1509 Case UCase(
"CurrentNode
")
1510 Select Case _ControlType
1512 If oSession.HasUNOMethod(_ControlView,
"getSelection
") Then
1513 _PropertyGet = Empty
1514 If _ControlModel.SelectionType
<> com.sun.star.view.SelectionType.NONE Then
1515 vSelection = _ControlView.getSelection()
1516 If IsArray(vSelection) Then
1517 If UBound(vSelection)
>=
0 Then Set _PropertyGet = vSelection(
0)
1519 Set _PropertyGet = vSelection
1523 Case Else : GoTo CatchType
1525 Case UCase(
"Default
")
1526 Select Case _ControlType
1528 If oSession.HasUNOProperty(_ControlModel,
"DefaultButton
") Then _PropertyGet = _ControlModel.DefaultButton
1529 Case Else : GoTo CatchType
1531 Case UCase(
"Enabled
")
1532 If oSession.HasUnoProperty(_ControlModel,
"Enabled
") Then _PropertyGet = _ControlModel.Enabled
1533 Case UCase(
"Format
")
1534 Select Case _ControlType
1536 If oSession.HasUNOProperty(_ControlModel,
"DateFormat
") Then _PropertyGet = _FormatsList()(_ControlModel.DateFormat)
1538 If oSession.HasUNOProperty(_ControlModel,
"TimeFormat
") Then _PropertyGet = _FormatsList()(_ControlModel.TimeFormat)
1539 Case CTLFORMATTEDFIELD
1540 If oSession.HasUNOProperty(_ControlModel,
"FormatsSupplier
") And oSession.HasUNOProperty(_ControlModel,
"FormatKey
") Then
1541 _PropertyGet = _ControlModel.FormatsSupplier.getNumberFormats.getByKey(_ControlModel.FormatKey).FormatString
1543 Case Else : GoTo CatchType
1545 Case UCase(
"ListCount
")
1546 Select Case _ControlType
1547 Case CTLCOMBOBOX, CTLLISTBOX
1548 If oSession.HasUNOProperty(_ControlModel,
"StringItemList
") Then _PropertyGet = UBound(_ControlModel.StringItemList) +
1
1549 Case CTLTABLECONTROL
' Returns zero when no table data yet
1550 If oSession.HasUNOProperty(_GridDataModel,
"RowCount
") Then _PropertyGet = _GridDataModel.RowCount
1551 Case Else : GoTo CatchType
1553 Case UCase(
"ListIndex
")
1554 Select Case _ControlType
1556 _PropertyGet = -
1 ' Not found, multiselection
1557 If oSession.HasUNOProperty(_ControlModel,
"Text
") And oSession.HasUNOProperty(_ControlModel,
"StringItemList
") Then
1558 _PropertyGet = ScriptForge.SF_Array.IndexOf(_ControlModel.StringItemList, _ControlModel.Text, CaseSensitive := True)
1561 _PropertyGet = -
1 ' Not found, multiselection
1562 If oSession.HasUNOProperty(_ControlModel,
"SelectedItems
") And oSession.HasUNOProperty(_ControlModel,
"StringItemList
") Then
1563 vSelection = _ControlModel.SelectedItems
1564 If UBound(vSelection)
>=
0 Then _PropertyGet = vSelection(
0)
1566 Case CTLTABLECONTROL
1567 _PropertyGet = -
1 ' No row selected, no data, multiselection
1568 If oSession.HasUNOProperty(_ControlModel,
"SelectionModel
") _
1569 And oSession.HasUNOProperty(_ControlView,
"CurrentRow
") Then
1570 ' Other selection types (multi, range) not supported
1571 If _ControlModel.SelectionModel = com.sun.star.view.SelectionType.SINGLE Then
1572 lIndex = _ControlView.CurrentRow
1573 If lIndex
< 0 And oSession.HasUNOProperty(_ControlView,
"SelectedRows
") Then
1574 If UBound(_ControlView.SelectedRows)
>=
0 Then lIndex = _ControlView.SelectedRows(
0)
1576 _PropertyGet = lIndex
1579 Case Else : GoTo CatchType
1581 Case UCase(
"Locked
")
1582 Select Case _ControlType
1583 Case CTLCOMBOBOX, CTLCURRENCYFIELD, CTLDATEFIELD, CTLFILECONTROL, CTLFORMATTEDFIELD, CTLLISTBOX _
1584 , CTLNUMERICFIELD, CTLPATTERNFIELD, CTLTEXTFIELD, CTLTIMEFIELD
1585 If oSession.HasUnoProperty(_ControlModel,
"ReadOnly
") Then _PropertyGet = _ControlModel.ReadOnly
1586 Case Else : GoTo CatchType
1588 Case UCase(
"MultiSelect
")
1589 Select Case _ControlType
1591 If oSession.HasUnoProperty(_ControlModel,
"MultiSelection
") Then
1592 _PropertyGet = _ControlModel.MultiSelection
1593 ElseIf oSession.HasUnoProperty(_ControlModel,
"MultiSelectionSimpleMode
") Then
' Not documented: gridcontrols only TBC ??
1594 _PropertyGet = _ControlModel.MultiSelectionSimpleMode
1596 Case Else : GoTo CatchType
1598 Case UCase(
"Name
")
1599 _PropertyGet = _Name
1600 Case UCase(
"OnActionPerformed
"), UCase(
"OnAdjustmentValueChanged
"), UCase(
"OnFocusGained
"), UCase(
"OnFocusLost
") _
1601 , UCase(
"OnItemStateChanged
"), UCase(
"OnKeyPressed
"), UCase(
"OnKeyReleased
") _
1602 , UCase(
"OnMouseDragged
"), UCase(
"OnMouseEntered
"), UCase(
"OnMouseExited
"), UCase(
"OnMouseMoved
") _
1603 , UCase(
"OnMousePressed
"), UCase(
"OnMouseReleased
"), UCase(
"OnTextChanged
")
1604 Set oControlEvents = _ControlModel.getEvents()
1605 sEventName =
"com.sun.star.awt.
" & _GetListener(psProperty)
& "::
" & _GetEventName(psProperty)
1606 If oControlEvents.hasByName(sEventName) Then
1607 _PropertyGet = oControlEvents.getByName(sEventName).ScriptCode
1609 _PropertyGet =
""
1611 Case UCase(
"OnNodeExpanded
")
1612 Select Case _ControlType
1614 _PropertyGet = _OnNodeExpanded
1615 Case Else : GoTo CatchType
1617 Case UCase(
"OnNodeSelected
")
1618 Select Case _ControlType
1620 _PropertyGet = _OnNodeSelected
1621 Case Else : GoTo CatchType
1623 Case UCase(
"Page
")
1624 If oSession.HasUnoProperty(_ControlModel,
"Step
") Then _PropertyGet = _ControlModel.Step
1625 Case UCase(
"Parent
")
1626 Set _PropertyGet = [_Parent]
1627 Case UCase(
"Picture
")
1628 Select Case _ControlType
1629 Case CTLBUTTON, CTLIMAGECONTROL
1630 If oSession.HasUnoProperty(_ControlModel,
"ImageURL
") Then _PropertyGet = ScriptForge.SF_FileSystem._ConvertFromUrl(_ControlModel.ImageURL)
1631 Case Else : GoTo CatchType
1633 Case UCase(
"RootNode
")
1634 Select Case _ControlType
1636 _PropertyGet = _TreeDataModel.getRoot()
1637 Case Else : GoTo CatchType
1639 Case UCase(
"RowSource
")
1640 Select Case _ControlType
1641 Case CTLCOMBOBOX, CTLLISTBOX
1642 If oSession.HasUnoProperty(_ControlModel,
"StringItemList
") Then
1643 If IsArray(_ControlModel.StringItemList) Then _PropertyGet = _ControlModel.StringItemList Else _PropertyGet = Array(_ControlModel.StringItemList)
1645 Case Else : GoTo CatchType
1647 Case UCase(
"Text
")
1648 Select Case _ControlType
1649 Case CTLCOMBOBOX, CTLFILECONTROL, CTLFORMATTEDFIELD, CTLPATTERNFIELD, CTLTEXTFIELD
1650 If oSession.HasUnoProperty(_ControlModel,
"Text
") Then _PropertyGet = _ControlModel.Text
1651 Case Else : GoTo CatchType
1653 Case UCase(
"TipText
")
1654 If oSession.HasUnoProperty(_ControlModel,
"HelpText
") Then _PropertyGet = _ControlModel.HelpText
1655 Case UCase(
"TripleState
")
1656 Select Case _ControlType
1658 If oSession.HasUnoProperty(_ControlModel,
"TriState
") Then _PropertyGet = _ControlModel.TriState
1659 Case Else : GoTo CatchType
1661 Case UCase(
"Value
")
' Default values are set here by control type, not in the
2nd argument
1663 Select Case _ControlType
1664 Case CTLBUTTON
'Boolean, toggle buttons only
1666 If oSession.HasUnoProperty(_ControlModel,
"Toggle
") Then
1667 If oSession.HasUnoProperty(_ControlModel,
"State
") Then vGet = ( _ControlModel.State =
1 )
1669 Case CTLCHECKBOX
'0 = Not checked,
1 = Checked,
2 = Don
't know
1670 If oSession.HasUnoProperty(_ControlModel,
"State
") Then vGet = _ControlModel.State Else vGet =
2
1671 Case CTLCOMBOBOX, CTLFILECONTROL, CTLPATTERNFIELD, CTLTEXTFIELD
'String
1672 If oSession.HasUnoProperty(_ControlModel,
"Text
") Then vGet = _ControlModel.Text Else vGet =
""
1673 Case CTLCURRENCYFIELD, CTLNUMERICFIELD
'Numeric
1674 If oSession.HasUnoProperty(_ControlModel,
"Value
") Then vGet = _ControlModel.Value Else vGet =
0
1675 Case CTLDATEFIELD
'Date
1677 If oSession.HasUnoProperty(_ControlModel,
"Date
") Then
1678 If VarType(_ControlModel.Date) = ScriptForge.V_OBJECT Then
' com.sun.star.util.Date
1679 Set vDate = _ControlModel.Date
1680 vGet = DateSerial(vDate.Year, vDate.Month, vDate.Day)
1683 Case CTLFORMATTEDFIELD
'String or numeric
1684 If oSession.HasUnoProperty(_ControlModel,
"EffectiveValue
") Then vGet = _ControlModel.EffectiveValue Else vGet =
""
1685 Case CTLLISTBOX
'String or array of strings depending on MultiSelection
1686 ' StringItemList is the list of the items displayed in the box
1687 ' SelectedItems is the list of the indexes in StringItemList of the selected items
1688 ' It can go beyond the limits of StringItemList
1689 ' It can contain multiple values even if the listbox is not multiselect
1690 If oSession.HasUnoProperty(_ControlModel,
"StringItemList
") And oSession.HasUnoProperty(_ControlModel,
"SelectedItems
") _
1691 And oSession.HasUnoProperty(_ControlModel,
"MultiSelection
") Then
1692 vSelection = _ControlModel.SelectedItems
1693 vList = _ControlModel.StringItemList
1694 If _ControlModel.MultiSelection Then vValues = Array()
1695 For i =
0 To UBound(vSelection)
1696 lIndex = vSelection(i)
1697 If lIndex
>=
0 And lIndex
<= UBound(vList) Then
1698 If Not _ControlModel.MultiSelection Then
1699 vValues = vList(lIndex)
1702 vValues = ScriptForge.SF_Array.Append(vValues, vList(lIndex))
1709 Case CTLPROGRESSBAR
'Numeric
1710 If oSession.HasUnoProperty(_ControlModel,
"ProgressValue
") Then vGet = _ControlModel.ProgressValue Else vGet =
0
1711 Case CTLRADIOBUTTON
'Boolean
1712 If oSession.HasUnoProperty(_ControlModel,
"State
") Then vGet = ( _ControlModel.State =
1 ) Else vGet = False
1713 Case CTLSCROLLBAR
'Numeric
1714 If oSession.HasUnoProperty(_ControlModel,
"ScrollValue
") Then vGet = _ControlModel.ScrollValue Else vGet =
0
1715 Case CTLTABLECONTROL
1716 vGet = Array()
' Default value when no row selected, no data, multiselection
1717 If oSession.HasUNOProperty(_ControlModel,
"SelectionModel
") _
1718 And oSession.HasUNOProperty(_ControlView,
"CurrentRow
") Then
1719 ' Other selection types (multi, range) not supported
1720 If _ControlModel.SelectionModel = com.sun.star.view.SelectionType.SINGLE Then
1721 lIndex = _ControlView.CurrentRow
1722 If lIndex
< 0 And oSession.HasUNOProperty(_ControlView,
"SelectedRows
") Then
1723 If UBound(_ControlView.SelectedRows)
>=
0 Then lIndex = _ControlView.SelectedRows(
0)
1725 If lIndex
>=
0 Then vGet = _GridDataModel.getRowData(lIndex)
1730 If oSession.HasUnoProperty(_ControlModel,
"Time
") Then
1731 If VarType(_ControlModel.Time) = ScriptForge.V_OBJECT Then
' com.sun.star.Util.Time
1732 Set vDate = _ControlModel.Time
1733 vGet = TimeSerial(vDate.Hours, vDate.Minutes, vDate.Seconds)
1736 Case Else : GoTo CatchType
1739 Case UCase(
"Visible
")
1740 If oSession.HasUnoMethod(_ControlView,
"isVisible
") Then _PropertyGet = CBool(_ControlView.isVisible())
1741 Case UCase(
"XControlModel
")
1742 Set _PropertyGet = _ControlModel
1743 Case UCase(
"XControlView
")
1744 Set _PropertyGet = _ControlView
1745 Case UCase(
"XGridColumnModel
")
1746 Set _PropertyGet = _GridColumnModel
1747 Case UCase(
"XGridDataModel
")
1748 Set _PropertyGet = _GridDataModel
1749 Case UCase(
"XTreeDataModel
")
1750 Set _PropertyGet = _TreeDataModel
1756 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
1762 End Function
' SFDialogs.SF_DialogControl._PropertyGet
1764 REM -----------------------------------------------------------------------------
1765 Private Function _PropertySet(Optional ByVal psProperty As String _
1766 , Optional ByVal pvValue As Variant _
1768 ''' Set the new value of the named property
1769 ''' Args:
1770 ''' psProperty: the name of the property
1771 ''' pvValue: the new value of the given property
1773 Dim bSet As Boolean
' Return value
1774 Static oSession As Object
' Alias of SF_Session
1775 Dim vSet As Variant
' Value to set in UNO model or view property
1776 Dim vFormats As Variant
' Format property: output of _FormatsList()
1777 Dim iFormat As Integer
' Format property: index in vFormats
1778 Dim vSelection As Variant
' Alias of Model.SelectedItems
1779 Dim vList As Variant
' Alias of Model.StringItemList
1780 Dim lIndex As Long
' Index in StringItemList
1781 Dim sItem As String
' A single item
1782 Dim vCtlTypes As Variant
' Array of allowed control types
1784 Dim cstThisSub As String
1785 Const cstSubArgs =
"Value
"
1787 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
1790 cstThisSub =
"SFDialogs.DialogControl.set
" & psProperty
1791 ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
1792 If Not [_Parent]._IsStillAlive() Then GoTo Finally
1794 If IsNull(oSession) Then Set oSession = ScriptForge.SF_Services.CreateScriptService(
"Session
")
1796 Select Case UCase(psProperty)
1797 Case UCase(
"Cancel
")
1798 Select Case _ControlType
1800 If Not ScriptForge.SF_Utils._Validate(pvValue,
"Cancel
", ScriptForge.V_BOOLEAN) Then GoTo Finally
1801 If oSession.HasUNOProperty(_ControlModel,
"PushButtonType
") Then
1802 If pvValue Then vSet = com.sun.star.awt.PushButtonType.CANCEL Else vSet = com.sun.star.awt.PushButtonType.STANDARD
1803 _ControlModel.PushButtonType = vSet
1805 Case Else : GoTo CatchType
1807 Case UCase(
"Caption
")
1808 Select Case _ControlType
1809 Case CTLBUTTON, CTLCHECKBOX, CTLFIXEDLINE, CTLFIXEDTEXT, CTLGROUPBOX, CTLRADIOBUTTON
1810 If Not ScriptForge.SF_Utils._Validate(pvValue,
"Caption
", V_STRING) Then GoTo Finally
1811 If oSession.HasUNOProperty(_ControlModel,
"Label
") Then _ControlModel.Label = pvValue
1812 Case Else : GoTo CatchType
1814 Case UCase(
"CurrentNode
")
1815 Select Case _ControlType
1817 If Not ScriptForge.SF_Utils._Validate(pvValue,
"Selection
", ScriptForge.V_OBJECT) Then GoTo Finally
1818 If oSession.UnoObjectType(pvValue)
<> "toolkit.MutableTreeNode
" Then GoTo CatchType
1821 If Not IsNull(pvValue) Then
1822 .addSelection(pvValue)
1823 ' Suspending temporarily the expansion listener avoids conflicts
1824 If Len(_OnNodeExpanded)
> 0 Then _ControlView.removeTreeExpansionListener(_ExpandListener)
1825 .makeNodeVisible(pvValue)
' Expand parent nodes and put node in the display area
1826 If Len(_OnNodeExpanded)
> 0 Then _ControlView.addTreeExpansionListener(_ExpandListener)
1829 Case Else : GoTo CatchType
1831 Case UCase(
"Default
")
1832 Select Case _ControlType
1834 If Not ScriptForge.SF_Utils._Validate(pvValue,
"Default
", ScriptForge.V_BOOLEAN) Then GoTo Finally
1835 If oSession.HasUNOProperty(_ControlModel,
"DefaultButton
") Then _ControlModel.DefaultButton = pvValue
1836 Case Else : GoTo CatchType
1838 Case UCase(
"Enabled
")
1839 If Not ScriptForge.SF_Utils._Validate(pvValue,
"Enabled
", ScriptForge.V_BOOLEAN) Then GoTo Finally
1840 If oSession.HasUnoProperty(_ControlModel,
"Enabled
") Then _ControlModel.Enabled = pvValue
1841 Case UCase(
"Format
")
1842 Select Case _ControlType
1843 Case CTLDATEFIELD, CTLTIMEFIELD
1844 vFormats = _FormatsList()
1845 If Not ScriptForge.SF_Utils._Validate(pvValue,
"Format
", V_STRING, vFormats) Then GoTo Finally
1846 iFormat = ScriptForge.SF_Array.IndexOf(vFormats, pvValue, CaseSensitive := False)
1847 If oSession.HasUNOProperty(_ControlModel,
"DateFormat
") Then
1848 _ControlModel.DateFormat = iFormat
1849 ElseIf oSession.HasUNOProperty(_ControlModel,
"TimeFormat
") Then
1850 _ControlModel.TimeFormat = iFormat
1852 Case Else : GoTo CatchType
1854 Case UCase(
"ListIndex
")
1855 If Not ScriptForge.SF_Utils._Validate(pvValue,
"ListIndex
", ScriptForge.V_NUMERIC) Then GoTo Finally
1856 Select Case _ControlType
1858 If oSession.HasUNOProperty(_ControlModel,
"Text
") And oSession.HasUNOProperty(_ControlModel,
"StringItemList
") Then
1859 _ControlModel.Text = _ControlModel.StringItemList(CInt(pvValue))
1862 If oSession.HasUNOProperty(_ControlModel,
"SelectedItems
") Then _ControlModel.SelectedItems = Array(CInt(pvValue))
1863 Case CTLTABLECONTROL
1864 If oSession.HasUNOProperty(_ControlModel,
"SelectionModel
") _
1865 And oSession.HasUNOMethod(_ControlView,
"selectRow
") Then
1866 ' Other selection types (multi, range) not supported
1867 If _ControlModel.SelectionModel = com.sun.star.view.SelectionType.SINGLE _
1868 And pvValue
>=
0 And pvValue
<= _GridDataModel.RowCount -
1 Then
1869 _ControlView.selectRow(pvValue)
1872 Case Else : GoTo CatchType
1874 Case UCase(
"Locked
")
1875 Select Case _ControlType
1876 Case CTLCOMBOBOX, CTLCURRENCYFIELD, CTLDATEFIELD, CTLFILECONTROL, CTLFORMATTEDFIELD, CTLLISTBOX _
1877 , CTLNUMERICFIELD, CTLPATTERNFIELD, CTLTEXTFIELD, CTLTIMEFIELD
1878 If Not ScriptForge.SF_Utils._Validate(pvValue,
"Locked
", ScriptForge.V_BOOLEAN) Then GoTo Finally
1879 If oSession.HasUnoProperty(_ControlModel,
"ReadOnly
") Then _ControlModel.ReadOnly = pvValue
1880 Case Else : GoTo CatchType
1882 Case UCase(
"MultiSelect
")
1883 Select Case _ControlType
1885 If Not ScriptForge.SF_Utils._Validate(pvValue,
"MultiSelect
", ScriptForge.V_BOOLEAN) Then GoTo Finally
1886 If oSession.HasUnoProperty(_ControlModel,
"MultiSelection
") Then _ControlModel.MultiSelection = pvValue
1887 If oSession.HasUnoProperty(_ControlModel,
"MultiSelectionSimpleMode
") Then _ControlModel.MultiSelectionSimpleMode = pvValue
1888 If oSession.HasUnoProperty(_ControlModel,
"SelectedItems
") Then
1889 If Not pvValue And UBound(_ControlModel.SelectedItems)
> 0 Then
' Cancel selections when MultiSelect becomes False
1890 lIndex = _ControlModel.SelectedItems(
0)
1891 _ControlModel.SelectedItems = Array(lIndex)
1894 Case Else : GoTo CatchType
1896 Case UCase(
"OnNodeExpanded
")
1897 Select Case _ControlType
1899 If Not ScriptForge.SF_Utils._Validate(pvValue, psProperty, V_STRING) Then GoTo Finally
1900 ' If the listener was already set, then stop it
1901 If Len(_OnNodeExpanded)
> 0 Then
1902 _ControlView.removeTreeExpansionListener(_ExpandListener)
1903 Set _ExpandListener = Nothing
1904 _OnNodeExpanded =
""
1906 ' Setup a new fresh listener
1907 If Len(pvValue)
> 0 Then
1908 Set _ExpandListener = CreateUnoListener(
"_SFEXP_
",
"com.sun.star.awt.tree.XTreeExpansionListener
")
1909 _ControlView.addTreeExpansionListener(_ExpandListener)
1910 _OnNodeExpanded = pvValue
1912 Case Else : GoTo CatchType
1914 Case UCase(
"OnNodeSelected
")
1915 Select Case _ControlType
1917 If Not ScriptForge.SF_Utils._Validate(pvValue, psProperty, V_STRING) Then GoTo Finally
1918 ' If the listener was already set, then stop it
1919 If Len(_OnNodeSelected)
> 0 Then
1920 _ControlView.removeSelectionChangeListener(_SelectListener)
1921 Set _SelectListener = Nothing
1922 _OnNodeSelected =
""
1924 ' Setup a new fresh listener
1925 If Len(pvValue)
> 0 Then
1926 Set _SelectListener = CreateUnoListener(
"_SFSEL_
",
"com.sun.star.view.XSelectionChangeListener
")
1927 _ControlView.addSelectionChangeListener(_SelectListener)
1928 _OnNodeSelected = pvValue
1930 Case Else : GoTo CatchType
1932 Case UCase(
"Page
")
1933 If Not ScriptForge.SF_Utils._Validate(pvValue,
"Page
", ScriptForge.V_NUMERIC) Then GoTo Finally
1934 If oSession.HasUnoProperty(_ControlModel,
"Step
") Then _ControlModel.Step = CLng(pvValue)
1935 Case UCase(
"Picture
")
1936 Select Case _ControlType
1937 Case CTLBUTTON, CTLIMAGECONTROL
1938 If Not ScriptForge.SF_Utils._ValidateFile(pvValue,
"Picture
") Then GoTo Finally
1939 If oSession.HasUnoProperty(_ControlModel,
"ImageURL
") Then _ControlModel.ImageURL = ScriptForge.SF_FileSystem._ConvertToUrl(pvValue)
1940 Case Else : GoTo CatchType
1942 Case UCase(
"RowSource
")
1943 Select Case _ControlType
1944 Case CTLCOMBOBOX, CTLLISTBOX
1945 If Not IsArray(pvValue) Then
1946 If Not ScriptForge.SF_Utils._Validate(pvValue,
"RowSource
", V_STRING) Then GoTo Finally
1947 pvArray = Array(pvArray)
1948 ElseIf Not ScriptForge.SF_Utils._ValidateArray(pvValue,
"RowSource
",
1, V_STRING, True) Then
1951 If oSession.HasUnoProperty(_ControlModel,
"StringItemList
") Then _ControlModel.StringItemList = pvValue
1952 Case Else : GoTo CatchType
1954 Case UCase(
"TipText
")
1955 If Not ScriptForge.SF_Utils._Validate(pvValue,
"TipText
", V_STRING) Then GoTo Finally
1956 If oSession.HasUnoProperty(_ControlModel,
"HelpText
") Then _ControlModel.HelpText = pvValue
1957 Case UCase(
"TripleState
")
1958 Select Case _ControlType
1960 If Not ScriptForge.SF_Utils._Validate(pvValue,
"TripleState
", ScriptForge.V_BOOLEAN) Then GoTo Finally
1961 If oSession.HasUnoProperty(_ControlModel,
"TriState
") Then _ControlModel.TriState = pvValue
1962 Case Else : GoTo CatchType
1964 Case UCase(
"Value
")
1965 Select Case _ControlType
1966 Case CTLBUTTON
'Boolean, toggle buttons only
1967 If Not ScriptForge.SF_Utils._Validate(pvValue,
"Value
", ScriptForge.V_BOOLEAN) Then GoTo Finally
1968 If oSession.HasUnoProperty(_ControlModel,
"Toggle
") And oSession.HasUnoProperty(_ControlModel,
"State
") Then
1969 _ControlModel.State = Iif(pvValue,
1,
0)
1971 Case CTLCHECKBOX
'0 = Not checked,
1 = Checked,
2 = Don
't know
1972 If Not ScriptForge.SF_Utils._Validate(pvValue,
"Value
", Array(ScriptForge.V_BOOLEAN, ScriptForge.V_NUMERIC), Array(
0,
1,
2, True, False)) Then GoTo Finally
1973 If oSession.HasUnoProperty(_ControlModel,
"State
") Then
1974 If VarType(pvValue) = ScriptForge.V_BOOLEAN Then pvValue = Iif(pvValue,
1,
0)
1975 _ControlModel.State = pvValue
1977 Case CTLCOMBOBOX, CTLFILECONTROL, CTLPATTERNFIELD, CTLTEXTFIELD
'String
1978 If Not ScriptForge.SF_Utils._Validate(pvValue,
"Value
", V_STRING) Then GoTo Finally
1979 If oSession.HasUnoProperty(_ControlModel,
"Text
") Then _ControlModel.Text = pvValue
1980 Case CTLCURRENCYFIELD, CTLNUMERICFIELD
'Numeric
1981 If Not ScriptForge.SF_Utils._Validate(pvValue,
"Value
", ScriptForge.V_NUMERIC) Then GoTo Finally
1982 If oSession.HasUnoProperty(_ControlModel,
"Value
") Then _ControlModel.Value = pvValue
1983 Case CTLDATEFIELD
'Date
1984 If Not ScriptForge.SF_Utils._Validate(pvValue,
"Value
", V_DATE) Then GoTo Finally
1985 If oSession.HasUnoProperty(_ControlModel,
"Date
") Then
1986 Set vSet = New com.sun.star.util.Date
1987 vSet.Year = Year(pvValue)
1988 vSet.Month = Month(pvValue)
1989 vSet.Day = Day(pvValue)
1990 _ControlModel.Date = vSet
1992 Case CTLFORMATTEDFIELD
'String or numeric
1993 If Not ScriptForge.SF_Utils._Validate(pvValue,
"Value
", Array(V_STRING, ScriptForge.V_NUMERIC)) Then GoTo Finally
1994 If oSession.HasUnoProperty(_ControlModel,
"EffectiveValue
") Then _ControlModel.EffectiveValue = pvValue
1995 Case CTLLISTBOX
'String or array of strings depending on MultiSelection
1996 ' StringItemList is the list of the items displayed in the box
1997 ' SelectedItems is the list of the indexes in StringItemList of the selected items
1998 ' It can go beyond the limits of StringItemList
1999 ' It can contain multiple values even if the listbox is not multiselect
2000 If oSession.HasUnoProperty(_ControlModel,
"StringItemList
") And oSession.HasUnoProperty(_ControlModel,
"SelectedItems
") _
2001 And oSession.HasUnoProperty(_ControlModel,
"MultiSelection
") Then
2002 vSelection = Array()
2003 If _ControlModel.MultiSelection Then
2004 If Not ScriptForge.SF_Utils._ValidateArray(pvValue,
"Value
",
1, V_STRING, True) Then GoTo Finally
2005 vList = _ControlModel.StringItemList
2006 For i = LBound(pvValue) To UBound(pvValue)
2008 lIndex = ScriptForge.SF_Array.IndexOf(vList, sItem)
2009 If lIndex
>=
0 Then vSelection = ScriptForge.SF_Array.Append(vSelection, lIndex)
2012 If Not ScriptForge.SF_Utils._Validate(pvValue,
"Value
", V_STRING) Then GoTo Finally
2013 lIndex = ScriptForge.SF_Array.IndexOf(_ControlModel.StringItemList, pvValue)
2014 If lIndex
>=
0 Then vSelection = Array(lIndex)
2016 _ControlModel.SelectedItems = vSelection
2018 Case CTLPROGRESSBAR
'Numeric
2019 If Not ScriptForge.SF_Utils._Validate(pvValue,
"Value
", ScriptForge.V_NUMERIC) Then GoTo Finally
2020 If oSession.HasUnoProperty(_ControlModel,
"ProgressValueMin
") Then
2021 If pvValue
< _ControlModel.ProgressValueMin Then pvValue = _ControlModel.ProgressValueMin
2023 If oSession.HasUnoProperty(_ControlModel,
"ProgressValueMax
") Then
2024 If pvValue
> _ControlModel.ProgressValueMax Then pvValue = _ControlModel.ProgressValueMax
2026 If oSession.HasUnoProperty(_ControlModel,
"ProgressValue
") Then _ControlModel.ProgressValue = pvValue
2027 Case CTLRADIOBUTTON
'Boolean
2028 If Not ScriptForge.SF_Utils._Validate(pvValue,
"Value
", ScriptForge.V_BOOLEAN) Then GoTo Finally
2029 If oSession.HasUnoProperty(_ControlModel,
"State
") Then _ControlModel.State = Iif(pvValue,
1,
0)
2030 Case CTLSCROLLBAR
'Numeric
2031 If Not ScriptForge.SF_Utils._Validate(pvValue,
"Value
", ScriptForge.V_NUMERIC) Then GoTo Finally
2032 If oSession.HasUnoProperty(_ControlModel,
"ScrollValueMin
") Then
2033 If pvValue
< _ControlModel.ScrollValueMin Then pvValue = _ControlModel.ScrollValueMin
2035 If oSession.HasUnoProperty(_ControlModel,
"ScrollValueMax
") Then
2036 If pvValue
> _ControlModel.ScrollValueMax Then pvValue = _ControlModel.ScrollValueMax
2038 If oSession.HasUnoProperty(_ControlModel,
"ScrollValue
") Then _ControlModel.ScrollValue = pvValue
2040 If Not ScriptForge.SF_Utils._Validate(pvValue,
"Value
", V_DATE) Then GoTo Finally
2041 If oSession.HasUnoProperty(_ControlModel,
"Time
") Then
2042 Set vSet = New com.sun.star.util.Time
2043 vSet.Hours = Hour(pvValue)
2044 vSet.Minutes = Minute(pvValue)
2045 vSet.Seconds = Second(pvValue)
2046 _ControlModel.Time = vSet
2048 Case Else : GoTo CatchType
2050 Case UCase(
"Visible
")
2051 If Not ScriptForge.SF_Utils._Validate(pvValue,
"Visible
", ScriptForge.V_BOOLEAN) Then GoTo Finally
2052 If oSession.HasUnoMethod(_ControlView,
"setVisible
") Then
2054 If oSession.HasUnoProperty(_ControlModel,
"EnableVisible
") Then _ControlModel.EnableVisible = True
2056 _ControlView.setVisible(pvValue)
2064 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
2069 ScriptForge.SF_Exception.RaiseFatal(CONTROLTYPEERROR, _Name, _DialogName, _ControlType, psProperty)
2071 End Function
' SFDialogs.SF_DialogControl._PropertySet
2073 REM -----------------------------------------------------------------------------
2074 Private Function _Repr() As String
2075 ''' Convert the Model instance to a readable string, typically for debugging purposes (DebugPrint ...)
2076 ''' Args:
2077 ''' Return:
2078 ''' "[DIALOGCONTROL]: Name, Type (dialogname)
2079 _Repr =
"[DIALOGCONTROL]:
" & _Name
& ",
" & _ControlType
& " (
" & _DialogName
& ")
"
2081 End Function
' SFDialogs.SF_DialogControl._Repr
2083 REM ============================================ END OF SFDIALOGS.SF_DIALOGCONTROL