merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / runner / graphical / HTMLResult.java
blob333fc02a25de4d80d2ac98f0cacd8438512397c9
1 /*
2 ************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * Copyright 2008 by Sun Microsystems, Inc.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * $RCSfile: HTMLResult.java,v $
11 * $Revision: 1.1.2.2 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 package graphical;
34 import java.io.File;
35 import java.io.FileWriter;
36 // import util.utils;
37 // import helper.OSHelper;
39 public class HTMLResult
41 private FileWriter m_aOut;
42 // private String m_sFilename;
43 // private String m_sNamePrefix; // the HTML files used a suffix to build it's right name
45 /**
46 * ls is the current line separator (carridge return)
48 private String ls;
50 public HTMLResult( String _sOutputPath, String _sHTMLFilename )
52 FileHelper.makeDirectories("", _sOutputPath);
53 // HTMLResult a = new HTMLResult();
54 String sFilename = FileHelper.appendPath(_sOutputPath, _sHTMLFilename);
56 try
58 File outputFile = new File(sFilename);
59 m_aOut = new FileWriter(outputFile.toString());
60 ls = System.getProperty("line.separator");
62 catch (java.io.IOException e)
64 e.printStackTrace();
65 GlobalLogWriter.get().println("ERROR: Can't create HTML Outputter");
66 // return null;
68 // m_sFilename = sFilename;
69 // a.m_sNamePrefix = _sNamePrefix;
70 // return a;
73 // public String getFilename() {return m_sFilename;}
75 private void writeln(String _sStr)
77 try
79 m_aOut.write( _sStr );
80 m_aOut.write ( ls );
82 catch (java.io.IOException e)
86 private void flush()
88 try
90 m_aOut.flush();
92 catch (java.io.IOException e)
98 /**
99 * create the HTML header
100 * @param _sTitle
102 public void header(String _sTitle)
104 writeln( "<HTML>");
105 writeln( "<HEAD>" );
106 writeln( "<TITLE>" + _sTitle + "</TITLE>");
107 writeln( "<LINK rel=\"stylesheet\" type=\"text/css\" href=\"/gfxcmp_ui/xmloff.css\" media=\"screen\" />");
108 writeln( "<LINK rel=\"stylesheet\" type=\"text/css\" href=\"/gfxcmp_ui/style.css\" media=\"screen\" />");
109 writeln( "</HEAD>");
110 writeln( "<BODY bgcolor=white>");
111 flush();
114 final static String TEST_TABLETITLE = "Document";
115 final static String VISUAL_STATUS_TABLETITLE = "Visual status";
116 final static String VISUAL_STATUS_MESSAGE_TABLETITLE = "Message";
117 final static String FIRSTGFX_TABLETITLE = "Original print file as jpeg";
119 public void indexSection(String _sOfficeInfo)
121 writeln( "<H2>Results for " + _sOfficeInfo + "</H2>");
122 writeln( "<P>This result was created at: " + DateHelper.getDateTimeForHumanreadableLog());
123 writeln( "<P>Legend:<BR>");
124 writeln( stronghtml(FIRSTGFX_TABLETITLE) + " contains the output printed via 'ghostscript' as a jpeg picture.<BR>");
126 writeln( "<TABLE class=\"infotable\">");
127 writeln( "<TR>");
128 writeln( tableHeaderCell(TEST_TABLETITLE));
129 writeln( tableHeaderCell(""));
130 writeln( tableHeaderCell(VISUAL_STATUS_TABLETITLE));
131 writeln( tableHeaderCell(VISUAL_STATUS_MESSAGE_TABLETITLE));
132 writeln( "</TR>");
133 flush();
136 * Returns the given _sHREF & _sPathInfo as a HTML String
137 * <A HREF="_sHREF">_sPathInfo</A>
138 * @param _sHREF
139 * @param _sPathInfo
140 * @return
142 private String getHREF(String _sHREF, String _sPathInfo)
144 StringBuffer a = new StringBuffer();
145 a.append("<A HREF=\"");
146 a.append(_sHREF);
147 a.append("\">");
148 a.append(_sPathInfo);
149 a.append("</A>");
150 return a.toString();
154 * Returns the given _sValue as a HTML Table cell with _sValue as content
155 * @param _sValue
156 * @return
158 private String tableDataCell(String _sValue)
160 StringBuffer a = new StringBuffer();
161 a.append("<TD>");
162 a.append(_sValue);
163 a.append("</TD>");
164 return a.toString();
168 * Returns the given _sValue as a HTML Table header cell with _sValue as content
169 * @param _sValue
170 * @return
172 private String tableHeaderCell(String _sValue)
174 StringBuffer a = new StringBuffer();
175 a.append("<TH>");
176 a.append(_sValue);
177 a.append("</TH>");
178 return a.toString();
181 public void indexLine(String _sHTMLFile, String _sHTMLName, String _sStatusRunThrough, String _sStatusMessage)
183 writeln( "<TR>");
184 writeln(tableDataCell( getHREF(_sHTMLFile, _sHTMLName) ) );
185 writeln(tableDataCell( "" ) );
186 writeln( tableDataCell(_sStatusRunThrough) );
187 writeln( tableDataCell(_sStatusMessage) );
188 writeln( "</TR>");
189 flush();
192 public void close()
194 writeln( "</TABLE>");
195 writeln( "</BODY></HTML>");
198 m_aOut.close();
200 catch (java.io.IOException e)
205 // -----------------------------------------------------------------------------
206 private String stronghtml(String _sValue)
208 StringBuffer a = new StringBuffer();
209 a.append("<STRONG>");
210 a.append(_sValue);
211 a.append("</STRONG>");
212 return a.toString();