Dear all,

we have the following bug in in Papyrus

Bug 521232 - [All diagrams] NPE if SVG unit is not in pixels

This bug is caused by calling getValue() in the following way (simplified to ease explanation)

SVGSVGElement svgRoot = svgDocument.getRootElement();
SVGAnimatedLength width = svgRoot.getWidth();
SVGLength baseWidth = width.getBaseVal();
if (baseWidth != null) {
   svgWidth = baseWidth.getValue();   // NPE occurs here
   ...

The NPE during the call of getValue occurs, if the svgRoot above belongs to an SVG file created with inkscape and units are in mm (default in Europe). A sample file can be downloaded from the Papyrus forum, see https://www.eclipse.org/forums/index.php/m/1771137/#msg_1771137

Thread [main] (Suspended (exception NullPointerException))   
    AbstractSVGLength$DefaultContext.getPixelUnitToMillimeter() line: not available [local variables unavailable]   
    UnitProcessor.svgToUserSpace(float, short, short, UnitProcessor$Context) line: not available
    AbstractSVGAnimatedLength$BaseSVGLength(AbstractSVGLength).getValue() line: not available [local variables unavailable]
    LinkLFSVGNodePlateFigure(SVGNodePlateFigure).getSvgDimension(SVGDocument) line: 212
    ...


value of baseWidth in case of error.
AbstractSVGAnimatedLength$BaseSVGLength  (id=1092)
    unitType    1   
    valid    false   
    value    0.0  



Yet the code works, if getValueInSpecifiedUnits() instead of getValue() is used. Thus, my question is: do we use batik in a wrong way, e.g.should be always getValueInSpecifiedUnits or is this a bug in batik which we should report?

Best regards

Ansgar


PS: The SVG tag flowRoot seems to be non-supported. Since that is a different issue, I will create a separate post.

--
Ansgar Radermacher                CEA/DRT/DILS/LISE
http://www-list.cea.fr/en/
phone: +33 16908 3812
mailto: ansgar.radermacher@cea.fr