소스 검색

Fixes for issues introduced with fox:destination:

DestinationElementMapping masks ExtensionElementMapping. That caused the tests for widow/orphan extension on tables to fail.
Improved Block child validation code (will need to be done for all FOs where fox:destination should be valid. Currently works only as child of fo:block or above fo:page-sequence where no layout managers are constructed.
No LMMaker for fox:destination. Improved the handling there so adding the extension element to the list there isn't necessary.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@525526 13f79535-47bb-0310-9956-ffa450edef68
pull/36/head
Jeremias Maerki 17 년 전
부모
커밋
b151c4958d

+ 1
- 2
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
org.apache.fop.render.pcl.extensions.PCLElementMapping

+ 10
- 0
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";

+ 14
- 10
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;
}

+ 0
- 89
src/java/org/apache/fop/fo/extensions/destination/DestinationElementMapping.java 파일 보기

@@ -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());
}
}

+ 19
- 20
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);
}
}


+ 8
- 2
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);
}

Loading…
취소
저장