EnumerateTTC.java

1
/*
2
 * $Id: EnumerateTTC.java 4065 2009-09-16 23:09:11Z psoares33 $
3
 * $Name$
4
 *
5
 * Copyright 2001, 2002 by Paulo Soares.
6
 *
7
 * The contents of this file are subject to the Mozilla Public License Version 1.1
8
 * (the "License"); you may not use this file except in compliance with the License.
9
 * You may obtain a copy of the License at http://www.mozilla.org/MPL/
10
 *
11
 * Software distributed under the License is distributed on an "AS IS" basis,
12
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13
 * for the specific language governing rights and limitations under the License.
14
 *
15
 * The Original Code is 'iText, a free JAVA-PDF library'.
16
 *
17
 * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
18
 * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
19
 * All Rights Reserved.
20
 * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
21
 * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
22
 *
23
 * Contributor(s): all the names of the contributors are added in the source code
24
 * where applicable.
25
 *
26
 * Alternatively, the contents of this file may be used under the terms of the
27
 * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
28
 * provisions of LGPL are applicable instead of those above.  If you wish to
29
 * allow use of your version of this file only under the terms of the LGPL
30
 * License and not to allow others to use your version of this file under
31
 * the MPL, indicate your decision by deleting the provisions above and
32
 * replace them with the notice and other provisions required by the LGPL.
33
 * If you do not delete the provisions above, a recipient may use your version
34
 * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
35
 *
36
 * This library is free software; you can redistribute it and/or modify it
37
 * under the terms of the MPL as stated above or under the terms of the GNU
38
 * Library General Public License as published by the Free Software Foundation;
39
 * either version 2 of the License, or any later version.
40
 *
41
 * This library is distributed in the hope that it will be useful, but WITHOUT
42
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
43
 * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
44
 * details.
45
 *
46
 * If you didn't download this code from the following link, you should check if
47
 * you aren't using an obsolete version:
48
 * http://www.lowagie.com/iText/
49
 */
50
51
package com.lowagie.text.pdf;
52
53
import java.io.IOException;
54
import java.util.HashMap;
55
import com.lowagie.text.error_messages.MessageLocalization;
56
57
import com.lowagie.text.DocumentException;
58
/** Enumerates all the fonts inside a True Type Collection.
59
 *
60
 * @author  Paulo Soares (psoares@consiste.pt)
61
 */
62
class EnumerateTTC extends TrueTypeFont{
63
64
    protected String[] names;
65
66
    EnumerateTTC(String ttcFile) throws DocumentException, IOException {
67
        fileName = ttcFile;
68
        rf = new RandomAccessFileOrArray(ttcFile);
69 1 1. : removed call to com/lowagie/text/pdf/EnumerateTTC::findNames → NO_COVERAGE
        findNames();
70
    }
71
72
    EnumerateTTC(byte[] ttcArray) throws DocumentException, IOException {
73
        fileName = "Byte array TTC";
74
        rf = new RandomAccessFileOrArray(ttcArray);
75 1 1. : removed call to com/lowagie/text/pdf/EnumerateTTC::findNames → NO_COVERAGE
        findNames();
76
    }
77
    
78
    void findNames() throws DocumentException, IOException {
79
        tables = new HashMap();
80
        
81
        try {
82
            String mainTag = readStandardString(4);
83 1 1. findNames : negated conditional → NO_COVERAGE
            if (!mainTag.equals("ttcf"))
84
                throw new DocumentException(MessageLocalization.getComposedMessage("1.is.not.a.valid.ttc.file", fileName));
85
            rf.skipBytes(4);
86
            int dirCount = rf.readInt();
87
            names = new String[dirCount];
88
            int dirPos = rf.getFilePointer();
89 3 1. findNames : changed conditional boundary → NO_COVERAGE
2. findNames : Changed increment from 1 to -1 → NO_COVERAGE
3. findNames : negated conditional → NO_COVERAGE
            for (int dirIdx = 0; dirIdx < dirCount; ++dirIdx) {
90 1 1. findNames : removed call to java/util/HashMap::clear → NO_COVERAGE
                tables.clear();
91 1 1. findNames : removed call to com/lowagie/text/pdf/RandomAccessFileOrArray::seek → NO_COVERAGE
                rf.seek(dirPos);
92 1 1. findNames : Replaced integer multiplication with division → NO_COVERAGE
                rf.skipBytes(dirIdx * 4);
93
                directoryOffset = rf.readInt();
94 1 1. findNames : removed call to com/lowagie/text/pdf/RandomAccessFileOrArray::seek → NO_COVERAGE
                rf.seek(directoryOffset);
95 1 1. findNames : negated conditional → NO_COVERAGE
                if (rf.readInt() != 0x00010000)
96
                    throw new DocumentException(MessageLocalization.getComposedMessage("1.is.not.a.valid.ttf.file", fileName));
97
                int num_tables = rf.readUnsignedShort();
98
                rf.skipBytes(6);
99 3 1. findNames : changed conditional boundary → NO_COVERAGE
2. findNames : Changed increment from 1 to -1 → NO_COVERAGE
3. findNames : negated conditional → NO_COVERAGE
                for (int k = 0; k < num_tables; ++k) {
100
                    String tag = readStandardString(4);
101
                    rf.skipBytes(4);
102
                    int[] table_location = new int[2];
103
                    table_location[0] = rf.readInt();
104
                    table_location[1] = rf.readInt();
105
                    tables.put(tag, table_location);
106
                }
107
                names[dirIdx] = getBaseFont();
108
            }
109
        }
110
        finally {
111 1 1. findNames : negated conditional → NO_COVERAGE
            if (rf != null)
112 1 1. findNames : removed call to com/lowagie/text/pdf/RandomAccessFileOrArray::close → NO_COVERAGE
                rf.close();
113
        }
114
    }
115
    
116
    String[] getNames() {
117
        return names;
118
    }
119
120
}

Mutations

69

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

75

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

83

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

89

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

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

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

90

1.1
Location : findNames
Killed by : none
removed call to java/util/HashMap::clear → NO_COVERAGE

91

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

92

1.1
Location : findNames
Killed by : none
Replaced integer multiplication with division → NO_COVERAGE

94

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

95

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

99

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

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

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

111

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

112

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

Active mutators

Tests examined


Report generated by PIT 1.4.2