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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
|
'encoding UTF-8 Do not remove or change this line!
'**************************************************************************
'* 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: reporttools.inc,v $
'*
'* $Revision: 1.2 $
'*
'* last change: $Author: jsk $ $Date: 2008-06-20 08:03:51 $
'*
'* 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.
'*
'/************************************************************************
'*
'* owner : marc.neumann@sun.com
'*
'* short description : Report Helper Routines for Base tests.
'*
'***************************************************************************************
'*
'* #1 fOpenNewReoprtDesign
'* #1 fCloseReportDesign
'* #1 fCloseReportView
'* #1 fSaveReport
'* #1 fOpenReport
'* #1 fFindREport
'* #1 fOpenReportNavigator
'* #1 fCloseReportNavigator
'* #1 fSwitchPageheader
'* #1 fExecutereport
'* #1 fCloseAddFieldDialog
'* #1 tools_reporttools_InstallExtension
'*
'\***********************************************************************************
'-------------------------------------------------------------------------
function fOpenNewReportDesign()
'/// open a a new report design from an open database
'/// <u>parameter:</u>
Kontext "DATABASE"
if ( Database.NotExists(3) ) then
fOpenNewReportDesign = false
exit function
end if
Database.MouseDown(50,50)
Database.MouseUp(50,50)
sleep(1)
ViewReports
NewReportDesign
sleep(5)
' Kontext "ReportDesign"
' ReportDesign.MouseDown(50,50)
' ReportDesign.MouseUp(50,50)
' sleep(1)
fOpenNewReportDesign = true
end function
'--------------------------------------------------------------------
function fCloseReportDesign( optional bSave )
'/// close an open Report
'/// <u>parameter:</u>
'/// <b><i>optional</i> bSave:</b> if true the Report shall be saved, if false the changes are lost
sleep(1)
Kontext "ReportDesign"
ReportDesign.UseMenu
hMenuSelectNr(1) ' the file menu
hMenuSelectNr(5) ' the Close Window
'when issue 30401 is fixed this has to be changed
Kontext "Messagebox"
if Messagebox.Exists(3) then
if ( IsMissing( bSave ) ) then
Messagebox.No
else
if bSave then
Messagebox.Yes
else
Messagebox.No
endif
endif
end if
sleep(1)
fCloseReportDesign = true
end function
'--------------------------------------------------------------------
function fCloseReportView()
'/// close an open Report View
'/// <u>parameter:</u>
sleep(1)
Kontext "DocumentWriter"
DocumentWriter.UseMenu
hMenuSelectNr(1) ' the file menu
hMenuSelectNr(5) ' the Close Window
sleep(1)
fCloseReportView = true
end function
'--------------------------------------------------------------------
function fSaveReport( sReportName as string, optional bCloseReport as boolean )
'/// save an open Report with the given name
'/// <u>parameter:</u>
'/// <b>sReportName:</b> the name under which the Report shall be saved. If the file allready exists, then the file will be overwritten
'/// <b><i>optional</i> bCloseReport:</b> if true the Report shall be closed after saving, if false Report stay open
sleep(1)
Kontext "DocumentWriter"
DocumentWriter.UseMenu
hMenuSelectNr(1) ' the file menu
hMenuSelectNr(6) ' the Save
Kontext "ReportSaveDialog"
if ReportSaveDialog.exists(3) then
ReportName.setText(sReportName)
SaveBtn.Click
'click yes in the overwrite messages box
Kontext "MessageBox"
if MessageBox.exists(1) then
MessageBox.Yes
endif
fSaveReport = true
else
fSaveFrom = false
end if
if ( IsMissing( bCloseReport ) ) then
' nothing
else
call fCloseReport()
end if
end function
'--------------------------------------------------------------------
function fOpenReport(sReportName as string)
'/// open a Report with the given name
'/// <u>parameter:</u>
'/// <b>sReportName:</b> the name of the Report which shall be open
if ( fFindReport(sReportName) = true ) then
printlog "Report found -> open"
Kontext "ContainerView"
OpenReport ' uno-Slot .uno:DB/Open
sleep(1)
fOpenReport = true
else
printlog "Report not found."
fOpenReport = false
end if
end function
'--------------------------------------------------------------------
function fOpenReportInDesign(sReportName as string)
'/// open a Report with the given name in the design mode
'/// <u>parameter:</u>
'/// <b>sReportName:</b> the name of the Report which shall be open
if ( fFindReport(sReportName) = true ) then
printlog "Report found -> open"
Kontext "ContainerView"
EditReport ' uno-Slot .uno:DB/Edit
sleep(1)
fOpenReportInDesign = true
else
printlog "Report not found."
fOpenReportInDesign = false
end if
end function
'--------------------------------------------------------------------
function fFindReport(sReportName as string)
'/// select a Report with the given name
'/// <u>parameter:</u>
'/// <b>sReportName:</b> the name of the Report which shall be selected
Dim iNumbersOfReports as integer
Dim i as integer
Kontext "DATABASE"
ViewReports
fFindReport = false
if ( Not DatabaseReportsView.exists(1) ) then
warnlog "The Report tree doesn't exists"
exit function
end if
iNumbersOfReports = DatabaseReportsView.getItemCount()
' this select the first entry
DatabaseReportsView.TypeKeys "<HOME>"
DatabaseReportsView.TypeKeys "<UP>"
for i = 1 to iNumbersOfReports
DatabaseReportsView.TypeKeys "<ADD>"
'printlog "i = " + i
'printlog "ReportName.getItemCount = " + ReportTree.getItemCount
if DatabaseReportsView.getItemCount > iNumbersOfReports then
iNumbersOfReports = DatabaseReportsView.getItemCount()
endif
'printlog "ReportName.getSeltext = " + ReportTree.getSeltext
if DatabaseReportsView.getSeltext = sReportName then
fFindReport = true
exit for
endif
DatabaseReportsView.TypeKeys "<DOWN>"
next
sleep(1)
end function
'--------------------------------------------------------------------
function fOpenReportNavigator
'/// open the report navigator
'/// <u>parameter:</u>
printlog "open report navigator"
Kontext "ReportDesign"
ReportDesign.UseMenu
hMenuSelectNr(3)
if (hMenuItemIsChecked(5) = false) then
hMenuSelectNr(5)
else
'nothing
endif
sleep(1)
end function
'--------------------------------------------------------------------
function fCloseReportNavigator
'/// open the report navigator
'/// <u>parameter:</u>
printlog "open report navigator"
Kontext "ReportDesign"
ReportDesign.UseMenu
hMenuSelectNr(3)
if (hMenuItemIsChecked(5) = true) then
hMenuSelectNr(5)
else
'nothing
endif
sleep(1)
end function
'--------------------------------------------------------------------
function fExecuteReport
'/// execute the report via the menu
'/// <u>parameter:</u>
Kontext "ReportDesign"
ReportDesign.UseMenu
hMenuSelectNr(2)
hMenuSelectNr(14)
end function
'--------------------------------------------------------------------
function fSwitchPageHeader
'/// delete or insert the Page Header via the menu
'/// <u>parameter:</u>
Kontext "ReportDesign"
ReportDesign.UseMenu
hMenuSelectNr(2)
hMenuSelectNr(8)
end function
'--------------------------------------------------------------------
function fCloseAddFieldDialog
'/// close the Add Field Dialog via the slot or menu
'/// <u>parameter:</u>
Kontext "ReportAddField"
if (ReportAddField.exists(3)) then
ReportAddField.close
else
' check if the dialog is really not there
' sometimes the focus is wrong. So I try a second way to disable the dialog
Kontext "ReportDesign"
ReportDesign.UseMenu
hMenuSelectNr(3)
if (hMenuItemIsChecked(3)) then
hMenuSelectNr(3)
else
warnlog "there should be the Add field dialog. But there is none."
endif
endif
end function
'--------------------------------------------------------------------
function fOpenAddFieldDialog
'/// open the Add Field Dialog via the slot or menu
'/// <u>parameter:</u>
Kontext "ReportAddField"
if (ReportAddField.exists(3)) then
' do nothing
else
Kontext "ReportDesign"
ReportDesign.UseMenu
hMenuSelectNr(3)
if (hMenuItemIsChecked(3)) then
hMenuSelectNr(3)
ReportDesign.UseMenu
hMenuSelectNr(3)
hMenuSelectNr(3)
printlog "1"
else
hMenuSelectNr(4)
printlog "2"
endif
Kontext "ReportAddField"
ReportAddField
if (ReportAddField.exists(3)) then
' do nothing
else
warnlog "there should be the Add field dialog. But there is none."
endif
endif
end function
'--------------------------------------------------------------------
function tools_reporttools_InstallExtension
'/// install the report designer extension
'/// <u>parameter:</u>
'/// <u>Return Value:</u><br>
'/// <ol>
'/// +<li>Errorcode (Integer)</li>
'/// <ul>
'/// <li>0 = No errors, extension was added correctly</li>
'/// <li> not 0 = an error occure see hExtensionAddGUI for more info </li>
'/// </ul>
'/// </ol>
dim i as integer
use "global/tools/includes/optional/t_extension_manager_tools.inc"
if (not hIsExtensionAlreadyInstalled("Report Builder")) then
i = hExtensionAddGUI( gTesttoolPath + "dbaccess/required/input/sun-report-builder.oxt", "AcceptLicense,InstallForUser" )
if (i > 0) then
tools_reporttools_InstallExtension = 0
else
if (i = -5) then
warnlog "Report extension was not installed due to unsatisfied dependencies."
tools_reporttools_InstallExtension = 5
else
warnlog "Report extension was not installed. Error Code = " + i
tools_reporttools_InstallExtension = i
endif
endif
else
tools_reporttools_InstallExtension = 0
endif
' restart the office
call ExitRestartTheOffice
end function
|