Browse Source

Validation added for master-name and master-reference properties.


git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198475 13f79535-47bb-0310-9956-ffa450edef68
tags/Root_Temp_KnuthStylePageBreaking
Glen Mazza 19 years ago
parent
commit
33505a7664

+ 9
- 0
src/java/org/apache/fop/fo/FONode.java View File

@@ -31,6 +31,7 @@ import org.apache.fop.apps.FOPException;
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;

/**
@@ -406,6 +407,14 @@ public abstract class FONode implements Cloneable {
}
}

/**
* 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

+ 8
- 26
src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java View File

@@ -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 @@ public class ConditionalPageMasterReference extends FObj {
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);
}

/**
@@ -133,30 +139,6 @@ public class ConditionalPageMasterReference extends FObj {
return true;
}

/**
* 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.
*/

+ 2
- 4
src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java View File

@@ -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 @@ public class LayoutMasterSet extends FObj {
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();
}

+ 7
- 3
src/java/org/apache/fop/fo/pagination/PageSequence.java View File

@@ -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 @@ public class PageSequence extends FObj {
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 @@ public class PageSequence extends FObj {
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();
}

+ 7
- 14
src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java View File

@@ -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 class PageSequenceMaster extends FObj {
*/
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 @@ public class PageSequenceMaster extends FObj {
*/
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);
}
/**

+ 5
- 1
src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java View File

@@ -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 class RepeatablePageMasterReference extends FObj
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");
}
}

/**

+ 8
- 2
src/java/org/apache/fop/fo/pagination/Root.java View File

@@ -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.FObj;
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.
@@ -259,6 +258,13 @@ public class Root extends FObj {
return bookmarkTree;
}

/**
* @see org.apache.fop.fo.FONode#getRoot()
*/
public Root getRoot() {
return this;
}

/**
* @see org.apache.fop.fo.FObj#getName()
*/

+ 5
- 1
src/java/org/apache/fop/fo/pagination/SimplePageMaster.java View File

@@ -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 @@ public class SimplePageMaster extends FObj {
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");
}
}

/**

+ 6
- 6
src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java View File

@@ -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 class SinglePageMasterReference extends FObj
*/
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 @@ public class SinglePageMasterReference extends FObj
*/
protected void startOfNode() throws FOPException {
PageSequenceMaster pageSequenceMaster = (PageSequenceMaster) parent;
if (masterReference == null) {
missingPropertyError("master-reference");
} else {
pageSequenceMaster.addSubsequenceSpecifier(this);
}
pageSequenceMaster.addSubsequenceSpecifier(this);
}
/**

Loading…
Cancel
Save