deweese 2005/03/02 17:19:53 Modified: . build.xml sources/org/apache/batik/bridge SVGAltGlyphElementBridge.java SVGAltGlyphHandler.java SVGTextElementBridge.java SVGTextPathElementBridge.java SVGUseElementBridge.java sources/org/apache/batik/dom AbstractAttr.java AbstractDocument.java AbstractElement.java GenericDocument.java sources/org/apache/batik/dom/svg SVGOMDocument.java sources/org/apache/batik/svggen/font SVGFont.java Log: 1) Removed use of 'getTagName' to use 'getLocalName' to avoid issues with prefixed svg elements. 2) Fixed a mistake in the generation of SVG fonts that include arabic forms (PR 33733) 3) Moved closer to DOM 3 idea of 'idness' for attributes. This lets me turn of 'idness' for cloned 'use' subtrees. This avoids cluttering the global hash with bogus 'id' instances. No one should ever match these 'ids' anyways. PR: 33733 Revision Changes Path 1.161 +2 -2 xml-batik/build.xml Index: build.xml =================================================================== RCS file: /home/cvs/xml-batik/build.xml,v retrieving revision 1.160 retrieving revision 1.161 diff -u -r1.160 -r1.161 --- build.xml 28 Feb 2005 17:37:18 -0000 1.160 +++ build.xml 3 Mar 2005 01:19:52 -0000 1.161 @@ -1127,7 +1127,7 @@ description="Runs test suite whose file or uri is passed as an input"> <java fork="yes" classname="${class-prefix}.test.xml.XMLTestSuiteRunner"> - <jvmarg value="-Xincgc" /> +<!-- <jvmarg value="-Xincgc" /> --> <!-- <jvmarg value="-Xrunhprof:format=b" /> --> <!-- <jvmarg value="-Xrunhprof:net=localhost:1234,format=b" /> --> <jvmarg value="-Xmx512m"/> <jvmarg value="-Xms64m"/> 1.18 +11 -7 xml-batik/sources/org/apache/batik/bridge/SVGAltGlyphElementBridge.java Index: SVGAltGlyphElementBridge.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGAltGlyphElementBridge.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- SVGAltGlyphElementBridge.java 22 Feb 2005 09:12:57 -0000 1.17 +++ SVGAltGlyphElementBridge.java 3 Mar 2005 01:19:52 -0000 1.18 @@ -92,9 +92,11 @@ // couldn't find the referenced element return null; } + if (!SVG_NAMESPACE_URI.equals(refElement.getNamespaceURI())) + return null; // Not an SVG element. // if the referenced element is a glyph - if (refElement.getTagName().equals(SVG_GLYPH_TAG)) { + if (refElement.getLocalName().equals(SVG_GLYPH_TAG)) { Glyph glyph = getGlyph(ctx, uri, altGlyphElement, fontSize, aci); @@ -109,7 +111,7 @@ } // else should be an altGlyphDef element - if (refElement.getTagName().equals(SVG_ALT_GLYPH_DEF_TAG)) { + if (refElement.getLocalName().equals(SVG_ALT_GLYPH_DEF_TAG)) { // if not local import the referenced altGlyphDef // into the current document @@ -142,7 +144,9 @@ for (int i = 0; i < numAltGlyphDefChildren; i++) { Node altGlyphChild = altGlyphDefChildren.item(i); if (altGlyphChild.getNodeType() == Node.ELEMENT_NODE) { - if (((Element)altGlyphChild).getTagName().equals(SVG_GLYPH_REF_TAG)) { + Element agc = (Element)altGlyphChild; + if (SVG_NAMESPACE_URI.equals(agc.getNamespaceURI()) && + SVG_GLYPH_REF_TAG.equals(agc.getLocalName())) { containsGlyphRefNodes = true; break; } @@ -269,12 +273,12 @@ } } - if (refGlyphElement == null - || !refGlyphElement.getTagName().equals(SVG_GLYPH_TAG)) { + if ((refGlyphElement == null) || + (!SVG_NAMESPACE_URI.equals(refGlyphElement.getNamespaceURI())) || + (!SVG_GLYPH_TAG.equals(refGlyphElement.getLocalName()))) // couldn't find the referenced glyph element, // or referenced element not a glyph return null; - } // see if the referenced glyph element is local SVGOMDocument document 1.10 +3 -2 xml-batik/sources/org/apache/batik/bridge/SVGAltGlyphHandler.java Index: SVGAltGlyphHandler.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGAltGlyphHandler.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- SVGAltGlyphHandler.java 18 Aug 2004 07:12:32 -0000 1.9 +++ SVGAltGlyphHandler.java 3 Mar 2005 01:19:52 -0000 1.10 @@ -64,7 +64,8 @@ (FontRenderContext frc, float fontSize, AttributedCharacterIterator aci) { try { - if (textElement.getTagName().equals(SVG_ALT_GLYPH_TAG)) { + if (SVG_NAMESPACE_URI.equals(textElement.getNamespaceURI()) && + SVG_ALT_GLYPH_TAG.equals(textElement.getLocalName())) { SVGAltGlyphElementBridge altGlyphBridge = (SVGAltGlyphElementBridge)ctx.getBridge(textElement); Glyph[] glyphArray = altGlyphBridge.createAltGlyphArray 1.104 +15 -12 xml-batik/sources/org/apache/batik/bridge/SVGTextElementBridge.java Index: SVGTextElementBridge.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGTextElementBridge.java,v retrieving revision 1.103 retrieving revision 1.104 diff -u -r1.103 -r1.104 --- SVGTextElementBridge.java 6 Feb 2005 00:58:47 -0000 1.103 +++ SVGTextElementBridge.java 3 Mar 2005 01:19:52 -0000 1.104 @@ -87,12 +87,16 @@ protected final static Integer ZERO = new Integer(0); public static final - AttributedCharacterIterator.Attribute TEXT_COMPOUND_DELIMITER - = GVTAttributedCharacterIterator.TextAttribute.TEXT_COMPOUND_DELIMITER; + AttributedCharacterIterator.Attribute TEXT_COMPOUND_DELIMITER = + GVTAttributedCharacterIterator.TextAttribute.TEXT_COMPOUND_DELIMITER; - public static final AttributedCharacterIterator.Attribute PAINT_INFO - = GVTAttributedCharacterIterator.TextAttribute.PAINT_INFO; + public static final AttributedCharacterIterator.Attribute PAINT_INFO = + GVTAttributedCharacterIterator.TextAttribute.PAINT_INFO; + public static final + AttributedCharacterIterator.Attribute ALT_GLYPH_HANDLER = + GVTAttributedCharacterIterator.TextAttribute.ALT_GLYPH_HANDLER; + protected AttributedString laidoutText; @@ -1357,11 +1361,11 @@ Map result = new HashMap(); String s; float f; - - if (element.getTagName().equals(SVG_ALT_GLYPH_TAG)) { - result.put - (GVTAttributedCharacterIterator.TextAttribute.ALT_GLYPH_HANDLER, - new SVGAltGlyphHandler(ctx, element)); + + if (SVG_NAMESPACE_URI.equals(element.getNamespaceURI()) && + element.getLocalName().equals(SVG_ALT_GLYPH_TAG)) { + result.put(ALT_GLYPH_HANDLER, + new SVGAltGlyphHandler(ctx, element)); } if (textPath != null) { @@ -2651,8 +2655,7 @@ aci.setIndex(info.characterIndex); //check is it is a altGlyph - if (aci.getAttribute(GVTAttributedCharacterIterator. - TextAttribute.ALT_GLYPH_HANDLER) != null){ + if (aci.getAttribute(ALT_GLYPH_HANDLER) != null){ info.glyphIndexStart = 0; info.glyphIndexEnd = info.layout.getGlyphCount()-1; } else { 1.8 +4 -2 xml-batik/sources/org/apache/batik/bridge/SVGTextPathElementBridge.java Index: SVGTextPathElementBridge.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGTextPathElementBridge.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- SVGTextPathElementBridge.java 18 Aug 2004 07:12:36 -0000 1.7 +++ SVGTextPathElementBridge.java 3 Mar 2005 01:19:53 -0000 1.8 @@ -64,7 +64,9 @@ String uri = XLinkSupport.getXLinkHref(textPathElement); Element pathElement = ctx.getReferencedElement(textPathElement, uri); - if (pathElement == null || !pathElement.getTagName().equals(SVG_PATH_TAG)) { + if ((pathElement == null) || + (!SVG_NAMESPACE_URI.equals(pathElement.getNamespaceURI())) || + (!pathElement.getLocalName().equals(SVG_PATH_TAG))) { // couldn't find the referenced element // or the referenced element was not a path throw new BridgeException(textPathElement, ERR_URI_BAD_TARGET, 1.47 +3 -4 xml-batik/sources/org/apache/batik/bridge/SVGUseElementBridge.java Index: SVGUseElementBridge.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGUseElementBridge.java,v retrieving revision 1.46 retrieving revision 1.47 diff -u -r1.46 -r1.47 --- SVGUseElementBridge.java 15 Dec 2004 10:50:29 -0000 1.46 +++ SVGUseElementBridge.java 3 Mar 2005 01:19:53 -0000 1.47 @@ -127,9 +127,8 @@ } // import or clone the referenced element in current document - Element localRefElement = (isLocal) - ? (Element)refElement.cloneNode(true) - : (Element)document.importNode(refElement, true); + Element localRefElement = + (Element)document.importNode(refElement, true, true); if (SVG_SYMBOL_TAG.equals(localRefElement.getLocalName())) { // The referenced 'symbol' and its contents are deep-cloned into 1.15 +13 -1 xml-batik/sources/org/apache/batik/dom/AbstractAttr.java Index: AbstractAttr.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/AbstractAttr.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- AbstractAttr.java 22 Feb 2005 09:12:57 -0000 1.14 +++ AbstractAttr.java 3 Mar 2005 01:19:53 -0000 1.15 @@ -42,6 +42,11 @@ protected boolean unspecified; /** + * Whether this attribute is an ID attribute + */ + protected boolean isIdAttr; + + /** * The owner element. */ protected AbstractElement ownerElement; @@ -69,11 +74,18 @@ } } + public boolean isId() { return isIdAttr; } + + public void setIsId(boolean isId) { + isIdAttr = isId; + } + /** * Sets the node name. */ public void setNodeName(String v) { nodeName = v; + isIdAttr = ownerDocument.isId(this); } /** 1.27 +21 -17 xml-batik/sources/org/apache/batik/dom/AbstractDocument.java Index: AbstractDocument.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/AbstractDocument.java,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- AbstractDocument.java 28 Feb 2005 17:37:18 -0000 1.26 +++ AbstractDocument.java 3 Mar 2005 01:19:53 -0000 1.27 @@ -239,19 +239,21 @@ */ public Node importNode(Node importedNode, boolean deep) throws DOMException { - /* TED: This is bad because it usually does not create the - * the proper subclass of Element for the document it is - * being imported into based on namespace/tag name. - */ - /** - if (importedNode instanceof AbstractNode) { - AbstractNode an = (AbstractNode)importedNode; - return (deep) - ? an.deepExport(an.cloneNode(false), this) - : an.export(an.cloneNode(false), this); - } - */ + return importNode(importedNode, deep, false); + } + /** + * Imports the given node 'importNode' to this document. + * It does so deeply if 'deep' is set to true. + * It will not mark id attributes as id's if 'trimId' is set false. + * this is used primarily for the clone trees of the 'use' element + * so they don't clutter the hashtable. + */ + public Node importNode(Node importedNode, boolean deep, boolean trimId) { + /* + * The trimming of id's is used by the 'use' element to keep + * down the amount of 'bogus' id's in the hashtable. + */ Node result; switch (importedNode.getNodeType()) { case ELEMENT_NODE: @@ -263,9 +265,11 @@ int len = attr.getLength(); for (int i = 0; i < len; i++) { Attr a = (Attr)attr.item(i); - if (a.getSpecified()) { - e.setAttributeNodeNS((Attr)importNode(a, true)); - } + if (!a.getSpecified()) continue; + AbstractAttr aa = (AbstractAttr)importNode(a, true); + if (trimId && aa.isId()) + aa.setIsId(false); // don't consider this an Id. + e.setAttributeNodeNS(aa); } } break; @@ -337,7 +341,7 @@ return n; } - public abstract boolean isID(Attr node); + public abstract boolean isId(Attr node); /** * <b>DOM</b>: Implements [EMAIL PROTECTED] 1.28 +4 -4 xml-batik/sources/org/apache/batik/dom/AbstractElement.java Index: AbstractElement.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/AbstractElement.java,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- AbstractElement.java 28 Feb 2005 17:37:18 -0000 1.27 +++ AbstractElement.java 3 Mar 2005 01:19:53 -0000 1.28 @@ -489,19 +489,19 @@ String newv, short change) { switch (change) { case MutationEvent.ADDITION: - if (ownerDocument.isID(node)) + if (((AbstractAttr)node).isId()) ownerDocument.addIdEntry(this, newv); attrAdded(node, newv); break; case MutationEvent.MODIFICATION: - if (ownerDocument.isID(node)) + if (((AbstractAttr)node).isId()) ownerDocument.updateIdEntry(this, oldv, newv); attrModified(node, oldv, newv); break; default: // MutationEvent.REMOVAL: - if (ownerDocument.isID(node)) + if (((AbstractAttr)node).isId()) ownerDocument.removeIdEntry(this, oldv); attrRemoved(node, oldv); } 1.11 +2 -2 xml-batik/sources/org/apache/batik/dom/GenericDocument.java Index: GenericDocument.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/GenericDocument.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- GenericDocument.java 28 Feb 2005 17:37:18 -0000 1.10 +++ GenericDocument.java 3 Mar 2005 01:19:53 -0000 1.11 @@ -79,7 +79,7 @@ * Returns true if the given Attr node represents an 'id' * for this document. */ - public boolean isID(Attr node) { + public boolean isId(Attr node) { if (node.getNamespaceURI() != null) return false; return ATTR_ID.equals(node.getNodeName()); } 1.57 +2 -2 xml-batik/sources/org/apache/batik/dom/svg/SVGOMDocument.java Index: SVGOMDocument.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/svg/SVGOMDocument.java,v retrieving revision 1.56 retrieving revision 1.57 diff -u -r1.56 -r1.57 --- SVGOMDocument.java 28 Feb 2005 17:37:18 -0000 1.56 +++ SVGOMDocument.java 3 Mar 2005 01:19:53 -0000 1.57 @@ -301,7 +301,7 @@ * Returns true if the given Attr node represents an 'id' * for this document. */ - public boolean isID(Attr node) { + public boolean isId(Attr node) { if (node.getNamespaceURI() != null) return false; return SVG_ID_ATTRIBUTE.equals(node.getNodeName()); } 1.9 +9 -5 xml-batik/sources/org/apache/batik/svggen/font/SVGFont.java Index: SVGFont.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/svggen/font/SVGFont.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- SVGFont.java 30 Oct 2004 18:38:05 -0000 1.8 +++ SVGFont.java 3 Mar 2005 01:19:53 -0000 1.9 @@ -504,7 +504,8 @@ arabInitGlyphIndex, defaultHorizAdvanceX, // " arabic-form=\"initial\"", - SVG_ARABIC_FORM_ATTRIBUTE + XML_EQUAL_QUOT + SVG_INITIAL_VALUE + XML_CHAR_QUOT, + (XML_SPACE + SVG_ARABIC_FORM_ATTRIBUTE + XML_EQUAL_QUOT + + SVG_INITIAL_VALUE + XML_CHAR_QUOT), code)); // sb.append("\r\n"); sb.append(EOL); @@ -517,8 +518,9 @@ font.getGlyph(arabMediGlyphIndex), arabMediGlyphIndex, defaultHorizAdvanceX, - SVG_ARABIC_FORM_ATTRIBUTE + XML_EQUAL_QUOT + SVG_MEDIAL_VALUE + XML_CHAR_QUOT, // " arabic-form=\"medial\"", + (XML_SPACE + SVG_ARABIC_FORM_ATTRIBUTE + XML_EQUAL_QUOT + + SVG_MEDIAL_VALUE + XML_CHAR_QUOT), code)); // sb.append("\r\n"); sb.append(EOL); @@ -531,8 +533,9 @@ font.getGlyph(arabTermGlyphIndex), arabTermGlyphIndex, defaultHorizAdvanceX, - SVG_ARABIC_FORM_ATTRIBUTE + XML_EQUAL_QUOT + SVG_TERMINAL_VALUE + XML_CHAR_QUOT, // " arabic-form=\"terminal\"", + (XML_SPACE + SVG_ARABIC_FORM_ATTRIBUTE + XML_EQUAL_QUOT + + SVG_TERMINAL_VALUE + XML_CHAR_QUOT), code)); // sb.append("\r\n"); sb.append(EOL); @@ -545,8 +548,9 @@ glyph, glyphIndex, defaultHorizAdvanceX, - SVG_ARABIC_FORM_ATTRIBUTE + XML_EQUAL_QUOT + SVG_ISOLATED_VALUE + XML_CHAR_QUOT, // " arabic-form=\"isolated\"", + (XML_SPACE + SVG_ARABIC_FORM_ATTRIBUTE + XML_EQUAL_QUOT + + SVG_ISOLATED_VALUE + XML_CHAR_QUOT), code)); } else { sb.append(getGlyphAsSVG(
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]