diff options
author | Keiron Liddle <keiron@apache.org> | 2002-02-20 09:30:40 +0000 |
---|---|---|
committer | Keiron Liddle <keiron@apache.org> | 2002-02-20 09:30:40 +0000 |
commit | 06edcc8412eaacb01bb7628a128ee382396c0629 (patch) | |
tree | 0b61e6c216d475dae741d00468bdf0e78f3c9870 /src/org/apache/fop/svg | |
parent | bdabe33342eb965037dbfcd5f50e0bc2d6160bf8 (diff) | |
download | xmlgraphics-fop-06edcc8412eaacb01bb7628a128ee382396c0629.tar.gz xmlgraphics-fop-06edcc8412eaacb01bb7628a128ee382396c0629.zip |
made svg context independant so that the svg document does not
hold onto the fo tree
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194656 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org/apache/fop/svg')
-rw-r--r-- | src/org/apache/fop/svg/SVGElement.java | 97 |
1 files changed, 55 insertions, 42 deletions
diff --git a/src/org/apache/fop/svg/SVGElement.java b/src/org/apache/fop/svg/SVGElement.java index c30177de8..f369ab466 100644 --- a/src/org/apache/fop/svg/SVGElement.java +++ b/src/org/apache/fop/svg/SVGElement.java @@ -84,39 +84,17 @@ public class SVGElement extends SVGObj { 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 @@ public class SVGElement extends SVGObj { 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 @@ public class SVGElement extends SVGObj { 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 @@ public class SVGElement extends SVGObj { } } } + +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"); + } +} + |