xref: /AOO42X/main/qadevOOo/runner/graphical/HTMLResult.java (revision b0efeae40e43e6d4ccd561d22ec612d42773857b) !
1ef39d40dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3ef39d40dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4ef39d40dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5ef39d40dSAndrew Rist  * distributed with this work for additional information
6ef39d40dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7ef39d40dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8ef39d40dSAndrew Rist  * "License"); you may not use this file except in compliance
9ef39d40dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11ef39d40dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13ef39d40dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14ef39d40dSAndrew Rist  * software distributed under the License is distributed on an
15ef39d40dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16ef39d40dSAndrew Rist  * KIND, either express or implied.  See the License for the
17ef39d40dSAndrew Rist  * specific language governing permissions and limitations
18ef39d40dSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20ef39d40dSAndrew Rist  *************************************************************/
21ef39d40dSAndrew Rist 
22ef39d40dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir package graphical;
25cdf0e10cSrcweir 
26cdf0e10cSrcweir import java.io.File;
27cdf0e10cSrcweir import java.io.FileWriter;
28cdf0e10cSrcweir // import util.utils;
29cdf0e10cSrcweir // import helper.OSHelper;
30cdf0e10cSrcweir 
31cdf0e10cSrcweir public class HTMLResult
32cdf0e10cSrcweir {
33cdf0e10cSrcweir     private FileWriter m_aOut;
34cdf0e10cSrcweir     // private String m_sFilename;
35cdf0e10cSrcweir     // private String m_sNamePrefix;              // the HTML files used a suffix to build it's right name
36cdf0e10cSrcweir 
37cdf0e10cSrcweir     /**
38*da74b300SJohn Bampton      * ls is the current line separator (carriage return)
39cdf0e10cSrcweir      */
40cdf0e10cSrcweir     private String ls;
41cdf0e10cSrcweir 
HTMLResult( String _sOutputPath, String _sHTMLFilename )42cdf0e10cSrcweir     public HTMLResult( String _sOutputPath, String _sHTMLFilename )
43cdf0e10cSrcweir         {
44cdf0e10cSrcweir             FileHelper.makeDirectories("", _sOutputPath);
45cdf0e10cSrcweir             // HTMLResult a = new HTMLResult();
46cdf0e10cSrcweir             String sFilename = FileHelper.appendPath(_sOutputPath, _sHTMLFilename);
47cdf0e10cSrcweir 
48cdf0e10cSrcweir             try
49cdf0e10cSrcweir             {
50cdf0e10cSrcweir                 File outputFile = new File(sFilename);
51cdf0e10cSrcweir                 m_aOut = new FileWriter(outputFile.toString());
52cdf0e10cSrcweir                 ls = System.getProperty("line.separator");
53cdf0e10cSrcweir             }
54cdf0e10cSrcweir             catch (java.io.IOException e)
55cdf0e10cSrcweir             {
56cdf0e10cSrcweir                 e.printStackTrace();
57cdf0e10cSrcweir                 GlobalLogWriter.println("ERROR: Can't create HTML Outputter");
58cdf0e10cSrcweir                 // return null;
59cdf0e10cSrcweir             }
60cdf0e10cSrcweir             // m_sFilename = sFilename;
61cdf0e10cSrcweir             // a.m_sNamePrefix = _sNamePrefix;
62cdf0e10cSrcweir             // return a;
63cdf0e10cSrcweir         }
64cdf0e10cSrcweir 
65cdf0e10cSrcweir     // public String getFilename() {return m_sFilename;}
66cdf0e10cSrcweir 
writeln(String _sStr)67cdf0e10cSrcweir     private void writeln(String _sStr)
68cdf0e10cSrcweir     {
69cdf0e10cSrcweir             try
70cdf0e10cSrcweir             {
71cdf0e10cSrcweir                 m_aOut.write( _sStr );
72cdf0e10cSrcweir                 m_aOut.write ( ls );
73cdf0e10cSrcweir             }
74cdf0e10cSrcweir             catch (java.io.IOException e)
75cdf0e10cSrcweir             {
76cdf0e10cSrcweir             }
77cdf0e10cSrcweir     }
flush()78cdf0e10cSrcweir     private void flush()
79cdf0e10cSrcweir     {
80cdf0e10cSrcweir         try
81cdf0e10cSrcweir         {
82cdf0e10cSrcweir             m_aOut.flush();
83cdf0e10cSrcweir         }
84cdf0e10cSrcweir         catch (java.io.IOException e)
85cdf0e10cSrcweir         {
86cdf0e10cSrcweir         }
87cdf0e10cSrcweir     }
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 
90cdf0e10cSrcweir     /**
91cdf0e10cSrcweir      * create the HTML header
92cdf0e10cSrcweir      * @param _sTitle
93cdf0e10cSrcweir      */
header(String _sTitle)94cdf0e10cSrcweir     public void header(String _sTitle)
95cdf0e10cSrcweir         {
96*da74b300SJohn Bampton                 writeln( "<html>");
97*da74b300SJohn Bampton                 writeln( "<head>" );
98*da74b300SJohn Bampton                 writeln( "<title>" + _sTitle + "</title>");
99*da74b300SJohn Bampton                 writeln( "<link rel=\"stylesheet\" type=\"text/css\" href=\"/gfxcmp_ui/xmloff.css\" media=\"screen\" />");
100*da74b300SJohn Bampton                 writeln( "<link rel=\"stylesheet\" type=\"text/css\" href=\"/gfxcmp_ui/style.css\" media=\"screen\" />");
101*da74b300SJohn Bampton                 writeln( "</head>");
102*da74b300SJohn Bampton                 writeln( "<body bgcolor=white>");
103cdf0e10cSrcweir                 flush();
104cdf0e10cSrcweir         }
105cdf0e10cSrcweir 
106cdf0e10cSrcweir     final static String TEST_TABLETITLE = "Document";
107cdf0e10cSrcweir     final static String VISUAL_STATUS_TABLETITLE = "Visual status";
108cdf0e10cSrcweir     final static String VISUAL_STATUS_MESSAGE_TABLETITLE = "Message";
109cdf0e10cSrcweir     final static String FIRSTGFX_TABLETITLE = "Original print file as jpeg";
110cdf0e10cSrcweir 
indexSection(String _sOfficeInfo)111cdf0e10cSrcweir     public void indexSection(String _sOfficeInfo)
112cdf0e10cSrcweir         {
113*da74b300SJohn Bampton                 writeln( "<h2>Results for " + _sOfficeInfo + "</h2>");
114*da74b300SJohn Bampton                 writeln( "<p>This result was created at: " + DateHelper.getDateTimeForHumanreadableLog());
115*da74b300SJohn Bampton                 writeln( "<p>Legend:<br>");
116*da74b300SJohn Bampton                 writeln( stronghtml(FIRSTGFX_TABLETITLE) + " contains the output printed via 'ghostscript' as a jpeg picture.<br>");
117cdf0e10cSrcweir 
118*da74b300SJohn Bampton                 writeln( "<table class=\"infotable\">");
119*da74b300SJohn Bampton                 writeln( "<tr>");
120cdf0e10cSrcweir                 writeln( tableHeaderCell(TEST_TABLETITLE));
121cdf0e10cSrcweir                 writeln( tableHeaderCell(""));
122cdf0e10cSrcweir                 writeln( tableHeaderCell(VISUAL_STATUS_TABLETITLE));
123cdf0e10cSrcweir                 writeln( tableHeaderCell(VISUAL_STATUS_MESSAGE_TABLETITLE));
124*da74b300SJohn Bampton                 writeln( "</tr>");
125cdf0e10cSrcweir                 flush();
126cdf0e10cSrcweir         }
127cdf0e10cSrcweir /**
128cdf0e10cSrcweir  * Returns the given _sHREF & _sPathInfo as a HTML String
129cdf0e10cSrcweir  * <A HREF="_sHREF">_sPathInfo</A>
130cdf0e10cSrcweir  * @param _sHREF
131cdf0e10cSrcweir  * @param _sPathInfo
132cdf0e10cSrcweir  * @return
133cdf0e10cSrcweir  */
getHREF(String _sHREF, String _sPathInfo)134cdf0e10cSrcweir     private String getHREF(String _sHREF, String _sPathInfo)
135cdf0e10cSrcweir         {
136cdf0e10cSrcweir             StringBuffer a = new StringBuffer();
137*da74b300SJohn Bampton             a.append("<a href=\"");
138cdf0e10cSrcweir             a.append(_sHREF);
139cdf0e10cSrcweir             a.append("\">");
140cdf0e10cSrcweir             a.append(_sPathInfo);
141*da74b300SJohn Bampton             a.append("</a>");
142cdf0e10cSrcweir             return a.toString();
143cdf0e10cSrcweir         }
144cdf0e10cSrcweir 
145cdf0e10cSrcweir     /**
146cdf0e10cSrcweir      * Returns the given _sValue as a HTML Table cell with _sValue as content
147cdf0e10cSrcweir      * @param _sValue
148cdf0e10cSrcweir      * @return
149cdf0e10cSrcweir      */
tableDataCell(String _sValue)150cdf0e10cSrcweir     private String tableDataCell(String _sValue)
151cdf0e10cSrcweir         {
152cdf0e10cSrcweir             StringBuffer a = new StringBuffer();
153*da74b300SJohn Bampton             a.append("<td>");
154cdf0e10cSrcweir             a.append(_sValue);
155*da74b300SJohn Bampton             a.append("</td>");
156cdf0e10cSrcweir             return a.toString();
157cdf0e10cSrcweir         }
158cdf0e10cSrcweir 
159cdf0e10cSrcweir     /**
160cdf0e10cSrcweir      * Returns the given _sValue as a HTML Table header cell with _sValue as content
161cdf0e10cSrcweir      * @param _sValue
162cdf0e10cSrcweir      * @return
163cdf0e10cSrcweir      */
tableHeaderCell(String _sValue)164cdf0e10cSrcweir     private String tableHeaderCell(String _sValue)
165cdf0e10cSrcweir         {
166cdf0e10cSrcweir             StringBuffer a = new StringBuffer();
167*da74b300SJohn Bampton             a.append("<th>");
168cdf0e10cSrcweir             a.append(_sValue);
169*da74b300SJohn Bampton             a.append("</th>");
170cdf0e10cSrcweir             return a.toString();
171cdf0e10cSrcweir         }
172cdf0e10cSrcweir 
indexLine(String _sHTMLFile, String _sHTMLName, String _sStatusRunThrough, String _sStatusMessage)173cdf0e10cSrcweir     public void indexLine(String _sHTMLFile, String _sHTMLName, String _sStatusRunThrough, String _sStatusMessage)
174cdf0e10cSrcweir         {
175*da74b300SJohn Bampton                 writeln( "<tr>");
176cdf0e10cSrcweir                 writeln(tableDataCell( getHREF(_sHTMLFile, _sHTMLName) ) );
177cdf0e10cSrcweir                 writeln(tableDataCell( "" ) );
178cdf0e10cSrcweir                 writeln( tableDataCell(_sStatusRunThrough) );
179cdf0e10cSrcweir                 writeln( tableDataCell(_sStatusMessage) );
180*da74b300SJohn Bampton                 writeln( "</tr>");
181cdf0e10cSrcweir                 flush();
182cdf0e10cSrcweir         }
183cdf0e10cSrcweir 
close()184cdf0e10cSrcweir     public void close()
185cdf0e10cSrcweir         {
186*da74b300SJohn Bampton             writeln( "</table>");
187*da74b300SJohn Bampton             writeln( "</body></html>");
188cdf0e10cSrcweir             try
189cdf0e10cSrcweir             {
190cdf0e10cSrcweir                 m_aOut.close();
191cdf0e10cSrcweir             }
192cdf0e10cSrcweir             catch (java.io.IOException e)
193cdf0e10cSrcweir             {
194cdf0e10cSrcweir             }
195cdf0e10cSrcweir         }
196cdf0e10cSrcweir 
197cdf0e10cSrcweir // -----------------------------------------------------------------------------
stronghtml(String _sValue)198cdf0e10cSrcweir     private String stronghtml(String _sValue)
199cdf0e10cSrcweir         {
200cdf0e10cSrcweir             StringBuffer a = new StringBuffer();
201*da74b300SJohn Bampton             a.append("<strong>");
202cdf0e10cSrcweir             a.append(_sValue);
203*da74b300SJohn Bampton             a.append("</strong>");
204cdf0e10cSrcweir             return a.toString();
205cdf0e10cSrcweir         }
206cdf0e10cSrcweir 
207cdf0e10cSrcweir }
208