diff options
author | Glen Mazza <gmazza@apache.org> | 2004-06-18 04:13:54 +0000 |
---|---|---|
committer | Glen Mazza <gmazza@apache.org> | 2004-06-18 04:13:54 +0000 |
commit | c92ecf9bf2632fe049d641c2fa129d9ba836ea9d (patch) | |
tree | 599dda1364bd99566f375249ee4252a56d22d396 /src/java/org | |
parent | ea13be29f9ebac2fa09fa8770bee8a93ab0d4a52 (diff) | |
download | xmlgraphics-fop-c92ecf9bf2632fe049d641c2fa129d9ba836ea9d.tar.gz xmlgraphics-fop-c92ecf9bf2632fe049d641c2fa129d9ba836ea9d.zip |
1. FOTreeBuilder modified to handle more of the renderer initialization.
2. AreaTree now takes a Renderer as a constructor, handles RenderPagesModel initialization.
3. FontInfo object moved from Driver/Document to fo.FOInputHandler.
4. getFontState/getFontInfo now take a fontInfo object directly instead of a apps.Document.
5. validity checking added to PageSequence.java
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197734 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org')
-rw-r--r-- | src/java/org/apache/fop/apps/Document.java | 14 | ||||
-rw-r--r-- | src/java/org/apache/fop/apps/Driver.java | 14 | ||||
-rw-r--r-- | src/java/org/apache/fop/area/AreaTree.java | 5 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/FOInputHandler.java | 15 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/FOTreeHandler.java | 31 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/FObjMixed.java | 4 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/PropertyManager.java | 34 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/flow/Leader.java | 2 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/flow/PageNumber.java | 2 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/flow/PageNumberCitation.java | 2 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/pagination/PageSequence.java | 179 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/pagination/Title.java | 2 | ||||
-rw-r--r-- | src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java | 2 | ||||
-rw-r--r-- | src/java/org/apache/fop/render/mif/MIFHandler.java | 2 | ||||
-rw-r--r-- | src/java/org/apache/fop/render/rtf/RTFHandler.java | 2 | ||||
-rw-r--r-- | src/java/org/apache/fop/tools/AreaTreeBuilder.java | 24 |
16 files changed, 174 insertions, 160 deletions
diff --git a/src/java/org/apache/fop/apps/Document.java b/src/java/org/apache/fop/apps/Document.java index 141ed6526..a910084d6 100644 --- a/src/java/org/apache/fop/apps/Document.java +++ b/src/java/org/apache/fop/apps/Document.java @@ -20,7 +20,6 @@ package org.apache.fop.apps; // FOP import org.apache.fop.fo.FOInputHandler; -import org.apache.fop.fonts.FontInfo; import org.apache.fop.render.Renderer; // SAX @@ -35,9 +34,6 @@ public class Document { /** The parent Driver object */ private Driver driver; - /** The Font information relevant for this document */ - private FontInfo fontInfo; - /** The Renderer being used for this document */ protected Renderer renderer; @@ -53,15 +49,6 @@ public class Document { */ public Document(Driver driver) { this.driver = driver; - this.fontInfo = new FontInfo(); - } - - /** - * Retrieve the font information for this document - * @return the FontInfo instance for this document - */ - public FontInfo getFontInfo() { - return this.fontInfo; } /** @@ -74,7 +61,6 @@ public class Document { /** * Get the renderer for this document - * * @return the renderer for this document */ public Renderer getRenderer() { diff --git a/src/java/org/apache/fop/apps/Driver.java b/src/java/org/apache/fop/apps/Driver.java index afdee0e4d..9808c1cdf 100644 --- a/src/java/org/apache/fop/apps/Driver.java +++ b/src/java/org/apache/fop/apps/Driver.java @@ -488,19 +488,7 @@ public class Driver { } currentDocument.renderer = renderer; - foInputHandler = new FOTreeHandler(currentDocument, true); - - try { - renderer.setupFontInfo(currentDocument.getFontInfo()); - // check that the "any,normal,400" font exists - if (!currentDocument.getFontInfo().isSetupValid()) { - throw new FOPException( - "No default font defined by OutputConverter"); - } - renderer.startRenderer(stream); - } catch (IOException e) { - throw new FOPException(e); - } + foInputHandler = new FOTreeHandler(currentDocument, stream, true); } currentDocument.foInputHandler = foInputHandler; diff --git a/src/java/org/apache/fop/area/AreaTree.java b/src/java/org/apache/fop/area/AreaTree.java index 2c5d57b05..ab7c1562c 100644 --- a/src/java/org/apache/fop/area/AreaTree.java +++ b/src/java/org/apache/fop/area/AreaTree.java @@ -21,6 +21,7 @@ package org.apache.fop.area; import org.apache.fop.area.extensions.BookmarkData; import org.apache.fop.fo.extensions.Outline; import org.apache.fop.fo.extensions.Bookmarks; +import org.apache.fop.render.Renderer; import java.util.ArrayList; import java.util.List; @@ -67,7 +68,9 @@ public class AreaTree { /** * Constructor. */ - public AreaTree () { + public AreaTree (Renderer renderer) { + // this.atModel = new CachedRenderPagesModel(renderer); + setTreeModel(new RenderPagesModel(renderer)); } diff --git a/src/java/org/apache/fop/fo/FOInputHandler.java b/src/java/org/apache/fop/fo/FOInputHandler.java index 67176aa2b..8616185dd 100644 --- a/src/java/org/apache/fop/fo/FOInputHandler.java +++ b/src/java/org/apache/fop/fo/FOInputHandler.java @@ -45,6 +45,7 @@ import org.apache.fop.fo.flow.TableCell; import org.apache.fop.fo.flow.TableRow; import org.apache.fop.fo.pagination.Flow; import org.apache.fop.fo.pagination.PageSequence; +import org.apache.fop.fonts.FontInfo; import org.apache.commons.logging.Log; import org.xml.sax.SAXException; @@ -67,6 +68,11 @@ public abstract class FOInputHandler { */ public Document doc = null; + /** + * The Font information relevant for this document + */ + protected FontInfo fontInfo; + /** * logging instance */ @@ -85,6 +91,7 @@ public abstract class FOInputHandler { */ public FOInputHandler(Document document) { doc = document; + this.fontInfo = new FontInfo(); } /** @@ -128,6 +135,14 @@ public abstract class FOInputHandler { } /** + * Retrieve the font information for this document + * @return the FontInfo instance for this document + */ + public FontInfo getFontInfo() { + return this.fontInfo; + } + + /** * This method is called to indicate the start of a new document run. * @throws SAXException In case of a problem */ diff --git a/src/java/org/apache/fop/fo/FOTreeHandler.java b/src/java/org/apache/fop/fo/FOTreeHandler.java index 549c73d3b..71433631b 100644 --- a/src/java/org/apache/fop/fo/FOTreeHandler.java +++ b/src/java/org/apache/fop/fo/FOTreeHandler.java @@ -20,6 +20,7 @@ package org.apache.fop.fo; // Java import java.io.IOException; +import java.io.OutputStream; import java.util.HashSet; import java.util.Iterator; @@ -30,7 +31,6 @@ import org.xml.sax.SAXException; import org.apache.fop.apps.Document; import org.apache.fop.apps.FOPException; import org.apache.fop.area.AreaTree; -import org.apache.fop.area.RenderPagesModel; import org.apache.fop.area.Title; import org.apache.fop.fo.extensions.Bookmarks; import org.apache.fop.fo.flow.BasicLink; @@ -104,15 +104,27 @@ public class FOTreeHandler extends FOInputHandler { * Main constructor * @param document the apps.Document implementation that governs this * FO Tree + * @param OutputStream stream to use to output results of renderer + * * @param store if true then use the store pages model and keep the * area tree in memory */ - public FOTreeHandler(Document doc, boolean store) { + public FOTreeHandler(Document doc, OutputStream stream, boolean store) throws FOPException { super(doc); - areaTree = new AreaTree(); - // this.atModel = new CachedRenderPagesModel(renderer); - areaTree.setTreeModel(new RenderPagesModel(doc.getRenderer())); + areaTree = new AreaTree(doc.getRenderer()); + + try { + doc.getRenderer().setupFontInfo(fontInfo); + // check that the "any,normal,400" font exists + if (!fontInfo.isSetupValid()) { + throw new FOPException( + "No default font defined by OutputConverter"); + } + doc.getRenderer().startRenderer(stream); + } catch (IOException e) { + throw new FOPException(e); + } if (collectStatistics) { runtime = Runtime.getRuntime(); @@ -483,15 +495,6 @@ public class FOTreeHandler extends FOInputHandler { } /** - * Get the font information for the layout handler. - * - * @return the font information - */ - public Document getFontInfo() { - return doc; - } - - /** * Runs the formatting of this page sequence into the given area tree * * @param pageSeq the PageSequence to be formatted diff --git a/src/java/org/apache/fop/fo/FObjMixed.java b/src/java/org/apache/fop/fo/FObjMixed.java index 343787701..18ddcf4e4 100644 --- a/src/java/org/apache/fop/fo/FObjMixed.java +++ b/src/java/org/apache/fop/fo/FObjMixed.java @@ -46,8 +46,8 @@ public class FObjMixed extends FObj { if (textInfo == null) { // Really only need one of these, but need to get fontInfo // stored in propMgr for later use. - propMgr.setFontInfo(getFOInputHandler().getDocument()); - textInfo = propMgr.getTextLayoutProps(getFOInputHandler().getDocument()); + propMgr.setFontInfo(getFOInputHandler().getFontInfo()); + textInfo = propMgr.getTextLayoutProps(getFOInputHandler().getFontInfo()); } FOText ft = new FOText(data, start, length, textInfo, this); diff --git a/src/java/org/apache/fop/fo/PropertyManager.java b/src/java/org/apache/fop/fo/PropertyManager.java index 972a224f4..00033b28c 100644 --- a/src/java/org/apache/fop/fo/PropertyManager.java +++ b/src/java/org/apache/fop/fo/PropertyManager.java @@ -19,9 +19,9 @@ package org.apache.fop.fo; // FOP -import org.apache.fop.apps.Document; import org.apache.fop.apps.FOPException; import org.apache.fop.fonts.Font; +import org.apache.fop.fonts.FontInfo; import org.apache.fop.fo.properties.Property; import org.apache.fop.fo.properties.CommonBorderAndPadding; import org.apache.fop.fo.properties.CommonMarginBlock; @@ -45,7 +45,7 @@ import org.xml.sax.Attributes; public class PropertyManager implements Constants { private PropertyList propertyList; - private Document document = null; + private FontInfo fontInfo = null; private Font fontState = null; private CommonBorderAndPadding borderAndPadding = null; private CommonHyphenation hyphProps = null; @@ -71,13 +71,12 @@ public class PropertyManager implements Constants { } /** - * Sets the Document object telling the property manager which fonts are + * Sets the FontInfo object telling the property manager which fonts are * available. - * @param document apps.Document implementation containing font - * information + * @param fontInfo FontInfo object */ - public void setFontInfo(Document document) { - this.document = document; + public void setFontInfo(FontInfo fontInfo) { + this.fontInfo = fontInfo; } @@ -88,12 +87,12 @@ public class PropertyManager implements Constants { * information * @return a FontState object */ - public Font getFontState(Document document) { + public Font getFontState(FontInfo fontInfo) { if (fontState == null) { - if (document == null) { - document = this.document; - } else if (this.document == null) { - this.document = document; + if (fontInfo == null) { + fontInfo = this.fontInfo; + } else if (this.fontInfo == null) { + this.fontInfo = fontInfo; } /**@todo this is ugly. need to improve. */ @@ -122,9 +121,9 @@ public class PropertyManager implements Constants { // various kinds of keywords too int fontSize = propertyList.get(PR_FONT_SIZE).getLength().getValue(); //int fontVariant = propertyList.get("font-variant").getEnum(); - String fname = document.getFontInfo().fontLookup(fontFamily, fontStyle, + String fname = fontInfo.fontLookup(fontFamily, fontStyle, fontWeight); - FontMetrics metrics = document.getFontInfo().getMetricsFor(fname); + FontMetrics metrics = fontInfo.getMetricsFor(fname); fontState = new Font(fname, metrics, fontSize); } return fontState; @@ -458,14 +457,13 @@ public class PropertyManager implements Constants { /** * Constructs a TextInfo objects. If it was constructed before it is * reused. - * @param document apps.Document implementation containing list of - * available fonts + * @param fontInfo FontInfo object containing list of available fonts * @return a TextInfo object */ - public TextInfo getTextLayoutProps(Document document) { + public TextInfo getTextLayoutProps(FontInfo fontInfo) { if (textInfo == null) { textInfo = new TextInfo(); - textInfo.fs = getFontState(document); + textInfo.fs = getFontState(fontInfo); textInfo.color = propertyList.get(PR_COLOR).getColorType(); textInfo.verticalAlign = diff --git a/src/java/org/apache/fop/fo/flow/Leader.java b/src/java/org/apache/fop/fo/flow/Leader.java index 3ba0eade2..42837265e 100644 --- a/src/java/org/apache/fop/fo/flow/Leader.java +++ b/src/java/org/apache/fop/fo/flow/Leader.java @@ -66,7 +66,7 @@ public class Leader extends FObjMixed { CommonBackground bProps = propMgr.getBackgroundProps(); // Common Font Properties - this.fontState = propMgr.getFontState(getFOInputHandler().getDocument()); + this.fontState = propMgr.getFontState(getFOInputHandler().getFontInfo()); // Common Margin Properties-Inline CommonMarginInline mProps = propMgr.getMarginInlineProps(); diff --git a/src/java/org/apache/fop/fo/flow/PageNumber.java b/src/java/org/apache/fop/fo/flow/PageNumber.java index 593c10df4..c9b60f3d5 100644 --- a/src/java/org/apache/fop/fo/flow/PageNumber.java +++ b/src/java/org/apache/fop/fo/flow/PageNumber.java @@ -77,7 +77,7 @@ public class PageNumber extends FObj { CommonBackground bProps = propMgr.getBackgroundProps(); // Common Font Properties - this.fontState = propMgr.getFontState(getFOInputHandler().getDocument()); + this.fontState = propMgr.getFontState(getFOInputHandler().getFontInfo()); // Common Margin Properties-Inline CommonMarginInline mProps = propMgr.getMarginInlineProps(); diff --git a/src/java/org/apache/fop/fo/flow/PageNumberCitation.java b/src/java/org/apache/fop/fo/flow/PageNumberCitation.java index 7b343d66c..7084305fc 100644 --- a/src/java/org/apache/fop/fo/flow/PageNumberCitation.java +++ b/src/java/org/apache/fop/fo/flow/PageNumberCitation.java @@ -82,7 +82,7 @@ public class PageNumberCitation extends FObj { CommonBackground bProps = propMgr.getBackgroundProps(); // Common Font Properties - this.fontState = propMgr.getFontState(getFOInputHandler().getDocument()); + this.fontState = propMgr.getFontState(getFOInputHandler().getFontInfo()); // Common Margin Properties-Inline CommonMarginInline mProps = propMgr.getMarginInlineProps(); diff --git a/src/java/org/apache/fop/fo/pagination/PageSequence.java b/src/java/org/apache/fop/fo/pagination/PageSequence.java index fc4d041d7..33e8e044a 100644 --- a/src/java/org/apache/fop/fo/pagination/PageSequence.java +++ b/src/java/org/apache/fop/fo/pagination/PageSequence.java @@ -23,10 +23,12 @@ import java.util.HashMap; // XML import org.xml.sax.Attributes; +import org.xml.sax.Locator; // FOP import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; +import org.apache.fop.fo.FOElementMapping; import org.apache.fop.fo.FOTreeVisitor; import org.apache.fop.apps.FOPException; @@ -131,6 +133,103 @@ public class PageSequence extends FObj { } /** + * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String) + XSL/FOP Content Model: (title?,static-content*,flow) + */ + protected void validateChildNode(Locator loc, String nsURI, String localName) { + if (nsURI == FOElementMapping.URI) { + if (localName.equals("title")) { + if (titleFO != null) { + tooManyNodesError(loc, "fo:title"); + } else if (flowMap.size() > 0) { + nodesOutOfOrderError(loc, "fo:title", "fo:static-content"); + } else if (mainFlow != null) { + nodesOutOfOrderError(loc, "fo:title", "fo:flow"); + } + } else if (localName.equals("static-content")) { + if (mainFlow != null) { + nodesOutOfOrderError(loc, "fo:static-content", "fo:flow"); + } + } else if (localName.equals("flow")) { + if (mainFlow != null) { + tooManyNodesError(loc, "fo:flow"); + } + } else { + invalidChildError(loc, nsURI, localName); + } + } else { + invalidChildError(loc, nsURI, localName); + } + } + + /** + * Signal end of this xml element. + * This passes the end page sequence to the structure handler + * so it can act upon that. + */ + protected void end() { + if (mainFlow == null) { + missingChildElementError("(title?,static-content*,flow)"); + } + try { + getFOInputHandler().endPageSequence(this); + } catch (FOPException fopex) { + getLogger().error("Error in PageSequence.end(): " + + fopex.getMessage(), fopex); + } + } + + /** + * Validate the child being added and initialize internal variables. + * XSL content model for page-sequence: + * <pre>(title?,static-content*,flow)</pre> + * + * @param child The flow object child to be added to the PageSequence. + */ + public void addChild(FONode child) { + try { + String childName = child.getName(); + if (childName.equals("fo:title")) { + this.titleFO = (Title)child; + } else if (childName.equals("fo:flow")) { + this.mainFlow = (Flow)child; + String flowName = this.mainFlow.getFlowName(); + if (flowMap.containsKey(flowName)) { + throw new FOPException("flow-name " + + flowName + + " is not unique within an fo:page-sequence"); + } + if (!this.layoutMasterSet.regionNameExists(flowName)) { + getLogger().error("region-name '" + + flowName + + "' doesn't exist in the layout-master-set."); + } + // Don't add main flow to the flow map +// addFlow(mainFlow); + startStructuredPageSequence(); + super.addChild(child); // For getChildren + } else if (childName.equals("fo:static-content")) { + String flowName = ((StaticContent)child).getFlowName(); + if (flowMap.containsKey(flowName)) { + throw new FOPException("flow-name " + flowName + + " is not unique within an fo:page-sequence"); + } + if (!this.layoutMasterSet.regionNameExists(flowName)) { + throw new FOPException("region-name '" + flowName + + "' doesn't exist in the layout-master-set."); + } + flowMap.put(flowName, child); +// addFlow((Flow)child); + startStructuredPageSequence(); + } + } catch (FOPException fopex) { + getLogger().error("Error in PageSequence.addChild(): " + + fopex.getMessage(), fopex); + } + } + + + /** * @see org.apache.fop.fo.FObj#addProperties */ protected void addProperties(Attributes attlist) throws FOPException { @@ -221,73 +320,6 @@ public class PageSequence extends FObj { /** - * Validate the child being added and initialize internal variables. - * XSL content model for page-sequence: - * <pre>(title?,static-content*,flow)</pre> - * - * @param child The flow object child to be added to the PageSequence. - */ - public void addChild(FONode child) { - try { - String childName = child.getName(); - if (childName.equals("fo:title")) { - if (this.flowMap.size() > 0) { - getLogger().warn("fo:title should be first in page-sequence"); - } else { - this.titleFO = (Title)child; - } - } else if (childName.equals("fo:flow")) { - if (this.mainFlow != null) { - throw new FOPException("Only a single fo:flow permitted" - + " per fo:page-sequence"); - } else { - this.mainFlow = (Flow)child; - String flowName = this.mainFlow.getFlowName(); - if (flowMap.containsKey(flowName)) { - throw new FOPException("flow-name " - + flowName - + " is not unique within an fo:page-sequence"); - } - if (!this.layoutMasterSet.regionNameExists(flowName)) { - getLogger().error("region-name '" - + flowName - + "' doesn't exist in the layout-master-set."); - } - // Don't add main flow to the flow map -// addFlow(mainFlow); - startStructuredPageSequence(); - super.addChild(child); // For getChildren - } - } else if (childName.equals("fo:static-content")) { - if (this.mainFlow != null) { - throw new FOPException(childName - + " must precede fo:flow; ignoring"); - } - String flowName = ((StaticContent)child).getFlowName(); - if (flowMap.containsKey(flowName)) { - throw new FOPException("flow-name " + flowName - + " is not unique within an fo:page-sequence"); - } - if (!this.layoutMasterSet.regionNameExists(flowName)) { - getLogger().error("region-name '" + flowName - + "' doesn't exist in the layout-master-set."); - } - flowMap.put(flowName, child); -// addFlow((Flow)child); - startStructuredPageSequence(); - } else { - // Ignore it! - getLogger().warn("FO '" + childName - + "' not a legal page-sequence child."); - return; - } - } catch (FOPException fopex) { - getLogger().error("Error in PageSequence.addChild(): " - + fopex.getMessage(), fopex); - } - } - - /** * Start the page-sequence logic in the Structured Handler */ private void startStructuredPageSequence() { @@ -297,19 +329,6 @@ public class PageSequence extends FObj { } } - /** - * Signal end of this xml element. - * This passes the end page sequence to the structure handler - * so it can act upon that. - */ - protected void end() { - try { - getFOInputHandler().endPageSequence(this); - } catch (FOPException fopex) { - getLogger().error("Error in PageSequence.end(): " - + fopex.getMessage(), fopex); - } - } /** * Initialize the current page number for the start of the page sequence. diff --git a/src/java/org/apache/fop/fo/pagination/Title.java b/src/java/org/apache/fop/fo/pagination/Title.java index a3b45b74b..70a24b9cc 100644 --- a/src/java/org/apache/fop/fo/pagination/Title.java +++ b/src/java/org/apache/fop/fo/pagination/Title.java @@ -59,7 +59,7 @@ public class Title extends FObjMixed { CommonBackground bProps = propMgr.getBackgroundProps(); // Common Font Properties - Font fontState = propMgr.getFontState(getFOInputHandler().getDocument()); + Font fontState = propMgr.getFontState(getFOInputHandler().getFontInfo()); // Common Margin Properties-Inline CommonMarginInline mProps = propMgr.getMarginInlineProps(); diff --git a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java index 35d640c4d..422da40d9 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java @@ -74,7 +74,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager { childLMiter = new BlockLMiter(this, childLMiter); userAgent = inBlock.getUserAgent(); setBlockTextInfo(inBlock.getPropertyManager().getTextLayoutProps( - inBlock.getFOInputHandler().getDocument())); + inBlock.getFOInputHandler().getFontInfo())); } private void setBlockTextInfo(TextInfo ti) { diff --git a/src/java/org/apache/fop/render/mif/MIFHandler.java b/src/java/org/apache/fop/render/mif/MIFHandler.java index c4283f566..4bfd23f3a 100644 --- a/src/java/org/apache/fop/render/mif/MIFHandler.java +++ b/src/java/org/apache/fop/render/mif/MIFHandler.java @@ -75,7 +75,7 @@ public class MIFHandler extends FOInputHandler { public MIFHandler(Document doc, OutputStream os) { super(doc); outStream = os; - FontSetup.setup(doc.getFontInfo(), null); + FontSetup.setup(fontInfo, null); } /** diff --git a/src/java/org/apache/fop/render/rtf/RTFHandler.java b/src/java/org/apache/fop/render/rtf/RTFHandler.java index a57f91fba..3f508ea35 100644 --- a/src/java/org/apache/fop/render/rtf/RTFHandler.java +++ b/src/java/org/apache/fop/render/rtf/RTFHandler.java @@ -131,7 +131,7 @@ public class RTFHandler extends FOInputHandler { bDefer = false; bDeferredExecution = false; iNestCount=0; - FontSetup.setup(doc.getFontInfo(), null); + FontSetup.setup(fontInfo, null); log.warn(ALPHA_WARNING); } diff --git a/src/java/org/apache/fop/tools/AreaTreeBuilder.java b/src/java/org/apache/fop/tools/AreaTreeBuilder.java index 71b36ecbf..d2d0baff9 100644 --- a/src/java/org/apache/fop/tools/AreaTreeBuilder.java +++ b/src/java/org/apache/fop/tools/AreaTreeBuilder.java @@ -160,13 +160,13 @@ public class AreaTreeBuilder { } rend.setLogger(logger); - org.apache.fop.apps.Document doc = new org.apache.fop.apps.Document(null); - rend.setupFontInfo(doc.getFontInfo()); + FontInfo fontInfo = new FontInfo(); + rend.setupFontInfo(fontInfo); FOUserAgent ua = new FOUserAgent(); rend.setUserAgent(ua); StorePagesModel sm = AreaTree.createStorePagesModel(); - TreeLoader tl = new TreeLoader(doc); + TreeLoader tl = new TreeLoader(rend, fontInfo); tl.setLogger(logger); tl.setTreeModel(sm); try { @@ -238,12 +238,14 @@ public class AreaTreeBuilder { class TreeLoader { private AreaTree areaTree; private AreaTreeModel model; - private org.apache.fop.apps.Document document; + private Renderer renderer; + private FontInfo fontInfo; private Font currentFontState; private Log logger = null; - TreeLoader(org.apache.fop.apps.Document doc) { - document = doc; + TreeLoader(Renderer renderer, FontInfo fontInfo) { + this.renderer = renderer; + this.fontInfo = fontInfo; } /** @@ -271,7 +273,7 @@ class TreeLoader { Element root = null; root = doc.getDocumentElement(); - areaTree = new AreaTree(); + areaTree = new AreaTree(renderer); areaTree.setTreeModel(model); readAreaTree(root); @@ -558,8 +560,8 @@ class TreeLoader { Character ch = new Character(getString((Element) obj).charAt(0)); addTraits((Element) obj, ch); - String fname = document.getFontInfo().fontLookup("sans-serif", "normal", Font.NORMAL); - FontMetrics metrics = document.getFontInfo().getMetricsFor(fname); + String fname = fontInfo.fontLookup("sans-serif", "normal", Font.NORMAL); + FontMetrics metrics = fontInfo.getMetricsFor(fname); currentFontState = new Font(fname, metrics, 12000); @@ -583,8 +585,8 @@ class TreeLoader { list.add(leader); } } else if (obj.getNodeName().equals("word")) { - String fname = document.getFontInfo().fontLookup("sans-serif", "normal", Font.NORMAL); - FontMetrics metrics = document.getFontInfo().getMetricsFor(fname); + String fname = fontInfo.fontLookup("sans-serif", "normal", Font.NORMAL); + FontMetrics metrics = fontInfo.getMetricsFor(fname); currentFontState = new Font(fname, metrics, 12000); TextArea text = getText((Element) obj); |