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.
/**
* 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();
/**
* @return the ViewHeight (in millipoints??)
+ * @todo check that each of these accessors are needed
*/
public int getViewHeight() {
return viewHeight;
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()
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;
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";
}
package org.apache.fop.fo.flow;
+// Java
+import java.util.List;
+
// XML
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
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;
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";
}
// 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
super(parent);
}
- public void acceptVisitor(AddLMVisitor aLMV) {
- aLMV.serveTableFooter(this);
- }
-
+ /**
+ * @see org.apache.fop.fo.FObj#getName()
+ */
public String getName() {
return "fo:table-footer";
}
// 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
super(parent);
}
- public void acceptVisitor(AddLMVisitor aLMV) {
- aLMV.serveTableHeader(this);
- }
-
+ /**
+ * @see org.apache.fop.fo.FObj#getName()
+ */
public String getName() {
return "fo:table-header";
}
* @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);
}
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;
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);
- }
}
--- /dev/null
+/*
+ * 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;
+ }
+}
+
* 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);
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 {