From: Glen Mazza Date: Sun, 21 Mar 2004 12:38:56 +0000 (+0000) Subject: 1.) Removed xsl file for property generation (no longer used, due to X-Git-Tag: Root_Temp_KnuthStylePageBreaking~795 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2e9f66f684d857e38a8d2ea5dd987936b79ba454;p=xmlgraphics-fop.git 1.) Removed xsl file for property generation (no longer used, due to Finn's work.) Removed build.xml entry. 2.) Disconnected the FOUserAgent from the SVGUserAgent. This will make the SVGUserAgent more portable although at the cost of a more complex constructor. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197467 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/build.xml b/build.xml index 4ea0154eb..416553ca4 100644 --- a/build.xml +++ b/build.xml @@ -218,10 +218,7 @@ list of possible build targets. - - - diff --git a/src/codegen/properties.xsl b/src/codegen/properties.xsl deleted file mode 100644 index e3e19beb3..000000000 --- a/src/codegen/properties.xsl +++ /dev/null @@ -1,1084 +0,0 @@ - - - - - - - - - - - - - - - - - /** Return object used to calculate base Length - * for percent specifications. - */ - public PercentBase getPercentBase(final FObj fo, final PropertyList propertyList) { - - - - return new LengthBase(fo, propertyList, LengthBase. - ); - - - - - - return new LengthBase(fo, propertyList, LengthBase.CUSTOM_BASE) { - public int getBaseLength() { - return ( - - ); - } - }); - - - - } - - - - - - protected boolean isAutoLengthAllowed() { - return true; - } - - - - - public Property checkEnumValues(String value) { - - - - - - - return super.checkEnumValues(value); - } - - - - - - - // Initialize hashtable of keywords - static HashMap s_htKeywords; - static { - s_htKeywords = new HashMap( - - ); - - - s_htKeywords.put(" - - ", " - - "); - - - } - - protected String checkValueKeywords(String keyword) { - String value = (String)s_htKeywords.get(keyword); - if (value == null) { - return super.checkValueKeywords(keyword); - } - else return value; - } - - - - - - - - - - - - - - - - - - - - - - // See if other value types are acceptable - protected Property convertPropertyDatatype( - Property p, PropertyList propertyList, FObj fo) { - - - - - - - - - - - - - - - - = p.get - - (); - if ( - - != null) { - return new - ( - - ); - } - - - return super.convertPropertyDatatype(p, propertyList, fo); - } - - - - - - - - - - - - - protected String getDefaultFor - - () { - return " - - "; - } - - - - - - - private Property m_defaultProp=null; - - - public Property make(PropertyList propertyList) throws FOPException { - - - - return make(propertyList, " - - ", propertyList.getParentFObj()); - - - - if (m_defaultProp == null) { - m_defaultProp=make(propertyList, " - - ", propertyList.getParentFObj()); - } - return m_defaultProp; - - - - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Maker - - - - - - - - - - - - - .Maker - - - - - - Property.Maker - - - - - - - - implements Constants - - - - package org.apache.fop.fo.properties; - - - - -import java.util.HashMap; - - - -import org.apache.fop.datatypes.*; - - -import org.apache.fop.fo.*; - - -import org.apache.fop.apps.FOPException; - - - -import org.apache.fop.fo.Constants; - - - -public class - - extends - - { - - - - - public interface Enums { - - - int - - = Constants. - - ; - - - - - - - - - public interface - - { - - - int - - = Constants. - - ; - - - } - - - } - - - - - - - protected final static EnumProperty s_prop - - = new EnumProperty( - - Enums. - - - ); - - - - - - - - - Enums - - - - - - - - - - - - - - - - - - - - Property.Maker - - - - - - - - static private class SP_ - - Maker extends - - - implements - - . - - - { - SP_ - - Maker(int sPropName) { - super(sPropName); - } - - - protected final static EnumProperty s_prop - - = new EnumProperty( - - ); - - - - - } - - final private static Property.Maker s_ - - Maker = - new SP_ - Maker( - - Constants.PR_ - - - - | - - Constants.CP_ - - - - ); - - - - final private static Property.Maker s_ - - Maker = - new - ( - - Constants.PR_ - - - - | - - Constants.CP_ - - - - ); - - - - - - - - static public Property.Maker maker(int propertyId) { - return new - - (propertyId); - } - - protected - - (int propId) { - super(propId); - - - m_shorthandMaker= getSubpropMaker(Constants.CP_ - - - - ); - - - } - - - - - Property.Maker m_shorthandMaker; - - public Property checkEnumValues(String value) { - return m_shorthandMaker.checkEnumValues(value); - } - - protected boolean isCompoundMaker() { - return true; - } - - protected Property.Maker getSubpropMaker(int subpropId) { - - - - - - - - if (subpropId == Constants.CP_ - - - - ) - return s_ - - Maker; - - - return super.getSubpropMaker(subpropId); - } - - protected Property setSubprop(Property baseProp, int subpropId, - Property subProp) { - - - val = baseProp.get - - (); - // Do some type checking??? - // Check if one of our subproperties??? - val.setComponent(subpropId, subProp, false); - return baseProp; - } - - public Property getSubpropValue(Property baseProp, int subpropId) { - - - val = baseProp.get - - (); - return val.getComponent(subpropId); - } - - - - - - public Property make(PropertyList propertyList) throws FOPException { - return makeCompound(propertyList, propertyList.getParentFObj()); - } - - - - private Property m_defaultProp=null; - public Property make(PropertyList propertyList) throws FOPException { - if (m_defaultProp == null) { - m_defaultProp=makeCompound( - propertyList, propertyList.getParentFObj()); - } - return m_defaultProp; - } - - - - - protected Property makeCompound(PropertyList pList, FObj fo) throws FOPException { - - p = new - - (); - Property subProp; - - - - - - - - // set default for subprop - - - subProp = getSubpropMaker(Constants.CP_ - - - - ).make(pList, getDefaultFor - - (), fo); - p.setComponent(Constants.CP_ - - - - , subProp, true); - - - return new - - (p); - } - - - - - - - - - - protected String getDefaultFor - - () { - - - - return " - - "; - - - - return " - - "; - - - - return ""; - - - - } - - - - /** Set the appropriate components when the "base" property is set. */ - public Property convertProperty(Property p, PropertyList pList,FObj fo) - throws FOPException { - if (p instanceof - - ) return p; - if (! (p instanceof EnumProperty)) { - // delegate to the subprop maker to do conversions - p = m_shorthandMaker.convertProperty(p,pList,fo); - } - if (p != null) { - Property prop = makeCompound(pList, fo); - - - pval = prop.get - - (); - - - pval.setComponent(Constants.CP_ - - - - , p, false); - - - return prop; - } - else return null; - - - } - - - - - - - public boolean isInherited() { - return - - ; - } - - - - - - - public boolean inheritsSpecified() { - return true; - } - - - - - - - - public Property compute(PropertyList propertyList) { - Property computedProperty = null; - Property correspondingProperty = propertyList.get(Constants.PR_ - - - - ); - if (correspondingProperty != null) { - int correspondingValue = correspondingProperty.getEnum(); - - - if (correspondingValue == Constants. - - ) - computedProperty = new EnumProperty( - - ); - else - - - ; - } - return computedProperty; - } - - - - - - - - public boolean isCorrespondingForced(PropertyList propertyList) { - FObj parentFO = propertyList.getParentFObj(); - - - if (propertyList.getExplicit( - - ) != null) - return true; - - - return false; - } - - - - - public Property compute(PropertyList propertyList) throws FOPException { - FObj parentFO = propertyList.getParentFObj(); - Property p=null; - - - - // Make sure the property is set before calculating it! - if (propertyList.getExplicitOrShorthand( - - ) == null) - return p; - StringBuffer sbExpr=new StringBuffer(); - sbExpr.setLength(0); - - - p = make(propertyList, sbExpr.toString(), propertyList.getParentFObj()); - - - - p= propertyList.getExplicitOrShorthand( - - ); - - - - if (p != null) { - p = convertProperty(p, propertyList, parentFO ); - } - - - else p = makeCompound(propertyList, parentFO); - - Property subprop; - - - - - - subprop = getSubpropMaker(" - - "). - make(propertyList, sbExpr.toString(), parentFO); - - - - subprop = propertyList.getExplicitOrShorthand( - - ); - - - - if (subprop != null) { - setSubprop(p, Constants.CP_ - - - - , subprop); - } - - - - return p; - } - - - - - - - public Property getShorthand(PropertyList propertyList) { - Property p = null; - ListProperty listprop; - - - - if (p == null) { - listprop = - (ListProperty)propertyList.getExplicit(Constants.PR_ - - - - ); - if (listprop != null) { - // Get a parser for the shorthand to set the individual properties - ShorthandParser shparser = - new - - (listprop); - p = shparser.getValueForProperty( - getPropId(), this, propertyList); - } - } - - - return p; - } - - - - - -} - - - - - - - - sbExpr.append("_fop-property-value("); - - - sbExpr.append(")"); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - UNKNOWN - - - - - - - - sbExpr.append(" - - "); - - - - - - - - - - parentFO.propertyList - - - propertyList - - - .wmMap(Constants.PR_ - - - - , Constants.PR_ - - - - , Constants.PR_ - - - - ) - - - - - - - - - - - - - - sbExpr.append(propertyList.wmRelToAbs(PropertyList. - - )); - - - - - sbExpr.append(parentFO.propertyList.wmRelToAbs(PropertyList. - - )); - - - - - sbExpr.append(propertyList.wmAbsToRel(PropertyList. - - )); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Conflict between subproperty datatypes: - != - - - - - - - - - - - - - if (value.equals(" - - ")) { - return s_prop - - ; - } - - - - - - - diff --git a/src/java/org/apache/fop/image/analyser/SVGReader.java b/src/java/org/apache/fop/image/analyser/SVGReader.java index 7ffd6194a..c7382f3f1 100644 --- a/src/java/org/apache/fop/image/analyser/SVGReader.java +++ b/src/java/org/apache/fop/image/analyser/SVGReader.java @@ -27,6 +27,9 @@ import java.awt.geom.AffineTransform; import org.w3c.dom.Element; import org.w3c.dom.svg.SVGDocument; +// Avalon +import org.apache.avalon.framework.logger.Logger; + // Batik import org.apache.batik.dom.svg.SAXSVGDocumentFactory; import org.apache.batik.dom.svg.SVGOMDocument; @@ -87,7 +90,8 @@ public class SVGReader implements ImageReader { if (batik) { try { Loader loader = new Loader(); - return loader.getImage(uri, bis, ua); + return loader.getImage(uri, bis, ua.getLogger(), + ua.getPixelUnitToMillimeter()); } catch (NoClassDefFoundError e) { batik = false; //ua.getLogger().error("Batik not in class path", e); @@ -104,7 +108,7 @@ public class SVGReader implements ImageReader { */ class Loader { private FopImage.ImageInfo getImage(String uri, InputStream fis, - FOUserAgent ua) { + Logger logger, float pixelUnitToMM) { // parse document and get the size attributes of the svg element try { @@ -174,8 +178,8 @@ public class SVGReader implements ImageReader { Element e = doc.getRootElement(); String s; - SVGUserAgent userAg = - new SVGUserAgent(ua, new AffineTransform()); + SVGUserAgent userAg = new SVGUserAgent(logger, pixelUnitToMM, + new AffineTransform()); BridgeContext ctx = new BridgeContext(userAg); UnitProcessor.Context uctx = UnitProcessor.createContext(ctx, e); diff --git a/src/java/org/apache/fop/render/pdf/PDFXMLHandler.java b/src/java/org/apache/fop/render/pdf/PDFXMLHandler.java index 01780d0b0..04d38ecf0 100644 --- a/src/java/org/apache/fop/render/pdf/PDFXMLHandler.java +++ b/src/java/org/apache/fop/render/pdf/PDFXMLHandler.java @@ -220,7 +220,9 @@ public class PDFXMLHandler implements XMLHandler { int yOffset = pdfInfo.currentYPosition; SVGUserAgent ua - = new SVGUserAgent(context.getUserAgent(), new AffineTransform()); + = new SVGUserAgent(context.getUserAgent().getLogger(), + context.getUserAgent().getPixelUnitToMillimeter(), + new AffineTransform()); GVTBuilder builder = new GVTBuilder(); BridgeContext ctx = new BridgeContext(ua); diff --git a/src/java/org/apache/fop/render/ps/PSXMLHandler.java b/src/java/org/apache/fop/render/ps/PSXMLHandler.java index 20e50e667..522ef0b79 100644 --- a/src/java/org/apache/fop/render/ps/PSXMLHandler.java +++ b/src/java/org/apache/fop/render/ps/PSXMLHandler.java @@ -257,8 +257,9 @@ public class PSXMLHandler implements XMLHandler { PSGenerator gen = psInfo.psGenerator; SVGUserAgent ua - = new SVGUserAgent(context.getUserAgent(), new AffineTransform()); - + = new SVGUserAgent(context.getUserAgent().getLogger(), + context.getUserAgent().getPixelUnitToMillimeter(), + new AffineTransform()); GVTBuilder builder = new GVTBuilder(); BridgeContext ctx = new BridgeContext(ua); diff --git a/src/java/org/apache/fop/svg/SVGUserAgent.java b/src/java/org/apache/fop/svg/SVGUserAgent.java index 7d5e80f83..06aaee0f6 100644 --- a/src/java/org/apache/fop/svg/SVGUserAgent.java +++ b/src/java/org/apache/fop/svg/SVGUserAgent.java @@ -18,7 +18,7 @@ package org.apache.fop.svg; -import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.apps.FOFileHandler; import org.apache.batik.bridge.UserAgentAdapter; import org.apache.avalon.framework.logger.Logger; @@ -34,16 +34,20 @@ import java.awt.Dimension; */ public class SVGUserAgent extends UserAgentAdapter { private AffineTransform currentTransform = null; - private FOUserAgent userAgent; + private Logger logger; + private float pixelUnitToMillimeter = 0.0f; /** * Creates a new SVGUserAgent. - * @param ua the FO user agent + * @param log an Avalon logging instance + * @param pixelUnitToMM The pixel to millimeter conversion factor + * currently in effect * @param at the current transform */ - public SVGUserAgent(FOUserAgent ua, AffineTransform at) { + public SVGUserAgent(Logger log, float pixelUnitToMM, AffineTransform at) { + logger = log; + pixelUnitToMillimeter = pixelUnitToMM; currentTransform = at; - userAgent = ua; } /** @@ -51,7 +55,7 @@ public class SVGUserAgent extends UserAgentAdapter { * @return Logger the logger */ protected final Logger getLogger() { - return this.userAgent.getLogger(); + return logger; } /** @@ -59,7 +63,7 @@ public class SVGUserAgent extends UserAgentAdapter { * @param message the message to display */ public void displayError(String message) { - getLogger().error(message); + logger.error(message); } /** @@ -67,7 +71,7 @@ public class SVGUserAgent extends UserAgentAdapter { * @param ex the exception to display */ public void displayError(Exception ex) { - getLogger().error("SVG Error" + ex.getMessage(), ex); + logger.error("SVG Error" + ex.getMessage(), ex); } /** @@ -76,7 +80,7 @@ public class SVGUserAgent extends UserAgentAdapter { * @param message the message to display */ public void displayMessage(String message) { - getLogger().info(message); + logger.info(message); } /** @@ -84,7 +88,7 @@ public class SVGUserAgent extends UserAgentAdapter { * @param message the message to display */ public void showAlert(String message) { - getLogger().warn(message); + logger.warn(message); } /** @@ -92,7 +96,7 @@ public class SVGUserAgent extends UserAgentAdapter { * @return the pixel unit to millimeter conversion factor */ public float getPixelUnitToMillimeter() { - return userAgent.getPixelUnitToMillimeter(); + return pixelUnitToMillimeter; } /** @@ -124,7 +128,7 @@ public class SVGUserAgent extends UserAgentAdapter { * @return the XML parser class name */ public String getXMLParserClassName() { - return org.apache.fop.apps.FOFileHandler.getParserClassName(); + return FOFileHandler.getParserClassName(); } /**