1 'encoding UTF-8 Do not remove or change this line!
\r
2 '**************************************************************************
\r
3 '* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
\r
5 '* Copyright 2008 by Sun Microsystems, Inc.
\r
7 '* OpenOffice.org - a multi-platform office productivity suite
\r
9 '* $RCSfile: ch2_xml_format.inc,v $
\r
13 '* last change: $Author: obo $ $Date: 2008-07-22 10:36:42 $
\r
15 '* This file is part of OpenOffice.org.
\r
17 '* OpenOffice.org is free software: you can redistribute it and/or modify
\r
18 '* it under the terms of the GNU Lesser General Public License version 3
\r
19 '* only, as published by the Free Software Foundation.
\r
21 '* OpenOffice.org is distributed in the hope that it will be useful,
\r
22 '* but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
23 '* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
24 '* GNU Lesser General Public License version 3 for more details
\r
25 '* (a copy is included in the LICENSE file that accompanied this code).
\r
27 '* You should have received a copy of the GNU Lesser General Public License
\r
28 '* version 3 along with OpenOffice.org. If not, see
\r
29 '* <http://www.openoffice.org/license.html>
\r
30 '* for a copy of the LGPLv3 License.
\r
32 '/***********************************************************************
\r
34 '* owner : oliver.craemer@sun.com
\r
36 '* short description : Verify the Chart2 XML file format
\r
38 '************************************************************************
\r
40 ' #1 tCompareXMLFormatCreate ' Verify Chart2 XML file format by using three characteristcs on new chart
\r
41 ' #1 tCompareXMLFormatLoad ' Verify Chart2 XML file format by using three characteristcs on loaded chart
\r
43 '\***********************************************************************
\r
45 testcase tCompareXMLFormatCreate
\r
46 '///+ Test purpose: Verify within three characteristics that there is really a chart
\r
48 dim sOutputFile as string
\r
49 dim sUnpackedStorageDir as string
\r
50 dim sChartContentXML as string
\r
52 gApplication = "WRITER"
\r
53 sOutputFile = convertpath(gOfficepath & "user\work\Chart2_XML.odt")
\r
54 sUnpackedStorageDir = (gOfficePath & ConvertPath("user\work\chart2_XML2"))
\r
55 sChartContentXML = (gOfficePath & ConvertPath("user\work\chart2_XML2") & ConvertPath("\Object 1\content.xml"))
\r
57 '/// File / New / Text
\r
58 printlog " Open new Writer document"
\r
60 '/// Insert chart with Insert / Object / Chart
\r
61 printlog " Insert chart with Insert / Object / Chart"
\r
63 '/// Save document to <i>gOfficepath</i>/user/work/Chart2_XML.odt
\r
64 printlog " Save document to <i>gOfficepath</i>/user/work/Chart2_XML.odt"
\r
65 if NOT hFileSaveAsKill (sOutputFile) then
\r
66 warnlog "Saving test document failed -> Aborting"
\r
70 printlog "File saved successfully."
\r
75 printlog "File closed"
\r
76 '/// Uncompress with <i>unzip</i> or <i>jar</i> the
\r
77 '///+ <i>gOfficepath</i>/user/work/verySimpleChart.ods document
\r
78 '///+ into <i>gOfficePath</i>/user/work/chart2_XML-directory
\r
79 printlog "Unpack storage of test document."
\r
80 UnpackStorage(sOutputFile, sUnpackedStorageDir)
\r
81 printlog "Read the test documents DOM."
\r
82 '/// Load the XML file <i>gOfficePath</i>/user/work/chart2_XML/Object 1/content.xml
\r
83 '///+ in an XML editor
\r
84 SAXReadFile(sChartContentXML)
\r
85 printlog "Set the DOM pointer to document root"
\r
88 printlog " |-office:document-content"
\r
89 '/// Open the element 'office:document-content'
\r
90 SAXSeekElement("office:document-content")
\r
91 printlog " |-office:body"
\r
92 '/// Open the element 'office:body'
\r
93 SAXSeekElement("office:body")
\r
94 printlog " |-office:chart"
\r
95 '/// Open the element 'office:chart'
\r
96 SAXSeekElement("office:chart")
\r
97 printlog " |-chart:chart"
\r
98 '/// Open the element 'chart:chart'
\r
99 SAXSeekElement("chart:chart")
\r
100 '/// Get the attribute value for <i>chart:class</i>.
\r
101 '///+ If it is 'chart:bar' the first characteristics validation has been
\r
103 if SAXGetAttributeValue("chart:class") = "chart:bar" then
\r
104 printlog "This is a bar chart as expected"
\r
106 warnlog "This is no bar chart, it is a " & SaxGetAttributeValue("chart:class")
\r
108 printlog "Seek for chart:plot-area"
\r
109 printlog " |-chart:plot-area"
\r
110 '/// Open the element 'chart:plot-area'
\r
111 SAXSeekElement("chart:plot-area")
\r
112 '/// If the attribute value of 'chart:data-source-has-labels' is 'both'
\r
113 '///+ the second characteristics validation has been passed.
\r
114 if SAXGetAttributeValue("chart:data-source-has-labels") = "both" then
\r
115 printlog "The label attribute for chart:plot-area is correct"
\r
117 warnlog "The lable attribute is not both, it is " & SaxGetAttributeValue("chart:data-source-has-labels")
\r
119 printlog "Seek for chart:series"
\r
120 printlog " |-chart:series"
\r
121 '/// Open the element 'chart:series'
\r
122 SAXSeekElement("chart:series")
\r
123 '/// If the attribute valie of 'chart:values-cell-range-address' is local-table.$B$2:.$B$5''
\r
124 '///+ the hird characteristics validation has been passed.
\r
125 if SAXGetAttributeValue("chart:values-cell-range-address") = "local-table.$B$2:.$B$5" then
\r
126 printlog "The cell range for chart:series is correct"
\r
128 warnlog "The cell range is not local-table.$B$2:.$B$5, it is " & SaxGetAttributeValue("chart:values-cell-range-address")
\r
130 ' DEBUG: printlog "I'm here: " & SAXGetElementName
\r
131 '/// Close the XML editor.
\r
135 '--------------------------------------------------------------------
\r
137 testcase tCompareXMLFormatLoad
\r
138 '///+ Test purpose: Verify within three characteristics that there is really a chart
\r
140 dim sOutputFile as string
\r
141 dim sUnpackedStorageDir as string
\r
142 dim sChartContentXML as string
\r
144 gApplication = "CALC"
\r
145 sOutputFile = convertpath(gOfficepath & "user\work\verySimpleChart.ods")
\r
146 sUnpackedStorageDir = (gOfficePath & ConvertPath("user\work\chart2_XML"))
\r
147 sChartContentXML = (gOfficePath & ConvertPath("user\work\chart2_XML") & ConvertPath("\Object 1\content.xml"))
\r
149 '/// File / Open / <i>gTestToolPath</i>/chart2/update/input/verySimpleChart.ods
\r
150 '/// File / Save As / <i>gOfficepath</i>/user/work/verySimpleChart.ods
\r
151 if fLoadVerySimpleChartAndSaveLocal() > 0 then
\r
152 warnlog "Loading test document failed!"
\r
155 printlog "Test document has successfully been loaded."
\r
158 '/// Select the chart object using the navigator
\r
159 printlog "Select chart using navigator"
\r
160 if fSelectFirstOLE = 0 then
\r
161 printlog "Chart is selected"
\r
163 warnlog "Chart could not be selected"
\r
164 call hCloseDocument
\r
168 '/// Activate chart with Edit / Object / Edit
\r
169 printlog "Activate chart by Edit / Object / Edit"
\r
172 'Save document localy
\r
173 Kontext "DocumentCalc"
\r
174 '/// Press twice <ESCAPE> to leave the chart object
\r
175 DocumentCalc.TypeKeys "<ESCAPE>" , 2 'Leave chart and unselect it
\r
176 '/// Press <CTRL+HOME> to get to cell A1
\r
177 DocumentCalc.TypeKeys "<MOD1 HOME>"
\r
178 '/// Press <F9> to re-calculate the spreadsheet and the objects
\r
179 DocumentCalc.TypeKeys "<F9>"
\r
180 '/// Save the document again
\r
181 if NOT hFileSave (sOutputFile) then
\r
182 warnlog "Saving test document localy failed -> Aborting"
\r
183 call hCloseDocument
\r
186 printlog "File with very simple chart saved successfully."
\r
189 call hCloseDocument
\r
191 printlog "File with very simple chart closed"
\r
192 '/// Uncompress with <i>unzip</i> or <i>jar</i> the
\r
193 '///+ <i>gOfficepath</i>/user/work/verySimpleChart.ods document
\r
194 '///+ into <i>gOfficePath</i>/user/work/chart2_XML-directory
\r
195 printlog "Unpack storage of test document."
\r
196 UnpackStorage(sOutputFile, sUnpackedStorageDir)
\r
197 printlog "Read the test documents DOM."
\r
198 '/// Load the XML file <i>gOfficePath</i>/user/work/chart2_XML/Object 1/content.xml
\r
199 '///+ in an XML editor
\r
200 SAXReadFile(sChartContentXML)
\r
201 printlog "Set the DOM pointer to document root"
\r
203 SAXSeekElement("/")
\r
204 printlog " |-office:document-content"
\r
205 '/// Open the element 'office:document-content'
\r
206 SAXSeekElement("office:document-content")
\r
207 printlog " |-office:body"
\r
208 '/// Open the element 'office:body'
\r
209 SAXSeekElement("office:body")
\r
210 printlog " |-office:chart"
\r
211 '/// Open the element 'office:chart'
\r
212 SAXSeekElement("office:chart")
\r
213 printlog " |-chart:chart"
\r
214 '/// Open the element 'chart:chart'
\r
215 SAXSeekElement("chart:chart")
\r
216 '/// Get the attribute value for <i>chart:class</i>.
\r
217 '///+ If it is 'chart:bar' the first characteristics validation has been
\r
219 if SAXGetAttributeValue("chart:class") = "chart:bar" then
\r
220 printlog "This is a bar chart as expected"
\r
222 warnlog "This is no bar chart, it is a " & SaxGetAttributeValue("chart:class")
\r
224 printlog "Seek for chart:plot-area"
\r
225 printlog " |-chart:plot-area"
\r
226 '/// Open the element 'chart:plot-area'
\r
227 SAXSeekElement("chart:plot-area")
\r
228 '/// If the attribute value of 'table:cell-range-address' is 'Sheet1.A1:Sheet1.B2'
\r
229 '///+ the second characteristics validation has been passed.
\r
230 if SAXGetAttributeValue("table:cell-range-address") = "Sheet1.A1:B2" then
\r
231 printlog "The cell range for chart:plot-area is correct"
\r
233 warnlog "#i100780#: The cell range is not Sheet1.A1:B2, it is " & SaxGetAttributeValue("table:cell-range-address")
\r
235 printlog "Seek for chart:series"
\r
236 printlog " |-chart:series"
\r
237 '/// Open the element 'chart:series'
\r
238 SAXSeekElement("chart:series")
\r
239 '/// If the attribute valie of 'chart:values-cell-range-address' is Sheet1.A1:Sheet1.A2''
\r
240 '///+ the hird characteristics validation has been passed.
\r
241 if SAXGetAttributeValue("chart:values-cell-range-address") = "Sheet1.A1:A2" then
\r
242 printlog "The cell range for chart:series is correct"
\r
244 warnlog "#i100780#: The cell range is not Sheet1.A1:A2, it is " & SaxGetAttributeValue("chart:values-cell-range-address")
\r
246 ' DEBUG: printlog "I'm here: " & SAXGetElementName
\r
247 '/// Close the XML editor.
\r