1 | /* | |
2 | * $Id: PdfDocument.java 4098 2009-11-16 13:27:45Z blowagie $ | |
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.pdf; | |
51 | ||
52 | import com.lowagie.text.*; | |
53 | import com.lowagie.text.Font; | |
54 | import com.lowagie.text.Image; | |
55 | import com.lowagie.text.List; | |
56 | import com.lowagie.text.Rectangle; | |
57 | import com.lowagie.text.error_messages.MessageLocalization; | |
58 | import com.lowagie.text.pdf.collection.PdfCollection; | |
59 | import com.lowagie.text.pdf.draw.DrawInterface; | |
60 | import com.lowagie.text.pdf.internal.PdfAnnotationsImp; | |
61 | import com.lowagie.text.pdf.internal.PdfViewerPreferencesImp; | |
62 | ||
63 | import java.awt.*; | |
64 | import java.io.IOException; | |
65 | import java.text.DecimalFormat; | |
66 | import java.util.*; | |
67 | ||
68 | ||
69 | /** | |
70 | * <CODE>PdfDocument</CODE> is the class that is used by <CODE>PdfWriter</CODE> | |
71 | * to translate a <CODE>Document</CODE> into a PDF with different pages. | |
72 | * <P> | |
73 | * A <CODE>PdfDocument</CODE> always listens to a <CODE>Document</CODE> | |
74 | * and adds the Pdf representation of every <CODE>Element</CODE> that is | |
75 | * added to the <CODE>Document</CODE>. | |
76 | * | |
77 | * @see com.lowagie.text.Document | |
78 | * @see com.lowagie.text.DocListener | |
79 | * @see PdfWriter | |
80 | * @since 2.0.8 (class was package-private before) | |
81 | */ | |
82 | ||
83 | public class PdfDocument extends Document { | |
84 | ||
85 | /** | |
86 | * <CODE>PdfInfo</CODE> is the PDF InfoDictionary. | |
87 | * <P> | |
88 | * A document's trailer may contain a reference to an Info dictionary that provides information | |
89 | * about the document. This optional dictionary may contain one or more keys, whose values | |
90 | * should be strings.<BR> | |
91 | * This object is described in the 'Portable Document Format Reference Manual version 1.3' | |
92 | * section 6.10 (page 120-121) | |
93 | * @since 2.0.8 (PdfDocument was package-private before) | |
94 | */ | |
95 | ||
96 | public static class PdfInfo extends PdfDictionary { | |
97 | ||
98 | /** | |
99 | * Construct a <CODE>PdfInfo</CODE>-object. | |
100 | */ | |
101 | ||
102 | PdfInfo() { | |
103 | super(); | |
104 |
1
1. |
addProducer(); |
105 |
1
1. |
addCreationDate(); |
106 | } | |
107 | ||
108 | /** | |
109 | * Constructs a <CODE>PdfInfo</CODE>-object. | |
110 | * | |
111 | * @param author name of the author of the document | |
112 | * @param title title of the document | |
113 | * @param subject subject of the document | |
114 | */ | |
115 | ||
116 | PdfInfo(String author, String title, String subject) { | |
117 | this(); | |
118 |
1
1. |
addTitle(title); |
119 |
1
1. |
addSubject(subject); |
120 |
1
1. |
addAuthor(author); |
121 | } | |
122 | ||
123 | /** | |
124 | * Adds the title of the document. | |
125 | * | |
126 | * @param title the title of the document | |
127 | */ | |
128 | ||
129 | void addTitle(String title) { | |
130 |
1
1. addTitle : removed call to com/lowagie/text/pdf/PdfDocument$PdfInfo::put → NO_COVERAGE |
put(PdfName.TITLE, new PdfString(title, PdfObject.TEXT_UNICODE)); |
131 | } | |
132 | ||
133 | /** | |
134 | * Adds the subject to the document. | |
135 | * | |
136 | * @param subject the subject of the document | |
137 | */ | |
138 | ||
139 | void addSubject(String subject) { | |
140 |
1
1. addSubject : removed call to com/lowagie/text/pdf/PdfDocument$PdfInfo::put → NO_COVERAGE |
put(PdfName.SUBJECT, new PdfString(subject, PdfObject.TEXT_UNICODE)); |
141 | } | |
142 | ||
143 | /** | |
144 | * Adds some keywords to the document. | |
145 | * | |
146 | * @param keywords the keywords of the document | |
147 | */ | |
148 | ||
149 | void addKeywords(String keywords) { | |
150 |
1
1. addKeywords : removed call to com/lowagie/text/pdf/PdfDocument$PdfInfo::put → NO_COVERAGE |
put(PdfName.KEYWORDS, new PdfString(keywords, PdfObject.TEXT_UNICODE)); |
151 | } | |
152 | ||
153 | /** | |
154 | * Adds the name of the author to the document. | |
155 | * | |
156 | * @param author the name of the author | |
157 | */ | |
158 | ||
159 | void addAuthor(String author) { | |
160 |
1
1. addAuthor : removed call to com/lowagie/text/pdf/PdfDocument$PdfInfo::put → NO_COVERAGE |
put(PdfName.AUTHOR, new PdfString(author, PdfObject.TEXT_UNICODE)); |
161 | } | |
162 | ||
163 | /** | |
164 | * Adds the name of the creator to the document. | |
165 | * | |
166 | * @param creator the name of the creator | |
167 | */ | |
168 | ||
169 | void addCreator(String creator) { | |
170 |
1
1. addCreator : removed call to com/lowagie/text/pdf/PdfDocument$PdfInfo::put → NO_COVERAGE |
put(PdfName.CREATOR, new PdfString(creator, PdfObject.TEXT_UNICODE)); |
171 | } | |
172 | ||
173 | /** | |
174 | * Adds the name of the producer to the document. | |
175 | */ | |
176 | void addProducer() { | |
177 |
1
1. addProducer : removed call to com/lowagie/text/pdf/PdfDocument$PdfInfo::addProducer → NO_COVERAGE |
addProducer(getVersion()); |
178 | } | |
179 | ||
180 | /** | |
181 | * Adds the name of the producer to the document. | |
182 | */ | |
183 | void addProducer(final String producer) { | |
184 |
1
1. addProducer : removed call to com/lowagie/text/pdf/PdfDocument$PdfInfo::put → NO_COVERAGE |
put(PdfName.PRODUCER, new PdfString(producer)); |
185 | } | |
186 | ||
187 | /** | |
188 | * Adds the date of creation to the document. | |
189 | */ | |
190 | ||
191 | void addCreationDate() { | |
192 | PdfString date = new PdfDate(); | |
193 |
1
1. addCreationDate : removed call to com/lowagie/text/pdf/PdfDocument$PdfInfo::put → NO_COVERAGE |
put(PdfName.CREATIONDATE, date); |
194 |
1
1. addCreationDate : removed call to com/lowagie/text/pdf/PdfDocument$PdfInfo::put → NO_COVERAGE |
put(PdfName.MODDATE, date); |
195 | } | |
196 | ||
197 | void addkey(String key, String value) { | |
198 |
2
1. addkey : negated conditional → NO_COVERAGE 2. addkey : negated conditional → NO_COVERAGE |
if (key.equals("Producer") || key.equals("CreationDate")) |
199 | return; | |
200 |
1
1. addkey : removed call to com/lowagie/text/pdf/PdfDocument$PdfInfo::put → NO_COVERAGE |
put(new PdfName(key), new PdfString(value, PdfObject.TEXT_UNICODE)); |
201 | } | |
202 | } | |
203 | ||
204 | /** | |
205 | * <CODE>PdfCatalog</CODE> is the PDF Catalog-object. | |
206 | * <P> | |
207 | * The Catalog is a dictionary that is the root node of the document. It contains a reference | |
208 | * to the tree of pages contained in the document, a reference to the tree of objects representing | |
209 | * the document's outline, a reference to the document's article threads, and the list of named | |
210 | * destinations. In addition, the Catalog indicates whether the document's outline or thumbnail | |
211 | * page images should be displayed automatically when the document is viewed and whether some location | |
212 | * other than the first page should be shown when the document is opened.<BR> | |
213 | * In this class however, only the reference to the tree of pages is implemented.<BR> | |
214 | * This object is described in the 'Portable Document Format Reference Manual version 1.3' | |
215 | * section 6.2 (page 67-71) | |
216 | */ | |
217 | ||
218 | static class PdfCatalog extends PdfDictionary { | |
219 | ||
220 | /** The writer writing the PDF for which we are creating this catalog object. */ | |
221 | PdfWriter writer; | |
222 | ||
223 | /** | |
224 | * Constructs a <CODE>PdfCatalog</CODE>. | |
225 | * | |
226 | * @param pages an indirect reference to the root of the document's Pages tree. | |
227 | * @param writer the writer the catalog applies to | |
228 | */ | |
229 | ||
230 | PdfCatalog(PdfIndirectReference pages, PdfWriter writer) { | |
231 | super(CATALOG); | |
232 | this.writer = writer; | |
233 |
1
1. |
put(PdfName.PAGES, pages); |
234 | } | |
235 | ||
236 | /** | |
237 | * Adds the names of the named destinations to the catalog. | |
238 | * @param localDestinations the local destinations | |
239 | * @param documentLevelJS the javascript used in the document | |
240 | * @param documentFileAttachment the attached files | |
241 | * @param writer the writer the catalog applies to | |
242 | */ | |
243 | void addNames(TreeMap<String, Object[]> localDestinations, HashMap<String, PdfIndirectReference> documentLevelJS, HashMap<String, PdfIndirectReference> documentFileAttachment, PdfWriter writer) { | |
244 |
3
1. addNames : negated conditional → NO_COVERAGE 2. addNames : negated conditional → NO_COVERAGE 3. addNames : negated conditional → NO_COVERAGE |
if (localDestinations.isEmpty() && documentLevelJS.isEmpty() && documentFileAttachment.isEmpty()) |
245 | return; | |
246 | try { | |
247 | PdfDictionary names = new PdfDictionary(); | |
248 |
1
1. addNames : negated conditional → NO_COVERAGE |
if (!localDestinations.isEmpty()) { |
249 | PdfArray ar = new PdfArray(); | |
250 | for (Map.Entry<String, Object[]> entry : localDestinations.entrySet()) { | |
251 | String name = entry.getKey(); | |
252 | Object[] obj = entry.getValue(); | |
253 |
1
1. addNames : negated conditional → NO_COVERAGE |
if (obj[2] == null) //no destination |
254 | continue; | |
255 | PdfIndirectReference ref = (PdfIndirectReference) obj[1]; | |
256 | ar.add(new PdfString(name, null)); | |
257 | ar.add(ref); | |
258 | } | |
259 |
2
1. addNames : changed conditional boundary → NO_COVERAGE 2. addNames : negated conditional → NO_COVERAGE |
if (ar.size() > 0) { |
260 | PdfDictionary dests = new PdfDictionary(); | |
261 |
1
1. addNames : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
dests.put(PdfName.NAMES, ar); |
262 |
1
1. addNames : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
names.put(PdfName.DESTS, writer.addToBody(dests).getIndirectReference()); |
263 | } | |
264 | } | |
265 |
1
1. addNames : negated conditional → NO_COVERAGE |
if (!documentLevelJS.isEmpty()) { |
266 | PdfDictionary tree = PdfNameTree.writeTree(documentLevelJS, writer); | |
267 |
1
1. addNames : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
names.put(PdfName.JAVASCRIPT, writer.addToBody(tree).getIndirectReference()); |
268 | } | |
269 |
1
1. addNames : negated conditional → NO_COVERAGE |
if (!documentFileAttachment.isEmpty()) { |
270 |
1
1. addNames : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
names.put(PdfName.EMBEDDEDFILES, writer.addToBody(PdfNameTree.writeTree(documentFileAttachment, writer)).getIndirectReference()); |
271 | } | |
272 |
2
1. addNames : changed conditional boundary → NO_COVERAGE 2. addNames : negated conditional → NO_COVERAGE |
if (names.size() > 0) |
273 |
1
1. addNames : removed call to com/lowagie/text/pdf/PdfDocument$PdfCatalog::put → NO_COVERAGE |
put(PdfName.NAMES, writer.addToBody(names).getIndirectReference()); |
274 | } | |
275 | catch (IOException e) { | |
276 | throw new ExceptionConverter(e); | |
277 | } | |
278 | } | |
279 | ||
280 | /** | |
281 | * Adds an open action to the catalog. | |
282 | * @param action the action that will be triggered upon opening the document | |
283 | */ | |
284 | void setOpenAction(PdfAction action) { | |
285 |
1
1. setOpenAction : removed call to com/lowagie/text/pdf/PdfDocument$PdfCatalog::put → NO_COVERAGE |
put(PdfName.OPENACTION, action); |
286 | } | |
287 | ||
288 | ||
289 | /** | |
290 | * Sets the document level additional actions. | |
291 | * @param actions dictionary of actions | |
292 | */ | |
293 | void setAdditionalActions(PdfDictionary actions) { | |
294 | try { | |
295 |
1
1. setAdditionalActions : removed call to com/lowagie/text/pdf/PdfDocument$PdfCatalog::put → NO_COVERAGE |
put(PdfName.AA, writer.addToBody(actions).getIndirectReference()); |
296 | } catch (Exception e) { | |
297 | throw new ExceptionConverter(e); | |
298 | } | |
299 | } | |
300 | } | |
301 | ||
302 | // CONSTRUCTING A PdfDocument/PdfWriter INSTANCE | |
303 | ||
304 | /** | |
305 | * Constructs a new PDF document. | |
306 | */ | |
307 | public PdfDocument() { | |
308 | super(); | |
309 | addProducer(); | |
310 | addCreationDate(); | |
311 | } | |
312 | ||
313 | /** The <CODE>PdfWriter</CODE>. */ | |
314 | protected PdfWriter writer; | |
315 | ||
316 | /** | |
317 | * Adds a <CODE>PdfWriter</CODE> to the <CODE>PdfDocument</CODE>. | |
318 | * | |
319 | * @param writer the <CODE>PdfWriter</CODE> that writes everything | |
320 | * what is added to this document to an outputstream. | |
321 | * @throws DocumentException on error | |
322 | */ | |
323 | public void addWriter(PdfWriter writer) throws DocumentException { | |
324 |
1
1. addWriter : negated conditional → NO_COVERAGE |
if (this.writer == null) { |
325 | this.writer = writer; | |
326 | annotationsImp = new PdfAnnotationsImp(writer); | |
327 | return; | |
328 | } | |
329 | throw new DocumentException(MessageLocalization.getComposedMessage("you.can.only.add.a.writer.to.a.pdfdocument.once")); | |
330 | } | |
331 | ||
332 | // LISTENER METHODS START | |
333 | ||
334 | // [L0] ElementListener interface | |
335 | ||
336 | /** This is the PdfContentByte object, containing the text. */ | |
337 | protected PdfContentByte text; | |
338 | ||
339 | /** This is the PdfContentByte object, containing the borders and other Graphics. */ | |
340 | protected PdfContentByte graphics; | |
341 | ||
342 | /** This represents the leading of the lines. */ | |
343 | protected float leading = 0; | |
344 | ||
345 | /** | |
346 | * Getter for the current leading. | |
347 | * @return the current leading | |
348 | * @since 2.1.2 | |
349 | */ | |
350 | public float getLeading() { | |
351 | return leading; | |
352 | } | |
353 | ||
354 | /** | |
355 | * Setter for the current leading. | |
356 | * @param leading the current leading | |
357 | * @since 2.1.6 | |
358 | */ | |
359 | void setLeading(float leading) { | |
360 | this.leading = leading; | |
361 | } | |
362 | ||
363 | /** This represents the current alignment of the PDF Elements. */ | |
364 | protected int alignment = Element.ALIGN_LEFT; | |
365 | ||
366 | /** This is the current height of the document. */ | |
367 | protected float currentHeight = 0; | |
368 | ||
369 | /** | |
370 | * Signals that onParagraph is valid (to avoid that a Chapter/Section title is treated as a Paragraph). | |
371 | * @since 2.1.2 | |
372 | */ | |
373 | protected boolean isSectionTitle = false; | |
374 | ||
375 | /** | |
376 | * Signals that the current leading has to be subtracted from a YMark object when positive. | |
377 | * @since 2.1.2 | |
378 | */ | |
379 | protected int leadingCount = 0; | |
380 | ||
381 | /** The current active <CODE>PdfAction</CODE> when processing an <CODE>Anchor</CODE>. */ | |
382 | protected PdfAction anchorAction = null; | |
383 | ||
384 | /** | |
385 | * Signals that an <CODE>Element</CODE> was added to the <CODE>Document</CODE>. | |
386 | * | |
387 | * @param element the element to add | |
388 | * @return <CODE>true</CODE> if the element was added, <CODE>false</CODE> if not. | |
389 | * @throws DocumentException when a document isn't open yet, or has been closed | |
390 | */ | |
391 | public boolean add(Element element) throws DocumentException { | |
392 |
2
1. add : negated conditional → NO_COVERAGE 2. add : negated conditional → NO_COVERAGE |
if (writer != null && writer.isPaused()) { |
393 |
1
1. add : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
394 | } | |
395 | try { | |
396 | switch(element.type()) { | |
397 | // Information (headers) | |
398 | case Element.HEADER: | |
399 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument$PdfInfo::addkey → NO_COVERAGE |
info.addkey(((Meta)element).getName(), ((Meta)element).getContent()); |
400 | break; | |
401 | case Element.TITLE: | |
402 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument$PdfInfo::addTitle → NO_COVERAGE |
info.addTitle(((Meta)element).getContent()); |
403 | break; | |
404 | case Element.SUBJECT: | |
405 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument$PdfInfo::addSubject → NO_COVERAGE |
info.addSubject(((Meta)element).getContent()); |
406 | break; | |
407 | case Element.KEYWORDS: | |
408 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument$PdfInfo::addKeywords → NO_COVERAGE |
info.addKeywords(((Meta)element).getContent()); |
409 | break; | |
410 | case Element.AUTHOR: | |
411 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument$PdfInfo::addAuthor → NO_COVERAGE |
info.addAuthor(((Meta)element).getContent()); |
412 | break; | |
413 | case Element.CREATOR: | |
414 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument$PdfInfo::addCreator → NO_COVERAGE |
info.addCreator(((Meta)element).getContent()); |
415 | break; | |
416 | case Element.PRODUCER: | |
417 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument$PdfInfo::addProducer → NO_COVERAGE |
info.addProducer(((Meta) element).getContent()); |
418 | break; | |
419 | case Element.CREATIONDATE: | |
420 | // you can not set the creation date, only reset it | |
421 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument$PdfInfo::addCreationDate → NO_COVERAGE |
info.addCreationDate(); |
422 | break; | |
423 | ||
424 | // content (text) | |
425 | case Element.CHUNK: { | |
426 | // if there isn't a current line available, we make one | |
427 |
1
1. add : negated conditional → NO_COVERAGE |
if (line == null) { |
428 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument::carriageReturn → NO_COVERAGE |
carriageReturn(); |
429 | } | |
430 | ||
431 | // we cast the element to a chunk | |
432 | PdfChunk chunk = new PdfChunk((Chunk) element, anchorAction); | |
433 | // we try to add the chunk to the line, until we succeed | |
434 | { | |
435 | PdfChunk overflow; | |
436 |
1
1. add : negated conditional → NO_COVERAGE |
while ((overflow = line.add(chunk)) != null) { |
437 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument::carriageReturn → NO_COVERAGE |
carriageReturn(); |
438 | chunk = overflow; | |
439 | chunk.trimFirstSpace(); | |
440 | } | |
441 | } | |
442 | pageEmpty = false; | |
443 |
1
1. add : negated conditional → NO_COVERAGE |
if (chunk.isAttribute(Chunk.NEWPAGE)) { |
444 | newPage(); | |
445 | } | |
446 | break; | |
447 | } | |
448 | case Element.ANCHOR: { | |
449 |
1
1. add : Replaced integer addition with subtraction → NO_COVERAGE |
leadingCount++; |
450 | Anchor anchor = (Anchor) element; | |
451 | String url = anchor.getReference(); | |
452 | leading = anchor.getLeading(); | |
453 |
1
1. add : negated conditional → NO_COVERAGE |
if (url != null) { |
454 | anchorAction = new PdfAction(url); | |
455 | } | |
456 | // we process the element | |
457 | element.process(this); | |
458 | anchorAction = null; | |
459 |
1
1. add : Replaced integer subtraction with addition → NO_COVERAGE |
leadingCount--; |
460 | break; | |
461 | } | |
462 | case Element.ANNOTATION: { | |
463 |
1
1. add : negated conditional → NO_COVERAGE |
if (line == null) { |
464 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument::carriageReturn → NO_COVERAGE |
carriageReturn(); |
465 | } | |
466 | Annotation annot = (Annotation) element; | |
467 | Rectangle rect = new Rectangle(0, 0); | |
468 |
1
1. add : negated conditional → NO_COVERAGE |
if (line != null) |
469 |
6
1. add : Replaced float subtraction with addition → NO_COVERAGE 2. add : Replaced float subtraction with addition → NO_COVERAGE 3. add : Replaced float subtraction with addition → NO_COVERAGE 4. add : Replaced float subtraction with addition → NO_COVERAGE 5. add : Replaced float addition with subtraction → NO_COVERAGE 6. add : Replaced float subtraction with addition → NO_COVERAGE |
rect = new Rectangle(annot.llx(indentRight() - line.widthLeft()), annot.ury(indentTop() - currentHeight - 20), annot.urx(indentRight() - line.widthLeft() + 20), annot.lly(indentTop() - currentHeight)); |
470 | PdfAnnotation an = PdfAnnotationsImp.convertAnnotation(writer, annot, rect); | |
471 |
1
1. add : removed call to com/lowagie/text/pdf/internal/PdfAnnotationsImp::addPlainAnnotation → NO_COVERAGE |
annotationsImp.addPlainAnnotation(an); |
472 | pageEmpty = false; | |
473 | break; | |
474 | } | |
475 | case Element.PHRASE: { | |
476 |
1
1. add : Replaced integer addition with subtraction → NO_COVERAGE |
leadingCount++; |
477 | // we cast the element to a phrase and set the leading of the document | |
478 | leading = ((Phrase) element).getLeading(); | |
479 | // we process the element | |
480 | element.process(this); | |
481 |
1
1. add : Replaced integer subtraction with addition → NO_COVERAGE |
leadingCount--; |
482 | break; | |
483 | } | |
484 | case Element.PARAGRAPH: { | |
485 |
1
1. add : Replaced integer addition with subtraction → NO_COVERAGE |
leadingCount++; |
486 | // we cast the element to a paragraph | |
487 | Paragraph paragraph = (Paragraph) element; | |
488 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument::addSpacing → NO_COVERAGE |
addSpacing(paragraph.getSpacingBefore(), leading, paragraph.getFont()); |
489 | ||
490 | // we adjust the parameters of the document | |
491 | alignment = paragraph.getAlignment(); | |
492 | leading = paragraph.getTotalLeading(); | |
493 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument::carriageReturn → NO_COVERAGE |
carriageReturn(); |
494 | ||
495 | // we don't want to make orphans/widows | |
496 |
5
1. add : changed conditional boundary → NO_COVERAGE 2. add : Replaced float addition with subtraction → NO_COVERAGE 3. add : Replaced float addition with subtraction → NO_COVERAGE 4. add : Replaced float subtraction with addition → NO_COVERAGE 5. add : negated conditional → NO_COVERAGE |
if (currentHeight + line.height() + leading > indentTop() - indentBottom()) { |
497 | newPage(); | |
498 | } | |
499 |
1
1. add : Replaced float addition with subtraction → NO_COVERAGE |
indentation.indentLeft += paragraph.getIndentationLeft(); |
500 |
1
1. add : Replaced float addition with subtraction → NO_COVERAGE |
indentation.indentRight += paragraph.getIndentationRight(); |
501 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument::carriageReturn → NO_COVERAGE |
carriageReturn(); |
502 | ||
503 | PdfPageEvent pageEvent = writer.getPageEvent(); | |
504 |
2
1. add : negated conditional → NO_COVERAGE 2. add : negated conditional → NO_COVERAGE |
if (pageEvent != null && !isSectionTitle) |
505 |
2
1. add : Replaced float subtraction with addition → NO_COVERAGE 2. add : removed call to com/lowagie/text/pdf/PdfPageEvent::onParagraph → NO_COVERAGE |
pageEvent.onParagraph(writer, this, indentTop() - currentHeight); |
506 | ||
507 | // if a paragraph has to be kept together, we wrap it in a table object | |
508 |
1
1. add : negated conditional → NO_COVERAGE |
if (paragraph.getKeepTogether()) { |
509 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument::carriageReturn → NO_COVERAGE |
carriageReturn(); |
510 | PdfPTable table = new PdfPTable(1); | |
511 |
1
1. add : removed call to com/lowagie/text/pdf/PdfPTable::setWidthPercentage → NO_COVERAGE |
table.setWidthPercentage(100f); |
512 | PdfPCell cell = new PdfPCell(); | |
513 |
1
1. add : removed call to com/lowagie/text/pdf/PdfPCell::addElement → NO_COVERAGE |
cell.addElement(paragraph); |
514 |
1
1. add : removed call to com/lowagie/text/pdf/PdfPCell::setBorder → NO_COVERAGE |
cell.setBorder(Table.NO_BORDER); |
515 |
1
1. add : removed call to com/lowagie/text/pdf/PdfPCell::setPadding → NO_COVERAGE |
cell.setPadding(0); |
516 |
1
1. add : removed call to com/lowagie/text/pdf/PdfPTable::addCell → NO_COVERAGE |
table.addCell(cell); |
517 |
1
1. add : Replaced float subtraction with addition → NO_COVERAGE |
indentation.indentLeft -= paragraph.getIndentationLeft(); |
518 |
1
1. add : Replaced float subtraction with addition → NO_COVERAGE |
indentation.indentRight -= paragraph.getIndentationRight(); |
519 | this.add(table); | |
520 |
1
1. add : Replaced float addition with subtraction → NO_COVERAGE |
indentation.indentLeft += paragraph.getIndentationLeft(); |
521 |
1
1. add : Replaced float addition with subtraction → NO_COVERAGE |
indentation.indentRight += paragraph.getIndentationRight(); |
522 | } | |
523 | else { | |
524 |
1
1. add : removed call to com/lowagie/text/pdf/PdfLine::setExtraIndent → NO_COVERAGE |
line.setExtraIndent(paragraph.getFirstLineIndent()); |
525 | element.process(this); | |
526 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument::carriageReturn → NO_COVERAGE |
carriageReturn(); |
527 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument::addSpacing → NO_COVERAGE |
addSpacing(paragraph.getSpacingAfter(), paragraph.getTotalLeading(), paragraph.getFont()); |
528 | } | |
529 | ||
530 |
2
1. add : negated conditional → NO_COVERAGE 2. add : negated conditional → NO_COVERAGE |
if (pageEvent != null && !isSectionTitle) |
531 |
2
1. add : Replaced float subtraction with addition → NO_COVERAGE 2. add : removed call to com/lowagie/text/pdf/PdfPageEvent::onParagraphEnd → NO_COVERAGE |
pageEvent.onParagraphEnd(writer, this, indentTop() - currentHeight); |
532 | ||
533 | alignment = Element.ALIGN_LEFT; | |
534 |
1
1. add : Replaced float subtraction with addition → NO_COVERAGE |
indentation.indentLeft -= paragraph.getIndentationLeft(); |
535 |
1
1. add : Replaced float subtraction with addition → NO_COVERAGE |
indentation.indentRight -= paragraph.getIndentationRight(); |
536 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument::carriageReturn → NO_COVERAGE |
carriageReturn(); |
537 |
1
1. add : Replaced integer subtraction with addition → NO_COVERAGE |
leadingCount--; |
538 | break; | |
539 | } | |
540 | case Element.SECTION: | |
541 | case Element.CHAPTER: { | |
542 | // Chapters and Sections only differ in their constructor | |
543 | // so we cast both to a Section | |
544 | Section section = (Section) element; | |
545 | PdfPageEvent pageEvent = writer.getPageEvent(); | |
546 | ||
547 |
1
1. add : negated conditional → NO_COVERAGE |
boolean hasTitle = section.isNotAddedYet() |
548 |
1
1. add : negated conditional → NO_COVERAGE |
&& section.getTitle() != null; |
549 | ||
550 | // if the section is a chapter, we begin a new page | |
551 |
1
1. add : negated conditional → NO_COVERAGE |
if (section.isTriggerNewPage()) { |
552 | newPage(); | |
553 | } | |
554 | ||
555 |
1
1. add : negated conditional → NO_COVERAGE |
if (hasTitle) { |
556 |
1
1. add : Replaced float subtraction with addition → NO_COVERAGE |
float fith = indentTop() - currentHeight; |
557 | int rotation = pageSize.getRotation(); | |
558 |
2
1. add : negated conditional → NO_COVERAGE 2. add : negated conditional → NO_COVERAGE |
if (rotation == 90 || rotation == 180) |
559 |
1
1. add : Replaced float subtraction with addition → NO_COVERAGE |
fith = pageSize.getHeight() - fith; |
560 | PdfDestination destination = new PdfDestination(PdfDestination.FITH, fith); | |
561 |
2
1. add : changed conditional boundary → NO_COVERAGE 2. add : negated conditional → NO_COVERAGE |
while (currentOutline.level() >= section.getDepth()) { |
562 | currentOutline = currentOutline.parent(); | |
563 | } | |
564 | PdfOutline outline = new PdfOutline(currentOutline, destination, section.getBookmarkTitle(), section.isBookmarkOpen()); | |
565 | currentOutline = outline; | |
566 | } | |
567 | ||
568 | // some values are set | |
569 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument::carriageReturn → NO_COVERAGE |
carriageReturn(); |
570 |
1
1. add : Replaced float addition with subtraction → NO_COVERAGE |
indentation.sectionIndentLeft += section.getIndentationLeft(); |
571 |
1
1. add : Replaced float addition with subtraction → NO_COVERAGE |
indentation.sectionIndentRight += section.getIndentationRight(); |
572 | ||
573 |
2
1. add : negated conditional → NO_COVERAGE 2. add : negated conditional → NO_COVERAGE |
if (section.isNotAddedYet() && pageEvent != null) |
574 |
1
1. add : negated conditional → NO_COVERAGE |
if (element.type() == Element.CHAPTER) |
575 |
2
1. add : Replaced float subtraction with addition → NO_COVERAGE 2. add : removed call to com/lowagie/text/pdf/PdfPageEvent::onChapter → NO_COVERAGE |
pageEvent.onChapter(writer, this, indentTop() - currentHeight, section.getTitle()); |
576 | else | |
577 |
2
1. add : Replaced float subtraction with addition → NO_COVERAGE 2. add : removed call to com/lowagie/text/pdf/PdfPageEvent::onSection → NO_COVERAGE |
pageEvent.onSection(writer, this, indentTop() - currentHeight, section.getDepth(), section.getTitle()); |
578 | ||
579 | // the title of the section (if any has to be printed) | |
580 |
1
1. add : negated conditional → NO_COVERAGE |
if (hasTitle) { |
581 | isSectionTitle = true; | |
582 | add(section.getTitle()); | |
583 | isSectionTitle = false; | |
584 | } | |
585 |
1
1. add : Replaced float addition with subtraction → NO_COVERAGE |
indentation.sectionIndentLeft += section.getIndentation(); |
586 | // we process the section | |
587 | element.process(this); | |
588 | flushLines(); | |
589 | // some parameters are set back to normal again | |
590 |
2
1. add : Replaced float addition with subtraction → NO_COVERAGE 2. add : Replaced float subtraction with addition → NO_COVERAGE |
indentation.sectionIndentLeft -= (section.getIndentationLeft() + section.getIndentation()); |
591 |
1
1. add : Replaced float subtraction with addition → NO_COVERAGE |
indentation.sectionIndentRight -= section.getIndentationRight(); |
592 | ||
593 |
2
1. add : negated conditional → NO_COVERAGE 2. add : negated conditional → NO_COVERAGE |
if (section.isComplete() && pageEvent != null) |
594 |
1
1. add : negated conditional → NO_COVERAGE |
if (element.type() == Element.CHAPTER) |
595 |
2
1. add : Replaced float subtraction with addition → NO_COVERAGE 2. add : removed call to com/lowagie/text/pdf/PdfPageEvent::onChapterEnd → NO_COVERAGE |
pageEvent.onChapterEnd(writer, this, indentTop() - currentHeight); |
596 | else | |
597 |
2
1. add : Replaced float subtraction with addition → NO_COVERAGE 2. add : removed call to com/lowagie/text/pdf/PdfPageEvent::onSectionEnd → NO_COVERAGE |
pageEvent.onSectionEnd(writer, this, indentTop() - currentHeight); |
598 | ||
599 | break; | |
600 | } | |
601 | case Element.LIST: { | |
602 | // we cast the element to a List | |
603 | List list = (List) element; | |
604 |
1
1. add : negated conditional → NO_COVERAGE |
if (list.isAlignindent()) { |
605 |
1
1. add : removed call to com/lowagie/text/List::normalizeIndentation → NO_COVERAGE |
list.normalizeIndentation(); |
606 | } | |
607 | // we adjust the document | |
608 |
1
1. add : Replaced float addition with subtraction → NO_COVERAGE |
indentation.listIndentLeft += list.getIndentationLeft(); |
609 |
1
1. add : Replaced float addition with subtraction → NO_COVERAGE |
indentation.indentRight += list.getIndentationRight(); |
610 | // we process the items in the list | |
611 | element.process(this); | |
612 | // some parameters are set back to normal again | |
613 |
1
1. add : Replaced float subtraction with addition → NO_COVERAGE |
indentation.listIndentLeft -= list.getIndentationLeft(); |
614 |
1
1. add : Replaced float subtraction with addition → NO_COVERAGE |
indentation.indentRight -= list.getIndentationRight(); |
615 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument::carriageReturn → NO_COVERAGE |
carriageReturn(); |
616 | break; | |
617 | } | |
618 | case Element.LISTITEM: { | |
619 |
1
1. add : Replaced integer addition with subtraction → NO_COVERAGE |
leadingCount++; |
620 | // we cast the element to a ListItem | |
621 | ListItem listItem = (ListItem) element; | |
622 | ||
623 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument::addSpacing → NO_COVERAGE |
addSpacing(listItem.getSpacingBefore(), leading, listItem.getFont()); |
624 | ||
625 | // we adjust the document | |
626 | alignment = listItem.getAlignment(); | |
627 |
1
1. add : Replaced float addition with subtraction → NO_COVERAGE |
indentation.listIndentLeft += listItem.getIndentationLeft(); |
628 |
1
1. add : Replaced float addition with subtraction → NO_COVERAGE |
indentation.indentRight += listItem.getIndentationRight(); |
629 | leading = listItem.getTotalLeading(); | |
630 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument::carriageReturn → NO_COVERAGE |
carriageReturn(); |
631 | ||
632 | // we prepare the current line to be able to show us the listsymbol | |
633 |
1
1. add : removed call to com/lowagie/text/pdf/PdfLine::setListItem → NO_COVERAGE |
line.setListItem(listItem); |
634 | // we process the item | |
635 | element.process(this); | |
636 | ||
637 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument::addSpacing → NO_COVERAGE |
addSpacing(listItem.getSpacingAfter(), listItem.getTotalLeading(), listItem.getFont()); |
638 | ||
639 | // if the last line is justified, it should be aligned to the left | |
640 |
1
1. add : negated conditional → NO_COVERAGE |
if (line.hasToBeJustified()) { |
641 |
1
1. add : removed call to com/lowagie/text/pdf/PdfLine::resetAlignment → NO_COVERAGE |
line.resetAlignment(); |
642 | } | |
643 | // some parameters are set back to normal again | |
644 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument::carriageReturn → NO_COVERAGE |
carriageReturn(); |
645 |
1
1. add : Replaced float subtraction with addition → NO_COVERAGE |
indentation.listIndentLeft -= listItem.getIndentationLeft(); |
646 |
1
1. add : Replaced float subtraction with addition → NO_COVERAGE |
indentation.indentRight -= listItem.getIndentationRight(); |
647 |
1
1. add : Replaced integer subtraction with addition → NO_COVERAGE |
leadingCount--; |
648 | break; | |
649 | } | |
650 | case Element.RECTANGLE: { | |
651 | Rectangle rectangle = (Rectangle) element; | |
652 |
1
1. add : removed call to com/lowagie/text/pdf/PdfContentByte::rectangle → NO_COVERAGE |
graphics.rectangle(rectangle); |
653 | pageEmpty = false; | |
654 | break; | |
655 | } | |
656 | case Element.PTABLE: { | |
657 | PdfPTable ptable = (PdfPTable)element; | |
658 |
2
1. add : changed conditional boundary → NO_COVERAGE 2. add : negated conditional → NO_COVERAGE |
if (ptable.size() <= ptable.getHeaderRows()) |
659 | break; //nothing to do | |
660 | ||
661 | // before every table, we add a new line and flush all lines | |
662 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument::ensureNewLine → NO_COVERAGE |
ensureNewLine(); |
663 | flushLines(); | |
664 | ||
665 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument::addPTable → NO_COVERAGE |
addPTable(ptable); |
666 | pageEmpty = false; | |
667 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument::newLine → NO_COVERAGE |
newLine(); |
668 | break; | |
669 | } | |
670 | case Element.MULTI_COLUMN_TEXT: { | |
671 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument::ensureNewLine → NO_COVERAGE |
ensureNewLine(); |
672 | flushLines(); | |
673 | MultiColumnText multiText = (MultiColumnText) element; | |
674 |
1
1. add : Replaced float subtraction with addition → NO_COVERAGE |
float height = multiText.write(writer.getDirectContent(), this, indentTop() - currentHeight); |
675 |
1
1. add : Replaced float addition with subtraction → NO_COVERAGE |
currentHeight += height; |
676 |
2
1. add : Replaced float multiplication with division → NO_COVERAGE 2. add : removed call to com/lowagie/text/pdf/PdfContentByte::moveText → NO_COVERAGE |
text.moveText(0, -1f* height); |
677 | pageEmpty = false; | |
678 | break; | |
679 | } | |
680 | case Element.TABLE : { | |
681 |
1
1. add : negated conditional → NO_COVERAGE |
if (element instanceof SimpleTable) { |
682 | PdfPTable ptable = ((SimpleTable)element).createPdfPTable(); | |
683 |
2
1. add : changed conditional boundary → NO_COVERAGE 2. add : negated conditional → NO_COVERAGE |
if (ptable.size() <= ptable.getHeaderRows()) |
684 | break; //nothing to do | |
685 | ||
686 | // before every table, we add a new line and flush all lines | |
687 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument::ensureNewLine → NO_COVERAGE |
ensureNewLine(); |
688 | flushLines(); | |
689 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument::addPTable → NO_COVERAGE |
addPTable(ptable); |
690 | pageEmpty = false; | |
691 | break; | |
692 |
1
1. add : negated conditional → NO_COVERAGE |
} else if (element instanceof Table) { |
693 | try { | |
694 | PdfPTable ptable = ((Table)element).createPdfPTable(); | |
695 |
2
1. add : changed conditional boundary → NO_COVERAGE 2. add : negated conditional → NO_COVERAGE |
if (ptable.size() <= ptable.getHeaderRows()) |
696 | break; //nothing to do | |
697 | // before every table, we add a new line and flush all lines | |
698 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument::ensureNewLine → NO_COVERAGE |
ensureNewLine(); |
699 | flushLines(); | |
700 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument::addPTable → NO_COVERAGE |
addPTable(ptable); |
701 | pageEmpty = false; | |
702 | break; | |
703 | } | |
704 | catch(BadElementException bee) { | |
705 | // constructing the PdfTable | |
706 | // Before the table, add a blank line using offset or default leading | |
707 | float offset = ((Table)element).getOffset(); | |
708 |
1
1. add : negated conditional → NO_COVERAGE |
if (Float.isNaN(offset)) |
709 | offset = leading; | |
710 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument::carriageReturn → NO_COVERAGE |
carriageReturn(); |
711 | lines.add(new PdfLine(indentLeft(), indentRight(), alignment, offset)); | |
712 |
1
1. add : Replaced float addition with subtraction → NO_COVERAGE |
currentHeight += offset; |
713 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument::addPdfTable → NO_COVERAGE |
addPdfTable((Table)element); |
714 | } | |
715 | } else { | |
716 |
1
1. add : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
717 | } | |
718 | break; | |
719 | } | |
720 | case Element.JPEG: | |
721 | case Element.JPEG2000: | |
722 | case Element.JBIG2: | |
723 | case Element.IMGRAW: | |
724 | case Element.IMGTEMPLATE: { | |
725 | //carriageReturn(); suggestion by Marc Campforts | |
726 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument::add → NO_COVERAGE |
add((Image) element); |
727 | break; | |
728 | } | |
729 | case Element.YMARK: { | |
730 | DrawInterface zh = (DrawInterface)element; | |
731 |
5
1. add : changed conditional boundary → NO_COVERAGE 2. add : Replaced float subtraction with addition → NO_COVERAGE 3. add : Replaced float subtraction with addition → NO_COVERAGE 4. add : negated conditional → NO_COVERAGE 5. add : removed call to com/lowagie/text/pdf/draw/DrawInterface::draw → NO_COVERAGE |
zh.draw(graphics, indentLeft(), indentBottom(), indentRight(), indentTop(), indentTop() - currentHeight - (leadingCount > 0 ? leading : 0)); |
732 | pageEmpty = false; | |
733 | break; | |
734 | } | |
735 | case Element.MARKED: { | |
736 | MarkedObject mo; | |
737 |
1
1. add : negated conditional → NO_COVERAGE |
if (element instanceof MarkedSection) { |
738 | mo = ((MarkedSection)element).getTitle(); | |
739 |
1
1. add : negated conditional → NO_COVERAGE |
if (mo != null) { |
740 | mo.process(this); | |
741 | } | |
742 | } | |
743 | mo = (MarkedObject)element; | |
744 | mo.process(this); | |
745 | break; | |
746 | } | |
747 | default: | |
748 |
1
1. add : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
749 | } | |
750 | lastElementType = element.type(); | |
751 |
1
1. add : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return true; |
752 | } | |
753 | catch(Exception e) { | |
754 | throw new DocumentException(e); | |
755 | } | |
756 | } | |
757 | ||
758 | // [L1] DocListener interface | |
759 | ||
760 | /** | |
761 | * Opens the document. | |
762 | * <P> | |
763 | * You have to open the document before you can begin to add content | |
764 | * to the body of the document. | |
765 | */ | |
766 | public void open() { | |
767 |
1
1. open : negated conditional → NO_COVERAGE |
if (!open) { |
768 |
1
1. open : removed call to com/lowagie/text/Document::open → NO_COVERAGE |
super.open(); |
769 |
1
1. open : removed call to com/lowagie/text/pdf/PdfWriter::open → NO_COVERAGE |
writer.open(); |
770 | rootOutline = new PdfOutline(writer); | |
771 | currentOutline = rootOutline; | |
772 | } | |
773 | try { | |
774 |
1
1. open : removed call to com/lowagie/text/pdf/PdfDocument::initPage → NO_COVERAGE |
initPage(); |
775 | } | |
776 | catch(DocumentException de) { | |
777 | throw new ExceptionConverter(de); | |
778 | } | |
779 | } | |
780 | ||
781 | // [L2] DocListener interface | |
782 | ||
783 | /** | |
784 | * Closes the document. | |
785 | * <B> | |
786 | * Once all the content has been written in the body, you have to close | |
787 | * the body. After that nothing can be written to the body anymore. | |
788 | */ | |
789 | public void close() { | |
790 |
1
1. close : negated conditional → NO_COVERAGE |
if (close) { |
791 | return; | |
792 | } | |
793 | try { | |
794 |
1
1. close : negated conditional → NO_COVERAGE |
boolean wasImage = (imageWait != null); |
795 | newPage(); | |
796 |
2
1. close : negated conditional → NO_COVERAGE 2. close : negated conditional → NO_COVERAGE |
if (imageWait != null || wasImage) newPage(); |
797 |
1
1. close : negated conditional → NO_COVERAGE |
if (annotationsImp.hasUnusedAnnotations()) |
798 | throw new RuntimeException(MessageLocalization.getComposedMessage("not.all.annotations.could.be.added.to.the.document.the.document.doesn.t.have.enough.pages")); | |
799 | PdfPageEvent pageEvent = writer.getPageEvent(); | |
800 |
1
1. close : negated conditional → NO_COVERAGE |
if (pageEvent != null) |
801 |
1
1. close : removed call to com/lowagie/text/pdf/PdfPageEvent::onCloseDocument → NO_COVERAGE |
pageEvent.onCloseDocument(writer, this); |
802 |
1
1. close : removed call to com/lowagie/text/Document::close → NO_COVERAGE |
super.close(); |
803 | ||
804 |
1
1. close : removed call to com/lowagie/text/pdf/PdfWriter::addLocalDestinations → NO_COVERAGE |
writer.addLocalDestinations(localDestinations); |
805 |
1
1. close : removed call to com/lowagie/text/pdf/PdfDocument::calculateOutlineCount → NO_COVERAGE |
calculateOutlineCount(); |
806 |
1
1. close : removed call to com/lowagie/text/pdf/PdfDocument::writeOutlines → NO_COVERAGE |
writeOutlines(); |
807 | } | |
808 | catch(Exception e) { | |
809 | throw new ExceptionConverter(e); | |
810 | } | |
811 | ||
812 |
1
1. close : removed call to com/lowagie/text/pdf/PdfWriter::close → NO_COVERAGE |
writer.close(); |
813 | } | |
814 | ||
815 | // [L3] DocListener interface | |
816 | protected int textEmptySize; | |
817 | ||
818 | // [C9] Metadata for the page | |
819 | /** XMP Metadata for the page. */ | |
820 | protected byte[] xmpMetadata = null; | |
821 | /** | |
822 | * Use this method to set the XMP Metadata. | |
823 | * @param xmpMetadata The xmpMetadata to set. | |
824 | */ | |
825 | public void setXmpMetadata(byte[] xmpMetadata) { | |
826 | this.xmpMetadata = xmpMetadata; | |
827 | } | |
828 | ||
829 | /** | |
830 | * Makes a new page and sends it to the <CODE>PdfWriter</CODE>. | |
831 | * | |
832 | * @return a <CODE>boolean</CODE> | |
833 | */ | |
834 | public boolean newPage() { | |
835 | lastElementType = -1; | |
836 |
1
1. newPage : negated conditional → NO_COVERAGE |
if (isPageEmpty()) { |
837 |
1
1. newPage : removed call to com/lowagie/text/pdf/PdfDocument::setNewPageSizeAndMargins → NO_COVERAGE |
setNewPageSizeAndMargins(); |
838 |
1
1. newPage : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
839 | } | |
840 |
2
1. newPage : negated conditional → NO_COVERAGE 2. newPage : negated conditional → NO_COVERAGE |
if (!open || close) { |
841 | throw new RuntimeException(MessageLocalization.getComposedMessage("the.document.is.not.open")); | |
842 | } | |
843 | PdfPageEvent pageEvent = writer.getPageEvent(); | |
844 |
1
1. newPage : negated conditional → NO_COVERAGE |
if (pageEvent != null) |
845 |
1
1. newPage : removed call to com/lowagie/text/pdf/PdfPageEvent::onEndPage → NO_COVERAGE |
pageEvent.onEndPage(writer, this); |
846 | ||
847 | //Added to inform any listeners that we are moving to a new page (added by David Freels) | |
848 | super.newPage(); | |
849 | ||
850 | // the following 2 lines were added by Pelikan Stephan | |
851 | indentation.imageIndentLeft = 0; | |
852 | indentation.imageIndentRight = 0; | |
853 | ||
854 | try { | |
855 | // we flush the arraylist with recently written lines | |
856 | flushLines(); | |
857 | ||
858 | // we prepare the elements of the page dictionary | |
859 | ||
860 | // [U1] page size and rotation | |
861 | int rotation = pageSize.getRotation(); | |
862 | ||
863 | // [C10] | |
864 |
1
1. newPage : negated conditional → NO_COVERAGE |
if (writer.isPdfX()) { |
865 |
2
1. newPage : negated conditional → NO_COVERAGE 2. newPage : negated conditional → NO_COVERAGE |
if (thisBoxSize.containsKey("art") && thisBoxSize.containsKey("trim")) |
866 | throw new PdfXConformanceException(MessageLocalization.getComposedMessage("only.one.of.artbox.or.trimbox.can.exist.in.the.page")); | |
867 |
2
1. newPage : negated conditional → NO_COVERAGE 2. newPage : negated conditional → NO_COVERAGE |
if (!thisBoxSize.containsKey("art") && !thisBoxSize.containsKey("trim")) { |
868 |
1
1. newPage : negated conditional → NO_COVERAGE |
if (thisBoxSize.containsKey("crop")) |
869 | thisBoxSize.put("trim", thisBoxSize.get("crop")); | |
870 | else | |
871 | thisBoxSize.put("trim", new PdfRectangle(pageSize, pageSize.getRotation())); | |
872 | } | |
873 | } | |
874 | ||
875 | // [M1] | |
876 |
1
1. newPage : removed call to com/lowagie/text/pdf/PageResources::addDefaultColorDiff → NO_COVERAGE |
pageResources.addDefaultColorDiff(writer.getDefaultColorspace()); |
877 |
1
1. newPage : negated conditional → NO_COVERAGE |
if (writer.isRgbTransparencyBlending()) { |
878 | PdfDictionary dcs = new PdfDictionary(); | |
879 |
1
1. newPage : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
dcs.put(PdfName.CS, PdfName.DEVICERGB); |
880 |
1
1. newPage : removed call to com/lowagie/text/pdf/PageResources::addDefaultColorDiff → NO_COVERAGE |
pageResources.addDefaultColorDiff(dcs); |
881 | } | |
882 | PdfDictionary resources = pageResources.getResources(); | |
883 | ||
884 | // we create the page dictionary | |
885 | ||
886 | PdfPage page = new PdfPage(new PdfRectangle(pageSize, rotation), thisBoxSize, resources, rotation); | |
887 |
1
1. newPage : removed call to com/lowagie/text/pdf/PdfPage::put → NO_COVERAGE |
page.put(PdfName.TABS, writer.getTabs()); |
888 | ||
889 | // we complete the page dictionary | |
890 | ||
891 | // [C9] if there is XMP data to add: add it | |
892 |
1
1. newPage : negated conditional → NO_COVERAGE |
if (xmpMetadata != null) { |
893 | PdfStream xmp = new PdfStream(xmpMetadata); | |
894 |
1
1. newPage : removed call to com/lowagie/text/pdf/PdfStream::put → NO_COVERAGE |
xmp.put(PdfName.TYPE, PdfName.METADATA); |
895 |
1
1. newPage : removed call to com/lowagie/text/pdf/PdfStream::put → NO_COVERAGE |
xmp.put(PdfName.SUBTYPE, PdfName.XML); |
896 | PdfEncryption crypto = writer.getEncryption(); | |
897 |
2
1. newPage : negated conditional → NO_COVERAGE 2. newPage : negated conditional → NO_COVERAGE |
if (crypto != null && !crypto.isMetadataEncrypted()) { |
898 | PdfArray ar = new PdfArray(); | |
899 | ar.add(PdfName.CRYPT); | |
900 |
1
1. newPage : removed call to com/lowagie/text/pdf/PdfStream::put → NO_COVERAGE |
xmp.put(PdfName.FILTER, ar); |
901 | } | |
902 |
1
1. newPage : removed call to com/lowagie/text/pdf/PdfPage::put → NO_COVERAGE |
page.put(PdfName.METADATA, writer.addToBody(xmp).getIndirectReference()); |
903 | } | |
904 | ||
905 | // [U3] page actions: transition, duration, additional actions | |
906 |
1
1. newPage : negated conditional → NO_COVERAGE |
if (this.transition!=null) { |
907 |
1
1. newPage : removed call to com/lowagie/text/pdf/PdfPage::put → NO_COVERAGE |
page.put(PdfName.TRANS, this.transition.getTransitionDictionary()); |
908 | transition = null; | |
909 | } | |
910 |
2
1. newPage : changed conditional boundary → NO_COVERAGE 2. newPage : negated conditional → NO_COVERAGE |
if (this.duration>0) { |
911 |
1
1. newPage : removed call to com/lowagie/text/pdf/PdfPage::put → NO_COVERAGE |
page.put(PdfName.DUR,new PdfNumber(this.duration)); |
912 | duration = 0; | |
913 | } | |
914 |
1
1. newPage : negated conditional → NO_COVERAGE |
if (pageAA != null) { |
915 |
1
1. newPage : removed call to com/lowagie/text/pdf/PdfPage::put → NO_COVERAGE |
page.put(PdfName.AA, writer.addToBody(pageAA).getIndirectReference()); |
916 | pageAA = null; | |
917 | } | |
918 | ||
919 | // [U4] we add the thumbs | |
920 |
1
1. newPage : negated conditional → NO_COVERAGE |
if (thumb != null) { |
921 |
1
1. newPage : removed call to com/lowagie/text/pdf/PdfPage::put → NO_COVERAGE |
page.put(PdfName.THUMB, thumb); |
922 | thumb = null; | |
923 | } | |
924 | ||
925 | // [U8] we check if the userunit is defined | |
926 |
2
1. newPage : changed conditional boundary → NO_COVERAGE 2. newPage : negated conditional → NO_COVERAGE |
if (writer.getUserunit() > 0f) { |
927 |
1
1. newPage : removed call to com/lowagie/text/pdf/PdfPage::put → NO_COVERAGE |
page.put(PdfName.USERUNIT, new PdfNumber(writer.getUserunit())); |
928 | } | |
929 | ||
930 | // [C5] and [C8] we add the annotations | |
931 |
1
1. newPage : negated conditional → NO_COVERAGE |
if (annotationsImp.hasUnusedAnnotations()) { |
932 | PdfArray array = annotationsImp.rotateAnnotations(writer, pageSize); | |
933 |
1
1. newPage : negated conditional → NO_COVERAGE |
if (array.size() != 0) |
934 |
1
1. newPage : removed call to com/lowagie/text/pdf/PdfPage::put → NO_COVERAGE |
page.put(PdfName.ANNOTS, array); |
935 | } | |
936 | ||
937 | // [F12] we add tag info | |
938 |
1
1. newPage : negated conditional → NO_COVERAGE |
if (writer.isTagged()) |
939 |
2
1. newPage : Replaced integer subtraction with addition → NO_COVERAGE 2. newPage : removed call to com/lowagie/text/pdf/PdfPage::put → NO_COVERAGE |
page.put(PdfName.STRUCTPARENTS, new PdfNumber(writer.getCurrentPageNumber() - 1)); |
940 | ||
941 |
2
1. newPage : changed conditional boundary → NO_COVERAGE 2. newPage : negated conditional → NO_COVERAGE |
if (text.size() > textEmptySize) |
942 |
1
1. newPage : removed call to com/lowagie/text/pdf/PdfContentByte::endText → NO_COVERAGE |
text.endText(); |
943 | else | |
944 | text = null; | |
945 | writer.add(page, new PdfContents(writer.getDirectContentUnder(), graphics, text, writer.getDirectContent(), pageSize)); | |
946 | // we initialize the new page | |
947 |
1
1. newPage : removed call to com/lowagie/text/pdf/PdfDocument::initPage → NO_COVERAGE |
initPage(); |
948 | } | |
949 | catch(DocumentException | IOException de) { | |
950 | // maybe this never happens, but it's better to check. | |
951 | throw new ExceptionConverter(de); | |
952 | } | |
953 |
1
1. newPage : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return true; |
954 | } | |
955 | ||
956 | // [L4] DocListener interface | |
957 | ||
958 | /** | |
959 | * Sets the pagesize. | |
960 | * | |
961 | * @param pageSize the new pagesize | |
962 | * @return <CODE>true</CODE> if the page size was set | |
963 | */ | |
964 | public boolean setPageSize(Rectangle pageSize) { | |
965 |
2
1. setPageSize : negated conditional → NO_COVERAGE 2. setPageSize : negated conditional → NO_COVERAGE |
if (writer != null && writer.isPaused()) { |
966 |
1
1. setPageSize : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
967 | } | |
968 | nextPageSize = new Rectangle(pageSize); | |
969 |
1
1. setPageSize : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return true; |
970 | } | |
971 | ||
972 | // [L5] DocListener interface | |
973 | ||
974 | /** margin in x direction starting from the left. Will be valid in the next page */ | |
975 | protected float nextMarginLeft; | |
976 | ||
977 | /** margin in x direction starting from the right. Will be valid in the next page */ | |
978 | protected float nextMarginRight; | |
979 | ||
980 | /** margin in y direction starting from the top. Will be valid in the next page */ | |
981 | protected float nextMarginTop; | |
982 | ||
983 | /** margin in y direction starting from the bottom. Will be valid in the next page */ | |
984 | protected float nextMarginBottom; | |
985 | ||
986 | /** | |
987 | * Sets the margins. | |
988 | * | |
989 | * @param marginLeft the margin on the left | |
990 | * @param marginRight the margin on the right | |
991 | * @param marginTop the margin on the top | |
992 | * @param marginBottom the margin on the bottom | |
993 | * @return a <CODE>boolean</CODE> | |
994 | */ | |
995 | public boolean setMargins(float marginLeft, float marginRight, float marginTop, float marginBottom) { | |
996 |
2
1. setMargins : negated conditional → NO_COVERAGE 2. setMargins : negated conditional → NO_COVERAGE |
if (writer != null && writer.isPaused()) { |
997 |
1
1. setMargins : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
998 | } | |
999 | nextMarginLeft = marginLeft; | |
1000 | nextMarginRight = marginRight; | |
1001 | nextMarginTop = marginTop; | |
1002 | nextMarginBottom = marginBottom; | |
1003 |
1
1. setMargins : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return true; |
1004 | } | |
1005 | ||
1006 | // [L6] DocListener interface | |
1007 | ||
1008 | /** | |
1009 | * @see com.lowagie.text.DocListener#setMarginMirroring(boolean) | |
1010 | */ | |
1011 | public boolean setMarginMirroring(boolean MarginMirroring) { | |
1012 |
2
1. setMarginMirroring : negated conditional → NO_COVERAGE 2. setMarginMirroring : negated conditional → NO_COVERAGE |
if (writer != null && writer.isPaused()) { |
1013 |
1
1. setMarginMirroring : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
1014 | } | |
1015 |
1
1. setMarginMirroring : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return super.setMarginMirroring(MarginMirroring); |
1016 | } | |
1017 | ||
1018 | /** | |
1019 | * @see com.lowagie.text.DocListener#setMarginMirroring(boolean) | |
1020 | * @since 2.1.6 | |
1021 | */ | |
1022 | public boolean setMarginMirroringTopBottom(boolean MarginMirroringTopBottom) { | |
1023 |
2
1. setMarginMirroringTopBottom : negated conditional → NO_COVERAGE 2. setMarginMirroringTopBottom : negated conditional → NO_COVERAGE |
if (writer != null && writer.isPaused()) { |
1024 |
1
1. setMarginMirroringTopBottom : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
1025 | } | |
1026 |
1
1. setMarginMirroringTopBottom : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return super.setMarginMirroringTopBottom(MarginMirroringTopBottom); |
1027 | } | |
1028 | ||
1029 | // [L7] DocListener interface | |
1030 | ||
1031 | /** | |
1032 | * Sets the page number. | |
1033 | * | |
1034 | * @param pageN the new page number | |
1035 | */ | |
1036 | public void setPageCount(int pageN) { | |
1037 |
2
1. setPageCount : negated conditional → NO_COVERAGE 2. setPageCount : negated conditional → NO_COVERAGE |
if (writer != null && writer.isPaused()) { |
1038 | return; | |
1039 | } | |
1040 |
1
1. setPageCount : removed call to com/lowagie/text/Document::setPageCount → NO_COVERAGE |
super.setPageCount(pageN); |
1041 | } | |
1042 | ||
1043 | // [L8] DocListener interface | |
1044 | ||
1045 | /** | |
1046 | * Sets the page number to 0. | |
1047 | */ | |
1048 | public void resetPageCount() { | |
1049 |
2
1. resetPageCount : negated conditional → NO_COVERAGE 2. resetPageCount : negated conditional → NO_COVERAGE |
if (writer != null && writer.isPaused()) { |
1050 | return; | |
1051 | } | |
1052 |
1
1. resetPageCount : removed call to com/lowagie/text/Document::resetPageCount → NO_COVERAGE |
super.resetPageCount(); |
1053 | } | |
1054 | ||
1055 | // [L9] DocListener interface | |
1056 | ||
1057 | /** | |
1058 | * Changes the header of this document. | |
1059 | * | |
1060 | * @param header the new header | |
1061 | */ | |
1062 | public void setHeader(HeaderFooter header) { | |
1063 |
2
1. setHeader : negated conditional → NO_COVERAGE 2. setHeader : negated conditional → NO_COVERAGE |
if (writer != null && writer.isPaused()) { |
1064 | return; | |
1065 | } | |
1066 |
1
1. setHeader : removed call to com/lowagie/text/Document::setHeader → NO_COVERAGE |
super.setHeader(header); |
1067 | } | |
1068 | ||
1069 | // [L10] DocListener interface | |
1070 | ||
1071 | /** | |
1072 | * Resets the header of this document. | |
1073 | */ | |
1074 | public void resetHeader() { | |
1075 |
2
1. resetHeader : negated conditional → NO_COVERAGE 2. resetHeader : negated conditional → NO_COVERAGE |
if (writer != null && writer.isPaused()) { |
1076 | return; | |
1077 | } | |
1078 |
1
1. resetHeader : removed call to com/lowagie/text/Document::resetHeader → NO_COVERAGE |
super.resetHeader(); |
1079 | } | |
1080 | ||
1081 | // [L11] DocListener interface | |
1082 | ||
1083 | /** | |
1084 | * Changes the footer of this document. | |
1085 | * | |
1086 | * @param footer the new footer | |
1087 | */ | |
1088 | public void setFooter(HeaderFooter footer) { | |
1089 |
2
1. setFooter : negated conditional → NO_COVERAGE 2. setFooter : negated conditional → NO_COVERAGE |
if (writer != null && writer.isPaused()) { |
1090 | return; | |
1091 | } | |
1092 |
1
1. setFooter : removed call to com/lowagie/text/Document::setFooter → NO_COVERAGE |
super.setFooter(footer); |
1093 | } | |
1094 | ||
1095 | // [L12] DocListener interface | |
1096 | ||
1097 | /** | |
1098 | * Resets the footer of this document. | |
1099 | */ | |
1100 | public void resetFooter() { | |
1101 |
2
1. resetFooter : negated conditional → NO_COVERAGE 2. resetFooter : negated conditional → NO_COVERAGE |
if (writer != null && writer.isPaused()) { |
1102 | return; | |
1103 | } | |
1104 |
1
1. resetFooter : removed call to com/lowagie/text/Document::resetFooter → NO_COVERAGE |
super.resetFooter(); |
1105 | } | |
1106 | ||
1107 | // DOCLISTENER METHODS END | |
1108 | ||
1109 | /** Signals that OnOpenDocument should be called. */ | |
1110 | protected boolean firstPageEvent = true; | |
1111 | ||
1112 | /** | |
1113 | * Initializes a page. | |
1114 | * <P> | |
1115 | * If the footer/header is set, it is printed. | |
1116 | * @throws DocumentException on error | |
1117 | */ | |
1118 | protected void initPage() throws DocumentException { | |
1119 | // the pagenumber is incremented | |
1120 |
1
1. initPage : Replaced integer addition with subtraction → NO_COVERAGE |
pageN++; |
1121 | ||
1122 | // initialization of some page objects | |
1123 |
1
1. initPage : removed call to com/lowagie/text/pdf/internal/PdfAnnotationsImp::resetAnnotations → NO_COVERAGE |
annotationsImp.resetAnnotations(); |
1124 | pageResources = new PageResources(); | |
1125 | ||
1126 |
1
1. initPage : removed call to com/lowagie/text/pdf/PdfWriter::resetContent → NO_COVERAGE |
writer.resetContent(); |
1127 | graphics = new PdfContentByte(writer); | |
1128 | text = new PdfContentByte(writer); | |
1129 |
1
1. initPage : removed call to com/lowagie/text/pdf/PdfContentByte::reset → NO_COVERAGE |
text.reset(); |
1130 |
1
1. initPage : removed call to com/lowagie/text/pdf/PdfContentByte::beginText → NO_COVERAGE |
text.beginText(); |
1131 | textEmptySize = text.size(); | |
1132 | ||
1133 | markPoint = 0; | |
1134 |
1
1. initPage : removed call to com/lowagie/text/pdf/PdfDocument::setNewPageSizeAndMargins → NO_COVERAGE |
setNewPageSizeAndMargins(); |
1135 | imageEnd = -1; | |
1136 | indentation.imageIndentRight = 0; | |
1137 | indentation.imageIndentLeft = 0; | |
1138 | indentation.indentBottom = 0; | |
1139 | indentation.indentTop = 0; | |
1140 | currentHeight = 0; | |
1141 | ||
1142 | // backgroundcolors, etc... | |
1143 | thisBoxSize = new HashMap<>(boxSize); | |
1144 |
1
1. initPage : negated conditional → NO_COVERAGE |
if (pageSize.getBackgroundColor() != null |
1145 |
1
1. initPage : negated conditional → NO_COVERAGE |
|| pageSize.hasBorders() |
1146 |
1
1. initPage : negated conditional → NO_COVERAGE |
|| pageSize.getBorderColor() != null) { |
1147 | add(pageSize); | |
1148 | } | |
1149 | ||
1150 | float oldleading = leading; | |
1151 | int oldAlignment = alignment; | |
1152 | // if there is a footer, the footer is added | |
1153 |
1
1. initPage : removed call to com/lowagie/text/pdf/PdfDocument::doFooter → NO_COVERAGE |
doFooter(); |
1154 | // we move to the left/top position of the page | |
1155 |
1
1. initPage : removed call to com/lowagie/text/pdf/PdfContentByte::moveText → NO_COVERAGE |
text.moveText(left(), top()); |
1156 |
1
1. initPage : removed call to com/lowagie/text/pdf/PdfDocument::doHeader → NO_COVERAGE |
doHeader(); |
1157 | pageEmpty = true; | |
1158 | // if there is an image waiting to be drawn, draw it | |
1159 | try { | |
1160 |
1
1. initPage : negated conditional → NO_COVERAGE |
if (imageWait != null) { |
1161 |
1
1. initPage : removed call to com/lowagie/text/pdf/PdfDocument::add → NO_COVERAGE |
add(imageWait); |
1162 | imageWait = null; | |
1163 | } | |
1164 | } | |
1165 | catch(Exception e) { | |
1166 | throw new ExceptionConverter(e); | |
1167 | } | |
1168 | leading = oldleading; | |
1169 | alignment = oldAlignment; | |
1170 |
1
1. initPage : removed call to com/lowagie/text/pdf/PdfDocument::carriageReturn → NO_COVERAGE |
carriageReturn(); |
1171 | ||
1172 | PdfPageEvent pageEvent = writer.getPageEvent(); | |
1173 |
1
1. initPage : negated conditional → NO_COVERAGE |
if (pageEvent != null) { |
1174 |
1
1. initPage : negated conditional → NO_COVERAGE |
if (firstPageEvent) { |
1175 |
1
1. initPage : removed call to com/lowagie/text/pdf/PdfPageEvent::onOpenDocument → NO_COVERAGE |
pageEvent.onOpenDocument(writer, this); |
1176 | } | |
1177 |
1
1. initPage : removed call to com/lowagie/text/pdf/PdfPageEvent::onStartPage → NO_COVERAGE |
pageEvent.onStartPage(writer, this); |
1178 | } | |
1179 | firstPageEvent = false; | |
1180 | } | |
1181 | ||
1182 | /** The line that is currently being written. */ | |
1183 | protected PdfLine line = null; | |
1184 | ||
1185 | /** The lines that are written until now. */ | |
1186 | protected ArrayList<PdfLine> lines = new ArrayList<>(); | |
1187 | ||
1188 | /** | |
1189 | * Adds the current line to the list of lines and also adds an empty line. | |
1190 | * @throws DocumentException on error | |
1191 | */ | |
1192 | protected void newLine() throws DocumentException { | |
1193 | lastElementType = -1; | |
1194 |
1
1. newLine : removed call to com/lowagie/text/pdf/PdfDocument::carriageReturn → NO_COVERAGE |
carriageReturn(); |
1195 |
2
1. newLine : negated conditional → NO_COVERAGE 2. newLine : negated conditional → NO_COVERAGE |
if (lines != null && !lines.isEmpty()) { |
1196 | lines.add(line); | |
1197 |
1
1. newLine : Replaced float addition with subtraction → NO_COVERAGE |
currentHeight += line.height(); |
1198 | } | |
1199 | line = new PdfLine(indentLeft(), indentRight(), alignment, leading); | |
1200 | } | |
1201 | ||
1202 | /** | |
1203 | * If the current line is not empty or null, it is added to the arraylist | |
1204 | * of lines and a new empty line is added. | |
1205 | */ | |
1206 | protected void carriageReturn() { | |
1207 | // the arraylist with lines may not be null | |
1208 |
1
1. carriageReturn : negated conditional → NO_COVERAGE |
if (lines == null) { |
1209 | lines = new ArrayList<>(); | |
1210 | } | |
1211 | // If the current line is not null | |
1212 |
1
1. carriageReturn : negated conditional → NO_COVERAGE |
if (line != null) { |
1213 | // we check if the end of the page is reached (bugfix by Francois Gravel) | |
1214 |
5
1. carriageReturn : changed conditional boundary → NO_COVERAGE 2. carriageReturn : Replaced float addition with subtraction → NO_COVERAGE 3. carriageReturn : Replaced float addition with subtraction → NO_COVERAGE 4. carriageReturn : Replaced float subtraction with addition → NO_COVERAGE 5. carriageReturn : negated conditional → NO_COVERAGE |
if (currentHeight + line.height() + leading < indentTop() - indentBottom()) { |
1215 | // if so nonempty lines are added and the height is augmented | |
1216 |
2
1. carriageReturn : changed conditional boundary → NO_COVERAGE 2. carriageReturn : negated conditional → NO_COVERAGE |
if (line.size() > 0) { |
1217 |
1
1. carriageReturn : Replaced float addition with subtraction → NO_COVERAGE |
currentHeight += line.height(); |
1218 | lines.add(line); | |
1219 | pageEmpty = false; | |
1220 | } | |
1221 | } | |
1222 | // if the end of the line is reached, we start a new page | |
1223 | else { | |
1224 | newPage(); | |
1225 | } | |
1226 | } | |
1227 |
4
1. carriageReturn : changed conditional boundary → NO_COVERAGE 2. carriageReturn : changed conditional boundary → NO_COVERAGE 3. carriageReturn : negated conditional → NO_COVERAGE 4. carriageReturn : negated conditional → NO_COVERAGE |
if (imageEnd > -1 && currentHeight > imageEnd) { |
1228 | imageEnd = -1; | |
1229 | indentation.imageIndentRight = 0; | |
1230 | indentation.imageIndentLeft = 0; | |
1231 | } | |
1232 | // a new current line is constructed | |
1233 | line = new PdfLine(indentLeft(), indentRight(), alignment, leading); | |
1234 | } | |
1235 | ||
1236 | /** | |
1237 | * Gets the current vertical page position. | |
1238 | * @param ensureNewLine Tells whether a new line shall be enforced. This may cause side effects | |
1239 | * for elements that do not terminate the lines they've started because those lines will get | |
1240 | * terminated. | |
1241 | * @return The current vertical page position. | |
1242 | */ | |
1243 | public float getVerticalPosition(boolean ensureNewLine) { | |
1244 | // ensuring that a new line has been started. | |
1245 |
1
1. getVerticalPosition : negated conditional → NO_COVERAGE |
if (ensureNewLine) { |
1246 |
1
1. getVerticalPosition : removed call to com/lowagie/text/pdf/PdfDocument::ensureNewLine → NO_COVERAGE |
ensureNewLine(); |
1247 | } | |
1248 |
3
1. getVerticalPosition : Replaced float subtraction with addition → NO_COVERAGE 2. getVerticalPosition : Replaced float subtraction with addition → NO_COVERAGE 3. getVerticalPosition : replaced return of float value with -(x + 1) for com/lowagie/text/pdf/PdfDocument::getVerticalPosition → NO_COVERAGE |
return top() - currentHeight - indentation.indentTop; |
1249 | } | |
1250 | ||
1251 | /** Holds the type of the last element, that has been added to the document. */ | |
1252 | protected int lastElementType = -1; | |
1253 | ||
1254 | /** | |
1255 | * Ensures that a new line has been started. | |
1256 | */ | |
1257 | protected void ensureNewLine() { | |
1258 | try { | |
1259 |
2
1. ensureNewLine : negated conditional → NO_COVERAGE 2. ensureNewLine : negated conditional → NO_COVERAGE |
if ((lastElementType == Element.PHRASE) || |
1260 | (lastElementType == Element.CHUNK)) { | |
1261 |
1
1. ensureNewLine : removed call to com/lowagie/text/pdf/PdfDocument::newLine → NO_COVERAGE |
newLine(); |
1262 | flushLines(); | |
1263 | } | |
1264 | } catch (DocumentException ex) { | |
1265 | throw new ExceptionConverter(ex); | |
1266 | } | |
1267 | } | |
1268 | ||
1269 | /** | |
1270 | * Writes all the lines to the text-object. | |
1271 | * | |
1272 | * @return the displacement that was caused | |
1273 | * @throws DocumentException on error | |
1274 | */ | |
1275 | protected float flushLines() throws DocumentException { | |
1276 | // checks if the ArrayList with the lines is not null | |
1277 |
1
1. flushLines : negated conditional → NO_COVERAGE |
if (lines == null) { |
1278 |
1
1. flushLines : replaced return of float value with -(x + 1) for com/lowagie/text/pdf/PdfDocument::flushLines → NO_COVERAGE |
return 0; |
1279 | } | |
1280 | // checks if a new Line has to be made. | |
1281 |
3
1. flushLines : changed conditional boundary → NO_COVERAGE 2. flushLines : negated conditional → NO_COVERAGE 3. flushLines : negated conditional → NO_COVERAGE |
if (line != null && line.size() > 0) { |
1282 | lines.add(line); | |
1283 | line = new PdfLine(indentLeft(), indentRight(), alignment, leading); | |
1284 | } | |
1285 | ||
1286 | // checks if the ArrayList with the lines is empty | |
1287 |
1
1. flushLines : negated conditional → NO_COVERAGE |
if (lines.isEmpty()) { |
1288 |
1
1. flushLines : replaced return of float value with -(x + 1) for com/lowagie/text/pdf/PdfDocument::flushLines → NO_COVERAGE |
return 0; |
1289 | } | |
1290 | ||
1291 | // initialization of some parameters | |
1292 | Object[] currentValues = new Object[2]; | |
1293 | PdfFont currentFont = null; | |
1294 | float displacement = 0; | |
1295 | PdfLine l; | |
1296 | Float lastBaseFactor = (float) 0; | |
1297 | currentValues[1] = lastBaseFactor; | |
1298 | // looping over all the lines | |
1299 | for (PdfLine line1 : lines) { | |
1300 | ||
1301 | // this is a line in the loop | |
1302 | l = line1; | |
1303 | ||
1304 |
4
1. flushLines : Replaced float subtraction with addition → NO_COVERAGE 2. flushLines : Replaced float addition with subtraction → NO_COVERAGE 3. flushLines : Replaced float addition with subtraction → NO_COVERAGE 4. flushLines : Replaced float addition with subtraction → NO_COVERAGE |
float moveTextX = l.indentLeft() - indentLeft() + indentation.indentLeft + indentation.listIndentLeft + indentation.sectionIndentLeft; |
1305 |
2
1. flushLines : removed negation → NO_COVERAGE 2. flushLines : removed call to com/lowagie/text/pdf/PdfContentByte::moveText → NO_COVERAGE |
text.moveText(moveTextX, -l.height()); |
1306 | // is the line preceded by a symbol? | |
1307 |
1
1. flushLines : negated conditional → NO_COVERAGE |
if (l.listSymbol() != null) { |
1308 |
2
1. flushLines : Replaced float subtraction with addition → NO_COVERAGE 2. flushLines : removed call to com/lowagie/text/pdf/ColumnText::showTextAligned → NO_COVERAGE |
ColumnText.showTextAligned(graphics, Element.ALIGN_LEFT, new Phrase(l.listSymbol()), text.getXTLM() - l.listIndent(), text.getYTLM(), 0); |
1309 | } | |
1310 | ||
1311 | currentValues[0] = currentFont; | |
1312 | ||
1313 |
1
1. flushLines : removed call to com/lowagie/text/pdf/PdfDocument::writeLineToContent → NO_COVERAGE |
writeLineToContent(l, text, graphics, currentValues, writer.getSpaceCharRatio()); |
1314 | ||
1315 | currentFont = (PdfFont) currentValues[0]; | |
1316 |
1
1. flushLines : Replaced float addition with subtraction → NO_COVERAGE |
displacement += l.height(); |
1317 |
2
1. flushLines : removed negation → NO_COVERAGE 2. flushLines : removed call to com/lowagie/text/pdf/PdfContentByte::moveText → NO_COVERAGE |
text.moveText(-moveTextX, 0); |
1318 | ||
1319 | } | |
1320 | lines = new ArrayList(); | |
1321 |
1
1. flushLines : replaced return of float value with -(x + 1) for com/lowagie/text/pdf/PdfDocument::flushLines → NO_COVERAGE |
return displacement; |
1322 | } | |
1323 | ||
1324 | /** The characters to be applied the hanging punctuation. */ | |
1325 | static final String hangingPunctuation = ".,;:'"; | |
1326 | ||
1327 | /** | |
1328 | * Writes a text line to the document. It takes care of all the attributes. | |
1329 | * <P> | |
1330 | * Before entering the line position must have been established and the | |
1331 | * <CODE>text</CODE> argument must be in text object scope (<CODE>beginText()</CODE>). | |
1332 | * @param line the line to be written | |
1333 | * @param text the <CODE>PdfContentByte</CODE> where the text will be written to | |
1334 | * @param graphics the <CODE>PdfContentByte</CODE> where the graphics will be written to | |
1335 | * @param currentValues the current font and extra spacing values | |
1336 | * @param ratio | |
1337 | * @throws DocumentException on error | |
1338 | */ | |
1339 | void writeLineToContent(PdfLine line, PdfContentByte text, PdfContentByte graphics, Object[] currentValues, float ratio) throws DocumentException { | |
1340 | PdfFont currentFont = (PdfFont)(currentValues[0]); | |
1341 | float lastBaseFactor = (Float) (currentValues[1]); | |
1342 | PdfChunk chunk; | |
1343 | int numberOfSpaces; | |
1344 | int lineLen; | |
1345 | boolean isJustified; | |
1346 | float hangingCorrection = 0; | |
1347 | float hScale = 1; | |
1348 | float lastHScale = Float.NaN; | |
1349 | float baseWordSpacing = 0; | |
1350 | float baseCharacterSpacing = 0; | |
1351 | float glueWidth = 0; | |
1352 | ||
1353 | numberOfSpaces = line.numberOfSpaces(); | |
1354 | lineLen = line.GetLineLengthUtf32(); | |
1355 | // does the line need to be justified? | |
1356 |
4
1. writeLineToContent : changed conditional boundary → NO_COVERAGE 2. writeLineToContent : negated conditional → NO_COVERAGE 3. writeLineToContent : negated conditional → NO_COVERAGE 4. writeLineToContent : negated conditional → NO_COVERAGE |
isJustified = line.hasToBeJustified() && (numberOfSpaces != 0 || lineLen > 1); |
1357 | int separatorCount = line.getSeparatorCount(); | |
1358 |
2
1. writeLineToContent : changed conditional boundary → NO_COVERAGE 2. writeLineToContent : negated conditional → NO_COVERAGE |
if (separatorCount > 0) { |
1359 |
1
1. writeLineToContent : Replaced float division with multiplication → NO_COVERAGE |
glueWidth = line.widthLeft() / separatorCount; |
1360 | } | |
1361 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
else if (isJustified) { |
1362 |
7
1. writeLineToContent : changed conditional boundary → NO_COVERAGE 2. writeLineToContent : Replaced float multiplication with division → NO_COVERAGE 3. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE 4. writeLineToContent : Replaced float subtraction with addition → NO_COVERAGE 5. writeLineToContent : Replaced float multiplication with division → NO_COVERAGE 6. writeLineToContent : negated conditional → NO_COVERAGE 7. writeLineToContent : negated conditional → NO_COVERAGE |
if (line.isNewlineSplit() && line.widthLeft() >= (lastBaseFactor * (ratio * numberOfSpaces + lineLen - 1))) { |
1363 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (line.isRTL()) { |
1364 |
6
1. writeLineToContent : Replaced float multiplication with division → NO_COVERAGE 2. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE 3. writeLineToContent : Replaced float subtraction with addition → NO_COVERAGE 4. writeLineToContent : Replaced float multiplication with division → NO_COVERAGE 5. writeLineToContent : Replaced float subtraction with addition → NO_COVERAGE 6. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::moveText → NO_COVERAGE |
text.moveText(line.widthLeft() - lastBaseFactor * (ratio * numberOfSpaces + lineLen - 1), 0); |
1365 | } | |
1366 |
1
1. writeLineToContent : Replaced float multiplication with division → NO_COVERAGE |
baseWordSpacing = ratio * lastBaseFactor; |
1367 | baseCharacterSpacing = lastBaseFactor; | |
1368 | } | |
1369 | else { | |
1370 | float width = line.widthLeft(); | |
1371 |
1
1. writeLineToContent : Replaced integer subtraction with addition → NO_COVERAGE |
PdfChunk last = line.getChunk(line.size() - 1); |
1372 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (last != null) { |
1373 | String s = last.toString(); | |
1374 | char c; | |
1375 |
5
1. writeLineToContent : changed conditional boundary → NO_COVERAGE 2. writeLineToContent : changed conditional boundary → NO_COVERAGE 3. writeLineToContent : Replaced integer subtraction with addition → NO_COVERAGE 4. writeLineToContent : negated conditional → NO_COVERAGE 5. writeLineToContent : negated conditional → NO_COVERAGE |
if (s.length() > 0 && hangingPunctuation.indexOf((c = s.charAt(s.length() - 1))) >= 0) { |
1376 | float oldWidth = width; | |
1377 |
2
1. writeLineToContent : Replaced float multiplication with division → NO_COVERAGE 2. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE |
width += last.font().width(c) * 0.4f; |
1378 |
1
1. writeLineToContent : Replaced float subtraction with addition → NO_COVERAGE |
hangingCorrection = width - oldWidth; |
1379 | } | |
1380 | } | |
1381 | // if there's a single word on the line and we are using NO_SPACE_CHAR_RATIO, | |
1382 | // we don't want any character spacing | |
1383 |
6
1. writeLineToContent : Replaced float multiplication with division → NO_COVERAGE 2. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE 3. writeLineToContent : Replaced float subtraction with addition → NO_COVERAGE 4. writeLineToContent : Replaced float division with multiplication → NO_COVERAGE 5. writeLineToContent : negated conditional → NO_COVERAGE 6. writeLineToContent : negated conditional → NO_COVERAGE |
float baseFactor = (numberOfSpaces == 0 && ratio == PdfWriter.NO_SPACE_CHAR_RATIO) |
1384 | ? 0f : width / (ratio * numberOfSpaces + lineLen - 1); | |
1385 |
1
1. writeLineToContent : Replaced float multiplication with division → NO_COVERAGE |
baseWordSpacing = ratio * baseFactor; |
1386 | baseCharacterSpacing = baseFactor; | |
1387 | lastBaseFactor = baseFactor; | |
1388 | } | |
1389 | } | |
1390 | ||
1391 | int lastChunkStroke = line.getLastStrokeChunk(); | |
1392 | int chunkStrokeIdx = 0; | |
1393 | float xMarker = text.getXTLM(); | |
1394 | float baseXMarker = xMarker; | |
1395 | float yMarker = text.getYTLM(); | |
1396 | boolean adjustMatrix = false; | |
1397 | float tabPosition = 0; | |
1398 | ||
1399 | // looping over all the chunks in 1 line | |
1400 | for (Iterator j = line.iterator(); j.hasNext(); ) { | |
1401 | chunk = (PdfChunk) j.next(); | |
1402 | Color color = chunk.color(); | |
1403 | hScale = 1; | |
1404 | ||
1405 |
2
1. writeLineToContent : changed conditional boundary → NO_COVERAGE 2. writeLineToContent : negated conditional → NO_COVERAGE |
if (chunkStrokeIdx <= lastChunkStroke) { |
1406 | float width; | |
1407 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (isJustified) { |
1408 | width = chunk.getWidthCorrected(baseCharacterSpacing, baseWordSpacing); | |
1409 | } | |
1410 | else { | |
1411 | width = chunk.width(); | |
1412 | } | |
1413 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (chunk.isStroked()) { |
1414 |
1
1. writeLineToContent : Replaced integer addition with subtraction → NO_COVERAGE |
PdfChunk nextChunk = line.getChunk(chunkStrokeIdx + 1); |
1415 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (chunk.isSeparator()) { |
1416 | width = glueWidth; | |
1417 | Object[] sep = (Object[])chunk.getAttribute(Chunk.SEPARATOR); | |
1418 | DrawInterface di = (DrawInterface)sep[0]; | |
1419 | Boolean vertical = (Boolean)sep[1]; | |
1420 | float fontSize = chunk.font().size(); | |
1421 | float ascender = chunk.font().getFont().getFontDescriptor(BaseFont.ASCENT, fontSize); | |
1422 | float descender = chunk.font().getFont().getFontDescriptor(BaseFont.DESCENT, fontSize); | |
1423 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (vertical) { |
1424 |
4
1. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE 2. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE 3. writeLineToContent : Replaced float subtraction with addition → NO_COVERAGE 4. writeLineToContent : removed call to com/lowagie/text/pdf/draw/DrawInterface::draw → NO_COVERAGE |
di.draw(graphics, baseXMarker, yMarker + descender, baseXMarker + line.getOriginalWidth(), ascender - descender, yMarker); |
1425 | } | |
1426 | else { | |
1427 |
4
1. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE 2. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE 3. writeLineToContent : Replaced float subtraction with addition → NO_COVERAGE 4. writeLineToContent : removed call to com/lowagie/text/pdf/draw/DrawInterface::draw → NO_COVERAGE |
di.draw(graphics, xMarker, yMarker + descender, xMarker + width, ascender - descender, yMarker); |
1428 | } | |
1429 | } | |
1430 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (chunk.isTab()) { |
1431 | Object[] tab = (Object[])chunk.getAttribute(Chunk.TAB); | |
1432 | DrawInterface di = (DrawInterface)tab[0]; | |
1433 |
1
1. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE |
tabPosition = (Float) tab[1] + (Float) tab[3]; |
1434 | float fontSize = chunk.font().size(); | |
1435 | float ascender = chunk.font().getFont().getFontDescriptor(BaseFont.ASCENT, fontSize); | |
1436 | float descender = chunk.font().getFont().getFontDescriptor(BaseFont.DESCENT, fontSize); | |
1437 |
2
1. writeLineToContent : changed conditional boundary → NO_COVERAGE 2. writeLineToContent : negated conditional → NO_COVERAGE |
if (tabPosition > xMarker) { |
1438 |
3
1. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE 2. writeLineToContent : Replaced float subtraction with addition → NO_COVERAGE 3. writeLineToContent : removed call to com/lowagie/text/pdf/draw/DrawInterface::draw → NO_COVERAGE |
di.draw(graphics, xMarker, yMarker + descender, tabPosition, ascender - descender, yMarker); |
1439 | } | |
1440 | float tmp = xMarker; | |
1441 | xMarker = tabPosition; | |
1442 | tabPosition = tmp; | |
1443 | } | |
1444 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (chunk.isAttribute(Chunk.BACKGROUND)) { |
1445 | float subtract = lastBaseFactor; | |
1446 |
2
1. writeLineToContent : negated conditional → NO_COVERAGE 2. writeLineToContent : negated conditional → NO_COVERAGE |
if (nextChunk != null && nextChunk.isAttribute(Chunk.BACKGROUND)) |
1447 | subtract = 0; | |
1448 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (nextChunk == null) |
1449 |
1
1. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE |
subtract += hangingCorrection; |
1450 | float fontSize = chunk.font().size(); | |
1451 | float ascender = chunk.font().getFont().getFontDescriptor(BaseFont.ASCENT, fontSize); | |
1452 | float descender = chunk.font().getFont().getFontDescriptor(BaseFont.DESCENT, fontSize); | |
1453 | Object[] bgr = (Object[]) chunk.getAttribute(Chunk.BACKGROUND); | |
1454 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::setColorFill → NO_COVERAGE |
graphics.setColorFill((Color)bgr[0]); |
1455 | float[] extra = (float[]) bgr[1]; | |
1456 |
4
1. writeLineToContent : Replaced float subtraction with addition → NO_COVERAGE 2. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE 3. writeLineToContent : Replaced float subtraction with addition → NO_COVERAGE 4. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::rectangle → NO_COVERAGE |
graphics.rectangle(xMarker - extra[0], |
1457 |
7
1. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE 2. writeLineToContent : Replaced float subtraction with addition → NO_COVERAGE 3. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE 4. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE 5. writeLineToContent : Replaced float subtraction with addition → NO_COVERAGE 6. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE 7. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE |
yMarker + descender - extra[1] + chunk.getTextRise(), |
1458 | width - subtract + extra[0] + extra[2], | |
1459 | ascender - descender + extra[1] + extra[3]); | |
1460 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::fill → NO_COVERAGE |
graphics.fill(); |
1461 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::setGrayFill → NO_COVERAGE |
graphics.setGrayFill(0); |
1462 | } | |
1463 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (chunk.isAttribute(Chunk.UNDERLINE)) { |
1464 | float subtract = lastBaseFactor; | |
1465 |
2
1. writeLineToContent : negated conditional → NO_COVERAGE 2. writeLineToContent : negated conditional → NO_COVERAGE |
if (nextChunk != null && nextChunk.isAttribute(Chunk.UNDERLINE)) |
1466 | subtract = 0; | |
1467 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (nextChunk == null) |
1468 |
1
1. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE |
subtract += hangingCorrection; |
1469 | Object[][] unders = (Object[][]) chunk.getAttribute(Chunk.UNDERLINE); | |
1470 | Color scolor = null; | |
1471 | for (Object[] obj : unders) { | |
1472 | scolor = (Color) obj[0]; | |
1473 | float[] ps = (float[]) obj[1]; | |
1474 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (scolor == null) |
1475 | scolor = color; | |
1476 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (scolor != null) |
1477 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::setColorStroke → NO_COVERAGE |
graphics.setColorStroke(scolor); |
1478 | float fsize = chunk.font().size(); | |
1479 |
3
1. writeLineToContent : Replaced float multiplication with division → NO_COVERAGE 2. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE 3. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::setLineWidth → NO_COVERAGE |
graphics.setLineWidth(ps[0] + fsize * ps[1]); |
1480 |
2
1. writeLineToContent : Replaced float multiplication with division → NO_COVERAGE 2. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE |
float shift = ps[2] + fsize * ps[3]; |
1481 | int cap2 = (int) ps[4]; | |
1482 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (cap2 != 0) |
1483 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::setLineCap → NO_COVERAGE |
graphics.setLineCap(cap2); |
1484 |
2
1. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE 2. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::moveTo → NO_COVERAGE |
graphics.moveTo(xMarker, yMarker + shift); |
1485 |
4
1. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE 2. writeLineToContent : Replaced float subtraction with addition → NO_COVERAGE 3. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE 4. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::lineTo → NO_COVERAGE |
graphics.lineTo(xMarker + width - subtract, yMarker + shift); |
1486 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::stroke → NO_COVERAGE |
graphics.stroke(); |
1487 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (scolor != null) |
1488 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::resetGrayStroke → NO_COVERAGE |
graphics.resetGrayStroke(); |
1489 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (cap2 != 0) |
1490 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::setLineCap → NO_COVERAGE |
graphics.setLineCap(0); |
1491 | } | |
1492 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::setLineWidth → NO_COVERAGE |
graphics.setLineWidth(1); |
1493 | } | |
1494 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (chunk.isAttribute(Chunk.ACTION)) { |
1495 | float subtract = lastBaseFactor; | |
1496 |
2
1. writeLineToContent : negated conditional → NO_COVERAGE 2. writeLineToContent : negated conditional → NO_COVERAGE |
if (nextChunk != null && nextChunk.isAttribute(Chunk.ACTION)) |
1497 | subtract = 0; | |
1498 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (nextChunk == null) |
1499 |
1
1. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE |
subtract += hangingCorrection; |
1500 |
4
1. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE 2. writeLineToContent : Replaced float subtraction with addition → NO_COVERAGE 3. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE 4. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::addAnnotation → NO_COVERAGE |
text.addAnnotation(new PdfAnnotation(writer, xMarker, yMarker, xMarker + width - subtract, yMarker + chunk.font().size(), (PdfAction)chunk.getAttribute(Chunk.ACTION))); |
1501 | } | |
1502 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (chunk.isAttribute(Chunk.REMOTEGOTO)) { |
1503 | float subtract = lastBaseFactor; | |
1504 |
2
1. writeLineToContent : negated conditional → NO_COVERAGE 2. writeLineToContent : negated conditional → NO_COVERAGE |
if (nextChunk != null && nextChunk.isAttribute(Chunk.REMOTEGOTO)) |
1505 | subtract = 0; | |
1506 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (nextChunk == null) |
1507 |
1
1. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE |
subtract += hangingCorrection; |
1508 | Object[] obj = (Object[]) chunk.getAttribute(Chunk.REMOTEGOTO); | |
1509 | String filename = (String)obj[0]; | |
1510 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (obj[1] instanceof String) |
1511 |
4
1. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE 2. writeLineToContent : Replaced float subtraction with addition → NO_COVERAGE 3. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE 4. writeLineToContent : removed call to com/lowagie/text/pdf/PdfDocument::remoteGoto → NO_COVERAGE |
remoteGoto(filename, (String)obj[1], xMarker, yMarker, xMarker + width - subtract, yMarker + chunk.font().size()); |
1512 | else | |
1513 |
4
1. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE 2. writeLineToContent : Replaced float subtraction with addition → NO_COVERAGE 3. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE 4. writeLineToContent : removed call to com/lowagie/text/pdf/PdfDocument::remoteGoto → NO_COVERAGE |
remoteGoto(filename, (Integer) obj[1], xMarker, yMarker, xMarker + width - subtract, yMarker + chunk.font().size()); |
1514 | } | |
1515 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (chunk.isAttribute(Chunk.LOCALGOTO)) { |
1516 | float subtract = lastBaseFactor; | |
1517 |
2
1. writeLineToContent : negated conditional → NO_COVERAGE 2. writeLineToContent : negated conditional → NO_COVERAGE |
if (nextChunk != null && nextChunk.isAttribute(Chunk.LOCALGOTO)) |
1518 | subtract = 0; | |
1519 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (nextChunk == null) |
1520 |
1
1. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE |
subtract += hangingCorrection; |
1521 |
4
1. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE 2. writeLineToContent : Replaced float subtraction with addition → NO_COVERAGE 3. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE 4. writeLineToContent : removed call to com/lowagie/text/pdf/PdfDocument::localGoto → NO_COVERAGE |
localGoto((String)chunk.getAttribute(Chunk.LOCALGOTO), xMarker, yMarker, xMarker + width - subtract, yMarker + chunk.font().size()); |
1522 | } | |
1523 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (chunk.isAttribute(Chunk.LOCALDESTINATION)) { |
1524 | float subtract = lastBaseFactor; | |
1525 |
2
1. writeLineToContent : negated conditional → NO_COVERAGE 2. writeLineToContent : negated conditional → NO_COVERAGE |
if (nextChunk != null && nextChunk.isAttribute(Chunk.LOCALDESTINATION)) |
1526 | subtract = 0; | |
1527 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (nextChunk == null) |
1528 |
1
1. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE |
subtract += hangingCorrection; |
1529 |
1
1. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE |
localDestination((String)chunk.getAttribute(Chunk.LOCALDESTINATION), new PdfDestination(PdfDestination.XYZ, xMarker, yMarker + chunk.font().size(), 0)); |
1530 | } | |
1531 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (chunk.isAttribute(Chunk.GENERICTAG)) { |
1532 | float subtract = lastBaseFactor; | |
1533 |
2
1. writeLineToContent : negated conditional → NO_COVERAGE 2. writeLineToContent : negated conditional → NO_COVERAGE |
if (nextChunk != null && nextChunk.isAttribute(Chunk.GENERICTAG)) |
1534 | subtract = 0; | |
1535 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (nextChunk == null) |
1536 |
1
1. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE |
subtract += hangingCorrection; |
1537 |
3
1. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE 2. writeLineToContent : Replaced float subtraction with addition → NO_COVERAGE 3. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE |
Rectangle rect = new Rectangle(xMarker, yMarker, xMarker + width - subtract, yMarker + chunk.font().size()); |
1538 | PdfPageEvent pev = writer.getPageEvent(); | |
1539 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (pev != null) |
1540 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfPageEvent::onGenericTag → NO_COVERAGE |
pev.onGenericTag(writer, this, rect, (String)chunk.getAttribute(Chunk.GENERICTAG)); |
1541 | } | |
1542 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (chunk.isAttribute(Chunk.PDFANNOTATION)) { |
1543 | float subtract = lastBaseFactor; | |
1544 |
2
1. writeLineToContent : negated conditional → NO_COVERAGE 2. writeLineToContent : negated conditional → NO_COVERAGE |
if (nextChunk != null && nextChunk.isAttribute(Chunk.PDFANNOTATION)) |
1545 | subtract = 0; | |
1546 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (nextChunk == null) |
1547 |
1
1. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE |
subtract += hangingCorrection; |
1548 | float fontSize = chunk.font().size(); | |
1549 | float ascender = chunk.font().getFont().getFontDescriptor(BaseFont.ASCENT, fontSize); | |
1550 | float descender = chunk.font().getFont().getFontDescriptor(BaseFont.DESCENT, fontSize); | |
1551 | PdfAnnotation annot = PdfFormField.shallowDuplicate((PdfAnnotation)chunk.getAttribute(Chunk.PDFANNOTATION)); | |
1552 |
5
1. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE 2. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE 3. writeLineToContent : Replaced float subtraction with addition → NO_COVERAGE 4. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE 5. writeLineToContent : removed call to com/lowagie/text/pdf/PdfAnnotation::put → NO_COVERAGE |
annot.put(PdfName.RECT, new PdfRectangle(xMarker, yMarker + descender, xMarker + width - subtract, yMarker + ascender)); |
1553 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::addAnnotation → NO_COVERAGE |
text.addAnnotation(annot); |
1554 | } | |
1555 | float[] params = (float[]) chunk.getAttribute(Chunk.SKEW); | |
1556 | Float hs = (Float)chunk.getAttribute(Chunk.HSCALE); | |
1557 |
2
1. writeLineToContent : negated conditional → NO_COVERAGE 2. writeLineToContent : negated conditional → NO_COVERAGE |
if (params != null || hs != null) { |
1558 | float b = 0, c = 0; | |
1559 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (params != null) { |
1560 | b = params[0]; | |
1561 | c = params[1]; | |
1562 | } | |
1563 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (hs != null) |
1564 | hScale = hs; | |
1565 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::setTextMatrix → NO_COVERAGE |
text.setTextMatrix(hScale, b, c, 1, xMarker, yMarker); |
1566 | } | |
1567 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (chunk.isAttribute(Chunk.CHAR_SPACING)) { |
1568 | Float cs = (Float) chunk.getAttribute(Chunk.CHAR_SPACING); | |
1569 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::setCharacterSpacing → NO_COVERAGE |
text.setCharacterSpacing(cs); |
1570 | } | |
1571 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (chunk.isImage()) { |
1572 | Image image = chunk.getImage(); | |
1573 | float[] matrix = image.matrix(); | |
1574 |
2
1. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE 2. writeLineToContent : Replaced float subtraction with addition → NO_COVERAGE |
matrix[Image.CX] = xMarker + chunk.getImageOffsetX() - matrix[Image.CX]; |
1575 |
2
1. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE 2. writeLineToContent : Replaced float subtraction with addition → NO_COVERAGE |
matrix[Image.CY] = yMarker + chunk.getImageOffsetY() - matrix[Image.CY]; |
1576 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::addImage → NO_COVERAGE |
graphics.addImage(image, matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); |
1577 |
4
1. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE 2. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE 3. writeLineToContent : Replaced float subtraction with addition → NO_COVERAGE 4. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::moveText → NO_COVERAGE |
text.moveText(xMarker + lastBaseFactor + image.getScaledWidth() - text.getXTLM(), 0); |
1578 | } | |
1579 | } | |
1580 |
1
1. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE |
xMarker += width; |
1581 |
1
1. writeLineToContent : Changed increment from 1 to -1 → NO_COVERAGE |
++chunkStrokeIdx; |
1582 | } | |
1583 | ||
1584 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (chunk.font().compareTo(currentFont) != 0) { |
1585 | currentFont = chunk.font(); | |
1586 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::setFontAndSize → NO_COVERAGE |
text.setFontAndSize(currentFont.getFont(), currentFont.size()); |
1587 | } | |
1588 | float rise = 0; | |
1589 | Object[] textRender = (Object[]) chunk.getAttribute(Chunk.TEXTRENDERMODE); | |
1590 | int tr = 0; | |
1591 | float strokeWidth = 1; | |
1592 | Color strokeColor = null; | |
1593 | Float fr = (Float)chunk.getAttribute(Chunk.SUBSUPSCRIPT); | |
1594 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (textRender != null) { |
1595 |
1
1. writeLineToContent : Replaced bitwise AND with OR → NO_COVERAGE |
tr = (Integer) textRender[0] & 3; |
1596 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (tr != PdfContentByte.TEXT_RENDER_MODE_FILL) |
1597 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::setTextRenderingMode → NO_COVERAGE |
text.setTextRenderingMode(tr); |
1598 |
2
1. writeLineToContent : negated conditional → NO_COVERAGE 2. writeLineToContent : negated conditional → NO_COVERAGE |
if (tr == PdfContentByte.TEXT_RENDER_MODE_STROKE || tr == PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE) { |
1599 | strokeWidth = (Float) textRender[1]; | |
1600 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (strokeWidth != 1) |
1601 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::setLineWidth → NO_COVERAGE |
text.setLineWidth(strokeWidth); |
1602 | strokeColor = (Color)textRender[2]; | |
1603 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (strokeColor == null) |
1604 | strokeColor = color; | |
1605 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (strokeColor != null) |
1606 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::setColorStroke → NO_COVERAGE |
text.setColorStroke(strokeColor); |
1607 | } | |
1608 | } | |
1609 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (fr != null) |
1610 | rise = fr; | |
1611 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (color != null) |
1612 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::setColorFill → NO_COVERAGE |
text.setColorFill(color); |
1613 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (rise != 0) |
1614 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::setTextRise → NO_COVERAGE |
text.setTextRise(rise); |
1615 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (chunk.isImage()) { |
1616 | adjustMatrix = true; | |
1617 | } | |
1618 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
else if (chunk.isHorizontalSeparator()) { |
1619 | PdfTextArray array = new PdfTextArray(); | |
1620 |
5
1. writeLineToContent : removed negation → NO_COVERAGE 2. writeLineToContent : Replaced float multiplication with division → NO_COVERAGE 3. writeLineToContent : Replaced float division with multiplication → NO_COVERAGE 4. writeLineToContent : Replaced float division with multiplication → NO_COVERAGE 5. writeLineToContent : removed call to com/lowagie/text/pdf/PdfTextArray::add → NO_COVERAGE |
array.add(-glueWidth * 1000f / chunk.font.size() / hScale); |
1621 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::showText → NO_COVERAGE |
text.showText(array); |
1622 | } | |
1623 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
else if (chunk.isTab()) { |
1624 | PdfTextArray array = new PdfTextArray(); | |
1625 |
5
1. writeLineToContent : Replaced float subtraction with addition → NO_COVERAGE 2. writeLineToContent : Replaced float multiplication with division → NO_COVERAGE 3. writeLineToContent : Replaced float division with multiplication → NO_COVERAGE 4. writeLineToContent : Replaced float division with multiplication → NO_COVERAGE 5. writeLineToContent : removed call to com/lowagie/text/pdf/PdfTextArray::add → NO_COVERAGE |
array.add((tabPosition - xMarker) * 1000f / chunk.font.size() / hScale); |
1626 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::showText → NO_COVERAGE |
text.showText(array); |
1627 | } | |
1628 | // If it is a CJK chunk or Unicode TTF we will have to simulate the | |
1629 | // space adjustment. | |
1630 |
4
1. writeLineToContent : changed conditional boundary → NO_COVERAGE 2. writeLineToContent : negated conditional → NO_COVERAGE 3. writeLineToContent : negated conditional → NO_COVERAGE 4. writeLineToContent : negated conditional → NO_COVERAGE |
else if (isJustified && numberOfSpaces > 0 && chunk.isSpecialEncoding()) { |
1631 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (hScale != lastHScale) { |
1632 | lastHScale = hScale; | |
1633 |
2
1. writeLineToContent : Replaced float division with multiplication → NO_COVERAGE 2. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::setWordSpacing → NO_COVERAGE |
text.setWordSpacing(baseWordSpacing / hScale); |
1634 |
3
1. writeLineToContent : Replaced float division with multiplication → NO_COVERAGE 2. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE 3. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::setCharacterSpacing → NO_COVERAGE |
text.setCharacterSpacing(baseCharacterSpacing / hScale + text.getCharacterSpacing()); |
1635 | } | |
1636 | String s = chunk.toString(); | |
1637 | int idx = s.indexOf(' '); | |
1638 |
2
1. writeLineToContent : changed conditional boundary → NO_COVERAGE 2. writeLineToContent : negated conditional → NO_COVERAGE |
if (idx < 0) |
1639 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::showText → NO_COVERAGE |
text.showText(s); |
1640 | else { | |
1641 |
4
1. writeLineToContent : removed negation → NO_COVERAGE 2. writeLineToContent : Replaced float multiplication with division → NO_COVERAGE 3. writeLineToContent : Replaced float division with multiplication → NO_COVERAGE 4. writeLineToContent : Replaced float division with multiplication → NO_COVERAGE |
float spaceCorrection = - baseWordSpacing * 1000f / chunk.font.size() / hScale; |
1642 | PdfTextArray textArray = new PdfTextArray(s.substring(0, idx)); | |
1643 | int lastIdx = idx; | |
1644 |
3
1. writeLineToContent : changed conditional boundary → NO_COVERAGE 2. writeLineToContent : Replaced integer addition with subtraction → NO_COVERAGE 3. writeLineToContent : negated conditional → NO_COVERAGE |
while ((idx = s.indexOf(' ', lastIdx + 1)) >= 0) { |
1645 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfTextArray::add → NO_COVERAGE |
textArray.add(spaceCorrection); |
1646 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfTextArray::add → NO_COVERAGE |
textArray.add(s.substring(lastIdx, idx)); |
1647 | lastIdx = idx; | |
1648 | } | |
1649 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfTextArray::add → NO_COVERAGE |
textArray.add(spaceCorrection); |
1650 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfTextArray::add → NO_COVERAGE |
textArray.add(s.substring(lastIdx)); |
1651 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::showText → NO_COVERAGE |
text.showText(textArray); |
1652 | } | |
1653 | } | |
1654 | else { | |
1655 |
2
1. writeLineToContent : negated conditional → NO_COVERAGE 2. writeLineToContent : negated conditional → NO_COVERAGE |
if (isJustified && hScale != lastHScale) { |
1656 | lastHScale = hScale; | |
1657 |
2
1. writeLineToContent : Replaced float division with multiplication → NO_COVERAGE 2. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::setWordSpacing → NO_COVERAGE |
text.setWordSpacing(baseWordSpacing / hScale); |
1658 |
3
1. writeLineToContent : Replaced float division with multiplication → NO_COVERAGE 2. writeLineToContent : Replaced float addition with subtraction → NO_COVERAGE 3. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::setCharacterSpacing → NO_COVERAGE |
text.setCharacterSpacing(baseCharacterSpacing / hScale + text.getCharacterSpacing()); |
1659 | } | |
1660 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::showText → NO_COVERAGE |
text.showText(chunk.toString()); |
1661 | } | |
1662 | ||
1663 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (rise != 0) |
1664 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::setTextRise → NO_COVERAGE |
text.setTextRise(0); |
1665 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (color != null) |
1666 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::resetRGBColorFill → NO_COVERAGE |
text.resetRGBColorFill(); |
1667 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (tr != PdfContentByte.TEXT_RENDER_MODE_FILL) |
1668 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::setTextRenderingMode → NO_COVERAGE |
text.setTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_FILL); |
1669 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (strokeColor != null) |
1670 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::resetRGBColorStroke → NO_COVERAGE |
text.resetRGBColorStroke(); |
1671 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (strokeWidth != 1) |
1672 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::setLineWidth → NO_COVERAGE |
text.setLineWidth(1); |
1673 |
2
1. writeLineToContent : negated conditional → NO_COVERAGE 2. writeLineToContent : negated conditional → NO_COVERAGE |
if (chunk.isAttribute(Chunk.SKEW) || chunk.isAttribute(Chunk.HSCALE)) { |
1674 | adjustMatrix = true; | |
1675 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::setTextMatrix → NO_COVERAGE |
text.setTextMatrix(xMarker, yMarker); |
1676 | } | |
1677 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (chunk.isAttribute(Chunk.CHAR_SPACING)) { |
1678 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::setCharacterSpacing → NO_COVERAGE |
text.setCharacterSpacing(baseCharacterSpacing); |
1679 | } | |
1680 | } | |
1681 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (isJustified) { |
1682 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::setWordSpacing → NO_COVERAGE |
text.setWordSpacing(0); |
1683 |
1
1. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::setCharacterSpacing → NO_COVERAGE |
text.setCharacterSpacing(0); |
1684 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (line.isNewlineSplit()) |
1685 | lastBaseFactor = 0; | |
1686 | } | |
1687 |
1
1. writeLineToContent : negated conditional → NO_COVERAGE |
if (adjustMatrix) |
1688 |
2
1. writeLineToContent : Replaced float subtraction with addition → NO_COVERAGE 2. writeLineToContent : removed call to com/lowagie/text/pdf/PdfContentByte::moveText → NO_COVERAGE |
text.moveText(baseXMarker - text.getXTLM(), 0); |
1689 | currentValues[0] = currentFont; | |
1690 | currentValues[1] = lastBaseFactor; | |
1691 | } | |
1692 | ||
1693 | protected Indentation indentation = new Indentation(); | |
1694 | ||
1695 | /** | |
1696 | * @since 2.0.8 (PdfDocument was package-private before) | |
1697 | */ | |
1698 | public static class Indentation { | |
1699 | ||
1700 | /** This represents the current indentation of the PDF Elements on the left side. */ | |
1701 | float indentLeft = 0; | |
1702 | ||
1703 | /** Indentation to the left caused by a section. */ | |
1704 | float sectionIndentLeft = 0; | |
1705 | ||
1706 | /** This represents the current indentation of the PDF Elements on the left side. */ | |
1707 | float listIndentLeft = 0; | |
1708 | ||
1709 | /** This is the indentation caused by an image on the left. */ | |
1710 | float imageIndentLeft = 0; | |
1711 | ||
1712 | /** This represents the current indentation of the PDF Elements on the right side. */ | |
1713 | float indentRight = 0; | |
1714 | ||
1715 | /** Indentation to the right caused by a section. */ | |
1716 | float sectionIndentRight = 0; | |
1717 | ||
1718 | /** This is the indentation caused by an image on the right. */ | |
1719 | float imageIndentRight = 0; | |
1720 | ||
1721 | /** This represents the current indentation of the PDF Elements on the top side. */ | |
1722 | float indentTop = 0; | |
1723 | ||
1724 | /** This represents the current indentation of the PDF Elements on the bottom side. */ | |
1725 | float indentBottom = 0; | |
1726 | } | |
1727 | ||
1728 | /** | |
1729 | * Gets the indentation on the left side. | |
1730 | * | |
1731 | * @return a margin | |
1732 | */ | |
1733 | ||
1734 | protected float indentLeft() { | |
1735 |
4
1. indentLeft : Replaced float addition with subtraction → NO_COVERAGE 2. indentLeft : Replaced float addition with subtraction → NO_COVERAGE 3. indentLeft : Replaced float addition with subtraction → NO_COVERAGE 4. indentLeft : replaced return of float value with -(x + 1) for com/lowagie/text/pdf/PdfDocument::indentLeft → NO_COVERAGE |
return left(indentation.indentLeft + indentation.listIndentLeft + indentation.imageIndentLeft + indentation.sectionIndentLeft); |
1736 | } | |
1737 | ||
1738 | /** | |
1739 | * Gets the indentation on the right side. | |
1740 | * | |
1741 | * @return a margin | |
1742 | */ | |
1743 | ||
1744 | protected float indentRight() { | |
1745 |
3
1. indentRight : Replaced float addition with subtraction → NO_COVERAGE 2. indentRight : Replaced float addition with subtraction → NO_COVERAGE 3. indentRight : replaced return of float value with -(x + 1) for com/lowagie/text/pdf/PdfDocument::indentRight → NO_COVERAGE |
return right(indentation.indentRight + indentation.sectionIndentRight + indentation.imageIndentRight); |
1746 | } | |
1747 | ||
1748 | /** | |
1749 | * Gets the indentation on the top side. | |
1750 | * | |
1751 | * @return a margin | |
1752 | */ | |
1753 | ||
1754 | protected float indentTop() { | |
1755 |
1
1. indentTop : replaced return of float value with -(x + 1) for com/lowagie/text/pdf/PdfDocument::indentTop → NO_COVERAGE |
return top(indentation.indentTop); |
1756 | } | |
1757 | ||
1758 | /** | |
1759 | * Gets the indentation on the bottom side. | |
1760 | * | |
1761 | * @return a margin | |
1762 | */ | |
1763 | ||
1764 | float indentBottom() { | |
1765 |
1
1. indentBottom : replaced return of float value with -(x + 1) for com/lowagie/text/pdf/PdfDocument::indentBottom → NO_COVERAGE |
return bottom(indentation.indentBottom); |
1766 | } | |
1767 | ||
1768 | /** | |
1769 | * Adds extra space. | |
1770 | * This method should probably be rewritten. | |
1771 | */ | |
1772 | protected void addSpacing(float extraspace, float oldleading, Font f) { | |
1773 |
1
1. addSpacing : negated conditional → NO_COVERAGE |
if (extraspace == 0) return; |
1774 |
1
1. addSpacing : negated conditional → NO_COVERAGE |
if (pageEmpty) return; |
1775 |
5
1. addSpacing : changed conditional boundary → NO_COVERAGE 2. addSpacing : Replaced float addition with subtraction → NO_COVERAGE 3. addSpacing : Replaced float addition with subtraction → NO_COVERAGE 4. addSpacing : Replaced float subtraction with addition → NO_COVERAGE 5. addSpacing : negated conditional → NO_COVERAGE |
if (currentHeight + line.height() + leading > indentTop() - indentBottom()) return; |
1776 | leading = extraspace; | |
1777 |
1
1. addSpacing : removed call to com/lowagie/text/pdf/PdfDocument::carriageReturn → NO_COVERAGE |
carriageReturn(); |
1778 |
2
1. addSpacing : negated conditional → NO_COVERAGE 2. addSpacing : negated conditional → NO_COVERAGE |
if (f.isUnderlined() || f.isStrikethru()) { |
1779 | f = new Font(f); | |
1780 | int style = f.getStyle(); | |
1781 |
1
1. addSpacing : Replaced bitwise AND with OR → NO_COVERAGE |
style &= ~Font.UNDERLINE; |
1782 |
1
1. addSpacing : Replaced bitwise AND with OR → NO_COVERAGE |
style &= ~Font.STRIKETHRU; |
1783 |
1
1. addSpacing : removed call to com/lowagie/text/Font::setStyle → NO_COVERAGE |
f.setStyle(style); |
1784 | } | |
1785 | Chunk space = new Chunk(" ", f); | |
1786 | space.process(this); | |
1787 |
1
1. addSpacing : removed call to com/lowagie/text/pdf/PdfDocument::carriageReturn → NO_COVERAGE |
carriageReturn(); |
1788 | leading = oldleading; | |
1789 | } | |
1790 | ||
1791 | // Info Dictionary and Catalog | |
1792 | ||
1793 | /** some meta information about the Document. */ | |
1794 | protected PdfInfo info = new PdfInfo(); | |
1795 | ||
1796 | /** | |
1797 | * Gets the <CODE>PdfInfo</CODE>-object. | |
1798 | * | |
1799 | * @return <CODE>PdfInfo</COPE> | |
1800 | */ | |
1801 | ||
1802 | protected PdfInfo getInfo() { | |
1803 | return info; | |
1804 | } | |
1805 | ||
1806 | /** | |
1807 | * Gets the <CODE>PdfCatalog</CODE>-object. | |
1808 | * | |
1809 | * @param pages an indirect reference to this document pages | |
1810 | * @return <CODE>PdfCatalog</CODE> | |
1811 | */ | |
1812 | ||
1813 | PdfCatalog getCatalog(PdfIndirectReference pages) { | |
1814 | PdfCatalog catalog = new PdfCatalog(pages, writer); | |
1815 | ||
1816 | // [C1] outlines | |
1817 |
2
1. getCatalog : changed conditional boundary → NO_COVERAGE 2. getCatalog : negated conditional → NO_COVERAGE |
if (rootOutline.getKids().size() > 0) { |
1818 |
1
1. getCatalog : removed call to com/lowagie/text/pdf/PdfDocument$PdfCatalog::put → NO_COVERAGE |
catalog.put(PdfName.PAGEMODE, PdfName.USEOUTLINES); |
1819 |
1
1. getCatalog : removed call to com/lowagie/text/pdf/PdfDocument$PdfCatalog::put → NO_COVERAGE |
catalog.put(PdfName.OUTLINES, rootOutline.indirectReference()); |
1820 | } | |
1821 | ||
1822 | // [C2] version | |
1823 |
1
1. getCatalog : removed call to com/lowagie/text/pdf/internal/PdfVersionImp::addToCatalog → NO_COVERAGE |
writer.getPdfVersion().addToCatalog(catalog); |
1824 | ||
1825 | // [C3] preferences | |
1826 |
1
1. getCatalog : removed call to com/lowagie/text/pdf/internal/PdfViewerPreferencesImp::addToCatalog → NO_COVERAGE |
viewerPreferences.addToCatalog(catalog); |
1827 | ||
1828 | // [C4] pagelabels | |
1829 |
1
1. getCatalog : negated conditional → NO_COVERAGE |
if (pageLabels != null) { |
1830 |
1
1. getCatalog : removed call to com/lowagie/text/pdf/PdfDocument$PdfCatalog::put → NO_COVERAGE |
catalog.put(PdfName.PAGELABELS, pageLabels.getDictionary(writer)); |
1831 | } | |
1832 | ||
1833 | // [C5] named objects | |
1834 |
1
1. getCatalog : removed call to com/lowagie/text/pdf/PdfDocument$PdfCatalog::addNames → NO_COVERAGE |
catalog.addNames(localDestinations, getDocumentLevelJS(), documentFileAttachment, writer); |
1835 | ||
1836 | // [C6] actions | |
1837 |
1
1. getCatalog : negated conditional → NO_COVERAGE |
if (openActionName != null) { |
1838 | PdfAction action = getLocalGotoAction(openActionName); | |
1839 |
1
1. getCatalog : removed call to com/lowagie/text/pdf/PdfDocument$PdfCatalog::setOpenAction → NO_COVERAGE |
catalog.setOpenAction(action); |
1840 | } | |
1841 |
1
1. getCatalog : negated conditional → NO_COVERAGE |
else if (openActionAction != null) |
1842 |
1
1. getCatalog : removed call to com/lowagie/text/pdf/PdfDocument$PdfCatalog::setOpenAction → NO_COVERAGE |
catalog.setOpenAction(openActionAction); |
1843 |
1
1. getCatalog : negated conditional → NO_COVERAGE |
if (additionalActions != null) { |
1844 |
1
1. getCatalog : removed call to com/lowagie/text/pdf/PdfDocument$PdfCatalog::setAdditionalActions → NO_COVERAGE |
catalog.setAdditionalActions(additionalActions); |
1845 | } | |
1846 | ||
1847 | // [C7] portable collections | |
1848 |
1
1. getCatalog : negated conditional → NO_COVERAGE |
if (collection != null) { |
1849 |
1
1. getCatalog : removed call to com/lowagie/text/pdf/PdfDocument$PdfCatalog::put → NO_COVERAGE |
catalog.put(PdfName.COLLECTION, collection); |
1850 | } | |
1851 | ||
1852 | // [C8] AcroForm | |
1853 |
1
1. getCatalog : negated conditional → NO_COVERAGE |
if (annotationsImp.hasValidAcroForm()) { |
1854 | try { | |
1855 |
1
1. getCatalog : removed call to com/lowagie/text/pdf/PdfDocument$PdfCatalog::put → NO_COVERAGE |
catalog.put(PdfName.ACROFORM, writer.addToBody(annotationsImp.getAcroForm()).getIndirectReference()); |
1856 | } | |
1857 | catch (IOException e) { | |
1858 | throw new ExceptionConverter(e); | |
1859 | } | |
1860 | } | |
1861 | ||
1862 |
1
1. getCatalog : mutated return of Object value for com/lowagie/text/pdf/PdfDocument::getCatalog to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return catalog; |
1863 | } | |
1864 | ||
1865 | // [C1] outlines | |
1866 | ||
1867 | /** This is the root outline of the document. */ | |
1868 | protected PdfOutline rootOutline; | |
1869 | ||
1870 | /** This is the current <CODE>PdfOutline</CODE> in the hierarchy of outlines. */ | |
1871 | protected PdfOutline currentOutline; | |
1872 | ||
1873 | /** | |
1874 | * Adds a named outline to the document . | |
1875 | * @param outline the outline to be added | |
1876 | * @param name the name of this local destination | |
1877 | */ | |
1878 | void addOutline(PdfOutline outline, String name) { | |
1879 | localDestination(name, outline.getPdfDestination()); | |
1880 | } | |
1881 | ||
1882 | /** | |
1883 | * Gets the root outline. All the outlines must be created with a parent. | |
1884 | * The first level is created with this outline. | |
1885 | * @return the root outline | |
1886 | */ | |
1887 | public PdfOutline getRootOutline() { | |
1888 | return rootOutline; | |
1889 | } | |
1890 | ||
1891 | ||
1892 | /** | |
1893 | * Updates the count in the outlines. | |
1894 | */ | |
1895 | void calculateOutlineCount() { | |
1896 |
1
1. calculateOutlineCount : negated conditional → NO_COVERAGE |
if (rootOutline.getKids().size() == 0) |
1897 | return; | |
1898 |
1
1. calculateOutlineCount : removed call to com/lowagie/text/pdf/PdfDocument::traverseOutlineCount → NO_COVERAGE |
traverseOutlineCount(rootOutline); |
1899 | } | |
1900 | ||
1901 | /** | |
1902 | * Recursive method to update the count in the outlines. | |
1903 | */ | |
1904 | void traverseOutlineCount(PdfOutline outline) { | |
1905 | java.util.List<PdfOutline> kids = outline.getKids(); | |
1906 | PdfOutline parent = outline.parent(); | |
1907 |
1
1. traverseOutlineCount : negated conditional → NO_COVERAGE |
if (kids.isEmpty()) { |
1908 |
1
1. traverseOutlineCount : negated conditional → NO_COVERAGE |
if (parent != null) { |
1909 |
2
1. traverseOutlineCount : Replaced integer addition with subtraction → NO_COVERAGE 2. traverseOutlineCount : removed call to com/lowagie/text/pdf/PdfOutline::setCount → NO_COVERAGE |
parent.setCount(parent.getCount() + 1); |
1910 | } | |
1911 | } | |
1912 | else { | |
1913 | for (PdfOutline kid : kids) { | |
1914 |
1
1. traverseOutlineCount : removed call to com/lowagie/text/pdf/PdfDocument::traverseOutlineCount → NO_COVERAGE |
traverseOutlineCount(kid); |
1915 | } | |
1916 |
1
1. traverseOutlineCount : negated conditional → NO_COVERAGE |
if (parent != null) { |
1917 |
1
1. traverseOutlineCount : negated conditional → NO_COVERAGE |
if (outline.isOpen()) { |
1918 |
3
1. traverseOutlineCount : Replaced integer addition with subtraction → NO_COVERAGE 2. traverseOutlineCount : Replaced integer addition with subtraction → NO_COVERAGE 3. traverseOutlineCount : removed call to com/lowagie/text/pdf/PdfOutline::setCount → NO_COVERAGE |
parent.setCount(outline.getCount() + parent.getCount() + 1); |
1919 | } | |
1920 | else { | |
1921 |
2
1. traverseOutlineCount : Replaced integer addition with subtraction → NO_COVERAGE 2. traverseOutlineCount : removed call to com/lowagie/text/pdf/PdfOutline::setCount → NO_COVERAGE |
parent.setCount(parent.getCount() + 1); |
1922 |
2
1. traverseOutlineCount : removed negation → NO_COVERAGE 2. traverseOutlineCount : removed call to com/lowagie/text/pdf/PdfOutline::setCount → NO_COVERAGE |
outline.setCount(-outline.getCount()); |
1923 | } | |
1924 | } | |
1925 | } | |
1926 | } | |
1927 | ||
1928 | /** | |
1929 | * Writes the outline tree to the body of the PDF document. | |
1930 | */ | |
1931 | void writeOutlines() throws IOException { | |
1932 |
1
1. writeOutlines : negated conditional → NO_COVERAGE |
if (rootOutline.getKids().size() == 0) |
1933 | return; | |
1934 |
1
1. writeOutlines : removed call to com/lowagie/text/pdf/PdfDocument::outlineTree → NO_COVERAGE |
outlineTree(rootOutline); |
1935 | writer.addToBody(rootOutline, rootOutline.indirectReference()); | |
1936 | } | |
1937 | ||
1938 | /** | |
1939 | * Recursive method used to write outlines. | |
1940 | */ | |
1941 | void outlineTree(PdfOutline outline) throws IOException { | |
1942 |
1
1. outlineTree : removed call to com/lowagie/text/pdf/PdfOutline::setIndirectReference → NO_COVERAGE |
outline.setIndirectReference(writer.getPdfIndirectReference()); |
1943 |
1
1. outlineTree : negated conditional → NO_COVERAGE |
if (outline.parent() != null) |
1944 |
1
1. outlineTree : removed call to com/lowagie/text/pdf/PdfOutline::put → NO_COVERAGE |
outline.put(PdfName.PARENT, outline.parent().indirectReference()); |
1945 | java.util.List<PdfOutline> kids = outline.getKids(); | |
1946 | int size = kids.size(); | |
1947 |
1
1. outlineTree : removed call to com/lowagie/text/pdf/PdfDocument::outlineTree → NO_COVERAGE |
for (PdfOutline kid1 : kids) outlineTree(kid1); |
1948 |
3
1. outlineTree : changed conditional boundary → NO_COVERAGE 2. outlineTree : Changed increment from 1 to -1 → NO_COVERAGE 3. outlineTree : negated conditional → NO_COVERAGE |
for (int k = 0; k < size; ++k) { |
1949 |
2
1. outlineTree : changed conditional boundary → NO_COVERAGE 2. outlineTree : negated conditional → NO_COVERAGE |
if (k > 0) |
1950 |
2
1. outlineTree : Replaced integer subtraction with addition → NO_COVERAGE 2. outlineTree : removed call to com/lowagie/text/pdf/PdfOutline::put → NO_COVERAGE |
kids.get(k).put(PdfName.PREV, kids.get(k - 1).indirectReference()); |
1951 |
3
1. outlineTree : changed conditional boundary → NO_COVERAGE 2. outlineTree : Replaced integer subtraction with addition → NO_COVERAGE 3. outlineTree : negated conditional → NO_COVERAGE |
if (k < size - 1) |
1952 |
2
1. outlineTree : Replaced integer addition with subtraction → NO_COVERAGE 2. outlineTree : removed call to com/lowagie/text/pdf/PdfOutline::put → NO_COVERAGE |
kids.get(k).put(PdfName.NEXT, kids.get(k + 1).indirectReference()); |
1953 | } | |
1954 |
2
1. outlineTree : changed conditional boundary → NO_COVERAGE 2. outlineTree : negated conditional → NO_COVERAGE |
if (size > 0) { |
1955 |
1
1. outlineTree : removed call to com/lowagie/text/pdf/PdfOutline::put → NO_COVERAGE |
outline.put(PdfName.FIRST, kids.get(0).indirectReference()); |
1956 |
2
1. outlineTree : Replaced integer subtraction with addition → NO_COVERAGE 2. outlineTree : removed call to com/lowagie/text/pdf/PdfOutline::put → NO_COVERAGE |
outline.put(PdfName.LAST, kids.get(size - 1).indirectReference()); |
1957 | } | |
1958 | for (PdfOutline kid : kids) { | |
1959 | writer.addToBody(kid, kid.indirectReference()); | |
1960 | } | |
1961 | } | |
1962 | ||
1963 | // [C3] PdfViewerPreferences interface | |
1964 | ||
1965 | /** Contains the Viewer preferences of this PDF document. */ | |
1966 | protected PdfViewerPreferencesImp viewerPreferences = new PdfViewerPreferencesImp(); | |
1967 | /** @see com.lowagie.text.pdf.interfaces.PdfViewerPreferences#setViewerPreferences(int) */ | |
1968 | void setViewerPreferences(int preferences) { | |
1969 | this.viewerPreferences.setViewerPreferences(preferences); | |
1970 | } | |
1971 | ||
1972 | /** @see com.lowagie.text.pdf.interfaces.PdfViewerPreferences#addViewerPreference(com.lowagie.text.pdf.PdfName, com.lowagie.text.pdf.PdfObject) */ | |
1973 | void addViewerPreference(PdfName key, PdfObject value) { | |
1974 | this.viewerPreferences.addViewerPreference(key, value); | |
1975 | } | |
1976 | ||
1977 | // [C4] Page labels | |
1978 | ||
1979 | protected PdfPageLabels pageLabels; | |
1980 | /** | |
1981 | * Sets the page labels | |
1982 | * @param pageLabels the page labels | |
1983 | */ | |
1984 | void setPageLabels(PdfPageLabels pageLabels) { | |
1985 | this.pageLabels = pageLabels; | |
1986 | } | |
1987 | ||
1988 | // [C5] named objects: local destinations, javascript, embedded files | |
1989 | ||
1990 | /** | |
1991 | * Implements a link to other part of the document. The jump will | |
1992 | * be made to a local destination with the same name, that must exist. | |
1993 | * @param name the name for this link | |
1994 | * @param llx the lower left x corner of the activation area | |
1995 | * @param lly the lower left y corner of the activation area | |
1996 | * @param urx the upper right x corner of the activation area | |
1997 | * @param ury the upper right y corner of the activation area | |
1998 | */ | |
1999 | void localGoto(String name, float llx, float lly, float urx, float ury) { | |
2000 | PdfAction action = getLocalGotoAction(name); | |
2001 |
1
1. localGoto : removed call to com/lowagie/text/pdf/internal/PdfAnnotationsImp::addPlainAnnotation → NO_COVERAGE |
annotationsImp.addPlainAnnotation(new PdfAnnotation(writer, llx, lly, urx, ury, action)); |
2002 | } | |
2003 | ||
2004 | /** | |
2005 | * Implements a link to another document. | |
2006 | * @param filename the filename for the remote document | |
2007 | * @param name the name to jump to | |
2008 | * @param llx the lower left x corner of the activation area | |
2009 | * @param lly the lower left y corner of the activation area | |
2010 | * @param urx the upper right x corner of the activation area | |
2011 | * @param ury the upper right y corner of the activation area | |
2012 | */ | |
2013 | void remoteGoto(String filename, String name, float llx, float lly, float urx, float ury) { | |
2014 |
1
1. remoteGoto : removed call to com/lowagie/text/pdf/internal/PdfAnnotationsImp::addPlainAnnotation → NO_COVERAGE |
annotationsImp.addPlainAnnotation(new PdfAnnotation(writer, llx, lly, urx, ury, new PdfAction(filename, name))); |
2015 | } | |
2016 | ||
2017 | /** | |
2018 | * Implements a link to another document. | |
2019 | * @param filename the filename for the remote document | |
2020 | * @param page the page to jump to | |
2021 | * @param llx the lower left x corner of the activation area | |
2022 | * @param lly the lower left y corner of the activation area | |
2023 | * @param urx the upper right x corner of the activation area | |
2024 | * @param ury the upper right y corner of the activation area | |
2025 | */ | |
2026 | void remoteGoto(String filename, int page, float llx, float lly, float urx, float ury) { | |
2027 |
1
1. remoteGoto : removed call to com/lowagie/text/pdf/PdfDocument::addAnnotation → NO_COVERAGE |
addAnnotation(new PdfAnnotation(writer, llx, lly, urx, ury, new PdfAction(filename, page))); |
2028 | } | |
2029 | ||
2030 | /** Implements an action in an area. | |
2031 | * @param action the <CODE>PdfAction</CODE> | |
2032 | * @param llx the lower left x corner of the activation area | |
2033 | * @param lly the lower left y corner of the activation area | |
2034 | * @param urx the upper right x corner of the activation area | |
2035 | * @param ury the upper right y corner of the activation area | |
2036 | */ | |
2037 | void setAction(PdfAction action, float llx, float lly, float urx, float ury) { | |
2038 |
1
1. setAction : removed call to com/lowagie/text/pdf/PdfDocument::addAnnotation → NO_COVERAGE |
addAnnotation(new PdfAnnotation(writer, llx, lly, urx, ury, action)); |
2039 | } | |
2040 | ||
2041 | /** | |
2042 | * Stores the destinations keyed by name. Value is | |
2043 | * <CODE>Object[]{PdfAction,PdfIndirectReference,PdfDestintion}</CODE>. | |
2044 | */ | |
2045 | protected TreeMap<String, Object[]> localDestinations = new TreeMap<>(); | |
2046 | ||
2047 | PdfAction getLocalGotoAction(String name) { | |
2048 | PdfAction action; | |
2049 | Object[] obj = localDestinations.get(name); | |
2050 |
1
1. getLocalGotoAction : negated conditional → NO_COVERAGE |
if (obj == null) |
2051 | obj = new Object[3]; | |
2052 |
1
1. getLocalGotoAction : negated conditional → NO_COVERAGE |
if (obj[0] == null) { |
2053 |
1
1. getLocalGotoAction : negated conditional → NO_COVERAGE |
if (obj[1] == null) { |
2054 | obj[1] = writer.getPdfIndirectReference(); | |
2055 | } | |
2056 | action = new PdfAction((PdfIndirectReference)obj[1]); | |
2057 | obj[0] = action; | |
2058 | localDestinations.put(name, obj); | |
2059 | } | |
2060 | else { | |
2061 | action = (PdfAction)obj[0]; | |
2062 | } | |
2063 |
1
1. getLocalGotoAction : mutated return of Object value for com/lowagie/text/pdf/PdfDocument::getLocalGotoAction to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return action; |
2064 | } | |
2065 | ||
2066 | /** | |
2067 | * The local destination to where a local goto with the same | |
2068 | * name will jump to. | |
2069 | * @param name the name of this local destination | |
2070 | * @param destination the <CODE>PdfDestination</CODE> with the jump coordinates | |
2071 | * @return <CODE>true</CODE> if the local destination was added, | |
2072 | * <CODE>false</CODE> if a local destination with the same name | |
2073 | * already existed | |
2074 | */ | |
2075 | boolean localDestination(String name, PdfDestination destination) { | |
2076 | Object[] obj = localDestinations.get(name); | |
2077 |
1
1. localDestination : negated conditional → NO_COVERAGE |
if (obj == null) |
2078 | obj = new Object[3]; | |
2079 |
1
1. localDestination : negated conditional → NO_COVERAGE |
if (obj[2] != null) |
2080 |
1
1. localDestination : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
2081 | obj[2] = destination; | |
2082 | localDestinations.put(name, obj); | |
2083 |
1
1. localDestination : negated conditional → NO_COVERAGE |
if (!destination.hasPage()) |
2084 | destination.addPage(writer.getCurrentPage()); | |
2085 |
1
1. localDestination : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return true; |
2086 | } | |
2087 | ||
2088 | /** | |
2089 | * Stores a list of document level JavaScript actions. | |
2090 | */ | |
2091 | int jsCounter; | |
2092 | protected HashMap<String, PdfIndirectReference> documentLevelJS = new HashMap<>(); | |
2093 | protected static final DecimalFormat SIXTEEN_DIGITS = new DecimalFormat("0000000000000000"); | |
2094 | void addJavaScript(PdfAction js) { | |
2095 |
1
1. addJavaScript : negated conditional → NO_COVERAGE |
if (js.get(PdfName.JS) == null) |
2096 | throw new RuntimeException(MessageLocalization.getComposedMessage("only.javascript.actions.are.allowed")); | |
2097 | try { | |
2098 |
1
1. addJavaScript : Replaced integer addition with subtraction → NO_COVERAGE |
documentLevelJS.put(SIXTEEN_DIGITS.format(jsCounter++), writer.addToBody(js).getIndirectReference()); |
2099 | } | |
2100 | catch (IOException e) { | |
2101 | throw new ExceptionConverter(e); | |
2102 | } | |
2103 | } | |
2104 | void addJavaScript(String name, PdfAction js) { | |
2105 |
1
1. addJavaScript : negated conditional → NO_COVERAGE |
if (js.get(PdfName.JS) == null) |
2106 | throw new RuntimeException(MessageLocalization.getComposedMessage("only.javascript.actions.are.allowed")); | |
2107 | try { | |
2108 | documentLevelJS.put(name, writer.addToBody(js).getIndirectReference()); | |
2109 | } | |
2110 | catch (IOException e) { | |
2111 | throw new ExceptionConverter(e); | |
2112 | } | |
2113 | } | |
2114 | ||
2115 | HashMap<String, PdfIndirectReference> getDocumentLevelJS() { | |
2116 | return documentLevelJS; | |
2117 | } | |
2118 | ||
2119 | protected HashMap<String, PdfIndirectReference> documentFileAttachment = new HashMap<>(); | |
2120 | ||
2121 | void addFileAttachment(String description, PdfFileSpecification fs) throws IOException { | |
2122 |
1
1. addFileAttachment : negated conditional → NO_COVERAGE |
if (description == null) { |
2123 | PdfString desc = (PdfString)fs.get(PdfName.DESC); | |
2124 |
1
1. addFileAttachment : negated conditional → NO_COVERAGE |
if (desc == null) { |
2125 | description = ""; | |
2126 | } | |
2127 | else { | |
2128 | description = PdfEncodings.convertToString(desc.getBytes(), null); | |
2129 | } | |
2130 | } | |
2131 |
1
1. addFileAttachment : removed call to com/lowagie/text/pdf/PdfFileSpecification::addDescription → NO_COVERAGE |
fs.addDescription(description, true); |
2132 |
1
1. addFileAttachment : negated conditional → NO_COVERAGE |
if (description.length() == 0) |
2133 | description = "Unnamed"; | |
2134 | String fn = PdfEncodings.convertToString(new PdfString(description, PdfObject.TEXT_UNICODE).getBytes(), null); | |
2135 | int k = 0; | |
2136 |
1
1. addFileAttachment : negated conditional → NO_COVERAGE |
while (documentFileAttachment.containsKey(fn)) { |
2137 |
1
1. addFileAttachment : Changed increment from 1 to -1 → NO_COVERAGE |
++k; |
2138 | fn = PdfEncodings.convertToString(new PdfString(description + " " + k, PdfObject.TEXT_UNICODE).getBytes(), null); | |
2139 | } | |
2140 | documentFileAttachment.put(fn, fs.getReference()); | |
2141 | } | |
2142 | ||
2143 | HashMap<String, PdfIndirectReference> getDocumentFileAttachment() { | |
2144 | return documentFileAttachment; | |
2145 | } | |
2146 | ||
2147 | // [C6] document level actions | |
2148 | ||
2149 | protected String openActionName; | |
2150 | ||
2151 | void setOpenAction(String name) { | |
2152 | openActionName = name; | |
2153 | openActionAction = null; | |
2154 | } | |
2155 | ||
2156 | protected PdfAction openActionAction; | |
2157 | void setOpenAction(PdfAction action) { | |
2158 | openActionAction = action; | |
2159 | openActionName = null; | |
2160 | } | |
2161 | ||
2162 | protected PdfDictionary additionalActions; | |
2163 | void addAdditionalAction(PdfName actionType, PdfAction action) { | |
2164 |
1
1. addAdditionalAction : negated conditional → NO_COVERAGE |
if (additionalActions == null) { |
2165 | additionalActions = new PdfDictionary(); | |
2166 | } | |
2167 |
1
1. addAdditionalAction : negated conditional → NO_COVERAGE |
if (action == null) |
2168 |
1
1. addAdditionalAction : removed call to com/lowagie/text/pdf/PdfDictionary::remove → NO_COVERAGE |
additionalActions.remove(actionType); |
2169 | else | |
2170 |
1
1. addAdditionalAction : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
additionalActions.put(actionType, action); |
2171 |
1
1. addAdditionalAction : negated conditional → NO_COVERAGE |
if (additionalActions.size() == 0) |
2172 | additionalActions = null; | |
2173 | } | |
2174 | ||
2175 | // [C7] portable collections | |
2176 | ||
2177 | protected PdfCollection collection; | |
2178 | ||
2179 | /** | |
2180 | * Sets the collection dictionary. | |
2181 | * @param collection a dictionary of type PdfCollection | |
2182 | */ | |
2183 | public void setCollection(PdfCollection collection) { | |
2184 | this.collection = collection; | |
2185 | } | |
2186 | ||
2187 | // [C8] AcroForm | |
2188 | ||
2189 | PdfAnnotationsImp annotationsImp; | |
2190 | ||
2191 | /** | |
2192 | * Gets the AcroForm object. | |
2193 | * @return the PdfAcroform object of the PdfDocument | |
2194 | */ | |
2195 | PdfAcroForm getAcroForm() { | |
2196 | return annotationsImp.getAcroForm(); | |
2197 | } | |
2198 | ||
2199 | void setSigFlags(int f) { | |
2200 | annotationsImp.setSigFlags(f); | |
2201 | } | |
2202 | ||
2203 | void addCalculationOrder(PdfFormField formField) { | |
2204 | annotationsImp.addCalculationOrder(formField); | |
2205 | } | |
2206 | ||
2207 | void addAnnotation(PdfAnnotation annot) { | |
2208 | pageEmpty = false; | |
2209 |
1
1. addAnnotation : removed call to com/lowagie/text/pdf/internal/PdfAnnotationsImp::addAnnotation → NO_COVERAGE |
annotationsImp.addAnnotation(annot); |
2210 | } | |
2211 | ||
2212 | // [F12] tagged PDF | |
2213 | ||
2214 | protected int markPoint; | |
2215 | ||
2216 | int getMarkPoint() { | |
2217 | return markPoint; | |
2218 | } | |
2219 | ||
2220 | void incMarkPoint() { | |
2221 |
1
1. incMarkPoint : Replaced integer addition with subtraction → NO_COVERAGE |
++markPoint; |
2222 | } | |
2223 | ||
2224 | // [U1] page sizes | |
2225 | ||
2226 | /** This is the size of the next page. */ | |
2227 | protected Rectangle nextPageSize = null; | |
2228 | ||
2229 | /** This is the size of the several boxes of the current Page. */ | |
2230 | protected HashMap<String, PdfRectangle> thisBoxSize = new HashMap<>(); | |
2231 | ||
2232 | /** This is the size of the several boxes that will be used in | |
2233 | * the next page. */ | |
2234 | protected HashMap<String, PdfRectangle> boxSize = new HashMap<>(); | |
2235 | ||
2236 | void setCropBoxSize(Rectangle crop) { | |
2237 |
1
1. setCropBoxSize : removed call to com/lowagie/text/pdf/PdfDocument::setBoxSize → NO_COVERAGE |
setBoxSize("crop", crop); |
2238 | } | |
2239 | ||
2240 | void setBoxSize(String boxName, Rectangle size) { | |
2241 |
1
1. setBoxSize : negated conditional → NO_COVERAGE |
if (size == null) |
2242 | boxSize.remove(boxName); | |
2243 | else | |
2244 | boxSize.put(boxName, new PdfRectangle(size)); | |
2245 | } | |
2246 | ||
2247 | protected void setNewPageSizeAndMargins() { | |
2248 | pageSize = nextPageSize; | |
2249 |
3
1. setNewPageSizeAndMargins : Replaced bitwise AND with OR → NO_COVERAGE 2. setNewPageSizeAndMargins : negated conditional → NO_COVERAGE 3. setNewPageSizeAndMargins : negated conditional → NO_COVERAGE |
if (marginMirroring && (getPageNumber() & 1) == 0) { |
2250 | marginRight = nextMarginLeft; | |
2251 | marginLeft = nextMarginRight; | |
2252 | } | |
2253 | else { | |
2254 | marginLeft = nextMarginLeft; | |
2255 | marginRight = nextMarginRight; | |
2256 | } | |
2257 |
3
1. setNewPageSizeAndMargins : Replaced bitwise AND with OR → NO_COVERAGE 2. setNewPageSizeAndMargins : negated conditional → NO_COVERAGE 3. setNewPageSizeAndMargins : negated conditional → NO_COVERAGE |
if (marginMirroringTopBottom && (getPageNumber() & 1) == 0) { |
2258 | marginTop = nextMarginBottom; | |
2259 | marginBottom = nextMarginTop; | |
2260 | } | |
2261 | else { | |
2262 | marginTop = nextMarginTop; | |
2263 | marginBottom = nextMarginBottom; | |
2264 | } | |
2265 | } | |
2266 | ||
2267 | /** | |
2268 | * Gives the size of a trim, art, crop or bleed box, or null if not defined. | |
2269 | * @param boxName crop, trim, art or bleed | |
2270 | */ | |
2271 | Rectangle getBoxSize(String boxName) { | |
2272 | PdfRectangle r = thisBoxSize.get(boxName); | |
2273 |
2
1. getBoxSize : negated conditional → NO_COVERAGE 2. getBoxSize : mutated return of Object value for com/lowagie/text/pdf/PdfDocument::getBoxSize to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
if (r != null) return r.getRectangle(); |
2274 |
1
1. getBoxSize : mutated return of Object value for com/lowagie/text/pdf/PdfDocument::getBoxSize to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return null; |
2275 | } | |
2276 | ||
2277 | // [U2] empty pages | |
2278 | ||
2279 | /** This checks if the page is empty. */ | |
2280 | private boolean pageEmpty = true; | |
2281 | ||
2282 | void setPageEmpty(boolean pageEmpty) { | |
2283 | this.pageEmpty = pageEmpty; | |
2284 | } | |
2285 | ||
2286 | boolean isPageEmpty() { | |
2287 |
6
1. isPageEmpty : negated conditional → NO_COVERAGE 2. isPageEmpty : negated conditional → NO_COVERAGE 3. isPageEmpty : negated conditional → NO_COVERAGE 4. isPageEmpty : negated conditional → NO_COVERAGE 5. isPageEmpty : negated conditional → NO_COVERAGE 6. isPageEmpty : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return writer == null || (writer.getDirectContent().size() == 0 && writer.getDirectContentUnder().size() == 0 && (pageEmpty || writer.isPaused())); |
2288 | } | |
2289 | ||
2290 | // [U3] page actions | |
2291 | ||
2292 | /** The duration of the page */ | |
2293 | protected int duration=-1; // negative values will indicate no duration | |
2294 | ||
2295 | /** The page transition */ | |
2296 | protected PdfTransition transition=null; | |
2297 | ||
2298 | /** | |
2299 | * Sets the display duration for the page (for presentations) | |
2300 | * @param seconds the number of seconds to display the page | |
2301 | */ | |
2302 | void setDuration(int seconds) { | |
2303 |
2
1. setDuration : changed conditional boundary → NO_COVERAGE 2. setDuration : negated conditional → NO_COVERAGE |
if (seconds > 0) |
2304 | this.duration=seconds; | |
2305 | else | |
2306 | this.duration=-1; | |
2307 | } | |
2308 | ||
2309 | /** | |
2310 | * Sets the transition for the page | |
2311 | * @param transition the PdfTransition object | |
2312 | */ | |
2313 | void setTransition(PdfTransition transition) { | |
2314 | this.transition=transition; | |
2315 | } | |
2316 | ||
2317 | protected PdfDictionary pageAA = null; | |
2318 | void setPageAction(PdfName actionType, PdfAction action) { | |
2319 |
1
1. setPageAction : negated conditional → NO_COVERAGE |
if (pageAA == null) { |
2320 | pageAA = new PdfDictionary(); | |
2321 | } | |
2322 |
1
1. setPageAction : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
pageAA.put(actionType, action); |
2323 | } | |
2324 | ||
2325 | // [U8] thumbnail images | |
2326 | ||
2327 | protected PdfIndirectReference thumb; | |
2328 | void setThumbnail(Image image) throws DocumentException { | |
2329 | thumb = writer.getImageReference(writer.addDirectImageSimple(image)); | |
2330 | } | |
2331 | ||
2332 | // [M0] Page resources contain references to fonts, extgstate, images,... | |
2333 | ||
2334 | /** This are the page resources of the current Page. */ | |
2335 | protected PageResources pageResources; | |
2336 | ||
2337 | PageResources getPageResources() { | |
2338 | return pageResources; | |
2339 | } | |
2340 | ||
2341 | // [M3] Images | |
2342 | ||
2343 | /** Holds value of property strictImageSequence. */ | |
2344 | protected boolean strictImageSequence = false; | |
2345 | ||
2346 | /** Getter for property strictImageSequence. | |
2347 | * @return Value of property strictImageSequence. | |
2348 | * | |
2349 | */ | |
2350 | boolean isStrictImageSequence() { | |
2351 | return this.strictImageSequence; | |
2352 | } | |
2353 | ||
2354 | /** Setter for property strictImageSequence. | |
2355 | * @param strictImageSequence New value of property strictImageSequence. | |
2356 | * | |
2357 | */ | |
2358 | void setStrictImageSequence(boolean strictImageSequence) { | |
2359 | this.strictImageSequence = strictImageSequence; | |
2360 | } | |
2361 | ||
2362 | /** This is the position where the image ends. */ | |
2363 | protected float imageEnd = -1; | |
2364 | ||
2365 | /** | |
2366 | * Method added by Pelikan Stephan | |
2367 | */ | |
2368 | public void clearTextWrap() { | |
2369 |
1
1. clearTextWrap : Replaced float subtraction with addition → NO_COVERAGE |
float tmpHeight = imageEnd - currentHeight; |
2370 |
1
1. clearTextWrap : negated conditional → NO_COVERAGE |
if (line != null) { |
2371 |
1
1. clearTextWrap : Replaced float addition with subtraction → NO_COVERAGE |
tmpHeight += line.height(); |
2372 | } | |
2373 |
4
1. clearTextWrap : changed conditional boundary → NO_COVERAGE 2. clearTextWrap : changed conditional boundary → NO_COVERAGE 3. clearTextWrap : negated conditional → NO_COVERAGE 4. clearTextWrap : negated conditional → NO_COVERAGE |
if ((imageEnd > -1) && (tmpHeight > 0)) { |
2374 |
1
1. clearTextWrap : removed call to com/lowagie/text/pdf/PdfDocument::carriageReturn → NO_COVERAGE |
carriageReturn(); |
2375 |
1
1. clearTextWrap : Replaced float addition with subtraction → NO_COVERAGE |
currentHeight += tmpHeight; |
2376 | } | |
2377 | } | |
2378 | ||
2379 | /** This is the image that could not be shown on a previous page. */ | |
2380 | protected Image imageWait = null; | |
2381 | ||
2382 | /** | |
2383 | * Adds an image to the document. | |
2384 | * @param image the <CODE>Image</CODE> to add | |
2385 | * @throws PdfException on error | |
2386 | * @throws DocumentException on error | |
2387 | */ | |
2388 | ||
2389 | protected void add(Image image) throws DocumentException { | |
2390 | ||
2391 |
1
1. add : negated conditional → NO_COVERAGE |
if (image.hasAbsoluteY()) { |
2392 |
1
1. add : removed call to com/lowagie/text/pdf/PdfContentByte::addImage → NO_COVERAGE |
graphics.addImage(image); |
2393 | pageEmpty = false; | |
2394 | return; | |
2395 | } | |
2396 | ||
2397 | // if there isn't enough room for the image on this page, save it for the next page | |
2398 |
5
1. add : changed conditional boundary → NO_COVERAGE 2. add : Replaced float subtraction with addition → NO_COVERAGE 3. add : Replaced float subtraction with addition → NO_COVERAGE 4. add : negated conditional → NO_COVERAGE 5. add : negated conditional → NO_COVERAGE |
if (currentHeight != 0 && indentTop() - currentHeight - image.getScaledHeight() < indentBottom()) { |
2399 |
2
1. add : negated conditional → NO_COVERAGE 2. add : negated conditional → NO_COVERAGE |
if (!strictImageSequence && imageWait == null) { |
2400 | imageWait = image; | |
2401 | return; | |
2402 | } | |
2403 | newPage(); | |
2404 |
5
1. add : changed conditional boundary → NO_COVERAGE 2. add : Replaced float subtraction with addition → NO_COVERAGE 3. add : Replaced float subtraction with addition → NO_COVERAGE 4. add : negated conditional → NO_COVERAGE 5. add : negated conditional → NO_COVERAGE |
if (currentHeight != 0 && indentTop() - currentHeight - image.getScaledHeight() < indentBottom()) { |
2405 | imageWait = image; | |
2406 | return; | |
2407 | } | |
2408 | } | |
2409 | pageEmpty = false; | |
2410 | // avoid endless loops | |
2411 |
1
1. add : negated conditional → NO_COVERAGE |
if (image == imageWait) |
2412 | imageWait = null; | |
2413 |
2
1. add : Replaced bitwise AND with OR → NO_COVERAGE 2. add : negated conditional → NO_COVERAGE |
boolean textwrap = (image.getAlignment() & Image.TEXTWRAP) == Image.TEXTWRAP |
2414 |
2
1. add : Replaced bitwise AND with OR → NO_COVERAGE 2. add : negated conditional → NO_COVERAGE |
&& !((image.getAlignment() & Image.MIDDLE) == Image.MIDDLE); |
2415 |
2
1. add : Replaced bitwise AND with OR → NO_COVERAGE 2. add : negated conditional → NO_COVERAGE |
boolean underlying = (image.getAlignment() & Image.UNDERLYING) == Image.UNDERLYING; |
2416 |
1
1. add : Replaced float division with multiplication → NO_COVERAGE |
float diff = leading / 2; |
2417 |
1
1. add : negated conditional → NO_COVERAGE |
if (textwrap) { |
2418 |
1
1. add : Replaced float addition with subtraction → NO_COVERAGE |
diff += leading; |
2419 | } | |
2420 |
3
1. add : Replaced float subtraction with addition → NO_COVERAGE 2. add : Replaced float subtraction with addition → NO_COVERAGE 3. add : Replaced float subtraction with addition → NO_COVERAGE |
float lowerleft = indentTop() - currentHeight - image.getScaledHeight() -diff; |
2421 | float[] mt = image.matrix(); | |
2422 |
1
1. add : Replaced float subtraction with addition → NO_COVERAGE |
float startPosition = indentLeft() - mt[4]; |
2423 |
4
1. add : Replaced bitwise AND with OR → NO_COVERAGE 2. add : Replaced float subtraction with addition → NO_COVERAGE 3. add : Replaced float subtraction with addition → NO_COVERAGE 4. add : negated conditional → NO_COVERAGE |
if ((image.getAlignment() & Image.RIGHT) == Image.RIGHT) startPosition = indentRight() - image.getScaledWidth() - mt[4]; |
2424 |
7
1. add : Replaced bitwise AND with OR → NO_COVERAGE 2. add : Replaced float subtraction with addition → NO_COVERAGE 3. add : Replaced float subtraction with addition → NO_COVERAGE 4. add : Replaced float division with multiplication → NO_COVERAGE 5. add : Replaced float addition with subtraction → NO_COVERAGE 6. add : Replaced float subtraction with addition → NO_COVERAGE 7. add : negated conditional → NO_COVERAGE |
if ((image.getAlignment() & Image.MIDDLE) == Image.MIDDLE) startPosition = indentLeft() + ((indentRight() - indentLeft() - image.getScaledWidth()) / 2) - mt[4]; |
2425 |
1
1. add : negated conditional → NO_COVERAGE |
if (image.hasAbsoluteX()) startPosition = image.getAbsoluteX(); |
2426 |
1
1. add : negated conditional → NO_COVERAGE |
if (textwrap) { |
2427 |
6
1. add : changed conditional boundary → NO_COVERAGE 2. add : changed conditional boundary → NO_COVERAGE 3. add : Replaced float addition with subtraction → NO_COVERAGE 4. add : Replaced float addition with subtraction → NO_COVERAGE 5. add : negated conditional → NO_COVERAGE 6. add : negated conditional → NO_COVERAGE |
if (imageEnd < 0 || imageEnd < currentHeight + image.getScaledHeight() + diff) { |
2428 |
2
1. add : Replaced float addition with subtraction → NO_COVERAGE 2. add : Replaced float addition with subtraction → NO_COVERAGE |
imageEnd = currentHeight + image.getScaledHeight() + diff; |
2429 | } | |
2430 |
2
1. add : Replaced bitwise AND with OR → NO_COVERAGE 2. add : negated conditional → NO_COVERAGE |
if ((image.getAlignment() & Image.RIGHT) == Image.RIGHT) { |
2431 | // indentation suggested by Pelikan Stephan | |
2432 |
2
1. add : Replaced float addition with subtraction → NO_COVERAGE 2. add : Replaced float addition with subtraction → NO_COVERAGE |
indentation.imageIndentRight += image.getScaledWidth() + image.getIndentationLeft(); |
2433 | } | |
2434 | else { | |
2435 | // indentation suggested by Pelikan Stephan | |
2436 |
2
1. add : Replaced float addition with subtraction → NO_COVERAGE 2. add : Replaced float addition with subtraction → NO_COVERAGE |
indentation.imageIndentLeft += image.getScaledWidth() + image.getIndentationRight(); |
2437 | } | |
2438 | } | |
2439 | else { | |
2440 |
3
1. add : Replaced bitwise AND with OR → NO_COVERAGE 2. add : Replaced float subtraction with addition → NO_COVERAGE 3. add : negated conditional → NO_COVERAGE |
if ((image.getAlignment() & Image.RIGHT) == Image.RIGHT) startPosition -= image.getIndentationRight(); |
2441 |
4
1. add : Replaced bitwise AND with OR → NO_COVERAGE 2. add : Replaced float subtraction with addition → NO_COVERAGE 3. add : Replaced float addition with subtraction → NO_COVERAGE 4. add : negated conditional → NO_COVERAGE |
else if ((image.getAlignment() & Image.MIDDLE) == Image.MIDDLE) startPosition += image.getIndentationLeft() - image.getIndentationRight(); |
2442 |
1
1. add : Replaced float addition with subtraction → NO_COVERAGE |
else startPosition += image.getIndentationLeft(); |
2443 | } | |
2444 |
2
1. add : Replaced float subtraction with addition → NO_COVERAGE 2. add : removed call to com/lowagie/text/pdf/PdfContentByte::addImage → NO_COVERAGE |
graphics.addImage(image, mt[0], mt[1], mt[2], mt[3], startPosition, lowerleft - mt[5]); |
2445 |
2
1. add : negated conditional → NO_COVERAGE 2. add : negated conditional → NO_COVERAGE |
if (!(textwrap || underlying)) { |
2446 |
2
1. add : Replaced float addition with subtraction → NO_COVERAGE 2. add : Replaced float addition with subtraction → NO_COVERAGE |
currentHeight += image.getScaledHeight() + diff; |
2447 | flushLines(); | |
2448 |
3
1. add : removed negation → NO_COVERAGE 2. add : Replaced float addition with subtraction → NO_COVERAGE 3. add : removed call to com/lowagie/text/pdf/PdfContentByte::moveText → NO_COVERAGE |
text.moveText(0, - (image.getScaledHeight() + diff)); |
2449 |
1
1. add : removed call to com/lowagie/text/pdf/PdfDocument::newLine → NO_COVERAGE |
newLine(); |
2450 | } | |
2451 | } | |
2452 | ||
2453 | // [M4] Adding a PdfPTable | |
2454 | ||
2455 | /** Adds a <CODE>PdfPTable</CODE> to the document. | |
2456 | * @param ptable the <CODE>PdfPTable</CODE> to be added to the document. | |
2457 | * @throws DocumentException on error | |
2458 | */ | |
2459 | void addPTable(PdfPTable ptable) throws DocumentException { | |
2460 | ColumnText ct = new ColumnText(writer.getDirectContent()); | |
2461 | // if the table prefers to be on a single page, and it wouldn't | |
2462 | //fit on the current page, start a new page. | |
2463 |
4
1. addPTable : changed conditional boundary → NO_COVERAGE 2. addPTable : negated conditional → NO_COVERAGE 3. addPTable : negated conditional → NO_COVERAGE 4. addPTable : negated conditional → NO_COVERAGE |
if (ptable.getKeepTogether() && !fitsPage(ptable, 0f) && currentHeight > 0) { |
2464 | newPage(); | |
2465 | } | |
2466 | // add dummy paragraph if we aren't at the top of a page, so that | |
2467 | // spacingBefore will be taken into account by ColumnText | |
2468 |
2
1. addPTable : changed conditional boundary → NO_COVERAGE 2. addPTable : negated conditional → NO_COVERAGE |
if (currentHeight > 0) { |
2469 | Paragraph p = new Paragraph(); | |
2470 |
1
1. addPTable : removed call to com/lowagie/text/Paragraph::setLeading → NO_COVERAGE |
p.setLeading(0); |
2471 |
1
1. addPTable : removed call to com/lowagie/text/pdf/ColumnText::addElement → NO_COVERAGE |
ct.addElement(p); |
2472 | } | |
2473 |
1
1. addPTable : removed call to com/lowagie/text/pdf/ColumnText::addElement → NO_COVERAGE |
ct.addElement(ptable); |
2474 | boolean he = ptable.isHeadersInEvent(); | |
2475 |
1
1. addPTable : removed call to com/lowagie/text/pdf/PdfPTable::setHeadersInEvent → NO_COVERAGE |
ptable.setHeadersInEvent(true); |
2476 | int loop = 0; | |
2477 | while (true) { | |
2478 |
2
1. addPTable : Replaced float subtraction with addition → NO_COVERAGE 2. addPTable : removed call to com/lowagie/text/pdf/ColumnText::setSimpleColumn → NO_COVERAGE |
ct.setSimpleColumn(indentLeft(), indentBottom(), indentRight(), indentTop() - currentHeight); |
2479 | int status = ct.go(); | |
2480 |
2
1. addPTable : Replaced bitwise AND with OR → NO_COVERAGE 2. addPTable : negated conditional → NO_COVERAGE |
if ((status & ColumnText.NO_MORE_TEXT) != 0) { |
2481 |
3
1. addPTable : Replaced float subtraction with addition → NO_COVERAGE 2. addPTable : Replaced float addition with subtraction → NO_COVERAGE 3. addPTable : removed call to com/lowagie/text/pdf/PdfContentByte::moveText → NO_COVERAGE |
text.moveText(0, ct.getYLine() - indentTop() + currentHeight); |
2482 |
1
1. addPTable : Replaced float subtraction with addition → NO_COVERAGE |
currentHeight = indentTop() - ct.getYLine(); |
2483 | break; | |
2484 | } | |
2485 |
2
1. addPTable : Replaced float subtraction with addition → NO_COVERAGE 2. addPTable : negated conditional → NO_COVERAGE |
if (indentTop() - currentHeight == ct.getYLine()) |
2486 |
1
1. addPTable : Changed increment from 1 to -1 → NO_COVERAGE |
++loop; |
2487 | else | |
2488 | loop = 0; | |
2489 |
1
1. addPTable : negated conditional → NO_COVERAGE |
if (loop == 3) { |
2490 | add(new Paragraph("ERROR: Infinite table loop")); | |
2491 | break; | |
2492 | } | |
2493 | newPage(); | |
2494 | } | |
2495 |
1
1. addPTable : removed call to com/lowagie/text/pdf/PdfPTable::setHeadersInEvent → NO_COVERAGE |
ptable.setHeadersInEvent(he); |
2496 | } | |
2497 | ||
2498 | /** | |
2499 | * Checks if a <CODE>PdfPTable</CODE> fits the current page of the <CODE>PdfDocument</CODE>. | |
2500 | * | |
2501 | * @param table the table that has to be checked | |
2502 | * @param margin a certain margin | |
2503 | * @return <CODE>true</CODE> if the <CODE>PdfPTable</CODE> fits the page, <CODE>false</CODE> otherwise. | |
2504 | */ | |
2505 | ||
2506 | boolean fitsPage(PdfPTable table, float margin) { | |
2507 |
1
1. fitsPage : negated conditional → NO_COVERAGE |
if (!table.isLockedWidth()) { |
2508 |
3
1. fitsPage : Replaced float subtraction with addition → NO_COVERAGE 2. fitsPage : Replaced float multiplication with division → NO_COVERAGE 3. fitsPage : Replaced float division with multiplication → NO_COVERAGE |
float totalWidth = (indentRight() - indentLeft()) * table.getWidthPercentage() / 100; |
2509 |
1
1. fitsPage : removed call to com/lowagie/text/pdf/PdfPTable::setTotalWidth → NO_COVERAGE |
table.setTotalWidth(totalWidth); |
2510 | } | |
2511 | // ensuring that a new line has been started. | |
2512 |
1
1. fitsPage : removed call to com/lowagie/text/pdf/PdfDocument::ensureNewLine → NO_COVERAGE |
ensureNewLine(); |
2513 |
4
1. fitsPage : changed conditional boundary → NO_COVERAGE 2. fitsPage : Replaced float addition with subtraction → NO_COVERAGE 3. fitsPage : negated conditional → NO_COVERAGE 4. fitsPage : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return table.getTotalHeight() + ((currentHeight > 0) ? table.spacingBefore() : 0f) |
2514 |
5
1. fitsPage : changed conditional boundary → NO_COVERAGE 2. fitsPage : Replaced float subtraction with addition → NO_COVERAGE 3. fitsPage : Replaced float subtraction with addition → NO_COVERAGE 4. fitsPage : Replaced float subtraction with addition → NO_COVERAGE 5. fitsPage : negated conditional → NO_COVERAGE |
<= indentTop() - currentHeight - indentBottom() - margin; |
2515 | } | |
2516 | ||
2517 | // [M4'] Adding a Table | |
2518 | ||
2519 | /** | |
2520 | * This is a helper class for adding a Table to a document. | |
2521 | * @since 2.0.8 (PdfDocument was package-private before) | |
2522 | */ | |
2523 | protected static class RenderingContext { | |
2524 | float pagetop = -1; | |
2525 | float oldHeight = -1; | |
2526 | ||
2527 | PdfContentByte cellGraphics = null; | |
2528 | ||
2529 | float lostTableBottom; | |
2530 | ||
2531 | float maxCellBottom; | |
2532 | float maxCellHeight; | |
2533 | ||
2534 | Map<PdfCell, Integer> rowspanMap = new HashMap<>(); | |
2535 | ||
2536 | // Possible keys and values are Set or Integer. Really? | |
2537 | Map<Object, Object> pageMap = new HashMap<>(); | |
2538 | ||
2539 | /** | |
2540 | * A PdfPTable | |
2541 | */ | |
2542 | public PdfTable table; | |
2543 | ||
2544 | /** | |
2545 | * Consumes the rowspan | |
2546 | * @param c | |
2547 | * @return a rowspan. | |
2548 | */ | |
2549 | public int consumeRowspan(PdfCell c) { | |
2550 |
1
1. consumeRowspan : negated conditional → NO_COVERAGE |
if (c.rowspan() == 1) { |
2551 |
1
1. consumeRowspan : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 1; |
2552 | } | |
2553 | ||
2554 | Integer i = rowspanMap.get(c); | |
2555 |
1
1. consumeRowspan : negated conditional → NO_COVERAGE |
if (i == null) { |
2556 | i = c.rowspan(); | |
2557 | } | |
2558 | ||
2559 |
1
1. consumeRowspan : Replaced integer subtraction with addition → NO_COVERAGE |
i = i - 1; |
2560 | rowspanMap.put(c, i); | |
2561 | ||
2562 |
2
1. consumeRowspan : changed conditional boundary → NO_COVERAGE 2. consumeRowspan : negated conditional → NO_COVERAGE |
if (i < 1) { |
2563 |
1
1. consumeRowspan : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 1; |
2564 | } | |
2565 |
1
1. consumeRowspan : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return i; |
2566 | } | |
2567 | ||
2568 | /** | |
2569 | * Looks at the current rowspan. | |
2570 | * @param c | |
2571 | * @return the current rowspan | |
2572 | */ | |
2573 | public int currentRowspan(PdfCell c) { | |
2574 | Integer i = rowspanMap.get(c); | |
2575 |
1
1. currentRowspan : negated conditional → NO_COVERAGE |
if (i == null) { |
2576 |
1
1. currentRowspan : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return c.rowspan(); |
2577 | } else { | |
2578 |
1
1. currentRowspan : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return i; |
2579 | } | |
2580 | } | |
2581 | ||
2582 | public int cellRendered(PdfCell cell, int pageNumber) { | |
2583 | Integer i = (Integer) pageMap.get(cell); | |
2584 |
1
1. cellRendered : negated conditional → NO_COVERAGE |
if (i == null) { |
2585 | i = 1; | |
2586 | } else { | |
2587 |
1
1. cellRendered : Replaced integer addition with subtraction → NO_COVERAGE |
i = i + 1; |
2588 | } | |
2589 | pageMap.put(cell, i); | |
2590 | ||
2591 | Integer pageInteger = pageNumber; | |
2592 | Set set = (Set) pageMap.get(pageInteger); | |
2593 | ||
2594 |
1
1. cellRendered : negated conditional → NO_COVERAGE |
if (set == null) { |
2595 | set = new HashSet(); | |
2596 | pageMap.put(pageInteger, set); | |
2597 | } | |
2598 | ||
2599 | set.add(cell); | |
2600 | ||
2601 |
1
1. cellRendered : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return i; |
2602 | } | |
2603 | ||
2604 | public int numCellRendered(PdfCell cell) { | |
2605 | Integer i = (Integer) pageMap.get(cell); | |
2606 |
1
1. numCellRendered : negated conditional → NO_COVERAGE |
if (i == null) { |
2607 | i = 0; | |
2608 | } | |
2609 |
1
1. numCellRendered : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return i; |
2610 | } | |
2611 | ||
2612 | public boolean isCellRenderedOnPage(PdfCell cell, int pageNumber) { | |
2613 | Integer pageInteger = pageNumber; | |
2614 | Set set = (Set) pageMap.get(pageInteger); | |
2615 | ||
2616 |
1
1. isCellRenderedOnPage : negated conditional → NO_COVERAGE |
if (set != null) { |
2617 |
1
1. isCellRenderedOnPage : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return set.contains(cell); |
2618 | } | |
2619 | ||
2620 |
1
1. isCellRenderedOnPage : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
2621 | } | |
2622 | } | |
2623 | ||
2624 | /** | |
2625 | * Adds a new table to the document. | |
2626 | * @param t Table to add. Rendered rows will be deleted after processing. | |
2627 | * @throws DocumentException | |
2628 | * @since iText 2.0.8 | |
2629 | */ | |
2630 | private void addPdfTable(Table t) throws DocumentException { | |
2631 | // before every table, we flush all lines | |
2632 | flushLines(); | |
2633 | ||
2634 |
1
1. addPdfTable : Replaced float subtraction with addition → NO_COVERAGE |
PdfTable table = new PdfTable(t, indentLeft(), indentRight(), indentTop() - currentHeight); |
2635 | RenderingContext ctx = new RenderingContext(); | |
2636 | ctx.pagetop = indentTop(); | |
2637 | ctx.oldHeight = currentHeight; | |
2638 | ctx.cellGraphics = new PdfContentByte(writer); | |
2639 | ctx.rowspanMap = new HashMap<>(); | |
2640 | ctx.table = table; | |
2641 | ||
2642 | // initialization of parameters | |
2643 | PdfCell cell; | |
2644 | ||
2645 | // drawing the table | |
2646 | ArrayList headercells = table.getHeaderCells(); | |
2647 | ArrayList cells = table.getCells(); | |
2648 | ArrayList rows = extractRows(cells, ctx); | |
2649 | boolean isContinue = false; | |
2650 |
1
1. addPdfTable : negated conditional → NO_COVERAGE |
while (!cells.isEmpty()) { |
2651 | // initialization of some extra parameters; | |
2652 | ctx.lostTableBottom = 0; | |
2653 | ||
2654 | // loop over the cells | |
2655 | boolean cellsShown = false; | |
2656 | ||
2657 | // draw the cells (line by line) | |
2658 | Iterator iterator = rows.iterator(); | |
2659 | ||
2660 | boolean atLeastOneFits = false; | |
2661 |
1
1. addPdfTable : negated conditional → NO_COVERAGE |
while (iterator.hasNext()) { |
2662 | ArrayList row = (ArrayList) iterator.next(); | |
2663 |
1
1. addPdfTable : removed call to com/lowagie/text/pdf/PdfDocument::analyzeRow → NO_COVERAGE |
analyzeRow(rows, ctx); |
2664 |
2
1. addPdfTable : Replaced bitwise AND with OR → NO_COVERAGE 2. addPdfTable : removed call to com/lowagie/text/pdf/PdfDocument::renderCells → NO_COVERAGE |
renderCells(ctx, row, table.hasToFitPageCells() & atLeastOneFits); |
2665 | ||
2666 |
1
1. addPdfTable : negated conditional → NO_COVERAGE |
if (!mayBeRemoved(row)) { |
2667 | break; | |
2668 | } | |
2669 |
1
1. addPdfTable : removed call to com/lowagie/text/pdf/PdfDocument::consumeRowspan → NO_COVERAGE |
consumeRowspan(row, ctx); |
2670 |
1
1. addPdfTable : removed call to java/util/Iterator::remove → NO_COVERAGE |
iterator.remove(); |
2671 | atLeastOneFits = true; | |
2672 | } | |
2673 | ||
2674 | // compose cells array list for subsequent code | |
2675 |
1
1. addPdfTable : removed call to java/util/ArrayList::clear → NO_COVERAGE |
cells.clear(); |
2676 | Set<PdfCell> opt = new HashSet<>(); | |
2677 | iterator = rows.iterator(); | |
2678 | while (iterator.hasNext()) { | |
2679 | ArrayList row = (ArrayList) iterator.next(); | |
2680 | ||
2681 | for (Object o : row) { | |
2682 | cell = (PdfCell) o; | |
2683 | ||
2684 |
1
1. addPdfTable : negated conditional → NO_COVERAGE |
if (!opt.contains(cell)) { |
2685 | cells.add(cell); | |
2686 | opt.add(cell); | |
2687 | } | |
2688 | } | |
2689 | } | |
2690 | ||
2691 | // we paint the graphics of the table after looping through all the cells | |
2692 | Rectangle tablerec = new Rectangle(table); | |
2693 |
1
1. addPdfTable : removed call to com/lowagie/text/Rectangle::setBorder → NO_COVERAGE |
tablerec.setBorder(table.getBorder()); |
2694 |
1
1. addPdfTable : removed call to com/lowagie/text/Rectangle::setBorderWidth → NO_COVERAGE |
tablerec.setBorderWidth(table.getBorderWidth()); |
2695 |
1
1. addPdfTable : removed call to com/lowagie/text/Rectangle::setBorderColor → NO_COVERAGE |
tablerec.setBorderColor(table.getBorderColor()); |
2696 |
1
1. addPdfTable : removed call to com/lowagie/text/Rectangle::setBackgroundColor → NO_COVERAGE |
tablerec.setBackgroundColor(table.getBackgroundColor()); |
2697 | PdfContentByte under = writer.getDirectContentUnder(); | |
2698 |
1
1. addPdfTable : removed call to com/lowagie/text/pdf/PdfContentByte::rectangle → NO_COVERAGE |
under.rectangle(tablerec.rectangle(top(), indentBottom())); |
2699 |
1
1. addPdfTable : removed call to com/lowagie/text/pdf/PdfContentByte::add → NO_COVERAGE |
under.add(ctx.cellGraphics); |
2700 | // bugfix by Gerald Fehringer: now again add the border for the table | |
2701 | // since it might have been covered by cell backgrounds | |
2702 |
1
1. addPdfTable : removed call to com/lowagie/text/Rectangle::setBackgroundColor → NO_COVERAGE |
tablerec.setBackgroundColor(null); |
2703 | tablerec = tablerec.rectangle(top(), indentBottom()); | |
2704 |
1
1. addPdfTable : removed call to com/lowagie/text/Rectangle::setBorder → NO_COVERAGE |
tablerec.setBorder(table.getBorder()); |
2705 |
1
1. addPdfTable : removed call to com/lowagie/text/pdf/PdfContentByte::rectangle → NO_COVERAGE |
under.rectangle(tablerec); |
2706 | // end bugfix | |
2707 | ||
2708 | ctx.cellGraphics = new PdfContentByte(null); | |
2709 | // if the table continues on the next page | |
2710 | ||
2711 |
1
1. addPdfTable : negated conditional → NO_COVERAGE |
if (!rows.isEmpty()) { |
2712 | isContinue = true; | |
2713 |
1
1. addPdfTable : removed call to com/lowagie/text/pdf/PdfContentByte::setLineWidth → NO_COVERAGE |
graphics.setLineWidth(table.getBorderWidth()); |
2714 |
3
1. addPdfTable : Replaced bitwise AND with OR → NO_COVERAGE 2. addPdfTable : negated conditional → NO_COVERAGE 3. addPdfTable : negated conditional → NO_COVERAGE |
if (cellsShown && (table.getBorder() & Rectangle.BOTTOM) == Rectangle.BOTTOM) { |
2715 | // Draw the bottom line | |
2716 | ||
2717 | // the color is set to the color of the element | |
2718 | Color tColor = table.getBorderColor(); | |
2719 |
1
1. addPdfTable : negated conditional → NO_COVERAGE |
if (tColor != null) { |
2720 |
1
1. addPdfTable : removed call to com/lowagie/text/pdf/PdfContentByte::setColorStroke → NO_COVERAGE |
graphics.setColorStroke(tColor); |
2721 | } | |
2722 |
1
1. addPdfTable : removed call to com/lowagie/text/pdf/PdfContentByte::moveTo → NO_COVERAGE |
graphics.moveTo(table.getLeft(), Math.max(table.getBottom(), indentBottom())); |
2723 |
1
1. addPdfTable : removed call to com/lowagie/text/pdf/PdfContentByte::lineTo → NO_COVERAGE |
graphics.lineTo(table.getRight(), Math.max(table.getBottom(), indentBottom())); |
2724 |
1
1. addPdfTable : removed call to com/lowagie/text/pdf/PdfContentByte::stroke → NO_COVERAGE |
graphics.stroke(); |
2725 |
1
1. addPdfTable : negated conditional → NO_COVERAGE |
if (tColor != null) { |
2726 |
1
1. addPdfTable : removed call to com/lowagie/text/pdf/PdfContentByte::resetRGBColorStroke → NO_COVERAGE |
graphics.resetRGBColorStroke(); |
2727 | } | |
2728 | } | |
2729 | ||
2730 | // old page | |
2731 | pageEmpty = false; | |
2732 | float difference = ctx.lostTableBottom; | |
2733 | ||
2734 | // new page | |
2735 | newPage(); | |
2736 | ||
2737 | // G.F.: if something added in page event i.e. currentHeight > 0 | |
2738 | float heightCorrection = 0; | |
2739 | boolean somethingAdded = false; | |
2740 |
2
1. addPdfTable : changed conditional boundary → NO_COVERAGE 2. addPdfTable : negated conditional → NO_COVERAGE |
if (currentHeight > 0) { |
2741 | heightCorrection = 6; | |
2742 |
1
1. addPdfTable : Replaced float addition with subtraction → NO_COVERAGE |
currentHeight += heightCorrection; |
2743 | somethingAdded = true; | |
2744 |
1
1. addPdfTable : removed call to com/lowagie/text/pdf/PdfDocument::newLine → NO_COVERAGE |
newLine(); |
2745 | flushLines(); | |
2746 |
1
1. addPdfTable : Replaced float subtraction with addition → NO_COVERAGE |
indentation.indentTop = currentHeight - leading; |
2747 | currentHeight = 0; | |
2748 | } | |
2749 | else { | |
2750 | flushLines(); | |
2751 | } | |
2752 | ||
2753 | // this part repeats the table headers (if any) | |
2754 | int size = headercells.size(); | |
2755 |
2
1. addPdfTable : changed conditional boundary → NO_COVERAGE 2. addPdfTable : negated conditional → NO_COVERAGE |
if (size > 0) { |
2756 | // this is the top of the headersection | |
2757 | cell = (PdfCell) headercells.get(0); | |
2758 | float oldTop = cell.getTop(0); | |
2759 | // loop over all the cells of the table header | |
2760 |
3
1. addPdfTable : changed conditional boundary → NO_COVERAGE 2. addPdfTable : Changed increment from 1 to -1 → NO_COVERAGE 3. addPdfTable : negated conditional → NO_COVERAGE |
for (int i = 0; i < size; i++) { |
2761 | cell = (PdfCell) headercells.get(i); | |
2762 | // calculation of the new cellpositions | |
2763 |
3
1. addPdfTable : Replaced float subtraction with addition → NO_COVERAGE 2. addPdfTable : Replaced float addition with subtraction → NO_COVERAGE 3. addPdfTable : removed call to com/lowagie/text/pdf/PdfCell::setTop → NO_COVERAGE |
cell.setTop(indentTop() - oldTop + cell.getTop(0)); |
2764 |
3
1. addPdfTable : Replaced float subtraction with addition → NO_COVERAGE 2. addPdfTable : Replaced float addition with subtraction → NO_COVERAGE 3. addPdfTable : removed call to com/lowagie/text/pdf/PdfCell::setBottom → NO_COVERAGE |
cell.setBottom(indentTop() - oldTop + cell.getBottom(0)); |
2765 | ctx.pagetop = cell.getBottom(); | |
2766 | // we paint the borders of the cell | |
2767 |
1
1. addPdfTable : removed call to com/lowagie/text/pdf/PdfContentByte::rectangle → NO_COVERAGE |
ctx.cellGraphics.rectangle(cell.rectangle(indentTop(), indentBottom())); |
2768 | // we write the text of the cell | |
2769 | ArrayList images = cell.getImages(indentTop(), indentBottom()); | |
2770 | for (Object image1 : images) { | |
2771 | cellsShown = true; | |
2772 | Image image = (Image) image1; | |
2773 |
1
1. addPdfTable : removed call to com/lowagie/text/pdf/PdfContentByte::addImage → NO_COVERAGE |
graphics.addImage(image); |
2774 | } | |
2775 |