git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1761019 13f79535-47bb-0310-9956-ffa450edef68pull/3/head
if (result == null) { | if (result == null) { | ||||
throw new IllegalArgumentException("Unknown resource type name: " + resourceTypeName); | throw new IllegalArgumentException("Unknown resource type name: " + resourceTypeName); | ||||
} | } | ||||
return result.byteValue(); | |||||
return result; | |||||
} | } | ||||
private Map defaultResourceLevels = new java.util.HashMap(); | private Map defaultResourceLevels = new java.util.HashMap(); |
SortedMap<Integer, CharacterSet> smallerSizes = charSets.headMap(requestedSize); | SortedMap<Integer, CharacterSet> smallerSizes = charSets.headMap(requestedSize); | ||||
SortedMap<Integer, CharacterSet> largerSizes = charSets.tailMap(requestedSize); | SortedMap<Integer, CharacterSet> largerSizes = charSets.tailMap(requestedSize); | ||||
int smallerSize = smallerSizes.isEmpty() ? 0 | int smallerSize = smallerSizes.isEmpty() ? 0 | ||||
: smallerSizes.lastKey().intValue(); | |||||
: smallerSizes.lastKey(); | |||||
int largerSize = largerSizes.isEmpty() ? Integer.MAX_VALUE | int largerSize = largerSizes.isEmpty() ? Integer.MAX_VALUE | ||||
: largerSizes.firstKey().intValue(); | |||||
: largerSizes.firstKey(); | |||||
Integer fontSize; | Integer fontSize; | ||||
if (!smallerSizes.isEmpty() | if (!smallerSizes.isEmpty() | ||||
} | } | ||||
substitutionCharSets.put(requestedSize, csm); | substitutionCharSets.put(requestedSize, csm); | ||||
// do not output the warning if the font size is closer to an integer less than 0.1 | // do not output the warning if the font size is closer to an integer less than 0.1 | ||||
if (!(Math.abs(fontSize.intValue() / 1000.0 - sizeInPt) < 0.1)) { | |||||
if (!(Math.abs(fontSize / 1000.0 - sizeInPt) < 0.1)) { | |||||
String msg = "No " + sizeInPt + "pt font " + getFontName() | String msg = "No " + sizeInPt + "pt font " + getFontName() | ||||
+ " found, substituted with " + fontSize.intValue() / 1000f + "pt font"; | |||||
+ " found, substituted with " + fontSize / 1000f + "pt font"; | |||||
LOG.warn(msg); | LOG.warn(msg); | ||||
} | } | ||||
} | } |
public boolean isAccessibilityEnabled() { | public boolean isAccessibilityEnabled() { | ||||
Boolean enabled = (Boolean)this.getRendererOptions().get(Accessibility.ACCESSIBILITY); | Boolean enabled = (Boolean)this.getRendererOptions().get(Accessibility.ACCESSIBILITY); | ||||
if (enabled != null) { | if (enabled != null) { | ||||
return enabled.booleanValue(); | |||||
return enabled; | |||||
} else { | } else { | ||||
return false; | return false; | ||||
} | } |
if (it.hasNext()) { | if (it.hasNext()) { | ||||
Object o = it.next(); | Object o = it.next(); | ||||
if (o instanceof Integer) { | if (o instanceof Integer) { | ||||
firstGlyph = ((Integer) o) .intValue(); | |||||
firstGlyph = (Integer) o; | |||||
} else { | } else { | ||||
throw new AdvancedTypographicTableFormatException("illegal entry, first entry must be Integer denoting first glyph value, but is: " + o); | throw new AdvancedTypographicTableFormatException("illegal entry, first entry must be Integer denoting first glyph value, but is: " + o); | ||||
} | } | ||||
while (it.hasNext()) { | while (it.hasNext()) { | ||||
Object o = it.next(); | Object o = it.next(); | ||||
if (o instanceof Integer) { | if (o instanceof Integer) { | ||||
int gc = ((Integer) o) .intValue(); | |||||
int gc = (Integer) o; | |||||
gca [ i++ ] = gc; | gca [ i++ ] = gc; | ||||
if (gc > gcMax) { | if (gc > gcMax) { | ||||
gcMax = gc; | gcMax = gc; |
for (Iterator it = entries.iterator(); it.hasNext();) { | for (Iterator it = entries.iterator(); it.hasNext();) { | ||||
Object o = it.next(); | Object o = it.next(); | ||||
if (o instanceof Integer) { | if (o instanceof Integer) { | ||||
int gid = ((Integer) o) .intValue(); | |||||
int gid = (Integer) o; | |||||
if ((gid >= 0) && (gid < 65536)) { | if ((gid >= 0) && (gid < 65536)) { | ||||
if (gid > gidMax) { | if (gid > gidMax) { | ||||
map [ i++ ] = gidMax = gid; | map [ i++ ] = gidMax = gid; |
if (((o = entries.get(2)) == null) || !(o instanceof Integer)) { | if (((o = entries.get(2)) == null) || !(o instanceof Integer)) { | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, third entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); | throw new AdvancedTypographicTableFormatException("illegal entries, third entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
nc1 = ((Integer)(o)).intValue(); | |||||
nc1 = (Integer) (o); | |||||
} | } | ||||
if (((o = entries.get(3)) == null) || !(o instanceof Integer)) { | if (((o = entries.get(3)) == null) || !(o instanceof Integer)) { | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, fourth entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); | throw new AdvancedTypographicTableFormatException("illegal entries, fourth entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
nc2 = ((Integer)(o)).intValue(); | |||||
nc2 = (Integer) (o); | |||||
} | } | ||||
if (((o = entries.get(4)) == null) || !(o instanceof PairValues[][])) { | if (((o = entries.get(4)) == null) || !(o instanceof PairValues[][])) { | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, fifth entry must be a PairValues[][], but is: " + ((o != null) ? o.getClass() : null)); | throw new AdvancedTypographicTableFormatException("illegal entries, fifth entry must be a PairValues[][], but is: " + ((o != null) ? o.getClass() : null)); | ||||
if (((o = entries.get(1)) == null) || !(o instanceof Integer)) { | if (((o = entries.get(1)) == null) || !(o instanceof Integer)) { | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, second entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); | throw new AdvancedTypographicTableFormatException("illegal entries, second entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
nmc = ((Integer)(o)).intValue(); | |||||
nmc = (Integer) (o); | |||||
} | } | ||||
if (((o = entries.get(2)) == null) || !(o instanceof MarkAnchor[])) { | if (((o = entries.get(2)) == null) || !(o instanceof MarkAnchor[])) { | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, third entry must be a MarkAnchor[], but is: " + ((o != null) ? o.getClass() : null)); | throw new AdvancedTypographicTableFormatException("illegal entries, third entry must be a MarkAnchor[], but is: " + ((o != null) ? o.getClass() : null)); | ||||
if (((o = entries.get(1)) == null) || !(o instanceof Integer)) { | if (((o = entries.get(1)) == null) || !(o instanceof Integer)) { | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, second entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); | throw new AdvancedTypographicTableFormatException("illegal entries, second entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
nmc = ((Integer)(o)).intValue(); | |||||
nmc = (Integer) (o); | |||||
} | } | ||||
if (((o = entries.get(2)) == null) || !(o instanceof Integer)) { | if (((o = entries.get(2)) == null) || !(o instanceof Integer)) { | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, third entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); | throw new AdvancedTypographicTableFormatException("illegal entries, third entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
mxc = ((Integer)(o)).intValue(); | |||||
mxc = (Integer) (o); | |||||
} | } | ||||
if (((o = entries.get(3)) == null) || !(o instanceof MarkAnchor[])) { | if (((o = entries.get(3)) == null) || !(o instanceof MarkAnchor[])) { | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, fourth entry must be a MarkAnchor[], but is: " + ((o != null) ? o.getClass() : null)); | throw new AdvancedTypographicTableFormatException("illegal entries, fourth entry must be a MarkAnchor[], but is: " + ((o != null) ? o.getClass() : null)); | ||||
if (((o = entries.get(1)) == null) || !(o instanceof Integer)) { | if (((o = entries.get(1)) == null) || !(o instanceof Integer)) { | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, second entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); | throw new AdvancedTypographicTableFormatException("illegal entries, second entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
nmc = ((Integer)(o)).intValue(); | |||||
nmc = (Integer) (o); | |||||
} | } | ||||
if (((o = entries.get(2)) == null) || !(o instanceof MarkAnchor[])) { | if (((o = entries.get(2)) == null) || !(o instanceof MarkAnchor[])) { | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, third entry must be a MarkAnchor[], but is: " + ((o != null) ? o.getClass() : null)); | throw new AdvancedTypographicTableFormatException("illegal entries, third entry must be a MarkAnchor[], but is: " + ((o != null) ? o.getClass() : null)); | ||||
if (((o = entries.get(1)) == null) || !(o instanceof Integer)) { | if (((o = entries.get(1)) == null) || !(o instanceof Integer)) { | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, second entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); | throw new AdvancedTypographicTableFormatException("illegal entries, second entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
ngc = ((Integer)(o)).intValue(); | |||||
ngc = (Integer) (o); | |||||
} | } | ||||
if (((o = entries.get(2)) == null) || !(o instanceof RuleSet[])) { | if (((o = entries.get(2)) == null) || !(o instanceof RuleSet[])) { | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, third entry must be an RuleSet[], but is: " + ((o != null) ? o.getClass() : null)); | throw new AdvancedTypographicTableFormatException("illegal entries, third entry must be an RuleSet[], but is: " + ((o != null) ? o.getClass() : null)); | ||||
if (((o = entries.get(3)) == null) || !(o instanceof Integer)) { | if (((o = entries.get(3)) == null) || !(o instanceof Integer)) { | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, fourth entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); | throw new AdvancedTypographicTableFormatException("illegal entries, fourth entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
ngc = ((Integer)(o)).intValue(); | |||||
ngc = (Integer) (o); | |||||
} | } | ||||
if (((o = entries.get(4)) == null) || !(o instanceof RuleSet[])) { | if (((o = entries.get(4)) == null) || !(o instanceof RuleSet[])) { | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, fifth entry must be an RuleSet[], but is: " + ((o != null) ? o.getClass() : null)); | throw new AdvancedTypographicTableFormatException("illegal entries, fifth entry must be an RuleSet[], but is: " + ((o != null) ? o.getClass() : null)); |
Object o = entries.get(0); | Object o = entries.get(0); | ||||
int delta = 0; | int delta = 0; | ||||
if (o instanceof Integer) { | if (o instanceof Integer) { | ||||
delta = ((Integer) o) .intValue(); | |||||
delta = (Integer) o; | |||||
} else { | } else { | ||||
throw new AdvancedTypographicTableFormatException("illegal entries entry, must be Integer, but is: " + o); | throw new AdvancedTypographicTableFormatException("illegal entries entry, must be Integer, but is: " + o); | ||||
} | } | ||||
for (Iterator it = entries.iterator(); it.hasNext();) { | for (Iterator it = entries.iterator(); it.hasNext();) { | ||||
Object o = it.next(); | Object o = it.next(); | ||||
if (o instanceof Integer) { | if (o instanceof Integer) { | ||||
int gid = ((Integer) o) .intValue(); | |||||
int gid = (Integer) o; | |||||
if ((gid >= 0) && (gid < 65536)) { | if ((gid >= 0) && (gid < 65536)) { | ||||
glyphs [ i++ ] = gid; | glyphs [ i++ ] = gid; | ||||
} else { | } else { | ||||
if (((o = entries.get(1)) == null) || !(o instanceof Integer)) { | if (((o = entries.get(1)) == null) || !(o instanceof Integer)) { | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, second entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); | throw new AdvancedTypographicTableFormatException("illegal entries, second entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
ngc = ((Integer)(o)).intValue(); | |||||
ngc = (Integer) (o); | |||||
} | } | ||||
if (((o = entries.get(2)) == null) || !(o instanceof RuleSet[])) { | if (((o = entries.get(2)) == null) || !(o instanceof RuleSet[])) { | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, third entry must be an RuleSet[], but is: " + ((o != null) ? o.getClass() : null)); | throw new AdvancedTypographicTableFormatException("illegal entries, third entry must be an RuleSet[], but is: " + ((o != null) ? o.getClass() : null)); | ||||
if (((o = entries.get(3)) == null) || !(o instanceof Integer)) { | if (((o = entries.get(3)) == null) || !(o instanceof Integer)) { | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, fourth entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); | throw new AdvancedTypographicTableFormatException("illegal entries, fourth entry must be an Integer, but is: " + ((o != null) ? o.getClass() : null)); | ||||
} else { | } else { | ||||
ngc = ((Integer)(o)).intValue(); | |||||
ngc = (Integer) (o); | |||||
} | } | ||||
if (((o = entries.get(4)) == null) || !(o instanceof RuleSet[])) { | if (((o = entries.get(4)) == null) || !(o instanceof RuleSet[])) { | ||||
throw new AdvancedTypographicTableFormatException("illegal entries, fifth entry must be an RuleSet[], but is: " + ((o != null) ? o.getClass() : null)); | throw new AdvancedTypographicTableFormatException("illegal entries, fifth entry must be an RuleSet[], but is: " + ((o != null) ? o.getClass() : null)); |
Integer sf = (Integer) stp[5]; // subtable format | Integer sf = (Integer) stp[5]; // subtable format | ||||
GlyphMappingTable mapping = (GlyphMappingTable) stp[6]; | GlyphMappingTable mapping = (GlyphMappingTable) stp[6]; | ||||
List entries = (List) stp[7]; | List entries = (List) stp[7]; | ||||
if (tt.intValue() == GlyphTable.GLYPH_TABLE_TYPE_DEFINITION) { | |||||
if (tt == GlyphTable.GLYPH_TABLE_TYPE_DEFINITION) { | |||||
int type = GDEFLookupType.getSubtableType(lt.intValue()); | int type = GDEFLookupType.getSubtableType(lt.intValue()); | ||||
String lid = "lu" + ln.intValue(); | |||||
int sequence = sn.intValue(); | |||||
int flags = lf.intValue(); | |||||
int format = sf.intValue(); | |||||
String lid = "lu" + ln; | |||||
int sequence = sn; | |||||
int flags = lf; | |||||
int format = sf; | |||||
st = GlyphDefinitionTable.createSubtable(type, lid, sequence, flags, format, mapping, entries); | st = GlyphDefinitionTable.createSubtable(type, lid, sequence, flags, format, mapping, entries); | ||||
} | } | ||||
return st; | return st; | ||||
Integer sf = (Integer) stp[5]; // subtable format | Integer sf = (Integer) stp[5]; // subtable format | ||||
GlyphCoverageTable coverage = (GlyphCoverageTable) stp[6]; | GlyphCoverageTable coverage = (GlyphCoverageTable) stp[6]; | ||||
List entries = (List) stp[7]; | List entries = (List) stp[7]; | ||||
if (tt.intValue() == GlyphTable.GLYPH_TABLE_TYPE_SUBSTITUTION) { | |||||
if (tt == GlyphTable.GLYPH_TABLE_TYPE_SUBSTITUTION) { | |||||
int type = GSUBLookupType.getSubtableType(lt.intValue()); | int type = GSUBLookupType.getSubtableType(lt.intValue()); | ||||
String lid = "lu" + ln.intValue(); | |||||
int sequence = sn.intValue(); | |||||
int flags = lf.intValue(); | |||||
int format = sf.intValue(); | |||||
String lid = "lu" + ln; | |||||
int sequence = sn; | |||||
int flags = lf; | |||||
int format = sf; | |||||
st = GlyphSubstitutionTable.createSubtable(type, lid, sequence, flags, format, coverage, entries); | st = GlyphSubstitutionTable.createSubtable(type, lid, sequence, flags, format, coverage, entries); | ||||
} | } | ||||
return st; | return st; | ||||
Integer sf = (Integer) stp[5]; // subtable format | Integer sf = (Integer) stp[5]; // subtable format | ||||
GlyphCoverageTable coverage = (GlyphCoverageTable) stp[6]; | GlyphCoverageTable coverage = (GlyphCoverageTable) stp[6]; | ||||
List entries = (List) stp[7]; | List entries = (List) stp[7]; | ||||
if (tt.intValue() == GlyphTable.GLYPH_TABLE_TYPE_POSITIONING) { | |||||
if (tt == GlyphTable.GLYPH_TABLE_TYPE_POSITIONING) { | |||||
int type = GSUBLookupType.getSubtableType(lt.intValue()); | int type = GSUBLookupType.getSubtableType(lt.intValue()); | ||||
String lid = "lu" + ln.intValue(); | |||||
int sequence = sn.intValue(); | |||||
int flags = lf.intValue(); | |||||
int format = sf.intValue(); | |||||
String lid = "lu" + ln; | |||||
int sequence = sn; | |||||
int flags = lf; | |||||
int format = sf; | |||||
st = GlyphPositioningTable.createSubtable(type, lid, sequence, flags, format, coverage, entries); | st = GlyphPositioningTable.createSubtable(type, lid, sequence, flags, format, coverage, entries); | ||||
} | } | ||||
return st; | return st; |
private static boolean containsHalfConsonant(GlyphSequence gs, int k) { | private static boolean containsHalfConsonant(GlyphSequence gs, int k) { | ||||
Boolean half = (Boolean) gs.getAssociation(k) .getPredication("half"); | Boolean half = (Boolean) gs.getAssociation(k) .getPredication("half"); | ||||
return (half != null) ? half.booleanValue() : false; | |||||
return (half != null) ? half : false; | |||||
} | } | ||||
@Override | @Override | ||||
private static boolean containsReph(GlyphSequence gs, int k) { | private static boolean containsReph(GlyphSequence gs, int k) { | ||||
Boolean rphf = (Boolean) gs.getAssociation(k) .getPredication("rphf"); | Boolean rphf = (Boolean) gs.getAssociation(k) .getPredication("rphf"); | ||||
return (rphf != null) ? rphf.booleanValue() : false; | |||||
return (rphf != null) ? rphf : false; | |||||
} | } | ||||
private static boolean containsMatra(GlyphSequence gs, int k) { | private static boolean containsMatra(GlyphSequence gs, int k) { |
private static boolean containsHalfConsonant(GlyphSequence gs, int k) { | private static boolean containsHalfConsonant(GlyphSequence gs, int k) { | ||||
Boolean half = (Boolean) gs.getAssociation(k) .getPredication("half"); | Boolean half = (Boolean) gs.getAssociation(k) .getPredication("half"); | ||||
return (half != null) ? half.booleanValue() : false; | |||||
return (half != null) ? half : false; | |||||
} | } | ||||
@Override | @Override | ||||
private static boolean containsReph(GlyphSequence gs, int k) { | private static boolean containsReph(GlyphSequence gs, int k) { | ||||
Boolean rphf = (Boolean) gs.getAssociation(k) .getPredication("rphf"); | Boolean rphf = (Boolean) gs.getAssociation(k) .getPredication("rphf"); | ||||
return (rphf != null) ? rphf.booleanValue() : false; | |||||
return (rphf != null) ? rphf : false; | |||||
} | } | ||||
private static boolean containsMatra(GlyphSequence gs, int k) { | private static boolean containsMatra(GlyphSequence gs, int k) { |
private static boolean containsHalfConsonant(GlyphSequence gs, int k) { | private static boolean containsHalfConsonant(GlyphSequence gs, int k) { | ||||
Boolean half = (Boolean) gs.getAssociation(k) .getPredication("half"); | Boolean half = (Boolean) gs.getAssociation(k) .getPredication("half"); | ||||
return (half != null) ? half.booleanValue() : false; | |||||
return (half != null) ? half : false; | |||||
} | } | ||||
@Override | @Override | ||||
private static boolean containsReph(GlyphSequence gs, int k) { | private static boolean containsReph(GlyphSequence gs, int k) { | ||||
Boolean rphf = (Boolean) gs.getAssociation(k) .getPredication("rphf"); | Boolean rphf = (Boolean) gs.getAssociation(k) .getPredication("rphf"); | ||||
return (rphf != null) ? rphf.booleanValue() : false; | |||||
return (rphf != null) ? rphf : false; | |||||
} | } | ||||
private static boolean containsMatra(GlyphSequence gs, int k) { | private static boolean containsMatra(GlyphSequence gs, int k) { |
private static boolean containsHalfConsonant(GlyphSequence gs, int k) { | private static boolean containsHalfConsonant(GlyphSequence gs, int k) { | ||||
Boolean half = (Boolean) gs.getAssociation(k).getPredication("half"); | Boolean half = (Boolean) gs.getAssociation(k).getPredication("half"); | ||||
return (half != null) ? half.booleanValue() : false; | |||||
return (half != null) ? half : false; | |||||
} | } | ||||
@Override | @Override | ||||
private static boolean containsReph(GlyphSequence gs, int k) { | private static boolean containsReph(GlyphSequence gs, int k) { | ||||
Boolean rphf = (Boolean) gs.getAssociation(k).getPredication("rphf"); | Boolean rphf = (Boolean) gs.getAssociation(k).getPredication("rphf"); | ||||
return (rphf != null) ? rphf.booleanValue() : false; | |||||
return (rphf != null) ? rphf : false; | |||||
} | } | ||||
private static boolean containsMatra(GlyphSequence gs, int k) { | private static boolean containsMatra(GlyphSequence gs, int k) { |
int[] sa = new int [ s.size() ]; | int[] sa = new int [ s.size() ]; | ||||
int ns = 0; | int ns = 0; | ||||
for (Iterator it = s.iterator(); it.hasNext();) { | for (Iterator it = s.iterator(); it.hasNext();) { | ||||
sa [ ns++ ] = ((Integer) it.next()) .intValue(); | |||||
sa [ ns++ ] = (Integer) it.next(); | |||||
} | } | ||||
Arrays.sort(sa); | Arrays.sort(sa); | ||||
return sa; | return sa; | ||||
Integer k = s; | Integer k = s; | ||||
Integer v = (Integer) m.get(k); | Integer v = (Integer) m.get(k); | ||||
if (v != null) { | if (v != null) { | ||||
m.put(k, v.intValue() + 1); | |||||
m.put(k, v + 1); | |||||
} else { | } else { | ||||
m.put(k, 0); | m.put(k, 0); | ||||
} | } | ||||
for (Iterator it = m.entrySet().iterator(); it.hasNext();) { | for (Iterator it = m.entrySet().iterator(); it.hasNext();) { | ||||
Map.Entry e = (Map.Entry) it.next(); | Map.Entry e = (Map.Entry) it.next(); | ||||
Integer k = (Integer) e.getKey(); | Integer k = (Integer) e.getKey(); | ||||
int s = k.intValue(); | |||||
int s = k; | |||||
switch (s) { | switch (s) { | ||||
case SCRIPT_UNDETERMINED: | case SCRIPT_UNDETERMINED: | ||||
case SCRIPT_UNCODED: | case SCRIPT_UNCODED: | ||||
default: | default: | ||||
Integer v = (Integer) e.getValue(); | Integer v = (Integer) e.getValue(); | ||||
assert v != null; | assert v != null; | ||||
int c = v.intValue(); | |||||
int c = v; | |||||
if (c > cMax) { | if (c > cMax) { | ||||
cMax = c; | cMax = c; | ||||
sMax = s; | sMax = s; |
if (number < 0) { | if (number < 0) { | ||||
throw new IllegalArgumentException("number must be non-negative"); | throw new IllegalArgumentException("number must be non-negative"); | ||||
} else if (token.length == 1) { | } else if (token.length == 1) { | ||||
int s = token[0].intValue(); | |||||
int s = token[0]; | |||||
switch (s) { | switch (s) { | ||||
case (int) '1': | case (int) '1': | ||||
fn = formatNumberAsDecimal(number, (int) '1', 1); | fn = formatNumberAsDecimal(number, (int) '1', 1); | ||||
} else if ((token.length == 2) && (token[0] == (int) 'W') && (token[1] == (int) 'w')) { | } else if ((token.length == 2) && (token[0] == (int) 'W') && (token[1] == (int) 'w')) { | ||||
fn = formatNumberAsWord(number, Character.TITLECASE_LETTER); | fn = formatNumberAsWord(number, Character.TITLECASE_LETTER); | ||||
} else if (isPaddedOne(token)) { | } else if (isPaddedOne(token)) { | ||||
int s = token [ token.length - 1 ].intValue(); | |||||
int s = token[token.length - 1]; | |||||
fn = formatNumberAsDecimal(number, s, token.length); | fn = formatNumberAsDecimal(number, s, token.length); | ||||
} else { | } else { | ||||
throw new IllegalArgumentException("invalid format token: \"" + UTF32.fromUTF32(token) + "\""); | throw new IllegalArgumentException("invalid format token: \"" + UTF32.fromUTF32(token) + "\""); | ||||
} | } | ||||
private static int getDecimalValue(Integer scalar) { | private static int getDecimalValue(Integer scalar) { | ||||
int s = scalar.intValue(); | |||||
int s = scalar; | |||||
if (Character.getType(s) == Character.DECIMAL_DIGIT_NUMBER) { | if (Character.getType(s) == Character.DECIMAL_DIGIT_NUMBER) { | ||||
return Character.getNumericValue(s); | return Character.getNumericValue(s); | ||||
} else { | } else { |
boolean useCache; | boolean useCache; | ||||
try { | try { | ||||
useCache = Boolean.valueOf( | useCache = Boolean.valueOf( | ||||
System.getProperty("org.apache.fop.fo.properties.use-cache", "true")) | |||||
.booleanValue(); | |||||
System.getProperty("org.apache.fop.fo.properties.use-cache", "true")); | |||||
} catch (SecurityException e) { | } catch (SecurityException e) { | ||||
useCache = true; | useCache = true; | ||||
LOG.info("Unable to access org.apache.fop.fo.properties.use-cache" | LOG.info("Unable to access org.apache.fop.fo.properties.use-cache" |
public char getUnicode(int index) { | public char getUnicode(int index) { | ||||
Character mapValue = usedCharsIndex.get(index); | Character mapValue = usedCharsIndex.get(index); | ||||
if (mapValue != null) { | if (mapValue != null) { | ||||
return mapValue.charValue(); | |||||
return mapValue; | |||||
} else { | } else { | ||||
return CharUtilities.NOT_A_CHARACTER; | return CharUtilities.NOT_A_CHARACTER; | ||||
} | } |
if (kernPair != null) { | if (kernPair != null) { | ||||
Integer width = kernPair.get((int) ch2); | Integer width = kernPair.get((int) ch2); | ||||
if (width != null) { | if (width != null) { | ||||
return width.intValue() * getFontSize() / 1000; | |||||
return width * getFontSize() / 1000; | |||||
} | } | ||||
} | } | ||||
return 0; | return 0; |
synchronized (changeLock) { | synchronized (changeLock) { | ||||
if (getFailedFontMap().containsKey(embedUrl)) { | if (getFailedFontMap().containsKey(embedUrl)) { | ||||
long failedLastModified = getFailedFontMap().get( | long failedLastModified = getFailedFontMap().get( | ||||
embedUrl).longValue(); | |||||
embedUrl); | |||||
if (lastModified != failedLastModified) { | if (lastModified != failedLastModified) { | ||||
// this font has been changed so lets remove it | // this font has been changed so lets remove it | ||||
// from failed font map for now | // from failed font map for now |
String oldName = triplets.get(triplet); | String oldName = triplets.get(triplet); | ||||
int newPriority = triplet.getPriority(); | int newPriority = triplet.getPriority(); | ||||
if (oldName != null) { | if (oldName != null) { | ||||
int oldPriority = tripletPriorities.get(triplet).intValue(); | |||||
int oldPriority = tripletPriorities.get(triplet); | |||||
if (oldPriority < newPriority) { | if (oldPriority < newPriority) { | ||||
logDuplicateFont(triplet, false, oldName, oldPriority, internalFontKey, newPriority); | logDuplicateFont(triplet, false, oldName, oldPriority, internalFontKey, newPriority); | ||||
return; | return; |
public char mapChar(char c) { | public char mapChar(char c) { | ||||
Character nc = charMap.get(c); | Character nc = charMap.get(c); | ||||
if (nc != null) { | if (nc != null) { | ||||
return nc.charValue(); | |||||
return nc; | |||||
} | } | ||||
return NOT_FOUND_CODE_POINT; | return NOT_FOUND_CODE_POINT; | ||||
} | } |
private char getUnicode(int index) { | private char getUnicode(int index) { | ||||
Character mapValue = usedCharsIndex.get(index); | Character mapValue = usedCharsIndex.get(index); | ||||
if (mapValue != null) { | if (mapValue != null) { | ||||
return mapValue.charValue(); | |||||
return mapValue; | |||||
} else { | } else { | ||||
return CharUtilities.NOT_A_CHARACTER; | return CharUtilities.NOT_A_CHARACTER; | ||||
} | } |
int[] wds = new int[cidWidths.size()]; | int[] wds = new int[cidWidths.size()]; | ||||
int j = 0; | int j = 0; | ||||
for (int count = 0; count < cidWidths.size(); count++) { | for (int count = 0; count < cidWidths.size(); count++) { | ||||
wds[j++] = cidWidths.get(count).intValue(); | |||||
wds[j++] = cidWidths.get(count); | |||||
} | } | ||||
//multiFont.addCIDWidthEntry(cidWidthIndex, wds); | //multiFont.addCIDWidthEntry(cidWidthIndex, wds); |
for (Map.Entry<Integer, Integer> e : h2.entrySet()) { | for (Map.Entry<Integer, Integer> e : h2.entrySet()) { | ||||
Integer kpx2 = e.getKey(); | Integer kpx2 = e.getKey(); | ||||
if (isCid || kpx2.intValue() < 256) { | |||||
if (isCid || kpx2 < 256) { | |||||
el2 = doc.createElement("pair"); | el2 = doc.createElement("pair"); | ||||
el2.setAttribute("kpx2", kpx2.toString()); | el2.setAttribute("kpx2", kpx2.toString()); | ||||
Integer val = e.getValue(); | Integer val = e.getValue(); |
} | } | ||||
} else if (weightObj instanceof Integer) { | } else if (weightObj instanceof Integer) { | ||||
Integer fontWeightInteger = (Integer)weightObj; | Integer fontWeightInteger = (Integer)weightObj; | ||||
int fontWeightValue = fontWeightInteger.intValue(); | |||||
int fontWeightValue = fontWeightInteger; | |||||
if (fontWeightValue == fontWeight) { | if (fontWeightValue == fontWeight) { | ||||
weightMatched = true; | weightMatched = true; | ||||
} | } | ||||
triplets.add(new FontTriplet(name, style, weight)); | triplets.add(new FontTriplet(name, style, weight)); | ||||
} else if (weightObj instanceof Integer) { | } else if (weightObj instanceof Integer) { | ||||
Integer weightInteger = (Integer)weightObj; | Integer weightInteger = (Integer)weightObj; | ||||
int weight = weightInteger.intValue(); | |||||
int weight = weightInteger; | |||||
triplets.add(new FontTriplet(name, style, weight)); | triplets.add(new FontTriplet(name, style, weight)); | ||||
} | } | ||||
} | } |
List<Integer> v = ansiIndex.get(j); | List<Integer> v = ansiIndex.get(j); | ||||
if (v != null) { | if (v != null) { | ||||
for (Integer aIdx : v) { | for (Integer aIdx : v) { | ||||
ansiWidth[aIdx.intValue()] | |||||
ansiWidth[aIdx] | |||||
= mtxTab[glyphIdx].getWx(); | = mtxTab[glyphIdx].getWx(); | ||||
if (log.isTraceEnabled()) { | if (log.isTraceEnabled()) { | ||||
log.trace("Added width " | log.trace("Added width " | ||||
+ mtxTab[glyphIdx].getWx() | + mtxTab[glyphIdx].getWx() | ||||
+ " uni: " + j | + " uni: " + j | ||||
+ " ansi: " + aIdx.intValue()); | |||||
+ " ansi: " + aIdx); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
List<Integer> v = ansiIndex.get(j); | List<Integer> v = ansiIndex.get(j); | ||||
if (v != null) { | if (v != null) { | ||||
for (Integer aIdx : v) { | for (Integer aIdx : v) { | ||||
ansiWidth[aIdx.intValue()] = mtxTab[glyphIdx].getWx(); | |||||
ansiWidth[aIdx] = mtxTab[glyphIdx].getWx(); | |||||
} | } | ||||
} | } | ||||
for (Map.Entry<Integer, Integer> e : ckpx.entrySet()) { | for (Map.Entry<Integer, Integer> e : ckpx.entrySet()) { | ||||
Integer unicodeKey2 = e.getKey(); | Integer unicodeKey2 = e.getKey(); | ||||
Integer cidKey2 = unicodeToGlyph(unicodeKey2.intValue()); | |||||
Integer cidKey2 = unicodeToGlyph(unicodeKey2); | |||||
Integer kern = e.getValue(); | Integer kern = e.getValue(); | ||||
Iterator uniMap = mtxTab[cidKey2.intValue()].getUnicodeIndex().listIterator(); | |||||
Iterator uniMap = mtxTab[cidKey2].getUnicodeIndex().listIterator(); | |||||
while (uniMap.hasNext()) { | while (uniMap.hasNext()) { | ||||
Integer unicodeKey = (Integer)uniMap.next(); | Integer unicodeKey = (Integer)uniMap.next(); | ||||
Integer[] ansiKeys = unicodeToWinAnsi(unicodeKey.intValue()); | |||||
Integer[] ansiKeys = unicodeToWinAnsi(unicodeKey); | |||||
for (int u = 0; u < ansiKeys.length; u++) { | for (int u = 0; u < ansiKeys.length; u++) { | ||||
akpx.put(ansiKeys[u], kern); | akpx.put(ansiKeys[u], kern); | ||||
} | } | ||||
} | } | ||||
if (akpx.size() > 0) { | if (akpx.size() > 0) { | ||||
Iterator uniMap = mtxTab[cidKey1.intValue()].getUnicodeIndex().listIterator(); | |||||
Iterator uniMap = mtxTab[cidKey1].getUnicodeIndex().listIterator(); | |||||
while (uniMap.hasNext()) { | while (uniMap.hasNext()) { | ||||
Integer unicodeKey = (Integer)uniMap.next(); | Integer unicodeKey = (Integer)uniMap.next(); | ||||
Integer[] ansiKeys = unicodeToWinAnsi(unicodeKey.intValue()); | |||||
Integer[] ansiKeys = unicodeToWinAnsi(unicodeKey); | |||||
for (int u = 0; u < ansiKeys.length; u++) { | for (int u = 0; u < ansiKeys.length; u++) { | ||||
ansiKerningTab.put(ansiKeys[u], akpx); | ansiKerningTab.put(ansiKeys[u], akpx); | ||||
} | } |
Integer origIndex = glyph.getKey(); | Integer origIndex = glyph.getKey(); | ||||
Integer subsetIndex = glyph.getValue(); | Integer subsetIndex = glyph.getValue(); | ||||
writeUShort(currentPos + subsetIndex.intValue() * 4, | |||||
mtxTab[origIndex.intValue()].getWx()); | |||||
writeUShort(currentPos + subsetIndex.intValue() * 4 + 2, | |||||
mtxTab[origIndex.intValue()].getLsb()); | |||||
writeUShort(currentPos + subsetIndex * 4, | |||||
mtxTab[origIndex].getWx()); | |||||
writeUShort(currentPos + subsetIndex * 4 + 2, | |||||
mtxTab[origIndex].getLsb()); | |||||
} | } | ||||
updateCheckSum(currentPos, hmtxSize, hmtx); | updateCheckSum(currentPos, hmtxSize, hmtx); |
} | } | ||||
Integer newParseMode = PARSE_MODE_CHANGES.get(key); | Integer newParseMode = PARSE_MODE_CHANGES.get(key); | ||||
if (newParseMode != null) { | if (newParseMode != null) { | ||||
parseMode = newParseMode.intValue(); | |||||
parseMode = newParseMode; | |||||
} | } | ||||
} | } | ||||
return (AFMFile)stack.pop(); | return (AFMFile)stack.pop(); | ||||
private static class IsBaseFont extends AbstractValueHandler { | private static class IsBaseFont extends AbstractValueHandler { | ||||
public void parse(String line, int startpos, Stack<Object> stack) throws IOException { | public void parse(String line, int startpos, Stack<Object> stack) throws IOException { | ||||
if (getBooleanValue(line, startpos).booleanValue()) { | |||||
if (getBooleanValue(line, startpos)) { | |||||
throw new IOException("Only base fonts are currently supported!"); | throw new IOException("Only base fonts are currently supported!"); | ||||
} | } | ||||
} | } | ||||
private static class IsCIDFont extends AbstractValueHandler { | private static class IsCIDFont extends AbstractValueHandler { | ||||
public void parse(String line, int startpos, Stack<Object> stack) throws IOException { | public void parse(String line, int startpos, Stack<Object> stack) throws IOException { | ||||
if (getBooleanValue(line, startpos).booleanValue()) { | |||||
if (getBooleanValue(line, startpos)) { | |||||
throw new IOException("CID fonts are currently not supported!"); | throw new IOException("CID fonts are currently not supported!"); | ||||
} | } | ||||
} | } |
private void parseToken(int pos) throws UnsupportedEncodingException { | private void parseToken(int pos) throws UnsupportedEncodingException { | ||||
byte[] bytesToken = new byte[token.size()]; | byte[] bytesToken = new byte[token.size()]; | ||||
for (int i = 0; i < token.size(); i++) { | for (int i = 0; i < token.size(); i++) { | ||||
bytesToken[i] = token.get(i).byteValue(); | |||||
bytesToken[i] = token.get(i); | |||||
} | } | ||||
parseToken(new String(bytesToken, "ASCII"), pos); | parseToken(new String(bytesToken, "ASCII"), pos); | ||||
token.clear(); | token.clear(); |
* @return its y-offset on the page | * @return its y-offset on the page | ||||
*/ | */ | ||||
private int getRowOffset(int rowIndex) { | private int getRowOffset(int rowIndex) { | ||||
return ((Integer) rowOffsets.get(rowIndex - firstRowIndex)).intValue(); | |||||
return (Integer) rowOffsets.get(rowIndex - firstRowIndex); | |||||
} | } | ||||
// TODO get rid of that | // TODO get rid of that |
*/ | */ | ||||
protected Font getFontFromArea(Area area) { | protected Font getFontFromArea(Area area) { | ||||
FontTriplet triplet = (FontTriplet)area.getTrait(Trait.FONT); | FontTriplet triplet = (FontTriplet)area.getTrait(Trait.FONT); | ||||
int size = ((Integer)area.getTrait(Trait.FONT_SIZE)).intValue(); | |||||
int size = (Integer) area.getTrait(Trait.FONT_SIZE); | |||||
return fontInfo.getFontInstance(triplet, size); | return fontInfo.getFontInstance(triplet, size); | ||||
} | } | ||||
/** @return the currentXPosition */ | /** @return the currentXPosition */ | ||||
public int getCurrentXPosition() { | public int getCurrentXPosition() { | ||||
return ((Integer)context.getProperty(RendererContextConstants.XPOS)).intValue(); | |||||
return (Integer) context.getProperty(RendererContextConstants.XPOS); | |||||
} | } | ||||
/** @return the currentYPosition */ | /** @return the currentYPosition */ | ||||
public int getCurrentYPosition() { | public int getCurrentYPosition() { | ||||
return ((Integer)context.getProperty(RendererContextConstants.YPOS)).intValue(); | |||||
return (Integer) context.getProperty(RendererContextConstants.YPOS); | |||||
} | } | ||||
/** @return the width of the image */ | /** @return the width of the image */ | ||||
public int getWidth() { | public int getWidth() { | ||||
return ((Integer)context.getProperty(RendererContextConstants.WIDTH)).intValue(); | |||||
return (Integer) context.getProperty(RendererContextConstants.WIDTH); | |||||
} | } | ||||
/** @return the height of the image */ | /** @return the height of the image */ | ||||
public int getHeight() { | public int getHeight() { | ||||
return ((Integer)context.getProperty(RendererContextConstants.HEIGHT)).intValue(); | |||||
return (Integer) context.getProperty(RendererContextConstants.HEIGHT); | |||||
} | } | ||||
/** @return the foreign attributes */ | /** @return the foreign attributes */ |
*/ | */ | ||||
public AFPInfo getInfo() { | public AFPInfo getInfo() { | ||||
AFPInfo info = new AFPInfo(); | AFPInfo info = new AFPInfo(); | ||||
info.setWidth(((Integer)getProperty(RendererContextConstants.WIDTH)).intValue()); | |||||
info.setHeight(((Integer)getProperty(RendererContextConstants.HEIGHT)).intValue()); | |||||
info.setX(((Integer)getProperty(RendererContextConstants.XPOS)).intValue()); | |||||
info.setY(((Integer)getProperty(RendererContextConstants.YPOS)).intValue()); | |||||
info.setWidth((Integer) getProperty(RendererContextConstants.WIDTH)); | |||||
info.setHeight((Integer) getProperty(RendererContextConstants.HEIGHT)); | |||||
info.setX((Integer) getProperty(RendererContextConstants.XPOS)); | |||||
info.setY((Integer) getProperty(RendererContextConstants.YPOS)); | |||||
info.setHandlerConfiguration((Configuration)getProperty( | info.setHandlerConfiguration((Configuration)getProperty( | ||||
RendererContextConstants.HANDLER_CONFIGURATION)); | RendererContextConstants.HANDLER_CONFIGURATION)); | ||||
info.setFontInfo((org.apache.fop.fonts.FontInfo)getProperty( | info.setFontInfo((org.apache.fop.fonts.FontInfo)getProperty( |
state.setFontStyle(style); | state.setFontStyle(style); | ||||
} | } | ||||
if (weight != null) { | if (weight != null) { | ||||
state.setFontWeight(weight.intValue()); | |||||
state.setFontWeight(weight); | |||||
} | } | ||||
if (variant != null) { | if (variant != null) { | ||||
state.setFontVariant(variant); | state.setFontVariant(variant); | ||||
} | } | ||||
if (size != null) { | if (size != null) { | ||||
state.setFontSize(size.intValue()); | |||||
state.setFontSize(size); | |||||
} | } | ||||
if (color != null) { | if (color != null) { | ||||
state.setTextColor(color); | state.setTextColor(color); |
boolean idRefOK = idRef != null && idRef.length() > 0; | boolean idRefOK = idRef != null && idRef.length() > 0; | ||||
if (pvKeyOK && idRefOK) { | if (pvKeyOK && idRefOK) { | ||||
Integer pageIndex = (Integer)pageIndices.get(pvKey); | Integer pageIndex = (Integer)pageIndices.get(pvKey); | ||||
action = getGoToActionForID(idRef, (pageIndex != null ? pageIndex.intValue() : -1)); | |||||
action = getGoToActionForID(idRef, (pageIndex != null ? pageIndex : -1)); | |||||
} else { | } else { | ||||
//Warnings already issued by AreaTreeHandler | //Warnings already issued by AreaTreeHandler | ||||
} | } | ||||
beginTextObject(); | beginTextObject(); | ||||
String fontName = getInternalFontNameForArea(text); | String fontName = getInternalFontNameForArea(text); | ||||
int size = ((Integer) text.getTrait(Trait.FONT_SIZE)).intValue(); | |||||
int size = (Integer) text.getTrait(Trait.FONT_SIZE); | |||||
StructureTreeElement structElem | StructureTreeElement structElem | ||||
= (StructureTreeElement) text.getTrait(Trait.STRUCTURE_TREE_ELEMENT); | = (StructureTreeElement) text.getTrait(Trait.STRUCTURE_TREE_ELEMENT); | ||||
establishStructureTreeElement(structElem); | establishStructureTreeElement(structElem); |
} | } | ||||
} | } | ||||
if (weight != null) { | if (weight != null) { | ||||
changed = (weight.intValue() != state.getFontWeight()); | |||||
changed = (weight != state.getFontWeight()); | |||||
if (changed) { | if (changed) { | ||||
state.setFontWeight(weight.intValue()); | |||||
state.setFontWeight(weight); | |||||
addAttribute(atts, "weight", weight.toString()); | addAttribute(atts, "weight", weight.toString()); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
if (size != null) { | if (size != null) { | ||||
changed = (size.intValue() != state.getFontSize()); | |||||
changed = (size != state.getFontSize()); | |||||
if (changed) { | if (changed) { | ||||
state.setFontSize(size.intValue()); | |||||
state.setFontSize(size); | |||||
addAttribute(atts, "size", size.toString()); | addAttribute(atts, "size", size.toString()); | ||||
} | } | ||||
} | } |
public static Java2DInfo getJava2DInfo(RendererContext context) { | public static Java2DInfo getJava2DInfo(RendererContext context) { | ||||
Java2DInfo pdfi = new Java2DInfo(); | Java2DInfo pdfi = new Java2DInfo(); | ||||
pdfi.state = (Java2DGraphicsState)context.getProperty(JAVA2D_STATE); | pdfi.state = (Java2DGraphicsState)context.getProperty(JAVA2D_STATE); | ||||
pdfi.width = ((Integer)context.getProperty(WIDTH)).intValue(); | |||||
pdfi.height = ((Integer)context.getProperty(HEIGHT)).intValue(); | |||||
pdfi.currentXPosition = ((Integer)context.getProperty(XPOS)).intValue(); | |||||
pdfi.currentYPosition = ((Integer)context.getProperty(YPOS)).intValue(); | |||||
pdfi.width = (Integer) context.getProperty(WIDTH); | |||||
pdfi.height = (Integer) context.getProperty(HEIGHT); | |||||
pdfi.currentXPosition = (Integer) context.getProperty(XPOS); | |||||
pdfi.currentYPosition = (Integer) context.getProperty(YPOS); | |||||
Map foreign = (Map)context.getProperty(RendererContextConstants.FOREIGN_ATTRIBUTES); | Map foreign = (Map)context.getProperty(RendererContextConstants.FOREIGN_ATTRIBUTES); | ||||
pdfi.paintAsBitmap = ImageHandlerUtil.isConversionModeBitmap(foreign); | pdfi.paintAsBitmap = ImageHandlerUtil.isConversionModeBitmap(foreign); | ||||
return pdfi; | return pdfi; |
private static boolean booleanValueOf(Object obj) { | private static boolean booleanValueOf(Object obj) { | ||||
if (obj instanceof Boolean) { | if (obj instanceof Boolean) { | ||||
return ((Boolean)obj).booleanValue(); | |||||
return (Boolean) obj; | |||||
} else if (obj instanceof String) { | } else if (obj instanceof String) { | ||||
return Boolean.valueOf((String)obj).booleanValue(); | |||||
return Boolean.valueOf((String) obj); | |||||
} else { | } else { | ||||
throw new IllegalArgumentException("Boolean or \"true\" or \"false\" expected."); | throw new IllegalArgumentException("Boolean or \"true\" or \"false\" expected."); | ||||
} | } |
pdfi.pdfPage = (PDFPage)context.getProperty(PDF_PAGE); | pdfi.pdfPage = (PDFPage)context.getProperty(PDF_PAGE); | ||||
pdfi.pdfContext = (PDFResourceContext)context.getProperty(PDF_CONTEXT); | pdfi.pdfContext = (PDFResourceContext)context.getProperty(PDF_CONTEXT); | ||||
//pdfi.currentStream = (PDFStream)context.getProperty(PDF_STREAM); | //pdfi.currentStream = (PDFStream)context.getProperty(PDF_STREAM); | ||||
pdfi.width = ((Integer)context.getProperty(WIDTH)).intValue(); | |||||
pdfi.height = ((Integer)context.getProperty(HEIGHT)).intValue(); | |||||
pdfi.width = (Integer) context.getProperty(WIDTH); | |||||
pdfi.height = (Integer) context.getProperty(HEIGHT); | |||||
pdfi.fi = (FontInfo)context.getProperty(PDF_FONT_INFO); | pdfi.fi = (FontInfo)context.getProperty(PDF_FONT_INFO); | ||||
pdfi.currentFontName = (String)context.getProperty(PDF_FONT_NAME); | pdfi.currentFontName = (String)context.getProperty(PDF_FONT_NAME); | ||||
pdfi.currentFontSize = ((Integer)context.getProperty(PDF_FONT_SIZE)).intValue(); | |||||
pdfi.currentXPosition = ((Integer)context.getProperty(XPOS)).intValue(); | |||||
pdfi.currentYPosition = ((Integer)context.getProperty(YPOS)).intValue(); | |||||
pdfi.currentFontSize = (Integer) context.getProperty(PDF_FONT_SIZE); | |||||
pdfi.currentXPosition = (Integer) context.getProperty(XPOS); | |||||
pdfi.currentYPosition = (Integer) context.getProperty(YPOS); | |||||
pdfi.cfg = (Configuration)context.getProperty(HANDLER_CONFIGURATION); | pdfi.cfg = (Configuration)context.getProperty(HANDLER_CONFIGURATION); | ||||
Map foreign = (Map)context.getProperty(RendererContextConstants.FOREIGN_ATTRIBUTES); | Map foreign = (Map)context.getProperty(RendererContextConstants.FOREIGN_ATTRIBUTES); | ||||
pdfi.paintAsBitmap = ImageHandlerUtil.isConversionModeBitmap(foreign); | pdfi.paintAsBitmap = ImageHandlerUtil.isConversionModeBitmap(foreign); |
protected int getPositiveInteger(Object o) { | protected int getPositiveInteger(Object o) { | ||||
if (o instanceof Integer) { | if (o instanceof Integer) { | ||||
Integer i = (Integer)o; | Integer i = (Integer)o; | ||||
if (i.intValue() < 1) { | |||||
if (i < 1) { | |||||
throw new IllegalArgumentException( | throw new IllegalArgumentException( | ||||
"Value must be a positive Integer"); | "Value must be a positive Integer"); | ||||
} | } | ||||
return i.intValue(); | |||||
return i; | |||||
} else if (o instanceof String) { | } else if (o instanceof String) { | ||||
return Integer.parseInt((String)o); | return Integer.parseInt((String)o); | ||||
} else { | } else { |
gen.getResourceTracker().notifyResourceUsageOnPage(PSProcSets.STD_PROCSET); | gen.getResourceTracker().notifyResourceUsageOnPage(PSProcSets.STD_PROCSET); | ||||
gen.writeDSCComment(DSCConstants.PAGE, new Object[] | gen.writeDSCComment(DSCConstants.PAGE, new Object[] | ||||
{name, | {name, | ||||
Integer.valueOf(this.currentPageNumber)}); | |||||
this.currentPageNumber}); | |||||
double pageWidth = size.width / 1000.0; | double pageWidth = size.width / 1000.0; | ||||
double pageHeight = size.height / 1000.0; | double pageHeight = size.height / 1000.0; | ||||
if (rotate) { | if (rotate) { | ||||
pageBoundingBox.setRect(0, 0, pageHeight, pageWidth); | pageBoundingBox.setRect(0, 0, pageHeight, pageWidth); | ||||
gen.writeDSCComment(DSCConstants.PAGE_BBOX, new Object[] { | gen.writeDSCComment(DSCConstants.PAGE_BBOX, new Object[] { | ||||
zero, zero, Long.valueOf(Math.round(pageHeight)), | |||||
Long.valueOf(Math.round(pageWidth)) }); | |||||
zero, zero, Math.round(pageHeight), | |||||
Math.round(pageWidth)}); | |||||
gen.writeDSCComment(DSCConstants.PAGE_HIRES_BBOX, new Object[] { | gen.writeDSCComment(DSCConstants.PAGE_HIRES_BBOX, new Object[] { | ||||
zero, zero, Double.valueOf(pageHeight), | |||||
Double.valueOf(pageWidth) }); | |||||
zero, zero, pageHeight, | |||||
pageWidth}); | |||||
gen.writeDSCComment(DSCConstants.PAGE_ORIENTATION, "Landscape"); | gen.writeDSCComment(DSCConstants.PAGE_ORIENTATION, "Landscape"); | ||||
} else { | } else { | ||||
pageBoundingBox.setRect(0, 0, pageWidth, pageHeight); | pageBoundingBox.setRect(0, 0, pageWidth, pageHeight); | ||||
gen.writeDSCComment(DSCConstants.PAGE_BBOX, new Object[] { | gen.writeDSCComment(DSCConstants.PAGE_BBOX, new Object[] { | ||||
zero, zero, Long.valueOf(Math.round(pageWidth)), | |||||
Long.valueOf(Math.round(pageHeight)) }); | |||||
zero, zero, Math.round(pageWidth), | |||||
Math.round(pageHeight)}); | |||||
gen.writeDSCComment(DSCConstants.PAGE_HIRES_BBOX, new Object[] { | gen.writeDSCComment(DSCConstants.PAGE_HIRES_BBOX, new Object[] { | ||||
zero, zero, Double.valueOf(pageWidth), | |||||
Double.valueOf(pageHeight) }); | |||||
zero, zero, pageWidth, | |||||
pageHeight}); | |||||
if (psUtil.isAutoRotateLandscape()) { | if (psUtil.isAutoRotateLandscape()) { | ||||
gen.writeDSCComment(DSCConstants.PAGE_ORIENTATION, | gen.writeDSCComment(DSCConstants.PAGE_ORIENTATION, | ||||
"Portrait"); | "Portrait"); |
private boolean booleanValueOf(Object obj) { | private boolean booleanValueOf(Object obj) { | ||||
if (obj instanceof Boolean) { | if (obj instanceof Boolean) { | ||||
return ((Boolean)obj).booleanValue(); | |||||
return (Boolean) obj; | |||||
} else if (obj instanceof String) { | } else if (obj instanceof String) { | ||||
return Boolean.valueOf((String)obj).booleanValue(); | |||||
return Boolean.valueOf((String) obj); | |||||
} else { | } else { | ||||
throw new IllegalArgumentException("Boolean or \"true\" or \"false\" expected."); | throw new IllegalArgumentException("Boolean or \"true\" or \"false\" expected."); | ||||
} | } | ||||
private int intValueOf(Object obj) { | private int intValueOf(Object obj) { | ||||
if (obj instanceof Integer) { | if (obj instanceof Integer) { | ||||
return ((Integer)obj).intValue(); | |||||
return (Integer) obj; | |||||
} else if (obj instanceof String) { | } else if (obj instanceof String) { | ||||
return Integer.parseInt((String)obj); | return Integer.parseInt((String)obj); | ||||
} else { | } else { |
PSInfo psi = new PSInfo(); | PSInfo psi = new PSInfo(); | ||||
psi.psGenerator = (PSGenerator)context.getProperty(PS_GENERATOR); | psi.psGenerator = (PSGenerator)context.getProperty(PS_GENERATOR); | ||||
psi.fontInfo = (org.apache.fop.fonts.FontInfo) context.getProperty(PS_FONT_INFO); | psi.fontInfo = (org.apache.fop.fonts.FontInfo) context.getProperty(PS_FONT_INFO); | ||||
psi.width = ((Integer)context.getProperty(WIDTH)).intValue(); | |||||
psi.height = ((Integer)context.getProperty(HEIGHT)).intValue(); | |||||
psi.currentXPosition = ((Integer)context.getProperty(XPOS)).intValue(); | |||||
psi.currentYPosition = ((Integer)context.getProperty(YPOS)).intValue(); | |||||
psi.width = (Integer) context.getProperty(WIDTH); | |||||
psi.height = (Integer) context.getProperty(HEIGHT); | |||||
psi.currentXPosition = (Integer) context.getProperty(XPOS); | |||||
psi.currentYPosition = (Integer) context.getProperty(YPOS); | |||||
psi.cfg = (Configuration)context.getProperty(HANDLER_CONFIGURATION); | psi.cfg = (Configuration)context.getProperty(HANDLER_CONFIGURATION); | ||||
return psi; | return psi; | ||||
} | } |
int greenComponent = color.getGreen(); | int greenComponent = color.getGreen(); | ||||
int blueComponent = color.getBlue(); | int blueComponent = color.getBlue(); | ||||
set(name, RtfColorTable.getInstance().getColorNumber( | set(name, RtfColorTable.getInstance().getColorNumber( | ||||
redComponent, greenComponent, blueComponent).intValue()); | |||||
redComponent, greenComponent, blueComponent)); | |||||
return this; | return this; | ||||
} | } | ||||
// convert number to integer | // convert number to integer | ||||
try { | try { | ||||
if (number != null && number.trim().length() > 0) { | if (number != null && number.trim().length() > 0) { | ||||
result = Float.valueOf(number).floatValue(); | |||||
result = Float.valueOf(number); | |||||
} | } | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
throw new FOPException("number format error: cannot convert '" | throw new FOPException("number format error: cannot convert '" | ||||
if (factor == null) { | if (factor == null) { | ||||
throw new FOPException("conversion factor not found for '" + units + "' units"); | throw new FOPException("conversion factor not found for '" + units + "' units"); | ||||
} | } | ||||
result *= factor.floatValue(); | |||||
result *= factor; | |||||
} | } | ||||
return result; | return result; | ||||
float result = 0; | float result = 0; | ||||
size = size.substring(0, size.length() - sFONTSUFFIX.length()); | size = size.substring(0, size.length() - sFONTSUFFIX.length()); | ||||
try { | try { | ||||
result = (Float.valueOf(size).floatValue()); | |||||
result = (Float.valueOf(size)); | |||||
} catch (Exception e) { | } catch (Exception e) { | ||||
throw new FOPException("Invalid font size value '" + size + "'"); | throw new FOPException("Invalid font size value '" + size + "'"); | ||||
} | } |
Object widthRaw = attrib.getValue(RtfPage.PAGE_WIDTH); | Object widthRaw = attrib.getValue(RtfPage.PAGE_WIDTH); | ||||
Object heightRaw = attrib.getValue(RtfPage.PAGE_HEIGHT); | Object heightRaw = attrib.getValue(RtfPage.PAGE_HEIGHT); | ||||
if ((widthRaw instanceof Integer) && (heightRaw instanceof Integer) | if ((widthRaw instanceof Integer) && (heightRaw instanceof Integer) | ||||
&& ((Integer) widthRaw).intValue() > ((Integer) heightRaw).intValue()) { | |||||
&& (Integer) widthRaw > (Integer) heightRaw) { | |||||
attrib.set(RtfPage.LANDSCAPE); | attrib.set(RtfPage.LANDSCAPE); | ||||
} | } | ||||
int useAblePageWidth = pagemaster.getPageWidth().getValue() | int useAblePageWidth = pagemaster.getPageWidth().getValue() | ||||
- pagemaster.getCommonMarginBlock().marginLeft.getValue() | - pagemaster.getCommonMarginBlock().marginLeft.getValue() | ||||
- pagemaster.getCommonMarginBlock().marginRight.getValue() | - pagemaster.getCommonMarginBlock().marginRight.getValue() | ||||
- sect.getRtfAttributes().getValueAsInteger(RtfPage.MARGIN_LEFT).intValue() | |||||
- sect.getRtfAttributes().getValueAsInteger(RtfPage.MARGIN_RIGHT).intValue(); | |||||
- sect.getRtfAttributes().getValueAsInteger(RtfPage.MARGIN_LEFT) | |||||
- sect.getRtfAttributes().getValueAsInteger(RtfPage.MARGIN_RIGHT); | |||||
percentManager.setDimension(pageSeq, useAblePageWidth); | percentManager.setDimension(pageSeq, useAblePageWidth); | ||||
bHeaderSpecified = false; | bHeaderSpecified = false; | ||||
//while the current column is in row-spanning, act as if | //while the current column is in row-spanning, act as if | ||||
//a vertical merged cell would have been specified. | //a vertical merged cell would have been specified. | ||||
while (tctx.getNumberOfColumns() > tctx.getColumnIndex() | while (tctx.getNumberOfColumns() > tctx.getColumnIndex() | ||||
&& tctx.getColumnRowSpanningNumber().intValue() > 0) { | |||||
&& tctx.getColumnRowSpanningNumber() > 0) { | |||||
RtfTableCell vCell = row.newTableCellMergedVertically( | RtfTableCell vCell = row.newTableCellMergedVertically( | ||||
(int)tctx.getColumnWidth(), | (int)tctx.getColumnWidth(), | ||||
tctx.getColumnRowSpanningAttrs()); | tctx.getColumnRowSpanningAttrs()); | ||||
//while the current column is in row-spanning, act as if | //while the current column is in row-spanning, act as if | ||||
//a vertical merged cell would have been specified. | //a vertical merged cell would have been specified. | ||||
while (tctx.getNumberOfColumns() > tctx.getColumnIndex() | while (tctx.getNumberOfColumns() > tctx.getColumnIndex() | ||||
&& tctx.getColumnRowSpanningNumber().intValue() > 0) { | |||||
&& tctx.getColumnRowSpanningNumber() > 0) { | |||||
RtfTableCell vCell = row.newTableCellMergedVertically( | RtfTableCell vCell = row.newTableCellMergedVertically( | ||||
(int)tctx.getColumnWidth(), | (int)tctx.getColumnWidth(), | ||||
tctx.getColumnRowSpanningAttrs()); | tctx.getColumnRowSpanningAttrs()); |
int greenComponent = fopColor.getGreen(); | int greenComponent = fopColor.getGreen(); | ||||
int blueComponent = fopColor.getBlue(); | int blueComponent = fopColor.getBlue(); | ||||
return RtfColorTable.getInstance().getColorNumber(redComponent, | return RtfColorTable.getInstance().getColorNumber(redComponent, | ||||
greenComponent, blueComponent).intValue(); | |||||
greenComponent, blueComponent); | |||||
} | } | ||||
} | } |
if (value == null) { | if (value == null) { | ||||
set(name); | set(name); | ||||
} else { | } else { | ||||
set(name, value.intValue()); | |||||
set(name, value); | |||||
} | } | ||||
} else if (attrs.getValue(name) instanceof String) { | } else if (attrs.getValue(name) instanceof String) { | ||||
String value = (String)attrs.getValue(name); | String value = (String)attrs.getValue(name); | ||||
*/ | */ | ||||
public void addIntegerValue(int addValue, String name) { | public void addIntegerValue(int addValue, String name) { | ||||
Integer value = (Integer) getValue(name); | Integer value = (Integer) getValue(name); | ||||
int v = (value != null) ? value.intValue() : 0; | |||||
int v = (value != null) ? value : 0; | |||||
set(name, v + addValue); | set(name, v + addValue); | ||||
} | } | ||||
} | } |
* Initialize the color table. | * Initialize the color table. | ||||
*/ | */ | ||||
private void init() { | private void init() { | ||||
addNamedColor("black", getColorNumber(0, 0, 0).intValue()); | |||||
addNamedColor("white", getColorNumber(255, 255, 255).intValue()); | |||||
addNamedColor("red", getColorNumber(255, 0, 0).intValue()); | |||||
addNamedColor("green", getColorNumber(0, 255, 0).intValue()); | |||||
addNamedColor("blue", getColorNumber(0, 0, 255).intValue()); | |||||
addNamedColor("cyan", getColorNumber(0, 255, 255).intValue()); | |||||
addNamedColor("magenta", getColorNumber(255, 0, 255).intValue()); | |||||
addNamedColor("yellow", getColorNumber(255, 255, 0).intValue()); | |||||
addNamedColor("black", getColorNumber(0, 0, 0)); | |||||
addNamedColor("white", getColorNumber(255, 255, 255)); | |||||
addNamedColor("red", getColorNumber(255, 0, 0)); | |||||
addNamedColor("green", getColorNumber(0, 255, 0)); | |||||
addNamedColor("blue", getColorNumber(0, 0, 255)); | |||||
addNamedColor("cyan", getColorNumber(0, 255, 255)); | |||||
addNamedColor("magenta", getColorNumber(255, 0, 255)); | |||||
addNamedColor("yellow", getColorNumber(255, 255, 0)); | |||||
getColorNumber(0, 0, 128); | getColorNumber(0, 0, 128); | ||||
getColorNumber(0, 128, 128); | getColorNumber(0, 128, 128); | ||||
// Added by Normand Masse | // Added by Normand Masse | ||||
// Gray color added | // Gray color added | ||||
addNamedColor("gray", getColorNumber(128, 128, 128).intValue()); | |||||
addNamedColor("gray", getColorNumber(128, 128, 128)); | |||||
getColorNumber(192, 192, 192); | getColorNumber(192, 192, 192); | ||||
} | } | ||||
//The color was found. Before returning the index, increment | //The color was found. Before returning the index, increment | ||||
//it by one. Because index 0 is reserved for auto-colored, but | //it by one. Because index 0 is reserved for auto-colored, but | ||||
//is not contained in colorTable. | //is not contained in colorTable. | ||||
retVal = ((Integer) o).intValue() + 1; | |||||
retVal = (Integer) o + 1; | |||||
} | } | ||||
return retVal; | return retVal; | ||||
int len = colorTable.size(); | int len = colorTable.size(); | ||||
for (int i = 0; i < len; i++) { | for (int i = 0; i < len; i++) { | ||||
int identifier = ((Integer) colorTable.get(i)).intValue(); | |||||
int identifier = (Integer) colorTable.get(i); | |||||
header.newLine(); | header.newLine(); | ||||
header.write("\\red" + determineColorLevel(identifier, RED)); | header.write("\\red" + determineColorLevel(identifier, RED)); |
retVal = fontTable.size() - 1; | retVal = fontTable.size() - 1; | ||||
} else { | } else { | ||||
retVal = ((Integer)o).intValue(); | |||||
retVal = (Integer) o; | |||||
} | } | ||||
return retVal; | return retVal; |
Object heightRaw = attrib.getValue(PAGE_HEIGHT); | Object heightRaw = attrib.getValue(PAGE_HEIGHT); | ||||
if ((widthRaw instanceof Integer) && (heightRaw instanceof Integer) | if ((widthRaw instanceof Integer) && (heightRaw instanceof Integer) | ||||
&& ((Integer) widthRaw).intValue() > ((Integer) heightRaw).intValue()) { | |||||
&& (Integer) widthRaw > (Integer) heightRaw) { | |||||
writeControlWord(LANDSCAPE); | writeControlWord(LANDSCAPE); | ||||
} | } | ||||
} | } |
} | } | ||||
commonAttributes.unset(key); | commonAttributes.unset(key); | ||||
return i.intValue(); | |||||
return i; | |||||
} | } | ||||
/** @return attributes, applicable to whole block. */ | /** @return attributes, applicable to whole block. */ |
sb.append('\\'); | sb.append('\\'); | ||||
sb.append(replacement); | sb.append(replacement); | ||||
sb.append(' '); | sb.append(' '); | ||||
} else if (c.charValue() > 127) { | |||||
} else if (c > 127) { | |||||
// write unicode representation - contributed by Michel Jacobson | // write unicode representation - contributed by Michel Jacobson | ||||
// <jacobson@idf.ext.jussieu.fr> | // <jacobson@idf.ext.jussieu.fr> | ||||
sb.append("\\u"); | sb.append("\\u"); | ||||
sb.append(Integer.toString((int)c.charValue())); | |||||
sb.append(Integer.toString((int) c)); | |||||
sb.append("\\\'3f"); | sb.append("\\\'3f"); | ||||
} else { | } else { | ||||
// plain char that is understood by RTF natively | // plain char that is understood by RTF natively |
} | } | ||||
// Adds the attributes to default attributes, if not available in default attributes | // Adds the attributes to default attributes, if not available in default attributes | ||||
attr.set("cs", style.intValue()); | |||||
attr.set("cs", style); | |||||
Object o = attrTable.get(name); | Object o = attrTable.get(name); | ||||
if (o != null) { | if (o != null) { | ||||
if (i == null) { | if (i == null) { | ||||
attr.set(attrName); | attr.set(attrName); | ||||
} else { | } else { | ||||
attr.set(attrName, i.intValue()); | |||||
attr.set(attrName, i); | |||||
} | } | ||||
} | } | ||||
} | } |
isNestedTable = Boolean.FALSE; | isNestedTable = Boolean.FALSE; | ||||
} else { | } else { | ||||
return isNestedTable.booleanValue(); | |||||
return isNestedTable; | |||||
} | } | ||||
return false; | return false; |
int iCurrentWidth = this.cellWidth; | int iCurrentWidth = this.cellWidth; | ||||
if (attrib.getValue("number-columns-spanned") != null) { | if (attrib.getValue("number-columns-spanned") != null) { | ||||
// Get the number of columns spanned | // Get the number of columns spanned | ||||
int nbMergedCells = ((Integer)attrib.getValue("number-columns-spanned")).intValue(); | |||||
int nbMergedCells = (Integer) attrib.getValue("number-columns-spanned"); | |||||
RtfTable tab = getRow().getTable(); | RtfTable tab = getRow().getTable(); | ||||
final Object leftIndent = attrib.getValue(ITableAttributes.ATTR_ROW_LEFT_INDENT); | final Object leftIndent = attrib.getValue(ITableAttributes.ATTR_ROW_LEFT_INDENT); | ||||
if (leftIndent != null) { | if (leftIndent != null) { | ||||
xPos = ((Integer)leftIndent).intValue(); | |||||
xPos = (Integer) leftIndent; | |||||
} | } | ||||
RtfAttributes tableBorderAttributes = getTable().getBorderAttributes(); | RtfAttributes tableBorderAttributes = getTable().getBorderAttributes(); | ||||
// set (RTF 1.5) gaph to the average of the (RTF 1.6) left and right padding values | // set (RTF 1.5) gaph to the average of the (RTF 1.6) left and right padding values | ||||
final Integer leftPadStr = (Integer)attrib.getValue(ATTR_ROW_PADDING_LEFT); | final Integer leftPadStr = (Integer)attrib.getValue(ATTR_ROW_PADDING_LEFT); | ||||
if (leftPadStr != null) { | if (leftPadStr != null) { | ||||
gaph = leftPadStr.intValue(); | |||||
gaph = leftPadStr; | |||||
} | } | ||||
final Integer rightPadStr = (Integer)attrib.getValue(ATTR_ROW_PADDING_RIGHT); | final Integer rightPadStr = (Integer)attrib.getValue(ATTR_ROW_PADDING_RIGHT); | ||||
if (rightPadStr != null) { | if (rightPadStr != null) { | ||||
gaph = (gaph + rightPadStr.intValue()) / 2; | |||||
gaph = (gaph + rightPadStr) / 2; | |||||
} | } | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
final String msg = "RtfTableRow.writePaddingAttributes: " + e.toString(); | final String msg = "RtfTableRow.writePaddingAttributes: " + e.toString(); |
setChildren(children); | setChildren(children); | ||||
par = new RtfParagraphBreak(this, writer); | par = new RtfParagraphBreak(this, writer); | ||||
for (int i = 0; i < deletedCloseGroupCount; i++) { | for (int i = 0; i < deletedCloseGroupCount; i++) { | ||||
addCloseGroupMark(((Integer)tmp.pop()).intValue()); | |||||
addCloseGroupMark((Integer) tmp.pop()); | |||||
} | } | ||||
} | } | ||||
return par; | return par; |
case LengthBase.TABLE_UNITS: | case LengthBase.TABLE_UNITS: | ||||
Object unit = tableUnitMap.get(fobj); | Object unit = tableUnitMap.get(fobj); | ||||
if (unit != null) { | if (unit != null) { | ||||
return ((Integer)unit).intValue(); | |||||
return (Integer) unit; | |||||
} else if (fobj.getParent() != null) { | } else if (fobj.getParent() != null) { | ||||
// If the object itself has no width the parent width will be used | // If the object itself has no width the parent width will be used | ||||
unit = tableUnitMap.get(fobj.getParent()); | unit = tableUnitMap.get(fobj.getParent()); | ||||
if (unit != null) { | if (unit != null) { | ||||
return ((Integer)unit).intValue(); | |||||
return (Integer) unit; | |||||
} | } | ||||
} | } | ||||
return 0; | return 0; | ||||
public void setDimension(FObj fobj) { | public void setDimension(FObj fobj) { | ||||
if (baseWidthSet) { | if (baseWidthSet) { | ||||
Integer width = findParent(fobj.getParent()); | Integer width = findParent(fobj.getParent()); | ||||
if (width.intValue() != -1) { | |||||
if (width != -1) { | |||||
lengthMap.put(fobj, width); | lengthMap.put(fobj, width); | ||||
} | } | ||||
} | } |
*/ | */ | ||||
public boolean getFirstSpanningCol() { | public boolean getFirstSpanningCol() { | ||||
Boolean b = (Boolean) colFirstSpanningCol.get(colIndex); | Boolean b = (Boolean) colFirstSpanningCol.get(colIndex); | ||||
return b.booleanValue(); | |||||
return b; | |||||
} | } | ||||
/** | /** | ||||
for (int z = 0; z < colRowSpanningNumber.size(); ++z) { | for (int z = 0; z < colRowSpanningNumber.size(); ++z) { | ||||
Integer i = (Integer)colRowSpanningNumber.get(z); | Integer i = (Integer)colRowSpanningNumber.get(z); | ||||
if (i.intValue() > 0) { | |||||
i = i.intValue() - 1; | |||||
if (i > 0) { | |||||
i = i - 1; | |||||
} | } | ||||
colRowSpanningNumber.set(z, i); | colRowSpanningNumber.set(z, i); | ||||
if (i.intValue() == 0) { | |||||
if (i == 0) { | |||||
colRowSpanningAttrs.set(z, null); | colRowSpanningAttrs.set(z, null); | ||||
colFirstSpanningCol.set(z, false); | colFirstSpanningCol.set(z, false); | ||||
} | } | ||||
setNextColumnWidth(INVALID_COLUMN_WIDTH); | setNextColumnWidth(INVALID_COLUMN_WIDTH); | ||||
} | } | ||||
} | } | ||||
return ((Float)colWidths.get(colIndex)).floatValue(); | |||||
return (Float) colWidths.get(colIndex); | |||||
} | } | ||||
/** | /** |
for (int y = 0; y < pageHeight; y++) { | for (int y = 0; y < pageHeight; y++) { | ||||
Character c = bm.getCharacter(x, y); | Character c = bm.getCharacter(x, y); | ||||
if (c != null) { | if (c != null) { | ||||
putChar(x, y, c.charValue(), false); | |||||
putChar(x, y, c, false); | |||||
} | } | ||||
} | } | ||||
} | } |
userAgent.getXMLHandlerRegistry().addXMLHandler(xmlHandler); | userAgent.getXMLHandlerRegistry().addXMLHandler(xmlHandler); | ||||
Boolean b = (Boolean)userAgent.getRendererOptions().get("compact-format"); | Boolean b = (Boolean)userAgent.getRendererOptions().get("compact-format"); | ||||
if (b != null) { | if (b != null) { | ||||
setCompactFormat(b.booleanValue()); | |||||
setCompactFormat(b); | |||||
} | } | ||||
} | } | ||||
GVTAttributedCharacterIterator.TextAttribute.GVT_FONT_FAMILIES); | GVTAttributedCharacterIterator.TextAttribute.GVT_FONT_FAMILIES); | ||||
String style = toStyle((Float) aci.getAttribute(TextAttribute.POSTURE)); | String style = toStyle((Float) aci.getAttribute(TextAttribute.POSTURE)); | ||||
int weight = toCSSWeight((Float) aci.getAttribute(TextAttribute.WEIGHT)); | int weight = toCSSWeight((Float) aci.getAttribute(TextAttribute.WEIGHT)); | ||||
float fontSize = ((Float) aci.getAttribute(TextAttribute.SIZE)).floatValue(); | |||||
float fontSize = (Float) aci.getAttribute(TextAttribute.SIZE); | |||||
String firstFontFamily = null; | String firstFontFamily = null; | ||||
//GVT_FONT can sometimes be different from the fonts in GVT_FONT_FAMILIES | //GVT_FONT can sometimes be different from the fonts in GVT_FONT_FAMILIES | ||||
public static int toCSSWeight(Float weight) { | public static int toCSSWeight(Float weight) { | ||||
if (weight == null) { | if (weight == null) { | ||||
return 400; | return 400; | ||||
} else if (weight <= TextAttribute.WEIGHT_EXTRA_LIGHT.floatValue()) { | |||||
} else if (weight <= TextAttribute.WEIGHT_EXTRA_LIGHT) { | |||||
return 100; | return 100; | ||||
} else if (weight <= TextAttribute.WEIGHT_LIGHT.floatValue()) { | |||||
} else if (weight <= TextAttribute.WEIGHT_LIGHT) { | |||||
return 200; | return 200; | ||||
} else if (weight <= TextAttribute.WEIGHT_DEMILIGHT.floatValue()) { | |||||
} else if (weight <= TextAttribute.WEIGHT_DEMILIGHT) { | |||||
return 300; | return 300; | ||||
} else if (weight <= TextAttribute.WEIGHT_REGULAR.floatValue()) { | |||||
} else if (weight <= TextAttribute.WEIGHT_REGULAR) { | |||||
return 400; | return 400; | ||||
} else if (weight <= TextAttribute.WEIGHT_SEMIBOLD.floatValue()) { | |||||
} else if (weight <= TextAttribute.WEIGHT_SEMIBOLD) { | |||||
return 500; | return 500; | ||||
} else if (weight < TextAttribute.WEIGHT_BOLD.floatValue()) { | |||||
} else if (weight < TextAttribute.WEIGHT_BOLD) { | |||||
return 600; | return 600; | ||||
} else if (weight == TextAttribute.WEIGHT_BOLD.floatValue()) { | } else if (weight == TextAttribute.WEIGHT_BOLD.floatValue()) { | ||||
return 700; | return 700; | ||||
} else if (weight <= TextAttribute.WEIGHT_HEAVY.floatValue()) { | |||||
} else if (weight <= TextAttribute.WEIGHT_HEAVY) { | |||||
return 800; | return 800; | ||||
} else if (weight <= TextAttribute.WEIGHT_EXTRABOLD.floatValue()) { | |||||
} else if (weight <= TextAttribute.WEIGHT_EXTRABOLD) { | |||||
return 900; | return 900; | ||||
} else { | } else { | ||||
return 900; | return 900; | ||||
} | } | ||||
public static String toStyle(Float posture) { | public static String toStyle(Float posture) { | ||||
return ((posture != null) && (posture.floatValue() > 0.0)) | |||||
return ((posture != null) && (posture > 0.0)) | |||||
? Font.STYLE_ITALIC | ? Font.STYLE_ITALIC | ||||
: Font.STYLE_NORMAL; | : Font.STYLE_NORMAL; | ||||
} | } |
//By default, enable font auto-detection if no cfg is given | //By default, enable font auto-detection if no cfg is given | ||||
boolean autoFonts = getAutoFontsDefault(); | boolean autoFonts = getAutoFontsDefault(); | ||||
if (hints.containsKey(KEY_AUTO_FONTS)) { | if (hints.containsKey(KEY_AUTO_FONTS)) { | ||||
autoFonts = ((Boolean)hints.get(KEY_AUTO_FONTS)).booleanValue(); | |||||
autoFonts = (Boolean) hints.get(KEY_AUTO_FONTS); | |||||
} | } | ||||
if (autoFonts) { | if (autoFonts) { | ||||
DefaultConfiguration c = new DefaultConfiguration("cfg"); | DefaultConfiguration c = new DefaultConfiguration("cfg"); | ||||
protected boolean isTextStroked() { | protected boolean isTextStroked() { | ||||
boolean stroke = false; | boolean stroke = false; | ||||
if (hints.containsKey(KEY_STROKE_TEXT)) { | if (hints.containsKey(KEY_STROKE_TEXT)) { | ||||
stroke = ((Boolean)hints.get(KEY_STROKE_TEXT)).booleanValue(); | |||||
stroke = (Boolean) hints.get(KEY_STROKE_TEXT); | |||||
} | } | ||||
return stroke; | return stroke; | ||||
} | } | ||||
*/ | */ | ||||
protected float getDeviceResolution() { | protected float getDeviceResolution() { | ||||
if (hints.containsKey(KEY_DEVICE_RESOLUTION)) { | if (hints.containsKey(KEY_DEVICE_RESOLUTION)) { | ||||
return ((Float)hints.get(KEY_DEVICE_RESOLUTION)).floatValue(); | |||||
return (Float) hints.get(KEY_DEVICE_RESOLUTION); | |||||
} else { | } else { | ||||
return GraphicsConstants.DEFAULT_DPI; | return GraphicsConstants.DEFAULT_DPI; | ||||
} | } | ||||
public float getPixelUnitToMillimeter() { | public float getPixelUnitToMillimeter() { | ||||
Object key = ImageTranscoder.KEY_PIXEL_UNIT_TO_MILLIMETER; | Object key = ImageTranscoder.KEY_PIXEL_UNIT_TO_MILLIMETER; | ||||
if (getTranscodingHints().containsKey(key)) { | if (getTranscodingHints().containsKey(key)) { | ||||
return ((Float)getTranscodingHints().get(key)).floatValue(); | |||||
return (Float) getTranscodingHints().get(key); | |||||
} else { | } else { | ||||
// return 0.3528f; // 72 dpi | // return 0.3528f; // 72 dpi | ||||
return UnitConv.IN2MM / 96; //96dpi = 0.2645833333333333333f; | return UnitConv.IN2MM / 96; //96dpi = 0.2645833333333333333f; |
if (kernPair != null) { | if (kernPair != null) { | ||||
Integer width = kernPair.get(ch2); | Integer width = kernPair.get(ch2); | ||||
if (width != null) { | if (width != null) { | ||||
currentStream.write(endText + (-width.intValue()) + " " + startText); | |||||
currentStream.write(endText + (-width) + " " + startText); | |||||
} | } | ||||
} | } | ||||
} | } |
this.language = (String) aci.getAttribute(GVTAttributedCharacterIterator.TextAttribute.LANGUAGE); | this.language = (String) aci.getAttribute(GVTAttributedCharacterIterator.TextAttribute.LANGUAGE); | ||||
Integer level = (Integer) aci.getAttribute(GVTAttributedCharacterIterator.TextAttribute.BIDI_LEVEL); | Integer level = (Integer) aci.getAttribute(GVTAttributedCharacterIterator.TextAttribute.BIDI_LEVEL); | ||||
if (level != null) { | if (level != null) { | ||||
this.level = level.intValue(); | |||||
this.level = level; | |||||
} | } | ||||
} | } | ||||
} | } |
Boolean pass = (Boolean)e.getValue(); | Boolean pass = (Boolean)e.getValue(); | ||||
System.out.println("file: " + fname | System.out.println("file: " + fname | ||||
+ " - reference success: " + pass); | + " - reference success: " + pass); | ||||
if (pass.booleanValue()) { | |||||
if (pass) { | |||||
broke = true; | broke = true; | ||||
} | } | ||||
} | } |
if (s == null) { | if (s == null) { | ||||
return defaultValue; | return defaultValue; | ||||
} else { | } else { | ||||
return Boolean.valueOf(s).booleanValue(); | |||||
return Boolean.valueOf(s); | |||||
} | } | ||||
} | } | ||||
protected boolean isTrue(Map params) { | protected boolean isTrue(Map params) { | ||||
Object obj = params.get(fieldName); | Object obj = params.get(fieldName); | ||||
if (obj instanceof Boolean) { | if (obj instanceof Boolean) { | ||||
return ((Boolean)obj).booleanValue(); | |||||
return (Boolean) obj; | |||||
} else { | } else { | ||||
return (obj != null); | return (obj != null); | ||||
} | } |
if (gmap != null) { | if (gmap != null) { | ||||
Integer cid = gmap.get(gid); | Integer cid = gmap.get(gid); | ||||
if (cid != null) { | if (cid != null) { | ||||
return cid.intValue(); | |||||
return cid; | |||||
} | } | ||||
} | } | ||||
} | } |
private static void checkBorder(String errorMsge, BorderSpecification border, | private static void checkBorder(String errorMsge, BorderSpecification border, | ||||
Object[] resolvedBorder) { | Object[] resolvedBorder) { | ||||
checkBorder(errorMsge, border, | checkBorder(errorMsge, border, | ||||
((Integer) resolvedBorder[0]).intValue(), | |||||
(Integer) resolvedBorder[0], | |||||
(Color) resolvedBorder[1]); | (Color) resolvedBorder[1]); | ||||
} | } | ||||
public void processingInstruction(String target, String data) throws SAXException { | public void processingInstruction(String target, String data) throws SAXException { | ||||
if ("fop-useragent-break-indent-inheritance".equals(target)) { | if ("fop-useragent-break-indent-inheritance".equals(target)) { | ||||
fopConfig.setBreakIndentInheritanceOnReferenceAreaBoundary( | fopConfig.setBreakIndentInheritanceOnReferenceAreaBoundary( | ||||
Boolean.valueOf(data).booleanValue()); | |||||
Boolean.valueOf(data)); | |||||
} else if ("fop-source-resolution".equals(target)) { | } else if ("fop-source-resolution".equals(target)) { | ||||
fopConfig.setSourceResolution(Float.parseFloat(data)); | fopConfig.setSourceResolution(Float.parseFloat(data)); | ||||
} | } |