1 | /* | |
2 | dgd: com.lowagie.text.pdf.parser | |
3 | <p> | |
4 | Copyright 2005 by David G. Durand. | |
5 | <p> | |
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 | <p> | |
14 | The Original Code is 'iText, a free JAVA-PDF library'. | |
15 | <p> | |
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 | <p> | |
22 | Contributor(s): all the names of the contributors are added in the source code | |
23 | where applicable. | |
24 | <p> | |
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 | <p> | |
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 | <p> | |
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 | package com.lowagie.text.pdf.parser; | |
46 | ||
47 | import com.lowagie.text.pdf.BaseFont; | |
48 | import com.lowagie.text.pdf.CMapAwareDocumentFont; | |
49 | import com.lowagie.text.pdf.PdfReader; | |
50 | import com.lowagie.text.pdf.PdfString; | |
51 | ||
52 | import javax.annotation.Nonnull; | |
53 | import javax.annotation.Nullable; | |
54 | import java.nio.charset.StandardCharsets; | |
55 | import java.util.ArrayList; | |
56 | import java.util.List; | |
57 | import java.util.Optional; | |
58 | ||
59 | /** | |
60 | * @author dgd | |
61 | */ | |
62 | public class ParsedText extends ParsedTextImpl { | |
63 | ||
64 | private final Matrix textToUserSpaceTransformMatrix; | |
65 | private final GraphicsState graphicsState; | |
66 | ||
67 | /** | |
68 | * retain original PdfString as we need to distinguish between the code points contained there, | |
69 | * and the standard Java (Unicode strings) that actually represent the content of this text. | |
70 | */ | |
71 | private PdfString pdfText = null; | |
72 | ||
73 | /** | |
74 | * This constructor should only be called when the origin for text display is at (0,0) and the | |
75 | * graphical state reflects all transformations of the baseline. This is in text space units. | |
76 | * <p> | |
77 | * Decodes a String (which will contain glyph ids encoded in the font's encoding) based on | |
78 | * the active font. This is supported for compatibility, but is no longer preferred. | |
79 | * | |
80 | * @param text string | |
81 | * @param graphicsState graphical state | |
82 | * @param textMatrix transform from text space to graphics (drawing space) | |
83 | */ | |
84 | @Deprecated | |
85 | ParsedText(String text, GraphicsState graphicsState, Matrix textMatrix) { | |
86 | this(text, new GraphicsState(graphicsState), textMatrix.multiply(graphicsState.getCtm()), | |
87 | getUnscaledFontSpaceWidth(graphicsState)); | |
88 | } | |
89 | ||
90 | /** | |
91 | * This constructor should only be called when the origin for text display is at (0,0) and the | |
92 | * graphical state reflects all transformations of the baseline. This is in text space units. | |
93 | * | |
94 | * @param text string | |
95 | * @param graphicsState graphical state | |
96 | * @param textMatrix transform from text space to graphics (drawing space) | |
97 | */ | |
98 | ParsedText(PdfString text, GraphicsState graphicsState, Matrix textMatrix) { | |
99 | this(text, new GraphicsState(graphicsState), textMatrix.multiply(graphicsState.getCtm()), | |
100 | getUnscaledFontSpaceWidth(graphicsState)); | |
101 | } | |
102 | ||
103 | /** | |
104 | * Internal constructor for a parsed text item. The constructors that call it | |
105 | * gather some information from the graphical state first. | |
106 | * | |
107 | * @param text This is a PdfString containing code points for the current font, not actually characters. | |
108 | * If the font has multiByte glyphs, (Identity-H encoding) we reparse the string so that the code | |
109 | * points don't get split into multiple characters. | |
110 | * @param graphicsState graphical state | |
111 | * @param textMatrix transform from text space to graphics (drawing space) | |
112 | * @param unscaledWidth width of the space character in the font. | |
113 | */ | |
114 | private ParsedText(PdfString text, GraphicsState graphicsState, Matrix textMatrix, float unscaledWidth) { | |
115 | super(null, pointToUserSpace(0, 0, textMatrix), | |
116 | pointToUserSpace(getStringWidth(text.toString(), graphicsState), 0f, textMatrix), | |
117 | pointToUserSpace(1.0f, 0f, textMatrix), | |
118 | convertHeightToUser(graphicsState.getFontAscentDescriptor(), textMatrix), | |
119 | convertHeightToUser(graphicsState.getFontDescentDescriptor(), textMatrix), | |
120 | convertWidthToUser(unscaledWidth, textMatrix)); | |
121 |
1
1. |
if (BaseFont.IDENTITY_H.equals(graphicsState.getFont().getEncoding())) { |
122 | pdfText = new PdfString(new String(text.getBytes(), StandardCharsets.UTF_16)); | |
123 | } else { | |
124 | pdfText = text; | |
125 | } | |
126 | textToUserSpaceTransformMatrix = textMatrix; | |
127 | this.graphicsState = graphicsState; | |
128 | } | |
129 | ||
130 | /** | |
131 | * Internal constructor when the code points are already in a string. | |
132 | * | |
133 | * @param text string | |
134 | * @param graphicsState graphical state | |
135 | * @param textMatrix transform from text space to graphics (drawing space) | |
136 | * @param unscaledWidth width of the space character in the font. | |
137 | */ | |
138 | @Deprecated | |
139 | private ParsedText(String text, GraphicsState graphicsState, Matrix textMatrix, float unscaledWidth) { | |
140 | super(text, pointToUserSpace(0, 0, textMatrix), | |
141 | pointToUserSpace(getStringWidth(text, graphicsState), 0f, textMatrix), | |
142 | pointToUserSpace(1.0f, 0f, textMatrix), | |
143 | convertHeightToUser(graphicsState.getFontAscentDescriptor(), textMatrix), | |
144 | convertHeightToUser(graphicsState.getFontDescentDescriptor(), textMatrix), | |
145 | convertWidthToUser(unscaledWidth, textMatrix)); | |
146 | textToUserSpaceTransformMatrix = textMatrix; | |
147 | this.graphicsState = graphicsState; | |
148 | } | |
149 | ||
150 | /** | |
151 | * @param xOffset | |
152 | * @param yOffset | |
153 | * @param textToUserSpaceTransformMatrix | |
154 | * @return | |
155 | */ | |
156 | private static Vector pointToUserSpace(float xOffset, float yOffset, | |
157 | Matrix textToUserSpaceTransformMatrix) { | |
158 |
1
1. pointToUserSpace : mutated return of Object value for com/lowagie/text/pdf/parser/ParsedText::pointToUserSpace to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new Vector(xOffset, yOffset, 1f) |
159 | .cross(textToUserSpaceTransformMatrix); | |
160 | } | |
161 | ||
162 | /** | |
163 | * Calculates the width of a space character. If the font does not define a | |
164 | * width for a standard space character , we also attempt to use the width | |
165 | * of \u00A0 (a non-breaking space in many fonts) | |
166 | * | |
167 | * @param graphicsState graphic state including current transformation to page coordinates from | |
168 | * text measurement | |
169 | * @return the width of a single space character in text space units | |
170 | */ | |
171 | private static float getUnscaledFontSpaceWidth(GraphicsState graphicsState) { | |
172 | char charToUse = ' '; | |
173 |
1
1. getUnscaledFontSpaceWidth : negated conditional → NO_COVERAGE |
if (graphicsState.getFont().getWidth(charToUse) == 0) { |
174 | charToUse = '\u00A0'; | |
175 | } | |
176 |
1
1. getUnscaledFontSpaceWidth : replaced return of float value with -(x + 1) for com/lowagie/text/pdf/parser/ParsedText::getUnscaledFontSpaceWidth → NO_COVERAGE |
return getStringWidth(String.valueOf(charToUse), graphicsState); |
177 | } | |
178 | ||
179 | /** | |
180 | * Gets the width of a String in text space units | |
181 | * | |
182 | * @param string the string that needs measuring | |
183 | * @param graphicsState graphic state including current transformation to page coordinates from | |
184 | * text measurement | |
185 | * @return the width of a String in text space units | |
186 | */ | |
187 | private static float getStringWidth(String string, GraphicsState graphicsState) { | |
188 | char[] chars = string.toCharArray(); | |
189 | float totalWidth = 0; | |
190 | for (char c : chars) { | |
191 |
1
1. getStringWidth : Replaced float division with multiplication → NO_COVERAGE |
float w = graphicsState.getFont().getWidth(c) / 1000.0f; |
192 |
1
1. getStringWidth : negated conditional → NO_COVERAGE |
float wordSpacing = Character.isSpaceChar(c) ? graphicsState.getWordSpacing() : 0f; |
193 |
3
1. getStringWidth : Replaced float multiplication with division → NO_COVERAGE 2. getStringWidth : Replaced float addition with subtraction → NO_COVERAGE 3. getStringWidth : Replaced float addition with subtraction → NO_COVERAGE |
totalWidth += (w * graphicsState.getFontSize() + graphicsState.getCharacterSpacing() + wordSpacing) |
194 |
2
1. getStringWidth : Replaced float multiplication with division → NO_COVERAGE 2. getStringWidth : Replaced float addition with subtraction → NO_COVERAGE |
* graphicsState.getHorizontalScaling(); |
195 | } | |
196 | ||
197 |
1
1. getStringWidth : replaced return of float value with -(x + 1) for com/lowagie/text/pdf/parser/ParsedText::getStringWidth → NO_COVERAGE |
return totalWidth; |
198 | } | |
199 | ||
200 | /** | |
201 | * @param width | |
202 | * @param textToUserSpaceTransformMatrix | |
203 | * @return | |
204 | */ | |
205 | private static float convertWidthToUser(float width, | |
206 | Matrix textToUserSpaceTransformMatrix) { | |
207 | Vector startPos = pointToUserSpace(0, 0, textToUserSpaceTransformMatrix); | |
208 | Vector endPos = pointToUserSpace(width, 0, | |
209 | textToUserSpaceTransformMatrix); | |
210 |
1
1. convertWidthToUser : replaced return of float value with -(x + 1) for com/lowagie/text/pdf/parser/ParsedText::convertWidthToUser → NO_COVERAGE |
return distance(startPos, endPos); |
211 | } | |
212 | ||
213 | /** | |
214 | * @param startPos | |
215 | * @param endPos | |
216 | * @return | |
217 | */ | |
218 | private static float distance(Vector startPos, Vector endPos) { | |
219 |
1
1. distance : replaced return of float value with -(x + 1) for com/lowagie/text/pdf/parser/ParsedText::distance → NO_COVERAGE |
return endPos.subtract(startPos).length(); |
220 | } | |
221 | ||
222 | /** | |
223 | * @param height | |
224 | * @param textToUserSpaceTransformMatrix | |
225 | * @return | |
226 | */ | |
227 | private static float convertHeightToUser(float height, | |
228 | Matrix textToUserSpaceTransformMatrix) { | |
229 | Vector startPos = pointToUserSpace(0, 0, textToUserSpaceTransformMatrix); | |
230 | Vector endPos = pointToUserSpace(0, height, | |
231 | textToUserSpaceTransformMatrix); | |
232 |
1
1. convertHeightToUser : replaced return of float value with -(x + 1) for com/lowagie/text/pdf/parser/ParsedText::convertHeightToUser → NO_COVERAGE |
return distance(endPos, startPos); |
233 | } | |
234 | ||
235 | /** | |
236 | * Decodes a Java String containing glyph ids encoded in the font's encoding, and determine the | |
237 | * unicode equivalent | |
238 | * | |
239 | * @param in the String that needs to be decoded | |
240 | * @return the decoded String | |
241 | */ | |
242 | // FIXME unreachable block and default encoding | |
243 | protected String decode(String in) { | |
244 | byte[] bytes; | |
245 |
1
1. decode : negated conditional → NO_COVERAGE |
if (BaseFont.IDENTITY_H.equals(graphicsState.getFont().getEncoding())) { |
246 | bytes = in.getBytes(StandardCharsets.UTF_16); | |
247 | } | |
248 | bytes = in.getBytes(); | |
249 |
1
1. decode : mutated return of Object value for com/lowagie/text/pdf/parser/ParsedText::decode to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return graphicsState.getFont().decode(bytes, 0, bytes.length); |
250 | } | |
251 | ||
252 | /** | |
253 | * This constructor should only be called when the origin for text display is at (0,0) and the | |
254 | * graphical state reflects all transformations of the baseline. This is in text space units. | |
255 | * <p> | |
256 | * Decodes a PdfString (which will contain glyph ids encoded in the font's encoding) based on | |
257 | * the active font, and determine the unicode equivalent | |
258 | * | |
259 | * @param pdfString the String that needs to be encoded | |
260 | * @return the encoded String | |
261 | * @since 2.1.7 | |
262 | */ | |
263 | protected String decode(PdfString pdfString) { | |
264 | byte[] bytes = pdfString.getOriginalBytes(); | |
265 |
1
1. decode : mutated return of Object value for com/lowagie/text/pdf/parser/ParsedText::decode to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return graphicsState.getFont().decode(bytes, 0, bytes.length); |
266 | } | |
267 | ||
268 | /** | |
269 | * Break this string if there are spaces within it. If so, we mark the new Words appropriately | |
270 | * for later assembly. | |
271 | * <p> | |
272 | * We are guaranteed that every space (internal word break) in this parsed text object will | |
273 | * create a new word in the result of this method. We are not guaranteed that these Word objects | |
274 | * are actually words until they have been assembled. | |
275 | * <p> | |
276 | * The word following any space preserves that space in its string value, so that the assembler | |
277 | * will not erroneously merge words that should be separate, regardless of the spacing. | |
278 | * | |
279 | * @return list of Word objects. | |
280 | */ | |
281 | public List<Word> getAsPartialWords() { | |
282 | List<Word> result = new ArrayList<>(); | |
283 | CMapAwareDocumentFont font = graphicsState.getFont(); | |
284 | char[] chars = pdfText.getOriginalChars(); | |
285 | boolean[] hasSpace = new boolean[chars.length]; | |
286 | float totalWidth = 0; | |
287 | StringBuffer wordAccum = new StringBuffer(3); | |
288 | float wordStartOffset = 0; | |
289 | boolean wordsAreComplete = preprocessString(chars, hasSpace); | |
290 | // Set When a word is created by whitespace that occurred before it. | |
291 | boolean currentBreakBefore = false; | |
292 | /* go through string splitting at spaces, and calculating widths */ | |
293 |
3
1. getAsPartialWords : changed conditional boundary → NO_COVERAGE 2. getAsPartialWords : Changed increment from 1 to -1 → NO_COVERAGE 3. getAsPartialWords : negated conditional → NO_COVERAGE |
for (int i = 0; i < chars.length; i++) { |
294 | char c = chars[i]; | |
295 |
1
1. getAsPartialWords : Replaced float division with multiplication → NO_COVERAGE |
float w = font.getWidth(c) / 1000.0f; |
296 | ||
297 |
1
1. getAsPartialWords : negated conditional → NO_COVERAGE |
if (hasSpace[i]) { |
298 |
2
1. getAsPartialWords : changed conditional boundary → NO_COVERAGE 2. getAsPartialWords : negated conditional → NO_COVERAGE |
if (wordAccum.length() > 0) { |
299 | result.add(createWord(wordAccum, wordStartOffset, totalWidth, getBaseline(), | |
300 | wordsAreComplete, currentBreakBefore)); | |
301 | wordAccum = new StringBuffer(); | |
302 | } | |
303 |
1
1. getAsPartialWords : negated conditional → NO_COVERAGE |
if (!Character.isWhitespace(c)) { |
304 | wordStartOffset = totalWidth; | |
305 | } | |
306 |
1
1. getAsPartialWords : Replaced float addition with subtraction → NO_COVERAGE |
totalWidth += graphicsState.calculateCharacterWidthWithSpace(w); |
307 |
1
1. getAsPartialWords : negated conditional → NO_COVERAGE |
if (Character.isWhitespace(c)) { |
308 | wordStartOffset = totalWidth; | |
309 | } | |
310 | wordAccum.append(c); | |
311 | currentBreakBefore = true; // next word will be marked as result of a space-character break | |
312 | } else { | |
313 | wordAccum.append(c); | |
314 |
1
1. getAsPartialWords : Replaced float addition with subtraction → NO_COVERAGE |
totalWidth += graphicsState.calculateCharacterWidthWithoutSpace(w); |
315 | } | |
316 | } | |
317 |
2
1. getAsPartialWords : changed conditional boundary → NO_COVERAGE 2. getAsPartialWords : negated conditional → NO_COVERAGE |
if (wordAccum.length() > 0) { |
318 | result.add(createWord(wordAccum, wordStartOffset, totalWidth, getBaseline(), | |
319 | wordsAreComplete, currentBreakBefore)); | |
320 | } | |
321 |
1
1. getAsPartialWords : mutated return of Object value for com/lowagie/text/pdf/parser/ParsedText::getAsPartialWords to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return result; |
322 | } | |
323 | ||
324 | /** | |
325 | * Calculate whether individual character positions (after font decoding from code to a | |
326 | * character), contain spaces and break words, and whether the resulting words should be treated | |
327 | * as complete (i.e. if any spaces were found. | |
328 | * | |
329 | * @param chars to check | |
330 | * @param hasSpace array same length as chars, each position representing whether it breaks a word | |
331 | * @return true if any spaces were found. | |
332 | */ | |
333 | private boolean preprocessString(char[] chars, boolean[] hasSpace) { | |
334 | boolean wordsAreComplete = false; | |
335 |
3
1. preprocessString : changed conditional boundary → NO_COVERAGE 2. preprocessString : Changed increment from 1 to -1 → NO_COVERAGE 3. preprocessString : negated conditional → NO_COVERAGE |
for (int i = 0; i < chars.length; i++) { |
336 | char c = chars[i]; | |
337 | hasSpace[i] = false; | |
338 | String charValue = graphicsState.getFont().decode(c); | |
339 | ||
340 |
1
1. preprocessString : negated conditional → NO_COVERAGE |
if (charValue != null) |
341 | for (char cFinal : charValue.toCharArray()) { | |
342 |
1
1. preprocessString : negated conditional → NO_COVERAGE |
if (Character.isSpaceChar(cFinal)) { |
343 | wordsAreComplete = true; | |
344 | hasSpace[i] = true; | |
345 | } | |
346 | } | |
347 | } | |
348 |
1
1. preprocessString : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return wordsAreComplete; |
349 | } | |
350 | ||
351 | /** | |
352 | * Create a word to represent a broken substring at a space. As spaces have zero "word length" | |
353 | * make sure that they also have a baseline to check | |
354 | * | |
355 | * @param wordAccum buffer of characters | |
356 | * @param wordStartOffset intial x-offset | |
357 | * @param wordEndOffset ending x offset. | |
358 | * @param baseline baseline of this word, so direction of progress can be measured in line ending | |
359 | * determination. | |
360 | * @param wordsAreComplete true means characters in this word won't be split apart graphically | |
361 | * @param currentBreakBefore true if this word fragment represents a word boundary, and any preceding fragment | |
362 | * is complete. | |
363 | * @return the new word | |
364 | */ | |
365 | private Word createWord(StringBuffer wordAccum, | |
366 | float wordStartOffset, | |
367 | float wordEndOffset, | |
368 | Vector baseline, | |
369 | boolean wordsAreComplete, | |
370 | boolean currentBreakBefore) { | |
371 |
1
1. createWord : mutated return of Object value for com/lowagie/text/pdf/parser/ParsedText::createWord to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new Word(graphicsState.getFont().decode(wordAccum.toString()), getAscent(), getDescent(), |
372 | pointToUserSpace(wordStartOffset, 0f, textToUserSpaceTransformMatrix), | |
373 | pointToUserSpace(wordEndOffset, 0f, textToUserSpaceTransformMatrix), baseline, | |
374 | getSingleSpaceWidth(), wordsAreComplete, currentBreakBefore); | |
375 | } | |
376 | ||
377 | /** | |
378 | * @param gs graphic state including current transformation to page coordinates from text | |
379 | * measurement | |
380 | * @return the unscaled (i.e. in Text space) width of our text | |
381 | */ | |
382 | public float getUnscaledTextWidth(GraphicsState gs) { | |
383 |
1
1. getUnscaledTextWidth : replaced return of float value with -(x + 1) for com/lowagie/text/pdf/parser/ParsedText::getUnscaledTextWidth → NO_COVERAGE |
return getStringWidth(getFontCodes(), gs); |
384 | } | |
385 | ||
386 | /** | |
387 | * {@inheritDoc} | |
388 | * | |
389 | * @see com.lowagie.text.pdf.parser.TextAssemblyBuffer#accumulate(com.lowagie.text.pdf.parser.TextAssembler, String) | |
390 | */ | |
391 | @Override | |
392 | public void accumulate(TextAssembler textAssembler, String contextName) { | |
393 | textAssembler.process(this, contextName); | |
394 | } | |
395 | ||
396 | /** | |
397 | * {@inheritDoc} | |
398 | * | |
399 | * @see com.lowagie.text.pdf.parser.TextAssemblyBuffer#assemble(com.lowagie.text.pdf.parser.TextAssembler) | |
400 | */ | |
401 | @Override | |
402 | public void assemble(TextAssembler textAssembler) { | |
403 | textAssembler.renderText(this); | |
404 | } | |
405 | ||
406 | /** | |
407 | * when returning the text from this item, we need to decode the code points we have. | |
408 | * | |
409 | * @see com.lowagie.text.pdf.parser.ParsedTextImpl#getText() | |
410 | */ | |
411 | @Nullable | |
412 | @Override | |
413 | public String getText() { | |
414 | String text = super.getText(); | |
415 |
2
1. getText : negated conditional → NO_COVERAGE 2. getText : negated conditional → NO_COVERAGE |
if (text == null && pdfText != null) { |
416 |
1
1. getText : mutated return of Object value for com/lowagie/text/pdf/parser/ParsedText::getText to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return decode(pdfText); |
417 | } | |
418 |
1
1. getText : mutated return of Object value for com/lowagie/text/pdf/parser/ParsedText::getText to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return text; |
419 | } | |
420 | ||
421 | /** | |
422 | * @return a string whose characters represent code points in a possibly two-byte font | |
423 | */ | |
424 | @Nonnull | |
425 | public String getFontCodes() { | |
426 |
1
1. getFontCodes : mutated return of Object value for com/lowagie/text/pdf/parser/ParsedText::getFontCodes to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return Optional.ofNullable(pdfText) |
427 | .map(PdfString::toString) | |
428 | .orElse(""); | |
429 | } | |
430 | ||
431 | /** | |
432 | * @see com.lowagie.text.pdf.parser.TextAssemblyBuffer#getFinalText(com.lowagie.text.pdf.PdfReader, | |
433 | * int, com.lowagie.text.pdf.parser.TextAssembler, boolean) | |
434 | */ | |
435 | @Override | |
436 | public FinalText getFinalText(PdfReader reader, int page, TextAssembler assembler, boolean useMarkup) { | |
437 | throw new RuntimeException("Final text should never be called on unprocessed word fragment."); | |
438 | } | |
439 | ||
440 | /** | |
441 | * @see java.lang.Object#toString() | |
442 | */ | |
443 | @Override | |
444 | public String toString() { | |
445 | return "[ParsedText: [" + getText() + "] " + getStartPoint() + ", " + getEndPoint() + "] lead" + "]"; | |
446 | } | |
447 | ||
448 | /** | |
449 | * @see com.lowagie.text.pdf.parser.ParsedTextImpl#shouldNotSplit() | |
450 | */ | |
451 | @Override | |
452 | public boolean shouldNotSplit() { | |
453 | return false; | |
454 | } | |
455 | ||
456 | /** | |
457 | * @return | |
458 | * @see com.lowagie.text.pdf.parser.ParsedTextImpl#breakBefore() | |
459 | */ | |
460 | @Override | |
461 | public boolean breakBefore() { | |
462 | return false; | |
463 | } | |
464 | ||
465 | } | |
Mutations | ||
121 |
1.1 |
|
158 |
1.1 |
|
173 |
1.1 |
|
176 |
1.1 |
|
191 |
1.1 |
|
192 |
1.1 |
|
193 |
1.1 2.2 3.3 |
|
194 |
1.1 2.2 |
|
197 |
1.1 |
|
210 |
1.1 |
|
219 |
1.1 |
|
232 |
1.1 |
|
245 |
1.1 |
|
249 |
1.1 |
|
265 |
1.1 |
|
293 |
1.1 2.2 3.3 |
|
295 |
1.1 |
|
297 |
1.1 |
|
298 |
1.1 2.2 |
|
303 |
1.1 |
|
306 |
1.1 |
|
307 |
1.1 |
|
314 |
1.1 |
|
317 |
1.1 2.2 |
|
321 |
1.1 |
|
335 |
1.1 2.2 3.3 |
|
340 |
1.1 |
|
342 |
1.1 |
|
348 |
1.1 |
|
371 |
1.1 |
|
383 |
1.1 |
|
415 |
1.1 2.2 |
|
416 |
1.1 |
|
418 |
1.1 |
|
426 |
1.1 |