git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1761020 13f79535-47bb-0310-9956-ffa450edef68pull/3/head
double[][] quadParts = CubicBezierApproximator.fixedMidPointApproximation( | double[][] quadParts = CubicBezierApproximator.fixedMidPointApproximation( | ||||
cubicCoords); | cubicCoords); | ||||
if (quadParts.length >= 4) { | if (quadParts.length >= 4) { | ||||
for (int segIndex = 0; segIndex < quadParts.length; segIndex++) { | |||||
double[] quadPts = quadParts[segIndex]; | |||||
for (double[] quadPts : quadParts) { | |||||
if (quadPts != null && quadPts.length == 4) { | if (quadPts != null && quadPts.length == 4) { | ||||
graphicsObj.addFillet(new int[]{ | graphicsObj.addFillet(new int[]{ | ||||
(int) Math.round(quadPts[X1]), | (int) Math.round(quadPts[X1]), |
*/ | */ | ||||
public void createPageTagLogicalElement(TagLogicalElement.State[] attributes) { | public void createPageTagLogicalElement(TagLogicalElement.State[] attributes) { | ||||
for (int i = 0; i < attributes.length; i++) { | |||||
for (TagLogicalElement.State attribute : attributes) { | |||||
currentPage.createTagLogicalElement(attributes[i]); | |||||
currentPage.createTagLogicalElement(attribute); | |||||
} | } | ||||
} | } | ||||
* the array of key value pairs. | * the array of key value pairs. | ||||
*/ | */ | ||||
public void createPageGroupTagLogicalElement(TagLogicalElement.State[] attributes) { | public void createPageGroupTagLogicalElement(TagLogicalElement.State[] attributes) { | ||||
for (int i = 0; i < attributes.length; i++) { | |||||
currentPageGroup.createTagLogicalElement(attributes[i]); | |||||
for (TagLogicalElement.State attribute : attributes) { | |||||
currentPageGroup.createTagLogicalElement(attribute); | |||||
} | } | ||||
} | } | ||||
//process D3AC89 Font Position | //process D3AC89 Font Position | ||||
processFontPosition(structuredFieldReader, characterSetOrientations, normalizer); | processFontPosition(structuredFieldReader, characterSetOrientations, normalizer); | ||||
//process D38C89 Font Index (per orientation) | //process D38C89 Font Index (per orientation) | ||||
for (int i = 0; i < characterSetOrientations.length; i++) { | |||||
CharacterSetOrientation characterSetOrientation = characterSetOrientations[i]; | |||||
for (CharacterSetOrientation characterSetOrientation : characterSetOrientations) { | |||||
processFontIndex(structuredFieldReader, characterSetOrientation, codePage, normalizer); | processFontIndex(structuredFieldReader, characterSetOrientation, codePage, normalizer); | ||||
characterSet.addCharacterSetOrientation(characterSetOrientation); | characterSet.addCharacterSetOrientation(characterSetOrientation); | ||||
} | } |
if (colSpaceType == ColorSpace.TYPE_CMYK) { | if (colSpaceType == ColorSpace.TYPE_CMYK) { | ||||
colspace = CMYK; | colspace = CMYK; | ||||
colsizes = new byte[] {0x08, 0x08, 0x08, 0x08}; | colsizes = new byte[] {0x08, 0x08, 0x08, 0x08}; | ||||
for (int i = 0; i < colorComponents.length; i++) { | |||||
baout.write(Math.round(colorComponents[i] * 255)); | |||||
for (float colorComponent : colorComponents) { | |||||
baout.write(Math.round(colorComponent * 255)); | |||||
} | } | ||||
} else if (colSpaceType == ColorSpace.TYPE_RGB) { | } else if (colSpaceType == ColorSpace.TYPE_RGB) { | ||||
colspace = RGB; | colspace = RGB; | ||||
colsizes = new byte[] {0x08, 0x08, 0x08, 0x00}; | colsizes = new byte[] {0x08, 0x08, 0x08, 0x00}; | ||||
for (int i = 0; i < colorComponents.length; i++) { | |||||
baout.write(Math.round(colorComponents[i] * 255)); | |||||
for (float colorComponent : colorComponents) { | |||||
baout.write(Math.round(colorComponent * 255)); | |||||
} | } | ||||
} else if (cs instanceof CIELabColorSpace) { | } else if (cs instanceof CIELabColorSpace) { | ||||
colspace = CIELAB; | colspace = CIELAB; |
//now add the name | //now add the name | ||||
byte[] name = (byte[]) overLays.get(i); | byte[] name = (byte[]) overLays.get(i); | ||||
for (int j = 0; j < name.length; j++) { | |||||
data[++pos] = name[j]; | |||||
for (byte aName : name) { | |||||
data[++pos] = aName; | |||||
} | } | ||||
data[++pos] = 0x04; //Resource Local Identifier (RLI) | data[++pos] = 0x04; //Resource Local Identifier (RLI) |
Configuration userConfig = null; | Configuration userConfig = null; | ||||
Configuration[] cfgs = cfg.getChild(type + "s").getChildren(type); | Configuration[] cfgs = cfg.getChild(type + "s").getChildren(type); | ||||
for (int i = 0; i < cfgs.length; ++i) { | |||||
Configuration child = cfgs[i]; | |||||
for (Configuration child : cfgs) { | |||||
try { | try { | ||||
if (child.getAttribute(mime).equals(mimeType)) { | if (child.getAttribute(mime).equals(mimeType)) { | ||||
userConfig = child; | userConfig = child; |
ImageImplRegistry registry = fopFactoryBuilder.getImageManager().getRegistry(); | ImageImplRegistry registry = fopFactoryBuilder.getImageManager().getRegistry(); | ||||
Configuration[] penalties = parent.getChildren("penalty"); | Configuration[] penalties = parent.getChildren("penalty"); | ||||
try { | try { | ||||
for (int i = 0, c = penalties.length; i < c; i++) { | |||||
Configuration penaltyCfg = penalties[i]; | |||||
for (Configuration penaltyCfg : penalties) { | |||||
String className = penaltyCfg.getAttribute("class"); | String className = penaltyCfg.getAttribute("class"); | ||||
String value = penaltyCfg.getAttribute("value"); | String value = penaltyCfg.getAttribute("value"); | ||||
Penalty p = null; | Penalty p = null; |
import java.io.Serializable; | import java.io.Serializable; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Iterator; | |||||
import java.util.List; | import java.util.List; | ||||
import org.apache.fop.area.inline.InlineArea; | import org.apache.fop.area.inline.InlineArea; | ||||
* @param inlineAreas the list of inline areas | * @param inlineAreas the list of inline areas | ||||
*/ | */ | ||||
public void setInlineAreas(List inlineAreas) { | public void setInlineAreas(List inlineAreas) { | ||||
for (Iterator<InlineArea> it = inlineAreas.iterator(); it.hasNext();) { | |||||
InlineArea ia = it.next(); | |||||
for (InlineArea ia : (Iterable<InlineArea>) inlineAreas) { | |||||
Area pa = ia.getParentArea(); | Area pa = ia.getParentArea(); | ||||
if (pa == null) { | if (pa == null) { | ||||
ia.setParentArea(this); | ia.setParentArea(this); | ||||
public void updateExtentsFromChildren() { | public void updateExtentsFromChildren() { | ||||
int ipd = 0; | int ipd = 0; | ||||
int bpd = 0; | int bpd = 0; | ||||
for (int i = 0, len = inlineAreas.size(); i < len; i++) { | |||||
ipd = Math.max(ipd, inlineAreas.get(i).getAllocIPD()); | |||||
bpd += inlineAreas.get(i).getAllocBPD(); | |||||
for (InlineArea inlineArea : inlineAreas) { | |||||
ipd = Math.max(ipd, inlineArea.getAllocIPD()); | |||||
bpd += inlineArea.getAllocBPD(); | |||||
} | } | ||||
setIPD(ipd); | setIPD(ipd); | ||||
setBPD(bpd); | setBPD(bpd); | ||||
// justified line: apply the variation factor | // justified line: apply the variation factor | ||||
boolean bUnresolvedAreasPresent = false; | boolean bUnresolvedAreasPresent = false; | ||||
// recursively apply variation factor to descendant areas | // recursively apply variation factor to descendant areas | ||||
for (int i = 0, len = inlineAreas.size(); i < len; i++) { | |||||
bUnresolvedAreasPresent |= inlineAreas.get(i) | |||||
for (InlineArea inlineArea : inlineAreas) { | |||||
bUnresolvedAreasPresent |= inlineArea | |||||
.applyVariationFactor(adjustingInfo.variationFactor, | .applyVariationFactor(adjustingInfo.variationFactor, | ||||
adjustingInfo.availableStretch, | adjustingInfo.availableStretch, | ||||
adjustingInfo.availableShrink); | adjustingInfo.availableShrink); |
package org.apache.fop.area; | package org.apache.fop.area; | ||||
import java.util.Iterator; | |||||
import java.util.List; | import java.util.List; | ||||
import org.apache.fop.fo.Constants; | import org.apache.fop.fo.Constants; | ||||
switch (wmtg.getColumnProgressionDirection().getEnumValue()) { | switch (wmtg.getColumnProgressionDirection().getEnumValue()) { | ||||
case Constants.EN_RL: | case Constants.EN_RL: | ||||
setBidiLevel(1); | setBidiLevel(1); | ||||
for (Iterator<NormalFlow> it = flowAreas.iterator(); it.hasNext();) { | |||||
it.next().setBidiLevel(1); | |||||
for (NormalFlow flowArea1 : flowAreas) { | |||||
flowArea1.setBidiLevel(1); | |||||
} | } | ||||
break; | break; | ||||
default: | default: | ||||
resetBidiLevel(); | resetBidiLevel(); | ||||
for (Iterator<NormalFlow> it = flowAreas.iterator(); it.hasNext();) { | |||||
it.next().resetBidiLevel(); | |||||
for (NormalFlow flowArea : flowAreas) { | |||||
flowArea.resetBidiLevel(); | |||||
} | } | ||||
break; | break; | ||||
} | } |
String dest = null; | String dest = null; | ||||
boolean newWindow = false; | boolean newWindow = false; | ||||
String[] values = traitValue.split(","); | String[] values = traitValue.split(","); | ||||
for (int i = 0, c = values.length; i < c; i++) { | |||||
String v = values[i]; | |||||
for (String v : values) { | |||||
if (v.startsWith("dest=")) { | if (v.startsWith("dest=")) { | ||||
dest = v.substring(5); | dest = v.substring(5); | ||||
} else if (v.startsWith("newWindow=")) { | } else if (v.startsWith("newWindow=")) { |
import java.io.IOException; | import java.io.IOException; | ||||
import java.io.ObjectInputStream; | import java.io.ObjectInputStream; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Iterator; | |||||
import java.util.List; | import java.util.List; | ||||
import org.apache.fop.area.Area; | import org.apache.fop.area.Area; | ||||
boolean hasUnresolvedAreas = false; | boolean hasUnresolvedAreas = false; | ||||
int cumulativeIPD = 0; | int cumulativeIPD = 0; | ||||
// recursively apply variation factor to descendant areas | // recursively apply variation factor to descendant areas | ||||
for (int i = 0, len = inlines.size(); i < len; i++) { | |||||
InlineArea inline = inlines.get(i); | |||||
for (InlineArea inline : inlines) { | |||||
hasUnresolvedAreas |= inline.applyVariationFactor( | hasUnresolvedAreas |= inline.applyVariationFactor( | ||||
variationFactor, lineStretch, lineShrink); | variationFactor, lineStretch, lineShrink); | ||||
cumulativeIPD += inline.getIPD(); //Update this area's IPD based on changes to children | cumulativeIPD += inline.getIPD(); //Update this area's IPD based on changes to children | ||||
@Override | @Override | ||||
public List collectInlineRuns(List runs) { | public List collectInlineRuns(List runs) { | ||||
for (Iterator<InlineArea> it = getChildAreas().iterator(); it.hasNext();) { | |||||
InlineArea ia = it.next(); | |||||
for (InlineArea ia : getChildAreas()) { | |||||
runs = ia.collectInlineRuns(runs); | runs = ia.collectInlineRuns(runs); | ||||
} | } | ||||
return runs; | return runs; | ||||
* signalling that they will inherit the level of their parent text area. | * signalling that they will inherit the level of their parent text area. | ||||
*/ | */ | ||||
public void resetChildrenLevel() { | public void resetChildrenLevel() { | ||||
for (Iterator it = inlines.iterator(); it.hasNext();) { | |||||
((InlineArea) it.next()) .resetBidiLevel(); | |||||
for (InlineArea inline : inlines) { | |||||
(inline).resetBidiLevel(); | |||||
} | } | ||||
} | } | ||||
private static int findMinLevel(int[] levels, int defaultLevel) { | private static int findMinLevel(int[] levels, int defaultLevel) { | ||||
if (levels != null) { | if (levels != null) { | ||||
int lMin = Integer.MAX_VALUE; | int lMin = Integer.MAX_VALUE; | ||||
for (int i = 0, n = levels.length; i < n; i++) { | |||||
int l = levels [ i ]; | |||||
for (int l : levels) { | |||||
if ((l >= 0) && (l < lMin)) { | if ((l >= 0) && (l < lMin)) { | ||||
lMin = l; | lMin = l; | ||||
} | } |
&& (args[i + 1].charAt(0) != '-')) { | && (args[i + 1].charAt(0) != '-')) { | ||||
String arg = args[i + 1]; | String arg = args[i + 1]; | ||||
String[] parts = arg.split(","); | String[] parts = arg.split(","); | ||||
for (int j = 0; j < parts.length; j++) { | |||||
String s = parts[j]; | |||||
for (String s : parts) { | |||||
if (s.matches("\\d+")) { | if (s.matches("\\d+")) { | ||||
renderingOptions.put(PrintRenderer.START_PAGE, Integer.valueOf(s)); | renderingOptions.put(PrintRenderer.START_PAGE, Integer.valueOf(s)); | ||||
} else if (s.matches("\\d+-\\d+")) { | } else if (s.matches("\\d+-\\d+")) { | ||||
if ("list".equals(mime)) { | if ("list".equals(mime)) { | ||||
String[] mimes = factory.getRendererFactory().listSupportedMimeTypes(); | String[] mimes = factory.getRendererFactory().listSupportedMimeTypes(); | ||||
System.out.println("Supported MIME types:"); | System.out.println("Supported MIME types:"); | ||||
for (int j = 0; j < mimes.length; j++) { | |||||
System.out.println(" " + mimes[j]); | |||||
for (String mime1 : mimes) { | |||||
System.out.println(" " + mime1); | |||||
} | } | ||||
// @SuppressFBWarnings("DM_EXIT") | // @SuppressFBWarnings("DM_EXIT") | ||||
System.exit(0); | System.exit(0); |
} | } | ||||
files = libDir.listFiles(filter); | files = libDir.listFiles(filter); | ||||
if (files != null) { | if (files != null) { | ||||
for (int i = 0, size = files.length; i < size; i++) { | |||||
jars.add(files[i].toURI().toURL()); | |||||
for (File file : files) { | |||||
jars.add(file.toURI().toURL()); | |||||
} | } | ||||
} | } | ||||
String optionalLib = System.getProperty("fop.optional.lib"); | String optionalLib = System.getProperty("fop.optional.lib"); | ||||
if (optionalLib != null) { | if (optionalLib != null) { | ||||
files = new File(optionalLib).listFiles(filter); | files = new File(optionalLib).listFiles(filter); | ||||
if (files != null) { | if (files != null) { | ||||
for (int i = 0, size = files.length; i < size; i++) { | |||||
jars.add(files[i].toURI().toURL()); | |||||
for (File file : files) { | |||||
jars.add(file.toURI().toURL()); | |||||
} | } | ||||
} | } | ||||
} | } |
package org.apache.fop.complexscripts.bidi; | package org.apache.fop.complexscripts.bidi; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Iterator; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.Stack; | import java.util.Stack; | ||||
import java.util.Vector; | import java.util.Vector; | ||||
} | } | ||||
private static void resolveInlineDirectionality(List ranges) { | private static void resolveInlineDirectionality(List ranges) { | ||||
for (Iterator it = ranges.iterator(); it.hasNext(); ) { | |||||
DelimitedTextRange r = (DelimitedTextRange) it.next(); | |||||
for (Object range : ranges) { | |||||
DelimitedTextRange r = (DelimitedTextRange) range; | |||||
r.resolve(); | r.resolve(); | ||||
if (log.isDebugEnabled()) { | if (log.isDebugEnabled()) { | ||||
log.debug(r); | log.debug(r); | ||||
} | } | ||||
private static List collectRuns(List inlines, List runs) { | private static List collectRuns(List inlines, List runs) { | ||||
for (Iterator it = inlines.iterator(); it.hasNext(); ) { | |||||
InlineArea ia = (InlineArea) it.next(); | |||||
for (Object inline : inlines) { | |||||
InlineArea ia = (InlineArea) inline; | |||||
runs = ia.collectInlineRuns(runs); | runs = ia.collectInlineRuns(runs); | ||||
} | } | ||||
return runs; | return runs; | ||||
private static List splitRuns(List runs) { | private static List splitRuns(List runs) { | ||||
List runsNew = new Vector(); | List runsNew = new Vector(); | ||||
for (Iterator it = runs.iterator(); it.hasNext(); ) { | |||||
InlineRun ir = (InlineRun) it.next(); | |||||
for (Object run : runs) { | |||||
InlineRun ir = (InlineRun) run; | |||||
if (ir.isHomogenous()) { | if (ir.isHomogenous()) { | ||||
runsNew.add(ir); | runsNew.add(ir); | ||||
} else { | } else { | ||||
if (mm == null) { | if (mm == null) { | ||||
mm = new int[] {Integer.MAX_VALUE, Integer.MIN_VALUE}; | mm = new int[] {Integer.MAX_VALUE, Integer.MIN_VALUE}; | ||||
} | } | ||||
for (Iterator it = runs.iterator(); it.hasNext(); ) { | |||||
InlineRun ir = (InlineRun) it.next(); | |||||
for (Object run : runs) { | |||||
InlineRun ir = (InlineRun) run; | |||||
ir.updateMinMax(mm); | ir.updateMinMax(mm); | ||||
} | } | ||||
return mm; | return mm; | ||||
return runsNew; | return runsNew; | ||||
} | } | ||||
private static void reverseWords(List runs, boolean mirror) { | private static void reverseWords(List runs, boolean mirror) { | ||||
for (Iterator it = runs.iterator(); it.hasNext(); ) { | |||||
InlineRun ir = (InlineRun) it.next(); | |||||
for (Object run : runs) { | |||||
InlineRun ir = (InlineRun) run; | |||||
ir.maybeReverseWord(mirror); | ir.maybeReverseWord(mirror); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
private static void replaceInlines(LineArea la, List runs) { | private static void replaceInlines(LineArea la, List runs) { | ||||
List<InlineArea> inlines = new ArrayList<InlineArea>(); | List<InlineArea> inlines = new ArrayList<InlineArea>(); | ||||
for (Iterator it = runs.iterator(); it.hasNext(); ) { | |||||
InlineRun ir = (InlineRun) it.next(); | |||||
for (Object run : runs) { | |||||
InlineRun ir = (InlineRun) run; | |||||
inlines.add(ir.getInline()); | inlines.add(ir.getInline()); | ||||
} | } | ||||
la.setInlineAreas(unflattenInlines(inlines)); | la.setInlineAreas(unflattenInlines(inlines)); | ||||
} | } | ||||
private static void dumpRuns(String header, List runs) { | private static void dumpRuns(String header, List runs) { | ||||
log.debug(header); | log.debug(header); | ||||
for (Iterator it = runs.iterator(); it.hasNext(); ) { | |||||
InlineRun ir = (InlineRun) it.next(); | |||||
for (Object run : runs) { | |||||
InlineRun ir = (InlineRun) run; | |||||
log.debug(ir); | log.debug(ir); | ||||
} | } | ||||
} | } | ||||
private static void dumpRanges(String header, List ranges) { | private static void dumpRanges(String header, List ranges) { | ||||
log.debug(header); | log.debug(header); | ||||
for (Iterator it = ranges.iterator(); it.hasNext(); ) { | |||||
DelimitedTextRange r = (DelimitedTextRange) it.next(); | |||||
for (Object range : ranges) { | |||||
DelimitedTextRange r = (DelimitedTextRange) range; | |||||
log.debug(r); | log.debug(r); | ||||
} | } | ||||
} | } | ||||
private static List pruneEmptyRanges(List ranges) { | private static List pruneEmptyRanges(List ranges) { | ||||
Vector rv = new Vector(); | Vector rv = new Vector(); | ||||
for (Iterator it = ranges.iterator(); it.hasNext(); ) { | |||||
DelimitedTextRange r = (DelimitedTextRange) it.next(); | |||||
for (Object range : ranges) { | |||||
DelimitedTextRange r = (DelimitedTextRange) range; | |||||
if (!r.isEmpty()) { | if (!r.isEmpty()) { | ||||
rv.add(r); | rv.add(r); | ||||
} | } |
package org.apache.fop.complexscripts.bidi; | package org.apache.fop.complexscripts.bidi; | ||||
import java.util.Iterator; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.Vector; | import java.util.Vector; | ||||
StringBuffer sb = new StringBuffer("DR: " + fn.getLocalName() + " { <" + CharUtilities.toNCRefs(buffer.toString()) + ">"); | StringBuffer sb = new StringBuffer("DR: " + fn.getLocalName() + " { <" + CharUtilities.toNCRefs(buffer.toString()) + ">"); | ||||
sb.append(", intervals <"); | sb.append(", intervals <"); | ||||
boolean first = true; | boolean first = true; | ||||
for (Iterator it = intervals.iterator(); it.hasNext(); ) { | |||||
TextInterval ti = (TextInterval) it.next(); | |||||
for (Object interval : intervals) { | |||||
TextInterval ti = (TextInterval) interval; | |||||
if (first) { | if (first) { | ||||
first = false; | first = false; | ||||
} else { | } else { | ||||
*/ | */ | ||||
private void assignLevels(int[] levels) { | private void assignLevels(int[] levels) { | ||||
Vector intervalsNew = new Vector(intervals.size()); | Vector intervalsNew = new Vector(intervals.size()); | ||||
for (Iterator it = intervals.iterator(); it.hasNext(); ) { | |||||
TextInterval ti = (TextInterval) it.next(); | |||||
for (Object interval : intervals) { | |||||
TextInterval ti = (TextInterval) interval; | |||||
intervalsNew.addAll(assignLevels(ti, levels)); | intervalsNew.addAll(assignLevels(ti, levels)); | ||||
} | } | ||||
if (!intervalsNew.equals(intervals)) { | if (!intervalsNew.equals(intervals)) { | ||||
* <p>Assign resolved levels for each interval to source #PCDATA in the associated FOText.</p> | * <p>Assign resolved levels for each interval to source #PCDATA in the associated FOText.</p> | ||||
*/ | */ | ||||
private void assignTextLevels() { | private void assignTextLevels() { | ||||
for (Iterator it = intervals.iterator(); it.hasNext(); ) { | |||||
TextInterval ti = (TextInterval) it.next(); | |||||
for (Object interval : intervals) { | |||||
TextInterval ti = (TextInterval) interval; | |||||
ti.assignTextLevels(); | ti.assignTextLevels(); | ||||
} | } | ||||
} | } | ||||
private void assignBlockLevel(Direction paragraphEmbeddingLevel) { | private void assignBlockLevel(Direction paragraphEmbeddingLevel) { | ||||
int defaultLevel = (paragraphEmbeddingLevel == Direction.RL) ? 1 : 0; | int defaultLevel = (paragraphEmbeddingLevel == Direction.RL) ? 1 : 0; | ||||
for (Iterator it = intervals.iterator(); it.hasNext(); ) { | |||||
TextInterval ti = (TextInterval) it.next(); | |||||
for (Object interval : intervals) { | |||||
TextInterval ti = (TextInterval) interval; | |||||
assignBlockLevel(ti.getNode(), defaultLevel); | assignBlockLevel(ti.getNode(), defaultLevel); | ||||
} | } | ||||
} | } |
int mn = Integer.MAX_VALUE; | int mn = Integer.MAX_VALUE; | ||||
int mx = Integer.MIN_VALUE; | int mx = Integer.MIN_VALUE; | ||||
if ((levels != null) && (levels.length > 0)) { | if ((levels != null) && (levels.length > 0)) { | ||||
for (int i = 0, n = levels.length; i < n; i++) { | |||||
int l = levels [ i ]; | |||||
for (int l : levels) { | |||||
if (l < mn) { | if (l < mn) { | ||||
mn = l; | mn = l; | ||||
} | } | ||||
StringBuffer lb = new StringBuffer(); | StringBuffer lb = new StringBuffer(); | ||||
int maxLevel = -1; | int maxLevel = -1; | ||||
int numLevels = levels.length; | int numLevels = levels.length; | ||||
for (int i = 0; i < numLevels; i++) { | |||||
int l = levels [ i ]; | |||||
for (int l : levels) { | |||||
if (l > maxLevel) { | if (l > maxLevel) { | ||||
maxLevel = l; | maxLevel = l; | ||||
} | } | ||||
// leave level buffer empty | // leave level buffer empty | ||||
} else if (maxLevel < 10) { | } else if (maxLevel < 10) { | ||||
// use string of decimal digits | // use string of decimal digits | ||||
for (int i = 0; i < numLevels; i++) { | |||||
lb.append((char) ('0' + levels [ i ])); | |||||
for (int level : levels) { | |||||
lb.append((char) ('0' + level)); | |||||
} | } | ||||
} else { | } else { | ||||
// use comma separated list | // use comma separated list | ||||
boolean first = true; | boolean first = true; | ||||
for (int i = 0; i < numLevels; i++) { | |||||
for (int level : levels) { | |||||
if (first) { | if (first) { | ||||
first = false; | first = false; | ||||
} else { | } else { | ||||
lb.append(','); | lb.append(','); | ||||
} | } | ||||
lb.append(levels [ i ]); | |||||
lb.append(level); | |||||
} | } | ||||
} | } | ||||
return lb.toString(); | return lb.toString(); |
package org.apache.fop.complexscripts.bidi; | package org.apache.fop.complexscripts.bidi; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Iterator; | |||||
import java.util.LinkedList; | import java.util.LinkedList; | ||||
import java.util.List; | import java.util.List; | ||||
import java.util.Stack; | import java.util.Stack; | ||||
} | } | ||||
List unflatten() { | List unflatten() { | ||||
if (il != null) { | if (il != null) { | ||||
for (Iterator<InlineArea> it = il.iterator(); it.hasNext(); ) { | |||||
process(it.next()); | |||||
for (InlineArea anIl : il) { | |||||
process(anIl); | |||||
} | } | ||||
} | } | ||||
finishAll(); | finishAll(); | ||||
} | } | ||||
private void finishInlineContainer(List<InlineParent> ich, TextArea tc, InlineArea ia) { | private void finishInlineContainer(List<InlineParent> ich, TextArea tc, InlineArea ia) { | ||||
if ((ich != null) && !ich.isEmpty()) { // finish non-matching inner inline container(s) | if ((ich != null) && !ich.isEmpty()) { // finish non-matching inner inline container(s) | ||||
for (Iterator<InlineParent> it = ich.iterator(); it.hasNext(); ) { | |||||
InlineParent ic = it.next(); | |||||
for (InlineParent ic : ich) { | |||||
InlineParent ic0 = icOrig.empty() ? null : icOrig.peek(); | InlineParent ic0 = icOrig.empty() ? null : icOrig.peek(); | ||||
if (ic0 == null) { | if (ic0 == null) { | ||||
assert icNew.empty(); | assert icNew.empty(); | ||||
} | } | ||||
} | } | ||||
private boolean alreadyUnflattened(InlineArea ia) { | private boolean alreadyUnflattened(InlineArea ia) { | ||||
for (Iterator<InlineArea> it = ilNew.iterator(); it.hasNext(); ) { | |||||
if (ia.isAncestorOrSelf(it.next())) { | |||||
for (InlineArea anIlNew : ilNew) { | |||||
if (ia.isAncestorOrSelf(anIlNew)) { | |||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
private void pushInlineContainers(List<InlineParent> ich) { | private void pushInlineContainers(List<InlineParent> ich) { | ||||
LinkedList<InlineParent> icl = new LinkedList<InlineParent>(); | LinkedList<InlineParent> icl = new LinkedList<InlineParent>(); | ||||
for (Iterator<InlineParent> it = ich.iterator(); it.hasNext(); ) { | |||||
InlineParent ic = it.next(); | |||||
for (InlineParent ic : ich) { | |||||
if (icOrig.search(ic) >= 0) { | if (icOrig.search(ic) >= 0) { | ||||
break; | break; | ||||
} else { | } else { | ||||
icl.addFirst(ic); | icl.addFirst(ic); | ||||
} | } | ||||
} | } | ||||
for (Iterator<InlineParent> it = icl.iterator(); it.hasNext(); ) { | |||||
InlineParent ic = it.next(); | |||||
for (InlineParent ic : icl) { | |||||
icOrig.push(ic); | icOrig.push(ic); | ||||
icNew.push(generateInlineContainer(ic)); | icNew.push(generateInlineContainer(ic)); | ||||
} | } | ||||
} | } | ||||
private void updateIPD(TextArea tc) { | private void updateIPD(TextArea tc) { | ||||
int numAdjustable = 0; | int numAdjustable = 0; | ||||
for (Iterator it = tc.getChildAreas().iterator(); it.hasNext(); ) { | |||||
InlineArea ia = (InlineArea) it.next(); | |||||
for (InlineArea ia : tc.getChildAreas()) { | |||||
if (ia instanceof SpaceArea) { | if (ia instanceof SpaceArea) { | ||||
SpaceArea sa = (SpaceArea) ia; | SpaceArea sa = (SpaceArea) ia; | ||||
if (sa.isAdjustable()) { | if (sa.isAdjustable()) { |
if ((entries == null) || (entries.size() == 0)) { | if ((entries == null) || (entries.size() == 0)) { | ||||
return false; | return false; | ||||
} else { | } else { | ||||
for (Iterator it = entries.iterator(); it.hasNext();) { | |||||
Object o = it.next(); | |||||
for (Object o : entries) { | |||||
if (!(o instanceof Integer)) { | if (!(o instanceof Integer)) { | ||||
return false; | return false; | ||||
} | } | ||||
if ((entries == null) || (entries.size() == 0)) { | if ((entries == null) || (entries.size() == 0)) { | ||||
return false; | return false; | ||||
} else { | } else { | ||||
for (Iterator it = entries.iterator(); it.hasNext();) { | |||||
Object o = it.next(); | |||||
for (Object o : entries) { | |||||
if (!(o instanceof MappingRange)) { | if (!(o instanceof MappingRange)) { | ||||
return false; | return false; | ||||
} | } | ||||
if ((entries == null) || (entries.size() == 0)) { | if ((entries == null) || (entries.size() == 0)) { | ||||
return false; | return false; | ||||
} else { | } else { | ||||
for (Iterator it = entries.iterator(); it.hasNext();) { | |||||
Object o = it.next(); | |||||
for (Object o : entries) { | |||||
if (!(o instanceof GlyphCoverageTable)) { | if (!(o instanceof GlyphCoverageTable)) { | ||||
return false; | return false; | ||||
} | } | ||||
List entries = new java.util.ArrayList(); | List entries = new java.util.ArrayList(); | ||||
entries.add(firstGlyph); | entries.add(firstGlyph); | ||||
if (gca != null) { | if (gca != null) { | ||||
for (int i = 0, n = gca.length; i < n; i++) { | |||||
entries.add(gca[i]); | |||||
for (int aGca : gca) { | |||||
entries.add(aGca); | |||||
} | } | ||||
} | } | ||||
return entries; | return entries; |
package org.apache.fop.complexscripts.fonts; | package org.apache.fop.complexscripts.fonts; | ||||
import java.util.Arrays; | import java.util.Arrays; | ||||
import java.util.Iterator; | |||||
import java.util.List; | import java.util.List; | ||||
import org.apache.commons.logging.Log; | import org.apache.commons.logging.Log; | ||||
if ((entries == null) || (entries.size() == 0)) { | if ((entries == null) || (entries.size() == 0)) { | ||||
return false; | return false; | ||||
} else { | } else { | ||||
for (Iterator it = entries.iterator(); it.hasNext();) { | |||||
Object o = it.next(); | |||||
for (Object o : entries) { | |||||
if (!(o instanceof Integer)) { | if (!(o instanceof Integer)) { | ||||
return false; | return false; | ||||
} | } | ||||
if ((entries == null) || (entries.size() == 0)) { | if ((entries == null) || (entries.size() == 0)) { | ||||
return false; | return false; | ||||
} else { | } else { | ||||
for (Iterator it = entries.iterator(); it.hasNext();) { | |||||
Object o = it.next(); | |||||
for (Object o : entries) { | |||||
if (!(o instanceof MappingRange)) { | if (!(o instanceof MappingRange)) { | ||||
return false; | return false; | ||||
} | } | ||||
public List getEntries() { | public List getEntries() { | ||||
List entries = new java.util.ArrayList(); | List entries = new java.util.ArrayList(); | ||||
if (map != null) { | if (map != null) { | ||||
for (int i = 0, n = map.length; i < n; i++) { | |||||
entries.add(map[i]); | |||||
for (int aMap : map) { | |||||
entries.add(aMap); | |||||
} | } | ||||
} | } | ||||
return entries; | return entries; | ||||
int n = entries.size(); | int n = entries.size(); | ||||
int gidMax = -1; | int gidMax = -1; | ||||
int[] map = new int [ n ]; | int[] map = new int [ n ]; | ||||
for (Iterator it = entries.iterator(); it.hasNext();) { | |||||
Object o = it.next(); | |||||
for (Object o : entries) { | |||||
if (o instanceof Integer) { | if (o instanceof Integer) { | ||||
int gid = (Integer) o; | 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; | |||||
} else { | } else { | ||||
log.info("ignoring out of order or duplicate glyph index: " + gid); | log.info("ignoring out of order or duplicate glyph index: " + gid); | ||||
skipped++; | skipped++; |
package org.apache.fop.complexscripts.fonts; | package org.apache.fop.complexscripts.fonts; | ||||
import java.util.HashMap; | import java.util.HashMap; | ||||
import java.util.Iterator; | |||||
import java.util.List; | import java.util.List; | ||||
import org.apache.commons.logging.Log; | import org.apache.commons.logging.Log; | ||||
if ((subtables == null) || (subtables.size() == 0)) { | if ((subtables == null) || (subtables.size() == 0)) { | ||||
throw new AdvancedTypographicTableFormatException("subtables must be non-empty"); | throw new AdvancedTypographicTableFormatException("subtables must be non-empty"); | ||||
} else { | } else { | ||||
for (Iterator it = subtables.iterator(); it.hasNext();) { | |||||
Object o = it.next(); | |||||
for (Object o : subtables) { | |||||
if (o instanceof GlyphDefinitionSubtable) { | if (o instanceof GlyphDefinitionSubtable) { | ||||
addSubtable((GlyphSubtable) o); | addSubtable((GlyphSubtable) o); | ||||
} else { | } else { |
package org.apache.fop.complexscripts.fonts; | package org.apache.fop.complexscripts.fonts; | ||||
import java.util.Arrays; | import java.util.Arrays; | ||||
import java.util.Iterator; | |||||
import java.util.List; | import java.util.List; | ||||
// CSOFF: LineLengthCheck | // CSOFF: LineLengthCheck | ||||
int[] sa = new int [ n ]; | int[] sa = new int [ n ]; | ||||
int[] ea = new int [ n ]; | int[] ea = new int [ n ]; | ||||
int[] ma = new int [ n ]; | int[] ma = new int [ n ]; | ||||
for (Iterator it = entries.iterator(); it.hasNext();) { | |||||
Object o = it.next(); | |||||
for (Object o : entries) { | |||||
if (o instanceof MappingRange) { | if (o instanceof MappingRange) { | ||||
MappingRange r = (MappingRange) o; | MappingRange r = (MappingRange) o; | ||||
int gs = r.getStart(); | int gs = r.getStart(); | ||||
throw new AdvancedTypographicTableFormatException("illegal mapping index: " + mi); | throw new AdvancedTypographicTableFormatException("illegal mapping index: " + mi); | ||||
} else { | } else { | ||||
int miLast; | int miLast; | ||||
sa [ i ] = gs; | |||||
ea [ i ] = gidMax = ge; | |||||
ma [ i ] = mi; | |||||
sa[i] = gs; | |||||
ea[i] = gidMax = ge; | |||||
ma[i] = mi; | |||||
if ((miLast = mi + (ge - gs)) > miMax) { | if ((miLast = mi + (ge - gs)) > miMax) { | ||||
miMax = miLast; | miMax = miLast; | ||||
} | } |
public boolean apply(GlyphTable.RuleLookup[] lookups, int nig) { | public boolean apply(GlyphTable.RuleLookup[] lookups, int nig) { | ||||
if ((lookups != null) && (lookups.length > 0)) { | if ((lookups != null) && (lookups.length > 0)) { | ||||
// apply each rule lookup to extracted input glyph array | // apply each rule lookup to extracted input glyph array | ||||
for (int i = 0, n = lookups.length; i < n; i++) { | |||||
GlyphTable.RuleLookup l = lookups [ i ]; | |||||
for (GlyphTable.RuleLookup l : lookups) { | |||||
if (l != null) { | if (l != null) { | ||||
GlyphTable.LookupTable lt = l.getLookup(); | GlyphTable.LookupTable lt = l.getLookup(); | ||||
if (lt != null) { | if (lt != null) { |
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Arrays; | import java.util.Arrays; | ||||
import java.util.Iterator; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | import java.util.Map; | ||||
if ((subtables == null) || (subtables.size() == 0)) { | if ((subtables == null) || (subtables.size() == 0)) { | ||||
throw new AdvancedTypographicTableFormatException("subtables must be non-empty"); | throw new AdvancedTypographicTableFormatException("subtables must be non-empty"); | ||||
} else { | } else { | ||||
for (Iterator it = subtables.iterator(); it.hasNext();) { | |||||
Object o = it.next(); | |||||
for (Object o : subtables) { | |||||
if (o instanceof GlyphPositioningSubtable) { | if (o instanceof GlyphPositioningSubtable) { | ||||
addSubtable((GlyphSubtable) o); | addSubtable((GlyphSubtable) o); | ||||
} else { | } else { | ||||
public List getEntries() { | public List getEntries() { | ||||
if (values != null) { | if (values != null) { | ||||
List entries = new ArrayList(values.length); | List entries = new ArrayList(values.length); | ||||
for (int i = 0, n = values.length; i < n; i++) { | |||||
entries.add(values[i]); | |||||
for (Value value : values) { | |||||
entries.add(value); | |||||
} | } | ||||
return entries; | return entries; | ||||
} else { | } else { | ||||
public PairValues getPairValues(int ci, int gi1, int gi2) { | public PairValues getPairValues(int ci, int gi1, int gi2) { | ||||
if ((pvm != null) && (ci < pvm.length)) { | if ((pvm != null) && (ci < pvm.length)) { | ||||
PairValues[] pvt = pvm [ ci ]; | PairValues[] pvt = pvm [ ci ]; | ||||
for (int i = 0, n = pvt.length; i < n; i++) { | |||||
PairValues pv = pvt [ i ]; | |||||
for (PairValues pv : pvt) { | |||||
if (pv != null) { | if (pv != null) { | ||||
int g = pv.getGlyph(); | int g = pv.getGlyph(); | ||||
if (g < gi2) { | if (g < gi2) { | ||||
RuleSet rs = rsa [ 0 ]; | RuleSet rs = rsa [ 0 ]; | ||||
if (rs != null) { | if (rs != null) { | ||||
Rule[] ra = rs.getRules(); | Rule[] ra = rs.getRules(); | ||||
for (int i = 0, n = ra.length; i < n; i++) { | |||||
Rule r = ra [ i ]; | |||||
for (Rule r : ra) { | |||||
if ((r != null) && (r instanceof ChainedGlyphSequenceRule)) { | if ((r != null) && (r instanceof ChainedGlyphSequenceRule)) { | ||||
ChainedGlyphSequenceRule cr = (ChainedGlyphSequenceRule) r; | ChainedGlyphSequenceRule cr = (ChainedGlyphSequenceRule) r; | ||||
int[] iga = cr.getGlyphs(gi); | int[] iga = cr.getGlyphs(gi); | ||||
RuleSet rs = rsa [ 0 ]; | RuleSet rs = rsa [ 0 ]; | ||||
if (rs != null) { | if (rs != null) { | ||||
Rule[] ra = rs.getRules(); | Rule[] ra = rs.getRules(); | ||||
for (int i = 0, n = ra.length; i < n; i++) { | |||||
Rule r = ra [ i ]; | |||||
for (Rule r : ra) { | |||||
if ((r != null) && (r instanceof ChainedClassSequenceRule)) { | if ((r != null) && (r instanceof ChainedClassSequenceRule)) { | ||||
ChainedClassSequenceRule cr = (ChainedClassSequenceRule) r; | ChainedClassSequenceRule cr = (ChainedClassSequenceRule) r; | ||||
int[] ca = cr.getClasses(cdt.getClassIndex(gi, ps.getClassMatchSet(gi))); | int[] ca = cr.getClasses(cdt.getClassIndex(gi, ps.getClassMatchSet(gi))); | ||||
RuleSet rs = rsa [ 0 ]; | RuleSet rs = rsa [ 0 ]; | ||||
if (rs != null) { | if (rs != null) { | ||||
Rule[] ra = rs.getRules(); | Rule[] ra = rs.getRules(); | ||||
for (int i = 0, n = ra.length; i < n; i++) { | |||||
Rule r = ra [ i ]; | |||||
for (Rule r : ra) { | |||||
if ((r != null) && (r instanceof ChainedCoverageSequenceRule)) { | if ((r != null) && (r instanceof ChainedCoverageSequenceRule)) { | ||||
ChainedCoverageSequenceRule cr = (ChainedCoverageSequenceRule) r; | ChainedCoverageSequenceRule cr = (ChainedCoverageSequenceRule) r; | ||||
GlyphCoverageTable[] gca = cr.getCoverages(); | GlyphCoverageTable[] gca = cr.getCoverages(); | ||||
RuleSet rs = rsa [ 0 ]; | RuleSet rs = rsa [ 0 ]; | ||||
if (rs != null) { | if (rs != null) { | ||||
Rule[] ra = rs.getRules(); | Rule[] ra = rs.getRules(); | ||||
for (int i = 0, n = ra.length; i < n; i++) { | |||||
Rule r = ra [ i ]; | |||||
for (Rule r : ra) { | |||||
if ((r != null) && (r instanceof ChainedGlyphSequenceRule)) { | if ((r != null) && (r instanceof ChainedGlyphSequenceRule)) { | ||||
ChainedGlyphSequenceRule cr = (ChainedGlyphSequenceRule) r; | ChainedGlyphSequenceRule cr = (ChainedGlyphSequenceRule) r; | ||||
int[] iga = cr.getGlyphs(gi); | int[] iga = cr.getGlyphs(gi); | ||||
RuleSet rs = rsa [ 0 ]; | RuleSet rs = rsa [ 0 ]; | ||||
if (rs != null) { | if (rs != null) { | ||||
Rule[] ra = rs.getRules(); | Rule[] ra = rs.getRules(); | ||||
for (int i = 0, n = ra.length; i < n; i++) { | |||||
Rule r = ra [ i ]; | |||||
for (Rule r : ra) { | |||||
if ((r != null) && (r instanceof ChainedClassSequenceRule)) { | if ((r != null) && (r instanceof ChainedClassSequenceRule)) { | ||||
ChainedClassSequenceRule cr = (ChainedClassSequenceRule) r; | ChainedClassSequenceRule cr = (ChainedClassSequenceRule) r; | ||||
int[] ica = cr.getClasses(icdt.getClassIndex(gi, ps.getClassMatchSet(gi))); | int[] ica = cr.getClasses(icdt.getClassIndex(gi, ps.getClassMatchSet(gi))); | ||||
RuleSet rs = rsa [ 0 ]; | RuleSet rs = rsa [ 0 ]; | ||||
if (rs != null) { | if (rs != null) { | ||||
Rule[] ra = rs.getRules(); | Rule[] ra = rs.getRules(); | ||||
for (int i = 0, n = ra.length; i < n; i++) { | |||||
Rule r = ra [ i ]; | |||||
for (Rule r : ra) { | |||||
if ((r != null) && (r instanceof ChainedCoverageSequenceRule)) { | if ((r != null) && (r instanceof ChainedCoverageSequenceRule)) { | ||||
ChainedCoverageSequenceRule cr = (ChainedCoverageSequenceRule) r; | ChainedCoverageSequenceRule cr = (ChainedCoverageSequenceRule) r; | ||||
GlyphCoverageTable[] igca = cr.getCoverages(); | GlyphCoverageTable[] igca = cr.getCoverages(); |
int nog = 0; | int nog = 0; | ||||
if ((lookups != null) && (lookups.length > 0)) { | if ((lookups != null) && (lookups.length > 0)) { | ||||
// apply each rule lookup to extracted input glyph array | // apply each rule lookup to extracted input glyph array | ||||
for (int i = 0, n = lookups.length; i < n; i++) { | |||||
GlyphTable.RuleLookup l = lookups [ i ]; | |||||
for (GlyphTable.RuleLookup l : lookups) { | |||||
if (l != null) { | if (l != null) { | ||||
GlyphTable.LookupTable lt = l.getLookup(); | GlyphTable.LookupTable lt = l.getLookup(); | ||||
if (lt != null) { | if (lt != null) { |
package org.apache.fop.complexscripts.fonts; | package org.apache.fop.complexscripts.fonts; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Iterator; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | import java.util.Map; | ||||
if ((subtables == null) || (subtables.size() == 0)) { | if ((subtables == null) || (subtables.size() == 0)) { | ||||
throw new AdvancedTypographicTableFormatException("subtables must be non-empty"); | throw new AdvancedTypographicTableFormatException("subtables must be non-empty"); | ||||
} else { | } else { | ||||
for (Iterator it = subtables.iterator(); it.hasNext();) { | |||||
Object o = it.next(); | |||||
for (Object o : subtables) { | |||||
if (o instanceof GlyphSubstitutionSubtable) { | if (o instanceof GlyphSubstitutionSubtable) { | ||||
addSubtable((GlyphSubtable) o); | addSubtable((GlyphSubtable) o); | ||||
} else { | } else { | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public List getEntries() { | public List getEntries() { | ||||
List entries = new ArrayList(glyphs.length); | List entries = new ArrayList(glyphs.length); | ||||
for (int i = 0, n = glyphs.length; i < n; i++) { | |||||
entries.add(glyphs[i]); | |||||
for (int glyph : glyphs) { | |||||
entries.add(glyph); | |||||
} | } | ||||
return entries; | return entries; | ||||
} | } | ||||
int i = 0; | int i = 0; | ||||
int n = entries.size(); | int n = entries.size(); | ||||
int[] glyphs = new int [ n ]; | int[] glyphs = new int [ n ]; | ||||
for (Iterator it = entries.iterator(); it.hasNext();) { | |||||
Object o = it.next(); | |||||
for (Object o : entries) { | |||||
if (o instanceof Integer) { | if (o instanceof Integer) { | ||||
int gid = (Integer) o; | int gid = (Integer) o; | ||||
if ((gid >= 0) && (gid < 65536)) { | if ((gid >= 0) && (gid < 65536)) { | ||||
glyphs [ i++ ] = gid; | |||||
glyphs[i++] = gid; | |||||
} else { | } else { | ||||
throw new AdvancedTypographicTableFormatException("illegal glyph index: " + gid); | throw new AdvancedTypographicTableFormatException("illegal glyph index: " + gid); | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public List getEntries() { | public List getEntries() { | ||||
List entries = new ArrayList(gaa.length); | List entries = new ArrayList(gaa.length); | ||||
for (int i = 0, n = gaa.length; i < n; i++) { | |||||
entries.add(gaa[i]); | |||||
for (int[] aGaa : gaa) { | |||||
entries.add(aGaa); | |||||
} | } | ||||
return entries; | return entries; | ||||
} | } | ||||
int i = 0; | int i = 0; | ||||
int n = entries.size(); | int n = entries.size(); | ||||
int[][] gaa = new int [ n ][]; | int[][] gaa = new int [ n ][]; | ||||
for (Iterator it = entries.iterator(); it.hasNext();) { | |||||
Object o = it.next(); | |||||
for (Object o : entries) { | |||||
if (o instanceof int[]) { | if (o instanceof int[]) { | ||||
gaa [ i++ ] = (int[]) o; | |||||
gaa[i++] = (int[]) o; | |||||
} else { | } else { | ||||
throw new AdvancedTypographicTableFormatException("illegal entries entry, must be int[]: " + o); | throw new AdvancedTypographicTableFormatException("illegal entries entry, must be int[]: " + o); | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public List getEntries() { | public List getEntries() { | ||||
List entries = new ArrayList(ligatureSets.length); | List entries = new ArrayList(ligatureSets.length); | ||||
for (int i = 0, n = ligatureSets.length; i < n; i++) { | |||||
entries.add(ligatureSets[i]); | |||||
for (LigatureSet ligatureSet : ligatureSets) { | |||||
entries.add(ligatureSet); | |||||
} | } | ||||
return entries; | return entries; | ||||
} | } | ||||
int i = 0; | int i = 0; | ||||
int n = entries.size(); | int n = entries.size(); | ||||
LigatureSet[] ligatureSets = new LigatureSet [ n ]; | LigatureSet[] ligatureSets = new LigatureSet [ n ]; | ||||
for (Iterator it = entries.iterator(); it.hasNext();) { | |||||
Object o = it.next(); | |||||
for (Object o : entries) { | |||||
if (o instanceof LigatureSet) { | if (o instanceof LigatureSet) { | ||||
ligatureSets [ i++ ] = (LigatureSet) o; | |||||
ligatureSets[i++] = (LigatureSet) o; | |||||
} else { | } else { | ||||
throw new AdvancedTypographicTableFormatException("illegal ligatures entry, must be LigatureSet: " + o); | throw new AdvancedTypographicTableFormatException("illegal ligatures entry, must be LigatureSet: " + o); | ||||
} | } | ||||
RuleSet rs = rsa [ 0 ]; | RuleSet rs = rsa [ 0 ]; | ||||
if (rs != null) { | if (rs != null) { | ||||
Rule[] ra = rs.getRules(); | Rule[] ra = rs.getRules(); | ||||
for (int i = 0, n = ra.length; i < n; i++) { | |||||
Rule r = ra [ i ]; | |||||
for (Rule r : ra) { | |||||
if ((r != null) && (r instanceof ChainedGlyphSequenceRule)) { | if ((r != null) && (r instanceof ChainedGlyphSequenceRule)) { | ||||
ChainedGlyphSequenceRule cr = (ChainedGlyphSequenceRule) r; | ChainedGlyphSequenceRule cr = (ChainedGlyphSequenceRule) r; | ||||
int[] iga = cr.getGlyphs(gi); | int[] iga = cr.getGlyphs(gi); | ||||
RuleSet rs = rsa [ 0 ]; | RuleSet rs = rsa [ 0 ]; | ||||
if (rs != null) { | if (rs != null) { | ||||
Rule[] ra = rs.getRules(); | Rule[] ra = rs.getRules(); | ||||
for (int i = 0, n = ra.length; i < n; i++) { | |||||
Rule r = ra [ i ]; | |||||
for (Rule r : ra) { | |||||
if ((r != null) && (r instanceof ChainedClassSequenceRule)) { | if ((r != null) && (r instanceof ChainedClassSequenceRule)) { | ||||
ChainedClassSequenceRule cr = (ChainedClassSequenceRule) r; | ChainedClassSequenceRule cr = (ChainedClassSequenceRule) r; | ||||
int[] ca = cr.getClasses(cdt.getClassIndex(gi, ss.getClassMatchSet(gi))); | int[] ca = cr.getClasses(cdt.getClassIndex(gi, ss.getClassMatchSet(gi))); | ||||
RuleSet rs = rsa [ 0 ]; | RuleSet rs = rsa [ 0 ]; | ||||
if (rs != null) { | if (rs != null) { | ||||
Rule[] ra = rs.getRules(); | Rule[] ra = rs.getRules(); | ||||
for (int i = 0, n = ra.length; i < n; i++) { | |||||
Rule r = ra [ i ]; | |||||
for (Rule r : ra) { | |||||
if ((r != null) && (r instanceof ChainedCoverageSequenceRule)) { | if ((r != null) && (r instanceof ChainedCoverageSequenceRule)) { | ||||
ChainedCoverageSequenceRule cr = (ChainedCoverageSequenceRule) r; | ChainedCoverageSequenceRule cr = (ChainedCoverageSequenceRule) r; | ||||
GlyphCoverageTable[] gca = cr.getCoverages(); | GlyphCoverageTable[] gca = cr.getCoverages(); | ||||
RuleSet rs = rsa [ 0 ]; | RuleSet rs = rsa [ 0 ]; | ||||
if (rs != null) { | if (rs != null) { | ||||
Rule[] ra = rs.getRules(); | Rule[] ra = rs.getRules(); | ||||
for (int i = 0, n = ra.length; i < n; i++) { | |||||
Rule r = ra [ i ]; | |||||
for (Rule r : ra) { | |||||
if ((r != null) && (r instanceof ChainedGlyphSequenceRule)) { | if ((r != null) && (r instanceof ChainedGlyphSequenceRule)) { | ||||
ChainedGlyphSequenceRule cr = (ChainedGlyphSequenceRule) r; | ChainedGlyphSequenceRule cr = (ChainedGlyphSequenceRule) r; | ||||
int[] iga = cr.getGlyphs(gi); | int[] iga = cr.getGlyphs(gi); | ||||
RuleSet rs = rsa [ 0 ]; | RuleSet rs = rsa [ 0 ]; | ||||
if (rs != null) { | if (rs != null) { | ||||
Rule[] ra = rs.getRules(); | Rule[] ra = rs.getRules(); | ||||
for (int i = 0, n = ra.length; i < n; i++) { | |||||
Rule r = ra [ i ]; | |||||
for (Rule r : ra) { | |||||
if ((r != null) && (r instanceof ChainedClassSequenceRule)) { | if ((r != null) && (r instanceof ChainedClassSequenceRule)) { | ||||
ChainedClassSequenceRule cr = (ChainedClassSequenceRule) r; | ChainedClassSequenceRule cr = (ChainedClassSequenceRule) r; | ||||
int[] ica = cr.getClasses(icdt.getClassIndex(gi, ss.getClassMatchSet(gi))); | int[] ica = cr.getClasses(icdt.getClassIndex(gi, ss.getClassMatchSet(gi))); | ||||
RuleSet rs = rsa [ 0 ]; | RuleSet rs = rsa [ 0 ]; | ||||
if (rs != null) { | if (rs != null) { | ||||
Rule[] ra = rs.getRules(); | Rule[] ra = rs.getRules(); | ||||
for (int i = 0, n = ra.length; i < n; i++) { | |||||
Rule r = ra [ i ]; | |||||
for (Rule r : ra) { | |||||
if ((r != null) && (r instanceof ChainedCoverageSequenceRule)) { | if ((r != null) && (r instanceof ChainedCoverageSequenceRule)) { | ||||
ChainedCoverageSequenceRule cr = (ChainedCoverageSequenceRule) r; | ChainedCoverageSequenceRule cr = (ChainedCoverageSequenceRule) r; | ||||
GlyphCoverageTable[] igca = cr.getCoverages(); | GlyphCoverageTable[] igca = cr.getCoverages(); | ||||
} else if (components == null) { | } else if (components == null) { | ||||
throw new AdvancedTypographicTableFormatException("invalid ligature components, must be non-null array"); | throw new AdvancedTypographicTableFormatException("invalid ligature components, must be non-null array"); | ||||
} else { | } else { | ||||
for (int i = 0, n = components.length; i < n; i++) { | |||||
int gc = components [ i ]; | |||||
for (int gc : components) { | |||||
if ((gc < 0) || (gc > 65535)) { | if ((gc < 0) || (gc > 65535)) { | ||||
throw new AdvancedTypographicTableFormatException("invalid component glyph index: " + gc); | throw new AdvancedTypographicTableFormatException("invalid component glyph index: " + gc); | ||||
} | } | ||||
} else { | } else { | ||||
this.ligatures = ligatures; | this.ligatures = ligatures; | ||||
int ncMax = -1; | int ncMax = -1; | ||||
for (int i = 0, n = ligatures.length; i < n; i++) { | |||||
Ligature l = ligatures [ i ]; | |||||
for (Ligature l : ligatures) { | |||||
int nc = l.getNumComponents() + 1; | int nc = l.getNumComponents() + 1; | ||||
if (nc > ncMax) { | if (nc > ncMax) { | ||||
ncMax = nc; | ncMax = nc; |
if ((subtables == null) || (subtables.length == 0)) { | if ((subtables == null) || (subtables.length == 0)) { | ||||
return false; | return false; | ||||
} else { | } else { | ||||
for (int i = 0, n = subtables.length; i < n; i++) { | |||||
if (subtables[i].usesReverseScan()) { | |||||
for (GlyphSubtable subtable : subtables) { | |||||
if (subtable.usesReverseScan()) { | |||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
} else { | } else { | ||||
int flags = 0; | int flags = 0; | ||||
// obtain first non-zero value of flags in array of subtables | // obtain first non-zero value of flags in array of subtables | ||||
for (int i = 0, n = subtables.length; i < n; i++) { | |||||
int f = subtables[i].getFlags(); | |||||
for (GlyphSubtable subtable1 : subtables) { | |||||
int f = subtable1.getFlags(); | |||||
if (flags == 0) { | if (flags == 0) { | ||||
flags = f; | flags = f; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
// enforce flag consistency | // enforce flag consistency | ||||
for (int i = 0, n = subtables.length; i < n; i++) { | |||||
int f = subtables[i].getFlags(); | |||||
for (GlyphSubtable subtable : subtables) { | |||||
int f = subtable.getFlags(); | |||||
if (f != flags) { | if (f != flags) { | ||||
throw new IllegalStateException("inconsistent lookup flags " + f + ", expected " + flags); | throw new IllegalStateException("inconsistent lookup flags " + f + ", expected " + flags); | ||||
} | } |
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Arrays; | import java.util.Arrays; | ||||
import java.util.HashMap; | import java.util.HashMap; | ||||
import java.util.Iterator; | |||||
import java.util.LinkedHashMap; | import java.util.LinkedHashMap; | ||||
import java.util.LinkedList; | import java.util.LinkedList; | ||||
import java.util.List; | import java.util.List; | ||||
public List/*<LookupTable>*/ getLookupTables() { | public List/*<LookupTable>*/ getLookupTables() { | ||||
TreeSet/*<String>*/ lids = new TreeSet/*<String>*/(lookupTables.keySet()); | TreeSet/*<String>*/ lids = new TreeSet/*<String>*/(lookupTables.keySet()); | ||||
List/*<LookupTable>*/ ltl = new ArrayList/*<LookupTable>*/(lids.size()); | List/*<LookupTable>*/ ltl = new ArrayList/*<LookupTable>*/(lids.size()); | ||||
for (Iterator it = lids.iterator(); it.hasNext(); ) { | |||||
String lid = (String) it.next(); | |||||
for (Object lid1 : lids) { | |||||
String lid = (String) lid1; | |||||
ltl.add(lookupTables.get(lid)); | ltl.add(lookupTables.get(lid)); | ||||
} | } | ||||
return ltl; | return ltl; | ||||
*/ | */ | ||||
protected void freezeSubtables() { | protected void freezeSubtables() { | ||||
if (!frozen) { | if (!frozen) { | ||||
for (Iterator it = lookupTables.values().iterator(); it.hasNext(); ) { | |||||
LookupTable lt = (LookupTable) it.next(); | |||||
for (Object o : lookupTables.values()) { | |||||
LookupTable lt = (LookupTable) o; | |||||
lt.freezeSubtables(lookupTables); | lt.freezeSubtables(lookupTables); | ||||
} | } | ||||
frozen = true; | frozen = true; | ||||
public List/*<LookupSpec>*/ matchLookupSpecs(String script, String language, String feature) { | public List/*<LookupSpec>*/ matchLookupSpecs(String script, String language, String feature) { | ||||
Set/*<LookupSpec>*/ keys = lookups.keySet(); | Set/*<LookupSpec>*/ keys = lookups.keySet(); | ||||
List/*<LookupSpec>*/ matches = new ArrayList/*<LookupSpec>*/(); | List/*<LookupSpec>*/ matches = new ArrayList/*<LookupSpec>*/(); | ||||
for (Iterator it = keys.iterator(); it.hasNext();) { | |||||
LookupSpec ls = (LookupSpec) it.next(); | |||||
for (Object key : keys) { | |||||
LookupSpec ls = (LookupSpec) key; | |||||
if (!"*".equals(script)) { | if (!"*".equals(script)) { | ||||
if (!ls.getScript().equals(script)) { | if (!ls.getScript().equals(script)) { | ||||
continue; | continue; | ||||
if (lm == null) { | if (lm == null) { | ||||
lm = new LinkedHashMap(); | lm = new LinkedHashMap(); | ||||
List/*<LookupSpec>*/ lsl = matchLookupSpecs(script, language, feature); | List/*<LookupSpec>*/ lsl = matchLookupSpecs(script, language, feature); | ||||
for (Iterator it = lsl.iterator(); it.hasNext(); ) { | |||||
LookupSpec ls = (LookupSpec) it.next(); | |||||
for (Object aLsl : lsl) { | |||||
LookupSpec ls = (LookupSpec) aLsl; | |||||
lm.put(ls, findLookupTables(ls)); | lm.put(ls, findLookupTables(ls)); | ||||
} | } | ||||
matchedLookups.put(lsm, lm); | matchedLookups.put(lsm, lm); | ||||
TreeSet/*<LookupTable>*/ lts = new TreeSet/*<LookupTable>*/(); | TreeSet/*<LookupTable>*/ lts = new TreeSet/*<LookupTable>*/(); | ||||
List/*<String>*/ ids; | List/*<String>*/ ids; | ||||
if ((ids = (List/*<String>*/) lookups.get(ls)) != null) { | if ((ids = (List/*<String>*/) lookups.get(ls)) != null) { | ||||
for (Iterator it = ids.iterator(); it.hasNext();) { | |||||
String lid = (String) it.next(); | |||||
for (Object id : ids) { | |||||
String lid = (String) id; | |||||
LookupTable lt; | LookupTable lt; | ||||
if ((lt = (LookupTable) lookupTables.get(lid)) != null) { | if ((lt = (LookupTable) lookupTables.get(lid)) != null) { | ||||
lts.add(lt); | lts.add(lt); | ||||
*/ | */ | ||||
public UseSpec[] assembleLookups(String[] features, Map/*<LookupSpec,List<LookupTable>>*/ lookups) { | public UseSpec[] assembleLookups(String[] features, Map/*<LookupSpec,List<LookupTable>>*/ lookups) { | ||||
TreeSet/*<UseSpec>*/ uss = new TreeSet/*<UseSpec>*/(); | TreeSet/*<UseSpec>*/ uss = new TreeSet/*<UseSpec>*/(); | ||||
for (int i = 0, n = features.length; i < n; i++) { | |||||
String feature = features[i]; | |||||
for (Iterator it = lookups.entrySet().iterator(); it.hasNext(); ) { | |||||
Map.Entry/*<LookupSpec,List<LookupTable>>*/ e = (Map.Entry/*<LookupSpec,List<LookupTable>>*/) it.next(); | |||||
for (String feature : features) { | |||||
for (Object o : lookups.entrySet()) { | |||||
Map.Entry/*<LookupSpec,List<LookupTable>>*/ e = (Map.Entry/*<LookupSpec,List<LookupTable>>*/) o; | |||||
LookupSpec ls = (LookupSpec) e.getKey(); | LookupSpec ls = (LookupSpec) e.getKey(); | ||||
if (ls.getFeature().equals(feature)) { | if (ls.getFeature().equals(feature)) { | ||||
List/*<LookupTable>*/ ltl = (List/*<LookupTable>*/) e.getValue(); | List/*<LookupTable>*/ ltl = (List/*<LookupTable>*/) e.getValue(); | ||||
if (ltl != null) { | if (ltl != null) { | ||||
for (Iterator ltit = ltl.iterator(); ltit.hasNext(); ) { | |||||
LookupTable lt = (LookupTable) ltit.next(); | |||||
for (Object aLtl : ltl) { | |||||
LookupTable lt = (LookupTable) aLtl; | |||||
uss.add(new UseSpec(lt, feature)); | uss.add(new UseSpec(lt, feature)); | ||||
} | } | ||||
} | } | ||||
*/ | */ | ||||
public static void resolveLookupReferences(RuleSet[] rsa, Map/*<String,LookupTable>*/ lookupTables) { | public static void resolveLookupReferences(RuleSet[] rsa, Map/*<String,LookupTable>*/ lookupTables) { | ||||
if ((rsa != null) && (lookupTables != null)) { | if ((rsa != null) && (lookupTables != null)) { | ||||
for (int i = 0, n = rsa.length; i < n; i++) { | |||||
RuleSet rs = rsa [ i ]; | |||||
for (RuleSet rs : rsa) { | |||||
if (rs != null) { | if (rs != null) { | ||||
rs.resolveLookupReferences(lookupTables); | rs.resolveLookupReferences(lookupTables); | ||||
} | } | ||||
this.idOrdinal = Integer.parseInt(id.substring(2)); | this.idOrdinal = Integer.parseInt(id.substring(2)); | ||||
this.subtables = new LinkedList/*<GlyphSubtable>*/(); | this.subtables = new LinkedList/*<GlyphSubtable>*/(); | ||||
if (subtables != null) { | if (subtables != null) { | ||||
for (Iterator it = subtables.iterator(); it.hasNext(); ) { | |||||
GlyphSubtable st = (GlyphSubtable) it.next(); | |||||
for (Object subtable : subtables) { | |||||
GlyphSubtable st = (GlyphSubtable) subtable; | |||||
addSubtable(st); | addSubtable(st); | ||||
} | } | ||||
} | } | ||||
private void resolveLookupReferences(GlyphSubtable[] subtables, Map/*<String,LookupTable>*/ lookupTables) { | private void resolveLookupReferences(GlyphSubtable[] subtables, Map/*<String,LookupTable>*/ lookupTables) { | ||||
if (subtables != null) { | if (subtables != null) { | ||||
for (int i = 0, n = subtables.length; i < n; i++) { | |||||
GlyphSubtable st = subtables [ i ]; | |||||
for (GlyphSubtable st : subtables) { | |||||
if (st != null) { | if (st != null) { | ||||
st.resolveLookupReferences(lookupTables); | st.resolveLookupReferences(lookupTables); | ||||
} | } | ||||
*/ | */ | ||||
public void resolveLookupReferences(Map/*<String,LookupTable>*/ lookupTables) { | public void resolveLookupReferences(Map/*<String,LookupTable>*/ lookupTables) { | ||||
if (lookups != null) { | if (lookups != null) { | ||||
for (int i = 0, n = lookups.length; i < n; i++) { | |||||
RuleLookup l = lookups [ i ]; | |||||
for (RuleLookup l : lookups) { | |||||
if (l != null) { | if (l != null) { | ||||
l.resolveLookupReferences(lookupTables); | l.resolveLookupReferences(lookupTables); | ||||
} | } | ||||
*/ | */ | ||||
public void resolveLookupReferences(Map/*<String,LookupTable>*/ lookupTables) { | public void resolveLookupReferences(Map/*<String,LookupTable>*/ lookupTables) { | ||||
if (rules != null) { | if (rules != null) { | ||||
for (int i = 0, n = rules.length; i < n; i++) { | |||||
Rule r = rules [ i ]; | |||||
for (Rule r : rules) { | |||||
if (r != null) { | if (r != null) { | ||||
r.resolveLookupReferences(lookupTables); | r.resolveLookupReferences(lookupTables); | ||||
} | } |
import java.io.IOException; | import java.io.IOException; | ||||
import java.util.Arrays; | import java.util.Arrays; | ||||
import java.util.Iterator; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | import java.util.Map; | ||||
} | } | ||||
private void constructLookupsFeatures(Map lookups, String st, String lt, List/*<String>*/ fids) { | private void constructLookupsFeatures(Map lookups, String st, String lt, List/*<String>*/ fids) { | ||||
for (Iterator fit = fids.iterator(); fit.hasNext();) { | |||||
String fid = (String) fit.next(); | |||||
for (Object fid1 : fids) { | |||||
String fid = (String) fid1; | |||||
constructLookupsFeature(lookups, st, lt, fid); | constructLookupsFeature(lookups, st, lt, fid); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
private void constructLookupsLanguages(Map lookups, String st, List/*<String>*/ ll, Map/*<String,Object[2]>*/ languages) { | private void constructLookupsLanguages(Map lookups, String st, List/*<String>*/ ll, Map/*<String,Object[2]>*/ languages) { | ||||
for (Iterator lit = ll.iterator(); lit.hasNext();) { | |||||
String lt = (String) lit.next(); | |||||
for (Object aLl : ll) { | |||||
String lt = (String) aLl; | |||||
constructLookupsLanguage(lookups, st, lt, languages); | constructLookupsLanguage(lookups, st, lt, languages); | ||||
} | } | ||||
} | } | ||||
private Map constructLookups() { | private Map constructLookups() { | ||||
Map/*<GlyphTable.LookupSpec,List<String>>*/ lookups = new java.util.LinkedHashMap(); | Map/*<GlyphTable.LookupSpec,List<String>>*/ lookups = new java.util.LinkedHashMap(); | ||||
for (Iterator sit = seScripts.keySet().iterator(); sit.hasNext();) { | |||||
String st = (String) sit.next(); | |||||
for (Object o : seScripts.keySet()) { | |||||
String st = (String) o; | |||||
Object[] sp = (Object[]) seScripts.get(st); | Object[] sp = (Object[]) seScripts.get(st); | ||||
if (sp != null) { | if (sp != null) { | ||||
assert sp.length == 3; | assert sp.length == 3; | ||||
private List constructGDEFSubtables() { | private List constructGDEFSubtables() { | ||||
List/*<GlyphDefinitionSubtable>*/ subtables = new java.util.ArrayList(); | List/*<GlyphDefinitionSubtable>*/ subtables = new java.util.ArrayList(); | ||||
if (seSubtables != null) { | if (seSubtables != null) { | ||||
for (Iterator it = seSubtables.iterator(); it.hasNext();) { | |||||
Object[] stp = (Object[]) it.next(); | |||||
for (Object seSubtable : seSubtables) { | |||||
Object[] stp = (Object[]) seSubtable; | |||||
GlyphSubtable st; | GlyphSubtable st; | ||||
if ((st = constructGDEFSubtable(stp)) != null) { | if ((st = constructGDEFSubtable(stp)) != null) { | ||||
subtables.add(st); | subtables.add(st); | ||||
private List constructGSUBSubtables() { | private List constructGSUBSubtables() { | ||||
List/*<GlyphSubtable>*/ subtables = new java.util.ArrayList(); | List/*<GlyphSubtable>*/ subtables = new java.util.ArrayList(); | ||||
if (seSubtables != null) { | if (seSubtables != null) { | ||||
for (Iterator it = seSubtables.iterator(); it.hasNext();) { | |||||
Object[] stp = (Object[]) it.next(); | |||||
for (Object seSubtable : seSubtables) { | |||||
Object[] stp = (Object[]) seSubtable; | |||||
GlyphSubtable st; | GlyphSubtable st; | ||||
if ((st = constructGSUBSubtable(stp)) != null) { | if ((st = constructGSUBSubtable(stp)) != null) { | ||||
subtables.add(st); | subtables.add(st); | ||||
private List constructGPOSSubtables() { | private List constructGPOSSubtables() { | ||||
List/*<GlyphSubtable>*/ subtables = new java.util.ArrayList(); | List/*<GlyphSubtable>*/ subtables = new java.util.ArrayList(); | ||||
if (seSubtables != null) { | if (seSubtables != null) { | ||||
for (Iterator it = seSubtables.iterator(); it.hasNext();) { | |||||
Object[] stp = (Object[]) it.next(); | |||||
for (Object seSubtable : seSubtables) { | |||||
Object[] stp = (Object[]) seSubtable; | |||||
GlyphSubtable st; | GlyphSubtable st; | ||||
if ((st = constructGPOSSubtable(stp)) != null) { | if ((st = constructGPOSSubtable(stp)) != null) { | ||||
subtables.add(st); | subtables.add(st); | ||||
sb.append('-'); | sb.append('-'); | ||||
} else { | } else { | ||||
boolean first = true; | boolean first = true; | ||||
for (int i = 0; i < ia.length; i++) { | |||||
for (int anIa : ia) { | |||||
if (!first) { | if (!first) { | ||||
sb.append(' '); | sb.append(' '); | ||||
} else { | } else { | ||||
first = false; | first = false; | ||||
} | } | ||||
sb.append(ia[i]); | |||||
sb.append(anIa); | |||||
} | } | ||||
} | } | ||||
return sb.toString(); | return sb.toString(); |
for (int i = 0, n = sa.length; i < n; i++) { | for (int i = 0, n = sa.length; i < n; i++) { | ||||
GlyphSequence s = sa [ i ]; | GlyphSequence s = sa [ i ]; | ||||
// apply basic shaping subs | // apply basic shaping subs | ||||
for (int j = 0, m = usa.length; j < m; j++) { | |||||
GlyphTable.UseSpec us = usa [ j ]; | |||||
for (GlyphTable.UseSpec us : usa) { | |||||
if (isBasicShapingUse(us)) { | if (isBasicShapingUse(us)) { | ||||
s.setPredications(true); | s.setPredications(true); | ||||
s = us.substitute(s, script, language, sct); | s = us.substitute(s, script, language, sct); | ||||
// reorder reph | // reorder reph | ||||
s = reorderReph(s); | s = reorderReph(s); | ||||
// apply presentation subs | // apply presentation subs | ||||
for (int j = 0, m = usa.length; j < m; j++) { | |||||
GlyphTable.UseSpec us = usa [ j ]; | |||||
for (GlyphTable.UseSpec us : usa) { | |||||
if (isPresentationUse(us)) { | if (isPresentationUse(us)) { | ||||
s.setPredications(true); | s.setPredications(true); | ||||
s = us.substitute(s, script, language, sct); | s = us.substitute(s, script, language, sct); | ||||
int[] ga = gs.getGlyphArray(false); | int[] ga = gs.getGlyphArray(false); | ||||
CharAssociation[] aa = gs.getAssociations(0, -1); | CharAssociation[] aa = gs.getAssociations(0, -1); | ||||
Vector<GlyphSequence> nsv = new Vector<GlyphSequence>(); | Vector<GlyphSequence> nsv = new Vector<GlyphSequence>(); | ||||
for (int i = 0, ns = sa.length; i < ns; i++) { | |||||
Segment s = sa [ i ]; | |||||
for (Segment s : sa) { | |||||
Vector<Integer> ngv = new Vector<Integer>(ng); | Vector<Integer> ngv = new Vector<Integer>(ng); | ||||
Vector<CharAssociation> nav = new Vector<CharAssociation>(ng); | Vector<CharAssociation> nav = new Vector<CharAssociation>(ng); | ||||
for (int j = 0; j < ng; j++) { | for (int j = 0; j < ng; j++) { | ||||
CharAssociation ca = aa [ j ]; | |||||
CharAssociation ca = aa[j]; | |||||
if (ca.contained(s.getOffset(), s.getCount())) { | if (ca.contained(s.getOffset(), s.getCount())) { | ||||
ngv.add(ga [ j ]); | |||||
ngv.add(ga[j]); | |||||
nav.add(ca); | nav.add(ca); | ||||
} | } | ||||
} | } | ||||
if (ngv.size() > 0) { | if (ngv.size() > 0) { | ||||
nsv.add(new GlyphSequence(gs, null, toIntArray(ngv), null, null, nav.toArray(new CharAssociation [ nav.size() ]), null)); | |||||
nsv.add(new GlyphSequence(gs, null, toIntArray(ngv), null, null, nav.toArray(new CharAssociation[nav.size()]), null)); | |||||
} | } | ||||
} | } | ||||
if (nsv.size() > 0) { | if (nsv.size() > 0) { |
*/ | */ | ||||
public GlyphSequence substitute(GlyphSequence gs, String script, String language, GlyphTable.UseSpec[] usa, ScriptContextTester sct) { | public GlyphSequence substitute(GlyphSequence gs, String script, String language, GlyphTable.UseSpec[] usa, ScriptContextTester sct) { | ||||
assert usa != null; | assert usa != null; | ||||
for (int i = 0, n = usa.length; i < n; i++) { | |||||
GlyphTable.UseSpec us = usa [ i ]; | |||||
for (GlyphTable.UseSpec us : usa) { | |||||
gs = us.substitute(gs, script, language, sct); | gs = us.substitute(gs, script, language, sct); | ||||
} | } | ||||
return gs; | return gs; | ||||
public boolean position(GlyphSequence gs, String script, String language, int fontSize, GlyphTable.UseSpec[] usa, int[] widths, int[][] adjustments, ScriptContextTester sct) { | public boolean position(GlyphSequence gs, String script, String language, int fontSize, GlyphTable.UseSpec[] usa, int[] widths, int[][] adjustments, ScriptContextTester sct) { | ||||
assert usa != null; | assert usa != null; | ||||
boolean adjusted = false; | boolean adjusted = false; | ||||
for (int i = 0, n = usa.length; i < n; i++) { | |||||
GlyphTable.UseSpec us = usa [ i ]; | |||||
for (GlyphTable.UseSpec us : usa) { | |||||
if (us.position(gs, script, language, fontSize, widths, adjustments, sct)) { | if (us.position(gs, script, language, fontSize, widths, adjustments, sct)) { | ||||
adjusted = true; | adjusted = true; | ||||
} | } |
*/ | */ | ||||
private static int[] extractIntervals(CharAssociation[] aa) { | private static int[] extractIntervals(CharAssociation[] aa) { | ||||
int ni = 0; | int ni = 0; | ||||
for (int i = 0, n = aa.length; i < n; i++) { | |||||
CharAssociation a = aa [ i ]; | |||||
for (CharAssociation a : aa) { | |||||
if (a.isDisjoint()) { | if (a.isDisjoint()) { | ||||
ni += a.getSubIntervalCount(); | ni += a.getSubIntervalCount(); | ||||
} else { | } else { | ||||
assert sa.length == ea.length; | assert sa.length == ea.length; | ||||
int ni = sa.length; | int ni = sa.length; | ||||
int[] incr = (ni < 21) ? SORT_INCREMENTS_03 : SORT_INCREMENTS_16; | int[] incr = (ni < 21) ? SORT_INCREMENTS_03 : SORT_INCREMENTS_16; | ||||
for (int k = 0; k < incr.length; k++) { | |||||
for (int h = incr [ k ], i = h, n = ni, j; i < n; i++) { | |||||
int s1 = sa [ i ]; | |||||
int e1 = ea [ i ]; | |||||
for (int anIncr : incr) { | |||||
for (int h = anIncr, i = h, n = ni, j; i < n; i++) { | |||||
int s1 = sa[i]; | |||||
int e1 = ea[i]; | |||||
for (j = i; j >= h; j -= h) { | for (j = i; j >= h; j -= h) { | ||||
int s2 = sa [ j - h ]; | |||||
int e2 = ea [ j - h ]; | |||||
int s2 = sa[j - h]; | |||||
int e2 = ea[j - h]; | |||||
if (s2 > s1) { | if (s2 > s1) { | ||||
sa [ j ] = s2; | |||||
ea [ j ] = e2; | |||||
sa[j] = s2; | |||||
ea[j] = e2; | |||||
} else if ((s2 == s1) && (e2 > e1)) { | } else if ((s2 == s1) && (e2 > e1)) { | ||||
sa [ j ] = s2; | |||||
ea [ j ] = e2; | |||||
sa[j] = s2; | |||||
ea[j] = e2; | |||||
} else { | } else { | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
sa [ j ] = s1; | |||||
ea [ j ] = e1; | |||||
sa[j] = s1; | |||||
ea[j] = e1; | |||||
} | } | ||||
} | } | ||||
int[] ia = new int [ ni * 2 ]; | int[] ia = new int [ ni * 2 ]; |
import java.util.Arrays; | import java.util.Arrays; | ||||
import java.util.HashMap; | import java.util.HashMap; | ||||
import java.util.HashSet; | import java.util.HashSet; | ||||
import java.util.Iterator; | |||||
import java.util.Map; | import java.util.Map; | ||||
import java.util.Set; | import java.util.Set; | ||||
} | } | ||||
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();) { | |||||
sa [ ns++ ] = (Integer) it.next(); | |||||
for (Object value : s) { | |||||
sa[ns++] = (Integer) value; | |||||
} | } | ||||
Arrays.sort(sa); | Arrays.sort(sa); | ||||
return sa; | return sa; | ||||
} | } | ||||
int sMax = -1; | int sMax = -1; | ||||
int cMax = -1; | int cMax = -1; | ||||
for (Iterator it = m.entrySet().iterator(); it.hasNext();) { | |||||
Map.Entry e = (Map.Entry) it.next(); | |||||
for (Object o : m.entrySet()) { | |||||
Map.Entry e = (Map.Entry) o; | |||||
Integer k = (Integer) e.getKey(); | Integer k = (Integer) e.getKey(); | ||||
int s = k; | int s = k; | ||||
switch (s) { | switch (s) { | ||||
case SCRIPT_UNDETERMINED: | |||||
case SCRIPT_UNCODED: | |||||
break; | |||||
default: | |||||
Integer v = (Integer) e.getValue(); | |||||
assert v != null; | |||||
int c = v; | |||||
if (c > cMax) { | |||||
cMax = c; | |||||
sMax = s; | |||||
} | |||||
break; | |||||
case SCRIPT_UNDETERMINED: | |||||
case SCRIPT_UNCODED: | |||||
break; | |||||
default: | |||||
Integer v = (Integer) e.getValue(); | |||||
assert v != null; | |||||
int c = v; | |||||
if (c > cMax) { | |||||
cMax = c; | |||||
sMax = s; | |||||
} | |||||
break; | |||||
} | } | ||||
} | } | ||||
if (sMax < 0) { | if (sMax < 0) { |
if (na > 0) { | if (na > 0) { | ||||
List gl = new ArrayList(na); | List gl = new ArrayList(na); | ||||
if (baa != null) { | if (baa != null) { | ||||
for (int i = 0; i < baa.length; i++) { | |||||
gl.add(baa[i]); | |||||
for (CharAssociation aBaa : baa) { | |||||
gl.add(aBaa); | |||||
} | } | ||||
} | } | ||||
if (iaa != null) { | if (iaa != null) { | ||||
for (int i = 0; i < iaa.length; i++) { | |||||
gl.add(iaa[i]); | |||||
for (CharAssociation anIaa : iaa) { | |||||
gl.add(anIaa); | |||||
} | } | ||||
} | } | ||||
if (laa != null) { | if (laa != null) { | ||||
for (int i = 0; i < laa.length; i++) { | |||||
gl.add(laa[i]); | |||||
for (CharAssociation aLaa : laa) { | |||||
gl.add(aLaa); | |||||
} | } | ||||
} | } | ||||
return gl; | return gl; | ||||
assert sa != null; | assert sa != null; | ||||
int tg = 0; | int tg = 0; | ||||
int ta = 0; | int ta = 0; | ||||
for (int i = 0, n = sa.length; i < n; i++) { | |||||
GlyphSequence s = sa [ i ]; | |||||
for (GlyphSequence s : sa) { | |||||
IntBuffer ga = s.getGlyphs(); | IntBuffer ga = s.getGlyphs(); | ||||
assert ga != null; | assert ga != null; | ||||
int ng = ga.limit(); | int ng = ga.limit(); | ||||
} | } | ||||
IntBuffer uga = IntBuffer.allocate(tg); | IntBuffer uga = IntBuffer.allocate(tg); | ||||
ArrayList ual = new ArrayList(ta); | ArrayList ual = new ArrayList(ta); | ||||
for (int i = 0, n = sa.length; i < n; i++) { | |||||
GlyphSequence s = sa [ i ]; | |||||
for (GlyphSequence s : sa) { | |||||
uga.put(s.getGlyphs()); | uga.put(s.getGlyphs()); | ||||
ual.addAll(s.getAssociations()); | ual.addAll(s.getAssociations()); | ||||
} | } |
int tokenType = TOKEN_NONE; | int tokenType = TOKEN_NONE; | ||||
List<Integer> token = new ArrayList<Integer>(); | List<Integer> token = new ArrayList<Integer>(); | ||||
Integer[] ca = UTF32.toUTF32(format, 0, true); | Integer[] ca = UTF32.toUTF32(format, 0, true); | ||||
for (int i = 0, n = ca.length; i < n; i++) { | |||||
int c = ca[i]; | |||||
for (Integer c : ca) { | |||||
int tokenTypeNew = isAlphaNumeric(c) ? TOKEN_ALPHANUMERIC : TOKEN_NONALPHANUMERIC; | int tokenTypeNew = isAlphaNumeric(c) ? TOKEN_ALPHANUMERIC : TOKEN_NONALPHANUMERIC; | ||||
if (tokenTypeNew != tokenType) { | if (tokenTypeNew != tokenType) { | ||||
if (token.size() > 0) { | if (token.size() > 0) { | ||||
if (tokenType == TOKEN_ALPHANUMERIC) { | if (tokenType == TOKEN_ALPHANUMERIC) { | ||||
tokens.add(token.toArray(new Integer [ token.size() ])); | |||||
tokens.add(token.toArray(new Integer[token.size()])); | |||||
} else { | } else { | ||||
separators.add(token.toArray(new Integer [ token.size() ])); | |||||
separators.add(token.toArray(new Integer[token.size()])); | |||||
} | } | ||||
token.clear(); | token.clear(); | ||||
} | } | ||||
for (String[] el : equivalentLanguages) { | for (String[] el : equivalentLanguages) { | ||||
assert el.length >= 2; | assert el.length >= 2; | ||||
if (el[0].equals(i3c)) { | if (el[0].equals(i3c)) { | ||||
for (int i = 0, n = el.length; i < n; i++) { | |||||
if (el[i].equals(lc)) { | |||||
for (String anEl : el) { | |||||
if (anEl.equals(lc)) { | |||||
return true; | return true; | ||||
} | } | ||||
} | } |
} else { | } else { | ||||
try { | try { | ||||
byte[] utf8 = Character.toString(ch).getBytes("UTF-8"); | byte[] utf8 = Character.toString(ch).getBytes("UTF-8"); | ||||
for (int j = 0, cj = utf8.length; j < cj; j++) { | |||||
appendEscape(sb, utf8[j]); | |||||
for (byte anUtf8 : utf8) { | |||||
appendEscape(sb, anUtf8); | |||||
} | } | ||||
} catch (UnsupportedEncodingException e) { | } catch (UnsupportedEncodingException e) { | ||||
throw new Error("Incompatible JVM. UTF-8 not supported."); | throw new Error("Incompatible JVM. UTF-8 not supported."); |
/** Integrates the border-after of the part. */ | /** Integrates the border-after of the part. */ | ||||
void resolveBordersLastRowInPart(List/*<GridUnit>*/ row, boolean withNormal, | void resolveBordersLastRowInPart(List/*<GridUnit>*/ row, boolean withNormal, | ||||
boolean withLeadingTrailing, boolean withRest) { | boolean withLeadingTrailing, boolean withRest) { | ||||
for (int i = 0; i < row.size(); i++) { | |||||
((GridUnit) row.get(i)).integrateBorderSegment(CommonBorderPaddingBackground.AFTER, | |||||
for (Object aRow : row) { | |||||
((GridUnit) aRow).integrateBorderSegment(CommonBorderPaddingBackground.AFTER, | |||||
tablePart, withNormal, withLeadingTrailing, withRest); | tablePart, withNormal, withLeadingTrailing, withRest); | ||||
} | } | ||||
} | } | ||||
// Resolve before- and after-borders for the table-row | // Resolve before- and after-borders for the table-row | ||||
if (container instanceof TableRow) { | if (container instanceof TableRow) { | ||||
TableRow tableRow = (TableRow) container; | TableRow tableRow = (TableRow) container; | ||||
for (Iterator iter = row.iterator(); iter.hasNext();) { | |||||
GridUnit gu = (GridUnit) iter.next(); | |||||
for (Object aRow : row) { | |||||
GridUnit gu = (GridUnit) aRow; | |||||
boolean first = (gu.getRowSpanIndex() == 0); | boolean first = (gu.getRowSpanIndex() == 0); | ||||
boolean last = gu.isLastGridUnitRowSpan(); | boolean last = gu.isLastGridUnitRowSpan(); | ||||
gu.integrateBorderSegment(CommonBorderPaddingBackground.BEFORE, tableRow, | gu.integrateBorderSegment(CommonBorderPaddingBackground.BEFORE, tableRow, | ||||
} | } | ||||
if (firstInPart) { | if (firstInPart) { | ||||
// Integrate the border-before of the part | // Integrate the border-before of the part | ||||
for (int i = 0; i < row.size(); i++) { | |||||
((GridUnit) row.get(i)).integrateBorderSegment( | |||||
for (Object aRow : row) { | |||||
((GridUnit) aRow).integrateBorderSegment( | |||||
CommonBorderPaddingBackground.BEFORE, tablePart, true, true, true); | CommonBorderPaddingBackground.BEFORE, tablePart, true, true, true); | ||||
} | } | ||||
firstInPart = false; | firstInPart = false; | ||||
* To represent those values we (ab)use the normal and the rest fields of | * To represent those values we (ab)use the normal and the rest fields of | ||||
* ConditionalBorder. But strictly speaking this is not their purposes. | * ConditionalBorder. But strictly speaking this is not their purposes. | ||||
*/ | */ | ||||
for (Iterator guIter = row.iterator(); guIter.hasNext();) { | |||||
ConditionalBorder borderBefore = ((GridUnit) guIter.next()).borderBefore; | |||||
for (Object aRow : row) { | |||||
ConditionalBorder borderBefore = ((GridUnit) aRow).borderBefore; | |||||
borderBefore.leadingTrailing = borderBefore.normal; | borderBefore.leadingTrailing = borderBefore.normal; | ||||
borderBefore.rest = borderBefore.normal; | borderBefore.rest = borderBefore.normal; | ||||
} | } | ||||
* grid units from the body will always resolve against the same, normal | * grid units from the body will always resolve against the same, normal | ||||
* header border. | * header border. | ||||
*/ | */ | ||||
for (Iterator guIter = previousRow.iterator(); guIter.hasNext();) { | |||||
ConditionalBorder borderAfter = ((GridUnit) guIter.next()).borderAfter; | |||||
for (Object aPreviousRow : previousRow) { | |||||
ConditionalBorder borderAfter = ((GridUnit) aPreviousRow).borderAfter; | |||||
borderAfter.leadingTrailing = borderAfter.normal; | borderAfter.leadingTrailing = borderAfter.normal; | ||||
borderAfter.rest = borderAfter.normal; | borderAfter.rest = borderAfter.normal; | ||||
leadingBorders.add(borderAfter); | leadingBorders.add(borderAfter); | ||||
resolveBordersLastRowInPart(footerLastRow, true, true, true); | resolveBordersLastRowInPart(footerLastRow, true, true, true); | ||||
trailingBorders = new ArrayList(table.getNumberOfColumns()); | trailingBorders = new ArrayList(table.getNumberOfColumns()); | ||||
// See same method in ResolverInHeader for an explanation of the hack | // See same method in ResolverInHeader for an explanation of the hack | ||||
for (Iterator guIter = footerFirstRow.iterator(); guIter.hasNext();) { | |||||
ConditionalBorder borderBefore = ((GridUnit) guIter.next()).borderBefore; | |||||
for (Object aFooterFirstRow : footerFirstRow) { | |||||
ConditionalBorder borderBefore = ((GridUnit) aFooterFirstRow).borderBefore; | |||||
borderBefore.leadingTrailing = borderBefore.normal; | borderBefore.leadingTrailing = borderBefore.normal; | ||||
borderBefore.rest = borderBefore.normal; | borderBefore.rest = borderBefore.normal; | ||||
trailingBorders.add(borderBefore); | trailingBorders.add(borderBefore); | ||||
// first row of table-footer | // first row of table-footer | ||||
resolveBordersBetweenRows(previousRow, footerFirstRow); | resolveBordersBetweenRows(previousRow, footerFirstRow); | ||||
// See endRow method in ResolverInHeader for an explanation of the hack | // See endRow method in ResolverInHeader for an explanation of the hack | ||||
for (Iterator guIter = footerLastRow.iterator(); guIter.hasNext();) { | |||||
ConditionalBorder borderAfter = ((GridUnit) guIter.next()).borderAfter; | |||||
for (Object aFooterLastRow : footerLastRow) { | |||||
ConditionalBorder borderAfter = ((GridUnit) aFooterLastRow).borderAfter; | |||||
borderAfter.leadingTrailing = borderAfter.normal; | borderAfter.leadingTrailing = borderAfter.normal; | ||||
borderAfter.rest = borderAfter.normal; | borderAfter.rest = borderAfter.normal; | ||||
} | } | ||||
previousRow = row; | previousRow = row; | ||||
if (firstInBody) { | if (firstInBody) { | ||||
firstInBody = false; | firstInBody = false; | ||||
for (Iterator iter = row.iterator(); iter.hasNext();) { | |||||
GridUnit gu = (GridUnit) iter.next(); | |||||
for (Object aRow : row) { | |||||
GridUnit gu = (GridUnit) aRow; | |||||
gu.borderBefore.leadingTrailing = gu.borderBefore.normal; | gu.borderBefore.leadingTrailing = gu.borderBefore.normal; | ||||
} | } | ||||
} | } | ||||
// Trailing and rest borders already resolved with integrateTrailingBorders | // Trailing and rest borders already resolved with integrateTrailingBorders | ||||
resolveBordersLastRowInTable(previousRow, true, false, false); | resolveBordersLastRowInTable(previousRow, true, false, false); | ||||
} | } | ||||
for (Iterator iter = previousRow.iterator(); iter.hasNext();) { | |||||
GridUnit gu = (GridUnit) iter.next(); | |||||
for (Object aPreviousRow : previousRow) { | |||||
GridUnit gu = (GridUnit) aPreviousRow; | |||||
gu.borderAfter.leadingTrailing = gu.borderAfter.normal; | gu.borderAfter.leadingTrailing = gu.borderAfter.normal; | ||||
} | } | ||||
} | } | ||||
if (leadingBorders == null || table.omitHeaderAtBreak()) { | if (leadingBorders == null || table.omitHeaderAtBreak()) { | ||||
// No header, leading borders determined by the table | // No header, leading borders determined by the table | ||||
leadingBorders = new ArrayList(table.getNumberOfColumns()); | leadingBorders = new ArrayList(table.getNumberOfColumns()); | ||||
for (Iterator colIter = table.getColumns().iterator(); colIter.hasNext();) { | |||||
ConditionalBorder border = ((TableColumn) colIter.next()).borderBefore; | |||||
for (Object o : table.getColumns()) { | |||||
ConditionalBorder border = ((TableColumn) o).borderBefore; | |||||
leadingBorders.add(border); | leadingBorders.add(border); | ||||
} | } | ||||
} | } | ||||
if (trailingBorders == null || table.omitFooterAtBreak()) { | if (trailingBorders == null || table.omitFooterAtBreak()) { | ||||
// No footer, trailing borders determined by the table | // No footer, trailing borders determined by the table | ||||
trailingBorders = new ArrayList(table.getNumberOfColumns()); | trailingBorders = new ArrayList(table.getNumberOfColumns()); | ||||
for (Iterator colIter = table.getColumns().iterator(); colIter.hasNext();) { | |||||
ConditionalBorder border = ((TableColumn) colIter.next()).borderAfter; | |||||
for (Object o : table.getColumns()) { | |||||
ConditionalBorder border = ((TableColumn) o).borderAfter; | |||||
trailingBorders.add(border); | trailingBorders.add(border); | ||||
} | } | ||||
} | } | ||||
delegate = null; | delegate = null; | ||||
/* TODO Temporary hack for resolved borders in header */ | /* TODO Temporary hack for resolved borders in header */ | ||||
if (headerLastRow != null) { | if (headerLastRow != null) { | ||||
for (Iterator iter = headerLastRow.iterator(); iter.hasNext();) { | |||||
GridUnit gu = (GridUnit) iter.next(); | |||||
for (Object aHeaderLastRow : headerLastRow) { | |||||
GridUnit gu = (GridUnit) aHeaderLastRow; | |||||
gu.borderAfter.leadingTrailing = gu.borderAfter.normal; | gu.borderAfter.leadingTrailing = gu.borderAfter.normal; | ||||
} | } | ||||
} | } | ||||
if (footerLastRow != null) { | if (footerLastRow != null) { | ||||
for (Iterator iter = footerLastRow.iterator(); iter.hasNext();) { | |||||
GridUnit gu = (GridUnit) iter.next(); | |||||
for (Object aFooterLastRow : footerLastRow) { | |||||
GridUnit gu = (GridUnit) aFooterLastRow; | |||||
gu.borderAfter.leadingTrailing = gu.borderAfter.normal; | gu.borderAfter.leadingTrailing = gu.borderAfter.normal; | ||||
} | } | ||||
} | } |
package org.apache.fop.fo.flow.table; | package org.apache.fop.fo.flow.table; | ||||
import java.util.Iterator; | |||||
import java.util.List; | import java.util.List; | ||||
import org.apache.fop.fo.Constants; | import org.apache.fop.fo.Constants; | ||||
this.bodyType = bodyType; | this.bodyType = bodyType; | ||||
this.gridUnits = gridUnits; | this.gridUnits = gridUnits; | ||||
// TODO this is ugly, but we may eventually be able to do without that index | // TODO this is ugly, but we may eventually be able to do without that index | ||||
for (Iterator guIter = gridUnits.iterator(); guIter.hasNext();) { | |||||
Object gu = guIter.next(); | |||||
for (Object gu : gridUnits) { | |||||
if (gu instanceof PrimaryGridUnit) { | if (gu instanceof PrimaryGridUnit) { | ||||
((PrimaryGridUnit) gu).setRowIndex(index); | ((PrimaryGridUnit) gu).setRowIndex(index); | ||||
} | } | ||||
if (row != null) { | if (row != null) { | ||||
keep = Keep.getKeep(row.getKeepWithPrevious()); | keep = Keep.getKeep(row.getKeepWithPrevious()); | ||||
} | } | ||||
for (Iterator iter = gridUnits.iterator(); iter.hasNext();) { | |||||
GridUnit gu = (GridUnit) iter.next(); | |||||
for (Object gridUnit : gridUnits) { | |||||
GridUnit gu = (GridUnit) gridUnit; | |||||
if (gu.isPrimary()) { | if (gu.isPrimary()) { | ||||
keep = keep.compare(gu.getPrimary().getKeepWithPrevious()); | keep = keep.compare(gu.getPrimary().getKeepWithPrevious()); | ||||
} | } | ||||
if (row != null) { | if (row != null) { | ||||
keep = Keep.getKeep(row.getKeepWithNext()); | keep = Keep.getKeep(row.getKeepWithNext()); | ||||
} | } | ||||
for (Iterator iter = gridUnits.iterator(); iter.hasNext();) { | |||||
GridUnit gu = (GridUnit) iter.next(); | |||||
for (Object gridUnit : gridUnits) { | |||||
GridUnit gu = (GridUnit) gridUnit; | |||||
if (!gu.isEmpty() && gu.getColSpanIndex() == 0 && gu.isLastGridUnitRowSpan()) { | if (!gu.isEmpty() && gu.getColSpanIndex() == 0 && gu.isLastGridUnitRowSpan()) { | ||||
keep = keep.compare(gu.getPrimary().getKeepWithNext()); | keep = keep.compare(gu.getPrimary().getKeepWithNext()); | ||||
} | } | ||||
*/ | */ | ||||
public int getBreakBefore() { | public int getBreakBefore() { | ||||
int breakBefore = Constants.EN_AUTO; | int breakBefore = Constants.EN_AUTO; | ||||
for (Iterator iter = gridUnits.iterator(); iter.hasNext();) { | |||||
GridUnit gu = (GridUnit) iter.next(); | |||||
for (Object gridUnit : gridUnits) { | |||||
GridUnit gu = (GridUnit) gridUnit; | |||||
if (gu.isPrimary()) { | if (gu.isPrimary()) { | ||||
breakBefore = BreakUtil.compareBreakClasses(breakBefore, | breakBefore = BreakUtil.compareBreakClasses(breakBefore, | ||||
gu.getPrimary().getBreakBefore()); | gu.getPrimary().getBreakBefore()); | ||||
*/ | */ | ||||
public int getBreakAfter() { | public int getBreakAfter() { | ||||
int breakAfter = Constants.EN_AUTO; | int breakAfter = Constants.EN_AUTO; | ||||
for (Iterator iter = gridUnits.iterator(); iter.hasNext();) { | |||||
GridUnit gu = (GridUnit) iter.next(); | |||||
for (Object gridUnit : gridUnits) { | |||||
GridUnit gu = (GridUnit) gridUnit; | |||||
if (!gu.isEmpty() && gu.getColSpanIndex() == 0 && gu.isLastGridUnitRowSpan()) { | if (!gu.isEmpty() && gu.getColSpanIndex() == 0 && gu.isLastGridUnitRowSpan()) { | ||||
breakAfter = BreakUtil.compareBreakClasses(breakAfter, | breakAfter = BreakUtil.compareBreakClasses(breakAfter, | ||||
gu.getPrimary().getBreakAfter()); | gu.getPrimary().getBreakAfter()); |
package org.apache.fop.fo.flow.table; | package org.apache.fop.fo.flow.table; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Iterator; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.ListIterator; | |||||
import org.apache.fop.fo.Constants; | import org.apache.fop.fo.Constants; | ||||
import org.apache.fop.fo.ValidationException; | import org.apache.fop.fo.ValidationException; | ||||
} | } | ||||
private static void setFlagForCols(int flag, List row) { | private static void setFlagForCols(int flag, List row) { | ||||
for (ListIterator iter = row.listIterator(); iter.hasNext();) { | |||||
((GridUnit) iter.next()).setFlag(flag); | |||||
for (Object aRow : row) { | |||||
((GridUnit) aRow).setFlag(flag); | |||||
} | } | ||||
} | } | ||||
eventProducer.breakIgnoredDueToRowSpanning(this, currentTableRow.getName(), false, | eventProducer.breakIgnoredDueToRowSpanning(this, currentTableRow.getName(), false, | ||||
currentTableRow.getLocator()); | currentTableRow.getLocator()); | ||||
} | } | ||||
for (Iterator iter = ((List) rows.get(currentRowIndex)).iterator(); iter.hasNext();) { | |||||
GridUnit gu = (GridUnit) iter.next(); | |||||
for (Object o : ((List) rows.get(currentRowIndex))) { | |||||
GridUnit gu = (GridUnit) o; | |||||
// The row hasn't been filled with empty grid units yet | // The row hasn't been filled with empty grid units yet | ||||
if (gu != null) { | if (gu != null) { | ||||
gu.setRow(currentTableRow); | gu.setRow(currentTableRow); |
package org.apache.fop.fo.flow.table; | package org.apache.fop.fo.flow.table; | ||||
import java.util.Iterator; | |||||
import java.util.LinkedList; | import java.util.LinkedList; | ||||
import java.util.List; | import java.util.List; | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
void endTable() throws ValidationException { | void endTable() throws ValidationException { | ||||
RowGroupBuilder delegate = new FixedColRowGroupBuilder(table); | RowGroupBuilder delegate = new FixedColRowGroupBuilder(table); | ||||
for (Iterator eventIter = events.iterator(); eventIter.hasNext();) { | |||||
((Event) eventIter.next()).play(delegate); | |||||
for (Object event : events) { | |||||
((Event) event).play(delegate); | |||||
} | } | ||||
delegate.endTable(); | delegate.endTable(); | ||||
} | } |
if (super.isCorrespondingForced(propertyList)) { | if (super.isCorrespondingForced(propertyList)) { | ||||
return true; | return true; | ||||
} | } | ||||
for (int i = 0; i < extraCorresponding.length; i++) { | |||||
int wmcorr = extraCorresponding[i][0]; //propertyList.getWritingMode()]; | |||||
for (int[] anExtraCorresponding : extraCorresponding) { | |||||
int wmcorr = anExtraCorresponding[0]; //propertyList.getWritingMode()]; | |||||
if (propertyList.getExplicit(wmcorr) != null) { | if (propertyList.getExplicit(wmcorr) != null) { | ||||
return true; | return true; | ||||
} | } |
String internalName = null; | String internalName = null; | ||||
for (int i = 0; i < embedFontInfoList.size(); i++) { | |||||
EmbedFontInfo embedFontInfo = embedFontInfoList.get(i); | |||||
for (EmbedFontInfo embedFontInfo : embedFontInfoList) { | |||||
internalName = "F" + num; | internalName = "F" + num; | ||||
num++; | num++; | ||||
fontInfo.addMetrics(internalName, font); | fontInfo.addMetrics(internalName, font); | ||||
List<FontTriplet> triplets = embedFontInfo.getFontTriplets(); | List<FontTriplet> triplets = embedFontInfo.getFontTriplets(); | ||||
for (int tripletIndex = 0; tripletIndex < triplets.size(); tripletIndex++) { | |||||
FontTriplet triplet = triplets.get(tripletIndex); | |||||
for (FontTriplet triplet : triplets) { | |||||
fontInfo.addFontProperties(internalName, triplet); | fontInfo.addFontProperties(internalName, triplet); | ||||
} | } | ||||
} | } |
URI embedFile = embedFontInfo.getEmbedURI(); | URI embedFile = embedFontInfo.getEmbedURI(); | ||||
log.debug("Adding font " + (embedFile != null ? embedFile + ", " : "") | log.debug("Adding font " + (embedFile != null ? embedFile + ", " : "") | ||||
+ "metrics URI " + embedFontInfo.getMetricsURI()); | + "metrics URI " + embedFontInfo.getMetricsURI()); | ||||
for (int j = 0; j < tripletList.size(); ++j) { | |||||
FontTriplet triplet = tripletList.get(j); | |||||
for (FontTriplet triplet : tripletList) { | |||||
log.debug(" Font triplet " | log.debug(" Font triplet " | ||||
+ triplet.getName() + ", " | + triplet.getName() + ", " | ||||
+ triplet.getStyle() + ", " | + triplet.getStyle() + ", " |
if (embedFontInfos == null) { | if (embedFontInfos == null) { | ||||
continue; | continue; | ||||
} | } | ||||
for (int i = 0, c = embedFontInfos.length; i < c; i++) { | |||||
EmbedFontInfo fontInfo = embedFontInfos[i]; | |||||
for (EmbedFontInfo fontInfo : embedFontInfos) { | |||||
if (fontInfo != null) { | if (fontInfo != null) { | ||||
fontInfoList.add(fontInfo); | fontInfoList.add(fontInfo); | ||||
} | } |
* @return file font file | * @return file font file | ||||
*/ | */ | ||||
public static File getFileFromUrls(String[] urls) { | public static File getFileFromUrls(String[] urls) { | ||||
for (int i = 0; i < urls.length; i++) { | |||||
String urlStr = urls[i]; | |||||
for (String urlStr : urls) { | |||||
if (urlStr != null) { | if (urlStr != null) { | ||||
File fontFile = null; | File fontFile = null; | ||||
if (urlStr.startsWith("file:")) { | if (urlStr.startsWith("file:")) { |
* @param weight font weight | * @param weight font weight | ||||
*/ | */ | ||||
public void addFontProperties(String name, String[] families, String style, int weight) { | public void addFontProperties(String name, String[] families, String style, int weight) { | ||||
for (int i = 0; i < families.length; i++) { | |||||
addFontProperties(name, families[i], style, weight); | |||||
for (String family : families) { | |||||
addFontProperties(name, family, style, weight); | |||||
} | } | ||||
} | } | ||||
private List<FontTriplet> fontLookup(String[] families, String style, int weight, boolean substitutable) { | private List<FontTriplet> fontLookup(String[] families, String style, int weight, boolean substitutable) { | ||||
List<FontTriplet> matchingTriplets = new ArrayList<FontTriplet>(); | List<FontTriplet> matchingTriplets = new ArrayList<FontTriplet>(); | ||||
FontTriplet triplet = null; | FontTriplet triplet = null; | ||||
for (int i = 0; i < families.length; i++) { | |||||
triplet = fontLookup(families[i], style, weight, substitutable); | |||||
for (String family : families) { | |||||
triplet = fontLookup(family, style, weight, substitutable); | |||||
if (triplet != null) { | if (triplet != null) { | ||||
matchingTriplets.add(triplet); | matchingTriplets.add(triplet); | ||||
} | } |
public void setup(FontInfo fontInfo, FontCollection[] fontCollections) { | public void setup(FontInfo fontInfo, FontCollection[] fontCollections) { | ||||
int startNum = 1; | int startNum = 1; | ||||
for (int i = 0, c = fontCollections.length; i < c; i++) { | |||||
startNum = fontCollections[i].setup(startNum, fontInfo); | |||||
for (FontCollection fontCollection : fontCollections) { | |||||
startNum = fontCollection.setup(startNum, fontInfo); | |||||
} | } | ||||
// Make any defined substitutions in the font info | // Make any defined substitutions in the font info | ||||
getFontSubstitutions().adjustFontInfo(fontInfo); | getFontSubstitutions().adjustFontInfo(fontInfo); |
Configuration cfg, boolean strict) throws FOPException { | Configuration cfg, boolean strict) throws FOPException { | ||||
List<FontTriplet.Matcher> matcherList = new java.util.ArrayList<FontTriplet.Matcher>(); | List<FontTriplet.Matcher> matcherList = new java.util.ArrayList<FontTriplet.Matcher>(); | ||||
Configuration[] matches = cfg.getChildren("match"); | Configuration[] matches = cfg.getChildren("match"); | ||||
for (int i = 0; i < matches.length; i++) { | |||||
for (Configuration matche : matches) { | |||||
try { | try { | ||||
matcherList.add(new FontFamilyRegExFontTripletMatcher( | matcherList.add(new FontFamilyRegExFontTripletMatcher( | ||||
matches[i].getAttribute("font-family"))); | |||||
matche.getAttribute("font-family"))); | |||||
} catch (ConfigurationException ce) { | } catch (ConfigurationException ce) { | ||||
LogUtil.handleException(log, ce, strict); | LogUtil.handleException(log, ce, strict); | ||||
continue; | continue; | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public boolean matches(FontTriplet triplet) { | public boolean matches(FontTriplet triplet) { | ||||
for (int i = 0, c = matchers.length; i < c; i++) { | |||||
if (matchers[i].matches(triplet)) { | |||||
for (FontTriplet.Matcher matcher : matchers) { | |||||
if (matcher.matches(triplet)) { | |||||
return true; | return true; | ||||
} | } | ||||
} | } |
CommonFont commonFont, PercentBaseContext context) { | CommonFont commonFont, PercentBaseContext context) { | ||||
FontInfo fi = fonode.getFOEventHandler().getFontInfo(); | FontInfo fi = fonode.getFOEventHandler().getFontInfo(); | ||||
FontTriplet[] fontkeys = commonFont.getFontState(fi); | FontTriplet[] fontkeys = commonFont.getFontState(fi); | ||||
for (int i = 0; i < fontkeys.length; i++) { | |||||
Font font = fi.getFontInstance(fontkeys[i], commonFont.fontSize | |||||
for (FontTriplet fontkey : fontkeys) { | |||||
Font font = fi.getFontInstance(fontkey, commonFont.fontSize | |||||
.getValue(context)); | .getValue(context)); | ||||
if (font.hasChar(c)) { | if (font.hasChar(c)) { | ||||
return font; | return font; |
fontInfo.addMetrics(internalName, font); | fontInfo.addMetrics(internalName, font); | ||||
List<FontTriplet> triplets = embedFontInfo.getFontTriplets(); | List<FontTriplet> triplets = embedFontInfo.getFontTriplets(); | ||||
for (int tripletIndex = 0; tripletIndex < triplets.size(); tripletIndex++) { | |||||
FontTriplet triplet = triplets.get(tripletIndex); | |||||
for (FontTriplet triplet : triplets) { | |||||
fontInfo.addFontProperties(internalName, triplet); | fontInfo.addFontProperties(internalName, triplet); | ||||
} | } | ||||
} | } |
*/ | */ | ||||
public static String guessStyle(String fontName) { | public static String guessStyle(String fontName) { | ||||
if (fontName != null) { | if (fontName != null) { | ||||
for (int i = 0; i < ITALIC_WORDS.length; i++) { | |||||
if (fontName.indexOf(ITALIC_WORDS[i]) != -1) { | |||||
for (String word : ITALIC_WORDS) { | |||||
if (fontName.indexOf(word) != -1) { | |||||
return Font.STYLE_ITALIC; | return Font.STYLE_ITALIC; | ||||
} | } | ||||
} | } | ||||
// weight | // weight | ||||
int weight = Font.WEIGHT_NORMAL; | int weight = Font.WEIGHT_NORMAL; | ||||
for (int i = 0; i < BOLD_WORDS.length; i++) { | |||||
if (fontName.indexOf(BOLD_WORDS[i]) != -1) { | |||||
for (String word : BOLD_WORDS) { | |||||
if (fontName.indexOf(word) != -1) { | |||||
weight = Font.WEIGHT_BOLD; | weight = Font.WEIGHT_BOLD; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
for (int i = 0; i < MEDIUM_WORDS.length; i++) { | |||||
if (fontName.indexOf(MEDIUM_WORDS[i]) != -1) { | |||||
for (String word : MEDIUM_WORDS) { | |||||
if (fontName.indexOf(word) != -1) { | |||||
weight = Font.WEIGHT_NORMAL + 100; //500 | weight = Font.WEIGHT_NORMAL + 100; //500 | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
//Search for "semi/demi" before "light", but after "bold" | //Search for "semi/demi" before "light", but after "bold" | ||||
//(normally semi/demi-bold is meant, but it can also be semi/demi-light) | //(normally semi/demi-bold is meant, but it can also be semi/demi-light) | ||||
for (int i = 0; i < DEMI_WORDS.length; i++) { | |||||
if (fontName.indexOf(DEMI_WORDS[i]) != -1) { | |||||
for (String word : DEMI_WORDS) { | |||||
if (fontName.indexOf(word) != -1) { | |||||
weight = Font.WEIGHT_BOLD - 100; //600 | weight = Font.WEIGHT_BOLD - 100; //600 | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
for (int i = 0; i < EXTRA_BOLD_WORDS.length; i++) { | |||||
if (fontName.indexOf(EXTRA_BOLD_WORDS[i]) != -1) { | |||||
for (String word : EXTRA_BOLD_WORDS) { | |||||
if (fontName.indexOf(word) != -1) { | |||||
weight = Font.WEIGHT_EXTRA_BOLD; | weight = Font.WEIGHT_EXTRA_BOLD; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
for (int i = 0; i < LIGHT_WORDS.length; i++) { | |||||
if (fontName.indexOf(LIGHT_WORDS[i]) != -1) { | |||||
for (String word : LIGHT_WORDS) { | |||||
if (fontName.indexOf(word) != -1) { | |||||
weight = Font.WEIGHT_LIGHT; | weight = Font.WEIGHT_LIGHT; | ||||
break; | break; | ||||
} | } |
private int[][] scaleAdjustments(int[][] adjustments, int fontSize) { | private int[][] scaleAdjustments(int[][] adjustments, int fontSize) { | ||||
if (adjustments != null) { | if (adjustments != null) { | ||||
for (int i = 0, n = adjustments.length; i < n; i++) { | |||||
int[] gpa = adjustments [ i ]; | |||||
for (int[] gpa : adjustments) { | |||||
for (int k = 0; k < 4; k++) { | for (int k = 0; k < 4; k++) { | ||||
gpa [ k ] = (gpa [ k ] * fontSize) / 1000; | |||||
gpa[k] = (gpa[k] * fontSize) / 1000; | |||||
} | } | ||||
} | } | ||||
return adjustments; | return adjustments; | ||||
for (int i = 0, n = cs.length(); i < n; i++) { | for (int i = 0, n = cs.length(); i < n; i++) { | ||||
int cc = cs.charAt(i); | int cc = cs.charAt(i); | ||||
int[] da = CharNormalize.decompose(cc, daBuffer); | int[] da = CharNormalize.decompose(cc, daBuffer); | ||||
for (int j = 0; j < da.length; j++) { | |||||
if (da[j] > 0) { | |||||
sb.append((char) da[j]); | |||||
for (int aDa : da) { | |||||
if (aDa > 0) { | |||||
sb.append((char) aDa); | |||||
} else { | } else { | ||||
break; | break; | ||||
} | } | ||||
private static boolean hasElidableControl(GlyphSequence gs) { | private static boolean hasElidableControl(GlyphSequence gs) { | ||||
int[] ca = gs.getCharacterArray(false); | int[] ca = gs.getCharacterArray(false); | ||||
for (int i = 0, n = ca.length; i < n; ++i) { | |||||
int ch = ca [ i ]; | |||||
for (int ch : ca) { | |||||
if (isElidableControl(ch)) { | if (isElidableControl(ch)) { | ||||
return true; | return true; | ||||
} | } |
String charName = Glyphs.charToGlyphName(c); | String charName = Glyphs.charToGlyphName(c); | ||||
String[] charNameAlternatives = Glyphs.getCharNameAlternativesFor(charName); | String[] charNameAlternatives = Glyphs.getCharNameAlternativesFor(charName); | ||||
if (charNameAlternatives != null && charNameAlternatives.length > 0) { | if (charNameAlternatives != null && charNameAlternatives.length > 0) { | ||||
for (int i = 0; i < charNameAlternatives.length; i++) { | |||||
for (String charNameAlternative : charNameAlternatives) { | |||||
if (log.isDebugEnabled()) { | if (log.isDebugEnabled()) { | ||||
log.debug("Checking alternative for char " + c + " (charname=" | log.debug("Checking alternative for char " + c + " (charname=" | ||||
+ charName + "): " + charNameAlternatives[i]); | |||||
+ charName + "): " + charNameAlternative); | |||||
} | } | ||||
String s = Glyphs.getUnicodeSequenceForGlyphName(charNameAlternatives[i]); | |||||
String s = Glyphs.getUnicodeSequenceForGlyphName(charNameAlternative); | |||||
if (s != null) { | if (s != null) { | ||||
d = lookupChar(s.charAt(0)); | d = lookupChar(s.charAt(0)); | ||||
if (d != SingleByteEncoding.NOT_FOUND_CODE_POINT) { | if (d != SingleByteEncoding.NOT_FOUND_CODE_POINT) { |
} else if ("cid-widths".equals(localName)) { | } else if ("cid-widths".equals(localName)) { | ||||
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++) { | |||||
wds[j++] = cidWidths.get(count); | |||||
for (Integer cidWidth : cidWidths) { | |||||
wds[j++] = cidWidth; | |||||
} | } | ||||
//multiFont.addCIDWidthEntry(cidWidthIndex, wds); | //multiFont.addCIDWidthEntry(cidWidthIndex, wds); |
List<File> fontDirList = new java.util.ArrayList<File>(); | List<File> fontDirList = new java.util.ArrayList<File>(); | ||||
String[] searchableDirectories = getSearchableDirectories(); | String[] searchableDirectories = getSearchableDirectories(); | ||||
if (searchableDirectories != null) { | if (searchableDirectories != null) { | ||||
for (int i = 0; i < searchableDirectories.length; i++) { | |||||
File fontDir = new File(searchableDirectories[i]); | |||||
for (String searchableDirectory : searchableDirectories) { | |||||
File fontDir = new File(searchableDirectory); | |||||
if (fontDir.exists() && fontDir.canRead()) { | if (fontDir.exists() && fontDir.canRead()) { | ||||
fontDirList.add(fontDir); | fontDirList.add(fontDir); | ||||
} | } |
package org.apache.fop.fonts.substitute; | package org.apache.fop.fonts.substitute; | ||||
import java.util.Iterator; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | import java.util.Map; | ||||
import java.util.Set; | import java.util.Set; | ||||
public void setFontWeight(String fontWeight) { | public void setFontWeight(String fontWeight) { | ||||
AttributeValue fontWeightAttribute = AttributeValue.valueOf(fontWeight); | AttributeValue fontWeightAttribute = AttributeValue.valueOf(fontWeight); | ||||
if (fontWeightAttribute != null) { | if (fontWeightAttribute != null) { | ||||
for (Iterator it = fontWeightAttribute.iterator(); it.hasNext();) { | |||||
Object weightObj = it.next(); | |||||
for (Object weightObj : fontWeightAttribute) { | |||||
if (weightObj instanceof String) { | if (weightObj instanceof String) { | ||||
String weightString = ((String)weightObj).trim(); | |||||
String weightString = ((String) weightObj).trim(); | |||||
try { | try { | ||||
FontUtil.parseCSS2FontWeight(weightString); | FontUtil.parseCSS2FontWeight(weightString); | ||||
} catch (IllegalArgumentException ex) { | } catch (IllegalArgumentException ex) { | ||||
List/*<FontTriplet>*/ matchingTriplets = new java.util.ArrayList/*<FontTriplet>*/(); | List/*<FontTriplet>*/ matchingTriplets = new java.util.ArrayList/*<FontTriplet>*/(); | ||||
// try to find matching destination font triplet | // try to find matching destination font triplet | ||||
for (Iterator attrIt = fontFamilyValue.iterator(); attrIt.hasNext();) { | |||||
String fontFamilyString = (String)attrIt.next(); | |||||
Map/*<FontTriplet>*/ triplets = (Map/*<FontTriplet>*/)fontInfo.getFontTriplets(); | |||||
for (Object aFontFamilyValue : fontFamilyValue) { | |||||
String fontFamilyString = (String) aFontFamilyValue; | |||||
Map/*<FontTriplet>*/ triplets = (Map/*<FontTriplet>*/) fontInfo.getFontTriplets(); | |||||
if (triplets != null) { | if (triplets != null) { | ||||
Set/*<FontTriplet>*/ tripletSet = triplets.keySet(); | Set/*<FontTriplet>*/ tripletSet = triplets.keySet(); | ||||
for (Iterator/*<FontTriplet>*/ tripletIt = tripletSet.iterator(); | |||||
tripletIt.hasNext();) { | |||||
FontTriplet triplet = (FontTriplet)tripletIt.next(); | |||||
for (Object aTripletSet : tripletSet) { | |||||
FontTriplet triplet = (FontTriplet) aTripletSet; | |||||
String fontName = triplet.getName(); | String fontName = triplet.getName(); | ||||
// matched font family name | // matched font family name | ||||
// try and match font weight | // try and match font weight | ||||
boolean weightMatched = false; | boolean weightMatched = false; | ||||
int fontWeight = triplet.getWeight(); | int fontWeight = triplet.getWeight(); | ||||
for (Iterator weightIt = weightValue.iterator(); weightIt.hasNext();) { | |||||
Object weightObj = weightIt.next(); | |||||
for (Object weightObj : weightValue) { | |||||
if (weightObj instanceof FontWeightRange) { | if (weightObj instanceof FontWeightRange) { | ||||
FontWeightRange intRange = (FontWeightRange)weightObj; | |||||
FontWeightRange intRange = (FontWeightRange) weightObj; | |||||
if (intRange.isWithinRange(fontWeight)) { | if (intRange.isWithinRange(fontWeight)) { | ||||
weightMatched = true; | weightMatched = true; | ||||
} | } | ||||
} else if (weightObj instanceof String) { | } else if (weightObj instanceof String) { | ||||
String fontWeightString = (String)weightObj; | |||||
String fontWeightString = (String) weightObj; | |||||
int fontWeightValue = FontUtil.parseCSS2FontWeight( | int fontWeightValue = FontUtil.parseCSS2FontWeight( | ||||
fontWeightString); | fontWeightString); | ||||
if (fontWeightValue == fontWeight) { | if (fontWeightValue == fontWeight) { | ||||
weightMatched = true; | weightMatched = true; | ||||
} | } | ||||
} else if (weightObj instanceof Integer) { | } else if (weightObj instanceof Integer) { | ||||
Integer fontWeightInteger = (Integer)weightObj; | |||||
Integer fontWeightInteger = (Integer) weightObj; | |||||
int fontWeightValue = fontWeightInteger; | int fontWeightValue = fontWeightInteger; | ||||
if (fontWeightValue == fontWeight) { | if (fontWeightValue == fontWeight) { | ||||
weightMatched = true; | weightMatched = true; | ||||
// try and match font style | // try and match font style | ||||
boolean styleMatched = false; | boolean styleMatched = false; | ||||
String fontStyleString = triplet.getStyle(); | String fontStyleString = triplet.getStyle(); | ||||
for (Iterator styleIt = styleValue.iterator(); styleIt.hasNext();) { | |||||
String style = (String)styleIt.next(); | |||||
for (Object aStyleValue : styleValue) { | |||||
String style = (String) aStyleValue; | |||||
if (fontStyleString.equals(style)) { | if (fontStyleString.equals(style)) { | ||||
styleMatched = true; | styleMatched = true; | ||||
} | } | ||||
if (matchingTriplets.size() == 1) { | if (matchingTriplets.size() == 1) { | ||||
bestTriplet = (FontTriplet)matchingTriplets.get(0); | bestTriplet = (FontTriplet)matchingTriplets.get(0); | ||||
} else { | } else { | ||||
for (Iterator iterator = matchingTriplets.iterator(); iterator.hasNext();) { | |||||
FontTriplet triplet = (FontTriplet)iterator.next(); | |||||
for (Object matchingTriplet : matchingTriplets) { | |||||
FontTriplet triplet = (FontTriplet) matchingTriplet; | |||||
if (bestTriplet == null) { | if (bestTriplet == null) { | ||||
bestTriplet = triplet; | bestTriplet = triplet; | ||||
} else { | } else { | ||||
List/*<FontTriplet>*/ triplets = new java.util.ArrayList/*<FontTriplet>*/(); | List/*<FontTriplet>*/ triplets = new java.util.ArrayList/*<FontTriplet>*/(); | ||||
AttributeValue fontFamilyValue = getFontFamily(); | AttributeValue fontFamilyValue = getFontFamily(); | ||||
for (Iterator fontFamilyIt = fontFamilyValue.iterator(); fontFamilyIt.hasNext();) { | |||||
String name = (String)fontFamilyIt.next(); | |||||
for (Object aFontFamilyValue : fontFamilyValue) { | |||||
String name = (String) aFontFamilyValue; | |||||
AttributeValue styleValue = getFontStyle(); | AttributeValue styleValue = getFontStyle(); | ||||
for (Iterator styleIt = styleValue.iterator(); styleIt.hasNext();) { | |||||
String style = (String)styleIt.next(); | |||||
for (Object aStyleValue : styleValue) { | |||||
String style = (String) aStyleValue; | |||||
AttributeValue weightValue = getFontWeight(); | AttributeValue weightValue = getFontWeight(); | ||||
for (Iterator weightIt = weightValue.iterator(); weightIt.hasNext();) { | |||||
Object weightObj = weightIt.next(); | |||||
for (Object weightObj : weightValue) { | |||||
if (weightObj instanceof FontWeightRange) { | if (weightObj instanceof FontWeightRange) { | ||||
FontWeightRange fontWeightRange = (FontWeightRange)weightObj; | |||||
FontWeightRange fontWeightRange = (FontWeightRange) weightObj; | |||||
int[] weightRange = fontWeightRange.toArray(); | int[] weightRange = fontWeightRange.toArray(); | ||||
for (int i = 0; i < weightRange.length; i++) { | |||||
triplets.add(new FontTriplet(name, style, weightRange[i])); | |||||
for (int aWeightRange : weightRange) { | |||||
triplets.add(new FontTriplet(name, style, aWeightRange)); | |||||
} | } | ||||
} else if (weightObj instanceof String) { | } else if (weightObj instanceof String) { | ||||
String weightString = (String)weightObj; | |||||
String weightString = (String) weightObj; | |||||
int weight = FontUtil.parseCSS2FontWeight(weightString); | int weight = FontUtil.parseCSS2FontWeight(weightString); | ||||
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; | int weight = weightInteger; | ||||
triplets.add(new FontTriplet(name, style, weight)); | triplets.add(new FontTriplet(name, style, weight)); | ||||
} | } |
FontQualifier fromQualifier = substitution.getFromQualifier(); | FontQualifier fromQualifier = substitution.getFromQualifier(); | ||||
List/*<FontTriplet>*/ tripletList = fromQualifier.getTriplets(); | List/*<FontTriplet>*/ tripletList = fromQualifier.getTriplets(); | ||||
for (Iterator tripletit = tripletList.iterator(); tripletit.hasNext();) { | |||||
FontTriplet triplet = (FontTriplet) tripletit.next(); | |||||
for (Object aTripletList : tripletList) { | |||||
FontTriplet triplet = (FontTriplet) aTripletList; | |||||
fontInfo.addFontProperties(internalFontKey, triplet); | fontInfo.addFontProperties(internalFontKey, triplet); | ||||
} | } | ||||
} | } |
*/ | */ | ||||
public void configure(FontSubstitutions substitutions) throws FOPException { | public void configure(FontSubstitutions substitutions) throws FOPException { | ||||
Configuration[] substitutionCfgs = cfg.getChildren("substitution"); | Configuration[] substitutionCfgs = cfg.getChildren("substitution"); | ||||
for (int i = 0; i < substitutionCfgs.length; i++) { | |||||
Configuration fromCfg = substitutionCfgs[i].getChild("from", false); | |||||
for (Configuration substitutionCfg : substitutionCfgs) { | |||||
Configuration fromCfg = substitutionCfg.getChild("from", false); | |||||
if (fromCfg == null) { | if (fromCfg == null) { | ||||
throw new FOPException("'substitution' element without child 'from' element"); | throw new FOPException("'substitution' element without child 'from' element"); | ||||
} | } | ||||
Configuration toCfg = substitutionCfgs[i].getChild("to", false); | |||||
Configuration toCfg = substitutionCfg.getChild("to", false); | |||||
if (fromCfg == null) { | if (fromCfg == null) { | ||||
throw new FOPException("'substitution' element without child 'to' element"); | throw new FOPException("'substitution' element without child 'to' element"); | ||||
} | } |
int localXHeight = 0; | int localXHeight = 0; | ||||
int localAscender = 0; | int localAscender = 0; | ||||
int localDescender = 0; | int localDescender = 0; | ||||
for (int i = 0; i < mtxTab.length; i++) { | |||||
if ("H".equals(mtxTab[i].getName())) { | |||||
localCapHeight = mtxTab[i].getBoundingBox()[3]; | |||||
} else if ("x".equals(mtxTab[i].getName())) { | |||||
localXHeight = mtxTab[i].getBoundingBox()[3]; | |||||
} else if ("d".equals(mtxTab[i].getName())) { | |||||
localAscender = mtxTab[i].getBoundingBox()[3]; | |||||
} else if ("p".equals(mtxTab[i].getName())) { | |||||
localDescender = mtxTab[i].getBoundingBox()[1]; | |||||
for (OFMtxEntry aMtxTab : mtxTab) { | |||||
if ("H".equals(aMtxTab.getName())) { | |||||
localCapHeight = aMtxTab.getBoundingBox()[3]; | |||||
} else if ("x".equals(aMtxTab.getName())) { | |||||
localXHeight = aMtxTab.getBoundingBox()[3]; | |||||
} else if ("d".equals(aMtxTab.getName())) { | |||||
localAscender = aMtxTab.getBoundingBox()[3]; | |||||
} else if ("p".equals(aMtxTab.getName())) { | |||||
localDescender = aMtxTab.getBoundingBox()[1]; | |||||
} else { | } else { | ||||
// OpenType Fonts with a version 3.0 "post" table don't have glyph names. | // OpenType Fonts with a version 3.0 "post" table don't have glyph names. | ||||
// Use Unicode indices instead. | // Use Unicode indices instead. | ||||
List unicodeIndex = mtxTab[i].getUnicodeIndex(); | |||||
List unicodeIndex = aMtxTab.getUnicodeIndex(); | |||||
if (unicodeIndex.size() > 0) { | if (unicodeIndex.size() > 0) { | ||||
//Only the first index is used | //Only the first index is used | ||||
char ch = (char)((Integer)unicodeIndex.get(0)).intValue(); | |||||
char ch = (char) ((Integer) unicodeIndex.get(0)).intValue(); | |||||
if (ch == 'H') { | if (ch == 'H') { | ||||
localCapHeight = mtxTab[i].getBoundingBox()[3]; | |||||
localCapHeight = aMtxTab.getBoundingBox()[3]; | |||||
} else if (ch == 'x') { | } else if (ch == 'x') { | ||||
localXHeight = mtxTab[i].getBoundingBox()[3]; | |||||
localXHeight = aMtxTab.getBoundingBox()[3]; | |||||
} else if (ch == 'd') { | } else if (ch == 'd') { | ||||
localAscender = mtxTab[i].getBoundingBox()[3]; | |||||
localAscender = aMtxTab.getBoundingBox()[3]; | |||||
} else if (ch == 'p') { | } else if (ch == 'p') { | ||||
localDescender = mtxTab[i].getBoundingBox()[1]; | |||||
localDescender = aMtxTab.getBoundingBox()[1]; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
while (uniMap.hasNext()) { | while (uniMap.hasNext()) { | ||||
Integer unicodeKey = (Integer)uniMap.next(); | Integer unicodeKey = (Integer)uniMap.next(); | ||||
Integer[] ansiKeys = unicodeToWinAnsi(unicodeKey); | Integer[] ansiKeys = unicodeToWinAnsi(unicodeKey); | ||||
for (int u = 0; u < ansiKeys.length; u++) { | |||||
akpx.put(ansiKeys[u], kern); | |||||
for (Integer ansiKey : ansiKeys) { | |||||
akpx.put(ansiKey, kern); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
while (uniMap.hasNext()) { | while (uniMap.hasNext()) { | ||||
Integer unicodeKey = (Integer)uniMap.next(); | Integer unicodeKey = (Integer)uniMap.next(); | ||||
Integer[] ansiKeys = unicodeToWinAnsi(unicodeKey); | Integer[] ansiKeys = unicodeToWinAnsi(unicodeKey); | ||||
for (int u = 0; u < ansiKeys.length; u++) { | |||||
ansiKerningTab.put(ansiKeys[u], akpx); | |||||
for (Integer ansiKey : ansiKeys) { | |||||
ansiKerningTab.put(ansiKey, akpx); | |||||
} | } | ||||
} | } | ||||
} | } |
if (hstrcmp(word, i, kv.getArray(), lo[p]) == 0) { | if (hstrcmp(word, i, kv.getArray(), lo[p]) == 0) { | ||||
values = getValues(eq[p]); // data pointer is in eq[] | values = getValues(eq[p]); // data pointer is in eq[] | ||||
int j = index; | int j = index; | ||||
for (int k = 0; k < values.length; k++) { | |||||
if (j < il.length && values[k] > il[j]) { | |||||
il[j] = values[k]; | |||||
for (byte value : values) { | |||||
if (j < il.length && value > il[j]) { | |||||
il[j] = value; | |||||
} | } | ||||
j++; | j++; | ||||
} | } | ||||
if (sc[q] == 0) { | if (sc[q] == 0) { | ||||
values = getValues(eq[q]); | values = getValues(eq[q]); | ||||
int j = index; | int j = index; | ||||
for (int k = 0; k < values.length; k++) { | |||||
if (j < il.length && values[k] > il[j]) { | |||||
il[j] = values[k]; | |||||
for (byte value : values) { | |||||
if (j < il.length && value > il[j]) { | |||||
il[j] = value; | |||||
} | } | ||||
j++; | j++; | ||||
} | } |
private ArrayList normalizeException(ArrayList ex) { | private ArrayList normalizeException(ArrayList ex) { | ||||
ArrayList res = new ArrayList(); | ArrayList res = new ArrayList(); | ||||
for (int i = 0; i < ex.size(); i++) { | |||||
Object item = ex.get(i); | |||||
for (Object item : ex) { | |||||
if (item instanceof String) { | if (item instanceof String) { | ||||
String str = (String)item; | |||||
String str = (String) item; | |||||
StringBuffer buf = new StringBuffer(); | StringBuffer buf = new StringBuffer(); | ||||
for (int j = 0; j < str.length(); j++) { | for (int j = 0; j < str.length(); j++) { | ||||
char c = str.charAt(j); | char c = str.charAt(j); | ||||
private String getExceptionWord(ArrayList ex) { | private String getExceptionWord(ArrayList ex) { | ||||
StringBuffer res = new StringBuffer(); | StringBuffer res = new StringBuffer(); | ||||
for (int i = 0; i < ex.size(); i++) { | |||||
Object item = ex.get(i); | |||||
for (Object item : ex) { | |||||
if (item instanceof String) { | if (item instanceof String) { | ||||
res.append((String)item); | |||||
res.append((String) item); | |||||
} else { | } else { | ||||
if (((Hyphen)item).noBreak != null) { | |||||
res.append(((Hyphen)item).noBreak); | |||||
if (((Hyphen) item).noBreak != null) { | |||||
res.append(((Hyphen) item).noBreak); | |||||
} | } | ||||
} | } | ||||
} | } |
private MinOptMax sum(MinOptMax[] lengths) { | private MinOptMax sum(MinOptMax[] lengths) { | ||||
MinOptMax sum = MinOptMax.ZERO; | MinOptMax sum = MinOptMax.ZERO; | ||||
for (int i = 0; i < lengths.length; i++) { | |||||
if (lengths[i] != null) { | |||||
sum = sum.plus(lengths[i]); | |||||
for (MinOptMax length : lengths) { | |||||
if (length != null) { | |||||
sum = sum.plus(length); | |||||
} | } | ||||
} | } | ||||
return sum; | return sum; |
package org.apache.fop.layoutmgr.inline; | package org.apache.fop.layoutmgr.inline; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Iterator; | |||||
import java.util.LinkedList; | import java.util.LinkedList; | ||||
import java.util.List; | import java.util.List; | ||||
import java.util.ListIterator; | import java.util.ListIterator; | ||||
Object obj = returnedList.remove(0); | Object obj = returnedList.remove(0); | ||||
if (obj instanceof KnuthSequence) { | if (obj instanceof KnuthSequence) { | ||||
KnuthSequence ks = (KnuthSequence)obj; | KnuthSequence ks = (KnuthSequence)obj; | ||||
for (Iterator it = ks.iterator(); it.hasNext();) { | |||||
contentElement = (KnuthElement)it.next(); | |||||
for (Object k : ks) { | |||||
contentElement = (KnuthElement) k; | |||||
stackSize += contentElement.getWidth(); | stackSize += contentElement.getWidth(); | ||||
contentList.add(contentElement); | contentList.add(contentElement); | ||||
} | } |
* @return true if the sequence contains a box | * @return true if the sequence contains a box | ||||
*/ | */ | ||||
public boolean containsBox() { | public boolean containsBox() { | ||||
for (int i = 0; i < this.size(); i++) { | |||||
KnuthElement el = (KnuthElement)this.get(i); | |||||
for (Object o : this) { | |||||
KnuthElement el = (KnuthElement) o; | |||||
if (el.isBox()) { | if (el.isBox()) { | ||||
return true; | return true; | ||||
} | } |
* and work out the total number of factors to use to distribute | * and work out the total number of factors to use to distribute | ||||
* the remaining space (if any) | * the remaining space (if any) | ||||
*/ | */ | ||||
for (Iterator i = colWidths.iterator(); i.hasNext();) { | |||||
Length colWidth = (Length) i.next(); | |||||
for (Object colWidth1 : colWidths) { | |||||
Length colWidth = (Length) colWidth1; | |||||
if (colWidth != null) { | if (colWidth != null) { | ||||
sumCols += colWidth.getValue(percentBaseContext); | sumCols += colWidth.getValue(percentBaseContext); | ||||
if (colWidth instanceof RelativeNumericProperty) { | if (colWidth instanceof RelativeNumericProperty) { |
int bodyType, LinkedList returnList) { | int bodyType, LinkedList returnList) { | ||||
log.debug("Handling row group with " + rowGroup.length + " rows..."); | log.debug("Handling row group with " + rowGroup.length + " rows..."); | ||||
EffRow row; | EffRow row; | ||||
for (int rgi = 0; rgi < rowGroup.length; rgi++) { | |||||
row = rowGroup[rgi]; | |||||
for (Iterator iter = row.getGridUnits().iterator(); iter.hasNext();) { | |||||
GridUnit gu = (GridUnit) iter.next(); | |||||
for (EffRow aRowGroup : rowGroup) { | |||||
row = aRowGroup; | |||||
for (Object o : row.getGridUnits()) { | |||||
GridUnit gu = (GridUnit) o; | |||||
if (gu.isPrimary()) { | if (gu.isPrimary()) { | ||||
PrimaryGridUnit primary = gu.getPrimary(); | PrimaryGridUnit primary = gu.getPrimary(); | ||||
// TODO a new LM must be created for every new static-content | // TODO a new LM must be created for every new static-content | ||||
//Get the element list for the cell contents | //Get the element list for the cell contents | ||||
List elems = primary.getCellLM().getNextKnuthElements( | List elems = primary.getCellLM().getNextKnuthElements( | ||||
childLC, alignment); | |||||
childLC, alignment); | |||||
ElementListObserver.observe(elems, "table-cell", primary.getCell().getId()); | ElementListObserver.observe(elems, "table-cell", primary.getCell().getId()); | ||||
primary.setElements(elems); | primary.setElements(elems); | ||||
} | } | ||||
rowHeights[rgi] = rowBPD.toMinOptMax(tableLM); | rowHeights[rgi] = rowBPD.toMinOptMax(tableLM); | ||||
explicitRowHeight = rowBPD.toMinOptMax(tableLM); | explicitRowHeight = rowBPD.toMinOptMax(tableLM); | ||||
} | } | ||||
for (Iterator iter = row.getGridUnits().iterator(); iter.hasNext();) { | |||||
GridUnit gu = (GridUnit) iter.next(); | |||||
for (Object o : row.getGridUnits()) { | |||||
GridUnit gu = (GridUnit) o; | |||||
if (!gu.isEmpty() && gu.getColSpanIndex() == 0 && gu.isLastGridUnitRowSpan()) { | if (!gu.isEmpty() && gu.getColSpanIndex() == 0 && gu.isLastGridUnitRowSpan()) { | ||||
PrimaryGridUnit primary = gu.getPrimary(); | PrimaryGridUnit primary = gu.getPrimary(); | ||||
int effectiveCellBPD = 0; | int effectiveCellBPD = 0; |
if (tablePartBackground != null) { | if (tablePartBackground != null) { | ||||
TableLayoutManager tableLM = tclm.getTableLM(); | TableLayoutManager tableLM = tclm.getTableLM(); | ||||
for (Iterator iter = tablePartBackgroundAreas.iterator(); iter.hasNext();) { | |||||
Block backgroundArea = (Block) iter.next(); | |||||
for (Object tablePartBackgroundArea : tablePartBackgroundAreas) { | |||||
Block backgroundArea = (Block) tablePartBackgroundArea; | |||||
TraitSetter.addBackground(backgroundArea, tablePartBackground, tableLM, | TraitSetter.addBackground(backgroundArea, tablePartBackground, tableLM, | ||||
-backgroundArea.getXOffset(), tablePartOffset - backgroundArea.getYOffset(), | -backgroundArea.getXOffset(), tablePartOffset - backgroundArea.getYOffset(), | ||||
tableLM.getContentAreaIPD(), currentRowOffset - tablePartOffset); | tableLM.getContentAreaIPD(), currentRowOffset - tablePartOffset); |
return; | return; | ||||
} | } | ||||
int n = childrenLMs.size(); | int n = childrenLMs.size(); | ||||
for (int j = 0; j < n; j++) { | |||||
LayoutManager lm = childrenLMs.get(j); | |||||
for (LayoutManager lm : childrenLMs) { | |||||
if (lm == null) { | if (lm == null) { | ||||
return; | return; | ||||
} else if (lm instanceof RetrieveTableMarkerLayoutManager) { | } else if (lm instanceof RetrieveTableMarkerLayoutManager) { |
getTableLM().registerMarkers(body.getMarkers(), true, isFirstPos, isLastPos); | getTableLM().registerMarkers(body.getMarkers(), true, isFirstPos, isLastPos); | ||||
} | } | ||||
painter.startTablePart(body); | painter.startTablePart(body); | ||||
for (Iterator iter = positions.iterator(); iter.hasNext();) { | |||||
painter.handleTableContentPosition((TableContentPosition) iter.next()); | |||||
for (Object position : positions) { | |||||
painter.handleTableContentPosition((TableContentPosition) position); | |||||
} | } | ||||
getTableLM().getCurrentPV().registerMarkers(body.getMarkers(), | getTableLM().getCurrentPV().registerMarkers(body.getMarkers(), | ||||
false, isFirstPos, isLastPos); | false, isFirstPos, isLastPos); |
curBlockArea.setBPD(tableHeight); | curBlockArea.setBPD(tableHeight); | ||||
if (columnBackgroundAreas != null) { | if (columnBackgroundAreas != null) { | ||||
for (Iterator iter = columnBackgroundAreas.iterator(); iter.hasNext();) { | |||||
ColumnBackgroundInfo b = (ColumnBackgroundInfo) iter.next(); | |||||
for (Object columnBackgroundArea : columnBackgroundAreas) { | |||||
ColumnBackgroundInfo b = (ColumnBackgroundInfo) columnBackgroundArea; | |||||
TraitSetter.addBackground(b.backgroundArea, | TraitSetter.addBackground(b.backgroundArea, | ||||
b.column.getCommonBorderPaddingBackground(), this, | b.column.getCommonBorderPaddingBackground(), this, | ||||
b.xShift, -b.backgroundArea.getYOffset(), | b.xShift, -b.backgroundArea.getYOffset(), | ||||
// if we get to this stage then we are at the footer of the table fragment; this means that no more | // if we get to this stage then we are at the footer of the table fragment; this means that no more | ||||
// different TCLM need to be saved (we already have all); we flag the list as being complete then | // different TCLM need to be saved (we already have all); we flag the list as being complete then | ||||
areAllTCLMsSaved = true; | areAllTCLMsSaved = true; | ||||
for (int i = 0; i < savedTCLMs.size(); i++) { | |||||
TableCellLayoutManager tclm = savedTCLMs.get(i); | |||||
for (TableCellLayoutManager tclm : savedTCLMs) { | |||||
if (this.repeatedHeader) { | if (this.repeatedHeader) { | ||||
tclm.setHasRepeatedHeader(true); | tclm.setHasRepeatedHeader(true); | ||||
} | } |
List rowGroup = (List) rowGroupsIter.next(); | List rowGroup = (List) rowGroupsIter.next(); | ||||
EffRow[] effRowGroup = new EffRow[rowGroup.size()]; | EffRow[] effRowGroup = new EffRow[rowGroup.size()]; | ||||
int i = 0; | int i = 0; | ||||
for (Iterator rowIter = rowGroup.iterator(); rowIter.hasNext();) { | |||||
List gridUnits = (List) rowIter.next(); | |||||
for (Object aRowGroup : rowGroup) { | |||||
List gridUnits = (List) aRowGroup; | |||||
effRowGroup[i++] = new EffRow(rowIndex++, tablePart, gridUnits); | effRowGroup[i++] = new EffRow(rowIndex++, tablePart, gridUnits); | ||||
} | } | ||||
return effRowGroup; | return effRowGroup; |
private void calcTotalHeight() { | private void calcTotalHeight() { | ||||
totalHeight = 0; | totalHeight = 0; | ||||
for (int i = 0; i < rowGroup.length; i++) { | |||||
totalHeight += rowGroup[i].getHeight().getOpt(); | |||||
for (EffRow aRowGroup : rowGroup) { | |||||
totalHeight += aRowGroup.getHeight().getOpt(); | |||||
} | } | ||||
if (log.isDebugEnabled()) { | if (log.isDebugEnabled()) { | ||||
log.debug("totalHeight=" + totalHeight); | log.debug("totalHeight=" + totalHeight); | ||||
private int getMaxRemainingHeight() { | private int getMaxRemainingHeight() { | ||||
int maxW = 0; | int maxW = 0; | ||||
for (Iterator iter = activeCells.iterator(); iter.hasNext();) { | |||||
ActiveCell activeCell = (ActiveCell) iter.next(); | |||||
for (Object activeCell1 : activeCells) { | |||||
ActiveCell activeCell = (ActiveCell) activeCell1; | |||||
int remain = activeCell.getRemainingLength(); | int remain = activeCell.getRemainingLength(); | ||||
PrimaryGridUnit pgu = activeCell.getPrimaryGridUnit(); | PrimaryGridUnit pgu = activeCell.getPrimaryGridUnit(); | ||||
for (int i = activeRowIndex + 1; i < pgu.getRowIndex() - rowGroup[0].getIndex() | for (int i = activeRowIndex + 1; i < pgu.getRowIndex() - rowGroup[0].getIndex() | ||||
LinkedList footnoteList = new LinkedList(); | LinkedList footnoteList = new LinkedList(); | ||||
//Put all involved grid units into a list | //Put all involved grid units into a list | ||||
List cellParts = new java.util.ArrayList(activeCells.size()); | List cellParts = new java.util.ArrayList(activeCells.size()); | ||||
for (Iterator iter = activeCells.iterator(); iter.hasNext();) { | |||||
ActiveCell activeCell = (ActiveCell) iter.next(); | |||||
for (Object activeCell2 : activeCells) { | |||||
ActiveCell activeCell = (ActiveCell) activeCell2; | |||||
CellPart part = activeCell.createCellPart(); | CellPart part = activeCell.createCellPart(); | ||||
cellParts.add(part); | cellParts.add(part); | ||||
activeCell.addFootnotes(footnoteList); | activeCell.addFootnotes(footnoteList); | ||||
Keep keep = getTableLM().getKeepTogether(); | Keep keep = getTableLM().getKeepTogether(); | ||||
int stepPenalty = 0; | int stepPenalty = 0; | ||||
for (Iterator iter = activeCells.iterator(); iter.hasNext();) { | |||||
ActiveCell activeCell = (ActiveCell) iter.next(); | |||||
for (Object activeCell1 : activeCells) { | |||||
ActiveCell activeCell = (ActiveCell) activeCell1; | |||||
keep = keep.compare(activeCell.getKeepWithNext()); | keep = keep.compare(activeCell.getKeepWithNext()); | ||||
stepPenalty = Math.max(stepPenalty, activeCell.getPenaltyValue()); | stepPenalty = Math.max(stepPenalty, activeCell.getPenaltyValue()); | ||||
} | } | ||||
* previous rows and spanning over this one) | * previous rows and spanning over this one) | ||||
*/ | */ | ||||
private void computeRowFirstStep(List cells) { | private void computeRowFirstStep(List cells) { | ||||
for (Iterator iter = cells.iterator(); iter.hasNext();) { | |||||
ActiveCell activeCell = (ActiveCell) iter.next(); | |||||
for (Object cell : cells) { | |||||
ActiveCell activeCell = (ActiveCell) cell; | |||||
rowFirstStep = Math.max(rowFirstStep, activeCell.getFirstStep()); | rowFirstStep = Math.max(rowFirstStep, activeCell.getFirstStep()); | ||||
} | } | ||||
} | } | ||||
private int computeMinStep() { | private int computeMinStep() { | ||||
int minStep = Integer.MAX_VALUE; | int minStep = Integer.MAX_VALUE; | ||||
boolean stepFound = false; | boolean stepFound = false; | ||||
for (Iterator iter = activeCells.iterator(); iter.hasNext();) { | |||||
ActiveCell activeCell = (ActiveCell) iter.next(); | |||||
for (Object activeCell1 : activeCells) { | |||||
ActiveCell activeCell = (ActiveCell) activeCell1; | |||||
int nextStep = activeCell.getNextStep(); | int nextStep = activeCell.getNextStep(); | ||||
if (nextStep >= 0) { | if (nextStep >= 0) { | ||||
stepFound = true; | stepFound = true; | ||||
* @see ActiveCell#signalRowFirstStep(int) | * @see ActiveCell#signalRowFirstStep(int) | ||||
*/ | */ | ||||
private void signalRowFirstStep() { | private void signalRowFirstStep() { | ||||
for (Iterator iter = activeCells.iterator(); iter.hasNext();) { | |||||
ActiveCell activeCell = (ActiveCell) iter.next(); | |||||
for (Object activeCell1 : activeCells) { | |||||
ActiveCell activeCell = (ActiveCell) activeCell1; | |||||
activeCell.signalRowFirstStep(rowFirstStep); | activeCell.signalRowFirstStep(rowFirstStep); | ||||
} | } | ||||
} | } | ||||
*/ | */ | ||||
private void signalNextStep(int step) { | private void signalNextStep(int step) { | ||||
nextBreakClass = Constants.EN_AUTO; | nextBreakClass = Constants.EN_AUTO; | ||||
for (Iterator iter = activeCells.iterator(); iter.hasNext();) { | |||||
ActiveCell activeCell = (ActiveCell) iter.next(); | |||||
for (Object activeCell1 : activeCells) { | |||||
ActiveCell activeCell = (ActiveCell) activeCell1; | |||||
nextBreakClass = BreakUtil.compareBreakClasses(nextBreakClass, | nextBreakClass = BreakUtil.compareBreakClasses(nextBreakClass, | ||||
activeCell.signalNextStep(step)); | activeCell.signalNextStep(step)); | ||||
} | } | ||||
*/ | */ | ||||
private int considerRowLastStep(int step) { | private int considerRowLastStep(int step) { | ||||
rowFinished = true; | rowFinished = true; | ||||
for (Iterator iter = activeCells.iterator(); iter.hasNext();) { | |||||
ActiveCell activeCell = (ActiveCell) iter.next(); | |||||
for (Object activeCell3 : activeCells) { | |||||
ActiveCell activeCell = (ActiveCell) activeCell3; | |||||
if (activeCell.endsOnRow(activeRowIndex)) { | if (activeCell.endsOnRow(activeRowIndex)) { | ||||
if (!activeCell.finishes(step)) { | if (!activeCell.finishes(step)) { | ||||
rowFinished = false; | rowFinished = false; | ||||
log.trace("Row finished, computing last step"); | log.trace("Row finished, computing last step"); | ||||
} | } | ||||
int maxStep = 0; | int maxStep = 0; | ||||
for (Iterator iter = activeCells.iterator(); iter.hasNext();) { | |||||
ActiveCell activeCell = (ActiveCell) iter.next(); | |||||
for (Object activeCell2 : activeCells) { | |||||
ActiveCell activeCell = (ActiveCell) activeCell2; | |||||
if (activeCell.endsOnRow(activeRowIndex)) { | if (activeCell.endsOnRow(activeRowIndex)) { | ||||
maxStep = Math.max(maxStep, activeCell.getLastStep()); | maxStep = Math.max(maxStep, activeCell.getLastStep()); | ||||
} | } | ||||
if (log.isTraceEnabled()) { | if (log.isTraceEnabled()) { | ||||
log.trace("Max step: " + maxStep); | log.trace("Max step: " + maxStep); | ||||
} | } | ||||
for (Iterator iter = activeCells.iterator(); iter.hasNext();) { | |||||
ActiveCell activeCell = (ActiveCell) iter.next(); | |||||
for (Object activeCell1 : activeCells) { | |||||
ActiveCell activeCell = (ActiveCell) activeCell1; | |||||
activeCell.endRow(activeRowIndex); | activeCell.endRow(activeRowIndex); | ||||
if (!activeCell.endsOnRow(activeRowIndex)) { | if (!activeCell.endsOnRow(activeRowIndex)) { | ||||
activeCell.signalRowLastStep(maxStep); | activeCell.signalRowLastStep(maxStep); | ||||
if (log.isTraceEnabled()) { | if (log.isTraceEnabled()) { | ||||
log.trace("Switching to row " + (activeRowIndex + 1)); | log.trace("Switching to row " + (activeRowIndex + 1)); | ||||
} | } | ||||
for (Iterator iter = activeCells.iterator(); iter.hasNext();) { | |||||
ActiveCell activeCell = (ActiveCell) iter.next(); | |||||
for (Object activeCell1 : activeCells) { | |||||
ActiveCell activeCell = (ActiveCell) activeCell1; | |||||
activeCell.nextRowStarts(); | activeCell.nextRowStarts(); | ||||
} | } | ||||
activeCells.addAll(nextActiveCells); | activeCells.addAll(nextActiveCells); |
/* generic creation of PDF object */ | /* generic creation of PDF object */ | ||||
super(parent); | super(parent); | ||||
for (int i = 0, c = values.length; i < c; i++) { | |||||
this.values.add(values[i]); | |||||
for (int value : values) { | |||||
this.values.add(value); | |||||
} | } | ||||
} | } | ||||
/* generic creation of PDF object */ | /* generic creation of PDF object */ | ||||
super(parent); | super(parent); | ||||
for (int i = 0, c = values.length; i < c; i++) { | |||||
this.values.add(values[i]); | |||||
for (double value : values) { | |||||
this.values.add(value); | |||||
} | } | ||||
} | } | ||||
/* generic creation of PDF object */ | /* generic creation of PDF object */ | ||||
super(parent); | super(parent); | ||||
for (int i = 0, c = values.length; i < c; i++) { | |||||
this.values.add(values[i]); | |||||
for (Object value : values) { | |||||
this.values.add(value); | |||||
} | } | ||||
} | } | ||||
ColorWithAlternatives colExt = (ColorWithAlternatives)color; | ColorWithAlternatives colExt = (ColorWithAlternatives)color; | ||||
//Alternate colors have priority | //Alternate colors have priority | ||||
Color[] alt = colExt.getAlternativeColors(); | Color[] alt = colExt.getAlternativeColors(); | ||||
for (int i = 0, c = alt.length; i < c; i++) { | |||||
Color col = alt[i]; | |||||
for (Color col : alt) { | |||||
boolean established = establishColorFromColor(codeBuffer, col, fill); | boolean established = establishColorFromColor(codeBuffer, col, fill); | ||||
if (established) { | if (established) { | ||||
return; | return; | ||||
if (comps.length != componentCount) { | if (comps.length != componentCount) { | ||||
throw new IllegalStateException("Color with unexpected component count encountered"); | throw new IllegalStateException("Color with unexpected component count encountered"); | ||||
} | } | ||||
for (int i = 0, c = comps.length; i < c; i++) { | |||||
DoubleFormatUtil.formatDouble(comps[i], 4, 4, codeBuffer); | |||||
for (float comp : comps) { | |||||
DoubleFormatUtil.formatDouble(comp, 4, 4, codeBuffer); | |||||
codeBuffer.append(" "); | codeBuffer.append(" "); | ||||
} | } | ||||
codeBuffer.append(command).append("\n"); | codeBuffer.append(command).append("\n"); |
addFilter(new FlateFilter()); | addFilter(new FlateFilter()); | ||||
} | } | ||||
} else { | } else { | ||||
for (int i = 0; i < filterset.size(); i++) { | |||||
String v = (String)filterset.get(i); | |||||
for (Object aFilterset : filterset) { | |||||
String v = (String) aFilterset; | |||||
addFilter(v); | addFilter(v); | ||||
} | } | ||||
} | } | ||||
private int populateNamesAndParms(List names, List parms) { | private int populateNamesAndParms(List names, List parms) { | ||||
// run the filters | // run the filters | ||||
int nonNullParams = 0; | int nonNullParams = 0; | ||||
for (int count = 0; count < filters.size(); count++) { | |||||
PDFFilter filter = filters.get(count); | |||||
for (PDFFilter filter : filters) { | |||||
// place the names in our local vector in reverse order | // place the names in our local vector in reverse order | ||||
if (filter.getName().length() > 0) { | if (filter.getName().length() > 0) { | ||||
names.add(0, filter.getName()); | names.add(0, filter.getName()); | ||||
private String buildFilterEntries(List names) { | private String buildFilterEntries(List names) { | ||||
int filterCount = 0; | int filterCount = 0; | ||||
StringBuffer sb = new StringBuffer(64); | StringBuffer sb = new StringBuffer(64); | ||||
for (int i = 0; i < names.size(); i++) { | |||||
final String name = (String)names.get(i); | |||||
for (Object name1 : names) { | |||||
final String name = (String) name1; | |||||
if (name.length() > 0) { | if (name.length() > 0) { | ||||
filterCount++; | filterCount++; | ||||
sb.append(name); | sb.append(name); | ||||
private void putFilterEntries(PDFDictionary dict, List names) { | private void putFilterEntries(PDFDictionary dict, List names) { | ||||
PDFArray array = new PDFArray(dict); | PDFArray array = new PDFArray(dict); | ||||
for (int i = 0, c = names.size(); i < c; i++) { | |||||
final String name = (String)names.get(i); | |||||
for (Object name1 : names) { | |||||
final String name = (String) name1; | |||||
if (name.length() > 0) { | if (name.length() > 0) { | ||||
array.add(new PDFName(name)); | array.add(new PDFName(name)); | ||||
} | } | ||||
if (parms.size() > 1) { | if (parms.size() > 1) { | ||||
sb.append("[ "); | sb.append("[ "); | ||||
} | } | ||||
for (int count = 0; count < parms.size(); count++) { | |||||
String s = (String)parms.get(count); | |||||
for (Object parm : parms) { | |||||
String s = (String) parm; | |||||
if (s != null) { | if (s != null) { | ||||
sb.append(s); | sb.append(s); | ||||
needParmsEntry = true; | needParmsEntry = true; | ||||
private void putDecodeParams(PDFDictionary dict, List parms) { | private void putDecodeParams(PDFDictionary dict, List parms) { | ||||
boolean needParmsEntry = false; | boolean needParmsEntry = false; | ||||
PDFArray array = new PDFArray(dict); | PDFArray array = new PDFArray(dict); | ||||
for (int i = 0, c = parms.size(); i < c; i++) { | |||||
Object obj = parms.get(i); | |||||
for (Object obj : parms) { | |||||
if (obj != null) { | if (obj != null) { | ||||
array.add(obj); | array.add(obj); | ||||
needParmsEntry = true; | needParmsEntry = true; |
sb.append("<< /Type /Pages\n/Count ") | sb.append("<< /Type /Pages\n/Count ") | ||||
.append(this.getCount()) | .append(this.getCount()) | ||||
.append("\n/Kids ["); | .append("\n/Kids ["); | ||||
for (int i = 0; i < kids.size(); i++) { | |||||
Object kid = kids.get(i); | |||||
for (Object kid : kids) { | |||||
if (kid == null) { | if (kid == null) { | ||||
throw new IllegalStateException("Gap in the kids list!"); | throw new IllegalStateException("Gap in the kids list!"); | ||||
} | } |
import java.awt.Shape; | import java.awt.Shape; | ||||
import java.awt.geom.Area; | import java.awt.geom.Area; | ||||
import java.awt.geom.GeneralPath; | import java.awt.geom.GeneralPath; | ||||
import java.util.Iterator; | |||||
import org.apache.xmlgraphics.java2d.color.ColorUtil; | import org.apache.xmlgraphics.java2d.color.ColorUtil; | ||||
PDFGState state; | PDFGState state; | ||||
PDFGState newState = new PDFGState(); | PDFGState newState = new PDFGState(); | ||||
newState.addValues(defaultState); | newState.addValues(defaultState); | ||||
for (Iterator it = getStateStack().iterator(); it.hasNext();) { | |||||
PDFData data = (PDFData)it.next(); | |||||
for (AbstractData abstractData : getStateStack()) { | |||||
PDFData data = (PDFData) abstractData; | |||||
state = data.gstate; | state = data.gstate; | ||||
if (state != null) { | if (state != null) { | ||||
newState.addValues(state); | newState.addValues(state); |
if (brackets) { | if (brackets) { | ||||
sb.append("<"); | sb.append("<"); | ||||
} | } | ||||
for (int i = 0; i < data.length; i++) { | |||||
sb.append(DIGITS[(data[i] >>> 4) & 0x0F]); | |||||
sb.append(DIGITS[data[i] & 0x0F]); | |||||
for (byte aData : data) { | |||||
sb.append(DIGITS[(aData >>> 4) & 0x0F]); | |||||
sb.append(DIGITS[aData & 0x0F]); | |||||
} | } | ||||
if (brackets) { | if (brackets) { | ||||
sb.append(">"); | sb.append(">"); | ||||
throw new CascadingRuntimeException("Incompatible VM", uee); | throw new CascadingRuntimeException("Incompatible VM", uee); | ||||
} | } | ||||
for (int i = 0; i < uniBytes.length; i++) { | |||||
buf.append(DIGITS[(uniBytes[i] >>> 4) & 0x0F]); | |||||
buf.append(DIGITS[uniBytes[i] & 0x0F]); | |||||
for (byte uniByte : uniBytes) { | |||||
buf.append(DIGITS[(uniByte >>> 4) & 0x0F]); | |||||
buf.append(DIGITS[uniByte & 0x0F]); | |||||
} | } | ||||
return buf.toString(); | return buf.toString(); | ||||
} | } | ||||
public static final byte[] escapeByteArray(byte[] data) { | public static final byte[] escapeByteArray(byte[] data) { | ||||
ByteArrayOutputStream bout = new ByteArrayOutputStream(data.length); | ByteArrayOutputStream bout = new ByteArrayOutputStream(data.length); | ||||
bout.write((int)'('); | bout.write((int)'('); | ||||
for (int i = 0; i < data.length; i++) { | |||||
final int b = data[i]; | |||||
for (final byte b : data) { | |||||
switch (b) { | switch (b) { | ||||
case '\n': | case '\n': | ||||
bout.write('\\'); | bout.write('\\'); |
StringBuffer p = new StringBuffer(); | StringBuffer p = new StringBuffer(); | ||||
p.append("[ "); | p.append("[ "); | ||||
int len = entries.size(); | int len = entries.size(); | ||||
for (int i = 0; i < len; i++) { | |||||
Object entry = entries.get(i); | |||||
for (Object entry : entries) { | |||||
if (entry instanceof int[]) { | if (entry instanceof int[]) { | ||||
int[] line = (int[])entry; | |||||
for (int j = 0; j < line.length; j++) { | |||||
p.append(line[j]); | |||||
int[] line = (int[]) entry; | |||||
for (int aLine : line) { | |||||
p.append(aLine); | |||||
p.append(" "); | p.append(" "); | ||||
} | } | ||||
} else { | } else { | ||||
((Entry)entry).fillInPDF(p); | |||||
((Entry) entry).fillInPDF(p); | |||||
} | } | ||||
} | } | ||||
p.append("]"); | p.append("]"); | ||||
// p.setLength(0); | // p.setLength(0); | ||||
p.append(start); | p.append(start); | ||||
p.append(" ["); | p.append(" ["); | ||||
for (int i = 0; i < metrics.length; i++) { | |||||
p.append(this.metrics[i]); | |||||
for (int metric : metrics) { | |||||
p.append(metric); | |||||
p.append(" "); | p.append(" "); | ||||
} | } | ||||
p.append("] "); | p.append("] "); |
*/ | */ | ||||
public boolean isMimeTypeSupported(String mimeType) { | public boolean isMimeTypeSupported(String mimeType) { | ||||
String[] mimes = getSupportedMimeTypes(); | String[] mimes = getSupportedMimeTypes(); | ||||
for (int i = 0; i < mimes.length; i++) { | |||||
if (mimes[i].equals(mimeType)) { | |||||
for (String mime : mimes) { | |||||
if (mime.equals(mimeType)) { | |||||
return true; | return true; | ||||
} | } | ||||
} | } |
private String convertToString(List children) { | private String convertToString(List children) { | ||||
StringBuffer sb = new StringBuffer(); | StringBuffer sb = new StringBuffer(); | ||||
for (int count = 0; count < children.size(); count++) { | |||||
InlineArea inline = (InlineArea) children.get(count); | |||||
for (Object aChildren : children) { | |||||
InlineArea inline = (InlineArea) aChildren; | |||||
//if (inline instanceof Character) { | //if (inline instanceof Character) { | ||||
// sb.append(((Character) inline).getChar()); | // sb.append(((Character) inline).getChar()); | ||||
/*} else*/ if (inline instanceof TextArea) { | |||||
/*} else*/ | |||||
if (inline instanceof TextArea) { | |||||
sb.append(((TextArea) inline).getText()); | sb.append(((TextArea) inline).getText()); | ||||
} else if (inline instanceof InlineParent) { | } else if (inline instanceof InlineParent) { | ||||
sb.append(convertToString( | sb.append(convertToString( | ||||
int saveBPPos = currentBPPosition; | int saveBPPos = currentBPPosition; | ||||
int saveSpanBPPos = saveBPPos; | int saveSpanBPPos = saveBPPos; | ||||
int saveIPPos = currentIPPosition; | int saveIPPos = currentIPPosition; | ||||
for (int count = 0; count < spans.size(); count++) { | |||||
span = (Span) spans.get(count); | |||||
for (Object span1 : spans) { | |||||
span = (Span) span1; | |||||
int level = span.getBidiLevel(); | int level = span.getBidiLevel(); | ||||
if (level < 0) { | if (level < 0) { | ||||
level = 0; | level = 0; | ||||
containingBPPosition = currentBPPosition; | containingBPPosition = currentBPPosition; | ||||
containingIPPosition = currentIPPosition; | containingIPPosition = currentIPPosition; | ||||
for (int count = 0; count < blocks.size(); count++) { | |||||
Object obj = blocks.get(count); | |||||
for (Object obj : blocks) { | |||||
if (obj instanceof Block) { | if (obj instanceof Block) { | ||||
currentIPPosition = contIP; | currentIPPosition = contIP; | ||||
containingBPPosition = contBP; | containingBPPosition = contBP; | ||||
} else { | } else { | ||||
currentIPPosition += line.getStartIndent(); | currentIPPosition += line.getStartIndent(); | ||||
} | } | ||||
for (int i = 0, l = children.size(); i < l; i++) { | |||||
InlineArea inline = (InlineArea) children.get(i); | |||||
for (Object aChildren : children) { | |||||
InlineArea inline = (InlineArea) aChildren; | |||||
renderInlineArea(inline); | renderInlineArea(inline); | ||||
} | } | ||||
currentBPPosition = saveBP; | currentBPPosition = saveBP; | ||||
List children = text.getChildAreas(); | List children = text.getChildAreas(); | ||||
int saveIP = currentIPPosition; | int saveIP = currentIPPosition; | ||||
int saveBP = currentBPPosition; | int saveBP = currentBPPosition; | ||||
for (int i = 0, l = children.size(); i < l; i++) { | |||||
InlineArea inline = (InlineArea) children.get(i); | |||||
for (Object aChildren : children) { | |||||
InlineArea inline = (InlineArea) aChildren; | |||||
renderInlineArea(inline); | renderInlineArea(inline); | ||||
} | } | ||||
currentIPPosition = saveIP + text.getAllocIPD(); | currentIPPosition = saveIP + text.getAllocIPD(); | ||||
int ipAdjust; | int ipAdjust; | ||||
if ((ip instanceof FilledArea) && ((level & 1) != 0)) { | if ((ip instanceof FilledArea) && ((level & 1) != 0)) { | ||||
int ipdChildren = 0; | int ipdChildren = 0; | ||||
for (int i = 0, l = children.size(); i < l; i++) { | |||||
InlineArea inline = (InlineArea) children.get(i); | |||||
for (Object aChildren : children) { | |||||
InlineArea inline = (InlineArea) aChildren; | |||||
ipdChildren += inline.getAllocIPD(); | ipdChildren += inline.getAllocIPD(); | ||||
} | } | ||||
ipAdjust = ip.getAllocIPD() - ipdChildren; | ipAdjust = ip.getAllocIPD() - ipdChildren; | ||||
} | } | ||||
currentBPPosition += ip.getBlockProgressionOffset(); | currentBPPosition += ip.getBlockProgressionOffset(); | ||||
// render children inlines | // render children inlines | ||||
for (int i = 0, l = children.size(); i < l; i++) { | |||||
InlineArea inline = (InlineArea) children.get(i); | |||||
for (Object aChildren : children) { | |||||
InlineArea inline = (InlineArea) aChildren; | |||||
renderInlineArea(inline); | renderInlineArea(inline); | ||||
} | } | ||||
currentIPPosition = saveIP + ip.getAllocIPD(); | currentIPPosition = saveIP + ip.getAllocIPD(); |
*/ | */ | ||||
public boolean isMimeTypeSupported(String mimeType) { | public boolean isMimeTypeSupported(String mimeType) { | ||||
String[] mimes = getSupportedMimeTypes(); | String[] mimes = getSupportedMimeTypes(); | ||||
for (int i = 0; i < mimes.length; i++) { | |||||
if (mimes[i].equals(mimeType)) { | |||||
for (String mime : mimes) { | |||||
if (mime.equals(mimeType)) { | |||||
return true; | return true; | ||||
} | } | ||||
} | } |
for (ImageHandler handler : this.handlerList) { | for (ImageHandler handler : this.handlerList) { | ||||
if (handler.isCompatible(context, null)) { | if (handler.isCompatible(context, null)) { | ||||
ImageFlavor[] f = handler.getSupportedImageFlavors(); | ImageFlavor[] f = handler.getSupportedImageFlavors(); | ||||
for (int i = 0; i < f.length; i++) { | |||||
flavors.add(f[i]); | |||||
for (ImageFlavor aF : f) { | |||||
flavors.add(aF); | |||||
} | } | ||||
} | } | ||||
} | } |
*/ | */ | ||||
public void addRendererMaker(AbstractRendererMaker maker) { | public void addRendererMaker(AbstractRendererMaker maker) { | ||||
String[] mimes = maker.getSupportedMimeTypes(); | String[] mimes = maker.getSupportedMimeTypes(); | ||||
for (int i = 0; i < mimes.length; i++) { | |||||
for (String mime : mimes) { | |||||
//This overrides any renderer previously set for a MIME type | //This overrides any renderer previously set for a MIME type | ||||
if (rendererMakerMapping.get(mimes[i]) != null) { | |||||
log.trace("Overriding renderer for " + mimes[i] | |||||
if (rendererMakerMapping.get(mime) != null) { | |||||
log.trace("Overriding renderer for " + mime | |||||
+ " with " + maker.getClass().getName()); | + " with " + maker.getClass().getName()); | ||||
} | } | ||||
rendererMakerMapping.put(mimes[i], maker); | |||||
rendererMakerMapping.put(mime, maker); | |||||
} | } | ||||
} | } | ||||
*/ | */ | ||||
public void addFOEventHandlerMaker(AbstractFOEventHandlerMaker maker) { | public void addFOEventHandlerMaker(AbstractFOEventHandlerMaker maker) { | ||||
String[] mimes = maker.getSupportedMimeTypes(); | String[] mimes = maker.getSupportedMimeTypes(); | ||||
for (int i = 0; i < mimes.length; i++) { | |||||
for (String mime : mimes) { | |||||
//This overrides any event handler previously set for a MIME type | //This overrides any event handler previously set for a MIME type | ||||
if (eventHandlerMakerMapping.get(mimes[i]) != null) { | |||||
log.trace("Overriding FOEventHandler for " + mimes[i] | |||||
if (eventHandlerMakerMapping.get(mime) != null) { | |||||
log.trace("Overriding FOEventHandler for " + mime | |||||
+ " with " + maker.getClass().getName()); | + " with " + maker.getClass().getName()); | ||||
} | } | ||||
eventHandlerMakerMapping.put(mimes[i], maker); | |||||
eventHandlerMakerMapping.put(mime, maker); | |||||
} | } | ||||
} | } | ||||
*/ | */ | ||||
public void addDocumentHandlerMaker(AbstractIFDocumentHandlerMaker maker) { | public void addDocumentHandlerMaker(AbstractIFDocumentHandlerMaker maker) { | ||||
String[] mimes = maker.getSupportedMimeTypes(); | String[] mimes = maker.getSupportedMimeTypes(); | ||||
for (int i = 0; i < mimes.length; i++) { | |||||
for (String mime : mimes) { | |||||
//This overrides any renderer previously set for a MIME type | //This overrides any renderer previously set for a MIME type | ||||
if (documentHandlerMakerMapping.get(mimes[i]) != null) { | |||||
log.trace("Overriding document handler for " + mimes[i] | |||||
if (documentHandlerMakerMapping.get(mime) != null) { | |||||
log.trace("Overriding document handler for " + mime | |||||
+ " with " + maker.getClass().getName()); | + " with " + maker.getClass().getName()); | ||||
} | } | ||||
documentHandlerMakerMapping.put(mimes[i], maker); | |||||
documentHandlerMakerMapping.put(mime, maker); | |||||
} | } | ||||
} | } | ||||
Configuration handlerConfig = null; | Configuration handlerConfig = null; | ||||
Configuration[] children = cfg.getChildren("xml-handler"); | Configuration[] children = cfg.getChildren("xml-handler"); | ||||
for (int i = 0; i < children.length; ++i) { | |||||
for (Configuration aChildren : children) { | |||||
try { | try { | ||||
if (children[i].getAttribute("namespace").equals(namespace)) { | |||||
handlerConfig = children[i]; | |||||
if (aChildren.getAttribute("namespace").equals(namespace)) { | |||||
handlerConfig = aChildren; | |||||
break; | break; | ||||
} | } | ||||
} catch (ConfigurationException e) { | } catch (ConfigurationException e) { |
private XMLHandler getXMLHandler(Renderer renderer, List<XMLHandler> lst) { | private XMLHandler getXMLHandler(Renderer renderer, List<XMLHandler> lst) { | ||||
XMLHandler handler; | XMLHandler handler; | ||||
if (lst != null) { | if (lst != null) { | ||||
for (int i = 0, c = lst.size(); i < c; i++) { | |||||
for (XMLHandler aLst : lst) { | |||||
//TODO Maybe add priorities later | //TODO Maybe add priorities later | ||||
handler = lst.get(i); | |||||
handler = aLst; | |||||
if (handler.supportsRenderer(renderer)) { | if (handler.supportsRenderer(renderer)) { | ||||
return handler; | return handler; | ||||
} | } |
if (defaultResourceLevelCfg != null) { | if (defaultResourceLevelCfg != null) { | ||||
AFPResourceLevelDefaults defaults = new AFPResourceLevelDefaults(); | AFPResourceLevelDefaults defaults = new AFPResourceLevelDefaults(); | ||||
String[] types = defaultResourceLevelCfg.getAttributeNames(); | String[] types = defaultResourceLevelCfg.getAttributeNames(); | ||||
for (int i = 0, c = types.length; i < c; i++) { | |||||
String type = types[i]; | |||||
for (String type : types) { | |||||
try { | try { | ||||
String level = defaultResourceLevelCfg.getAttribute(type); | String level = defaultResourceLevelCfg.getAttribute(type); | ||||
defaults.setDefaultResourceLevel(type, AFPResourceLevel.valueOf(level)); | defaults.setDefaultResourceLevel(type, AFPResourceLevel.valueOf(level)); |
*/ | */ | ||||
public boolean isMimeTypeSupported(String mimeType) { | public boolean isMimeTypeSupported(String mimeType) { | ||||
String[] mimes = getSupportedMimeTypes(); | String[] mimes = getSupportedMimeTypes(); | ||||
for (int i = 0; i < mimes.length; i++) { | |||||
if (mimes[i].equals(mimeType)) { | |||||
for (String mime : mimes) { | |||||
if (mime.equals(mimeType)) { | |||||
return true; | return true; | ||||
} | } | ||||
} | } |
private AffineTransform combine(AffineTransform[] transforms) { | private AffineTransform combine(AffineTransform[] transforms) { | ||||
AffineTransform at = new AffineTransform(); | AffineTransform at = new AffineTransform(); | ||||
for (int i = 0, c = transforms.length; i < c; i++) { | |||||
at.concatenate(transforms[i]); | |||||
for (AffineTransform transform : transforms) { | |||||
at.concatenate(transform); | |||||
} | } | ||||
return at; | return at; | ||||
} | } |
private void processExtensionAttachments(AreaTreeObject area) throws IFException { | private void processExtensionAttachments(AreaTreeObject area) throws IFException { | ||||
if (area.hasExtensionAttachments()) { | if (area.hasExtensionAttachments()) { | ||||
for (Iterator iter = area.getExtensionAttachments().iterator(); | |||||
iter.hasNext();) { | |||||
ExtensionAttachment attachment = (ExtensionAttachment) iter.next(); | |||||
for (ExtensionAttachment attachment : area.getExtensionAttachments()) { | |||||
this.documentHandler.handleExtensionObject(attachment); | this.documentHandler.handleExtensionObject(attachment); | ||||
} | } | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
protected void restoreStateStackAfterBreakOut(List breakOutList) { | protected void restoreStateStackAfterBreakOut(List breakOutList) { | ||||
log.debug("Block.FIXED --> restoring context after break-out"); | log.debug("Block.FIXED --> restoring context after break-out"); | ||||
for (int i = 0, c = breakOutList.size(); i < c; i++) { | |||||
for (Object aBreakOutList : breakOutList) { | |||||
graphicContextStack.push(graphicContext); | graphicContextStack.push(graphicContext); | ||||
this.graphicContext = (IFGraphicContext)breakOutList.get(i); | |||||
this.graphicContext = (IFGraphicContext) aBreakOutList; | |||||
//Handle groups | //Handle groups | ||||
IFGraphicContext.Group[] groups = graphicContext.getGroups(); | IFGraphicContext.Group[] groups = graphicContext.getGroups(); | ||||
for (int j = 0, jc = groups.length; j < jc; j++) { | |||||
for (IFGraphicContext.Group group : groups) { | |||||
try { | try { | ||||
groups[j].start(painter); | |||||
group.start(painter); | |||||
} catch (IFException ife) { | } catch (IFException ife) { | ||||
handleIFException(ife); | handleIFException(ife); | ||||
} | } |
if (dp == null) { | if (dp == null) { | ||||
return true; | return true; | ||||
} else { | } else { | ||||
for (int i = 0, n = dp.length; i < n; i++) { | |||||
if (!isPAIdentity(dp[i])) { | |||||
for (int[] aDp : dp) { | |||||
if (!isPAIdentity(aDp)) { | |||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
if (dp == null) { | if (dp == null) { | ||||
return false; | return false; | ||||
} else { | } else { | ||||
for (int i = 0, n = dp.length; i < n; i++) { | |||||
int[] pa = dp[i]; | |||||
for (int[] pa : dp) { | |||||
if ((pa != null) && (pa[0] != pa[2])) { | if ((pa != null) && (pa[0] != pa[2])) { | ||||
return false; | return false; | ||||
} | } |
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); | GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); | ||||
java.awt.Font[] fonts = env.getAllFonts(); | java.awt.Font[] fonts = env.getAllFonts(); | ||||
for (int i = 0; i < fonts.length; i++) { | |||||
java.awt.Font f = fonts[i]; | |||||
for (java.awt.Font f : fonts) { | |||||
if (HARDCODED_FONT_NAMES.contains(f.getName())) { | if (HARDCODED_FONT_NAMES.contains(f.getName())) { | ||||
continue; //skip | continue; //skip | ||||
} | } |
public PCLGenerator(OutputStream out, int maxResolution) { | public PCLGenerator(OutputStream out, int maxResolution) { | ||||
this(out); | this(out); | ||||
boolean found = false; | boolean found = false; | ||||
for (int i = 0; i < PCL_RESOLUTIONS.length; i++) { | |||||
if (PCL_RESOLUTIONS[i] == maxResolution) { | |||||
for (int pclResolutions : PCL_RESOLUTIONS) { | |||||
if (pclResolutions == maxResolution) { | |||||
found = true; | found = true; | ||||
break; | break; | ||||
} | } |
if (curNode.getAttributes().getNamedItem("style") != null) { | if (curNode.getAttributes().getNamedItem("style") != null) { | ||||
String[] stylePairs = curNode.getAttributes().getNamedItem("style").getNodeValue() | String[] stylePairs = curNode.getAttributes().getNamedItem("style").getNodeValue() | ||||
.split(";"); | .split(";"); | ||||
for (int styleAtt = 0; styleAtt < stylePairs.length; styleAtt++) { | |||||
String[] style = stylePairs[styleAtt].split(":"); | |||||
for (String stylePair : stylePairs) { | |||||
String[] style = stylePair.split(":"); | |||||
if (style[0].equalsIgnoreCase("stop-opacity")) { | if (style[0].equalsIgnoreCase("stop-opacity")) { | ||||
if (Double.parseDouble(style[1]) < 1) { | if (Double.parseDouble(style[1]) < 1) { | ||||
return true; | return true; |
//Calculation for column-widths which are not set | //Calculation for column-widths which are not set | ||||
prepareTable(table); | prepareTable(table); | ||||
for (Iterator it = table.getColumns().iterator(); it.hasNext();) { | |||||
recurseFONode((FONode) it.next()); | |||||
} | |||||
for (Object o : table.getColumns()) { | |||||
recurseFONode((FONode) o); | |||||
} | |||||
} else { | } else { | ||||
//TODO Implement implicit column setup handling! | //TODO Implement implicit column setup handling! | ||||
RTFEventProducer eventProducer = RTFEventProducer.Provider.get( | RTFEventProducer eventProducer = RTFEventProducer.Provider.get( |
int len = colorTable.size(); | int len = colorTable.size(); | ||||
for (int i = 0; i < len; i++) { | |||||
int identifier = (Integer) colorTable.get(i); | |||||
for (Object aColorTable : colorTable) { | |||||
int identifier = (Integer) aColorTable; | |||||
header.newLine(); | header.newLine(); | ||||
header.write("\\red" + determineColorLevel(identifier, RED)); | header.write("\\red" + determineColorLevel(identifier, RED)); |
import java.io.IOException; | import java.io.IOException; | ||||
import java.io.Writer; | import java.io.Writer; | ||||
import java.util.Iterator; | |||||
import java.util.LinkedList; | import java.util.LinkedList; | ||||
import java.util.List; | import java.util.List; | ||||
} | } | ||||
private int findChildren(RtfElement aChild, int iStart) { | private int findChildren(RtfElement aChild, int iStart) { | ||||
for (Iterator it = this.getChildren().iterator(); it.hasNext();) { | |||||
final RtfElement e = (RtfElement)it.next(); | |||||
if (aChild == e) { | |||||
return iStart; | |||||
} else if (e instanceof RtfContainer) { | |||||
int iFound = ((RtfContainer)e).findChildren(aChild, (iStart + 1)); | |||||
if (iFound != -1) { | |||||
return iFound; | |||||
} | |||||
} | |||||
for (Object o : this.getChildren()) { | |||||
final RtfElement e = (RtfElement) o; | |||||
if (aChild == e) { | |||||
return iStart; | |||||
} else if (e instanceof RtfContainer) { | |||||
int iFound = ((RtfContainer) e).findChildren(aChild, (iStart + 1)); | |||||
if (iFound != -1) { | |||||
return iFound; | |||||
} | |||||
} | |||||
} | } | ||||
return -1; | return -1; | ||||
} | } | ||||
*/ | */ | ||||
protected void writeRtfContent() | protected void writeRtfContent() | ||||
throws IOException { | throws IOException { | ||||
for (Iterator it = children.iterator(); it.hasNext();) { | |||||
final RtfElement e = (RtfElement)it.next(); | |||||
for (Object aChildren : children) { | |||||
final RtfElement e = (RtfElement) aChildren; | |||||
e.writeRtf(); | e.writeRtf(); | ||||
} | } | ||||
} | } | ||||
/** true if this (recursively) contains at least one RtfText object */ | /** true if this (recursively) contains at least one RtfText object */ | ||||
boolean containsText() { | boolean containsText() { | ||||
boolean result = false; | boolean result = false; | ||||
for (Iterator it = children.iterator(); it.hasNext();) { | |||||
final RtfElement e = (RtfElement)it.next(); | |||||
for (Object aChildren : children) { | |||||
final RtfElement e = (RtfElement) aChildren; | |||||
if (e instanceof RtfText) { | if (e instanceof RtfText) { | ||||
result = !e.isEmpty(); | result = !e.isEmpty(); | ||||
} else if (e instanceof RtfContainer) { | } else if (e instanceof RtfContainer) { | ||||
if (((RtfContainer)e).containsText()) { | |||||
if (((RtfContainer) e).containsText()) { | |||||
result = true; | result = true; | ||||
} | } | ||||
} | } | ||||
void dump(Writer w, int indent) | void dump(Writer w, int indent) | ||||
throws IOException { | throws IOException { | ||||
super.dump(w, indent); | super.dump(w, indent); | ||||
for (Iterator it = children.iterator(); it.hasNext();) { | |||||
final RtfElement e = (RtfElement)it.next(); | |||||
for (Object aChildren : children) { | |||||
final RtfElement e = (RtfElement) aChildren; | |||||
e.dump(w, indent + 1); | e.dump(w, indent + 1); | ||||
} | } | ||||
} | } | ||||
*/ | */ | ||||
public boolean isEmpty() { | public boolean isEmpty() { | ||||
boolean result = true; | boolean result = true; | ||||
for (Iterator it = children.iterator(); it.hasNext();) { | |||||
final RtfElement e = (RtfElement)it.next(); | |||||
for (Object aChildren : children) { | |||||
final RtfElement e = (RtfElement) aChildren; | |||||
if (!e.isEmpty()) { | if (!e.isEmpty()) { | ||||
result = false; | result = false; | ||||
break; | break; |
if (nameList != null) { | if (nameList != null) { | ||||
// process only given attribute names | // process only given attribute names | ||||
for (int i = 0; i < nameList.length; i++) { | |||||
final String name = nameList[i]; | |||||
for (final String name : nameList) { | |||||
if (attr.isSet(name)) { | if (attr.isSet(name)) { | ||||
writeOneAttribute(name, attr.getValue(name)); | writeOneAttribute(name, attr.getValue(name)); | ||||
} | } |
writeSizeInfo(); | writeSizeInfo(); | ||||
writeAttributes(getRtfAttributes(), null); | writeAttributes(getRtfAttributes(), null); | ||||
for (int i = 0; i < imagedata.length; i++) { | |||||
int iData = imagedata [i]; | |||||
for (byte anImagedata : imagedata) { | |||||
int iData = anImagedata; | |||||
// Make positive byte | // Make positive byte | ||||
if (iData < 0) { | if (iData < 0) { |