if (foInputHandler instanceof FOTreeHandler) {
currentDocument.setLayoutStrategy(new LayoutManagerLS());
}
- treeBuilder.document = currentDocument;
+ treeBuilder.foTreeControl = currentDocument;
try {
if (foInputHandler instanceof FOTreeHandler) {
FOTreeHandler foTreeHandler = (FOTreeHandler)foInputHandler;
// FOP
import org.apache.fop.apps.Driver;
+import org.apache.fop.fo.FOTreeControl;
import org.apache.fop.fonts.Font;
import org.apache.fop.fonts.FontMetrics;
import org.apache.fop.layout.LayoutStrategy;
* Class storing information for the FOP Document being processed, and managing
* the processing of it.
*/
-public class Document {
+public class Document implements FOTreeControl {
/** The parent Driver object */
private Driver driver;
// FOP
import org.apache.fop.apps.FOPException;
-import org.apache.fop.control.Document;
+import org.apache.fop.fo.FOTreeControl;
import org.apache.fop.util.CharUtilities;
/**
* which returns the parent Document.
* @return the Document object that is the parent of this node.
*/
- public Document getDocument() {
- return parent.getDocument();
+ public FOTreeControl getFOTreeControl() {
+ return parent.getFOTreeControl();
}
/**
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
-import org.apache.fop.control.Document;
+import org.apache.fop.fo.FOTreeControl;
import org.apache.fop.fo.pagination.Root;
// SAX
private FOUserAgent userAgent;
- public Document document;
+ public FOTreeControl foTreeControl;
/**
* Default constructor
+ fobj.getName()));
}
rootFObj = (Root)fobj;
- rootFObj.setDocument(document);
+ rootFObj.setFOTreeControl(foTreeControl);
} else {
currentFObj.addChild(fobj);
}
--- /dev/null
+/*
+ * $Id$
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ============================================================================
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * on behalf of the Apache Software Foundation and was originally created by
+ * James Tauber <jtauber@jtauber.com>. For more information on the Apache
+ * Software Foundation, please see <http://www.apache.org/>.
+ */
+
+package org.apache.fop.fo;
+
+import org.apache.fop.fonts.FontMetrics;
+
+/**
+ * An interface for classes that are conceptually the parent class of the
+ * fo.pagination.Root object. The purpose of the interface is to maintain
+ * encapsulation of the FO Tree classes, but to acknowledge that a higher-level
+ * object is needed to control the building of the FO Tree, to provide it
+ * with information about the environment, and to keep track of meta-type
+ * information.
+ */
+
+public interface FOTreeControl {
+
+ public String fontLookup(String family, String style,
+ int weight);
+
+ public FontMetrics getMetricsFor(String fontName);
+
+}
*/
package org.apache.fop.fo;
-import org.apache.fop.control.Document;
+import org.apache.fop.fo.FOTreeControl;
import org.apache.fop.layoutmgr.InlineStackingLayoutManager;
import org.apache.fop.layoutmgr.LMiter;
/** TextInfo for this object */
protected TextInfo textInfo = null;
/** FontInfo for this object */
- protected Document fontInfo = null;
+ protected FOTreeControl fontInfo = null;
/**
* @param parent FONode that is the parent of this object
if (textInfo == null) {
// Really only need one of these, but need to get fontInfo
// stored in propMgr for later use.
- propMgr.setFontInfo(getDocument());
- textInfo = propMgr.getTextLayoutProps(getDocument());
+ propMgr.setFontInfo(getFOTreeControl());
+ textInfo = propMgr.getTextLayoutProps(getFOTreeControl());
}
FOText ft = new FOText(data, start, length, textInfo, this);
import org.apache.fop.area.CTM;
import org.apache.fop.datatypes.FODimension;
import org.apache.fop.fonts.Font;
-import org.apache.fop.control.Document;
+import org.apache.fop.fo.FOTreeControl;
import org.apache.fop.fo.properties.CommonBorderAndPadding;
import org.apache.fop.fo.properties.CommonMarginBlock;
import org.apache.fop.fo.properties.CommonMarginInline;
public class PropertyManager {
private PropertyList properties;
- private Document doc = null;
+ private FOTreeControl foTreeControl = null;
private Font fontState = null;
private CommonBorderAndPadding borderAndPadding = null;
private CommonHyphenation hyphProps = null;
* available.
* @param doc Document containing font information
*/
- public void setFontInfo(Document doc) {
- this.doc = doc;
+ public void setFontInfo(FOTreeControl foTreeControl) {
+ this.foTreeControl = foTreeControl;
}
* @param doc Document containing the font information
* @return a FontState object
*/
- public Font getFontState(Document doc) {
+ public Font getFontState(FOTreeControl foTreeControl) {
if (fontState == null) {
- if (doc == null) {
- doc = this.doc;
- } else if (this.doc == null) {
- this.doc = doc;
+ if (foTreeControl == null) {
+ foTreeControl = this.foTreeControl;
+ } else if (this.foTreeControl == null) {
+ this.foTreeControl = foTreeControl;
}
/**@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 = doc.fontLookup(fontFamily, fontStyle,
+ String fname = foTreeControl.fontLookup(fontFamily, fontStyle,
fontWeight);
- FontMetrics metrics = doc.getMetricsFor(fname);
+ FontMetrics metrics = foTreeControl.getMetricsFor(fname);
fontState = new Font(fname, metrics, fontSize);
}
return fontState;
* @param doc Document containing list of available fonts
* @return a TextInfo object
*/
- public TextInfo getTextLayoutProps(Document doc) {
+ public TextInfo getTextLayoutProps(FOTreeControl foTreeControl) {
if (textInfo == null) {
textInfo = new TextInfo();
- textInfo.fs = getFontState(doc);
+ textInfo.fs = getFontState(foTreeControl);
textInfo.color = properties.get("color").getColorType();
textInfo.verticalAlign =
import java.util.List;
// FOP
-import org.apache.fop.control.Document;
+import org.apache.fop.fo.FOTreeControl;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.FOTreeVisitor;
*/
private int runningPageNumberCounter = 0;
- private Document document = null;
+ private FOTreeControl foTreeControl = null;
/**
* @see org.apache.fop.fo.FONode#FONode(FONode)
}
/**
- * Sets the Document that this Root is attached to
- * @param document the Document that this Root is attached to
+ * Sets the FOTreeControl that this Root is attached to
+ * @param foTreeControl the FOTreeControl implementation to which this Root
+ * is attached
*/
- public void setDocument(Document document) {
- this.document = document;
+ public void setFOTreeControl(FOTreeControl foTreeControl) {
+ this.foTreeControl = foTreeControl;
}
/**
* 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
+ * of the tree, it returns the actual foTreeControl object. Thus, any FONode
+ * can use this chain to find which foTreeControl it is being built for.
+ * @return the FOTreeControl implementation that this Root is attached to
*/
- public Document getDocument() {
- return document;
+ public FOTreeControl getFOTreeControl() {
+ return foTreeControl;
}
public void acceptVisitor(FOTreeVisitor fotv) {
BlockLayoutManager blm = new BlockLayoutManager();
blm.setUserAgent(node.getUserAgent());
blm.setFObj(node);
- TextInfo ti = node.getPropertyManager().getTextLayoutProps(node.getDocument());
+ TextInfo ti = node.getPropertyManager().getTextLayoutProps(node.getFOTreeControl());
blm.setBlockTextInfo(ti);
currentLMList.add(blm);
}