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: w_xml_vertical_alignment.inc,v $
13 '* last change: $Author: rt $ $Date: 2008-07-11 07:35:32 $
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 : helge.delfs@sun.com
36 '* short description : testing vertical alignment in writer
38 '*************************************************************************************************
40 ' #1 tVerticalAlignmentWriter 'Testing for vertical alignment in writer
42 '\*************************************************************************************************
44 testcase tVerticalAlignmentWriter
45 ' Dimensioning variables
46 dim iSaxSeekIndex as INTEGER 'counter-variable for searching through the styles:styles
47 dim sSaveAsFile as STRING 'TestDoc is going to be saved with this name
48 dim sWriterContentXML as STRING 'Location of the content.xml
49 dim sLoadFileName as STRING 'Variable for name of the Testdoc
50 dim sUnpackStorageDir as STRING 'Name of the direcotry where the xml file is being unpacked
51 dim sAttrValue as STRING 'Name of the variable to store the searched value in
52 Dim xXMLStyleName as STRING 'Draw:Style-name to be searched for
53 Dim iChildCount as INTEGER 'Counter for SAX Child nodes
55 ' Setting paths and variables
56 sSaveAsFile = gOfficePath & ConvertPath("user\work\VerticalAlignment.odt")
57 printlog "Save-path is " & sSaveAsFile
58 sUnpackStorageDir = gOfficePath & ConvertPath("user\work\VerticalAlignment")
59 printlog "UnpackStorageDir is " & sUnpackStorageDir
60 printlog "Used Save-As Filter is " & gWriterFilter
61 sWriterContentXML = gOfficePath & ConvertPath("user\work\VerticalAlignment\content.xml")
62 printlog "ContentXML File is to be found in " & sWriterContentXML
63 sLoadFileName = ConvertPath (gTesttoolPath + "xml\optional\input\writer\verttoline1.doc")
64 printlog "The used TestDoc is " & sLoadFileName
66 printlog "Checking if storage Directory is empty"
67 if Dir(sUnpackStorageDir) <> "" then
68 printlog "UnpackStorageDir was not empty, deleting."
69 RmDir (sUnpackStorageDir)
71 printlog "UnpackStorageDir is emtpy."
74 printlog "Loading test document gTesttoolPath\xml\optional\input\writer\verttoline1.doc"
75 if hFileOpen (sLoadFileName) = FALSE then
76 warnlog "Loading File failed!"
78 printlog "Save document in ODF file format."
79 if hFileSaveAsWithFilterKill (sSaveAsFile , "writer8") = FALSE then
80 warnlog "Saving " & sSaveAsFile & " failed! -> Exiting test!"
86 printlog "Unzip or unjar the gOfficePath/user/work/VerticalAlignment.odt into the directory gOfficePath/user/work/VerticalAlignment"
87 UnpackStorage(sSaveAsFile, sUnpackStorageDir)
88 printlog "Use a XML editor like jEdit and open the structure of the XML file gOfficePath/user/work/VerticalAlignment/Object 1/content.xml"
89 printlog "opening XML file and creating DOM."
90 SAXReadFile(sWriterContentXML)
92 printlog "Go to the root node."
94 printlog "Get the Draw style name to search the attribute in..."
95 printlog "office:document-content"
96 printlog "Search for draw:style-name to be used in..."
97 SAXSeekElement("office:document-content")
98 printlog "office:body"
99 SAXSeekElement("office:body")
100 printlog "office:text"
101 SAXSeekElement("office:text")
103 SAXSeekElement("text:p" , 1)
104 printlog "draw:frame"
105 SAXSeekElement("draw:frame" , 1)
106 printlog "draw:style-name"
107 xXMLStyleName = SAXGetAttributeValue("draw:style-name")
108 printlog "draw:style-name to search for is " & xXMLStyleName & "."
109 printlog "Search for: style:vertical-pos="from-top""
110 'Setting parser back to root node
112 printlog "Seek office:document-content."
113 SAXSeekElement("office:document-content")
114 printlog "Seek office:automatic-styles."
115 SAXSeekElement("office:automatic-styles")
116 printlog "Search through style:style elements."
117 printlog "...in one of the 4 style:style elements there should be a..."
118 iChildCount = SAXGetChildCount
119 'printlog "There are " & iChildCount & " Childnodes."
120 for iSaxSeekIndex = 1 to iChildCount
121 SAXSeekElement(iSaxSeekIndex)
122 if SAXGetAttributeValue("style:name") = xXMLStyleName then
123 SAXSeekElement("style:graphic-properties")
124 printlog "style:graphic-properties with the value from-top"
125 printlog "Seeking for style:vertical-pos."
126 if SaxGetAttributeName(5) = "style:vertical-pos" then
127 'printlog "Found attribute 'style:vertical-pos' in childnode " & iSaxSeekIndex & "."
128 printlog "Get value from style:vertical-pos."
129 sAttrValue = SAXGetAttributeValue("style:vertical-pos")
130 'printlog "Value is " & sAttrValue & "."
132 if sAttrValue = "from-top" then
133 printlog "Expected value of 'style:vertical-pos' = from-top was found."
136 warnlog "Expected value of 'style:vertical-pos' = from-top was not found!"
140 warnlog "Attribut style:vertical-pos not found in element " & iSaxSeekIndex & "."