gmazza 2004/08/15 21:11:42 Modified: . fop.bat src/java/org/apache/fop/fo/flow ExternalGraphic.java Float.java Footnote.java FootnoteBody.java InstreamForeignObject.java Leader.java ListBlock.java src/java/org/apache/fop/fo/pagination Flow.java StaticContent.java src/java/org/apache/fop/layoutmgr AddLMVisitor.java PageNumberCitationLayoutManager.java Added: src/java/org/apache/fop/layoutmgr LeaderLayoutManager.java Log: 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. Revision Changes Path 1.20 +1 -1 xml-fop/fop.bat Index: fop.bat =================================================================== RCS file: /home/cvs/xml-fop/fop.bat,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- fop.bat 18 Apr 2004 22:39:02 -0000 1.19 +++ fop.bat 16 Aug 2004 04:11:41 -0000 1.20 @@ -43,7 +43,7 @@ set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\xalan-2.4.1.jar set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\batik.jar set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\avalon-framework-4.1.4.jar -set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\commons-io-dev-20040206.jar +set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\commons-io-1.0.jar set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\commons-logging-1.0.3.jar set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\jimi-1.0.jar set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\jai_core.jar 1.38 +1 -1 xml-fop/src/java/org/apache/fop/fo/flow/ExternalGraphic.java Index: ExternalGraphic.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/ExternalGraphic.java,v retrieving revision 1.37 retrieving revision 1.38 diff -u -r1.37 -r1.38 --- ExternalGraphic.java 13 Aug 2004 00:03:49 -0000 1.37 +++ ExternalGraphic.java 16 Aug 2004 04:11:41 -0000 1.38 @@ -72,7 +72,7 @@ /** * @see org.apache.fop.fo.FObj#addLayoutManager(List) - */ + */ public void addLayoutManager(List list) { if (getURL() != null) { ExternalGraphicLayoutManager lm = new ExternalGraphicLayoutManager(this); 1.13 +1 -1 xml-fop/src/java/org/apache/fop/fo/flow/Float.java Index: Float.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/Float.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- Float.java 11 Aug 2004 22:56:48 -0000 1.12 +++ Float.java 16 Aug 2004 04:11:41 -0000 1.13 @@ -52,7 +52,7 @@ /** * 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 { 1.22 +1 -1 xml-fop/src/java/org/apache/fop/fo/flow/Footnote.java Index: Footnote.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/Footnote.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- Footnote.java 13 Aug 2004 00:03:49 -0000 1.21 +++ Footnote.java 16 Aug 2004 04:11:41 -0000 1.22 @@ -82,7 +82,7 @@ /** * 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 { 1.19 +1 -1 xml-fop/src/java/org/apache/fop/fo/flow/FootnoteBody.java Index: FootnoteBody.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/FootnoteBody.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- FootnoteBody.java 13 Aug 2004 12:29:51 -0000 1.18 +++ FootnoteBody.java 16 Aug 2004 04:11:41 -0000 1.19 @@ -60,7 +60,7 @@ /** * 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 { 1.21 +1 -1 xml-fop/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java Index: InstreamForeignObject.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- InstreamForeignObject.java 14 Aug 2004 18:36:21 -0000 1.20 +++ InstreamForeignObject.java 16 Aug 2004 04:11:41 -0000 1.21 @@ -66,7 +66,7 @@ /** * 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 { 1.33 +23 -16 xml-fop/src/java/org/apache/fop/fo/flow/Leader.java Index: Leader.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/Leader.java,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- Leader.java 11 Aug 2004 04:15:25 -0000 1.32 +++ Leader.java 16 Aug 2004 04:11:41 -0000 1.33 @@ -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 @@ } + /** + * @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 @@ 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() */ 1.24 +33 -11 xml-fop/src/java/org/apache/fop/fo/flow/ListBlock.java Index: ListBlock.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/ListBlock.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- ListBlock.java 11 Aug 2004 04:15:25 -0000 1.23 +++ ListBlock.java 16 Aug 2004 04:11:41 -0000 1.24 @@ -23,6 +23,7 @@ // 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.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 @@ 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 @@ -87,6 +85,35 @@ } /** + * @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) */ public boolean generatesInlineAreas() { @@ -99,11 +126,6 @@ public void addLayoutManager(List list) { ListBlockLayoutManager lm = new ListBlockLayoutManager(this); list.add(lm); - } - - protected void endOfNode() throws SAXParseException { - super.endOfNode(); - getFOInputHandler().endList(this); } public String getName() { 1.27 +2 -2 xml-fop/src/java/org/apache/fop/fo/pagination/Flow.java Index: Flow.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/pagination/Flow.java,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- Flow.java 8 Aug 2004 18:39:25 -0000 1.26 +++ Flow.java 16 Aug 2004 04:11:42 -0000 1.27 @@ -86,7 +86,7 @@ /** * 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 { 1.21 +2 -2 xml-fop/src/java/org/apache/fop/fo/pagination/StaticContent.java Index: StaticContent.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/pagination/StaticContent.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- StaticContent.java 8 Aug 2004 18:39:26 -0000 1.20 +++ StaticContent.java 16 Aug 2004 04:11:42 -0000 1.21 @@ -55,7 +55,7 @@ /** * 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 { 1.57 +1 -111 xml-fop/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java Index: AddLMVisitor.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java,v retrieving revision 1.56 retrieving revision 1.57 diff -u -r1.56 -r1.57 --- AddLMVisitor.java 14 Aug 2004 18:36:21 -0000 1.56 +++ AddLMVisitor.java 16 Aug 2004 04:11:42 -0000 1.57 @@ -21,18 +21,8 @@ import java.util.List; import java.util.ListIterator; -import org.apache.fop.area.Trait; -import org.apache.fop.area.inline.FilledArea; -import org.apache.fop.area.inline.InlineArea; -import org.apache.fop.area.inline.Space; -import org.apache.fop.area.inline.TextArea; -import org.apache.fop.datatypes.Length; -import org.apache.fop.fo.Constants; import org.apache.fop.fo.FObj; -import org.apache.fop.fo.flow.Inline; -import org.apache.fop.fo.flow.Leader; import org.apache.fop.fo.flow.Wrapper; -import org.apache.fop.traits.MinOptMax; import org.apache.fop.fo.LMVisited; /** @@ -100,104 +90,4 @@ } } } - - public void serveLeader(final Leader node) { - LeafNodeLayoutManager lm = new LeafNodeLayoutManager(node) { - public InlineArea get(LayoutContext context) { - return getLeaderInlineArea(node, this); - } - - protected MinOptMax getAllocationIPD(int refIPD) { - return getLeaderAllocIPD(node, refIPD); - } - - /*protected void offsetArea(LayoutContext context) { - if(leaderPattern == LeaderPattern.DOTS) { - curArea.setOffset(context.getBaseline()); - } - }*/ - }; - lm.setAlignment(node.getProperty(Constants.PR_LEADER_ALIGNMENT).getEnum()); - currentLMList.add(lm); - } - - public MinOptMax getLeaderAllocIPD(Leader node, int ipd) { - // length of the leader - int opt = node.getLength(Constants.PR_LEADER_LENGTH | Constants.CP_OPTIMUM, ipd); - int min = node.getLength(Constants.PR_LEADER_LENGTH | Constants.CP_MINIMUM, ipd); - int max = node.getLength(Constants.PR_LEADER_LENGTH | Constants.CP_MAXIMUM, ipd); - - return new MinOptMax(min, opt, max); - } - - private InlineArea getLeaderInlineArea(Leader node, LayoutManager parentLM) { - InlineArea leaderArea = null; - - if (node.getLeaderPattern() == Constants.LeaderPattern.RULE) { - org.apache.fop.area.inline.Leader leader = new org.apache.fop.area.inline.Leader(); - leader.setRuleStyle(node.getRuleStyle()); - leader.setRuleThickness(node.getRuleThickness()); - leaderArea = leader; - } else if (node.getLeaderPattern() == Constants.LeaderPattern.SPACE) { - leaderArea = new Space(); - } else if (node.getLeaderPattern() == Constants.LeaderPattern.DOTS) { - TextArea t = new TextArea(); - char dot = '.'; // userAgent.getLeaderDotCharacter(); - - t.setTextArea("" + dot); - t.addTrait(Trait.FONT_NAME, node.getFontState().getFontName()); - t.addTrait(Trait.FONT_SIZE, - new Integer(node.getFontState().getFontSize())); - // set offset of dot within inline parent - t.setOffset(node.getFontState().getAscender()); - int width = node.getFontState().getCharWidth(dot); - Space spacer = null; - if (node.getPatternWidth() > width) { - spacer = new Space(); - spacer.setWidth(node.getPatternWidth() - width); - width = node.getPatternWidth(); - } - FilledArea fa = new FilledArea(); - fa.setUnitWidth(width); - fa.addChild(t); - if (spacer != null) { - fa.addChild(spacer); - } - fa.setHeight(node.getFontState().getAscender()); - - leaderArea = fa; - } else if (node.getLeaderPattern() == Constants.LeaderPattern.USECONTENT) { - if (node.getChildNodes() == null) { - node.getLogger().error("Leader use-content with no content"); - return null; - } - InlineStackingLayoutManager lm; - lm = new InlineStackingLayoutManager(node); - lm.setLMiter(new LMiter(lm, node.getChildNodes())); - lm.initialize(); - - // get breaks then add areas to FilledArea - FilledArea fa = new FilledArea(); - - ContentLayoutManager clm = new ContentLayoutManager(fa); - clm.setParent(parentLM); - clm.setUserAgent(node.getUserAgent()); - lm.setParent(clm); - - clm.fillArea(lm); - int width = clm.getStackingSize(); - Space spacer = null; - if (node.getPatternWidth() > width) { - spacer = new Space(); - spacer.setWidth(node.getPatternWidth() - width); - width = node.getPatternWidth(); - } - fa.setUnitWidth(width); - if (spacer != null) { - fa.addChild(spacer); - } - leaderArea = fa; - } - return leaderArea; - } } 1.3 +3 -3 xml-fop/src/java/org/apache/fop/layoutmgr/PageNumberCitationLayoutManager.java Index: PageNumberCitationLayoutManager.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/PageNumberCitationLayoutManager.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- PageNumberCitationLayoutManager.java 11 Aug 2004 22:56:48 -0000 1.2 +++ PageNumberCitationLayoutManager.java 16 Aug 2004 04:11:42 -0000 1.3 @@ -28,7 +28,7 @@ import org.apache.fop.fonts.Font; /** - * LayoutManager for the fo:basic-link formatting object + * LayoutManager for the fo:page-number-citation formatting object */ public class PageNumberCitationLayoutManager extends LeafNodeLayoutManager { @@ -39,7 +39,7 @@ * Constructor * * @param node the formatting object that creates this area - * @todo better null checking font + * @todo better null checking of font object */ public PageNumberCitationLayoutManager(PageNumberCitation node) { super(node); 1.1 xml-fop/src/java/org/apache/fop/layoutmgr/LeaderLayoutManager.java Index: LeaderLayoutManager.java =================================================================== /* * Copyright 1999-2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* $Id: LeaderLayoutManager.java,v 1.1 2004/08/16 04:11:42 gmazza Exp $ */ package org.apache.fop.layoutmgr; import org.apache.fop.area.Trait; import org.apache.fop.area.inline.FilledArea; import org.apache.fop.area.inline.InlineArea; import org.apache.fop.area.inline.Space; import org.apache.fop.area.inline.TextArea; import org.apache.fop.datatypes.Length; import org.apache.fop.fo.Constants; import org.apache.fop.fo.flow.Inline; import org.apache.fop.fo.flow.Leader; import org.apache.fop.fonts.Font; import org.apache.fop.traits.MinOptMax; /** * LayoutManager for the fo:leader formatting object */ public class LeaderLayoutManager extends LeafNodeLayoutManager { Leader ldrNode; Font font = null; /** * Constructor * * @param node the formatting object that creates this area * @todo better null checking of font object */ public LeaderLayoutManager(Leader node) { super(node); ldrNode = node; font = node.getFontState(); setAlignment(node.getProperty(PR_LEADER_ALIGNMENT).getEnum()); } public InlineArea get(LayoutContext context) { return getLeaderInlineArea(); } protected MinOptMax getAllocationIPD(int refIPD) { return getLeaderAllocIPD(refIPD); } private MinOptMax getLeaderAllocIPD(int ipd) { // length of the leader int opt = ldrNode.getLength(PR_LEADER_LENGTH | CP_OPTIMUM, ipd); int min = ldrNode.getLength(PR_LEADER_LENGTH | CP_MINIMUM, ipd); int max = ldrNode.getLength(PR_LEADER_LENGTH | CP_MAXIMUM, ipd); return new MinOptMax(min, opt, max); } private InlineArea getLeaderInlineArea() { InlineArea leaderArea = null; if (ldrNode.getLeaderPattern() == LeaderPattern.RULE) { org.apache.fop.area.inline.Leader leader = new org.apache.fop.area.inline.Leader(); leader.setRuleStyle(ldrNode.getRuleStyle()); leader.setRuleThickness(ldrNode.getRuleThickness()); leaderArea = leader; } else if (ldrNode.getLeaderPattern() == LeaderPattern.SPACE) { leaderArea = new Space(); } else if (ldrNode.getLeaderPattern() == LeaderPattern.DOTS) { TextArea t = new TextArea(); char dot = '.'; // userAgent.getLeaderDotCharacter(); t.setTextArea("" + dot); t.addTrait(Trait.FONT_NAME, font.getFontName()); t.addTrait(Trait.FONT_SIZE, new Integer(font.getFontSize())); // set offset of dot within inline parent t.setOffset(font.getAscender()); int width = font.getCharWidth(dot); Space spacer = null; if (ldrNode.getPatternWidth() > width) { spacer = new Space(); spacer.setWidth(ldrNode.getPatternWidth() - width); width = ldrNode.getPatternWidth(); } FilledArea fa = new FilledArea(); fa.setUnitWidth(width); fa.addChild(t); if (spacer != null) { fa.addChild(spacer); } fa.setHeight(font.getAscender()); leaderArea = fa; } else if (ldrNode.getLeaderPattern() == LeaderPattern.USECONTENT) { if (ldrNode.getChildNodes() == null) { ldrNode.getLogger().error("Leader use-content with no content"); return null; } InlineStackingLayoutManager lm; lm = new InlineStackingLayoutManager(ldrNode); lm.setLMiter(new LMiter(lm, ldrNode.getChildNodes())); lm.initialize(); // get breaks then add areas to FilledArea FilledArea fa = new FilledArea(); ContentLayoutManager clm = new ContentLayoutManager(fa); clm.setParent(this); clm.setUserAgent(ldrNode.getUserAgent()); lm.setParent(clm); clm.fillArea(lm); int width = clm.getStackingSize(); Space spacer = null; if (ldrNode.getPatternWidth() > width) { spacer = new Space(); spacer.setWidth(ldrNode.getPatternWidth() - width); width = ldrNode.getPatternWidth(); } fa.setUnitWidth(width); if (spacer != null) { fa.addChild(spacer); } leaderArea = fa; } return leaderArea; } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]