From a93ce40b9a41760b54fde89f3e8b31d924c866f6 Mon Sep 17 00:00:00 2001 From: Glenn Adams Date: Sat, 7 Apr 2012 20:23:56 +0000 Subject: [PATCH] Bugzilla #49763: Incorrect message when encountering a block in an inline in a footnote git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1310853 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/fo/FONode.java | 46 ++++++++++++++----- src/java/org/apache/fop/fo/flow/Inline.java | 3 +- .../fop/render/ps/NativeTextHandler.java | 1 - status.xml | 3 ++ 4 files changed, 38 insertions(+), 15 deletions(-) diff --git a/src/java/org/apache/fop/fo/FONode.java b/src/java/org/apache/fop/fo/FONode.java index 99d133f16..c66259f11 100644 --- a/src/java/org/apache/fop/fo/FONode.java +++ b/src/java/org/apache/fop/fo/FONode.java @@ -404,6 +404,27 @@ public abstract class FONode implements Cloneable { return new OneCharIterator(CharUtilities.CODE_EOT); } + /** + * Helper function to obtain standard usage prefix for FOP related + * namespace URIs. + * @param namespaceURI URI of node found + * (e.g., "http://www.w3.org/1999/XSL/Format") + * @return the prefix or null if none + */ + public static String getNodePrefix(String namespaceURI) { + if (namespaceURI.equals(FOElementMapping.URI)) { + return "fo"; + } else if (namespaceURI.equals(ExtensionElementMapping.URI)) { + return "fox"; + } else if (namespaceURI.equals(InternalElementMapping.URI)) { + return "foi"; + } else if (namespaceURI.equals(SVGElementMapping.URI)) { + return "svg"; + } else { + return null; + } + } + /** * Helper function to standardize the names of all namespace URI - local * name pairs in text messages. @@ -416,14 +437,9 @@ public abstract class FONode implements Cloneable { * with the unabbreviated URI otherwise. */ public static String getNodeString(String namespaceURI, String localName) { - if (namespaceURI.equals(FOElementMapping.URI)) { - return "fo:" + localName; - } else if (namespaceURI.equals(ExtensionElementMapping.URI)) { - return "fox:" + localName; - } else if (namespaceURI.equals(InternalElementMapping.URI)) { - return "foi:" + localName; // used FOP internally for accessibility - } else if (namespaceURI.equals(SVGElementMapping.URI)) { - return "svg:" + localName; + String prefix = getNodePrefix ( namespaceURI ); + if ( prefix != null ) { + return prefix + ":" + localName; } else { return "(Namespace URI: \"" + namespaceURI + "\", " + "Local Name: \"" + localName + "\")"; @@ -527,16 +543,22 @@ public abstract class FONode implements Cloneable { * * @param loc org.xml.sax.Locator object of the error (*not* parent node) * @param parentName the name of the parent element - * @param nsURI namespace URI of incoming invalid node - * @param lName local name (i.e., no prefix) of incoming node + * @param nsURI namespace URI of incoming offending node + * @param lName local name (i.e., no prefix) of incoming offending node * @param ruleViolated name of the rule violated (used to lookup a resource in a bundle) * @throws ValidationException the validation error provoked by the method call */ protected void invalidChildError(Locator loc, String parentName, String nsURI, String lName, String ruleViolated) throws ValidationException { - getFOValidationEventProducer().invalidChild(this, parentName, - new QName(nsURI, lName), ruleViolated, loc); + String prefix = getNodePrefix ( nsURI ); + QName qn; // qualified name of offending node + if ( prefix != null ) { + qn = new QName(nsURI, prefix, lName); + } else { + qn = new QName(nsURI, lName); + } + getFOValidationEventProducer().invalidChild(this, parentName, qn, ruleViolated, loc); } /** diff --git a/src/java/org/apache/fop/fo/flow/Inline.java b/src/java/org/apache/fop/fo/flow/Inline.java index 3a9583580..941850cdd 100644 --- a/src/java/org/apache/fop/fo/flow/Inline.java +++ b/src/java/org/apache/fop/fo/flow/Inline.java @@ -118,8 +118,7 @@ public class Inline extends InlineLevel { invalidChildError(loc, nsURI, localName); } else if (!canHaveBlockLevelChildren && isBlockItem(nsURI, localName) && !isNeutralItem(nsURI, localName)) { - invalidChildError(loc, getParent().getName(), nsURI, getName(), - "rule.inlineContent"); + invalidChildError(loc, getName(), nsURI, localName, "rule.inlineContent"); } else { blockOrInlineItemFound = true; } diff --git a/src/java/org/apache/fop/render/ps/NativeTextHandler.java b/src/java/org/apache/fop/render/ps/NativeTextHandler.java index a31d828b1..5a39842fb 100644 --- a/src/java/org/apache/fop/render/ps/NativeTextHandler.java +++ b/src/java/org/apache/fop/render/ps/NativeTextHandler.java @@ -31,7 +31,6 @@ import org.apache.xmlgraphics.ps.PSGenerator; import org.apache.fop.fonts.Font; import org.apache.fop.fonts.FontInfo; import org.apache.fop.fonts.FontSetup; -import org.apache.fop.fonts.FontTriplet; /** * Specialized TextHandler implementation that the PSGraphics2D class delegates to to paint text diff --git a/status.xml b/status.xml index a00e11f59..140016156 100644 --- a/status.xml +++ b/status.xml @@ -62,6 +62,9 @@ documents. Example: the fix of marks layering will be such a case when it's done. --> + + Incorrect message when encountering a block in an inline in a footnote. + Specified rule-thickness applies only when leader-pattern is rule, otherwise should use default thickness. -- 2.39.5