merged tag ooo/DEV300_m102
[LibreOffice.git] / qadevOOo / runner / graphical / HTMLResult.java
blobaf2a31a308eaf9263d48e31dbd0a5dc88c4cb2ba
1 /*
2 ************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 package graphical;
31 import java.io.File;
32 import java.io.FileWriter;
33 // import util.utils;
34 // import helper.OSHelper;
36 public class HTMLResult
38 private FileWriter m_aOut;
39 // private String m_sFilename;
40 // private String m_sNamePrefix; // the HTML files used a suffix to build it's right name
42 /**
43 * ls is the current line separator (carridge return)
45 private String ls;
47 public HTMLResult( String _sOutputPath, String _sHTMLFilename )
49 FileHelper.makeDirectories("", _sOutputPath);
50 // HTMLResult a = new HTMLResult();
51 String sFilename = FileHelper.appendPath(_sOutputPath, _sHTMLFilename);
53 try
55 File outputFile = new File(sFilename);
56 m_aOut = new FileWriter(outputFile.toString());
57 ls = System.getProperty("line.separator");
59 catch (java.io.IOException e)
61 e.printStackTrace();
62 GlobalLogWriter.println("ERROR: Can't create HTML Outputter");
63 // return null;
65 // m_sFilename = sFilename;
66 // a.m_sNamePrefix = _sNamePrefix;
67 // return a;
70 // public String getFilename() {return m_sFilename;}
72 private void writeln(String _sStr)
74 try
76 m_aOut.write( _sStr );
77 m_aOut.write ( ls );
79 catch (java.io.IOException e)
83 private void flush()
85 try
87 m_aOut.flush();
89 catch (java.io.IOException e)
95 /**
96 * create the HTML header
97 * @param _sTitle
99 public void header(String _sTitle)
101 writeln( "<HTML>");
102 writeln( "<HEAD>" );
103 writeln( "<TITLE>" + _sTitle + "</TITLE>");
104 writeln( "<LINK rel=\"stylesheet\" type=\"text/css\" href=\"/gfxcmp_ui/xmloff.css\" media=\"screen\" />");
105 writeln( "<LINK rel=\"stylesheet\" type=\"text/css\" href=\"/gfxcmp_ui/style.css\" media=\"screen\" />");
106 writeln( "</HEAD>");
107 writeln( "<BODY bgcolor=white>");
108 flush();
111 final static String TEST_TABLETITLE = "Document";
112 final static String VISUAL_STATUS_TABLETITLE = "Visual status";
113 final static String VISUAL_STATUS_MESSAGE_TABLETITLE = "Message";
114 final static String FIRSTGFX_TABLETITLE = "Original print file as jpeg";
116 public void indexSection(String _sOfficeInfo)
118 writeln( "<H2>Results for " + _sOfficeInfo + "</H2>");
119 writeln( "<P>This result was created at: " + DateHelper.getDateTimeForHumanreadableLog());
120 writeln( "<P>Legend:<BR>");
121 writeln( stronghtml(FIRSTGFX_TABLETITLE) + " contains the output printed via 'ghostscript' as a jpeg picture.<BR>");
123 writeln( "<TABLE class=\"infotable\">");
124 writeln( "<TR>");
125 writeln( tableHeaderCell(TEST_TABLETITLE));
126 writeln( tableHeaderCell(""));
127 writeln( tableHeaderCell(VISUAL_STATUS_TABLETITLE));
128 writeln( tableHeaderCell(VISUAL_STATUS_MESSAGE_TABLETITLE));
129 writeln( "</TR>");
130 flush();
133 * Returns the given _sHREF & _sPathInfo as a HTML String
134 * <A HREF="_sHREF">_sPathInfo</A>
135 * @param _sHREF
136 * @param _sPathInfo
137 * @return
139 private String getHREF(String _sHREF, String _sPathInfo)
141 StringBuffer a = new StringBuffer();
142 a.append("<A HREF=\"");
143 a.append(_sHREF);
144 a.append("\">");
145 a.append(_sPathInfo);
146 a.append("</A>");
147 return a.toString();
151 * Returns the given _sValue as a HTML Table cell with _sValue as content
152 * @param _sValue
153 * @return
155 private String tableDataCell(String _sValue)
157 StringBuffer a = new StringBuffer();
158 a.append("<TD>");
159 a.append(_sValue);
160 a.append("</TD>");
161 return a.toString();
165 * Returns the given _sValue as a HTML Table header cell with _sValue as content
166 * @param _sValue
167 * @return
169 private String tableHeaderCell(String _sValue)
171 StringBuffer a = new StringBuffer();
172 a.append("<TH>");
173 a.append(_sValue);
174 a.append("</TH>");
175 return a.toString();
178 public void indexLine(String _sHTMLFile, String _sHTMLName, String _sStatusRunThrough, String _sStatusMessage)
180 writeln( "<TR>");
181 writeln(tableDataCell( getHREF(_sHTMLFile, _sHTMLName) ) );
182 writeln(tableDataCell( "" ) );
183 writeln( tableDataCell(_sStatusRunThrough) );
184 writeln( tableDataCell(_sStatusMessage) );
185 writeln( "</TR>");
186 flush();
189 public void close()
191 writeln( "</TABLE>");
192 writeln( "</BODY></HTML>");
195 m_aOut.close();
197 catch (java.io.IOException e)
202 // -----------------------------------------------------------------------------
203 private String stronghtml(String _sValue)
205 StringBuffer a = new StringBuffer();
206 a.append("<STRONG>");
207 a.append(_sValue);
208 a.append("</STRONG>");
209 return a.toString();