gmazza 2005/03/10 15:32:45
Modified: src/java/org/apache/fop/fo/pagination
RepeatablePageMasterReference.java
SimplePageMaster.java PageSequence.java Root.java
PageSequenceMaster.java
ConditionalPageMasterReference.java
SinglePageMasterReference.java LayoutMasterSet.java
src/java/org/apache/fop/fo FONode.java
Log:
Validation added for master-name and master-reference properties.
Revision Changes Path
1.25 +5 -1
xml-fop/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java
Index: RepeatablePageMasterReference.java
===================================================================
RCS file:
/home/cvs/xml-fop/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- RepeatablePageMasterReference.java 24 Nov 2004 21:07:29 -0000
1.24
+++ RepeatablePageMasterReference.java 10 Mar 2005 23:32:44 -0000
1.25
@@ -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.
@@ -59,6 +59,10 @@
public void bind(PropertyList pList) throws FOPException {
masterReference = pList.get(PR_MASTER_REFERENCE).getString();
maximumRepeats = pList.get(PR_MAXIMUM_REPEATS);
+
+ if (masterReference == null || masterReference.equals("")) {
+ missingPropertyError("master-reference");
+ }
}
/**
1.31 +5 -1
xml-fop/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java
Index: SimplePageMaster.java
===================================================================
RCS file:
/home/cvs/xml-fop/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- SimplePageMaster.java 28 Oct 2004 10:00:23 -0000 1.30
+++ SimplePageMaster.java 10 Mar 2005 23:32:44 -0000 1.31
@@ -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.
@@ -78,6 +78,10 @@
pageWidth = pList.get(PR_PAGE_WIDTH).getLength();
referenceOrientation =
pList.get(PR_REFERENCE_ORIENTATION).getNumeric();
writingMode = pList.getWritingMode();
+
+ if (masterName == null || masterName.equals("")) {
+ missingPropertyError("master-name");
+ }
}
/**
1.59 +7 -3
xml-fop/src/java/org/apache/fop/fo/pagination/PageSequence.java
Index: PageSequence.java
===================================================================
RCS file:
/home/cvs/xml-fop/src/java/org/apache/fop/fo/pagination/PageSequence.java,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -r1.58 -r1.59
--- PageSequence.java 18 Feb 2005 03:54:50 -0000 1.58
+++ PageSequence.java 10 Mar 2005 23:32:44 -0000 1.59
@@ -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.
@@ -108,6 +108,10 @@
initialPageNumber = pList.get(PR_INITIAL_PAGE_NUMBER).getNumeric();
forcePageCount = pList.get(PR_FORCE_PAGE_COUNT).getEnum();
masterReference = pList.get(PR_MASTER_REFERENCE).getString();
+
+ if (masterReference == null || masterReference.equals("")) {
+ missingPropertyError("master-reference");
+ }
}
/**
@@ -124,8 +128,8 @@
root.getLayoutMasterSet().getPageSequenceMaster(masterReference);
if (this.pageSequenceMaster == null) {
throw new ValidationException("master-reference '" +
masterReference
- + "' for fo:page-sequence matches no"
- + " simple-page-master or
page-sequence-master", locator);
+ + "' for fo:page-sequence matches no"
+ + " simple-page-master or page-sequence-master", locator);
} else {
pageSequenceMaster.reset();
}
1.42 +8 -2 xml-fop/src/java/org/apache/fop/fo/pagination/Root.java
Index: Root.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/pagination/Root.java,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- Root.java 1 Mar 2005 00:11:03 -0000 1.41
+++ Root.java 10 Mar 2005 23:32:44 -0000 1.42
@@ -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.
@@ -30,7 +30,6 @@
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.ValidationException;
import org.apache.fop.fo.pagination.bookmarks.BookmarkTree;
-import org.apache.fop.fo.extensions.ExtensionElementMapping;
/**
* The fo:root formatting object. Contains page masters, page-sequences.
@@ -260,6 +259,13 @@
}
/**
+ * @see org.apache.fop.fo.FONode#getRoot()
+ */
+ public Root getRoot() {
+ return this;
+ }
+
+ /**
* @see org.apache.fop.fo.FObj#getName()
*/
public String getName() {
1.27 +7 -14
xml-fop/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java
Index: PageSequenceMaster.java
===================================================================
RCS file:
/home/cvs/xml-fop/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- PageSequenceMaster.java 28 Oct 2004 10:00:23 -0000 1.26
+++ PageSequenceMaster.java 10 Mar 2005 23:32:44 -0000 1.27
@@ -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.
@@ -63,6 +63,10 @@
*/
public void bind(PropertyList pList) throws FOPException {
masterName = pList.get(PR_MASTER_NAME).getString();
+
+ if (masterName == null || masterName.equals("")) {
+ missingPropertyError("master-name");
+ }
}
/**
@@ -70,19 +74,8 @@
*/
protected void startOfNode() throws FOPException {
subSequenceSpecifiers = new java.util.ArrayList();
- if (parent.getName().equals("fo:layout-master-set")) {
- this.layoutMasterSet = (LayoutMasterSet)parent;
- if (masterName == null) {
- getLogger().warn("page-sequence-master does not have "
- + "a master-name and so is being
ignored");
- } else {
- this.layoutMasterSet.addPageSequenceMaster(masterName, this);
- }
- } else {
- throw new ValidationException("fo:page-sequence-master must be
child "
- + "of fo:layout-master-set, not "
- + parent.getName(), locator);
- }
+ layoutMasterSet = parent.getRoot().getLayoutMasterSet();
+ layoutMasterSet.addPageSequenceMaster(masterName, this);
}
/**
1.24 +8 -26
xml-fop/src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java
Index: ConditionalPageMasterReference.java
===================================================================
RCS file:
/home/cvs/xml-fop/src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- ConditionalPageMasterReference.java 24 Nov 2004 21:07:29 -0000
1.23
+++ ConditionalPageMasterReference.java 10 Mar 2005 23:32:44 -0000
1.24
@@ -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.
@@ -60,13 +60,19 @@
pagePosition = pList.get(PR_PAGE_POSITION).getEnum();
oddOrEven = pList.get(PR_ODD_OR_EVEN).getEnum();
blankOrNotBlank = pList.get(PR_BLANK_OR_NOT_BLANK).getEnum();
+
+ if (masterReference == null || masterReference.equals("")) {
+ missingPropertyError("master-reference");
+ }
}
/**
* @see org.apache.fop.fo.FONode#startOfNode
*/
protected void startOfNode() throws FOPException {
- validateParent(parent);
+ this.repeatablePageMasterAlternatives =
+ (RepeatablePageMasterAlternatives) parent;
+
this.repeatablePageMasterAlternatives.addConditionalPageMasterReference(this);
}
/**
@@ -134,30 +140,6 @@
}
/**
- * Check that the parent is the right type of formatting object
- * repeatable-page-master-alternatives.
- * @param parent parent node
- * @throws ValidationException If the parent is invalid
- */
- protected void validateParent(FONode parent) throws ValidationException {
- if
(parent.getName().equals("fo:repeatable-page-master-alternatives")) {
- this.repeatablePageMasterAlternatives =
- (RepeatablePageMasterAlternatives)parent;
-
- if (getMasterReference() == null) {
- getLogger().warn("single-page-master-reference"
- + "does not have a master-name and so
is being ignored");
- } else {
-
this.repeatablePageMasterAlternatives.addConditionalPageMasterReference(this);
- }
- } else {
- throw new
ValidationException("fo:conditional-page-master-reference must be child "
- + "of
fo:repeatable-page-master-alternatives, not "
- + parent.getName(), locator);
- }
- }
-
- /**
* Returns the "master-reference" property.
*/
public String getMasterReference() {
1.18 +6 -6
xml-fop/src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java
Index: SinglePageMasterReference.java
===================================================================
RCS file:
/home/cvs/xml-fop/src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- SinglePageMasterReference.java 28 Oct 2004 10:00:23 -0000 1.17
+++ SinglePageMasterReference.java 10 Mar 2005 23:32:44 -0000 1.18
@@ -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.
@@ -57,6 +57,10 @@
*/
public void bind(PropertyList pList) throws FOPException {
masterReference = pList.get(PR_MASTER_REFERENCE).getString();
+
+ if (masterReference == null || masterReference.equals("")) {
+ missingPropertyError("master-reference");
+ }
}
/**
@@ -64,11 +68,7 @@
*/
protected void startOfNode() throws FOPException {
PageSequenceMaster pageSequenceMaster = (PageSequenceMaster) parent;
- if (masterReference == null) {
- missingPropertyError("master-reference");
- } else {
- pageSequenceMaster.addSubsequenceSpecifier(this);
- }
+ pageSequenceMaster.addSubsequenceSpecifier(this);
}
/**
1.29 +2 -4
xml-fop/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java
Index: LayoutMasterSet.java
===================================================================
RCS file:
/home/cvs/xml-fop/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- LayoutMasterSet.java 28 Oct 2004 10:00:23 -0000 1.28
+++ LayoutMasterSet.java 10 Mar 2005 23:32:44 -0000 1.29
@@ -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.
@@ -65,10 +65,8 @@
if (parent.getName().equals("fo:root")) {
Root root = (Root)parent;
root.setLayoutMasterSet(this);
- } else {
- throw new ValidationException("fo:layout-master-set must be
child of fo:root, not "
- + parent.getName(), locator);
}
+
simplePageMasters = new java.util.HashMap();
pageSequenceMasters = new java.util.HashMap();
}
1.57 +9 -0 xml-fop/src/java/org/apache/fop/fo/FONode.java
Index: FONode.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FONode.java,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -r1.56 -r1.57
--- FONode.java 5 Mar 2005 04:52:06 -0000 1.56
+++ FONode.java 10 Mar 2005 23:32:45 -0000 1.57
@@ -31,6 +31,7 @@
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.fo.extensions.ExtensionElementMapping;
import org.apache.fop.fo.extensions.svg.SVGElementMapping;
+import org.apache.fop.fo.pagination.Root;
import org.apache.fop.util.CharUtilities;
/**
@@ -407,6 +408,14 @@
}
/**
+ * Returns the root node of this tree
+ * @return the root node
+ */
+ public Root getRoot() {
+ return parent.getRoot();
+ }
+
+ /**
* Returns the name of the node
* @return the name of this node
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]