vmote 2003/08/15 23:43:51 Modified: src/java/org/apache/fop/apps Driver.java src/java/org/apache/fop/fo FONode.java FOTreeBuilder.java FObjMixed.java PropertyManager.java XMLObj.java src/java/org/apache/fop/fo/flow InstreamForeignObject.java src/java/org/apache/fop/fo/pagination Root.java Log: 1. tie Document to fo.FOTreeBuilder and fo.pagination.Root 2. add getDocument() method to FONode (using this.parent for all nodes except Root) 3. start using getDocument() to gain access to font collections stored in Document Revision Changes Path 1.26 +1 -0 xml-fop/src/java/org/apache/fop/apps/Driver.java Index: Driver.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/apps/Driver.java,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- Driver.java 15 Aug 2003 20:37:51 -0000 1.25 +++ Driver.java 16 Aug 2003 06:43:50 -0000 1.26 @@ -601,6 +601,7 @@ if (foInputHandler instanceof FOTreeHandler) { currentDocument.setLayoutStrategy(new LayoutManagerLS()); } + treeBuilder.document = currentDocument; try { if (foInputHandler instanceof FOTreeHandler) { FOTreeHandler foTreeHandler = (FOTreeHandler)foInputHandler; 1.6 +6 -0 xml-fop/src/java/org/apache/fop/fo/FONode.java Index: FONode.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FONode.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- FONode.java 29 Jul 2003 18:42:31 -0000 1.5 +++ FONode.java 16 Aug 2003 06:43:51 -0000 1.6 @@ -61,6 +61,7 @@ // FOP import org.apache.fop.apps.FOPException; +import org.apache.fop.control.Document; import org.apache.fop.util.CharUtilities; /** @@ -209,5 +210,10 @@ protected boolean isMarker() { return false; } + + public Document getDocument() { + return parent.getDocument(); + } + } 1.10 +7 -2 xml-fop/src/java/org/apache/fop/fo/FOTreeBuilder.java Index: FOTreeBuilder.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FOTreeBuilder.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- FOTreeBuilder.java 29 Jul 2003 19:33:29 -0000 1.9 +++ FOTreeBuilder.java 16 Aug 2003 06:43:51 -0000 1.10 @@ -54,6 +54,8 @@ import java.util.HashMap; import java.util.Map; import java.util.Set; +import org.apache.fop.control.Document; +import org.apache.fop.fo.pagination.Root; // SAX import org.apache.avalon.framework.logger.Logger; @@ -110,7 +112,7 @@ /** * The root of the formatting object tree */ - protected FONode rootFObj = null; + protected Root rootFObj = null; /** * The class that handles formatting and rendering to a stream @@ -120,6 +122,8 @@ private FOUserAgent userAgent; + public Document document; + /** * Default constructor */ @@ -290,7 +294,8 @@ + " be fo:root, not " + fobj.getName())); } - rootFObj = fobj; + rootFObj = (Root)fobj; + rootFObj.setDocument(document); } else { currentFObj.addChild(fobj); } 1.7 +2 -2 xml-fop/src/java/org/apache/fop/fo/FObjMixed.java Index: FObjMixed.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FObjMixed.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- FObjMixed.java 14 Aug 2003 07:42:58 -0000 1.6 +++ FObjMixed.java 16 Aug 2003 06:43:51 -0000 1.7 @@ -104,8 +104,8 @@ if (textInfo == null) { // Really only need one of these, but need to get fontInfo // stored in propMgr for later use. - propMgr.setFontInfo(fontInfo); - textInfo = propMgr.getTextLayoutProps(fontInfo); + propMgr.setFontInfo(getDocument()); + textInfo = propMgr.getTextLayoutProps(getDocument()); } FOText ft = new FOText(data, start, length, textInfo, this); 1.7 +16 -16 xml-fop/src/java/org/apache/fop/fo/PropertyManager.java Index: PropertyManager.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/PropertyManager.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- PropertyManager.java 14 Aug 2003 15:31:09 -0000 1.6 +++ PropertyManager.java 16 Aug 2003 06:43:51 -0000 1.7 @@ -83,7 +83,7 @@ public class PropertyManager { private PropertyList properties; - private Document fontInfo = null; + private Document doc = null; private Font fontState = null; private CommonBorderAndPadding borderAndPadding = null; private CommonHyphenation hyphProps = null; @@ -118,27 +118,27 @@ } /** - * Sets the FontInfo object telling the property manager which fonts are + * Sets the Document object telling the property manager which fonts are * available. - * @param fontInfo available fonts + * @param doc Document containing font information */ - public void setFontInfo(Document fontInfo) { - this.fontInfo = fontInfo; + public void setFontInfo(Document doc) { + this.doc = doc; } /** * Constructs a FontState object. If it was constructed before it is * reused. - * @param fontInfo FontInfo to work with + * @param doc Document containing the font information * @return a FontState object */ - public Font getFontState(Document fontInfo) { + public Font getFontState(Document doc) { if (fontState == null) { - if (fontInfo == null) { - fontInfo = this.fontInfo; - } else if (this.fontInfo == null) { - this.fontInfo = fontInfo; + if (doc == null) { + doc = this.doc; + } else if (this.doc == null) { + this.doc = doc; } /[EMAIL PROTECTED] this is ugly. need to improve. */ @@ -167,9 +167,9 @@ // various kinds of keywords too int fontSize = properties.get("font-size").getLength().getValue(); //int fontVariant = properties.get("font-variant").getEnum(); - String fname = fontInfo.fontLookup(fontFamily, fontStyle, + String fname = doc.fontLookup(fontFamily, fontStyle, fontWeight); - FontMetrics metrics = fontInfo.getMetricsFor(fname); + FontMetrics metrics = doc.getMetricsFor(fname); fontState = new Font(fname, metrics, fontSize); } return fontState; @@ -476,13 +476,13 @@ /** * Constructs a TextInfo objects. If it was constructed before it is * reused. - * @param fontInfo available fonts + * @param doc Document containing list of available fonts * @return a TextInfo object */ - public TextInfo getTextLayoutProps(Document fontInfo) { + public TextInfo getTextLayoutProps(Document doc) { if (textInfo == null) { textInfo = new TextInfo(); - textInfo.fs = getFontState(fontInfo); + textInfo.fs = getFontState(doc); textInfo.color = properties.get("color").getColorType(); textInfo.verticalAlign = 1.3 +1 -1 xml-fop/src/java/org/apache/fop/fo/XMLObj.java Index: XMLObj.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/XMLObj.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- XMLObj.java 14 Jul 2003 14:14:03 -0000 1.2 +++ XMLObj.java 16 Aug 2003 06:43:51 -0000 1.3 @@ -102,7 +102,7 @@ /** * @return DOM document representing this foreign XML */ - public Document getDocument() { + public Document getDOMDocument() { return doc; } 1.4 +1 -1 xml-fop/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java Index: InstreamForeignObject.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- InstreamForeignObject.java 14 Jul 2003 00:44:13 -0000 1.3 +++ InstreamForeignObject.java 16 Aug 2003 06:43:51 -0000 1.4 @@ -237,7 +237,7 @@ Rectangle2D placement = new Rectangle2D.Float(xoffset, yoffset, cwidth, cheight); - Document doc = child.getDocument(); + Document doc = child.getDOMDocument(); String ns = child.getDocumentNamespace(); children = null; 1.4 +25 -1 xml-fop/src/java/org/apache/fop/fo/pagination/Root.java Index: Root.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/pagination/Root.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Root.java 27 Jun 2003 00:16:28 -0000 1.3 +++ Root.java 16 Aug 2003 06:43:51 -0000 1.4 @@ -50,9 +50,11 @@ */ package org.apache.fop.fo.pagination; -// FOP +// java import java.util.List; +// FOP +import org.apache.fop.control.Document; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; @@ -68,6 +70,8 @@ */ private int runningPageNumberCounter = 0; + private Document document = null; + /** * @see org.apache.fop.fo.FONode#FONode(FONode) */ @@ -137,4 +141,24 @@ public void setLayoutMasterSet(LayoutMasterSet layoutMasterSet) { this.layoutMasterSet = layoutMasterSet; } + + /** + * Sets the Document that this Root is attached to + * @param document the Document that this Root is attached to + */ + public void setDocument(Document document) { + this.document = document; + } + + /** + * This method overrides the FONode version. The FONode version calls the + * method by the same name for the parent object. Since Root is at the top + * of the tree, it returns the actual Document object. Thus, any FONode can + * use this chain to find which Document it is being built for. + * @return the Document that this Root is attached to + */ + public Document getDocument() { + return document; + } + }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]