Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / wizards / source / access2base / Dialog.xba
blob69caed33ccae683a696e156a5d8da6d08a77c056
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="Dialog" script:language="StarBasic">
4 REM =======================================================================================================================
5 REM === The Access2Base library is a part of the LibreOffice project. ===
6 REM === Full documentation is available on http://www.access2base.com ===
7 REM =======================================================================================================================
9 Option Compatible
10 Option ClassModule
12 Option Explicit
14 REM -----------------------------------------------------------------------------------------------------------------------
15 REM --- CLASS ROOT FIELDS ---
16 REM -----------------------------------------------------------------------------------------------------------------------
18 Private _Type As String &apos; Must be DIALOG
19 Private _This As Object &apos; Workaround for absence of This builtin function
20 Private _Parent As Object
21 Private _Name As String
22 Private _Shortcut As String
23 Private _Dialog As Object &apos; com.sun.star.io.XInputStreamProvider
24 Private _Storage As String &apos; GLOBAL or DOCUMENT
25 Private _Library As String
26 Private UnoDialog As Object &apos; com.sun.star.awt.XControl
28 REM -----------------------------------------------------------------------------------------------------------------------
29 REM --- CONSTRUCTORS / DESTRUCTORS ---
30 REM -----------------------------------------------------------------------------------------------------------------------
31 Private Sub Class_Initialize()
32 _Type = OBJDIALOG
33 Set _This = Nothing
34 Set _Parent = Nothing
35 _Name = &quot;&quot;
36 Set _Dialog = Nothing
37 _Storage = &quot;&quot;
38 _Library = &quot;&quot;
39 Set UnoDialog = Nothing
40 End Sub &apos; Constructor
42 REM -----------------------------------------------------------------------------------------------------------------------
43 Private Sub Class_Terminate()
44 On Local Error Resume Next
45 Call Class_Initialize()
46 End Sub &apos; Destructor
48 REM -----------------------------------------------------------------------------------------------------------------------
49 Public Sub Dispose()
50 Call Class_Terminate()
51 End Sub &apos; Explicit destructor
53 REM -----------------------------------------------------------------------------------------------------------------------
54 REM --- CLASS GET/LET/SET PROPERTIES ---
55 REM -----------------------------------------------------------------------------------------------------------------------
56 REM -----------------------------------------------------------------------------------------------------------------------
57 Property Get Caption() As Variant
58 Caption = _PropertyGet(&quot;Caption&quot;)
59 End Property &apos; Caption (get)
61 Property Let Caption(ByVal pvValue As Variant)
62 Call _PropertySet(&quot;Caption&quot;, pvValue)
63 End Property &apos; Caption (set)
65 REM -----------------------------------------------------------------------------------------------------------------------
66 Property Get Height() As Variant
67 Height = _PropertyGet(&quot;Height&quot;)
68 End Property &apos; Height (get)
70 Property Let Height(ByVal pvValue As Variant)
71 Call _PropertySet(&quot;Height&quot;, pvValue)
72 End Property &apos; Height (set)
74 REM -----------------------------------------------------------------------------------------------------------------------
75 Property Get IsLoaded() As Boolean
76 IsLoaded = _PropertyGet(&quot;IsLoaded&quot;)
77 End Property
79 REM -----------------------------------------------------------------------------------------------------------------------
80 Property Get Name() As String
81 Name = _PropertyGet(&quot;Name&quot;)
82 End Property &apos; Name (get)
84 Public Function pName() As String &apos; For compatibility with &lt; V0.9.0
85 pName = _PropertyGet(&quot;Name&quot;)
86 End Function &apos; pName (get)
88 REM -----------------------------------------------------------------------------------------------------------------------
89 Property Get ObjectType() As String
90 ObjectType = _PropertyGet(&quot;ObjectType&quot;)
91 End Property &apos; ObjectType (get)
93 REM -----------------------------------------------------------------------------------------------------------------------
94 Property Get OnFocusGained() As Variant
95 OnFocusGained = _PropertyGet(&quot;OnFocusGained&quot;)
96 End Property &apos; OnFocusGained (get)
98 Property Let OnFocusGained(ByVal pvValue As Variant)
99 Call _PropertySet(&quot;OnFocusGained&quot;, pvValue)
100 End Property &apos; OnFocusGained (set)
102 REM -----------------------------------------------------------------------------------------------------------------------
103 Property Get OnFocusLost() As Variant
104 OnFocusLost = _PropertyGet(&quot;OnFocusLost&quot;)
105 End Property &apos; OnFocusLost (get)
107 Property Let OnFocusLost(ByVal pvValue As Variant)
108 Call _PropertySet(&quot;OnFocusLost&quot;, pvValue)
109 End Property &apos; OnFocusLost (set)
111 REM -----------------------------------------------------------------------------------------------------------------------
112 Property Get OnKeyPressed() As Variant
113 OnKeyPressed = _PropertyGet(&quot;OnKeyPressed&quot;)
114 End Property &apos; OnKeyPressed (get)
116 Property Let OnKeyPressed(ByVal pvValue As Variant)
117 Call _PropertySet(&quot;OnKeyPressed&quot;, pvValue)
118 End Property &apos; OnKeyPressed (set)
120 REM -----------------------------------------------------------------------------------------------------------------------
121 Property Get OnKeyReleased() As Variant
122 OnKeyReleased = _PropertyGet(&quot;OnKeyReleased&quot;)
123 End Property &apos; OnKeyReleased (get)
125 Property Let OnKeyReleased(ByVal pvValue As Variant)
126 Call _PropertySet(&quot;OnKeyReleased&quot;, pvValue)
127 End Property &apos; OnKeyReleased (set)
129 REM -----------------------------------------------------------------------------------------------------------------------
130 Property Get OnMouseDragged() As Variant
131 OnMouseDragged = _PropertyGet(&quot;OnMouseDragged&quot;)
132 End Property &apos; OnMouseDragged (get)
134 Property Let OnMouseDragged(ByVal pvValue As Variant)
135 Call _PropertySet(&quot;OnMouseDragged&quot;, pvValue)
136 End Property &apos; OnMouseDragged (set)
138 REM -----------------------------------------------------------------------------------------------------------------------
139 Property Get OnMouseEntered() As Variant
140 OnMouseEntered = _PropertyGet(&quot;OnMouseEntered&quot;)
141 End Property &apos; OnMouseEntered (get)
143 Property Let OnMouseEntered(ByVal pvValue As Variant)
144 Call _PropertySet(&quot;OnMouseEntered&quot;, pvValue)
145 End Property &apos; OnMouseEntered (set)
147 REM -----------------------------------------------------------------------------------------------------------------------
148 Property Get OnMouseExited() As Variant
149 OnMouseExited = _PropertyGet(&quot;OnMouseExited&quot;)
150 End Property &apos; OnMouseExited (get)
152 Property Let OnMouseExited(ByVal pvValue As Variant)
153 Call _PropertySet(&quot;OnMouseExited&quot;, pvValue)
154 End Property &apos; OnMouseExited (set)
156 REM -----------------------------------------------------------------------------------------------------------------------
157 Property Get OnMouseMoved() As Variant
158 OnMouseMoved = _PropertyGet(&quot;OnMouseMoved&quot;)
159 End Property &apos; OnMouseMoved (get)
161 Property Let OnMouseMoved(ByVal pvValue As Variant)
162 Call _PropertySet(&quot;OnMouseMoved&quot;, pvValue)
163 End Property &apos; OnMouseMoved (set)
165 REM -----------------------------------------------------------------------------------------------------------------------
166 Property Get OnMousePressed() As Variant
167 OnMousePressed = _PropertyGet(&quot;OnMousePressed&quot;)
168 End Property &apos; OnMousePressed (get)
170 Property Let OnMousePressed(ByVal pvValue As Variant)
171 Call _PropertySet(&quot;OnMousePressed&quot;, pvValue)
172 End Property &apos; OnMousePressed (set)
174 REM -----------------------------------------------------------------------------------------------------------------------
175 Property Get OnMouseReleased() As Variant
176 OnMouseReleased = _PropertyGet(&quot;OnMouseReleased&quot;)
177 End Property &apos; OnMouseReleased (get)
179 Property Let OnMouseReleased(ByVal pvValue As Variant)
180 Call _PropertySet(&quot;OnMouseReleased&quot;, pvValue)
181 End Property &apos; OnMouseReleased (set)
183 REM -----------------------------------------------------------------------------------------------------------------------
184 Public Function OptionGroup(ByVal Optional pvGroupName As Variant) As Variant
185 &apos; Return either an error or an object of type OPTIONGROUP based on its name
186 &apos; A group is determined by the successive TabIndexes of the radio button
187 &apos; The name of the group = the name of its first element
189 Utils._SetCalledSub(&quot;Dialog.OptionGroup&quot;)
190 If IsMissing(pvGroupName) Then Call _TraceArguments()
191 If _ErrorHandler() Then On Local Error Goto Error_Function
193 Set OptionGroup = Nothing
194 If Not Utils._CheckArgument(pvGroupName, 1, vbString) Then Goto Exit_Function
196 Dim iAllCount As Integer, iRadioLast As Integer, iGroupCount As Integer, iBegin As Integer, iEnd As Integer
197 Dim oRadios() As Object, sGroupName As String
198 Dim i As Integer, j As Integer, bFound As Boolean, ocControl As Object, oRadio As Object, iTabIndex As Integer
199 Dim ogGroup As Object, vGroup() As Variant, vIndex() As Variant
200 iAllCount = Controls.Count
201 If iAllCount &gt; 0 Then
202 iRadioLast = -1
203 ReDim oRadios(0 To iAllCount - 1)
204 For i = 0 To iAllCount - 1 &apos; Store all RadioButtons objects
205 Set ocControl = Controls(i)
206 If ocControl._SubType = CTLRADIOBUTTON Then
207 iRadioLast = iRadioLast + 1
208 Set oRadios(iRadioLast) = ocControl
209 End If
210 Next i
211 Else
212 Goto Error_Arg &apos; No control in dialog
213 End If
215 If iRadioLast &lt; 0 then Goto Error_Arg &apos; No radio buttons in the dialog
217 &apos;Resort oRadio array based on tab indexes
218 If iRadioLast &gt; 0 Then
219 For i = 0 To iRadioLast - 1 &apos; Bubble sort
220 For j = i + 1 To iRadioLast
221 If oRadios(i).TabIndex &gt; oRadios(j).TabIndex Then
222 Set oRadio = oRadios(i)
223 Set oRadios(i) = oRadios(j)
224 Set oRadios(j) = oRadio
225 End If
226 Next j
227 Next i
228 End If
230 &apos;Scan Names to find match with argument
231 bFound = False
232 For i = 0 To iRadioLast
233 If UCase(oRadios(i)._Name) = UCase(pvGroupName) Then
234 Select Case i
235 Case 0 : bFound = True
236 Case Else
237 If oRadios(i).TabIndex &gt; oRadios(i - 1).TabIndex + 1 Then
238 bFound = True
239 Else
240 Goto Error_Arg &apos; same group as preceding item although name correct
241 End If
242 End Select
243 If bFound Then
244 iBegin = i
245 iEnd = i
246 sGroupName = oRadios(i)._Name
247 End If
248 ElseIf bFound Then
249 If oRadios(i).TabIndex = oRadios(i - 1).TabIndex + 1 Then iEnd = i
250 End If
251 Next i
253 If bFound Then &apos; Create OptionGroup
254 iGroupCount = iEnd - iBegin + 1
255 Set ogGroup = New OptionGroup
256 ReDim vGroup(0 To iGroupCount - 1)
257 ReDim vIndex(0 To iGroupCount - 1)
258 With ogGroup
259 ._This = ogGroup
260 ._Name = sGroupName
261 ._Count = iGroupCount
262 ._ButtonsGroup = vGroup
263 ._ButtonsIndex = vIndex
264 For i = 0 To iGroupCount - 1
265 Set ._ButtonsGroup(i) = oRadios(iBegin + i).ControlModel
266 ._ButtonsIndex(i) = i
267 Next i
268 ._ParentType = CTLPARENTISDIALOG
269 ._ParentComponent = UnoDialog
270 End With
271 Else Goto Error_Arg
272 End If
274 Set OptionGroup = ogGroup
276 Exit_Function:
277 Utils._ResetCalledSub(&quot;Dialog.OptionGroup&quot;)
278 Exit Function
279 Error_Arg:
280 TraceError(TRACEFATAL, ERRWRONGARGUMENT, Utils._CalledSub(), 0, , Array(1, pvGroupName))
281 Goto Exit_Function
282 Error_Function:
283 TraceError(TRACEABORT, Err, &quot;Dialog.OptionGroup&quot;, Erl)
284 GoTo Exit_Function
285 End Function &apos; OptionGroup V0.9.1
287 REM -----------------------------------------------------------------------------------------------------------------------
288 Property Get Page() As Variant
289 Page = _PropertyGet(&quot;Page&quot;)
290 End Property &apos; Page (get)
292 Property Let Page(ByVal pvValue As Variant)
293 Call _PropertySet(&quot;Page&quot;, pvValue)
294 End Property &apos; Page (set)
296 REM -----------------------------------------------------------------------------------------------------------------------
297 Public Function Parent() As Object
298 Parent = _Parent
299 End Function &apos; Parent (get) V6.4.0
301 REM -----------------------------------------------------------------------------------------------------------------------
302 Public Function Properties(ByVal Optional pvIndex As Variant) As Variant
303 &apos; Return
304 &apos; a Collection object if pvIndex absent
305 &apos; a Property object otherwise
307 Const cstThisSub = &quot;Dialog.Properties&quot;
308 Utils._SetCalledSub(cstThisSub)
310 Dim vProperty As Variant, vPropertiesList() As Variant, sObject As String
312 vPropertiesList = _PropertiesList()
313 sObject = Utils._PCase(_Type)
314 If IsMissing(pvIndex) Then
315 vProperty = PropertiesGet._Properties(sObject, _This, vPropertiesList)
316 Else
317 vProperty = PropertiesGet._Properties(sObject, _This, vPropertiesList, pvIndex)
318 vProperty._Value = _PropertyGet(vPropertiesList(pvIndex))
319 End If
321 Exit_Function:
322 Set Properties = vProperty
323 Utils._ResetCalledSub(cstThisSub)
324 Exit Function
325 End Function &apos; Properties
327 REM -----------------------------------------------------------------------------------------------------------------------
328 Property Get Visible() As Variant
329 Visible = _PropertyGet(&quot;Visible&quot;)
330 End Property &apos; Visible (get)
332 Property Let Visible(ByVal pvValue As Variant)
333 Call _PropertySet(&quot;Visible&quot;, pvValue)
334 End Property &apos; Visible (set)
336 REM -----------------------------------------------------------------------------------------------------------------------
337 Property Get Width() As Variant
338 Width = _PropertyGet(&quot;Width&quot;)
339 End Property &apos; Width (get)
341 Property Let Width(ByVal pvValue As Variant)
342 Call _PropertySet(&quot;Width&quot;, pvValue)
343 End Property &apos; Width (set)
345 REM -----------------------------------------------------------------------------------------------------------------------
346 REM --- CLASS METHODS ---
347 REM -----------------------------------------------------------------------------------------------------------------------
349 Public Function Controls(Optional ByVal pvIndex As Variant) As Variant
350 &apos; Return a Control object with name or index = pvIndex
352 If _ErrorHandler() Then On Local Error Goto Error_Function
353 Utils._SetCalledSub(&quot;Dialog.Controls&quot;)
355 Dim ocControl As Variant, sParentShortcut As String, iControlCount As Integer
356 Dim oCounter As Variant, sControls() As Variant, i As Integer, bFound As Boolean, sIndex As String
357 Dim j As Integer
359 Set ocControl = Nothing
360 If Not IsLoaded Then Goto Trace_Error_NotOpen
361 Set ocControl = New Control
362 Set ocControl._This = ocControl
363 Set ocControl._Parent = _This
364 ocControl._ParentType = CTLPARENTISDIALOG
365 sParentShortcut = _Shortcut
366 sControls() = UnoDialog.Model.getElementNames()
367 iControlCount = UBound(sControls) + 1
369 If IsMissing(pvIndex) Then &apos; No argument, return Collection object
370 Set oCounter = New Collect
371 Set oCounter._This = oCounter
372 oCounter._CollType = COLLCONTROLS
373 oCounter._Count = iControlCount
374 Set oCounter._Parent = _This
375 Set Controls = oCounter
376 Goto Exit_Function
377 End If
379 If Not Utils._CheckArgument(pvIndex, 1, Utils._AddNumeric(vbString)) Then Goto Exit_Function
381 &apos; Start building the ocControl object
382 &apos; Determine exact name
384 Select Case VarType(pvIndex)
385 Case vbInteger, vbLong, vbSingle, vbDouble, vbCurrency, vbBigint, vbDecimal
386 If pvIndex &lt; 0 Or pvIndex &gt; iControlCount - 1 Then Goto Trace_Error_Index
387 ocControl._Name = sControls(pvIndex)
388 Case vbString &apos; Check control name validity (non case sensitive)
389 bFound = False
390 sIndex = UCase(Utils._Trim(pvIndex))
391 For i = 0 To iControlCount - 1
392 If UCase(sControls(i)) = sIndex Then
393 bFound = True
394 Exit For
395 End If
396 Next i
397 If bFound Then ocControl._Name = sControls(i) Else Goto Trace_NotFound
398 End Select
400 ocControl._Shortcut = sParentShortcut &amp; &quot;!&quot; &amp; Utils._Surround(ocControl._Name)
401 Set ocControl.ControlModel = UnoDialog.Model.getByName(ocControl._Name)
402 Set ocControl.ControlView = UnoDialog.getControl(ocControl._Name)
403 ocControl._ImplementationName = ocControl.ControlModel.getImplementationName()
404 ocControl._FormComponent = UnoDialog
406 ocControl._Initialize()
407 Set Controls = ocControl
409 Exit_Function:
410 Utils._ResetCalledSub(&quot;Dialog.Controls&quot;)
411 Exit Function
412 Trace_Error:
413 TraceError(TRACEFATAL, ERRWRONGARGUMENT, Utils._CalledSub(), 0, , Array(iArg, pvIndex))
414 Set Controls = Nothing
415 Goto Exit_Function
416 Trace_Error_NotOpen:
417 TraceError(TRACEFATAL, ERRDIALOGNOTSTARTED, Utils._CalledSub(), 0, , _Name)
418 Set Controls = Nothing
419 Goto Exit_Function
420 Trace_Error_Index:
421 TraceError(TRACEFATAL, ERRCOLLECTION, Utils._CalledSub(), 0, 1)
422 Set Controls = Nothing
423 Goto Exit_Function
424 Trace_NotFound:
425 TraceError(TRACEFATAL, ERRCONTROLNOTFOUND, Utils._CalledSub(), 0, , Array(pvIndex, pvIndex))
426 Set Controls = Nothing
427 Goto Exit_Function
428 Error_Function:
429 TraceError(TRACEABORT, Err, &quot;Dialog.Controls&quot;, Erl)
430 Set Controls = Nothing
431 GoTo Exit_Function
432 End Function &apos; Controls
434 REM -----------------------------------------------------------------------------------------------------------------------
435 Public Sub EndExecute(ByVal Optional pvReturn As Variant)
436 &apos; Stop executing the dialog
438 If _ErrorHandler() Then On Local Error Goto Error_Sub
439 Utils._SetCalledSub(&quot;Dialog.endExecute&quot;)
441 If IsMissing(pvReturn) Then pvReturn = 0
442 If Not Utils._CheckArgument(pvReturn, 1, Utils._AddNumeric(), , False) Then Goto Trace_Error
444 Dim lExecute As Long
445 lExecute = CLng(pvReturn)
446 If IsNull(_Dialog) Then Goto Error_Execute
447 If IsNull(UnoDialog) Then Goto Error_Not_Started
448 Call UnoDialog.endDialog(lExecute)
450 Exit_Sub:
451 Utils._ResetCalledSub(&quot;Dialog.endExecute&quot;)
452 Exit Sub
453 Trace_Error:
454 TraceError(TRACEFATAL, ERRWRONGARGUMENT, Utils._CalledSub(), 0, , Array(&quot;1&quot;, Utils._CStr(pvReturn)))
455 Goto Exit_Sub
456 Error_Execute:
457 TraceError(TRACEFATAL, ERRDIALOGUNDEFINED, Utils._CalledSub(), 0)
458 Goto Exit_Sub
459 Error_Not_Started:
460 TraceError(TRACEWARNING, ERRDIALOGNOTSTARTED, Utils._CalledSub(), 0, 1, _Name)
461 Goto Exit_Sub
462 Error_Sub:
463 TraceError(TRACEABORT, Err, &quot;Dialog.endExecute&quot;, Erl)
464 GoTo Exit_Sub
465 End Sub &apos; EndExecute
467 REM -----------------------------------------------------------------------------------------------------------------------
468 Public Function Execute() As Long
469 &apos; Execute dialog
471 &apos;If _ErrorHandler() Then On Local Error Goto Error_Function
472 &apos;Seems smart not to trap errors: debugging of dialog events otherwise made very difficult !
473 Utils._SetCalledSub(&quot;Dialog.Execute&quot;)
475 Dim lExecute As Long
476 If IsNull(_Dialog) Then Goto Error_Execute
477 If IsNull(UnoDialog) Then Goto Error_Not_Started
478 lExecute = UnoDialog.execute()
480 Select Case lExecute
481 Case 1 : Execute = dlgOK
482 Case 0 : Execute = dlgCancel
483 Case Else : Execute = lExecute
484 End Select
486 Exit_Function:
487 Utils._ResetCalledSub(&quot;Dialog.Execute&quot;)
488 Exit Function
489 Error_Execute:
490 TraceError(TRACEFATAL, ERRDIALOGUNDEFINED, Utils._CalledSub(), 0)
491 Goto Exit_Function
492 Error_Not_Started:
493 TraceError(TRACEWARNING, ERRDIALOGNOTSTARTED, Utils._CalledSub(), 0, 1, _Name)
494 Goto Exit_Function
495 Error_Function:
496 TraceError(TRACEABORT, Err, &quot;Dialog.Execute&quot;, Erl)
497 GoTo Exit_Function
498 End Function &apos; Execute
500 REM -----------------------------------------------------------------------------------------------------------------------
501 Public Function getProperty(Optional ByVal pvProperty As Variant) As Variant
502 &apos; Return property value of psProperty property name
504 Utils._SetCalledSub(&quot;Dialog.getProperty&quot;)
505 If IsMissing(pvProperty) Then Call _TraceArguments()
506 getProperty = _PropertyGet(pvProperty)
507 Utils._ResetCalledSub(&quot;Dialog.getProperty&quot;)
509 End Function &apos; getProperty
511 REM -----------------------------------------------------------------------------------------------------------------------
512 Public Function hasProperty(ByVal Optional pvProperty As Variant) As Boolean
513 &apos; Return True if object has a valid property called pvProperty (case-insensitive comparison !)
515 If IsMissing(pvProperty) Then hasProperty = PropertiesGet._hasProperty(_Type, _PropertiesList()) Else hasProperty = PropertiesGet._hasProperty(_Type, _PropertiesList(), pvProperty)
516 Exit Function
518 End Function &apos; hasProperty
520 REM -----------------------------------------------------------------------------------------------------------------------
521 Public Function Move( ByVal Optional pvLeft As Variant _
522 , ByVal Optional pvTop As Variant _
523 , ByVal Optional pvWidth As Variant _
524 , ByVal Optional pvHeight As Variant _
525 ) As Variant
526 &apos; Execute Move method
527 Utils._SetCalledSub(&quot;Dialog.Move&quot;)
528 On Local Error Goto Error_Function
529 Move = False
530 Dim iArgNr As Integer
531 Select Case UCase(_A2B_.CalledSub)
532 Case UCase(&quot;Move&quot;) : iArgNr = 1
533 Case UCase(&quot;Dialog.Move&quot;) : iArgNr = 0
534 End Select
535 If IsMissing(pvLeft) Then pvLeft = -1
536 If IsMissing(pvTop) Then pvTop = -1
537 If IsMissing(pvWidth) Then pvWidth = -1
538 If IsMissing(pvHeight) Then pvHeight = -1
539 If Not Utils._CheckArgument(pvLeft, iArgNr + 1, Utils._AddNumeric()) Then Goto Exit_Function
540 If Not Utils._CheckArgument(pvTop, iArgNr + 2, Utils._AddNumeric()) Then Goto Exit_Function
541 If Not Utils._CheckArgument(pvWidth, iArgNr + 3, Utils._AddNumeric()) Then Goto Exit_Function
542 If Not Utils._CheckArgument(pvHeight, iArgNr + 4, Utils._AddNumeric()) Then Goto Exit_Function
544 Dim iArg As Integer, iWrong As Integer &apos; Check arguments values
545 iArg = 0
546 If pvHeight &lt; -1 Then
547 iArg = 4 : iWrong = pvHeight
548 ElseIf pvWidth &lt; -1 Then
549 iArg = 3 : iWrong = pvWidth
550 ElseIf pvTop &lt; -1 Then
551 iArg = 2 : iWrong = pvTop
552 ElseIf pvLeft &lt; -1 Then
553 iArg = 1 : iWrong = pvLeft
554 End If
555 If iArg &gt; 0 Then
556 TraceError(TRACEFATAL, ERRWRONGARGUMENT, Utils._CalledSub(), 0, 1, Array(iArgNr + iArg, iWrong))
557 Goto Exit_Function
558 End If
560 Dim iPosSize As Integer
561 iPosSize = 0
562 If pvLeft &gt;= 0 Then iPosSize = iPosSize + com.sun.star.awt.PosSize.X
563 If pvTop &gt;= 0 Then iPosSize = iPosSize + com.sun.star.awt.PosSize.Y
564 If pvWidth &gt; 0 Then iPosSize = iPosSize + com.sun.star.awt.PosSize.WIDTH
565 If pvHeight &gt; 0 Then iPosSize = iPosSize + com.sun.star.awt.PosSize.HEIGHT
566 If iPosSize &gt; 0 Then UnoDialog.setPosSize(pvLeft, pvTop, pvWidth, pvHeight, iPosSize)
567 Move = True
569 Exit_Function:
570 Utils._ResetCalledSub(&quot;Dialog.Move&quot;)
571 Exit Function
572 Error_Function:
573 TraceError(TRACEABORT, Err, &quot;Dialog.Move&quot;, Erl)
574 GoTo Exit_Function
575 End Function &apos; Move
577 REM -----------------------------------------------------------------------------------------------------------------------
578 Public Function setProperty(ByVal Optional psProperty As String, ByVal Optional pvValue As Variant) As Boolean
579 &apos; Return True if property setting OK
580 Utils._SetCalledSub(&quot;Dialog.setProperty&quot;)
581 setProperty = _PropertySet(psProperty, pvValue)
582 Utils._ResetCalledSub(&quot;Dialog.setProperty&quot;)
583 End Function
585 REM -----------------------------------------------------------------------------------------------------------------------
586 Public Function Start() As Boolean
587 &apos; Create dialog
589 If _ErrorHandler() Then On Local Error Goto Error_Function
590 Utils._SetCalledSub(&quot;Dialog.Start&quot;)
592 Dim oStart As Object
593 Start = False
594 If IsNull(_Dialog) Then Goto Error_Start
595 If Not IsNull(UnoDialog) Then Goto Error_Yet_Started
596 Set oStart = CreateUnoDialog(_Dialog)
597 If IsNull(oStart) Then
598 Goto Error_Start
599 Else
600 Start = True
601 Set UnoDialog = oStart
602 With _A2B_
603 If .hasItem(COLLALLDIALOGS, _Name) Then .Dialogs.Remove(_Name) &apos; Inserted to solve errors, when aborts between start and terminate
604 .Dialogs.Add(UnoDialog, UCase(_Name))
605 End With
606 End If
608 Exit_Function:
609 Utils._ResetCalledSub(&quot;Dialog.Start&quot;)
610 Exit Function
611 Error_Start:
612 TraceError(TRACEFATAL, ERRDIALOGUNDEFINED, Utils._CalledSub(), 0)
613 Goto Exit_Function
614 Error_Yet_Started:
615 TraceError(TRACEWARNING, ERRDIALOGSTARTED, Utils._CalledSub(), 0)
616 Goto Exit_Function
617 Error_Function:
618 TraceError(TRACEABORT, Err, &quot;Dialog.Start&quot;, Erl)
619 GoTo Exit_Function
620 End Function &apos; Start
622 REM -----------------------------------------------------------------------------------------------------------------------
623 Public Function Terminate() As Boolean
624 &apos; Close dialog
626 If _ErrorHandler() Then On Local Error Goto Error_Function
627 Utils._SetCalledSub(&quot;Dialog.Terminate&quot;)
629 Terminate = False
630 If IsNull(_Dialog) Then Goto Error_Terminate
631 If IsNull(UnoDialog) Then Goto Error_Not_Started
632 UnoDialog.Dispose()
633 Set UnoDialog = Nothing
634 _A2B_.Dialogs.Remove(_Name)
635 Terminate = True
637 Exit_Function:
638 Utils._ResetCalledSub(&quot;Dialog.Terminate&quot;)
639 Exit Function
640 Error_Terminate:
641 TraceError(TRACEFATAL, ERRDIALOGUNDEFINED, Utils._CalledSub(), 0)
642 Goto Exit_Function
643 Error_Not_Started:
644 TraceError(TRACEWARNING, ERRDIALOGNOTSTARTED, Utils._CalledSub(), 0, 1, _Name)
645 Goto Exit_Function
646 Error_Function:
647 TraceError(TRACEABORT, Err, &quot;Dialog.Terminate&quot;, Erl)
648 GoTo Exit_Function
649 End Function &apos; Terminate
651 REM -----------------------------------------------------------------------------------------------------------------------
652 REM --- PRIVATE FUNCTIONS ---
653 REM -----------------------------------------------------------------------------------------------------------------------
655 REM -----------------------------------------------------------------------------------------------------------------------
656 Private Function _GetListener(ByVal psProperty As String) As String
657 &apos; Return the X...Listener corresponding with the property in argument
659 Select Case UCase(psProperty)
660 Case UCase(&quot;OnFocusGained&quot;), UCase(&quot;OnFocusLost&quot;)
661 _GetListener = &quot;XFocusListener&quot;
662 Case UCase(&quot;OnKeyPressed&quot;), UCase(&quot;OnKeyReleased&quot;)
663 _GetListener = &quot;XKeyListener&quot;
664 Case UCase(&quot;OnMouseDragged&quot;), UCase(&quot;OnMouseMoved&quot;)
665 _GetListener = &quot;XMouseMotionListener&quot;
666 Case UCase(&quot;OnMouseEntered&quot;), UCase(&quot;OnMouseExited&quot;), UCase(&quot;OnMousePressed&quot;), UCase(&quot;OnMouseReleased&quot;)
667 _GetListener = &quot;XMouseListener&quot;
668 End Select
670 End Function &apos; _GetListener V1.7.0
672 REM -----------------------------------------------------------------------------------------------------------------------
673 Private Function _PropertiesList() As Variant
675 If IsLoaded Then
676 _PropertiesList = Array(&quot;Caption&quot;, &quot;Height&quot;, &quot;IsLoaded&quot;, &quot;Name&quot; _
677 , &quot;OnFocusGained&quot;, &quot;OnFocusLost&quot;, &quot;OnKeyPressed&quot;, &quot;OnKeyReleased&quot;, &quot;OnMouseDragged&quot; _
678 , &quot;OnMouseEntered&quot;, &quot;OnMouseExited&quot;, &quot;OnMouseMoved&quot;, &quot;OnMousePressed&quot;, &quot;OnMouseReleased&quot; _
679 , &quot;ObjectType&quot;, &quot;Page&quot;, &quot;Visible&quot;, &quot;Width&quot; _
681 Else
682 _PropertiesList = Array(&quot;IsLoaded&quot;, &quot;Name&quot; _
684 End If
686 End Function &apos; _PropertiesList
688 REM -----------------------------------------------------------------------------------------------------------------------
689 Private Function _PropertyGet(ByVal psProperty As String) As Variant
690 &apos; Return property value of the psProperty property name
692 If _ErrorHandler() Then On Local Error Goto Error_Function
693 Utils._SetCalledSub(&quot;Dialog.get&quot; &amp; psProperty)
695 Dim oDialogEvents As Object, sEventName As String
697 &apos;Execute
698 _PropertyGet = EMPTY
700 Select Case UCase(psProperty)
701 Case UCase(&quot;Name&quot;), UCase(&quot;IsLoaded&quot;)
702 Case Else
703 If IsNull(UnoDialog) Then Goto Trace_Error_Dialog
704 End Select
705 Select Case UCase(psProperty)
706 Case UCase(&quot;Caption&quot;)
707 _PropertyGet = UnoDialog.getTitle()
708 Case UCase(&quot;Height&quot;)
709 _PropertyGet = UnoDialog.getPosSize().Height
710 Case UCase(&quot;IsLoaded&quot;)
711 _PropertyGet = _A2B_.hasItem(COLLALLDIALOGS, _Name)
712 Case UCase(&quot;Name&quot;)
713 _PropertyGet = _Name
714 Case UCase(&quot;ObjectType&quot;)
715 _PropertyGet = _Type
716 Case UCase(&quot;OnFocusGained&quot;), UCase(&quot;OnFocusLost&quot;), UCase(&quot;OnKeyPressed&quot;), UCase(&quot;OnKeyReleased&quot;) _
717 , UCase(&quot;OnMouseDragged&quot;), UCase(&quot;OnMouseEntered&quot;), UCase(&quot;OnMouseExited&quot;), UCase(&quot;OnMouseMoved&quot;) _
718 , UCase(&quot;OnMousePressed&quot;), UCase(&quot;OnMouseReleased&quot;)
719 Set oDialogEvents = unoDialog.Model.getEvents()
720 sEventName = &quot;com.sun.star.awt.&quot; &amp; _GetListener(psProperty) &amp; &quot;::&quot; &amp; Utils._GetEventName(psProperty)
721 If oDialogEvents.hasByName(sEventName) Then
722 _PropertyGet = oDialogEvents.getByName(sEventName).ScriptCode
723 Else
724 _PropertyGet = &quot;&quot;
725 End If
726 Case UCase(&quot;Page&quot;)
727 _PropertyGet = UnoDialog.Model.Step
728 Case UCase(&quot;Visible&quot;)
729 _PropertyGet = UnoDialog.IsVisible()
730 Case UCase(&quot;Width&quot;)
731 _PropertyGet = UnoDialog.getPosSize().Width
732 Case Else
733 Goto Trace_Error
734 End Select
736 Exit_Function:
737 Utils._ResetCalledSub(&quot;Dialog.get&quot; &amp; psProperty)
738 Exit Function
739 Trace_Error:
740 TraceError(TRACEWARNING, ERRPROPERTY, Utils._CalledSub(), 0, 1, psProperty)
741 _PropertyGet = EMPTY
742 Goto Exit_Function
743 Trace_Error_Dialog:
744 TraceError(TRACEFATAL, ERRDIALOGNOTSTARTED, Utils._CalledSub(), 0, 1, _Name)
745 _PropertyGet = EMPTY
746 Goto Exit_Function
747 Error_Function:
748 TraceError(TRACEABORT, Err, &quot;Dialog._PropertyGet&quot;, Erl)
749 _PropertyGet = EMPTY
750 GoTo Exit_Function
751 End Function &apos; _PropertyGet
753 REM -----------------------------------------------------------------------------------------------------------------------
754 Private Function _PropertySet(ByVal psProperty As String, ByVal pvValue As Variant) As Boolean
756 Utils._SetCalledSub(&quot;Dialog.set&quot; &amp; psProperty)
757 If _ErrorHandler() Then On Local Error Goto Error_Function
758 _PropertySet = True
760 Dim oDialogEvents As Object, sEventName As String, oEvent As Object, sListener As String, sEvent As String
762 &apos;Execute
763 Dim iArgNr As Integer
765 If _IsLeft(_A2B_.CalledSub, &quot;Dialog.&quot;) Then iArgNr = 1 Else iArgNr = 2
766 If IsNull(UnoDialog) Then Goto Trace_Error_Dialog
767 Select Case UCase(psProperty)
768 Case UCase(&quot;Caption&quot;)
769 If Not Utils._CheckArgument(pvValue, iArgNr, vbString, , False) Then Goto Trace_Error_Value
770 UnoDialog.setTitle(pvValue)
771 Case UCase(&quot;Height&quot;)
772 If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric(), , False) Then Goto Trace_Error_Value
773 UnoDialog.setPosSize(0, 0, 0, pvValue, com.sun.star.awt.PosSize.HEIGHT)
774 Case UCase(&quot;OnFocusGained&quot;), UCase(&quot;OnFocusLost&quot;), UCase(&quot;OnKeyPressed&quot;), UCase(&quot;OnKeyReleased&quot;) _
775 , UCase(&quot;OnMouseDragged&quot;), UCase(&quot;OnMouseEntered&quot;), UCase(&quot;OnMouseExited&quot;), UCase(&quot;OnMouseMoved&quot;) _
776 , UCase(&quot;OnMousePressed&quot;), UCase(&quot;OnMouseReleased&quot;)
777 If Not Utils._CheckArgument(pvValue, iArgNr, vbString, , False) Then Goto Trace_Error_Value
778 If Not Utils._RegisterDialogEventScript(UnoDialog.Model _
779 , psProperty _
780 , _GetListener(psProperty) _
781 , pvValue _
782 ) Then GoTo Trace_Error_Dialog
783 Case UCase(&quot;Page&quot;)
784 If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric(), , False) Then Goto Trace_Error_Value
785 If pvValue &lt; 0 Then Goto Trace_Error_Value
786 UnoDialog.Model.Step = pvValue
787 Case UCase(&quot;Visible&quot;)
788 If Not Utils._CheckArgument(pvValue, iArgNr, vbBoolean, , False) Then Goto Trace_Error_Value
789 UnoDialog.setVisible(pvValue)
790 Case UCase(&quot;Width&quot;)
791 If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric()) Then Goto Trace_Error_Value
792 UnoDialog.setPosSize(0, 0, pvValue, 0, com.sun.star.awt.PosSize.WIDTH)
793 Case Else
794 Goto Trace_Error
795 End Select
797 Exit_Function:
798 Utils._ResetCalledSub(&quot;Dialog.set&quot; &amp; psProperty)
799 Exit Function
800 Trace_Error_Dialog:
801 TraceError(TRACEFATAL, ERRDIALOGNOTSTARTED, Utils._CalledSub(), 0, 1, _Name)
802 _PropertySet = False
803 Goto Exit_Function
804 Trace_Error:
805 TraceError(TRACEFATAL, ERRPROPERTY, Utils._CalledSub(), 0, 1, psProperty)
806 _PropertySet = False
807 Goto Exit_Function
808 Trace_Error_Value:
809 TraceError(TRACEFATAL, ERRPROPERTYVALUE, Utils._CalledSub(), 0, 1, Array(pvValue, psProperty))
810 _PropertySet = False
811 Goto Exit_Function
812 Error_Function:
813 TraceError(TRACEABORT, Err, &quot;Dialog._PropertySet&quot;, Erl)
814 _PropertySet = False
815 GoTo Exit_Function
816 End Function &apos; _PropertySet
818 </script:module>