aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/fo/flow
diff options
context:
space:
mode:
authorGlen Mazza <gmazza@apache.org>2004-08-18 03:26:37 +0000
committerGlen Mazza <gmazza@apache.org>2004-08-18 03:26:37 +0000
commit74ca9b8223ae7f3168ffc75f3b85c1b692af09b4 (patch)
tree12d220c455ed3d8a6585c418c3de98e8771f3e01 /src/java/org/apache/fop/fo/flow
parent98a82065accd4dfb081daa8429f03f0fed993dff (diff)
downloadxmlgraphics-fop-74ca9b8223ae7f3168ffc75f3b85c1b692af09b4.tar.gz
xmlgraphics-fop-74ca9b8223ae7f3168ffc75f3b85c1b692af09b4.zip
1. Moved getNameId() from FObj to FONode.
2. Centralized determination of generatesInlineAreas() from multiple FObj subclasses into fo.PropertySets BitSet object. 3. validateChildNode() implemented for fo:list-item. 4. fo:initial-property-set now extending FObj instead of ToBeImplementedElement; burden of implementation on individual FOInputHandler subclasses. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197882 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/fo/flow')
-rw-r--r--src/java/org/apache/fop/fo/flow/Block.java20
-rw-r--r--src/java/org/apache/fop/fo/flow/BlockContainer.java10
-rw-r--r--src/java/org/apache/fop/fo/flow/ExternalGraphic.java1
-rw-r--r--src/java/org/apache/fop/fo/flow/InitialPropertySet.java12
-rw-r--r--src/java/org/apache/fop/fo/flow/InstreamForeignObject.java9
-rw-r--r--src/java/org/apache/fop/fo/flow/ListBlock.java38
-rw-r--r--src/java/org/apache/fop/fo/flow/ListItem.java95
-rw-r--r--src/java/org/apache/fop/fo/flow/Table.java7
-rw-r--r--src/java/org/apache/fop/fo/flow/TableAndCaption.java6
9 files changed, 74 insertions, 124 deletions
diff --git a/src/java/org/apache/fop/fo/flow/Block.java b/src/java/org/apache/fop/fo/flow/Block.java
index 537a0f553..254864f6f 100644
--- a/src/java/org/apache/fop/fo/flow/Block.java
+++ b/src/java/org/apache/fop/fo/flow/Block.java
@@ -32,6 +32,7 @@ import org.apache.fop.fo.CharIterator;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.FObjMixed;
+import org.apache.fop.fo.PropertySets;
import org.apache.fop.fo.RecursiveCharIterator;
import org.apache.fop.layoutmgr.BlockLayoutManager;
import org.apache.fop.fo.Constants;
@@ -91,6 +92,7 @@ public class Block extends FObjMixed {
/**
* @param parent FONode that is the parent of this object
+ *
*/
public Block(FONode parent) {
super(parent);
@@ -176,24 +178,18 @@ public class Block extends FObjMixed {
}
/**
- * @return false (Block cannot generate inline areas)
- */
- public boolean generatesInlineAreas() {
- return false;
- }
-
- /**
* @see org.apache.fop.fo.FONode#addChildNode(FONode)
*/
public void addChildNode(FONode child) {
// Handle whitespace based on values of properties
// Handle a sequence of inline-producing child nodes in
// one pass
- if (child instanceof FObj && ((FObj) child).generatesInlineAreas()) {
- if (firstInlineChild == null) {
- firstInlineChild = child;
- }
- // lastInlineChild = childNodes.size();
+ if (child instanceof FObj && ("fo:text".equals(child.getName())
+ || PropertySets.generatesInlineAreas(child.getNameId()))) {
+ if (firstInlineChild == null) {
+ firstInlineChild = child;
+ }
+ // lastInlineChild = childNodes.size();
} else {
// Handle whitespace in preceeding inline areas if any
handleWhiteSpace();
diff --git a/src/java/org/apache/fop/fo/flow/BlockContainer.java b/src/java/org/apache/fop/fo/flow/BlockContainer.java
index 2f2813db5..91214ad1b 100644
--- a/src/java/org/apache/fop/fo/flow/BlockContainer.java
+++ b/src/java/org/apache/fop/fo/flow/BlockContainer.java
@@ -76,13 +76,6 @@ public class BlockContainer extends FObj {
}
/**
- * @return false (BlockContainer cannot generate inline areas)
- */
- public boolean generatesInlineAreas() {
- return false;
- }
-
- /**
* @return the span for this object
*/
public int getSpan() {
@@ -98,6 +91,9 @@ public class BlockContainer extends FObj {
list.add(blm);
}
+ /**
+ * @see org.apache.fop.fo.FObj#getName()
+ */
public String getName() {
return "fo:block-container";
}
diff --git a/src/java/org/apache/fop/fo/flow/ExternalGraphic.java b/src/java/org/apache/fop/fo/flow/ExternalGraphic.java
index 99bb8bedb..fd449e946 100644
--- a/src/java/org/apache/fop/fo/flow/ExternalGraphic.java
+++ b/src/java/org/apache/fop/fo/flow/ExternalGraphic.java
@@ -59,6 +59,7 @@ public class ExternalGraphic extends FObj {
/**
* @see org.apache.fop.fo.FObj#addProperties
+ * @todo switch method from image() to startImage()?
*/
protected void addProperties(Attributes attlist) throws SAXParseException {
super.addProperties(attlist);
diff --git a/src/java/org/apache/fop/fo/flow/InitialPropertySet.java b/src/java/org/apache/fop/fo/flow/InitialPropertySet.java
index 982d1b434..a3b39e0bb 100644
--- a/src/java/org/apache/fop/fo/flow/InitialPropertySet.java
+++ b/src/java/org/apache/fop/fo/flow/InitialPropertySet.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-/* $Id$ */
+/* $Id:$ */
package org.apache.fop.fo.flow;
@@ -25,13 +25,12 @@ import org.xml.sax.SAXParseException;
// FOP
import org.apache.fop.fo.FONode;
-import org.apache.fop.fo.ToBeImplementedElement;
+import org.apache.fop.fo.FObj;
/**
- * Class modelling the fo:initial-property-set object. See Sec. 6.6.4 of the
- * XSL-FO Standard.
+ * Class modelling the fo:initial-property-set object.
*/
-public class InitialPropertySet extends ToBeImplementedElement {
+public class InitialPropertySet extends FObj {
/**
* @param parent FONode that is the parent of this object
@@ -49,6 +48,9 @@ public class InitialPropertySet extends ToBeImplementedElement {
invalidChildError(loc, nsURI, localName);
}
+ /**
+ * @see org.apache.fop.fo.FObj#getName()
+ */
public String getName() {
return "fo:initial-property-set";
}
diff --git a/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java b/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java
index 8bd5a5f49..0da8d71ff 100644
--- a/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java
+++ b/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java
@@ -114,15 +114,6 @@ public class InstreamForeignObject extends FObj {
}
/**
- * This flow object generates inline areas.
- * @see org.apache.fop.fo.FObj#generatesInlineAreas()
- * @return true
- */
- public boolean generatesInlineAreas() {
- return true;
- }
-
- /**
* @see org.apache.fop.fo.FObj#addLayoutManager(List)
*/
public void addLayoutManager(List list) {
diff --git a/src/java/org/apache/fop/fo/flow/ListBlock.java b/src/java/org/apache/fop/fo/flow/ListBlock.java
index 86d6b70e8..244095c25 100644
--- a/src/java/org/apache/fop/fo/flow/ListBlock.java
+++ b/src/java/org/apache/fop/fo/flow/ListBlock.java
@@ -38,18 +38,6 @@ import org.apache.fop.layoutmgr.list.ListBlockLayoutManager;
*/
public class ListBlock extends FObj {
- private int align;
- private int alignLast;
- private int breakBefore;
- private int breakAfter;
- private int lineHeight;
- private int startIndent;
- private int endIndent;
- private int spaceBefore;
- private int spaceAfter;
- private int spaceBetweenListRows = 0;
- private ColorType backgroundColor;
-
// used for child node validation
private boolean hasListItem = false;
@@ -65,22 +53,6 @@ public class ListBlock extends FObj {
*/
protected void addProperties(Attributes attlist) throws SAXParseException {
super.addProperties(attlist);
-
- this.align = this.propertyList.get(PR_TEXT_ALIGN).getEnum();
- this.alignLast = this.propertyList.get(PR_TEXT_ALIGN_LAST).getEnum();
- this.lineHeight =
- this.propertyList.get(PR_LINE_HEIGHT).getLength().getValue();
- this.startIndent =
- this.propertyList.get(PR_START_INDENT).getLength().getValue();
- this.endIndent =
- this.propertyList.get(PR_END_INDENT).getLength().getValue();
- this.spaceBefore =
- this.propertyList.get(PR_SPACE_BEFORE | CP_OPTIMUM).getLength().getValue();
- this.spaceAfter =
- this.propertyList.get(PR_SPACE_AFTER | CP_OPTIMUM).getLength().getValue();
- this.spaceBetweenListRows = 0; // not used at present
- this.backgroundColor =
- this.propertyList.get(PR_BACKGROUND_COLOR).getColorType();
getFOInputHandler().startList(this);
}
@@ -114,13 +86,6 @@ public class ListBlock extends FObj {
}
/**
- * @return false (ListBlock does not generate inline areas)
- */
- public boolean generatesInlineAreas() {
- return false;
- }
-
- /**
* @see org.apache.fop.fo.FObj#addLayoutManager(List)
*/
public void addLayoutManager(List list) {
@@ -128,6 +93,9 @@ public class ListBlock extends FObj {
list.add(lm);
}
+ /**
+ * @see org.apache.fop.fo.FObj#getName()
+ */
public String getName() {
return "fo:list-block";
}
diff --git a/src/java/org/apache/fop/fo/flow/ListItem.java b/src/java/org/apache/fop/fo/flow/ListItem.java
index 49aaf4fe2..7fd8170b2 100644
--- a/src/java/org/apache/fop/fo/flow/ListItem.java
+++ b/src/java/org/apache/fop/fo/flow/ListItem.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-/* $Id$ */
+/* $Id:$ */
package org.apache.fop.fo.flow;
@@ -23,6 +23,7 @@ import java.util.List;
// XML
import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
import org.xml.sax.SAXParseException;
// FOP
@@ -31,24 +32,13 @@ import org.apache.fop.fo.FObj;
import org.apache.fop.layoutmgr.list.ListItemLayoutManager;
/**
- * Class modelling the fo:list-item object. See Sec. 6.8.3 of the XSL-FO
- * Standard.
+ * Class modelling the fo:list-item object.
*/
public class ListItem extends FObj {
private ListItemLabel label = null;
private ListItemBody body = null;
- private int align;
- private int alignLast;
- private int breakBefore;
- private int breakAfter;
- private int lineHeight;
- private int startIndent;
- private int endIndent;
- private int spaceBefore;
- private int spaceAfter;
-
/**
* @param parent FONode that is the parent of this object
*/
@@ -62,49 +52,68 @@ public class ListItem extends FObj {
protected void addProperties(Attributes attlist) throws SAXParseException {
super.addProperties(attlist);
getFOInputHandler().startListItem(this);
- this.align = this.propertyList.get(PR_TEXT_ALIGN).getEnum();
- this.alignLast = this.propertyList.get(PR_TEXT_ALIGN_LAST).getEnum();
- this.lineHeight =
- this.propertyList.get(PR_LINE_HEIGHT).getLength().getValue();
- this.spaceBefore =
- this.propertyList.get(PR_SPACE_BEFORE | CP_OPTIMUM).getLength().getValue();
- this.spaceAfter =
- this.propertyList.get(PR_SPACE_AFTER | CP_OPTIMUM).getLength().getValue();
+ }
+
+ /**
+ * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
+ * XSL Content Model: marker* (list-item-label,list-item-body)
+ */
+ protected void validateChildNode(Locator loc, String nsURI, String localName)
+ throws SAXParseException {
+ if (nsURI == FO_URI && localName.equals("marker")) {
+ if (label != null) {
+ nodesOutOfOrderError(loc, "fo:marker", "fo:list-item-label");
+ }
+ } else if (nsURI == FO_URI && localName.equals("list-item-label")) {
+ if (label != null) {
+ tooManyNodesError(loc, "fo:list-item-label");
+ }
+ } else if (nsURI == FO_URI && localName.equals("list-item-body")) {
+ if (label == null) {
+ nodesOutOfOrderError(loc, "fo:list-item-label", "fo:list-item-body");
+ } else if (body != null) {
+ tooManyNodesError(loc, "fo:list-item-body");
+ }
+ } else {
+ invalidChildError(loc, nsURI, localName);
+ }
}
/**
* @see org.apache.fop.fo.FONode#addChildNode(FONode)
+ * @todo see if can/should rely on base class for this
+ * (i.e., add to childNodes instead)
*/
public void addChildNode(FONode child) {
- if ("fo:list-item-label".equals(child.getName())) {
- label = (ListItemLabel)child;
- } else if ("fo:list-item-body".equals(child.getName())) {
- body = (ListItemBody)child;
- } else if ("fo:marker".equals(child.getName())) {
- // marker
- } else {
- // error
+ int nameId = ((FObj)child).getNameId();
+
+ if (nameId == FO_LIST_ITEM_LABEL) {
+ label = (ListItemLabel) child;
+ } else if (nameId == FO_LIST_ITEM_BODY) {
+ body = (ListItemBody) child;
+ } else if (nameId == FO_MARKER) {
+ addMarker((Marker) child);
}
}
/**
- * @return false (ListItem cannot generate inline areas)
+ * Make sure content model satisfied, if so then tell the
+ * FOInputHandler that we are at the end of the flow.
+ * @see org.apache.fop.fo.FONode#end
*/
- public boolean generatesInlineAreas() {
- return false;
+ protected void endOfNode() throws SAXParseException {
+ if (label == null || body == null) {
+ missingChildElementError("marker* (list-item-label,list-item-body)");
+ }
+ getFOInputHandler().endListItem(this);
}
/**
* @see org.apache.fop.fo.FObj#addLayoutManager(List)
- * @todo remove checks for non-nulls after validateChildNode() added
*/
public void addLayoutManager(List list) {
- if (label != null && body != null) {
- ListItemLayoutManager blm = new ListItemLayoutManager(this);
- list.add(blm);
- } else {
- getLogger().error("list-item requires list-item-label and list-item-body");
- }
+ ListItemLayoutManager blm = new ListItemLayoutManager(this);
+ list.add(blm);
}
public ListItemLabel getLabel() {
@@ -115,11 +124,9 @@ public class ListItem extends FObj {
return body;
}
- protected void endOfNode() throws SAXParseException {
- super.endOfNode();
- getFOInputHandler().endListItem(this);
- }
-
+ /**
+ * @see org.apache.fop.fo.FObj#getName()
+ */
public String getName() {
return "fo:list-item";
}
diff --git a/src/java/org/apache/fop/fo/flow/Table.java b/src/java/org/apache/fop/fo/flow/Table.java
index e6402ecda..57e380fb9 100644
--- a/src/java/org/apache/fop/fo/flow/Table.java
+++ b/src/java/org/apache/fop/fo/flow/Table.java
@@ -130,13 +130,6 @@ public class Table extends FObj {
}
}
- /**
- * @return false (Table does not generate inline areas)
- */
- public boolean generatesInlineAreas() {
- return false;
- }
-
private ArrayList getColumns() {
return columns;
}
diff --git a/src/java/org/apache/fop/fo/flow/TableAndCaption.java b/src/java/org/apache/fop/fo/flow/TableAndCaption.java
index caa8ee189..cd79627f9 100644
--- a/src/java/org/apache/fop/fo/flow/TableAndCaption.java
+++ b/src/java/org/apache/fop/fo/flow/TableAndCaption.java
@@ -36,12 +36,8 @@ public class TableAndCaption extends ToBeImplementedElement {
}
/**
- * @return false (TableAndCaption doesn't generate inline areas)
+ * @see org.apache.fop.fo.FObj#getName()
*/
- public boolean generatesInlineAreas() {
- return false;
- }
-
public String getName() {
return "fo:table-and-caption";
}