git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1036179 13f79535-47bb-0310-9956-ffa450edef68tags/fop-1_1rc1old
<property name="severity" value="warning"/> | <property name="severity" value="warning"/> | ||||
</module> | </module> | ||||
<module name="ConstantNameCheck"> | <module name="ConstantNameCheck"> | ||||
<property name="format" value="^[A-Z](_?[A-Z0-9]+)*$"/> | |||||
<property name="format" value="^([A-Z](_?[A-Z0-9]+)*)|(log)$"/> | |||||
<property name="severity" value="warning"/> | <property name="severity" value="warning"/> | ||||
</module> | </module> | ||||
<module name="LocalFinalVariableNameCheck"> | <module name="LocalFinalVariableNameCheck"> |
for (java.util.Iterator it = pageSequences.iterator(); it.hasNext();) { | for (java.util.Iterator it = pageSequences.iterator(); it.hasNext();) { | ||||
PageSequenceResults pageSequenceResults = (PageSequenceResults)it.next(); | PageSequenceResults pageSequenceResults = (PageSequenceResults)it.next(); | ||||
System.out.println("PageSequence " | System.out.println("PageSequence " | ||||
+ (String.valueOf(pageSequenceResults.getID()).length() > 0 | |||||
? pageSequenceResults.getID() : "<no id>") | |||||
+ (String.valueOf(pageSequenceResults.getId()).length() > 0 | |||||
? pageSequenceResults.getId() : "<no id>") | |||||
+ " generated " + pageSequenceResults.getPageCount() + " pages."); | + " generated " + pageSequenceResults.getPageCount() + " pages."); | ||||
} | } | ||||
System.out.println("Generated " + foResults.getPageCount() + " pages in total."); | System.out.println("Generated " + foResults.getPageCount() + " pages in total."); |
for (java.util.Iterator it = pageSequences.iterator(); it.hasNext();) { | for (java.util.Iterator it = pageSequences.iterator(); it.hasNext();) { | ||||
PageSequenceResults pageSequenceResults = (PageSequenceResults)it.next(); | PageSequenceResults pageSequenceResults = (PageSequenceResults)it.next(); | ||||
System.out.println("PageSequence " | System.out.println("PageSequence " | ||||
+ (String.valueOf(pageSequenceResults.getID()).length() > 0 | |||||
? pageSequenceResults.getID() : "<no id>") | |||||
+ (String.valueOf(pageSequenceResults.getId()).length() > 0 | |||||
? pageSequenceResults.getId() : "<no id>") | |||||
+ " generated " + pageSequenceResults.getPageCount() + " pages."); | + " generated " + pageSequenceResults.getPageCount() + " pages."); | ||||
} | } | ||||
System.out.println("Generated " + foResults.getPageCount() + " pages in total."); | System.out.println("Generated " + foResults.getPageCount() + " pages in total."); |
public abstract class AbstractAFPPainter { | public abstract class AbstractAFPPainter { | ||||
/** Static logging instance */ | /** Static logging instance */ | ||||
protected static Log log = LogFactory.getLog("org.apache.xmlgraphics.afp"); | |||||
protected static final Log log = LogFactory.getLog("org.apache.xmlgraphics.afp"); | |||||
/** data stream */ | /** data stream */ | ||||
protected final DataStream dataStream; | protected final DataStream dataStream; |
protected static final byte SF_CLASS = (byte)0xD3; | protected static final byte SF_CLASS = (byte)0xD3; | ||||
/** the structure field header */ | /** the structure field header */ | ||||
protected static final byte[] SF_HEADER = new byte[] { | |||||
static final byte[] SF_HEADER = new byte[] { | |||||
0x5A, // Structured field identifier | 0x5A, // Structured field identifier | ||||
0x00, // Length byte 1 | 0x00, // Length byte 1 | ||||
0x10, // Length byte 2 | 0x10, // Length byte 2 |
* | * | ||||
* @return The ID | * @return The ID | ||||
*/ | */ | ||||
public String getID() { | |||||
public String getId() { | |||||
return this.id; | return this.id; | ||||
} | } | ||||
* Base object for all areas. | * Base object for all areas. | ||||
*/ | */ | ||||
public class Area extends AreaTreeObject implements Serializable { | public class Area extends AreaTreeObject implements Serializable { | ||||
private static final long serialVersionUID = 6342888466142626492L; | |||||
// stacking directions | // stacking directions | ||||
/** | /** | ||||
* Stacking left to right | * Stacking left to right | ||||
/** | /** | ||||
* logging instance | * logging instance | ||||
*/ | */ | ||||
protected static Log log = LogFactory.getLog(Area.class); | |||||
protected static final Log log = LogFactory.getLog(Area.class); | |||||
/** | /** |
protected PageSequence currentPageSequence; | protected PageSequence currentPageSequence; | ||||
// private List offDocumentItems = new java.util.ArrayList(); | // private List offDocumentItems = new java.util.ArrayList(); | ||||
/** logger instance */ | /** logger instance */ | ||||
protected static Log log = LogFactory.getLog(AreaTreeModel.class); | |||||
protected static final Log log = LogFactory.getLog(AreaTreeModel.class); | |||||
/** | /** | ||||
* Create a new store pages model | * Create a new store pages model |
public class AreaTreeParser { | public class AreaTreeParser { | ||||
/** Logger instance */ | /** Logger instance */ | ||||
protected static Log log = LogFactory.getLog(AreaTreeParser.class); | |||||
protected static final Log log = LogFactory.getLog(AreaTreeParser.class); | |||||
private static SAXTransformerFactory tFactory | private static SAXTransformerFactory tFactory | ||||
= (SAXTransformerFactory)SAXTransformerFactory.newInstance(); | = (SAXTransformerFactory)SAXTransformerFactory.newInstance(); |
* See fo:region-body definition in the XSL Rec for more information. | * See fo:region-body definition in the XSL Rec for more information. | ||||
*/ | */ | ||||
public class BeforeFloat extends BlockParent { | public class BeforeFloat extends BlockParent { | ||||
private static final long serialVersionUID = 4101415711488333380L; | |||||
// this is an optional block area that will be rendered | // this is an optional block area that will be rendered | ||||
// as the separator only if there are float areas | // as the separator only if there are float areas | ||||
private Block separator = null; | private Block separator = null; |
* It holds child block areas such as other blocks or lines. | * It holds child block areas such as other blocks or lines. | ||||
*/ | */ | ||||
public class Block extends BlockParent { | public class Block extends BlockParent { | ||||
private static final long serialVersionUID = 6843727817993665788L; | |||||
/** | /** | ||||
* Normally stacked with other blocks. | * Normally stacked with other blocks. | ||||
*/ | */ |
*/ | */ | ||||
public class BlockParent extends Area { | public class BlockParent extends Area { | ||||
/** | |||||
* | |||||
*/ | |||||
private static final long serialVersionUID = 7076916890348533805L; | |||||
// this position is used for absolute position | // this position is used for absolute position | ||||
// or as an indent | // or as an indent | ||||
// this has the size in the block progression dimension | // this has the size in the block progression dimension |
* The block-container creates this area. | * The block-container creates this area. | ||||
*/ | */ | ||||
public class BlockViewport extends Block { | public class BlockViewport extends Block { | ||||
private static final long serialVersionUID = -7840580922580735157L; | |||||
// clipping for this viewport | // clipping for this viewport | ||||
private boolean clip = false; | private boolean clip = false; | ||||
// transform if rotated or absolute | // transform if rotated or absolute |
* See fo:region-body definition in the XSL Rec for more information. | * See fo:region-body definition in the XSL Rec for more information. | ||||
*/ | */ | ||||
public class BodyRegion extends RegionReference { | public class BodyRegion extends RegionReference { | ||||
private static final long serialVersionUID = -1848872997724078080L; | |||||
private BeforeFloat beforeFloat; // optional | private BeforeFloat beforeFloat; // optional | ||||
private MainReference mainReference; // mandatory | private MainReference mainReference; // mandatory | ||||
private Footnote footnote; // optional | private Footnote footnote; // optional |
*/ | */ | ||||
public class CTM implements Serializable { | public class CTM implements Serializable { | ||||
private static final long serialVersionUID = -8743287485623778341L; | |||||
private double a, b, c, d, e, f; | private double a, b, c, d, e, f; | ||||
private static final CTM CTM_LRTB = new CTM(1, 0, 0, 1, 0, 0); | private static final CTM CTM_LRTB = new CTM(1, 0, 0, 1, 0, 0); |
* See fo:region-body definition in the XSL Rec for more information. | * See fo:region-body definition in the XSL Rec for more information. | ||||
*/ | */ | ||||
public class Footnote extends BlockParent { | public class Footnote extends BlockParent { | ||||
private static final long serialVersionUID = -7907428219886367161L; | |||||
private Block separator = null; | private Block separator = null; | ||||
// footnote has an optional separator | // footnote has an optional separator |
*/ | */ | ||||
public class LineArea extends Area { | public class LineArea extends Area { | ||||
private static final long serialVersionUID = 7670235908329290684L; | |||||
/** | /** | ||||
* this class stores information about line width and potential adjustments | * this class stores information about line width and potential adjustments | ||||
* that can be used in order to re-compute adjustement and / or indents when a | * that can be used in order to re-compute adjustement and / or indents when a | ||||
* 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 int lineAlignment; | private int lineAlignment; | ||||
private int difference; | private int difference; | ||||
private int availableStretch; | private int availableStretch; |
* Link resolving for resolving internal links. | * Link resolving for resolving internal links. | ||||
*/ | */ | ||||
public class LinkResolver implements Resolvable, Serializable { | public class LinkResolver implements Resolvable, Serializable { | ||||
private static final long serialVersionUID = -7102134165192960718L; | |||||
private boolean resolved = false; | private boolean resolved = false; | ||||
private String idRef; | private String idRef; | ||||
private Area area; | private Area area; |
*/ | */ | ||||
public class MainReference extends Area { | public class MainReference extends Area { | ||||
private static final long serialVersionUID = 7635126485620012448L; | |||||
private BodyRegion parent; | private BodyRegion parent; | ||||
private List spanAreas = new java.util.ArrayList(); | private List spanAreas = new java.util.ArrayList(); | ||||
private boolean isEmpty = true; | private boolean isEmpty = true; |
* See fo:region-body definition in the XSL Rec for more information. | * See fo:region-body definition in the XSL Rec for more information. | ||||
*/ | */ | ||||
public class NormalFlow extends BlockParent { | public class NormalFlow extends BlockParent { | ||||
private static final long serialVersionUID = -3753538631016929004L; | |||||
/** | /** | ||||
* Constructor. | * Constructor. | ||||
* @param ipd of Normal flow object | * @param ipd of Normal flow object |
* the top level page and regions. | * the top level page and regions. | ||||
*/ | */ | ||||
public class Page extends AreaTreeObject implements Serializable, Cloneable { | public class Page extends AreaTreeObject implements Serializable, Cloneable { | ||||
private static final long serialVersionUID = 6272157047421543866L; | |||||
// contains before, start, body, end and after regions | // contains before, start, body, end and after regions | ||||
private RegionViewport regionBefore = null; | private RegionViewport regionBefore = null; | ||||
private RegionViewport regionStart = null; | private RegionViewport regionStart = null; |
/** | /** | ||||
* logging instance | * logging instance | ||||
*/ | */ | ||||
protected static Log log = LogFactory.getLog(PageViewport.class); | |||||
protected static final Log log = LogFactory.getLog(PageViewport.class); | |||||
/** | /** | ||||
* Create a page viewport. | * Create a page viewport. |
*/ | */ | ||||
public class RegionReference extends Area implements Cloneable { | public class RegionReference extends Area implements Cloneable { | ||||
private static final long serialVersionUID = -298980963268244238L; | |||||
/** Reference to the region FO. */ | /** Reference to the region FO. */ | ||||
//protected Region regionFO; | //protected Region regionFO; | ||||
private int regionClass; | private int regionClass; | ||||
private String regionName; | private String regionName; | ||||
private CTM ctm; | private CTM ctm; | ||||
// the list of block areas from the static flow | // the list of block areas from the static flow | ||||
private ArrayList blocks = new ArrayList(); | private ArrayList blocks = new ArrayList(); | ||||
* in the fo:region-body description in the XSL Recommendation. | * in the fo:region-body description in the XSL Recommendation. | ||||
*/ | */ | ||||
public class RegionViewport extends Area implements Cloneable { | public class RegionViewport extends Area implements Cloneable { | ||||
private static final long serialVersionUID = 505781815165102572L; | |||||
// this rectangle is relative to the page | // this rectangle is relative to the page | ||||
private RegionReference regionReference; | private RegionReference regionReference; | ||||
private Rectangle2D viewArea; | private Rectangle2D viewArea; |
* See fo:region-body definition in the XSL Rec for more information. | * See fo:region-body definition in the XSL Rec for more information. | ||||
*/ | */ | ||||
public class Span extends Area { | public class Span extends Area { | ||||
private static final long serialVersionUID = -5551430053660081549L; | |||||
// the list of flow reference areas in this span area | // the list of flow reference areas in this span area | ||||
private List flowAreas; | private List flowAreas; | ||||
private int colCount; | private int colCount; |
*/ | */ | ||||
public final class Trait implements Serializable { | public final class Trait implements Serializable { | ||||
private static final long serialVersionUID = 3234280285391611437L; | |||||
private Trait() { | private Trait() { | ||||
} | } | ||||
*/ | */ | ||||
public static class InternalLink implements Serializable { | public static class InternalLink implements Serializable { | ||||
private static final long serialVersionUID = -8993505060996723039L; | |||||
/** The unique key of the PageViewport. */ | /** The unique key of the PageViewport. */ | ||||
private String pvKey; | private String pvKey; | ||||
*/ | */ | ||||
public static class ExternalLink implements Serializable { | public static class ExternalLink implements Serializable { | ||||
private static final long serialVersionUID = -3720707599232620946L; | |||||
private String destination; | private String destination; | ||||
private boolean newWindow; | private boolean newWindow; | ||||
*/ | */ | ||||
public static class Background implements Serializable { | public static class Background implements Serializable { | ||||
private static final long serialVersionUID = 8452078676273242870L; | |||||
/** The background color if any. */ | /** The background color if any. */ | ||||
private Color color = null; | private Color color = null; | ||||
*/ | */ | ||||
public abstract class AbstractTextArea extends InlineParent { | public abstract class AbstractTextArea extends InlineParent { | ||||
private static final long serialVersionUID = -1246306443569094371L; | |||||
/** | /** | ||||
* this class stores information about spaces and potential adjustments | * this class stores information about spaces and potential adjustments | ||||
* that can be used in order to re-compute adjustments when a | * that can be used in order to re-compute adjustments when a | ||||
*/ | */ | ||||
protected class TextAdjustingInfo extends InlineAdjustingInfo { | protected class TextAdjustingInfo extends InlineAdjustingInfo { | ||||
private static final long serialVersionUID = -2412095162983479947L; | |||||
/** difference between the optimal width of a space | /** difference between the optimal width of a space | ||||
* and the default width of a space according to the font | * and the default width of a space according to the font | ||||
* (this is equivalent to the property word-spacing.optimum) | * (this is equivalent to the property word-spacing.optimum) |
*/ | */ | ||||
public class Anchor extends InlineArea { | public class Anchor extends InlineArea { | ||||
private static final long serialVersionUID = 5227798744787823499L; | |||||
// has a keep with adjacent area | // has a keep with adjacent area | ||||
// has reference to associated footnote or float out-of-line area | // has reference to associated footnote or float out-of-line area | ||||
* This allows an inline area to have blocks as children. | * This allows an inline area to have blocks as children. | ||||
*/ | */ | ||||
public class Container extends Area { | public class Container extends Area { | ||||
private static final long serialVersionUID = 5256423939348189260L; | |||||
/** | /** | ||||
* The list of block areas stacked inside this container | * The list of block areas stacked inside this container | ||||
*/ | */ |
* this as a normal inline parent. | * this as a normal inline parent. | ||||
*/ | */ | ||||
public class FilledArea extends InlineParent { | public class FilledArea extends InlineParent { | ||||
private static final long serialVersionUID = 8586584705587017474L; | |||||
private int unitWidth; | private int unitWidth; | ||||
/** | /** |
* The url of the image is used as a key to reference the image cache. | * The url of the image is used as a key to reference the image cache. | ||||
*/ | */ | ||||
public class Image extends Area { | public class Image extends Area { | ||||
private static final long serialVersionUID = 4800834714349695386L; | |||||
private String url; | private String url; | ||||
/** | /** |
*/ | */ | ||||
public class InlineArea extends Area { | public class InlineArea extends Area { | ||||
private static final long serialVersionUID = -8940066479810170980L; | |||||
/** | /** | ||||
* this class stores information about potential adjustments | * this class stores information about potential adjustments | ||||
* that can be used in order to re-compute adjustments when a | * that can be used in order to re-compute adjustments when a | ||||
* page-number or a page-number-citation is resolved | * page-number or a page-number-citation is resolved | ||||
*/ | */ | ||||
protected class InlineAdjustingInfo implements Serializable { | protected class InlineAdjustingInfo implements Serializable { | ||||
private static final long serialVersionUID = -5601387735459712149L; | |||||
/** stretch of the inline area */ | /** stretch of the inline area */ | ||||
protected int availableStretch; | protected int availableStretch; | ||||
/** shrink of the inline area */ | /** shrink of the inline area */ |
*/ | */ | ||||
public class InlineBlockParent extends InlineArea { | public class InlineBlockParent extends InlineArea { | ||||
private static final long serialVersionUID = -3661746143321407377L; | |||||
/** | /** | ||||
* The list of inline areas added to this inline parent. | * The list of inline areas added to this inline parent. | ||||
*/ | */ |
* This is an inline area that can have other inlines as children. | * This is an inline area that can have other inlines as children. | ||||
*/ | */ | ||||
public class InlineParent extends InlineArea { | public class InlineParent extends InlineArea { | ||||
private static final long serialVersionUID = -3047168298770354813L; | |||||
/** | /** | ||||
* The list of inline areas added to this inline parent. | * The list of inline areas added to this inline parent. | ||||
*/ | */ |
// if space replaced with a space | // if space replaced with a space | ||||
// otherwise this is a holder for a line | // otherwise this is a holder for a line | ||||
private static final long serialVersionUID = -8011373048313956301L; | |||||
private int ruleStyle = Constants.EN_SOLID; | private int ruleStyle = Constants.EN_SOLID; | ||||
private int ruleThickness = 1000; | private int ruleThickness = 1000; | ||||
*/ | */ | ||||
public class Space extends InlineArea { | public class Space extends InlineArea { | ||||
private static final long serialVersionUID = -8748265505356839796L; | |||||
} | } |
*/ | */ | ||||
public class SpaceArea extends InlineArea { | public class SpaceArea extends InlineArea { | ||||
private static final long serialVersionUID = 2218803009825411416L; | |||||
/** | /** | ||||
* The space for this space area | * The space for this space area | ||||
*/ | */ |
*/ | */ | ||||
public class TextArea extends AbstractTextArea { | public class TextArea extends AbstractTextArea { | ||||
private static final long serialVersionUID = 7315900267242540809L; | |||||
/** | /** | ||||
* Create a text inline area | * Create a text inline area | ||||
*/ | */ |
*/ | */ | ||||
public class UnresolvedPageNumber extends TextArea implements Resolvable { | public class UnresolvedPageNumber extends TextArea implements Resolvable { | ||||
private static final long serialVersionUID = -1758090835371647980L; | |||||
private boolean resolved = false; | private boolean resolved = false; | ||||
private String pageIDRef; | private String pageIDRef; | ||||
private String text; | private String text; |
* holds the area and positions it. | * holds the area and positions it. | ||||
*/ | */ | ||||
public class Viewport extends InlineArea { | public class Viewport extends InlineArea { | ||||
private static final long serialVersionUID = 813338534627918689L; | |||||
// contents could be container, foreign object or image | // contents could be container, foreign object or image | ||||
private Area content; | private Area content; | ||||
// clipping for the viewport | // clipping for the viewport |
*/ | */ | ||||
public class WordArea extends InlineArea { | public class WordArea extends InlineArea { | ||||
private static final long serialVersionUID = 6444644662158970942L; | |||||
/** The text for this word area */ | /** The text for this word area */ | ||||
protected String word; | protected String word; | ||||
/* user configuration file */ | /* user configuration file */ | ||||
private File userConfigFile = null; | private File userConfigFile = null; | ||||
/* input fo file */ | /* input fo file */ | ||||
private File fofile = null; | |||||
private File foFile = null; | |||||
/* xsltfile (xslt transformation as input) */ | /* xsltfile (xslt transformation as input) */ | ||||
private File xsltfile = null; | |||||
private File xsltFile = null; | |||||
/* xml file (xslt transformation as input) */ | /* xml file (xslt transformation as input) */ | ||||
private File xmlfile = null; | |||||
private File xmlFile = null; | |||||
/* area tree input file */ | /* area tree input file */ | ||||
private File areatreefile = null; | |||||
private File areatreeFile = null; | |||||
/* intermediate format input file */ | /* intermediate format input file */ | ||||
private File iffile = null; | |||||
private File ifFile = null; | |||||
/* area tree input file */ | /* area tree input file */ | ||||
private File imagefile = null; | |||||
private File imageFile = null; | |||||
/* output file */ | /* output file */ | ||||
private File outfile = null; | |||||
private File outFile = null; | |||||
/* input mode */ | /* input mode */ | ||||
private int inputmode = NOT_SET; | |||||
private int inputMode = NOT_SET; | |||||
/* output mode */ | /* output mode */ | ||||
private String outputmode = null; | |||||
private String outputMode = null; | |||||
/* true if System.in (stdin) should be used for the input file */ | /* true if System.in (stdin) should be used for the input file */ | ||||
private boolean useStdIn = false; | private boolean useStdIn = false; | ||||
/* true if System.out (stdout) should be used for the output file */ | /* true if System.out (stdout) should be used for the output file */ | ||||
inputHandler = createInputHandler(); | inputHandler = createInputHandler(); | ||||
if (MimeConstants.MIME_FOP_AWT_PREVIEW.equals(outputmode)) { | |||||
if (MimeConstants.MIME_FOP_AWT_PREVIEW.equals(outputMode)) { | |||||
//set the system look&feel for the preview dialog | //set the system look&feel for the preview dialog | ||||
try { | try { | ||||
UIManager.setLookAndFeel( | UIManager.setLookAndFeel( | ||||
renderer.setRenderable(inputHandler); //set before user agent! | renderer.setRenderable(inputHandler); //set before user agent! | ||||
renderer.setUserAgent(foUserAgent); | renderer.setUserAgent(foUserAgent); | ||||
foUserAgent.setRendererOverride(renderer); | foUserAgent.setRendererOverride(renderer); | ||||
} else if (MimeConstants.MIME_FOP_AREA_TREE.equals(outputmode) | |||||
} else if (MimeConstants.MIME_FOP_AREA_TREE.equals(outputMode) | |||||
&& mimicRenderer != null) { | && mimicRenderer != null) { | ||||
// render from FO to Intermediate Format | // render from FO to Intermediate Format | ||||
Renderer targetRenderer = foUserAgent.getRendererFactory().createRenderer( | Renderer targetRenderer = foUserAgent.getRendererFactory().createRenderer( | ||||
//Make sure the prepared XMLRenderer is used | //Make sure the prepared XMLRenderer is used | ||||
foUserAgent.setRendererOverride(xmlRenderer); | foUserAgent.setRendererOverride(xmlRenderer); | ||||
} else if (MimeConstants.MIME_FOP_IF.equals(outputmode) | |||||
} else if (MimeConstants.MIME_FOP_IF.equals(outputMode) | |||||
&& mimicRenderer != null) { | && mimicRenderer != null) { | ||||
// render from FO to Intermediate Format | // render from FO to Intermediate Format | ||||
IFSerializer serializer = new IFSerializer(); | IFSerializer serializer = new IFSerializer(); | ||||
if (isSystemInOutFile(filename)) { | if (isSystemInOutFile(filename)) { | ||||
this.useStdIn = true; | this.useStdIn = true; | ||||
} else { | } else { | ||||
fofile = new File(filename); | |||||
foFile = new File(filename); | |||||
} | } | ||||
return 1; | return 1; | ||||
} | } | ||||
throw new FOPException("you must specify the stylesheet " | throw new FOPException("you must specify the stylesheet " | ||||
+ "file for the '-xsl' option"); | + "file for the '-xsl' option"); | ||||
} else { | } else { | ||||
xsltfile = new File(args[i + 1]); | |||||
xsltFile = new File(args[i + 1]); | |||||
return 1; | return 1; | ||||
} | } | ||||
} | } | ||||
if (isSystemInOutFile(filename)) { | if (isSystemInOutFile(filename)) { | ||||
this.useStdIn = true; | this.useStdIn = true; | ||||
} else { | } else { | ||||
xmlfile = new File(filename); | |||||
xmlFile = new File(filename); | |||||
} | } | ||||
return 1; | return 1; | ||||
} | } | ||||
if (isSystemInOutFile(filename)) { | if (isSystemInOutFile(filename)) { | ||||
this.useStdOut = true; | this.useStdOut = true; | ||||
} else { | } else { | ||||
outfile = new File(filename); | |||||
outFile = new File(filename); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
private int parseUnknownOption(String[] args, int i) throws FOPException { | private int parseUnknownOption(String[] args, int i) throws FOPException { | ||||
if (inputmode == NOT_SET) { | |||||
inputmode = FO_INPUT; | |||||
if (inputMode == NOT_SET) { | |||||
inputMode = FO_INPUT; | |||||
String filename = args[i]; | String filename = args[i]; | ||||
if (isSystemInOutFile(filename)) { | if (isSystemInOutFile(filename)) { | ||||
this.useStdIn = true; | this.useStdIn = true; | ||||
} else { | } else { | ||||
fofile = new File(filename); | |||||
foFile = new File(filename); | |||||
} | } | ||||
} else if (outputmode == null) { | |||||
outputmode = MimeConstants.MIME_PDF; | |||||
} else if (outputMode == null) { | |||||
outputMode = MimeConstants.MIME_PDF; | |||||
setOutputFile(args[i]); | setOutputFile(args[i]); | ||||
} else { | } else { | ||||
throw new FOPException("Don't know what to do with " | throw new FOPException("Don't know what to do with " | ||||
if (isSystemInOutFile(filename)) { | if (isSystemInOutFile(filename)) { | ||||
this.useStdIn = true; | this.useStdIn = true; | ||||
} else { | } else { | ||||
areatreefile = new File(filename); | |||||
areatreeFile = new File(filename); | |||||
} | } | ||||
return 1; | return 1; | ||||
} | } | ||||
if (isSystemInOutFile(filename)) { | if (isSystemInOutFile(filename)) { | ||||
this.useStdIn = true; | this.useStdIn = true; | ||||
} else { | } else { | ||||
iffile = new File(filename); | |||||
ifFile = new File(filename); | |||||
} | } | ||||
return 1; | return 1; | ||||
} | } | ||||
if (isSystemInOutFile(filename)) { | if (isSystemInOutFile(filename)) { | ||||
this.useStdIn = true; | this.useStdIn = true; | ||||
} else { | } else { | ||||
imagefile = new File(filename); | |||||
imageFile = new File(filename); | |||||
} | } | ||||
return 1; | return 1; | ||||
} | } | ||||
} | } | ||||
private void setOutputMode(String mime) throws FOPException { | private void setOutputMode(String mime) throws FOPException { | ||||
if (outputmode == null) { | |||||
outputmode = mime; | |||||
if (outputMode == null) { | |||||
outputMode = mime; | |||||
} else { | } else { | ||||
throw new FOPException("you can only set one output method"); | throw new FOPException("you can only set one output method"); | ||||
} | } | ||||
} | } | ||||
private void setInputFormat(int format) throws FOPException { | private void setInputFormat(int format) throws FOPException { | ||||
if (inputmode == NOT_SET || inputmode == format) { | |||||
inputmode = format; | |||||
if (inputMode == NOT_SET || inputMode == format) { | |||||
inputMode = format; | |||||
} else { | } else { | ||||
throw new FOPException("Only one input mode can be specified!"); | throw new FOPException("Only one input mode can be specified!"); | ||||
} | } | ||||
* checks whether all necessary information has been given in a consistent way | * checks whether all necessary information has been given in a consistent way | ||||
*/ | */ | ||||
private void checkSettings() throws FOPException, FileNotFoundException { | private void checkSettings() throws FOPException, FileNotFoundException { | ||||
if (inputmode == NOT_SET) { | |||||
if (inputMode == NOT_SET) { | |||||
throw new FOPException("No input file specified"); | throw new FOPException("No input file specified"); | ||||
} | } | ||||
if (outputmode == null) { | |||||
if (outputMode == null) { | |||||
throw new FOPException("No output file specified"); | throw new FOPException("No output file specified"); | ||||
} | } | ||||
if ((outputmode.equals(MimeConstants.MIME_FOP_AWT_PREVIEW) | |||||
|| outputmode.equals(MimeConstants.MIME_FOP_PRINT)) | |||||
&& outfile != null) { | |||||
if ((outputMode.equals(MimeConstants.MIME_FOP_AWT_PREVIEW) | |||||
|| outputMode.equals(MimeConstants.MIME_FOP_PRINT)) | |||||
&& outFile != null) { | |||||
throw new FOPException("Output file may not be specified " | throw new FOPException("Output file may not be specified " | ||||
+ "for AWT or PRINT output"); | + "for AWT or PRINT output"); | ||||
} | } | ||||
if (inputmode == XSLT_INPUT) { | |||||
if (inputMode == XSLT_INPUT) { | |||||
// check whether xml *and* xslt file have been set | // check whether xml *and* xslt file have been set | ||||
if (xmlfile == null && !this.useStdIn) { | |||||
if (xmlFile == null && !this.useStdIn) { | |||||
throw new FOPException("XML file must be specified for the transform mode"); | throw new FOPException("XML file must be specified for the transform mode"); | ||||
} | } | ||||
if (xsltfile == null) { | |||||
if (xsltFile == null) { | |||||
throw new FOPException("XSLT file must be specified for the transform mode"); | throw new FOPException("XSLT file must be specified for the transform mode"); | ||||
} | } | ||||
// warning if fofile has been set in xslt mode | // warning if fofile has been set in xslt mode | ||||
if (fofile != null) { | |||||
if (foFile != null) { | |||||
log.warn("Can't use fo file with transform mode! Ignoring.\n" | log.warn("Can't use fo file with transform mode! Ignoring.\n" | ||||
+ "Your input is " + "\n xmlfile: " | + "Your input is " + "\n xmlfile: " | ||||
+ xmlfile.getAbsolutePath() | |||||
+ xmlFile.getAbsolutePath() | |||||
+ "\nxsltfile: " | + "\nxsltfile: " | ||||
+ xsltfile.getAbsolutePath() | |||||
+ xsltFile.getAbsolutePath() | |||||
+ "\n fofile: " | + "\n fofile: " | ||||
+ fofile.getAbsolutePath()); | |||||
+ foFile.getAbsolutePath()); | |||||
} | } | ||||
if (xmlfile != null && !xmlfile.exists()) { | |||||
if (xmlFile != null && !xmlFile.exists()) { | |||||
throw new FileNotFoundException("Error: xml file " | throw new FileNotFoundException("Error: xml file " | ||||
+ xmlfile.getAbsolutePath() | |||||
+ xmlFile.getAbsolutePath() | |||||
+ " not found "); | + " not found "); | ||||
} | } | ||||
if (!xsltfile.exists()) { | |||||
if (!xsltFile.exists()) { | |||||
throw new FileNotFoundException("Error: xsl file " | throw new FileNotFoundException("Error: xsl file " | ||||
+ xsltfile.getAbsolutePath() | |||||
+ xsltFile.getAbsolutePath() | |||||
+ " not found "); | + " not found "); | ||||
} | } | ||||
} else if (inputmode == FO_INPUT) { | |||||
if (outputmode.equals(MimeConstants.MIME_XSL_FO)) { | |||||
} else if (inputMode == FO_INPUT) { | |||||
if (outputMode.equals(MimeConstants.MIME_XSL_FO)) { | |||||
throw new FOPException( | throw new FOPException( | ||||
"FO output mode is only available if you use -xml and -xsl"); | "FO output mode is only available if you use -xml and -xsl"); | ||||
} | } | ||||
if (fofile != null && !fofile.exists()) { | |||||
if (foFile != null && !foFile.exists()) { | |||||
throw new FileNotFoundException("Error: fo file " | throw new FileNotFoundException("Error: fo file " | ||||
+ fofile.getAbsolutePath() | |||||
+ foFile.getAbsolutePath() | |||||
+ " not found "); | + " not found "); | ||||
} | } | ||||
} else if (inputmode == AREATREE_INPUT) { | |||||
if (outputmode.equals(MimeConstants.MIME_XSL_FO)) { | |||||
} else if (inputMode == AREATREE_INPUT) { | |||||
if (outputMode.equals(MimeConstants.MIME_XSL_FO)) { | |||||
throw new FOPException( | throw new FOPException( | ||||
"FO output mode is only available if you use -xml and -xsl"); | "FO output mode is only available if you use -xml and -xsl"); | ||||
} else if (outputmode.equals(MimeConstants.MIME_FOP_AREA_TREE)) { | |||||
} else if (outputMode.equals(MimeConstants.MIME_FOP_AREA_TREE)) { | |||||
throw new FOPException( | throw new FOPException( | ||||
"Area Tree Output is not available if Area Tree is used as input!"); | "Area Tree Output is not available if Area Tree is used as input!"); | ||||
} | } | ||||
if (areatreefile != null && !areatreefile.exists()) { | |||||
if (areatreeFile != null && !areatreeFile.exists()) { | |||||
throw new FileNotFoundException("Error: area tree file " | throw new FileNotFoundException("Error: area tree file " | ||||
+ areatreefile.getAbsolutePath() | |||||
+ areatreeFile.getAbsolutePath() | |||||
+ " not found "); | + " not found "); | ||||
} | } | ||||
} else if (inputmode == IF_INPUT) { | |||||
if (outputmode.equals(MimeConstants.MIME_XSL_FO)) { | |||||
} else if (inputMode == IF_INPUT) { | |||||
if (outputMode.equals(MimeConstants.MIME_XSL_FO)) { | |||||
throw new FOPException( | throw new FOPException( | ||||
"FO output mode is only available if you use -xml and -xsl"); | "FO output mode is only available if you use -xml and -xsl"); | ||||
} else if (outputmode.equals(MimeConstants.MIME_FOP_AREA_TREE)) { | |||||
} else if (outputMode.equals(MimeConstants.MIME_FOP_AREA_TREE)) { | |||||
throw new FOPException( | throw new FOPException( | ||||
"Area Tree Output is not available if Intermediate Format" | "Area Tree Output is not available if Intermediate Format" | ||||
+ " is used as input!"); | + " is used as input!"); | ||||
} else if (outputmode.equals(MimeConstants.MIME_FOP_IF)) { | |||||
} else if (outputMode.equals(MimeConstants.MIME_FOP_IF)) { | |||||
throw new FOPException( | throw new FOPException( | ||||
"Intermediate Output is not available if Intermediate Format" | "Intermediate Output is not available if Intermediate Format" | ||||
+ " is used as input!"); | + " is used as input!"); | ||||
} | } | ||||
if (iffile != null && !iffile.exists()) { | |||||
if (ifFile != null && !ifFile.exists()) { | |||||
throw new FileNotFoundException("Error: intermediate format file " | throw new FileNotFoundException("Error: intermediate format file " | ||||
+ iffile.getAbsolutePath() | |||||
+ ifFile.getAbsolutePath() | |||||
+ " not found "); | + " not found "); | ||||
} | } | ||||
} else if (inputmode == IMAGE_INPUT) { | |||||
if (outputmode.equals(MimeConstants.MIME_XSL_FO)) { | |||||
} else if (inputMode == IMAGE_INPUT) { | |||||
if (outputMode.equals(MimeConstants.MIME_XSL_FO)) { | |||||
throw new FOPException( | throw new FOPException( | ||||
"FO output mode is only available if you use -xml and -xsl"); | "FO output mode is only available if you use -xml and -xsl"); | ||||
} | } | ||||
if (imagefile != null && !imagefile.exists()) { | |||||
if (imageFile != null && !imageFile.exists()) { | |||||
throw new FileNotFoundException("Error: image file " | throw new FileNotFoundException("Error: image file " | ||||
+ imagefile.getAbsolutePath() | |||||
+ imageFile.getAbsolutePath() | |||||
+ " not found "); | + " not found "); | ||||
} | } | ||||
} | } | ||||
* @throws FOPException for invalid output formats | * @throws FOPException for invalid output formats | ||||
*/ | */ | ||||
protected String getOutputFormat() throws FOPException { | protected String getOutputFormat() throws FOPException { | ||||
if (outputmode == null) { | |||||
if (outputMode == null) { | |||||
throw new FOPException("Renderer has not been set!"); | throw new FOPException("Renderer has not been set!"); | ||||
} | } | ||||
if (outputmode.equals(MimeConstants.MIME_FOP_AREA_TREE)) { | |||||
if (outputMode.equals(MimeConstants.MIME_FOP_AREA_TREE)) { | |||||
renderingOptions.put("fineDetail", isCoarseAreaXml()); | renderingOptions.put("fineDetail", isCoarseAreaXml()); | ||||
} | } | ||||
return outputmode; | |||||
return outputMode; | |||||
} | } | ||||
/** | /** | ||||
* @throws IllegalArgumentException if invalid/missing parameters | * @throws IllegalArgumentException if invalid/missing parameters | ||||
*/ | */ | ||||
private InputHandler createInputHandler() { | private InputHandler createInputHandler() { | ||||
switch (inputmode) { | |||||
switch (inputMode) { | |||||
case FO_INPUT: | case FO_INPUT: | ||||
return new InputHandler(fofile); | |||||
return new InputHandler(foFile); | |||||
case AREATREE_INPUT: | case AREATREE_INPUT: | ||||
return new AreaTreeInputHandler(areatreefile); | |||||
return new AreaTreeInputHandler(areatreeFile); | |||||
case IF_INPUT: | case IF_INPUT: | ||||
return new IFInputHandler(iffile); | |||||
return new IFInputHandler(ifFile); | |||||
case XSLT_INPUT: | case XSLT_INPUT: | ||||
InputHandler handler = new InputHandler(xmlfile, xsltfile, xsltParams); | |||||
InputHandler handler = new InputHandler(xmlFile, xsltFile, xsltParams); | |||||
if (useCatalogResolver) { | if (useCatalogResolver) { | ||||
handler.createCatalogResolver(foUserAgent); | handler.createCatalogResolver(foUserAgent); | ||||
} | } | ||||
return handler; | return handler; | ||||
case IMAGE_INPUT: | case IMAGE_INPUT: | ||||
return new ImageInputHandler(imagefile, xsltfile, xsltParams); | |||||
return new ImageInputHandler(imageFile, xsltFile, xsltParams); | |||||
default: | default: | ||||
throw new IllegalArgumentException("Error creating InputHandler object."); | throw new IllegalArgumentException("Error creating InputHandler object."); | ||||
} | } | ||||
* Returns the XSL-FO file if set. | * Returns the XSL-FO file if set. | ||||
* @return the XSL-FO file, null if not set | * @return the XSL-FO file, null if not set | ||||
*/ | */ | ||||
public File getFOFile() { | |||||
return fofile; | |||||
public File getFoFile() { | |||||
return foFile; | |||||
} | } | ||||
/** | /** | ||||
* Returns the input XML file if set. | * Returns the input XML file if set. | ||||
* @return the input XML file, null if not set | * @return the input XML file, null if not set | ||||
*/ | */ | ||||
public File getXMLFile() { | |||||
return xmlfile; | |||||
public File getXmlFile() { | |||||
return xmlFile; | |||||
} | } | ||||
/** | /** | ||||
* Returns the stylesheet to be used for transformation to XSL-FO. | * Returns the stylesheet to be used for transformation to XSL-FO. | ||||
* @return stylesheet | * @return stylesheet | ||||
*/ | */ | ||||
public File getXSLFile() { | |||||
return xsltfile; | |||||
public File getXslFile() { | |||||
return xsltFile; | |||||
} | } | ||||
/** | /** | ||||
* @return the output file | * @return the output file | ||||
*/ | */ | ||||
public File getOutputFile() { | public File getOutputFile() { | ||||
return outfile; | |||||
return outFile; | |||||
} | } | ||||
/** | /** | ||||
* @return either the fofile or the xmlfile | * @return either the fofile or the xmlfile | ||||
*/ | */ | ||||
public File getInputFile() { | public File getInputFile() { | ||||
switch (inputmode) { | |||||
switch (inputMode) { | |||||
case FO_INPUT: | case FO_INPUT: | ||||
return fofile; | |||||
return foFile; | |||||
case XSLT_INPUT: | case XSLT_INPUT: | ||||
return xmlfile; | |||||
return xmlFile; | |||||
default: | default: | ||||
return fofile; | |||||
return foFile; | |||||
} | } | ||||
} | } | ||||
*/ | */ | ||||
private void dumpConfiguration() { | private void dumpConfiguration() { | ||||
log.info("Input mode: "); | log.info("Input mode: "); | ||||
switch (inputmode) { | |||||
switch (inputMode) { | |||||
case NOT_SET: | case NOT_SET: | ||||
log.info("not set"); | log.info("not set"); | ||||
break; | break; | ||||
if (isInputFromStdIn()) { | if (isInputFromStdIn()) { | ||||
log.info("fo input file: from stdin"); | log.info("fo input file: from stdin"); | ||||
} else { | } else { | ||||
log.info("fo input file: " + fofile.toString()); | |||||
log.info("fo input file: " + foFile.toString()); | |||||
} | } | ||||
break; | break; | ||||
case XSLT_INPUT: | case XSLT_INPUT: | ||||
if (isInputFromStdIn()) { | if (isInputFromStdIn()) { | ||||
log.info("xml input file: from stdin"); | log.info("xml input file: from stdin"); | ||||
} else { | } else { | ||||
log.info("xml input file: " + xmlfile.toString()); | |||||
log.info("xml input file: " + xmlFile.toString()); | |||||
} | } | ||||
log.info("xslt stylesheet: " + xsltfile.toString()); | |||||
log.info("xslt stylesheet: " + xsltFile.toString()); | |||||
break; | break; | ||||
case AREATREE_INPUT: | case AREATREE_INPUT: | ||||
log.info("AT "); | log.info("AT "); | ||||
if (isInputFromStdIn()) { | if (isInputFromStdIn()) { | ||||
log.info("area tree input file: from stdin"); | log.info("area tree input file: from stdin"); | ||||
} else { | } else { | ||||
log.info("area tree input file: " + areatreefile.toString()); | |||||
log.info("area tree input file: " + areatreeFile.toString()); | |||||
} | } | ||||
break; | break; | ||||
case IF_INPUT: | case IF_INPUT: | ||||
if (isInputFromStdIn()) { | if (isInputFromStdIn()) { | ||||
log.info("intermediate input file: from stdin"); | log.info("intermediate input file: from stdin"); | ||||
} else { | } else { | ||||
log.info("intermediate input file: " + iffile.toString()); | |||||
log.info("intermediate input file: " + ifFile.toString()); | |||||
} | } | ||||
break; | break; | ||||
case IMAGE_INPUT: | case IMAGE_INPUT: | ||||
if (isInputFromStdIn()) { | if (isInputFromStdIn()) { | ||||
log.info("image input file: from stdin"); | log.info("image input file: from stdin"); | ||||
} else { | } else { | ||||
log.info("image input file: " + imagefile.toString()); | |||||
log.info("image input file: " + imageFile.toString()); | |||||
} | } | ||||
break; | break; | ||||
default: | default: | ||||
log.info("unknown input type"); | log.info("unknown input type"); | ||||
} | } | ||||
log.info("Output mode: "); | log.info("Output mode: "); | ||||
if (outputmode == null) { | |||||
if (outputMode == null) { | |||||
log.info("not set"); | log.info("not set"); | ||||
} else if (MimeConstants.MIME_FOP_AWT_PREVIEW.equals(outputmode)) { | |||||
} else if (MimeConstants.MIME_FOP_AWT_PREVIEW.equals(outputMode)) { | |||||
log.info("awt on screen"); | log.info("awt on screen"); | ||||
if (outfile != null) { | |||||
if (outFile != null) { | |||||
log.error("awt mode, but outfile is set:"); | log.error("awt mode, but outfile is set:"); | ||||
log.error("out file: " + outfile.toString()); | |||||
log.error("out file: " + outFile.toString()); | |||||
} | } | ||||
} else if (MimeConstants.MIME_FOP_PRINT.equals(outputmode)) { | |||||
} else if (MimeConstants.MIME_FOP_PRINT.equals(outputMode)) { | |||||
log.info("print directly"); | log.info("print directly"); | ||||
if (outfile != null) { | |||||
if (outFile != null) { | |||||
log.error("print mode, but outfile is set:"); | log.error("print mode, but outfile is set:"); | ||||
log.error("out file: " + outfile.toString()); | |||||
log.error("out file: " + outFile.toString()); | |||||
} | } | ||||
} else if (MimeConstants.MIME_FOP_AREA_TREE.equals(outputmode)) { | |||||
} else if (MimeConstants.MIME_FOP_AREA_TREE.equals(outputMode)) { | |||||
log.info("area tree"); | log.info("area tree"); | ||||
if (mimicRenderer != null) { | if (mimicRenderer != null) { | ||||
log.info("mimic renderer: " + mimicRenderer); | log.info("mimic renderer: " + mimicRenderer); | ||||
if (isOutputToStdOut()) { | if (isOutputToStdOut()) { | ||||
log.info("output file: to stdout"); | log.info("output file: to stdout"); | ||||
} else { | } else { | ||||
log.info("output file: " + outfile.toString()); | |||||
log.info("output file: " + outFile.toString()); | |||||
} | } | ||||
} else if (MimeConstants.MIME_FOP_IF.equals(outputmode)) { | |||||
} else if (MimeConstants.MIME_FOP_IF.equals(outputMode)) { | |||||
log.info("intermediate format"); | log.info("intermediate format"); | ||||
log.info("output file: " + outfile.toString()); | |||||
log.info("output file: " + outFile.toString()); | |||||
} else { | } else { | ||||
log.info(outputmode); | |||||
log.info(outputMode); | |||||
if (isOutputToStdOut()) { | if (isOutputToStdOut()) { | ||||
log.info("output file: to stdout"); | log.info("output file: to stdout"); | ||||
} else { | } else { | ||||
log.info("output file: " + outfile.toString()); | |||||
log.info("output file: " + outFile.toString()); | |||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* logging instance | * logging instance | ||||
*/ | */ | ||||
protected static Log log = LogFactory.getLog(LengthBase.class); | |||||
protected static final Log log = LogFactory.getLog(LengthBase.class); | |||||
/** | /** | ||||
* The FO for which this property is to be calculated. | * The FO for which this property is to be calculated. |
protected Locator locator; | protected Locator locator; | ||||
/** Logger for fo-tree related messages **/ | /** Logger for fo-tree related messages **/ | ||||
protected static Log log = LogFactory.getLog(FONode.class); | |||||
protected static final Log log = LogFactory.getLog(FONode.class); | |||||
/** | /** | ||||
* Base constructor | * Base constructor |
} | } | ||||
/** @return the baseline-shift property */ | /** @return the baseline-shift property */ | ||||
public Length getBaseLineShift() { | |||||
public Length getBaselineShift() { | |||||
return baselineShift; | return baselineShift; | ||||
} | } | ||||
*/ | */ | ||||
public class XMPMetadata implements ExtensionAttachment, Serializable, XMLizable { | public class XMPMetadata implements ExtensionAttachment, Serializable, XMLizable { | ||||
private static final long serialVersionUID = 591347206217931578L; | |||||
/** The category URI for this extension attachment. */ | /** The category URI for this extension attachment. */ | ||||
public static final String CATEGORY = XMPConstants.XMP_NAMESPACE; | public static final String CATEGORY = XMPConstants.XMP_NAMESPACE; | ||||
public class Property { | public class Property { | ||||
/** Logger for all property classes */ | /** Logger for all property classes */ | ||||
protected static Log log = LogFactory.getLog(PropertyMaker.class); | |||||
protected static final Log log = LogFactory.getLog(PropertyMaker.class); | |||||
/** | /** | ||||
* The original specified value for properties which inherit | * The original specified value for properties which inherit | ||||
if (obj != this) { | if (obj != this) { | ||||
return obj.toString(); | return obj.toString(); | ||||
} | } | ||||
return null; | |||||
return ""; | |||||
} | } | ||||
} | } |
public class FontInfo { | public class FontInfo { | ||||
/** logging instance */ | /** logging instance */ | ||||
protected static Log log = LogFactory.getLog(FontInfo.class); | |||||
protected static final Log log = LogFactory.getLog(FontInfo.class); | |||||
/** Map containing fonts that have been used */ | /** Map containing fonts that have been used */ | ||||
private Map/*<String,FontMetrics>*/ usedFonts = null; //(String = font key) | private Map/*<String,FontMetrics>*/ usedFonts = null; //(String = font key) |
*/ | */ | ||||
public class FontInfoConfigurator { | public class FontInfoConfigurator { | ||||
/** logger instance */ | /** logger instance */ | ||||
protected static Log log = LogFactory.getLog(FontInfoConfigurator.class); | |||||
protected static final Log log = LogFactory.getLog(FontInfoConfigurator.class); | |||||
private Configuration cfg; | private Configuration cfg; | ||||
private FontManager fontManager; | private FontManager fontManager; |
public abstract class FontLoader { | public abstract class FontLoader { | ||||
/** logging instance */ | /** logging instance */ | ||||
protected static Log log = LogFactory.getLog(FontLoader.class); | |||||
protected static final Log log = LogFactory.getLog(FontLoader.class); | |||||
/** URI representing the font file */ | /** URI representing the font file */ | ||||
protected String fontFileURI = null; | protected String fontFileURI = null; |
public void preview(PFMFile pfm) { | public void preview(PFMFile pfm) { | ||||
if (log != null && log.isInfoEnabled()) { | if (log != null && log.isInfoEnabled()) { | ||||
log.info("Font: " + pfm.getWindowsName()); | log.info("Font: " + pfm.getWindowsName()); | ||||
log.info("Name: " + pfm.getPostscriptName()); | |||||
log.info("Name: " + pfm.getPostScriptName()); | |||||
log.info("CharSet: " + pfm.getCharSetName()); | log.info("CharSet: " + pfm.getCharSetName()); | ||||
log.info("CapHeight: " + pfm.getCapHeight()); | log.info("CapHeight: " + pfm.getCapHeight()); | ||||
log.info("XHeight: " + pfm.getXHeight()); | log.info("XHeight: " + pfm.getXHeight()); | ||||
Element el = doc.createElement("font-name"); | Element el = doc.createElement("font-name"); | ||||
root.appendChild(el); | root.appendChild(el); | ||||
el.appendChild(doc.createTextNode(pfm.getPostscriptName())); | |||||
el.appendChild(doc.createTextNode(pfm.getPostScriptName())); | |||||
// Currently unused. | // Currently unused. | ||||
// String s = pfm.getPostscriptName(); | // String s = pfm.getPostscriptName(); |
private static final long serialVersionUID = -9173104935431899722L; | private static final long serialVersionUID = -9173104935431899722L; | ||||
/** logging instance */ | /** logging instance */ | ||||
protected static Log log = LogFactory.getLog(FontSubstitutions.class); | |||||
protected static final Log log = LogFactory.getLog(FontSubstitutions.class); | |||||
/** | /** | ||||
* Adjusts a given fontInfo using this font substitution catalog | * Adjusts a given fontInfo using this font substitution catalog |
public class FontWeightRange { | public class FontWeightRange { | ||||
/** logging instance */ | /** logging instance */ | ||||
protected static Log log = LogFactory.getLog("org.apache.fop.render.fonts"); | |||||
protected static final Log log = LogFactory.getLog("org.apache.fop.render.fonts"); | |||||
/** | /** | ||||
* Returns an <code>FontWeightRange</code> object holding the | * Returns an <code>FontWeightRange</code> object holding the |
// Header stuff | // Header stuff | ||||
private String windowsName; | private String windowsName; | ||||
private String postscriptName; | |||||
private String postScriptName; | |||||
private short dfItalic; | private short dfItalic; | ||||
private int dfWeight; | private int dfWeight; | ||||
private short dfCharSet; | private short dfCharSet; | ||||
inStream.reset(); | inStream.reset(); | ||||
inStream.skip(driverInfoOffset); | inStream.skip(driverInfoOffset); | ||||
postscriptName = inStream.readString(); | |||||
postScriptName = inStream.readString(); | |||||
if (extMetricsOffset != 0) { | if (extMetricsOffset != 0) { | ||||
inStream.reset(); | inStream.reset(); | ||||
* | * | ||||
* @return The Postscript name. | * @return The Postscript name. | ||||
*/ | */ | ||||
public String getPostscriptName() { | |||||
return postscriptName; | |||||
public String getPostScriptName() { | |||||
return postScriptName; | |||||
} | } | ||||
/** | /** | ||||
case 0: | case 0: | ||||
return "WinAnsi"; // AKA ISOAdobe | return "WinAnsi"; // AKA ISOAdobe | ||||
case 2: | case 2: | ||||
if ("Symbol".equals(getPostscriptName())) { | |||||
if ("Symbol".equals(getPostScriptName())) { | |||||
return "Symbol"; | return "Symbol"; | ||||
} | } | ||||
break; | break; |
names.add(afm.getFamilyName()); | names.add(afm.getFamilyName()); | ||||
returnFont.setFamilyNames(names); | returnFont.setFamilyNames(names); | ||||
} else { | } else { | ||||
returnFont.setFontName(pfm.getPostscriptName()); | |||||
String fullName = pfm.getPostscriptName(); | |||||
returnFont.setFontName(pfm.getPostScriptName()); | |||||
String fullName = pfm.getPostScriptName(); | |||||
fullName = fullName.replace('-', ' '); //Hack! Try to emulate full name | fullName = fullName.replace('-', ' '); //Hack! Try to emulate full name | ||||
returnFont.setFullName(fullName); //emulate afm.getFullName() | returnFont.setFullName(fullName); //emulate afm.getFullName() | ||||
Set names = new java.util.HashSet(); | Set names = new java.util.HashSet(); |
*/ | */ | ||||
public class ByteVector implements Serializable { | public class ByteVector implements Serializable { | ||||
private static final long serialVersionUID = 1554572867863466772L; | |||||
/** | /** | ||||
* Capacity increment size | * Capacity increment size | ||||
*/ | */ |
*/ | */ | ||||
public class CharVector implements Cloneable, Serializable { | public class CharVector implements Cloneable, Serializable { | ||||
private static final long serialVersionUID = 4263472982169004048L; | |||||
/** | /** | ||||
* Capacity increment size | * Capacity increment size | ||||
*/ | */ |
*/ | */ | ||||
public class Hyphen implements Serializable { | public class Hyphen implements Serializable { | ||||
private static final long serialVersionUID = 8989909741110279085L; | |||||
/** pre break string */ | /** pre break string */ | ||||
public String preBreak; // CSOK: VisibilityModifier | public String preBreak; // CSOK: VisibilityModifier | ||||
public final class Hyphenator { | public final class Hyphenator { | ||||
/** logging instance */ | /** logging instance */ | ||||
protected static Log log = LogFactory.getLog(Hyphenator.class); | |||||
protected static final Log log = LogFactory.getLog(Hyphenator.class); | |||||
private static HyphenationTreeCache hTreeCache = null; | private static HyphenationTreeCache hTreeCache = null; | ||||
* if it ain't broken, don't fix it. | * if it ain't broken, don't fix it. | ||||
*/ | */ | ||||
private static final long serialVersionUID = 3175412271203716160L; | |||||
/** | /** | ||||
* Pointer to low branch and to rest of the key when it is | * Pointer to low branch and to rest of the key when it is | ||||
* stored directly in this node, we don't have unions in java! | * stored directly in this node, we don't have unions in java! |
public abstract class AbstractBreaker { | public abstract class AbstractBreaker { | ||||
/** logging instance */ | /** logging instance */ | ||||
protected static Log log = LogFactory.getLog(AbstractBreaker.class); | |||||
protected static final Log log = LogFactory.getLog(AbstractBreaker.class); | |||||
/** | /** | ||||
* A page break position. | * A page break position. | ||||
*/ | */ | ||||
public class BlockSequence extends BlockKnuthSequence { | public class BlockSequence extends BlockKnuthSequence { | ||||
private static final long serialVersionUID = -5348831120146774118L; | |||||
/** Number of elements to ignore at the beginning of the list. */ | /** Number of elements to ignore at the beginning of the list. */ | ||||
int ignoreAtStart = 0; // CSOK: VisibilityModifier | int ignoreAtStart = 0; // CSOK: VisibilityModifier | ||||
/** Number of elements to ignore at the end of the list. */ | /** Number of elements to ignore at the end of the list. */ |
*/ | */ | ||||
public class BlockKnuthSequence extends KnuthSequence { | public class BlockKnuthSequence extends KnuthSequence { | ||||
private static final long serialVersionUID = 1648962416582509095L; | |||||
private boolean isClosed = false; | private boolean isClosed = false; | ||||
/** | /** |
public abstract class BreakingAlgorithm { | public abstract class BreakingAlgorithm { | ||||
/** the logger for the class */ | /** the logger for the class */ | ||||
protected static Log log = LogFactory.getLog(BreakingAlgorithm.class); | |||||
protected static final Log log = LogFactory.getLog(BreakingAlgorithm.class); | |||||
/** Maximum adjustment ration */ | /** Maximum adjustment ration */ | ||||
protected static final int INFINITE_RATIO = 1000; | protected static final int INFINITE_RATIO = 1000; |
*/ | */ | ||||
public class InlineKnuthSequence extends KnuthSequence { | public class InlineKnuthSequence extends KnuthSequence { | ||||
private static final long serialVersionUID = 1354774188859946549L; | |||||
private boolean isClosed = false; | private boolean isClosed = false; | ||||
/** | /** |
public abstract class UnresolvedListElementWithLength extends UnresolvedListElement { | public abstract class UnresolvedListElementWithLength extends UnresolvedListElement { | ||||
/** Logger instance */ | /** Logger instance */ | ||||
protected static Log log = LogFactory.getLog(UnresolvedListElementWithLength.class); | |||||
protected static final Log log = LogFactory.getLog(UnresolvedListElementWithLength.class); | |||||
private MinOptMax length; | private MinOptMax length; | ||||
private boolean conditional; | private boolean conditional; |
public class ImageLayout implements Constants { | public class ImageLayout implements Constants { | ||||
/** logging instance */ | /** logging instance */ | ||||
protected static Log log = LogFactory.getLog(ImageLayout.class); | |||||
protected static final Log log = LogFactory.getLog(ImageLayout.class); | |||||
//Input | //Input | ||||
private GraphicsProperties props; | private GraphicsProperties props; |
/** | /** | ||||
* logging instance | * logging instance | ||||
*/ | */ | ||||
protected static Log log = LogFactory.getLog(LeafNodeLayoutManager.class); | |||||
protected static final Log log = LogFactory.getLog(LeafNodeLayoutManager.class); | |||||
/** | /** | ||||
* The inline area that this leafnode will add. | * The inline area that this leafnode will add. |
// this class represents a paragraph | // this class represents a paragraph | ||||
private class Paragraph extends InlineKnuthSequence { | private class Paragraph extends InlineKnuthSequence { | ||||
private static final long serialVersionUID = 5862072380375189105L; | |||||
/** Number of elements to ignore at the beginning of the list. */ | /** Number of elements to ignore at the beginning of the list. */ | ||||
private int ignoreAtStart = 0; | private int ignoreAtStart = 0; | ||||
/** Number of elements to ignore at the end of the list. */ | /** Number of elements to ignore at the end of the list. */ |
public abstract class PDFObject implements PDFWritable { | public abstract class PDFObject implements PDFWritable { | ||||
/** logger for all PDFObjects (and descendants) */ | /** logger for all PDFObjects (and descendants) */ | ||||
protected static Log log = LogFactory.getLog(PDFObject.class.getName()); | |||||
protected static final Log log = LogFactory.getLog(PDFObject.class.getName()); | |||||
/** | /** | ||||
* the object's number | * the object's number |
*/ | */ | ||||
public abstract class AbstractConfigurator { | public abstract class AbstractConfigurator { | ||||
/** logger instance */ | /** logger instance */ | ||||
protected static 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"; | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public String getNamespace() { | |||||
public String getNameSpace() { | |||||
return SVGDOMImplementation.SVG_NAMESPACE_URI; | return SVGDOMImplementation.SVG_NAMESPACE_URI; | ||||
} | } | ||||
implements Renderer, Constants { | implements Renderer, Constants { | ||||
/** logging instance */ | /** logging instance */ | ||||
protected static Log log = LogFactory.getLog("org.apache.fop.render"); | |||||
protected static final Log log = LogFactory.getLog("org.apache.fop.render"); | |||||
/** | /** | ||||
* user agent | * user agent |
implements RendererConfigurator, IFDocumentHandlerConfigurator { | implements RendererConfigurator, IFDocumentHandlerConfigurator { | ||||
/** logger instance */ | /** logger instance */ | ||||
protected static Log log = LogFactory.getLog(PrintRendererConfigurator.class); | |||||
protected static final Log log = LogFactory.getLog(PrintRendererConfigurator.class); | |||||
/** | /** | ||||
* Default constructor | * Default constructor |
* @return the XML namespace for the XML dialect this XMLHandler supports, | * @return the XML namespace for the XML dialect this XMLHandler supports, | ||||
* null if all XML content is handled by this instance. | * null if all XML content is handled by this instance. | ||||
*/ | */ | ||||
String getNamespace(); | |||||
String getNameSpace(); | |||||
} | } | ||||
public class XMLHandlerConfigurator extends AbstractRendererConfigurator { | public class XMLHandlerConfigurator extends AbstractRendererConfigurator { | ||||
/** logger instance */ | /** logger instance */ | ||||
protected static Log log = LogFactory.getLog(XMLHandlerConfigurator.class); | |||||
protected static final Log log = LogFactory.getLog(XMLHandlerConfigurator.class); | |||||
/** | /** | ||||
* Default constructor | * Default constructor |
* @param handler the XMLHandler instance | * @param handler the XMLHandler instance | ||||
*/ | */ | ||||
public void addXMLHandler(XMLHandler handler) { | public void addXMLHandler(XMLHandler handler) { | ||||
String ns = handler.getNamespace(); | |||||
String ns = handler.getNameSpace(); | |||||
if (ns == null) { | if (ns == null) { | ||||
setDefaultXMLHandler(handler); | setDefaultXMLHandler(handler); | ||||
} else { | } else { |
* | * | ||||
* @return the uri | * @return the uri | ||||
*/ | */ | ||||
public String getURI() { | |||||
public String getUri() { | |||||
return this.uri; | return this.uri; | ||||
} | } | ||||
implements ContentHandlerFactory.ObjectSource { | implements ContentHandlerFactory.ObjectSource { | ||||
/** Logger instance */ | /** Logger instance */ | ||||
protected static Log log = LogFactory.getLog(AFPExtensionHandler.class); | |||||
protected static final Log log = LogFactory.getLog(AFPExtensionHandler.class); | |||||
private StringBuffer content = new StringBuffer(); | private StringBuffer content = new StringBuffer(); | ||||
private Attributes lastAttributes; | private Attributes lastAttributes; |
*/ | */ | ||||
public class PageChangeEvent extends EventObject { | public class PageChangeEvent extends EventObject { | ||||
private static final long serialVersionUID = -5969283475959932887L; | |||||
private int oldPage; | private int oldPage; | ||||
private int newPage; | private int newPage; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.io.OutputStream; | import java.io.OutputStream; | ||||
import java.util.Iterator; | import java.util.Iterator; | ||||
import java.util.NoSuchElementException; | |||||
import org.apache.commons.logging.Log; | import org.apache.commons.logging.Log; | ||||
multiWriter.close(); | multiWriter.close(); | ||||
} | } | ||||
} else { | } else { | ||||
writer.writeImage((RenderedImage) pageImagesItr.next(), outputStream, writerParams); | |||||
RenderedImage renderedImage = null; | |||||
if (pageImagesItr.hasNext()) { | |||||
renderedImage = (RenderedImage) pageImagesItr.next(); | |||||
} | |||||
writer.writeImage(renderedImage, outputStream, writerParams); | |||||
if (pageImagesItr.hasNext()) { | if (pageImagesItr.hasNext()) { | ||||
BitmapRendererEventProducer eventProducer | BitmapRendererEventProducer eventProducer | ||||
= BitmapRendererEventProducer.Provider.get( | = BitmapRendererEventProducer.Provider.get( | ||||
try { | try { | ||||
pageImage = getPageImage(current++); | pageImage = getPageImage(current++); | ||||
} catch (FOPException e) { | } catch (FOPException e) { | ||||
log.error(e); | |||||
return null; | |||||
throw new NoSuchElementException(e.getMessage()); | |||||
} | } | ||||
if (COMPRESSION_CCITT_T4.equalsIgnoreCase(writerParams.getCompressionMethod()) | if (COMPRESSION_CCITT_T4.equalsIgnoreCase(writerParams.getCompressionMethod()) |
public class IFParser implements IFConstants { | public class IFParser implements IFConstants { | ||||
/** Logger instance */ | /** Logger instance */ | ||||
protected static Log log = LogFactory.getLog(IFParser.class); | |||||
protected static final Log log = LogFactory.getLog(IFParser.class); | |||||
private static SAXTransformerFactory tFactory | private static SAXTransformerFactory tFactory | ||||
= (SAXTransformerFactory)SAXTransformerFactory.newInstance(); | = (SAXTransformerFactory)SAXTransformerFactory.newInstance(); |
//if optimizations can be done to avoid int->float->int conversions. | //if optimizations can be done to avoid int->float->int conversions. | ||||
/** logging instance */ | /** logging instance */ | ||||
protected static Log log = LogFactory.getLog(IFRenderer.class); | |||||
protected static final Log log = LogFactory.getLog(IFRenderer.class); | |||||
/** XML MIME type */ | /** XML MIME type */ | ||||
public static final String IF_MIME_TYPE = MimeConstants.MIME_FOP_IF; | public static final String IF_MIME_TYPE = MimeConstants.MIME_FOP_IF; |
throw new NullPointerException("action must not be null"); | throw new NullPointerException("action must not be null"); | ||||
} | } | ||||
if (!action.isComplete()) { | if (!action.isComplete()) { | ||||
assert action.hasID(); | |||||
incompleteActions.put(action.getID(), action); | |||||
assert action.hasId(); | |||||
incompleteActions.put(action.getId(), action); | |||||
} | } | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public void addResolvedAction(AbstractAction action) throws IFException { | public void addResolvedAction(AbstractAction action) throws IFException { | ||||
assert action.isComplete(); | assert action.isComplete(); | ||||
assert action.hasID(); | |||||
AbstractAction noted = (AbstractAction)incompleteActions.remove(action.getID()); | |||||
assert action.hasId(); | |||||
AbstractAction noted = (AbstractAction)incompleteActions.remove(action.getId()); | |||||
if (noted != null) { | if (noted != null) { | ||||
completeActions.add(action); | completeActions.add(action); | ||||
} else { | } else { |
* Sets an ID to make the action referencable. | * Sets an ID to make the action referencable. | ||||
* @param id the ID | * @param id the ID | ||||
*/ | */ | ||||
public void setID(String id) { | |||||
public void setId(String id) { | |||||
this.id = id; | this.id = id; | ||||
} | } | ||||
* Returns an optional ID for this action. | * Returns an optional ID for this action. | ||||
* @return the ID or null | * @return the ID or null | ||||
*/ | */ | ||||
public String getID() { | |||||
public String getId() { | |||||
return this.id; | return this.id; | ||||
} | } | ||||
* Indicates whether the action has an ID and is therefore referencable. | * Indicates whether the action has an ID and is therefore referencable. | ||||
* @return true if the action has an ID | * @return true if the action has an ID | ||||
*/ | */ | ||||
public boolean hasID() { | |||||
public boolean hasId() { | |||||
return this.id != null; | return this.id != null; | ||||
} | } | ||||
* Returns a string that is used to prefix a generated ID to make it unique. | * Returns a string that is used to prefix a generated ID to make it unique. | ||||
* @return the prefix string | * @return the prefix string | ||||
*/ | */ | ||||
public String getIDPrefix() { | |||||
public String getIdPrefix() { | |||||
return null; | return null; | ||||
} | } | ||||
*/ | */ | ||||
public synchronized String generateNewID(AbstractAction action) { | public synchronized String generateNewID(AbstractAction action) { | ||||
this.lastGeneratedID++; | this.lastGeneratedID++; | ||||
String prefix = action.getIDPrefix(); | |||||
String prefix = action.getIdPrefix(); | |||||
if (prefix == null) { | if (prefix == null) { | ||||
throw new IllegalArgumentException("Action class is not compatible"); | throw new IllegalArgumentException("Action class is not compatible"); | ||||
} | } | ||||
* @return the action instance that should be used in place of the given one | * @return the action instance that should be used in place of the given one | ||||
*/ | */ | ||||
public AbstractAction put(AbstractAction action) { | public AbstractAction put(AbstractAction action) { | ||||
if (!action.hasID()) { | |||||
action.setID(generateNewID(action)); | |||||
if (!action.hasId()) { | |||||
action.setId(generateNewID(action)); | |||||
} | } | ||||
AbstractAction effAction = normalize(action); | AbstractAction effAction = normalize(action); | ||||
if (effAction == action) { | if (effAction == action) { | ||||
this.actionRegistry.put(action.getID(), action); | |||||
this.actionRegistry.put(action.getId(), action); | |||||
} | } | ||||
return effAction; | return effAction; | ||||
} | } |
implements DocumentNavigationExtensionConstants { | implements DocumentNavigationExtensionConstants { | ||||
/** Logger instance */ | /** Logger instance */ | ||||
protected static Log log = LogFactory.getLog(DocumentNavigationHandler.class); | |||||
protected static final Log log = LogFactory.getLog(DocumentNavigationHandler.class); | |||||
private StringBuffer content = new StringBuffer(); | private StringBuffer content = new StringBuffer(); | ||||
private Stack objectStack = new Stack(); | private Stack objectStack = new Stack(); | ||||
boolean newWindow = "new".equals(showDestination); | boolean newWindow = "new".equals(showDestination); | ||||
URIAction action = new URIAction(gotoURI, newWindow); | URIAction action = new URIAction(gotoURI, newWindow); | ||||
if (id != null) { | if (id != null) { | ||||
action.setID(id); | |||||
action.setId(id); | |||||
} | } | ||||
if (structurePointer != null) { | if (structurePointer != null) { | ||||
action.setStructurePointer(structurePointer); | action.setStructurePointer(structurePointer); |
* or null, if the position isn't known, yet | * or null, if the position isn't known, yet | ||||
*/ | */ | ||||
public GoToXYAction(String id, int pageIndex, Point targetLocation) { | public GoToXYAction(String id, int pageIndex, Point targetLocation) { | ||||
setID(id); | |||||
setId(id); | |||||
if (pageIndex < 0 && targetLocation != null) { | if (pageIndex < 0 && targetLocation != null) { | ||||
throw new IllegalArgumentException( | throw new IllegalArgumentException( | ||||
"Page index may not be null if target location is known!"); | "Page index may not be null if target location is known!"); | ||||
AttributesImpl atts = new AttributesImpl(); | AttributesImpl atts = new AttributesImpl(); | ||||
if (this.isCompleteExceptTargetLocation()) { | if (this.isCompleteExceptTargetLocation()) { | ||||
final Point reportedTargetLocation = this.getTargetLocation(); | final Point reportedTargetLocation = this.getTargetLocation(); | ||||
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, | ||||
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()); | |||||
} | } | ||||
handler.startElement(GOTO_XY.getNamespaceURI(), | handler.startElement(GOTO_XY.getNamespaceURI(), | ||||
GOTO_XY.getLocalName(), GOTO_XY.getQName(), atts); | GOTO_XY.getLocalName(), GOTO_XY.getQName(), atts); | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public String toString() { | public String toString() { | ||||
return "GoToXY: ID=" + getID() | |||||
return "GoToXY: ID=" + getId() | |||||
+ ", page=" + getPageIndex() | + ", page=" + getPageIndex() | ||||
+ ", loc=" + getTargetLocation() + ", " | + ", loc=" + getTargetLocation() + ", " | ||||
+ (isComplete() ? "complete" : "INCOMPLETE"); | + (isComplete() ? "complete" : "INCOMPLETE"); |
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public String getIDPrefix() { | |||||
public String getIdPrefix() { | |||||
return "fop-" + GOTO_URI.getLocalName(); | return "fop-" + GOTO_URI.getLocalName(); | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public void toSAX(ContentHandler handler) throws SAXException { | public void toSAX(ContentHandler handler) throws SAXException { | ||||
AttributesImpl atts = new AttributesImpl(); | AttributesImpl atts = new AttributesImpl(); | ||||
if (hasID()) { | |||||
atts.addAttribute(null, "id", "id", XMLUtil.CDATA, getID()); | |||||
if (hasId()) { | |||||
atts.addAttribute(null, "id", "id", XMLUtil.CDATA, getId()); | |||||
} | } | ||||
atts.addAttribute(null, "uri", "uri", XMLUtil.CDATA, getURI()); | atts.addAttribute(null, "uri", "uri", XMLUtil.CDATA, getURI()); | ||||
if (isNewWindow()) { | if (isNewWindow()) { |
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public void addResolvedAction(AbstractAction action) throws IFException { | public void addResolvedAction(AbstractAction action) throws IFException { | ||||
assert action.isComplete(); | assert action.isComplete(); | ||||
PDFAction pdfAction = (PDFAction)this.incompleteActions.remove(action.getID()); | |||||
PDFAction pdfAction = (PDFAction)this.incompleteActions.remove(action.getId()); | |||||
if (pdfAction == null) { | if (pdfAction == null) { | ||||
getAction(action); | getAction(action); | ||||
} else if (pdfAction instanceof PDFGoTo) { | } else if (pdfAction instanceof PDFGoTo) { | ||||
if (action == null) { | if (action == null) { | ||||
return null; | return null; | ||||
} | } | ||||
PDFAction pdfAction = (PDFAction)this.completeActions.get(action.getID()); | |||||
PDFAction pdfAction = (PDFAction)this.completeActions.get(action.getId()); | |||||
if (pdfAction != null) { | if (pdfAction != null) { | ||||
return pdfAction; | return pdfAction; | ||||
} else if (action instanceof GoToXYAction) { | } else if (action instanceof GoToXYAction) { | ||||
pdfAction = (PDFAction) incompleteActions.get(action.getID()); | |||||
pdfAction = (PDFAction) incompleteActions.get(action.getId()); | |||||
if (pdfAction != null) { | if (pdfAction != null) { | ||||
return pdfAction; | return pdfAction; | ||||
} else { | } else { | ||||
if (action.isComplete()) { | if (action.isComplete()) { | ||||
updateTargetLocation(pdfGoTo, a); | updateTargetLocation(pdfGoTo, a); | ||||
} else { | } else { | ||||
this.incompleteActions.put(action.getID(), pdfGoTo); | |||||
this.incompleteActions.put(action.getId(), pdfGoTo); | |||||
} | } | ||||
return pdfGoTo; | return pdfGoTo; | ||||
} | } | ||||
//Some PDF actions are pooled | //Some PDF actions are pooled | ||||
getPDFDoc().registerObject(pdfAction); | getPDFDoc().registerObject(pdfAction); | ||||
} | } | ||||
this.completeActions.put(action.getID(), pdfAction); | |||||
this.completeActions.put(action.getId(), pdfAction); | |||||
return pdfAction; | return pdfAction; | ||||
} else { | } else { | ||||
throw new UnsupportedOperationException("Unsupported action type: " | throw new UnsupportedOperationException("Unsupported action type: " | ||||
//Queue this object now that it's complete | //Queue this object now that it's complete | ||||
getPDFDoc().addObject(pdfGoTo); | getPDFDoc().addObject(pdfGoTo); | ||||
this.completeActions.put(action.getID(), pdfGoTo); | |||||
this.completeActions.put(action.getId(), pdfGoTo); | |||||
} | } | ||||
} | } |
implements ContentHandlerFactory.ObjectSource { | implements ContentHandlerFactory.ObjectSource { | ||||
/** Logger instance */ | /** Logger instance */ | ||||
protected static Log log = LogFactory.getLog(PDFExtensionHandler.class); | |||||
protected static final Log log = LogFactory.getLog(PDFExtensionHandler.class); | |||||
private Attributes lastAttributes; | private Attributes lastAttributes; | ||||
public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils { | public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils { | ||||
/** logging instance */ | /** logging instance */ | ||||
protected static Log log = LogFactory.getLog(PSFontUtils.class); | |||||
protected static final Log log = LogFactory.getLog(PSFontUtils.class); | |||||
/** | /** | ||||
* Generates the PostScript code for the font dictionary. This method should only be | * Generates the PostScript code for the font dictionary. This method should only be |
* Returns the image URI. | * Returns the image URI. | ||||
* @return the image URI | * @return the image URI | ||||
*/ | */ | ||||
public String getImageURI() { | |||||
public String getImageUri() { | |||||
return this.uri; | return this.uri; | ||||
} | } | ||||
private void generateFormForImage(PSGenerator gen, PSImageFormResource form) | private void generateFormForImage(PSGenerator gen, PSImageFormResource form) | ||||
throws IOException { | throws IOException { | ||||
final String uri = form.getImageURI(); | |||||
final String uri = form.getImageUri(); | |||||
ImageManager manager = userAgent.getFactory().getImageManager(); | ImageManager manager = userAgent.getFactory().getImageManager(); | ||||
ImageInfo info = null; | ImageInfo info = null; |
implements ContentHandlerFactory.ObjectSource { | implements ContentHandlerFactory.ObjectSource { | ||||
/** Logger instance */ | /** Logger instance */ | ||||
protected static Log log = LogFactory.getLog(PSExtensionHandler.class); | |||||
protected static final Log log = LogFactory.getLog(PSExtensionHandler.class); | |||||
private StringBuffer content = new StringBuffer(); | private StringBuffer content = new StringBuffer(); | ||||
private Attributes lastAttributes; | private Attributes lastAttributes; |
attrFont(fobj.getCommonFont(), attrib); | attrFont(fobj.getCommonFont(), attrib); | ||||
attrFontColor(fobj.getColor(), attrib); | attrFontColor(fobj.getColor(), attrib); | ||||
attrTextDecoration(fobj.getTextDecoration(), attrib); | attrTextDecoration(fobj.getTextDecoration(), attrib); | ||||
attrBaseLineShift(fobj.getBaseLineShift(), attrib); | |||||
attrBaseLineShift(fobj.getBaselineShift(), attrib); | |||||
return attrib; | return attrib; | ||||
} | } | ||||
private static int paraKeepTogetherOpen = 0; | private static int paraKeepTogetherOpen = 0; | ||||
private static boolean paraResetProperties = false; | private static boolean paraResetProperties = false; | ||||
private static ParagraphKeeptogetherContext instance = null; | |||||
private ParagraphKeeptogetherContext() { | private ParagraphKeeptogetherContext() { | ||||
} | } | ||||
/** | |||||
* Singelton. | |||||
* | |||||
* @return The instance of ParagraphKeeptogetherContext | |||||
*/ | |||||
public static ParagraphKeeptogetherContext getInstance() { | |||||
if (instance == null) { | |||||
instance = new ParagraphKeeptogetherContext(); | |||||
} | |||||
return instance; | |||||
} | |||||
/** | /** | ||||
* @return the level of current "keep whith next" paragraph | * @return the level of current "keep whith next" paragraph | ||||
*/ | */ |
private static final String PARA_KEEP_OFF = "para-keep:off"; | private static final String PARA_KEEP_OFF = "para-keep:off"; | ||||
private final RtfAttributes attrib; | private final RtfAttributes attrib; | ||||
private ParagraphKeeptogetherContext paragraphKeeptogetherContext; | |||||
RtfJforCmd(RtfContainer parent, Writer w, RtfAttributes attrs) throws IOException { | RtfJforCmd(RtfContainer parent, Writer w, RtfAttributes attrs) throws IOException { | ||||
super((RtfContainer)parent, w); | super((RtfContainer)parent, w); | ||||
attrib = attrs; | attrib = attrs; | ||||
paragraphKeeptogetherContext = ParagraphKeeptogetherContext.getInstance(); | |||||
} | } | ||||
/** | /** | ||||
* logging instance | * logging instance | ||||
*/ | */ | ||||
protected static Log log = LogFactory.getLog(RtfTextrun.class); | |||||
protected static final Log log = LogFactory.getLog(RtfTextrun.class); | |||||
/** Manager for handling space-* property. */ | /** Manager for handling space-* property. */ | ||||
private RtfSpaceManager rtfSpaceManager = new RtfSpaceManager(); | private RtfSpaceManager rtfSpaceManager = new RtfSpaceManager(); | ||||
//add RtfSpaceSplitter to inherit accumulated space | //add RtfSpaceSplitter to inherit accumulated space | ||||
rtfSpaceManager.pushRtfSpaceSplitter(attrs); | rtfSpaceManager.pushRtfSpaceSplitter(attrs); | ||||
rtfSpaceManager.setCandidate(attrs); | rtfSpaceManager.setCandidate(attrs); | ||||
RtfString r = new RtfString(this, writer, s); | |||||
rtfSpaceManager.popRtfSpaceSplitter(); | rtfSpaceManager.popRtfSpaceSplitter(); | ||||
} | } | ||||
ListIterator lit = children.listIterator(children.size()); | ListIterator lit = children.listIterator(children.size()); | ||||
while (lit.hasPrevious() | while (lit.hasPrevious() | ||||
&& (lit.previous() instanceof RtfCloseGroupMark)) { | && (lit.previous() instanceof RtfCloseGroupMark)) { | ||||
tmp.push(new Integer(((RtfCloseGroupMark)lit.next()).getBreakType())); | |||||
tmp.push(Integer.valueOf(((RtfCloseGroupMark)lit.next()).getBreakType())); | |||||
lit.remove(); | lit.remove(); | ||||
deletedCloseGroupCount++; | deletedCloseGroupCount++; | ||||
} | } |
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public String getNamespace() { | |||||
public String getNameSpace() { | |||||
return null; //Handle all XML content | return null; //Handle all XML content | ||||
} | } | ||||