aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/fo/pagination
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/org/apache/fop/fo/pagination')
-rw-r--r--src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java9
-rw-r--r--src/java/org/apache/fop/fo/pagination/Flow.java13
-rw-r--r--src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java14
-rw-r--r--src/java/org/apache/fop/fo/pagination/PageMasterReference.java10
-rw-r--r--src/java/org/apache/fop/fo/pagination/PageSequence.java11
-rw-r--r--src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java13
-rw-r--r--src/java/org/apache/fop/fo/pagination/Region.java11
-rw-r--r--src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java11
-rw-r--r--src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java7
-rw-r--r--src/java/org/apache/fop/fo/pagination/SimplePageMaster.java15
-rw-r--r--src/java/org/apache/fop/fo/pagination/StaticContent.java7
11 files changed, 63 insertions, 58 deletions
diff --git a/src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java b/src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java
index 02c9e4fca..3d3c42576 100644
--- a/src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java
+++ b/src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java
@@ -27,7 +27,6 @@ import org.xml.sax.SAXParseException;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
import org.apache.fop.layoutmgr.AddLMVisitor;
-import org.apache.fop.apps.FOPException;
/**
* A conditional-page-master-reference formatting object.
@@ -66,7 +65,7 @@ public class ConditionalPageMasterReference extends FObj {
/**
* @see org.apache.fop.fo.FObj#addProperties
*/
- protected void addProperties(Attributes attlist) throws FOPException {
+ protected void addProperties(Attributes attlist) throws SAXParseException {
super.addProperties(attlist);
if (getProperty(PR_MASTER_REFERENCE) != null) {
setMasterName(getProperty(PR_MASTER_REFERENCE).getString());
@@ -156,7 +155,7 @@ public class ConditionalPageMasterReference extends FObj {
* @param parent parent node
* @throws FOPException If the parent is invalid
*/
- protected void validateParent(FONode parent) throws FOPException {
+ protected void validateParent(FONode parent) throws SAXParseException {
if (parent.getName().equals("fo:repeatable-page-master-alternatives")) {
this.repeatablePageMasterAlternatives =
(RepeatablePageMasterAlternatives)parent;
@@ -168,9 +167,9 @@ public class ConditionalPageMasterReference extends FObj {
this.repeatablePageMasterAlternatives.addConditionalPageMasterReference(this);
}
} else {
- throw new FOPException("fo:conditional-page-master-reference must be child "
+ throw new SAXParseException("fo:conditional-page-master-reference must be child "
+ "of fo:repeatable-page-master-alternatives, not "
- + parent.getName());
+ + parent.getName(), locator);
}
}
diff --git a/src/java/org/apache/fop/fo/pagination/Flow.java b/src/java/org/apache/fop/fo/pagination/Flow.java
index d333d13f2..cbfbecb66 100644
--- a/src/java/org/apache/fop/fo/pagination/Flow.java
+++ b/src/java/org/apache/fop/fo/pagination/Flow.java
@@ -31,7 +31,6 @@ import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.FOElementMapping;
import org.apache.fop.layoutmgr.AddLMVisitor;
-import org.apache.fop.apps.FOPException;
/**
* Class modelling the fo:flow object. See Sec. 6.4.18 in the XSL-FO Standard.
@@ -100,13 +99,13 @@ public class Flow extends FObj {
/**
* @see org.apache.fop.fo.FObj#addProperties
*/
- protected void addProperties(Attributes attlist) throws FOPException {
+ protected void addProperties(Attributes attlist) throws SAXParseException {
super.addProperties(attlist);
if (parent.getName().equals("fo:page-sequence")) {
this.pageSequence = (PageSequence) parent;
} else {
- throw new FOPException("flow must be child of "
- + "page-sequence, not " + parent.getName());
+ throw new SAXParseException("flow must be child of "
+ + "page-sequence, not " + parent.getName(), locator);
}
// according to communication from Paul Grosso (XSL-List,
// 001228, Number 406), confusion in spec section 6.4.5 about
@@ -134,10 +133,10 @@ public class Flow extends FObj {
* @param name the name of the flow to set
* @throws FOPException for an empty name
*/
- protected void setFlowName(String name) throws FOPException {
+ protected void setFlowName(String name) throws SAXParseException {
if (name == null || name.equals("")) {
- throw new FOPException("A 'flow-name' is required for "
- + getName());
+ throw new SAXParseException("A 'flow-name' is required for "
+ + getName(), locator);
} else {
flowName = name;
}
diff --git a/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java b/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java
index 94303e466..356ecc71d 100644
--- a/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java
+++ b/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java
@@ -83,15 +83,15 @@ public class LayoutMasterSet extends FObj {
/**
* @see org.apache.fop.fo.FObj#addProperties
*/
- protected void addProperties(Attributes attlist) throws FOPException {
+ 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 FOPException("fo:layout-master-set must be child of fo:root, not "
- + parent.getName());
+ throw new SAXParseException("fo:layout-master-set must be child of fo:root, not "
+ + parent.getName(), locator);
}
this.simplePageMasters = new java.util.HashMap();
@@ -170,9 +170,9 @@ public class LayoutMasterSet extends FObj {
/**
* Section 7.25.7: check to see that if a region-name is a
* duplicate, that it maps to the same fo region-class.
- * @throws FOPException if there's a name duplication
+ * @throws SAXParseException if there's a name duplication
*/
- public void checkRegionNames() throws FOPException {
+ public void checkRegionNames() throws SAXParseException {
// (user-entered) region-name to default region map.
Map allRegions = new java.util.HashMap();
for (Iterator spm = simplePageMasters.values().iterator();
@@ -187,13 +187,13 @@ public class LayoutMasterSet extends FObj {
String defaultRegionName =
(String) allRegions.get(region.getRegionName());
if (!defaultRegionName.equals(region.getDefaultRegionName())) {
- throw new FOPException("Region-name ("
+ throw new SAXParseException("Region-name ("
+ region.getRegionName()
+ ") is being mapped to multiple "
+ "region-classes ("
+ defaultRegionName + " and "
+ region.getDefaultRegionName()
- + ")");
+ + ")", locator);
}
}
allRegions.put(region.getRegionName(),
diff --git a/src/java/org/apache/fop/fo/pagination/PageMasterReference.java b/src/java/org/apache/fop/fo/pagination/PageMasterReference.java
index 2b6426c6d..3e7c971a3 100644
--- a/src/java/org/apache/fop/fo/pagination/PageMasterReference.java
+++ b/src/java/org/apache/fop/fo/pagination/PageMasterReference.java
@@ -20,11 +20,11 @@ package org.apache.fop.fo.pagination;
// SAX
import org.xml.sax.Attributes;
+import org.xml.sax.SAXParseException;
// FOP
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
-import org.apache.fop.apps.FOPException;
import org.apache.fop.layoutmgr.AddLMVisitor;
/**
@@ -46,7 +46,7 @@ public abstract class PageMasterReference extends FObj
/**
* @see org.apache.fop.fo.FObj#addProperties
*/
- protected void addProperties(Attributes attlist) throws FOPException {
+ protected void addProperties(Attributes attlist) throws SAXParseException {
super.addProperties(attlist);
if (getProperty(PR_MASTER_REFERENCE) != null) {
this.masterName = getProperty(PR_MASTER_REFERENCE).getString();
@@ -69,7 +69,7 @@ public abstract class PageMasterReference extends FObj
* @param parent parent node
* @throws FOPException If the parent is invalid.
*/
- protected void validateParent(FONode parent) throws FOPException {
+ protected void validateParent(FONode parent) throws SAXParseException {
if (parent.getName().equals("fo:page-sequence-master")) {
PageSequenceMaster pageSequenceMaster = (PageSequenceMaster)parent;
@@ -80,9 +80,9 @@ public abstract class PageMasterReference extends FObj
pageSequenceMaster.addSubsequenceSpecifier(this);
}
} else {
- throw new FOPException(getName() + " must be"
+ throw new SAXParseException(getName() + " must be"
+ "child of fo:page-sequence-master, not "
- + parent.getName());
+ + parent.getName(), locator);
}
}
diff --git a/src/java/org/apache/fop/fo/pagination/PageSequence.java b/src/java/org/apache/fop/fo/pagination/PageSequence.java
index 3e37adcf5..9f1a7ee3d 100644
--- a/src/java/org/apache/fop/fo/pagination/PageSequence.java
+++ b/src/java/org/apache/fop/fo/pagination/PageSequence.java
@@ -27,6 +27,7 @@ import org.xml.sax.Locator;
import org.xml.sax.SAXParseException;
// FOP
+import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.FOElementMapping;
@@ -230,7 +231,7 @@ public class PageSequence extends FObj {
/**
* @see org.apache.fop.fo.FObj#addProperties
*/
- protected void addProperties(Attributes attlist) throws FOPException {
+ protected void addProperties(Attributes attlist) throws SAXParseException {
super.addProperties(attlist);
this.root = (Root) parent;
@@ -258,8 +259,8 @@ public class PageSequence extends FObj {
int pageStart = new Integer(ipnValue).intValue();
this.explicitFirstNumber = (pageStart > 0) ? pageStart : 1;
} catch (NumberFormatException nfe) {
- throw new FOPException("\"" + ipnValue
- + "\" is not a valid value for initial-page-number");
+ throw new SAXParseException("\"" + ipnValue
+ + "\" is not a valid value for initial-page-number", locator);
}
}
@@ -270,9 +271,9 @@ public class PageSequence extends FObj {
this.pageSequenceMaster =
this.layoutMasterSet.getPageSequenceMaster(masterName);
if (this.pageSequenceMaster == null) {
- throw new FOPException("master-reference '" + masterName
+ throw new SAXParseException("master-reference '" + masterName
+ "' for fo:page-sequence matches no"
- + " simple-page-master or page-sequence-master");
+ + " simple-page-master or page-sequence-master", locator);
}
}
diff --git a/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java b/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java
index ecb542ef5..cc746780d 100644
--- a/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java
+++ b/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java
@@ -92,7 +92,7 @@ public class PageSequenceMaster extends FObj {
/**
* @see org.apache.fop.fo.FObj#addProperties
*/
- protected void addProperties(Attributes attlist) throws FOPException {
+ protected void addProperties(Attributes attlist) throws SAXParseException {
super.addProperties(attlist);
subSequenceSpecifiers = new java.util.ArrayList();
if (parent.getName().equals("fo:layout-master-set")) {
@@ -102,12 +102,17 @@ public class PageSequenceMaster extends FObj {
getLogger().warn("page-sequence-master does not have "
+ "a master-name and so is being ignored");
} else {
- this.layoutMasterSet.addPageSequenceMaster(masterName, this);
+ try {
+ this.layoutMasterSet.addPageSequenceMaster(masterName, this);
+ } catch (Exception e) {
+ throw new SAXParseException("Error with adding Page Sequence Master: "
+ + e.getMessage(), locator);
+ }
}
} else {
- throw new FOPException("fo:page-sequence-master must be child "
+ throw new SAXParseException("fo:page-sequence-master must be child "
+ "of fo:layout-master-set, not "
- + parent.getName());
+ + parent.getName(), locator);
}
}
diff --git a/src/java/org/apache/fop/fo/pagination/Region.java b/src/java/org/apache/fop/fo/pagination/Region.java
index 056a65125..b04c51a29 100644
--- a/src/java/org/apache/fop/fo/pagination/Region.java
+++ b/src/java/org/apache/fop/fo/pagination/Region.java
@@ -26,7 +26,6 @@ import org.xml.sax.Locator;
import org.xml.sax.SAXParseException;
// FOP
-import org.apache.fop.apps.FOPException;
import org.apache.fop.datatypes.FODimension;
import org.apache.fop.fo.FONode;
import org.apache.fop.layoutmgr.AddLMVisitor;
@@ -78,7 +77,7 @@ public abstract class Region extends FObj {
/**
* @see org.apache.fop.fo.FObj#addProperties
*/
- protected void addProperties(Attributes attlist) throws FOPException {
+ protected void addProperties(Attributes attlist) throws SAXParseException {
super.addProperties(attlist);
// regions may have name, or default
@@ -91,18 +90,18 @@ public abstract class Region extends FObj {
// check that name is OK. Not very pretty.
if (isReserved(getRegionName())
&& !getRegionName().equals(getDefaultRegionName())) {
- throw new FOPException("region-name '" + regionName
+ throw new SAXParseException("region-name '" + regionName
+ "' for " + this.getName()
- + " not permitted.");
+ + " not permitted.", locator);
}
}
if (parent instanceof SimplePageMaster) {
layoutMaster = (SimplePageMaster)parent;
} else {
- throw new FOPException(this.getName() + " must be child "
+ throw new SAXParseException(this.getName() + " must be child "
+ "of simple-page-master, not "
- + parent.getName());
+ + parent.getName(), locator);
}
this.wm = this.propertyList.get(PR_WRITING_MODE).getEnum();
diff --git a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java
index f43f3f5ae..9dde9b90f 100644
--- a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java
+++ b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java
@@ -31,7 +31,6 @@ import org.apache.fop.fo.FOElementMapping;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
import org.apache.fop.layoutmgr.AddLMVisitor;
-import org.apache.fop.apps.FOPException;
/**
* A repeatable-page-master-alternatives formatting object.
@@ -84,7 +83,7 @@ public class RepeatablePageMasterAlternatives extends FObj
/**
* @see org.apache.fop.fo.FObj#addProperties
*/
- protected void addProperties(Attributes attlist) throws FOPException {
+ protected void addProperties(Attributes attlist) throws SAXParseException {
super.addProperties(attlist);
conditionalPageMasterRefs = new ArrayList();
@@ -92,9 +91,9 @@ public class RepeatablePageMasterAlternatives extends FObj
PageSequenceMaster pageSequenceMaster = (PageSequenceMaster)parent;
pageSequenceMaster.addSubsequenceSpecifier(this);
} else {
- throw new FOPException("fo:repeatable-page-master-alternatives "
+ throw new SAXParseException("fo:repeatable-page-master-alternatives "
+ "must be child of fo:page-sequence-master, not "
- + parent.getName());
+ + parent.getName(), locator);
}
String mr = getProperty(PR_MAXIMUM_REPEATS).getString();
@@ -109,8 +108,8 @@ public class RepeatablePageMasterAlternatives extends FObj
this.maximumRepeats = 0;
}
} catch (NumberFormatException nfe) {
- throw new FOPException("Invalid number for "
- + "'maximum-repeats' property");
+ throw new SAXParseException("Invalid number for "
+ + "'maximum-repeats' property", locator);
}
}
}
diff --git a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java
index 04f15fdc6..8c0267b84 100644
--- a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java
+++ b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java
@@ -26,7 +26,6 @@ import org.xml.sax.SAXParseException;
// FOP
import org.apache.fop.fo.FONode;
import org.apache.fop.layoutmgr.AddLMVisitor;
-import org.apache.fop.apps.FOPException;
/**
* A repeatable-page-master-reference formatting object.
@@ -62,7 +61,7 @@ public class RepeatablePageMasterReference extends PageMasterReference
/**
* @see org.apache.fop.fo.FObj#addProperties
*/
- protected void addProperties(Attributes attlist) throws FOPException {
+ protected void addProperties(Attributes attlist) throws SAXParseException {
super.addProperties(attlist);
String mr = getProperty(PR_MAXIMUM_REPEATS).getString();
if (mr.equals("no-limit")) {
@@ -76,8 +75,8 @@ public class RepeatablePageMasterReference extends PageMasterReference
this.maximumRepeats = 0;
}
} catch (NumberFormatException nfe) {
- throw new FOPException("Invalid number for "
- + "'maximum-repeats' property");
+ throw new SAXParseException("Invalid number for "
+ + "'maximum-repeats' property", locator);
}
}
}
diff --git a/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java b/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java
index 722ee8cb6..76b422ad6 100644
--- a/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java
+++ b/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java
@@ -25,12 +25,12 @@ import java.util.Map;
// XML
import org.xml.sax.Attributes;
+import org.xml.sax.SAXParseException;
// FOP
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
import org.apache.fop.layoutmgr.AddLMVisitor;
-import org.apache.fop.apps.FOPException;
/**
* A simple-page-master formatting object.
@@ -55,7 +55,7 @@ public class SimplePageMaster extends FObj {
/**
* @see org.apache.fop.fo.FObj#addProperties
*/
- protected void addProperties(Attributes attlist) throws FOPException {
+ protected void addProperties(Attributes attlist) throws SAXParseException {
super.addProperties(attlist);
if (parent.getName().equals("fo:layout-master-set")) {
@@ -65,12 +65,17 @@ public class SimplePageMaster extends FObj {
getLogger().warn("simple-page-master does not have "
+ "a master-name and so is being ignored");
} else {
- layoutMasterSet.addSimplePageMaster(this);
+ try {
+ layoutMasterSet.addSimplePageMaster(this);
+ } catch (Exception e) {
+ throw new SAXParseException("Error with adding Page Sequence Master: "
+ + e.getMessage(), locator);
+ }
}
} else {
- throw new FOPException("fo:simple-page-master must be child "
+ throw new SAXParseException("fo:simple-page-master must be child "
+ "of fo:layout-master-set, not "
- + parent.getName());
+ + parent.getName(), locator);
}
//Well, there are only 5 regions so we can save a bit of memory here
regions = new HashMap(5);
diff --git a/src/java/org/apache/fop/fo/pagination/StaticContent.java b/src/java/org/apache/fop/fo/pagination/StaticContent.java
index d0b5ef71c..e1fcbd734 100644
--- a/src/java/org/apache/fop/fo/pagination/StaticContent.java
+++ b/src/java/org/apache/fop/fo/pagination/StaticContent.java
@@ -24,7 +24,6 @@ import org.xml.sax.Locator;
import org.xml.sax.SAXParseException;
// FOP
-import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.FOElementMapping;
import org.apache.fop.fo.FONode;
import org.apache.fop.layoutmgr.AddLMVisitor;
@@ -73,10 +72,10 @@ public class StaticContent extends Flow {
* @param name the flow-name to set
* @throws FOPException for a missing flow name
*/
- protected void setFlowName(String name) throws FOPException {
+ protected void setFlowName(String name) throws SAXParseException {
if (name == null || name.equals("")) {
- throw new FOPException("A 'flow-name' is required for "
- + getName() + ".");
+ throw new SAXParseException("A 'flow-name' is required for "
+ + getName() + ".", locator);
} else {
super.setFlowName(name);
}