aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache/fop/image/analyser
diff options
context:
space:
mode:
authorKeiron Liddle <keiron@apache.org>2001-09-25 12:32:36 +0000
committerKeiron Liddle <keiron@apache.org>2001-09-25 12:32:36 +0000
commitd62d9670a2c2c9c839677eb5a6a7cdd223b8f136 (patch)
tree3f2e173eea93725051b4d484863ba3849b45f9d7 /src/org/apache/fop/image/analyser
parente8ebf0309db50be59038219c1b88d0c50d12621b (diff)
downloadxmlgraphics-fop-d62d9670a2c2c9c839677eb5a6a7cdd223b8f136.tar.gz
xmlgraphics-fop-d62d9670a2c2c9c839677eb5a6a7cdd223b8f136.zip
gets the width and height in a better way
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194483 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org/apache/fop/image/analyser')
-rw-r--r--src/org/apache/fop/image/analyser/SVGReader.java29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/org/apache/fop/image/analyser/SVGReader.java b/src/org/apache/fop/image/analyser/SVGReader.java
index 1b3801470..57b0c0060 100644
--- a/src/org/apache/fop/image/analyser/SVGReader.java
+++ b/src/org/apache/fop/image/analyser/SVGReader.java
@@ -72,18 +72,27 @@ public class SVGReader extends AbstractImageReader {
new SAXSVGDocumentFactory(SVGImage.getParserName());
SVGDocument doc = factory.createDocument(uri, imageStream);
- // this is ugly preprocessing to get the width and height
+ Element e = ((SVGDocument)doc).getRootElement();
+ String s;
UserAgent userAgent = new MUserAgent(new AffineTransform());
- GVTBuilder builder = new GVTBuilder();
BridgeContext ctx = new BridgeContext(userAgent);
- GraphicsNode root;
- root = builder.build(ctx, doc);
- // get the 'width' and 'height' attributes of the SVG document
- width = (int) ctx.getDocumentSize().getWidth();
- height = (int) ctx.getDocumentSize().getHeight();
- ctx = null;
- builder = null;
- ///////
+ UnitProcessor.Context uctx = UnitProcessor.createContext(ctx, e);
+
+ // 'width' attribute - default is 100%
+ s = e.getAttributeNS(null, SVGOMDocument.SVG_WIDTH_ATTRIBUTE);
+ if (s.length() == 0) {
+ s = SVGOMDocument.SVG_SVG_WIDTH_DEFAULT_VALUE;
+ }
+ width = (int)UnitProcessor.svgHorizontalLengthToUserSpace
+ (s, SVGOMDocument.SVG_WIDTH_ATTRIBUTE, uctx);
+
+ // 'height' attribute - default is 100%
+ s = e.getAttributeNS(null, SVGOMDocument.SVG_HEIGHT_ATTRIBUTE);
+ if (s.length() == 0) {
+ s = SVGOMDocument.SVG_SVG_HEIGHT_DEFAULT_VALUE;
+ }
+ height = (int)UnitProcessor.svgVerticalLengthToUserSpace
+ (s, SVGOMDocument.SVG_HEIGHT_ATTRIBUTE, uctx);
return true;
} catch (NoClassDefFoundError ncdfe) {