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