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 =======================================================================================================================
13 REM -----------------------------------------------------------------------------------------------------------------------
14 REM --- CLASS ROOT FIELDS ---
15 REM -----------------------------------------------------------------------------------------------------------------------
17 Private _Type As String
' Must be DIALOG
18 Private _Name As String
19 Private _Shortcut As String
20 Private _Dialog As Object
' com.sun.star.io.XInputStreamProvider
21 Private _Storage As String
' GLOBAL or DOCUMENT
22 Private _Library As String
23 Private UnoDialog As Object
' com.sun.star.awt.XControl
25 REM -----------------------------------------------------------------------------------------------------------------------
26 REM --- CONSTRUCTORS / DESTRUCTORS ---
27 REM -----------------------------------------------------------------------------------------------------------------------
28 Private Sub Class_Initialize()
32 _Storage =
""
33 _Library =
""
34 Set UnoDialog = Nothing
35 End Sub
' Constructor
37 REM -----------------------------------------------------------------------------------------------------------------------
38 Private Sub Class_Terminate()
39 On Local Error Resume Next
40 Call Class_Initialize()
41 End Sub
' Destructor
43 REM -----------------------------------------------------------------------------------------------------------------------
45 Call Class_Terminate()
46 End Sub
' Explicit destructor
48 REM -----------------------------------------------------------------------------------------------------------------------
49 REM --- CLASS GET/LET/SET PROPERTIES ---
50 REM -----------------------------------------------------------------------------------------------------------------------
51 REM -----------------------------------------------------------------------------------------------------------------------
52 Property Get Caption() As Variant
53 Caption = _PropertyGet(
"Caption
")
54 End Property
' Caption (get)
56 Property Let Caption(ByVal pvValue As Variant)
57 Call _PropertySet(
"Caption
", pvValue)
58 End Property
' Caption (set)
60 REM -----------------------------------------------------------------------------------------------------------------------
61 Property Get Height() As Variant
62 Height = _PropertyGet(
"Height
")
63 End Property
' Height (get)
65 Property Let Height(ByVal pvValue As Variant)
66 Call _PropertySet(
"Height
", pvValue)
67 End Property
' Height (set)
69 REM -----------------------------------------------------------------------------------------------------------------------
70 Property Get IsLoaded() As Boolean
71 IsLoaded = _PropertyGet(
"IsLoaded
")
74 REM -----------------------------------------------------------------------------------------------------------------------
75 Property Get Name() As String
76 Name = _PropertyGet(
"Name
")
77 End Property
' Name (get)
79 Public Function pName() As String
' For compatibility with
< V0.9
.0
80 pName = _PropertyGet(
"Name
")
81 End Function
' pName (get)
83 REM -----------------------------------------------------------------------------------------------------------------------
84 Property Get ObjectType() As String
85 ObjectType = _PropertyGet(
"ObjectType
")
86 End Property
' ObjectType (get)
88 REM -----------------------------------------------------------------------------------------------------------------------
89 Property Get OnFocusGained() As Variant
90 OnFocusGained = _PropertyGet(
"OnFocusGained
")
91 End Property
' OnFocusGained (get)
93 Property Let OnFocusGained(ByVal pvValue As Variant)
94 Call _PropertySet(
"OnFocusGained
", pvValue)
95 End Property
' OnFocusGained (set)
97 REM -----------------------------------------------------------------------------------------------------------------------
98 Property Get OnFocusLost() As Variant
99 OnFocusLost = _PropertyGet(
"OnFocusLost
")
100 End Property
' OnFocusLost (get)
102 Property Let OnFocusLost(ByVal pvValue As Variant)
103 Call _PropertySet(
"OnFocusLost
", pvValue)
104 End Property
' OnFocusLost (set)
106 REM -----------------------------------------------------------------------------------------------------------------------
107 Property Get OnKeyPressed() As Variant
108 OnKeyPressed = _PropertyGet(
"OnKeyPressed
")
109 End Property
' OnKeyPressed (get)
111 Property Let OnKeyPressed(ByVal pvValue As Variant)
112 Call _PropertySet(
"OnKeyPressed
", pvValue)
113 End Property
' OnKeyPressed (set)
115 REM -----------------------------------------------------------------------------------------------------------------------
116 Property Get OnKeyReleased() As Variant
117 OnKeyReleased = _PropertyGet(
"OnKeyReleased
")
118 End Property
' OnKeyReleased (get)
120 Property Let OnKeyReleased(ByVal pvValue As Variant)
121 Call _PropertySet(
"OnKeyReleased
", pvValue)
122 End Property
' OnKeyReleased (set)
124 REM -----------------------------------------------------------------------------------------------------------------------
125 Property Get OnMouseDragged() As Variant
126 OnMouseDragged = _PropertyGet(
"OnMouseDragged
")
127 End Property
' OnMouseDragged (get)
129 Property Let OnMouseDragged(ByVal pvValue As Variant)
130 Call _PropertySet(
"OnMouseDragged
", pvValue)
131 End Property
' OnMouseDragged (set)
133 REM -----------------------------------------------------------------------------------------------------------------------
134 Property Get OnMouseEntered() As Variant
135 OnMouseEntered = _PropertyGet(
"OnMouseEntered
")
136 End Property
' OnMouseEntered (get)
138 Property Let OnMouseEntered(ByVal pvValue As Variant)
139 Call _PropertySet(
"OnMouseEntered
", pvValue)
140 End Property
' OnMouseEntered (set)
142 REM -----------------------------------------------------------------------------------------------------------------------
143 Property Get OnMouseExited() As Variant
144 OnMouseExited = _PropertyGet(
"OnMouseExited
")
145 End Property
' OnMouseExited (get)
147 Property Let OnMouseExited(ByVal pvValue As Variant)
148 Call _PropertySet(
"OnMouseExited
", pvValue)
149 End Property
' OnMouseExited (set)
151 REM -----------------------------------------------------------------------------------------------------------------------
152 Property Get OnMouseMoved() As Variant
153 OnMouseMoved = _PropertyGet(
"OnMouseMoved
")
154 End Property
' OnMouseMoved (get)
156 Property Let OnMouseMoved(ByVal pvValue As Variant)
157 Call _PropertySet(
"OnMouseMoved
", pvValue)
158 End Property
' OnMouseMoved (set)
160 REM -----------------------------------------------------------------------------------------------------------------------
161 Property Get OnMousePressed() As Variant
162 OnMousePressed = _PropertyGet(
"OnMousePressed
")
163 End Property
' OnMousePressed (get)
165 Property Let OnMousePressed(ByVal pvValue As Variant)
166 Call _PropertySet(
"OnMousePressed
", pvValue)
167 End Property
' OnMousePressed (set)
169 REM -----------------------------------------------------------------------------------------------------------------------
170 Property Get OnMouseReleased() As Variant
171 OnMouseReleased = _PropertyGet(
"OnMouseReleased
")
172 End Property
' OnMouseReleased (get)
174 Property Let OnMouseReleased(ByVal pvValue As Variant)
175 Call _PropertySet(
"OnMouseReleased
", pvValue)
176 End Property
' OnMouseReleased (set)
178 REM -----------------------------------------------------------------------------------------------------------------------
179 Public Function OptionGroup(ByVal Optional pvGroupName As Variant) As Variant
180 ' Return either an error or an object of type OPTIONGROUP based on its name
181 ' A group is determined by the successive TabIndexes of the radio button
182 ' The name of the group = the name of its first element
184 Utils._SetCalledSub(
"Dialog.OptionGroup
")
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
> 0 Then
198 ReDim oRadios(
0 To iAllCount -
1)
199 For i =
0 To iAllCount -
1 ' Store all RadioButtons objects
200 Set ocControl = Controls(i)
201 If ocControl._SubType = CTLRADIOBUTTON Then
202 iRadioLast = iRadioLast +
1
203 Set oRadios(iRadioLast) = ocControl
207 Goto Error_Arg
' No control in dialog
210 If iRadioLast
< 0 then Goto Error_Arg
' No radio buttons in the dialog
212 'Resort oRadio array based on tab indexes
213 If iRadioLast
> 0 Then
214 For i =
0 To iRadioLast -
1 ' Bubble sort
215 For j = i +
1 To iRadioLast
216 If oRadios(i).TabIndex
> oRadios(j).TabIndex Then
217 Set oRadio = oRadios(i)
218 Set oRadios(i) = oRadios(j)
219 Set oRadios(j) = oRadio
225 'Scan Names to find match with argument
227 For i =
0 To iRadioLast
228 If UCase(oRadios(i)._Name) = UCase(pvGroupName) Then
230 Case
0 : bFound = True
232 If oRadios(i).TabIndex
> oRadios(i -
1).TabIndex +
1 Then
235 Goto Error_Arg
' same group as preceding item although name correct
241 sGroupName = oRadios(i)._Name
244 If oRadios(i).TabIndex = oRadios(i -
1).TabIndex +
1 Then iEnd = i
248 If bFound Then
' 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)
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
262 ._ParentType = CTLPARENTISDIALOG
263 ._ParentComponent = UnoDialog
268 Set OptionGroup = ogGroup
271 Utils._ResetCalledSub(
"Dialog.OptionGroup
")
274 TraceError(TRACEFATAL, ERRWRONGARGUMENT, Utils._CalledSub(),
0, , Array(
1, pvGroupName))
277 TraceError(TRACEABORT, Err,
"Dialog.OptionGroup
", Erl)
279 End Function
' OptionGroup V0.9
.1
281 REM -----------------------------------------------------------------------------------------------------------------------
282 Property Get Page() As Variant
283 Page = _PropertyGet(
"Page
")
284 End Property
' Page (get)
286 Property Let Page(ByVal pvValue As Variant)
287 Call _PropertySet(
"Page
", pvValue)
288 End Property
' Page (set)
290 REM -----------------------------------------------------------------------------------------------------------------------
291 Public Function Properties(ByVal Optional pvIndex As Variant) As Variant
293 ' a Collection object if pvIndex absent
294 ' a Property object otherwise
296 Const cstThisSub =
"Dialog.Properties
"
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)
306 vProperty = PropertiesGet._Properties(sObject, _Name, vPropertiesList, pvIndex)
307 vProperty._Value = _PropertyGet(vPropertiesList(pvIndex))
311 Set Properties = vProperty
312 Utils._ResetCalledSub(cstThisSub)
314 End Function
' Properties
316 REM -----------------------------------------------------------------------------------------------------------------------
317 Property Get Visible() As Variant
318 Visible = _PropertyGet(
"Visible
")
319 End Property
' Visible (get)
321 Property Let Visible(ByVal pvValue As Variant)
322 Call _PropertySet(
"Visible
", pvValue)
323 End Property
' Visible (set)
325 REM -----------------------------------------------------------------------------------------------------------------------
326 Property Get Width() As Variant
327 Width = _PropertyGet(
"Width
")
328 End Property
' Width (get)
330 Property Let Width(ByVal pvValue As Variant)
331 Call _PropertySet(
"Width
", pvValue)
332 End Property
' Width (set)
334 REM -----------------------------------------------------------------------------------------------------------------------
335 REM --- CLASS METHODS ---
336 REM -----------------------------------------------------------------------------------------------------------------------
338 Public Function Controls(Optional ByVal pvIndex As Variant) As Variant
339 ' Return a Control object with name or index = pvIndex
341 If _ErrorHandler() Then On Local Error Goto Error_Function
342 Utils._SetCalledSub(
"Dialog.Controls
")
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
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
' No argument, return Collection object
357 Set oCounter = New Collect
358 oCounter._CollType = COLLCONTROLS
359 oCounter._Count = iControlCount
360 Set Controls = oCounter
364 If Not Utils._CheckArgument(pvIndex,
1, Utils._AddNumeric(vbString)) Then Goto Exit_Function
366 ' Start building the ocControl object
367 ' Determine exact name
369 Select Case VarType(pvIndex)
370 Case vbInteger, vbLong, vbSingle, vbDouble, vbCurrency, vbBigint, vbDecimal
371 If pvIndex
< 0 Or pvIndex
> iControlCount -
1 Then Goto Trace_Error_Index
372 ocControl._Name = sControls(pvIndex)
373 Case vbString
' Check control name validity (non case sensitive)
375 sIndex = UCase(Utils._Trim(pvIndex))
376 For i =
0 To iControlCount -
1
377 If UCase(sControls(i)) = sIndex Then
382 If bFound Then ocControl._Name = sControls(i) Else Goto Trace_NotFound
385 ocControl._Shortcut = sParentShortcut
& "!
" & 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
395 Utils._ResetCalledSub(
"Dialog.Controls
")
398 TraceError(TRACEFATAL, ERRWRONGARGUMENT, Utils._CalledSub(),
0, , Array(iArg, pvIndex))
399 Set Controls = Nothing
402 TraceError(TRACEFATAL, ERRDIALOGNOTSTARTED, Utils._CalledSub(),
0, , _Name)
403 Set Controls = Nothing
406 TraceError(TRACEFATAL, ERRCOLLECTION, Utils._CalledSub(),
0,
1)
407 Set Controls = Nothing
410 TraceError(TRACEFATAL, ERRCONTROLNOTFOUND, Utils._CalledSub(),
0, , Array(pvIndex, pvIndex))
411 Set Controls = Nothing
414 TraceError(TRACEABORT, Err,
"Dialog.Controls
", Erl)
415 Set Controls = Nothing
417 End Function
' Controls
419 REM -----------------------------------------------------------------------------------------------------------------------
420 Public Sub EndExecute(ByVal Optional pvReturn As Variant)
421 ' Stop executing the dialog
423 If _ErrorHandler() Then On Local Error Goto Error_Sub
424 Utils._SetCalledSub(
"Dialog.endExecute
")
426 If IsMissing(pvReturn) Then pvReturn =
0
427 If Not Utils._CheckArgument(pvReturn,
1, Utils._AddNumeric(), , False) Then Goto Trace_Error
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)
436 Utils._ResetCalledSub(
"Dialog.endExecute
")
439 TraceError(TRACEFATAL, ERRWRONGARGUMENT, Utils._CalledSub(),
0, , Array(
"1", Utils._CStr(pvReturn)))
442 TraceError(TRACEFATAL, ERRDIALOGUNDEFINED, Utils._CalledSub(),
0)
445 TraceError(TRACEWARNING, ERRDIALOGNOTSTARTED, Utils._CalledSub(),
0,
1, _Name)
448 TraceError(TRACEABORT, Err,
"Dialog.endExecute
", Erl)
450 End Sub
' EndExecute
452 REM -----------------------------------------------------------------------------------------------------------------------
453 Public Function Execute() As Long
454 ' Execute dialog
456 'If _ErrorHandler() Then On Local Error Goto Error_Function
457 'Seems smart not to trap errors: debugging of dialog events otherwise made very difficult !
458 Utils._SetCalledSub(
"Dialog.Execute
")
461 If IsNull(_Dialog) Then Goto Error_Execute
462 If IsNull(UnoDialog) Then Goto Error_Not_Started
463 lExecute = UnoDialog.execute()
466 Case
1 : Execute = dlgOK
467 Case
0 : Execute = dlgCancel
468 Case Else : Execute = lExecute
472 Utils._ResetCalledSub(
"Dialog.Execute
")
475 TraceError(TRACEFATAL, ERRDIALOGUNDEFINED, Utils._CalledSub(),
0)
478 TraceError(TRACEWARNING, ERRDIALOGNOTSTARTED, Utils._CalledSub(),
0,
1, _Name)
481 TraceError(TRACEABORT, Err,
"Dialog.Execute
", Erl)
483 End Function
' Execute
485 REM -----------------------------------------------------------------------------------------------------------------------
486 Public Function getProperty(Optional ByVal pvProperty As Variant) As Variant
487 ' Return property value of psProperty property name
489 Utils._SetCalledSub(
"Dialog.getProperty
")
490 If IsMissing(pvProperty) Then Call _TraceArguments()
491 getProperty = _PropertyGet(pvProperty)
492 Utils._ResetCalledSub(
"Dialog.getProperty
")
494 End Function
' getProperty
496 REM -----------------------------------------------------------------------------------------------------------------------
497 Public Function hasProperty(ByVal Optional pvProperty As Variant) As Boolean
498 ' 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)
503 End Function
' 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 _
511 ' Execute Move method
512 Utils._SetCalledSub(
"Dialog.Move
")
513 If IsMissing(pvLeft) Then Call _TraceArguments()
514 On Local Error Goto Error_Function
516 Dim iArgNr As Integer
517 Select Case UCase(_A2B_.CalledSub)
518 Case UCase(
"Move
") : iArgNr =
1
519 Case UCase(
"Dialog.Move
") : iArgNr =
0
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
' Check arguments values
532 If pvHeight
< -
1 Then
533 iArg =
4 : iWrong = pvHeight
534 ElseIf pvWidth
< -
1 Then
535 iArg =
3 : iWrong = pvWidth
536 ElseIf pvTop
< -
1 Then
537 iArg =
2 : iWrong = pvTop
538 ElseIf pvLeft
< -
1 Then
539 iArg =
1 : iWrong = pvLeft
542 TraceError(TRACEFATAL, ERRWRONGARGUMENT, Utils._CalledSub(),
0,
1, Array(iArgNr + iArg, iWrong))
546 Dim iPosSize As Integer
548 If pvLeft
>=
0 Then iPosSize = iPosSize + com.sun.star.awt.PosSize.X
549 If pvTop
>=
0 Then iPosSize = iPosSize + com.sun.star.awt.PosSize.Y
550 If pvWidth
> 0 Then iPosSize = iPosSize + com.sun.star.awt.PosSize.WIDTH
551 If pvHeight
> 0 Then iPosSize = iPosSize + com.sun.star.awt.PosSize.HEIGHT
552 If iPosSize
> 0 Then UnoDialog.setPosSize(pvLeft, pvTop, pvWidth, pvHeight, iPosSize)
556 Utils._ResetCalledSub(
"Dialog.Move
")
559 TraceError(TRACEABORT, Err,
"Dialog.Move
", Erl)
561 End Function
' Move
563 REM -----------------------------------------------------------------------------------------------------------------------
564 Public Function setProperty(ByVal Optional psProperty As String, ByVal Optional pvValue As Variant) As Boolean
565 ' Return True if property setting OK
566 Utils._SetCalledSub(
"Dialog.setProperty
")
567 setProperty = _PropertySet(psProperty, pvValue)
568 Utils._ResetCalledSub(
"Dialog.setProperty
")
571 REM -----------------------------------------------------------------------------------------------------------------------
572 Public Function Start() As Boolean
575 If _ErrorHandler() Then On Local Error Goto Error_Function
576 Utils._SetCalledSub(
"Dialog.Start
")
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
587 Set UnoDialog = oStart
589 If .hasItem(COLLALLDIALOGS, _Name) Then .Dialogs.Remove(_Name)
' Inserted to solve errors, when aborts between start and terminate
590 .Dialogs.Add(UnoDialog, UCase(_Name))
595 Utils._ResetCalledSub(
"Dialog.Start
")
598 TraceError(TRACEFATAL, ERRDIALOGUNDEFINED, Utils._CalledSub(),
0)
601 TraceError(TRACEWARNING, ERRDIALOGSTARTED, Utils._CalledSub(),
0)
604 TraceError(TRACEABORT, Err,
"Dialog.Start
", Erl)
606 End Function
' Start
608 REM -----------------------------------------------------------------------------------------------------------------------
609 Public Function Terminate() As Boolean
612 If _ErrorHandler() Then On Local Error Goto Error_Function
613 Utils._SetCalledSub(
"Dialog.Terminate
")
616 If IsNull(_Dialog) Then Goto Error_Terminate
617 If IsNull(UnoDialog) Then Goto Error_Not_Started
619 Set UnoDialog = Nothing
620 _A2B_.Dialogs.Remove(_Name)
624 Utils._ResetCalledSub(
"Dialog.Terminate
")
627 TraceError(TRACEFATAL, ERRDIALOGUNDEFINED, Utils._CalledSub(),
0)
630 TraceError(TRACEWARNING, ERRDIALOGNOTSTARTED, Utils._CalledSub(),
0,
1, _Name)
633 TraceError(TRACEABORT, Err,
"Dialog.Terminate
", Erl)
635 End Function
' Terminate
637 REM -----------------------------------------------------------------------------------------------------------------------
638 REM --- PRIVATE FUNCTIONS ---
639 REM -----------------------------------------------------------------------------------------------------------------------
641 REM -----------------------------------------------------------------------------------------------------------------------
642 Private Function _GetListener(ByVal psProperty As String) As String
643 ' Return the X...Listener corresponding with the property in argument
645 Select Case UCase(psProperty)
646 Case UCase(
"OnFocusGained
"), UCase(
"OnFocusLost
")
647 _GetListener =
"XFocusListener
"
648 Case UCase(
"OnKeyPressed
"), UCase(
"OnKeyReleased
")
649 _GetListener =
"XKeyListener
"
650 Case UCase(
"OnMouseDragged
"), UCase(
"OnMouseMoved
")
651 _GetListener =
"XMouseMotionListener
"
652 Case UCase(
"OnMouseEntered
"), UCase(
"OnMouseExited
"), UCase(
"OnMousePressed
"), UCase(
"OnMouseReleased
")
653 _GetListener =
"XMouseListener
"
656 End Function
' _GetListener V1.7
.0
658 REM -----------------------------------------------------------------------------------------------------------------------
659 Private Function _PropertiesList() As Variant
662 _PropertiesList = Array(
"Caption
",
"Height
",
"IsLoaded
",
"Name
" _
663 ,
"OnFocusGained
",
"OnFocusLost
",
"OnKeyPressed
",
"OnKeyReleased
",
"OnMouseDragged
" _
664 ,
"OnMouseEntered
",
"OnMouseExited
",
"OnMouseMoved
",
"OnMousePressed
",
"OnMouseReleased
" _
665 ,
"ObjectType
",
"Page
",
"Visible
",
"Width
" _
668 _PropertiesList = Array(
"IsLoaded
",
"Name
" _
672 End Function
' _PropertiesList
674 REM -----------------------------------------------------------------------------------------------------------------------
675 Private Function _PropertyGet(ByVal psProperty As String) As Variant
676 ' Return property value of the psProperty property name
678 If _ErrorHandler() Then On Local Error Goto Error_Function
679 Utils._SetCalledSub(
"Dialog.get
" & psProperty)
681 Dim oDialogEvents As Object, sEventName As String
686 Select Case UCase(psProperty)
687 Case UCase(
"Name
"), UCase(
"IsLoaded
")
689 If IsNull(UnoDialog) Then Goto Trace_Error_Dialog
691 Select Case UCase(psProperty)
692 Case UCase(
"Caption
")
693 _PropertyGet = UnoDialog.getTitle()
694 Case UCase(
"Height
")
695 _PropertyGet = UnoDialog.getPosSize().Height
696 Case UCase(
"IsLoaded
")
697 _PropertyGet = _A2B_.hasItem(COLLALLDIALOGS, _Name)
698 Case UCase(
"Name
")
700 Case UCase(
"ObjectType
")
702 Case UCase(
"OnFocusGained
"), UCase(
"OnFocusLost
"), UCase(
"OnKeyPressed
"), UCase(
"OnKeyReleased
") _
703 , UCase(
"OnMouseDragged
"), UCase(
"OnMouseEntered
"), UCase(
"OnMouseExited
"), UCase(
"OnMouseMoved
") _
704 , UCase(
"OnMousePressed
"), UCase(
"OnMouseReleased
")
705 Set oDialogEvents = unoDialog.Model.getEvents()
706 sEventName =
"com.sun.star.awt.
" & _GetListener(psProperty)
& "::
" & Utils._GetEventName(psProperty)
707 If oDialogEvents.hasByName(sEventName) Then
708 _PropertyGet = oDialogEvents.getByName(sEventName).ScriptCode
710 _PropertyGet =
""
712 Case UCase(
"Page
")
713 _PropertyGet = UnoDialog.Model.Step
714 Case UCase(
"Visible
")
715 _PropertyGet = UnoDialog.IsVisible()
716 Case UCase(
"Width
")
717 _PropertyGet = UnoDialog.getPosSize().Width
723 Utils._ResetCalledSub(
"Dialog.get
" & psProperty)
726 TraceError(TRACEWARNING, ERRPROPERTY, Utils._CalledSub(),
0,
1, psProperty)
730 TraceError(TRACEFATAL, ERRDIALOGNOTSTARTED, Utils._CalledSub(),
0,
1, _Name)
734 TraceError(TRACEABORT, Err,
"Dialog._PropertyGet
", Erl)
737 End Function
' _PropertyGet
739 REM -----------------------------------------------------------------------------------------------------------------------
740 Private Function _PropertySet(ByVal psProperty As String, ByVal pvValue As Variant) As Boolean
742 Utils._SetCalledSub(
"Dialog.set
" & psProperty)
743 If _ErrorHandler() Then On Local Error Goto Error_Function
746 Dim oDialogEvents As Object, sEventName As String, oEvent As Object, sListener As String, sEvent As String
749 Dim iArgNr As Integer
751 If _IsLeft(_A2B_.CalledSub,
"Dialog.
") Then iArgNr =
1 Else iArgNr =
2
752 If IsNull(UnoDialog) Then Goto Trace_Error_Dialog
753 Select Case UCase(psProperty)
754 Case UCase(
"Caption
")
755 If Not Utils._CheckArgument(pvValue, iArgNr, vbString, , False) Then Goto Trace_Error_Value
756 UnoDialog.setTitle(pvValue)
757 Case UCase(
"Height
")
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(
"OnFocusGained
"), UCase(
"OnFocusLost
"), UCase(
"OnKeyPressed
"), UCase(
"OnKeyReleased
") _
761 , UCase(
"OnMouseDragged
"), UCase(
"OnMouseEntered
"), UCase(
"OnMouseExited
"), UCase(
"OnMouseMoved
") _
762 , UCase(
"OnMousePressed
"), UCase(
"OnMouseReleased
")
763 If Not Utils._CheckArgument(pvValue, iArgNr, vbString, , False) Then Goto Trace_Error_Value
764 If Not Utils._RegisterDialogEventScript(UnoDialog.Model _
766 , _GetListener(psProperty) _
768 ) Then GoTo Trace_Error_Dialog
769 Case UCase(
"Page
")
770 If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric(), , False) Then Goto Trace_Error_Value
771 If pvValue
< 0 Then Goto Trace_Error_Value
772 UnoDialog.Model.Step = pvValue
773 Case UCase(
"Visible
")
774 If Not Utils._CheckArgument(pvValue, iArgNr, vbBoolean, , False) Then Goto Trace_Error_Value
775 UnoDialog.setVisible(pvValue)
776 Case UCase(
"Width
")
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)
784 Utils._ResetCalledSub(
"Dialog.set
" & psProperty)
787 TraceError(TRACEFATAL, ERRDIALOGNOTSTARTED, Utils._CalledSub(),
0,
1, _Name)
791 TraceError(TRACEFATAL, ERRPROPERTY, Utils._CalledSub(),
0,
1, psProperty)
795 TraceError(TRACEFATAL, ERRPROPERTYVALUE, Utils._CalledSub(),
0,
1, Array(pvValue, psProperty))
799 TraceError(TRACEABORT, Err,
"Dialog._PropertySet
", Erl)
802 End Function
' _PropertySet