PdfCopyFieldsImp.java

1
/*
2
 * $Id: PdfCopyFieldsImp.java 4065 2009-09-16 23:09:11Z psoares33 $
3
 * Copyright 2004 by Paulo Soares.
4
 *
5
 * The contents of this file are subject to the Mozilla Public License Version 1.1
6
 * (the "License"); you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at http://www.mozilla.org/MPL/
8
 *
9
 * Software distributed under the License is distributed on an "AS IS" basis,
10
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
 * for the specific language governing rights and limitations under the License.
12
 *
13
 * The Original Code is 'iText, a free JAVA-PDF library'.
14
 *
15
 * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
16
 * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
17
 * All Rights Reserved.
18
 * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
19
 * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
20
 *
21
 * Contributor(s): all the names of the contributors are added in the source code
22
 * where applicable.
23
 *
24
 * Alternatively, the contents of this file may be used under the terms of the
25
 * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
26
 * provisions of LGPL are applicable instead of those above.  If you wish to
27
 * allow use of your version of this file only under the terms of the LGPL
28
 * License and not to allow others to use your version of this file under
29
 * the MPL, indicate your decision by deleting the provisions above and
30
 * replace them with the notice and other provisions required by the LGPL.
31
 * If you do not delete the provisions above, a recipient may use your version
32
 * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
33
 *
34
 * This library is free software; you can redistribute it and/or modify it
35
 * under the terms of the MPL as stated above or under the terms of the GNU
36
 * Library General Public License as published by the Free Software Foundation;
37
 * either version 2 of the License, or any later version.
38
 *
39
 * This library is distributed in the hope that it will be useful, but WITHOUT
40
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
41
 * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
42
 * details.
43
 *
44
 * If you didn't download this code from the following link, you should check if
45
 * you aren't using an obsolete version:
46
 * http://www.lowagie.com/iText/
47
 */
48
package com.lowagie.text.pdf;
49
50
import java.io.IOException;
51
import java.io.OutputStream;
52
import java.util.ArrayList;
53
import java.util.HashMap;
54
import java.util.Iterator;
55
import java.util.List;
56
import java.util.Map;
57
import java.util.StringTokenizer;
58
import com.lowagie.text.error_messages.MessageLocalization;
59
60
import com.lowagie.text.Document;
61
import com.lowagie.text.DocumentException;
62
63
import com.lowagie.text.exceptions.BadPasswordException;
64
import com.lowagie.text.ExceptionConverter;
65
import com.lowagie.text.pdf.AcroFields.Item;
66
67
/**
68
 *
69
 * @author  psoares
70
 */
71
class PdfCopyFieldsImp extends PdfWriter {
72
73
    private static final PdfName iTextTag = new PdfName("_iTextTag_");
74
    private static final Integer zero = 0;
75
    List<PdfReader> readers = new ArrayList<>();
76
    Map<PdfReader, IntHashtable> readers2intrefs = new HashMap<>();
77
    Map<PdfReader, IntHashtable> pages2intrefs = new HashMap<>();
78
    Map<PdfReader, IntHashtable> visited = new HashMap<>();
79
    List<AcroFields> fields = new ArrayList<>();
80
    RandomAccessFileOrArray file;
81
    Map<String, Object> fieldTree = new HashMap<>();
82
    List<PdfIndirectReference> pageRefs = new ArrayList<>();
83
    List<PdfDictionary> pageDics = new ArrayList<>();
84
    PdfDictionary resources = new PdfDictionary();
85
    PdfDictionary form;
86
    boolean closing = false;
87
    Document nd;
88
    private Map<PdfArray, List<Integer>> tabOrder;
89
    private List<Object> calculationOrder = new ArrayList<>();
90
    private List<Object> calculationOrderRefs;
91
    private boolean hasSignature;
92
    
93
    PdfCopyFieldsImp(OutputStream os) throws DocumentException {
94
        this(os, '\0');
95
    }
96
    
97
    PdfCopyFieldsImp(OutputStream os, char pdfVersion) throws DocumentException {
98
        super(new PdfDocument(), os);
99 1 1. : removed call to com/lowagie/text/pdf/PdfDocument::addWriter → NO_COVERAGE
        pdf.addWriter(this);
100 1 1. : negated conditional → NO_COVERAGE
        if (pdfVersion != 0)
101 1 1. : removed call to com/lowagie/text/pdf/PdfWriter::setPdfVersion → NO_COVERAGE
            super.setPdfVersion(pdfVersion);
102
        nd = new Document();
103 1 1. : removed call to com/lowagie/text/Document::addDocListener → NO_COVERAGE
        nd.addDocListener(pdf);
104
    }
105
    
106
    void addDocument(PdfReader reader, List pagesToKeep) throws DocumentException, IOException {
107 2 1. addDocument : negated conditional → NO_COVERAGE
2. addDocument : negated conditional → NO_COVERAGE
        if (!readers2intrefs.containsKey(reader) && reader.isTampered())
108
            throw new DocumentException(MessageLocalization.getComposedMessage("the.document.was.reused"));
109
        reader = new PdfReader(reader);        
110 1 1. addDocument : removed call to com/lowagie/text/pdf/PdfReader::selectPages → NO_COVERAGE
        reader.selectPages(pagesToKeep);
111 1 1. addDocument : negated conditional → NO_COVERAGE
        if (reader.getNumberOfPages() == 0)
112
            return;
113 1 1. addDocument : removed call to com/lowagie/text/pdf/PdfReader::setTampered → NO_COVERAGE
        reader.setTampered(false);
114 1 1. addDocument : removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::addDocument → NO_COVERAGE
        addDocument(reader);
115
    }
116
    
117
    void addDocument(PdfReader reader) throws DocumentException, IOException {
118 1 1. addDocument : negated conditional → NO_COVERAGE
        if (!reader.isOpenedWithFullPermissions())
119
            throw new BadPasswordException(MessageLocalization.getComposedMessage("pdfreader.not.opened.with.owner.password"));
120 1 1. addDocument : removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::openDoc → NO_COVERAGE
        openDoc();
121 1 1. addDocument : negated conditional → NO_COVERAGE
        if (readers2intrefs.containsKey(reader)) {
122
            reader = new PdfReader(reader);
123
        }
124
        else {
125 1 1. addDocument : negated conditional → NO_COVERAGE
            if (reader.isTampered())
126
                throw new DocumentException(MessageLocalization.getComposedMessage("the.document.was.reused"));
127 1 1. addDocument : removed call to com/lowagie/text/pdf/PdfReader::consolidateNamedDestinations → NO_COVERAGE
            reader.consolidateNamedDestinations();
128 1 1. addDocument : removed call to com/lowagie/text/pdf/PdfReader::setTampered → NO_COVERAGE
            reader.setTampered(true);
129
        }
130
        reader.shuffleSubsetNames();
131
        readers2intrefs.put(reader, new IntHashtable());
132
        readers.add(reader);
133
        int len = reader.getNumberOfPages();
134
        IntHashtable refs = new IntHashtable();
135 3 1. addDocument : changed conditional boundary → NO_COVERAGE
2. addDocument : Changed increment from 1 to -1 → NO_COVERAGE
3. addDocument : negated conditional → NO_COVERAGE
        for (int p = 1; p <= len; ++p) {
136
            refs.put(reader.getPageOrigRef(p).getNumber(), 1);
137 1 1. addDocument : removed call to com/lowagie/text/pdf/PdfReader::releasePage → NO_COVERAGE
            reader.releasePage(p);
138
        }
139
        pages2intrefs.put(reader, refs);
140
        visited.put(reader, new IntHashtable());
141
        fields.add(reader.getAcroFields());
142 1 1. addDocument : removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::updateCalculationOrder → NO_COVERAGE
        updateCalculationOrder(reader);
143
    }
144
    
145
    private static String getCOName(PdfReader reader, PRIndirectReference ref) {
146
        String name = "";
147 1 1. getCOName : negated conditional → NO_COVERAGE
        while (ref != null) {
148
            PdfObject obj = PdfReader.getPdfObject(ref);
149 2 1. getCOName : negated conditional → NO_COVERAGE
2. getCOName : negated conditional → NO_COVERAGE
            if (obj == null || obj.type() != PdfObject.DICTIONARY)
150
                break;
151
            PdfDictionary dic = (PdfDictionary)obj;
152
            PdfString t = dic.getAsString(PdfName.T);
153 1 1. getCOName : negated conditional → NO_COVERAGE
            if (t != null) {
154
                name = t.toUnicodeString()+ "." + name;
155
            }
156
            ref = (PRIndirectReference)dic.get(PdfName.PARENT);
157
        }
158 1 1. getCOName : negated conditional → NO_COVERAGE
        if (name.endsWith("."))
159 1 1. getCOName : Replaced integer subtraction with addition → NO_COVERAGE
            name = name.substring(0, name.length() - 1);
160 1 1. getCOName : mutated return of Object value for com/lowagie/text/pdf/PdfCopyFieldsImp::getCOName to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return name;
161
    }
162
    
163
    /**
164
     * @since    2.1.5; before 2.1.5 the method was private
165
     */
166
    protected void updateCalculationOrder(PdfReader reader) {
167
        PdfDictionary catalog = reader.getCatalog();
168
        PdfDictionary acro = catalog.getAsDict(PdfName.ACROFORM);
169 1 1. updateCalculationOrder : negated conditional → NO_COVERAGE
        if (acro == null)
170
            return;
171
        PdfArray co = acro.getAsArray(PdfName.CO);
172 2 1. updateCalculationOrder : negated conditional → NO_COVERAGE
2. updateCalculationOrder : negated conditional → NO_COVERAGE
        if (co == null || co.size() == 0)
173
            return;
174
        AcroFields af = reader.getAcroFields();
175 2 1. updateCalculationOrder : changed conditional boundary → NO_COVERAGE
2. updateCalculationOrder : negated conditional → NO_COVERAGE
        for (int k = 0; k < co.size(); ++k) {
176
            PdfObject obj = co.getPdfObject(k);
177 2 1. updateCalculationOrder : negated conditional → NO_COVERAGE
2. updateCalculationOrder : negated conditional → NO_COVERAGE
            if (obj == null || !obj.isIndirect())
178
                continue;
179
            String name = getCOName(reader, (PRIndirectReference)obj);
180 1 1. updateCalculationOrder : negated conditional → NO_COVERAGE
            if (af.getFieldItem(name) == null)
181
                continue;
182
            name = "." + name;
183 1 1. updateCalculationOrder : negated conditional → NO_COVERAGE
            if (calculationOrder.contains(name))
184
                continue;
185
            calculationOrder.add(name);
186
        }
187
    }
188
    
189
    void propagate(PdfObject obj, PdfIndirectReference refo, boolean restricted) {
190 1 1. propagate : negated conditional → NO_COVERAGE
        if (obj == null)
191
            return;
192
//        if (refo != null)
193
//            addToBody(obj, refo);
194 1 1. propagate : negated conditional → NO_COVERAGE
        if (obj instanceof PdfIndirectReference)
195
            return;
196
        switch (obj.type()) {
197
            case PdfObject.DICTIONARY:
198
            case PdfObject.STREAM: {
199
                PdfDictionary dic = (PdfDictionary)obj;
200
                for (PdfName key : dic.getKeys()) {
201 3 1. propagate : negated conditional → NO_COVERAGE
2. propagate : negated conditional → NO_COVERAGE
3. propagate : negated conditional → NO_COVERAGE
                    if (restricted && (key.equals(PdfName.PARENT) || key.equals(PdfName.KIDS)))
202
                        continue;
203
                    PdfObject ob = dic.get(key);
204 2 1. propagate : negated conditional → NO_COVERAGE
2. propagate : negated conditional → NO_COVERAGE
                    if (ob != null && ob.isIndirect()) {
205
                        PRIndirectReference ind = (PRIndirectReference) ob;
206 2 1. propagate : negated conditional → NO_COVERAGE
2. propagate : negated conditional → NO_COVERAGE
                        if (!setVisited(ind) && !isPage(ind)) {
207
                            PdfIndirectReference ref = getNewReference(ind);
208 1 1. propagate : removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::propagate → NO_COVERAGE
                            propagate(PdfReader.getPdfObjectRelease(ind), ref, restricted);
209
                        }
210
                    } else
211 1 1. propagate : removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::propagate → NO_COVERAGE
                        propagate(ob, null, restricted);
212
                }
213
                break;
214
            }
215
            case PdfObject.ARRAY: {
216
                //PdfArray arr = new PdfArray();
217 1 1. propagate : negated conditional → NO_COVERAGE
                for (Iterator it = ((PdfArray)obj).listIterator(); it.hasNext();) {
218
                    PdfObject ob = (PdfObject)it.next();
219 2 1. propagate : negated conditional → NO_COVERAGE
2. propagate : negated conditional → NO_COVERAGE
                    if (ob != null && ob.isIndirect()) {
220
                        PRIndirectReference ind = (PRIndirectReference)ob;
221 2 1. propagate : negated conditional → NO_COVERAGE
2. propagate : negated conditional → NO_COVERAGE
                        if (!isVisited(ind) && !isPage(ind)) {
222
                            PdfIndirectReference ref = getNewReference(ind);
223 1 1. propagate : removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::propagate → NO_COVERAGE
                            propagate(PdfReader.getPdfObjectRelease(ind), ref, restricted);
224
                        }
225
                    }
226
                    else
227 1 1. propagate : removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::propagate → NO_COVERAGE
                        propagate(ob, null, restricted);
228
                }
229
                break;
230
            }
231
            case PdfObject.INDIRECT: {
232
                throw new RuntimeException(MessageLocalization.getComposedMessage("reference.pointing.to.reference"));
233
            }
234
        }
235
    }
236
    
237
    private void adjustTabOrder(PdfArray annots, PdfIndirectReference ind, PdfNumber nn) {
238
        int v = nn.intValue();
239
        List<Integer> t = tabOrder.get(annots);
240 1 1. adjustTabOrder : negated conditional → NO_COVERAGE
        if (t == null) {
241
            t = new ArrayList<>();
242 1 1. adjustTabOrder : Replaced integer subtraction with addition → NO_COVERAGE
            int size = annots.size() - 1;
243 3 1. adjustTabOrder : changed conditional boundary → NO_COVERAGE
2. adjustTabOrder : Changed increment from 1 to -1 → NO_COVERAGE
3. adjustTabOrder : negated conditional → NO_COVERAGE
            for (int k = 0; k < size; ++k) {
244
                t.add(zero);
245
            }
246
            t.add(v);
247
            tabOrder.put(annots, t);
248
            annots.add(ind);
249
        }
250
        else {
251 1 1. adjustTabOrder : Replaced integer subtraction with addition → NO_COVERAGE
            int size = t.size() - 1;
252 3 1. adjustTabOrder : changed conditional boundary → NO_COVERAGE
2. adjustTabOrder : Changed increment from -1 to 1 → NO_COVERAGE
3. adjustTabOrder : negated conditional → NO_COVERAGE
            for (int k = size; k >= 0; --k) {
253 2 1. adjustTabOrder : changed conditional boundary → NO_COVERAGE
2. adjustTabOrder : negated conditional → NO_COVERAGE
                if (t.get(k) <= v) {
254 2 1. adjustTabOrder : Replaced integer addition with subtraction → NO_COVERAGE
2. adjustTabOrder : removed call to java/util/List::add → NO_COVERAGE
                    t.add(k + 1, v);
255 2 1. adjustTabOrder : Replaced integer addition with subtraction → NO_COVERAGE
2. adjustTabOrder : removed call to com/lowagie/text/pdf/PdfArray::add → NO_COVERAGE
                    annots.add(k + 1, ind);
256
                    size = -2;
257
                    break;
258
                }
259
            }
260 1 1. adjustTabOrder : negated conditional → NO_COVERAGE
            if (size != -2) {
261 1 1. adjustTabOrder : removed call to java/util/List::add → NO_COVERAGE
                t.add(0, v);
262 1 1. adjustTabOrder : removed call to com/lowagie/text/pdf/PdfArray::add → NO_COVERAGE
                annots.add(0, ind);
263
            }
264
        }
265
    }
266
    
267
    protected PdfArray branchForm(Map<String, Object> level, PdfIndirectReference parent, String fname) throws IOException {
268
        PdfArray arr = new PdfArray();
269
        for (Map.Entry<String, Object> entry : level.entrySet()) {
270
            String name = entry.getKey();
271
            Object obj = entry.getValue();
272
            PdfIndirectReference ind = getPdfIndirectReference();
273
            PdfDictionary dic = new PdfDictionary();
274 1 1. branchForm : negated conditional → NO_COVERAGE
            if (parent != null)
275 1 1. branchForm : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
                dic.put(PdfName.PARENT, parent);
276 1 1. branchForm : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
            dic.put(PdfName.T, new PdfString(name, PdfObject.TEXT_UNICODE));
277
            String fname2 = fname + "." + name;
278
            int coidx = calculationOrder.indexOf(fname2);
279 2 1. branchForm : changed conditional boundary → NO_COVERAGE
2. branchForm : negated conditional → NO_COVERAGE
            if (coidx >= 0)
280
                calculationOrderRefs.set(coidx, ind);
281 1 1. branchForm : negated conditional → NO_COVERAGE
            if (obj instanceof HashMap) {
282 1 1. branchForm : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
                dic.put(PdfName.KIDS, branchForm((Map<String, Object>) obj, ind, fname2));
283
                arr.add(ind);
284
                addToBody(dic, ind);
285
            } else {
286
                ArrayList list = (ArrayList) obj;
287 1 1. branchForm : removed call to com/lowagie/text/pdf/PdfDictionary::mergeDifferent → NO_COVERAGE
                dic.mergeDifferent((PdfDictionary) list.get(0));
288 1 1. branchForm : negated conditional → NO_COVERAGE
                if (list.size() == 3) {
289 1 1. branchForm : removed call to com/lowagie/text/pdf/PdfDictionary::mergeDifferent → NO_COVERAGE
                    dic.mergeDifferent((PdfDictionary) list.get(2));
290
                    int page = (Integer) list.get(1);
291 1 1. branchForm : Replaced integer subtraction with addition → NO_COVERAGE
                    PdfDictionary pageDic = pageDics.get(page - 1);
292
                    PdfArray annots = pageDic.getAsArray(PdfName.ANNOTS);
293 1 1. branchForm : negated conditional → NO_COVERAGE
                    if (annots == null) {
294
                        annots = new PdfArray();
295 1 1. branchForm : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
                        pageDic.put(PdfName.ANNOTS, annots);
296
                    }
297
                    PdfNumber nn = (PdfNumber) dic.get(iTextTag);
298 1 1. branchForm : removed call to com/lowagie/text/pdf/PdfDictionary::remove → NO_COVERAGE
                    dic.remove(iTextTag);
299 1 1. branchForm : removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::adjustTabOrder → NO_COVERAGE
                    adjustTabOrder(annots, ind, nn);
300
                } else {
301
                    PdfArray kids = new PdfArray();
302 3 1. branchForm : changed conditional boundary → NO_COVERAGE
2. branchForm : Changed increment from 2 to -2 → NO_COVERAGE
3. branchForm : negated conditional → NO_COVERAGE
                    for (int k = 1; k < list.size(); k += 2) {
303
                        int page = (Integer) list.get(k);
304 1 1. branchForm : Replaced integer subtraction with addition → NO_COVERAGE
                        PdfDictionary pageDic = pageDics.get(page - 1);
305
                        PdfArray annots = pageDic.getAsArray(PdfName.ANNOTS);
306 1 1. branchForm : negated conditional → NO_COVERAGE
                        if (annots == null) {
307
                            annots = new PdfArray();
308 1 1. branchForm : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
                            pageDic.put(PdfName.ANNOTS, annots);
309
                        }
310
                        PdfDictionary widget = new PdfDictionary();
311 2 1. branchForm : Replaced integer addition with subtraction → NO_COVERAGE
2. branchForm : removed call to com/lowagie/text/pdf/PdfDictionary::merge → NO_COVERAGE
                        widget.merge((PdfDictionary) list.get(k + 1));
312 1 1. branchForm : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
                        widget.put(PdfName.PARENT, ind);
313
                        PdfNumber nn = (PdfNumber) widget.get(iTextTag);
314 1 1. branchForm : removed call to com/lowagie/text/pdf/PdfDictionary::remove → NO_COVERAGE
                        widget.remove(iTextTag);
315
                        PdfIndirectReference wref = addToBody(widget).getIndirectReference();
316 1 1. branchForm : removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::adjustTabOrder → NO_COVERAGE
                        adjustTabOrder(annots, wref, nn);
317
                        kids.add(wref);
318 1 1. branchForm : removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::propagate → NO_COVERAGE
                        propagate(widget, null, false);
319
                    }
320 1 1. branchForm : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
                    dic.put(PdfName.KIDS, kids);
321
                }
322
                arr.add(ind);
323
                addToBody(dic, ind);
324 1 1. branchForm : removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::propagate → NO_COVERAGE
                propagate(dic, null, false);
325
            }
326
        }
327 1 1. branchForm : mutated return of Object value for com/lowagie/text/pdf/PdfCopyFieldsImp::branchForm to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return arr;
328
    }
329
    
330
    protected void createAcroForms() throws IOException {
331 1 1. createAcroForms : negated conditional → NO_COVERAGE
        if (fieldTree.isEmpty())
332
            return;
333
        form = new PdfDictionary();
334 1 1. createAcroForms : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
        form.put(PdfName.DR, resources);
335 1 1. createAcroForms : removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::propagate → NO_COVERAGE
        propagate(resources, null, false);
336 1 1. createAcroForms : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
        form.put(PdfName.DA, new PdfString("/Helv 0 Tf 0 g "));
337
        tabOrder = new HashMap<>();
338
        calculationOrderRefs = new ArrayList<>(calculationOrder);
339 1 1. createAcroForms : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
        form.put(PdfName.FIELDS, branchForm(fieldTree, null, ""));
340 1 1. createAcroForms : negated conditional → NO_COVERAGE
        if (hasSignature)
341 1 1. createAcroForms : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
            form.put(PdfName.SIGFLAGS, new PdfNumber(3));
342
        PdfArray co = new PdfArray();
343
        for (Object obj : calculationOrderRefs) {
344 1 1. createAcroForms : negated conditional → NO_COVERAGE
            if (obj instanceof PdfIndirectReference)
345
                co.add((PdfIndirectReference) obj);
346
        }
347 2 1. createAcroForms : changed conditional boundary → NO_COVERAGE
2. createAcroForms : negated conditional → NO_COVERAGE
        if (co.size() > 0)
348 1 1. createAcroForms : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
            form.put(PdfName.CO, co);
349
    }
350
    
351
    public void close() {
352 1 1. close : negated conditional → NO_COVERAGE
        if (closing) {
353 1 1. close : removed call to com/lowagie/text/pdf/PdfWriter::close → NO_COVERAGE
            super.close();
354
            return;
355
        }
356
        closing = true;
357
        try {
358 1 1. close : removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::closeIt → NO_COVERAGE
            closeIt();
359
        }
360
        catch (Exception e) {
361
            throw new ExceptionConverter(e);
362
        }
363
    }
364
    
365
    /**
366
     * Creates the new PDF by merging the fields and forms.
367
     */
368
    protected void closeIt() throws IOException {
369
        for (PdfReader reader : readers) {
370 1 1. closeIt : removed call to com/lowagie/text/pdf/PdfReader::removeFields → NO_COVERAGE
            reader.removeFields();
371
        }
372
        for (PdfReader reader : readers) {
373 2 1. closeIt : changed conditional boundary → NO_COVERAGE
2. closeIt : negated conditional → NO_COVERAGE
            for (int page = 1; page <= reader.getNumberOfPages(); ++page) {
374
                pageRefs.add(getNewReference(reader.getPageOrigRef(page)));
375
                pageDics.add(reader.getPageN(page));
376
            }
377
        }
378 1 1. closeIt : removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::mergeFields → NO_COVERAGE
        mergeFields();
379 1 1. closeIt : removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::createAcroForms → NO_COVERAGE
        createAcroForms();
380
        for (PdfReader reader : readers) {
381 2 1. closeIt : changed conditional boundary → NO_COVERAGE
2. closeIt : negated conditional → NO_COVERAGE
            for (int page = 1; page <= reader.getNumberOfPages(); ++page) {
382
                PdfDictionary dic = reader.getPageN(page);
383
                PdfIndirectReference pageRef = getNewReference(reader.getPageOrigRef(page));
384
                PdfIndirectReference parent = root.addPageRef(pageRef);
385 1 1. closeIt : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
                dic.put(PdfName.PARENT, parent);
386 1 1. closeIt : removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::propagate → NO_COVERAGE
                propagate(dic, pageRef, false);
387
            }
388
        }
389
        for (Map.Entry<PdfReader, IntHashtable> entry : readers2intrefs.entrySet()) {
390
            PdfReader reader = entry.getKey();
391
            try {
392
                file = reader.getSafeFile();
393 1 1. closeIt : removed call to com/lowagie/text/pdf/RandomAccessFileOrArray::reOpen → NO_COVERAGE
                file.reOpen();
394
                IntHashtable t = entry.getValue();
395
                int[] keys = t.toOrderedKeys();
396
                for (int key : keys) {
397
                    PRIndirectReference ref = new PRIndirectReference(reader, key);
398
                    addToBody(PdfReader.getPdfObjectRelease(ref), t.get(key));
399
                }
400
            } finally {
401
                try {
402 1 1. closeIt : removed call to com/lowagie/text/pdf/RandomAccessFileOrArray::close → NO_COVERAGE
                    file.close();
403 1 1. closeIt : removed call to com/lowagie/text/pdf/PdfReader::close → NO_COVERAGE
                    reader.close();
404
                } catch (Exception e) {
405
                    // empty on purpose
406
                }
407
            }
408
        }
409 1 1. closeIt : removed call to com/lowagie/text/pdf/PdfDocument::close → NO_COVERAGE
        pdf.close();
410
    }
411
    
412
    void addPageOffsetToField(Map<String, Item> fd, int pageOffset) {
413 1 1. addPageOffsetToField : negated conditional → NO_COVERAGE
        if (pageOffset == 0)
414
            return;
415
        for (Item item : fd.values()) {
416 3 1. addPageOffsetToField : changed conditional boundary → NO_COVERAGE
2. addPageOffsetToField : Changed increment from 1 to -1 → NO_COVERAGE
3. addPageOffsetToField : negated conditional → NO_COVERAGE
            for (int k = 0; k < item.size(); ++k) {
417
                int p = item.getPage(k);
418 2 1. addPageOffsetToField : Replaced integer addition with subtraction → NO_COVERAGE
2. addPageOffsetToField : removed call to com/lowagie/text/pdf/AcroFields$Item::forcePage → NO_COVERAGE
                item.forcePage(k, p + pageOffset);
419
            }
420
        }
421
    }
422
423
    void createWidgets(List<Object> list, Item item) {
424 2 1. createWidgets : changed conditional boundary → NO_COVERAGE
2. createWidgets : negated conditional → NO_COVERAGE
        for (int k = 0; k < item.size(); ++k) {
425
            list.add(item.getPage(k));
426
            PdfDictionary merged = item.getMerged(k);
427
            PdfObject dr = merged.get(PdfName.DR);
428 1 1. createWidgets : negated conditional → NO_COVERAGE
            if (dr != null)
429 1 1. createWidgets : removed call to com/lowagie/text/pdf/PdfFormField::mergeResources → NO_COVERAGE
                PdfFormField.mergeResources(resources, (PdfDictionary)PdfReader.getPdfObject(dr));
430
            PdfDictionary widget = new PdfDictionary();
431
            for (PdfName key : merged.getKeys()) {
432 1 1. createWidgets : negated conditional → NO_COVERAGE
                if (widgetKeys.containsKey(key))
433 1 1. createWidgets : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
                    widget.put(key, merged.get(key));
434
            }
435 2 1. createWidgets : Replaced integer addition with subtraction → NO_COVERAGE
2. createWidgets : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
            widget.put(iTextTag, new PdfNumber(item.getTabOrder(k) + 1));
436
            list.add(widget);
437
        }
438
    }
439
    
440
    void mergeField(String name, Item item) {
441
        Map<String, Object> map = fieldTree;
442
        StringTokenizer tk = new StringTokenizer(name, ".");
443 1 1. mergeField : negated conditional → NO_COVERAGE
        if (!tk.hasMoreTokens())
444
            return;
445
        while (true) {
446
            String s = tk.nextToken();
447
            Object obj = map.get(s);
448 1 1. mergeField : negated conditional → NO_COVERAGE
            if (tk.hasMoreTokens()) {
449 1 1. mergeField : negated conditional → NO_COVERAGE
                if (obj == null) {
450
                    obj = new HashMap();
451
                    map.put(s, obj);
452
                    map = (HashMap)obj;
453
                }
454 1 1. mergeField : negated conditional → NO_COVERAGE
                else if (obj instanceof HashMap)
455
                    map = (HashMap)obj;
456
                else
457
                    return;
458
            }
459
            else {
460 1 1. mergeField : negated conditional → NO_COVERAGE
                if (obj instanceof HashMap)
461
                    return;
462
                PdfDictionary merged = item.getMerged(0);
463 1 1. mergeField : negated conditional → NO_COVERAGE
                if (obj == null) {
464
                    PdfDictionary field = new PdfDictionary();
465 1 1. mergeField : negated conditional → NO_COVERAGE
                    if (PdfName.SIG.equals(merged.get(PdfName.FT)))
466
                        hasSignature = true;
467
                    for (PdfName key : merged.getKeys()) {
468 1 1. mergeField : negated conditional → NO_COVERAGE
                        if (fieldKeys.containsKey(key))
469 1 1. mergeField : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
                            field.put(key, merged.get(key));
470
                    }
471
                    List<Object> list = new ArrayList<>();
472
                    list.add(field);
473 1 1. mergeField : removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::createWidgets → NO_COVERAGE
                    createWidgets(list, item);
474
                    map.put(s, list);
475
                }
476
                else {
477
                    List<Object> list = (List<Object>) obj;
478
                    PdfDictionary field = (PdfDictionary)list.get(0);
479
                    PdfName type1 = (PdfName)field.get(PdfName.FT);
480
                    PdfName type2 = (PdfName)merged.get(PdfName.FT);
481 2 1. mergeField : negated conditional → NO_COVERAGE
2. mergeField : negated conditional → NO_COVERAGE
                    if (type1 == null || !type1.equals(type2))
482
                        return;
483
                    int flag1 = 0;
484
                    PdfObject f1 = field.get(PdfName.FF);
485 2 1. mergeField : negated conditional → NO_COVERAGE
2. mergeField : negated conditional → NO_COVERAGE
                    if (f1 != null && f1.isNumber())
486
                        flag1 = ((PdfNumber)f1).intValue();
487
                    int flag2 = 0;
488
                    PdfObject f2 = merged.get(PdfName.FF);
489 2 1. mergeField : negated conditional → NO_COVERAGE
2. mergeField : negated conditional → NO_COVERAGE
                    if (f2 != null && f2.isNumber())
490
                        flag2 = ((PdfNumber)f2).intValue();
491 1 1. mergeField : negated conditional → NO_COVERAGE
                    if (type1.equals(PdfName.BTN)) {
492 3 1. mergeField : Replaced XOR with AND → NO_COVERAGE
2. mergeField : Replaced bitwise AND with OR → NO_COVERAGE
3. mergeField : negated conditional → NO_COVERAGE
                        if (((flag1 ^ flag2) & PdfFormField.FF_PUSHBUTTON) != 0)
493
                            return;
494 5 1. mergeField : Replaced bitwise AND with OR → NO_COVERAGE
2. mergeField : Replaced XOR with AND → NO_COVERAGE
3. mergeField : Replaced bitwise AND with OR → NO_COVERAGE
4. mergeField : negated conditional → NO_COVERAGE
5. mergeField : negated conditional → NO_COVERAGE
                        if ((flag1 & PdfFormField.FF_PUSHBUTTON) == 0 && ((flag1 ^ flag2) & PdfFormField.FF_RADIO) != 0)
495
                            return;
496
                    }
497 1 1. mergeField : negated conditional → NO_COVERAGE
                    else if (type1.equals(PdfName.CH)) {
498 3 1. mergeField : Replaced XOR with AND → NO_COVERAGE
2. mergeField : Replaced bitwise AND with OR → NO_COVERAGE
3. mergeField : negated conditional → NO_COVERAGE
                        if (((flag1 ^ flag2) & PdfFormField.FF_COMBO) != 0)
499
                            return;
500
                    }
501 1 1. mergeField : removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::createWidgets → NO_COVERAGE
                    createWidgets(list, item);
502
                }
503
                return;
504
            }
505
        }
506
    }
507
    
508
    void mergeWithMaster(Map<String, Item> fd) {
509
        for (Map.Entry<String, Item> entry : fd.entrySet()) {
510
            String name = entry.getKey();
511 1 1. mergeWithMaster : removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::mergeField → NO_COVERAGE
            mergeField(name, entry.getValue());
512
        }
513
    }
514
    
515
    void mergeFields() {
516
        int pageOffset = 0;
517 3 1. mergeFields : changed conditional boundary → NO_COVERAGE
2. mergeFields : Changed increment from 1 to -1 → NO_COVERAGE
3. mergeFields : negated conditional → NO_COVERAGE
        for (int k = 0; k < fields.size(); ++k) {
518
            Map<String, Item> fd = fields.get(k).getFields();
519 1 1. mergeFields : removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::addPageOffsetToField → NO_COVERAGE
            addPageOffsetToField(fd, pageOffset);
520 1 1. mergeFields : removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::mergeWithMaster → NO_COVERAGE
            mergeWithMaster(fd);
521 1 1. mergeFields : Replaced integer addition with subtraction → NO_COVERAGE
            pageOffset += readers.get(k).getNumberOfPages();
522
        }
523
    }
524
525
    public PdfIndirectReference getPageReference(int page) {
526 2 1. getPageReference : Replaced integer subtraction with addition → NO_COVERAGE
2. getPageReference : mutated return of Object value for com/lowagie/text/pdf/PdfCopyFieldsImp::getPageReference to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return pageRefs.get(page - 1);
527
    }
528
    
529
    protected PdfDictionary getCatalog(PdfIndirectReference rootObj) {
530
        try {
531
            PdfDictionary cat = pdf.getCatalog(rootObj);
532 1 1. getCatalog : negated conditional → NO_COVERAGE
            if (form != null) {
533
                PdfIndirectReference ref = addToBody(form).getIndirectReference();
534 1 1. getCatalog : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
                cat.put(PdfName.ACROFORM, ref);
535
            }
536 1 1. getCatalog : mutated return of Object value for com/lowagie/text/pdf/PdfCopyFieldsImp::getCatalog to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
            return cat;
537
        }
538
        catch (IOException e) {
539
            throw new ExceptionConverter(e);
540
        }
541
    }
542
543
    protected PdfIndirectReference getNewReference(PRIndirectReference ref) {
544 1 1. getNewReference : mutated return of Object value for com/lowagie/text/pdf/PdfCopyFieldsImp::getNewReference to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return new PdfIndirectReference(0, getNewObjectNumber(ref.getReader(), ref.getNumber(), 0));
545
    }
546
    
547
    protected int getNewObjectNumber(PdfReader reader, int number, int generation) {
548
        IntHashtable refs = readers2intrefs.get(reader);
549
        int n = refs.get(number);
550 1 1. getNewObjectNumber : negated conditional → NO_COVERAGE
        if (n == 0) {
551
            n = getIndirectReferenceNumber();
552
            refs.put(number, n);
553
        }
554 1 1. getNewObjectNumber : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
        return n;
555
    }
556
    
557
    
558
    /**
559
     * Sets a reference to "visited" in the copy process.
560
     * @param    ref    the reference that needs to be set to "visited"
561
     * @return    true if the reference was set to visited
562
     */
563
    protected boolean setVisited(PRIndirectReference ref) {
564
        IntHashtable refs = visited.get(ref.getReader());
565 1 1. setVisited : negated conditional → NO_COVERAGE
        if (refs != null)
566 2 1. setVisited : negated conditional → NO_COVERAGE
2. setVisited : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
            return (refs.put(ref.getNumber(), 1) != 0);
567
        else
568 1 1. setVisited : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
            return false;
569
    }
570
    
571
    /**
572
     * Checks if a reference has already been "visited" in the copy process.
573
     * @param    ref    the reference that needs to be checked
574
     * @return    true if the reference was already visited
575
     */
576
    protected boolean isVisited(PRIndirectReference ref) {
577
        IntHashtable refs = visited.get(ref.getReader());
578 1 1. isVisited : negated conditional → NO_COVERAGE
        if (refs != null)
579 1 1. isVisited : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
            return refs.containsKey(ref.getNumber());
580
        else
581 1 1. isVisited : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
            return false;
582
    }
583
    
584
    protected boolean isVisited(PdfReader reader, int number, int generation) {
585
        IntHashtable refs = readers2intrefs.get(reader);
586 1 1. isVisited : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
        return refs.containsKey(number);
587
    }
588
    
589
    /**
590
     * Checks if a reference refers to a page object.
591
     * @param    ref    the reference that needs to be checked
592
     * @return    true is the reference refers to a page object.
593
     */
594
    protected boolean isPage(PRIndirectReference ref) {
595
        IntHashtable refs = pages2intrefs.get(ref.getReader());
596 1 1. isPage : negated conditional → NO_COVERAGE
        if (refs != null)
597 1 1. isPage : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
            return refs.containsKey(ref.getNumber());
598
        else
599 1 1. isPage : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
            return false;
600
    }
601
602
    RandomAccessFileOrArray getReaderFile(PdfReader reader) {
603
            return file;
604
    }
605
606
    public void openDoc() {
607 1 1. openDoc : negated conditional → NO_COVERAGE
        if (!nd.isOpen())
608 1 1. openDoc : removed call to com/lowagie/text/Document::open → NO_COVERAGE
            nd.open();
609
    }    
610
    
611
    protected static final Map<PdfName, Integer> widgetKeys = new HashMap<>();
612
    protected static final Map<PdfName, Integer> fieldKeys = new HashMap<>();
613
    static {
614
        Integer one = 1;
615
        widgetKeys.put(PdfName.SUBTYPE, one);
616
        widgetKeys.put(PdfName.CONTENTS, one);
617
        widgetKeys.put(PdfName.RECT, one);
618
        widgetKeys.put(PdfName.NM, one);
619
        widgetKeys.put(PdfName.M, one);
620
        widgetKeys.put(PdfName.F, one);
621
        widgetKeys.put(PdfName.BS, one);
622
        widgetKeys.put(PdfName.BORDER, one);
623
        widgetKeys.put(PdfName.AP, one);
624
        widgetKeys.put(PdfName.AS, one);
625
        widgetKeys.put(PdfName.C, one);
626
        widgetKeys.put(PdfName.A, one);
627
        widgetKeys.put(PdfName.STRUCTPARENT, one);
628
        widgetKeys.put(PdfName.OC, one);
629
        widgetKeys.put(PdfName.H, one);
630
        widgetKeys.put(PdfName.MK, one);
631
        widgetKeys.put(PdfName.DA, one);
632
        widgetKeys.put(PdfName.Q, one);
633
        fieldKeys.put(PdfName.AA, one);
634
        fieldKeys.put(PdfName.FT, one);
635
        fieldKeys.put(PdfName.TU, one);
636
        fieldKeys.put(PdfName.TM, one);
637
        fieldKeys.put(PdfName.FF, one);
638
        fieldKeys.put(PdfName.V, one);
639
        fieldKeys.put(PdfName.DV, one);
640
        fieldKeys.put(PdfName.DS, one);
641
        fieldKeys.put(PdfName.RV, one);
642
        fieldKeys.put(PdfName.OPT, one);
643
        fieldKeys.put(PdfName.MAXLEN, one);
644
        fieldKeys.put(PdfName.TI, one);
645
        fieldKeys.put(PdfName.I, one);
646
        fieldKeys.put(PdfName.LOCK, one);
647
        fieldKeys.put(PdfName.SV, one);
648
    }
649
}

Mutations

99

1.1
Location :
Killed by : none
removed call to com/lowagie/text/pdf/PdfDocument::addWriter → NO_COVERAGE

100

1.1
Location :
Killed by : none
negated conditional → NO_COVERAGE

101

1.1
Location :
Killed by : none
removed call to com/lowagie/text/pdf/PdfWriter::setPdfVersion → NO_COVERAGE

103

1.1
Location :
Killed by : none
removed call to com/lowagie/text/Document::addDocListener → NO_COVERAGE

107

1.1
Location : addDocument
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : addDocument
Killed by : none
negated conditional → NO_COVERAGE

110

1.1
Location : addDocument
Killed by : none
removed call to com/lowagie/text/pdf/PdfReader::selectPages → NO_COVERAGE

111

1.1
Location : addDocument
Killed by : none
negated conditional → NO_COVERAGE

113

1.1
Location : addDocument
Killed by : none
removed call to com/lowagie/text/pdf/PdfReader::setTampered → NO_COVERAGE

114

1.1
Location : addDocument
Killed by : none
removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::addDocument → NO_COVERAGE

118

1.1
Location : addDocument
Killed by : none
negated conditional → NO_COVERAGE

120

1.1
Location : addDocument
Killed by : none
removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::openDoc → NO_COVERAGE

121

1.1
Location : addDocument
Killed by : none
negated conditional → NO_COVERAGE

125

1.1
Location : addDocument
Killed by : none
negated conditional → NO_COVERAGE

127

1.1
Location : addDocument
Killed by : none
removed call to com/lowagie/text/pdf/PdfReader::consolidateNamedDestinations → NO_COVERAGE

128

1.1
Location : addDocument
Killed by : none
removed call to com/lowagie/text/pdf/PdfReader::setTampered → NO_COVERAGE

135

1.1
Location : addDocument
Killed by : none
changed conditional boundary → NO_COVERAGE

2.2
Location : addDocument
Killed by : none
Changed increment from 1 to -1 → NO_COVERAGE

3.3
Location : addDocument
Killed by : none
negated conditional → NO_COVERAGE

137

1.1
Location : addDocument
Killed by : none
removed call to com/lowagie/text/pdf/PdfReader::releasePage → NO_COVERAGE

142

1.1
Location : addDocument
Killed by : none
removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::updateCalculationOrder → NO_COVERAGE

147

1.1
Location : getCOName
Killed by : none
negated conditional → NO_COVERAGE

149

1.1
Location : getCOName
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : getCOName
Killed by : none
negated conditional → NO_COVERAGE

153

1.1
Location : getCOName
Killed by : none
negated conditional → NO_COVERAGE

158

1.1
Location : getCOName
Killed by : none
negated conditional → NO_COVERAGE

159

1.1
Location : getCOName
Killed by : none
Replaced integer subtraction with addition → NO_COVERAGE

160

1.1
Location : getCOName
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfCopyFieldsImp::getCOName to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

169

1.1
Location : updateCalculationOrder
Killed by : none
negated conditional → NO_COVERAGE

172

1.1
Location : updateCalculationOrder
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : updateCalculationOrder
Killed by : none
negated conditional → NO_COVERAGE

175

1.1
Location : updateCalculationOrder
Killed by : none
changed conditional boundary → NO_COVERAGE

2.2
Location : updateCalculationOrder
Killed by : none
negated conditional → NO_COVERAGE

177

1.1
Location : updateCalculationOrder
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : updateCalculationOrder
Killed by : none
negated conditional → NO_COVERAGE

180

1.1
Location : updateCalculationOrder
Killed by : none
negated conditional → NO_COVERAGE

183

1.1
Location : updateCalculationOrder
Killed by : none
negated conditional → NO_COVERAGE

190

1.1
Location : propagate
Killed by : none
negated conditional → NO_COVERAGE

194

1.1
Location : propagate
Killed by : none
negated conditional → NO_COVERAGE

201

1.1
Location : propagate
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : propagate
Killed by : none
negated conditional → NO_COVERAGE

3.3
Location : propagate
Killed by : none
negated conditional → NO_COVERAGE

204

1.1
Location : propagate
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : propagate
Killed by : none
negated conditional → NO_COVERAGE

206

1.1
Location : propagate
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : propagate
Killed by : none
negated conditional → NO_COVERAGE

208

1.1
Location : propagate
Killed by : none
removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::propagate → NO_COVERAGE

211

1.1
Location : propagate
Killed by : none
removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::propagate → NO_COVERAGE

217

1.1
Location : propagate
Killed by : none
negated conditional → NO_COVERAGE

219

1.1
Location : propagate
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : propagate
Killed by : none
negated conditional → NO_COVERAGE

221

1.1
Location : propagate
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : propagate
Killed by : none
negated conditional → NO_COVERAGE

223

1.1
Location : propagate
Killed by : none
removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::propagate → NO_COVERAGE

227

1.1
Location : propagate
Killed by : none
removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::propagate → NO_COVERAGE

240

1.1
Location : adjustTabOrder
Killed by : none
negated conditional → NO_COVERAGE

242

1.1
Location : adjustTabOrder
Killed by : none
Replaced integer subtraction with addition → NO_COVERAGE

243

1.1
Location : adjustTabOrder
Killed by : none
changed conditional boundary → NO_COVERAGE

2.2
Location : adjustTabOrder
Killed by : none
Changed increment from 1 to -1 → NO_COVERAGE

3.3
Location : adjustTabOrder
Killed by : none
negated conditional → NO_COVERAGE

251

1.1
Location : adjustTabOrder
Killed by : none
Replaced integer subtraction with addition → NO_COVERAGE

252

1.1
Location : adjustTabOrder
Killed by : none
changed conditional boundary → NO_COVERAGE

2.2
Location : adjustTabOrder
Killed by : none
Changed increment from -1 to 1 → NO_COVERAGE

3.3
Location : adjustTabOrder
Killed by : none
negated conditional → NO_COVERAGE

253

1.1
Location : adjustTabOrder
Killed by : none
changed conditional boundary → NO_COVERAGE

2.2
Location : adjustTabOrder
Killed by : none
negated conditional → NO_COVERAGE

254

1.1
Location : adjustTabOrder
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

2.2
Location : adjustTabOrder
Killed by : none
removed call to java/util/List::add → NO_COVERAGE

255

1.1
Location : adjustTabOrder
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

2.2
Location : adjustTabOrder
Killed by : none
removed call to com/lowagie/text/pdf/PdfArray::add → NO_COVERAGE

260

1.1
Location : adjustTabOrder
Killed by : none
negated conditional → NO_COVERAGE

261

1.1
Location : adjustTabOrder
Killed by : none
removed call to java/util/List::add → NO_COVERAGE

262

1.1
Location : adjustTabOrder
Killed by : none
removed call to com/lowagie/text/pdf/PdfArray::add → NO_COVERAGE

274

1.1
Location : branchForm
Killed by : none
negated conditional → NO_COVERAGE

275

1.1
Location : branchForm
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

276

1.1
Location : branchForm
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

279

1.1
Location : branchForm
Killed by : none
changed conditional boundary → NO_COVERAGE

2.2
Location : branchForm
Killed by : none
negated conditional → NO_COVERAGE

281

1.1
Location : branchForm
Killed by : none
negated conditional → NO_COVERAGE

282

1.1
Location : branchForm
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

287

1.1
Location : branchForm
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::mergeDifferent → NO_COVERAGE

288

1.1
Location : branchForm
Killed by : none
negated conditional → NO_COVERAGE

289

1.1
Location : branchForm
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::mergeDifferent → NO_COVERAGE

291

1.1
Location : branchForm
Killed by : none
Replaced integer subtraction with addition → NO_COVERAGE

293

1.1
Location : branchForm
Killed by : none
negated conditional → NO_COVERAGE

295

1.1
Location : branchForm
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

298

1.1
Location : branchForm
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::remove → NO_COVERAGE

299

1.1
Location : branchForm
Killed by : none
removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::adjustTabOrder → NO_COVERAGE

302

1.1
Location : branchForm
Killed by : none
changed conditional boundary → NO_COVERAGE

2.2
Location : branchForm
Killed by : none
Changed increment from 2 to -2 → NO_COVERAGE

3.3
Location : branchForm
Killed by : none
negated conditional → NO_COVERAGE

304

1.1
Location : branchForm
Killed by : none
Replaced integer subtraction with addition → NO_COVERAGE

306

1.1
Location : branchForm
Killed by : none
negated conditional → NO_COVERAGE

308

1.1
Location : branchForm
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

311

1.1
Location : branchForm
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

2.2
Location : branchForm
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::merge → NO_COVERAGE

312

1.1
Location : branchForm
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

314

1.1
Location : branchForm
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::remove → NO_COVERAGE

316

1.1
Location : branchForm
Killed by : none
removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::adjustTabOrder → NO_COVERAGE

318

1.1
Location : branchForm
Killed by : none
removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::propagate → NO_COVERAGE

320

1.1
Location : branchForm
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

324

1.1
Location : branchForm
Killed by : none
removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::propagate → NO_COVERAGE

327

1.1
Location : branchForm
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfCopyFieldsImp::branchForm to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

331

1.1
Location : createAcroForms
Killed by : none
negated conditional → NO_COVERAGE

334

1.1
Location : createAcroForms
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

335

1.1
Location : createAcroForms
Killed by : none
removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::propagate → NO_COVERAGE

336

1.1
Location : createAcroForms
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

339

1.1
Location : createAcroForms
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

340

1.1
Location : createAcroForms
Killed by : none
negated conditional → NO_COVERAGE

341

1.1
Location : createAcroForms
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

344

1.1
Location : createAcroForms
Killed by : none
negated conditional → NO_COVERAGE

347

1.1
Location : createAcroForms
Killed by : none
changed conditional boundary → NO_COVERAGE

2.2
Location : createAcroForms
Killed by : none
negated conditional → NO_COVERAGE

348

1.1
Location : createAcroForms
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

352

1.1
Location : close
Killed by : none
negated conditional → NO_COVERAGE

353

1.1
Location : close
Killed by : none
removed call to com/lowagie/text/pdf/PdfWriter::close → NO_COVERAGE

358

1.1
Location : close
Killed by : none
removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::closeIt → NO_COVERAGE

370

1.1
Location : closeIt
Killed by : none
removed call to com/lowagie/text/pdf/PdfReader::removeFields → NO_COVERAGE

373

1.1
Location : closeIt
Killed by : none
changed conditional boundary → NO_COVERAGE

2.2
Location : closeIt
Killed by : none
negated conditional → NO_COVERAGE

378

1.1
Location : closeIt
Killed by : none
removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::mergeFields → NO_COVERAGE

379

1.1
Location : closeIt
Killed by : none
removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::createAcroForms → NO_COVERAGE

381

1.1
Location : closeIt
Killed by : none
changed conditional boundary → NO_COVERAGE

2.2
Location : closeIt
Killed by : none
negated conditional → NO_COVERAGE

385

1.1
Location : closeIt
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

386

1.1
Location : closeIt
Killed by : none
removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::propagate → NO_COVERAGE

393

1.1
Location : closeIt
Killed by : none
removed call to com/lowagie/text/pdf/RandomAccessFileOrArray::reOpen → NO_COVERAGE

402

1.1
Location : closeIt
Killed by : none
removed call to com/lowagie/text/pdf/RandomAccessFileOrArray::close → NO_COVERAGE

403

1.1
Location : closeIt
Killed by : none
removed call to com/lowagie/text/pdf/PdfReader::close → NO_COVERAGE

409

1.1
Location : closeIt
Killed by : none
removed call to com/lowagie/text/pdf/PdfDocument::close → NO_COVERAGE

413

1.1
Location : addPageOffsetToField
Killed by : none
negated conditional → NO_COVERAGE

416

1.1
Location : addPageOffsetToField
Killed by : none
changed conditional boundary → NO_COVERAGE

2.2
Location : addPageOffsetToField
Killed by : none
Changed increment from 1 to -1 → NO_COVERAGE

3.3
Location : addPageOffsetToField
Killed by : none
negated conditional → NO_COVERAGE

418

1.1
Location : addPageOffsetToField
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

2.2
Location : addPageOffsetToField
Killed by : none
removed call to com/lowagie/text/pdf/AcroFields$Item::forcePage → NO_COVERAGE

424

1.1
Location : createWidgets
Killed by : none
changed conditional boundary → NO_COVERAGE

2.2
Location : createWidgets
Killed by : none
negated conditional → NO_COVERAGE

428

1.1
Location : createWidgets
Killed by : none
negated conditional → NO_COVERAGE

429

1.1
Location : createWidgets
Killed by : none
removed call to com/lowagie/text/pdf/PdfFormField::mergeResources → NO_COVERAGE

432

1.1
Location : createWidgets
Killed by : none
negated conditional → NO_COVERAGE

433

1.1
Location : createWidgets
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

435

1.1
Location : createWidgets
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

2.2
Location : createWidgets
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

443

1.1
Location : mergeField
Killed by : none
negated conditional → NO_COVERAGE

448

1.1
Location : mergeField
Killed by : none
negated conditional → NO_COVERAGE

449

1.1
Location : mergeField
Killed by : none
negated conditional → NO_COVERAGE

454

1.1
Location : mergeField
Killed by : none
negated conditional → NO_COVERAGE

460

1.1
Location : mergeField
Killed by : none
negated conditional → NO_COVERAGE

463

1.1
Location : mergeField
Killed by : none
negated conditional → NO_COVERAGE

465

1.1
Location : mergeField
Killed by : none
negated conditional → NO_COVERAGE

468

1.1
Location : mergeField
Killed by : none
negated conditional → NO_COVERAGE

469

1.1
Location : mergeField
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

473

1.1
Location : mergeField
Killed by : none
removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::createWidgets → NO_COVERAGE

481

1.1
Location : mergeField
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : mergeField
Killed by : none
negated conditional → NO_COVERAGE

485

1.1
Location : mergeField
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : mergeField
Killed by : none
negated conditional → NO_COVERAGE

489

1.1
Location : mergeField
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : mergeField
Killed by : none
negated conditional → NO_COVERAGE

491

1.1
Location : mergeField
Killed by : none
negated conditional → NO_COVERAGE

492

1.1
Location : mergeField
Killed by : none
Replaced XOR with AND → NO_COVERAGE

2.2
Location : mergeField
Killed by : none
Replaced bitwise AND with OR → NO_COVERAGE

3.3
Location : mergeField
Killed by : none
negated conditional → NO_COVERAGE

494

1.1
Location : mergeField
Killed by : none
Replaced bitwise AND with OR → NO_COVERAGE

2.2
Location : mergeField
Killed by : none
Replaced XOR with AND → NO_COVERAGE

3.3
Location : mergeField
Killed by : none
Replaced bitwise AND with OR → NO_COVERAGE

4.4
Location : mergeField
Killed by : none
negated conditional → NO_COVERAGE

5.5
Location : mergeField
Killed by : none
negated conditional → NO_COVERAGE

497

1.1
Location : mergeField
Killed by : none
negated conditional → NO_COVERAGE

498

1.1
Location : mergeField
Killed by : none
Replaced XOR with AND → NO_COVERAGE

2.2
Location : mergeField
Killed by : none
Replaced bitwise AND with OR → NO_COVERAGE

3.3
Location : mergeField
Killed by : none
negated conditional → NO_COVERAGE

501

1.1
Location : mergeField
Killed by : none
removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::createWidgets → NO_COVERAGE

511

1.1
Location : mergeWithMaster
Killed by : none
removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::mergeField → NO_COVERAGE

517

1.1
Location : mergeFields
Killed by : none
changed conditional boundary → NO_COVERAGE

2.2
Location : mergeFields
Killed by : none
Changed increment from 1 to -1 → NO_COVERAGE

3.3
Location : mergeFields
Killed by : none
negated conditional → NO_COVERAGE

519

1.1
Location : mergeFields
Killed by : none
removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::addPageOffsetToField → NO_COVERAGE

520

1.1
Location : mergeFields
Killed by : none
removed call to com/lowagie/text/pdf/PdfCopyFieldsImp::mergeWithMaster → NO_COVERAGE

521

1.1
Location : mergeFields
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

526

1.1
Location : getPageReference
Killed by : none
Replaced integer subtraction with addition → NO_COVERAGE

2.2
Location : getPageReference
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfCopyFieldsImp::getPageReference to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

532

1.1
Location : getCatalog
Killed by : none
negated conditional → NO_COVERAGE

534

1.1
Location : getCatalog
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

536

1.1
Location : getCatalog
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfCopyFieldsImp::getCatalog to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

544

1.1
Location : getNewReference
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfCopyFieldsImp::getNewReference to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

550

1.1
Location : getNewObjectNumber
Killed by : none
negated conditional → NO_COVERAGE

554

1.1
Location : getNewObjectNumber
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

565

1.1
Location : setVisited
Killed by : none
negated conditional → NO_COVERAGE

566

1.1
Location : setVisited
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : setVisited
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

568

1.1
Location : setVisited
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

578

1.1
Location : isVisited
Killed by : none
negated conditional → NO_COVERAGE

579

1.1
Location : isVisited
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

581

1.1
Location : isVisited
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

586

1.1
Location : isVisited
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

596

1.1
Location : isPage
Killed by : none
negated conditional → NO_COVERAGE

597

1.1
Location : isPage
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

599

1.1
Location : isPage
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

607

1.1
Location : openDoc
Killed by : none
negated conditional → NO_COVERAGE

608

1.1
Location : openDoc
Killed by : none
removed call to com/lowagie/text/Document::open → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.4.2