1 /*************************************************************************
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: INIOutputter.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
34 import java
.io
.FileWriter
;
36 public class INIOutputter
40 String m_sNamePrefix
; // the HTML files used a suffix to build it's right name
43 * ls is the current line separator (carridge return)
47 public static INIOutputter
create( String _sOutputPath
, String _sHTMLFilename
, String _sNamePrefix
, String _sTitle
)
49 FileHelper
.makeDirectories("", _sOutputPath
);
50 INIOutputter a
= new INIOutputter();
51 String fs
= System
.getProperty("file.separator");
52 String sFilename
= _sOutputPath
+ fs
+ _sHTMLFilename
;
56 File outputFile
= new File(sFilename
);
57 a
.m_aOut
= new FileWriter(outputFile
.toString());
58 a
.ls
= System
.getProperty("line.separator");
60 catch (java
.io
.IOException e
)
63 GlobalLogWriter
.get().println("ERROR: Can't create INI Outputter");
66 a
.m_sFilename
= sFilename
;
67 a
.m_sNamePrefix
= _sNamePrefix
;
71 public String
getFilename() {return m_sFilename
;}
73 public void createHeader()
77 m_aOut
.write("; This file is automatically created by a convwatch run" + ls
);
78 m_aOut
.write("; " + ls
);
79 m_aOut
.write("; If you see this file in a browser you may have forgotten to set the follows in the property file" + ls
);
80 m_aOut
.write("; " + PropertyName
.DOC_COMPARATOR_HTML_OUTPUT_PREFIX
+ "=http://lla-1.germany/gfxcmp/cw.php?inifile=" + ls
);
81 m_aOut
.write("; Please check the documentation if you got confused." + ls
);
82 m_aOut
.write("; " + ls
);
83 m_aOut
.write("; " + ls
);
85 catch (java
.io
.IOException e
)
90 public void writeSection(String _sSectionName
)
94 m_aOut
.write("[" + _sSectionName
+ "]" + ls
);
97 catch (java
.io
.IOException e
)
102 public void writeValue(String _sName
, String _sValue
)
106 m_aOut
.write(_sName
+ "=" + _sValue
+ ls
);
109 catch (java
.io
.IOException e
)
114 public void startSection(int _nNumber
)
116 writeSection( "page" + String
.valueOf(_nNumber
));
126 catch (java
.io
.IOException e
)
131 public void checkLine(StatusHelper _aStatus
, boolean _bCurrentResult
)
135 m_aOut
.write( "oldgfx=" + _aStatus
.m_sOldGfx
+ ls
);
136 m_aOut
.write( "newgfx=" + _aStatus
.m_sNewGfx
+ ls
);
137 m_aOut
.write( "diffgfx=" + _aStatus
.m_sDiffGfx
+ ls
);
139 String sPercent
= String
.valueOf(_aStatus
.nPercent
) + "%";
140 if (_aStatus
.nPercent
> 0 && _aStatus
.nPercent
< 5)
142 sPercent
+= " (less 5% is ok)";
144 m_aOut
.write("percent=" + sPercent
+ ls
);
146 if (_aStatus
.m_sDiff_BM_Gfx
== null)
148 m_aOut
.write("BM=false" + ls
);
152 m_aOut
.write("BM=true" + ls
);
153 m_aOut
.write( "old_BM_gfx=" + _aStatus
.m_sOld_BM_Gfx
+ ls
);
154 m_aOut
.write( "new_BM_gfx=" + _aStatus
.m_sNew_BM_Gfx
+ ls
);
155 m_aOut
.write( "diff_BM_gfx=" + _aStatus
.m_sDiff_BM_Gfx
+ ls
);
157 String sPercent2
= String
.valueOf(_aStatus
.nPercent2
) + "%";
158 if (_aStatus
.nPercent2
> 0 && _aStatus
.nPercent2
< 5)
160 sPercent2
+= " (less 5% is ok)";
162 m_aOut
.write("percent2=" + sPercent2
+ ls
);
165 writeResult(_bCurrentResult
);
168 catch (java
.io
.IOException e
)
173 void writeResult(boolean _bCurrentResult
) throws java
.io
.IOException
175 // is the check positiv, in a defined range
178 m_aOut
.write("result=YES" + ls
);
182 m_aOut
.write("result=NO" + ls
);
186 public void checkDiffDiffLine(StatusHelper _aStatus
, boolean _bCurrentResult
)
190 m_aOut
.write( "oldgfx=" + _aStatus
.m_sOldGfx
+ ls
);
191 m_aOut
.write( "newgfx=" + _aStatus
.m_sNewGfx
+ ls
);
192 m_aOut
.write( "diffgfx=" + _aStatus
.m_sDiffGfx
+ ls
);
194 String sPercent
= String
.valueOf(_aStatus
.nPercent
) + "%";
195 // if (_aStatus.nPercent > 0 && _aStatus.nPercent < 5)
197 // sPercent += " (less 5% is ok)";
199 m_aOut
.write("percent=" + sPercent
+ ls
);
201 // is the check positiv, in a defined range
202 writeResult(_bCurrentResult
);
205 catch (java
.io
.IOException e
)