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_xml_print_scale.inc,v $
13 '* last change: $Author: rt $ $Date: 2008-07-11 07:29:05 $
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.creamer@sun.com
36 '* short description : Check content.xml and styles.xml for correct print scaling settings
38 '*************************************************************************************************
43 '\*************************************************************************************************
45 printLog Chr(13) + "--------- Print scaling attributes ----------"
51 '************************************************************
52 testcase tPrintScaling
54 dim iInnerIndex as INTEGER
59 dim sOutputFile as STRING
60 sOutputFile = ( gOfficePath & ConvertPath( "user\work\printScaling" ) & sExtension )
62 dim sUnpackedStorageDir as STRING
63 sUnpackedStorageDir = ( gOfficePath & ConvertPath( "user\work\printScaling" ))
64 if (dir ( sUnpackedStorageDir ) <> "" ) then
65 rmDir ( sUnpackedStorageDir )
66 if (dir ( sUnpackedStorageDir ) <> "" ) then
67 warnlog "The diretory has not been deleted. Exiting test!"
72 dim sContentXML as STRING
73 sContentXML = ( sUnpackedStorageDir & ConvertPath( "\content.xml" ))
75 dim sStylesXML as STRING
76 sStylesXML = ( sUnpackedStorageDir & ConvertPath( "\styles.xml" ))
78 dim asTableStyleAssocations ( 5 , 3 ) as STRING
80 dim sNameSheet1 as STRING
82 dim sNameSheet2 as STRING
84 dim sNameSheet3 as STRING
87 dim sNameStyle1 as STRING
88 sNameStyle1 = "1stStyle"
89 dim sNameStyle2 as STRING
90 sNameStyle2 = "2ndStyle"
91 dim sNameStyle3 as STRING
92 sNameStyle3 = "3rdStyle"
94 dim iTablesInDocument as INTEGER
95 dim iStylesInAutomaticStyles as INTEGER
96 dim iMasterPageStylesInStylesXML as INTEGER
97 dim sCurrentTableName as STRING
98 dim sExpectedTableName as STRING
99 dim sCurrentTableStyle as STRING
100 dim sCurrentAutomaticStyle as STRING
101 dim sCurrentMasterPageStyle as STRING
103 dim sExpectedScaleTo as STRING
104 dim sExpectedScaleToX as STRING
105 dim sExpectedScaleToY as STRING
106 dim sExpectedScaleToPages as STRING
108 printlog "Create a new spreadsheet document"
113 printlog "Type in the first cell the number 1 and press RETURN"
114 Kontext "DocumentCalc"
115 DocumentCalc.TypeKeys "1<RETURN>"
117 printlog "Format / Sheet / Rename"
119 Kontext "TabelleUmbenennen"
121 case 1 : Tabellenname.SetText sNameSheet1
122 printlog " In first round name it 'Ten'"
123 case 2 : Tabellenname.SetText sNameSheet2
124 printlog " In first round name it 'Moves'"
125 case 3 : Tabellenname.SetText sNameSheet3
126 printlog " In first round name it 'Ahead'"
128 printlog "Press OK on dialog"
131 printlog "Edit / Sheet / Select"
133 Kontext "SelectSheets"
134 printlog "In round 1 and 2 select the next sheet."
135 printlog "In round three select the first sheet."
137 SheetSelectionBox.Select sNameSheet1
139 SheetSelectionBox.Select ( iIndex + 1 )
141 printlog "Press OK on dialog."
145 printlog "Format / Styles / Catalog"
147 Kontext "Vorlagenkatalog"
148 Vorlagen.select ( 2 )
151 Kontext "Vorlagenkatalog"
155 printlog "Page format dilog shoud appear)"
156 printlog "Select Page 'Organizer'"
158 Active.SetPage TabVerwalten
159 printlog "Close MsgBox when appeared"
160 if Active.Exists(2) then
161 if Active.GetRT = 304 then
162 Printlog Active.GetText
166 Kontext "TabVerwalten"
167 printlog "Assign name for each style"
169 case 1 : VorlagenName.setText sNameStyle1
170 printlog "First round name: '1stStyle'"
171 case 2 : VorlagenName.setText sNameStyle2
172 printlog "Second round name:'2ndStyle'"
173 case 3 : VorlagenName.setText sNameStyle3
174 printlog "Third round name: '3rdStyle'"
176 printlog "Select Page 'Sheet'"
178 Active.SetPage TabTabelleCalc
179 Kontext "TabTabelleCalc"
180 scalingMode.Select ( iIndex )
182 case 1 : SkalierungProzent.setText "55%"
183 printlog "1. round: Scale size to 55%"
184 case 2 : ScalePageWidth.setText "3"
185 ScalePageHeight.setText "4"
186 printlog "2. round: Scale output to 3 pages wide and 4 pages high"
187 case 3 : AnzahlMaxSeiten.setText "6"
188 printlog "3 round: Scale output to a total of 6 pages"
190 printlog "Leave page format dilog using OK"
193 printlog "Close style catalog using OK"
194 Kontext "Vorlagenkatalog"
198 printlog "Edit / Sheet / Select"
200 Kontext "SelectSheets"
201 printlog "Select 1, 2. or 3 sheet"
202 SheetSelectionBox.Select ( iIndex )
207 if NOT Gestalter.exists(2) then
208 printlog "Format / Stylist"
212 printlog "Click on 'Page styles'"
214 Kontext "Vorlagenliste"
215 printlog "Type [HOME]-key"
216 Vorlagenliste.TypeKeys "<HOME>"
218 printlog "Select 1, 2, or 3 (depends on the round)"
219 Vorlagenliste.Select ( iIndex )
220 printlog "Type [RETURN]"
221 Vorlagenliste.TypeKeys "<RETURN>"
224 if Gestalter.exists(2) then
225 printlog "Format / Stylist"
228 printlog "Save in current default ODF format"
229 if hFileSaveAsWithFilterKill ( sOutputFile , "calc8" ) = FALSE then
230 warnlog "Saving " & sOutputFile & " failed! -> Exiting test!"
233 printlog "Close document"
236 printlog "Unpack storage (=compressed XML files) to obtain the XML files"
237 UnpackStorage ( sOutputFile , sUnpackedStorageDir )
238 printlog "Read 'content.xml' DOM."
239 printlog "Read DOM of content.xml"
240 SAXReadFile ( sContentXML )
242 printlog "Set the DOM pointer on element 'office:spreadsheet'"
244 SAXSeekElement ( "/" )
245 printlog " |-office:document-content"
246 SAXSeekElement ( "office:document-content" )
247 printlog " |-office:body"
248 SAXSeekElement ( "office:body" )
249 printlog " |-office:spreadsheet"
250 SAXSeekElement ( "office:spreadsheet" )
251 iTablesInDocument = SAXGetChildCount
252 printlog "Check correct number of sheets"
253 if iTablesInDocument <> 3 then
254 warnlog "Unexpected number of tables in the document -> Check this out!"
256 printlog " nodes table:table"
257 for iIndex = 1 to iTablesInDocument
258 printlog " |-table:table"
259 SAXSeekElement ( "table:table" , iIndex )
260 printlog "Get 'table:name' and 'table:style-name' for all tables"
261 sCurrentTableName = SAXGetAttributeValue ( "table:name" )
262 sCurrentTableStyle = SAXGetAttributeValue ( "table:style-name" )
264 case 1 : sExpectedTableName = sNameSheet1
265 case 2 : sExpectedTableName = sNameSheet2
266 case 3 : sExpectedTableName = sNameSheet3
268 printlog "Check correct table names"
269 if sCurrentTableName <> sExpectedTableName then
270 warnlog "OOPS, this table has got an unexpected name -> Check this out!"
272 printlog "Memorize associations of table and style names"
273 asTableStyleAssocations ( iIndex , 0 ) = sCurrentTableName
274 asTableStyleAssocations ( iIndex , 1 ) = sCurrentTableStyle
279 printlog "Go back in DOM-tree to 'office:automatic-styles'"
280 printlog " |-office:automatic-styles"
281 SAXSeekElement( "office:automatic-styles" )
282 iStylesInAutomaticStyles = SAXGetChildCount
283 if iStylesInAutomaticStyles < 5 then
284 warnlog "Unexpected number of styles in 'content.xml' -> Check this out!"
286 for iIndex = 1 to iStylesInAutomaticStyles
287 printlog "Seek nodes style:style"
288 printlog " |-office:automatic-styles"
289 SAXSeekElement( "style:style" , iIndex )
290 if SAXGetAttributeValue ( "style:family" ) = "table" then
291 sCurrentAutomaticStyle = SAXGetAttributeValue ( "style:name" )
292 printlog " + Found table style " & sCurrentAutomaticStyle & " at postion " & iIndex
293 printlog "Memorize associations of table and master pages names using previously determined style names"
294 for iInnerIndex = 1 to iTablesInDocument
295 if sCurrentAutomaticStyle = asTableStyleAssocations ( iInnerIndex , 1 ) then
296 asTableStyleAssocations ( iInnerIndex , 2 ) = SAXGetAttributeValue ( "style:master-page-name" )
302 printlog "Release DOM of 'content.xml'"
304 printlog "| <<< DOM released <<<"
307 printlog "Read 'styles.xml' DOM."
308 printlog "Read DOM of styles.xml"
309 SAXReadFile ( sStylesXML )
311 printlog "Set the DOM pointer on element 'office:master-styles'"
313 SAXSeekElement ( "/" )
314 printlog " |-office:document-styles"
315 SAXSeekElement ( "office:document-styles" )
316 printlog " |-office:master-styles"
317 SAXSeekElement ( "office:master-styles" )
318 iMasterPageStylesInStylesXML = SAXGetChildCount
319 printlog "Seek nodes style:master-page"
320 for iIndex = 1 to iMasterPageStylesInStylesXML
321 printlog " |-style:master-page"
322 SAXSeekElement( iIndex )
323 sCurrentMasterPageStyle = SAXGetAttributeValue ( "style:name" )
324 printlog " + Found table style " & sCurrentMasterPageStyle & " at postion " & iIndex
325 for iInnerIndex = 1 to iTablesInDocument
326 printlog "Memorize associations of table names and master page styles using master page names found in 'context.xml'"
327 if sCurrentMasterPageStyle = asTableStyleAssocations ( iInnerIndex , 2 ) then
328 if SAXGetElementName <> "style:master-page" then
329 warnlog "Unexpected style type found -> Check this out!"
330 qaErrorLog SAXGetElementName & " instead of 'style:master-page'"
332 asTableStyleAssocations ( iInnerIndex , 3 ) = SAXGetAttributeValue ( "style:page-layout-name" )
333 printlog "Check correct UI strings for master page styles"
334 select case SAXGetAttributeValue ( "style:display-name" )
335 case sNameStyle1 : sExpectedTableName = sNameSheet1
336 case sNameStyle2 : sExpectedTableName = sNameSheet2
337 case sNameStyle3 : sExpectedTableName = sNameSheet3
339 printlog "Check if UI strings for master page styles are correctly assigned to the three sheets"
340 if sExpectedTableName <> asTableStyleAssocations ( iInnerIndex , 0 ) then
341 warnlog "Association of UI Style name and table doesn't meet expectation -> Check this out!"
342 qaErrorLog "Expected '" & sExpectedTableName & "' but found '" & asTableStyleAssocations ( iInnerIndex , 0 ) & "'"
349 printlog "Go back in DOM-tree to 'office:automatic-styles'"
350 printlog " |-office:automatic-styles"
351 SAXSeekElement ( "office:automatic-styles" )
352 iStylesInAutomaticStyles = SAXGetChildCount
353 printlog "Seek nodes style:page-layout"
354 for iIndex = 1 to iStylesInAutomaticStyles
355 printlog " |-style:page-layout"
356 SAXSeekElement ( iIndex )
357 sCurrentAutomaticStyle = SAXGetAttributeValue ( "style:name" )
358 printlog "Check for each sheet if expected page scaling is correctly assigned"
359 for iInnerIndex = 1 to iTablesInDocument
360 if sCurrentAutomaticStyle = asTableStyleAssocations ( iInnerIndex , 3 ) then
361 if SAXGetElementName <> "style:page-layout" then
362 warnlog "Unexpected style type found -> Check this out!"
363 qaErrorLog SAXGetElementName & " instead of 'style:page-layout'"
365 printlog " |-style:page-layout"
366 SAXSeekElement ( "style:page-layout-properties" )
367 select case asTableStyleAssocations ( iInnerIndex , 0 )
369 sExpectedScaleTo = "55%"
370 sExpectedScaleToX = ""
371 sExpectedScaleToY = ""
372 sExpectedScaleToPages = ""
374 sExpectedScaleTo = ""
375 sExpectedScaleToX = "3"
376 sExpectedScaleToY = "4"
377 sExpectedScaleToPages = ""
379 sExpectedScaleTo = ""
380 sExpectedScaleToX = ""
381 sExpectedScaleToY = ""
382 sExpectedScaleToPages = "6"
384 if sExpectedScaleTo <> SAXGetAttributeValue ( "style:scale-to") then
385 warnlog " Attribute 'style:scale-to' has unexpected value: " & SAXGetAttributeValue ( "style:scale-to")
386 qaErrorLog "Expected: " & sExpectedScaleTo
388 if sExpectedScaleToX <> SAXGetAttributeValue ( "style:scale-to-X") then
389 warnlog "Attribute 'style:scale-to-X' has unexpected value: " & SAXGetAttributeValue ( "style:scale-to-X")
390 qaErrorLog "Expected: " & sExpectedScaleToX
392 if sExpectedScaleToY <> SAXGetAttributeValue ( "style:scale-to-Y") then
393 warnlog "Attribute 'style:scale-to-Y' has unexpected value: " & SAXGetAttributeValue ( "style:scale-to-Y")
394 qaErrorLog "Expected: " & sExpectedScaleToY
396 if sExpectedScaleToPages <> SAXGetAttributeValue ( "style:scale-to-pages") then
397 warnlog "Attribute 'style:scale-to-pages' has unexpected value: " & SAXGetAttributeValue ( "style:scale-to-pages")
398 qaErrorLog "Expected: " & sExpectedScaleToPages
406 printlog "Release DOM of 'styles.xml'"