1 | /* | |
2 | * $Id: PdfChunk.java 4092 2009-11-11 17:58:16Z psoares33 $ | |
3 | * | |
4 | * Copyright 1999, 2000, 2001, 2002 Bruno Lowagie | |
5 | * | |
6 | * The contents of this file are subject to the Mozilla Public License Version 1.1 | |
7 | * (the "License"); you may not use this file except in compliance with the License. | |
8 | * You may obtain a copy of the License at http://www.mozilla.org/MPL/ | |
9 | * | |
10 | * Software distributed under the License is distributed on an "AS IS" basis, | |
11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |
12 | * for the specific language governing rights and limitations under the License. | |
13 | * | |
14 | * The Original Code is 'iText, a free JAVA-PDF library'. | |
15 | * | |
16 | * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by | |
17 | * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie. | |
18 | * All Rights Reserved. | |
19 | * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer | |
20 | * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved. | |
21 | * | |
22 | * Contributor(s): all the names of the contributors are added in the source code | |
23 | * where applicable. | |
24 | * | |
25 | * Alternatively, the contents of this file may be used under the terms of the | |
26 | * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the | |
27 | * provisions of LGPL are applicable instead of those above. If you wish to | |
28 | * allow use of your version of this file only under the terms of the LGPL | |
29 | * License and not to allow others to use your version of this file under | |
30 | * the MPL, indicate your decision by deleting the provisions above and | |
31 | * replace them with the notice and other provisions required by the LGPL. | |
32 | * If you do not delete the provisions above, a recipient may use your version | |
33 | * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE. | |
34 | * | |
35 | * This library is free software; you can redistribute it and/or modify it | |
36 | * under the terms of the MPL as stated above or under the terms of the GNU | |
37 | * Library General Public License as published by the Free Software Foundation; | |
38 | * either version 2 of the License, or any later version. | |
39 | * | |
40 | * This library is distributed in the hope that it will be useful, but WITHOUT | |
41 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
42 | * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more | |
43 | * details. | |
44 | * | |
45 | * If you didn't download this code from the following link, you should check if | |
46 | * you aren't using an obsolete version: | |
47 | * http://www.lowagie.com/iText/ | |
48 | */ | |
49 | ||
50 | package com.lowagie.text.pdf; | |
51 | ||
52 | import java.awt.Color; | |
53 | import java.util.HashMap; | |
54 | import java.util.Map; | |
55 | ||
56 | import com.lowagie.text.Chunk; | |
57 | import com.lowagie.text.Font; | |
58 | import com.lowagie.text.Image; | |
59 | import com.lowagie.text.SplitCharacter; | |
60 | import com.lowagie.text.Utilities; | |
61 | ||
62 | /** | |
63 | * A <CODE>PdfChunk</CODE> is the PDF translation of a <CODE>Chunk</CODE>. | |
64 | * <P> | |
65 | * A <CODE>PdfChunk</CODE> is a <CODE>PdfString</CODE> in a certain | |
66 | * <CODE>PdfFont</CODE> and <CODE>Color</CODE>. | |
67 | * | |
68 | * @see PdfString | |
69 | * @see com.lowagie.text.Chunk | |
70 | * @see com.lowagie.text.Font | |
71 | */ | |
72 | ||
73 | public class PdfChunk { | |
74 | ||
75 | private static final char[] singleSpace = {' '}; | |
76 | private static final PdfChunk[] thisChunk = new PdfChunk[1]; | |
77 | private static final float ITALIC_ANGLE = 0.21256f; | |
78 | /** The allowed attributes in variable <CODE>attributes</CODE>. */ | |
79 | private static final Map<String, Object> keysAttributes = new HashMap<>(); | |
80 | | |
81 | /** The allowed attributes in variable <CODE>noStroke</CODE>. */ | |
82 | private static final Map<String, Object> keysNoStroke = new HashMap<>(); | |
83 | | |
84 | static { | |
85 | keysAttributes.put(Chunk.ACTION, null); | |
86 | keysAttributes.put(Chunk.UNDERLINE, null); | |
87 | keysAttributes.put(Chunk.REMOTEGOTO, null); | |
88 | keysAttributes.put(Chunk.LOCALGOTO, null); | |
89 | keysAttributes.put(Chunk.LOCALDESTINATION, null); | |
90 | keysAttributes.put(Chunk.GENERICTAG, null); | |
91 | keysAttributes.put(Chunk.NEWPAGE, null); | |
92 | keysAttributes.put(Chunk.IMAGE, null); | |
93 | keysAttributes.put(Chunk.BACKGROUND, null); | |
94 | keysAttributes.put(Chunk.PDFANNOTATION, null); | |
95 | keysAttributes.put(Chunk.SKEW, null); | |
96 | keysAttributes.put(Chunk.HSCALE, null); | |
97 | keysAttributes.put(Chunk.SEPARATOR, null); | |
98 | keysAttributes.put(Chunk.TAB, null); | |
99 | keysAttributes.put(Chunk.CHAR_SPACING, null); | |
100 | keysNoStroke.put(Chunk.SUBSUPSCRIPT, null); | |
101 | keysNoStroke.put(Chunk.SPLITCHARACTER, null); | |
102 | keysNoStroke.put(Chunk.HYPHENATION, null); | |
103 | keysNoStroke.put(Chunk.TEXTRENDERMODE, null); | |
104 | } | |
105 | | |
106 | // membervariables | |
107 | ||
108 | /** The value of this object. */ | |
109 | protected String value = PdfObject.NOTHING; | |
110 | | |
111 | /** The encoding. */ | |
112 | protected String encoding = BaseFont.WINANSI; | |
113 | | |
114 | | |
115 | /** The font for this <CODE>PdfChunk</CODE>. */ | |
116 | protected PdfFont font; | |
117 | | |
118 | protected BaseFont baseFont; | |
119 | | |
120 | protected SplitCharacter splitCharacter; | |
121 | /** | |
122 | * Metric attributes. | |
123 | * <P> | |
124 | * This attributes require the measurement of characters widths when rendering | |
125 | * such as underline. | |
126 | */ | |
127 | protected Map<String, Object> attributes = new HashMap<>(); | |
128 | | |
129 | /** | |
130 | * Non metric attributes. | |
131 | * <P> | |
132 | * This attributes do not require the measurement of characters widths when rendering | |
133 | * such as Color. | |
134 | */ | |
135 | protected Map<String, Object> noStroke = new HashMap<>(); | |
136 | | |
137 | /** <CODE>true</CODE> if the chunk split was cause by a newline. */ | |
138 | protected boolean newlineSplit; | |
139 | | |
140 | /** The image in this <CODE>PdfChunk</CODE>, if it has one */ | |
141 | protected Image image; | |
142 | | |
143 | /** The offset in the x direction for the image */ | |
144 | protected float offsetX; | |
145 | | |
146 | /** The offset in the y direction for the image */ | |
147 | protected float offsetY; | |
148 | ||
149 | /** Indicates if the height and offset of the Image has to be taken into account */ | |
150 | protected boolean changeLeading = false; | |
151 | ||
152 | // constructors | |
153 | | |
154 | /** | |
155 | * Constructs a <CODE>PdfChunk</CODE>-object. | |
156 | * | |
157 | * @param string the content of the <CODE>PdfChunk</CODE>-object | |
158 | * @param other Chunk with the same style you want for the new Chunk | |
159 | */ | |
160 | | |
161 | PdfChunk(String string, PdfChunk other) { | |
162 | thisChunk[0] = this; | |
163 | value = string; | |
164 | this.font = other.font; | |
165 | this.attributes = other.attributes; | |
166 | this.noStroke = other.noStroke; | |
167 | this.baseFont = other.baseFont; | |
168 | Object[] obj = (Object[]) attributes.get(Chunk.IMAGE); | |
169 |
1
1. |
if (obj == null) |
170 | image = null; | |
171 | else { | |
172 | image = (Image)obj[0]; | |
173 | offsetX = (Float) obj[1]; | |
174 | offsetY = (Float) obj[2]; | |
175 | changeLeading = (Boolean) obj[3]; | |
176 | } | |
177 | encoding = font.getFont().getEncoding(); | |
178 | splitCharacter = (SplitCharacter)noStroke.get(Chunk.SPLITCHARACTER); | |
179 |
1
1. |
if (splitCharacter == null) |
180 | splitCharacter = DefaultSplitCharacter.DEFAULT; | |
181 | } | |
182 | | |
183 | /** | |
184 | * Constructs a <CODE>PdfChunk</CODE>-object. | |
185 | * | |
186 | * @param chunk the original <CODE>Chunk</CODE>-object | |
187 | * @param action the <CODE>PdfAction</CODE> if the <CODE>Chunk</CODE> comes from an <CODE>Anchor</CODE> | |
188 | */ | |
189 | | |
190 | PdfChunk(Chunk chunk, PdfAction action) { | |
191 | thisChunk[0] = this; | |
192 | value = chunk.getContent(); | |
193 | | |
194 | Font f = chunk.getFont(); | |
195 | float size = f.getSize(); | |
196 |
1
1. |
if (size == Font.UNDEFINED) |
197 | size = 12; | |
198 | baseFont = f.getBaseFont(); | |
199 | int style = f.getStyle(); | |
200 |
1
1. |
if (style == Font.UNDEFINED) { |
201 | style = Font.NORMAL; | |
202 | } | |
203 |
1
1. |
if (baseFont == null) { |
204 | // translation of the font-family to a PDF font-family | |
205 | baseFont = f.getCalculatedBaseFont(false); | |
206 | } | |
207 | else { | |
208 | // bold simulation | |
209 |
2
1. 2. |
if ((style & Font.BOLD) != 0) |
210 |
1
1. |
attributes.put(Chunk.TEXTRENDERMODE, new Object[]{PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE, size / 30f, null}); |
211 | // italic simulation | |
212 |
2
1. 2. |
if ((style & Font.ITALIC) != 0) |
213 | attributes.put(Chunk.SKEW, new float[]{0, ITALIC_ANGLE}); | |
214 | } | |
215 | font = new PdfFont(baseFont, size); | |
216 | // other style possibilities | |
217 | Map<String, Object> attr = chunk.getAttributes(); | |
218 |
1
1. |
if (attr != null) { |
219 | for (Map.Entry<String, Object> entry : attr.entrySet()) { | |
220 | String name = entry.getKey(); | |
221 |
1
1. |
if (keysAttributes.containsKey(name)) { |
222 | attributes.put(name, entry.getValue()); | |
223 |
1
1. |
} else if (keysNoStroke.containsKey(name)) { |
224 | noStroke.put(name, entry.getValue()); | |
225 | } | |
226 | } | |
227 |
1
1. |
if ("".equals(attr.get(Chunk.GENERICTAG))) { |
228 | attributes.put(Chunk.GENERICTAG, chunk.getContent()); | |
229 | } | |
230 | } | |
231 |
1
1. |
if (f.isUnderlined()) { |
232 | Object[] obj = {null, new float[]{0, 1f / 15, 0, -1f / 3, 0}}; | |
233 | Object[][] unders = Utilities.addToArray((Object[][]) attributes.get(Chunk.UNDERLINE), obj); | |
234 | attributes.put(Chunk.UNDERLINE, unders); | |
235 | } | |
236 |
1
1. |
if (f.isStrikethru()) { |
237 | Object[] obj = {null, new float[]{0, 1f / 15, 0, 1f / 3, 0}}; | |
238 | Object[][] unders = Utilities.addToArray((Object[][]) attributes.get(Chunk.UNDERLINE), obj); | |
239 | attributes.put(Chunk.UNDERLINE, unders); | |
240 | } | |
241 |
1
1. |
if (action != null) |
242 | attributes.put(Chunk.ACTION, action); | |
243 | // the color can't be stored in a PdfFont | |
244 | noStroke.put(Chunk.COLOR, f.getColor()); | |
245 | noStroke.put(Chunk.ENCODING, font.getFont().getEncoding()); | |
246 | Object[] obj = (Object[]) attributes.get(Chunk.IMAGE); | |
247 |
1
1. |
if (obj == null) { |
248 | image = null; | |
249 | } | |
250 | else { | |
251 | attributes.remove(Chunk.HSCALE); // images are scaled in other ways | |
252 | image = (Image)obj[0]; | |
253 | offsetX = (Float) obj[1]; | |
254 | offsetY = (Float) obj[2]; | |
255 | changeLeading = (Boolean) obj[3]; | |
256 | } | |
257 |
1
1. |
font.setImage(image); |
258 | Float hs = (Float)attributes.get(Chunk.HSCALE); | |
259 |
1
1. |
if (hs != null) |
260 |
1
1. |
font.setHorizontalScaling(hs); |
261 | encoding = font.getFont().getEncoding(); | |
262 | splitCharacter = (SplitCharacter)noStroke.get(Chunk.SPLITCHARACTER); | |
263 |
1
1. |
if (splitCharacter == null) |
264 | splitCharacter = DefaultSplitCharacter.DEFAULT; | |
265 | } | |
266 | | |
267 | // methods | |
268 | | |
269 | /** Gets the Unicode equivalent to a CID. | |
270 | * The (inexistent) CID <FF00> is translated as '\n'. | |
271 | * It has only meaning with CJK fonts with Identity encoding. | |
272 | * @param c the CID code | |
273 | * @return the Unicode equivalent | |
274 | */ | |
275 | public int getUnicodeEquivalent(int c) { | |
276 | return baseFont.getUnicodeEquivalent(c); | |
277 | } | |
278 | ||
279 | protected int getWord(String text, int start) { | |
280 | int len = text.length(); | |
281 |
2
1. getWord : changed conditional boundary → NO_COVERAGE 2. getWord : negated conditional → NO_COVERAGE |
while (start < len) { |
282 |
1
1. getWord : negated conditional → NO_COVERAGE |
if (!Character.isLetter(text.charAt(start))) |
283 | break; | |
284 |
1
1. getWord : Changed increment from 1 to -1 → NO_COVERAGE |
++start; |
285 | } | |
286 |
1
1. getWord : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return start; |
287 | } | |
288 | | |
289 | /** | |
290 | * Splits this <CODE>PdfChunk</CODE> if it's too long for the given width. | |
291 | * <P> | |
292 | * Returns <VAR>null</VAR> if the <CODE>PdfChunk</CODE> wasn't truncated. | |
293 | * | |
294 | * @param width a given width | |
295 | * @return the <CODE>PdfChunk</CODE> that doesn't fit into the width. | |
296 | */ | |
297 | | |
298 | PdfChunk split(float width) { | |
299 | newlineSplit = false; | |
300 |
1
1. split : negated conditional → NO_COVERAGE |
if (image != null) { |
301 |
2
1. split : changed conditional boundary → NO_COVERAGE 2. split : negated conditional → NO_COVERAGE |
if (image.getScaledWidth() > width) { |
302 | PdfChunk pc = new PdfChunk(Chunk.OBJECT_REPLACEMENT_CHARACTER, this); | |
303 | value = ""; | |
304 | attributes = new HashMap<>(); | |
305 | image = null; | |
306 | font = PdfFont.getDefaultFont(); | |
307 |
1
1. split : mutated return of Object value for com/lowagie/text/pdf/PdfChunk::split to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return pc; |
308 | } | |
309 | else | |
310 |
1
1. split : mutated return of Object value for com/lowagie/text/pdf/PdfChunk::split to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return null; |
311 | } | |
312 | HyphenationEvent hyphenationEvent = (HyphenationEvent)noStroke.get(Chunk.HYPHENATION); | |
313 | int currentPosition = 0; | |
314 | int splitPosition = -1; | |
315 | float currentWidth = 0; | |
316 | | |
317 | // loop over all the characters of a string | |
318 | // or until the totalWidth is reached | |
319 | int lastSpace = -1; | |
320 | float lastSpaceWidth = 0; | |
321 | int length = value.length(); | |
322 | char[] valueArray = value.toCharArray(); | |
323 | char character = 0; | |
324 | BaseFont ft = font.getFont(); | |
325 | boolean surrogate = false; | |
326 |
2
1. split : negated conditional → NO_COVERAGE 2. split : negated conditional → NO_COVERAGE |
if (ft.getFontType() == BaseFont.FONT_TYPE_CJK && ft.getUnicodeEquivalent(' ') != ' ') { |
327 |
2
1. split : changed conditional boundary → NO_COVERAGE 2. split : negated conditional → NO_COVERAGE |
while (currentPosition < length) { |
328 | // the width of every character is added to the currentWidth | |
329 | char cidChar = valueArray[currentPosition]; | |
330 | character = (char)ft.getUnicodeEquivalent(cidChar); | |
331 | // if a newLine or carriageReturn is encountered | |
332 |
1
1. split : negated conditional → NO_COVERAGE |
if (character == '\n') { |
333 | newlineSplit = true; | |
334 |
1
1. split : Replaced integer addition with subtraction → NO_COVERAGE |
String returnValue = value.substring(currentPosition + 1); |
335 | value = value.substring(0, currentPosition); | |
336 |
2
1. split : changed conditional boundary → NO_COVERAGE 2. split : negated conditional → NO_COVERAGE |
if (value.length() < 1) { |
337 | value = "\u0001"; | |
338 | } | |
339 |
1
1. split : mutated return of Object value for com/lowagie/text/pdf/PdfChunk::split to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new PdfChunk(returnValue, this); |
340 | } | |
341 |
1
1. split : Replaced float addition with subtraction → NO_COVERAGE |
currentWidth += getCharWidth(cidChar); |
342 |
1
1. split : negated conditional → NO_COVERAGE |
if (character == ' ') { |
343 |
1
1. split : Replaced integer addition with subtraction → NO_COVERAGE |
lastSpace = currentPosition + 1; |
344 | lastSpaceWidth = currentWidth; | |
345 | } | |
346 |
2
1. split : changed conditional boundary → NO_COVERAGE 2. split : negated conditional → NO_COVERAGE |
if (currentWidth > width) |
347 | break; | |
348 | // if a split-character is encountered, the splitPosition is altered | |
349 |
1
1. split : negated conditional → NO_COVERAGE |
if (splitCharacter.isSplitCharacter(0, currentPosition, length, valueArray, thisChunk)) |
350 |
1
1. split : Replaced integer addition with subtraction → NO_COVERAGE |
splitPosition = currentPosition + 1; |
351 |
1
1. split : Changed increment from 1 to -1 → NO_COVERAGE |
currentPosition++; |
352 | } | |
353 | } | |
354 | else { | |
355 |
2
1. split : changed conditional boundary → NO_COVERAGE 2. split : negated conditional → NO_COVERAGE |
while (currentPosition < length) { |
356 | // the width of every character is added to the currentWidth | |
357 | character = valueArray[currentPosition]; | |
358 | // if a newLine or carriageReturn is encountered | |
359 |
2
1. split : negated conditional → NO_COVERAGE 2. split : negated conditional → NO_COVERAGE |
if (character == '\r' || character == '\n') { |
360 | newlineSplit = true; | |
361 | int inc = 1; | |
362 |
6
1. split : changed conditional boundary → NO_COVERAGE 2. split : Replaced integer addition with subtraction → NO_COVERAGE 3. split : Replaced integer addition with subtraction → NO_COVERAGE 4. split : negated conditional → NO_COVERAGE 5. split : negated conditional → NO_COVERAGE 6. split : negated conditional → NO_COVERAGE |
if (character == '\r' && currentPosition + 1 < length && valueArray[currentPosition + 1] == '\n') |
363 | inc = 2; | |
364 |
1
1. split : Replaced integer addition with subtraction → NO_COVERAGE |
String returnValue = value.substring(currentPosition + inc); |
365 | value = value.substring(0, currentPosition); | |
366 |
2
1. split : changed conditional boundary → NO_COVERAGE 2. split : negated conditional → NO_COVERAGE |
if (value.length() < 1) { |
367 | value = " "; | |
368 | } | |
369 |
1
1. split : mutated return of Object value for com/lowagie/text/pdf/PdfChunk::split to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new PdfChunk(returnValue, this); |
370 | } | |
371 | surrogate = Utilities.isSurrogatePair(valueArray, currentPosition); | |
372 |
1
1. split : negated conditional → NO_COVERAGE |
if (surrogate) |
373 |
2
1. split : Replaced integer addition with subtraction → NO_COVERAGE 2. split : Replaced float addition with subtraction → NO_COVERAGE |
currentWidth += getCharWidth(Utilities.convertToUtf32(valueArray[currentPosition], valueArray[currentPosition + 1])); |
374 | else | |
375 |
1
1. split : Replaced float addition with subtraction → NO_COVERAGE |
currentWidth += getCharWidth(character); |
376 |
1
1. split : negated conditional → NO_COVERAGE |
if (character == ' ') { |
377 |
1
1. split : Replaced integer addition with subtraction → NO_COVERAGE |
lastSpace = currentPosition + 1; |
378 | lastSpaceWidth = currentWidth; | |
379 | } | |
380 |
1
1. split : negated conditional → NO_COVERAGE |
if (surrogate) |
381 |
1
1. split : Changed increment from 1 to -1 → NO_COVERAGE |
currentPosition++; |
382 |
2
1. split : changed conditional boundary → NO_COVERAGE 2. split : negated conditional → NO_COVERAGE |
if (currentWidth > width) |
383 | break; | |
384 | // if a split-character is encountered, the splitPosition is altered | |
385 |
1
1. split : negated conditional → NO_COVERAGE |
if (splitCharacter.isSplitCharacter(0, currentPosition, length, valueArray, null)) |
386 |
1
1. split : Replaced integer addition with subtraction → NO_COVERAGE |
splitPosition = currentPosition + 1; |
387 |
1
1. split : Changed increment from 1 to -1 → NO_COVERAGE |
currentPosition++; |
388 | } | |
389 | } | |
390 | | |
391 | // if all the characters fit in the total width, null is returned (there is no overflow) | |
392 |
1
1. split : negated conditional → NO_COVERAGE |
if (currentPosition == length) { |
393 |
1
1. split : mutated return of Object value for com/lowagie/text/pdf/PdfChunk::split to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return null; |
394 | } | |
395 | // otherwise, the string has to be truncated | |
396 |
2
1. split : changed conditional boundary → NO_COVERAGE 2. split : negated conditional → NO_COVERAGE |
if (splitPosition < 0) { |
397 | String returnValue = value; | |
398 | value = ""; | |
399 |
1
1. split : mutated return of Object value for com/lowagie/text/pdf/PdfChunk::split to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new PdfChunk(returnValue, this); |
400 | } | |
401 |
3
1. split : changed conditional boundary → NO_COVERAGE 2. split : negated conditional → NO_COVERAGE 3. split : negated conditional → NO_COVERAGE |
if (lastSpace > splitPosition && splitCharacter.isSplitCharacter(0, 0, 1, singleSpace, null)) |
402 | splitPosition = lastSpace; | |
403 |
5
1. split : changed conditional boundary → NO_COVERAGE 2. split : changed conditional boundary → NO_COVERAGE 3. split : negated conditional → NO_COVERAGE 4. split : negated conditional → NO_COVERAGE 5. split : negated conditional → NO_COVERAGE |
if (hyphenationEvent != null && lastSpace >= 0 && lastSpace < currentPosition) { |
404 | int wordIdx = getWord(value, lastSpace); | |
405 |
2
1. split : changed conditional boundary → NO_COVERAGE 2. split : negated conditional → NO_COVERAGE |
if (wordIdx > lastSpace) { |
406 |
1
1. split : Replaced float subtraction with addition → NO_COVERAGE |
String pre = hyphenationEvent.getHyphenatedWordPre(value.substring(lastSpace, wordIdx), font.getFont(), font.size(), width - lastSpaceWidth); |
407 | String post = hyphenationEvent.getHyphenatedWordPost(); | |
408 |
2
1. split : changed conditional boundary → NO_COVERAGE 2. split : negated conditional → NO_COVERAGE |
if (pre.length() > 0) { |
409 | String returnValue = post + value.substring(wordIdx); | |
410 | value = trim(value.substring(0, lastSpace) + pre); | |
411 |
1
1. split : mutated return of Object value for com/lowagie/text/pdf/PdfChunk::split to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new PdfChunk(returnValue, this); |
412 | } | |
413 | } | |
414 | } | |
415 | String returnValue = value.substring(splitPosition); | |
416 | value = trim(value.substring(0, splitPosition)); | |
417 |
1
1. split : mutated return of Object value for com/lowagie/text/pdf/PdfChunk::split to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new PdfChunk(returnValue, this); |
418 | } | |
419 | | |
420 | /** | |
421 | * Truncates this <CODE>PdfChunk</CODE> if it's too long for the given width. | |
422 | * <P> | |
423 | * Returns <VAR>null</VAR> if the <CODE>PdfChunk</CODE> wasn't truncated. | |
424 | * | |
425 | * @param width a given width | |
426 | * @return the <CODE>PdfChunk</CODE> that doesn't fit into the width. | |
427 | */ | |
428 | | |
429 | PdfChunk truncate(float width) { | |
430 |
1
1. truncate : negated conditional → NO_COVERAGE |
if (image != null) { |
431 |
2
1. truncate : changed conditional boundary → NO_COVERAGE 2. truncate : negated conditional → NO_COVERAGE |
if (image.getScaledWidth() > width) { |
432 | PdfChunk pc = new PdfChunk("", this); | |
433 | value = ""; | |
434 | attributes.remove(Chunk.IMAGE); | |
435 | image = null; | |
436 | font = PdfFont.getDefaultFont(); | |
437 |
1
1. truncate : mutated return of Object value for com/lowagie/text/pdf/PdfChunk::truncate to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return pc; |
438 | } | |
439 | else | |
440 |
1
1. truncate : mutated return of Object value for com/lowagie/text/pdf/PdfChunk::truncate to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return null; |
441 | } | |
442 | | |
443 | int currentPosition = 0; | |
444 | float currentWidth = 0; | |
445 | | |
446 | // it's no use trying to split if there isn't even enough place for a space | |
447 |
2
1. truncate : changed conditional boundary → NO_COVERAGE 2. truncate : negated conditional → NO_COVERAGE |
if (width < font.width()) { |
448 | String returnValue = value.substring(1); | |
449 | value = value.substring(0, 1); | |
450 |
1
1. truncate : mutated return of Object value for com/lowagie/text/pdf/PdfChunk::truncate to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new PdfChunk(returnValue, this); |
451 | } | |
452 | | |
453 | // loop over all the characters of a string | |
454 | // or until the totalWidth is reached | |
455 | int length = value.length(); | |
456 | boolean surrogate = false; | |
457 | char character; | |
458 |
2
1. truncate : changed conditional boundary → NO_COVERAGE 2. truncate : negated conditional → NO_COVERAGE |
while (currentPosition < length) { |
459 | // the width of every character is added to the currentWidth | |
460 | surrogate = Utilities.isSurrogatePair(value, currentPosition); | |
461 |
1
1. truncate : negated conditional → NO_COVERAGE |
if (surrogate) |
462 |
1
1. truncate : Replaced float addition with subtraction → NO_COVERAGE |
currentWidth += getCharWidth(Utilities.convertToUtf32(value, currentPosition)); |
463 | else | |
464 |
1
1. truncate : Replaced float addition with subtraction → NO_COVERAGE |
currentWidth += getCharWidth(value.charAt(currentPosition)); |
465 |
2
1. truncate : changed conditional boundary → NO_COVERAGE 2. truncate : negated conditional → NO_COVERAGE |
if (currentWidth > width) |
466 | break; | |
467 |
1
1. truncate : negated conditional → NO_COVERAGE |
if (surrogate) |
468 |
1
1. truncate : Changed increment from 1 to -1 → NO_COVERAGE |
currentPosition++; |
469 |
1
1. truncate : Changed increment from 1 to -1 → NO_COVERAGE |
currentPosition++; |
470 | } | |
471 | | |
472 | // if all the characters fit in the total width, null is returned (there is no overflow) | |
473 |
1
1. truncate : negated conditional → NO_COVERAGE |
if (currentPosition == length) { |
474 |
1
1. truncate : mutated return of Object value for com/lowagie/text/pdf/PdfChunk::truncate to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return null; |
475 | } | |
476 | | |
477 | // otherwise, the string has to be truncated | |
478 | //currentPosition -= 2; | |
479 | // we have to chop off minimum 1 character from the chunk | |
480 |
1
1. truncate : negated conditional → NO_COVERAGE |
if (currentPosition == 0) { |
481 | currentPosition = 1; | |
482 |
1
1. truncate : negated conditional → NO_COVERAGE |
if (surrogate) |
483 |
1
1. truncate : Changed increment from 1 to -1 → NO_COVERAGE |
++currentPosition; |
484 | } | |
485 | String returnValue = value.substring(currentPosition); | |
486 | value = value.substring(0, currentPosition); | |
487 |
1
1. truncate : mutated return of Object value for com/lowagie/text/pdf/PdfChunk::truncate to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new PdfChunk(returnValue, this); |
488 | } | |
489 | | |
490 | // methods to retrieve the membervariables | |
491 | | |
492 | /** | |
493 | * Returns the font of this <CODE>Chunk</CODE>. | |
494 | * | |
495 | * @return a <CODE>PdfFont</CODE> | |
496 | */ | |
497 | | |
498 | PdfFont font() { | |
499 | return font; | |
500 | } | |
501 | | |
502 | /** | |
503 | * Returns the color of this <CODE>Chunk</CODE>. | |
504 | * | |
505 | * @return a <CODE>Color</CODE> | |
506 | */ | |
507 | | |
508 | Color color() { | |
509 |
1
1. color : mutated return of Object value for com/lowagie/text/pdf/PdfChunk::color to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return (Color)noStroke.get(Chunk.COLOR); |
510 | } | |
511 | | |
512 | /** | |
513 | * Returns the width of this <CODE>PdfChunk</CODE>. | |
514 | * | |
515 | * @return a width | |
516 | */ | |
517 | | |
518 | float width() { | |
519 |
1
1. width : negated conditional → NO_COVERAGE |
if (isAttribute(Chunk.CHAR_SPACING)) { |
520 | Float cs = (Float) getAttribute(Chunk.CHAR_SPACING); | |
521 |
3
1. width : Replaced float multiplication with division → NO_COVERAGE 2. width : Replaced float addition with subtraction → NO_COVERAGE 3. width : replaced return of float value with -(x + 1) for com/lowagie/text/pdf/PdfChunk::width → NO_COVERAGE |
return font.width(value) + value.length() * cs; |
522 | } | |
523 |
1
1. width : replaced return of float value with -(x + 1) for com/lowagie/text/pdf/PdfChunk::width → NO_COVERAGE |
return font.width(value); |
524 | } | |
525 | | |
526 | /** | |
527 | * Checks if the <CODE>PdfChunk</CODE> split was caused by a newline. | |
528 | * @return <CODE>true</CODE> if the <CODE>PdfChunk</CODE> split was caused by a newline. | |
529 | */ | |
530 | | |
531 | public boolean isNewlineSplit() | |
532 | { | |
533 | return newlineSplit; | |
534 | } | |
535 | | |
536 | /** | |
537 | * Gets the width of the <CODE>PdfChunk</CODE> taking into account the | |
538 | * extra character and word spacing. | |
539 | * @param charSpacing the extra character spacing | |
540 | * @param wordSpacing the extra word spacing | |
541 | * @return the calculated width | |
542 | */ | |
543 | | |
544 | public float getWidthCorrected(float charSpacing, float wordSpacing) | |
545 | { | |
546 |
1
1. getWidthCorrected : negated conditional → NO_COVERAGE |
if (image != null) { |
547 |
2
1. getWidthCorrected : Replaced float addition with subtraction → NO_COVERAGE 2. getWidthCorrected : replaced return of float value with -(x + 1) for com/lowagie/text/pdf/PdfChunk::getWidthCorrected → NO_COVERAGE |
return image.getScaledWidth() + charSpacing; |
548 | } | |
549 | int numberOfSpaces = 0; | |
550 | int idx = -1; | |
551 |
3
1. getWidthCorrected : changed conditional boundary → NO_COVERAGE 2. getWidthCorrected : Replaced integer addition with subtraction → NO_COVERAGE 3. getWidthCorrected : negated conditional → NO_COVERAGE |
while ((idx = value.indexOf(' ', idx + 1)) >= 0) |
552 |
1
1. getWidthCorrected : Changed increment from 1 to -1 → NO_COVERAGE |
++numberOfSpaces; |
553 |
5
1. getWidthCorrected : Replaced float multiplication with division → NO_COVERAGE 2. getWidthCorrected : Replaced float multiplication with division → NO_COVERAGE 3. getWidthCorrected : Replaced float addition with subtraction → NO_COVERAGE 4. getWidthCorrected : Replaced float addition with subtraction → NO_COVERAGE 5. getWidthCorrected : replaced return of float value with -(x + 1) for com/lowagie/text/pdf/PdfChunk::getWidthCorrected → NO_COVERAGE |
return width() + (value.length() * charSpacing + numberOfSpaces * wordSpacing); |
554 | } | |
555 | | |
556 | /** | |
557 | * Gets the text displacement relative to the baseline. | |
558 | * @return a displacement in points | |
559 | */ | |
560 | public float getTextRise() { | |
561 | Float f = (Float) getAttribute(Chunk.SUBSUPSCRIPT); | |
562 |
1
1. getTextRise : negated conditional → NO_COVERAGE |
if (f != null) { |
563 |
1
1. getTextRise : replaced return of float value with -(x + 1) for com/lowagie/text/pdf/PdfChunk::getTextRise → NO_COVERAGE |
return f; |
564 | } | |
565 |
1
1. getTextRise : replaced return of float value with -(x + 1) for com/lowagie/text/pdf/PdfChunk::getTextRise → NO_COVERAGE |
return 0.0f; |
566 | } | |
567 | | |
568 | /** | |
569 | * Trims the last space. | |
570 | * @return the width of the space trimmed, otherwise 0 | |
571 | */ | |
572 | | |
573 | public float trimLastSpace() | |
574 | { | |
575 | BaseFont ft = font.getFont(); | |
576 |
2
1. trimLastSpace : negated conditional → NO_COVERAGE 2. trimLastSpace : negated conditional → NO_COVERAGE |
if (ft.getFontType() == BaseFont.FONT_TYPE_CJK && ft.getUnicodeEquivalent(' ') != ' ') { |
577 |
3
1. trimLastSpace : changed conditional boundary → NO_COVERAGE 2. trimLastSpace : negated conditional → NO_COVERAGE 3. trimLastSpace : negated conditional → NO_COVERAGE |
if (value.length() > 1 && value.endsWith("\u0001")) { |
578 |
1
1. trimLastSpace : Replaced integer subtraction with addition → NO_COVERAGE |
value = value.substring(0, value.length() - 1); |
579 |
1
1. trimLastSpace : replaced return of float value with -(x + 1) for com/lowagie/text/pdf/PdfChunk::trimLastSpace → NO_COVERAGE |
return font.width('\u0001'); |
580 | } | |
581 | } | |
582 | else { | |
583 |
3
1. trimLastSpace : changed conditional boundary → NO_COVERAGE 2. trimLastSpace : negated conditional → NO_COVERAGE 3. trimLastSpace : negated conditional → NO_COVERAGE |
if (value.length() > 1 && value.endsWith(" ")) { |
584 |
1
1. trimLastSpace : Replaced integer subtraction with addition → NO_COVERAGE |
value = value.substring(0, value.length() - 1); |
585 |
1
1. trimLastSpace : replaced return of float value with -(x + 1) for com/lowagie/text/pdf/PdfChunk::trimLastSpace → NO_COVERAGE |
return font.width(' '); |
586 | } | |
587 | } | |
588 |
1
1. trimLastSpace : replaced return of float value with -(x + 1) for com/lowagie/text/pdf/PdfChunk::trimLastSpace → NO_COVERAGE |
return 0; |
589 | } | |
590 | public float trimFirstSpace() | |
591 | { | |
592 | BaseFont ft = font.getFont(); | |
593 |
2
1. trimFirstSpace : negated conditional → NO_COVERAGE 2. trimFirstSpace : negated conditional → NO_COVERAGE |
if (ft.getFontType() == BaseFont.FONT_TYPE_CJK && ft.getUnicodeEquivalent(' ') != ' ') { |
594 |
3
1. trimFirstSpace : changed conditional boundary → NO_COVERAGE 2. trimFirstSpace : negated conditional → NO_COVERAGE 3. trimFirstSpace : negated conditional → NO_COVERAGE |
if (value.length() > 1 && value.startsWith("\u0001")) { |
595 | value = value.substring(1); | |
596 |
1
1. trimFirstSpace : replaced return of float value with -(x + 1) for com/lowagie/text/pdf/PdfChunk::trimFirstSpace → NO_COVERAGE |
return font.width('\u0001'); |
597 | } | |
598 | } | |
599 | else { | |
600 |
3
1. trimFirstSpace : changed conditional boundary → NO_COVERAGE 2. trimFirstSpace : negated conditional → NO_COVERAGE 3. trimFirstSpace : negated conditional → NO_COVERAGE |
if (value.length() > 1 && value.startsWith(" ")) { |
601 | value = value.substring(1); | |
602 |
1
1. trimFirstSpace : replaced return of float value with -(x + 1) for com/lowagie/text/pdf/PdfChunk::trimFirstSpace → NO_COVERAGE |
return font.width(' '); |
603 | } | |
604 | } | |
605 |
1
1. trimFirstSpace : replaced return of float value with -(x + 1) for com/lowagie/text/pdf/PdfChunk::trimFirstSpace → NO_COVERAGE |
return 0; |
606 | } | |
607 | | |
608 | /** | |
609 | * Gets an attribute. The search is made in <CODE>attributes</CODE> | |
610 | * and <CODE>noStroke</CODE>. | |
611 | * @param name the attribute key | |
612 | * @return the attribute value or null if not found | |
613 | */ | |
614 | | |
615 | Object getAttribute(String name) | |
616 | { | |
617 |
1
1. getAttribute : negated conditional → NO_COVERAGE |
if (attributes.containsKey(name)) |
618 |
1
1. getAttribute : mutated return of Object value for com/lowagie/text/pdf/PdfChunk::getAttribute to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return attributes.get(name); |
619 |
1
1. getAttribute : mutated return of Object value for com/lowagie/text/pdf/PdfChunk::getAttribute to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return noStroke.get(name); |
620 | } | |
621 | | |
622 | /** | |
623 | *Checks if the attribute exists. | |
624 | * @param name the attribute key | |
625 | * @return <CODE>true</CODE> if the attribute exists | |
626 | */ | |
627 | | |
628 | boolean isAttribute(String name) | |
629 | { | |
630 |
1
1. isAttribute : negated conditional → NO_COVERAGE |
if (attributes.containsKey(name)) |
631 |
1
1. isAttribute : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return true; |
632 |
1
1. isAttribute : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return noStroke.containsKey(name); |
633 | } | |
634 | | |
635 | /** | |
636 | * Checks if this <CODE>PdfChunk</CODE> needs some special metrics handling. | |
637 | * @return <CODE>true</CODE> if this <CODE>PdfChunk</CODE> needs some special metrics handling. | |
638 | */ | |
639 | | |
640 | boolean isStroked() | |
641 | { | |
642 |
2
1. isStroked : negated conditional → NO_COVERAGE 2. isStroked : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return (!attributes.isEmpty()); |
643 | } | |
644 | | |
645 | /** | |
646 | * Checks if this <CODE>PdfChunk</CODE> is a Separator Chunk. | |
647 | * @return true if this chunk is a separator. | |
648 | * @since 2.1.2 | |
649 | */ | |
650 | boolean isSeparator() { | |
651 |
1
1. isSeparator : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return isAttribute(Chunk.SEPARATOR); |
652 | } | |
653 | | |
654 | /** | |
655 | * Checks if this <CODE>PdfChunk</CODE> is a horizontal Separator Chunk. | |
656 | * @return true if this chunk is a horizontal separator. | |
657 | * @since 2.1.2 | |
658 | */ | |
659 | boolean isHorizontalSeparator() { | |
660 |
1
1. isHorizontalSeparator : negated conditional → NO_COVERAGE |
if (isAttribute(Chunk.SEPARATOR)) { |
661 | Object[] o = (Object[])getAttribute(Chunk.SEPARATOR); | |
662 |
2
1. isHorizontalSeparator : negated conditional → NO_COVERAGE 2. isHorizontalSeparator : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return !(Boolean) o[1]; |
663 | } | |
664 |
1
1. isHorizontalSeparator : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
665 | } | |
666 | | |
667 | /** | |
668 | * Checks if this <CODE>PdfChunk</CODE> is a tab Chunk. | |
669 | * @return true if this chunk is a separator. | |
670 | * @since 2.1.2 | |
671 | */ | |
672 | boolean isTab() { | |
673 |
1
1. isTab : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return isAttribute(Chunk.TAB); |
674 | } | |
675 | | |
676 | /** | |
677 | * Correction for the tab position based on the left starting position. | |
678 | * @param newValue the new value for the left X. | |
679 | * @since 2.1.2 | |
680 | */ | |
681 | void adjustLeft(float newValue) { | |
682 | Object[] o = (Object[])attributes.get(Chunk.TAB); | |
683 |
1
1. adjustLeft : negated conditional → NO_COVERAGE |
if (o != null) { |
684 | attributes.put(Chunk.TAB, new Object[]{o[0], o[1], o[2], newValue}); | |
685 | } | |
686 | } | |
687 | | |
688 | /** | |
689 | * Checks if there is an image in the <CODE>PdfChunk</CODE>. | |
690 | * @return <CODE>true</CODE> if an image is present | |
691 | */ | |
692 | | |
693 | boolean isImage() | |
694 | { | |
695 |
2
1. isImage : negated conditional → NO_COVERAGE 2. isImage : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return image != null; |
696 | } | |
697 | | |
698 | /** | |
699 | * Gets the image in the <CODE>PdfChunk</CODE>. | |
700 | * @return the image or <CODE>null</CODE> | |
701 | */ | |
702 | | |
703 | Image getImage() | |
704 | { | |
705 | return image; | |
706 | } | |
707 | | |
708 | /** | |
709 | * Sets the image offset in the x direction | |
710 | * @param offsetX the image offset in the x direction | |
711 | */ | |
712 | | |
713 | void setImageOffsetX(float offsetX) | |
714 | { | |
715 | this.offsetX = offsetX; | |
716 | } | |
717 | | |
718 | /** | |
719 | * Gets the image offset in the x direction | |
720 | * @return the image offset in the x direction | |
721 | */ | |
722 | | |
723 | float getImageOffsetX() | |
724 | { | |
725 | return offsetX; | |
726 | } | |
727 | | |
728 | /** | |
729 | * Sets the image offset in the y direction | |
730 | * @param offsetY the image offset in the y direction | |
731 | */ | |
732 | | |
733 | void setImageOffsetY(float offsetY) | |
734 | { | |
735 | this.offsetY = offsetY; | |
736 | } | |
737 | | |
738 | /** | |
739 | * Gets the image offset in the y direction | |
740 | * @return Gets the image offset in the y direction | |
741 | */ | |
742 | | |
743 | float getImageOffsetY() | |
744 | { | |
745 | return offsetY; | |
746 | } | |
747 | | |
748 | /** | |
749 | * sets the value. | |
750 | * @param value content of the Chunk | |
751 | */ | |
752 | | |
753 | void setValue(String value) | |
754 | { | |
755 | this.value = value; | |
756 | } | |
757 | ||
758 | /** | |
759 | * @see java.lang.Object#toString() | |
760 | */ | |
761 | public String toString() { | |
762 | return value; | |
763 | } | |
764 | ||
765 | /** | |
766 | * Tells you if this string is in Chinese, Japanese, Korean or Identity-H. | |
767 | * @return true if the Chunk has a special encoding | |
768 | */ | |
769 | | |
770 | boolean isSpecialEncoding() { | |
771 |
3
1. isSpecialEncoding : negated conditional → NO_COVERAGE 2. isSpecialEncoding : negated conditional → NO_COVERAGE 3. isSpecialEncoding : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return encoding.equals(CJKFont.CJK_ENCODING) || encoding.equals(BaseFont.IDENTITY_H); |
772 | } | |
773 | | |
774 | /** | |
775 | * Gets the encoding of this string. | |
776 | * | |
777 | * @return a <CODE>String</CODE> | |
778 | */ | |
779 | | |
780 | String getEncoding() { | |
781 | return encoding; | |
782 | } | |
783 | ||
784 | int length() { | |
785 | return value.length(); | |
786 | } | |
787 | | |
788 | int lengthUtf32() { | |
789 |
1
1. lengthUtf32 : negated conditional → NO_COVERAGE |
if (!BaseFont.IDENTITY_H.equals(encoding)) |
790 |
1
1. lengthUtf32 : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return value.length(); |
791 | int total = 0; | |
792 | int len = value.length(); | |
793 |
3
1. lengthUtf32 : changed conditional boundary → NO_COVERAGE 2. lengthUtf32 : Changed increment from 1 to -1 → NO_COVERAGE 3. lengthUtf32 : negated conditional → NO_COVERAGE |
for (int k = 0; k < len; ++k) { |
794 |
1
1. lengthUtf32 : negated conditional → NO_COVERAGE |
if (Utilities.isSurrogateHigh(value.charAt(k))) |
795 |
1
1. lengthUtf32 : Changed increment from 1 to -1 → NO_COVERAGE |
++k; |
796 |
1
1. lengthUtf32 : Changed increment from 1 to -1 → NO_COVERAGE |
++total; |
797 | } | |
798 |
1
1. lengthUtf32 : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return total; |
799 | } | |
800 | | |
801 | boolean isExtSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck) { | |
802 | return splitCharacter.isSplitCharacter(start, current, end, cc, ck); | |
803 | } | |
804 | | |
805 | /** | |
806 | * Removes all the <VAR>' '</VAR> and <VAR>'-'</VAR>-characters on the right of a <CODE>String</CODE>. | |
807 | * <P> | |
808 | * @param string the <CODE>String<CODE> that has to be trimmed. | |
809 | * @return the trimmed <CODE>String</CODE> | |
810 | */ | |
811 | String trim(String string) { | |
812 | BaseFont ft = font.getFont(); | |
813 |
2
1. trim : negated conditional → NO_COVERAGE 2. trim : negated conditional → NO_COVERAGE |
if (ft.getFontType() == BaseFont.FONT_TYPE_CJK && ft.getUnicodeEquivalent(' ') != ' ') { |
814 |
1
1. trim : negated conditional → NO_COVERAGE |
while (string.endsWith("\u0001")) { |
815 |
1
1. trim : Replaced integer subtraction with addition → NO_COVERAGE |
string = string.substring(0, string.length() - 1); |
816 | } | |
817 | } | |
818 | else { | |
819 |
2
1. trim : negated conditional → NO_COVERAGE 2. trim : negated conditional → NO_COVERAGE |
while (string.endsWith(" ") || string.endsWith("\t")) { |
820 |
1
1. trim : Replaced integer subtraction with addition → NO_COVERAGE |
string = string.substring(0, string.length() - 1); |
821 | } | |
822 | } | |
823 |
1
1. trim : mutated return of Object value for com/lowagie/text/pdf/PdfChunk::trim to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return string; |
824 | } | |
825 | ||
826 | public boolean changeLeading() { | |
827 | return changeLeading; | |
828 | } | |
829 | | |
830 | float getCharWidth(int c) { | |
831 |
1
1. getCharWidth : negated conditional → NO_COVERAGE |
if (noPrint(c)) |
832 |
1
1. getCharWidth : replaced return of float value with -(x + 1) for com/lowagie/text/pdf/PdfChunk::getCharWidth → NO_COVERAGE |
return 0; |
833 |
1
1. getCharWidth : negated conditional → NO_COVERAGE |
if (isAttribute(Chunk.CHAR_SPACING)) { |
834 | Float cs = (Float) getAttribute(Chunk.CHAR_SPACING); | |
835 |
2
1. getCharWidth : Replaced float addition with subtraction → NO_COVERAGE 2. getCharWidth : replaced return of float value with -(x + 1) for com/lowagie/text/pdf/PdfChunk::getCharWidth → NO_COVERAGE |
return font.width(c) + cs; |
836 | } | |
837 |
1
1. getCharWidth : replaced return of float value with -(x + 1) for com/lowagie/text/pdf/PdfChunk::getCharWidth → NO_COVERAGE |
return font.width(c); |
838 | } | |
839 | | |
840 | public static boolean noPrint(int c) { | |
841 |
9
1. noPrint : changed conditional boundary → NO_COVERAGE 2. noPrint : changed conditional boundary → NO_COVERAGE 3. noPrint : changed conditional boundary → NO_COVERAGE 4. noPrint : changed conditional boundary → NO_COVERAGE 5. noPrint : negated conditional → NO_COVERAGE 6. noPrint : negated conditional → NO_COVERAGE 7. noPrint : negated conditional → NO_COVERAGE 8. noPrint : negated conditional → NO_COVERAGE 9. noPrint : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return ((c >= 0x200b && c <= 0x200f) || (c >= 0x202a && c <= 0x202e)); |
842 | } | |
843 | | |
844 | } | |
Mutations | ||
169 |
1.1 |
|
179 |
1.1 |
|
196 |
1.1 |
|
200 |
1.1 |
|
203 |
1.1 |
|
209 |
1.1 2.2 |
|
210 |
1.1 |
|
212 |
1.1 2.2 |
|
218 |
1.1 |
|
221 |
1.1 |
|
223 |
1.1 |
|
227 |
1.1 |
|
231 |
1.1 |
|
236 |
1.1 |
|
241 |
1.1 |
|
247 |
1.1 |
|
257 |
1.1 |
|
259 |
1.1 |
|
260 |
1.1 |
|
263 |
1.1 |
|
281 |
1.1 2.2 |
|
282 |
1.1 |
|
284 |
1.1 |
|
286 |
1.1 |
|
300 |
1.1 |
|
301 |
1.1 2.2 |
|
307 |
1.1 |
|
310 |
1.1 |
|
326 |
1.1 2.2 |
|
327 |
1.1 2.2 |
|
332 |
1.1 |
|
334 |
1.1 |
|
336 |
1.1 2.2 |
|
339 |
1.1 |
|
341 |
1.1 |
|
342 |
1.1 |
|
343 |
1.1 |
|
346 |
1.1 2.2 |
|
349 |
1.1 |
|
350 |
1.1 |
|
351 |
1.1 |
|
355 |
1.1 2.2 |
|
359 |
1.1 2.2 |
|
362 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
364 |
1.1 |
|
366 |
1.1 2.2 |
|
369 |
1.1 |
|
372 |
1.1 |
|
373 |
1.1 2.2 |
|
375 |
1.1 |
|
376 |
1.1 |
|
377 |
1.1 |
|
380 |
1.1 |
|
381 |
1.1 |
|
382 |
1.1 2.2 |
|
385 |
1.1 |
|
386 |
1.1 |
|
387 |
1.1 |
|
392 |
1.1 |
|
393 |
1.1 |
|
396 |
1.1 2.2 |
|
399 |
1.1 |
|
401 |
1.1 2.2 3.3 |
|
403 |
1.1 2.2 3.3 4.4 5.5 |
|
405 |
1.1 2.2 |
|
406 |
1.1 |
|
408 |
1.1 2.2 |
|
411 |
1.1 |
|
417 |
1.1 |
|
430 |
1.1 |
|
431 |
1.1 2.2 |
|
437 |
1.1 |
|
440 |
1.1 |
|
447 |
1.1 2.2 |
|
450 |
1.1 |
|
458 |
1.1 2.2 |
|
461 |
1.1 |
|
462 |
1.1 |
|
464 |
1.1 |
|
465 |
1.1 2.2 |
|
467 |
1.1 |
|
468 |
1.1 |
|
469 |
1.1 |
|
473 |
1.1 |
|
474 |
1.1 |
|
480 |
1.1 |
|
482 |
1.1 |
|
483 |
1.1 |
|
487 |
1.1 |
|
509 |
1.1 |
|
519 |
1.1 |
|
521 |
1.1 2.2 3.3 |
|
523 |
1.1 |
|
546 |
1.1 |
|
547 |
1.1 2.2 |
|
551 |
1.1 2.2 3.3 |
|
552 |
1.1 |
|
553 |
1.1 2.2 3.3 4.4 5.5 |
|
562 |
1.1 |
|
563 |
1.1 |
|
565 |
1.1 |
|
576 |
1.1 2.2 |
|
577 |
1.1 2.2 3.3 |
|
578 |
1.1 |
|
579 |
1.1 |
|
583 |
1.1 2.2 3.3 |
|
584 |
1.1 |
|
585 |
1.1 |
|
588 |
1.1 |
|
593 |
1.1 2.2 |
|
594 |
1.1 2.2 3.3 |
|
596 |
1.1 |
|
600 |
1.1 2.2 3.3 |
|
602 |
1.1 |
|
605 |
1.1 |
|
617 |
1.1 |
|
618 |
1.1 |
|
619 |
1.1 |
|
630 |
1.1 |
|
631 |
1.1 |
|
632 |
1.1 |
|
642 |
1.1 2.2 |
|
651 |
1.1 |
|
660 |
1.1 |
|
662 |
1.1 2.2 |
|
664 |
1.1 |
|
673 |
1.1 |
|
683 |
1.1 |
|
695 |
1.1 2.2 |
|
771 |
1.1 2.2 3.3 |
|
789 |
1.1 |
|
790 |
1.1 |
|
793 |
1.1 2.2 3.3 |
|
794 |
1.1 |
|
795 |
1.1 |
|
796 |
1.1 |
|
798 |
1.1 |
|
813 |
1.1 2.2 |
|
814 |
1.1 |
|
815 |
1.1 |
|
819 |
1.1 2.2 |
|
820 |
1.1 |
|
823 |
1.1 |
|
831 |
1.1 |
|
832 |
1.1 |
|
833 |
1.1 |
|
835 |
1.1 2.2 |
|
837 |
1.1 |
|
841 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 |