You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by gm...@apache.org on 2005/04/25 01:54:34 UTC
cvs commit: xml-fop/src/java/org/apache/fop/fo/flow Wrapper.java
gmazza 2005/04/24 16:54:34
Modified: src/java/org/apache/fop/layoutmgr Tag:
Temp_KnuthStylePageBreaking
PageSequenceLayoutManager.java
LayoutManagerMapping.java LayoutManagerMaker.java
src/java/org/apache/fop/area Tag:
Temp_KnuthStylePageBreaking AreaTreeHandler.java
src/java/org/apache/fop/fo/flow Tag:
Temp_KnuthStylePageBreaking Wrapper.java
Log:
--Validation for fo:wrapper added.
--Made LayoutManagerMapping.initialize() protected to facilitate
subclassing of this class.
--For direct requests of particular LayoutManager overrides, switched
from FOPException to IllegalStateException when the mapping is
missing or duplicate.
Revision Changes Path
No revision
No revision
1.50.2.14 +3 -9 xml-fop/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
Index: PageSequenceLayoutManager.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java,v
retrieving revision 1.50.2.13
retrieving revision 1.50.2.14
diff -u -r1.50.2.13 -r1.50.2.14
--- PageSequenceLayoutManager.java 14 Apr 2005 00:17:06 -0000 1.50.2.13
+++ PageSequenceLayoutManager.java 24 Apr 2005 23:54:34 -0000 1.50.2.14
@@ -446,14 +446,8 @@
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);
1.7.2.2 +9 -13 xml-fop/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java
Index: LayoutManagerMapping.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java,v
retrieving revision 1.7.2.1
retrieving revision 1.7.2.2
diff -u -r1.7.2.1 -r1.7.2.2
--- LayoutManagerMapping.java 5 Apr 2005 15:42:45 -0000 1.7.2.1
+++ LayoutManagerMapping.java 24 Apr 2005 23:54:34 -0000 1.7.2.2
@@ -21,14 +21,11 @@
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;
@@ -64,10 +61,10 @@
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;
/**
@@ -88,7 +85,7 @@
/**
* 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());
@@ -141,18 +138,17 @@
/**
* @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);
}
1.2.2.1 +9 -8 xml-fop/src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java
Index: LayoutManagerMaker.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -r1.2 -r1.2.2.1
--- LayoutManagerMaker.java 27 Dec 2004 10:13:05 -0000 1.2
+++ LayoutManagerMaker.java 24 Apr 2005 23:54:34 -0000 1.2.2.1
@@ -1,5 +1,5 @@
/*
- * 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.
@@ -19,7 +19,7 @@
import java.util.List;
import org.apache.fop.fo.FONode;
-import org.apache.fop.apps.FOPException;
+
/**
* The interface for all LayoutManager makers
@@ -34,14 +34,15 @@
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);
}
No revision
No revision
1.34.2.1 +2 -9 xml-fop/src/java/org/apache/fop/area/AreaTreeHandler.java
Index: AreaTreeHandler.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/area/AreaTreeHandler.java,v
retrieving revision 1.34
retrieving revision 1.34.2.1
diff -u -r1.34 -r1.34.2.1
--- AreaTreeHandler.java 17 Feb 2005 00:27:53 -0000 1.34
+++ AreaTreeHandler.java 24 Apr 2005 23:54:34 -0000 1.34.2.1
@@ -230,15 +230,8 @@
// 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();
}
No revision
No revision
1.19.2.1 +27 -8 xml-fop/src/java/org/apache/fop/fo/flow/Wrapper.java
Index: Wrapper.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/Wrapper.java,v
retrieving revision 1.19
retrieving revision 1.19.2.1
diff -u -r1.19 -r1.19.2.1
--- Wrapper.java 24 Dec 2004 12:06:26 -0000 1.19
+++ Wrapper.java 24 Apr 2005 23:54:34 -0000 1.19.2.1
@@ -1,5 +1,5 @@
/*
- * 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.
@@ -19,28 +19,26 @@
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
*/
@@ -63,6 +61,27 @@
}
/**
+ * @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.
*/
public String getId() {
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org