keiron      01/09/25 05:32:36

  Modified:    src/org/apache/fop/svg SVGElement.java
               src/org/apache/fop/image/analyser SVGReader.java
  Log:
  gets the width and height in a better way
  
  Revision  Changes    Path
  1.13      +20 -11    xml-fop/src/org/apache/fop/svg/SVGElement.java
  
  Index: SVGElement.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/svg/SVGElement.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- SVGElement.java   2001/09/24 07:31:52     1.12
  +++ SVGElement.java   2001/09/25 12:32:36     1.13
  @@ -1,5 +1,5 @@
   /*
  - * $Id: SVGElement.java,v 1.12 2001/09/24 07:31:52 keiron Exp $
  + * $Id: SVGElement.java,v 1.13 2001/09/25 12:32:36 keiron Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -138,19 +138,28 @@
           };
           ((SVGOMDocument)doc).setSVGContext(dc);
   
  -        // this is ugly preprocessing to get the width and height
  +        Element e = ((SVGDocument)doc).getRootElement();
  +        String s;
           SVGUserAgent userAgent = new SVGUserAgent(new AffineTransform());
           userAgent.setLogger(log);
  -        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
  -        float width = (float)ctx.getDocumentSize().getWidth();
  -        float height = (float)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;
  +        }
  +        float width = 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;
  +        }
  +        float height = UnitProcessor.svgVerticalLengthToUserSpace
  +                     (s, SVGOMDocument.SVG_HEIGHT_ATTRIBUTE, uctx);
   
           SVGArea svg = new SVGArea(fs, width, height);
           svg.setSVGDocument(doc);
  
  
  
  1.11      +20 -11    xml-fop/src/org/apache/fop/image/analyser/SVGReader.java
  
  Index: SVGReader.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/image/analyser/SVGReader.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- SVGReader.java    2001/09/24 07:31:52     1.10
  +++ SVGReader.java    2001/09/25 12:32:36     1.11
  @@ -1,5 +1,5 @@
   /*
  - * $Id: SVGReader.java,v 1.10 2001/09/24 07:31:52 keiron Exp $
  + * $Id: SVGReader.java,v 1.11 2001/09/25 12:32:36 keiron Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -72,18 +72,27 @@
                 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) {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to