aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/fo
diff options
context:
space:
mode:
authorGlen Mazza <gmazza@apache.org>2004-08-14 18:36:21 +0000
committerGlen Mazza <gmazza@apache.org>2004-08-14 18:36:21 +0000
commit09a6084a3915ca1786610bb524105c711fac0a5d (patch)
treefbb5e7aabac082edbaea93b43a66b42228ee56bf /src/java/org/apache/fop/fo
parentc051ae01325e8bffb9985204eaf1115ec4d39329 (diff)
downloadxmlgraphics-fop-09a6084a3915ca1786610bb524105c711fac0a5d.tar.gz
xmlgraphics-fop-09a6084a3915ca1786610bb524105c711fac0a5d.zip
1.) fo:Instream-Foreign-Object initialization logic moved from AddLMVisitor
to flow.InstreamForiegnObject.java, and the layout logic itself moved to a new layoutmgr.InstreamForeignObjectLM.java. (Broke with usual nomenclature of adding ~LayoutManager to end, given that newer 1.1 and post-1.1 FO names are getting even larger.) 2.) validateChildNode() added for fo:inline. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197871 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/fo')
-rw-r--r--src/java/org/apache/fop/fo/FObjMixed.java1
-rw-r--r--src/java/org/apache/fop/fo/flow/Inline.java86
-rw-r--r--src/java/org/apache/fop/fo/flow/InstreamForeignObject.java20
3 files changed, 66 insertions, 41 deletions
diff --git a/src/java/org/apache/fop/fo/FObjMixed.java b/src/java/org/apache/fop/fo/FObjMixed.java
index d5d272f6e..902bd3457 100644
--- a/src/java/org/apache/fop/fo/FObjMixed.java
+++ b/src/java/org/apache/fop/fo/FObjMixed.java
@@ -26,6 +26,7 @@ import org.apache.fop.layoutmgr.InlineStackingLayoutManager;
/**
* Base class for representation of mixed content formatting objects
* and their processing
+ * @todo define what a "mixed content formatting object" is
*/
public class FObjMixed extends FObj {
/** TextInfo for this object */
diff --git a/src/java/org/apache/fop/fo/flow/Inline.java b/src/java/org/apache/fop/fo/flow/Inline.java
index 4e97670dc..5df8b7573 100644
--- a/src/java/org/apache/fop/fo/flow/Inline.java
+++ b/src/java/org/apache/fop/fo/flow/Inline.java
@@ -20,34 +20,23 @@ 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.apps.FOPException;
import org.apache.fop.fo.CharIterator;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObjMixed;
import org.apache.fop.fo.InlineCharIterator;
-import org.apache.fop.layoutmgr.AddLMVisitor;
-import org.apache.fop.fo.properties.CommonAccessibility;
-import org.apache.fop.fo.properties.CommonAural;
-import org.apache.fop.fo.properties.CommonBackground;
-import org.apache.fop.fo.properties.CommonBorderAndPadding;
-import org.apache.fop.fo.properties.CommonMarginInline;
-import org.apache.fop.fo.properties.CommonRelativePosition;
/**
- * Class modelling the fo:inline object. See Sec. 6.6.7 of the XSL-FO Standard.
+ * Class modelling the fo:inline formatting object.
*/
public class Inline extends FObjMixed {
- // Textdecoration
- /** is this text underlined? */
- protected boolean underlined = false;
- /** is this text overlined? */
- protected boolean overlined = false;
- /** is this text lined through? */
- protected boolean lineThrough = false;
+ // used for FO validation
+ private boolean blockOrInlineItemFound = false;
+ private boolean canHaveBlockLevelChildren = true;
/**
* @param parent FONode that is the parent of this object
@@ -62,28 +51,56 @@ public class Inline extends FObjMixed {
protected void addProperties(Attributes attlist) throws SAXParseException {
super.addProperties(attlist);
- if (parent.getName().equals("fo:flow")) {
- throw new SAXParseException("inline formatting objects cannot"
- + " be directly under flow", locator);
- }
-
- int textDecoration = this.propertyList.get(PR_TEXT_DECORATION).getEnum();
-
- if (textDecoration == TextDecoration.UNDERLINE) {
- this.underlined = true;
- }
+ /* Check to see if this node can have block-level children.
+ * See validateChildNode() below.
+ */
+ int lvlLeader = findAncestor("fo:leader");
+ int lvlFootnote = findAncestor("fo:footnote");
+ int lvlInCntr = findAncestor("fo:inline-container");
+
+ if (lvlLeader > 0) {
+ if (lvlInCntr < 0 ||
+ (lvlInCntr > 0 && lvlInCntr > lvlLeader)) {
+ canHaveBlockLevelChildren = false;
+ }
+ } else if (lvlFootnote > 0) {
+ if (lvlInCntr < 0 || lvlInCntr > lvlFootnote) {
+ canHaveBlockLevelChildren = false;
+ }
+ }
- if (textDecoration == TextDecoration.OVERLINE) {
- this.overlined = true;
- }
+ getFOInputHandler().startInline(this);
+ }
- if (textDecoration == TextDecoration.LINE_THROUGH) {
- this.lineThrough = true;
+ /**
+ * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
+ * XSL Content Model: marker* (#PCDATA|%inline;|%block;)*
+ * Additionally: " An fo:inline that is a descendant of an fo:leader
+ * or fo:footnote may not have block-level children, unless it has a
+ * nearer ancestor that is an fo:inline-container." (paraphrased)
+ */
+ protected void validateChildNode(Locator loc, String nsURI, String localName)
+ throws SAXParseException {
+ if (nsURI == FO_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)) {
+ String ruleViolated =
+ " An fo:inline that is a descendant of an fo:leader" +
+ " or fo:footnote may not have block-level children," +
+ " unless it has a nearer ancestor that is an" +
+ " fo:inline-container.";
+ invalidChildError(loc, nsURI, localName, ruleViolated);
+ } else {
+ blockOrInlineItemFound = true;
}
-
- getFOInputHandler().startInline(this);
}
+
/**
* @see org.apache.fop.fo.FONode#end
*/
@@ -98,6 +115,9 @@ public class Inline extends FObjMixed {
return new InlineCharIterator(this, propMgr.getBorderAndPadding());
}
+ /**
+ * @see org.apache.fop.fo.FObj#getName()
+ */
public String getName() {
return "fo:inline";
}
diff --git a/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java b/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java
index f11a7ece3..5c7264aa4 100644
--- a/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java
+++ b/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java
@@ -18,6 +18,9 @@
package org.apache.fop.fo.flow;
+// Java
+import java.util.List;
+
// XML
import org.xml.sax.Attributes;
import org.xml.sax.Locator;
@@ -25,8 +28,7 @@ import org.xml.sax.SAXParseException;
// FOP
import org.apache.fop.fo.FONode;
-import org.apache.fop.fo.LMVisited;
-import org.apache.fop.layoutmgr.AddLMVisitor;
+import org.apache.fop.layoutmgr.InstreamForeignObjectLM;
import org.apache.fop.fo.FObj;
/**
@@ -34,7 +36,7 @@ import org.apache.fop.fo.FObj;
* This is an atomic inline object that contains
* xml data.
*/
-public class InstreamForeignObject extends FObj implements LMVisited {
+public class InstreamForeignObject extends FObj {
boolean hasNonXSLNamespaceElement = false;
@@ -121,14 +123,16 @@ public class InstreamForeignObject extends FObj implements LMVisited {
}
/**
- * 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.
+ * @see org.apache.fop.fo.FObj#addLayoutManager(List)
*/
- public void acceptVisitor(AddLMVisitor aLMV) {
- aLMV.serveInstreamForeignObject(this);
+ public void addLayoutManager(List list) {
+ InstreamForeignObjectLM lm = new InstreamForeignObjectLM(this);
+ list.add(lm);
}
+ /**
+ * @see org.apache.fop.fo.FObj#getName()
+ */
public String getName() {
return "fo:instream-foreign-object";
}