+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.fo;
-
-import org.apache.fop.apps.FOPException;
-
-public class BoxPropShorthandParser extends GenericShorthandParser {
-
- public BoxPropShorthandParser(ListProperty listprop) {
- super(listprop);
- }
-
- // Stores 1 to 4 values of same type
- // Set the given property based on the number of values set
- // Example: padding, border-width, border-color, border-style, margin
- protected Property convertValueForProperty(String propName,
- Property.Maker maker,
- PropertyList propertyList) {
- Property p = null;
- if (propName.indexOf("-top") >= 0) {
- p = getElement(0);
- } else if (propName.indexOf("-right") >= 0) {
- p = getElement(count() > 1 ? 1 : 0);
- } else if (propName.indexOf("-bottom") >= 0) {
- p = getElement(count() > 2 ? 2 : 0);
- } else if (propName.indexOf("-left") >= 0) {
- p = getElement(count() > 3 ? 3 : (count() > 1 ? 1 : 0));
- }
- // if p not null, try to convert it to a value of the correct type
- if (p != null) {
- return maker.convertShorthandProperty(propertyList, p, null);
- }
- return p;
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.fo;
-
-public class CharacterProperty extends Property {
-
- public static class Maker extends Property.Maker {
-
- public Maker(String propName) {
- super(propName);
- }
-
- public Property make(PropertyList propertyList, String value,
- FObj fo) {
- char c = value.charAt(0);
- return new CharacterProperty(c);
- }
-
- } // end Charakter.Maker
-
- private char character;
-
- public CharacterProperty(char character) {
- this.character = character;
- }
-
- public Object getObject() {
- return new Character(character);
- }
-
- public char getCharacter() {
- return this.character;
- }
-
- public String getString() {
- return new Character(character).toString();
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.fo;
-
-// FOP
-import org.apache.fop.fo.*;
-import org.apache.fop.messaging.MessageHandler;
-import org.apache.fop.fo.flow.*;
-import org.apache.fop.fo.properties.*;
-import org.apache.fop.layout.AreaTree;
-import org.apache.fop.apps.FOPException;
-
-/**
- * The fo:root formatting object. Contains page masters, root extensions,
- * page-sequences.
- */
-public class ColorProfile extends ToBeImplementedElement {
-
- public static class Maker extends FObj.Maker {
- public FObj make(FObj parent,
- PropertyList propertyList) throws FOPException {
- return new ColorProfile(parent, propertyList);
- }
-
- }
-
- public static FObj.Maker maker() {
- return new ColorProfile.Maker();
- }
-
- protected ColorProfile(FObj parent,
- PropertyList propertyList) throws FOPException {
- super(parent, propertyList);
- this.name = "fo:color-profile";
-
- // this.properties.get("src");
- // this.properties.get("color-profile-name");
- // this.properties.get("rendering-intent");
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.fo;
-
-import org.apache.fop.datatypes.ColorType;
-
-public class ColorTypeProperty extends Property {
-
- public static class Maker extends Property.Maker {
-
- public Maker(String propName) {
- super(propName);
- }
-
- public Property convertProperty(Property p,
- PropertyList propertyList, FObj fo) {
- if (p instanceof ColorTypeProperty)
- return p;
- ColorType val = p.getColorType();
- if (val != null)
- return new ColorTypeProperty(val);
- return convertPropertyDatatype(p, propertyList, fo);
- }
-
- }
-
- private ColorType colorType;
-
- public ColorTypeProperty(ColorType colorType) {
- this.colorType = colorType;
- }
-
- // Can't convert to any other types
- public ColorType getColorType() {
- return this.colorType;
- }
-
- public Object getObject() {
- return this.colorType;
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.fo;
-
-import org.apache.fop.datatypes.Length;
-import org.apache.fop.datatypes.CondLength;
-
-public class CondLengthProperty extends Property {
-
- public static class Maker extends Property.Maker {
-
- public Maker(String name) {
- super(name);
- }
-
- }
-
- private CondLength condLength = null;
-
- public CondLengthProperty(CondLength condLength) {
- this.condLength = condLength;
- }
-
- public CondLength getCondLength() {
- return this.condLength;
- }
-
- /* Question, should we allow this? */
- public Length getLength() {
- return this.condLength.getLength().getLength();
- }
-
- public Object getObject() {
- return this.condLength;
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.fo;
-
-// FOP
-import org.apache.fop.fo.*;
-import org.apache.fop.messaging.MessageHandler;
-import org.apache.fop.fo.flow.*;
-import org.apache.fop.fo.properties.*;
-import org.apache.fop.layout.AreaTree;
-import org.apache.fop.apps.FOPException;
-
-/**
- */
-public class Declarations extends ToBeImplementedElement {
-
- public static class Maker extends FObj.Maker {
- public FObj make(FObj parent,
- PropertyList propertyList) throws FOPException {
- return new Declarations(parent, propertyList);
- }
-
- }
-
- public static FObj.Maker maker() {
- return new Declarations.Maker();
- }
-
- protected Declarations(FObj parent,
- PropertyList propertyList) throws FOPException {
- super(parent, propertyList);
- this.name = "fo:declarations";
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.fo;
-
-/**
- * Interface for adding supported element and property mappings to
- * the given builder.
- */
-public interface ElementMapping {
- public void addToBuilder(TreeBuilder builder);
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.fo;
-
-import org.apache.fop.apps.FOPException;
-import org.apache.fop.messaging.MessageHandler;
-
-public class EnumProperty extends Property {
-
- public static class Maker extends Property.Maker {
-
- protected Maker(String propName) {
- super(propName);
- }
-
-
- /**
- * Called by subclass if no match found.
- */
- public Property checkEnumValues(String value) {
- MessageHandler.errorln("WARNING: Unknown enumerated value for property '"
- + getPropName() + "': " + value);
- return null;
- }
-
- protected Property findConstant(String value) {
- return null;
- }
-
- public Property convertProperty(Property p,
- PropertyList propertyList,
- FObj fo) throws FOPException {
- if (p instanceof EnumProperty)
- return p;
- else
- return null;
- }
-
- }
-
- private int value;
-
- public EnumProperty(int explicitValue) {
- this.value = explicitValue;
- }
-
- public int getEnum() {
- return this.value;
- }
-
- public Object getObject() {
- // FIXME: return String value: property must reference maker
- // return maker.getEnumValue(this.value);
- return new Integer(this.value);
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources."
- */
-
-package org.apache.fop.fo;
-
-// FOP
-import org.apache.fop.layout.Area;
-import org.apache.fop.messaging.MessageHandler;
-import org.apache.fop.layout.BlockArea;
-import org.apache.fop.layout.FontState;
-import org.apache.fop.layout.*;
-import org.apache.fop.datatypes.*;
-import org.apache.fop.fo.properties.*;
-import org.apache.fop.apps.FOPException;
-import org.apache.fop.system.BufferManager;
-
-/**
- * a text node in the formatting object tree
- *
- * Modified by Mark Lillywhite, mark-fop@inomial.com.
- * Unfortunately the BufferManager implementatation holds
- * onto references to the character data in this object
- * longer than the lifetime of the object itself, causing
- * excessive memory consumption and OOM errors.
- */
-public class FOText extends FONode {
-
- protected char[] ca;
- protected int start;
- protected int length;
-
- FontState fs;
- float red;
- float green;
- float blue;
- int wrapOption;
- int whiteSpaceCollapse;
- int verticalAlign;
-
- // Textdecoration
- protected boolean underlined = false;
- protected boolean overlined = false;
- protected boolean lineThrough = false;
-
- TextState ts;
-
-
- public FOText(char[] chars, int s, int e, FObj parent) {
- super(parent);
- this.start = 0;
- this.ca = new char[e - s];
- for (int i = s; i < e; i++)
- ca[i - s] = chars[i];
- this.length = e - s;
-
- /* ML - remove refs to BufferManager
- this.bufferManager = parent.bufferManager;
- if (this.bufferManager != null) {
- bufferManager.writeBuffer((Object)this, ca);
- } else {
- System.out.println("abnormal exit");
- System.exit(0);
- }
- */
- }
-
- public void setUnderlined(boolean ul) {
- this.underlined = ul;
- }
-
- public void setOverlined(boolean ol) {
- this.overlined = ol;
- }
-
- public void setLineThrough(boolean lt) {
- this.lineThrough = lt;
- }
-
-
- public boolean willCreateArea() {
- // ML - remove refs to BufferManager
- //char ca[] = this.bufferManager.readBuffer((Object)this);
-
- this.whiteSpaceCollapse =
- this.parent.properties.get("white-space-collapse").getEnum();
- if (this.whiteSpaceCollapse == WhiteSpaceCollapse.FALSE
- && length > 0) {
- return true;
- }
-
- for (int i = start; i < start + length; i++) {
- char ch = ca[i];
- if (!((ch == ' ') || (ch == '\n') || (ch == '\r')
- || (ch == '\t'))) { // whitespace
- return true;
- }
- }
- return false;
- }
-
- public Status layout(Area area) throws FOPException {
- // ML - remove refs to BufferManager
- // char ca[] = this.bufferManager.readBuffer((Object)this);
- if (!(area instanceof BlockArea)) {
- MessageHandler.errorln("WARNING: text outside block area"
- + new String(ca, start, length));
- return new Status(Status.OK);
- }
- if (this.marker == START) {
- String fontFamily =
- this.parent.properties.get("font-family").getString();
- String fontStyle =
- this.parent.properties.get("font-style").getString();
- String fontWeight =
- this.parent.properties.get("font-weight").getString();
- int fontSize =
- this.parent.properties.get("font-size").getLength().mvalue();
- // font-variant support
- // added by Eric SCHAEFFER
- int fontVariant =
- this.parent.properties.get("font-variant").getEnum();
-
- this.fs = new FontState(area.getFontInfo(), fontFamily,
- fontStyle, fontWeight, fontSize,
- fontVariant);
-
- ColorType c = this.parent.properties.get("color").getColorType();
- this.red = c.red();
- this.green = c.green();
- this.blue = c.blue();
-
- this.verticalAlign =
- this.parent.properties.get("vertical-align").getEnum();
-
- this.wrapOption =
- this.parent.properties.get("wrap-option").getEnum();
- this.whiteSpaceCollapse =
- this.parent.properties.get("white-space-collapse").getEnum();
- this.ts = new TextState();
- ts.setUnderlined(underlined);
- ts.setOverlined(overlined);
- ts.setLineThrough(lineThrough);
-
- this.marker = this.start;
- }
- int orig_start = this.marker;
- this.marker = addText((BlockArea)area, fs, red, green, blue,
- wrapOption, this.getLinkSet(),
- whiteSpaceCollapse, ca, this.marker, length,
- ts, verticalAlign);
- if (this.marker == -1) {
-
-
- // commented out by Hani Elabed, 11/28/2000
- // if this object has been laid out
- // successfully, leave it alone....
- // Now, to prevent the array index out of
- // bound of LineArea.addText(), I have added
- // the following test at the beginning of that method.
- // if( start == -1 ) return -1;
- // see LineArea.addText()
-
- // this.marker = 0;
- return new Status(Status.OK);
- } else if (this.marker != orig_start) {
- return new Status(Status.AREA_FULL_SOME);
- } else {
- return new Status(Status.AREA_FULL_NONE);
- }
- }
-
- // font-variant support : addText is a wrapper for addRealText
- // added by Eric SCHAEFFER
- public static int addText(BlockArea ba, FontState fontState, float red,
- float green, float blue, int wrapOption,
- LinkSet ls, int whiteSpaceCollapse,
- char data[], int start, int end,
- TextState textState, int vAlign) {
- if (fontState.getFontVariant() == FontVariant.SMALL_CAPS) {
- FontState smallCapsFontState;
- try {
- int smallCapsFontHeight =
- (int)(((double)fontState.getFontSize()) * 0.8d);
- smallCapsFontState = new FontState(fontState.getFontInfo(),
- fontState.getFontFamily(),
- fontState.getFontStyle(),
- fontState.getFontWeight(),
- smallCapsFontHeight,
- FontVariant.NORMAL);
- } catch (FOPException ex) {
- smallCapsFontState = fontState;
- MessageHandler.errorln("Error creating small-caps FontState: "
- + ex.getMessage());
- }
-
- // parse text for upper/lower case and call addRealText
- char c;
- boolean isLowerCase;
- int caseStart;
- FontState fontStateToUse;
- for (int i = start; i < end; ) {
- caseStart = i;
- c = data[i];
- isLowerCase = (java.lang.Character.isLetter(c)
- && java.lang.Character.isLowerCase(c));
- while (isLowerCase
- == (java.lang.Character.isLetter(c)
- && java.lang.Character.isLowerCase(c))) {
- if (isLowerCase) {
- data[i] = java.lang.Character.toUpperCase(c);
- }
- i++;
- if (i == end)
- break;
- c = data[i];
- }
- if (isLowerCase) {
- fontStateToUse = smallCapsFontState;
- } else {
- fontStateToUse = fontState;
- }
- int index = addRealText(ba, fontStateToUse, red, green, blue,
- wrapOption, ls, whiteSpaceCollapse,
- data, caseStart, i, textState,
- vAlign);
- if (index != -1) {
- return index;
- }
- }
-
- return -1;
- }
-
- // font-variant normal
- return addRealText(ba, fontState, red, green, blue, wrapOption, ls,
- whiteSpaceCollapse, data, start, end, textState,
- vAlign);
- }
-
- protected static int addRealText(BlockArea ba, FontState fontState,
- float red, float green, float blue,
- int wrapOption, LinkSet ls,
- int whiteSpaceCollapse, char data[],
- int start, int end, TextState textState,
- int vAlign) {
- int ts, te;
- char[] ca;
-
- ts = start;
- te = end;
- ca = data;
-
- LineArea la = ba.getCurrentLineArea();
- if (la == null) {
- return start;
- }
-
- la.changeFont(fontState);
- la.changeColor(red, green, blue);
- la.changeWrapOption(wrapOption);
- la.changeWhiteSpaceCollapse(whiteSpaceCollapse);
- la.changeVerticalAlign(vAlign);
- // la.changeHyphenation(language, country, hyphenate,
- // hyphenationChar, hyphenationPushCharacterCount,
- // hyphenationRemainCharacterCount);
- ba.setupLinkSet(ls);
-
- ts = la.addText(ca, ts, te, ls, textState);
- // this.hasLines = true;
-
- while (ts != -1) {
- la = ba.createNextLineArea();
- if (la == null) {
- return ts;
- }
- la.changeFont(fontState);
- la.changeColor(red, green, blue);
- la.changeWrapOption(wrapOption);
- la.changeWhiteSpaceCollapse(whiteSpaceCollapse);
- // la.changeHyphenation(language, country, hyphenate,
- // hyphenationChar, hyphenationPushCharacterCount,
- // hyphenationRemainCharacterCount);
- ba.setupLinkSet(ls);
-
- ts = la.addText(ca, ts, te, ls, textState);
- }
- return -1;
- }
-
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.fo;
-
-// FOP
-import org.apache.fop.layout.AreaTree;
-import org.apache.fop.messaging.MessageHandler;
-import org.apache.fop.apps.FOPException;
-import org.apache.fop.apps.StreamRenderer;
-import org.apache.fop.fo.pagination.Root;
-import org.apache.fop.system.BufferManager;
-import org.apache.fop.fo.pagination.PageSequence;
-
-// SAX
-import org.xml.sax.helpers.DefaultHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.InputSource;
-import org.xml.sax.Attributes;
-
-// Java
-import java.util.Hashtable;
-import java.util.Stack;
-import java.io.IOException;
-
-/**
- * SAX Handler that builds the formatting object tree.
- *
- * Modified by Mark Lillywhite mark-fop@inomial.com. Now uses
- * StreamRenderer to automagically render the document as
- * soon as it receives a page-sequence end-tag. Also,
- * calls methods to set up and shut down the renderer at
- * the beginning and end of the FO document. Finally,
- * supresses adding the PageSequence object to the Root,
- * since it is parsed immediately.
- */
-public class FOTreeBuilder extends DefaultHandler implements TreeBuilder {
-
- /**
- * table mapping element names to the makers of objects
- * representing formatting objects
- */
- protected Hashtable fobjTable = new Hashtable();
-
- /**
- * class that builds a property list for each formatting object
- */
- protected Hashtable propertylistTable = new Hashtable();
-
- /**
- * current formatting object being handled
- */
- protected FObj currentFObj = null;
-
- /**
- * the root of the formatting object tree
- */
- protected FObj rootFObj = null;
-
- public BufferManager bufferManager;
-
- /**
- * set of names of formatting objects encountered but unknown
- */
- protected Hashtable unknownFOs = new Hashtable();
-
- /**
- *
- * The class that handles formatting and rendering to a stream
- * (mark-fop@inomial.com)
- */
- private StreamRenderer streamRenderer;
-
- public FOTreeBuilder() {}
-
-
- public void setStreamRenderer(StreamRenderer streamRenderer) {
- this.streamRenderer = streamRenderer;
- }
-
- /**
- * add a mapping from element name to maker.
- *
- * @param namespaceURI namespace URI of formatting object element
- * @param localName local name of formatting object element
- * @param maker Maker for class representing formatting object
- */
- public void addMapping(String namespaceURI, String localName,
- FObj.Maker maker) {
- this.fobjTable.put(namespaceURI + "^" + localName, maker);
- }
-
- /**
- * add a mapping from element name to maker.
- *
- * @param namespaceURI namespace URI of formatting object element
- * @param localName local name of formatting object element
- * @param maker Maker for class representing formatting object
- */
- public void addPropertyList(String namespaceURI, Hashtable list) {
- PropertyListBuilder plb;
- plb = (PropertyListBuilder)this.propertylistTable.get(namespaceURI);
- if (plb == null) {
- plb = new PropertyListBuilder();
- plb.addList(list);
- this.propertylistTable.put(namespaceURI, plb);
- } else {
- plb.addList(list);
- }
- }
-
- /**
- * add a mapping from element name to maker.
- *
- * @param namespaceURI namespace URI of formatting object element
- * @param localName local name of formatting object element
- * @param maker Maker for class representing formatting object
- */
- public void addElementPropertyList(String namespaceURI, String localName,
- Hashtable list) {
- PropertyListBuilder plb;
- plb = (PropertyListBuilder)this.propertylistTable.get(namespaceURI);
- if (plb == null) {
- plb = new PropertyListBuilder();
- plb.addElementList(localName, list);
- this.propertylistTable.put(namespaceURI, plb);
- } else {
- plb.addElementList(localName, list);
- }
- }
-
- /**
- * SAX Handler for characters
- */
- public void characters(char data[], int start, int length) {
- currentFObj.addCharacters(data, start, start + length);
- }
-
- /**
- * SAX Handler for the end of an element
- */
- public void endElement(String uri, String localName, String rawName)
- throws SAXException {
- currentFObj.end();
-
- //
- // mark-fop@inomial.com - tell the stream renderer to render
- // this page-sequence
- //
- if(currentFObj instanceof PageSequence)
- streamRenderer.render((PageSequence) currentFObj);
-
- currentFObj = (FObj)currentFObj.getParent();
- }
-
- /**
- * SAX Handler for the start of the document
- */
- public void startDocument()
- throws SAXException {
- rootFObj = null; // allows FOTreeBuilder to be reused
- MessageHandler.logln("building formatting object tree");
- streamRenderer.startRenderer();
- }
-
- public void endDocument()
- throws SAXException {
- MessageHandler.logln("Parsing of document complete, stopping renderer");
- streamRenderer.stopRenderer();
- }
-
- /**
- * SAX Handler for the start of an element
- */
- public void startElement(String uri, String localName, String rawName,
- Attributes attlist) throws SAXException {
- /* the formatting object started */
- FObj fobj;
-
- /* the maker for the formatting object started */
- FObj.Maker fobjMaker;
-
- // String fullName = mapName(rawName);
- String fullName = uri + "^" + localName;
- fobjMaker = (FObj.Maker)fobjTable.get(fullName);
- PropertyListBuilder currentListBuilder =
- (PropertyListBuilder)this.propertylistTable.get(uri);
-
- if (fobjMaker == null) {
- if (!this.unknownFOs.containsKey(fullName)) {
- this.unknownFOs.put(fullName, "");
- MessageHandler.errorln("WARNING: Unknown formatting object "
- + fullName);
- }
- fobjMaker = new Unknown.Maker(); // fall back
- }
-
- try {
- PropertyList list = null;
- if (currentListBuilder != null) {
- list =
- currentListBuilder.makeList(fullName, attlist,
- (currentFObj == null) ? null
- : currentFObj.properties, currentFObj);
- } else {
- list = currentFObj.properties;
- }
- fobj = fobjMaker.make(currentFObj, list);
- } catch (FOPException e) {
- throw new SAXException(e);
- }
-
- if (rootFObj == null) {
- rootFObj = fobj;
- rootFObj.setBufferManager(this.bufferManager);
- if (!fobj.getName().equals("fo:root")) {
- throw new SAXException(new FOPException("Root element must"
- + " be root, not "
- + fobj.getName()));
- }
- } else if(!(fobj instanceof org.apache.fop.fo.pagination.PageSequence)) {
- currentFObj.addChild(fobj);
- }
-
- currentFObj = fobj;
- }
-
- /**
- * format this formatting object tree
- *
- * @param areaTree the area tree to format into
- */
- public void format(AreaTree areaTree) throws FOPException {
- MessageHandler.logln("formatting FOs into areas");
- this.bufferManager.readComplete();
- ((Root)this.rootFObj).format(areaTree);
- }
-
- public void reset() {
- currentFObj = null;
- rootFObj = null;
- streamRenderer = null;
- }
-
- public boolean hasData() {
- return (rootFObj != null);
- }
-
- public void setBufferManager(BufferManager bufferManager) {
- this.bufferManager = bufferManager;
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.fo;
-
-// FOP
-import org.apache.fop.layout.Area;
-import org.apache.fop.apps.FOPException;
-import org.apache.fop.datatypes.IDReferences;
-
-// Java
-import java.util.Hashtable;
-import java.util.Enumeration;
-
-/**
- * base class for representation of formatting objects and their processing
- */
-public class FObj extends FONode {
-
- public static class Maker {
- public FObj make(FObj parent,
- PropertyList propertyList) throws FOPException {
- return new FObj(parent, propertyList);
- }
-
- }
-
- public static Maker maker() {
- return new Maker();
- }
-
- // protected PropertyList properties;
- public PropertyList properties;
- protected PropertyManager propMgr;
-
- protected String name;
-
- protected FObj(FObj parent, PropertyList propertyList) {
- super(parent);
- this.properties = propertyList; // TO BE REMOVED!!!
- propertyList.setFObj(this);
- this.propMgr = makePropertyManager(propertyList);
- this.name = "default FO";
- setWritingMode();
- }
-
- protected PropertyManager makePropertyManager(PropertyList propertyList) {
- return new PropertyManager(propertyList);
- }
-
- /**
- * adds characters (does nothing here)
- * @param data text
- * @param start start position
- * @param length length of the text
- */
- protected void addCharacters(char data[], int start, int length) {
- // ignore
- }
-
- /**
- * generates the area or areas for this formatting object
- * and adds these to the area. This method should always be
- * overridden by all sub classes
- *
- * @param area
- */
- public Status layout(Area area) throws FOPException {
- // should always be overridden
- return new Status(Status.OK);
- }
-
- /**
- * returns the name of the formatting object
- * @return the name of this formatting objects
- */
- public String getName() {
- return this.name;
- }
-
- /**
- *
- */
- protected void start() {
- // do nothing by default
- }
-
- /**
- *
- */
- protected void end() {
- // do nothing by default
- }
-
- /**
- * lets outside sources access the property list
- * first used by PageNumberCitation to find the "id" property
- * @param name - the name of the desired property to obtain
- * @return the property
- */
- public Property getProperty(String name) {
- return (properties.get(name));
- }
-
-
- /**
- * Return the "content width" of the areas generated by this FO.
- * This is used by percent-based properties to get the dimension of
- * the containing block.
- * If an FO has a property with a percentage value, that value
- * is usually calculated on the basis of the corresponding dimension
- * of the area which contains areas generated by the FO.
- * NOTE: subclasses of FObj should implement this to return a reasonable
- * value!
- */
- public int getContentWidth() {
- return 0;
- }
-
- /**
- * removes property id
- * @param idReferences the id to remove
- */
- public void removeID(IDReferences idReferences) {
- if (((FObj)this).properties.get("id") == null
- || ((FObj)this).properties.get("id").getString() == null)
- return;
- idReferences.removeID(((FObj)this).properties.get("id").getString());
- int numChildren = this.children.size();
- for (int i = 0; i < numChildren; i++) {
- FONode child = (FONode)children.elementAt(i);
- if ((child instanceof FObj)) {
- ((FObj)child).removeID(idReferences);
- }
- }
- }
-
- public boolean generatesReferenceAreas() {
- return false;
- }
-
- /**
- * Set writing mode for this FO.
- * Find nearest ancestor, including self, which generates
- * reference areas and use the value of its writing-mode property.
- * If no such ancestor is found, use the value on the root FO.
- */
- private void setWritingMode() {
- FObj p;
- FObj parent;
- for (p = this;
- !p.generatesReferenceAreas() && (parent = p.getParent()) != null;
- p = parent);
- this.properties.setWritingMode(p.getProperty("writing-mode").getEnum());
- }
-
-}
-
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.fo;
-
-import org.apache.fop.layout.Area;
-import org.apache.fop.apps.FOPException;
-
-/**
- * base class for representation of mixed content formatting objects
- * and their processing
- */
-public class FObjMixed extends FObj {
-
- public static class Maker extends FObj.Maker {
- public FObj make(FObj parent,
- PropertyList propertyList) throws FOPException {
- return new FObjMixed(parent, propertyList);
- }
-
- }
-
- public static FObj.Maker maker() {
- return new FObjMixed.Maker();
- }
-
- protected FObjMixed(FObj parent, PropertyList propertyList) {
- super(parent, propertyList);
- }
-
- protected void addCharacters(char data[], int start, int length) {
- addChild(new FOText(data, start, length, this));
- }
-
- public Status layout(Area area) throws FOPException {
-
- if (this.properties != null) {
- Property prop = this.properties.get("id");
- if (prop != null) {
- String id = prop.getString();
-
- if (this.marker == START) {
- if (area.getIDReferences() != null)
- area.getIDReferences().createID(id);
- this.marker = 0;
- }
-
- if (this.marker == 0) {
- if (area.getIDReferences() != null)
- area.getIDReferences().configureID(id, area);
- }
- }
- }
-
- int numChildren = this.children.size();
- for (int i = this.marker; i < numChildren; i++) {
- FONode fo = (FONode)children.elementAt(i);
- Status status;
- if ((status = fo.layout(area)).isIncomplete()) {
- this.marker = i;
- return status;
- }
- }
- return new Status(Status.OK);
- }
-
-}
-
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.fo;
-
-import java.util.Vector;
-import java.util.Enumeration;
-
-public class GenericShorthandParser implements ShorthandParser {
-
- protected Vector list; // Vector of Property objects
-
- public GenericShorthandParser(ListProperty listprop) {
- this.list = listprop.getList();
- }
-
- protected Property getElement(int index) {
- if (list.size() > index)
- return (Property)list.elementAt(index);
- else
- return null;
- }
-
- protected int count() {
- return list.size();
- }
-
- // Stores 1 to 3 values for border width, style, color
- // Used for: border, border-top, border-right etc
- public Property getValueForProperty(String propName,
- Property.Maker maker,
- PropertyList propertyList) {
- Property prop = null;
- // Check for keyword "inherit"
- if (count() == 1) {
- String sval = ((Property)list.elementAt(0)).getString();
- if (sval != null && sval.equals("inherit")) {
- return propertyList.getFromParent(propName);
- }
- }
- return convertValueForProperty(propName, maker, propertyList);
- }
-
-
- protected Property convertValueForProperty(String propName,
- Property.Maker maker,
- PropertyList propertyList) {
- Property prop = null;
- // Try each of the stored values in turn
- Enumeration eprop = list.elements();
- while (eprop.hasMoreElements() && prop == null) {
- Property p = (Property)eprop.nextElement();
- prop = maker.convertShorthandProperty(propertyList, p, null);
- }
- return prop;
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.fo;
-
-import org.apache.fop.datatypes.Keep;
-
-public class KeepProperty extends Property {
-
- public static class Maker extends Property.Maker {
-
- protected Maker(String name) {
- super(name);
- }
-
- }
-
- private Keep keep;
-
- public KeepProperty(Keep keep) {
- this.keep = keep;
- }
-
- public Keep getKeep() {
- return this.keep;
- }
-
- public Object getObject() {
- return this.keep;
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.fo;
-
-import org.apache.fop.datatypes.Length;
-import org.apache.fop.datatypes.LengthPair;
-
-public class LengthPairProperty extends Property {
-
- public static class Maker extends LengthProperty.Maker {
-
- protected Maker(String name) {
- super(name);
- }
-
- }
-
- private LengthPair lengthPair;
-
- public LengthPairProperty(LengthPair lengthPair) {
- this.lengthPair = lengthPair;
- }
-
- public LengthPair getLengthPair() {
- return this.lengthPair;
- }
-
- public Object getObject() {
- return this.lengthPair;
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.fo;
-
-import org.apache.fop.datatypes.Length;
-import org.apache.fop.datatypes.PercentLength;
-import org.apache.fop.datatypes.TableColLength;
-import org.apache.fop.fo.expr.Numeric;
-import org.apache.fop.apps.FOPException;
-
-public class LengthProperty extends Property {
-
- public static class Maker extends Property.Maker {
-
- public /* protected */ Maker(String name) {
- super(name);
- }
-
- /**
- * protected Property checkPropertyKeywords(String value) {
- * if (isAutoLengthAllowed() && value.equals("auto")) {
- * return new LengthProperty(Length.AUTO);
- * }
- * return null;
- * }
- */
-
- protected boolean isAutoLengthAllowed() {
- return false;
- }
-
- public Property convertProperty(Property p,
- PropertyList propertyList,
- FObj fo) throws FOPException {
- if (isAutoLengthAllowed()) {
- String pval = p.getString();
- if (pval != null && pval.equals("auto"))
- return new LengthProperty(Length.AUTO);
- }
- if (p instanceof LengthProperty)
- return p;
- Length val = p.getLength();
- if (val != null)
- return new LengthProperty(val);
- return convertPropertyDatatype(p, propertyList, fo);
- }
-
- }
-
- /*
- * public static Property.Maker maker(String prop) {
- * return new Maker(prop);
- * }
- */
-
- /**
- * This object may be also be a subclass of Length, such
- * as PercentLength, TableColLength.
- */
- private Length length;
-
- public LengthProperty(Length length) {
- this.length = length;
- // System.err.println("Set LengthProperty: " + length.toString());
- }
-
- public Numeric getNumeric() {
- // Can't just do new Numeric(length) because it always uses
- // the constructor for Length!
- // Otherwise, must make each class know about Numeric...
- // ie, return length.asNumeric(): cleaner
- if (length instanceof PercentLength)
- return new Numeric((PercentLength)length);
- if (length instanceof TableColLength)
- return new Numeric((TableColLength)length);
- return new Numeric(length);
- }
-
- public Length getLength() {
- return this.length;
- }
-
- public Object getObject() {
- return this.length;
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.fo;
-
-import org.apache.fop.datatypes.Length;
-import org.apache.fop.datatypes.LengthRange;
-
-public class LengthRangeProperty extends Property {
-
- public static class Maker extends LengthProperty.Maker {
-
- protected Maker(String name) {
- super(name);
- }
-
- }
-
- private LengthRange lengthRange;
-
- public LengthRangeProperty(LengthRange lengthRange) {
- this.lengthRange = lengthRange;
- }
-
- public LengthRange getLengthRange() {
- return this.lengthRange;
- }
-
- public Object getObject() {
- return this.lengthRange;
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.fo;
-
-import java.util.Vector;
-
-public class ListProperty extends Property {
-
- public static class Maker extends Property.Maker {
-
- public Maker(String name) {
- super(name);
- }
-
- public Property convertProperty(Property p,
- PropertyList propertyList, FObj fo) {
- if (p instanceof ListProperty)
- return p;
- else
- return new ListProperty(p);
- }
-
- }
-
- protected Vector list;
-
- public ListProperty(Property prop) {
- list = new Vector();
- list.addElement(prop);
- }
-
- public void addProperty(Property prop) {
- list.addElement(prop);
- }
-
- public Vector getList() {
- return list;
- }
-
- public Object getObject() {
- return list;
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-package org.apache.fop.fo;
-
-import org.apache.fop.datatypes.ColorType;
-import org.apache.fop.fo.expr.Numeric;
-
-public class NumberProperty extends Property {
-
- public static class Maker extends Property.Maker {
-
- public Maker(String propName) {
- super(propName);
- }
-
- public Property convertProperty(Property p,
- PropertyList propertyList, FObj fo) {
- if (p instanceof NumberProperty)
- return p;
- Number val = p.getNumber();
- if (val != null)
- return new NumberProperty(val);
- return convertPropertyDatatype(p, propertyList, fo);
- }
-
- }
-
- private Number number;
-
- public NumberProperty(Number num) {
- this.number = num;
- }
-
- public NumberProperty(double num) {
- this.number = new Double(num);
- }
-
- public NumberProperty(int num) {
- this.number = new Integer(num);
- }
-
- public Number getNumber() {
- return this.number;
- }
-
- /**
- * public Double getDouble() {
- * return new Double(this.number.doubleValue());
- * }
- * public Integer getInteger() {
- * return new Integer(this.number.intValue());
- * }
- */
-
- public Object getObject() {
- return this.number;
- }
-
- public Numeric getNumeric() {
- return new Numeric(this.number);
- }
-
- public ColorType getColorType() {
- // Convert numeric value to color ???
- // Convert to hexadecimal and then try to make it into a color?
- return new ColorType((float)0.0, (float)0.0, (float)0.0);
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.fo;
-
-import org.apache.fop.messaging.MessageHandler;
-import org.apache.fop.datatypes.*;
-import org.apache.fop.fo.expr.Numeric;
-import org.apache.fop.fo.expr.PropertyParser;
-import org.apache.fop.fo.expr.PropertyInfo;
-import org.apache.fop.fo.expr.PropertyException;
-import org.apache.fop.apps.FOPException;
-import java.util.Vector;
-
-public class Property {
-
- public static class Maker {
- private static final String UNKNOWN = "UNKNOWN";
- private String propName;
-
- /**
- * Return the name of the property whose value is being set.
- */
- protected String getPropName() {
- return propName;
- }
-
- /**
- * Construct an instance of a Property.Maker for the given property.
- * @param propName The name of the property to be made.
- */
- protected Maker(String propName) {
- this.propName = propName;
- }
-
- /**
- * Construct an instance of a Property.Maker.
- * Note: the property name is set to "UNKNOWN".
- */
- protected Maker() {
- this.propName = UNKNOWN;
- }
-
-
- /**
- * Default implementation of isInherited.
- * @return A boolean indicating whether this property is inherited.
- */
- public boolean isInherited() {
- return false;
- }
-
- /**
- * Return a boolean indicating whether this property inherits the
- * "specified" value rather than the "computed" value. The default is
- * to inherit the "computed" value.
- * @return If true, property inherits the value specified.
- */
- public boolean inheritsSpecified() {
- return false;
- }
-
-
- /**
- * Return an object implementing the PercentBase interface.
- * This is used to handle properties specified as a percentage of
- * some "base length", such as the content width of their containing
- * box.
- * Overridden by subclasses which allow percent specifications. See
- * the documentation on properties.xsl for details.
- */
- public PercentBase getPercentBase(FObj fo, PropertyList pl) {
- return null;
- }
-
- /**
- * Return a Maker object which is used to set the values on components
- * of compound property types, such as "space".
- * Overridden by property maker subclasses which handle
- * compound properties.
- * @param subprop The name of the component for which a Maker is to
- * returned, for example "optimum", if the FO attribute is
- * space.optimum='10pt'.
- */
- protected Maker getSubpropMaker(String subprop) {
- return null;
- }
-
- /**
- * Return a property value for the given component of a compound
- * property.
- * @param p A property value for a compound property type such as
- * SpaceProperty.
- * @param subprop The name of the component whose value is to be
- * returned.
- * NOTE: this is only to ease porting when calls are made to
- * PropertyList.get() using a component name of a compound property,
- * such as get("space.optimum"). The recommended technique is:
- * get("space").getOptimum().
- * Overridden by property maker subclasses which handle
- * compound properties.
- */
- public Property getSubpropValue(Property p, String subprop) {
- return null;
- }
-
- /**
- * Return a property value for a compound property. If the property
- * value is already partially initialized, this method will modify it.
- * @param baseProp The Property object representing the compound property,
- * such as SpaceProperty.
- * @param partName The name of the component whose value is specified.
- * @param propertyList The propertyList being built.
- * @param fo The FO whose properties are being set.
- * @return A compound property object.
- */
- public Property make(Property baseProp, String partName,
- PropertyList propertyList, String value,
- FObj fo) throws FOPException {
- if (baseProp == null) {
- baseProp = makeCompound(propertyList, fo);
- }
- Maker spMaker = getSubpropMaker(partName);
- if (spMaker != null) {
- Property p = spMaker.make(propertyList, value, fo);
- if (p != null) {
- return setSubprop(baseProp, partName, p);
- }
- } else {
- MessageHandler.errorln("WARNING: compound property component "
- + partName + " unknown.");
- }
- return baseProp;
- }
-
- /**
- * Set a component in a compound property and return the modified
- * compound property object.
- * This default implementation returns the original base property
- * without modifying it.
- * It is overridden by property maker subclasses which handle
- * compound properties.
- * @param baseProp The Property object representing the compound property,
- * such as SpaceProperty.
- * @param partName The name of the component whose value is specified.
- * @param subProp A Property object holding the specified value of the
- * component to be set.
- * @return The modified compound property object.
- */
- protected Property setSubprop(Property baseProp, String partName,
- Property subProp) {
- return baseProp;
- }
-
- /**
- * Create a Property object from an attribute specification.
- * @param propertyList The PropertyList object being built for this FO.
- * @param value The attribute value.
- * @param fo The current FO whose properties are being set.
- * @return The initialized Property object.
- */
- public Property make(PropertyList propertyList, String value,
- FObj fo) throws FOPException {
- try {
- Property pret = null;
- String pvalue = value;
- pret = checkEnumValues(value);
- if (pret == null) {
- /* Check for keyword shorthand values to be substituted. */
- pvalue = checkValueKeywords(value);
- // Override parsePropertyValue in each subclass of Property.Maker
- Property p = PropertyParser.parse(pvalue,
- new PropertyInfo(this,
- propertyList, fo));
- pret = convertProperty(p, propertyList, fo);
- } else if (isCompoundMaker()) {
- pret = convertProperty(pret, propertyList, fo);
- }
- if (pret == null) {
- throw new org.apache.fop.fo.expr.PropertyException("No conversion defined");
- } else if (inheritsSpecified()) {
- pret.setSpecifiedValue(pvalue);
- }
- return pret;
- } catch (org.apache.fop.fo.expr.PropertyException propEx) {
- MessageHandler.errorln("Error in " + propName
- + " property value '" + value + "': "
- + propEx);
- throw new FOPException("Property error");
- }
- }
-
- public Property convertShorthandProperty(PropertyList propertyList,
- Property prop, FObj fo) {
- Property pret = null;
- try {
- pret = convertProperty(prop, propertyList, fo);
- if (pret == null) {
- // If value is a name token, may be keyword or Enum
- String sval = prop.getNCname();
- if (sval != null) {
- // System.err.println("Convert shorthand ncname " + sval);
- pret = checkEnumValues(sval);
- if (pret == null) {
- /* Check for keyword shorthand values to be substituted. */
- String pvalue = checkValueKeywords(sval);
- if (!pvalue.equals(sval)) {
- // System.err.println("Convert shorthand keyword" + pvalue);
- // Substituted a value: must parse it
- Property p =
- PropertyParser.parse(pvalue,
- new PropertyInfo(this,
- propertyList,
- fo));
- pret = convertProperty(p, propertyList, fo);
- }
- }
- }
- }
- } catch (FOPException e) {
-
- MessageHandler.errorln("convertShorthandProperty caught FOPException "
- + e);
- } catch (org.apache.fop.fo.expr.PropertyException propEx) {
- MessageHandler.errorln("convertShorthandProperty caught PropertyException "
- + propEx);
- }
- if (pret != null) {
- /*
- * System.err.println("Return shorthand value " + pret.getString() +
- * " for " + getPropName());
- */
- }
- return pret;
- }
-
- protected boolean isCompoundMaker() {
- return false;
- }
-
- public Property checkEnumValues(String value) {
- return null;
- }
-
- /**
- * Return a String to be parsed if the passed value corresponds to
- * a keyword which can be parsed and used to initialize the property.
- * For example, the border-width family of properties can have the
- * initializers "thin", "medium", or "thick". The foproperties.xml
- * file specifies a length value equivalent for these keywords,
- * such as "0.5pt" for "thin". These values are considered parseable,
- * since the Length object is no longer responsible for parsing
- * unit expresssions.
- * @param value The string value of property attribute.
- * @return A String containging a parseable equivalent or null if
- * the passed value isn't a keyword initializer for this Property.
- */
- protected String checkValueKeywords(String value) {
- return value;
- }
-
- /**
- * Return a Property object based on the passed Property object.
- * This method is called if the Property object built by the parser
- * isn't the right type for this property.
- * It is overridden by subclasses when the property specification in
- * foproperties.xml specifies conversion rules.
- * @param p The Property object return by the expression parser
- * @param propertyList The PropertyList object being built for this FO.
- * @param fo The current FO whose properties are being set.
- * @return A Property of the correct type or null if the parsed value
- * can't be converted to the correct type.
- */
- public Property convertProperty(Property p,
- PropertyList propertyList,
- FObj fo) throws FOPException {
- return null;
- }
-
- protected Property convertPropertyDatatype(Property p,
- PropertyList propertyList,
- FObj fo) {
- return null;
- }
-
- /**
- * Return a Property object representing the initial value.
- * @param propertyList The PropertyList object being built for this FO.
- */
- public Property make(PropertyList propertyList) throws FOPException {
- return null;
- }
-
- /**
- * Return a Property object representing the initial value.
- * @param propertyList The PropertyList object being built for this FO.
- * @param parentFO The parent FO for the FO whose property is being made.
- * @return a Property subclass object holding a "compound" property object
- * initialized to the default values for each component.
- */
- protected Property makeCompound(PropertyList propertyList,
- FObj parentFO) throws FOPException {
- return null;
- }
-
- /**
- * Return a Property object representing the value of this property,
- * based on other property values for this FO.
- * A special case is properties which inherit the specified value,
- * rather than the computed value.
- * @param propertyList The PropertyList for the FO.
- * @return Property A computed Property value or null if no rules
- * are specified (in foproperties.xml) to compute the value.
- */
- public Property compute(PropertyList propertyList)
- throws FOPException {
- if (inheritsSpecified()) {
- // recalculate based on last specified value
- // Climb up propertylist and find last spec'd value
- // NEED PROPNAME!!! get from Maker
- Property specProp =
- propertyList.getNearestSpecified(propName);
- if (specProp != null) {
- // Only need to do this if the value is relative!!!
- String specVal = specProp.getSpecifiedValue();
- if (specVal != null) {
- try {
- return make(propertyList, specVal,
- propertyList.getParentFObj());
- } catch (FOPException e) {
- MessageHandler.errorln("Error computing property value for "
- + propName + " from "
- + specVal);
- return null;
- }
- }
- }
- }
- return null; // standard
- }
-
- public boolean isCorrespondingForced(PropertyList propertyList) {
- return false;
- }
-
- public Property getShorthand(PropertyList propertyList) {
- return null;
- }
-
- } // end of nested Maker class
-
- /**
- * The original specified value for properties which inherit
- * specified values.
- */
- private String specVal;
-
- /**
- * Set the original value specified for the property attribute.
- * @param specVal The specified value.
- */
- public void setSpecifiedValue(String specVal) {
- this.specVal = specVal;
- }
-
- /**
- * Return the original value specified for the property attribute.
- * @return The specified value as a String.
- */
- public String getSpecifiedValue() {
- return specVal;
- }
-
- /**
- * Accessor functions for all possible Property datatypes
- */
- public Length getLength() {
- return null;
- }
-
- public ColorType getColorType() {
- return null;
- }
-
- public CondLength getCondLength() {
- return null;
- }
-
- public LengthRange getLengthRange() {
- return null;
- }
-
- public LengthPair getLengthPair() {
- return null;
- }
-
- public Space getSpace() {
- return null;
- }
-
- public Keep getKeep() {
- return null;
- }
-
- public int getEnum() {
- return 0;
- }
-
- public char getCharacter() {
- return 0;
- }
-
- public Vector getList() {
- return null;
- } // List of Property objects
-
- public Number getNumber() {
- return null;
- }
-
- // Classes used when evaluating property expressions
- public Numeric getNumeric() {
- return null;
- }
-
- public String getNCname() {
- return null;
- }
-
- public Object getObject() {
- return null;
- }
-
- public String getString() {
- Object o = getObject();
- return (o == null) ? null : o.toString();
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.fo;
-
-import java.util.Hashtable;
-import org.apache.fop.messaging.MessageHandler;
-import org.apache.fop.fo.properties.WritingMode;
-import org.apache.fop.apps.FOPException;
-
-public class PropertyList extends Hashtable {
-
- private byte[] wmtable = null; // writing-mode values
- public static final int LEFT = 0;
- public static final int RIGHT = 1;
- public static final int TOP = 2;
- public static final int BOTTOM = 3;
- public static final int HEIGHT = 4;
- public static final int WIDTH = 5;
-
- public static final int START = 0;
- public static final int END = 1;
- public static final int BEFORE = 2;
- public static final int AFTER = 3;
- public static final int BLOCKPROGDIM = 4;
- public static final int INLINEPROGDIM = 5;
-
- private static final String[] sAbsNames = new String[] {
- "left", "right", "top", "bottom", "height", "width"
- };
-
- private static final String[] sRelNames = new String[] {
- "start", "end", "before", "after", "block-progression-dimension",
- "inline-progression-dimension"
- };
-
- static private final Hashtable wmtables = new Hashtable(4);
- {
- wmtables.put(new Integer(WritingMode.LR_TB), /* lr-tb */
- new byte[] {
- START, END, BEFORE, AFTER, BLOCKPROGDIM, INLINEPROGDIM
- });
- wmtables.put(new Integer(WritingMode.RL_TB), /* rl-tb */
- new byte[] {
- END, START, BEFORE, AFTER, BLOCKPROGDIM, INLINEPROGDIM
- });
- wmtables.put(new Integer(WritingMode.TB_RL), /* tb-rl */
- new byte[] {
- AFTER, BEFORE, START, END, INLINEPROGDIM, BLOCKPROGDIM
- });
- }
-
- private PropertyListBuilder builder;
- private PropertyList parentPropertyList = null;
- String namespace = "";
- String element = "";
- FObj fobj = null;
-
- public PropertyList(PropertyList parentPropertyList, String space,
- String el) {
- this.parentPropertyList = parentPropertyList;
- this.namespace = space;
- this.element = el;
- }
-
- public void setFObj(FObj fobj) {
- this.fobj = fobj;
- }
-
- public FObj getFObj() {
- return this.fobj;
- }
-
- public FObj getParentFObj() {
- if (parentPropertyList != null) {
- return parentPropertyList.getFObj();
- } else
- return null;
- }
-
- /**
- * Return the value explicitly specified on this FO.
- * @param propertyName The name of the property whose value is desired.
- * It may be a compound name, such as space-before.optimum.
- * @return The value if the property is explicitly set or set by
- * a shorthand property, otherwise null.
- */
- public Property getExplicitOrShorthand(String propertyName) {
- /* Handle request for one part of a compound property */
- int sepchar = propertyName.indexOf('.');
- String baseName;
- if (sepchar > -1) {
- baseName = propertyName.substring(0, sepchar);
- } else
- baseName = propertyName;
- Property p = getExplicitBaseProp(baseName);
- if (p == null) {
- p = builder.getShorthand(this, namespace, element, baseName);
- }
- if (p != null && sepchar > -1) {
- return builder.getSubpropValue(namespace, element, baseName, p,
- propertyName.substring(sepchar
- + 1));
- }
- return p;
- }
-
- /**
- * Return the value explicitly specified on this FO.
- * @param propertyName The name of the property whose value is desired.
- * It may be a compound name, such as space-before.optimum.
- * @return The value if the property is explicitly set, otherwise null.
- */
- public Property getExplicit(String propertyName) {
- /* Handle request for one part of a compound property */
- int sepchar = propertyName.indexOf('.');
- if (sepchar > -1) {
- String baseName = propertyName.substring(0, sepchar);
- Property p = getExplicitBaseProp(baseName);
- if (p != null) {
- return this.builder.getSubpropValue(namespace, element,
- baseName, p,
- propertyName.substring(sepchar
- + 1));
- } else
- return null;
- }
- return (Property)super.get(propertyName);
- }
-
- /**
- * Return the value explicitly specified on this FO.
- * @param propertyName The name of the base property whose value is desired.
- * @return The value if the property is explicitly set, otherwise null.
- */
- public Property getExplicitBaseProp(String propertyName) {
- return (Property)super.get(propertyName);
- }
-
- /**
- * Return the value of this property inherited by this FO.
- * Implements the inherited-property-value function.
- * The property must be inheritable!
- * @param propertyName The name of the property whose value is desired.
- * @return The inherited value, otherwise null.
- */
- public Property getInherited(String propertyName) {
- if (builder != null) {
- if (parentPropertyList != null
- && builder.isInherited(namespace, element,
- propertyName)) {
- return parentPropertyList.get(propertyName);
- } else {
- // return the "initial" value
- try {
- return builder.makeProperty(this, namespace, element,
- propertyName);
- } catch (org.apache.fop.apps.FOPException e) {
- MessageHandler.errorln("Exception in getInherited(): property="
- + propertyName + " : " + e);
- }
- }
- }
- return null; // No builder or exception in makeProperty!
- }
-
- /*
- * If the property is a relative property with a corresponding absolute
- * value specified, the absolute value is used. This is also true of
- * the inheritance priority (I think...)
- * If the property is an "absolute" property and it isn't specified, then
- * we try to compute it from the corresponding relative property: this
- * happends in computeProperty.
- */
- private Property findProperty(String propertyName, boolean bTryInherit) {
- Property p = null;
- if (builder.isCorrespondingForced(this, namespace, element,
- propertyName)) {
- p = builder.computeProperty(this, namespace, element,
- propertyName);
- } else {
- p = getExplicitBaseProp(propertyName);
- if (p == null) {
- p = this.builder.computeProperty(this, namespace, element,
- propertyName);
- }
- if (p == null) { // check for shorthand specification
- p = builder.getShorthand(this, namespace, element,
- propertyName);
- }
- if (p == null
- && bTryInherit) { // else inherit (if has parent and is inheritable)
- if (this.parentPropertyList != null
- && builder.isInherited(namespace, element,
- propertyName)) {
- p = parentPropertyList.findProperty(propertyName, true);
- }
- }
- }
- return p;
- }
-
-
- /**
- * Return the property on the current FlowObject if it is specified, or if a
- * corresponding property is specified. If neither is specified, it returns null.
- */
- public Property getSpecified(String propertyName) {
- return get(propertyName, false, false);
- }
-
-
- /**
- * Return the property on the current FlowObject. If it isn't set explicitly,
- * this will try to compute it based on other properties, or if it is
- * inheritable, to return the inherited value. If all else fails, it returns
- * the default value.
- */
- public Property get(String propertyName) {
- return get(propertyName, true, true);
- }
-
- /**
- * Return the property on the current FlowObject. Depending on the passed flags,
- * this will try to compute it based on other properties, or if it is
- * inheritable, to return the inherited value. If all else fails, it returns
- * the default value.
- */
- private Property get(String propertyName, boolean bTryInherit,
- boolean bTryDefault) {
-
- if (builder == null)
- MessageHandler.errorln("OH OH, builder has not been set");
-
- /* Handle request for one part of a compound property */
- int sepchar = propertyName.indexOf('.');
- String subpropName = null;
- if (sepchar > -1) {
- subpropName = propertyName.substring(sepchar + 1);
- propertyName = propertyName.substring(0, sepchar);
- }
-
- Property p = findProperty(propertyName, bTryInherit);
- if (p == null && bTryDefault) { // default value for this FO!
- try {
- p = this.builder.makeProperty(this, namespace, element,
- propertyName);
- } catch (FOPException e) {
- // don't know what to do here
- }
- }
-/*
- // if value is inherit then get computed value from
- // parent
- // namespaces??
- if(p != null && "inherit".equals(p.getString())) {
- if (this.parentPropertyList != null) {
- p = parentPropertyList.get(propertyName, true, false);
- }
- }
-*/
- if (subpropName != null && p != null) {
- return this.builder.getSubpropValue(namespace, element,
- propertyName, p, subpropName);
- } else
- return p;
- }
-
- public void setBuilder(PropertyListBuilder builder) {
- this.builder = builder;
- }
-
- public String getNameSpace() {
- return namespace;
- }
-
- public String getElement() {
- return element;
- }
-
- /**
- * Return the "nearest" specified value for the given property.
- * Implements the from-nearest-specified-value function.
- * @param propertyName The name of the property whose value is desired.
- * @return The computed value if the property is explicitly set on some
- * ancestor of the current FO, else the initial value.
- */
- public Property getNearestSpecified(String propertyName) {
- Property p = null;
- for (PropertyList plist = this; p == null && plist != null;
- plist = plist.parentPropertyList) {
- p = plist.getExplicit(propertyName);
- }
- if (p == null) {
- // If no explicit setting found, return initial (default) value.
- try {
- p = this.builder.makeProperty(this, namespace, element,
- propertyName);
- } catch (FOPException e) {
- MessageHandler.errorln("Exception in getNearestSpecified(): property="
- + propertyName + " : " + e);
- }
- }
- return p;
- }
-
- /**
- * Return the value of this property on the parent of this FO.
- * Implements the from-parent function.
- * @param propertyName The name of the property whose value is desired.
- * @return The computed value on the parent or the initial value if this
- * FO is the root or is in a different namespace from its parent.
- */
- public Property getFromParent(String propertyName) {
- if (parentPropertyList != null) {
- return parentPropertyList.get(propertyName);
- } else if (builder != null) {
- // return the "initial" value
- try {
- return builder.makeProperty(this, namespace, element,
- propertyName);
- } catch (org.apache.fop.apps.FOPException e) {
- MessageHandler.errorln("Exception in getFromParent(): property="
- + propertyName + " : " + e);
- }
- }
- return null; // No builder or exception in makeProperty!
- }
-
- /**
- * Given an absolute direction (top, bottom, left, right),
- * return the corresponding writing model relative direction name
- * for the flow object. Uses the stored writingMode.
- */
- public String wmAbsToRel(int absdir) {
- if (wmtable != null) {
- return sRelNames[wmtable[absdir]];
- } else
- return "";
- }
-
- /**
- * Given a writing mode relative direction (start, end, before, after)
- * return the corresponding absolute direction name
- * for the flow object. Uses the stored writingMode.
- */
- public String wmRelToAbs(int reldir) {
- if (wmtable != null) {
- for (int i = 0; i < wmtable.length; i++) {
- if (wmtable[i] == reldir)
- return sAbsNames[i];
- }
- }
- return "";
- }
-
- /**
- * Set the writing mode traits for the FO with this property list.
- */
- public void setWritingMode(int writingMode) {
- this.wmtable = (byte[])wmtables.get(new Integer(writingMode));
- }
-
-}
-
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.fo;
-
-import org.apache.fop.fo.properties.*;
-import org.apache.fop.messaging.MessageHandler;
-import org.apache.fop.svg.*;
-import org.apache.fop.datatypes.*;
-
-import org.apache.fop.apps.FOPException;
-
-import org.xml.sax.Attributes;
-
-import java.util.Hashtable;
-
-public class PropertyListBuilder {
-
- /**
- * Name of font-size property attribute to set first.
- */
- private static final String FONTSIZEATTR = "font-size";
-
- private Hashtable propertyListTable;
- private Hashtable elementTable;
-
- public PropertyListBuilder() {
- this.propertyListTable = new Hashtable();
- this.elementTable = new Hashtable();
- }
-
- public void addList(Hashtable list) {
- propertyListTable = list; // should add all
- }
-
- public void addElementList(String element, Hashtable list) {
- elementTable.put(element, list);
- }
-
- public Property computeProperty(PropertyList propertyList, String space,
- String element, String propertyName) {
-
- Property p = null;
- Property.Maker propertyMaker = findMaker(space, element,
- propertyName);
- if (propertyMaker != null) {
- try {
- p = propertyMaker.compute(propertyList);
- } catch (FOPException e) {
- MessageHandler.errorln("ERROR: exception occurred while computing"
- + " value of property '"
- + propertyName + "': "
- + e.getMessage());
- }
- } else {
- MessageHandler.errorln("WARNING: property " + propertyName
- + " ignored");
- }
- return p;
- }
-
- public boolean isInherited(String space, String element,
- String propertyName) {
- boolean b;
-
- Property.Maker propertyMaker = findMaker(space, element,
- propertyName);
- if (propertyMaker != null) {
- b = propertyMaker.isInherited();
- } else {
- // MessageHandler.errorln("WARNING: Unknown property " + propertyName);
- b = true;
- }
- return b;
- }
-
- public PropertyList makeList(String elementName, Attributes attributes,
- PropertyList parentPropertyList,
- FObj parentFO) throws FOPException {
- int index = elementName.indexOf("^");
- String space = "http://www.w3.org/TR/1999/XSL/Format";
- if (index != -1) {
- space = elementName.substring(0, index);
- }
-
- PropertyList par = null;
- if (parentPropertyList != null
- && space.equals(parentPropertyList.getNameSpace())) {
- par = parentPropertyList;
- }
- // System.out.println(elementName.substring(index + 1));
- PropertyList p = new PropertyList(par, space,
- elementName.substring(index + 1));
- p.setBuilder(this);
- Hashtable table;
- table = (Hashtable)elementTable.get(elementName.substring(index + 1));
-
- /* Store names of properties already set. */
- StringBuffer propsDone = new StringBuffer(256);
- propsDone.append(' ');
-
- /*
- * If font-size is set on this FO, must set it first, since
- * other attributes specified in terms of "ems" depend on it.
- * When we do "shorthand" properties, must handle the "font"
- * property as well to see if font-size is set.
- */
- String fontsizeval = attributes.getValue(FONTSIZEATTR);
- if (fontsizeval != null) {
- Property.Maker propertyMaker = findMaker(table, FONTSIZEATTR);
- if (propertyMaker != null) {
- try {
- p.put(FONTSIZEATTR,
- propertyMaker.make(p, fontsizeval, parentFO));
- } catch (FOPException e) {}
- }
- // Put in the "done" list even if error or no Maker.
- propsDone.append(FONTSIZEATTR + ' ');
- }
-
- for (int i = 0; i < attributes.getLength(); i++) {
- String attributeName = attributes.getQName(i);
- /* Handle "compound" properties, ex. space-before.minimum */
- int sepchar = attributeName.indexOf('.');
- String propName = attributeName;
- String subpropName = null;
- Property propVal = null;
- if (sepchar > -1) {
- propName = attributeName.substring(0, sepchar);
- subpropName = attributeName.substring(sepchar + 1);
- } else if (propsDone.toString().indexOf(' ' + propName + ' ')
- != -1) {
- // Already processed this property (base property
- // for a property with sub-components or font-size)
- continue;
- }
-
- Property.Maker propertyMaker = findMaker(table, propName);
-
- if (propertyMaker != null) {
- try {
- if (subpropName != null) {
- Property baseProp = p.getExplicitBaseProp(propName);
- if (baseProp == null) {
- // See if it is specified later in this list
- String baseValue = attributes.getValue(propName);
- if (baseValue != null) {
- baseProp = propertyMaker.make(p, baseValue,
- parentFO);
- propsDone.append(propName + ' ');
- }
- // else baseProp = propertyMaker.makeCompound(p, parentFO);
- }
- propVal = propertyMaker.make(baseProp, subpropName,
- p,
- attributes.getValue(i),
- parentFO);
- } else {
- propVal = propertyMaker.make(p,
- attributes.getValue(i),
- parentFO);
- }
- if (propVal != null) {
- p.put(propName, propVal);
- }
- } catch (FOPException e) { /* Do other props. */
- }
- } else {
- if (!attributeName.startsWith("xmlns"))
- MessageHandler.errorln("WARNING: property '"
- + attributeName + "' ignored");
- }
- }
-
- return p;
- }
-
- public Property getSubpropValue(String space, String element,
- String propertyName, Property p,
- String subpropName) {
- Property.Maker maker = findMaker(space, element, propertyName);
- if (maker != null) {
- return maker.getSubpropValue(p, subpropName);
- } else
- return null;
- }
-
-
- public boolean isCorrespondingForced(PropertyList propertyList,
- String space, String element,
- String propertyName) {
- Property.Maker propertyMaker = findMaker(space, element,
- propertyName);
- if (propertyMaker != null) {
- return propertyMaker.isCorrespondingForced(propertyList);
- } else {
- MessageHandler.errorln("WARNING: no Maker for " + propertyName);
- }
- return false;
- }
-
- public Property getShorthand(PropertyList propertyList, String space,
- String element, String propertyName) {
- Property.Maker propertyMaker = findMaker(space, element,
- propertyName);
- if (propertyMaker != null) {
- return propertyMaker.getShorthand(propertyList);
- } else {
- MessageHandler.errorln("WARNING: no Maker for " + propertyName);
- return null;
- }
- }
-
-
- public Property makeProperty(PropertyList propertyList, String space,
- String element,
- String propertyName) throws FOPException {
-
- Property p = null;
-
- Property.Maker propertyMaker = findMaker(space, element,
- propertyName);
- if (propertyMaker != null) {
- p = propertyMaker.make(propertyList);
- } else {
- MessageHandler.errorln("WARNING: property " + propertyName
- + " ignored");
- }
- return p;
- }
-
- protected Property.Maker findMaker(String space, String elementName,
- String propertyName) {
- return findMaker((Hashtable)elementTable.get(elementName),
- propertyName);
- }
-
- /**
- * Convenience function to return the Maker for a given property
- * given the Hashtable containing properties specific to this element.
- * If table is non-null and
- * @param elemTable Element-specific properties or null if none.
- * @param propertyName Name of property.
- * @return A Maker for this property.
- */
- private Property.Maker findMaker(Hashtable elemTable,
- String propertyName) {
- Property.Maker propertyMaker = null;
- if (elemTable != null) {
- propertyMaker = (Property.Maker)elemTable.get(propertyName);
- }
- if (propertyMaker == null) {
- propertyMaker =
- (Property.Maker)propertyListTable.get(propertyName);
- }
- return propertyMaker;
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.fo;
-
-import org.apache.fop.layout.FontState;
-import org.apache.fop.layout.FontInfo;
-import org.apache.fop.layout.BorderAndPadding;
-import org.apache.fop.layout.MarginProps;
-import org.apache.fop.layout.BackgroundProps;
-import org.apache.fop.layout.MarginInlineProps;
-import org.apache.fop.layout.AccessibilityProps;
-import org.apache.fop.layout.AuralProps;
-import org.apache.fop.layout.RelativePositionProps;
-import org.apache.fop.layout.AbsolutePositionProps;
-import org.apache.fop.fo.properties.BreakAfter;
-import org.apache.fop.fo.properties.BreakBefore;
-import org.apache.fop.fo.properties.Constants;
-import org.apache.fop.layout.HyphenationProps;
-import org.apache.fop.apps.FOPException;
-import java.text.MessageFormat;
-import java.text.FieldPosition;
-import org.apache.fop.layout.Area;
-import org.apache.fop.layout.ColumnArea;
-
-public class PropertyManager {
-
- private PropertyList properties;
- private FontState fontState = null;
- private BorderAndPadding borderAndPadding = null;
- private HyphenationProps hyphProps = null;
-
- private String[] saLeft;
- private String[] saRight;
- private String[] saTop;
- private String[] saBottom;
-
- private static MessageFormat msgColorFmt =
- new MessageFormat("border-{0}-color");
- private static MessageFormat msgStyleFmt =
- new MessageFormat("border-{0}-style");
- private static MessageFormat msgWidthFmt =
- new MessageFormat("border-{0}-width");
- private static MessageFormat msgPaddingFmt =
- new MessageFormat("padding-{0}");
-
- public PropertyManager(PropertyList pList) {
- this.properties = pList;
- }
-
- private void initDirections() {
- saLeft = new String[1];
- saRight = new String[1];
- saTop = new String[1];
- saBottom = new String[1];
- saTop[0] = properties.wmAbsToRel(PropertyList.TOP);
- saBottom[0] = properties.wmAbsToRel(PropertyList.BOTTOM);
- saLeft[0] = properties.wmAbsToRel(PropertyList.LEFT);
- saRight[0] = properties.wmAbsToRel(PropertyList.RIGHT);
- }
-
- public FontState getFontState(FontInfo fontInfo) throws FOPException {
- if (fontState == null) {
- String fontFamily = properties.get("font-family").getString();
- String fontStyle = properties.get("font-style").getString();
- String fontWeight = properties.get("font-weight").getString();
- // NOTE: this is incomplete. font-size may be specified with
- // various kinds of keywords too
- int fontSize = properties.get("font-size").getLength().mvalue();
- int fontVariant = properties.get("font-variant").getEnum();
- // fontInfo is same for the whole FOP run but set in all FontState
- fontState = new FontState(fontInfo, fontFamily, fontStyle,
- fontWeight, fontSize, fontVariant);
- }
- return fontState;
- }
-
-
- public BorderAndPadding getBorderAndPadding() {
- if (borderAndPadding == null) {
- this.borderAndPadding = new BorderAndPadding();
- initDirections();
-
- initBorderInfo(BorderAndPadding.TOP, saTop);
- initBorderInfo(BorderAndPadding.BOTTOM, saBottom);
- initBorderInfo(BorderAndPadding.LEFT, saLeft);
- initBorderInfo(BorderAndPadding.RIGHT, saRight);
- }
- return borderAndPadding;
- }
-
- private void initBorderInfo(int whichSide, String[] saSide) {
- borderAndPadding.setPadding(whichSide,
- properties.get(msgPaddingFmt.format(saSide)).getCondLength());
- // If style = none, force width to 0, don't get Color
- int style = properties.get(msgStyleFmt.format(saSide)).getEnum();
- if (style != Constants.NONE) {
- borderAndPadding.setBorder(whichSide, style,
- properties.get(msgWidthFmt.format(saSide)).getCondLength(),
- properties.get(msgColorFmt.format(saSide)).getColorType());
- }
- }
-
- public HyphenationProps getHyphenationProps() {
- if (hyphProps == null) {
- this.hyphProps = new HyphenationProps();
- hyphProps.hyphenate = this.properties.get("hyphenate").getEnum();
- hyphProps.hyphenationChar =
- this.properties.get("hyphenation-character").getCharacter();
- hyphProps.hyphenationPushCharacterCount =
- this.properties.get("hyphenation-push-character-count").getNumber().intValue();
- hyphProps.hyphenationRemainCharacterCount =
- this.properties.get("hyphenation-remain-character-count").getNumber().intValue();
- hyphProps.language = this.properties.get("language").getString();
- hyphProps.country = this.properties.get("country").getString();
- }
- return hyphProps;
- }
-
- public int checkBreakBefore(Area area) {
- if (!(area instanceof ColumnArea)) {
- switch (properties.get("break-before").getEnum()) {
- case BreakBefore.PAGE:
- return Status.FORCE_PAGE_BREAK;
- case BreakBefore.ODD_PAGE:
- return Status.FORCE_PAGE_BREAK_ODD;
- case BreakBefore.EVEN_PAGE:
- return Status.FORCE_PAGE_BREAK_EVEN;
- case BreakBefore.COLUMN:
- return Status.FORCE_COLUMN_BREAK;
- default:
- return Status.OK;
- }
- } else {
- ColumnArea colArea = (ColumnArea)area;
- switch (properties.get("break-before").getEnum()) {
- case BreakBefore.PAGE:
- // if first ColumnArea, and empty, return OK
- if (!colArea.hasChildren() && (colArea.getColumnIndex() == 1))
- return Status.OK;
- else
- return Status.FORCE_PAGE_BREAK;
- case BreakBefore.ODD_PAGE:
- // if first ColumnArea, empty, _and_ in odd page,
- // return OK
- if (!colArea.hasChildren() && (colArea.getColumnIndex() == 1)
- && (colArea.getPage().getNumber() % 2 != 0))
- return Status.OK;
- else
- return Status.FORCE_PAGE_BREAK_ODD;
- case BreakBefore.EVEN_PAGE:
- // if first ColumnArea, empty, _and_ in even page,
- // return OK
- if (!colArea.hasChildren() && (colArea.getColumnIndex() == 1)
- && (colArea.getPage().getNumber() % 2 == 0))
- return Status.OK;
- else
- return Status.FORCE_PAGE_BREAK_EVEN;
- case BreakBefore.COLUMN:
- // if ColumnArea is empty return OK
- if (!area.hasChildren())
- return Status.OK;
- else
- return Status.FORCE_COLUMN_BREAK;
- default:
- return Status.OK;
- }
- }
- }
-
- public int checkBreakAfter(Area area) {
- switch (properties.get("break-after").getEnum()) {
- case BreakAfter.PAGE:
- return Status.FORCE_PAGE_BREAK;
- case BreakAfter.ODD_PAGE:
- return Status.FORCE_PAGE_BREAK_ODD;
- case BreakAfter.EVEN_PAGE:
- return Status.FORCE_PAGE_BREAK_EVEN;
- case BreakAfter.COLUMN:
- return Status.FORCE_COLUMN_BREAK;
- default:
- return Status.OK;
- }
- }
-
- public MarginProps getMarginProps() {
- MarginProps props = new MarginProps();
-
- // Common Margin Properties-Block
- props.marginTop =
- this.properties.get("margin-top").getLength().mvalue();
- props.marginBottom =
- this.properties.get("margin-bottom").getLength().mvalue();
- props.marginLeft =
- this.properties.get("margin-left").getLength().mvalue();
- props.marginRight =
- this.properties.get("margin-right").getLength().mvalue();
- /*
- * // need to get opt, min and max
- * props.spaceBefore = this.properties.get("space-before").getLength().mvalue();
- * props.spaceAfter = this.properties.get("space-after").getLength().mvalue();
- * props.startIndent = this.properties.get("start-indent").getLength().mvalue();
- * props.endIndent = this.properties.get("end-indent").getLength().mvalue();
- */
- return props;
- }
-
- public BackgroundProps getBackgroundProps() {
- BackgroundProps bp = new BackgroundProps();
- return bp;
- }
-
- public MarginInlineProps getMarginInlineProps() {
- MarginInlineProps props = new MarginInlineProps();
- return props;
- }
-
- public AccessibilityProps getAccessibilityProps() {
- AccessibilityProps props = new AccessibilityProps();
- String str;
- str = this.properties.get("source-document").getString();
- if(!"none".equals(str)) {
- props.sourceDoc = str;
- }
- str = this.properties.get("role").getString();
- if(!"none".equals(str)) {
- props.role = str;
- }
- return props;
- }
-
- public AuralProps getAuralProps() {
- AuralProps props = new AuralProps();
- return props;
- }
-
- public RelativePositionProps getRelativePositionProps() {
- RelativePositionProps props = new RelativePositionProps();
- return props;
- }
-
- public AbsolutePositionProps getAbsolutePositionProps() {
- AbsolutePositionProps props = new AbsolutePositionProps();
- return props;
- }
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.fo;
-
-public interface ShorthandParser {
- public Property getValueForProperty(String propName,
- Property.Maker maker,
- PropertyList propertyList);
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-package org.apache.fop.fo;
-
-import org.apache.fop.datatypes.Length;
-import org.apache.fop.datatypes.Space;
-import org.apache.fop.datatypes.LengthRange;
-
-public class SpaceProperty extends Property {
-
- public static class Maker extends LengthRangeProperty.Maker {
- protected Maker(String name) {
- super(name);
- }
-
- }
-
- private Space space;
-
- public SpaceProperty(Space space) {
- this.space = space;
- }
-
- public Space getSpace() {
- return this.space;
- }
-
- /* Space extends LengthRange */
- public LengthRange getLengthRange() {
- return this.space;
- }
-
- public Object getObject() {
- return this.space;
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.fo;
-
-import java.util.Enumeration;
-import java.util.Hashtable;
-
-import org.apache.fop.fo.properties.FOPropertyMapping;
-import org.apache.fop.fo.flow.*;
-import org.apache.fop.fo.pagination.*;
-
-public class StandardElementMapping implements ElementMapping {
-
- public void addToBuilder(TreeBuilder builder) {
-
- String uri = "http://www.w3.org/1999/XSL/Format";
-
- // Declarations and Pagination and Layout Formatting Objects
- builder.addMapping(uri, "root", Root.maker());
- builder.addMapping(uri, "declarations", Declarations.maker());
- builder.addMapping(uri, "color-profile", ColorProfile.maker());
- builder.addMapping(uri, "page-sequence", PageSequence.maker());
- builder.addMapping(uri, "layout-master-set", LayoutMasterSet.maker());
- builder.addMapping(uri, "page-sequence-master",
- PageSequenceMaster.maker());
- builder.addMapping(uri, "single-page-master-reference",
- SinglePageMasterReference.maker());
- builder.addMapping(uri, "repeatable-page-master-reference",
- RepeatablePageMasterReference.maker());
- builder.addMapping(uri, "repeatable-page-master-alternatives",
- RepeatablePageMasterAlternatives.maker());
- builder.addMapping(uri, "conditional-page-master-reference",
- ConditionalPageMasterReference.maker());
- builder.addMapping(uri, "simple-page-master",
- SimplePageMaster.maker());
- builder.addMapping(uri, "region-body", RegionBody.maker());
- builder.addMapping(uri, "region-before", RegionBefore.maker());
- builder.addMapping(uri, "region-after", RegionAfter.maker());
- builder.addMapping(uri, "region-start", RegionStart.maker());
- builder.addMapping(uri, "region-end", RegionEnd.maker());
- builder.addMapping(uri, "flow", Flow.maker());
- builder.addMapping(uri, "static-content", StaticContent.maker());
- builder.addMapping(uri, "title", Title.maker());
-
- // Block-level Formatting Objects
- builder.addMapping(uri, "block", Block.maker());
- builder.addMapping(uri, "block-container", BlockContainer.maker());
-
- // Inline-level Formatting Objects
- builder.addMapping(uri, "bidi-override", BidiOverride.maker());
- builder.addMapping(uri, "character",
- org.apache.fop.fo.flow.Character.maker());
- builder.addMapping(uri, "initial-property-set",
- InitialPropertySet.maker());
- builder.addMapping(uri, "external-graphic", ExternalGraphic.maker());
- builder.addMapping(uri, "instream-foreign-object",
- InstreamForeignObject.maker());
- builder.addMapping(uri, "inline", Inline.maker());
- builder.addMapping(uri, "inline-container", InlineContainer.maker());
- builder.addMapping(uri, "leader", Leader.maker());
- builder.addMapping(uri, "page-number", PageNumber.maker());
- builder.addMapping(uri, "page-number-citation",
- PageNumberCitation.maker());
-
- // Formatting Objects for Tables
- builder.addMapping(uri, "table-and-caption", TableAndCaption.maker());
- builder.addMapping(uri, "table", Table.maker());
- builder.addMapping(uri, "table-column", TableColumn.maker());
- builder.addMapping(uri, "table-caption", TableCaption.maker());
- builder.addMapping(uri, "table-header", TableHeader.maker());
- builder.addMapping(uri, "table-footer", TableFooter.maker());
- builder.addMapping(uri, "table-body", TableBody.maker());
- builder.addMapping(uri, "table-row", TableRow.maker());
- builder.addMapping(uri, "table-cell", TableCell.maker());
-
- // Formatting Objects for Lists
- builder.addMapping(uri, "list-block", ListBlock.maker());
- builder.addMapping(uri, "list-item", ListItem.maker());
- builder.addMapping(uri, "list-item-body", ListItemBody.maker());
- builder.addMapping(uri, "list-item-label", ListItemLabel.maker());
-
- // Dynamic Effects: Link and Multi Formatting Objects
- builder.addMapping(uri, "basic-link", BasicLink.maker());
- builder.addMapping(uri, "multi-switch", MultiSwitch.maker());
- builder.addMapping(uri, "multi-case", MultiCase.maker());
- builder.addMapping(uri, "multi-toggle", MultiToggle.maker());
- builder.addMapping(uri, "multi-properties", MultiProperties.maker());
- builder.addMapping(uri, "multi-property-set",
- MultiPropertySet.maker());
-
- // Out-of-Line Formatting Objects
- builder.addMapping(uri, "float",
- org.apache.fop.fo.flow.Float.maker());
- builder.addMapping(uri, "footnote", Footnote.maker());
- builder.addMapping(uri, "footnote-body", FootnoteBody.maker());
-
- // Other Formatting Objects
- builder.addMapping(uri, "wrapper", Wrapper.maker());
- builder.addMapping(uri, "marker", Marker.maker());
- builder.addMapping(uri, "retrieve-marker", RetrieveMarker.maker());
-
- builder.addPropertyList(uri, FOPropertyMapping.getGenericMappings());
- /* Add any element mappings */
- for (Enumeration e = FOPropertyMapping.getElementMappings();
- e.hasMoreElements(); ) {
- String elem = (String)e.nextElement();
- builder.addElementPropertyList(uri, elem,
- FOPropertyMapping.getElementMapping(elem));
- }
-
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.fo;
-
-/**
- * classes representating the status of laying out a formatting object
- */
-public class Status {
-
- protected int code;
-
- public final static int OK = 1;
- public final static int AREA_FULL_NONE = 2;
- public final static int AREA_FULL_SOME = 3;
- public final static int FORCE_PAGE_BREAK = 4;
- public final static int FORCE_PAGE_BREAK_EVEN = 5;
- public final static int FORCE_PAGE_BREAK_ODD = 6;
- public final static int FORCE_COLUMN_BREAK = 7;
- public final static int KEEP_WITH_NEXT = 8;
-
- public Status(int code) {
- this.code = code;
- }
-
- public int getCode() {
- return this.code;
- }
-
- public boolean isIncomplete() {
- return ((this.code != OK) && (this.code != KEEP_WITH_NEXT));
- }
-
- public boolean laidOutNone() {
- return (this.code == AREA_FULL_NONE);
- }
-
- public boolean isPageBreak() {
- return ((this.code == FORCE_PAGE_BREAK)
- || (this.code == FORCE_PAGE_BREAK_EVEN)
- || (this.code == FORCE_PAGE_BREAK_ODD));
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.fo;
-
-
-public class StringProperty extends Property {
-
- public static class Maker extends Property.Maker {
-
- public Maker(String propName) {
- super(propName);
- }
-
- public Property make(PropertyList propertyList, String value,
- FObj fo) {
- // Work around the fact that most String properties are not
- // specified as actual String literals (with "" or '') since
- // the attribute values themselves are Strings!
- // If the value starts with ' or ", make sure it also ends with
- // this character
- // Otherwise, just take the whole value as the String
- int vlen = value.length() - 1;
- if (vlen > 0) {
- char q1 = value.charAt(0);
- if (q1 == '"' || q1 == '\'') {
- if (value.charAt(vlen) == q1) {
- return new StringProperty(value.substring(1, vlen));
- }
- System.err.println("Warning String-valued property starts with quote"
- + " but doesn't end with quote: "
- + value);
- // fall through and use the entire value, including first quote
- }
- }
- return new StringProperty(value);
- }
-
- } // end String.Maker
-
- private String str;
-
- public StringProperty(String str) {
- this.str = str;
- // System.err.println("Set StringProperty: " + str);
- }
-
- public Object getObject() {
- return this.str;
- }
-
- public String getString() {
- return this.str;
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.fo;
-
-// FOP
-import org.apache.fop.fo.*;
-import org.apache.fop.datatypes.*;
-import org.apache.fop.layout.*;
-import org.apache.fop.messaging.MessageHandler;
-import org.apache.fop.fo.flow.*;
-import org.apache.fop.fo.properties.*;
-import org.apache.fop.layout.AreaTree;
-import org.apache.fop.apps.FOPException;
-
-/**
- */
-public class Title extends ToBeImplementedElement {
-
- public static class Maker extends FObj.Maker {
- public FObj make(FObj parent,
- PropertyList propertyList) throws FOPException {
- return new Title(parent, propertyList);
- }
-
- }
-
- public static FObj.Maker maker() {
- return new Title.Maker();
- }
-
- protected Title(FObj parent,
- PropertyList propertyList) throws FOPException {
- super(parent, propertyList);
- this.name = "fo:title";
- }
-
- public Status layout(Area area) throws FOPException {
-
- // Common Accessibility Properties
- AccessibilityProps mAccProps = propMgr.getAccessibilityProps();
-
- // Common Aural Properties
- AuralProps mAurProps = propMgr.getAuralProps();
-
- // Common Border, Padding, and Background Properties
- BorderAndPadding bap = propMgr.getBorderAndPadding();
- BackgroundProps bProps = propMgr.getBackgroundProps();
-
- // Common Font Properties
- FontState fontState = propMgr.getFontState(area.getFontInfo());
-
- // Common Margin Properties-Inline
- MarginInlineProps mProps = propMgr.getMarginInlineProps();
-
- Property prop;
- prop = this.properties.get("baseline-shift");
- if (prop instanceof LengthProperty) {
- Length bShift = prop.getLength();
- } else if (prop instanceof EnumProperty) {
- int bShift = prop.getEnum();
- }
- ColorType col = this.properties.get("color").getColorType();
- Length lHeight = this.properties.get("line-height").getLength();
- int lShiftAdj = this.properties.get(
- "line-height-shift-adjustment").getEnum();
- int vis = this.properties.get("visibility").getEnum();
- Length zIndex = this.properties.get("z-index").getLength();
-
- return super.layout(area);
- }
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.fo;
-
-// FOP
-import org.apache.fop.fo.*;
-import org.apache.fop.messaging.MessageHandler;
-import org.apache.fop.fo.flow.*;
-import org.apache.fop.fo.properties.*;
-import org.apache.fop.layout.Area;
-import org.apache.fop.apps.FOPException;
-
-/**
- */
-public class ToBeImplementedElement extends FObj {
-
- protected ToBeImplementedElement(FObj parent, PropertyList propertyList)
- throws FOPException {
- super(parent, propertyList);
- }
-
- public Status layout(Area area) throws FOPException {
- MessageHandler.logln("This element \"" + this.name
- + "\" is not yet implemented.");
- return new Status(Status.OK);
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.fo;
-
-// FOP
-import org.apache.fop.layout.AreaTree;
-import org.apache.fop.messaging.MessageHandler;
-import org.apache.fop.apps.FOPException;
-import org.apache.fop.fo.pagination.Root;
-
-// SAX
-import org.xml.sax.helpers.DefaultHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.InputSource;
-import org.xml.sax.Attributes;
-
-// Java
-import java.util.Hashtable;
-import java.util.Stack;
-import java.io.IOException;
-
-/**
- */
-public interface TreeBuilder {
-
-
- /**
- * add a mapping from element name to maker.
- *
- * @param namespaceURI namespace URI of formatting object element
- * @param localName local name of formatting object element
- * @param maker Maker for class representing formatting object
- */
- public void addMapping(String namespaceURI, String localName,
- FObj.Maker maker);
-
- /**
- * add a mapping from element name to maker.
- *
- * @param namespaceURI namespace URI of formatting object element
- * @param localName local name of formatting object element
- * @param maker Maker for class representing formatting object
- */
- public void addPropertyList(String namespaceURI, Hashtable list);
-
- /**
- * add a mapping from element name to maker.
- *
- * @param namespaceURI namespace URI of formatting object element
- * @param localName local name of formatting object element
- * @param maker Maker for class representing formatting object
- */
- public void addElementPropertyList(String namespaceURI, String localName,
- Hashtable list);
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.fo;
-
-// FOP
-import org.apache.fop.fo.*;
-import org.apache.fop.layout.*;
-import org.apache.fop.messaging.MessageHandler;
-import org.apache.fop.fo.flow.*;
-import org.apache.fop.fo.properties.*;
-import org.apache.fop.layout.AreaTree;
-import org.apache.fop.apps.FOPException;
-
-/**
- * This represents an unknown element.
- * For example with unsupported namespaces.
- * This prevents any further problems arising from the unknown
- * data.
- */
-public class Unknown extends FObj {
-
- public static class Maker extends FObj.Maker {
- public FObj make(FObj parent,
- PropertyList propertyList) throws FOPException {
- return new Unknown(parent, propertyList);
- }
-
- }
-
- public static FObj.Maker maker() {
- return new Unknown.Maker();
- }
-
- protected Unknown(FObj parent,
- PropertyList propertyList) throws FOPException {
- super(parent, propertyList);
- this.name = "unknown";
- }
-
- public Status layout(Area area) throws FOPException {
- MessageHandler.logln("Layout Unknown element");
- return new Status(Status.OK);
- }
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.fo;
-
-public interface XTElementMapping {
-
- public void addToBuilder(XTFOTreeBuilder builder);
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.fo;
-
-// FOP
-import org.apache.fop.layout.AreaTree;
-import org.apache.fop.messaging.MessageHandler;
-import org.apache.fop.apps.FOPException;
-import org.apache.fop.fo.pagination.Root;
-
-// SAX
-import org.xml.sax.SAXException;
-import org.xml.sax.Attributes;
-import org.xml.sax.helpers.AttributesImpl;
-import org.xml.sax.DocumentHandler;
-import org.xml.sax.AttributeList;
-
-// Java
-import java.util.Hashtable;
-import java.util.Stack;
-import java.io.IOException;
-
-/**
- * SAX Handler that builds the formatting object tree.
- */
-// public class XTFOTreeBuilder extends HandlerBase {
-public class XTFOTreeBuilder extends FOTreeBuilder
- implements DocumentHandler {
-
- // namespace implementation ideas pinched from John Cowan
- protected static class NSMap {
- String prefix;
- String uri;
- int level;
-
- NSMap(String prefix, String uri, int level) {
- this.prefix = prefix;
- this.uri = uri;
- this.level = level;
- }
-
- }
-
- protected int level = 0;
- protected String m_uri = null;
- protected String m_localPart = null;
- protected Stack namespaceStack = new Stack();
-
- {
- namespaceStack.push(new NSMap("xml",
- "http://www.w3.org/XML/1998/namespace",
- -1));
- namespaceStack.push(new NSMap("", "", -1));
- }
-
- protected String findURI(String prefix) {
- for (int i = namespaceStack.size() - 1; i >= 0; i--) {
- NSMap nsMap = (NSMap)(namespaceStack.elementAt(i));
- if (prefix.equals(nsMap.prefix))
- return nsMap.uri;
- }
- return null;
- }
-
- protected String mapName(String name) throws SAXException {
-
- int colon = name.indexOf(':');
- String prefix = "";
- m_localPart = name;
- if (colon != -1) {
- prefix = name.substring(0, colon);
- m_localPart = name.substring(colon + 1);
- }
- m_uri = findURI(prefix);
- if (m_uri == null) {
- if (prefix.equals("")) {
- return name;
- } else {
- throw new SAXException(new FOPException("Unknown namespace prefix "
- + prefix));
- }
- }
- return m_uri + "^" + m_localPart;
- }
-
- /**
- * SAX1 Handler for the end of an element
- */
- public void endElement(String rawName) throws SAXException {
- mapName(rawName);
- super.endElement(m_uri, m_localPart, rawName);
- level--;
- while (((NSMap)namespaceStack.peek()).level > level) {
- namespaceStack.pop();
- }
- }
-
- /**
- * SAX1 Handler for the start of an element
- */
- public void startElement(String rawName,
- AttributeList attlist) throws SAXException {
-
- // SAX2 version of AttributeList
- AttributesImpl newAttrs = new AttributesImpl();
-
- level++;
- int length = attlist.getLength();
- for (int i = 0; i < length; i++) {
- String att = attlist.getName(i);
- if (att.equals("xmlns")) {
- namespaceStack.push(new NSMap("", attlist.getValue(i),
- level));
- } else if (att.startsWith("xmlns:")) {
- String value = attlist.getValue(i);
- namespaceStack.push(new NSMap(att.substring(6), value,
- level));
- } else {
- mapName(att);
- newAttrs.addAttribute(m_uri, m_localPart, att,
- attlist.getType(i),
- attlist.getValue(i));
- }
-
- }
-
- mapName(rawName);
- super.startElement(m_uri, m_localPart, rawName, newAttrs);
- }
-
-}