if (foInputHandler instanceof FOTreeHandler) {
currentDocument.setLayoutStrategy(new LayoutManagerLS());
}
+ treeBuilder.document = currentDocument;
try {
if (foInputHandler instanceof FOTreeHandler) {
FOTreeHandler foTreeHandler = (FOTreeHandler)foInputHandler;
// FOP
import org.apache.fop.apps.FOPException;
+import org.apache.fop.control.Document;
import org.apache.fop.util.CharUtilities;
/**
protected boolean isMarker() {
return false;
}
+
+ public Document getDocument() {
+ return parent.getDocument();
+ }
+
}
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;
/**
* 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
private FOUserAgent userAgent;
+ public Document document;
+
/**
* Default constructor
*/
+ " be fo:root, not "
+ fobj.getName()));
}
- rootFObj = fobj;
+ rootFObj = (Root)fobj;
+ rootFObj.setDocument(document);
} else {
currentFObj.addChild(fobj);
}
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);
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;
}
/**
- * 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;
}
/**@todo this is ugly. need to improve. */
// 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;
/**
* 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 =
/**
* @return DOM document representing this foreign XML
*/
- public Document getDocument() {
+ public Document getDOMDocument() {
return doc;
}
Rectangle2D placement = new Rectangle2D.Float(xoffset, yoffset, cwidth, cheight);
- Document doc = child.getDocument();
+ Document doc = child.getDOMDocument();
String ns = child.getDocumentNamespace();
children = null;
*/
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;
*/
private int runningPageNumberCounter = 0;
+ private Document document = null;
+
/**
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
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;
+ }
+
}