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: c_arrayconstants.inc,v $
13 '* last change: $Author: jsi $ $Date: 2008-06-16 08:05:49 $
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 : calc arrayconstants level2 test
38 '************************************************************************
40 ' #1 tArrayconstants01 ' Direct input and OASIS format
41 ' #1 tArrayconstants02 ' Import / Export to MSExcel
43 '\***********************************************************************
45 testcase tArrayconstants01
47 dim sFunctionTRUE as string
48 dim sFunctionFALSE as string
49 dim sFunctionSIN as string
50 dim sError512 as string
51 dim sError533 as string
52 dim sdecimalseperator as string
53 dim sLocalFile as string
54 dim sCellcontent as string
56 sFunctionTRUE = fFunctionName ("TRUE")
57 sFunctionFALSE = fFunctionName ("FALSE")
58 sFunctionSIN = fFunctionName ("SIN")
59 sError512 = fError_l10n ("512")
60 sError533 = fError_l10n ("533")
61 sDecimalseperator = GetDecimalSeperator
62 sLocalFile = convertpath ( gOfficepath & "user/work/arrayconstants.ods" )
64 '///Open new spreadsheet document
65 printlog "Open new spreadsheet document"
68 '///In cell A1 enter "={1;2;3}"
69 printlog "In cell A1 enter ""={1;2;3}"""
70 call fCalcSelectRange ("A1")
71 kontext "DocumentCalc"
72 DocumentCalc.TypeKeys ("={1;2;3} <RETURN>")
73 '///Check that the cellvalue is "1"
74 printlog "Check that the cellvalue is ""1"""
75 call fCalcCompareCellValue ("A1","1")
77 '///In cell A2 enter "={1;2;3|4;5;6}"
78 printlog "In cell A2 enter ""={1;2;3|4;5;6}"""
79 call fCalcSelectRange ("A2")
80 kontext "DocumentCalc"
81 DocumentCalc.TypeKeys ("={1;2;3|4;5;6} <RETURN>")
82 '///Check that the cellvalue is "1"
83 printlog "Check that the cellvalue is ""1"""
84 call fCalcCompareCellValue ("A2","1")
86 '///In cell A3 enter "={0;1;2|False;TRUE;"two"}"
87 printlog "In cell A3 enter ""={0;1;2|" & sFunctionFALSE & ";" & sFunctionTRUE & ";""two""}"""
88 call fCalcSelectRange ("A3")
89 kontext "DocumentCalc"
90 DocumentCalc.TypeKeys ("={0;1;2|" & sFunctionFALSE & ";" & sFunctionTRUE & ";""two""} <RETURN>")
91 '///Check that the cellvalue is "0"
92 printlog "Check that the cellvalue is ""0"""
93 call fCalcCompareCellValue ("A3","0")
95 '///Multiselect cells A4:C4, type "=sin({1;2;3})" and press <ctrl shift enter>
96 printlog "Multiselect cells A4:C4, type ""=sin({1;2;3})"" and press <ctrl shift enter>"
97 call fCalcSelectRange ("A4:C4")
98 kontext "DocumentCalc"
99 DocumentCalc.TypeKeys ("=" & sFunctionSIN & "({1;2;3}) <MOD1 SHIFT RETURN>")
100 '///Check that the cellvalue of A4 is "0.84"
101 printlog "Check that the cellvalue of A4 is ""0.84"""
102 call fCalcSelectRange ("A5")
103 kontext "DocumentCalc"
104 DocumentCalc.TypeKeys "=A4<TAB>=B4<TAB>=C4<RETURN>" 'because a part of a matrix is protected we need a helpcell with only the values
105 call fCalcCompareCellValue ("A5","0" & sDecimalseperator & "84")
106 '///Check that the cell contents of B4 is "0.91"
107 printlog "Check that the cell contents of B4 is ""0.91"""
108 call fCalcCompareCellValue ("B5","0" & sDecimalseperator & "91")
109 '///Check that the cell contents of C4 is "0.14"
110 printlog "Check that the cell contents of C4 is ""0.14"""
111 call fCalcCompareCellValue ("C5","0" & sDecimalseperator & "14")
113 '///In cell A6 enter "={1;2|4;5;6}"
114 printlog "In cell A6 enter ""={1;2|4;5;6}"""
115 call fCalcSelectRange ("A6")
116 kontext "DocumentCalc"
117 DocumentCalc.TypeKeys ("={1;2|4;5;6} <RETURN>")
118 '///Check that the cellvalue is "Err:512"
119 printlog "Check that the cellvalue is ""Err:512"""
120 call fCalcCompareCellValue ("A6",sError512)
122 '///In cell A7 enter "={1;2+3}"
123 printlog "In cell A7 enter ""={1;2+3}"""
124 call fCalcSelectRange ("A7")
125 kontext "DocumentCalc"
126 DocumentCalc.TypeKeys ("={1;2+3} <RETURN>")
127 '///Check that the cellvalue is "Err:512"
128 printlog "Check that the cellvalue is ""Err:512"""
129 call fCalcCompareCellValue ("A7",sError512)
131 '///In cell A8 enter "={1;2;{3;4;5}}"
132 printlog "In cell A8 enter ""={1;2;{3;4;5}}"""
133 call fCalcSelectRange ("A8")
134 kontext "DocumentCalc"
135 DocumentCalc.TypeKeys ("={1;2;{3;4;5}} <RETURN>")
137 '///Cancel appearing MsgBox for correction of a wrong formular
138 if active.exists then
141 '///Check that the cellvalue is "Err:533"
142 printlog "Check that the cellvalue is ""Err:533"""
143 call fCalcCompareCellValue ("A8",sError533)
145 '///In cell A9 enter "={-1;2;3}"
146 printlog "In cell A9 enter ""={-1;2;3}"""
147 call fCalcSelectRange ("A9")
148 kontext "DocumentCalc"
149 DocumentCalc.TypeKeys ("={-1;2;3} <RETURN>")
150 '///Check that the cellvalue is "-1"
151 printlog "Check that the cellvalue is ""-1"""
152 call fCalcCompareCellValue ("A9",-1)
155 printlog "Save document"
156 call hFileSaveAsKill ( slocalfile )
159 printlog "Close document"
163 printlog "Load Document"
164 call hFileOpen ( slocalfile )
167 '///Check that all formulars are the same as before.
168 printlog "Check that all formulars are the same as before."
170 '///+Check that the editline shows "={1;2;3}" for cell A1
171 printlog " Check that the editline shows ""={1;2;3}"" for cell A1"
172 scellcontent = "={1;2;3}"
173 call fCalcCompareCellFormular ("A1",scellcontent)
175 '///+Check that the editline shows "={1;2;3|4;5;6}" for cell A2
176 printlog " Check that the editline shows ""={1;2;3|4;5;6}"" for cell A2"
177 scellcontent = "={1;2;3|4;5;6}"
178 call fCalcCompareCellFormular ("A2",scellcontent)
180 '///+Check that the editline shows "={0;1;2|False;TRUE;"two"}" for cell A3
181 printlog " Check that the editline shows ""={0;1;2|" & sFunctionFALSE & ";" & sFunctionTRUE & ";""two""}"" for cell A3"
182 scellcontent = "={0;1;2|" & sFunctionFALSE & ";" & sFunctionTRUE & ";""two""}"
183 call fCalcCompareCellFormular ("A3",scellcontent)
185 '///+Check that the editline shows "=SIN({1;2;3})" for cell A4:C4
186 printlog " Check that the editline shows ""=" & sFunctionSIN & "({1;2;3})"" for cell A4:C4"
187 scellcontent = "=" & sFunctionSIN & "({1;2;3})"
188 call fCalcCompareCellFormular ("A4:C4",scellcontent)
190 '///+Check that the editline shows "={1;2|4;5;6}" for cell A6
191 printlog " Check that the editline shows ""={1;2|4;5;6}"" for cell A6"
192 scellcontent = "={1;2|4;5;6}"
193 call fCalcCompareCellFormular ("A6",scellcontent)
195 '///+Check that the editline shows "={1;2+3}" for cell A7
196 printlog " Check that the editline shows ""={1;2+3}"" for cell A7"
197 scellcontent = "={1;2+3}"
198 call fCalcCompareCellFormular ("A7",scellcontent)
200 '///+Check that the editline shows "={1;2;{3;4;5}}" for cell A8
201 printlog " Check that the editline shows ""={1;2;{3;4;5}}"" for cell A8"
202 scellcontent = "={1;2;{3;4;5}}"
203 call fCalcCompareCellFormular ("A8",scellcontent)
205 '///+Check that the editline shows "={-1;2;3}" for cell A9
206 printlog " Check that the editline shows ""={-1;2;3}"" for cell A9"
207 scellcontent = "={-1;2;3}"
208 call fCalcCompareCellFormular ("A9",scellcontent)
211 printlog "Close Document"
216 '--------------------------------------------------------------------
218 testcase tArrayconstants02
220 Dim sImportFile as string
221 Dim sLocalFile as string
222 Dim sFunctionSUM as string
223 Dim sFunctionMDETERM as string
224 Dim sCellcontent as string
226 sImportFile = convertpath ( gTesttoolpath & "spreadsheet/optional/input/arrayconstants.xls" )
227 sLocalFile = convertpath ( gOfficepath & "user/work/arrayconstants.xls" )
228 sFunctionSUM = fFunctionName ("SUM")
229 sFunctionMDETERM = fFunctionName ("MDETERM")
231 '///Load xls testdocument <i>gTestToolPath</i>/spreadsheet/optional/input/arrayconstants.xls
232 printlog "Load xls testdocument <i>gTestToolPath</i>/spreadsheet/optional/input/arrayconstants.xls"
233 call hFileOpen ( sImportFile )
235 '///If the file is not editable, click the edit button on standardbar
236 printlog "If the file is not editable, click the edit button on standardbar"
237 call sMakeReadOnlyDocumentEditable
239 '///Check that the cell contents of B4 is 1
240 printlog "Check that the cell contents of B4 is 1"
241 call fCalcCompareCellValue ("F4","1")
242 '///Check that the cell contents of C5 is 4
243 printlog "Check that the cell contents of C5 is 4"
244 call fCalcCompareCellValue ("G5","4")
245 '///Check that the editline shows "={1;2|3;4}" for cell B4
246 printlog "Check that the editline shows ""={1;2|3;4}"" for cell B4"
247 scellcontent = "={1;2|3;4}"
248 call fCalcCompareCellFormular ("B4:C5",scellcontent)
249 '///Check that the cell contents of B8 is 10
250 printlog "Check that the cell contents of B8 is 10"
251 call fCalcCompareCellValue ("B8","10")
252 '///Check that the editline for cell B8 is "=SUM({1;2|3;4})"
253 printlog "Check that the editline for cell B8 is ""=SUM({1;2|3;4})"""
254 scellcontent = "=" & sFunctionSUM & "({1;2|3;4})"
255 call fCalcCompareCellFormular ("B8",scellcontent)
256 '///Check that the cell contents of B11 is -2
257 printlog "Check that the cell contents of B11 is -2"
258 call fCalcCompareCellValue ("B11","-2")
259 '///Check that the editline for cell B11 is "=MDETERM({1;2|3;4})"
260 printlog "Check that the editline for cell B11 is ""=MDETERM({1;2|3;4})"""
261 scellcontent = "=" & sFunctionMDETERM & "({1;2|3;4})"
262 call fCalcCompareCellFormular ("B11",scellcontent)
263 '///Check that the cell contents of B14 is 1
264 printlog "Check that the cell contents of B14 is 1"
265 call fCalcCompareCellValue ("F14","1")
266 '///Check that the editline for cell B14 is "{=name}"
267 printlog "Check that the editline for cell B14 is ""=name"""
268 scellcontent = "=name"
269 call fCalcCompareCellFormular ("B14:C15",scellcontent)
271 '/// Save document back to xls locally
272 printlog "Save document back to xls locally"
273 call hFileSaveAsKill ( slocalfile )
276 printlog "Close document"
280 printlog "Load Document"
281 call hFileOpen ( slocalfile )
284 '///Check that all cellvalues are the same as before
285 printlog "Check that all cellvalues are the same as before"
286 '///+Check that the cell contents of B4 is 1
287 printlog "Check that the cell contents of B4 is 1"
288 call fCalcCompareCellValue ("F4","1")
289 '///+Check that the cell contents of C5 is 4
290 printlog "Check that the cell contents of C5 is 4"
291 call fCalcCompareCellValue ("G5","4")
292 '///+Check that the editline shows "={1;2|3;4}" for cell B4
293 printlog "Check that the editline shows ""={1;2|3;4}"" for cell B4"
294 scellcontent = "={1;2|3;4}"
295 call fCalcCompareCellFormular ("B4:C5",scellcontent)
296 '///+Check that the cell contents of B8 is 10
297 printlog "Check that the cell contents of B8 is 10"
298 call fCalcCompareCellValue ("B8","10")
299 '///+Check that the editline for cell B8 is "=SUM({1;2|3;4})"
300 printlog "Check that the editline for cell B8 is ""=SUM({1;2|3;4})"""
301 scellcontent = "=" & sFunctionSUM & "({1;2|3;4})"
302 call fCalcCompareCellFormular ("B8",scellcontent)
303 '///+Check that the cell contents of B11 is -2
304 printlog "Check that the cell contents of B11 is -2"
305 call fCalcCompareCellValue ("B11","-2")
306 '///+Check that the editline for cell B11 is "=MDETERM({1;2|3;4})"
307 printlog "Check that the editline for cell B11 is ""=MDETERM({1;2|3;4})"""
308 scellcontent = "=" & sFunctionMDETERM & "({1;2|3;4})"
309 call fCalcCompareCellFormular ("B11",scellcontent)
310 '///+Check that the cell contents of B14 is 1
311 printlog "Check that the cell contents of B14 is 1"
312 call fCalcCompareCellValue ("F14","1")
313 '///+Check that the editline for cell B14 is "{=name}"
314 printlog "Check that the editline for cell B14 is ""=name"""
315 scellcontent = "=name"
316 call fCalcCompareCellFormular ("B14:C15",scellcontent)
319 printlog "Close document"