// If no main flow, nothing to layout!
if (pageSequence.getMainFlow() != null) {
PageSequenceLayoutManager pageSLM;
- try {
- pageSLM = (PageSequenceLayoutManager)
+ pageSLM = (PageSequenceLayoutManager)
getLayoutManagerMaker().makeLayoutManager(pageSequence);
- } catch (FOPException e) {
- log.error("Failed to create a PageSequenceLayoutManager; "
- + "no pages will be laid out:");
- log.error(e.getMessage());
- return;
- }
pageSLM.setAreaTreeHandler(this);
pageSLM.activateLayout();
}
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 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.
package org.apache.fop.fo.flow;
// Java
-import java.util.List;
-import java.util.ListIterator;
-
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObjMixed;
import org.apache.fop.fo.PropertyList;
+import org.apache.fop.fo.ValidationException;
+import org.xml.sax.Locator;
/**
* Implementation for fo:wrapper formatting object.
* The wrapper object serves as
* a property holder for its child node objects.
- *
- * Content: (#PCDATA|%inline;|%block;)*
- * Properties: id
- * @todo implement validateChildNode()
*/
public class Wrapper extends FObjMixed {
// The value of properties relevant for fo:wrapper.
private String id;
// End of property values
+ // used for FO validation
+ private boolean blockOrInlineItemFound = false;
+
/**
* @param parent FONode that is the parent of this object
*/
checkId(id);
}
+ /**
+ * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
+ * XSL Content Model: marker* (#PCDATA|%inline;|%block;)*
+ * Additionally (unimplemented): "An fo:wrapper that is a child of an
+ * fo:multi-properties is only permitted to have children that would
+ * be permitted in place of the fo:multi-properties."
+ */
+ protected void validateChildNode(Locator loc, String nsURI, String localName)
+ throws ValidationException {
+ if (nsURI == FO_URI && localName.equals("marker")) {
+ if (blockOrInlineItemFound) {
+ nodesOutOfOrderError(loc, "fo:marker",
+ "(#PCDATA|%inline;|%block;)");
+ }
+ } else if (isBlockOrInlineItem(nsURI, localName)) {
+ blockOrInlineItemFound = true;
+ } else {
+ invalidChildError(loc, nsURI, localName);
+ }
+ }
+
/**
* Return the "id" property.
*/
/*
- * Copyright 2004 The Apache Software Foundation.
+ * Copyright 2004-2005 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.
import java.util.List;
import org.apache.fop.fo.FONode;
-import org.apache.fop.apps.FOPException;
+
/**
* The interface for all LayoutManager makers
public void makeLayoutManagers(FONode node, List lms);
/**
- * Make the LayoutManager for the node.
- * If not exactly one LayoutManagers is made,
- * a FOPException is thrown.
+ * Make a specific LayoutManager for the node.
+ * If not exactly one LayoutManagers is available,
+ * an IllegalStateException is thrown.
* @param node the FO node for which the LayoutManagers are made
* @return The created LayoutManager
+ * @throws IllegalStateException if not exactly one
+ * LayoutManager is available for the requested node
*/
- public LayoutManager makeLayoutManager(FONode node)
- throws FOPException;
+ public LayoutManager makeLayoutManager(FONode node);
}
import java.util.Map;
import java.util.HashMap;
import java.util.List;
-import java.util.ListIterator;
import java.util.Iterator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.fop.apps.FOPException;
-
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FOText;
import org.apache.fop.fo.FObjMixed;
import org.apache.fop.layoutmgr.list.ListBlockLayoutManager;
import org.apache.fop.layoutmgr.list.ListItemLayoutManager;
-import org.apache.fop.layoutmgr.table.Body;
+/*import org.apache.fop.layoutmgr.table.Body;
import org.apache.fop.layoutmgr.table.Cell;
import org.apache.fop.layoutmgr.table.Column;
-import org.apache.fop.layoutmgr.table.Row;
+import org.apache.fop.layoutmgr.table.Row;*/
import org.apache.fop.layoutmgr.table.TableLayoutManager;
/**
/**
* Initializes the set of maker objects associated with this LayoutManagerMapping
*/
- private void initialize() {
+ protected void initialize() {
makers.put(FOText.class, new FOTextLayoutManagerMaker());
makers.put(FObjMixed.class, new Maker());
makers.put(BidiOverride.class, new BidiOverrideLayoutManagerMaker());
/**
* @see org.apache.fop.layoutmgr.LayoutManagerMaker#makeLayoutManager(FONode)
*/
- public LayoutManager makeLayoutManager(FONode node)
- throws FOPException {
+ public LayoutManager makeLayoutManager(FONode node) {
List lms = new ArrayList();
makeLayoutManagers(node, lms);
if (lms.size() == 0) {
- throw new FOPException("No LayoutManager for class "
+ throw new IllegalStateException("LayoutManager for class "
+ node.getClass()
- + "; 1 was required");
+ + " is missing.");
} else if (lms.size() > 1) {
- throw new FOPException("More than 1 LayoutManager for class "
+ throw new IllegalStateException("Duplicate LayoutManagers for class "
+ node.getClass()
- + "; 1 was required");
+ + " found, only one may be declared.");
}
return (LayoutManager) lms.get(0);
}
RegionViewport rv = curPage.getPage().getRegionViewport(regionID);
StaticContentLayoutManager lm;
- try {
- lm = (StaticContentLayoutManager)
- areaTreeHandler.getLayoutManagerMaker().makeLayoutManager(sc);
- } catch (FOPException e) { // severe error
- throw new IllegalStateException(
- "Internal error: Failed to create a StaticContentLayoutManager "
- + "for flow " + sc.getFlowName());
- }
+ lm = (StaticContentLayoutManager)
+ areaTreeHandler.getLayoutManagerMaker().makeLayoutManager(sc);
lm.initialize();
lm.setRegionReference(rv.getRegionReference());
lm.setParent(this);