/** Parent FO node */
protected FONode parent;
- /** Name of the node */
- protected String name;
-
/** Marks input file containing this object **/
public String systemId;
*/
public void processNode(String elementName, Locator locator, Attributes attlist) throws FOPException {
System.out.println("name = " + elementName);
- this.name = elementName;
}
/**
* @return the name of this object
*/
public String getName() {
- return this.name;
+ return null;
}
/**
}
}
- /**
- * This is a hook for the AddLMVisitor class to be able to access
- * this object.
- * @param aLMV the AddLMVisitor object that can access this object.
- */
- public void acceptVisitor(AddLMVisitor aLMV) {
- aLMV.serveFOText(this);
- }
-
-
private class TextCharIterator extends AbstractCharIterator {
private int curIndex = 0;
}
}
-
+
+ public String getName() {
+ return "fo:text";
+ }
+
+ /**
+ * This is a hook for the AddLMVisitor class to be able to access
+ * this object.
+ * @param aLMV the AddLMVisitor object that can access this object.
+ */
+ public void acceptVisitor(AddLMVisitor aLMV) {
+ aLMV.serveFOText(this);
+ }
}
/** Property manager for providing refined properties/traits. */
protected PropertyManager propMgr;
- /** Id of this fo element of null if no id. */
- protected String id = null;
-
/** The immediate child nodes of this node. */
public ArrayList childNodes = null;
+ /** Used to indicate if this FO is either an Out Of Line FO (see rec)
+ or a descendant of one. Used during validateChildNode() FO
+ validation.
+ */
+ private boolean isOutOfLineFODescendant = false;
+
+ /** Id of this fo element or null if no id. */
+ protected String id = null;
+
/** Markers added to this element. */
protected Map markers = null;
/** Dynamic layout dimension. Used to resolve relative lengths. */
protected Map layoutDimension = null;
- /** During input FO validation, certain FO's are not valid as
- child nodes if they would be a descendant of an Out Of Line
- Formatting Object as defined in specification (See Sect. 6.2
- of spec.) This value is also set to true if this object
- itself is an Out Of Line FO.
- */
- protected boolean isOutOfLineFODescendant = false;
-
/**
* Create a new formatting object.
* All formatting object classes extend this class.
*
* @param parent the parent node
+ * @todo move propertyListTable initialization someplace else?
*/
public FObj(FONode parent) {
super(parent);
}
}
- /**
- * Used to indicate if this FO is the descendant of an out-of-line
- * formatting object (From Sect. 6.10, fo:float, fo:footnote,
- * fo:footnote-body). Important for validating child nodes.
- * @return true if descendant, false otherwise
- */
- public boolean getIsOutOfLineFODescendant() {
- return isOutOfLineFODescendant;
- }
-
/**
* @see org.apache.fop.fo.FONode#processNode
*/
addProperties(attlist);
}
- /**
- * Set the name of this element.
- * The prepends "fo:" to the name to indicate it is in the fo namespace.
- * @param str the xml element name
- */
- public void setName(String str) {
- name = "fo:" + str;
- }
-
/**
* Set properties for this FO based on node attributes
* @param attlist Collection of attributes passed to us from the parser.
setWritingMode();
}
+ /**
+ * Returns Out Of Line FO Descendant indicator.
+ * @return true if Out of Line FO or Out Of Line descendant, false otherwise
+ */
+ public boolean getIsOutOfLineFODescendant() {
+ return isOutOfLineFODescendant;
+ }
+
/**
* Return the PropertyManager object for this FO. PropertyManager
* tends to hold the traits for this FO, and is primarily used in layout.
*/
protected void addChildNode(FONode child) {
if (containsMarkers() && "fo:marker".equals(child.getName())) {
- addMarker((Marker)child);
+ addMarker((Marker) child);
} else {
if (childNodes == null) {
childNodes = new ArrayList();
/**
* Check if this formatting object may contain markers.
*
- * @return true if this can contian markers
+ * @return true if this can contain markers
+ * @todo confirm if still needed after validateChildNode() fully implemented
*/
protected boolean containsMarkers() {
return false;
|| isNeutralItem(nsURI, lName)));
}
+ /**
+ * Convenience method for validity checking. Checks if the
+ * incoming node is a member of the "%block;" parameter entity
+ * or "%inline;" parameter entity
+ * @param nsURI namespace URI of incoming node
+ * @param lName local name (i.e., no prefix) of incoming node
+ * @return true if a member, false if not
+ */
+ protected boolean isBlockOrInlineItem(String nsURI, String lName) {
+ return (isBlockItem(nsURI, lName) || isInlineItem(nsURI, lName));
+ }
+
/**
* Convenience method for validity checking. Checks if the
* incoming node is a member of the neutral item list
FOText ft = new FOText(data, start, length, textInfo, this);
ft.setLocation(locator);
- ft.setName("text");
/* characters() processing empty for FOTreeHandler, not empty for RTF & MIFHandlers */
getFOInputHandler().characters(ft.ca, ft.startIndex, ft.endIndex);
super(parent);
}
- private void setup() {
- getLogger().debug("This element \"" + this.name
- + "\" is not yet implemented.");
- }
-
/**
* This is a hook for the AddLMVisitor class to be able to access
* this object.
/** DOM document containing this node */
protected Document doc;
+ /** Name of the node */
+ protected String name;
+
/**
*
* @param parent the parent formatting object
return null;
}
+ /**
+ * Returns the name of the object
+ * @return the name of this object
+ */
+ public String getName() {
+ return name;
+ }
+
/**
* @return string containing the namespace for this node
*/
// XML
import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
import org.xml.sax.SAXParseException;
// FOP
import org.apache.fop.apps.FOPException;
+import org.apache.fop.fo.FOElementMapping;
import org.apache.fop.fo.FONode;
import org.apache.fop.layoutmgr.AddLMVisitor;
import org.apache.fop.fo.properties.CommonAccessibility;
* that are created by the fo element.
*/
public class BasicLink extends Inline {
-
private String link = null;
private boolean external = false;
+ // used for FO validation
+ private boolean blockOrInlineItemFound = false;
+
/**
* @param parent FONode that is the parent of this object
*/
getFOInputHandler().startLink(this);
}
- public void setup() {
+ /**
+ * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
+ * XSL Content Model: marker* (#PCDATA|%inline;|%block;)*
+ */
+ protected void validateChildNode(Locator loc, String nsURI, String localName)
+ throws SAXParseException {
+ if (nsURI == FOElementMapping.URI && localName.equals("marker")) {
+ if (blockOrInlineItemFound) {
+ nodesOutOfOrderError(loc, "fo:marker", "(#PCDATA|%inline;|%block;)");
+ }
+ } else if (!isBlockOrInlineItem(nsURI, localName)) {
+ invalidChildError(loc, nsURI, localName);
+ } else {
+ blockOrInlineItemFound = true;
+ }
+ }
+
+ /**
+ * @see org.apache.fop.fo.FONode#end
+ */
+ protected void endOfNode() throws SAXParseException {
+ super.endOfNode();
+ getFOInputHandler().endLink();
+ }
+
+ /**
+ * @return the String value of the link
+ */
+ public String getLink() {
+ return link;
+ }
+
+ /**
+ * @return true if the link is external, false otherwise
+ */
+ public boolean getExternal() {
+ return external;
+ }
+
+ public String getName() {
+ return "fo:basic-link";
+ }
+
+ /**
+ * @todo check if needed; not being called currently
+ */
+ private void setup() {
String destination;
int linkType;
// Common Relative Position Properties
CommonRelativePosition mRelProps = propMgr.getRelativePositionProps();
- // this.propertyList.get("alignment-adjust");
- // this.propertyList.get("alignment-baseline");
- // this.propertyList.get("baseline-shift");
- // this.propertyList.get("destination-place-offset");
- // this.propertyList.get("dominant-baseline");
String ext = propertyList.get(PR_EXTERNAL_DESTINATION).getString();
setupID();
- // this.propertyList.get("indicate-destination");
+
String internal = propertyList.get(PR_INTERNAL_DESTINATION).getString();
+
if (ext.length() > 0) {
link = ext;
external = true;
} else {
getLogger().error("basic-link requires an internal or external destination");
}
- // this.propertyList.get("keep-together");
- // this.propertyList.get("keep-with-next");
- // this.propertyList.get("keep-with-previous");
- // this.propertyList.get("line-height");
- // this.propertyList.get("line-height-shift-adjustment");
- // this.propertyList.get("show-destination");
- // this.propertyList.get("target-processing-context");
- // this.propertyList.get("target-presentation-context");
- // this.propertyList.get("target-stylesheet");
-
}
/**
* @return true (BasicLink can contain Markers)
- */
+ */
protected boolean containsMarkers() {
return true;
}
- /**
- * @return the String value of the link
- */
- public String getLink() {
- return link;
- }
-
- /**
- * @return true if the link is external, false otherwise
- */
- public boolean getExternal() {
- return external;
- }
-
/**
* This is a hook for the AddLMVisitor class to be able to access
* this object.
* @param aLMV the AddLMVisitor object that can access this object.
*/
public void acceptVisitor(AddLMVisitor aLMV) {
+ setup();
aLMV.serveBasicLink(this);
}
-
- /**
- * @see org.apache.fop.fo.FONode#end
- */
- protected void endOfNode() throws SAXParseException {
- super.endOfNode();
- getFOInputHandler().endLink();
- }
-
- public String getName() {
- return "fo:basic-link";
- }
}
* Setup this image.
* This gets the sizes for the image and the dimensions and clipping.
*/
- public void setup() {
+ private void setup() {
url = this.propertyList.get(PR_SRC).getString();
if (url == null) {
return;
return viewHeight;
}
- /**
- * This is a hook for the AddLMVisitor class to be able to access
- * this object.
- * @param aLMV the AddLMVisitor object that can access this object.
- */
- public void acceptVisitor(AddLMVisitor aLMV) {
- aLMV.serveExternalGraphic(this);
- }
-
public String getURL() {
return url;
}
return "fo:external-graphic";
}
+ /**
+ * This is a hook for the AddLMVisitor class to be able to access
+ * this object.
+ * @param aLMV the AddLMVisitor object that can access this object.
+ */
+ public void acceptVisitor(AddLMVisitor aLMV) {
+ setup();
+ aLMV.serveExternalGraphic(this);
+ }
}
*/
public Float(FONode parent) {
super(parent);
- this.name = "fo:float";
}
private void setup() {
super(parent);
}
- public void setup() {
+ private void setup() {
// Common Accessibility Properties
CommonAccessibility mAccProps = propMgr.getAccessibilityProps();
return patternWidth;
}
+ public String getName() {
+ return "fo:leader";
+ }
+
/**
* This is a hook for the AddLMVisitor class to be able to access
* this object.
* @param aLMV the AddLMVisitor object that can access this object.
*/
public void acceptVisitor(AddLMVisitor aLMV) {
+ setup();
aLMV.serveLeader(this);
}
-
- public String getName() {
- return "fo:leader";
- }
}
getFOInputHandler().startPageNumber(this);
}
- public void setup() {
+ private void setup() {
// Common Accessibility Properties
CommonAccessibility mAccProps = propMgr.getAccessibilityProps();
return fontState;
}
- /**
- * This is a hook for the AddLMVisitor class to be able to access
- * this object.
- * @param aLMV the AddLMVisitor object that can access this object.
- */
- public void acceptVisitor(AddLMVisitor aLMV) {
- aLMV.servePageNumber(this);
- }
-
protected void endOfNode() throws SAXParseException {
getFOInputHandler().endPageNumber(this);
}
public String getName() {
return "fo:page-number";
}
+
+ /**
+ * This is a hook for the AddLMVisitor class to be able to access
+ * this object.
+ * @param aLMV the AddLMVisitor object that can access this object.
+ */
+ public void acceptVisitor(AddLMVisitor aLMV) {
+ setup();
+ aLMV.servePageNumber(this);
+ }
}
return width;
}
- public void setup() {
+ private void setup() {
// Common Accessibility Properties
CommonAccessibility mAccProps = propMgr.getAccessibilityProps();
unresolved = isUnresolved;
}
- public void acceptVisitor(AddLMVisitor aLMV) {
- aLMV.servePageNumberCitation(this);
- }
-
public Font getFontState() {
return fontState;
}
public String getName() {
return "fo:page-number-citation";
}
+
+ public void acceptVisitor(AddLMVisitor aLMV) {
+ setup();
+ aLMV.servePageNumberCitation(this);
+ }
}
/**
* Initialize property values.
*/
- public void setup() {
+ private void setup() {
// Common Accessibility Properties
CommonAccessibility mAccProps = propMgr.getAccessibilityProps();
/**
* @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
- * XSL/FOP Content Model: empty
+ * XSL Content Model: empty
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
throws SAXParseException {
*/
private int contentWidth;
- /**
- * Content-width of current column area during layout
- */
+ /** used for FO validation */
private boolean blockItemFound = false;
/**
/**
* @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
- * XSL/FOP Content Model: marker* (%block;)+
+ * XSL Content Model: marker* (%block;)+
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
throws SAXParseException {
/**
* @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
- XSL/FOP Content Model: (title?,static-content*,flow)
+ XSL Content Model: (title?,static-content*,flow)
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
throws SAXParseException {
if (isReserved(getRegionName())
&& !getRegionName().equals(getDefaultRegionName())) {
throw new FOPException("region-name '" + regionName
- + "' for " + this.name
+ + "' for " + this.getName()
+ " not permitted.");
}
}
if (parent instanceof SimplePageMaster) {
layoutMaster = (SimplePageMaster)parent;
} else {
- throw new FOPException(this.name + " must be child "
+ throw new FOPException(this.getName() + " must be child "
+ "of simple-page-master, not "
+ parent.getName());
}
/**
* @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
- * XSL/FOP Content Model: empty
+ * XSL Content Model: empty
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
throws SAXParseException {
/**
* @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
- * XSL/FOP Content Model: empty
+ * XSL Content Model: empty
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
throws SAXParseException {
/**
* @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
- * XSL/FOP Content Model: (%block;)+
+ * XSL Content Model: (%block;)+
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
throws SAXParseException {
* Add start and end properties for the link
*/
public void serveBasicLink(final BasicLink node) {
- node.setup();
InlineStackingLayoutManager lm;
lm = new InlineStackingLayoutManager(node) {
protected InlineParent createArea() {
}
private InlineArea getLeaderInlineArea(Leader node, LayoutManager parentLM) {
- node.setup();
InlineArea leaderArea = null;
if (node.getLeaderPattern() == Constants.LeaderPattern.RULE) {
* @return the viewport containing the image area
*/
public InlineArea getExternalGraphicInlineArea(ExternalGraphic node) {
- node.setup();
if (node.getURL() == null) {
return null;
}
* @param lms the list to which the layout manager(s) should be added
*/
public void servePageNumber(final PageNumber node) {
- node.setup();
LayoutManager lm;
lm = new LeafNodeLayoutManager(node) {
public InlineArea get(LayoutContext context) {
}
public void servePageNumberCitation(final PageNumberCitation node) {
- node.setup();
LayoutManager lm;
lm = new LeafNodeLayoutManager(node) {
public InlineArea get(LayoutContext context) {