diff options
Diffstat (limited to 'src/java')
6 files changed, 52 insertions, 123 deletions
diff --git a/src/java/META-INF/services/org.apache.fop.fo.ElementMapping b/src/java/META-INF/services/org.apache.fop.fo.ElementMapping index 3204baa64..0194b19db 100644 --- a/src/java/META-INF/services/org.apache.fop.fo.ElementMapping +++ b/src/java/META-INF/services/org.apache.fop.fo.ElementMapping @@ -7,5 +7,4 @@ org.apache.fop.fo.extensions.xmp.XMPElementMapping org.apache.fop.fo.extensions.xmp.RDFElementMapping org.apache.fop.render.ps.extensions.PSExtensionElementMapping org.apache.fop.render.afp.extensions.AFPElementMapping -org.apache.fop.render.pcl.extensions.PCLElementMapping -org.apache.fop.fo.extensions.destination.DestinationElementMapping
\ No newline at end of file +org.apache.fop.render.pcl.extensions.PCLElementMapping
\ No newline at end of file diff --git a/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java b/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java index 0b5ae827b..b5ed3e61c 100644 --- a/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java +++ b/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java @@ -20,7 +20,9 @@ package org.apache.fop.fo.extensions; import org.apache.fop.fo.ElementMapping; +import org.apache.fop.fo.FONode; import org.apache.fop.fo.UnknownXMLObj; +import org.apache.fop.fo.extensions.destination.Destination; import org.apache.fop.util.QName; import java.util.HashMap; @@ -41,6 +43,7 @@ public class ExtensionElementMapping extends ElementMapping { propertyAttributes.add("block-progression-unit"); propertyAttributes.add("widow-content-limit"); propertyAttributes.add("orphan-content-limit"); + propertyAttributes.add("internal-destination"); } /** @@ -58,9 +61,16 @@ public class ExtensionElementMapping extends ElementMapping { foObjs = new HashMap(); foObjs.put("outline", new UnknownXMLObj.Maker(URI)); foObjs.put("label", new UnknownXMLObj.Maker(URI)); + foObjs.put("destination", new DestinationMaker()); } } + static class DestinationMaker extends ElementMapping.Maker { + public FONode make(FONode parent) { + return new Destination(parent); + } + } + /** @see org.apache.fop.fo.ElementMapping#getStandardPrefix() */ public String getStandardPrefix() { return "fox"; diff --git a/src/java/org/apache/fop/fo/extensions/destination/Destination.java b/src/java/org/apache/fop/fo/extensions/destination/Destination.java index 81c432601..b4611661e 100644 --- a/src/java/org/apache/fop/fo/extensions/destination/Destination.java +++ b/src/java/org/apache/fop/fo/extensions/destination/Destination.java @@ -22,9 +22,7 @@ package org.apache.fop.fo.extensions.destination; import org.apache.fop.fo.ValidationException; import org.apache.fop.apps.FOPException; import org.apache.fop.fo.PropertyList; -import org.apache.fop.fo.FOEventHandler; import org.apache.fop.fo.FONode; -import org.apache.fop.fo.FObj; import org.apache.fop.fo.pagination.Root; import org.apache.fop.fo.extensions.ExtensionElementMapping; @@ -34,10 +32,10 @@ import org.xml.sax.Locator; /** * Class for named destinations in PDF. */ -public class Destination extends FObj { +public class Destination extends FONode { - String internalDestination; - Root root; + private String internalDestination; + private Root root; /** * Constructs a Destination object (called by Maker). @@ -50,15 +48,17 @@ public class Destination extends FObj { } /** - * @see org.apache.fop.fo.FObj#bind(PropertyList) + * @see org.apache.fop.fo.FONode#processNode(java.lang.String, org.xml.sax.Locator, + * org.xml.sax.Attributes, org.apache.fop.fo.PropertyList) */ - public void bind(PropertyList pList) throws FOPException { - internalDestination = pList.get(PR_INTERNAL_DESTINATION).getString(); - if (internalDestination.length() == 0) { + public void processNode(String elementName, Locator locator, + Attributes attlist, PropertyList pList) throws FOPException { + internalDestination = attlist.getValue("internal-destination"); + if (internalDestination == null || internalDestination.length() == 0) { attributeError("Missing attribute: internal-destination must be specified."); } } - + /** * @see org.apache.fop.fo.FONode#endOfNode */ @@ -75,6 +75,10 @@ public class Destination extends FObj { invalidChildError(loc, nsURI, localName); } + /** + * Returns the internal destination (an reference of the id property of any FO). + * @return the internal destination + */ public String getInternalDestination() { return internalDestination; } diff --git a/src/java/org/apache/fop/fo/extensions/destination/DestinationElementMapping.java b/src/java/org/apache/fop/fo/extensions/destination/DestinationElementMapping.java deleted file mode 100644 index d0f398617..000000000 --- a/src/java/org/apache/fop/fo/extensions/destination/DestinationElementMapping.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.extensions.destination; - -import java.util.HashMap; -import java.util.Set; - -import org.apache.fop.fo.FONode; -import org.apache.fop.fo.ElementMapping; -import org.apache.fop.fo.extensions.ExtensionElementMapping; -import org.apache.fop.util.QName; - -import org.apache.fop.fo.extensions.destination.Destination; - -/** - * Set up the destination element mapping. - */ -public class DestinationElementMapping extends ElementMapping { - - /** - * The FOP extension namespace URI - */ - public static final String URI = ExtensionElementMapping.URI; - - private static final Set propertyAttributes = new java.util.HashSet(); - - static { - //The extension property (fox:*) for named destinations - propertyAttributes.add("internal-destination"); - } - - /** - * Constructor. - */ - public DestinationElementMapping() { - namespaceURI = URI; - } - - /** - * @see org.apache.fop.fo.ElementMapping#initialize() - */ - protected void initialize() { - if (foObjs == null) { - foObjs = new HashMap(); - foObjs.put("destination", new DestinationMaker()); - } - } - - static class DestinationMaker extends ElementMapping.Maker { - public FONode make(FONode parent) { - return new Destination(parent); - } - } - - /** - * @see org.apache.fop.fo.ElementMapping#getStandardPrefix() - */ - public String getStandardPrefix() { - return "fox"; - } - - /** - * @see org.apache.fop.fo.ElementMapping#isAttributeProperty(org.apache.fop.util.QName) - */ - public boolean isAttributeProperty(QName attributeName) { - if (!URI.equals(attributeName.getNamespaceURI())) { - throw new IllegalArgumentException("The namespace URIs don't match"); - } - return propertyAttributes.contains(attributeName.getLocalName()); - } - -} diff --git a/src/java/org/apache/fop/fo/flow/Block.java b/src/java/org/apache/fop/fo/flow/Block.java index 5dc5ee67c..6beffdfe5 100644 --- a/src/java/org/apache/fop/fo/flow/Block.java +++ b/src/java/org/apache/fop/fo/flow/Block.java @@ -296,28 +296,27 @@ public class Block extends FObjMixed { * fo:inline-container." */ protected void validateChildNode(Locator loc, String nsURI, String localName) - throws ValidationException - { - if (FOX_URI.equals(nsURI) && localName.equals("destination")) { - // Found a fox:destination element - ignore it - } else if (FO_URI.equals(nsURI) && localName.equals("marker")) { - if (blockOrInlineItemFound || initialPropertySetFound) { - nodesOutOfOrderError(loc, "fo:marker", - "initial-property-set? (#PCDATA|%inline;|%block;)"); - } - } else if (FO_URI.equals(nsURI) && localName.equals("initial-property-set")) { - if (initialPropertySetFound) { - tooManyNodesError(loc, "fo:initial-property-set"); - } else if (blockOrInlineItemFound) { - nodesOutOfOrderError(loc, "fo:initial-property-set", - "(#PCDATA|%inline;|%block;)"); + throws ValidationException { + if (FO_URI.equals(nsURI)) { + if (localName.equals("marker")) { + if (blockOrInlineItemFound || initialPropertySetFound) { + nodesOutOfOrderError(loc, "fo:marker", + "initial-property-set? (#PCDATA|%inline;|%block;)"); + } + } else if (localName.equals("initial-property-set")) { + if (initialPropertySetFound) { + tooManyNodesError(loc, "fo:initial-property-set"); + } else if (blockOrInlineItemFound) { + nodesOutOfOrderError(loc, "fo:initial-property-set", + "(#PCDATA|%inline;|%block;)"); + } else { + initialPropertySetFound = true; + } + } else if (isBlockOrInlineItem(nsURI, localName)) { + blockOrInlineItemFound = true; } else { - initialPropertySetFound = true; + invalidChildError(loc, nsURI, localName); } - } else if (isBlockOrInlineItem(nsURI, localName)) { - blockOrInlineItemFound = true; - } else { - invalidChildError(loc, nsURI, localName); } } diff --git a/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java b/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java index d296e1c5d..de779b011 100644 --- a/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java +++ b/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java @@ -28,6 +28,7 @@ import java.util.Iterator; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.fop.fo.FOElementMapping; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FOText; import org.apache.fop.fo.FObjMixed; @@ -140,7 +141,6 @@ public class LayoutManagerMapping implements LayoutManagerMaker { makers.put(TableHeader.class, new Maker()); makers.put(Wrapper.class, new WrapperLayoutManagerMaker()); makers.put(Title.class, new InlineLayoutManagerMaker()); - makers.put(Destination.class, new Maker()); } /** @@ -149,7 +149,13 @@ public class LayoutManagerMapping implements LayoutManagerMaker { public void makeLayoutManagers(FONode node, List lms) { Maker maker = (Maker) makers.get(node.getClass()); if (maker == null) { - log.error("No LayoutManager maker for class " + node.getClass()); + if (FOElementMapping.URI.equals(node.getNamespaceURI())) { + log.error("No LayoutManager maker for class " + node.getClass()); + } else { + if (log.isDebugEnabled()) { + log.debug("Skipping the creation of a layout manager for " + node.getClass()); + } + } } else { maker.make(node, lms); } |