1 'encoding UTF-8 Do not remove or change this line!
2 '**************************************************************************
3 '* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 '* Copyright 2008 by Sun Microsystems, Inc.
7 '* OpenOffice.org - a multi-platform office productivity suite
9 '* $RCSfile: reporttools.inc,v $
13 '* last change: $Author: jsk $ $Date: 2008-06-20 08:03:51 $
15 '* This file is part of OpenOffice.org.
17 '* OpenOffice.org is free software: you can redistribute it and/or modify
18 '* it under the terms of the GNU Lesser General Public License version 3
19 '* only, as published by the Free Software Foundation.
21 '* OpenOffice.org is distributed in the hope that it will be useful,
22 '* but WITHOUT ANY WARRANTY; without even the implied warranty of
23 '* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 '* GNU Lesser General Public License version 3 for more details
25 '* (a copy is included in the LICENSE file that accompanied this code).
27 '* You should have received a copy of the GNU Lesser General Public License
28 '* version 3 along with OpenOffice.org. If not, see
29 '* <http://www.openoffice.org/license.html>
30 '* for a copy of the LGPLv3 License.
32 '/************************************************************************
34 '* owner : marc.neumann@sun.com
36 '* short description : Report Helper Routines for Base tests.
38 '***************************************************************************************
40 '* #1 fOpenNewReoprtDesign
41 '* #1 fCloseReportDesign
42 '* #1 fCloseReportView
46 '* #1 fOpenReportNavigator
47 '* #1 fCloseReportNavigator
48 '* #1 fSwitchPageheader
50 '* #1 fCloseAddFieldDialog
51 '* #1 tools_reporttools_InstallExtension
53 '\***********************************************************************************
54 '-------------------------------------------------------------------------
55 function fOpenNewReportDesign()
56 '/// open a a new report design from an open database
57 '/// <u>parameter:</u>
60 if ( Database.NotExists(3) ) then
61 fOpenNewReportDesign = false
65 Database.MouseDown(50,50)
66 Database.MouseUp(50,50)
75 ' Kontext "ReportDesign"
76 ' ReportDesign.MouseDown(50,50)
77 ' ReportDesign.MouseUp(50,50)
81 fOpenNewReportDesign = true
84 '--------------------------------------------------------------------
85 function fCloseReportDesign( optional bSave )
86 '/// close an open Report
87 '/// <u>parameter:</u>
88 '/// <b><i>optional</i> bSave:</b> if true the Report shall be saved, if false the changes are lost
92 Kontext "ReportDesign"
94 hMenuSelectNr(1) ' the file menu
95 hMenuSelectNr(5) ' the Close Window
97 'when issue 30401 is fixed this has to be changed
99 if Messagebox.Exists(3) then
100 if ( IsMissing( bSave ) ) then
113 fCloseReportDesign = true
116 '--------------------------------------------------------------------
117 function fCloseReportView()
118 '/// close an open Report View
119 '/// <u>parameter:</u>
123 Kontext "DocumentWriter"
124 DocumentWriter.UseMenu
125 hMenuSelectNr(1) ' the file menu
126 hMenuSelectNr(5) ' the Close Window
130 fCloseReportView = true
133 '--------------------------------------------------------------------
134 function fSaveReport( sReportName as string, optional bCloseReport as boolean )
135 '/// save an open Report with the given name
136 '/// <u>parameter:</u>
137 '/// <b>sReportName:</b> the name under which the Report shall be saved. If the file allready exists, then the file will be overwritten
138 '/// <b><i>optional</i> bCloseReport:</b> if true the Report shall be closed after saving, if false Report stay open
141 Kontext "DocumentWriter"
142 DocumentWriter.UseMenu
143 hMenuSelectNr(1) ' the file menu
144 hMenuSelectNr(6) ' the Save
146 Kontext "ReportSaveDialog"
147 if ReportSaveDialog.exists(3) then
148 ReportName.setText(sReportName)
150 'click yes in the overwrite messages box
152 if MessageBox.exists(1) then
160 if ( IsMissing( bCloseReport ) ) then
167 '--------------------------------------------------------------------
168 function fOpenReport(sReportName as string)
169 '/// open a Report with the given name
170 '/// <u>parameter:</u>
171 '/// <b>sReportName:</b> the name of the Report which shall be open
173 if ( fFindReport(sReportName) = true ) then
174 printlog "Report found -> open"
175 Kontext "ContainerView"
176 OpenReport ' uno-Slot .uno:DB/Open
180 printlog "Report not found."
185 '--------------------------------------------------------------------
186 function fOpenReportInDesign(sReportName as string)
187 '/// open a Report with the given name in the design mode
188 '/// <u>parameter:</u>
189 '/// <b>sReportName:</b> the name of the Report which shall be open
191 if ( fFindReport(sReportName) = true ) then
192 printlog "Report found -> open"
193 Kontext "ContainerView"
194 EditReport ' uno-Slot .uno:DB/Edit
196 fOpenReportInDesign = true
198 printlog "Report not found."
199 fOpenReportInDesign = false
203 '--------------------------------------------------------------------
204 function fFindReport(sReportName as string)
205 '/// select a Report with the given name
206 '/// <u>parameter:</u>
207 '/// <b>sReportName:</b> the name of the Report which shall be selected
209 Dim iNumbersOfReports as integer
218 if ( Not DatabaseReportsView.exists(1) ) then
219 warnlog "The Report tree doesn't exists"
223 iNumbersOfReports = DatabaseReportsView.getItemCount()
225 ' this select the first entry
226 DatabaseReportsView.TypeKeys "<HOME>"
227 DatabaseReportsView.TypeKeys "<UP>"
230 for i = 1 to iNumbersOfReports
232 DatabaseReportsView.TypeKeys "<ADD>"
234 'printlog "ReportName.getItemCount = " + ReportTree.getItemCount
235 if DatabaseReportsView.getItemCount > iNumbersOfReports then
236 iNumbersOfReports = DatabaseReportsView.getItemCount()
238 'printlog "ReportName.getSeltext = " + ReportTree.getSeltext
239 if DatabaseReportsView.getSeltext = sReportName then
243 DatabaseReportsView.TypeKeys "<DOWN>"
248 '--------------------------------------------------------------------
249 function fOpenReportNavigator
250 '/// open the report navigator
251 '/// <u>parameter:</u>
252 printlog "open report navigator"
253 Kontext "ReportDesign"
256 if (hMenuItemIsChecked(5) = false) then
265 '--------------------------------------------------------------------
266 function fCloseReportNavigator
267 '/// open the report navigator
268 '/// <u>parameter:</u>
269 printlog "open report navigator"
270 Kontext "ReportDesign"
273 if (hMenuItemIsChecked(5) = true) then
282 '--------------------------------------------------------------------
283 function fExecuteReport
284 '/// execute the report via the menu
285 '/// <u>parameter:</u>
287 Kontext "ReportDesign"
293 '--------------------------------------------------------------------
294 function fSwitchPageHeader
295 '/// delete or insert the Page Header via the menu
296 '/// <u>parameter:</u>
298 Kontext "ReportDesign"
304 '--------------------------------------------------------------------
305 function fCloseAddFieldDialog
306 '/// close the Add Field Dialog via the slot or menu
307 '/// <u>parameter:</u>
309 Kontext "ReportAddField"
310 if (ReportAddField.exists(3)) then
313 ' check if the dialog is really not there
314 ' sometimes the focus is wrong. So I try a second way to disable the dialog
315 Kontext "ReportDesign"
318 if (hMenuItemIsChecked(3)) then
321 warnlog "there should be the Add field dialog. But there is none."
325 '--------------------------------------------------------------------
326 function fOpenAddFieldDialog
327 '/// open the Add Field Dialog via the slot or menu
328 '/// <u>parameter:</u>
330 Kontext "ReportAddField"
331 if (ReportAddField.exists(3)) then
334 Kontext "ReportDesign"
337 if (hMenuItemIsChecked(3)) then
347 Kontext "ReportAddField"
349 if (ReportAddField.exists(3)) then
352 warnlog "there should be the Add field dialog. But there is none."
357 '--------------------------------------------------------------------
358 function tools_reporttools_InstallExtension
359 '/// install the report designer extension
360 '/// <u>parameter:</u>
361 '/// <u>Return Value:</u><br>
364 '/// +<li>Errorcode (Integer)</li>
366 '/// <li>0 = No errors, extension was added correctly</li>
367 '/// <li> not 0 = an error occure see hExtensionAddGUI for more info </li>
372 use "global/tools/includes/optional/t_extension_manager_tools.inc"
373 if (not hIsExtensionAlreadyInstalled("Report Builder")) then
374 i = hExtensionAddGUI( gTesttoolPath + "dbaccess/required/input/sun-report-builder.oxt", "AcceptLicense,InstallForUser" )
376 tools_reporttools_InstallExtension = 0
379 warnlog "Report extension was not installed due to unsatisfied dependencies."
380 tools_reporttools_InstallExtension = 5
382 warnlog "Report extension was not installed. Error Code = " + i
383 tools_reporttools_InstallExtension = i
387 tools_reporttools_InstallExtension = 0
391 call ExitRestartTheOffice