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 =======================================================================================================================
14 REM -----------------------------------------------------------------------------------------------------------------------
15 REM --- CLASS ROOT FIELDS ---
16 REM -----------------------------------------------------------------------------------------------------------------------
18 Private _Type As String
' Must be DIALOG
19 Private _This As Object
' 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
' com.sun.star.io.XInputStreamProvider
24 Private _Storage As String
' GLOBAL or DOCUMENT
25 Private _Library As String
26 Private UnoDialog As Object
' com.sun.star.awt.XControl
28 REM -----------------------------------------------------------------------------------------------------------------------
29 REM --- CONSTRUCTORS / DESTRUCTORS ---
30 REM -----------------------------------------------------------------------------------------------------------------------
31 Private Sub Class_Initialize()
37 _Storage =
""
38 _Library =
""
39 Set UnoDialog = Nothing
40 End Sub
' Constructor
42 REM -----------------------------------------------------------------------------------------------------------------------
43 Private Sub Class_Terminate()
44 On Local Error Resume Next
45 Call Class_Initialize()
46 End Sub
' Destructor
48 REM -----------------------------------------------------------------------------------------------------------------------
50 Call Class_Terminate()
51 End Sub
' Explicit destructor
53 REM -----------------------------------------------------------------------------------------------------------------------
54 REM --- CLASS GET/LET/SET PROPERTIES ---
55 REM -----------------------------------------------------------------------------------------------------------------------
56 REM -----------------------------------------------------------------------------------------------------------------------
57 Property Get Caption() As Variant
58 Caption = _PropertyGet(
"Caption
")
59 End Property
' Caption (get)
61 Property Let Caption(ByVal pvValue As Variant)
62 Call _PropertySet(
"Caption
", pvValue)
63 End Property
' Caption (set)
65 REM -----------------------------------------------------------------------------------------------------------------------
66 Property Get Height() As Variant
67 Height = _PropertyGet(
"Height
")
68 End Property
' Height (get)
70 Property Let Height(ByVal pvValue As Variant)
71 Call _PropertySet(
"Height
", pvValue)
72 End Property
' Height (set)
74 REM -----------------------------------------------------------------------------------------------------------------------
75 Property Get IsLoaded() As Boolean
76 IsLoaded = _PropertyGet(
"IsLoaded
")
79 REM -----------------------------------------------------------------------------------------------------------------------
80 Property Get Name() As String
81 Name = _PropertyGet(
"Name
")
82 End Property
' Name (get)
84 Public Function pName() As String
' For compatibility with
< V0.9
.0
85 pName = _PropertyGet(
"Name
")
86 End Function
' pName (get)
88 REM -----------------------------------------------------------------------------------------------------------------------
89 Property Get ObjectType() As String
90 ObjectType = _PropertyGet(
"ObjectType
")
91 End Property
' ObjectType (get)
93 REM -----------------------------------------------------------------------------------------------------------------------
94 Property Get OnFocusGained() As Variant
95 OnFocusGained = _PropertyGet(
"OnFocusGained
")
96 End Property
' OnFocusGained (get)
98 Property Let OnFocusGained(ByVal pvValue As Variant)
99 Call _PropertySet(
"OnFocusGained
", pvValue)
100 End Property
' OnFocusGained (set)
102 REM -----------------------------------------------------------------------------------------------------------------------
103 Property Get OnFocusLost() As Variant
104 OnFocusLost = _PropertyGet(
"OnFocusLost
")
105 End Property
' OnFocusLost (get)
107 Property Let OnFocusLost(ByVal pvValue As Variant)
108 Call _PropertySet(
"OnFocusLost
", pvValue)
109 End Property
' OnFocusLost (set)
111 REM -----------------------------------------------------------------------------------------------------------------------
112 Property Get OnKeyPressed() As Variant
113 OnKeyPressed = _PropertyGet(
"OnKeyPressed
")
114 End Property
' OnKeyPressed (get)
116 Property Let OnKeyPressed(ByVal pvValue As Variant)
117 Call _PropertySet(
"OnKeyPressed
", pvValue)
118 End Property
' OnKeyPressed (set)
120 REM -----------------------------------------------------------------------------------------------------------------------
121 Property Get OnKeyReleased() As Variant
122 OnKeyReleased = _PropertyGet(
"OnKeyReleased
")
123 End Property
' OnKeyReleased (get)
125 Property Let OnKeyReleased(ByVal pvValue As Variant)
126 Call _PropertySet(
"OnKeyReleased
", pvValue)
127 End Property
' OnKeyReleased (set)
129 REM -----------------------------------------------------------------------------------------------------------------------
130 Property Get OnMouseDragged() As Variant
131 OnMouseDragged = _PropertyGet(
"OnMouseDragged
")
132 End Property
' OnMouseDragged (get)
134 Property Let OnMouseDragged(ByVal pvValue As Variant)
135 Call _PropertySet(
"OnMouseDragged
", pvValue)
136 End Property
' OnMouseDragged (set)
138 REM -----------------------------------------------------------------------------------------------------------------------
139 Property Get OnMouseEntered() As Variant
140 OnMouseEntered = _PropertyGet(
"OnMouseEntered
")
141 End Property
' OnMouseEntered (get)
143 Property Let OnMouseEntered(ByVal pvValue As Variant)
144 Call _PropertySet(
"OnMouseEntered
", pvValue)
145 End Property
' OnMouseEntered (set)
147 REM -----------------------------------------------------------------------------------------------------------------------
148 Property Get OnMouseExited() As Variant
149 OnMouseExited = _PropertyGet(
"OnMouseExited
")
150 End Property
' OnMouseExited (get)
152 Property Let OnMouseExited(ByVal pvValue As Variant)
153 Call _PropertySet(
"OnMouseExited
", pvValue)
154 End Property
' OnMouseExited (set)
156 REM -----------------------------------------------------------------------------------------------------------------------
157 Property Get OnMouseMoved() As Variant
158 OnMouseMoved = _PropertyGet(
"OnMouseMoved
")
159 End Property
' OnMouseMoved (get)
161 Property Let OnMouseMoved(ByVal pvValue As Variant)
162 Call _PropertySet(
"OnMouseMoved
", pvValue)
163 End Property
' OnMouseMoved (set)
165 REM -----------------------------------------------------------------------------------------------------------------------
166 Property Get OnMousePressed() As Variant
167 OnMousePressed = _PropertyGet(
"OnMousePressed
")
168 End Property
' OnMousePressed (get)
170 Property Let OnMousePressed(ByVal pvValue As Variant)
171 Call _PropertySet(
"OnMousePressed
", pvValue)
172 End Property
' OnMousePressed (set)
174 REM -----------------------------------------------------------------------------------------------------------------------
175 Property Get OnMouseReleased() As Variant
176 OnMouseReleased = _PropertyGet(
"OnMouseReleased
")
177 End Property
' OnMouseReleased (get)
179 Property Let OnMouseReleased(ByVal pvValue As Variant)
180 Call _PropertySet(
"OnMouseReleased
", pvValue)
181 End Property
' OnMouseReleased (set)
183 REM -----------------------------------------------------------------------------------------------------------------------
184 Public Function OptionGroup(ByVal Optional pvGroupName As Variant) As Variant
185 ' Return either an error or an object of type OPTIONGROUP based on its name
186 ' A group is determined by the successive TabIndexes of the radio button
187 ' The name of the group = the name of its first element
189 Utils._SetCalledSub(
"Dialog.OptionGroup
")
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
> 0 Then
203 ReDim oRadios(
0 To iAllCount -
1)
204 For i =
0 To iAllCount -
1 ' Store all RadioButtons objects
205 Set ocControl = Controls(i)
206 If ocControl._SubType = CTLRADIOBUTTON Then
207 iRadioLast = iRadioLast +
1
208 Set oRadios(iRadioLast) = ocControl
212 Goto Error_Arg
' No control in dialog
215 If iRadioLast
< 0 then Goto Error_Arg
' No radio buttons in the dialog
217 'Resort oRadio array based on tab indexes
218 If iRadioLast
> 0 Then
219 For i =
0 To iRadioLast -
1 ' Bubble sort
220 For j = i +
1 To iRadioLast
221 If oRadios(i).TabIndex
> oRadios(j).TabIndex Then
222 Set oRadio = oRadios(i)
223 Set oRadios(i) = oRadios(j)
224 Set oRadios(j) = oRadio
230 'Scan Names to find match with argument
232 For i =
0 To iRadioLast
233 If UCase(oRadios(i)._Name) = UCase(pvGroupName) Then
235 Case
0 : bFound = True
237 If oRadios(i).TabIndex
> oRadios(i -
1).TabIndex +
1 Then
240 Goto Error_Arg
' same group as preceding item although name correct
246 sGroupName = oRadios(i)._Name
249 If oRadios(i).TabIndex = oRadios(i -
1).TabIndex +
1 Then iEnd = i
253 If bFound Then
' 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)
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
268 ._ParentType = CTLPARENTISDIALOG
269 ._ParentComponent = UnoDialog
274 Set OptionGroup = ogGroup
277 Utils._ResetCalledSub(
"Dialog.OptionGroup
")
280 TraceError(TRACEFATAL, ERRWRONGARGUMENT, Utils._CalledSub(),
0, , Array(
1, pvGroupName))
283 TraceError(TRACEABORT, Err,
"Dialog.OptionGroup
", Erl)
285 End Function
' OptionGroup V0.9
.1
287 REM -----------------------------------------------------------------------------------------------------------------------
288 Property Get Page() As Variant
289 Page = _PropertyGet(
"Page
")
290 End Property
' Page (get)
292 Property Let Page(ByVal pvValue As Variant)
293 Call _PropertySet(
"Page
", pvValue)
294 End Property
' Page (set)
296 REM -----------------------------------------------------------------------------------------------------------------------
297 Public Function Parent() As Object
299 End Function
' Parent (get) V6.4
.0
301 REM -----------------------------------------------------------------------------------------------------------------------
302 Public Function Properties(ByVal Optional pvIndex As Variant) As Variant
304 ' a Collection object if pvIndex absent
305 ' a Property object otherwise
307 Const cstThisSub =
"Dialog.Properties
"
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)
317 vProperty = PropertiesGet._Properties(sObject, _This, vPropertiesList, pvIndex)
318 vProperty._Value = _PropertyGet(vPropertiesList(pvIndex))
322 Set Properties = vProperty
323 Utils._ResetCalledSub(cstThisSub)
325 End Function
' Properties
327 REM -----------------------------------------------------------------------------------------------------------------------
328 Property Get Visible() As Variant
329 Visible = _PropertyGet(
"Visible
")
330 End Property
' Visible (get)
332 Property Let Visible(ByVal pvValue As Variant)
333 Call _PropertySet(
"Visible
", pvValue)
334 End Property
' Visible (set)
336 REM -----------------------------------------------------------------------------------------------------------------------
337 Property Get Width() As Variant
338 Width = _PropertyGet(
"Width
")
339 End Property
' Width (get)
341 Property Let Width(ByVal pvValue As Variant)
342 Call _PropertySet(
"Width
", pvValue)
343 End Property
' Width (set)
345 REM -----------------------------------------------------------------------------------------------------------------------
346 REM --- CLASS METHODS ---
347 REM -----------------------------------------------------------------------------------------------------------------------
349 Public Function Controls(Optional ByVal pvIndex As Variant) As Variant
350 ' Return a Control object with name or index = pvIndex
352 If _ErrorHandler() Then On Local Error Goto Error_Function
353 Utils._SetCalledSub(
"Dialog.Controls
")
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
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
' 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
379 If Not Utils._CheckArgument(pvIndex,
1, Utils._AddNumeric(vbString)) Then Goto Exit_Function
381 ' Start building the ocControl object
382 ' Determine exact name
384 Select Case VarType(pvIndex)
385 Case vbInteger, vbLong, vbSingle, vbDouble, vbCurrency, vbBigint, vbDecimal
386 If pvIndex
< 0 Or pvIndex
> iControlCount -
1 Then Goto Trace_Error_Index
387 ocControl._Name = sControls(pvIndex)
388 Case vbString
' Check control name validity (non case sensitive)
390 sIndex = UCase(Utils._Trim(pvIndex))
391 For i =
0 To iControlCount -
1
392 If UCase(sControls(i)) = sIndex Then
397 If bFound Then ocControl._Name = sControls(i) Else Goto Trace_NotFound
400 ocControl._Shortcut = sParentShortcut
& "!
" & 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
410 Utils._ResetCalledSub(
"Dialog.Controls
")
413 TraceError(TRACEFATAL, ERRWRONGARGUMENT, Utils._CalledSub(),
0, , Array(iArg, pvIndex))
414 Set Controls = Nothing
417 TraceError(TRACEFATAL, ERRDIALOGNOTSTARTED, Utils._CalledSub(),
0, , _Name)
418 Set Controls = Nothing
421 TraceError(TRACEFATAL, ERRCOLLECTION, Utils._CalledSub(),
0,
1)
422 Set Controls = Nothing
425 TraceError(TRACEFATAL, ERRCONTROLNOTFOUND, Utils._CalledSub(),
0, , Array(pvIndex, pvIndex))
426 Set Controls = Nothing
429 TraceError(TRACEABORT, Err,
"Dialog.Controls
", Erl)
430 Set Controls = Nothing
432 End Function
' Controls
434 REM -----------------------------------------------------------------------------------------------------------------------
435 Public Sub EndExecute(ByVal Optional pvReturn As Variant)
436 ' Stop executing the dialog
438 If _ErrorHandler() Then On Local Error Goto Error_Sub
439 Utils._SetCalledSub(
"Dialog.endExecute
")
441 If IsMissing(pvReturn) Then pvReturn =
0
442 If Not Utils._CheckArgument(pvReturn,
1, Utils._AddNumeric(), , False) Then Goto Trace_Error
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)
451 Utils._ResetCalledSub(
"Dialog.endExecute
")
454 TraceError(TRACEFATAL, ERRWRONGARGUMENT, Utils._CalledSub(),
0, , Array(
"1", Utils._CStr(pvReturn)))
457 TraceError(TRACEFATAL, ERRDIALOGUNDEFINED, Utils._CalledSub(),
0)
460 TraceError(TRACEWARNING, ERRDIALOGNOTSTARTED, Utils._CalledSub(),
0,
1, _Name)
463 TraceError(TRACEABORT, Err,
"Dialog.endExecute
", Erl)
465 End Sub
' EndExecute
467 REM -----------------------------------------------------------------------------------------------------------------------
468 Public Function Execute() As Long
469 ' Execute dialog
471 'If _ErrorHandler() Then On Local Error Goto Error_Function
472 'Seems smart not to trap errors: debugging of dialog events otherwise made very difficult !
473 Utils._SetCalledSub(
"Dialog.Execute
")
476 If IsNull(_Dialog) Then Goto Error_Execute
477 If IsNull(UnoDialog) Then Goto Error_Not_Started
478 lExecute = UnoDialog.execute()
481 Case
1 : Execute = dlgOK
482 Case
0 : Execute = dlgCancel
483 Case Else : Execute = lExecute
487 Utils._ResetCalledSub(
"Dialog.Execute
")
490 TraceError(TRACEFATAL, ERRDIALOGUNDEFINED, Utils._CalledSub(),
0)
493 TraceError(TRACEWARNING, ERRDIALOGNOTSTARTED, Utils._CalledSub(),
0,
1, _Name)
496 TraceError(TRACEABORT, Err,
"Dialog.Execute
", Erl)
498 End Function
' Execute
500 REM -----------------------------------------------------------------------------------------------------------------------
501 Public Function getProperty(Optional ByVal pvProperty As Variant) As Variant
502 ' Return property value of psProperty property name
504 Utils._SetCalledSub(
"Dialog.getProperty
")
505 If IsMissing(pvProperty) Then Call _TraceArguments()
506 getProperty = _PropertyGet(pvProperty)
507 Utils._ResetCalledSub(
"Dialog.getProperty
")
509 End Function
' getProperty
511 REM -----------------------------------------------------------------------------------------------------------------------
512 Public Function hasProperty(ByVal Optional pvProperty As Variant) As Boolean
513 ' 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)
518 End Function
' 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 _
526 ' Execute Move method
527 Utils._SetCalledSub(
"Dialog.Move
")
528 On Local Error Goto Error_Function
530 Dim iArgNr As Integer
531 Select Case UCase(_A2B_.CalledSub)
532 Case UCase(
"Move
") : iArgNr =
1
533 Case UCase(
"Dialog.Move
") : iArgNr =
0
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
' Check arguments values
546 If pvHeight
< -
1 Then
547 iArg =
4 : iWrong = pvHeight
548 ElseIf pvWidth
< -
1 Then
549 iArg =
3 : iWrong = pvWidth
550 ElseIf pvTop
< -
1 Then
551 iArg =
2 : iWrong = pvTop
552 ElseIf pvLeft
< -
1 Then
553 iArg =
1 : iWrong = pvLeft
556 TraceError(TRACEFATAL, ERRWRONGARGUMENT, Utils._CalledSub(),
0,
1, Array(iArgNr + iArg, iWrong))
560 Dim iPosSize As Integer
562 If pvLeft
>=
0 Then iPosSize = iPosSize + com.sun.star.awt.PosSize.X
563 If pvTop
>=
0 Then iPosSize = iPosSize + com.sun.star.awt.PosSize.Y
564 If pvWidth
> 0 Then iPosSize = iPosSize + com.sun.star.awt.PosSize.WIDTH
565 If pvHeight
> 0 Then iPosSize = iPosSize + com.sun.star.awt.PosSize.HEIGHT
566 If iPosSize
> 0 Then UnoDialog.setPosSize(pvLeft, pvTop, pvWidth, pvHeight, iPosSize)
570 Utils._ResetCalledSub(
"Dialog.Move
")
573 TraceError(TRACEABORT, Err,
"Dialog.Move
", Erl)
575 End Function
' Move
577 REM -----------------------------------------------------------------------------------------------------------------------
578 Public Function setProperty(ByVal Optional psProperty As String, ByVal Optional pvValue As Variant) As Boolean
579 ' Return True if property setting OK
580 Utils._SetCalledSub(
"Dialog.setProperty
")
581 setProperty = _PropertySet(psProperty, pvValue)
582 Utils._ResetCalledSub(
"Dialog.setProperty
")
585 REM -----------------------------------------------------------------------------------------------------------------------
586 Public Function Start() As Boolean
589 If _ErrorHandler() Then On Local Error Goto Error_Function
590 Utils._SetCalledSub(
"Dialog.Start
")
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
601 Set UnoDialog = oStart
603 If .hasItem(COLLALLDIALOGS, _Name) Then .Dialogs.Remove(_Name)
' Inserted to solve errors, when aborts between start and terminate
604 .Dialogs.Add(UnoDialog, UCase(_Name))
609 Utils._ResetCalledSub(
"Dialog.Start
")
612 TraceError(TRACEFATAL, ERRDIALOGUNDEFINED, Utils._CalledSub(),
0)
615 TraceError(TRACEWARNING, ERRDIALOGSTARTED, Utils._CalledSub(),
0)
618 TraceError(TRACEABORT, Err,
"Dialog.Start
", Erl)
620 End Function
' Start
622 REM -----------------------------------------------------------------------------------------------------------------------
623 Public Function Terminate() As Boolean
626 If _ErrorHandler() Then On Local Error Goto Error_Function
627 Utils._SetCalledSub(
"Dialog.Terminate
")
630 If IsNull(_Dialog) Then Goto Error_Terminate
631 If IsNull(UnoDialog) Then Goto Error_Not_Started
633 Set UnoDialog = Nothing
634 _A2B_.Dialogs.Remove(_Name)
638 Utils._ResetCalledSub(
"Dialog.Terminate
")
641 TraceError(TRACEFATAL, ERRDIALOGUNDEFINED, Utils._CalledSub(),
0)
644 TraceError(TRACEWARNING, ERRDIALOGNOTSTARTED, Utils._CalledSub(),
0,
1, _Name)
647 TraceError(TRACEABORT, Err,
"Dialog.Terminate
", Erl)
649 End Function
' Terminate
651 REM -----------------------------------------------------------------------------------------------------------------------
652 REM --- PRIVATE FUNCTIONS ---
653 REM -----------------------------------------------------------------------------------------------------------------------
655 REM -----------------------------------------------------------------------------------------------------------------------
656 Private Function _GetListener(ByVal psProperty As String) As String
657 ' Return the X...Listener corresponding with the property in argument
659 Select Case UCase(psProperty)
660 Case UCase(
"OnFocusGained
"), UCase(
"OnFocusLost
")
661 _GetListener =
"XFocusListener
"
662 Case UCase(
"OnKeyPressed
"), UCase(
"OnKeyReleased
")
663 _GetListener =
"XKeyListener
"
664 Case UCase(
"OnMouseDragged
"), UCase(
"OnMouseMoved
")
665 _GetListener =
"XMouseMotionListener
"
666 Case UCase(
"OnMouseEntered
"), UCase(
"OnMouseExited
"), UCase(
"OnMousePressed
"), UCase(
"OnMouseReleased
")
667 _GetListener =
"XMouseListener
"
670 End Function
' _GetListener V1.7
.0
672 REM -----------------------------------------------------------------------------------------------------------------------
673 Private Function _PropertiesList() As Variant
676 _PropertiesList = Array(
"Caption
",
"Height
",
"IsLoaded
",
"Name
" _
677 ,
"OnFocusGained
",
"OnFocusLost
",
"OnKeyPressed
",
"OnKeyReleased
",
"OnMouseDragged
" _
678 ,
"OnMouseEntered
",
"OnMouseExited
",
"OnMouseMoved
",
"OnMousePressed
",
"OnMouseReleased
" _
679 ,
"ObjectType
",
"Page
",
"Visible
",
"Width
" _
682 _PropertiesList = Array(
"IsLoaded
",
"Name
" _
686 End Function
' _PropertiesList
688 REM -----------------------------------------------------------------------------------------------------------------------
689 Private Function _PropertyGet(ByVal psProperty As String) As Variant
690 ' Return property value of the psProperty property name
692 If _ErrorHandler() Then On Local Error Goto Error_Function
693 Utils._SetCalledSub(
"Dialog.get
" & psProperty)
695 Dim oDialogEvents As Object, sEventName As String
700 Select Case UCase(psProperty)
701 Case UCase(
"Name
"), UCase(
"IsLoaded
")
703 If IsNull(UnoDialog) Then Goto Trace_Error_Dialog
705 Select Case UCase(psProperty)
706 Case UCase(
"Caption
")
707 _PropertyGet = UnoDialog.getTitle()
708 Case UCase(
"Height
")
709 _PropertyGet = UnoDialog.getPosSize().Height
710 Case UCase(
"IsLoaded
")
711 _PropertyGet = _A2B_.hasItem(COLLALLDIALOGS, _Name)
712 Case UCase(
"Name
")
714 Case UCase(
"ObjectType
")
716 Case UCase(
"OnFocusGained
"), UCase(
"OnFocusLost
"), UCase(
"OnKeyPressed
"), UCase(
"OnKeyReleased
") _
717 , UCase(
"OnMouseDragged
"), UCase(
"OnMouseEntered
"), UCase(
"OnMouseExited
"), UCase(
"OnMouseMoved
") _
718 , UCase(
"OnMousePressed
"), UCase(
"OnMouseReleased
")
719 Set oDialogEvents = unoDialog.Model.getEvents()
720 sEventName =
"com.sun.star.awt.
" & _GetListener(psProperty)
& "::
" & Utils._GetEventName(psProperty)
721 If oDialogEvents.hasByName(sEventName) Then
722 _PropertyGet = oDialogEvents.getByName(sEventName).ScriptCode
724 _PropertyGet =
""
726 Case UCase(
"Page
")
727 _PropertyGet = UnoDialog.Model.Step
728 Case UCase(
"Visible
")
729 _PropertyGet = UnoDialog.IsVisible()
730 Case UCase(
"Width
")
731 _PropertyGet = UnoDialog.getPosSize().Width
737 Utils._ResetCalledSub(
"Dialog.get
" & psProperty)
740 TraceError(TRACEWARNING, ERRPROPERTY, Utils._CalledSub(),
0,
1, psProperty)
744 TraceError(TRACEFATAL, ERRDIALOGNOTSTARTED, Utils._CalledSub(),
0,
1, _Name)
748 TraceError(TRACEABORT, Err,
"Dialog._PropertyGet
", Erl)
751 End Function
' _PropertyGet
753 REM -----------------------------------------------------------------------------------------------------------------------
754 Private Function _PropertySet(ByVal psProperty As String, ByVal pvValue As Variant) As Boolean
756 Utils._SetCalledSub(
"Dialog.set
" & psProperty)
757 If _ErrorHandler() Then On Local Error Goto Error_Function
760 Dim oDialogEvents As Object, sEventName As String, oEvent As Object, sListener As String, sEvent As String
763 Dim iArgNr As Integer
765 If _IsLeft(_A2B_.CalledSub,
"Dialog.
") Then iArgNr =
1 Else iArgNr =
2
766 If IsNull(UnoDialog) Then Goto Trace_Error_Dialog
767 Select Case UCase(psProperty)
768 Case UCase(
"Caption
")
769 If Not Utils._CheckArgument(pvValue, iArgNr, vbString, , False) Then Goto Trace_Error_Value
770 UnoDialog.setTitle(pvValue)
771 Case UCase(
"Height
")
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(
"OnFocusGained
"), UCase(
"OnFocusLost
"), UCase(
"OnKeyPressed
"), UCase(
"OnKeyReleased
") _
775 , UCase(
"OnMouseDragged
"), UCase(
"OnMouseEntered
"), UCase(
"OnMouseExited
"), UCase(
"OnMouseMoved
") _
776 , UCase(
"OnMousePressed
"), UCase(
"OnMouseReleased
")
777 If Not Utils._CheckArgument(pvValue, iArgNr, vbString, , False) Then Goto Trace_Error_Value
778 If Not Utils._RegisterDialogEventScript(UnoDialog.Model _
780 , _GetListener(psProperty) _
782 ) Then GoTo Trace_Error_Dialog
783 Case UCase(
"Page
")
784 If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric(), , False) Then Goto Trace_Error_Value
785 If pvValue
< 0 Then Goto Trace_Error_Value
786 UnoDialog.Model.Step = pvValue
787 Case UCase(
"Visible
")
788 If Not Utils._CheckArgument(pvValue, iArgNr, vbBoolean, , False) Then Goto Trace_Error_Value
789 UnoDialog.setVisible(pvValue)
790 Case UCase(
"Width
")
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)
798 Utils._ResetCalledSub(
"Dialog.set
" & psProperty)
801 TraceError(TRACEFATAL, ERRDIALOGNOTSTARTED, Utils._CalledSub(),
0,
1, _Name)
805 TraceError(TRACEFATAL, ERRPROPERTY, Utils._CalledSub(),
0,
1, psProperty)
809 TraceError(TRACEFATAL, ERRPROPERTYVALUE, Utils._CalledSub(),
0,
1, Array(pvValue, psProperty))
813 TraceError(TRACEABORT, Err,
"Dialog._PropertySet
", Erl)
816 End Function
' _PropertySet