From 4f9065f69ba1791e40bb57e6d2d1acaa81a7042c Mon Sep 17 00:00:00 2001 From: Glen Mazza Date: Mon, 16 Aug 2004 04:11:42 +0000 Subject: 1. fo:leader layout initialization logic moved from AddLMVisitor to fo.flow.Leader. 2. fo:leader layout logic moved from AddLMVisitor to new layoutmgr.LayoutLeaderManager class. 3. validateChildNode() for fo:list-block implemented. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197876 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/fop/fo/flow/ExternalGraphic.java | 2 +- src/java/org/apache/fop/fo/flow/Float.java | 2 +- src/java/org/apache/fop/fo/flow/Footnote.java | 2 +- src/java/org/apache/fop/fo/flow/FootnoteBody.java | 2 +- .../apache/fop/fo/flow/InstreamForeignObject.java | 2 +- src/java/org/apache/fop/fo/flow/Leader.java | 39 +++++++++++-------- src/java/org/apache/fop/fo/flow/ListBlock.java | 44 ++++++++++++++++------ src/java/org/apache/fop/fo/pagination/Flow.java | 2 +- .../apache/fop/fo/pagination/StaticContent.java | 2 +- 9 files changed, 63 insertions(+), 34 deletions(-) (limited to 'src/java/org/apache/fop/fo') diff --git a/src/java/org/apache/fop/fo/flow/ExternalGraphic.java b/src/java/org/apache/fop/fo/flow/ExternalGraphic.java index 581ab9fc2..99bb8bedb 100644 --- a/src/java/org/apache/fop/fo/flow/ExternalGraphic.java +++ b/src/java/org/apache/fop/fo/flow/ExternalGraphic.java @@ -72,7 +72,7 @@ public class ExternalGraphic extends FObj { /** * @see org.apache.fop.fo.FObj#addLayoutManager(List) - */ + */ public void addLayoutManager(List list) { if (getURL() != null) { ExternalGraphicLayoutManager lm = new ExternalGraphicLayoutManager(this); diff --git a/src/java/org/apache/fop/fo/flow/Float.java b/src/java/org/apache/fop/fo/flow/Float.java index 31c4b93cc..56acb0ce9 100644 --- a/src/java/org/apache/fop/fo/flow/Float.java +++ b/src/java/org/apache/fop/fo/flow/Float.java @@ -52,7 +52,7 @@ public class Float extends ToBeImplementedElement { /** * Make sure content model satisfied, if so then tell the - * StructureRenderer that we are at the end of the flow. + * FOInputHandler that we are at the end of the flow. * @see org.apache.fop.fo.FONode#end */ protected void endOfNode() throws SAXParseException { diff --git a/src/java/org/apache/fop/fo/flow/Footnote.java b/src/java/org/apache/fop/fo/flow/Footnote.java index 024c49ff1..252f31d93 100644 --- a/src/java/org/apache/fop/fo/flow/Footnote.java +++ b/src/java/org/apache/fop/fo/flow/Footnote.java @@ -82,7 +82,7 @@ public class Footnote extends FObj { /** * Make sure content model satisfied, if so then tell the - * StructureRenderer that we are at the end of the flow. + * FOInputHandler that we are at the end of the flow. * @see org.apache.fop.fo.FONode#end */ protected void endOfNode() throws SAXParseException { diff --git a/src/java/org/apache/fop/fo/flow/FootnoteBody.java b/src/java/org/apache/fop/fo/flow/FootnoteBody.java index a7f86b6f5..d8734f4d4 100644 --- a/src/java/org/apache/fop/fo/flow/FootnoteBody.java +++ b/src/java/org/apache/fop/fo/flow/FootnoteBody.java @@ -60,7 +60,7 @@ public class FootnoteBody extends FObj { /** * Make sure content model satisfied, if so then tell the - * StructureRenderer that we are at the end of the flow. + * FOInputHandler that we are at the end of the flow. * @see org.apache.fop.fo.FONode#end */ protected void endOfNode() throws SAXParseException { diff --git a/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java b/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java index 5c7264aa4..8bd5a5f49 100644 --- a/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java +++ b/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java @@ -66,7 +66,7 @@ public class InstreamForeignObject extends FObj { /** * Make sure content model satisfied, if so then tell the - * StructureRenderer that we are at the end of the flow. + * FOInputHandler that we are at the end of the flow. * @see org.apache.fop.fo.FONode#end */ protected void endOfNode() throws SAXParseException { diff --git a/src/java/org/apache/fop/fo/flow/Leader.java b/src/java/org/apache/fop/fo/flow/Leader.java index 77c8e4c3f..1aa240c6b 100644 --- a/src/java/org/apache/fop/fo/flow/Leader.java +++ b/src/java/org/apache/fop/fo/flow/Leader.java @@ -18,21 +18,24 @@ package org.apache.fop.fo.flow; +// Java +import java.util.List; + +// FOP import org.apache.fop.datatypes.ColorType; import org.apache.fop.datatypes.Length; import org.apache.fop.fo.FONode; -import org.apache.fop.layoutmgr.AddLMVisitor; import org.apache.fop.fo.FObjMixed; import org.apache.fop.fo.properties.PercentLength; import org.apache.fop.fonts.Font; -import org.apache.fop.fo.LMVisited; +import org.apache.fop.layoutmgr.LeaderLayoutManager; /** - * Class modelling fo:leader object. See Sec. 6.6.9 of the XSL-FO Standard. + * Class modelling fo:leader object. * The main property of fo:leader is leader-pattern. * The following patterns are treated: rule, space, dots and use-content. */ -public class Leader extends FObjMixed implements LMVisited { +public class Leader extends FObjMixed { private int ruleStyle; private int ruleThickness; @@ -89,12 +92,14 @@ public class Leader extends FObjMixed implements LMVisited { } + /** + * @todo check need for each of these accessors (should be LM instead?) + */ public int getLength(int propId, int dim) { int length; Length maxlength = propertyList.get(propId).getLength(); if (maxlength instanceof PercentLength) { - length = (int)(((PercentLength)maxlength).value() - * dim); + length = (int)(((PercentLength)maxlength).value() * dim); } else { length = maxlength.getValue(); } @@ -121,20 +126,22 @@ public class Leader extends FObjMixed implements LMVisited { return patternWidth; } - public String getName() { - return "fo:leader"; - } - /** - * 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) { + public void addLayoutManager(List list) { setup(); - aLMV.serveLeader(this); + LeaderLayoutManager lm = new LeaderLayoutManager(this); + list.add(lm); } - + + /** + * @see org.apache.fop.fo.FObj#getName() + */ + public String getName() { + return "fo:leader"; + } + /** * @see org.apache.fop.fo.FObj#getNameId() */ diff --git a/src/java/org/apache/fop/fo/flow/ListBlock.java b/src/java/org/apache/fop/fo/flow/ListBlock.java index e16d39ce7..86d6b70e8 100644 --- a/src/java/org/apache/fop/fo/flow/ListBlock.java +++ b/src/java/org/apache/fop/fo/flow/ListBlock.java @@ -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 @@ -30,12 +31,6 @@ import org.apache.fop.datatypes.ColorType; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; import org.apache.fop.layoutmgr.list.ListBlockLayoutManager; -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.CommonMarginBlock; -import org.apache.fop.fo.properties.CommonRelativePosition; /** * Class modelling the fo:list-block object. See Sec. 6.8.2 of the XSL-FO @@ -54,6 +49,9 @@ public class ListBlock extends FObj { private int spaceAfter; private int spaceBetweenListRows = 0; private ColorType backgroundColor; + + // used for child node validation + private boolean hasListItem = false; /** * @param parent FONode that is the parent of this object @@ -86,6 +84,35 @@ public class ListBlock extends FObj { getFOInputHandler().startList(this); } + /** + * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String) + * XSL Content Model: marker* (list-item)+ + */ + protected void validateChildNode(Locator loc, String nsURI, String localName) + throws SAXParseException { + if (nsURI == FO_URI && localName.equals("marker")) { + if (hasListItem) { + nodesOutOfOrderError(loc, "fo:marker", "fo:list-item"); + } + } else if (nsURI == FO_URI && localName.equals("list-item")) { + hasListItem = true; + } else { + invalidChildError(loc, nsURI, localName); + } + } + + /** + * 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 (!hasListItem) { + missingChildElementError("marker* (list-item)+"); + } + getFOInputHandler().endList(this); + } + /** * @return false (ListBlock does not generate inline areas) */ @@ -101,11 +128,6 @@ public class ListBlock extends FObj { list.add(lm); } - protected void endOfNode() throws SAXParseException { - super.endOfNode(); - getFOInputHandler().endList(this); - } - public String getName() { return "fo:list-block"; } diff --git a/src/java/org/apache/fop/fo/pagination/Flow.java b/src/java/org/apache/fop/fo/pagination/Flow.java index b659d1e5b..37233ca14 100644 --- a/src/java/org/apache/fop/fo/pagination/Flow.java +++ b/src/java/org/apache/fop/fo/pagination/Flow.java @@ -86,7 +86,7 @@ public class Flow extends FObj { /** * Make sure content model satisfied, if so then tell the - * StructureRenderer that we are at the end of the flow. + * FOInputHandler that we are at the end of the flow. * @see org.apache.fop.fo.FONode#end */ protected void endOfNode() throws SAXParseException { diff --git a/src/java/org/apache/fop/fo/pagination/StaticContent.java b/src/java/org/apache/fop/fo/pagination/StaticContent.java index 3a1b96820..405e8d014 100644 --- a/src/java/org/apache/fop/fo/pagination/StaticContent.java +++ b/src/java/org/apache/fop/fo/pagination/StaticContent.java @@ -55,7 +55,7 @@ public class StaticContent extends Flow { /** * Make sure content model satisfied, if so then tell the - * StructureRenderer that we are at the end of the flow. + * FOInputHandler that we are at the end of the flow. * @see org.apache.fop.fo.FONode#end */ protected void endOfNode() throws SAXParseException { -- cgit v1.2.3