1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="awt_XTextComponent" script:language="StarBasic">
'*************************************************************************
'
' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
'
' Copyright 2008 by Sun Microsystems, Inc.
'
' OpenOffice.org - a multi-platform office productivity suite
'
' $RCSfile: awt_XTextComponent.xba,v $
'
' $Revision: 1.3 $
'
' This file is part of OpenOffice.org.
'
' OpenOffice.org is free software: you can redistribute it and/or modify
' it under the terms of the GNU Lesser General Public License version 3
' only, as published by the Free Software Foundation.
'
' OpenOffice.org is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU Lesser General Public License version 3 for more details
' (a copy is included in the LICENSE file that accompanied this code).
'
' You should have received a copy of the GNU Lesser General Public License
' version 3 along with OpenOffice.org. If not, see
' <http://www.openoffice.org/license.html>
' for a copy of the LGPLv3 License.
'
'*************************************************************************
'*************************************************************************
' Be sure that all variables are dimensioned:
option explicit
Dim bCB1_textChanged As Boolean
Dim bCB2_textChanged As Boolean
Sub RunTest()
'*************************************************************************
' INTERFACE:
' com.sun.star.awt.XTextComponent
'*************************************************************************
On Error Goto ErrHndl
Dim bOK As Boolean
Dim oListener1 As Object, oListener2 As Object
Dim vSelection As new com.sun.star.awt.Selection
Dim vSelectionSelection As new com.sun.star.awt.Selection
Dim vGetSelection As new com.sun.star.awt.Selection
Dim vInsertSelection As new com.sun.star.awt.Selection
Dim cGetText As String
Dim len2set As Integer
Out.Log("create two com.sun.star.awt.XTextListener")
oListener1 = createUNOListener("CB1_", "com.sun.star.awt.XTextListener")
oListener2 = createUNOListener("CB2_", "com.sun.star.awt.XTextListener")
Test.StartMethod("setText()")
bOK = true
Dim cText As String
cText = "XTextComponent: setText()"
oObj.setText(cText)
Test.StartMethod("getText()")
bOK = bOK AND (cText = oObj.getText())
Test.MethodTested("setText()", bOK)
Test.MethodTested("getText()", bOK)
Test.StartMethod("insertText()")
bOK = true
oObj.setText("setSelection")
vInsertSelection.Min = 0
vInsertSelection.Max = 3
oObj.insertText(vInsertSelection,"new")
Out.Log("result of getText is: '" + oObj.getText() +"'. It sould be 'newSelection'")
bOK = bOK AND (oObj.getText() = "newSelection")
Test.MethodTested("insertText()", bOK)
Test.StartMethod("setSelection()")
bOK = true
vSelectionSelection.Min = 2
vSelectionSelection.Max = 3
oObj.setSelection(vSelectionSelection)
Test.StartMethod("getSelection()")
vGetSelection = oObj.getSelection()
bOK = bOK AND (vGetSelection.Min = vSelectionSelection.Min) AND _
(vGetSelection.Max = vSelectionSelection.Max)
Test.MethodTested("setSelection()", bOK)
Test.MethodTested("getSelection()", bOK)
Test.StartMethod("getSelectedText()")
bOK = true
oObj.setText("getSelectedText")
vSelectionSelection.Min = 0
vSelectionSelection.Max = 3
oObj.setSelection(vSelectionSelection)
Out.Log("result of getSelectedText is: '" + oObj.getSelectedText() +"'. It sould be 'get'")
bOK = bOK AND (oObj.getSelectedText() = "get")
Test.MethodTested("getSelectedText()", bOK)
Test.StartMethod("setEditable()")
bOK = true
oObj.setEditable(true)
Test.StartMethod("isEditable()")
bOK = bOK AND oObj.isEditable()
oObj.setEditable(false)
bOK = bOK AND NOT oObj.isEditable()
oObj.setEditable(true)
bOK = bOK AND oObj.isEditable()
Test.MethodTested("setEditable()", bOK)
Test.MethodTested("isEditable()", bOK)
Test.StartMethod("setMaxTextLen()")
bOK = true
if (oObj.getMaxTextLen = 12) then
len2set = 10
else
len2set = 12
endif
oObj.setMaxTextLen(len2set)
oObj.setText("0123456789ABCDE")
cGetText = oObj.getText()
Out.Log("result of Len(cGetText) is: '" + Len(cGetText) + "'. It sould be >'" + len2set+"' ")
bOK = bOK AND (Len(cGetText) > len2set)
Test.MethodTested("setMaxTextLen()", bOK)
Test.StartMethod("getMaxTextLen()")
bOK = true
if (oObj.getMaxTextLen = 12) then
len2set = 10
else
len2set = 12
endif
oObj.setMaxTextLen(len2set)
Out.Log("result of getMaxTextLen is: '" + oObj.getMaxTextLen() +"'. It sould be '"+len2set+"'")
bOK = bOK AND (oObj.getMaxTextLen() = len2set)
Test.MethodTested("getMaxTextLen()", bOK)
bCB1_textChanged = false
bCB2_textChanged = false
Test.StartMethod("addTextListener()")
bOK = true
oObj.addTextListener(oListener1)
oObj.addTextListener(oListener2)
oObj.setText("addTextListener")
Wait(500)
bOK = bOK AND bCB1_textChanged AND bCB2_textChanged
Test.MethodTested("addTextListener()", bOK)
bCB1_textChanged = false
bCB2_textChanged = false
Test.StartMethod("removeTextListener()")
bOK = true
oObj.removeTextListener(oListener1)
oObj.setText("removeTextListener")
Wait(500)
bOK = bOK AND NOT bCB1_textChanged AND bCB2_textChanged
oObj.removeTextListener(oListener2)
Test.MethodTested("removeTextListener()", bOK)
Exit Sub
ErrHndl:
Test.Exception()
bOK = false
resume next
End Sub
Sub CB1_disposing()
End Sub
Sub CB2_disposing()
End Sub
' Listener call backs for com.sun.star.awt.XTextListener
Sub CB1_textChanged
Out.Log("CallBack for Listener1 textChanged was called.")
bCB1_textChanged = true
End Sub
Sub CB2_TextChanged
Out.Log("CallBack for Listener2 textChanged was called.")
bCB2_textChanged = true
End Sub
</script:module>
|