You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ke...@apache.org on 2002/02/20 10:30:40 UTC

cvs commit: xml-fop/src/org/apache/fop/svg SVGElement.java

keiron      02/02/20 01:30:40

  Modified:    src/org/apache/fop/svg SVGElement.java
  Log:
  made svg context independant so that the svg document does not
  hold onto the fo tree
  
  Revision  Changes    Path
  1.20      +56 -43    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.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- SVGElement.java	15 Nov 2001 08:12:37 -0000	1.19
  +++ SVGElement.java	20 Feb 2002 09:30:40 -0000	1.20
  @@ -1,5 +1,5 @@
   /*
  - * $Id: SVGElement.java,v 1.19 2001/11/15 08:12:37 keiron Exp $
  + * $Id: SVGElement.java,v 1.20 2002/02/20 09:30:40 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.
  @@ -84,39 +84,17 @@
   
               this.fs = area.getFontState();
   
  -        final Element svgRoot = element;
  +        // TODO - change so doesn't hold onto fo,area tree
  +        Element svgRoot = element;
           /* create an SVG area */
           /* if width and height are zero, get the bounds of the content. */
  -        DefaultSVGContext dc = new DefaultSVGContext() {
  -            public float getPixelToMM() {
  -                // 72 dpi
  -                return 0.35277777777777777778f;
  -            }
  -
  -            public float getViewportWidth(Element e) throws IllegalStateException {
  -                if(e == svgRoot) {
  -                    ForeignObjectArea foa = (ForeignObjectArea)area;
  -                    if(!foa.isContentWidthAuto()) {
  -                        return foa.getContentWidth();
  -                    }
  -                }
  -                return super.getViewportWidth(e);
  -            }
  -
  -            public float getViewportHeight(Element e) throws IllegalStateException {
  -                if(e == svgRoot) {
  -                    ForeignObjectArea foa = (ForeignObjectArea)area;
  -                    if(!foa.isContentHeightAuto()) {
  -                        return foa.getContentHeight();
  -                    }
  -                }
  -                return super.getViewportHeight(e);
  -            }
  -
  -            public List getDefaultFontFamilyValue() {
  -                return FONT_FAMILY;
  -            }
  -        };
  +        FOPSVGContext dc = new FOPSVGContext();
  +        dc.svgRoot = element;
  +        ForeignObjectArea foa = (ForeignObjectArea)area;
  +        dc.cwauto = foa.isContentWidthAuto();
  +        dc.chauto = foa.isContentHeightAuto();
  +        dc.cwidth = foa.getContentWidth();
  +        dc.cheight = foa.getContentHeight();
           ((SVGOMDocument)doc).setSVGContext(dc);
   
           try {
  @@ -145,7 +123,6 @@
           svg.end();
   
           /* add the SVG area to the containing area */
  -        ForeignObjectArea foa = (ForeignObjectArea)area;
           foa.setObject(svg);
           foa.setIntrinsicWidth(svg.getWidth());
           foa.setIntrinsicHeight(svg.getHeight());
  @@ -164,16 +141,6 @@
           buildTopLevel(doc, element);
       }
   
  -    public final static List FONT_FAMILY;
  -    static {
  -        FONT_FAMILY = new ArrayList();
  -        FONT_FAMILY.add("Helvetica");
  -        FONT_FAMILY.add("Times");
  -        FONT_FAMILY.add("Courier");
  -        FONT_FAMILY.add("sans-serif");
  -        FONT_FAMILY.add("serif");
  -    }
  -
       public static Point2D getSize(FontState fs, Element svgRoot) {
           String str;
           UnitProcessor.Context ctx;
  @@ -267,3 +234,49 @@
           }
       }
   }
  +
  +class FOPSVGContext extends DefaultSVGContext {
  +        public boolean cwauto;
  +        public boolean chauto;
  +        public float cwidth;
  +        public float cheight;
  +        public Element svgRoot;
  +
  +            public float getPixelToMM() {
  +                // 72 dpi
  +                return 0.35277777777777777778f;
  +            }
  +
  +            public float getViewportWidth(Element e) throws IllegalStateException {
  +            if(e == svgRoot) {
  +                if(!cwauto) {
  +                   return cwidth;
  +                }
  +            }
  +                return super.getViewportWidth(e);
  +            }
  +
  +            public float getViewportHeight(Element e) throws IllegalStateException {
  +            if(e == svgRoot) {
  +                if(!chauto) {
  +                    return cheight;
  +                }
  +            }
  +                return super.getViewportHeight(e);
  +            }
  +
  +            public List getDefaultFontFamilyValue() {
  +                return FONT_FAMILY;
  +    }
  +
  +    public final static List FONT_FAMILY;
  +    static {
  +        FONT_FAMILY = new ArrayList();
  +        FONT_FAMILY.add("Helvetica");
  +        FONT_FAMILY.add("Times");
  +        FONT_FAMILY.add("Courier");
  +        FONT_FAMILY.add("sans-serif");
  +        FONT_FAMILY.add("serif");
  +    }
  +}
  +
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org