1 | /* | |
2 | * $Id: ColumnText.java 4091 2009-11-10 15:15:28Z psoares33 $ | |
3 | * | |
4 | * Copyright 2001, 2002 by Paulo Soares. | |
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 | import java.util.ArrayList; | |
52 | import java.util.LinkedList; | |
53 | import java.util.Stack; | |
54 | import com.lowagie.text.error_messages.MessageLocalization; | |
55 | ||
56 | import com.lowagie.text.Chunk; | |
57 | import com.lowagie.text.DocumentException; | |
58 | import com.lowagie.text.Element; | |
59 | ||
60 | import com.lowagie.text.Image; | |
61 | import com.lowagie.text.ListItem; | |
62 | import com.lowagie.text.Paragraph; | |
63 | import com.lowagie.text.Phrase; | |
64 | import com.lowagie.text.SimpleTable; | |
65 | import com.lowagie.text.ExceptionConverter; | |
66 | import com.lowagie.text.pdf.draw.DrawInterface; | |
67 | ||
68 | /** | |
69 | * Formats text in a columnwise form. The text is bound | |
70 | * on the left and on the right by a sequence of lines. This allows the column | |
71 | * to have any shape, not only rectangular. | |
72 | * <P> | |
73 | * Several parameters can be set like the first paragraph line indent and | |
74 | * extra space between paragraphs. | |
75 | * <P> | |
76 | * A call to the method <CODE>go</CODE> will return one of the following | |
77 | * situations: the column ended or the text ended. | |
78 | * <P> | |
79 | * I the column ended, a new column definition can be loaded with the method | |
80 | * <CODE>setColumns</CODE> and the method <CODE>go</CODE> can be called again. | |
81 | * <P> | |
82 | * If the text ended, more text can be loaded with <CODE>addText</CODE> | |
83 | * and the method <CODE>go</CODE> can be called again.<BR> | |
84 | * The only limitation is that one or more complete paragraphs must be loaded | |
85 | * each time. | |
86 | * <P> | |
87 | * Full bidirectional reordering is supported. If the run direction is | |
88 | * <CODE>PdfWriter.RUN_DIRECTION_RTL</CODE> the meaning of the horizontal | |
89 | * alignments and margins is mirrored. | |
90 | * @author Paulo Soares (psoares@consiste.pt) | |
91 | */ | |
92 | ||
93 | public class ColumnText { | |
94 | /** Eliminate the arabic vowels */ | |
95 | public static final int AR_NOVOWEL = ArabicLigaturizer.ar_novowel; | |
96 | /** Compose the tashkeel in the ligatures. */ | |
97 | public static final int AR_COMPOSEDTASHKEEL = ArabicLigaturizer.ar_composedtashkeel; | |
98 | /** Do some extra double ligatures. */ | |
99 | public static final int AR_LIG = ArabicLigaturizer.ar_lig; | |
100 | /** | |
101 | * Digit shaping option: Replace European digits (U+0030...U+0039) by Arabic-Indic digits. | |
102 | */ | |
103 | public static final int DIGITS_EN2AN = ArabicLigaturizer.DIGITS_EN2AN; | |
104 | | |
105 | /** | |
106 | * Digit shaping option: Replace Arabic-Indic digits by European digits (U+0030...U+0039). | |
107 | */ | |
108 | public static final int DIGITS_AN2EN = ArabicLigaturizer.DIGITS_AN2EN; | |
109 | | |
110 | /** | |
111 | * Digit shaping option: | |
112 | * Replace European digits (U+0030...U+0039) by Arabic-Indic digits | |
113 | * if the most recent strongly directional character | |
114 | * is an Arabic letter (its Bidi direction value is RIGHT_TO_LEFT_ARABIC). | |
115 | * The initial state at the start of the text is assumed to be not an Arabic, | |
116 | * letter, so European digits at the start of the text will not change. | |
117 | * Compare to DIGITS_ALEN2AN_INIT_AL. | |
118 | */ | |
119 | public static final int DIGITS_EN2AN_INIT_LR = ArabicLigaturizer.DIGITS_EN2AN_INIT_LR; | |
120 | | |
121 | /** | |
122 | * Digit shaping option: | |
123 | * Replace European digits (U+0030...U+0039) by Arabic-Indic digits | |
124 | * if the most recent strongly directional character | |
125 | * is an Arabic letter (its Bidi direction value is RIGHT_TO_LEFT_ARABIC). | |
126 | * The initial state at the start of the text is assumed to be an Arabic, | |
127 | * letter, so European digits at the start of the text will change. | |
128 | * Compare to DIGITS_ALEN2AN_INT_LR. | |
129 | */ | |
130 | public static final int DIGITS_EN2AN_INIT_AL = ArabicLigaturizer.DIGITS_EN2AN_INIT_AL; | |
131 | | |
132 | /** | |
133 | * Digit type option: Use Arabic-Indic digits (U+0660...U+0669). | |
134 | */ | |
135 | public static final int DIGIT_TYPE_AN = ArabicLigaturizer.DIGIT_TYPE_AN; | |
136 | | |
137 | /** | |
138 | * Digit type option: Use Eastern (Extended) Arabic-Indic digits (U+06f0...U+06f9). | |
139 | */ | |
140 | public static final int DIGIT_TYPE_AN_EXTENDED = ArabicLigaturizer.DIGIT_TYPE_AN_EXTENDED; | |
141 | | |
142 | protected int runDirection = PdfWriter.RUN_DIRECTION_DEFAULT; | |
143 | | |
144 | /** the space char ratio */ | |
145 | public static final float GLOBAL_SPACE_CHAR_RATIO = 0; | |
146 | | |
147 | /** Initial value of the status. */ | |
148 | public static final int START_COLUMN = 0; | |
149 | | |
150 | /** Signals that there is no more text available. */ | |
151 | public static final int NO_MORE_TEXT = 1; | |
152 | | |
153 | /** Signals that there is no more column. */ | |
154 | public static final int NO_MORE_COLUMN = 2; | |
155 | | |
156 | /** The column is valid. */ | |
157 | protected static final int LINE_STATUS_OK = 0; | |
158 | | |
159 | /** The line is out the column limits. */ | |
160 | protected static final int LINE_STATUS_OFFLIMITS = 1; | |
161 | | |
162 | /** The line cannot fit this column position. */ | |
163 | protected static final int LINE_STATUS_NOLINE = 2; | |
164 | | |
165 | /** Upper bound of the column. */ | |
166 | protected float maxY; | |
167 | | |
168 | /** Lower bound of the column. */ | |
169 | protected float minY; | |
170 | | |
171 | protected float leftX; | |
172 | | |
173 | protected float rightX; | |
174 | | |
175 | /** The column alignment. Default is left alignment. */ | |
176 | protected int alignment = Element.ALIGN_LEFT; | |
177 | | |
178 | /** The left column bound. */ | |
179 | protected ArrayList leftWall; | |
180 | | |
181 | /** The right column bound. */ | |
182 | protected ArrayList rightWall; | |
183 | | |
184 | /** The chunks that form the text. */ | |
185 | // protected ArrayList chunks = new ArrayList(); | |
186 | protected BidiLine bidiLine; | |
187 | | |
188 | /** The current y line location. Text will be written at this line minus the leading. */ | |
189 | protected float yLine; | |
190 | | |
191 | /** The leading for the current line. */ | |
192 | protected float currentLeading = 16; | |
193 | | |
194 | /** The fixed text leading. */ | |
195 | protected float fixedLeading = 16; | |
196 | | |
197 | /** The text leading that is multiplied by the biggest font size in the line. */ | |
198 | protected float multipliedLeading = 0; | |
199 | | |
200 | /** The <CODE>PdfContent</CODE> where the text will be written to. */ | |
201 | protected PdfContentByte canvas; | |
202 | | |
203 | protected PdfContentByte[] canvases; | |
204 | | |
205 | /** The line status when trying to fit a line to a column. */ | |
206 | protected int lineStatus; | |
207 | | |
208 | /** The first paragraph line indent. */ | |
209 | protected float indent = 0; | |
210 | | |
211 | /** The following paragraph lines indent. */ | |
212 | protected float followingIndent = 0; | |
213 | | |
214 | /** The right paragraph lines indent. */ | |
215 | protected float rightIndent = 0; | |
216 | | |
217 | /** The extra space between paragraphs. */ | |
218 | protected float extraParagraphSpace = 0; | |
219 | | |
220 | /** The width of the line when the column is defined as a simple rectangle. */ | |
221 | protected float rectangularWidth = -1; | |
222 | | |
223 | protected boolean rectangularMode = false; | |
224 | /** Holds value of property spaceCharRatio. */ | |
225 | private float spaceCharRatio = GLOBAL_SPACE_CHAR_RATIO; | |
226 | ||
227 | private boolean lastWasNewline = true; | |
228 | | |
229 | /** Holds value of property linesWritten. */ | |
230 | private int linesWritten; | |
231 | | |
232 | private float firstLineY; | |
233 | private boolean firstLineYDone = false; | |
234 | | |
235 | /** Holds value of property arabicOptions. */ | |
236 | private int arabicOptions = 0; | |
237 | | |
238 | protected float descender; | |
239 | | |
240 | protected boolean composite = false; | |
241 | | |
242 | protected ColumnText compositeColumn; | |
243 | | |
244 | protected LinkedList compositeElements; | |
245 | | |
246 | protected int listIdx = 0; | |
247 | | |
248 | private boolean splittedRow; | |
249 | | |
250 | protected Phrase waitPhrase; | |
251 | | |
252 | /** if true, first line height is adjusted so that the max ascender touches the top */ | |
253 | private boolean useAscender = false; | |
254 | ||
255 | /** Holds value of property filledWidth. */ | |
256 | private float filledWidth; | |
257 | ||
258 | private boolean adjustFirstLine = true; | |
259 | | |
260 | /** | |
261 | * Creates a <CODE>ColumnText</CODE>. | |
262 | * | |
263 | * @param canvas the place where the text will be written to. Can | |
264 | * be a template. | |
265 | */ | |
266 | public ColumnText(PdfContentByte canvas) { | |
267 | this.canvas = canvas; | |
268 | } | |
269 | | |
270 | /** | |
271 | * Creates an independent duplicated of the instance <CODE>org</CODE>. | |
272 | * | |
273 | * @param org the original <CODE>ColumnText</CODE> | |
274 | * @return the duplicated | |
275 | */ | |
276 | public static ColumnText duplicate(ColumnText org) { | |
277 | ColumnText ct = new ColumnText(null); | |
278 | ct.setACopy(org); | |
279 |
1
1. duplicate : mutated return of Object value for com/lowagie/text/pdf/ColumnText::duplicate to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return ct; |
280 | } | |
281 | | |
282 | /** | |
283 | * Makes this instance an independent copy of <CODE>org</CODE>. | |
284 | * | |
285 | * @param org the original <CODE>ColumnText</CODE> | |
286 | * @return itself | |
287 | */ | |
288 | public ColumnText setACopy(ColumnText org) { | |
289 |
1
1. setACopy : removed call to com/lowagie/text/pdf/ColumnText::setSimpleVars → NO_COVERAGE |
setSimpleVars(org); |
290 |
1
1. setACopy : negated conditional → NO_COVERAGE |
if (org.bidiLine != null) |
291 | bidiLine = new BidiLine(org.bidiLine); | |
292 |
1
1. setACopy : mutated return of Object value for com/lowagie/text/pdf/ColumnText::setACopy to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return this; |
293 | } | |
294 | | |
295 | protected void setSimpleVars(ColumnText org) { | |
296 | maxY = org.maxY; | |
297 | minY = org.minY; | |
298 | alignment = org.alignment; | |
299 | leftWall = null; | |
300 |
1
1. setSimpleVars : negated conditional → NO_COVERAGE |
if (org.leftWall != null) |
301 | leftWall = new ArrayList(org.leftWall); | |
302 | rightWall = null; | |
303 |
1
1. setSimpleVars : negated conditional → NO_COVERAGE |
if (org.rightWall != null) |
304 | rightWall = new ArrayList(org.rightWall); | |
305 | yLine = org.yLine; | |
306 | currentLeading = org.currentLeading; | |
307 | fixedLeading = org.fixedLeading; | |
308 | multipliedLeading = org.multipliedLeading; | |
309 | canvas = org.canvas; | |
310 | canvases = org.canvases; | |
311 | lineStatus = org.lineStatus; | |
312 | indent = org.indent; | |
313 | followingIndent = org.followingIndent; | |
314 | rightIndent = org.rightIndent; | |
315 | extraParagraphSpace = org.extraParagraphSpace; | |
316 | rectangularWidth = org.rectangularWidth; | |
317 | rectangularMode = org.rectangularMode; | |
318 | spaceCharRatio = org.spaceCharRatio; | |
319 | lastWasNewline = org.lastWasNewline; | |
320 | linesWritten = org.linesWritten; | |
321 | arabicOptions = org.arabicOptions; | |
322 | runDirection = org.runDirection; | |
323 | descender = org.descender; | |
324 | composite = org.composite; | |
325 | splittedRow = org.splittedRow; | |
326 |
1
1. setSimpleVars : negated conditional → NO_COVERAGE |
if (org.composite) { |
327 | compositeElements = new LinkedList(org.compositeElements); | |
328 |
1
1. setSimpleVars : negated conditional → NO_COVERAGE |
if (splittedRow) { |
329 | PdfPTable table = (PdfPTable)compositeElements.getFirst(); | |
330 | compositeElements.set(0, new PdfPTable(table)); | |
331 | } | |
332 |
1
1. setSimpleVars : negated conditional → NO_COVERAGE |
if (org.compositeColumn != null) |
333 | compositeColumn = duplicate(org.compositeColumn); | |
334 | } | |
335 | listIdx = org.listIdx; | |
336 | firstLineY = org.firstLineY; | |
337 | leftX = org.leftX; | |
338 | rightX = org.rightX; | |
339 | firstLineYDone = org.firstLineYDone; | |
340 | waitPhrase = org.waitPhrase; | |
341 | useAscender = org.useAscender; | |
342 | filledWidth = org.filledWidth; | |
343 | adjustFirstLine = org.adjustFirstLine; | |
344 | } | |
345 | | |
346 | private void addWaitingPhrase() { | |
347 |
2
1. addWaitingPhrase : negated conditional → NO_COVERAGE 2. addWaitingPhrase : negated conditional → NO_COVERAGE |
if (bidiLine == null && waitPhrase != null) { |
348 | bidiLine = new BidiLine(); | |
349 | for (Object o : waitPhrase.getChunks()) { | |
350 |
1
1. addWaitingPhrase : removed call to com/lowagie/text/pdf/BidiLine::addChunk → NO_COVERAGE |
bidiLine.addChunk(new PdfChunk((Chunk) o, null)); |
351 | } | |
352 | waitPhrase = null; | |
353 | } | |
354 | } | |
355 | | |
356 | /** | |
357 | * Adds a <CODE>Phrase</CODE> to the current text array. | |
358 | * Will not have any effect if addElement() was called before. | |
359 | * | |
360 | * @param phrase the text | |
361 | */ | |
362 | public void addText(Phrase phrase) { | |
363 |
2
1. addText : negated conditional → NO_COVERAGE 2. addText : negated conditional → NO_COVERAGE |
if (phrase == null || composite) |
364 | return; | |
365 |
1
1. addText : removed call to com/lowagie/text/pdf/ColumnText::addWaitingPhrase → NO_COVERAGE |
addWaitingPhrase(); |
366 |
1
1. addText : negated conditional → NO_COVERAGE |
if (bidiLine == null) { |
367 | waitPhrase = phrase; | |
368 | return; | |
369 | } | |
370 | for (Object o : phrase.getChunks()) { | |
371 |
1
1. addText : removed call to com/lowagie/text/pdf/BidiLine::addChunk → NO_COVERAGE |
bidiLine.addChunk(new PdfChunk((Chunk) o, null)); |
372 | } | |
373 | } | |
374 | | |
375 | /** | |
376 | * Replaces the current text array with this <CODE>Phrase</CODE>. | |
377 | * Anything added previously with addElement() is lost. | |
378 | * | |
379 | * @param phrase the text | |
380 | */ | |
381 | public void setText(Phrase phrase) { | |
382 | bidiLine = null; | |
383 | composite = false; | |
384 | compositeColumn = null; | |
385 | compositeElements = null; | |
386 | listIdx = 0; | |
387 | splittedRow = false; | |
388 | waitPhrase = phrase; | |
389 | } | |
390 | | |
391 | /** | |
392 | * Adds a <CODE>Chunk</CODE> to the current text array. | |
393 | * Will not have any effect if addElement() was called before. | |
394 | * | |
395 | * @param chunk the text | |
396 | */ | |
397 | public void addText(Chunk chunk) { | |
398 |
2
1. addText : negated conditional → NO_COVERAGE 2. addText : negated conditional → NO_COVERAGE |
if (chunk == null || composite) |
399 | return; | |
400 |
1
1. addText : removed call to com/lowagie/text/pdf/ColumnText::addText → NO_COVERAGE |
addText(new Phrase(chunk)); |
401 | } | |
402 | | |
403 | /** | |
404 | * Adds an element. Elements supported are <CODE>Paragraph</CODE>, | |
405 | * <CODE>List</CODE>, <CODE>PdfPTable</CODE>, <CODE>Image</CODE> and | |
406 | * <CODE>Graphic</CODE>. | |
407 | * <p> | |
408 | * It removes all the text placed with <CODE>addText()</CODE>. | |
409 | * | |
410 | * @param element the <CODE>Element</CODE> | |
411 | */ | |
412 | public void addElement(Element element) { | |
413 |
1
1. addElement : negated conditional → NO_COVERAGE |
if (element == null) |
414 | return; | |
415 |
1
1. addElement : negated conditional → NO_COVERAGE |
if (element instanceof Image) { |
416 | Image img = (Image)element; | |
417 | PdfPTable t = new PdfPTable(1); | |
418 | float w = img.getWidthPercentage(); | |
419 |
1
1. addElement : negated conditional → NO_COVERAGE |
if (w == 0) { |
420 |
1
1. addElement : removed call to com/lowagie/text/pdf/PdfPTable::setTotalWidth → NO_COVERAGE |
t.setTotalWidth(img.getScaledWidth()); |
421 |
1
1. addElement : removed call to com/lowagie/text/pdf/PdfPTable::setLockedWidth → NO_COVERAGE |
t.setLockedWidth(true); |
422 | } | |
423 | else | |
424 |
1
1. addElement : removed call to com/lowagie/text/pdf/PdfPTable::setWidthPercentage → NO_COVERAGE |
t.setWidthPercentage(w); |
425 |
1
1. addElement : removed call to com/lowagie/text/pdf/PdfPTable::setSpacingAfter → NO_COVERAGE |
t.setSpacingAfter(img.getSpacingAfter()); |
426 |
1
1. addElement : removed call to com/lowagie/text/pdf/PdfPTable::setSpacingBefore → NO_COVERAGE |
t.setSpacingBefore(img.getSpacingBefore()); |
427 | switch (img.getAlignment()) { | |
428 | case Image.LEFT: | |
429 |
1
1. addElement : removed call to com/lowagie/text/pdf/PdfPTable::setHorizontalAlignment → NO_COVERAGE |
t.setHorizontalAlignment(Element.ALIGN_LEFT); |
430 | break; | |
431 | case Image.RIGHT: | |
432 |
1
1. addElement : removed call to com/lowagie/text/pdf/PdfPTable::setHorizontalAlignment → NO_COVERAGE |
t.setHorizontalAlignment(Element.ALIGN_RIGHT); |
433 | break; | |
434 | default: | |
435 |
1
1. addElement : removed call to com/lowagie/text/pdf/PdfPTable::setHorizontalAlignment → NO_COVERAGE |
t.setHorizontalAlignment(Element.ALIGN_CENTER); |
436 | break; | |
437 | } | |
438 | PdfPCell c = new PdfPCell(img, true); | |
439 |
1
1. addElement : removed call to com/lowagie/text/pdf/PdfPCell::setPadding → NO_COVERAGE |
c.setPadding(0); |
440 |
1
1. addElement : removed call to com/lowagie/text/pdf/PdfPCell::setBorder → NO_COVERAGE |
c.setBorder(img.getBorder()); |
441 |
1
1. addElement : removed call to com/lowagie/text/pdf/PdfPCell::setBorderColor → NO_COVERAGE |
c.setBorderColor(img.getBorderColor()); |
442 |
1
1. addElement : removed call to com/lowagie/text/pdf/PdfPCell::setBorderWidth → NO_COVERAGE |
c.setBorderWidth(img.getBorderWidth()); |
443 |
1
1. addElement : removed call to com/lowagie/text/pdf/PdfPCell::setBackgroundColor → NO_COVERAGE |
c.setBackgroundColor(img.getBackgroundColor()); |
444 |
1
1. addElement : removed call to com/lowagie/text/pdf/PdfPTable::addCell → NO_COVERAGE |
t.addCell(c); |
445 | element = t; | |
446 | } | |
447 |
1
1. addElement : negated conditional → NO_COVERAGE |
if (element.type() == Element.CHUNK) { |
448 | element = new Paragraph((Chunk)element); | |
449 | } | |
450 |
1
1. addElement : negated conditional → NO_COVERAGE |
else if (element.type() == Element.PHRASE) { |
451 | element = new Paragraph((Phrase)element); | |
452 | } | |
453 |
1
1. addElement : negated conditional → NO_COVERAGE |
if (element instanceof SimpleTable) { |
454 | try { | |
455 | element = ((SimpleTable)element).createPdfPTable(); | |
456 | } catch (DocumentException e) { | |
457 | throw new IllegalArgumentException(MessageLocalization.getComposedMessage("element.not.allowed")); | |
458 | } | |
459 | } | |
460 |
4
1. addElement : negated conditional → NO_COVERAGE 2. addElement : negated conditional → NO_COVERAGE 3. addElement : negated conditional → NO_COVERAGE 4. addElement : negated conditional → NO_COVERAGE |
else if (element.type() != Element.PARAGRAPH && element.type() != Element.LIST && element.type() != Element.PTABLE && element.type() != Element.YMARK) |
461 | throw new IllegalArgumentException(MessageLocalization.getComposedMessage("element.not.allowed")); | |
462 |
1
1. addElement : negated conditional → NO_COVERAGE |
if (!composite) { |
463 | composite = true; | |
464 | compositeElements = new LinkedList(); | |
465 | bidiLine = null; | |
466 | waitPhrase = null; | |
467 | } | |
468 | compositeElements.add(element); | |
469 | } | |
470 | | |
471 | /** | |
472 | * Converts a sequence of lines representing one of the column bounds into | |
473 | * an internal format. | |
474 | * <p> | |
475 | * Each array element will contain a <CODE>float[4]</CODE> representing | |
476 | * the line x = ax + b. | |
477 | * | |
478 | * @param cLine the column array | |
479 | * @return the converted array | |
480 | */ | |
481 | protected ArrayList convertColumn(float[] cLine) { | |
482 |
2
1. convertColumn : changed conditional boundary → NO_COVERAGE 2. convertColumn : negated conditional → NO_COVERAGE |
if (cLine.length < 4) |
483 | throw new RuntimeException(MessageLocalization.getComposedMessage("no.valid.column.line.found")); | |
484 | ArrayList cc = new ArrayList(); | |
485 |
4
1. convertColumn : changed conditional boundary → NO_COVERAGE 2. convertColumn : Changed increment from 2 to -2 → NO_COVERAGE 3. convertColumn : Replaced integer subtraction with addition → NO_COVERAGE 4. convertColumn : negated conditional → NO_COVERAGE |
for (int k = 0; k < cLine.length - 2; k += 2) { |
486 | float x1 = cLine[k]; | |
487 |
1
1. convertColumn : Replaced integer addition with subtraction → NO_COVERAGE |
float y1 = cLine[k + 1]; |
488 |
1
1. convertColumn : Replaced integer addition with subtraction → NO_COVERAGE |
float x2 = cLine[k + 2]; |
489 |
1
1. convertColumn : Replaced integer addition with subtraction → NO_COVERAGE |
float y2 = cLine[k + 3]; |
490 |
1
1. convertColumn : negated conditional → NO_COVERAGE |
if (y1 == y2) |
491 | continue; | |
492 | // x = ay + b | |
493 |
3
1. convertColumn : Replaced float subtraction with addition → NO_COVERAGE 2. convertColumn : Replaced float subtraction with addition → NO_COVERAGE 3. convertColumn : Replaced float division with multiplication → NO_COVERAGE |
float a = (x1 - x2) / (y1 - y2); |
494 |
2
1. convertColumn : Replaced float multiplication with division → NO_COVERAGE 2. convertColumn : Replaced float subtraction with addition → NO_COVERAGE |
float b = x1 - a * y1; |
495 | float[] r = new float[4]; | |
496 | r[0] = Math.min(y1, y2); | |
497 | r[1] = Math.max(y1, y2); | |
498 | r[2] = a; | |
499 | r[3] = b; | |
500 | cc.add(r); | |
501 | maxY = Math.max(maxY, r[1]); | |
502 | minY = Math.min(minY, r[0]); | |
503 | } | |
504 |
1
1. convertColumn : negated conditional → NO_COVERAGE |
if (cc.isEmpty()) |
505 | throw new RuntimeException(MessageLocalization.getComposedMessage("no.valid.column.line.found")); | |
506 |
1
1. convertColumn : mutated return of Object value for com/lowagie/text/pdf/ColumnText::convertColumn to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return cc; |
507 | } | |
508 | | |
509 | /** | |
510 | * Finds the intersection between the <CODE>yLine</CODE> and the column. It will | |
511 | * set the <CODE>lineStatus</CODE> appropriately. | |
512 | * | |
513 | * @param wall the column to intersect | |
514 | * @return the x coordinate of the intersection | |
515 | */ | |
516 | protected float findLimitsPoint(ArrayList wall) { | |
517 | lineStatus = LINE_STATUS_OK; | |
518 |
4
1. findLimitsPoint : changed conditional boundary → NO_COVERAGE 2. findLimitsPoint : changed conditional boundary → NO_COVERAGE 3. findLimitsPoint : negated conditional → NO_COVERAGE 4. findLimitsPoint : negated conditional → NO_COVERAGE |
if (yLine < minY || yLine > maxY) { |
519 | lineStatus = LINE_STATUS_OFFLIMITS; | |
520 |
1
1. findLimitsPoint : replaced return of float value with -(x + 1) for com/lowagie/text/pdf/ColumnText::findLimitsPoint → NO_COVERAGE |
return 0; |
521 | } | |
522 |
1
1. findLimitsPoint : negated conditional → NO_COVERAGE |
for (Object o : wall) { |
523 | float[] r = (float[]) o; | |
524 |
4
1. findLimitsPoint : changed conditional boundary → NO_COVERAGE 2. findLimitsPoint : changed conditional boundary → NO_COVERAGE 3. findLimitsPoint : negated conditional → NO_COVERAGE 4. findLimitsPoint : negated conditional → NO_COVERAGE |
if (yLine < r[0] || yLine > r[1]) |
525 | continue; | |
526 |
3
1. findLimitsPoint : Replaced float multiplication with division → NO_COVERAGE 2. findLimitsPoint : Replaced float addition with subtraction → NO_COVERAGE 3. findLimitsPoint : replaced return of float value with -(x + 1) for com/lowagie/text/pdf/ColumnText::findLimitsPoint → NO_COVERAGE |
return r[2] * yLine + r[3]; |
527 | } | |
528 | lineStatus = LINE_STATUS_NOLINE; | |
529 |
1
1. findLimitsPoint : replaced return of float value with -(x + 1) for com/lowagie/text/pdf/ColumnText::findLimitsPoint → NO_COVERAGE |
return 0; |
530 | } | |
531 | | |
532 | /** | |
533 | * Finds the intersection between the <CODE>yLine</CODE> and the two | |
534 | * column bounds. It will set the <CODE>lineStatus</CODE> appropriately. | |
535 | * | |
536 | * @return a <CODE>float[2]</CODE>with the x coordinates of the intersection | |
537 | */ | |
538 | protected float[] findLimitsOneLine() { | |
539 | float x1 = findLimitsPoint(leftWall); | |
540 |
2
1. findLimitsOneLine : negated conditional → NO_COVERAGE 2. findLimitsOneLine : negated conditional → NO_COVERAGE |
if (lineStatus == LINE_STATUS_OFFLIMITS || lineStatus == LINE_STATUS_NOLINE) |
541 |
1
1. findLimitsOneLine : mutated return of Object value for com/lowagie/text/pdf/ColumnText::findLimitsOneLine to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return null; |
542 | float x2 = findLimitsPoint(rightWall); | |
543 |
1
1. findLimitsOneLine : negated conditional → NO_COVERAGE |
if (lineStatus == LINE_STATUS_NOLINE) |
544 |
1
1. findLimitsOneLine : mutated return of Object value for com/lowagie/text/pdf/ColumnText::findLimitsOneLine to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return null; |
545 |
1
1. findLimitsOneLine : mutated return of Object value for com/lowagie/text/pdf/ColumnText::findLimitsOneLine to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new float[]{x1, x2}; |
546 | } | |
547 | | |
548 | /** | |
549 | * Finds the intersection between the <CODE>yLine</CODE>, | |
550 | * the <CODE>yLine-leading</CODE>and the two column bounds. | |
551 | * It will set the <CODE>lineStatus</CODE> appropriately. | |
552 | * | |
553 | * @return a <CODE>float[4]</CODE>with the x coordinates of the intersection | |
554 | */ | |
555 | protected float[] findLimitsTwoLines() { | |
556 | boolean repeat = false; | |
557 | for (;;) { | |
558 |
2
1. findLimitsTwoLines : negated conditional → NO_COVERAGE 2. findLimitsTwoLines : negated conditional → NO_COVERAGE |
if (repeat && currentLeading == 0) |
559 |
1
1. findLimitsTwoLines : mutated return of Object value for com/lowagie/text/pdf/ColumnText::findLimitsTwoLines to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return null; |
560 | repeat = true; | |
561 | float[] x1 = findLimitsOneLine(); | |
562 |
1
1. findLimitsTwoLines : negated conditional → NO_COVERAGE |
if (lineStatus == LINE_STATUS_OFFLIMITS) |
563 |
1
1. findLimitsTwoLines : mutated return of Object value for com/lowagie/text/pdf/ColumnText::findLimitsTwoLines to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return null; |
564 |
1
1. findLimitsTwoLines : Replaced float subtraction with addition → NO_COVERAGE |
yLine -= currentLeading; |
565 |
1
1. findLimitsTwoLines : negated conditional → NO_COVERAGE |
if (lineStatus == LINE_STATUS_NOLINE) { |
566 | continue; | |
567 | } | |
568 | float[] x2 = findLimitsOneLine(); | |
569 |
1
1. findLimitsTwoLines : negated conditional → NO_COVERAGE |
if (lineStatus == LINE_STATUS_OFFLIMITS) |
570 |
1
1. findLimitsTwoLines : mutated return of Object value for com/lowagie/text/pdf/ColumnText::findLimitsTwoLines to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return null; |
571 |
1
1. findLimitsTwoLines : negated conditional → NO_COVERAGE |
if (lineStatus == LINE_STATUS_NOLINE) { |
572 |
1
1. findLimitsTwoLines : Replaced float subtraction with addition → NO_COVERAGE |
yLine -= currentLeading; |
573 | continue; | |
574 | } | |
575 |
4
1. findLimitsTwoLines : changed conditional boundary → NO_COVERAGE 2. findLimitsTwoLines : changed conditional boundary → NO_COVERAGE 3. findLimitsTwoLines : negated conditional → NO_COVERAGE 4. findLimitsTwoLines : negated conditional → NO_COVERAGE |
if (x1[0] >= x2[1] || x2[0] >= x1[1]) |
576 | continue; | |
577 |
1
1. findLimitsTwoLines : mutated return of Object value for com/lowagie/text/pdf/ColumnText::findLimitsTwoLines to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new float[]{x1[0], x1[1], x2[0], x2[1]}; |
578 | } | |
579 | } | |
580 | | |
581 | /** | |
582 | * Sets the columns bounds. Each column bound is described by a | |
583 | * <CODE>float[]</CODE> with the line points [x1,y1,x2,y2,...]. | |
584 | * The array must have at least 4 elements. | |
585 | * | |
586 | * @param leftLine the left column bound | |
587 | * @param rightLine the right column bound | |
588 | */ | |
589 | public void setColumns(float[] leftLine, float[] rightLine) { | |
590 | maxY = -10e20f; | |
591 | minY = 10e20f; | |
592 |
2
1. setColumns : Replaced integer subtraction with addition → NO_COVERAGE 2. setColumns : removed call to com/lowagie/text/pdf/ColumnText::setYLine → NO_COVERAGE |
setYLine(Math.max(leftLine[1], leftLine[leftLine.length - 1])); |
593 | rightWall = convertColumn(rightLine); | |
594 | leftWall = convertColumn(leftLine); | |
595 | rectangularWidth = -1; | |
596 | rectangularMode = false; | |
597 | } | |
598 | | |
599 | /** | |
600 | * Simplified method for rectangular columns. | |
601 | * | |
602 | * @param phrase a <CODE>Phrase</CODE> | |
603 | * @param llx the lower left x corner | |
604 | * @param lly the lower left y corner | |
605 | * @param urx the upper right x corner | |
606 | * @param ury the upper right y corner | |
607 | * @param leading the leading | |
608 | * @param alignment the column alignment | |
609 | */ | |
610 | public void setSimpleColumn(Phrase phrase, float llx, float lly, float urx, float ury, float leading, int alignment) { | |
611 |
1
1. setSimpleColumn : removed call to com/lowagie/text/pdf/ColumnText::addText → NO_COVERAGE |
addText(phrase); |
612 |
1
1. setSimpleColumn : removed call to com/lowagie/text/pdf/ColumnText::setSimpleColumn → NO_COVERAGE |
setSimpleColumn(llx, lly, urx, ury, leading, alignment); |
613 | } | |
614 | | |
615 | /** | |
616 | * Simplified method for rectangular columns. | |
617 | * | |
618 | * @param llx the lower left x corner | |
619 | * @param lly the lower left y corner | |
620 | * @param urx the upper right x corner | |
621 | * @param ury the upper right y corner | |
622 | * @param leading the leading | |
623 | * @param alignment the column alignment | |
624 | */ | |
625 | public void setSimpleColumn(float llx, float lly, float urx, float ury, float leading, int alignment) { | |
626 |
1
1. setSimpleColumn : removed call to com/lowagie/text/pdf/ColumnText::setLeading → NO_COVERAGE |
setLeading(leading); |
627 | this.alignment = alignment; | |
628 |
1
1. setSimpleColumn : removed call to com/lowagie/text/pdf/ColumnText::setSimpleColumn → NO_COVERAGE |
setSimpleColumn(llx, lly, urx, ury); |
629 | } | |
630 | | |
631 | /** | |
632 | * Simplified method for rectangular columns. | |
633 | * | |
634 | * @param llx | |
635 | * @param lly | |
636 | * @param urx | |
637 | * @param ury | |
638 | */ | |
639 | public void setSimpleColumn(float llx, float lly, float urx, float ury) { | |
640 | leftX = Math.min(llx, urx); | |
641 | maxY = Math.max(lly, ury); | |
642 | minY = Math.min(lly, ury); | |
643 | rightX = Math.max(llx, urx); | |
644 | yLine = maxY; | |
645 |
1
1. setSimpleColumn : Replaced float subtraction with addition → NO_COVERAGE |
rectangularWidth = rightX - leftX; |
646 |
2
1. setSimpleColumn : changed conditional boundary → NO_COVERAGE 2. setSimpleColumn : negated conditional → NO_COVERAGE |
if (rectangularWidth < 0) |
647 | rectangularWidth = 0; | |
648 | rectangularMode = true; | |
649 | } | |
650 | | |
651 | /** | |
652 | * Sets the leading to fixed. | |
653 | * | |
654 | * @param leading the leading | |
655 | */ | |
656 | public void setLeading(float leading) { | |
657 | fixedLeading = leading; | |
658 | multipliedLeading = 0; | |
659 | } | |
660 | | |
661 | /** | |
662 | * Sets the leading fixed and variable. The resultant leading will be | |
663 | * fixedLeading+multipliedLeading*maxFontSize where maxFontSize is the | |
664 | * size of the biggest font in the line. | |
665 | * | |
666 | * @param fixedLeading the fixed leading | |
667 | * @param multipliedLeading the variable leading | |
668 | */ | |
669 | public void setLeading(float fixedLeading, float multipliedLeading) { | |
670 | this.fixedLeading = fixedLeading; | |
671 | this.multipliedLeading = multipliedLeading; | |
672 | } | |
673 | | |
674 | /** | |
675 | * Gets the fixed leading. | |
676 | * | |
677 | * @return the leading | |
678 | */ | |
679 | public float getLeading() { | |
680 | return fixedLeading; | |
681 | } | |
682 | | |
683 | /** | |
684 | * Gets the variable leading. | |
685 | * | |
686 | * @return the leading | |
687 | */ | |
688 | public float getMultipliedLeading() { | |
689 | return multipliedLeading; | |
690 | } | |
691 | | |
692 | /** | |
693 | * Sets the yLine. The line will be written to yLine-leading. | |
694 | * | |
695 | * @param yLine the yLine | |
696 | */ | |
697 | public void setYLine(float yLine) { | |
698 | this.yLine = yLine; | |
699 | } | |
700 | | |
701 | /** | |
702 | * Gets the yLine. | |
703 | * | |
704 | * @return the yLine | |
705 | */ | |
706 | public float getYLine() { | |
707 | return yLine; | |
708 | } | |
709 | | |
710 | /** | |
711 | * Sets the alignment. | |
712 | * | |
713 | * @param alignment the alignment | |
714 | */ | |
715 | public void setAlignment(int alignment) { | |
716 | this.alignment = alignment; | |
717 | } | |
718 | | |
719 | /** | |
720 | * Gets the alignment. | |
721 | * | |
722 | * @return the alignment | |
723 | */ | |
724 | public int getAlignment() { | |
725 | return alignment; | |
726 | } | |
727 | | |
728 | /** | |
729 | * Sets the first paragraph line indent. | |
730 | * | |
731 | * @param indent the indent | |
732 | */ | |
733 | public void setIndent(float indent) { | |
734 | this.indent = indent; | |
735 | lastWasNewline = true; | |
736 | } | |
737 | | |
738 | /** | |
739 | * Gets the first paragraph line indent. | |
740 | * | |
741 | * @return the indent | |
742 | */ | |
743 | public float getIndent() { | |
744 | return indent; | |
745 | } | |
746 | | |
747 | /** | |
748 | * Sets the following paragraph lines indent. | |
749 | * | |
750 | * @param indent the indent | |
751 | */ | |
752 | public void setFollowingIndent(float indent) { | |
753 | this.followingIndent = indent; | |
754 | lastWasNewline = true; | |
755 | } | |
756 | | |
757 | /** | |
758 | * Gets the following paragraph lines indent. | |
759 | * | |
760 | * @return the indent | |
761 | */ | |
762 | public float getFollowingIndent() { | |
763 | return followingIndent; | |
764 | } | |
765 | | |
766 | /** | |
767 | * Sets the right paragraph lines indent. | |
768 | * | |
769 | * @param indent the indent | |
770 | */ | |
771 | public void setRightIndent(float indent) { | |
772 | this.rightIndent = indent; | |
773 | lastWasNewline = true; | |
774 | } | |
775 | | |
776 | /** | |
777 | * Gets the right paragraph lines indent. | |
778 | * | |
779 | * @return the indent | |
780 | */ | |
781 | public float getRightIndent() { | |
782 | return rightIndent; | |
783 | } | |
784 | | |
785 | /** | |
786 | * Outputs the lines to the document. It is equivalent to <CODE>go(false)</CODE>. | |
787 | * | |
788 | * @return returns the result of the operation. It can be <CODE>NO_MORE_TEXT</CODE> | |
789 | * and/or <CODE>NO_MORE_COLUMN</CODE> | |
790 | * @throws DocumentException on error | |
791 | */ | |
792 | public int go() throws DocumentException { | |
793 |
1
1. go : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return go(false); |
794 | } | |
795 | | |
796 | /** | |
797 | * Outputs the lines to the document. The output can be simulated. | |
798 | * @param simulate <CODE>true</CODE> to simulate the writing to the document | |
799 | * @return returns the result of the operation. It can be <CODE>NO_MORE_TEXT</CODE> | |
800 | * and/or <CODE>NO_MORE_COLUMN</CODE> | |
801 | * @throws DocumentException on error | |
802 | */ | |
803 | public int go(boolean simulate) throws DocumentException { | |
804 |
1
1. go : negated conditional → NO_COVERAGE |
if (composite) |
805 |
1
1. go : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return goComposite(simulate); |
806 |
1
1. go : removed call to com/lowagie/text/pdf/ColumnText::addWaitingPhrase → NO_COVERAGE |
addWaitingPhrase(); |
807 |
1
1. go : negated conditional → NO_COVERAGE |
if (bidiLine == null) |
808 |
1
1. go : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return NO_MORE_TEXT; |
809 | descender = 0; | |
810 | linesWritten = 0; | |
811 | boolean dirty = false; | |
812 | float ratio = spaceCharRatio; | |
813 | Object[] currentValues = new Object[2]; | |
814 | PdfFont currentFont = null; | |
815 | Float lastBaseFactor = (float) 0; | |
816 | currentValues[1] = lastBaseFactor; | |
817 | PdfDocument pdf = null; | |
818 | PdfContentByte graphics = null; | |
819 | PdfContentByte text = null; | |
820 | firstLineY = Float.NaN; | |
821 | int localRunDirection = PdfWriter.RUN_DIRECTION_NO_BIDI; | |
822 |
1
1. go : negated conditional → NO_COVERAGE |
if (runDirection != PdfWriter.RUN_DIRECTION_DEFAULT) |
823 | localRunDirection = runDirection; | |
824 |
1
1. go : negated conditional → NO_COVERAGE |
if (canvas != null) { |
825 | graphics = canvas; | |
826 | pdf = canvas.getPdfDocument(); | |
827 | text = canvas.getDuplicate(); | |
828 | } | |
829 |
1
1. go : negated conditional → NO_COVERAGE |
else if (!simulate) |
830 | throw new NullPointerException(MessageLocalization.getComposedMessage("columntext.go.with.simulate.eq.eq.false.and.text.eq.eq.null")); | |
831 |
1
1. go : negated conditional → NO_COVERAGE |
if (!simulate) { |
832 |
1
1. go : negated conditional → NO_COVERAGE |
if (ratio == GLOBAL_SPACE_CHAR_RATIO) |
833 | ratio = text.getPdfWriter().getSpaceCharRatio(); | |
834 |
2
1. go : changed conditional boundary → NO_COVERAGE 2. go : negated conditional → NO_COVERAGE |
else if (ratio < 0.001f) |
835 | ratio = 0.001f; | |
836 | } | |
837 | float firstIndent = 0; | |
838 | PdfLine line; | |
839 | float x1; | |
840 | int status = 0; | |
841 | while(true) { | |
842 |
1
1. go : negated conditional → NO_COVERAGE |
firstIndent = (lastWasNewline ? indent : followingIndent); // |
843 |
1
1. go : negated conditional → NO_COVERAGE |
if (rectangularMode) { |
844 |
3
1. go : changed conditional boundary → NO_COVERAGE 2. go : Replaced float addition with subtraction → NO_COVERAGE 3. go : negated conditional → NO_COVERAGE |
if (rectangularWidth <= firstIndent + rightIndent) { |
845 | status = NO_MORE_COLUMN; | |
846 |
1
1. go : negated conditional → NO_COVERAGE |
if (bidiLine.isEmpty()) |
847 |
1
1. go : Replaced bitwise OR with AND → NO_COVERAGE |
status |= NO_MORE_TEXT; |
848 | break; | |
849 | } | |
850 |
1
1. go : negated conditional → NO_COVERAGE |
if (bidiLine.isEmpty()) { |
851 | status = NO_MORE_TEXT; | |
852 | break; | |
853 | } | |
854 |
2
1. go : Replaced float subtraction with addition → NO_COVERAGE 2. go : Replaced float subtraction with addition → NO_COVERAGE |
line = bidiLine.processLine(leftX, rectangularWidth - firstIndent - rightIndent, alignment, localRunDirection, arabicOptions); |
855 |
1
1. go : negated conditional → NO_COVERAGE |
if (line == null) { |
856 | status = NO_MORE_TEXT; | |
857 | break; | |
858 | } | |
859 | float[] maxSize = line.getMaxSize(); | |
860 |
2
1. go : negated conditional → NO_COVERAGE 2. go : negated conditional → NO_COVERAGE |
if (isUseAscender() && Float.isNaN(firstLineY)) |
861 | currentLeading = line.getAscender(); | |
862 | else | |
863 |
2
1. go : Replaced float multiplication with division → NO_COVERAGE 2. go : Replaced float addition with subtraction → NO_COVERAGE |
currentLeading = Math.max(fixedLeading + maxSize[0] * multipliedLeading, maxSize[1]); |
864 |
5
1. go : changed conditional boundary → NO_COVERAGE 2. go : changed conditional boundary → NO_COVERAGE 3. go : Replaced float subtraction with addition → NO_COVERAGE 4. go : negated conditional → NO_COVERAGE 5. go : negated conditional → NO_COVERAGE |
if (yLine > maxY || yLine - currentLeading < minY ) { |
865 | status = NO_MORE_COLUMN; | |
866 |
1
1. go : removed call to com/lowagie/text/pdf/BidiLine::restore → NO_COVERAGE |
bidiLine.restore(); |
867 | break; | |
868 | } | |
869 |
1
1. go : Replaced float subtraction with addition → NO_COVERAGE |
yLine -= currentLeading; |
870 |
2
1. go : negated conditional → NO_COVERAGE 2. go : negated conditional → NO_COVERAGE |
if (!simulate && !dirty) { |
871 |
1
1. go : removed call to com/lowagie/text/pdf/PdfContentByte::beginText → NO_COVERAGE |
text.beginText(); |
872 | dirty = true; | |
873 | } | |
874 |
1
1. go : negated conditional → NO_COVERAGE |
if (Float.isNaN(firstLineY)) |
875 | firstLineY = yLine; | |
876 |
2
1. go : Replaced float subtraction with addition → NO_COVERAGE 2. go : removed call to com/lowagie/text/pdf/ColumnText::updateFilledWidth → NO_COVERAGE |
updateFilledWidth(rectangularWidth - line.widthLeft()); |
877 | x1 = leftX; | |
878 | } | |
879 | else { | |
880 | float yTemp = yLine; | |
881 | float[] xx = findLimitsTwoLines(); | |
882 |
1
1. go : negated conditional → NO_COVERAGE |
if (xx == null) { |
883 | status = NO_MORE_COLUMN; | |
884 |
1
1. go : negated conditional → NO_COVERAGE |
if (bidiLine.isEmpty()) |
885 |
1
1. go : Replaced bitwise OR with AND → NO_COVERAGE |
status |= NO_MORE_TEXT; |
886 | yLine = yTemp; | |
887 | break; | |
888 | } | |
889 |
1
1. go : negated conditional → NO_COVERAGE |
if (bidiLine.isEmpty()) { |
890 | status = NO_MORE_TEXT; | |
891 | yLine = yTemp; | |
892 | break; | |
893 | } | |
894 | x1 = Math.max(xx[0], xx[2]); | |
895 | float x2 = Math.min(xx[1], xx[3]); | |
896 |
4
1. go : changed conditional boundary → NO_COVERAGE 2. go : Replaced float subtraction with addition → NO_COVERAGE 3. go : Replaced float addition with subtraction → NO_COVERAGE 4. go : negated conditional → NO_COVERAGE |
if (x2 - x1 <= firstIndent + rightIndent) |
897 | continue; | |
898 |
2
1. go : negated conditional → NO_COVERAGE 2. go : negated conditional → NO_COVERAGE |
if (!simulate && !dirty) { |
899 |
1
1. go : removed call to com/lowagie/text/pdf/PdfContentByte::beginText → NO_COVERAGE |
text.beginText(); |
900 | dirty = true; | |
901 | } | |
902 |
3
1. go : Replaced float subtraction with addition → NO_COVERAGE 2. go : Replaced float subtraction with addition → NO_COVERAGE 3. go : Replaced float subtraction with addition → NO_COVERAGE |
line = bidiLine.processLine(x1, x2 - x1 - firstIndent - rightIndent, alignment, localRunDirection, arabicOptions); |
903 |
1
1. go : negated conditional → NO_COVERAGE |
if (line == null) { |
904 | status = NO_MORE_TEXT; | |
905 | yLine = yTemp; | |
906 | break; | |
907 | } | |
908 | } | |
909 |
1
1. go : negated conditional → NO_COVERAGE |
if (!simulate) { |
910 | currentValues[0] = currentFont; | |
911 |
4
1. go : Replaced float addition with subtraction → NO_COVERAGE 2. go : Replaced float addition with subtraction → NO_COVERAGE 3. go : negated conditional → NO_COVERAGE 4. go : removed call to com/lowagie/text/pdf/PdfContentByte::setTextMatrix → NO_COVERAGE |
text.setTextMatrix(x1 + (line.isRTL() ? rightIndent : firstIndent) + line.indentLeft(), yLine); |
912 |
1
1. go : removed call to com/lowagie/text/pdf/PdfDocument::writeLineToContent → NO_COVERAGE |
pdf.writeLineToContent(line, text, graphics, currentValues, ratio); |
913 | currentFont = (PdfFont)currentValues[0]; | |
914 | } | |
915 | lastWasNewline = line.isNewlineSplit(); | |
916 |
2
1. go : Replaced float subtraction with addition → NO_COVERAGE 2. go : negated conditional → NO_COVERAGE |
yLine -= line.isNewlineSplit() ? extraParagraphSpace : 0; |
917 |
1
1. go : Replaced integer addition with subtraction → NO_COVERAGE |
++linesWritten; |
918 | descender = line.getDescender(); | |
919 | } | |
920 |
1
1. go : negated conditional → NO_COVERAGE |
if (dirty) { |
921 |
1
1. go : removed call to com/lowagie/text/pdf/PdfContentByte::endText → NO_COVERAGE |
text.endText(); |
922 |
1
1. go : removed call to com/lowagie/text/pdf/PdfContentByte::add → NO_COVERAGE |
canvas.add(text); |
923 | } | |
924 |
1
1. go : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return status; |
925 | } | |
926 | | |
927 | /** | |
928 | * Sets the extra space between paragraphs. | |
929 | * | |
930 | * @return the extra space between paragraphs | |
931 | */ | |
932 | public float getExtraParagraphSpace() { | |
933 | return extraParagraphSpace; | |
934 | } | |
935 | | |
936 | /** | |
937 | * Sets the extra space between paragraphs. | |
938 | * | |
939 | * @param extraParagraphSpace the extra space between paragraphs | |
940 | */ | |
941 | public void setExtraParagraphSpace(float extraParagraphSpace) { | |
942 | this.extraParagraphSpace = extraParagraphSpace; | |
943 | } | |
944 | | |
945 | /** | |
946 | * Clears the chunk array. | |
947 | * A call to <CODE>go()</CODE> will always return NO_MORE_TEXT. | |
948 | */ | |
949 | public void clearChunks() { | |
950 |
1
1. clearChunks : negated conditional → NO_COVERAGE |
if (bidiLine != null) |
951 |
1
1. clearChunks : removed call to com/lowagie/text/pdf/BidiLine::clearChunks → NO_COVERAGE |
bidiLine.clearChunks(); |
952 | } | |
953 | | |
954 | /** | |
955 | * Gets the space/character extra spacing ratio for fully justified text. | |
956 | * | |
957 | * @return the space/character extra spacing ratio | |
958 | */ | |
959 | public float getSpaceCharRatio() { | |
960 | return spaceCharRatio; | |
961 | } | |
962 | | |
963 | /** | |
964 | * Sets the ratio between the extra word spacing and the extra character | |
965 | * spacing when the text is fully justified. | |
966 | * Extra word spacing will grow <CODE>spaceCharRatio</CODE> times more | |
967 | * than extra character spacing. | |
968 | * If the ratio is <CODE>PdfWriter.NO_SPACE_CHAR_RATIO</CODE> then the | |
969 | * extra character spacing will be zero. | |
970 | * | |
971 | * @param spaceCharRatio the ratio between the extra word spacing and the extra character spacing | |
972 | */ | |
973 | public void setSpaceCharRatio(float spaceCharRatio) { | |
974 | this.spaceCharRatio = spaceCharRatio; | |
975 | } | |
976 | ||
977 | /** | |
978 | * Sets the run direction. | |
979 | * | |
980 | * @param runDirection the run direction | |
981 | */ | |
982 | public void setRunDirection(int runDirection) { | |
983 |
4
1. setRunDirection : changed conditional boundary → NO_COVERAGE 2. setRunDirection : changed conditional boundary → NO_COVERAGE 3. setRunDirection : negated conditional → NO_COVERAGE 4. setRunDirection : negated conditional → NO_COVERAGE |
if (runDirection < PdfWriter.RUN_DIRECTION_DEFAULT || runDirection > PdfWriter.RUN_DIRECTION_RTL) |
984 | throw new RuntimeException(MessageLocalization.getComposedMessage("invalid.run.direction.1", runDirection)); | |
985 | this.runDirection = runDirection; | |
986 | } | |
987 | | |
988 | /** | |
989 | * Gets the run direction. | |
990 | * | |
991 | * @return the run direction | |
992 | */ | |
993 | public int getRunDirection() { | |
994 | return runDirection; | |
995 | } | |
996 | | |
997 | /** | |
998 | * Gets the number of lines written. | |
999 | * | |
1000 | * @return the number of lines written | |
1001 | */ | |
1002 | public int getLinesWritten() { | |
1003 | return this.linesWritten; | |
1004 | } | |
1005 | | |
1006 | /** | |
1007 | * Gets the arabic shaping options. | |
1008 | * | |
1009 | * @return the arabic shaping options | |
1010 | */ | |
1011 | public int getArabicOptions() { | |
1012 | return this.arabicOptions; | |
1013 | } | |
1014 | | |
1015 | /** | |
1016 | * Sets the arabic shaping options. The option can be AR_NOVOWEL, | |
1017 | * AR_COMPOSEDTASHKEEL and AR_LIG. | |
1018 | * | |
1019 | * @param arabicOptions the arabic shaping options | |
1020 | */ | |
1021 | public void setArabicOptions(int arabicOptions) { | |
1022 | this.arabicOptions = arabicOptions; | |
1023 | } | |
1024 | | |
1025 | /** | |
1026 | * Gets the biggest descender value of the last line written. | |
1027 | * | |
1028 | * @return the biggest descender value of the last line written | |
1029 | */ | |
1030 | public float getDescender() { | |
1031 | return descender; | |
1032 | } | |
1033 | | |
1034 | /** | |
1035 | * Gets the width that the line will occupy after writing. | |
1036 | * Only the width of the first line is returned. | |
1037 | * | |
1038 | * @param phrase the <CODE>Phrase</CODE> containing the line | |
1039 | * @param runDirection the run direction | |
1040 | * @param arabicOptions the options for the arabic shaping | |
1041 | * @return the width of the line | |
1042 | */ | |
1043 | public static float getWidth(Phrase phrase, int runDirection, int arabicOptions) { | |
1044 | ColumnText ct = new ColumnText(null); | |
1045 |
1
1. getWidth : removed call to com/lowagie/text/pdf/ColumnText::addText → NO_COVERAGE |
ct.addText(phrase); |
1046 |
1
1. getWidth : removed call to com/lowagie/text/pdf/ColumnText::addWaitingPhrase → NO_COVERAGE |
ct.addWaitingPhrase(); |
1047 | PdfLine line = ct.bidiLine.processLine(0, 20000, Element.ALIGN_LEFT, runDirection, arabicOptions); | |
1048 |
1
1. getWidth : negated conditional → NO_COVERAGE |
if (line == null) |
1049 |
1
1. getWidth : replaced return of float value with -(x + 1) for com/lowagie/text/pdf/ColumnText::getWidth → NO_COVERAGE |
return 0; |
1050 | else | |
1051 |
2
1. getWidth : Replaced float subtraction with addition → NO_COVERAGE 2. getWidth : replaced return of float value with -(x + 1) for com/lowagie/text/pdf/ColumnText::getWidth → NO_COVERAGE |
return 20000 - line.widthLeft(); |
1052 | } | |
1053 | | |
1054 | /** | |
1055 | * Gets the width that the line will occupy after writing. | |
1056 | * Only the width of the first line is returned. | |
1057 | * | |
1058 | * @param phrase the <CODE>Phrase</CODE> containing the line | |
1059 | * @return the width of the line | |
1060 | */ | |
1061 | public static float getWidth(Phrase phrase) { | |
1062 |
1
1. getWidth : replaced return of float value with -(x + 1) for com/lowagie/text/pdf/ColumnText::getWidth → NO_COVERAGE |
return getWidth(phrase, PdfWriter.RUN_DIRECTION_NO_BIDI, 0); |
1063 | } | |
1064 | | |
1065 | /** | |
1066 | * Shows a line of text. Only the first line is written. | |
1067 | * | |
1068 | * @param canvas where the text is to be written to | |
1069 | * @param alignment the alignment. It is not influenced by the run direction | |
1070 | * @param phrase the <CODE>Phrase</CODE> with the text | |
1071 | * @param x the x reference position | |
1072 | * @param y the y reference position | |
1073 | * @param rotation the rotation to be applied in degrees counterclockwise | |
1074 | * @param runDirection the run direction | |
1075 | * @param arabicOptions the options for the arabic shaping | |
1076 | */ | |
1077 | public static void showTextAligned(PdfContentByte canvas, int alignment, Phrase phrase, float x, float y, float rotation, int runDirection, int arabicOptions) { | |
1078 |
3
1. showTextAligned : negated conditional → NO_COVERAGE 2. showTextAligned : negated conditional → NO_COVERAGE 3. showTextAligned : negated conditional → NO_COVERAGE |
if (alignment != Element.ALIGN_LEFT && alignment != Element.ALIGN_CENTER |
1079 | && alignment != Element.ALIGN_RIGHT) | |
1080 | alignment = Element.ALIGN_LEFT; | |
1081 |
1
1. showTextAligned : removed call to com/lowagie/text/pdf/PdfContentByte::saveState → NO_COVERAGE |
canvas.saveState(); |
1082 | ColumnText ct = new ColumnText(canvas); | |
1083 | float lly = -1; | |
1084 | float ury = 2; | |
1085 | float llx; | |
1086 | float urx; | |
1087 | switch (alignment) { | |
1088 | case Element.ALIGN_LEFT: | |
1089 | llx = 0; | |
1090 | urx = 20000; | |
1091 | break; | |
1092 | case Element.ALIGN_RIGHT: | |
1093 | llx = -20000; | |
1094 | urx = 0; | |
1095 | break; | |
1096 | default: | |
1097 | llx = -20000; | |
1098 | urx = 20000; | |
1099 | break; | |
1100 | } | |
1101 |
1
1. showTextAligned : negated conditional → NO_COVERAGE |
if (rotation == 0) { |
1102 |
1
1. showTextAligned : Replaced float addition with subtraction → NO_COVERAGE |
llx += x; |
1103 |
1
1. showTextAligned : Replaced float addition with subtraction → NO_COVERAGE |
lly += y; |
1104 |
1
1. showTextAligned : Replaced float addition with subtraction → NO_COVERAGE |
urx += x; |
1105 |
1
1. showTextAligned : Replaced float addition with subtraction → NO_COVERAGE |
ury += y; |
1106 | } | |
1107 | else { | |
1108 |
2
1. showTextAligned : Replaced double multiplication with division → NO_COVERAGE 2. showTextAligned : Replaced double division with multiplication → NO_COVERAGE |
double alpha = rotation * Math.PI / 180.0; |
1109 | float cos = (float)Math.cos(alpha); | |
1110 | float sin = (float)Math.sin(alpha); | |
1111 |
2
1. showTextAligned : removed negation → NO_COVERAGE 2. showTextAligned : removed call to com/lowagie/text/pdf/PdfContentByte::concatCTM → NO_COVERAGE |
canvas.concatCTM(cos, sin, -sin, cos, x, y); |
1112 | } | |
1113 |
1
1. showTextAligned : removed call to com/lowagie/text/pdf/ColumnText::setSimpleColumn → NO_COVERAGE |
ct.setSimpleColumn(phrase, llx, lly, urx, ury, 2, alignment); |
1114 |
1
1. showTextAligned : negated conditional → NO_COVERAGE |
if (runDirection == PdfWriter.RUN_DIRECTION_RTL) { |
1115 |
1
1. showTextAligned : negated conditional → NO_COVERAGE |
if (alignment == Element.ALIGN_LEFT) |
1116 | alignment = Element.ALIGN_RIGHT; | |
1117 |
1
1. showTextAligned : negated conditional → NO_COVERAGE |
else if (alignment == Element.ALIGN_RIGHT) |
1118 | alignment = Element.ALIGN_LEFT; | |
1119 | } | |
1120 |
1
1. showTextAligned : removed call to com/lowagie/text/pdf/ColumnText::setAlignment → NO_COVERAGE |
ct.setAlignment(alignment); |
1121 |
1
1. showTextAligned : removed call to com/lowagie/text/pdf/ColumnText::setArabicOptions → NO_COVERAGE |
ct.setArabicOptions(arabicOptions); |
1122 |
1
1. showTextAligned : removed call to com/lowagie/text/pdf/ColumnText::setRunDirection → NO_COVERAGE |
ct.setRunDirection(runDirection); |
1123 | try { | |
1124 | ct.go(); | |
1125 | } | |
1126 | catch (DocumentException e) { | |
1127 | throw new ExceptionConverter(e); | |
1128 | } | |
1129 |
1
1. showTextAligned : removed call to com/lowagie/text/pdf/PdfContentByte::restoreState → NO_COVERAGE |
canvas.restoreState(); |
1130 | } | |
1131 | ||
1132 | /** | |
1133 | * Shows a line of text. Only the first line is written. | |
1134 | * | |
1135 | * @param canvas where the text is to be written to | |
1136 | * @param alignment the alignment | |
1137 | * @param phrase the <CODE>Phrase</CODE> with the text | |
1138 | * @param x the x reference position | |
1139 | * @param y the y reference position | |
1140 | * @param rotation the rotation to be applied in degrees counterclockwise | |
1141 | */ | |
1142 | public static void showTextAligned(PdfContentByte canvas, int alignment, Phrase phrase, float x, float y, float rotation) { | |
1143 |
1
1. showTextAligned : removed call to com/lowagie/text/pdf/ColumnText::showTextAligned → NO_COVERAGE |
showTextAligned(canvas, alignment, phrase, x, y, rotation, PdfWriter.RUN_DIRECTION_NO_BIDI, 0); |
1144 | } | |
1145 | ||
1146 | protected int goComposite(boolean simulate) throws DocumentException { | |
1147 |
1
1. goComposite : negated conditional → NO_COVERAGE |
if (!rectangularMode) |
1148 | throw new DocumentException(MessageLocalization.getComposedMessage("irregular.columns.are.not.supported.in.composite.mode")); | |
1149 | linesWritten = 0; | |
1150 | descender = 0; | |
1151 | boolean firstPass = adjustFirstLine; | |
1152 | | |
1153 | main_loop: | |
1154 | while (true) { | |
1155 |
1
1. goComposite : negated conditional → NO_COVERAGE |
if (compositeElements.isEmpty()) |
1156 |
1
1. goComposite : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return NO_MORE_TEXT; |
1157 | Element element = (Element)compositeElements.getFirst(); | |
1158 |
1
1. goComposite : negated conditional → NO_COVERAGE |
if (element.type() == Element.PARAGRAPH) { |
1159 | Paragraph para = (Paragraph)element; | |
1160 | int status = 0; | |
1161 |
3
1. goComposite : changed conditional boundary → NO_COVERAGE 2. goComposite : Changed increment from 1 to -1 → NO_COVERAGE 3. goComposite : negated conditional → NO_COVERAGE |
for (int keep = 0; keep < 2; ++keep) { |
1162 | float lastY = yLine; | |
1163 | boolean createHere = false; | |
1164 |
1
1. goComposite : negated conditional → NO_COVERAGE |
if (compositeColumn == null) { |
1165 | compositeColumn = new ColumnText(canvas); | |
1166 |
3
1. goComposite : negated conditional → NO_COVERAGE 2. goComposite : negated conditional → NO_COVERAGE 3. goComposite : removed call to com/lowagie/text/pdf/ColumnText::setUseAscender → NO_COVERAGE |
compositeColumn.setUseAscender(firstPass && useAscender); |
1167 |
1
1. goComposite : removed call to com/lowagie/text/pdf/ColumnText::setAlignment → NO_COVERAGE |
compositeColumn.setAlignment(para.getAlignment()); |
1168 |
2
1. goComposite : Replaced float addition with subtraction → NO_COVERAGE 2. goComposite : removed call to com/lowagie/text/pdf/ColumnText::setIndent → NO_COVERAGE |
compositeColumn.setIndent(para.getIndentationLeft() + para.getFirstLineIndent()); |
1169 |
1
1. goComposite : removed call to com/lowagie/text/pdf/ColumnText::setExtraParagraphSpace → NO_COVERAGE |
compositeColumn.setExtraParagraphSpace(para.getExtraParagraphSpace()); |
1170 |
1
1. goComposite : removed call to com/lowagie/text/pdf/ColumnText::setFollowingIndent → NO_COVERAGE |
compositeColumn.setFollowingIndent(para.getIndentationLeft()); |
1171 |
1
1. goComposite : removed call to com/lowagie/text/pdf/ColumnText::setRightIndent → NO_COVERAGE |
compositeColumn.setRightIndent(para.getIndentationRight()); |
1172 |
1
1. goComposite : removed call to com/lowagie/text/pdf/ColumnText::setLeading → NO_COVERAGE |
compositeColumn.setLeading(para.getLeading(), para.getMultipliedLeading()); |
1173 |
1
1. goComposite : removed call to com/lowagie/text/pdf/ColumnText::setRunDirection → NO_COVERAGE |
compositeColumn.setRunDirection(runDirection); |
1174 |
1
1. goComposite : removed call to com/lowagie/text/pdf/ColumnText::setArabicOptions → NO_COVERAGE |
compositeColumn.setArabicOptions(arabicOptions); |
1175 |
1
1. goComposite : removed call to com/lowagie/text/pdf/ColumnText::setSpaceCharRatio → NO_COVERAGE |
compositeColumn.setSpaceCharRatio(spaceCharRatio); |
1176 |
1
1. goComposite : removed call to com/lowagie/text/pdf/ColumnText::addText → NO_COVERAGE |
compositeColumn.addText(para); |
1177 |
1
1. goComposite : negated conditional → NO_COVERAGE |
if (!firstPass) { |
1178 |
1
1. goComposite : Replaced float subtraction with addition → NO_COVERAGE |
yLine -= para.getSpacingBefore(); |
1179 | } | |
1180 | createHere = true; | |
1181 | } | |
1182 | compositeColumn.leftX = leftX; | |
1183 | compositeColumn.rightX = rightX; | |
1184 | compositeColumn.yLine = yLine; | |
1185 | compositeColumn.rectangularWidth = rectangularWidth; | |
1186 | compositeColumn.rectangularMode = rectangularMode; | |
1187 | compositeColumn.minY = minY; | |
1188 | compositeColumn.maxY = maxY; | |
1189 |
3
1. goComposite : negated conditional → NO_COVERAGE 2. goComposite : negated conditional → NO_COVERAGE 3. goComposite : negated conditional → NO_COVERAGE |
boolean keepCandidate = (para.getKeepTogether() && createHere && !firstPass); |
1190 |
3
1. goComposite : negated conditional → NO_COVERAGE 2. goComposite : negated conditional → NO_COVERAGE 3. goComposite : negated conditional → NO_COVERAGE |
status = compositeColumn.go(simulate || (keepCandidate && keep == 0)); |
1191 |
1
1. goComposite : removed call to com/lowagie/text/pdf/ColumnText::updateFilledWidth → NO_COVERAGE |
updateFilledWidth(compositeColumn.filledWidth); |
1192 |
3
1. goComposite : Replaced bitwise AND with OR → NO_COVERAGE 2. goComposite : negated conditional → NO_COVERAGE 3. goComposite : negated conditional → NO_COVERAGE |
if ((status & NO_MORE_TEXT) == 0 && keepCandidate) { |
1193 | compositeColumn = null; | |
1194 | yLine = lastY; | |
1195 |
1
1. goComposite : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return NO_MORE_COLUMN; |
1196 | } | |
1197 |
2
1. goComposite : negated conditional → NO_COVERAGE 2. goComposite : negated conditional → NO_COVERAGE |
if (simulate || !keepCandidate) |
1198 | break; | |
1199 |
1
1. goComposite : negated conditional → NO_COVERAGE |
if (keep == 0) { |
1200 | compositeColumn = null; | |
1201 | yLine = lastY; | |
1202 | } | |
1203 | } | |
1204 | firstPass = false; | |
1205 | yLine = compositeColumn.yLine; | |
1206 |
1
1. goComposite : Replaced integer addition with subtraction → NO_COVERAGE |
linesWritten += compositeColumn.linesWritten; |
1207 | descender = compositeColumn.descender; | |
1208 |
2
1. goComposite : Replaced bitwise AND with OR → NO_COVERAGE 2. goComposite : negated conditional → NO_COVERAGE |
if ((status & NO_MORE_TEXT) != 0) { |
1209 | compositeColumn = null; | |
1210 | compositeElements.removeFirst(); | |
1211 |
1
1. goComposite : Replaced float subtraction with addition → NO_COVERAGE |
yLine -= para.getSpacingAfter(); |
1212 | } | |
1213 |
2
1. goComposite : Replaced bitwise AND with OR → NO_COVERAGE 2. goComposite : negated conditional → NO_COVERAGE |
if ((status & NO_MORE_COLUMN) != 0) { |
1214 |
1
1. goComposite : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return NO_MORE_COLUMN; |
1215 | } | |
1216 | } | |
1217 |
1
1. goComposite : negated conditional → NO_COVERAGE |
else if (element.type() == Element.LIST) { |
1218 | com.lowagie.text.List list = (com.lowagie.text.List)element; | |
1219 | ArrayList items = list.getItems(); | |
1220 | ListItem item = null; | |
1221 | float listIndentation = list.getIndentationLeft(); | |
1222 | int count = 0; | |
1223 | Stack stack = new Stack(); | |
1224 |
3
1. goComposite : changed conditional boundary → NO_COVERAGE 2. goComposite : Changed increment from 1 to -1 → NO_COVERAGE 3. goComposite : negated conditional → NO_COVERAGE |
for (int k = 0; k < items.size(); ++k) { |
1225 | Object obj = items.get(k); | |
1226 |
1
1. goComposite : negated conditional → NO_COVERAGE |
if (obj instanceof ListItem) { |
1227 |
1
1. goComposite : negated conditional → NO_COVERAGE |
if (count == listIdx) { |
1228 | item = (ListItem)obj; | |
1229 | break; | |
1230 | } | |
1231 |
1
1. goComposite : Changed increment from 1 to -1 → NO_COVERAGE |
else ++count; |
1232 | } | |
1233 |
1
1. goComposite : negated conditional → NO_COVERAGE |
else if (obj instanceof com.lowagie.text.List) { |
1234 | stack.push(new Object[]{list, k, listIndentation}); | |
1235 | list = (com.lowagie.text.List)obj; | |
1236 | items = list.getItems(); | |
1237 |
1
1. goComposite : Replaced float addition with subtraction → NO_COVERAGE |
listIndentation += list.getIndentationLeft(); |
1238 | k = -1; | |
1239 | continue; | |
1240 | } | |
1241 |
2
1. goComposite : Replaced integer subtraction with addition → NO_COVERAGE 2. goComposite : negated conditional → NO_COVERAGE |
if (k == items.size() - 1) { |
1242 |
1
1. goComposite : negated conditional → NO_COVERAGE |
if (!stack.isEmpty()) { |
1243 | Object[] objs = (Object[]) stack.pop(); | |
1244 | list = (com.lowagie.text.List)objs[0]; | |
1245 | items = list.getItems(); | |
1246 | k = (Integer) objs[1]; | |
1247 | listIndentation = (Float) objs[2]; | |
1248 | } | |
1249 | } | |
1250 | } | |
1251 | int status = 0; | |
1252 |
3
1. goComposite : changed conditional boundary → NO_COVERAGE 2. goComposite : Changed increment from 1 to -1 → NO_COVERAGE 3. goComposite : negated conditional → NO_COVERAGE |
for (int keep = 0; keep < 2; ++keep) { |
1253 | float lastY = yLine; | |
1254 | boolean createHere = false; | |
1255 |
1
1. goComposite : negated conditional → NO_COVERAGE |
if (compositeColumn == null) { |
1256 |
1
1. goComposite : negated conditional → NO_COVERAGE |
if (item == null) { |
1257 | listIdx = 0; | |
1258 | compositeElements.removeFirst(); | |
1259 | continue main_loop; | |
1260 | } | |
1261 | compositeColumn = new ColumnText(canvas); | |
1262 |
3
1. goComposite : negated conditional → NO_COVERAGE 2. goComposite : negated conditional → NO_COVERAGE 3. goComposite : removed call to com/lowagie/text/pdf/ColumnText::setUseAscender → NO_COVERAGE |
compositeColumn.setUseAscender(firstPass && useAscender); |
1263 |
1
1. goComposite : removed call to com/lowagie/text/pdf/ColumnText::setAlignment → NO_COVERAGE |
compositeColumn.setAlignment(item.getAlignment()); |
1264 |
3
1. goComposite : Replaced float addition with subtraction → NO_COVERAGE 2. goComposite : Replaced float addition with subtraction → NO_COVERAGE 3. goComposite : removed call to com/lowagie/text/pdf/ColumnText::setIndent → NO_COVERAGE |
compositeColumn.setIndent(item.getIndentationLeft() + listIndentation + item.getFirstLineIndent()); |
1265 |
1
1. goComposite : removed call to com/lowagie/text/pdf/ColumnText::setExtraParagraphSpace → NO_COVERAGE |
compositeColumn.setExtraParagraphSpace(item.getExtraParagraphSpace()); |
1266 |
1
1. goComposite : removed call to com/lowagie/text/pdf/ColumnText::setFollowingIndent → NO_COVERAGE |
compositeColumn.setFollowingIndent(compositeColumn.getIndent()); |
1267 |
2
1. goComposite : Replaced float addition with subtraction → NO_COVERAGE 2. goComposite : removed call to com/lowagie/text/pdf/ColumnText::setRightIndent → NO_COVERAGE |
compositeColumn.setRightIndent(item.getIndentationRight() + list.getIndentationRight()); |
1268 |
1
1. goComposite : removed call to com/lowagie/text/pdf/ColumnText::setLeading → NO_COVERAGE |
compositeColumn.setLeading(item.getLeading(), item.getMultipliedLeading()); |
1269 |
1
1. goComposite : removed call to com/lowagie/text/pdf/ColumnText::setRunDirection → NO_COVERAGE |
compositeColumn.setRunDirection(runDirection); |
1270 |
1
1. goComposite : removed call to com/lowagie/text/pdf/ColumnText::setArabicOptions → NO_COVERAGE |
compositeColumn.setArabicOptions(arabicOptions); |
1271 |
1
1. goComposite : removed call to com/lowagie/text/pdf/ColumnText::setSpaceCharRatio → NO_COVERAGE |
compositeColumn.setSpaceCharRatio(spaceCharRatio); |
1272 |
1
1. goComposite : removed call to com/lowagie/text/pdf/ColumnText::addText → NO_COVERAGE |
compositeColumn.addText(item); |
1273 |
1
1. goComposite : negated conditional → NO_COVERAGE |
if (!firstPass) { |
1274 |
1
1. goComposite : Replaced float subtraction with addition → NO_COVERAGE |
yLine -= item.getSpacingBefore(); |
1275 | } | |
1276 | createHere = true; | |
1277 | } | |
1278 | compositeColumn.leftX = leftX; | |
1279 | compositeColumn.rightX = rightX; | |
1280 | compositeColumn.yLine = yLine; | |
1281 | compositeColumn.rectangularWidth = rectangularWidth; | |
1282 | compositeColumn.rectangularMode = rectangularMode; | |
1283 | compositeColumn.minY = minY; | |
1284 | compositeColumn.maxY = maxY; | |
1285 |
3
1. goComposite : negated conditional → NO_COVERAGE 2. goComposite : negated conditional → NO_COVERAGE 3. goComposite : negated conditional → NO_COVERAGE |
boolean keepCandidate = (item.getKeepTogether() && createHere && !firstPass); |
1286 |
3
1. goComposite : negated conditional → NO_COVERAGE 2. goComposite : negated conditional → NO_COVERAGE 3. goComposite : negated conditional → NO_COVERAGE |
status = compositeColumn.go(simulate || (keepCandidate && keep == 0)); |
1287 |
1
1. goComposite : removed call to com/lowagie/text/pdf/ColumnText::updateFilledWidth → NO_COVERAGE |
updateFilledWidth(compositeColumn.filledWidth); |
1288 |
3
1. goComposite : Replaced bitwise AND with OR → NO_COVERAGE 2. goComposite : negated conditional → NO_COVERAGE 3. goComposite : negated conditional → NO_COVERAGE |
if ((status & NO_MORE_TEXT) == 0 && keepCandidate) { |
1289 | compositeColumn = null; | |
1290 | yLine = lastY; | |
1291 |
1
1. goComposite : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return NO_MORE_COLUMN; |
1292 | } | |
1293 |
2
1. goComposite : negated conditional → NO_COVERAGE 2. goComposite : negated conditional → NO_COVERAGE |
if (simulate || !keepCandidate) |
1294 | break; | |
1295 |
1
1. goComposite : negated conditional → NO_COVERAGE |
if (keep == 0) { |
1296 | compositeColumn = null; | |
1297 | yLine = lastY; | |
1298 | } | |
1299 | } | |
1300 | firstPass = false; | |
1301 | yLine = compositeColumn.yLine; | |
1302 |
1
1. goComposite : Replaced integer addition with subtraction → NO_COVERAGE |
linesWritten += compositeColumn.linesWritten; |
1303 | descender = compositeColumn.descender; | |
1304 |
2
1. goComposite : negated conditional → NO_COVERAGE 2. goComposite : negated conditional → NO_COVERAGE |
if (!Float.isNaN(compositeColumn.firstLineY) && !compositeColumn.firstLineYDone) { |
1305 |
1
1. goComposite : negated conditional → NO_COVERAGE |
if (!simulate) |
1306 |
2
1. goComposite : Replaced float addition with subtraction → NO_COVERAGE 2. goComposite : removed call to com/lowagie/text/pdf/ColumnText::showTextAligned → NO_COVERAGE |
showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(item.getListSymbol()), compositeColumn.leftX + listIndentation, compositeColumn.firstLineY, 0); |
1307 | compositeColumn.firstLineYDone = true; | |
1308 | } | |
1309 |
2
1. goComposite : Replaced bitwise AND with OR → NO_COVERAGE 2. goComposite : negated conditional → NO_COVERAGE |
if ((status & NO_MORE_TEXT) != 0) { |
1310 | compositeColumn = null; | |
1311 |
1
1. goComposite : Replaced integer addition with subtraction → NO_COVERAGE |
++listIdx; |
1312 |
1
1. goComposite : Replaced float subtraction with addition → NO_COVERAGE |
yLine -= item.getSpacingAfter(); |
1313 | } | |
1314 |
2
1. goComposite : Replaced bitwise AND with OR → NO_COVERAGE 2. goComposite : negated conditional → NO_COVERAGE |
if ((status & NO_MORE_COLUMN) != 0) |
1315 |
1
1. goComposite : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return NO_MORE_COLUMN; |
1316 | } | |
1317 |
1
1. goComposite : negated conditional → NO_COVERAGE |
else if (element.type() == Element.PTABLE) { |
1318 | // don't write anything in the current column if there's no more space available | |
1319 |
4
1. goComposite : changed conditional boundary → NO_COVERAGE 2. goComposite : changed conditional boundary → NO_COVERAGE 3. goComposite : negated conditional → NO_COVERAGE 4. goComposite : negated conditional → NO_COVERAGE |
if (yLine < minY || yLine > maxY) |
1320 |
1
1. goComposite : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return NO_MORE_COLUMN; |
1321 | | |
1322 | // get the PdfPTable element | |
1323 | PdfPTable table = (PdfPTable)element; | |
1324 | // we ignore tables without a body | |
1325 |
2
1. goComposite : changed conditional boundary → NO_COVERAGE 2. goComposite : negated conditional → NO_COVERAGE |
if (table.size() <= table.getHeaderRows()) { |
1326 | compositeElements.removeFirst(); | |
1327 | continue; | |
1328 | } | |
1329 | | |
1330 | // offsets | |
1331 | float yTemp = yLine; | |
1332 |
2
1. goComposite : negated conditional → NO_COVERAGE 2. goComposite : negated conditional → NO_COVERAGE |
if (!firstPass && listIdx == 0) |
1333 |
1
1. goComposite : Replaced float subtraction with addition → NO_COVERAGE |
yTemp -= table.spacingBefore(); |
1334 | float yLineWrite = yTemp; | |
1335 | | |
1336 | // don't write anything in the current column if there's no more space available | |
1337 |
4
1. goComposite : changed conditional boundary → NO_COVERAGE 2. goComposite : changed conditional boundary → NO_COVERAGE 3. goComposite : negated conditional → NO_COVERAGE 4. goComposite : negated conditional → NO_COVERAGE |
if (yTemp < minY || yTemp > maxY) |
1338 |
1
1. goComposite : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return NO_MORE_COLUMN; |
1339 | | |
1340 | // coordinates | |
1341 | currentLeading = 0; | |
1342 | float x1 = leftX; | |
1343 | float tableWidth; | |
1344 |
1
1. goComposite : negated conditional → NO_COVERAGE |
if (table.isLockedWidth()) { |
1345 | tableWidth = table.getTotalWidth(); | |
1346 |
1
1. goComposite : removed call to com/lowagie/text/pdf/ColumnText::updateFilledWidth → NO_COVERAGE |
updateFilledWidth(tableWidth); |
1347 | } | |
1348 | else { | |
1349 |
2
1. goComposite : Replaced float multiplication with division → NO_COVERAGE 2. goComposite : Replaced float division with multiplication → NO_COVERAGE |
tableWidth = rectangularWidth * table.getWidthPercentage() / 100f; |
1350 |
1
1. goComposite : removed call to com/lowagie/text/pdf/PdfPTable::setTotalWidth → NO_COVERAGE |
table.setTotalWidth(tableWidth); |
1351 | } | |
1352 | | |
1353 | // how many header rows are real header rows; how many are footer rows? | |
1354 | int headerRows = table.getHeaderRows(); | |
1355 | int footerRows = table.getFooterRows(); | |
1356 |
2
1. goComposite : changed conditional boundary → NO_COVERAGE 2. goComposite : negated conditional → NO_COVERAGE |
if (footerRows > headerRows) |
1357 | footerRows = headerRows; | |
1358 |
1
1. goComposite : Replaced integer subtraction with addition → NO_COVERAGE |
int realHeaderRows = headerRows - footerRows; |
1359 | float headerHeight = table.getHeaderHeight(); | |
1360 | float footerHeight = table.getFooterHeight(); | |
1361 | ||
1362 | // make sure the header and footer fit on the page | |
1363 |
4
1. goComposite : changed conditional boundary → NO_COVERAGE 2. goComposite : negated conditional → NO_COVERAGE 3. goComposite : negated conditional → NO_COVERAGE 4. goComposite : negated conditional → NO_COVERAGE |
boolean skipHeader = (!firstPass && table.isSkipFirstHeader() && listIdx <= headerRows); |
1364 |
1
1. goComposite : negated conditional → NO_COVERAGE |
if (!skipHeader) { |
1365 |
1
1. goComposite : Replaced float subtraction with addition → NO_COVERAGE |
yTemp -= headerHeight; |
1366 |
4
1. goComposite : changed conditional boundary → NO_COVERAGE 2. goComposite : changed conditional boundary → NO_COVERAGE 3. goComposite : negated conditional → NO_COVERAGE 4. goComposite : negated conditional → NO_COVERAGE |
if (yTemp < minY || yTemp > maxY) { |
1367 |
1
1. goComposite : negated conditional → NO_COVERAGE |
if (firstPass) { |
1368 | compositeElements.removeFirst(); | |
1369 | continue; | |
1370 | } | |
1371 |
1
1. goComposite : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return NO_MORE_COLUMN; |
1372 | } | |
1373 | } | |
1374 | | |
1375 | // how many real rows (not header or footer rows) fit on a page? | |
1376 | int k; | |
1377 |
2
1. goComposite : changed conditional boundary → NO_COVERAGE 2. goComposite : negated conditional → NO_COVERAGE |
if (listIdx < headerRows) |
1378 | listIdx = headerRows; | |
1379 |
1
1. goComposite : negated conditional → NO_COVERAGE |
if (!table.isComplete()) |
1380 |
1
1. goComposite : Replaced float subtraction with addition → NO_COVERAGE |
yTemp -= footerHeight; |
1381 |
2
1. goComposite : changed conditional boundary → NO_COVERAGE 2. goComposite : negated conditional → NO_COVERAGE |
for (k = listIdx; k < table.size(); ++k) { |
1382 | float rowHeight = table.getRowHeight(k); | |
1383 |
3
1. goComposite : changed conditional boundary → NO_COVERAGE 2. goComposite : Replaced float subtraction with addition → NO_COVERAGE 3. goComposite : negated conditional → NO_COVERAGE |
if (yTemp - rowHeight < minY) |
1384 | break; | |
1385 |
1
1. goComposite : Replaced float subtraction with addition → NO_COVERAGE |
yTemp -= rowHeight; |
1386 | } | |
1387 |
1
1. goComposite : negated conditional → NO_COVERAGE |
if (!table.isComplete()) |
1388 |
1
1. goComposite : Replaced float addition with subtraction → NO_COVERAGE |
yTemp += footerHeight; |
1389 | // either k is the first row that doesn't fit on the page (break); | |
1390 |
2
1. goComposite : changed conditional boundary → NO_COVERAGE 2. goComposite : negated conditional → NO_COVERAGE |
if (k < table.size()) { |
1391 |
4
1. goComposite : negated conditional → NO_COVERAGE 2. goComposite : negated conditional → NO_COVERAGE 3. goComposite : negated conditional → NO_COVERAGE 4. goComposite : negated conditional → NO_COVERAGE |
if (table.isSplitRows() && (!table.isSplitLate() || (k == listIdx && firstPass))) { |
1392 |
1
1. goComposite : negated conditional → NO_COVERAGE |
if (!splittedRow) { |
1393 | splittedRow = true; | |
1394 | table = new PdfPTable(table); | |
1395 | compositeElements.set(0, table); | |
1396 | ArrayList rows = table.getRows(); | |
1397 |
3
1. goComposite : changed conditional boundary → NO_COVERAGE 2. goComposite : Changed increment from 1 to -1 → NO_COVERAGE 3. goComposite : negated conditional → NO_COVERAGE |
for (int i = headerRows; i < listIdx; ++i) |
1398 | rows.set(i, null); | |
1399 | } | |
1400 |
1
1. goComposite : Replaced float subtraction with addition → NO_COVERAGE |
float h = yTemp - minY; |
1401 | PdfPRow newRow = table.getRow(k).splitRow(table, k, h); | |
1402 |
1
1. goComposite : negated conditional → NO_COVERAGE |
if (newRow == null) { |
1403 |
1
1. goComposite : negated conditional → NO_COVERAGE |
if (k == listIdx) |
1404 |
1
1. goComposite : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return NO_MORE_COLUMN; |
1405 | } | |
1406 | else { | |
1407 | yTemp = minY; | |
1408 |
2
1. goComposite : Changed increment from 1 to -1 → NO_COVERAGE 2. goComposite : removed call to java/util/ArrayList::add → NO_COVERAGE |
table.getRows().add(++k, newRow); |
1409 | } | |
1410 | } | |
1411 |
3
1. goComposite : negated conditional → NO_COVERAGE 2. goComposite : negated conditional → NO_COVERAGE 3. goComposite : negated conditional → NO_COVERAGE |
else if (!table.isSplitRows() && k == listIdx && firstPass) { |
1412 | compositeElements.removeFirst(); | |
1413 | splittedRow = false; | |
1414 | continue; | |
1415 | } | |
1416 |
6
1. goComposite : negated conditional → NO_COVERAGE 2. goComposite : negated conditional → NO_COVERAGE 3. goComposite : negated conditional → NO_COVERAGE 4. goComposite : negated conditional → NO_COVERAGE 5. goComposite : negated conditional → NO_COVERAGE 6. goComposite : negated conditional → NO_COVERAGE |
else if (k == listIdx && !firstPass && (!table.isSplitRows() || table.isSplitLate()) && (table.getFooterRows() == 0 || table.isComplete())) |
1417 |
1
1. goComposite : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return NO_MORE_COLUMN; |
1418 | } | |
1419 | // or k is the number of rows in the table (for loop was done). | |
1420 | firstPass = false; | |
1421 | // we draw the table (for real now) | |
1422 |
1
1. goComposite : negated conditional → NO_COVERAGE |
if (!simulate) { |
1423 | // set the alignment | |
1424 | switch (table.getHorizontalAlignment()) { | |
1425 | case Element.ALIGN_LEFT: | |
1426 | break; | |
1427 | case Element.ALIGN_RIGHT: | |
1428 |
2
1. goComposite : Replaced float subtraction with addition → NO_COVERAGE 2. goComposite : Replaced float addition with subtraction → NO_COVERAGE |
x1 += rectangularWidth - tableWidth; |
1429 | break; | |
1430 | default: | |
1431 |
3
1. goComposite : Replaced float subtraction with addition → NO_COVERAGE 2. goComposite : Replaced float division with multiplication → NO_COVERAGE 3. goComposite : Replaced float addition with subtraction → NO_COVERAGE |
x1 += (rectangularWidth - tableWidth) / 2f; |
1432 | } | |
1433 | // copy the rows that fit on the page in a new table nt | |
1434 | PdfPTable nt = PdfPTable.shallowCopy(table); | |
1435 | ArrayList sub = nt.getRows(); | |
1436 | | |
1437 | // first we add the real header rows (if necessary) | |
1438 |
3
1. goComposite : changed conditional boundary → NO_COVERAGE 2. goComposite : negated conditional → NO_COVERAGE 3. goComposite : negated conditional → NO_COVERAGE |
if (!skipHeader && realHeaderRows > 0) { |
1439 | sub.addAll(table.getRows(0, realHeaderRows)); | |
1440 | } | |
1441 | else | |
1442 |
1
1. goComposite : removed call to com/lowagie/text/pdf/PdfPTable::setHeaderRows → NO_COVERAGE |
nt.setHeaderRows(footerRows); |
1443 | // then we add the real content | |
1444 | sub.addAll(table.getRows(listIdx, k)); | |
1445 | // if k < table.size(), we must indicate that the new table is complete; | |
1446 | // otherwise no footers will be added (because iText thinks the table continues on the same page) | |
1447 |
1
1. goComposite : negated conditional → NO_COVERAGE |
boolean showFooter = !table.isSkipLastFooter(); |
1448 | boolean newPageFollows = false; | |
1449 |
2
1. goComposite : changed conditional boundary → NO_COVERAGE 2. goComposite : negated conditional → NO_COVERAGE |
if (k < table.size()) { |
1450 |
1
1. goComposite : removed call to com/lowagie/text/pdf/PdfPTable::setComplete → NO_COVERAGE |
nt.setComplete(true); |
1451 | showFooter = true; | |
1452 | newPageFollows = true; | |
1453 | } | |
1454 | // we add the footer rows if necessary (not for incomplete tables) | |
1455 |
5
1. goComposite : changed conditional boundary → NO_COVERAGE 2. goComposite : Changed increment from 1 to -1 → NO_COVERAGE 3. goComposite : negated conditional → NO_COVERAGE 4. goComposite : negated conditional → NO_COVERAGE 5. goComposite : negated conditional → NO_COVERAGE |
for (int j = 0; j < footerRows && nt.isComplete() && showFooter; ++j) |
1456 |
1
1. goComposite : Replaced integer addition with subtraction → NO_COVERAGE |
sub.add(table.getRow(j + realHeaderRows)); |
1457 | ||
1458 | // we need a correction if the last row needs to be extended | |
1459 | float rowHeight = 0; | |
1460 |
1
1. goComposite : Replaced integer subtraction with addition → NO_COVERAGE |
int index = sub.size() - 1; |
1461 |
2
1. goComposite : Replaced integer subtraction with addition → NO_COVERAGE 2. goComposite : negated conditional → NO_COVERAGE |
if (showFooter) index -= footerRows; |
1462 | PdfPRow last = (PdfPRow)sub.get(index); | |
1463 |
1
1. goComposite : negated conditional → NO_COVERAGE |
if (table.isExtendLastRow(newPageFollows)) { |
1464 | rowHeight = last.getMaxHeights(); | |
1465 |
3
1. goComposite : Replaced float subtraction with addition → NO_COVERAGE 2. goComposite : Replaced float addition with subtraction → NO_COVERAGE 3. goComposite : removed call to com/lowagie/text/pdf/PdfPRow::setMaxHeights → NO_COVERAGE |
last.setMaxHeights(yTemp - minY + rowHeight); |
1466 | yTemp = minY; | |
1467 | } | |
1468 | | |
1469 | // now we render the rows of the new table | |
1470 |
1
1. goComposite : negated conditional → NO_COVERAGE |
if (canvases != null) |
1471 | nt.writeSelectedRows(0, -1, x1, yLineWrite, canvases); | |
1472 | else | |
1473 | nt.writeSelectedRows(0, -1, x1, yLineWrite, canvas); | |
1474 |
1
1. goComposite : negated conditional → NO_COVERAGE |
if (table.isExtendLastRow(newPageFollows)) { |
1475 |
1
1. goComposite : removed call to com/lowagie/text/pdf/PdfPRow::setMaxHeights → NO_COVERAGE |
last.setMaxHeights(rowHeight); |
1476 | } | |
1477 | } | |
1478 |
3
1. goComposite : changed conditional boundary → NO_COVERAGE 2. goComposite : negated conditional → NO_COVERAGE 3. goComposite : negated conditional → NO_COVERAGE |
else if (table.isExtendLastRow() && minY > PdfPRow.BOTTOM_LIMIT) |
1479 | yTemp = minY; | |
1480 | yLine = yTemp; | |
1481 |
2
1. goComposite : negated conditional → NO_COVERAGE 2. goComposite : negated conditional → NO_COVERAGE |
if (!(skipHeader || table.isComplete())) |
1482 |
1
1. goComposite : Replaced float addition with subtraction → NO_COVERAGE |
yLine += footerHeight; |
1483 |
2
1. goComposite : changed conditional boundary → NO_COVERAGE 2. goComposite : negated conditional → NO_COVERAGE |
if (k >= table.size()) { |
1484 |
1
1. goComposite : Replaced float subtraction with addition → NO_COVERAGE |
yLine -= table.spacingAfter(); |
1485 | compositeElements.removeFirst(); | |
1486 | splittedRow = false; | |
1487 | listIdx = 0; | |
1488 | } | |
1489 | else { | |
1490 |
1
1. goComposite : negated conditional → NO_COVERAGE |
if (splittedRow) { |
1491 | ArrayList rows = table.getRows(); | |
1492 |
3
1. goComposite : changed conditional boundary → NO_COVERAGE 2. goComposite : Changed increment from 1 to -1 → NO_COVERAGE 3. goComposite : negated conditional → NO_COVERAGE |
for (int i = listIdx; i < k; ++i) |
1493 | rows.set(i, null); | |
1494 | } | |
1495 | listIdx = k; | |
1496 |
1
1. goComposite : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return NO_MORE_COLUMN; |
1497 | } | |
1498 | } | |
1499 |
1
1. goComposite : negated conditional → NO_COVERAGE |
else if (element.type() == Element.YMARK) { |
1500 |
1
1. goComposite : negated conditional → NO_COVERAGE |
if (!simulate) { |
1501 | DrawInterface zh = (DrawInterface)element; | |
1502 |
1
1. goComposite : removed call to com/lowagie/text/pdf/draw/DrawInterface::draw → NO_COVERAGE |
zh.draw(canvas, leftX, minY, rightX, maxY, yLine); |
1503 | } | |
1504 | compositeElements.removeFirst(); | |
1505 | } | |
1506 | else | |
1507 | compositeElements.removeFirst(); | |
1508 | } | |
1509 | } | |
1510 | | |
1511 | /** | |
1512 | * Gets the canvas. | |
1513 | * If a set of four canvases exists, the TEXTCANVAS is returned. | |
1514 | * | |
1515 | * @return a PdfContentByte. | |
1516 | */ | |
1517 | public PdfContentByte getCanvas() { | |
1518 | return canvas; | |
1519 | } | |
1520 | | |
1521 | /** | |
1522 | * Sets the canvas. | |
1523 | * If before a set of four canvases was set, it is being unset. | |
1524 | * | |
1525 | * @param canvas | |
1526 | */ | |
1527 | public void setCanvas(PdfContentByte canvas) { | |
1528 | this.canvas = canvas; | |
1529 | this.canvases = null; | |
1530 |
1
1. setCanvas : negated conditional → NO_COVERAGE |
if (compositeColumn != null) |
1531 |
1
1. setCanvas : removed call to com/lowagie/text/pdf/ColumnText::setCanvas → NO_COVERAGE |
compositeColumn.setCanvas(canvas); |
1532 | } | |
1533 | | |
1534 | /** | |
1535 | * Sets the canvases. | |
1536 | * | |
1537 | * @param canvases | |
1538 | */ | |
1539 | public void setCanvases(PdfContentByte[] canvases) { | |
1540 | this.canvases = canvases; | |
1541 | this.canvas = canvases[PdfPTable.TEXTCANVAS]; | |
1542 |
1
1. setCanvases : negated conditional → NO_COVERAGE |
if (compositeColumn != null) |
1543 |
1
1. setCanvases : removed call to com/lowagie/text/pdf/ColumnText::setCanvases → NO_COVERAGE |
compositeColumn.setCanvases(canvases); |
1544 | } | |
1545 | | |
1546 | /** | |
1547 | * Gets the canvases. | |
1548 | * | |
1549 | * @return an array of PdfContentByte | |
1550 | */ | |
1551 | public PdfContentByte[] getCanvases() { | |
1552 | return canvases; | |
1553 | } | |
1554 | | |
1555 | /** | |
1556 | * Checks if the element has a height of 0. | |
1557 | * | |
1558 | * @return true or false | |
1559 | * @since 2.1.2 | |
1560 | */ | |
1561 | public boolean zeroHeightElement() { | |
1562 |
4
1. zeroHeightElement : negated conditional → NO_COVERAGE 2. zeroHeightElement : negated conditional → NO_COVERAGE 3. zeroHeightElement : negated conditional → NO_COVERAGE 4. zeroHeightElement : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return composite && !compositeElements.isEmpty() && ((Element)compositeElements.getFirst()).type() == Element.YMARK; |
1563 | } | |
1564 | | |
1565 | /** | |
1566 | * Checks if UseAscender is enabled/disabled. | |
1567 | * | |
1568 | * @return true is the adjustment of the first line height is based on max ascender. | |
1569 | */ | |
1570 | public boolean isUseAscender() { | |
1571 | return useAscender; | |
1572 | } | |
1573 | ||
1574 | /** | |
1575 | * Enables/Disables adjustment of first line height based on max ascender. | |
1576 | * | |
1577 | * @param useAscender enable adjustment if true | |
1578 | */ | |
1579 | public void setUseAscender(boolean useAscender) { | |
1580 | this.useAscender = useAscender; | |
1581 | } | |
1582 | | |
1583 | /** | |
1584 | * Checks the status variable and looks if there's still some text. | |
1585 | */ | |
1586 | public static boolean hasMoreText(int status) { | |
1587 |
3
1. hasMoreText : Replaced bitwise AND with OR → NO_COVERAGE 2. hasMoreText : negated conditional → NO_COVERAGE 3. hasMoreText : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return (status & ColumnText.NO_MORE_TEXT) == 0; |
1588 | } | |
1589 | ||
1590 | /** | |
1591 | * Gets the real width used by the largest line. | |
1592 | * | |
1593 | * @return the real width used by the largest line | |
1594 | */ | |
1595 | public float getFilledWidth() { | |
1596 | return filledWidth; | |
1597 | } | |
1598 | ||
1599 | /** | |
1600 | * Sets the real width used by the largest line. | |
1601 | * Only used to set it to zero to start another measurement. | |
1602 | * | |
1603 | * @param filledWidth the real width used by the largest line | |
1604 | */ | |
1605 | public void setFilledWidth(float filledWidth) { | |
1606 | this.filledWidth = filledWidth; | |
1607 | } | |
1608 | | |
1609 | /** | |
1610 | * Replaces the <CODE>filledWidth</CODE> if greater than the existing one. | |
1611 | * | |
1612 | * @param w the new <CODE>filledWidth</CODE> if greater than the existing one | |
1613 | */ | |
1614 | public void updateFilledWidth(float w) { | |
1615 |
2
1. updateFilledWidth : changed conditional boundary → NO_COVERAGE 2. updateFilledWidth : negated conditional → NO_COVERAGE |
if (w > filledWidth) |
1616 | filledWidth = w; | |
1617 | } | |
1618 | ||
1619 | ||
1620 | /** | |
1621 | * Gets the first line adjustment property. | |
1622 | * | |
1623 | * @return the first line adjustment property. | |
1624 | */ | |
1625 | public boolean isAdjustFirstLine() { | |
1626 | return adjustFirstLine; | |
1627 | } | |
1628 | ||
1629 | /** | |
1630 | * Sets the first line adjustment. | |
1631 | * Some objects have properties, like spacing before, that behave | |
1632 | * differently if the object is the first to be written after go() or not. | |
1633 | * The first line adjustment is <CODE>true</CODE> by default but can be | |
1634 | * changed if several objects are to be placed one after the other in the | |
1635 | * same column calling go() several times. | |
1636 | * | |
1637 | * @param adjustFirstLine <CODE>true</CODE> to adjust the first line, <CODE>false</CODE> otherwise | |
1638 | */ | |
1639 | public void setAdjustFirstLine(boolean adjustFirstLine) { | |
1640 | this.adjustFirstLine = adjustFirstLine; | |
1641 | } | |
1642 | } | |
Mutations | ||
279 |
1.1 |
|
289 |
1.1 |
|
290 |
1.1 |
|
292 |
1.1 |
|
300 |
1.1 |
|
303 |
1.1 |
|
326 |
1.1 |
|
328 |
1.1 |
|
332 |
1.1 |
|
347 |
1.1 2.2 |
|
350 |
1.1 |
|
363 |
1.1 2.2 |
|
365 |
1.1 |
|
366 |
1.1 |
|
371 |
1.1 |
|
398 |
1.1 2.2 |
|
400 |
1.1 |
|
413 |
1.1 |
|
415 |
1.1 |
|
419 |
1.1 |
|
420 |
1.1 |
|
421 |
1.1 |
|
424 |
1.1 |
|
425 |
1.1 |
|
426 |
1.1 |
|
429 |
1.1 |
|
432 |
1.1 |
|
435 |
1.1 |
|
439 |
1.1 |
|
440 |
1.1 |
|
441 |
1.1 |
|
442 |
1.1 |
|
443 |
1.1 |
|
444 |
1.1 |
|
447 |
1.1 |
|
450 |
1.1 |
|
453 |
1.1 |
|
460 |
1.1 2.2 3.3 4.4 |
|
462 |
1.1 |
|
482 |
1.1 2.2 |
|
485 |
1.1 2.2 3.3 4.4 |
|
487 |
1.1 |
|
488 |
1.1 |
|
489 |
1.1 |
|
490 |
1.1 |
|
493 |
1.1 2.2 3.3 |
|
494 |
1.1 2.2 |
|
504 |
1.1 |
|
506 |
1.1 |
|
518 |
1.1 2.2 3.3 4.4 |
|
520 |
1.1 |
|
522 |
1.1 |
|
524 |
1.1 2.2 3.3 4.4 |
|
526 |
1.1 2.2 3.3 |
|
529 |
1.1 |
|
540 |
1.1 2.2 |
|
541 |
1.1 |
|
543 |
1.1 |
|
544 |
1.1 |
|
545 |
1.1 |
|
558 |
1.1 2.2 |
|
559 |
1.1 |
|
562 |
1.1 |
|
563 |
1.1 |
|
564 |
1.1 |
|
565 |
1.1 |
|
569 |
1.1 |
|
570 |
1.1 |
|
571 |
1.1 |
|
572 |
1.1 |
|
575 |
1.1 2.2 3.3 4.4 |
|
577 |
1.1 |
|
592 |
1.1 2.2 |
|
611 |
1.1 |
|
612 |
1.1 |
|
626 |
1.1 |
|
628 |
1.1 |
|
645 |
1.1 |
|
646 |
1.1 2.2 |
|
793 |
1.1 |
|
804 |
1.1 |
|
805 |
1.1 |
|
806 |
1.1 |
|
807 |
1.1 |
|
808 |
1.1 |
|
822 |
1.1 |
|
824 |
1.1 |
|
829 |
1.1 |
|
831 |
1.1 |
|
832 |
1.1 |
|
834 |
1.1 2.2 |
|
842 |
1.1 |
|
843 |
1.1 |
|
844 |
1.1 2.2 3.3 |
|
846 |
1.1 |
|
847 |
1.1 |
|
850 |
1.1 |
|
854 |
1.1 2.2 |
|
855 |
1.1 |
|
860 |
1.1 2.2 |
|
863 |
1.1 2.2 |
|
864 |
1.1 2.2 3.3 4.4 5.5 |
|
866 |
1.1 |
|
869 |
1.1 |
|
870 |
1.1 2.2 |
|
871 |
1.1 |
|
874 |
1.1 |
|
876 |
1.1 2.2 |
|
882 |
1.1 |
|
884 |
1.1 |
|
885 |
1.1 |
|
889 |
1.1 |
|
896 |
1.1 2.2 3.3 4.4 |
|
898 |
1.1 2.2 |
|
899 |
1.1 |
|
902 |
1.1 2.2 3.3 |
|
903 |
1.1 |
|
909 |
1.1 |
|
911 |
1.1 2.2 3.3 4.4 |
|
912 |
1.1 |
|
916 |
1.1 2.2 |
|
917 |
1.1 |
|
920 |
1.1 |
|
921 |
1.1 |
|
922 |
1.1 |
|
924 |
1.1 |
|
950 |
1.1 |
|
951 |
1.1 |
|
983 |
1.1 2.2 3.3 4.4 |
|
1045 |
1.1 |
|
1046 |
1.1 |
|
1048 |
1.1 |
|
1049 |
1.1 |
|
1051 |
1.1 2.2 |
|
1062 |
1.1 |
|
1078 |
1.1 2.2 3.3 |
|
1081 |
1.1 |
|
1101 |
1.1 |
|
1102 |
1.1 |
|
1103 |
1.1 |
|
1104 |
1.1 |
|
1105 |
1.1 |
|
1108 |
1.1 2.2 |
|
1111 |
1.1 2.2 |
|
1113 |
1.1 |
|
1114 |
1.1 |
|
1115 |
1.1 |
|
1117 |
1.1 |
|
1120 |
1.1 |
|
1121 |
1.1 |
|
1122 |
1.1 |
|
1129 |
1.1 |
|
1143 |
1.1 |
|
1147 |
1.1 |
|
1155 |
1.1 |
|
1156 |
1.1 |
|
1158 |
1.1 |
|
1161 |
1.1 2.2 3.3 |
|
1164 |
1.1 |
|
1166 |
1.1 2.2 3.3 |
|
1167 |
1.1 |
|
1168 |
1.1 2.2 |
|
1169 |
1.1 |
|
1170 |
1.1 |
|
1171 |
1.1 |
|
1172 |
1.1 |
|
1173 |
1.1 |
|
1174 |
1.1 |
|
1175 |
1.1 |
|
1176 |
1.1 |
|
1177 |
1.1 |
|
1178 |
1.1 |
|
1189 |
1.1 2.2 3.3 |
|
1190 |
1.1 2.2 3.3 |
|
1191 |
1.1 |
|
1192 |
1.1 2.2 3.3 |
|
1195 |
1.1 |
|
1197 |
1.1 2.2 |
|
1199 |
1.1 |
|
1206 |
1.1 |
|
1208 |
1.1 2.2 |
|
1211 |
1.1 |
|
1213 |
1.1 2.2 |
|
1214 |
1.1 |
|
1217 |
1.1 |
|
1224 |
1.1 2.2 3.3 |
|
1226 |
1.1 |
|
1227 |
1.1 |
|
1231 |
1.1 |
|
1233 |
1.1 |
|
1237 |
1.1 |
|
1241 |
1.1 2.2 |
|
1242 |
1.1 |
|
1252 |
1.1 2.2 3.3 |
|
1255 |
1.1 |
|
1256 |
1.1 |
|
1262 |
1.1 2.2 3.3 |
|
1263 |
1.1 |
|
1264 |
1.1 2.2 3.3 |
|
1265 |
1.1 |
|
1266 |
1.1 |
|
1267 |
1.1 2.2 |
|
1268 |
1.1 |
|
1269 |
1.1 |
|
1270 |
1.1 |
|
1271 |
1.1 |
|
1272 |
1.1 |
|
1273 |
1.1 |
|
1274 |
1.1 |
|
1285 |
1.1 2.2 3.3 |
|
1286 |
1.1 2.2 3.3 |
|
1287 |
1.1 |
|
1288 |
1.1 2.2 3.3 |
|
1291 |
1.1 |
|
1293 |
1.1 2.2 |
|
1295 |
1.1 |
|
1302 |
1.1 |
|
1304 |
1.1 2.2 |
|
1305 |
1.1 |
|
1306 |
1.1 2.2 |
|
1309 |
1.1 2.2 |
|
1311 |
1.1 |
|
1312 |
1.1 |
|
1314 |
1.1 2.2 |
|
1315 |
1.1 |
|
1317 |
1.1 |
|
1319 |
1.1 2.2 3.3 4.4 |
|
1320 |
1.1 |
|
1325 |
1.1 2.2 |
|
1332 |
1.1 2.2 |
|
1333 |
1.1 |
|
1337 |
1.1 2.2 3.3 4.4 |
|
1338 |
1.1 |
|
1344 |
1.1 |
|
1346 |
1.1 |
|
1349 |
1.1 2.2 |
|
1350 |
1.1 |
|
1356 |
1.1 2.2 |
|
1358 |
1.1 |
|
1363 |
1.1 2.2 3.3 4.4 |
|
1364 |
1.1 |
|
1365 |
1.1 |
|
1366 |
1.1 2.2 3.3 4.4 |
|
1367 |
1.1 |
|
1371 |
1.1 |
|
1377 |
1.1 2.2 |
|
1379 |
1.1 |
|
1380 |
1.1 |
|
1381 |
1.1 2.2 |
|
1383 |
1.1 2.2 3.3 |
|
1385 |
1.1 |
|
1387 |
1.1 |
|
1388 |
1.1 |
|
1390 |
1.1 2.2 |
|
1391 |
1.1 2.2 3.3 4.4 |
|
1392 |
1.1 |
|
1397 |
1.1 2.2 3.3 |
|
1400 |
1.1 |
|
1402 |
1.1 |
|
1403 |
1.1 |
|
1404 |
1.1 |
|
1408 |
1.1 2.2 |
|
1411 |
1.1 2.2 3.3 |
|
1416 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
1417 |
1.1 |
|
1422 |
1.1 |
|
1428 |
1.1 2.2 |
|
1431 |
1.1 2.2 3.3 |
|
1438 |
1.1 2.2 3.3 |
|
1442 |
1.1 |
|
1447 |
1.1 |
|
1449 |
1.1 2.2 |
|
1450 |
1.1 |
|
1455 |
1.1 2.2 3.3 4.4 5.5 |
|
1456 |
1.1 |
|
1460 |
1.1 |
|
1461 |
1.1 2.2 |
|
1463 |
1.1 |
|
1465 |
1.1 2.2 3.3 |
|
1470 |
1.1 |
|
1474 |
1.1 |
|
1475 |
1.1 |
|
1478 |
1.1 2.2 3.3 |
|
1481 |
1.1 2.2 |
|
1482 |
1.1 |
|
1483 |
1.1 2.2 |
|
1484 |
1.1 |
|
1490 |
1.1 |
|
1492 |
1.1 2.2 3.3 |
|
1496 |
1.1 |
|
1499 |
1.1 |
|
1500 |
1.1 |
|
1502 |
1.1 |
|
1530 |
1.1 |
|
1531 |
1.1 |
|
1542 |
1.1 |
|
1543 |
1.1 |
|
1562 |
1.1 2.2 3.3 4.4 |
|
1587 |
1.1 2.2 3.3 |
|
1615 |
1.1 2.2 |