gmazza 2004/08/11 15:56:48 Modified: src/java/org/apache/fop/fo/flow ExternalGraphic.java Float.java TableBody.java TableFooter.java TableHeader.java src/java/org/apache/fop/layoutmgr AbstractLayoutManager.java AddLMVisitor.java PageNumberCitationLayoutManager.java PageNumberLayoutManager.java Added: src/java/org/apache/fop/layoutmgr ExternalGraphicLayoutManager.java Log: 1.) LM initialization logic for fo:table-body, fo:table-footer, and fo:table-header moved out of AddLMVisitor. 2.) New LayoutManager subclass created for fo:external-graphic formatting object. 3.) ValidateChildNode(), endOfNode() implemented for fo:float. Revision Changes Path 1.36 +12 -43 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.35 retrieving revision 1.36 diff -u -r1.35 -r1.36 --- ExternalGraphic.java 11 Aug 2004 04:15:25 -0000 1.35 +++ ExternalGraphic.java 11 Aug 2004 22:56:48 -0000 1.36 @@ -27,18 +27,14 @@ import org.xml.sax.Locator; import org.xml.sax.SAXParseException; +// FOP import org.apache.fop.area.inline.Image; -import org.apache.fop.area.inline.InlineArea; -import org.apache.fop.area.inline.Viewport; import org.apache.fop.datatypes.Length; -import org.apache.fop.fo.properties.CommonBorderAndPadding; -import org.apache.fop.fo.properties.CommonBackground; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; import org.apache.fop.image.FopImage; import org.apache.fop.image.ImageFactory; -import org.apache.fop.layoutmgr.LeafNodeLayoutManager; -import org.apache.fop.layoutmgr.TraitSetter; +import org.apache.fop.layoutmgr.ExternalGraphicLayoutManager; /** * External graphic formatting object. @@ -88,6 +84,7 @@ /** * Setup this image. * This gets the sizes for the image and the dimensions and clipping. + * @todo move logic to LM class and/or addProperties() as appropriate */ private void setup() { url = this.propertyList.get(PR_SRC).getString(); @@ -230,6 +227,7 @@ /** * @return the ViewHeight (in millipoints??) + * @todo check that each of these accessors are needed */ public int getViewHeight() { return viewHeight; @@ -251,52 +249,23 @@ return placement; } - public String getName() { - return "fo:external-graphic"; - } - /** * @see org.apache.fop.fo.FObj#addLayoutManager(List) */ public void addLayoutManager(List list) { setup(); - InlineArea area = getExternalGraphicInlineArea(); - if (area != null) { - LeafNodeLayoutManager lm = new LeafNodeLayoutManager(this); - lm.setCurrentArea(area); - lm.setAlignment(getProperty(PR_VERTICAL_ALIGN).getEnum()); - lm.setLead(getViewHeight()); + if (getURL() != null) { + ExternalGraphicLayoutManager lm = new ExternalGraphicLayoutManager(this); list.add(lm); } } - /** - * Get the inline area for this external grpahic. - * This creates the image area and puts it inside a viewport. - * - * @return the viewport containing the image area - * @todo see if can move to LM classes. - */ - public InlineArea getExternalGraphicInlineArea() { - if (getURL() == null) { - return null; - } - Image imArea = new Image(getURL()); - Viewport vp = new Viewport(imArea); - vp.setWidth(getViewWidth()); - vp.setHeight(getViewHeight()); - vp.setClip(getClip()); - vp.setContentPosition(getPlacement()); - vp.setOffset(0); - - // Common Border, Padding, and Background Properties - CommonBorderAndPadding bap = getPropertyManager().getBorderAndPadding(); - CommonBackground bProps = getPropertyManager().getBackgroundProps(); - TraitSetter.addBorders(vp, bap); - TraitSetter.addBackground(vp, bProps); - - return vp; - } + /** + * @see org.apache.fop.fo.FObj#getName() + */ + public String getName() { + return "fo:external-graphic"; + } /** * @see org.apache.fop.fo.FObj#getNameId() 1.12 +27 -4 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.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- Float.java 8 Aug 2004 18:39:22 -0000 1.11 +++ Float.java 11 Aug 2004 22:56:48 -0000 1.12 @@ -18,6 +18,11 @@ package org.apache.fop.fo.flow; +// XML +import org.xml.sax.Attributes; +import org.xml.sax.Locator; +import org.xml.sax.SAXParseException; + // FOP import org.apache.fop.fo.FONode; import org.apache.fop.fo.ToBeImplementedElement; @@ -34,13 +39,31 @@ super(parent); } - private void setup() { - - // this.propertyList.get("float"); - // this.propertyList.get("clear"); + /** + * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String) + * XSL Content Model: (%block;)+ + */ + protected void validateChildNode(Locator loc, String nsURI, String localName) + throws SAXParseException { + if (!isBlockItem(nsURI, localName)) { + invalidChildError(loc, nsURI, localName); + } + } + /** + * Make sure content model satisfied, if so then tell the + * StructureRenderer that we are at the end of the flow. + * @see org.apache.fop.fo.FONode#end + */ + protected void endOfNode() throws SAXParseException { + if (childNodes == null) { + missingChildElementError("(%block;)+"); + } } + /** + * @see org.apache.fop.fo.FObj#getName() + */ public String getName() { return "fo:float"; } 1.24 +16 -12 xml-fop/src/java/org/apache/fop/fo/flow/TableBody.java Index: TableBody.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/TableBody.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- TableBody.java 11 Aug 2004 04:15:26 -0000 1.23 +++ TableBody.java 11 Aug 2004 22:56:48 -0000 1.24 @@ -18,6 +18,9 @@ package org.apache.fop.fo.flow; +// Java +import java.util.List; + // XML import org.xml.sax.Attributes; import org.xml.sax.SAXException; @@ -27,14 +30,13 @@ import org.apache.fop.datatypes.ColorType; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; -import org.apache.fop.layoutmgr.AddLMVisitor; -import org.apache.fop.fo.LMVisited; +import org.apache.fop.layoutmgr.table.Body; /** * Class modelling the fo:table-body object. See Sec. 6.7.8 of the XSL-FO * Standard. */ -public class TableBody extends FObj implements LMVisited { +public class TableBody extends FObj { private int spaceBefore; private int spaceAfter; @@ -61,19 +63,21 @@ getFOInputHandler().startBody(this); } - /** - * 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. - */ - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveTableBody(this); - } - protected void endOfNode() throws SAXParseException { getFOInputHandler().endBody(this); } + /** + * @see org.apache.fop.fo.FObj#addLayoutManager(List) + */ + public void addLayoutManager(List list) { + Body blm = new Body(this); + list.add(blm); + } + + /** + * @see org.apache.fop.fo.FObj#getName() + */ public String getName() { return "fo:table-body"; } 1.10 +4 -7 xml-fop/src/java/org/apache/fop/fo/flow/TableFooter.java Index: TableFooter.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/TableFooter.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- TableFooter.java 8 Aug 2004 18:39:23 -0000 1.9 +++ TableFooter.java 11 Aug 2004 22:56:48 -0000 1.10 @@ -20,14 +20,12 @@ // FOP import org.apache.fop.fo.FONode; -import org.apache.fop.layoutmgr.AddLMVisitor; -import org.apache.fop.fo.LMVisited; /** * Class modelling the fo:table-footer object. See Sec. 6.7.7 of the XSL-FO * Standard. */ -public class TableFooter extends TableBody implements LMVisited { +public class TableFooter extends TableBody { /** * @param parent FONode that is the parent of this object @@ -36,10 +34,9 @@ super(parent); } - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveTableFooter(this); - } - + /** + * @see org.apache.fop.fo.FObj#getName() + */ public String getName() { return "fo:table-footer"; } 1.10 +4 -7 xml-fop/src/java/org/apache/fop/fo/flow/TableHeader.java Index: TableHeader.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/TableHeader.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- TableHeader.java 8 Aug 2004 18:39:23 -0000 1.9 +++ TableHeader.java 11 Aug 2004 22:56:48 -0000 1.10 @@ -20,14 +20,12 @@ // FOP import org.apache.fop.fo.FONode; -import org.apache.fop.layoutmgr.AddLMVisitor; -import org.apache.fop.fo.LMVisited; /** * Class modelling the fo:table-header object. See Sec. 6.7.6 of the XSL-FO * Standard. */ -public class TableHeader extends TableBody implements LMVisited { +public class TableHeader extends TableBody { /** * @param parent FONode that is the parent of this object @@ -36,10 +34,9 @@ super(parent); } - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveTableHeader(this); - } - + /** + * @see org.apache.fop.fo.FObj#getName() + */ public String getName() { return "fo:table-header"; } 1.19 +3 -0 xml-fop/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java Index: AbstractLayoutManager.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- AbstractLayoutManager.java 24 Jul 2004 22:56:31 -0000 1.18 +++ AbstractLayoutManager.java 11 Aug 2004 22:56:48 -0000 1.19 @@ -67,6 +67,9 @@ * @param fo the formatting object for this layout manager */ public AbstractLayoutManager(FObj fo) { + if (fo == null) { + throw new IllegalStateException("Null formatting object found."); + } setFObj(fo); } 1.53 +1 -21 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.52 retrieving revision 1.53 diff -u -r1.52 -r1.53 --- AddLMVisitor.java 10 Aug 2004 05:33:15 -0000 1.52 +++ AddLMVisitor.java 11 Aug 2004 22:56:48 -0000 1.53 @@ -49,8 +49,6 @@ import org.apache.fop.fo.flow.TableBody; import org.apache.fop.fo.flow.TableCell; import org.apache.fop.fo.flow.TableColumn; -import org.apache.fop.fo.flow.TableFooter; -import org.apache.fop.fo.flow.TableHeader; import org.apache.fop.fo.flow.TableRow; import org.apache.fop.fo.flow.Wrapper; import org.apache.fop.fo.pagination.Title; @@ -434,26 +432,8 @@ return clm; } - public void serveTableBody(TableBody node) { - currentLMList.add(getTableBodyLayoutManager(node)); - } - public Body getTableBodyLayoutManager(TableBody node) { Body blm = new Body(node); return blm; } - - /** - * @param node TableFooter object to process - */ - public void serveTableFooter(TableFooter node) { - serveTableBody((TableBody)node); - } - - /** - * @param node TableHeader object to process - */ - public void serveTableHeader(TableHeader node) { - serveTableBody((TableBody)node); - } } 1.2 +2 -4 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.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- PageNumberCitationLayoutManager.java 10 Aug 2004 05:33:15 -0000 1.1 +++ PageNumberCitationLayoutManager.java 11 Aug 2004 22:56:48 -0000 1.2 @@ -39,9 +39,7 @@ * Constructor * * @param node the formatting object that creates this area - * @todo better null checking of node, font - * @todo see if cleaner way to remove redundant pncNode variable (already - * being stored as an FObj in base class) + * @todo better null checking font */ public PageNumberCitationLayoutManager(PageNumberCitation node) { super(node); 1.2 +2 -2 xml-fop/src/java/org/apache/fop/layoutmgr/PageNumberLayoutManager.java Index: PageNumberLayoutManager.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/PageNumberLayoutManager.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- PageNumberLayoutManager.java 8 Aug 2004 17:52:35 -0000 1.1 +++ PageNumberLayoutManager.java 11 Aug 2004 22:56:48 -0000 1.2 @@ -25,7 +25,7 @@ import org.apache.fop.fonts.Font; /** - * LayoutManager for the fo:basic-link formatting object + * LayoutManager for the fo:page-number formatting object */ public class PageNumberLayoutManager extends LeafNodeLayoutManager { 1.1 xml-fop/src/java/org/apache/fop/layoutmgr/ExternalGraphicLayoutManager.java Index: ExternalGraphicLayoutManager.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: ExternalGraphicLayoutManager.java,v 1.1 2004/08/11 22:56:48 gmazza Exp $ */ package org.apache.fop.layoutmgr; import org.apache.fop.area.inline.Image; import org.apache.fop.area.inline.InlineArea; import org.apache.fop.area.inline.Viewport; import org.apache.fop.fo.flow.ExternalGraphic; import org.apache.fop.fo.properties.CommonBorderAndPadding; import org.apache.fop.fo.properties.CommonBackground; /** * LayoutManager for the fo:external-graphic formatting object */ public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager { ExternalGraphic graphic = null; /** * Constructor * * @param node the fo:external-graphic formatting object that creates the area */ public ExternalGraphicLayoutManager(ExternalGraphic node) { super(node); graphic = node; InlineArea area = getExternalGraphicInlineArea(); setCurrentArea(area); setAlignment(graphic.getProperty(PR_VERTICAL_ALIGN).getEnum()); setLead(graphic.getViewHeight()); } /** * Get the inline area for this external grpahic. * This creates the image area and puts it inside a viewport. * * @return the viewport containing the image area */ public InlineArea getExternalGraphicInlineArea() { Image imArea = new Image(graphic.getURL()); Viewport vp = new Viewport(imArea); vp.setWidth(graphic.getViewWidth()); vp.setHeight(graphic.getViewHeight()); vp.setClip(graphic.getClip()); vp.setContentPosition(graphic.getPlacement()); vp.setOffset(0); // Common Border, Padding, and Background Properties CommonBorderAndPadding bap = graphic.getPropertyManager().getBorderAndPadding(); CommonBackground bProps = graphic.getPropertyManager().getBackgroundProps(); TraitSetter.addBorders(vp, bap); TraitSetter.addBackground(vp, bProps); return vp; } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]