From 9729fe17d699d1d3816054dfb722369aba187d54 Mon Sep 17 00:00:00 2001 From: Glen Mazza Date: Fri, 20 Aug 2004 09:38:21 +0000 Subject: [PATCH] 1.) validateChildNode() added for fo:marker. 2.) new getPropString() convenience method added to FObj, will reduce need for many individual methods on each FO. 3.) fo:float disconnected from ToBeImplementedElement in favor of a class-specific warning. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197883 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/fop/area/AreaTreeHandler.java | 2 +- src/java/org/apache/fop/fo/FObj.java | 15 ++++++- src/java/org/apache/fop/fo/flow/Float.java | 11 ++++- src/java/org/apache/fop/fo/flow/Marker.java | 27 ++++++------ src/java/org/apache/fop/fo/flow/Table.java | 4 +- .../org/apache/fop/fo/flow/TableColumn.java | 42 +++++++------------ 6 files changed, 57 insertions(+), 44 deletions(-) diff --git a/src/java/org/apache/fop/area/AreaTreeHandler.java b/src/java/org/apache/fop/area/AreaTreeHandler.java index 38566fa96..02e9bd0c0 100644 --- a/src/java/org/apache/fop/area/AreaTreeHandler.java +++ b/src/java/org/apache/fop/area/AreaTreeHandler.java @@ -436,7 +436,7 @@ public class AreaTreeHandler extends FOInputHandler { // to the Title. InlineStackingLayoutManager lm; lm = new InlineStackingLayoutManager(foTitle); - lm.setLMiter(new LMiter(lm, foTitle.childNodes.listIterator())); + lm.setLMiter(new LMiter(lm, foTitle.getChildNodes())); lm.initialize(); // get breaks then add areas to title diff --git a/src/java/org/apache/fop/fo/FObj.java b/src/java/org/apache/fop/fo/FObj.java index cbff2af55..27e91c126 100644 --- a/src/java/org/apache/fop/fo/FObj.java +++ b/src/java/org/apache/fop/fo/FObj.java @@ -180,13 +180,24 @@ public class FObj extends FONode implements Constants { /** * Helper method to quickly obtain the value of a property * for this FO, without querying for the propertyList first. - * @param name - the name of the desired property to obtain + * @param propId - the Constants ID of the desired property to obtain * @return the property */ public Property getProperty(int propId) { return propertyList.get(propId); } + /** + * Helper method to quickly obtain the String value of a property + * for this FO, without querying for the propertyList first. + * Meaningful only for properties having a string representation + * @param propId - the Constants ID of the desired property to obtain + * @return the String value of the property value + */ + public String getPropString(int propId) { + return propertyList.get(propId).getString(); + } + /** * @see org.apache.fop.fo.FONode#addChildNode(FONode) */ @@ -378,7 +389,7 @@ public class FObj extends FONode implements Constants { * @param marker Marker to add. */ protected void addMarker(Marker marker) { - String mcname = marker.getMarkerClassName(); + String mcname = marker.getPropString(PR_MARKER_CLASS_NAME); if (childNodes != null) { // check for empty childNodes for (Iterator iter = childNodes.iterator(); iter.hasNext();) { diff --git a/src/java/org/apache/fop/fo/flow/Float.java b/src/java/org/apache/fop/fo/flow/Float.java index 56acb0ce9..3a9c61806 100644 --- a/src/java/org/apache/fop/fo/flow/Float.java +++ b/src/java/org/apache/fop/fo/flow/Float.java @@ -25,18 +25,25 @@ import org.xml.sax.SAXParseException; // FOP import org.apache.fop.fo.FONode; -import org.apache.fop.fo.ToBeImplementedElement; +import org.apache.fop.fo.FObj; /** * fo:float element. */ -public class Float extends ToBeImplementedElement { +public class Float extends FObj { + static boolean notImplementedWarningGiven = false; + /** * @see org.apache.fop.fo.FONode#FONode(FONode) */ public Float(FONode parent) { super(parent); + + if (!notImplementedWarningGiven) { + getLogger().warn("fo:float is not yet implemented."); + notImplementedWarningGiven = true; + } } /** diff --git a/src/java/org/apache/fop/fo/flow/Marker.java b/src/java/org/apache/fop/fo/flow/Marker.java index 61fe5e04c..347b480af 100644 --- a/src/java/org/apache/fop/fo/flow/Marker.java +++ b/src/java/org/apache/fop/fo/flow/Marker.java @@ -20,6 +20,7 @@ package org.apache.fop.fo.flow; // XML import org.xml.sax.Attributes; +import org.xml.sax.Locator; import org.xml.sax.SAXParseException; // FOP @@ -28,16 +29,11 @@ import org.apache.fop.fo.FObjMixed; /** * Marker formatting object. - * This is the marker formatting object that handles merkers. - * This attempts to add itself to the parent formatting object. */ public class Marker extends FObjMixed { - private String markerClassName; - /** * Create a marker fo. - * * @param parent the parent fo node */ public Marker(FONode parent) { @@ -49,19 +45,26 @@ public class Marker extends FObjMixed { */ protected void addProperties(Attributes attlist) throws SAXParseException { super.addProperties(attlist); - this.markerClassName = - this.propertyList.get(PR_MARKER_CLASS_NAME).getString(); } /** - * Get the marker class name for this marker. - * - * @return the marker class name + * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String) + * XSL Content Model: (#PCDATA|%inline;|%block;)* + * Additionally: "An fo:marker may contain any formatting objects that + * are permitted as a replacement of any fo:retrieve-marker that retrieves + * the fo:marker's children." + * @todo implement "additional" constraint, possibly within fo:retrieve-marker */ - public String getMarkerClassName() { - return markerClassName; + protected void validateChildNode(Locator loc, String nsURI, String localName) + throws SAXParseException { + if (!isBlockOrInlineItem(nsURI, localName)) { + invalidChildError(loc, nsURI, localName); + } } + /** + * @see org.apache.fop.fo.FObj#getName() + */ public String getName() { return "fo:marker"; } diff --git a/src/java/org/apache/fop/fo/flow/Table.java b/src/java/org/apache/fop/fo/flow/Table.java index 57e380fb9..8146045a1 100644 --- a/src/java/org/apache/fop/fo/flow/Table.java +++ b/src/java/org/apache/fop/fo/flow/Table.java @@ -168,7 +168,6 @@ public class Table extends FObj { } public Column getTableColumnLayoutManager(TableColumn node) { - node.initialize(); Column clm = new Column(node); return clm; } @@ -178,6 +177,9 @@ public class Table extends FObj { return blm; } + /** + * @see org.apache.fop.fo.FObj#getName() + */ public String getName() { return "fo:table"; } diff --git a/src/java/org/apache/fop/fo/flow/TableColumn.java b/src/java/org/apache/fop/fo/flow/TableColumn.java index 31cc896c7..7cf6e813c 100644 --- a/src/java/org/apache/fop/fo/flow/TableColumn.java +++ b/src/java/org/apache/fop/fo/flow/TableColumn.java @@ -36,14 +36,11 @@ import org.apache.fop.fo.FObj; public class TableColumn extends FObj { private ColorType backgroundColor; - private Length columnWidth; private int columnOffset; private int numColumnsRepeated; private int iColumnNumber; - private boolean initialized = false; - /** * @param parent FONode that is the parent of this object */ @@ -61,14 +58,28 @@ public class TableColumn extends FObj { } /** - * @see org.apache.fop.fo.FObj#addProperties + * @see org.apache.fop.fo.FObj#addProperties(Attributes) */ protected void addProperties(Attributes attlist) throws SAXParseException { super.addProperties(attlist); - initialize(); // init some basic property values + + iColumnNumber = propertyList.get(PR_COLUMN_NUMBER).getNumber().intValue(); + numColumnsRepeated = + propertyList.get(PR_NUMBER_COLUMNS_REPEATED).getNumber().intValue(); + this.backgroundColor = + this.propertyList.get(PR_BACKGROUND_COLOR).getColorType(); + columnWidth = this.propertyList.get(PR_COLUMN_WIDTH).getLength(); + getFOInputHandler().startColumn(this); } + /** + * @see org.apache.fop.fo.FONode#endOfNode + */ + protected void endOfNode() throws SAXParseException { + getFOInputHandler().endColumn(this); + } + /** * @return Length object containing column width */ @@ -90,27 +101,6 @@ public class TableColumn extends FObj { return numColumnsRepeated; } - /** - * @todo convert to addProperties() - */ - public void initialize() { - iColumnNumber = propertyList.get(PR_COLUMN_NUMBER).getNumber().intValue(); - - numColumnsRepeated = - propertyList.get(PR_NUMBER_COLUMNS_REPEATED).getNumber().intValue(); - - this.backgroundColor = - this.propertyList.get(PR_BACKGROUND_COLOR).getColorType(); - - columnWidth = this.propertyList.get(PR_COLUMN_WIDTH).getLength(); - - initialized = true; - } - - protected void endOfNode() throws SAXParseException { - getFOInputHandler().endColumn(this); - } - public String getName() { return "fo:table-column"; } -- 2.39.5