diff options
Diffstat (limited to 'src/java/org/apache/fop/fo')
8 files changed, 120 insertions, 172 deletions
diff --git a/src/java/org/apache/fop/fo/FObj.java b/src/java/org/apache/fop/fo/FObj.java index 9aefe68ab..a1a25e8b7 100644 --- a/src/java/org/apache/fop/fo/FObj.java +++ b/src/java/org/apache/fop/fo/FObj.java @@ -202,6 +202,8 @@ public class FObj extends FONode implements Constants { * Convenience method to quickly obtain the length value of a property * for this FO, without querying for the propertyList first. * Meaningful only for properties having a length representation + * Note: getValue() only correct after resolution completed, therefore + * should be called only in layout manager code. * @param propId - the Constants ID of the desired property to obtain * @return the length value of the property value */ @@ -358,8 +360,8 @@ public class FObj extends FONode implements Constants { /** * Check if this formatting object generates reference areas. - * * @return true if generates reference areas + * @todo see if needed */ public boolean generatesReferenceAreas() { return false; diff --git a/src/java/org/apache/fop/fo/flow/PageNumberCitation.java b/src/java/org/apache/fop/fo/flow/PageNumberCitation.java index c8e25eeda..456b96a50 100644 --- a/src/java/org/apache/fop/fo/flow/PageNumberCitation.java +++ b/src/java/org/apache/fop/fo/flow/PageNumberCitation.java @@ -27,10 +27,8 @@ import org.xml.sax.Locator; import org.xml.sax.SAXParseException; // FOP -import org.apache.fop.datatypes.ColorType; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; -import org.apache.fop.fonts.Font; import org.apache.fop.layoutmgr.PageNumberCitationLayoutManager; /** @@ -40,16 +38,6 @@ import org.apache.fop.layoutmgr.PageNumberCitationLayoutManager; * block referenced with the ref-id attribute. */ public class PageNumberCitation extends FObj { - /** Fontstate for this object **/ - protected Font fontState; - - private float red; - private float green; - private float blue; - private int wrapOption; - private String pageNumber; - private String refId; - private boolean unresolved = false; /** * @param parent FONode that is the parent of this object @@ -59,6 +47,17 @@ public class PageNumberCitation extends FObj { } /** + * @see org.apache.fop.fo.FObj#addProperties + */ + protected void addProperties(Attributes attlist) throws SAXParseException { + super.addProperties(attlist); + + if (getPropString(PR_REF_ID) == null || getPropString(PR_REF_ID).equals("")) { + missingPropertyError("ref-id"); + } + } + + /** * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String) * XSL Content Model: empty */ @@ -68,47 +67,9 @@ public class PageNumberCitation extends FObj { } /** - * @todo switch this method to addProperties() - */ - private void setup() { - // Common Font Properties - this.fontState = propMgr.getFontState(getFOInputHandler().getFontInfo()); - - ColorType c = this.propertyList.get(PR_COLOR).getColorType(); - this.red = c.getRed(); - this.green = c.getGreen(); - this.blue = c.getBlue(); - - this.wrapOption = getPropEnum(PR_WRAP_OPTION); - this.refId = getPropString(PR_REF_ID); - - if (this.refId.equals("")) { - //throw new FOPException("page-number-citation must contain \"ref-id\""); - } - - } - - public String getRefId() { - return refId; - } - - public boolean getUnresolved() { - return unresolved; - } - - public void setUnresolved(boolean isUnresolved) { - unresolved = isUnresolved; - } - - public Font getFontState() { - return fontState; - } - - /** * @see org.apache.fop.fo.FObj#addLayoutManager(List) */ public void addLayoutManager(List list) { - setup(); PageNumberCitationLayoutManager lm = new PageNumberCitationLayoutManager(this); list.add(lm); diff --git a/src/java/org/apache/fop/fo/flow/TableCell.java b/src/java/org/apache/fop/fo/flow/TableCell.java index ed2caa557..944e943c5 100644 --- a/src/java/org/apache/fop/fo/flow/TableCell.java +++ b/src/java/org/apache/fop/fo/flow/TableCell.java @@ -23,7 +23,7 @@ import java.util.List; // XML import org.xml.sax.Attributes; -import org.xml.sax.SAXException; +import org.xml.sax.Locator; import org.xml.sax.SAXParseException; // FOP @@ -35,7 +35,7 @@ import org.apache.fop.fo.properties.CommonBorderAndPadding; /** * Class modelling the fo:table-cell object. - * @todo implement validateChildNode() + * @todo check need for all instance variables stored here */ public class TableCell extends FObj { @@ -47,6 +47,9 @@ public class TableCell extends FObj { private int numRowsSpanned; private int iColNumber = -1; // uninitialized + /** used for FO validation */ + private boolean blockItemFound = false; + /** * Offset of content rectangle in inline-progression-direction, * relative to table. @@ -121,11 +124,73 @@ public class TableCell extends FObj { */ protected void addProperties(Attributes attlist) throws SAXParseException { super.addProperties(attlist); - doSetup(); // init some basic property values + this.iColNumber = + propertyList.get(PR_COLUMN_NUMBER).getNumber().intValue(); + if (iColNumber < 0) { + iColNumber = 0; + } + this.numColumnsSpanned = + this.propertyList.get(PR_NUMBER_COLUMNS_SPANNED).getNumber().intValue(); + if (numColumnsSpanned < 1) { + numColumnsSpanned = 1; + } + this.numRowsSpanned = + this.propertyList.get(PR_NUMBER_ROWS_SPANNED).getNumber().intValue(); + if (numRowsSpanned < 1) { + numRowsSpanned = 1; + } + + this.backgroundColor = + this.propertyList.get(PR_BACKGROUND_COLOR).getColorType(); + + bSepBorders = (getPropEnum(PR_BORDER_COLLAPSE) == BorderCollapse.SEPARATE); + + calcBorders(propMgr.getBorderAndPadding()); + + // Vertical cell alignment + verticalAlign = getPropEnum(PR_DISPLAY_ALIGN); + if (verticalAlign == DisplayAlign.AUTO) { + // Depends on all cells starting in row + bRelativeAlign = true; + verticalAlign = getPropEnum(PR_RELATIVE_ALIGN); + } else { + bRelativeAlign = false; // Align on a per-cell basis + } + + this.minCellHeight = getPropLength(PR_HEIGHT); getFOInputHandler().startCell(this); } /** + * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String) + * XSL Content Model: marker* (%block;)+ + */ + protected void validateChildNode(Locator loc, String nsURI, String localName) + throws SAXParseException { + if (nsURI == FO_URI && localName.equals("marker")) { + if (blockItemFound) { + nodesOutOfOrderError(loc, "fo:marker", "(%block;)"); + } + } else if (!isBlockItem(nsURI, localName)) { + invalidChildError(loc, nsURI, localName); + } else { + blockItemFound = true; + } + } + + /** + * 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 + */ + protected void endOfNode() throws SAXParseException { + if (!blockItemFound) { + missingChildElementError("marker* (%block;)+"); + } + getFOInputHandler().endCell(this); + } + + /** * Set position relative to table (set by body?) */ public void setStartOffset(int offset) { @@ -164,47 +229,6 @@ public class TableCell extends FObj { } /** - * @todo convert to addProperties() - */ - private void doSetup() { - - this.iColNumber = - propertyList.get(PR_COLUMN_NUMBER).getNumber().intValue(); - if (iColNumber < 0) { - iColNumber = 0; - } - this.numColumnsSpanned = - this.propertyList.get(PR_NUMBER_COLUMNS_SPANNED).getNumber().intValue(); - if (numColumnsSpanned < 1) { - numColumnsSpanned = 1; - } - this.numRowsSpanned = - this.propertyList.get(PR_NUMBER_ROWS_SPANNED).getNumber().intValue(); - if (numRowsSpanned < 1) { - numRowsSpanned = 1; - } - - this.backgroundColor = - this.propertyList.get(PR_BACKGROUND_COLOR).getColorType(); - - bSepBorders = (getPropEnum(PR_BORDER_COLLAPSE) == BorderCollapse.SEPARATE); - - calcBorders(propMgr.getBorderAndPadding()); - - // Vertical cell alignment - verticalAlign = getPropEnum(PR_DISPLAY_ALIGN); - if (verticalAlign == DisplayAlign.AUTO) { - // Depends on all cells starting in row - bRelativeAlign = true; - verticalAlign = getPropEnum(PR_RELATIVE_ALIGN); - } else { - bRelativeAlign = false; // Align on a per-cell basis - } - - this.minCellHeight = getPropLength(PR_HEIGHT); - } - - /** * Calculate cell border and padding, including offset of content * rectangle from the theoretical grid position. */ @@ -307,11 +331,10 @@ public class TableCell extends FObj { Cell clm = new Cell(this); list.add(clm); } - - protected void endOfNode() throws SAXParseException { - getFOInputHandler().endCell(this); - } + /** + * @see org.apache.fop.fo.FObj#getName() + */ public String getName() { return "fo:table-cell"; } diff --git a/src/java/org/apache/fop/fo/pagination/Flow.java b/src/java/org/apache/fop/fo/pagination/Flow.java index c756749ca..723911c42 100644 --- a/src/java/org/apache/fop/fo/pagination/Flow.java +++ b/src/java/org/apache/fop/fo/pagination/Flow.java @@ -48,9 +48,10 @@ public class Flow extends FObj { private ArrayList markerSnapshot; /** - * flow-name attribute + * flow-name attribute: indicates the region the content of this + * flow should go to. */ - private String flowName; + protected String flowName; /** * Content-width of current column area during layout @@ -68,6 +69,25 @@ public class Flow extends FObj { } /** + * @see org.apache.fop.fo.FObj#addProperties + */ + protected void addProperties(Attributes attlist) throws SAXParseException { + super.addProperties(attlist); + + this.pageSequence = (PageSequence) parent; + + flowName = getPropString(PR_FLOW_NAME); + + if (flowName == null || flowName.equals("")) { + missingPropertyError("flow-name"); + } + + // Now done in addChild of page-sequence + //pageSequence.addFlow(this); + getFOInputHandler().startFlow(this); + } + + /** * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String) * XSL Content Model: marker* (%block;)+ */ @@ -97,64 +117,12 @@ public class Flow extends FObj { } /** - * @see org.apache.fop.fo.FObj#addProperties - */ - protected void addProperties(Attributes attlist) throws SAXParseException { - super.addProperties(attlist); - if (parent.getName().equals("fo:page-sequence")) { - this.pageSequence = (PageSequence) parent; - } else { - throw new SAXParseException("flow must be child of " - + "page-sequence, not " + parent.getName(), locator); - } - // according to communication from Paul Grosso (XSL-List, - // 001228, Number 406), confusion in spec section 6.4.5 about - // multiplicity of fo:flow in XSL 1.0 is cleared up - one (1) - // fo:flow per fo:page-sequence only. - - /* if (pageSequence.isFlowSet()) { - if (this.name.equals("fo:flow")) { - throw new FOPException("Only a single fo:flow permitted" - + " per fo:page-sequence"); - } else { - throw new FOPException(this.name - + " not allowed after fo:flow"); - } - } - */ - setFlowName(getProperty(PR_FLOW_NAME).getString()); - // Now done in addChild of page-sequence - //pageSequence.addFlow(this); - - getFOInputHandler().startFlow(this); - } - - /** - * @param name the name of the flow to set - * @throws FOPException for an empty name - */ - protected void setFlowName(String name) throws SAXParseException { - if (name == null || name.equals("")) { - throw new SAXParseException("A 'flow-name' is required for " - + getName(), locator); - } else { - flowName = name; - } - } - - /** - * @return the name of this flow - */ - public String getFlowName() { - return flowName; - } - - /** * @param contentWidth content width of this flow, in millipoints (??) */ protected void setContentWidth(int contentWidth) { this.contentWidth = contentWidth; } + /** * @return the content width of this flow (really of the region * in which it is flowing), in millipoints (??). @@ -178,6 +146,9 @@ public class Flow extends FObj { list.add(lm); } + /** + * @see org.apache.fop.fo.FObj#getName() + */ public String getName() { return "fo:flow"; } diff --git a/src/java/org/apache/fop/fo/pagination/PageSequence.java b/src/java/org/apache/fop/fo/pagination/PageSequence.java index 57eff5ccd..7a025097f 100644 --- a/src/java/org/apache/fop/fo/pagination/PageSequence.java +++ b/src/java/org/apache/fop/fo/pagination/PageSequence.java @@ -189,7 +189,7 @@ public class PageSequence extends FObj { this.titleFO = (Title)child; } else if (childName.equals("fo:flow")) { this.mainFlow = (Flow)child; - String flowName = this.mainFlow.getFlowName(); + String flowName = this.mainFlow.getPropString(PR_FLOW_NAME); if (flowMap.containsKey(flowName)) { throw new FOPException("flow-name " + flowName @@ -205,7 +205,7 @@ public class PageSequence extends FObj { startStructuredPageSequence(); super.addChildNode(child); // For getChildren } else if (childName.equals("fo:static-content")) { - String flowName = ((StaticContent)child).getFlowName(); + String flowName = ((StaticContent)child).getPropString(PR_FLOW_NAME); if (flowMap.containsKey(flowName)) { throw new FOPException("flow-name " + flowName + " is not unique within an fo:page-sequence"); diff --git a/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java b/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java index 173e0be84..631187e4f 100644 --- a/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java +++ b/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java @@ -193,6 +193,9 @@ public class PageSequenceMaster extends FObj { return pageMaster; } + /** + * @see org.apache.fop.fo.FObj#getName() + */ public String getName() { return "fo:page-sequence-master"; } diff --git a/src/java/org/apache/fop/fo/pagination/Root.java b/src/java/org/apache/fop/fo/pagination/Root.java index 0f8189092..a879f9469 100644 --- a/src/java/org/apache/fop/fo/pagination/Root.java +++ b/src/java/org/apache/fop/fo/pagination/Root.java @@ -222,6 +222,9 @@ public class Root extends FObj { return foInputHandler; } + /** + * @see org.apache.fop.fo.FObj#getName() + */ public String getName() { return "fo:root"; } diff --git a/src/java/org/apache/fop/fo/pagination/StaticContent.java b/src/java/org/apache/fop/fo/pagination/StaticContent.java index 81b8e67af..6e9441afb 100644 --- a/src/java/org/apache/fop/fo/pagination/StaticContent.java +++ b/src/java/org/apache/fop/fo/pagination/StaticContent.java @@ -38,9 +38,6 @@ public class StaticContent extends Flow { super(parent); } - private void setup() { - } - /** * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String) * XSL Content Model: (%block;)+ @@ -65,20 +62,8 @@ public class StaticContent extends Flow { } /** - * flowname checking is more stringient for static content currently - * @param name the flow-name to set - * @throws SAXParseException for a missing flow name + * @see org.apache.fop.fo.FObj#getName() */ - protected void setFlowName(String name) throws SAXParseException { - if (name == null || name.equals("")) { - throw new SAXParseException("A 'flow-name' is required for " - + getName() + ".", locator); - } else { - super.setFlowName(name); - } - - } - public String getName() { return "fo:static-content"; } |