deweese 2004/11/04 17:34:33 Modified: sources/org/apache/batik/css/engine CSSEngine.java SVGCSSEngine.java sources/org/apache/batik/dom/svg ExtensibleSVGDOMImplementation.java sources/org/apache/batik/transcoder SVGAbstractTranscoder.java Log: 1) Fixed width/height change onload bug in transcoders submitted by Simon Mieth. Thanks! 2) Fixed a bug with CSS shorthand properties not being set by presentation attributes. 3) ExtensibleSVGDOMImplementation now allows 'extension' elements in the SVG Namespace (they are always lower priority than 'buit ins'). Revision Changes Path 1.41 +34 -13 xml-batik/sources/org/apache/batik/css/engine/CSSEngine.java Index: CSSEngine.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/css/engine/CSSEngine.java,v retrieving revision 1.40 retrieving revision 1.41 diff -u -r1.40 -r1.41 --- CSSEngine.java 20 Aug 2004 19:29:47 -0000 1.40 +++ CSSEngine.java 5 Nov 2004 01:34:33 -0000 1.41 @@ -411,13 +411,18 @@ } if (hints) { - len = vm.length; - nonCSSPresentationalHints = new HashSet(); + nonCSSPresentationalHints = new HashSet(vm.length+sm.length); nonCSSPresentationalHintsNamespaceURI = hintsNS; - for (int i = len - 1; i >= 0; --i) { + len = vm.length; + for (int i = 0; i < len; i++) { String pn = vm[i].getPropertyName(); nonCSSPresentationalHints.add(pn); } + len = sm.length; + for (int i = 0; i < len; i++) { + String pn = sm[i].getPropertyName(); + nonCSSPresentationalHints.add(pn); + } } if (cssContext.isDynamic() && @@ -665,7 +670,7 @@ public StyleMap getCascadedStyleMap(CSSStylableElement elt, String pseudo) { int props = getNumberOfProperties(); - StyleMap result = new StyleMap(props); + final StyleMap result = new StyleMap(props); // Apply the user-agent style-sheet to the result. if (userAgentStyleSheet != null) { @@ -683,7 +688,28 @@ element = elt; try { - // Apply the non-CSS presentational hints to the result. + // Apply the non-CSS presentational hints to the result. + ShorthandManager.PropertyHandler ph = + new ShorthandManager.PropertyHandler() { + public void property(String pname, LexicalUnit lu, + boolean important) { + int idx = getPropertyIndex(pname); + if (idx != -1) { + ValueManager vm = valueManagers[idx]; + Value v = vm.createValue(lu, CSSEngine.this); + putAuthorProperty(result, idx, v, important, + StyleMap.NON_CSS_ORIGIN); + return; + } + idx = getShorthandIndex(pname); + if (idx == -1) + return; // Unknown property... + // Shorthand value + shorthandManagers[idx].setValues + (CSSEngine.this, this, lu, important); + } + }; + if (nonCSSPresentationalHints != null) { NamedNodeMap attrs = elt.getAttributes(); int len = attrs.getLength(); @@ -693,13 +719,8 @@ if (nonCSSPresentationalHints.contains(an)) { try { LexicalUnit lu; - int idx = getPropertyIndex(an); - lu = parser.parsePropertyValue - (attr.getNodeValue()); - ValueManager vm = valueManagers[idx]; - Value v = vm.createValue(lu, this); - putAuthorProperty(result, idx, v, false, - StyleMap.NON_CSS_ORIGIN); + lu = parser.parsePropertyValue(attr.getNodeValue()); + ph.property(an, lu, false); } catch (Exception e) { String m = e.getMessage(); if (m == null) m = ""; 1.8 +5 -13 xml-batik/sources/org/apache/batik/css/engine/SVGCSSEngine.java Index: SVGCSSEngine.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/css/engine/SVGCSSEngine.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- SVGCSSEngine.java 18 Aug 2004 07:12:48 -0000 1.7 +++ SVGCSSEngine.java 5 Nov 2004 01:34:33 -0000 1.8 @@ -147,12 +147,8 @@ private static ValueManager[] mergeArrays(ValueManager[] a1, ValueManager[] a2) { ValueManager[] result = new ValueManager[a1.length + a2.length]; - for (int i = 0; i < a1.length; i++) { - result[i] = a1[i]; - } - for (int i = 0; i < a2.length; i++) { - result[i + a1.length] = a2[i]; - } + System.arraycopy(a1, 0, result, 0, a1.length); + System.arraycopy(a2, 0, result, a1.length, a2.length); return result; } @@ -163,12 +159,8 @@ ShorthandManager[] a2) { ShorthandManager[] result = new ShorthandManager[a1.length + a2.length]; - for (int i = 0; i < a1.length; i++) { - result[i] = a1[i]; - } - for (int i = 0; i < a2.length; i++) { - result[i + a1.length] = a2[i]; - } + System.arraycopy(a1, 0, result, 0, a1.length); + System.arraycopy(a2, 0, result, a1.length, a2.length); return result; } 1.10 +14 -8 xml-batik/sources/org/apache/batik/dom/svg/ExtensibleSVGDOMImplementation.java Index: ExtensibleSVGDOMImplementation.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/svg/ExtensibleSVGDOMImplementation.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- ExtensibleSVGDOMImplementation.java 18 Aug 2004 07:13:13 -0000 1.9 +++ ExtensibleSVGDOMImplementation.java 5 Nov 2004 01:34:33 -0000 1.10 @@ -203,14 +203,20 @@ if (SVG_NAMESPACE_URI.equals(namespaceURI)) { String name = DOMUtilities.getLocalName(qualifiedName); ElementFactory ef = (ElementFactory)factories.get(name); - if (ef == null) { - throw document.createDOMException - (DOMException.NOT_FOUND_ERR, - "invalid.element", - new Object[] { namespaceURI, - qualifiedName }); + if (ef != null) + return ef.create(DOMUtilities.getPrefix(qualifiedName), + document); + if (customFactories != null) { + ElementFactory cef; + cef = (ElementFactory)customFactories.get(namespaceURI, name); + if (cef != null) + return cef.create(DOMUtilities.getPrefix(qualifiedName), + document); } - return ef.create(DOMUtilities.getPrefix(qualifiedName), document); + + throw document.createDOMException + (DOMException.NOT_FOUND_ERR, "invalid.element", + new Object[] { namespaceURI, qualifiedName }); } if (namespaceURI != null) { if (customFactories != null) { 1.21 +13 -16 xml-batik/sources/org/apache/batik/transcoder/SVGAbstractTranscoder.java Index: SVGAbstractTranscoder.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/transcoder/SVGAbstractTranscoder.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- SVGAbstractTranscoder.java 18 Aug 2004 07:15:41 -0000 1.20 +++ SVGAbstractTranscoder.java 5 Nov 2004 01:34:33 -0000 1.21 @@ -198,15 +198,24 @@ ((Boolean)hints.get(KEY_EXECUTE_ONLOAD)).booleanValue() && BaseScriptingEnvironment.isDynamicDocument(svgDoc)); - if (isDynamic) - ctx.setDynamicState(BridgeContext.DYNAMIC); - GraphicsNode gvtRoot; try { + if (isDynamic) + ctx.setDynamicState(BridgeContext.DYNAMIC); + gvtRoot = builder.build(ctx, svgDoc); + + // dispatch an 'onload' event if needed + if (ctx.isDynamic()) { + BaseScriptingEnvironment se; + se = new BaseScriptingEnvironment(ctx); + se.loadScripts(); + se.dispatchSVGLoadEvent(); + } } catch (BridgeException ex) { throw new TranscoderException(ex); } + // get the 'width' and 'height' attributes of the SVG document float docWidth = (float)ctx.getDocumentSize().getWidth(); float docHeight = (float)ctx.getDocumentSize().getHeight(); @@ -260,18 +269,6 @@ curTxf = new AffineTransform(); } else { curTxf = Px; - } - - try { - // dispatch an 'onload' event if needed - if (ctx.isDynamic()) { - BaseScriptingEnvironment se; - se = new BaseScriptingEnvironment(ctx); - se.loadScripts(); - se.dispatchSVGLoadEvent(); - } - } catch (BridgeException ex) { - throw new TranscoderException(ex); } this.root = gvtRoot;
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]