/**
* Return an iterator over the object's childNodes starting
- * at the pased node.
+ * at the passed-in node.
* @param childNode First node in the iterator
* @return A ListIterator or null if childNode isn't a child of
* this FObj.
|| (!isOutOfLineFODescendant && lName.equals("float"))
|| lName.equals("retrieve-marker")));
}
+
+ /**
+ * Convenience method for validity checking. Checks if the
+ * current node has an ancestor of a given name.
+ * @param ancestorName -- node name to check for (e.g., "fo:root")
+ * @return number of levels above FO where ancestor exists,
+ * -1 if not found
+ */
+ protected int findAncestor(String ancestorName) {
+ int found = 1;
+ FONode temp = getParent();
+ while (temp != null) {
+ if (temp.getName().equals(ancestorName)) {
+ return found;
+ }
+ found += 1;
+ temp = temp.getParent();
+ }
+ return -1;
+ }
}
package org.apache.fop.fo.flow;
+// XML
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXParseException;
+
// FOP
+import org.apache.fop.fo.FOElementMapping;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObjMixed;
import org.apache.fop.layoutmgr.AddLMVisitor;
*/
public class BidiOverride extends FObjMixed {
+ // used for FO validation
+ private boolean blockOrInlineItemFound = false;
+ private boolean canHaveBlockLevelChildren = true;
+
/**
* @param parent FONode that is the parent of this object
*/
public BidiOverride(FONode parent) {
super(parent);
- }
-
- private void setup() {
-
- // Common Aural Properties
- CommonAural mAurProps = propMgr.getAuralProps();
+
+ /* Check to see if this node can have block-level children.
+ * See validateChildNode() below.
+ */
+ int lvlLeader = findAncestor("fo:leader");
+ int lvlInCntr = findAncestor("fo:inline-container");
+ int lvlInline = findAncestor("fo:inline");
+ int lvlFootnote = findAncestor("fo:footnote");
- // Common Font Properties
- //this.fontState = propMgr.getFontState(area.getFontInfo());
+ if (lvlLeader > 0) {
+ if (lvlInCntr < 0 ||
+ (lvlInCntr > 0 && lvlInCntr > lvlLeader)) {
+ canHaveBlockLevelChildren = false;
+ }
+ } else if (lvlInline > 0 && lvlFootnote == (lvlInline + 1)) {
+ if (lvlInCntr < 0 ||
+ (lvlInCntr > 0 && lvlInCntr > lvlInline)) {
+ canHaveBlockLevelChildren = false;
+ }
+ }
- // Common Margin Properties-Inline
- CommonRelativePosition mProps = propMgr.getRelativePositionProps();
+ }
- // this.propertyList.get("color");
- // this.propertyList.get("direction");
+ /**
+ * @see org.apache.fop.fo.FObj#addProperties
+ */
+ protected void addProperties(Attributes attlist) throws SAXParseException {
+ super.addProperties(attlist);
setupID();
- // this.propertyList.get("letter-spacing");
- // this.propertyList.get("line-height");
- // this.propertyList.get("line-height-shift-adjustment");
- // this.propertyList.get("score-spaces");
- // this.propertyList.get("text-shadow");
- // this.propertyList.get("text-transform");
- // this.propertyList.get("unicode-bidi");
- // this.propertyList.get("word-spacing");
+ }
+ /**
+ * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
+ * XSL Content Model: marker* (#PCDATA|%inline;|%block;)*
+ * Additionally: "An fo:bidi-override that is a descendant of an fo:leader
+ * or of the fo:inline child of an fo:footnote may not have block-level
+ * children, unless it has a nearer ancestor that is an
+ * fo:inline-container."
+ */
+ 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 if (!canHaveBlockLevelChildren && isBlockItem(nsURI, localName)) {
+ invalidChildError(loc, nsURI, localName);
+ } else {
+ blockOrInlineItemFound = true;
+ }
+ }
+
+ public String getName() {
+ return "fo:bidi-override";
}
/**
public void acceptVisitor(AddLMVisitor aLMV) {
aLMV.serveBidiOverride(this);
}
-
- public String getName() {
- return "fo:bidi-override";
- }
}
+ " be directly under flow", locator);
}
- // Common Accessibility Properties
- CommonAccessibility mAccProps = propMgr.getAccessibilityProps();
-
- // Common Aural Properties
- CommonAural mAurProps = propMgr.getAuralProps();
-
- // Common Border, Padding, and Background Properties
- CommonBorderAndPadding bap = propMgr.getBorderAndPadding();
- CommonBackground bProps = propMgr.getBackgroundProps();
-
- // Common Font Properties
- //this.fontState = propMgr.getFontState(area.getFontInfo());
-
- // Common Margin Properties-Inline
- CommonMarginInline mProps = propMgr.getMarginInlineProps();
-
- // 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("color");
- // this.propertyList.get("dominant-baseline");
setupID();
- // 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("text-devoration");
- // this.propertyList.get("visibility");
- // this.propertyList.get("z-index");
int textDecoration = this.propertyList.get(PR_TEXT_DECORATION).getEnum();
getFOInputHandler().startInline(this);
}
+ /**
+ * @see org.apache.fop.fo.FONode#end
+ */
+ protected void endOfNode() throws SAXParseException {
+ getFOInputHandler().endInline(this);
+ }
+
/**
* @return true (Inline can contain Markers)
*/
aLMV.serveInline(this);
}
- /**
- * @see org.apache.fop.fo.FONode#end
- */
- protected void endOfNode() throws SAXParseException {
- getFOInputHandler().endInline(this);
- }
-
public String getName() {
return "fo:inline";
}