1 | /* | |
2 | * $Id: HtmlWriter.java 4065 2009-09-16 23:09:11Z psoares33 $ | |
3 | * | |
4 | * Copyright 1999, 2000, 2001, 2002 by Bruno Lowagie. | |
5 | * | |
6 | * The contents of this file are subject to the Mozilla Public License Version 1.1 | |
7 | * (the "License"); you may not use this file except in compliance with the License. | |
8 | * You may obtain a copy of the License at http://www.mozilla.org/MPL/ | |
9 | * | |
10 | * Software distributed under the License is distributed on an "AS IS" basis, | |
11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |
12 | * for the specific language governing rights and limitations under the License. | |
13 | * | |
14 | * The Original Code is 'iText, a free JAVA-PDF library'. | |
15 | * | |
16 | * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by | |
17 | * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie. | |
18 | * All Rights Reserved. | |
19 | * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer | |
20 | * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved. | |
21 | * | |
22 | * Contributor(s): all the names of the contributors are added in the source code | |
23 | * where applicable. | |
24 | * | |
25 | * Alternatively, the contents of this file may be used under the terms of the | |
26 | * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the | |
27 | * provisions of LGPL are applicable instead of those above. If you wish to | |
28 | * allow use of your version of this file only under the terms of the LGPL | |
29 | * License and not to allow others to use your version of this file under | |
30 | * the MPL, indicate your decision by deleting the provisions above and | |
31 | * replace them with the notice and other provisions required by the LGPL. | |
32 | * If you do not delete the provisions above, a recipient may use your version | |
33 | * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE | |
34 | * | |
35 | * This library is free software; you can redistribute it and/or modify it | |
36 | * under the terms of the MPL as stated above or under the terms of the GNU | |
37 | * Library General Public License as published by the Free Software Foundation; | |
38 | * either version 2 of the License, or any later version. | |
39 | * | |
40 | * This library is distributed in the hope that it will be useful, but WITHOUT | |
41 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
42 | * FOR A PARTICULAR PURPOSE. See the GNU LIBRARY GENERAL PUBLIC LICENSE for more | |
43 | * details. | |
44 | * | |
45 | * If you didn't download this code from the following link, you should check if | |
46 | * you aren't using an obsolete version: | |
47 | * http://www.lowagie.com/iText/ | |
48 | */ | |
49 | ||
50 | package com.lowagie.text.html; | |
51 | ||
52 | import java.io.IOException; | |
53 | import java.io.OutputStream; | |
54 | import java.util.*; | |
55 | ||
56 | import com.lowagie.text.error_messages.MessageLocalization; | |
57 | ||
58 | import com.lowagie.text.Anchor; | |
59 | import com.lowagie.text.Annotation; | |
60 | import com.lowagie.text.BadElementException; | |
61 | import com.lowagie.text.Cell; | |
62 | import com.lowagie.text.Chunk; | |
63 | import com.lowagie.text.DocWriter; | |
64 | import com.lowagie.text.Document; | |
65 | import com.lowagie.text.DocumentException; | |
66 | import com.lowagie.text.Element; | |
67 | ||
68 | import com.lowagie.text.Font; | |
69 | import com.lowagie.text.Header; | |
70 | import com.lowagie.text.HeaderFooter; | |
71 | import com.lowagie.text.Image; | |
72 | import com.lowagie.text.List; | |
73 | import com.lowagie.text.ListItem; | |
74 | import com.lowagie.text.MarkedObject; | |
75 | import com.lowagie.text.MarkedSection; | |
76 | import com.lowagie.text.Meta; | |
77 | import com.lowagie.text.Paragraph; | |
78 | import com.lowagie.text.Phrase; | |
79 | import com.lowagie.text.Rectangle; | |
80 | import com.lowagie.text.Row; | |
81 | import com.lowagie.text.Section; | |
82 | import com.lowagie.text.SimpleTable; | |
83 | import com.lowagie.text.Table; | |
84 | import com.lowagie.text.ExceptionConverter; | |
85 | import com.lowagie.text.pdf.BaseFont; | |
86 | ||
87 | /** | |
88 | * A <CODE>DocWriter</CODE> class for HTML. | |
89 | * <P> | |
90 | * An <CODE>HtmlWriter</CODE> can be added as a <CODE>DocListener</CODE> | |
91 | * to a certain <CODE>Document</CODE> by getting an instance. | |
92 | * Every <CODE>Element</CODE> added to the original <CODE>Document</CODE> | |
93 | * will be written to the <CODE>OutputStream</CODE> of this <CODE>HtmlWriter</CODE>. | |
94 | * <P> | |
95 | * Example: | |
96 | * <BLOCKQUOTE><PRE> | |
97 | * // creation of the document with a certain size and certain margins | |
98 | * Document document = new Document(PageSize.A4, 50, 50, 50, 50); | |
99 | * try { | |
100 | * // this will write HTML to the Standard OutputStream | |
101 | * <STRONG>HtmlWriter.getInstance(document, System.out);</STRONG> | |
102 | * // this will write HTML to a file called text.html | |
103 | * <STRONG>HtmlWriter.getInstance(document, new FileOutputStream("text.html"));</STRONG> | |
104 | * // this will write HTML to for instance the OutputStream of a HttpServletResponse-object | |
105 | * <STRONG>HtmlWriter.getInstance(document, response.getOutputStream());</STRONG> | |
106 | * } | |
107 | * catch(DocumentException de) { | |
108 | * System.err.println(de.getMessage()); | |
109 | * } | |
110 | * // this will close the document and all the OutputStreams listening to it | |
111 | * <STRONG>document.close();</CODE> | |
112 | * </PRE></BLOCKQUOTE> | |
113 | */ | |
114 | ||
115 | public class HtmlWriter extends DocWriter { | |
116 | | |
117 | // static membervariables (tags) | |
118 | | |
119 | /** This is a possible HTML-tag. */ | |
120 | public static final byte[] BEGINCOMMENT = getISOBytes("<!-- "); | |
121 | | |
122 | /** This is a possible HTML-tag. */ | |
123 | public static final byte[] ENDCOMMENT = getISOBytes(" -->"); | |
124 | | |
125 | /** This is a possible HTML-tag. */ | |
126 | public static final String NBSP = " "; | |
127 | | |
128 | // membervariables | |
129 | | |
130 | /** This is the current font of the HTML. */ | |
131 | protected Stack<Font> currentfont = new Stack<>(); | |
132 | | |
133 | /** This is the standard font of the HTML. */ | |
134 | protected Font standardfont = new Font(); | |
135 | | |
136 | /** This is a path for images. */ | |
137 | protected String imagepath = null; | |
138 | | |
139 | /** Stores the page number. */ | |
140 | protected int pageN = 0; | |
141 | | |
142 | /** This is the textual part of a header */ | |
143 | protected HeaderFooter header = null; | |
144 | | |
145 | /** This is the textual part of the footer */ | |
146 | protected HeaderFooter footer = null; | |
147 | | |
148 | /** Store the markup properties of a MarkedObject. */ | |
149 | protected Properties markup = new Properties(); | |
150 | | |
151 | // constructor | |
152 | | |
153 | /** | |
154 | * Constructs a <CODE>HtmlWriter</CODE>. | |
155 | * | |
156 | * @param doc The <CODE>Document</CODE> that has to be written as HTML | |
157 | * @param os The <CODE>OutputStream</CODE> the writer has to write to. | |
158 | */ | |
159 | | |
160 | protected HtmlWriter(Document doc, OutputStream os) { | |
161 | super(doc, os); | |
162 | | |
163 |
1
1. |
document.addDocListener(this); |
164 | this.pageN = document.getPageNumber(); | |
165 | try { | |
166 |
1
1. |
os.write(LT); |
167 |
1
1. |
os.write(getISOBytes(HtmlTags.HTML)); |
168 |
1
1. |
os.write(GT); |
169 |
1
1. |
os.write(NEWLINE); |
170 |
1
1. |
os.write(TAB); |
171 |
1
1. |
os.write(LT); |
172 |
1
1. |
os.write(getISOBytes(HtmlTags.HEAD)); |
173 |
1
1. |
os.write(GT); |
174 | } | |
175 | catch(IOException ioe) { | |
176 | throw new ExceptionConverter(ioe); | |
177 | } | |
178 | } | |
179 | | |
180 | // get an instance of the HtmlWriter | |
181 | | |
182 | /** | |
183 | * Gets an instance of the <CODE>HtmlWriter</CODE>. | |
184 | * | |
185 | * @param document The <CODE>Document</CODE> that has to be written | |
186 | * @param os The <CODE>OutputStream</CODE> the writer has to write to. | |
187 | * @return a new <CODE>HtmlWriter</CODE> | |
188 | */ | |
189 | | |
190 | public static HtmlWriter getInstance(Document document, OutputStream os) { | |
191 |
1
1. getInstance : mutated return of Object value for com/lowagie/text/html/HtmlWriter::getInstance to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new HtmlWriter(document, os); |
192 | } | |
193 | | |
194 | // implementation of the DocListener methods | |
195 | | |
196 | /** | |
197 | * Signals that an new page has to be started. | |
198 | * | |
199 | * @return <CODE>true</CODE> if this action succeeded, <CODE>false</CODE> if not. | |
200 | */ | |
201 | | |
202 | public boolean newPage() { | |
203 | try { | |
204 |
1
1. newPage : removed call to com/lowagie/text/html/HtmlWriter::writeStart → NO_COVERAGE |
writeStart(HtmlTags.DIV); |
205 |
1
1. newPage : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(" "); |
206 |
1
1. newPage : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.STYLE); |
207 |
1
1. newPage : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write("=\""); |
208 |
1
1. newPage : removed call to com/lowagie/text/html/HtmlWriter::writeCssProperty → NO_COVERAGE |
writeCssProperty(Markup.CSS_KEY_PAGE_BREAK_BEFORE, Markup.CSS_VALUE_ALWAYS); |
209 |
1
1. newPage : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write("\" /"); |
210 |
1
1. newPage : removed call to com/lowagie/text/pdf/OutputStreamCounter::write → NO_COVERAGE |
os.write(GT); |
211 | } | |
212 | catch(IOException ioe) { | |
213 | throw new ExceptionConverter(ioe); | |
214 | } | |
215 |
1
1. newPage : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return true; |
216 | } | |
217 | | |
218 | /** | |
219 | * Signals that an <CODE>Element</CODE> was added to the <CODE>Document</CODE>. | |
220 | * | |
221 | * @param element a high level object that has to be translated to HTML | |
222 | * @return <CODE>true</CODE> if the element was added, <CODE>false</CODE> if not. | |
223 | * @throws DocumentException when a document isn't open yet, or has been closed | |
224 | */ | |
225 | | |
226 | public boolean add(Element element) throws DocumentException { | |
227 |
1
1. add : negated conditional → NO_COVERAGE |
if (pause) { |
228 |
1
1. add : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
229 | } | |
230 |
2
1. add : negated conditional → NO_COVERAGE 2. add : negated conditional → NO_COVERAGE |
if (open && !element.isContent()) { |
231 | throw new DocumentException(MessageLocalization.getComposedMessage("the.document.is.open.you.can.only.add.elements.with.content")); | |
232 | } | |
233 | try { | |
234 | switch(element.type()) { | |
235 | case Element.HEADER: | |
236 | try { | |
237 | Header h = (Header) element; | |
238 |
1
1. add : negated conditional → NO_COVERAGE |
if (HtmlTags.STYLESHEET.equals(h.getName())) { |
239 |
1
1. add : removed call to com/lowagie/text/html/HtmlWriter::writeLink → NO_COVERAGE |
writeLink(h); |
240 | } | |
241 |
1
1. add : negated conditional → NO_COVERAGE |
else if (HtmlTags.JAVASCRIPT.equals(h.getName())) { |
242 |
1
1. add : removed call to com/lowagie/text/html/HtmlWriter::writeJavaScript → NO_COVERAGE |
writeJavaScript(h); |
243 | } | |
244 | else { | |
245 |
1
1. add : removed call to com/lowagie/text/html/HtmlWriter::writeHeader → NO_COVERAGE |
writeHeader(h); |
246 | } | |
247 | } | |
248 | catch(ClassCastException cce) { | |
249 | } | |
250 |
1
1. add : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return true; |
251 | case Element.SUBJECT: | |
252 | case Element.KEYWORDS: | |
253 | case Element.AUTHOR: | |
254 | Meta meta = (Meta) element; | |
255 |
1
1. add : removed call to com/lowagie/text/html/HtmlWriter::writeHeader → NO_COVERAGE |
writeHeader(meta); |
256 |
1
1. add : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return true; |
257 | case Element.TITLE: | |
258 |
1
1. add : removed call to com/lowagie/text/html/HtmlWriter::addTabs → NO_COVERAGE |
addTabs(2); |
259 |
1
1. add : removed call to com/lowagie/text/html/HtmlWriter::writeStart → NO_COVERAGE |
writeStart(HtmlTags.TITLE); |
260 |
1
1. add : removed call to com/lowagie/text/pdf/OutputStreamCounter::write → NO_COVERAGE |
os.write(GT); |
261 |
1
1. add : removed call to com/lowagie/text/html/HtmlWriter::addTabs → NO_COVERAGE |
addTabs(3); |
262 |
1
1. add : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlEncoder.encode(((Meta)element).getContent())); |
263 |
1
1. add : removed call to com/lowagie/text/html/HtmlWriter::addTabs → NO_COVERAGE |
addTabs(2); |
264 |
1
1. add : removed call to com/lowagie/text/html/HtmlWriter::writeEnd → NO_COVERAGE |
writeEnd(HtmlTags.TITLE); |
265 |
1
1. add : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return true; |
266 | case Element.CREATOR: | |
267 |
1
1. add : removed call to com/lowagie/text/html/HtmlWriter::writeComment → NO_COVERAGE |
writeComment("Creator: " + HtmlEncoder.encode(((Meta)element).getContent())); |
268 |
1
1. add : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return true; |
269 | case Element.PRODUCER: | |
270 |
1
1. add : removed call to com/lowagie/text/html/HtmlWriter::writeComment → NO_COVERAGE |
writeComment("Producer: " + HtmlEncoder.encode(((Meta)element).getContent())); |
271 |
1
1. add : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return true; |
272 | case Element.CREATIONDATE: | |
273 |
1
1. add : removed call to com/lowagie/text/html/HtmlWriter::writeComment → NO_COVERAGE |
writeComment("Creationdate: " + HtmlEncoder.encode(((Meta)element).getContent())); |
274 |
1
1. add : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return true; |
275 | case Element.MARKED: | |
276 |
1
1. add : negated conditional → NO_COVERAGE |
if (element instanceof MarkedSection) { |
277 | MarkedSection ms = (MarkedSection)element; | |
278 |
1
1. add : removed call to com/lowagie/text/html/HtmlWriter::addTabs → NO_COVERAGE |
addTabs(1); |
279 |
1
1. add : removed call to com/lowagie/text/html/HtmlWriter::writeStart → NO_COVERAGE |
writeStart(HtmlTags.DIV); |
280 | writeMarkupAttributes(ms.getMarkupAttributes()); | |
281 |
1
1. add : removed call to com/lowagie/text/pdf/OutputStreamCounter::write → NO_COVERAGE |
os.write(GT); |
282 | MarkedObject mo = ((MarkedSection)element).getTitle(); | |
283 |
1
1. add : negated conditional → NO_COVERAGE |
if (mo != null) { |
284 | markup = mo.getMarkupAttributes(); | |
285 | mo.process(this); | |
286 | } | |
287 | ms.process(this); | |
288 |
1
1. add : removed call to com/lowagie/text/html/HtmlWriter::writeEnd → NO_COVERAGE |
writeEnd(HtmlTags.DIV); |
289 |
1
1. add : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return true; |
290 | } | |
291 | else { | |
292 | MarkedObject mo = (MarkedObject) element; | |
293 | markup = mo.getMarkupAttributes(); | |
294 |
1
1. add : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return mo.process(this); |
295 | } | |
296 | default: | |
297 |
1
1. add : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(element, 2); |
298 |
1
1. add : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return true; |
299 | } | |
300 | } | |
301 | catch(IOException ioe) { | |
302 | throw new ExceptionConverter(ioe); | |
303 | } | |
304 | } | |
305 | | |
306 | /** | |
307 | * Signals that the <CODE>Document</CODE> has been opened and that | |
308 | * <CODE>Elements</CODE> can be added. | |
309 | * <P> | |
310 | * The <CODE>HEAD</CODE>-section of the HTML-document is written. | |
311 | */ | |
312 | | |
313 | public void open() { | |
314 |
1
1. open : removed call to com/lowagie/text/DocWriter::open → NO_COVERAGE |
super.open(); |
315 | try { | |
316 |
1
1. open : removed call to com/lowagie/text/html/HtmlWriter::writeComment → NO_COVERAGE |
writeComment(Document.getVersion()); |
317 |
1
1. open : removed call to com/lowagie/text/html/HtmlWriter::writeComment → NO_COVERAGE |
writeComment("CreationDate: " + new Date().toString()); |
318 |
1
1. open : removed call to com/lowagie/text/html/HtmlWriter::addTabs → NO_COVERAGE |
addTabs(1); |
319 |
1
1. open : removed call to com/lowagie/text/html/HtmlWriter::writeEnd → NO_COVERAGE |
writeEnd(HtmlTags.HEAD); |
320 |
1
1. open : removed call to com/lowagie/text/html/HtmlWriter::addTabs → NO_COVERAGE |
addTabs(1); |
321 |
1
1. open : removed call to com/lowagie/text/html/HtmlWriter::writeStart → NO_COVERAGE |
writeStart(HtmlTags.BODY); |
322 |
2
1. open : changed conditional boundary → NO_COVERAGE 2. open : negated conditional → NO_COVERAGE |
if (document.leftMargin() > 0) { |
323 |
1
1. open : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.LEFTMARGIN, String.valueOf(document.leftMargin())); |
324 | } | |
325 |
2
1. open : changed conditional boundary → NO_COVERAGE 2. open : negated conditional → NO_COVERAGE |
if (document.rightMargin() > 0) { |
326 |
1
1. open : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.RIGHTMARGIN, String.valueOf(document.rightMargin())); |
327 | } | |
328 |
2
1. open : changed conditional boundary → NO_COVERAGE 2. open : negated conditional → NO_COVERAGE |
if (document.topMargin() > 0) { |
329 |
1
1. open : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.TOPMARGIN, String.valueOf(document.topMargin())); |
330 | } | |
331 |
2
1. open : changed conditional boundary → NO_COVERAGE 2. open : negated conditional → NO_COVERAGE |
if (document.bottomMargin() > 0) { |
332 |
1
1. open : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.BOTTOMMARGIN, String.valueOf(document.bottomMargin())); |
333 | } | |
334 |
1
1. open : negated conditional → NO_COVERAGE |
if (pageSize.getBackgroundColor() != null) { |
335 |
1
1. open : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.BACKGROUNDCOLOR, HtmlEncoder.encode(pageSize.getBackgroundColor())); |
336 | } | |
337 |
1
1. open : negated conditional → NO_COVERAGE |
if (document.getJavaScript_onLoad() != null) { |
338 |
1
1. open : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.JAVASCRIPT_ONLOAD, HtmlEncoder.encode(document.getJavaScript_onLoad())); |
339 | } | |
340 |
1
1. open : negated conditional → NO_COVERAGE |
if (document.getJavaScript_onUnLoad() != null) { |
341 |
1
1. open : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.JAVASCRIPT_ONUNLOAD, HtmlEncoder.encode(document.getJavaScript_onUnLoad())); |
342 | } | |
343 |
1
1. open : negated conditional → NO_COVERAGE |
if (document.getHtmlStyleClass() != null) { |
344 |
1
1. open : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(Markup.HTML_ATTR_CSS_CLASS, document.getHtmlStyleClass()); |
345 | } | |
346 |
1
1. open : removed call to com/lowagie/text/pdf/OutputStreamCounter::write → NO_COVERAGE |
os.write(GT); |
347 |
1
1. open : removed call to com/lowagie/text/html/HtmlWriter::initHeader → NO_COVERAGE |
initHeader(); // line added by David Freels |
348 | } | |
349 | catch(IOException ioe) { | |
350 | throw new ExceptionConverter(ioe); | |
351 | } | |
352 | } | |
353 | | |
354 | /** | |
355 | * Signals that the <CODE>Document</CODE> was closed and that no other | |
356 | * <CODE>Elements</CODE> will be added. | |
357 | */ | |
358 | | |
359 | public void close() { | |
360 | try { | |
361 |
1
1. close : removed call to com/lowagie/text/html/HtmlWriter::initFooter → NO_COVERAGE |
initFooter(); // line added by David Freels |
362 |
1
1. close : removed call to com/lowagie/text/html/HtmlWriter::addTabs → NO_COVERAGE |
addTabs(1); |
363 |
1
1. close : removed call to com/lowagie/text/html/HtmlWriter::writeEnd → NO_COVERAGE |
writeEnd(HtmlTags.BODY); |
364 |
1
1. close : removed call to com/lowagie/text/pdf/OutputStreamCounter::write → NO_COVERAGE |
os.write(NEWLINE); |
365 |
1
1. close : removed call to com/lowagie/text/html/HtmlWriter::writeEnd → NO_COVERAGE |
writeEnd(HtmlTags.HTML); |
366 |
1
1. close : removed call to com/lowagie/text/DocWriter::close → NO_COVERAGE |
super.close(); |
367 | } | |
368 | catch(IOException ioe) { | |
369 | throw new ExceptionConverter(ioe); | |
370 | } | |
371 | } | |
372 | | |
373 | // some protected methods | |
374 | | |
375 | /** | |
376 | * Adds the header to the top of the </CODE>Document</CODE> | |
377 | */ | |
378 | | |
379 | protected void initHeader() { | |
380 |
1
1. initHeader : negated conditional → NO_COVERAGE |
if (header != null) { |
381 | try { | |
382 | add(header.paragraph()); | |
383 | } | |
384 | catch(Exception e) { | |
385 | throw new ExceptionConverter(e); | |
386 | } | |
387 | } | |
388 | } | |
389 | | |
390 | /** | |
391 | * Adds the header to the top of the </CODE>Document</CODE> | |
392 | */ | |
393 | | |
394 | protected void initFooter() { | |
395 |
1
1. initFooter : negated conditional → NO_COVERAGE |
if (footer != null) { |
396 | try { | |
397 | // Set the page number. HTML has no notion of a page, so it should always | |
398 | // add up to 1 | |
399 |
2
1. initFooter : Replaced integer addition with subtraction → NO_COVERAGE 2. initFooter : removed call to com/lowagie/text/HeaderFooter::setPageNumber → NO_COVERAGE |
footer.setPageNumber(pageN + 1); |
400 | add(footer.paragraph()); | |
401 | } | |
402 | catch(Exception e) { | |
403 | throw new ExceptionConverter(e); | |
404 | } | |
405 | } | |
406 | } | |
407 | | |
408 | /** | |
409 | * Writes a Metatag in the header. | |
410 | * | |
411 | * @param meta the element that has to be written | |
412 | * @throws IOException | |
413 | */ | |
414 | | |
415 | protected void writeHeader(Meta meta) throws IOException { | |
416 |
1
1. writeHeader : removed call to com/lowagie/text/html/HtmlWriter::addTabs → NO_COVERAGE |
addTabs(2); |
417 |
1
1. writeHeader : removed call to com/lowagie/text/html/HtmlWriter::writeStart → NO_COVERAGE |
writeStart(HtmlTags.META); |
418 | switch(meta.type()) { | |
419 | case Element.HEADER: | |
420 |
1
1. writeHeader : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.NAME, meta.getName()); |
421 | break; | |
422 | case Element.SUBJECT: | |
423 |
1
1. writeHeader : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.NAME, HtmlTags.SUBJECT); |
424 | break; | |
425 | case Element.KEYWORDS: | |
426 |
1
1. writeHeader : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.NAME, HtmlTags.KEYWORDS); |
427 | break; | |
428 | case Element.AUTHOR: | |
429 |
1
1. writeHeader : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.NAME, HtmlTags.AUTHOR); |
430 | break; | |
431 | } | |
432 |
1
1. writeHeader : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.CONTENT, HtmlEncoder.encode(meta.getContent())); |
433 |
1
1. writeHeader : removed call to com/lowagie/text/html/HtmlWriter::writeEnd → NO_COVERAGE |
writeEnd(); |
434 | } | |
435 | | |
436 | /** | |
437 | * Writes a link in the header. | |
438 | * | |
439 | * @param header the element that has to be written | |
440 | * @throws IOException | |
441 | */ | |
442 | | |
443 | protected void writeLink(Header header) throws IOException { | |
444 |
1
1. writeLink : removed call to com/lowagie/text/html/HtmlWriter::addTabs → NO_COVERAGE |
addTabs(2); |
445 |
1
1. writeLink : removed call to com/lowagie/text/html/HtmlWriter::writeStart → NO_COVERAGE |
writeStart(HtmlTags.LINK); |
446 |
1
1. writeLink : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.REL, header.getName()); |
447 |
1
1. writeLink : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.TYPE, HtmlTags.TEXT_CSS); |
448 |
1
1. writeLink : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.REFERENCE, header.getContent()); |
449 |
1
1. writeLink : removed call to com/lowagie/text/html/HtmlWriter::writeEnd → NO_COVERAGE |
writeEnd(); |
450 | } | |
451 | | |
452 | /** | |
453 | * Writes a JavaScript section or, if the markup attribute HtmlTags.URL is set, a JavaScript reference in the header. | |
454 | * | |
455 | * @param header the element that has to be written | |
456 | * @throws IOException | |
457 | */ | |
458 | | |
459 | protected void writeJavaScript(Header header) throws IOException { | |
460 |
1
1. writeJavaScript : removed call to com/lowagie/text/html/HtmlWriter::addTabs → NO_COVERAGE |
addTabs(2); |
461 |
1
1. writeJavaScript : removed call to com/lowagie/text/html/HtmlWriter::writeStart → NO_COVERAGE |
writeStart(HtmlTags.SCRIPT); |
462 |
1
1. writeJavaScript : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.LANGUAGE, HtmlTags.JAVASCRIPT); |
463 |
2
1. writeJavaScript : changed conditional boundary → NO_COVERAGE 2. writeJavaScript : negated conditional → NO_COVERAGE |
if (markup.size() > 0) { |
464 | /* JavaScript reference example: | |
465 | * | |
466 | * <script language="JavaScript" src="/myPath/MyFunctions.js"/> | |
467 | */ | |
468 | writeMarkupAttributes(markup); | |
469 |
1
1. writeJavaScript : removed call to com/lowagie/text/pdf/OutputStreamCounter::write → NO_COVERAGE |
os.write(GT); |
470 |
1
1. writeJavaScript : removed call to com/lowagie/text/html/HtmlWriter::writeEnd → NO_COVERAGE |
writeEnd(HtmlTags.SCRIPT); |
471 | } | |
472 | else { | |
473 | /* JavaScript coding convention: | |
474 | * | |
475 | * <script language="JavaScript" type="text/javascript"> | |
476 | * <!-- | |
477 | * // ... JavaScript methods ... | |
478 | * //--> | |
479 | * </script> | |
480 | */ | |
481 |
1
1. writeJavaScript : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.TYPE, Markup.HTML_VALUE_JAVASCRIPT); |
482 |
1
1. writeJavaScript : removed call to com/lowagie/text/pdf/OutputStreamCounter::write → NO_COVERAGE |
os.write(GT); |
483 |
1
1. writeJavaScript : removed call to com/lowagie/text/html/HtmlWriter::addTabs → NO_COVERAGE |
addTabs(2); |
484 |
1
1. writeJavaScript : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(new String(BEGINCOMMENT) + "\n"); |
485 |
1
1. writeJavaScript : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(header.getContent()); |
486 |
1
1. writeJavaScript : removed call to com/lowagie/text/html/HtmlWriter::addTabs → NO_COVERAGE |
addTabs(2); |
487 |
1
1. writeJavaScript : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write("//" + new String(ENDCOMMENT)); |
488 |
1
1. writeJavaScript : removed call to com/lowagie/text/html/HtmlWriter::addTabs → NO_COVERAGE |
addTabs(2); |
489 |
1
1. writeJavaScript : removed call to com/lowagie/text/html/HtmlWriter::writeEnd → NO_COVERAGE |
writeEnd(HtmlTags.SCRIPT); |
490 | } | |
491 | } | |
492 | | |
493 | /** | |
494 | * Writes some comment. | |
495 | * <P> | |
496 | * This method writes some comment. | |
497 | * | |
498 | * @param comment the comment that has to be written | |
499 | * @throws IOException | |
500 | */ | |
501 | | |
502 | protected void writeComment(String comment) throws IOException { | |
503 |
1
1. writeComment : removed call to com/lowagie/text/html/HtmlWriter::addTabs → NO_COVERAGE |
addTabs(2); |
504 |
1
1. writeComment : removed call to com/lowagie/text/pdf/OutputStreamCounter::write → NO_COVERAGE |
os.write(BEGINCOMMENT); |
505 |
1
1. writeComment : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(comment); |
506 |
1
1. writeComment : removed call to com/lowagie/text/pdf/OutputStreamCounter::write → NO_COVERAGE |
os.write(ENDCOMMENT); |
507 | } | |
508 | | |
509 | // public methods | |
510 | | |
511 | /** | |
512 | * Changes the standardfont. | |
513 | * | |
514 | * @param standardfont The font | |
515 | */ | |
516 | | |
517 | public void setStandardFont(Font standardfont) { | |
518 | this.standardfont = standardfont; | |
519 | } | |
520 | | |
521 | /** | |
522 | * Checks if a given font is the same as the font that was last used. | |
523 | * | |
524 | * @param font the font of an object | |
525 | * @return true if the font differs | |
526 | */ | |
527 | | |
528 | public boolean isOtherFont(Font font) { | |
529 | try { | |
530 | Font cFont = currentfont.peek(); | |
531 |
2
1. isOtherFont : negated conditional → NO_COVERAGE 2. isOtherFont : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return cFont.compareTo(font) != 0; |
532 | } | |
533 | catch(EmptyStackException ese) { | |
534 |
2
1. isOtherFont : negated conditional → NO_COVERAGE 2. isOtherFont : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return standardfont.compareTo(font) != 0; |
535 | } | |
536 | } | |
537 | | |
538 | /** | |
539 | * Sets the basepath for images. | |
540 | * <P> | |
541 | * This is especially useful if you add images using a file, | |
542 | * rather than an URL. In PDF there is no problem, since | |
543 | * the images are added inline, but in HTML it is sometimes | |
544 | * necessary to use a relative path or a special path to some | |
545 | * images directory. | |
546 | * | |
547 | * @param imagepath the new imagepath | |
548 | */ | |
549 | | |
550 | public void setImagepath(String imagepath) { | |
551 | this.imagepath = imagepath; | |
552 | } | |
553 | | |
554 | /** | |
555 | * Resets the imagepath. | |
556 | */ | |
557 | | |
558 | public void resetImagepath() { | |
559 | imagepath = null; | |
560 | } | |
561 | | |
562 | /** | |
563 | * Changes the header of this document. | |
564 | * | |
565 | * @param header the new header | |
566 | */ | |
567 | | |
568 | public void setHeader(HeaderFooter header) { | |
569 | this.header = header; | |
570 | } | |
571 | | |
572 | /** | |
573 | * Changes the footer of this document. | |
574 | * | |
575 | * @param footer the new footer | |
576 | */ | |
577 | | |
578 | public void setFooter(HeaderFooter footer) { | |
579 | this.footer = footer; | |
580 | } | |
581 | | |
582 | /** | |
583 | * Signals that a <CODE>String</CODE> was added to the <CODE>Document</CODE>. | |
584 | * | |
585 | * @param string a String to add to the HTML | |
586 | * @return <CODE>true</CODE> if the string was added, <CODE>false</CODE> if not. | |
587 | */ | |
588 | | |
589 | public boolean add(String string) { | |
590 |
1
1. add : negated conditional → NO_COVERAGE |
if (pause) { |
591 |
1
1. add : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
592 | } | |
593 | try | |
594 | { | |
595 |
1
1. add : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(string); |
596 |
1
1. add : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return true; |
597 | } | |
598 | catch(IOException ioe) { | |
599 | throw new ExceptionConverter(ioe); | |
600 | } | |
601 | } | |
602 | | |
603 | /** | |
604 | * Writes the HTML representation of an element. | |
605 | * | |
606 | * @param element the element | |
607 | * @param indent the indentation | |
608 | * @throws IOException | |
609 | */ | |
610 | | |
611 | protected void write(Element element, int indent) throws IOException { | |
612 | Properties styleAttributes = null; | |
613 | switch(element.type()) { | |
614 | case Element.MARKED: { | |
615 | try { | |
616 | add(element); | |
617 | } catch (DocumentException e) { | |
618 |
1
1. write : removed call to com/lowagie/text/DocumentException::printStackTrace → NO_COVERAGE |
e.printStackTrace(); |
619 | } | |
620 | return; | |
621 | } | |
622 | case Element.CHUNK: | |
623 | { | |
624 | Chunk chunk = (Chunk) element; | |
625 | // if the chunk contains an image, return the image representation | |
626 | Image image = chunk.getImage(); | |
627 |
1
1. write : negated conditional → NO_COVERAGE |
if (image != null) { |
628 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(image, indent); |
629 | return; | |
630 | } | |
631 | | |
632 |
1
1. write : negated conditional → NO_COVERAGE |
if (chunk.isEmpty()) return; |
633 | Map<String, Object> attributes = chunk.getAttributes(); | |
634 |
2
1. write : negated conditional → NO_COVERAGE 2. write : negated conditional → NO_COVERAGE |
if (attributes != null && attributes.get(Chunk.NEWPAGE) != null) { |
635 | return; | |
636 | } | |
637 |
3
1. write : changed conditional boundary → NO_COVERAGE 2. write : negated conditional → NO_COVERAGE 3. write : negated conditional → NO_COVERAGE |
boolean tag = isOtherFont(chunk.getFont()) || markup.size() > 0; |
638 |
1
1. write : negated conditional → NO_COVERAGE |
if (tag) { |
639 | // start span tag | |
640 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::addTabs → NO_COVERAGE |
addTabs(indent); |
641 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeStart → NO_COVERAGE |
writeStart(HtmlTags.SPAN); |
642 |
1
1. write : negated conditional → NO_COVERAGE |
if (isOtherFont(chunk.getFont())) { |
643 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(chunk.getFont(), null); |
644 | } | |
645 | writeMarkupAttributes(markup); | |
646 |
1
1. write : removed call to com/lowagie/text/pdf/OutputStreamCounter::write → NO_COVERAGE |
os.write(GT); |
647 | } | |
648 |
2
1. write : negated conditional → NO_COVERAGE 2. write : negated conditional → NO_COVERAGE |
if (attributes != null && attributes.get(Chunk.SUBSUPSCRIPT) != null) { |
649 | // start sup or sub tag | |
650 |
2
1. write : changed conditional boundary → NO_COVERAGE 2. write : negated conditional → NO_COVERAGE |
if ((Float) attributes.get(Chunk.SUBSUPSCRIPT) > 0) { |
651 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeStart → NO_COVERAGE |
writeStart(HtmlTags.SUP); |
652 | } | |
653 | else { | |
654 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeStart → NO_COVERAGE |
writeStart(HtmlTags.SUB); |
655 | } | |
656 |
1
1. write : removed call to com/lowagie/text/pdf/OutputStreamCounter::write → NO_COVERAGE |
os.write(GT); |
657 | } | |
658 | // contents | |
659 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlEncoder.encode(chunk.getContent())); |
660 |
2
1. write : negated conditional → NO_COVERAGE 2. write : negated conditional → NO_COVERAGE |
if (attributes != null && attributes.get(Chunk.SUBSUPSCRIPT) != null) { |
661 | // end sup or sub tag | |
662 |
1
1. write : removed call to com/lowagie/text/pdf/OutputStreamCounter::write → NO_COVERAGE |
os.write(LT); |
663 |
1
1. write : removed call to com/lowagie/text/pdf/OutputStreamCounter::write → NO_COVERAGE |
os.write(FORWARD); |
664 |
2
1. write : changed conditional boundary → NO_COVERAGE 2. write : negated conditional → NO_COVERAGE |
if ((Float) attributes.get(Chunk.SUBSUPSCRIPT) > 0) { |
665 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.SUP); |
666 | } | |
667 | else { | |
668 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.SUB); |
669 | } | |
670 |
1
1. write : removed call to com/lowagie/text/pdf/OutputStreamCounter::write → NO_COVERAGE |
os.write(GT); |
671 | } | |
672 |
1
1. write : negated conditional → NO_COVERAGE |
if (tag) { |
673 | // end tag | |
674 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeEnd → NO_COVERAGE |
writeEnd(Markup.HTML_TAG_SPAN); |
675 | } | |
676 | return; | |
677 | } | |
678 | case Element.PHRASE: | |
679 | { | |
680 | Phrase phrase = (Phrase) element; | |
681 | styleAttributes = new Properties(); | |
682 |
1
1. write : negated conditional → NO_COVERAGE |
if (phrase.hasLeading()) styleAttributes.setProperty(Markup.CSS_KEY_LINEHEIGHT, phrase.getLeading() + "pt"); |
683 | | |
684 | // start tag | |
685 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::addTabs → NO_COVERAGE |
addTabs(indent); |
686 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeStart → NO_COVERAGE |
writeStart(Markup.HTML_TAG_SPAN); |
687 | writeMarkupAttributes(markup); | |
688 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(phrase.getFont(), styleAttributes); |
689 |
1
1. write : removed call to com/lowagie/text/pdf/OutputStreamCounter::write → NO_COVERAGE |
os.write(GT); |
690 | currentfont.push(phrase.getFont()); | |
691 | // contents | |
692 | for (Object o : phrase) { | |
693 |
2
1. write : Replaced integer addition with subtraction → NO_COVERAGE 2. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write((Element) o, indent + 1); |
694 | } | |
695 | // end tag | |
696 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::addTabs → NO_COVERAGE |
addTabs(indent); |
697 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeEnd → NO_COVERAGE |
writeEnd(Markup.HTML_TAG_SPAN); |
698 | currentfont.pop(); | |
699 | return; | |
700 | } | |
701 | case Element.ANCHOR: | |
702 | { | |
703 | Anchor anchor = (Anchor) element; | |
704 | styleAttributes = new Properties(); | |
705 |
1
1. write : negated conditional → NO_COVERAGE |
if (anchor.hasLeading()) styleAttributes.setProperty(Markup.CSS_KEY_LINEHEIGHT, anchor.getLeading() + "pt"); |
706 | | |
707 | // start tag | |
708 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::addTabs → NO_COVERAGE |
addTabs(indent); |
709 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeStart → NO_COVERAGE |
writeStart(HtmlTags.ANCHOR); |
710 |
1
1. write : negated conditional → NO_COVERAGE |
if (anchor.getName() != null) { |
711 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.NAME, anchor.getName()); |
712 | } | |
713 |
1
1. write : negated conditional → NO_COVERAGE |
if (anchor.getReference() != null) { |
714 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.REFERENCE, anchor.getReference()); |
715 | } | |
716 | writeMarkupAttributes(markup); | |
717 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(anchor.getFont(), styleAttributes); |
718 |
1
1. write : removed call to com/lowagie/text/pdf/OutputStreamCounter::write → NO_COVERAGE |
os.write(GT); |
719 | currentfont.push(anchor.getFont()); | |
720 | // contents | |
721 | for (Object o : anchor) { | |
722 |
2
1. write : Replaced integer addition with subtraction → NO_COVERAGE 2. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write((Element) o, indent + 1); |
723 | } | |
724 | // end tag | |
725 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::addTabs → NO_COVERAGE |
addTabs(indent); |
726 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeEnd → NO_COVERAGE |
writeEnd(HtmlTags.ANCHOR); |
727 | currentfont.pop(); | |
728 | return; | |
729 | } | |
730 | case Element.PARAGRAPH: | |
731 | { | |
732 | Paragraph paragraph = (Paragraph) element; | |
733 | styleAttributes = new Properties(); | |
734 |
1
1. write : negated conditional → NO_COVERAGE |
if (paragraph.hasLeading()) styleAttributes.setProperty(Markup.CSS_KEY_LINEHEIGHT, paragraph.getTotalLeading() + "pt"); |
735 | // start tag | |
736 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::addTabs → NO_COVERAGE |
addTabs(indent); |
737 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeStart → NO_COVERAGE |
writeStart(HtmlTags.DIV); |
738 | writeMarkupAttributes(markup); | |
739 | String alignment = HtmlEncoder.getAlignment(paragraph.getAlignment()); | |
740 |
1
1. write : negated conditional → NO_COVERAGE |
if (!"".equals(alignment)) { |
741 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.ALIGN, alignment); |
742 | } | |
743 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(paragraph.getFont(), styleAttributes); |
744 |
1
1. write : removed call to com/lowagie/text/pdf/OutputStreamCounter::write → NO_COVERAGE |
os.write(GT); |
745 | currentfont.push(paragraph.getFont()); | |
746 | // contents | |
747 | for (Object o : paragraph) { | |
748 |
2
1. write : Replaced integer addition with subtraction → NO_COVERAGE 2. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write((Element) o, indent + 1); |
749 | } | |
750 | // end tag | |
751 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::addTabs → NO_COVERAGE |
addTabs(indent); |
752 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeEnd → NO_COVERAGE |
writeEnd(HtmlTags.DIV); |
753 | currentfont.pop(); | |
754 | return; | |
755 | } | |
756 | case Element.SECTION: | |
757 | case Element.CHAPTER: | |
758 | { | |
759 | // part of the start tag + contents | |
760 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeSection → NO_COVERAGE |
writeSection((Section) element, indent); |
761 | return; | |
762 | } | |
763 | case Element.LIST: | |
764 | { | |
765 | List list = (List) element; | |
766 | // start tag | |
767 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::addTabs → NO_COVERAGE |
addTabs(indent); |
768 |
1
1. write : negated conditional → NO_COVERAGE |
if (list.isNumbered()) { |
769 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeStart → NO_COVERAGE |
writeStart(HtmlTags.ORDEREDLIST); |
770 | } | |
771 | else { | |
772 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeStart → NO_COVERAGE |
writeStart(HtmlTags.UNORDEREDLIST); |
773 | } | |
774 | writeMarkupAttributes(markup); | |
775 |
1
1. write : removed call to com/lowagie/text/pdf/OutputStreamCounter::write → NO_COVERAGE |
os.write(GT); |
776 | // contents | |
777 | for (Object o : list.getItems()) { | |
778 |
2
1. write : Replaced integer addition with subtraction → NO_COVERAGE 2. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write((Element) o, indent + 1); |
779 | } | |
780 | // end tag | |
781 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::addTabs → NO_COVERAGE |
addTabs(indent); |
782 |
1
1. write : negated conditional → NO_COVERAGE |
if (list.isNumbered()) { |
783 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeEnd → NO_COVERAGE |
writeEnd(HtmlTags.ORDEREDLIST); |
784 | } | |
785 | else { | |
786 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeEnd → NO_COVERAGE |
writeEnd(HtmlTags.UNORDEREDLIST); |
787 | } | |
788 | return; | |
789 | } | |
790 | case Element.LISTITEM: | |
791 | { | |
792 | ListItem listItem = (ListItem) element; | |
793 | styleAttributes = new Properties(); | |
794 |
1
1. write : negated conditional → NO_COVERAGE |
if (listItem.hasLeading()) styleAttributes.setProperty(Markup.CSS_KEY_LINEHEIGHT, listItem.getTotalLeading() + "pt"); |
795 | | |
796 | // start tag | |
797 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::addTabs → NO_COVERAGE |
addTabs(indent); |
798 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeStart → NO_COVERAGE |
writeStart(HtmlTags.LISTITEM); |
799 | writeMarkupAttributes(markup); | |
800 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(listItem.getFont(), styleAttributes); |
801 |
1
1. write : removed call to com/lowagie/text/pdf/OutputStreamCounter::write → NO_COVERAGE |
os.write(GT); |
802 | currentfont.push(listItem.getFont()); | |
803 | // contents | |
804 | for (Object o : listItem) { | |
805 |
2
1. write : Replaced integer addition with subtraction → NO_COVERAGE 2. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write((Element) o, indent + 1); |
806 | } | |
807 | // end tag | |
808 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::addTabs → NO_COVERAGE |
addTabs(indent); |
809 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeEnd → NO_COVERAGE |
writeEnd(HtmlTags.LISTITEM); |
810 | currentfont.pop(); | |
811 | return; | |
812 | } | |
813 | case Element.CELL: | |
814 | { | |
815 | Cell cell = (Cell) element; | |
816 | | |
817 | // start tag | |
818 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::addTabs → NO_COVERAGE |
addTabs(indent); |
819 |
1
1. write : negated conditional → NO_COVERAGE |
if (cell.isHeader()) { |
820 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeStart → NO_COVERAGE |
writeStart(HtmlTags.HEADERCELL); |
821 | } | |
822 | else { | |
823 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeStart → NO_COVERAGE |
writeStart(HtmlTags.CELL); |
824 | } | |
825 | writeMarkupAttributes(markup); | |
826 |
1
1. write : negated conditional → NO_COVERAGE |
if (cell.getBorderWidth() != Rectangle.UNDEFINED) { |
827 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.BORDERWIDTH, String.valueOf(cell.getBorderWidth())); |
828 | } | |
829 |
1
1. write : negated conditional → NO_COVERAGE |
if (cell.getBorderColor() != null) { |
830 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.BORDERCOLOR, HtmlEncoder.encode(cell.getBorderColor())); |
831 | } | |
832 |
1
1. write : negated conditional → NO_COVERAGE |
if (cell.getBackgroundColor() != null) { |
833 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.BACKGROUNDCOLOR, HtmlEncoder.encode(cell.getBackgroundColor())); |
834 | } | |
835 | String alignment = HtmlEncoder.getAlignment(cell.getHorizontalAlignment()); | |
836 |
1
1. write : negated conditional → NO_COVERAGE |
if (!"".equals(alignment)) { |
837 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.HORIZONTALALIGN, alignment); |
838 | } | |
839 | alignment = HtmlEncoder.getAlignment(cell.getVerticalAlignment()); | |
840 |
1
1. write : negated conditional → NO_COVERAGE |
if (!"".equals(alignment)) { |
841 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.VERTICALALIGN, alignment); |
842 | } | |
843 |
1
1. write : negated conditional → NO_COVERAGE |
if (cell.getWidthAsString() != null) { |
844 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.WIDTH, cell.getWidthAsString()); |
845 | } | |
846 |
1
1. write : negated conditional → NO_COVERAGE |
if (cell.getColspan() != 1) { |
847 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.COLSPAN, String.valueOf(cell.getColspan())); |
848 | } | |
849 |
1
1. write : negated conditional → NO_COVERAGE |
if (cell.getRowspan() != 1) { |
850 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.ROWSPAN, String.valueOf(cell.getRowspan())); |
851 | } | |
852 |
1
1. write : negated conditional → NO_COVERAGE |
if (cell.getMaxLines() == 1) { |
853 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.STYLE, "white-space: nowrap;"); |
854 | } | |
855 |
1
1. write : removed call to com/lowagie/text/pdf/OutputStreamCounter::write → NO_COVERAGE |
os.write(GT); |
856 | // contents | |
857 |
1
1. write : negated conditional → NO_COVERAGE |
if (cell.isEmpty()) { |
858 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(NBSP); |
859 | } else { | |
860 | for (Iterator i = cell.getElements(); i.hasNext(); ) { | |
861 |
2
1. write : Replaced integer addition with subtraction → NO_COVERAGE 2. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write((Element) i.next(), indent + 1); |
862 | } | |
863 | } | |
864 | // end tag | |
865 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::addTabs → NO_COVERAGE |
addTabs(indent); |
866 |
1
1. write : negated conditional → NO_COVERAGE |
if (cell.isHeader()) { |
867 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeEnd → NO_COVERAGE |
writeEnd(HtmlTags.HEADERCELL); |
868 | } | |
869 | else { | |
870 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeEnd → NO_COVERAGE |
writeEnd(HtmlTags.CELL); |
871 | } | |
872 | return; | |
873 | } | |
874 | case Element.ROW: | |
875 | { | |
876 | Row row = (Row) element; | |
877 | | |
878 | // start tag | |
879 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::addTabs → NO_COVERAGE |
addTabs(indent); |
880 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeStart → NO_COVERAGE |
writeStart(HtmlTags.ROW); |
881 | writeMarkupAttributes(markup); | |
882 |
1
1. write : removed call to com/lowagie/text/pdf/OutputStreamCounter::write → NO_COVERAGE |
os.write(GT); |
883 | // contents | |
884 | Element cell; | |
885 |
2
1. write : changed conditional boundary → NO_COVERAGE 2. write : negated conditional → NO_COVERAGE |
for (int i = 0; i < row.getColumns(); i++) { |
886 |
1
1. write : negated conditional → NO_COVERAGE |
if ((cell = (Element)row.getCell(i)) != null) { |
887 |
2
1. write : Replaced integer addition with subtraction → NO_COVERAGE 2. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(cell, indent + 1); |
888 | } | |
889 | } | |
890 | // end tag | |
891 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::addTabs → NO_COVERAGE |
addTabs(indent); |
892 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeEnd → NO_COVERAGE |
writeEnd(HtmlTags.ROW); |
893 | return; | |
894 | } | |
895 | case Element.TABLE: | |
896 | { | |
897 | Table table; | |
898 | try { | |
899 | table = (Table) element; | |
900 | } | |
901 | catch(ClassCastException cce) { | |
902 | try { | |
903 | table = ((SimpleTable)element).createTable(); | |
904 | } catch (BadElementException e) { | |
905 | throw new ExceptionConverter(e); | |
906 | } | |
907 | } | |
908 |
1
1. write : removed call to com/lowagie/text/Table::complete → NO_COVERAGE |
table.complete(); |
909 | // start tag | |
910 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::addTabs → NO_COVERAGE |
addTabs(indent); |
911 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeStart → NO_COVERAGE |
writeStart(HtmlTags.TABLE); |
912 | writeMarkupAttributes(markup); | |
913 |
1
1. write : removed call to com/lowagie/text/pdf/OutputStreamCounter::write → NO_COVERAGE |
os.write(SPACE); |
914 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.WIDTH); |
915 |
1
1. write : removed call to com/lowagie/text/pdf/OutputStreamCounter::write → NO_COVERAGE |
os.write(EQUALS); |
916 |
1
1. write : removed call to com/lowagie/text/pdf/OutputStreamCounter::write → NO_COVERAGE |
os.write(QUOTE); |
917 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(String.valueOf(table.getWidth())); |
918 |
1
1. write : negated conditional → NO_COVERAGE |
if (!table.isLocked()){ |
919 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write("%"); |
920 | } | |
921 |
1
1. write : removed call to com/lowagie/text/pdf/OutputStreamCounter::write → NO_COVERAGE |
os.write(QUOTE); |
922 | String alignment = HtmlEncoder.getAlignment(table.getAlignment()); | |
923 |
1
1. write : negated conditional → NO_COVERAGE |
if (!"".equals(alignment)) { |
924 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.ALIGN, alignment); |
925 | } | |
926 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.CELLPADDING, String.valueOf(table.getPadding())); |
927 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.CELLSPACING, String.valueOf(table.getSpacing())); |
928 |
1
1. write : negated conditional → NO_COVERAGE |
if (table.getBorderWidth() != Rectangle.UNDEFINED) { |
929 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.BORDERWIDTH, String.valueOf(table.getBorderWidth())); |
930 | } | |
931 |
1
1. write : negated conditional → NO_COVERAGE |
if (table.getBorderColor() != null) { |
932 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.BORDERCOLOR, HtmlEncoder.encode(table.getBorderColor())); |
933 | } | |
934 |
1
1. write : negated conditional → NO_COVERAGE |
if (table.getBackgroundColor() != null) { |
935 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.BACKGROUNDCOLOR, HtmlEncoder.encode(table.getBackgroundColor())); |
936 | } | |
937 |
1
1. write : removed call to com/lowagie/text/pdf/OutputStreamCounter::write → NO_COVERAGE |
os.write(GT); |
938 | // contents | |
939 | Row row; | |
940 | for (Iterator iterator = table.iterator(); iterator.hasNext(); ) { | |
941 | row = (Row) iterator.next(); | |
942 |
2
1. write : Replaced integer addition with subtraction → NO_COVERAGE 2. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(row, indent + 1); |
943 | } | |
944 | // end tag | |
945 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::addTabs → NO_COVERAGE |
addTabs(indent); |
946 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeEnd → NO_COVERAGE |
writeEnd(HtmlTags.TABLE); |
947 | return; | |
948 | } | |
949 | case Element.ANNOTATION: | |
950 | { | |
951 | Annotation annotation = (Annotation) element; | |
952 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeComment → NO_COVERAGE |
writeComment(annotation.title() + ": " + annotation.content()); |
953 | return; | |
954 | } | |
955 | case Element.IMGRAW: | |
956 | case Element.JPEG: | |
957 | case Element.JPEG2000: | |
958 | case Element.IMGTEMPLATE: | |
959 | { | |
960 | Image image = (Image) element; | |
961 |
1
1. write : negated conditional → NO_COVERAGE |
if (image.getUrl() == null) { |
962 | return; | |
963 | } | |
964 | | |
965 | // start tag | |
966 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::addTabs → NO_COVERAGE |
addTabs(indent); |
967 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeStart → NO_COVERAGE |
writeStart(HtmlTags.IMAGE); |
968 | String path = image.getUrl().toString(); | |
969 |
1
1. write : negated conditional → NO_COVERAGE |
if (imagepath != null) { |
970 |
2
1. write : changed conditional boundary → NO_COVERAGE 2. write : negated conditional → NO_COVERAGE |
if (path.indexOf('/') > 0) { |
971 |
1
1. write : Replaced integer addition with subtraction → NO_COVERAGE |
path = imagepath + path.substring(path.lastIndexOf('/') + 1); |
972 | } | |
973 | else { | |
974 | path = imagepath + path; | |
975 | } | |
976 | } | |
977 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.URL, path); |
978 |
3
1. write : changed conditional boundary → NO_COVERAGE 2. write : Replaced bitwise AND with OR → NO_COVERAGE 3. write : negated conditional → NO_COVERAGE |
if ((image.getAlignment() & Image.RIGHT) > 0) { |
979 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.ALIGN, HtmlTags.ALIGN_RIGHT); |
980 | } | |
981 |
3
1. write : changed conditional boundary → NO_COVERAGE 2. write : Replaced bitwise AND with OR → NO_COVERAGE 3. write : negated conditional → NO_COVERAGE |
else if ((image.getAlignment() & Image.MIDDLE) > 0) { |
982 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.ALIGN, HtmlTags.ALIGN_MIDDLE); |
983 | } | |
984 | else { | |
985 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.ALIGN, HtmlTags.ALIGN_LEFT); |
986 | } | |
987 |
1
1. write : negated conditional → NO_COVERAGE |
if (image.getAlt() != null) { |
988 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.ALT, image.getAlt()); |
989 | } | |
990 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.PLAINWIDTH, String.valueOf(image.getScaledWidth())); |
991 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.PLAINHEIGHT, String.valueOf(image.getScaledHeight())); |
992 | writeMarkupAttributes(markup); | |
993 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeEnd → NO_COVERAGE |
writeEnd(); |
994 | return; | |
995 | } | |
996 | | |
997 | default: | |
998 | return; | |
999 | } | |
1000 | } | |
1001 | | |
1002 | /** | |
1003 | * Writes the HTML representation of a section. | |
1004 | * | |
1005 | * @param section the section to write | |
1006 | * @param indent the indentation | |
1007 | * @throws IOException | |
1008 | */ | |
1009 | | |
1010 | protected void writeSection(Section section, int indent) throws IOException { | |
1011 |
1
1. writeSection : negated conditional → NO_COVERAGE |
if (section.getTitle() != null) { |
1012 |
1
1. writeSection : Replaced integer subtraction with addition → NO_COVERAGE |
int depth = section.getDepth() - 1; |
1013 |
2
1. writeSection : changed conditional boundary → NO_COVERAGE 2. writeSection : negated conditional → NO_COVERAGE |
if (depth > 5) { |
1014 | depth = 5; | |
1015 | } | |
1016 | Properties styleAttributes = new Properties(); | |
1017 |
1
1. writeSection : negated conditional → NO_COVERAGE |
if (section.getTitle().hasLeading()) styleAttributes.setProperty(Markup.CSS_KEY_LINEHEIGHT, section.getTitle().getTotalLeading() + "pt"); |
1018 | // start tag | |
1019 |
1
1. writeSection : removed call to com/lowagie/text/html/HtmlWriter::addTabs → NO_COVERAGE |
addTabs(indent); |
1020 |
1
1. writeSection : removed call to com/lowagie/text/html/HtmlWriter::writeStart → NO_COVERAGE |
writeStart(HtmlTags.H[depth]); |
1021 |
1
1. writeSection : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(section.getTitle().getFont(), styleAttributes); |
1022 | String alignment = HtmlEncoder.getAlignment(section.getTitle().getAlignment()); | |
1023 |
1
1. writeSection : negated conditional → NO_COVERAGE |
if (!"".equals(alignment)) { |
1024 |
1
1. writeSection : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.ALIGN, alignment); |
1025 | } | |
1026 | writeMarkupAttributes(markup); | |
1027 |
1
1. writeSection : removed call to com/lowagie/text/pdf/OutputStreamCounter::write → NO_COVERAGE |
os.write(GT); |
1028 | currentfont.push(section.getTitle().getFont()); | |
1029 | // contents | |
1030 | for (Object o : section.getTitle()) { | |
1031 |
2
1. writeSection : Replaced integer addition with subtraction → NO_COVERAGE 2. writeSection : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write((Element) o, indent + 1); |
1032 | } | |
1033 | // end tag | |
1034 |
1
1. writeSection : removed call to com/lowagie/text/html/HtmlWriter::addTabs → NO_COVERAGE |
addTabs(indent); |
1035 |
1
1. writeSection : removed call to com/lowagie/text/html/HtmlWriter::writeEnd → NO_COVERAGE |
writeEnd(HtmlTags.H[depth]); |
1036 | currentfont.pop(); | |
1037 | } | |
1038 | for (Object o : section) { | |
1039 |
1
1. writeSection : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write((Element) o, indent); |
1040 | } | |
1041 | } | |
1042 | | |
1043 | /** | |
1044 | * Writes the representation of a <CODE>Font</CODE>. | |
1045 | * | |
1046 | * @param font a <CODE>Font</CODE> | |
1047 | * @param styleAttributes the style of the font | |
1048 | * @throws IOException | |
1049 | */ | |
1050 | | |
1051 | protected void write(Font font, Properties styleAttributes) throws IOException { | |
1052 |
2
1. write : negated conditional → NO_COVERAGE 2. write : negated conditional → NO_COVERAGE |
if (font == null || !isOtherFont(font) /* || styleAttributes == null*/) return; |
1053 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(" "); |
1054 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(HtmlTags.STYLE); |
1055 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write("=\""); |
1056 |
1
1. write : negated conditional → NO_COVERAGE |
if (styleAttributes != null) { |
1057 | String key; | |
1058 |
1
1. write : negated conditional → NO_COVERAGE |
for (Enumeration e = styleAttributes.propertyNames(); e.hasMoreElements(); ) { |
1059 | key = (String)e.nextElement(); | |
1060 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeCssProperty → NO_COVERAGE |
writeCssProperty(key, styleAttributes.getProperty(key)); |
1061 | } | |
1062 | } | |
1063 |
1
1. write : negated conditional → NO_COVERAGE |
if (isOtherFont(font)) { |
1064 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeCssProperty → NO_COVERAGE |
writeCssProperty(Markup.CSS_KEY_FONTFAMILY, font.getFamilyname()); |
1065 | | |
1066 |
1
1. write : negated conditional → NO_COVERAGE |
if (font.getSize() != Font.UNDEFINED) { |
1067 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeCssProperty → NO_COVERAGE |
writeCssProperty(Markup.CSS_KEY_FONTSIZE, font.getSize() + "pt"); |
1068 | } | |
1069 |
1
1. write : negated conditional → NO_COVERAGE |
if (font.getColor() != null) { |
1070 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeCssProperty → NO_COVERAGE |
writeCssProperty(Markup.CSS_KEY_COLOR, HtmlEncoder.encode(font.getColor())); |
1071 | } | |
1072 | | |
1073 | int fontstyle = font.getStyle(); | |
1074 | BaseFont bf = font.getBaseFont(); | |
1075 |
1
1. write : negated conditional → NO_COVERAGE |
if (bf != null) { |
1076 | String ps = bf.getPostscriptFontName().toLowerCase(); | |
1077 |
1
1. write : negated conditional → NO_COVERAGE |
if (ps.contains("bold")) { |
1078 |
1
1. write : negated conditional → NO_COVERAGE |
if (fontstyle == Font.UNDEFINED) |
1079 | fontstyle = 0; | |
1080 |
1
1. write : Replaced bitwise OR with AND → NO_COVERAGE |
fontstyle |= Font.BOLD; |
1081 | } | |
1082 |
2
1. write : negated conditional → NO_COVERAGE 2. write : negated conditional → NO_COVERAGE |
if (ps.contains("italic") || ps.contains("oblique")) { |
1083 |
1
1. write : negated conditional → NO_COVERAGE |
if (fontstyle == Font.UNDEFINED) |
1084 | fontstyle = 0; | |
1085 |
1
1. write : Replaced bitwise OR with AND → NO_COVERAGE |
fontstyle |= Font.ITALIC; |
1086 | } | |
1087 | } | |
1088 |
2
1. write : negated conditional → NO_COVERAGE 2. write : negated conditional → NO_COVERAGE |
if (fontstyle != Font.UNDEFINED && fontstyle != Font.NORMAL) { |
1089 |
1
1. write : Replaced bitwise AND with OR → NO_COVERAGE |
switch (fontstyle & Font.BOLDITALIC) { |
1090 | case Font.BOLD: | |
1091 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeCssProperty → NO_COVERAGE |
writeCssProperty(Markup.CSS_KEY_FONTWEIGHT, Markup.CSS_VALUE_BOLD); |
1092 | break; | |
1093 | case Font.ITALIC: | |
1094 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeCssProperty → NO_COVERAGE |
writeCssProperty(Markup.CSS_KEY_FONTSTYLE, Markup.CSS_VALUE_ITALIC); |
1095 | break; | |
1096 | case Font.BOLDITALIC: | |
1097 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeCssProperty → NO_COVERAGE |
writeCssProperty(Markup.CSS_KEY_FONTWEIGHT, Markup.CSS_VALUE_BOLD); |
1098 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeCssProperty → NO_COVERAGE |
writeCssProperty(Markup.CSS_KEY_FONTSTYLE, Markup.CSS_VALUE_ITALIC); |
1099 | break; | |
1100 | } | |
1101 | | |
1102 | // CSS only supports one decoration tag so if both are specified | |
1103 | // only one of the two will display | |
1104 |
3
1. write : changed conditional boundary → NO_COVERAGE 2. write : Replaced bitwise AND with OR → NO_COVERAGE 3. write : negated conditional → NO_COVERAGE |
if ((fontstyle & Font.UNDERLINE) > 0) { |
1105 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeCssProperty → NO_COVERAGE |
writeCssProperty(Markup.CSS_KEY_TEXTDECORATION, Markup.CSS_VALUE_UNDERLINE); |
1106 | } | |
1107 |
3
1. write : changed conditional boundary → NO_COVERAGE 2. write : Replaced bitwise AND with OR → NO_COVERAGE 3. write : negated conditional → NO_COVERAGE |
if ((fontstyle & Font.STRIKETHRU) > 0) { |
1108 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::writeCssProperty → NO_COVERAGE |
writeCssProperty(Markup.CSS_KEY_TEXTDECORATION, Markup.CSS_VALUE_LINETHROUGH); |
1109 | } | |
1110 | } | |
1111 | } | |
1112 |
1
1. write : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write("\""); |
1113 | } | |
1114 | | |
1115 | /** | |
1116 | * Writes out a CSS property. | |
1117 | * @param prop a CSS property | |
1118 | * @param value the value of the CSS property | |
1119 | * @throws IOException | |
1120 | */ | |
1121 | protected void writeCssProperty(String prop, String value) throws IOException { | |
1122 |
1
1. writeCssProperty : removed call to com/lowagie/text/html/HtmlWriter::write → NO_COVERAGE |
write(new StringBuffer(prop).append(": ").append(value).append("; ").toString()); |
1123 | } | |
1124 | } | |
Mutations | ||
163 |
1.1 |
|
166 |
1.1 |
|
167 |
1.1 |
|
168 |
1.1 |
|
169 |
1.1 |
|
170 |
1.1 |
|
171 |
1.1 |
|
172 |
1.1 |
|
173 |
1.1 |
|
191 |
1.1 |
|
204 |
1.1 |
|
205 |
1.1 |
|
206 |
1.1 |
|
207 |
1.1 |
|
208 |
1.1 |
|
209 |
1.1 |
|
210 |
1.1 |
|
215 |
1.1 |
|
227 |
1.1 |
|
228 |
1.1 |
|
230 |
1.1 2.2 |
|
238 |
1.1 |
|
239 |
1.1 |
|
241 |
1.1 |
|
242 |
1.1 |
|
245 |
1.1 |
|
250 |
1.1 |
|
255 |
1.1 |
|
256 |
1.1 |
|
258 |
1.1 |
|
259 |
1.1 |
|
260 |
1.1 |
|
261 |
1.1 |
|
262 |
1.1 |
|
263 |
1.1 |
|
264 |
1.1 |
|
265 |
1.1 |
|
267 |
1.1 |
|
268 |
1.1 |
|
270 |
1.1 |
|
271 |
1.1 |
|
273 |
1.1 |
|
274 |
1.1 |
|
276 |
1.1 |
|
278 |
1.1 |
|
279 |
1.1 |
|
281 |
1.1 |
|
283 |
1.1 |
|
288 |
1.1 |
|
289 |
1.1 |
|
294 |
1.1 |
|
297 |
1.1 |
|
298 |
1.1 |
|
314 |
1.1 |
|
316 |
1.1 |
|
317 |
1.1 |
|
318 |
1.1 |
|
319 |
1.1 |
|
320 |
1.1 |
|
321 |
1.1 |
|
322 |
1.1 2.2 |
|
323 |
1.1 |
|
325 |
1.1 2.2 |
|
326 |
1.1 |
|
328 |
1.1 2.2 |
|
329 |
1.1 |
|
331 |
1.1 2.2 |
|
332 |
1.1 |
|
334 |
1.1 |
|
335 |
1.1 |
|
337 |
1.1 |
|
338 |
1.1 |
|
340 |
1.1 |
|
341 |
1.1 |
|
343 |
1.1 |
|
344 |
1.1 |
|
346 |
1.1 |
|
347 |
1.1 |
|
361 |
1.1 |
|
362 |
1.1 |
|
363 |
1.1 |
|
364 |
1.1 |
|
365 |
1.1 |
|
366 |
1.1 |
|
380 |
1.1 |
|
395 |
1.1 |
|
399 |
1.1 2.2 |
|
416 |
1.1 |
|
417 |
1.1 |
|
420 |
1.1 |
|
423 |
1.1 |
|
426 |
1.1 |
|
429 |
1.1 |
|
432 |
1.1 |
|
433 |
1.1 |
|
444 |
1.1 |
|
445 |
1.1 |
|
446 |
1.1 |
|
447 |
1.1 |
|
448 |
1.1 |
|
449 |
1.1 |
|
460 |
1.1 |
|
461 |
1.1 |
|
462 |
1.1 |
|
463 |
1.1 2.2 |
|
469 |
1.1 |
|
470 |
1.1 |
|
481 |
1.1 |
|
482 |
1.1 |
|
483 |
1.1 |
|
484 |
1.1 |
|
485 |
1.1 |
|
486 |
1.1 |
|
487 |
1.1 |
|
488 |
1.1 |
|
489 |
1.1 |
|
503 |
1.1 |
|
504 |
1.1 |
|
505 |
1.1 |
|
506 |
1.1 |
|
531 |
1.1 2.2 |
|
534 |
1.1 2.2 |
|
590 |
1.1 |
|
591 |
1.1 |
|
595 |
1.1 |
|
596 |
1.1 |
|
618 |
1.1 |
|
627 |
1.1 |
|
628 |
1.1 |
|
632 |
1.1 |
|
634 |
1.1 2.2 |
|
637 |
1.1 2.2 3.3 |
|
638 |
1.1 |
|
640 |
1.1 |
|
641 |
1.1 |
|
642 |
1.1 |
|
643 |
1.1 |
|
646 |
1.1 |
|
648 |
1.1 2.2 |
|
650 |
1.1 2.2 |
|
651 |
1.1 |
|
654 |
1.1 |
|
656 |
1.1 |
|
659 |
1.1 |
|
660 |
1.1 2.2 |
|
662 |
1.1 |
|
663 |
1.1 |
|
664 |
1.1 2.2 |
|
665 |
1.1 |
|
668 |
1.1 |
|
670 |
1.1 |
|
672 |
1.1 |
|
674 |
1.1 |
|
682 |
1.1 |
|
685 |
1.1 |
|
686 |
1.1 |
|
688 |
1.1 |
|
689 |
1.1 |
|
693 |
1.1 2.2 |
|
696 |
1.1 |
|
697 |
1.1 |
|
705 |
1.1 |
|
708 |
1.1 |
|
709 |
1.1 |
|
710 |
1.1 |
|
711 |
1.1 |
|
713 |
1.1 |
|
714 |
1.1 |
|
717 |
1.1 |
|
718 |
1.1 |
|
722 |
1.1 2.2 |
|
725 |
1.1 |
|
726 |
1.1 |
|
734 |
1.1 |
|
736 |
1.1 |
|
737 |
1.1 |
|
740 |
1.1 |
|
741 |
1.1 |
|
743 |
1.1 |
|
744 |
1.1 |
|
748 |
1.1 2.2 |
|
751 |
1.1 |
|
752 |
1.1 |
|
760 |
1.1 |
|
767 |
1.1 |
|
768 |
1.1 |
|
769 |
1.1 |
|
772 |
1.1 |
|
775 |
1.1 |
|
778 |
1.1 2.2 |
|
781 |
1.1 |
|
782 |
1.1 |
|
783 |
1.1 |
|
786 |
1.1 |
|
794 |
1.1 |
|
797 |
1.1 |
|
798 |
1.1 |
|
800 |
1.1 |
|
801 |
1.1 |
|
805 |
1.1 2.2 |
|
808 |
1.1 |
|
809 |
1.1 |
|
818 |
1.1 |
|
819 |
1.1 |
|
820 |
1.1 |
|
823 |
1.1 |
|
826 |
1.1 |
|
827 |
1.1 |
|
829 |
1.1 |
|
830 |
1.1 |
|
832 |
1.1 |
|
833 |
1.1 |
|
836 |
1.1 |
|
837 |
1.1 |
|
840 |
1.1 |
|
841 |
1.1 |
|
843 |
1.1 |
|
844 |
1.1 |
|
846 |
1.1 |
|
847 |
1.1 |
|
849 |
1.1 |
|
850 |
1.1 |
|
852 |
1.1 |
|
853 |
1.1 |
|
855 |
1.1 |
|
857 |
1.1 |
|
858 |
1.1 |
|
861 |
1.1 2.2 |
|
865 |
1.1 |
|
866 |
1.1 |
|
867 |
1.1 |
|
870 |
1.1 |
|
879 |
1.1 |
|
880 |
1.1 |
|
882 |
1.1 |
|
885 |
1.1 2.2 |
|
886 |
1.1 |
|
887 |
1.1 2.2 |
|
891 |
1.1 |
|
892 |
1.1 |
|
908 |
1.1 |
|
910 |
1.1 |
|
911 |
1.1 |
|
913 |
1.1 |
|
914 |
1.1 |
|
915 |
1.1 |
|
916 |
1.1 |
|
917 |
1.1 |
|
918 |
1.1 |
|
919 |
1.1 |
|
921 |
1.1 |
|
923 |
1.1 |
|
924 |
1.1 |
|
926 |
1.1 |
|
927 |
1.1 |
|
928 |
1.1 |
|
929 |
1.1 |
|
931 |
1.1 |
|
932 |
1.1 |
|
934 |
1.1 |
|
935 |
1.1 |
|
937 |
1.1 |
|
942 |
1.1 2.2 |
|
945 |
1.1 |
|
946 |
1.1 |
|
952 |
1.1 |
|
961 |
1.1 |
|
966 |
1.1 |
|
967 |
1.1 |
|
969 |
1.1 |
|
970 |
1.1 2.2 |
|
971 |
1.1 |
|
977 |
1.1 |
|
978 |
1.1 2.2 3.3 |
|
979 |
1.1 |
|
981 |
1.1 2.2 3.3 |
|
982 |
1.1 |
|
985 |
1.1 |
|
987 |
1.1 |
|
988 |
1.1 |
|
990 |
1.1 |
|
991 |
1.1 |
|
993 |
1.1 |
|
1011 |
1.1 |
|
1012 |
1.1 |
|
1013 |
1.1 2.2 |
|
1017 |
1.1 |
|
1019 |
1.1 |
|
1020 |
1.1 |
|
1021 |
1.1 |
|
1023 |
1.1 |
|
1024 |
1.1 |
|
1027 |
1.1 |
|
1031 |
1.1 2.2 |
|
1034 |
1.1 |
|
1035 |
1.1 |
|
1039 |
1.1 |
|
1052 |
1.1 2.2 |
|
1053 |
1.1 |
|
1054 |
1.1 |
|
1055 |
1.1 |
|
1056 |
1.1 |
|
1058 |
1.1 |
|
1060 |
1.1 |
|
1063 |
1.1 |
|
1064 |
1.1 |
|
1066 |
1.1 |
|
1067 |
1.1 |
|
1069 |
1.1 |
|
1070 |
1.1 |
|
1075 |
1.1 |
|
1077 |
1.1 |
|
1078 |
1.1 |
|
1080 |
1.1 |
|
1082 |
1.1 2.2 |
|
1083 |
1.1 |
|
1085 |
1.1 |
|
1088 |
1.1 2.2 |
|
1089 |
1.1 |
|
1091 |
1.1 |
|
1094 |
1.1 |
|
1097 |
1.1 |
|
1098 |
1.1 |
|
1104 |
1.1 2.2 3.3 |
|
1105 |
1.1 |
|
1107 |
1.1 2.2 3.3 |
|
1108 |
1.1 |
|
1112 |
1.1 |
|
1122 |
1.1 |