From: Glen Mazza Date: Fri, 27 Aug 2004 05:36:43 +0000 (+0000) Subject: PR: X-Git-Tag: Root_Temp_KnuthStylePageBreaking~600 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=40cd84e83da5af6109d89b296e27770054697d96;p=xmlgraphics-fop.git PR: Obtained from: Submitted by: Reviewed by: 1.) Removed PageMasterReference.java, no longer needed. 2.) Added validateChildNode() to XMLOBJ.java to check that the parent of an XSL FO is itself an XSL FO. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197891 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/fo/XMLObj.java b/src/java/org/apache/fop/fo/XMLObj.java index b87ae8dcd..b12bbeffb 100644 --- a/src/java/org/apache/fop/fo/XMLObj.java +++ b/src/java/org/apache/fop/fo/XMLObj.java @@ -48,13 +48,23 @@ public abstract class XMLObj extends FONode { protected String name; /** - * * @param parent the parent formatting object */ public XMLObj(FONode parent) { super(parent); } + /** + * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String) + * here, blocks XSL FO's from having non-FO parents. + */ + protected void validateChildNode(Locator loc, String nsURI, String localName) + throws SAXParseException { + if (nsURI == FO_URI) { + invalidChildError(loc, nsURI, localName); + } + } + /** * @see org.apache.fop.fo.FONode#processNode */ diff --git a/src/java/org/apache/fop/fo/pagination/PageMasterReference.java b/src/java/org/apache/fop/fo/pagination/PageMasterReference.java deleted file mode 100644 index 7a586cd60..000000000 --- a/src/java/org/apache/fop/fo/pagination/PageMasterReference.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 1999-2004 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -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; - -/** - * Base PageMasterReference class. Provides implementation for handling the - * master-reference attribute and containment within a PageSequenceMaster - */ -public abstract class PageMasterReference extends FObj - implements SubSequenceSpecifier { - - private String masterName; - - /** - * @see org.apache.fop.fo.FONode#FONode(FONode) - */ - public PageMasterReference(FONode parent) { - super(parent); - } - - /** - * @see org.apache.fop.fo.FObj#addProperties - */ - protected void addProperties(Attributes attlist) throws SAXParseException { - super.addProperties(attlist); - if (getProperty(PR_MASTER_REFERENCE) != null) { - this.masterName = getProperty(PR_MASTER_REFERENCE).getString(); - } - validateParent(parent); - } - - - /** - * Returns the "master-reference" attribute of this page master reference - * @return the name of the page master - */ - public String getMasterName() { - return masterName; - } - - /** - * Checks that the parent is the right element. The default implementation - * checks for fo:page-sequence-master. - * @param parent parent node - * @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; - - if (getMasterName() == null) { - getLogger().warn(getName() - + " does not have a master-reference and so is being ignored"); - } else { - pageSequenceMaster.addSubsequenceSpecifier(this); - } - } else { - throw new SAXParseException(getName() + " must be" - + "child of fo:page-sequence-master, not " - + parent.getName(), locator); - } - } - - public String getName() { - return "fo:page-master-reference"; - } -} diff --git a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java index 99d9f71e6..3435f1148 100644 --- a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java +++ b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java @@ -25,18 +25,19 @@ import org.xml.sax.SAXParseException; // FOP import org.apache.fop.fo.FONode; +import org.apache.fop.fo.FObj; /** * A repeatable-page-master-reference formatting object. * 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 { +public class RepeatablePageMasterReference extends FObj + implements SubSequenceSpecifier { private static final int INFINITE = -1; private PageSequenceMaster pageSequenceMaster; - private int maximumRepeats; private int numberConsumed = 0; @@ -47,21 +48,23 @@ public class RepeatablePageMasterReference extends PageMasterReference { super(parent); } - /** - * @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 + * @todo need to */ protected void addProperties(Attributes attlist) throws SAXParseException { super.addProperties(attlist); + + PageSequenceMaster pageSequenceMaster = (PageSequenceMaster) parent; + + if (getPropString(PR_MASTER_REFERENCE) == null) { + missingPropertyError("master-reference"); + } else { + pageSequenceMaster.addSubsequenceSpecifier(this); + } + String mr = getPropString(PR_MAXIMUM_REPEATS); + if (mr.equals("no-limit")) { this.maximumRepeats = INFINITE; } else { @@ -79,6 +82,15 @@ public class RepeatablePageMasterReference extends PageMasterReference { } } + /** + * @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.pagination.SubSequenceSpecifier */ @@ -92,7 +104,7 @@ public class RepeatablePageMasterReference extends PageMasterReference { return null; } } - return getMasterName(); + return getPropString(PR_MASTER_REFERENCE); } /** @@ -102,6 +114,9 @@ public class RepeatablePageMasterReference extends PageMasterReference { this.numberConsumed = 0; } + /** + * @see org.apache.fop.fo.FObj#getName() + */ public String getName() { return "fo:repeatable-page-master-reference"; } diff --git a/src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java b/src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java index 94642714f..50acb9476 100644 --- a/src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java +++ b/src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java @@ -25,13 +25,15 @@ import org.xml.sax.SAXParseException; // FOP import org.apache.fop.fo.FONode; +import org.apache.fop.fo.FObj; /** * A single-page-master-reference formatting object. * This is a reference for a single page. It returns the * master name only once until reset. */ -public class SinglePageMasterReference extends PageMasterReference { +public class SinglePageMasterReference extends FObj + implements SubSequenceSpecifier { private static final int FIRST = 0; private static final int DONE = 1; @@ -46,6 +48,20 @@ public class SinglePageMasterReference extends PageMasterReference { this.state = FIRST; } + /** + * @see org.apache.fop.fo.FObj#addProperties + */ + protected void addProperties(Attributes attlist) throws SAXParseException { + super.addProperties(attlist); + + PageSequenceMaster pageSequenceMaster = (PageSequenceMaster) parent; + if (getPropString(PR_MASTER_REFERENCE) == null) { + missingPropertyError("master-reference"); + } else { + pageSequenceMaster.addSubsequenceSpecifier(this); + } + } + /** * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String) * XSL Content Model: empty @@ -63,7 +79,7 @@ public class SinglePageMasterReference extends PageMasterReference { boolean isEmptyPage) { if (this.state == FIRST) { this.state = DONE; - return getMasterName(); + return getPropString(PR_MASTER_REFERENCE); } else { return null; }