aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/fop/fo/FONode.java13
-rw-r--r--src/java/org/apache/fop/fo/flow/Block.java2
-rw-r--r--src/java/org/apache/fop/fo/flow/BlockContainer.java4
-rw-r--r--src/java/org/apache/fop/fo/flow/Footnote.java3
-rw-r--r--src/java/org/apache/fop/fo/flow/InlineContainer.java4
-rw-r--r--src/java/org/apache/fop/fo/flow/Leader.java1
-rw-r--r--src/java/org/apache/fop/fo/flow/ListBlock.java3
-rw-r--r--src/java/org/apache/fop/fo/flow/ListItemBody.java4
-rw-r--r--src/java/org/apache/fop/fo/flow/ListItemLabel.java4
-rw-r--r--src/java/org/apache/fop/fo/flow/MultiCase.java1
-rw-r--r--src/java/org/apache/fop/fo/flow/MultiSwitch.java1
-rw-r--r--src/java/org/apache/fop/fo/flow/MultiToggle.java1
-rw-r--r--src/java/org/apache/fop/fo/flow/PageNumber.java3
-rw-r--r--src/java/org/apache/fop/fo/flow/PageNumberCitation.java3
-rw-r--r--src/java/org/apache/fop/fo/flow/Table.java2
-rw-r--r--src/java/org/apache/fop/fo/flow/TableAndCaption.java1
-rw-r--r--src/java/org/apache/fop/fo/flow/TableBody.java4
-rw-r--r--src/java/org/apache/fop/fo/flow/TableCaption.java1
-rw-r--r--src/java/org/apache/fop/fo/flow/TableCell.java4
-rw-r--r--src/java/org/apache/fop/fo/flow/TableColumn.java3
-rw-r--r--src/java/org/apache/fop/fo/flow/TableFooter.java4
-rw-r--r--src/java/org/apache/fop/fo/flow/TableHeader.java4
-rw-r--r--src/java/org/apache/fop/fo/flow/TableRow.java4
-rw-r--r--src/java/org/apache/fop/fo/flow/Wrapper.java1
-rw-r--r--src/java/org/apache/fop/fo/pagination/Flow.java2
-rw-r--r--src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java96
-rw-r--r--src/java/org/apache/fop/fo/pagination/PageMasterReference.java4
-rw-r--r--src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java7
-rw-r--r--src/java/org/apache/fop/fo/pagination/Region.java18
-rw-r--r--src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java3
-rw-r--r--src/java/org/apache/fop/fo/pagination/SimplePageMaster.java125
-rw-r--r--src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java3
-rw-r--r--src/java/org/apache/fop/fo/pagination/StaticContent.java3
-rw-r--r--src/java/org/apache/fop/fo/pagination/Title.java2
34 files changed, 204 insertions, 134 deletions
diff --git a/src/java/org/apache/fop/fo/FONode.java b/src/java/org/apache/fop/fo/FONode.java
index 000539700..64c1f199d 100644
--- a/src/java/org/apache/fop/fo/FONode.java
+++ b/src/java/org/apache/fop/fo/FONode.java
@@ -36,7 +36,6 @@ import org.apache.fop.fo.extensions.svg.SVGElementMapping;
/**
* base class for nodes in the XML tree
- *
*/
public abstract class FONode {
@@ -321,6 +320,18 @@ public abstract class FONode {
}
/**
+ * Helper function to return missing child element errors
+ * (e.g., fo:layout-master-set not having any page-master child element)
+ * @param contentModel The XSL Content Model for the fo: object.
+ * or a similar description indicating child elements needed.
+ */
+ protected void missingPropertyError(String propertyName)
+ throws SAXParseException {
+ throw new SAXParseException(errorText(locator) + getName() +
+ " is missing required \"" + propertyName + "\" property.", locator);
+ }
+
+ /**
* Helper function to return "Error (line#/column#)" string for
* above exception messages
* @param loc org.xml.sax.Locator object
diff --git a/src/java/org/apache/fop/fo/flow/Block.java b/src/java/org/apache/fop/fo/flow/Block.java
index 254864f6f..d46651e8b 100644
--- a/src/java/org/apache/fop/fo/flow/Block.java
+++ b/src/java/org/apache/fop/fo/flow/Block.java
@@ -53,7 +53,7 @@ import org.apache.fop.util.CharUtilities;
"this." from blockArea since BlockArea is now local.
*/
/**
- * Class modelling the fo:block object. See Sec. 6.5.2 of the XSL-FO Standard.
+ * Class modelling the fo:block object.
*/
public class Block extends FObjMixed {
diff --git a/src/java/org/apache/fop/fo/flow/BlockContainer.java b/src/java/org/apache/fop/fo/flow/BlockContainer.java
index 91214ad1b..a27a0f24f 100644
--- a/src/java/org/apache/fop/fo/flow/BlockContainer.java
+++ b/src/java/org/apache/fop/fo/flow/BlockContainer.java
@@ -31,8 +31,8 @@ import org.xml.sax.Attributes;
import org.xml.sax.SAXParseException;
/**
- * Class modelling the fo:block-container object. See Sec. 6.5.3 of the XSL-FO
- * Standard.
+ * Class modelling the fo:block-container object.
+ * @todo implement validateChildNode()
*/
public class BlockContainer extends FObj {
diff --git a/src/java/org/apache/fop/fo/flow/Footnote.java b/src/java/org/apache/fop/fo/flow/Footnote.java
index 252f31d93..8dc407708 100644
--- a/src/java/org/apache/fop/fo/flow/Footnote.java
+++ b/src/java/org/apache/fop/fo/flow/Footnote.java
@@ -31,8 +31,7 @@ import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
/**
- * Class modelling the fo:footnote object. See Sec. 6.10.3 of the XSL-FO
- * Standard.
+ * Class modelling the fo:footnote object.
*/
public class Footnote extends FObj {
diff --git a/src/java/org/apache/fop/fo/flow/InlineContainer.java b/src/java/org/apache/fop/fo/flow/InlineContainer.java
index c5251f63b..4e50556cd 100644
--- a/src/java/org/apache/fop/fo/flow/InlineContainer.java
+++ b/src/java/org/apache/fop/fo/flow/InlineContainer.java
@@ -33,8 +33,8 @@ import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
/**
- * Class modelling the fo:inline-container object. See Sec. 6.6.8 of the XSL-FO
- * Standard.
+ * Class modelling the fo:inline-container object.
+ * @todo implement validateChildNode()
*/
public class InlineContainer extends FObj {
diff --git a/src/java/org/apache/fop/fo/flow/Leader.java b/src/java/org/apache/fop/fo/flow/Leader.java
index 1aa240c6b..a417777b4 100644
--- a/src/java/org/apache/fop/fo/flow/Leader.java
+++ b/src/java/org/apache/fop/fo/flow/Leader.java
@@ -34,6 +34,7 @@ import org.apache.fop.layoutmgr.LeaderLayoutManager;
* Class modelling fo:leader object.
* The main property of fo:leader is leader-pattern.
* The following patterns are treated: rule, space, dots and use-content.
+ * @todo implement validateChildNode()
*/
public class Leader extends FObjMixed {
diff --git a/src/java/org/apache/fop/fo/flow/ListBlock.java b/src/java/org/apache/fop/fo/flow/ListBlock.java
index 244095c25..58e0a024b 100644
--- a/src/java/org/apache/fop/fo/flow/ListBlock.java
+++ b/src/java/org/apache/fop/fo/flow/ListBlock.java
@@ -33,8 +33,7 @@ import org.apache.fop.fo.FObj;
import org.apache.fop.layoutmgr.list.ListBlockLayoutManager;
/**
- * Class modelling the fo:list-block object. See Sec. 6.8.2 of the XSL-FO
- * Standard.
+ * Class modelling the fo:list-block object.
*/
public class ListBlock extends FObj {
diff --git a/src/java/org/apache/fop/fo/flow/ListItemBody.java b/src/java/org/apache/fop/fo/flow/ListItemBody.java
index 0c68947cb..73a7f47a3 100644
--- a/src/java/org/apache/fop/fo/flow/ListItemBody.java
+++ b/src/java/org/apache/fop/fo/flow/ListItemBody.java
@@ -23,8 +23,8 @@ import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
/**
- * Class modelling the fo:list-item-body object. See Sec. 6.8.4 of the XSL-FO
- * Standard.
+ * Class modelling the fo:list-item-body object.
+ * @todo implement validateChildNode()
*/
public class ListItemBody extends FObj {
diff --git a/src/java/org/apache/fop/fo/flow/ListItemLabel.java b/src/java/org/apache/fop/fo/flow/ListItemLabel.java
index 5b313f305..b117bcb87 100644
--- a/src/java/org/apache/fop/fo/flow/ListItemLabel.java
+++ b/src/java/org/apache/fop/fo/flow/ListItemLabel.java
@@ -27,8 +27,8 @@ import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
/**
- * Class modelling the fo:list-item-label object. See Sec. 6.8.5 of the XSL-FO
- * Standard.
+ * Class modelling the fo:list-item-label object.
+ * @todo implement validateChildNode()
*/
public class ListItemLabel extends FObj {
diff --git a/src/java/org/apache/fop/fo/flow/MultiCase.java b/src/java/org/apache/fop/fo/flow/MultiCase.java
index 32b6803df..4ec5ea6c1 100644
--- a/src/java/org/apache/fop/fo/flow/MultiCase.java
+++ b/src/java/org/apache/fop/fo/flow/MultiCase.java
@@ -24,6 +24,7 @@ import org.apache.fop.fo.FObj;
/**
* Class modelling the fo:multi-case object.
+ * @todo implement validateChildNode()
*/
public class MultiCase extends FObj {
diff --git a/src/java/org/apache/fop/fo/flow/MultiSwitch.java b/src/java/org/apache/fop/fo/flow/MultiSwitch.java
index 99c392f27..9c653172c 100644
--- a/src/java/org/apache/fop/fo/flow/MultiSwitch.java
+++ b/src/java/org/apache/fop/fo/flow/MultiSwitch.java
@@ -24,6 +24,7 @@ import org.apache.fop.fo.FObj;
/**
* Class modelling the fo:multi-switch object.
+ * @todo implement validateChildNode()
*/
public class MultiSwitch extends FObj {
diff --git a/src/java/org/apache/fop/fo/flow/MultiToggle.java b/src/java/org/apache/fop/fo/flow/MultiToggle.java
index a4a58e018..3d78a7476 100644
--- a/src/java/org/apache/fop/fo/flow/MultiToggle.java
+++ b/src/java/org/apache/fop/fo/flow/MultiToggle.java
@@ -24,6 +24,7 @@ import org.apache.fop.fo.FObj;
/**
* Class modelling the fo:multi-toggle property.
+ * @todo implement validateChildNode()
*/
public class MultiToggle extends FObj {
diff --git a/src/java/org/apache/fop/fo/flow/PageNumber.java b/src/java/org/apache/fop/fo/flow/PageNumber.java
index dd69e26d7..d4585cdb2 100644
--- a/src/java/org/apache/fop/fo/flow/PageNumber.java
+++ b/src/java/org/apache/fop/fo/flow/PageNumber.java
@@ -34,8 +34,7 @@ import org.apache.fop.fonts.Font;
import org.apache.fop.layoutmgr.PageNumberLayoutManager;
/**
- * Class modelling the fo:page-number object. See Sec. 6.6.10 of the XSL-FO
- * Standard.
+ * Class modelling the fo:page-number object.
*/
public class PageNumber extends FObj {
/** FontState for this object */
diff --git a/src/java/org/apache/fop/fo/flow/PageNumberCitation.java b/src/java/org/apache/fop/fo/flow/PageNumberCitation.java
index ff06b1b02..73257626d 100644
--- a/src/java/org/apache/fop/fo/flow/PageNumberCitation.java
+++ b/src/java/org/apache/fop/fo/flow/PageNumberCitation.java
@@ -34,8 +34,7 @@ import org.apache.fop.fonts.Font;
import org.apache.fop.layoutmgr.PageNumberCitationLayoutManager;
/**
- * Class modelling the fo:page-number-citation object. See Sec. 6.6.11 of the
- * XSL-FO Standard.
+ * Class modelling the fo:page-number-citation object.
* This inline fo is replaced with the text for a page number.
* The page number used is the page that contains the start of the
* block referenced with the ref-id attribute.
diff --git a/src/java/org/apache/fop/fo/flow/Table.java b/src/java/org/apache/fop/fo/flow/Table.java
index 8146045a1..570372944 100644
--- a/src/java/org/apache/fop/fo/flow/Table.java
+++ b/src/java/org/apache/fop/fo/flow/Table.java
@@ -43,7 +43,7 @@ import org.apache.fop.fo.properties.CommonRelativePosition;
import org.apache.fop.fo.properties.LengthRangeProperty;
/**
- * Class modelling the fo:table object. See Sec. 6.7.3 of the XSL-FO Standard.
+ * Class modelling the fo:table object.
*/
public class Table extends FObj {
private static final int MINCOLWIDTH = 10000; // 10pt
diff --git a/src/java/org/apache/fop/fo/flow/TableAndCaption.java b/src/java/org/apache/fop/fo/flow/TableAndCaption.java
index df01c19c0..8538cc4f1 100644
--- a/src/java/org/apache/fop/fo/flow/TableAndCaption.java
+++ b/src/java/org/apache/fop/fo/flow/TableAndCaption.java
@@ -24,6 +24,7 @@ import org.apache.fop.fo.FObj;
/**
* Class modelling the fo:table-and-caption property.
+ * @todo implement validateChildNode()
*/
public class TableAndCaption extends FObj {
diff --git a/src/java/org/apache/fop/fo/flow/TableBody.java b/src/java/org/apache/fop/fo/flow/TableBody.java
index 392961826..2b0ad8dfc 100644
--- a/src/java/org/apache/fop/fo/flow/TableBody.java
+++ b/src/java/org/apache/fop/fo/flow/TableBody.java
@@ -33,8 +33,8 @@ import org.apache.fop.fo.FObj;
import org.apache.fop.layoutmgr.table.Body;
/**
- * Class modelling the fo:table-body object. See Sec. 6.7.8 of the XSL-FO
- * Standard.
+ * Class modelling the fo:table-body object.
+ * @todo implement validateChildNode()
*/
public class TableBody extends FObj {
diff --git a/src/java/org/apache/fop/fo/flow/TableCaption.java b/src/java/org/apache/fop/fo/flow/TableCaption.java
index 8fcbb776d..cbe53a4d0 100644
--- a/src/java/org/apache/fop/fo/flow/TableCaption.java
+++ b/src/java/org/apache/fop/fo/flow/TableCaption.java
@@ -24,6 +24,7 @@ import org.apache.fop.fo.FObj;
/**
* Class modelling the fo:table-caption object.
+ * @todo implement validateChildNode()
*/
public class TableCaption extends FObj {
diff --git a/src/java/org/apache/fop/fo/flow/TableCell.java b/src/java/org/apache/fop/fo/flow/TableCell.java
index 8907f5957..cb6928d87 100644
--- a/src/java/org/apache/fop/fo/flow/TableCell.java
+++ b/src/java/org/apache/fop/fo/flow/TableCell.java
@@ -34,8 +34,8 @@ import org.apache.fop.layoutmgr.table.Cell;
import org.apache.fop.fo.properties.CommonBorderAndPadding;
/**
- * Class modelling the fo:table-cell object. See Sec. 6.7.10 of the XSL-FO
- * Standard.
+ * Class modelling the fo:table-cell object.
+ * @todo implement validateChildNode()
*/
public class TableCell extends FObj {
diff --git a/src/java/org/apache/fop/fo/flow/TableColumn.java b/src/java/org/apache/fop/fo/flow/TableColumn.java
index 7cf6e813c..0ab7a4215 100644
--- a/src/java/org/apache/fop/fo/flow/TableColumn.java
+++ b/src/java/org/apache/fop/fo/flow/TableColumn.java
@@ -30,8 +30,7 @@ import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
/**
- * Class modelling the fo:table-column object. See Sec. 6.7.4 of the XSL-FO
- * Standard.
+ * Class modelling the fo:table-column object.
*/
public class TableColumn extends FObj {
diff --git a/src/java/org/apache/fop/fo/flow/TableFooter.java b/src/java/org/apache/fop/fo/flow/TableFooter.java
index 61c1d239c..c64f0590a 100644
--- a/src/java/org/apache/fop/fo/flow/TableFooter.java
+++ b/src/java/org/apache/fop/fo/flow/TableFooter.java
@@ -22,8 +22,8 @@ package org.apache.fop.fo.flow;
import org.apache.fop.fo.FONode;
/**
- * Class modelling the fo:table-footer object. See Sec. 6.7.7 of the XSL-FO
- * Standard.
+ * Class modelling the fo:table-footer object.
+ * @todo implement validateChildNode()
*/
public class TableFooter extends TableBody {
diff --git a/src/java/org/apache/fop/fo/flow/TableHeader.java b/src/java/org/apache/fop/fo/flow/TableHeader.java
index 102b84d45..0b61b524d 100644
--- a/src/java/org/apache/fop/fo/flow/TableHeader.java
+++ b/src/java/org/apache/fop/fo/flow/TableHeader.java
@@ -22,8 +22,8 @@ package org.apache.fop.fo.flow;
import org.apache.fop.fo.FONode;
/**
- * Class modelling the fo:table-header object. See Sec. 6.7.6 of the XSL-FO
- * Standard.
+ * Class modelling the fo:table-header object.
+ * @todo implement validateChildNode()
*/
public class TableHeader extends TableBody {
diff --git a/src/java/org/apache/fop/fo/flow/TableRow.java b/src/java/org/apache/fop/fo/flow/TableRow.java
index 31d262651..21d5057d7 100644
--- a/src/java/org/apache/fop/fo/flow/TableRow.java
+++ b/src/java/org/apache/fop/fo/flow/TableRow.java
@@ -36,8 +36,8 @@ import org.apache.fop.fo.properties.Property;
/**
- * Class modelling the fo:table-row object. See Sec. 6.7.9 of the XSL-FO
- * Standard.
+ * Class modelling the fo:table-row object.
+ * @todo implement validateChildNode()
*/
public class TableRow extends FObj {
diff --git a/src/java/org/apache/fop/fo/flow/Wrapper.java b/src/java/org/apache/fop/fo/flow/Wrapper.java
index fe294f9e9..5f01c7fa9 100644
--- a/src/java/org/apache/fop/fo/flow/Wrapper.java
+++ b/src/java/org/apache/fop/fo/flow/Wrapper.java
@@ -34,6 +34,7 @@ import org.apache.fop.fo.FObjMixed;
*
* Content: (#PCDATA|%inline;|%block;)*
* Properties: id
+ * @todo implement validateChildNode()
*/
public class Wrapper extends FObjMixed {
diff --git a/src/java/org/apache/fop/fo/pagination/Flow.java b/src/java/org/apache/fop/fo/pagination/Flow.java
index 37233ca14..c756749ca 100644
--- a/src/java/org/apache/fop/fo/pagination/Flow.java
+++ b/src/java/org/apache/fop/fo/pagination/Flow.java
@@ -33,7 +33,7 @@ import org.apache.fop.fo.FObj;
import org.apache.fop.layoutmgr.FlowLayoutManager;
/**
- * Class modelling the fo:flow object. See Sec. 6.4.18 in the XSL-FO Standard.
+ * Class modelling the fo:flow object.
*/
public class Flow extends FObj {
diff --git a/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java b/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java
index 2d143e421..a0ad061c3 100644
--- a/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java
+++ b/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java
@@ -30,7 +30,6 @@ import org.xml.sax.SAXParseException;
// FOP
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
-import org.apache.fop.apps.FOPException;
/**
* The layout-master-set formatting object.
@@ -54,6 +53,24 @@ public class LayoutMasterSet extends FObj {
}
/**
+ * @see org.apache.fop.fo.FObj#addProperties
+ */
+ protected void addProperties(Attributes attlist) throws SAXParseException {
+ super.addProperties(attlist);
+
+ if (parent.getName().equals("fo:root")) {
+ Root root = (Root)parent;
+ root.setLayoutMasterSet(this);
+ } else {
+ throw new SAXParseException("fo:layout-master-set must be child of fo:root, not "
+ + parent.getName(), locator);
+ }
+
+ this.simplePageMasters = new java.util.HashMap();
+ this.pageSequenceMasters = new java.util.HashMap();
+ }
+
+ /**
* @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
XSL/FOP: (simple-page-master|page-sequence-master)+
*/
@@ -79,40 +96,32 @@ public class LayoutMasterSet extends FObj {
}
/**
- * @see org.apache.fop.fo.FObj#addProperties
+ * Add a simple page master.
+ * The name is checked to throw an error if already added.
+ * @param sPM simple-page-master to add
+ * @throws SAXParseException if there's a problem with name uniqueness
*/
- protected void addProperties(Attributes attlist) throws SAXParseException {
- super.addProperties(attlist);
+ protected void addSimplePageMaster(SimplePageMaster sPM)
+ throws SAXParseException {
- if (parent.getName().equals("fo:root")) {
- Root root = (Root)parent;
- root.setLayoutMasterSet(this);
- } else {
- throw new SAXParseException("fo:layout-master-set must be child of fo:root, not "
- + parent.getName(), locator);
+ // check for duplication of master-name
+ String masterName = sPM.getPropString(PR_MASTER_NAME);
+ if (existsName(masterName)) {
+ throw new SAXParseException("'master-name' ("
+ + masterName
+ + ") must be unique "
+ + "across page-masters and page-sequence-masters", sPM.locator);
}
-
- this.simplePageMasters = new java.util.HashMap();
- this.pageSequenceMasters = new java.util.HashMap();
+ this.simplePageMasters.put(masterName, sPM);
}
- /**
- * Add a simple page master.
- * The name is checked to throw an error if already added.
- * @param simplePageMaster simple-page-master to add
- * @throws FOPException if there's a problem with name uniqueness
- */
- protected void addSimplePageMaster(SimplePageMaster simplePageMaster)
- throws FOPException {
- // check against duplication of master-name
- if (existsName(simplePageMaster.getMasterName())) {
- throw new FOPException("'master-name' ("
- + simplePageMaster.getMasterName()
- + ") must be unique "
- + "across page-masters and page-sequence-masters");
+ private boolean existsName(String masterName) {
+ if (simplePageMasters.containsKey(masterName)
+ || pageSequenceMasters.containsKey(masterName)) {
+ return true;
+ } else {
+ return false;
}
- this.simplePageMasters.put(simplePageMaster.getMasterName(),
- simplePageMaster);
}
/**
@@ -130,19 +139,20 @@ public class LayoutMasterSet extends FObj {
* Add a page sequence master.
* The name is checked to throw an error if already added.
* @param masterName name for the master
- * @param pageSequenceMaster PageSequenceMaster instance
- * @throws FOPException if there's a problem with name uniqueness
+ * @param pSM PageSequenceMaster instance
+ * @throws SAXParseException if there's a problem with name uniqueness
*/
protected void addPageSequenceMaster(String masterName,
- PageSequenceMaster pageSequenceMaster)
- throws FOPException {
+ PageSequenceMaster pSM)
+ throws SAXParseException {
// check against duplication of master-name
if (existsName(masterName)) {
- throw new FOPException("'master-name' (" + masterName
- + ") must be unique "
- + "across page-masters and page-sequence-masters");
+ throw new SAXParseException("'master-name' ("
+ + masterName
+ + ") must be unique "
+ + "across page-masters and page-sequence-masters", pSM.locator);
}
- this.pageSequenceMasters.put(masterName, pageSequenceMaster);
+ this.pageSequenceMasters.put(masterName, pSM);
}
/**
@@ -156,15 +166,6 @@ public class LayoutMasterSet extends FObj {
return (PageSequenceMaster)this.pageSequenceMasters.get(masterName);
}
- private boolean existsName(String masterName) {
- if (simplePageMasters.containsKey(masterName)
- || pageSequenceMasters.containsKey(masterName)) {
- return true;
- } else {
- return false;
- }
- }
-
/**
* Section 7.25.7: check to see that if a region-name is a
* duplicate, that it maps to the same fo region-class.
@@ -215,6 +216,9 @@ public class LayoutMasterSet extends FObj {
return false;
}
+ /**
+ * @see org.apache.fop.fo.FObj#getName()
+ */
public String getName() {
return "fo:layout-master-set";
}
diff --git a/src/java/org/apache/fop/fo/pagination/PageMasterReference.java b/src/java/org/apache/fop/fo/pagination/PageMasterReference.java
index 390477043..7a586cd60 100644
--- a/src/java/org/apache/fop/fo/pagination/PageMasterReference.java
+++ b/src/java/org/apache/fop/fo/pagination/PageMasterReference.java
@@ -66,11 +66,11 @@ public abstract class PageMasterReference extends FObj
* Checks that the parent is the right element. The default implementation
* checks for fo:page-sequence-master.
* @param parent parent node
- * @throws FOPException If the parent is invalid.
+ * @throws SAXParseException If the parent is invalid.
*/
protected void validateParent(FONode parent) throws SAXParseException {
if (parent.getName().equals("fo:page-sequence-master")) {
- PageSequenceMaster pageSequenceMaster = (PageSequenceMaster)parent;
+ PageSequenceMaster pageSequenceMaster = (PageSequenceMaster) parent;
if (getMasterName() == null) {
getLogger().warn(getName()
diff --git a/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java b/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java
index 31629edf8..173e0be84 100644
--- a/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java
+++ b/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java
@@ -100,12 +100,7 @@ public class PageSequenceMaster extends FObj {
getLogger().warn("page-sequence-master does not have "
+ "a master-name and so is being ignored");
} else {
- try {
- this.layoutMasterSet.addPageSequenceMaster(masterName, this);
- } catch (Exception e) {
- throw new SAXParseException("Error with adding Page Sequence Master: "
- + e.getMessage(), locator);
- }
+ this.layoutMasterSet.addPageSequenceMaster(masterName, this);
}
} else {
throw new SAXParseException("fo:page-sequence-master must be child "
diff --git a/src/java/org/apache/fop/fo/pagination/Region.java b/src/java/org/apache/fop/fo/pagination/Region.java
index ffc16940f..20837c65d 100644
--- a/src/java/org/apache/fop/fo/pagination/Region.java
+++ b/src/java/org/apache/fop/fo/pagination/Region.java
@@ -67,15 +67,6 @@ public abstract class Region extends FObj {
}
/**
- * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
- * XSL Content Model: empty
- */
- protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws SAXParseException {
- invalidChildError(loc, nsURI, localName);
- }
-
- /**
* @see org.apache.fop.fo.FObj#addProperties
*/
protected void addProperties(Attributes attlist) throws SAXParseException {
@@ -111,6 +102,15 @@ public abstract class Region extends FObj {
this.overflow = this.propertyList.get(PR_OVERFLOW).getEnum();
}
+ /**
+ * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
+ * XSL Content Model: empty
+ */
+ protected void validateChildNode(Locator loc, String nsURI, String localName)
+ throws SAXParseException {
+ invalidChildError(loc, nsURI, localName);
+ }
+
public abstract Rectangle getViewportRectangle(FODimension pageRefRect);
/**
diff --git a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java
index 0e6223e54..99d9f71e6 100644
--- a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java
+++ b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java
@@ -31,8 +31,7 @@ import org.apache.fop.fo.FONode;
* This handles a reference with a specified number of repeating
* instances of the referenced page master (may have no limit).
*/
-public class RepeatablePageMasterReference extends PageMasterReference
- implements SubSequenceSpecifier {
+public class RepeatablePageMasterReference extends PageMasterReference {
private static final int INFINITE = -1;
diff --git a/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java b/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java
index e334988b2..7a4debebf 100644
--- a/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java
+++ b/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java
@@ -25,6 +25,7 @@ import java.util.Map;
// XML
import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
import org.xml.sax.SAXParseException;
// FOP
@@ -44,6 +45,13 @@ public class SimplePageMaster extends FObj {
private String masterName;
+ // used for node validation
+ private boolean hasRegionBody = false;
+ private boolean hasRegionBefore = false;
+ private boolean hasRegionAfter = false;
+ private boolean hasRegionStart = false;
+ private boolean hasRegionEnd = false;
+
/**
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
@@ -57,30 +65,91 @@ public class SimplePageMaster extends FObj {
protected void addProperties(Attributes attlist) throws SAXParseException {
super.addProperties(attlist);
- if (parent.getName().equals("fo:layout-master-set")) {
- LayoutMasterSet layoutMasterSet = (LayoutMasterSet)parent;
- masterName = this.propertyList.get(PR_MASTER_NAME).getString();
- if (masterName == null) {
- getLogger().warn("simple-page-master does not have "
- + "a master-name and so is being ignored");
- } else {
- try {
- layoutMasterSet.addSimplePageMaster(this);
- } catch (Exception e) {
- throw new SAXParseException("Error with adding Page Sequence Master: "
- + e.getMessage(), locator);
- }
- }
+ LayoutMasterSet layoutMasterSet = (LayoutMasterSet) parent;
+
+ if (getPropString(PR_MASTER_NAME) == null) {
+ missingPropertyError("master-name");
} else {
- throw new SAXParseException("fo:simple-page-master must be child "
- + "of fo:layout-master-set, not "
- + parent.getName(), locator);
+ layoutMasterSet.addSimplePageMaster(this);
}
+
//Well, there are only 5 regions so we can save a bit of memory here
regions = new HashMap(5);
}
/**
+ * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
+ * XSL Content Model: (region-body,region-before?,region-after?,region-start?,region-end?)
+ */
+ protected void validateChildNode(Locator loc, String nsURI, String localName)
+ throws SAXParseException {
+ if (nsURI == FO_URI && localName.equals("region-body")) {
+ if (hasRegionBody) {
+ tooManyNodesError(loc, "fo:region-body");
+ } else {
+ hasRegionBody = true;
+ }
+ } else if (nsURI == FO_URI && localName.equals("region-before")) {
+ if (!hasRegionBody) {
+ nodesOutOfOrderError(loc, "fo:region-body", "fo:region-before");
+ } else if (hasRegionBefore) {
+ tooManyNodesError(loc, "fo:region-before");
+ } else if (hasRegionAfter) {
+ nodesOutOfOrderError(loc, "fo:region-before", "fo:region-after");
+ } else if (hasRegionStart) {
+ nodesOutOfOrderError(loc, "fo:region-before", "fo:region-start");
+ } else if (hasRegionEnd) {
+ nodesOutOfOrderError(loc, "fo:region-before", "fo:region-end");
+ } else {
+ hasRegionBody = true;
+ }
+ } else if (nsURI == FO_URI && localName.equals("region-after")) {
+ if (!hasRegionBody) {
+ nodesOutOfOrderError(loc, "fo:region-body", "fo:region-after");
+ } else if (hasRegionAfter) {
+ tooManyNodesError(loc, "fo:region-after");
+ } else if (hasRegionStart) {
+ nodesOutOfOrderError(loc, "fo:region-after", "fo:region-start");
+ } else if (hasRegionEnd) {
+ nodesOutOfOrderError(loc, "fo:region-after", "fo:region-end");
+ } else {
+ hasRegionAfter = true;
+ }
+ } else if (nsURI == FO_URI && localName.equals("region-start")) {
+ if (!hasRegionBody) {
+ nodesOutOfOrderError(loc, "fo:region-body", "fo:region-start");
+ } else if (hasRegionStart) {
+ tooManyNodesError(loc, "fo:region-start");
+ } else if (hasRegionEnd) {
+ nodesOutOfOrderError(loc, "fo:region-start", "fo:region-end");
+ } else {
+ hasRegionStart = true;
+ }
+ } else if (nsURI == FO_URI && localName.equals("region-end")) {
+ if (!hasRegionBody) {
+ nodesOutOfOrderError(loc, "fo:region-body", "fo:region-end");
+ } else if (hasRegionEnd) {
+ tooManyNodesError(loc, "fo:region-end");
+ } else {
+ hasRegionEnd = true;
+ }
+ } else {
+ invalidChildError(loc, nsURI, localName);
+ }
+ }
+
+ /**
+ * Make sure content model satisfied.
+ * @see org.apache.fop.fo.FONode#end
+ */
+ protected void endOfNode() throws SAXParseException {
+ if (!hasRegionBody) {
+ missingChildElementError("(region-body, region-before?," +
+ " region-after?, region-start?, region-end?)");
+ }
+ }
+
+ /**
* @see org.apache.fop.fo.FObj#generatesReferenceAreas()
*/
public boolean generatesReferenceAreas() {
@@ -92,19 +161,14 @@ public class SimplePageMaster extends FObj {
* @return the page master name
*/
public String getMasterName() {
- return masterName;
+ return getPropString(PR_MASTER_NAME);
}
/**
* @see org.apache.fop.fo.FONode#addChildNode(FONode)
*/
protected void addChildNode(FONode child) {
- if (child instanceof Region) {
- addRegion((Region)child);
- } else {
- getLogger().error("SimplePageMaster cannot have child of type "
- + child.getName());
- }
+ addRegion((Region)child);
}
/**
@@ -113,13 +177,7 @@ public class SimplePageMaster extends FObj {
*/
protected void addRegion(Region region) {
String key = String.valueOf(region.getRegionClassCode());
- if (regions.containsKey(key)) {
- getLogger().error("Only one region of class " + region.getRegionName()
- + " allowed within a simple-page-master. The duplicate"
- + " region (" + region.getName() + ") is ignored.");
- } else {
- regions.put(key, region);
- }
+ regions.put(key, region);
}
/**
@@ -148,7 +206,7 @@ public class SimplePageMaster extends FObj {
protected boolean regionNameExists(String regionName) {
for (Iterator regenum = regions.values().iterator();
regenum.hasNext();) {
- Region r = (Region)regenum.next();
+ Region r = (Region) regenum.next();
if (r.getRegionName().equals(regionName)) {
return true;
}
@@ -156,6 +214,9 @@ public class SimplePageMaster extends FObj {
return false;
}
+ /**
+ * @see org.apache.fop.fo.FObj#getName()
+ */
public String getName() {
return "fo:simple-page-master";
}
diff --git a/src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java b/src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java
index f90e5c584..94642714f 100644
--- a/src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java
+++ b/src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java
@@ -31,8 +31,7 @@ import org.apache.fop.fo.FONode;
* This is a reference for a single page. It returns the
* master name only once until reset.
*/
-public class SinglePageMasterReference extends PageMasterReference
- implements SubSequenceSpecifier {
+public class SinglePageMasterReference extends PageMasterReference {
private static final int FIRST = 0;
private static final int DONE = 1;
diff --git a/src/java/org/apache/fop/fo/pagination/StaticContent.java b/src/java/org/apache/fop/fo/pagination/StaticContent.java
index 02f725676..81b8e67af 100644
--- a/src/java/org/apache/fop/fo/pagination/StaticContent.java
+++ b/src/java/org/apache/fop/fo/pagination/StaticContent.java
@@ -27,8 +27,7 @@ import org.xml.sax.SAXParseException;
import org.apache.fop.fo.FONode;
/**
- * Class modelling the fo:static-content object. See Sec. 6.4.19 of the XSL-FO
- * Standard.
+ * Class modelling the fo:static-content object.
*/
public class StaticContent extends Flow {
diff --git a/src/java/org/apache/fop/fo/pagination/Title.java b/src/java/org/apache/fop/fo/pagination/Title.java
index f887db91b..8f1d1158a 100644
--- a/src/java/org/apache/fop/fo/pagination/Title.java
+++ b/src/java/org/apache/fop/fo/pagination/Title.java
@@ -39,7 +39,7 @@ import org.apache.fop.fonts.Font;
import org.apache.fop.fo.properties.CommonMarginInline;
/**
- * Class modelling the fo:title object. See Sec. 6.4.20 in the XSL-FO Standard.
+ * Class modelling the fo:title object.
*/
public class Title extends FObjMixed {