diff options
author | Glen Mazza <gmazza@apache.org> | 2004-08-11 22:56:48 +0000 |
---|---|---|
committer | Glen Mazza <gmazza@apache.org> | 2004-08-11 22:56:48 +0000 |
commit | 89db98aa88db50f99cc106202e43d9c4ff73f180 (patch) | |
tree | 69cf478db473e4c009aebb0c37d014d043556ccb /src/java/org/apache | |
parent | cd6e57eb77f97de51c242bcff0aae1276b47b3b0 (diff) | |
download | xmlgraphics-fop-89db98aa88db50f99cc106202e43d9c4ff73f180.tar.gz xmlgraphics-fop-89db98aa88db50f99cc106202e43d9c4ff73f180.zip |
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.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197866 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache')
10 files changed, 142 insertions, 97 deletions
diff --git a/src/java/org/apache/fop/fo/flow/ExternalGraphic.java b/src/java/org/apache/fop/fo/flow/ExternalGraphic.java index 82ff0cfff..4a37eab8a 100644 --- a/src/java/org/apache/fop/fo/flow/ExternalGraphic.java +++ b/src/java/org/apache/fop/fo/flow/ExternalGraphic.java @@ -27,18 +27,14 @@ import org.xml.sax.Attributes; 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 @@ public class ExternalGraphic extends FObj { /** * 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 @@ public class ExternalGraphic extends FObj { /** * @return the ViewHeight (in millipoints??) + * @todo check that each of these accessors are needed */ public int getViewHeight() { return viewHeight; @@ -251,52 +249,23 @@ public class ExternalGraphic extends FObj { 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() diff --git a/src/java/org/apache/fop/fo/flow/Float.java b/src/java/org/apache/fop/fo/flow/Float.java index 403f0adc0..31c4b93cc 100644 --- a/src/java/org/apache/fop/fo/flow/Float.java +++ b/src/java/org/apache/fop/fo/flow/Float.java @@ -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 @@ public class Float extends ToBeImplementedElement { 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"; } diff --git a/src/java/org/apache/fop/fo/flow/TableBody.java b/src/java/org/apache/fop/fo/flow/TableBody.java index 1b4ef4804..392961826 100644 --- a/src/java/org/apache/fop/fo/flow/TableBody.java +++ b/src/java/org/apache/fop/fo/flow/TableBody.java @@ -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.xml.sax.SAXParseException; 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 @@ public class TableBody extends FObj implements LMVisited { 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"; } diff --git a/src/java/org/apache/fop/fo/flow/TableFooter.java b/src/java/org/apache/fop/fo/flow/TableFooter.java index b2816df9c..61c1d239c 100644 --- a/src/java/org/apache/fop/fo/flow/TableFooter.java +++ b/src/java/org/apache/fop/fo/flow/TableFooter.java @@ -20,14 +20,12 @@ package org.apache.fop.fo.flow; // 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 @@ public class TableFooter extends TableBody implements LMVisited { super(parent); } - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveTableFooter(this); - } - + /** + * @see org.apache.fop.fo.FObj#getName() + */ public String getName() { return "fo:table-footer"; } diff --git a/src/java/org/apache/fop/fo/flow/TableHeader.java b/src/java/org/apache/fop/fo/flow/TableHeader.java index f2960147c..102b84d45 100644 --- a/src/java/org/apache/fop/fo/flow/TableHeader.java +++ b/src/java/org/apache/fop/fo/flow/TableHeader.java @@ -20,14 +20,12 @@ package org.apache.fop.fo.flow; // 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 @@ public class TableHeader extends TableBody implements LMVisited { super(parent); } - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveTableHeader(this); - } - + /** + * @see org.apache.fop.fo.FObj#getName() + */ public String getName() { return "fo:table-header"; } diff --git a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java index b25ec4752..e1071156f 100644 --- a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java @@ -67,6 +67,9 @@ public abstract class AbstractLayoutManager implements LayoutManager, Constants * @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); } diff --git a/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java b/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java index 475f14f3c..6b179f257 100644 --- a/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java +++ b/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java @@ -49,8 +49,6 @@ import org.apache.fop.fo.flow.TableAndCaption; 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 @@ public class AddLMVisitor { 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); - } } diff --git a/src/java/org/apache/fop/layoutmgr/ExternalGraphicLayoutManager.java b/src/java/org/apache/fop/layoutmgr/ExternalGraphicLayoutManager.java new file mode 100644 index 000000000..7eacb32d5 --- /dev/null +++ b/src/java/org/apache/fop/layoutmgr/ExternalGraphicLayoutManager.java @@ -0,0 +1,74 @@ +/* + * 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$ */ + +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; + } +} + diff --git a/src/java/org/apache/fop/layoutmgr/PageNumberCitationLayoutManager.java b/src/java/org/apache/fop/layoutmgr/PageNumberCitationLayoutManager.java index 364f1113f..06185a33a 100644 --- a/src/java/org/apache/fop/layoutmgr/PageNumberCitationLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/PageNumberCitationLayoutManager.java @@ -39,9 +39,7 @@ public class PageNumberCitationLayoutManager extends LeafNodeLayoutManager { * 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); diff --git a/src/java/org/apache/fop/layoutmgr/PageNumberLayoutManager.java b/src/java/org/apache/fop/layoutmgr/PageNumberLayoutManager.java index b5bfc8462..28b418a17 100644 --- a/src/java/org/apache/fop/layoutmgr/PageNumberLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/PageNumberLayoutManager.java @@ -25,7 +25,7 @@ import org.apache.fop.area.Trait; 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 { |