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