1 | /* | |
2 | * $Id: PdfViewerPreferencesImp.java 3867 2009-04-17 17:49:57Z blowagie $ | |
3 | * | |
4 | * Copyright 2006 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.internal; | |
51 | ||
52 | import com.lowagie.text.pdf.PdfArray; | |
53 | import com.lowagie.text.pdf.PdfBoolean; | |
54 | import com.lowagie.text.pdf.PdfDictionary; | |
55 | import com.lowagie.text.pdf.PdfName; | |
56 | import com.lowagie.text.pdf.PdfNumber; | |
57 | import com.lowagie.text.pdf.PdfObject; | |
58 | import com.lowagie.text.pdf.PdfReader; | |
59 | import com.lowagie.text.pdf.PdfWriter; | |
60 | import com.lowagie.text.pdf.interfaces.PdfViewerPreferences; | |
61 | ||
62 | /** | |
63 | * Stores the information concerning viewer preferences, | |
64 | * and contains the business logic that allows you to set viewer preferences. | |
65 | */ | |
66 | ||
67 | public class PdfViewerPreferencesImp implements PdfViewerPreferences { | |
68 | public static final PdfName[] VIEWER_PREFERENCES = { | |
69 | PdfName.HIDETOOLBAR, // 0 | |
70 | PdfName.HIDEMENUBAR, // 1 | |
71 | PdfName.HIDEWINDOWUI, // 2 | |
72 | PdfName.FITWINDOW, // 3 | |
73 | PdfName.CENTERWINDOW, // 4 | |
74 | PdfName.DISPLAYDOCTITLE, // 5 | |
75 | PdfName.NONFULLSCREENPAGEMODE, // 6 | |
76 | PdfName.DIRECTION, // 7 | |
77 | PdfName.VIEWAREA, // 8 | |
78 | PdfName.VIEWCLIP, // 9 | |
79 | PdfName.PRINTAREA, // 10 | |
80 | PdfName.PRINTCLIP, // 11 | |
81 | PdfName.PRINTSCALING, // 12 | |
82 | PdfName.DUPLEX, // 13 | |
83 | PdfName.PICKTRAYBYPDFSIZE, // 14 | |
84 | PdfName.PRINTPAGERANGE, // 15 | |
85 | PdfName.NUMCOPIES // 16 | |
86 | }; | |
87 | ||
88 | ||
89 | /** | |
90 | * A series of viewer preferences. | |
91 | */ | |
92 | public static final PdfName[] NONFULLSCREENPAGEMODE_PREFERENCES = { | |
93 | PdfName.USENONE, PdfName.USEOUTLINES, PdfName.USETHUMBS, PdfName.USEOC | |
94 | }; | |
95 | /** | |
96 | * A series of viewer preferences. | |
97 | */ | |
98 | public static final PdfName[] DIRECTION_PREFERENCES = { | |
99 | PdfName.L2R, PdfName.R2L | |
100 | }; | |
101 | /** | |
102 | * A series of viewer preferences. | |
103 | */ | |
104 | public static final PdfName[] PAGE_BOUNDARIES = { | |
105 | PdfName.MEDIABOX, PdfName.CROPBOX, PdfName.BLEEDBOX, PdfName.TRIMBOX, PdfName.ARTBOX | |
106 | }; | |
107 | /** | |
108 | * A series of viewer preferences | |
109 | */ | |
110 | public static final PdfName[] PRINTSCALING_PREFERENCES = { | |
111 | PdfName.APPDEFAULT, PdfName.NONE | |
112 | }; | |
113 | /** | |
114 | * A series of viewer preferences. | |
115 | */ | |
116 | public static final PdfName[] DUPLEX_PREFERENCES = { | |
117 | PdfName.SIMPLEX, PdfName.DUPLEXFLIPSHORTEDGE, PdfName.DUPLEXFLIPLONGEDGE | |
118 | }; | |
119 | | |
120 | /** This value will hold the viewer preferences for the page layout and page mode. */ | |
121 | private int pageLayoutAndMode = 0; | |
122 | | |
123 | /** This dictionary holds the viewer preferences (other than page layout and page mode). */ | |
124 | private PdfDictionary viewerPreferences = new PdfDictionary(); | |
125 | | |
126 | /** The mask to decide if a ViewerPreferences dictionary is needed */ | |
127 | private static final int viewerPreferencesMask = 0xfff000; | |
128 | ||
129 | /** | |
130 | * Returns the page layout and page mode value. | |
131 | */ | |
132 | public int getPageLayoutAndMode() { | |
133 | return pageLayoutAndMode; | |
134 | } | |
135 | ||
136 | /** | |
137 | * Returns the viewer preferences. | |
138 | */ | |
139 | public PdfDictionary getViewerPreferences() { | |
140 | return viewerPreferences; | |
141 | } | |
142 | | |
143 | /** | |
144 | * Sets the viewer preferences as the sum of several constants. | |
145 | * | |
146 | * @param preferences | |
147 | * the viewer preferences | |
148 | * @see PdfViewerPreferences#setViewerPreferences | |
149 | */ | |
150 | public void setViewerPreferences(int preferences) { | |
151 |
1
1. setViewerPreferences : Replaced bitwise OR with AND → NO_COVERAGE |
this.pageLayoutAndMode |= preferences; |
152 | // for backwards compatibility, it is also possible | |
153 | // to set the following viewer preferences with this method: | |
154 |
2
1. setViewerPreferences : Replaced bitwise AND with OR → NO_COVERAGE 2. setViewerPreferences : negated conditional → NO_COVERAGE |
if ((preferences & viewerPreferencesMask) != 0) { |
155 |
1
1. setViewerPreferences : Replaced bitwise AND with OR → NO_COVERAGE |
pageLayoutAndMode = ~viewerPreferencesMask & pageLayoutAndMode; |
156 |
2
1. setViewerPreferences : Replaced bitwise AND with OR → NO_COVERAGE 2. setViewerPreferences : negated conditional → NO_COVERAGE |
if ((preferences & PdfWriter.HideToolbar) != 0) |
157 |
1
1. setViewerPreferences : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
viewerPreferences.put(PdfName.HIDETOOLBAR, PdfBoolean.PDFTRUE); |
158 |
2
1. setViewerPreferences : Replaced bitwise AND with OR → NO_COVERAGE 2. setViewerPreferences : negated conditional → NO_COVERAGE |
if ((preferences & PdfWriter.HideMenubar) != 0) |
159 |
1
1. setViewerPreferences : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
viewerPreferences.put(PdfName.HIDEMENUBAR, PdfBoolean.PDFTRUE); |
160 |
2
1. setViewerPreferences : Replaced bitwise AND with OR → NO_COVERAGE 2. setViewerPreferences : negated conditional → NO_COVERAGE |
if ((preferences & PdfWriter.HideWindowUI) != 0) |
161 |
1
1. setViewerPreferences : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
viewerPreferences.put(PdfName.HIDEWINDOWUI, PdfBoolean.PDFTRUE); |
162 |
2
1. setViewerPreferences : Replaced bitwise AND with OR → NO_COVERAGE 2. setViewerPreferences : negated conditional → NO_COVERAGE |
if ((preferences & PdfWriter.FitWindow) != 0) |
163 |
1
1. setViewerPreferences : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
viewerPreferences.put(PdfName.FITWINDOW, PdfBoolean.PDFTRUE); |
164 |
2
1. setViewerPreferences : Replaced bitwise AND with OR → NO_COVERAGE 2. setViewerPreferences : negated conditional → NO_COVERAGE |
if ((preferences & PdfWriter.CenterWindow) != 0) |
165 |
1
1. setViewerPreferences : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
viewerPreferences.put(PdfName.CENTERWINDOW, PdfBoolean.PDFTRUE); |
166 |
2
1. setViewerPreferences : Replaced bitwise AND with OR → NO_COVERAGE 2. setViewerPreferences : negated conditional → NO_COVERAGE |
if ((preferences & PdfWriter.DisplayDocTitle) != 0) |
167 |
1
1. setViewerPreferences : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
viewerPreferences.put(PdfName.DISPLAYDOCTITLE, PdfBoolean.PDFTRUE); |
168 | | |
169 |
2
1. setViewerPreferences : Replaced bitwise AND with OR → NO_COVERAGE 2. setViewerPreferences : negated conditional → NO_COVERAGE |
if ((preferences & PdfWriter.NonFullScreenPageModeUseNone) != 0) |
170 |
1
1. setViewerPreferences : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
viewerPreferences.put(PdfName.NONFULLSCREENPAGEMODE, PdfName.USENONE); |
171 |
2
1. setViewerPreferences : Replaced bitwise AND with OR → NO_COVERAGE 2. setViewerPreferences : negated conditional → NO_COVERAGE |
else if ((preferences & PdfWriter.NonFullScreenPageModeUseOutlines) != 0) |
172 |
1
1. setViewerPreferences : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
viewerPreferences.put(PdfName.NONFULLSCREENPAGEMODE, PdfName.USEOUTLINES); |
173 |
2
1. setViewerPreferences : Replaced bitwise AND with OR → NO_COVERAGE 2. setViewerPreferences : negated conditional → NO_COVERAGE |
else if ((preferences & PdfWriter.NonFullScreenPageModeUseThumbs) != 0) |
174 |
1
1. setViewerPreferences : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
viewerPreferences.put(PdfName.NONFULLSCREENPAGEMODE, PdfName.USETHUMBS); |
175 |
2
1. setViewerPreferences : Replaced bitwise AND with OR → NO_COVERAGE 2. setViewerPreferences : negated conditional → NO_COVERAGE |
else if ((preferences & PdfWriter.NonFullScreenPageModeUseOC) != 0) |
176 |
1
1. setViewerPreferences : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
viewerPreferences.put(PdfName.NONFULLSCREENPAGEMODE, PdfName.USEOC); |
177 | ||
178 |
2
1. setViewerPreferences : Replaced bitwise AND with OR → NO_COVERAGE 2. setViewerPreferences : negated conditional → NO_COVERAGE |
if ((preferences & PdfWriter.DirectionL2R) != 0) |
179 |
1
1. setViewerPreferences : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
viewerPreferences.put(PdfName.DIRECTION, PdfName.L2R); |
180 |
2
1. setViewerPreferences : Replaced bitwise AND with OR → NO_COVERAGE 2. setViewerPreferences : negated conditional → NO_COVERAGE |
else if ((preferences & PdfWriter.DirectionR2L) != 0) |
181 |
1
1. setViewerPreferences : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
viewerPreferences.put(PdfName.DIRECTION, PdfName.R2L); |
182 | ||
183 |
2
1. setViewerPreferences : Replaced bitwise AND with OR → NO_COVERAGE 2. setViewerPreferences : negated conditional → NO_COVERAGE |
if ((preferences & PdfWriter.PrintScalingNone) != 0) |
184 |
1
1. setViewerPreferences : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
viewerPreferences.put(PdfName.PRINTSCALING, PdfName.NONE); |
185 | } | |
186 | } | |
187 | | |
188 | /** | |
189 | * Given a key for a viewer preference (a PdfName object), | |
190 | * this method returns the index in the VIEWER_PREFERENCES array. | |
191 | * @param key a PdfName referring to a viewer preference | |
192 | * @return an index in the VIEWER_PREFERENCES array | |
193 | */ | |
194 | private int getIndex(PdfName key) { | |
195 |
3
1. getIndex : changed conditional boundary → NO_COVERAGE 2. getIndex : Changed increment from 1 to -1 → NO_COVERAGE 3. getIndex : negated conditional → NO_COVERAGE |
for (int i = 0; i < VIEWER_PREFERENCES.length; i++) { |
196 |
1
1. getIndex : negated conditional → NO_COVERAGE |
if (VIEWER_PREFERENCES[i].equals(key)) |
197 |
1
1. getIndex : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return i; |
198 | } | |
199 |
1
1. getIndex : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return -1; |
200 | } | |
201 | | |
202 | /** | |
203 | * Checks if some value is valid for a certain key. | |
204 | */ | |
205 | private boolean isPossibleValue(PdfName value, PdfName[] accepted) { | |
206 | for (PdfName pdfName : accepted) { | |
207 |
1
1. isPossibleValue : negated conditional → NO_COVERAGE |
if (pdfName.equals(value)) { |
208 |
1
1. isPossibleValue : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return true; |
209 | } | |
210 | } | |
211 |
1
1. isPossibleValue : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
212 | } | |
213 | | |
214 | /** | |
215 | * Sets the viewer preferences for printing. | |
216 | */ | |
217 | public void addViewerPreference(PdfName key, PdfObject value) { | |
218 | switch(getIndex(key)) { | |
219 | case 0: // HIDETOOLBAR | |
220 | case 1: // HIDEMENUBAR | |
221 | case 2: // HIDEWINDOWUI | |
222 | case 3: // FITWINDOW | |
223 | case 4: // CENTERWINDOW | |
224 | case 5: // DISPLAYDOCTITLE | |
225 | case 14: // PICKTRAYBYPDFSIZE | |
226 |
1
1. addViewerPreference : negated conditional → NO_COVERAGE |
if (value instanceof PdfBoolean) { |
227 |
1
1. addViewerPreference : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
viewerPreferences.put(key, value); |
228 | } | |
229 | break; | |
230 | case 6: // NONFULLSCREENPAGEMODE | |
231 |
1
1. addViewerPreference : negated conditional → NO_COVERAGE |
if (value instanceof PdfName |
232 |
1
1. addViewerPreference : negated conditional → NO_COVERAGE |
&& isPossibleValue((PdfName)value, NONFULLSCREENPAGEMODE_PREFERENCES)) { |
233 |
1
1. addViewerPreference : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
viewerPreferences.put(key, value); |
234 | } | |
235 | break; | |
236 | case 7: // DIRECTION | |
237 |
1
1. addViewerPreference : negated conditional → NO_COVERAGE |
if (value instanceof PdfName |
238 |
1
1. addViewerPreference : negated conditional → NO_COVERAGE |
&& isPossibleValue((PdfName)value, DIRECTION_PREFERENCES)) { |
239 |
1
1. addViewerPreference : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
viewerPreferences.put(key, value); |
240 | } | |
241 | break; | |
242 | case 8: // VIEWAREA | |
243 | case 9: // VIEWCLIP | |
244 | case 10: // PRINTAREA | |
245 | case 11: // PRINTCLIP | |
246 |
1
1. addViewerPreference : negated conditional → NO_COVERAGE |
if (value instanceof PdfName |
247 |
1
1. addViewerPreference : negated conditional → NO_COVERAGE |
&& isPossibleValue((PdfName)value, PAGE_BOUNDARIES)) { |
248 |
1
1. addViewerPreference : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
viewerPreferences.put(key, value); |
249 | } | |
250 | break; | |
251 | case 12: // PRINTSCALING | |
252 |
1
1. addViewerPreference : negated conditional → NO_COVERAGE |
if (value instanceof PdfName |
253 |
1
1. addViewerPreference : negated conditional → NO_COVERAGE |
&& isPossibleValue((PdfName)value, PRINTSCALING_PREFERENCES)) { |
254 |
1
1. addViewerPreference : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
viewerPreferences.put(key, value); |
255 | } | |
256 | break; | |
257 | case 13: // DUPLEX | |
258 |
1
1. addViewerPreference : negated conditional → NO_COVERAGE |
if (value instanceof PdfName |
259 |
1
1. addViewerPreference : negated conditional → NO_COVERAGE |
&& isPossibleValue((PdfName)value, DUPLEX_PREFERENCES)) { |
260 |
1
1. addViewerPreference : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
viewerPreferences.put(key, value); |
261 | } | |
262 | break; | |
263 | case 15: // PRINTPAGERANGE | |
264 |
1
1. addViewerPreference : negated conditional → NO_COVERAGE |
if (value instanceof PdfArray) { |
265 |
1
1. addViewerPreference : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
viewerPreferences.put(key, value); |
266 | } | |
267 | break; | |
268 | case 16: // NUMCOPIES | |
269 |
1
1. addViewerPreference : negated conditional → NO_COVERAGE |
if (value instanceof PdfNumber) { |
270 |
1
1. addViewerPreference : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
viewerPreferences.put(key, value); |
271 | } | |
272 | break; | |
273 | } | |
274 | } | |
275 | ||
276 | /** | |
277 | * Adds the viewer preferences defined in the preferences parameter to a | |
278 | * PdfDictionary (more specifically the root or catalog of a PDF file). | |
279 | * | |
280 | * @param catalog | |
281 | */ | |
282 | public void addToCatalog(PdfDictionary catalog) { | |
283 | // Page Layout | |
284 |
1
1. addToCatalog : removed call to com/lowagie/text/pdf/PdfDictionary::remove → NO_COVERAGE |
catalog.remove(PdfName.PAGELAYOUT); |
285 |
2
1. addToCatalog : Replaced bitwise AND with OR → NO_COVERAGE 2. addToCatalog : negated conditional → NO_COVERAGE |
if ((pageLayoutAndMode & PdfWriter.PageLayoutSinglePage) != 0) |
286 |
1
1. addToCatalog : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
catalog.put(PdfName.PAGELAYOUT, PdfName.SINGLEPAGE); |
287 |
2
1. addToCatalog : Replaced bitwise AND with OR → NO_COVERAGE 2. addToCatalog : negated conditional → NO_COVERAGE |
else if ((pageLayoutAndMode & PdfWriter.PageLayoutOneColumn) != 0) |
288 |
1
1. addToCatalog : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
catalog.put(PdfName.PAGELAYOUT, PdfName.ONECOLUMN); |
289 |
2
1. addToCatalog : Replaced bitwise AND with OR → NO_COVERAGE 2. addToCatalog : negated conditional → NO_COVERAGE |
else if ((pageLayoutAndMode & PdfWriter.PageLayoutTwoColumnLeft) != 0) |
290 |
1
1. addToCatalog : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
catalog.put(PdfName.PAGELAYOUT, PdfName.TWOCOLUMNLEFT); |
291 |
2
1. addToCatalog : Replaced bitwise AND with OR → NO_COVERAGE 2. addToCatalog : negated conditional → NO_COVERAGE |
else if ((pageLayoutAndMode & PdfWriter.PageLayoutTwoColumnRight) != 0) |
292 |
1
1. addToCatalog : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
catalog.put(PdfName.PAGELAYOUT, PdfName.TWOCOLUMNRIGHT); |
293 |
2
1. addToCatalog : Replaced bitwise AND with OR → NO_COVERAGE 2. addToCatalog : negated conditional → NO_COVERAGE |
else if ((pageLayoutAndMode & PdfWriter.PageLayoutTwoPageLeft) != 0) |
294 |
1
1. addToCatalog : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
catalog.put(PdfName.PAGELAYOUT, PdfName.TWOPAGELEFT); |
295 |
2
1. addToCatalog : Replaced bitwise AND with OR → NO_COVERAGE 2. addToCatalog : negated conditional → NO_COVERAGE |
else if ((pageLayoutAndMode & PdfWriter.PageLayoutTwoPageRight) != 0) |
296 |
1
1. addToCatalog : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
catalog.put(PdfName.PAGELAYOUT, PdfName.TWOPAGERIGHT); |
297 | ||
298 | // Page Mode | |
299 |
1
1. addToCatalog : removed call to com/lowagie/text/pdf/PdfDictionary::remove → NO_COVERAGE |
catalog.remove(PdfName.PAGEMODE); |
300 |
2
1. addToCatalog : Replaced bitwise AND with OR → NO_COVERAGE 2. addToCatalog : negated conditional → NO_COVERAGE |
if ((pageLayoutAndMode & PdfWriter.PageModeUseNone) != 0) |
301 |
1
1. addToCatalog : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
catalog.put(PdfName.PAGEMODE, PdfName.USENONE); |
302 |
2
1. addToCatalog : Replaced bitwise AND with OR → NO_COVERAGE 2. addToCatalog : negated conditional → NO_COVERAGE |
else if ((pageLayoutAndMode & PdfWriter.PageModeUseOutlines) != 0) |
303 |
1
1. addToCatalog : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
catalog.put(PdfName.PAGEMODE, PdfName.USEOUTLINES); |
304 |
2
1. addToCatalog : Replaced bitwise AND with OR → NO_COVERAGE 2. addToCatalog : negated conditional → NO_COVERAGE |
else if ((pageLayoutAndMode & PdfWriter.PageModeUseThumbs) != 0) |
305 |
1
1. addToCatalog : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
catalog.put(PdfName.PAGEMODE, PdfName.USETHUMBS); |
306 |
2
1. addToCatalog : Replaced bitwise AND with OR → NO_COVERAGE 2. addToCatalog : negated conditional → NO_COVERAGE |
else if ((pageLayoutAndMode & PdfWriter.PageModeFullScreen) != 0) |
307 |
1
1. addToCatalog : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
catalog.put(PdfName.PAGEMODE, PdfName.FULLSCREEN); |
308 |
2
1. addToCatalog : Replaced bitwise AND with OR → NO_COVERAGE 2. addToCatalog : negated conditional → NO_COVERAGE |
else if ((pageLayoutAndMode & PdfWriter.PageModeUseOC) != 0) |
309 |
1
1. addToCatalog : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
catalog.put(PdfName.PAGEMODE, PdfName.USEOC); |
310 |
2
1. addToCatalog : Replaced bitwise AND with OR → NO_COVERAGE 2. addToCatalog : negated conditional → NO_COVERAGE |
else if ((pageLayoutAndMode & PdfWriter.PageModeUseAttachments) != 0) |
311 |
1
1. addToCatalog : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
catalog.put(PdfName.PAGEMODE, PdfName.USEATTACHMENTS); |
312 | ||
313 | // viewer preferences (Table 8.1 of the PDF Reference) | |
314 |
1
1. addToCatalog : removed call to com/lowagie/text/pdf/PdfDictionary::remove → NO_COVERAGE |
catalog.remove(PdfName.VIEWERPREFERENCES); |
315 |
2
1. addToCatalog : changed conditional boundary → NO_COVERAGE 2. addToCatalog : negated conditional → NO_COVERAGE |
if (viewerPreferences.size() > 0) { |
316 |
1
1. addToCatalog : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE |
catalog.put(PdfName.VIEWERPREFERENCES, viewerPreferences); |
317 | } | |
318 | } | |
319 | ||
320 | public static PdfViewerPreferencesImp getViewerPreferences(PdfDictionary catalog) { | |
321 | PdfViewerPreferencesImp preferences = new PdfViewerPreferencesImp(); | |
322 | int prefs = 0; | |
323 | PdfName name = null; | |
324 | // page layout | |
325 | PdfObject obj = PdfReader.getPdfObjectRelease(catalog.get(PdfName.PAGELAYOUT)); | |
326 |
2
1. getViewerPreferences : negated conditional → NO_COVERAGE 2. getViewerPreferences : negated conditional → NO_COVERAGE |
if (obj != null && obj.isName()) { |
327 | name = (PdfName) obj; | |
328 |
1
1. getViewerPreferences : negated conditional → NO_COVERAGE |
if (name.equals(PdfName.SINGLEPAGE)) |
329 |
1
1. getViewerPreferences : Replaced bitwise OR with AND → NO_COVERAGE |
prefs |= PdfWriter.PageLayoutSinglePage; |
330 |
1
1. getViewerPreferences : negated conditional → NO_COVERAGE |
else if (name.equals(PdfName.ONECOLUMN)) |
331 |
1
1. getViewerPreferences : Replaced bitwise OR with AND → NO_COVERAGE |
prefs |= PdfWriter.PageLayoutOneColumn; |
332 |
1
1. getViewerPreferences : negated conditional → NO_COVERAGE |
else if (name.equals(PdfName.TWOCOLUMNLEFT)) |
333 |
1
1. getViewerPreferences : Replaced bitwise OR with AND → NO_COVERAGE |
prefs |= PdfWriter.PageLayoutTwoColumnLeft; |
334 |
1
1. getViewerPreferences : negated conditional → NO_COVERAGE |
else if (name.equals(PdfName.TWOCOLUMNRIGHT)) |
335 |
1
1. getViewerPreferences : Replaced bitwise OR with AND → NO_COVERAGE |
prefs |= PdfWriter.PageLayoutTwoColumnRight; |
336 |
1
1. getViewerPreferences : negated conditional → NO_COVERAGE |
else if (name.equals(PdfName.TWOPAGELEFT)) |
337 |
1
1. getViewerPreferences : Replaced bitwise OR with AND → NO_COVERAGE |
prefs |= PdfWriter.PageLayoutTwoPageLeft; |
338 |
1
1. getViewerPreferences : negated conditional → NO_COVERAGE |
else if (name.equals(PdfName.TWOPAGERIGHT)) |
339 |
1
1. getViewerPreferences : Replaced bitwise OR with AND → NO_COVERAGE |
prefs |= PdfWriter.PageLayoutTwoPageRight; |
340 | } | |
341 | // page mode | |
342 | obj = PdfReader.getPdfObjectRelease(catalog.get(PdfName.PAGEMODE)); | |
343 |
2
1. getViewerPreferences : negated conditional → NO_COVERAGE 2. getViewerPreferences : negated conditional → NO_COVERAGE |
if (obj != null && obj.isName()) { |
344 | name = (PdfName) obj; | |
345 |
1
1. getViewerPreferences : negated conditional → NO_COVERAGE |
if (name.equals(PdfName.USENONE)) |
346 |
1
1. getViewerPreferences : Replaced bitwise OR with AND → NO_COVERAGE |
prefs |= PdfWriter.PageModeUseNone; |
347 |
1
1. getViewerPreferences : negated conditional → NO_COVERAGE |
else if (name.equals(PdfName.USEOUTLINES)) |
348 |
1
1. getViewerPreferences : Replaced bitwise OR with AND → NO_COVERAGE |
prefs |= PdfWriter.PageModeUseOutlines; |
349 |
1
1. getViewerPreferences : negated conditional → NO_COVERAGE |
else if (name.equals(PdfName.USETHUMBS)) |
350 |
1
1. getViewerPreferences : Replaced bitwise OR with AND → NO_COVERAGE |
prefs |= PdfWriter.PageModeUseThumbs; |
351 |
1
1. getViewerPreferences : negated conditional → NO_COVERAGE |
else if (name.equals(PdfName.FULLSCREEN)) |
352 |
1
1. getViewerPreferences : Replaced bitwise OR with AND → NO_COVERAGE |
prefs |= PdfWriter.PageModeFullScreen; |
353 |
1
1. getViewerPreferences : negated conditional → NO_COVERAGE |
else if (name.equals(PdfName.USEOC)) |
354 |
1
1. getViewerPreferences : Replaced bitwise OR with AND → NO_COVERAGE |
prefs |= PdfWriter.PageModeUseOC; |
355 |
1
1. getViewerPreferences : negated conditional → NO_COVERAGE |
else if (name.equals(PdfName.USEATTACHMENTS)) |
356 |
1
1. getViewerPreferences : Replaced bitwise OR with AND → NO_COVERAGE |
prefs |= PdfWriter.PageModeUseAttachments; |
357 | } | |
358 | // set page layout and page mode preferences | |
359 |
1
1. getViewerPreferences : removed call to com/lowagie/text/pdf/internal/PdfViewerPreferencesImp::setViewerPreferences → NO_COVERAGE |
preferences.setViewerPreferences(prefs); |
360 | // other preferences | |
361 | obj = PdfReader.getPdfObjectRelease(catalog | |
362 | .get(PdfName.VIEWERPREFERENCES)); | |
363 |
2
1. getViewerPreferences : negated conditional → NO_COVERAGE 2. getViewerPreferences : negated conditional → NO_COVERAGE |
if (obj != null && obj.isDictionary()) { |
364 | PdfDictionary vp = (PdfDictionary) obj; | |
365 | for (PdfName viewerPreference : VIEWER_PREFERENCES) { | |
366 | obj = PdfReader.getPdfObjectRelease(vp.get(viewerPreference)); | |
367 |
1
1. getViewerPreferences : removed call to com/lowagie/text/pdf/internal/PdfViewerPreferencesImp::addViewerPreference → NO_COVERAGE |
preferences.addViewerPreference(viewerPreference, obj); |
368 | } | |
369 | } | |
370 |
1
1. getViewerPreferences : mutated return of Object value for com/lowagie/text/pdf/internal/PdfViewerPreferencesImp::getViewerPreferences to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return preferences; |
371 | } | |
372 | } | |
Mutations | ||
151 |
1.1 |
|
154 |
1.1 2.2 |
|
155 |
1.1 |
|
156 |
1.1 2.2 |
|
157 |
1.1 |
|
158 |
1.1 2.2 |
|
159 |
1.1 |
|
160 |
1.1 2.2 |
|
161 |
1.1 |
|
162 |
1.1 2.2 |
|
163 |
1.1 |
|
164 |
1.1 2.2 |
|
165 |
1.1 |
|
166 |
1.1 2.2 |
|
167 |
1.1 |
|
169 |
1.1 2.2 |
|
170 |
1.1 |
|
171 |
1.1 2.2 |
|
172 |
1.1 |
|
173 |
1.1 2.2 |
|
174 |
1.1 |
|
175 |
1.1 2.2 |
|
176 |
1.1 |
|
178 |
1.1 2.2 |
|
179 |
1.1 |
|
180 |
1.1 2.2 |
|
181 |
1.1 |
|
183 |
1.1 2.2 |
|
184 |
1.1 |
|
195 |
1.1 2.2 3.3 |
|
196 |
1.1 |
|
197 |
1.1 |
|
199 |
1.1 |
|
207 |
1.1 |
|
208 |
1.1 |
|
211 |
1.1 |
|
226 |
1.1 |
|
227 |
1.1 |
|
231 |
1.1 |
|
232 |
1.1 |
|
233 |
1.1 |
|
237 |
1.1 |
|
238 |
1.1 |
|
239 |
1.1 |
|
246 |
1.1 |
|
247 |
1.1 |
|
248 |
1.1 |
|
252 |
1.1 |
|
253 |
1.1 |
|
254 |
1.1 |
|
258 |
1.1 |
|
259 |
1.1 |
|
260 |
1.1 |
|
264 |
1.1 |
|
265 |
1.1 |
|
269 |
1.1 |
|
270 |
1.1 |
|
284 |
1.1 |
|
285 |
1.1 2.2 |
|
286 |
1.1 |
|
287 |
1.1 2.2 |
|
288 |
1.1 |
|
289 |
1.1 2.2 |
|
290 |
1.1 |
|
291 |
1.1 2.2 |
|
292 |
1.1 |
|
293 |
1.1 2.2 |
|
294 |
1.1 |
|
295 |
1.1 2.2 |
|
296 |
1.1 |
|
299 |
1.1 |
|
300 |
1.1 2.2 |
|
301 |
1.1 |
|
302 |
1.1 2.2 |
|
303 |
1.1 |
|
304 |
1.1 2.2 |
|
305 |
1.1 |
|
306 |
1.1 2.2 |
|
307 |
1.1 |
|
308 |
1.1 2.2 |
|
309 |
1.1 |
|
310 |
1.1 2.2 |
|
311 |
1.1 |
|
314 |
1.1 |
|
315 |
1.1 2.2 |
|
316 |
1.1 |
|
326 |
1.1 2.2 |
|
328 |
1.1 |
|
329 |
1.1 |
|
330 |
1.1 |
|
331 |
1.1 |
|
332 |
1.1 |
|
333 |
1.1 |
|
334 |
1.1 |
|
335 |
1.1 |
|
336 |
1.1 |
|
337 |
1.1 |
|
338 |
1.1 |
|
339 |
1.1 |
|
343 |
1.1 2.2 |
|
345 |
1.1 |
|
346 |
1.1 |
|
347 |
1.1 |
|
348 |
1.1 |
|
349 |
1.1 |
|
350 |
1.1 |
|
351 |
1.1 |
|
352 |
1.1 |
|
353 |
1.1 |
|
354 |
1.1 |
|
355 |
1.1 |
|
356 |
1.1 |
|
359 |
1.1 |
|
363 |
1.1 2.2 |
|
367 |
1.1 |
|
370 |
1.1 |