git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1039179 13f79535-47bb-0310-9956-ffa450edef68tags/fop-1_1rc1old
* The methods fromJava and fromTeX are commented out because they are not Java 1.4 compliant. | * The methods fromJava and fromTeX are commented out because they are not Java 1.4 compliant. | ||||
*/ | */ | ||||
public final class UnicodeClasses { | public final class UnicodeClasses { | ||||
/** directory containing unicode properties files */ | /** directory containing unicode properties files */ | ||||
public static final String UNICODE_DIR = "http://www.unicode.org/Public/UNIDATA/"; | public static final String UNICODE_DIR = "http://www.unicode.org/Public/UNIDATA/"; | ||||
w.write("<!-- in 'src/java/org/apache/fop/hyphenation' -->\n"); | w.write("<!-- in 'src/java/org/apache/fop/hyphenation' -->\n"); | ||||
w.write("<!-- * commit the changed file -->\n"); | w.write("<!-- * commit the changed file -->\n"); | ||||
} | } | ||||
/** | /** | ||||
* Generate classes.xml from Java's compiled-in Unicode Character Database | * Generate classes.xml from Java's compiled-in Unicode Character Database | ||||
* @param hexcode whether to prefix each class with the hexcode (only for debugging purposes) | * @param hexcode whether to prefix each class with the hexcode (only for debugging purposes) | ||||
ow.write("<classes>\n"); | ow.write("<classes>\n"); | ||||
// loop over the first Unicode plane | // loop over the first Unicode plane | ||||
for (int code = Character.MIN_VALUE; code <= maxChar; ++code) { | for (int code = Character.MIN_VALUE; code <= maxChar; ++code) { | ||||
// skip surrogate area | // skip surrogate area | ||||
if (code == Character.MIN_SURROGATE) { | if (code == Character.MIN_SURROGATE) { | ||||
code = Character.MAX_SURROGATE; | code = Character.MAX_SURROGATE; | ||||
|| Character.getType(code) == Character.OTHER_LETTER)) { | || Character.getType(code) == Character.OTHER_LETTER)) { | ||||
continue; | continue; | ||||
} | } | ||||
// skip a number of blocks | // skip a number of blocks | ||||
Character.UnicodeBlock ubi = Character.UnicodeBlock.of(code); | Character.UnicodeBlock ubi = Character.UnicodeBlock.of(code); | ||||
if (ubi.equals(Character.UnicodeBlock.SUPERSCRIPTS_AND_SUBSCRIPTS) | if (ubi.equals(Character.UnicodeBlock.SUPERSCRIPTS_AND_SUBSCRIPTS) | ||||
ow.flush(); | ow.flush(); | ||||
ow.close(); | ow.close(); | ||||
} | } | ||||
/** | /** | ||||
* The column numbers in the UCD file | * The column numbers in the UCD file | ||||
*/ | */ | ||||
public static final int UNICODE = 0, GENERAL_CATEGORY = 2, SIMPLE_UPPERCASE_MAPPING = 12, | public static final int UNICODE = 0, GENERAL_CATEGORY = 2, SIMPLE_UPPERCASE_MAPPING = 12, | ||||
SIMPLE_LOWERCASE_MAPPING = 13, SIMPLE_TITLECASE_MAPPING = 14, NUM_FIELDS = 15; | SIMPLE_LOWERCASE_MAPPING = 13, SIMPLE_TITLECASE_MAPPING = 14, NUM_FIELDS = 15; | ||||
/** | /** | ||||
* Generate classes.xml from Unicode Character Database files | * Generate classes.xml from Unicode Character Database files | ||||
* @param hexcode whether to prefix each class with the hexcode (only for debugging purposes) | * @param hexcode whether to prefix each class with the hexcode (only for debugging purposes) | ||||
* @param unidataPath path to the directory with UCD files | |||||
* @param unidataPath path to the directory with UCD files | |||||
* @param outfilePath output file | * @param outfilePath output file | ||||
* @throws IOException if the input files are not found | * @throws IOException if the input files are not found | ||||
* @throws URISyntaxException if {@code unidataPath} cannot be converted to a URI | * @throws URISyntaxException if {@code unidataPath} cannot be converted to a URI | ||||
throw new FileNotFoundException | throw new FileNotFoundException | ||||
("URI with file or http scheme required for UNIDATA input directory"); | ("URI with file or http scheme required for UNIDATA input directory"); | ||||
} | } | ||||
File f = new File(outfilePath); | File f = new File(outfilePath); | ||||
if (f.exists()) { | if (f.exists()) { | ||||
f.delete(); | f.delete(); | ||||
f.createNewFile(); | f.createNewFile(); | ||||
FileOutputStream fw = new FileOutputStream(f); | FileOutputStream fw = new FileOutputStream(f); | ||||
OutputStreamWriter ow = new OutputStreamWriter(fw, "utf-8"); | OutputStreamWriter ow = new OutputStreamWriter(fw, "utf-8"); | ||||
URI inuri = unidata.resolve("Blocks.txt"); | URI inuri = unidata.resolve("Blocks.txt"); | ||||
InputStream inis = null; | InputStream inis = null; | ||||
if (scheme.equals("file")) { | if (scheme.equals("file")) { | ||||
if (j < blockNames.length) { | if (j < blockNames.length) { | ||||
continue; | continue; | ||||
} | } | ||||
int uppercode = -1, titlecode = -1; | int uppercode = -1, titlecode = -1; | ||||
if (!"".equals(fields[SIMPLE_UPPERCASE_MAPPING])) { | if (!"".equals(fields[SIMPLE_UPPERCASE_MAPPING])) { | ||||
uppercode = Integer.parseInt(fields[SIMPLE_UPPERCASE_MAPPING], 16); | uppercode = Integer.parseInt(fields[SIMPLE_UPPERCASE_MAPPING], 16); | ||||
/** | /** | ||||
* Generate classes.xml from XeTeX's Unicode letters file | * Generate classes.xml from XeTeX's Unicode letters file | ||||
* @param hexcode whether to prefix each class with the hexcode (only for debugging purposes) | * @param hexcode whether to prefix each class with the hexcode (only for debugging purposes) | ||||
* @param lettersPath path to XeTeX's Unicode letters file unicode-letters-XeTeX.tex | |||||
* @param lettersPath path to XeTeX's Unicode letters file unicode-letters-XeTeX.tex | |||||
* @param outfilePath output file | * @param outfilePath output file | ||||
* @throws IOException in case of an I/O exception | * @throws IOException in case of an I/O exception | ||||
*/ | */ | ||||
inbr.close(); | inbr.close(); | ||||
} | } | ||||
/** | /** | ||||
* @param args [--hexcode] [--java|--ucd|--tex] outfile [infile] | * @param args [--hexcode] [--java|--ucd|--tex] outfile [infile] | ||||
* @throws IOException if the input file cannot be found | * @throws IOException if the input file cannot be found | ||||
if (++i < args.length) { | if (++i < args.length) { | ||||
infile = args[i]; | infile = args[i]; | ||||
} | } | ||||
if (type.equals("java") && infile != null) { | if (type.equals("java") && infile != null) { | ||||
System.err.println("Type java does not allow an infile"); | System.err.println("Type java does not allow an infile"); | ||||
System.exit(1); | System.exit(1); |
* Write the Apache license text in various forms | * Write the Apache license text in various forms | ||||
*/ | */ | ||||
public final class License { | public final class License { | ||||
private License() { | private License() { | ||||
} | } | ||||
* The subversion Id keyword line | * The subversion Id keyword line | ||||
*/ | */ | ||||
public static final String ID = "$Id$"; | public static final String ID = "$Id$"; | ||||
/** | /** | ||||
* Calculate the maximum line length in the Apache license text | * Calculate the maximum line length in the Apache license text | ||||
* for use in formatting | |||||
* for use in formatting | |||||
*/ | */ | ||||
private static int maxLength; | private static int maxLength; | ||||
static { | static { | ||||
w.write("\n"); | w.write("\n"); | ||||
w.write("<!-- " + ID + " -->\n"); | w.write("<!-- " + ID + " -->\n"); | ||||
} | } | ||||
/** | /** | ||||
* For testing purposes | * For testing purposes | ||||
* @param args optional, --java or --xml | * @param args optional, --java or --xml |
* The encoding to use to convert to US ASCII (7 bit) | * The encoding to use to convert to US ASCII (7 bit) | ||||
*/ | */ | ||||
String US_ASCII_ENCODING = "US-ASCII"; | String US_ASCII_ENCODING = "US-ASCII"; | ||||
/** | /** | ||||
* The scaling of the default transform is set to | * The scaling of the default transform is set to | ||||
* approximately 72 user space coordinates per square inch | * approximately 72 user space coordinates per square inch | ||||
*/ | */ | ||||
int DPI_72 = 72; | int DPI_72 = 72; | ||||
/** | /** | ||||
* 72dpi in millipoints | * 72dpi in millipoints | ||||
*/ | */ |
//set color converter (i.e. an rgb to grayscale converter) | //set color converter (i.e. an rgb to grayscale converter) | ||||
graphicsObj.setColorConverter(g2d.getPaintingState().getColorConverter()); | graphicsObj.setColorConverter(g2d.getPaintingState().getColorConverter()); | ||||
// paint to graphics object | // paint to graphics object | ||||
Graphics2DImagePainter painter = graphicsObjectInfo.getPainter(); | Graphics2DImagePainter painter = graphicsObjectInfo.getPainter(); | ||||
Rectangle2D area = graphicsObjectInfo.getArea(); | Rectangle2D area = graphicsObjectInfo.getArea(); |
/** | /** | ||||
* Main constructor | * Main constructor | ||||
* | |||||
* | |||||
* @param afpFont The AFP Font | * @param afpFont The AFP Font | ||||
* @param tripletList List of font triplets to associate with this font | * @param tripletList List of font triplets to associate with this font | ||||
*/ | */ | ||||
/** | /** | ||||
* Returns the afp font | * Returns the afp font | ||||
* | |||||
* | |||||
* @return the afp font | * @return the afp font | ||||
*/ | */ | ||||
public AFPFont getAFPFont() { | public AFPFont getAFPFont() { | ||||
/** | /** | ||||
* Returns the list of font triplets associated with this font. | * Returns the list of font triplets associated with this font. | ||||
* | |||||
* | |||||
* @return List of font triplets | * @return List of font triplets | ||||
*/ | */ | ||||
public List/*<FontTriplet>*/ getFontTriplets() { | public List/*<FontTriplet>*/ getFontTriplets() { |
/** the internal graphics state */ | /** the internal graphics state */ | ||||
private static final class GraphicsState { | private static final class GraphicsState { | ||||
private GraphicsState() { | private GraphicsState() { | ||||
} | } | ||||
/** | /** | ||||
* Constructor for the Include Page Overlay | * Constructor for the Include Page Overlay | ||||
* | |||||
* | |||||
* @param overlayName Name of the page segment | * @param overlayName Name of the page segment | ||||
* @param x The x position | * @param x The x position | ||||
* @param y The y position | * @param y The y position | ||||
*/ | */ | ||||
public IncludePageOverlay(String overlayName, int x, int y, int orientation) { | public IncludePageOverlay(String overlayName, int x, int y, int orientation) { | ||||
super(overlayName); | super(overlayName); | ||||
this.x = x; | this.x = x; | ||||
this.y = y; | this.y = y; | ||||
setOrientation(orientation); | setOrientation(orientation); |
* The x position where we need to put this object on the page | * The x position where we need to put this object on the page | ||||
*/ | */ | ||||
private int x; | private int x; | ||||
/** | /** | ||||
* The y position where we need to put this object on the page | * The y position where we need to put this object on the page | ||||
*/ | */ | ||||
private int y; | private int y; | ||||
/** | /** | ||||
* Constructor for the Include Page Segment | * Constructor for the Include Page Segment | ||||
* | |||||
* | |||||
* @param name Name of the page segment | * @param name Name of the page segment | ||||
* @param x The x position | * @param x The x position | ||||
* @param y The y position | * @param y The y position | ||||
*/ | */ | ||||
public IncludePageSegment(String name, int x, int y) { | public IncludePageSegment(String name, int x, int y) { | ||||
super(name); | super(name); | ||||
this.x = x; | this.x = x; | ||||
this.y = y; | this.y = y; | ||||
} | } |
* The ASF licenses this file to You under the Apache License, Version 2.0 | * The ASF licenses this file to You under the Apache License, Version 2.0 | ||||
* (the "License"); you may not use this file except in compliance with | * (the "License"); you may not use this file except in compliance with | ||||
* the License. You may obtain a copy of the License at | * the License. You may obtain a copy of the License at | ||||
* | |||||
* | |||||
* http://www.apache.org/licenses/LICENSE-2.0 | * http://www.apache.org/licenses/LICENSE-2.0 | ||||
* | |||||
* | |||||
* Unless required by applicable law or agreed to in writing, software | * Unless required by applicable law or agreed to in writing, software | ||||
* distributed under the License is distributed on an "AS IS" BASIS, | * distributed under the License is distributed on an "AS IS" BASIS, | ||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
public class InterchangeSet { | public class InterchangeSet { | ||||
/** interchange set 1 string value */ | /** interchange set 1 string value */ | ||||
public static final String MODCA_PRESENTATION_INTERCHANGE_SET_1 = "MO:DCA-P IS/1"; | public static final String MODCA_PRESENTATION_INTERCHANGE_SET_1 = "MO:DCA-P IS/1"; | ||||
/** interchange set 2 string value */ | /** interchange set 2 string value */ | ||||
public static final String MODCA_PRESENTATION_INTERCHANGE_SET_2 = "MO:DCA-P IS/2"; | public static final String MODCA_PRESENTATION_INTERCHANGE_SET_2 = "MO:DCA-P IS/2"; | ||||
/** resource interchange set string value */ | /** resource interchange set string value */ | ||||
public static final String MODCA_RESOURCE_INTERCHANGE_SET = "MO:DCA-L"; | public static final String MODCA_RESOURCE_INTERCHANGE_SET = "MO:DCA-L"; | ||||
/** | /** | ||||
* Returns the interchange set value of a given string | * Returns the interchange set value of a given string | ||||
* | |||||
* | |||||
* @param str an interchange set value | * @param str an interchange set value | ||||
* @return an interchange set | * @return an interchange set | ||||
*/ | */ | ||||
/** | /** | ||||
* Main constructor | * Main constructor | ||||
* | |||||
* | |||||
* @param value the interchange set value | * @param value the interchange set value | ||||
*/ | */ | ||||
public InterchangeSet(int value) { | public InterchangeSet(int value) { | ||||
/** | /** | ||||
* Returns true if complies with MOD:CA interchange set 1 | * Returns true if complies with MOD:CA interchange set 1 | ||||
* | |||||
* | |||||
* @return true if complies with MOD:CA interchange set 1 | * @return true if complies with MOD:CA interchange set 1 | ||||
*/ | */ | ||||
protected boolean is1() { | protected boolean is1() { | ||||
return value == SET_1; | return value == SET_1; | ||||
} | } | ||||
/** | /** | ||||
* Returns true if complies with MOD:CA interchange set 2 | * Returns true if complies with MOD:CA interchange set 2 | ||||
* | |||||
* | |||||
* @return true if complies with MOD:CA interchange set 2 | * @return true if complies with MOD:CA interchange set 2 | ||||
*/ | */ | ||||
public boolean is2() { | public boolean is2() { | ||||
return value == SET_2; | return value == SET_2; | ||||
} | } | ||||
/** | /** | ||||
* Returns true if complies with MOD:CA resource set | * Returns true if complies with MOD:CA resource set | ||||
* | |||||
* | |||||
* @return true if complies with MOD:CA resource set | * @return true if complies with MOD:CA resource set | ||||
*/ | */ | ||||
public boolean isResource() { | public boolean isResource() { | ||||
return value == RESOURCE_SET; | return value == RESOURCE_SET; | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public String toString() { | public String toString() { | ||||
return NAMES[value]; | return NAMES[value]; | ||||
} | } | ||||
/** | /** | ||||
* Returns true if MOD:CA interchange set 2 (resource groups) is supported | * Returns true if MOD:CA interchange set 2 (resource groups) is supported | ||||
* | |||||
* | |||||
* @return true if MOD:CA interchange set 2 (resource groups) is supported | * @return true if MOD:CA interchange set 2 (resource groups) is supported | ||||
*/ | */ | ||||
public boolean supportsLevel2() { | public boolean supportsLevel2() { |
/** | /** | ||||
* Constructor for the Invoke Medium Map | * Constructor for the Invoke Medium Map | ||||
* | |||||
* | |||||
* @param name the name of the medium map | * @param name the name of the medium map | ||||
*/ | */ | ||||
public InvokeMediumMap(String name) { | public InvokeMediumMap(String name) { |
public class MapPageOverlay extends AbstractAFPObject { | public class MapPageOverlay extends AbstractAFPObject { | ||||
private static final int MAX_SIZE = 253; | private static final int MAX_SIZE = 253; | ||||
/** | /** | ||||
* The collection of overlays (maximum of 254 stored as byte[]) | * The collection of overlays (maximum of 254 stored as byte[]) | ||||
*/ | */ | ||||
} | } | ||||
return this.overLays; | return this.overLays; | ||||
} | } | ||||
/** | /** | ||||
* Add an overlay to to the map page overlay object. | * Add an overlay to to the map page overlay object. | ||||
* | * |
* The ASF licenses this file to You under the Apache License, Version 2.0 | * The ASF licenses this file to You under the Apache License, Version 2.0 | ||||
* (the "License"); you may not use this file except in compliance with | * (the "License"); you may not use this file except in compliance with | ||||
* the License. You may obtain a copy of the License at | * the License. You may obtain a copy of the License at | ||||
* | |||||
* | |||||
* http://www.apache.org/licenses/LICENSE-2.0 | * http://www.apache.org/licenses/LICENSE-2.0 | ||||
* | |||||
* | |||||
* Unless required by applicable law or agreed to in writing, software | * Unless required by applicable law or agreed to in writing, software | ||||
* distributed under the License is distributed on an "AS IS" BASIS, | * distributed under the License is distributed on an "AS IS" BASIS, | ||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
public class PageSegment extends AbstractNamedAFPObject { | public class PageSegment extends AbstractNamedAFPObject { | ||||
private List/*<AbstractAFPObject>*/ objects = null; | private List/*<AbstractAFPObject>*/ objects = null; | ||||
/** | /** | ||||
* Main constructor | * Main constructor | ||||
* | |||||
* | |||||
* @param name the name of this object | * @param name the name of this object | ||||
*/ | */ | ||||
public PageSegment(String name) { | public PageSegment(String name) { | ||||
/** | /** | ||||
* Returns a list of objects contained withing this page segment | * Returns a list of objects contained withing this page segment | ||||
* | |||||
* | |||||
* @return a list of objects contained within this page segment | * @return a list of objects contained within this page segment | ||||
*/ | */ | ||||
public List/*<AbstractAFPObject>*/ getObjects() { | public List/*<AbstractAFPObject>*/ getObjects() { | ||||
/** | /** | ||||
* Adds a resource object (image/graphic) to this page segment | * Adds a resource object (image/graphic) to this page segment | ||||
* | |||||
* | |||||
* @param object the resource objec to add to this page segment | * @param object the resource objec to add to this page segment | ||||
*/ | */ | ||||
public void addObject(AbstractAFPObject object) { | public void addObject(AbstractAFPObject object) { | ||||
getObjects().add(object); | getObjects().add(object); | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
protected void writeStart(OutputStream os) throws IOException { | protected void writeStart(OutputStream os) throws IOException { | ||||
byte[] data = new byte[17]; | byte[] data = new byte[17]; | ||||
copySF(data, Type.END, Category.PAGE_SEGMENT); | copySF(data, Type.END, Category.PAGE_SEGMENT); | ||||
os.write(data); | os.write(data); | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public String toString() { | public String toString() { | ||||
return this.name; | return this.name; |
FullyQualifiedNameTriplet.FORMAT_CHARSTR, | FullyQualifiedNameTriplet.FORMAT_CHARSTR, | ||||
name); | name); | ||||
setAttributeValue(value); | setAttributeValue(value); | ||||
setAttributeQualifier(tleID, 1); | |||||
setAttributeQualifier(tleID, 1); | |||||
byte[] data = new byte[SF_HEADER.length]; | byte[] data = new byte[SF_HEADER.length]; | ||||
copySF(data, Type.ATTRIBUTE, Category.PROCESS_ELEMENT); | copySF(data, Type.ATTRIBUTE, Category.PROCESS_ELEMENT); | ||||
int tripletDataLength = getTripletDataLength(); | int tripletDataLength = getTripletDataLength(); | ||||
byte[] l = BinaryUtils.convert(data.length + tripletDataLength - 1, 2); | byte[] l = BinaryUtils.convert(data.length + tripletDataLength - 1, 2); | ||||
data[1] = l[0]; | data[1] = l[0]; |
/** | /** | ||||
* Constructor for the TagLogicalElementBean. | * Constructor for the TagLogicalElementBean. | ||||
* | |||||
* | |||||
* @param key the key attribute | * @param key the key attribute | ||||
* @param value the value attribute | * @param value the value attribute | ||||
*/ | */ | ||||
/** | /** | ||||
* Getter for the key attribute. | * Getter for the key attribute. | ||||
* | |||||
* | |||||
* @return the key | * @return the key | ||||
*/ | */ | ||||
public String getKey() { | public String getKey() { | ||||
/** | /** | ||||
* Getter for the value attribute. | * Getter for the value attribute. | ||||
* | |||||
* | |||||
* @return the value | * @return the value | ||||
*/ | */ | ||||
public String getValue() { | public String getValue() { |
* page-number or a page-number-citation is resolved | * page-number or a page-number-citation is resolved | ||||
*/ | */ | ||||
private final class LineAdjustingInfo implements Serializable { | private final class LineAdjustingInfo implements Serializable { | ||||
private static final long serialVersionUID = -6103629976229458273L; | private static final long serialVersionUID = -6103629976229458273L; | ||||
private int lineAlignment; | private int lineAlignment; |
public static final Integer OVERLINE_COLOR = new Integer(35); | public static final Integer OVERLINE_COLOR = new Integer(35); | ||||
/** Trait for color of linethrough decorations when rendering inline parent. */ | /** Trait for color of linethrough decorations when rendering inline parent. */ | ||||
public static final Integer LINETHROUGH_COLOR = new Integer(36); | public static final Integer LINETHROUGH_COLOR = new Integer(36); | ||||
/** The ptr trait. Used for accessibility */ | /** The ptr trait. Used for accessibility */ | ||||
public static final Integer PTR = new Integer(37); | public static final Integer PTR = new Integer(37); | ||||
private static final long serialVersionUID = 4800834714349695386L; | private static final long serialVersionUID = 4800834714349695386L; | ||||
private String url; | private String url; | ||||
/** | /** | ||||
* Create a new image with the given url. | * Create a new image with the given url. | ||||
* | * |
* The ASF licenses this file to You under the Apache License, Version 2.0 | * The ASF licenses this file to You under the Apache License, Version 2.0 | ||||
* (the "License"); you may not use this file except in compliance with | * (the "License"); you may not use this file except in compliance with | ||||
* the License. You may obtain a copy of the License at | * the License. You may obtain a copy of the License at | ||||
* | |||||
* | |||||
* http://www.apache.org/licenses/LICENSE-2.0 | * http://www.apache.org/licenses/LICENSE-2.0 | ||||
* | |||||
* | |||||
* Unless required by applicable law or agreed to in writing, software | * Unless required by applicable law or agreed to in writing, software | ||||
* distributed under the License is distributed on an "AS IS" BASIS, | * distributed under the License is distributed on an "AS IS" BASIS, | ||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
/** @return the "break-before" property. */ | /** @return the "break-before" property. */ | ||||
int getBreakBefore(); | int getBreakBefore(); | ||||
} | } |
* Window - Preferences - Java - Code Generation - Code and Comments | * Window - Preferences - Java - Code Generation - Code and Comments | ||||
*/ | */ | ||||
public class DimensionPropertyMaker extends CorrespondingPropertyMaker { | public class DimensionPropertyMaker extends CorrespondingPropertyMaker { | ||||
private int[][] extraCorresponding = null; | private int[][] extraCorresponding = null; | ||||
/** | /** |
import org.apache.fop.fonts.autodetect.FontInfoFinder; | import org.apache.fop.fonts.autodetect.FontInfoFinder; | ||||
/** | /** | ||||
* Adds a list of fonts to a given font info list | |||||
* Adds a list of fonts to a given font info list | |||||
*/ | */ | ||||
public class FontAdder { | public class FontAdder { | ||||
private FontEventListener listener; | private FontEventListener listener; | ||||
this.resolver = resolver; | this.resolver = resolver; | ||||
this.listener = listener; | this.listener = listener; | ||||
} | } | ||||
/** | /** | ||||
* Iterates over font url list adding to font info list | * Iterates over font url list adding to font info list | ||||
* @param fontURLList font file list | * @param fontURLList font file list |
/** | /** | ||||
* Returns the default font cache file. | * Returns the default font cache file. | ||||
* | |||||
* | |||||
* @param forWriting | * @param forWriting | ||||
* true if the user directory should be created | * true if the user directory should be created | ||||
* @return the default font cache file | * @return the default font cache file | ||||
/** | /** | ||||
* Reads the default font cache file and returns its contents. | * Reads the default font cache file and returns its contents. | ||||
* | |||||
* | |||||
* @return the font cache deserialized from the file (or null if no cache | * @return the font cache deserialized from the file (or null if no cache | ||||
* file exists or if it could not be read) | * file exists or if it could not be read) | ||||
*/ | */ | ||||
/** | /** | ||||
* Reads a font cache file and returns its contents. | * Reads a font cache file and returns its contents. | ||||
* | |||||
* | |||||
* @param cacheFile | * @param cacheFile | ||||
* the cache file | * the cache file | ||||
* @return the font cache deserialized from the file (or null if no cache | * @return the font cache deserialized from the file (or null if no cache | ||||
/** | /** | ||||
* Writes the font cache to disk. | * Writes the font cache to disk. | ||||
* | |||||
* | |||||
* @throws FOPException | * @throws FOPException | ||||
* fop exception | * fop exception | ||||
*/ | */ | ||||
/** | /** | ||||
* Writes the font cache to disk. | * Writes the font cache to disk. | ||||
* | |||||
* | |||||
* @param cacheFile | * @param cacheFile | ||||
* the file to write to | * the file to write to | ||||
* @throws FOPException | * @throws FOPException | ||||
/** | /** | ||||
* creates a key given a font info for the font mapping | * creates a key given a font info for the font mapping | ||||
* | |||||
* | |||||
* @param fontInfo | * @param fontInfo | ||||
* font info | * font info | ||||
* @return font cache key | * @return font cache key | ||||
/** | /** | ||||
* cache has been updated since it was read | * cache has been updated since it was read | ||||
* | |||||
* | |||||
* @return if this cache has changed | * @return if this cache has changed | ||||
*/ | */ | ||||
public boolean hasChanged() { | public boolean hasChanged() { | ||||
/** | /** | ||||
* is this font in the cache? | * is this font in the cache? | ||||
* | |||||
* | |||||
* @param embedUrl | * @param embedUrl | ||||
* font info | * font info | ||||
* @return boolean | * @return boolean | ||||
/** | /** | ||||
* is this font info in the cache? | * is this font info in the cache? | ||||
* | |||||
* | |||||
* @param fontInfo | * @param fontInfo | ||||
* font info | * font info | ||||
* @return font | * @return font | ||||
/** | /** | ||||
* Tries to identify a File instance from an array of URLs. If there's no | * Tries to identify a File instance from an array of URLs. If there's no | ||||
* file URL in the array, the method returns null. | * file URL in the array, the method returns null. | ||||
* | |||||
* | |||||
* @param urls | * @param urls | ||||
* array of possible font urls | * array of possible font urls | ||||
* @return file font file | * @return file font file | ||||
/** | /** | ||||
* Adds a font info to cache | * Adds a font info to cache | ||||
* | |||||
* | |||||
* @param fontInfo | * @param fontInfo | ||||
* font info | * font info | ||||
*/ | */ | ||||
/** | /** | ||||
* Returns a font from the cache. | * Returns a font from the cache. | ||||
* | |||||
* | |||||
* @param embedUrl | * @param embedUrl | ||||
* font info | * font info | ||||
* @return CachedFontFile object | * @return CachedFontFile object | ||||
* Returns the EmbedFontInfo instances belonging to a font file. If the font | * Returns the EmbedFontInfo instances belonging to a font file. If the font | ||||
* file was modified since it was cached the entry is removed and null is | * file was modified since it was cached the entry is removed and null is | ||||
* returned. | * returned. | ||||
* | |||||
* | |||||
* @param embedUrl | * @param embedUrl | ||||
* the font URL | * the font URL | ||||
* @param lastModified | * @param lastModified | ||||
/** | /** | ||||
* removes font from cache | * removes font from cache | ||||
* | |||||
* | |||||
* @param embedUrl | * @param embedUrl | ||||
* embed url | * embed url | ||||
*/ | */ | ||||
/** | /** | ||||
* has this font previously failed to load? | * has this font previously failed to load? | ||||
* | |||||
* | |||||
* @param embedUrl | * @param embedUrl | ||||
* embed url | * embed url | ||||
* @param lastModified | * @param lastModified | ||||
/** | /** | ||||
* Registers a failed font with the cache | * Registers a failed font with the cache | ||||
* | |||||
* | |||||
* @param embedUrl | * @param embedUrl | ||||
* embed url | * embed url | ||||
* @param lastModified | * @param lastModified | ||||
/** | /** | ||||
* Retrieve the last modified date/time of a URL. | * Retrieve the last modified date/time of a URL. | ||||
* | |||||
* | |||||
* @param url | * @param url | ||||
* the URL | * the URL | ||||
* @return the last modified date/time | * @return the last modified date/time | ||||
/** | /** | ||||
* Gets the modified timestamp for font file (not always available) | * Gets the modified timestamp for font file (not always available) | ||||
* | |||||
* | |||||
* @return modified timestamp | * @return modified timestamp | ||||
*/ | */ | ||||
public long lastModified() { | public long lastModified() { | ||||
/** | /** | ||||
* Gets the modified timestamp for font file (used for the purposes of | * Gets the modified timestamp for font file (used for the purposes of | ||||
* font info caching) | * font info caching) | ||||
* | |||||
* | |||||
* @param lastModified | * @param lastModified | ||||
* modified font file timestamp | * modified font file timestamp | ||||
*/ | */ |
private static final String[] FONT_MIMETYPES = { | private static final String[] FONT_MIMETYPES = { | ||||
"application/x-font", "application/x-font-truetype" | "application/x-font", "application/x-font-truetype" | ||||
}; | }; | ||||
private FontManager fontManager; | private FontManager fontManager; | ||||
private FontAdder fontAdder; | private FontAdder fontAdder; | ||||
private boolean strict; | private boolean strict; | ||||
List/*<URL>*/ fontURLList = fontFileFinder.find( | List/*<URL>*/ fontURLList = fontFileFinder.find( | ||||
fontBase.getAbsolutePath()); | fontBase.getAbsolutePath()); | ||||
fontAdder.add(fontURLList, fontInfoList); | fontAdder.add(fontURLList, fontInfoList); | ||||
//Can only use the font base URL if it's a file URL | //Can only use the font base URL if it's a file URL | ||||
} | } | ||||
} catch (IOException e) { | } catch (IOException e) { |
} | } | ||||
return fontCache; | return fontCache; | ||||
} | } | ||||
/** | /** | ||||
* Saves the FontCache as necessary | * Saves the FontCache as necessary | ||||
* | |||||
* @throws FOPException fop exception | |||||
* | |||||
* @throws FOPException fop exception | |||||
*/ | */ | ||||
public void saveCache() throws FOPException { | public void saveCache() throws FOPException { | ||||
if (useCache) { | if (useCache) { |
// global font configuration | // global font configuration | ||||
Configuration fontsCfg = cfg.getChild("fonts", false); | Configuration fontsCfg = cfg.getChild("fonts", false); | ||||
if (fontsCfg != null) { | if (fontsCfg != null) { | ||||
// font substitution | // font substitution | ||||
Configuration substitutionsCfg = fontsCfg.getChild("substitutions", false); | Configuration substitutionsCfg = fontsCfg.getChild("substitutions", false); | ||||
if (substitutionsCfg != null) { | if (substitutionsCfg != null) { |
} | } | ||||
} | } | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public String toString() { | public String toString() { | ||||
return getFullName(); | return getFullName(); | ||||
} | |||||
} | |||||
} | } |
* @param lang the language | * @param lang the language | ||||
* @param country the country (may be null or "none") | * @param country the country (may be null or "none") | ||||
* @param hyphPatNames the map of user-configured hyphenation pattern file names | * @param hyphPatNames the map of user-configured hyphenation pattern file names | ||||
* @return the hyphenation pattern file name or null | |||||
* @return the hyphenation pattern file name or null | |||||
*/ | */ | ||||
public static String constructUserKey(String lang, String country, Map hyphPatNames) { | public static String constructUserKey(String lang, String country, Map hyphPatNames) { | ||||
String userKey = null; | String userKey = null; | ||||
} | } | ||||
return userKey; | return userKey; | ||||
} | } | ||||
/** | /** | ||||
* Cache a hyphenation tree under its key. | * Cache a hyphenation tree under its key. | ||||
* @param key the key (ex. "de_CH" or "en") | * @param key the key (ex. "de_CH" or "en") |
parser = mainParser; | parser = mainParser; | ||||
} | } | ||||
} | } | ||||
// | // | ||||
// ContentHandler methods | // ContentHandler methods | ||||
// | // | ||||
/** | /** | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
* @throws SAXException | |||||
* @throws SAXException | |||||
*/ | */ | ||||
public void startElement(String uri, String local, String raw, | public void startElement(String uri, String local, String raw, | ||||
Attributes attrs) throws SAXException { | Attributes attrs) throws SAXException { | ||||
public void addPattern(String p, String v) { | public void addPattern(String p, String v) { | ||||
testOut.println("pattern: " + p + " : " + v); | testOut.println("pattern: " + p + " : " + v); | ||||
} | } | ||||
private PrintStream testOut = System.out; | private PrintStream testOut = System.out; | ||||
/** | /** | ||||
* Set test out stream. | * Set test out stream. | ||||
* @param testOut the testOut to set | * @param testOut the testOut to set | ||||
public void setTestOut(PrintStream testOut) { | public void setTestOut(PrintStream testOut) { | ||||
this.testOut = testOut; | this.testOut = testOut; | ||||
} | } | ||||
/** | /** | ||||
* Close test out file. | * Close test out file. | ||||
*/ | */ | ||||
} | } | ||||
} | } | ||||
} | } |
/** | /** | ||||
* Serialize hyphenation patterns | * Serialize hyphenation patterns | ||||
* For all xml files in the source directory a pattern file is built in the target directory | * For all xml files in the source directory a pattern file is built in the target directory | ||||
* This class may be called from the ant build file in a java task | |||||
* This class may be called from the ant build file in a java task | |||||
*/ | */ | ||||
public class SerializeHyphPattern { | public class SerializeHyphPattern { | ||||
private boolean errorDump = false; | private boolean errorDump = false; | ||||
/** | /** |
/** Holder for symbolic literals for the fitness classes */ | /** Holder for symbolic literals for the fitness classes */ | ||||
static final class FitnessClasses { | static final class FitnessClasses { | ||||
private FitnessClasses() { | private FitnessClasses() { | ||||
} | } | ||||
* @param ipd inline progression dimension | * @param ipd inline progression dimension | ||||
* @param bHyph true if hyphenated | * @param bHyph true if hyphenated | ||||
* @param alignmentContext an alignment context | * @param alignmentContext an alignment context | ||||
*/ | |||||
*/ | |||||
public AreaInfo(short iLS, MinOptMax ipd, boolean bHyph, | public AreaInfo(short iLS, MinOptMax ipd, boolean bHyph, | ||||
AlignmentContext alignmentContext) { | AlignmentContext alignmentContext) { | ||||
iLScount = iLS; | iLScount = iLS; |
* identical, this method is not required to check everything. In the case | * identical, this method is not required to check everything. In the case | ||||
* of PDFObjects, this means that the overriding function does not have to | * of PDFObjects, this means that the overriding function does not have to | ||||
* check for {@link #getObjectID()}. | * check for {@link #getObjectID()}. | ||||
* | |||||
* | |||||
* @param o | * @param o | ||||
* object to compare to. | * object to compare to. | ||||
* @return true if the other object has the same content. | * @return true if the other object has the same content. |
protected static final Log log = LogFactory.getLog(AbstractConfigurator.class); | protected static final Log log = LogFactory.getLog(AbstractConfigurator.class); | ||||
private static final String MIME = "mime"; | private static final String MIME = "mime"; | ||||
/** fop factory configuration */ | /** fop factory configuration */ | ||||
protected FOUserAgent userAgent = null; | protected FOUserAgent userAgent = null; | ||||
public static DummyPercentBaseContext getInstance() { | public static DummyPercentBaseContext getInstance() { | ||||
return singleton; | return singleton; | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public int getBaseLength(int lengthBase, FObj fo) { | public int getBaseLength(int lengthBase, FObj fo) { | ||||
return 0; | return 0; |
super.startOfNode(); | super.startOfNode(); | ||||
if (parent.getNameId() != Constants.FO_PAGE_SEQUENCE | if (parent.getNameId() != Constants.FO_PAGE_SEQUENCE | ||||
&& parent.getNameId() != Constants.FO_SIMPLE_PAGE_MASTER) { | && parent.getNameId() != Constants.FO_SIMPLE_PAGE_MASTER) { | ||||
invalidChildError(getLocator(), parent.getName(), getNamespaceURI(), getName(), | invalidChildError(getLocator(), parent.getName(), getNamespaceURI(), getName(), | ||||
"rule.childOfPageSequence"); | "rule.childOfPageSequence"); | ||||
} | } |
* <p> | * <p> | ||||
* This function will always return a valid value for safety. Use | * This function will always return a valid value for safety. Use | ||||
* {@link #isComplete()} to check if the link is actually complete. | * {@link #isComplete()} to check if the link is actually complete. | ||||
* | |||||
* | |||||
* @return the page index (0-based) | * @return the page index (0-based) | ||||
*/ | */ | ||||
public int getPageIndex() { | public int getPageIndex() { | ||||
* <p> | * <p> | ||||
* This function will always return a valid value for safety. Use | * This function will always return a valid value for safety. Use | ||||
* {@link #isComplete()} to check if the link is actually complete. | * {@link #isComplete()} to check if the link is actually complete. | ||||
* | |||||
* | |||||
* @return the target location (coordinates in millipoints) | * @return the target location (coordinates in millipoints) | ||||
*/ | */ | ||||
public Point getTargetLocation() { | public Point getTargetLocation() { | ||||
private boolean isCompleteExceptTargetLocation() { | private boolean isCompleteExceptTargetLocation() { | ||||
return (getPageIndex() >= 0); | return (getPageIndex() >= 0); | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public boolean isComplete() { | public boolean isComplete() { | ||||
return this.isCompleteExceptTargetLocation() && (this.targetLocation != null); | return this.isCompleteExceptTargetLocation() && (this.targetLocation != null); | ||||
atts.addAttribute(null, "id", "id", XMLUtil.CDATA, getID()); | atts.addAttribute(null, "id", "id", XMLUtil.CDATA, getID()); | ||||
atts.addAttribute(null, "page-index", "page-index", | atts.addAttribute(null, "page-index", "page-index", | ||||
XMLUtil.CDATA, Integer.toString(pageIndex)); | XMLUtil.CDATA, Integer.toString(pageIndex)); | ||||
atts.addAttribute(null, "x", "x", XMLUtil.CDATA, | |||||
atts.addAttribute(null, "x", "x", XMLUtil.CDATA, | |||||
Integer.toString(reportedTargetLocation.x)); | Integer.toString(reportedTargetLocation.x)); | ||||
atts.addAttribute(null, "y", "y", XMLUtil.CDATA, | |||||
atts.addAttribute(null, "y", "y", XMLUtil.CDATA, | |||||
Integer.toString(reportedTargetLocation.y)); | Integer.toString(reportedTargetLocation.y)); | ||||
} else { | } else { | ||||
atts.addAttribute(null, "idref", "idref", XMLUtil.CDATA, getID()); | atts.addAttribute(null, "idref", "idref", XMLUtil.CDATA, getID()); |
// sRGB hasn't been set up for the PDF document | // sRGB hasn't been set up for the PDF document | ||||
// so install but don't set to DefaultRGB | // so install but don't set to DefaultRGB | ||||
cs = PDFICCBasedColorSpace.setupsRGBColorSpace(doc); | cs = PDFICCBasedColorSpace.setupsRGBColorSpace(doc); | ||||
} | |||||
} | |||||
pdfICCStream = cs.getICCStream(); | pdfICCStream = cs.getICCStream(); | ||||
} | } | ||||
return pdfICCStream; | return pdfICCStream; |
userAgent.getFactory().getImageManager(), | userAgent.getFactory().getImageManager(), | ||||
userAgent.getImageSessionContext(), | userAgent.getImageSessionContext(), | ||||
new AffineTransform()); | new AffineTransform()); | ||||
//Cloning SVG DOM as Batik attaches non-thread-safe facilities (like the CSS engine) | //Cloning SVG DOM as Batik attaches non-thread-safe facilities (like the CSS engine) | ||||
//to it. | //to it. | ||||
Document clonedDoc = BatikUtil.cloneSVGDocument(imageSVG.getDocument()); | Document clonedDoc = BatikUtil.cloneSVGDocument(imageSVG.getDocument()); |
/** Provider class for the event producer. */ | /** Provider class for the event producer. */ | ||||
final class Provider { | final class Provider { | ||||
private Provider() { | private Provider() { | ||||
} | } | ||||
public static final String FOOTERY = "footery"; | public static final String FOOTERY = "footery"; | ||||
/** constant for itap level */ | /** constant for itap level */ | ||||
public static final String ITAP = "itap"; | public static final String ITAP = "itap"; | ||||
/** String array of RtfPage attributes */ | /** String array of RtfPage attributes */ | ||||
public static final String[] PAGE_ATTR = new String[]{ | public static final String[] PAGE_ATTR = new String[]{ | ||||
PAGE_WIDTH, PAGE_HEIGHT, LANDSCAPE, MARGIN_TOP, MARGIN_BOTTOM, | PAGE_WIDTH, PAGE_HEIGHT, LANDSCAPE, MARGIN_TOP, MARGIN_BOTTOM, |
return result; | return result; | ||||
} | } | ||||
/** | |||||
/** | |||||
* Push an RtfContainer on our stack. | * Push an RtfContainer on our stack. | ||||
* @param c the container | * @param c the container | ||||
*/ | */ |
super(name); | super(name); | ||||
} | } | ||||
/** | |||||
/** | |||||
* @param key a key | * @param key a key | ||||
* @return an mif element | * @return an mif element | ||||
*/ | */ |