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: ch_tools_common.inc,v $
13 '* last change: $Author: obo $ $Date: 2008-07-21 12:08:07 $
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 : oliver.craemer@sun.com
36 '* short description : Chart2 Tool library
38 '**************************************************************************************************
40 ' #1 fInsertOLE ' User Insert / Object / OLE to insert a chart
41 ' #1 fLoadVerySimpleChart ' Load file with a very simple chart
42 ' #1 fLoadVerySimpleChartAndSaveLocal ' Load file with a very simple chart and save it loacally
43 ' #1 fConvertChartTo3D ' Function to invoke the 'Insert::Titles...' dialog
44 ' #1 fOpenTestDocumentAndSelectDataRange ' Opens a test document and executes FormatDataRange
45 ' #1 fOpenTestDocumentAndInsertChart ' Opens a test document and selects a data range at a specific position
47 '\************************************************************************************************
49 sub fInsertOLE as BOOLEAN
50 'Insert Chart OLE in Document
52 '/// Insert / Object / OLE
55 Kontext "OLEObjektEinfuegen"
56 '/// Check if list box is not empty
57 if Objekttyp.getItemcount < 1 then
58 warnlog "There are no OLE-Objects in the listbox"
60 '/// Select 3rd entry in listbox (which should be the chart)
61 Objekttyp.TypeKeys "<HOME>"
62 Objekttyp.TypeKeys "<Down>", 2
63 '/// Quit dialog using OK
69 '--------------------------------------------------------------------
71 function fLoadVerySimpleChart() as INTEGER
72 fLoadVerySimpleChart = 99
73 'Load file with a very simple chart
77 '+ 1 := Serious problem trying to load the document
78 '+99 := Unexpected error
80 dim sInputFile as string
81 sInputFile = convertpath( gtesttoolpath & "chart2/required/input/verySimpleChart.ods" )
82 '/// Load file <i>gTesttoolpath</i>/chart2/required/input/verySimpleChart.ods
84 call hFileOpen ( sInputFile )
85 printlog "File with very simple chart loaded"
86 fLoadVerySimpleChart = 0
88 qaErrorLog "Loading file with very simple chart seems to fail"
89 fLoadVerySimpleChart = 1
93 '--------------------------------------------------------------------
95 function fLoadVerySimpleChartAndSaveLocal() as INTEGER
96 fLoadVerySimpleChartAndSaveLocal = 99
97 'Load file with a very simple chart and save it loacally
101 '+ 1 := Serious problem trying to load the document
102 '+ 2 := Serious problem trying to save the document
104 dim iCheckIsFileLoaded as INTEGER
105 dim sOutputFile as STRING
106 sOutputFile = convertpath( gOfficepath & "user/work/verySimpleChart.ods" )
107 iCheckIsFileLoaded = fLoadVerySimpleChart()
108 if iCheckIsFileLoaded > 0 then
109 'When loading fails pass error code to current function
110 fLoadVerySimpleChartAndSaveLocal = iCheckIsFileLoaded
113 printlog "File with very simple chart loaded successfully."
115 '/// Save document local
116 Kontext "DocumentCalc"
117 DocumentCalc.TypeKeys "<ESCAPE>"
118 DocumentCalc.TypeKeys "<MOD1 HOME>"
119 if NOT hFileSaveAsKill (sOutputFile) then
120 fLoadVerySimpleChartAndSaveLocal = 2
121 qaErrorLog "Saving test document localy failed -> Aborting"
125 printlog "File with very simple chart saved successfully."
127 fLoadVerySimpleChartAndSaveLocal = 0
130 '--------------------------------------------------------------------
132 function fConvertChartTo3D() as BOOLEAN
133 fConvertChartTo3D = FALSE
134 'Function to invoke the 'Insert::Titles...' dialog
136 'Returns TRUE on success
138 '/// Invoke Format::Chart Type...
139 if fInvokeChartTypeDialog() > 0 then
140 warnlog "Invoking 'Format::Chart Type...' seems to cause an Error"
144 if fSetChartType3D ( TRUE ) = 0 then
145 fConvertChartTo3D = TRUE
147 warnlog "Converting chart to 3D seems to cause an Error"
150 '/// Close Chart Type dialog with OK
151 if fCloseChartTypeDialogOK() > 0 then
152 warnlog "Closing Chart Type dialog seems to cause an Error"
153 fConvertChartTo3D = FALSE
157 '-------------------------------------------------------------------------
159 function fOpenTestDocumentAndSelectDataRange(sInputFile as string) as BOOLEAN
160 fOpenTestDocumentAndSelectDataRange = FALSE
161 call hFileOpen(sInputFile)
163 Call sMakeReadOnlyDocumentEditable()
164 '/// Select chart using navigator
165 printlog "Select chart using navigator"
167 '/// Edit / Object / Edit
168 printlog "Edit / Object / Edit"
170 '///Open FORMAT / DATA RANGES
171 printlog "Open FORMAT / DATA RANGES"
174 '///Switch to tabpage Data Range
175 printlog "Switch to tabpage Data Range"
177 'Switching tabpages as workaround for #i77237#
178 Active.SetPage TabChartTypeDataSeries
179 QAErrorLog "#i77237#-Testtool can't access OK after switching tabpage"
180 Active.SetPage TabChartTypeDataRange
181 Kontext "TabChartTypeDataRange"
182 call DialogTest ( TabChartTypeDataRange )
183 fOpenTestDocumentAndSelectDataRange = TRUE
186 '-------------------------------------------------------------------------
188 function fOpenTestDocumentAndInsertChart(sInputFile as string) as BOOLEAN
189 fOpenTestDocumentAndInsertChart = FALSE
190 call hFileOpen(sInputFile)
192 Call sMakeReadOnlyDocumentEditable()
193 Kontext "DocumentCalc"
194 printlog "Type <STRG+HOME>"
195 DocumentCalc.TypeKeys "<MOD1 HOME>"
196 printlog "Type twice <RIGHT> cursor key"
197 DocumentCalc.TypeKeys "<RIGHT>" , 2
198 printlog "Type thrice <DOWN> cursor key"
199 DocumentCalc.TypeKeys "<DOWN>" , 3
200 printlog "Menu Insert chart to open chart wizard"
204 fOpenTestDocumentAndInsertChart = TRUE
206 fOpenTestDocumentAndInsertChart = FALSE