From 40959556d3eaa2bac9d3943ccf8e904b3a8a9ba5 Mon Sep 17 00:00:00 2001 From: Karen Lease Date: Sat, 16 Dec 2000 21:57:06 +0000 Subject: [PATCH] Improve handling of compound properties git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193880 13f79535-47bb-0310-9956-ffa450edef68 --- src/codegen/foproperties.xml | 93 ++++++--- src/codegen/properties.xsl | 387 ++++++++++++++++++++++++----------- 2 files changed, 328 insertions(+), 152 deletions(-) diff --git a/src/codegen/foproperties.xml b/src/codegen/foproperties.xml index 6e6f47650..e4c5bdccb 100644 --- a/src/codegen/foproperties.xml +++ b/src/codegen/foproperties.xml @@ -5,7 +5,7 @@ generic-color GenericColor ColorType - + new ColorType(strval) @@ -23,7 +23,7 @@ Number 0 -1 - + + + border-cond-width-template GenericCondBorderWidth - GenericCondLength 0.5pt 1pt 2pt false - 0pt + CondLength + + + length + Length + 0.5pt + 1pt + 2pt + medium + + + conditionality + String + + - + border-width-template GenericBorderWidth @@ -127,27 +145,31 @@ GenericSpace false Space - 0pt - + minimum Length + 0pt - + optimum Length + 0pt - + maximum Length + 0pt precedence Number + 0 conditionality String + discard @@ -157,7 +179,7 @@ Length 12pt - + start-indent @@ -375,11 +397,11 @@ Length normal 1.2em - + new PercentLength(numval.doubleValue(), getPercentBase(fo,propertyList)) - + text-indent @@ -433,18 +455,22 @@ padding-before GenericCondPadding + retain padding-after GenericCondPadding + retain padding-start - GenericPadding + GenericCondPadding + discard padding-end - GenericPadding + GenericCondPadding + discard padding-top @@ -487,6 +513,7 @@ border-before-width GenericCondBorderWidth + retain border-after-color @@ -501,6 +528,7 @@ border-after-width GenericCondBorderWidth + retain border-start-color @@ -514,7 +542,8 @@ border-start-width - GenericBorderWidth + GenericCondBorderWidth + discard border-end-color @@ -528,7 +557,8 @@ border-end-width - GenericBorderWidth + GenericCondBorderWidth + discard border-top-color @@ -671,7 +701,7 @@ false Length - + auto @@ -769,27 +799,29 @@ leader-length - LeaderLength true LengthRange - 12.0pt + - + minimum Length + 0pt + - + optimum Length + 12.0pt + - + maximum Length + 100% + - @@ -799,7 +831,8 @@ Length use-font-metrics 0pt - + + @@ -892,7 +925,6 @@ 1 - region-name RegionName @@ -901,7 +933,6 @@ - hyphenate Hyphenate diff --git a/src/codegen/properties.xsl b/src/codegen/properties.xsl index 5f0d252ee..95f768a60 100644 --- a/src/codegen/properties.xsl +++ b/src/codegen/properties.xsl @@ -8,6 +8,124 @@ + + + + /** 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; + } + + + + + protected String checkValueKeywords(String value) { + + if (value.equals("")) { + return new String(""); + } + + return super.checkValueKeywords(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; + + } + + + + @@ -92,9 +210,31 @@ public class extends - final private static Property.Maker s_Maker = + + + + + + + + + static private class SP_Maker + extends Property.Maker { + SP_Maker(String sPropName) { + super(sPropName); + } + + } + final private static Property.Maker s_Maker = + new SP_Maker( + "."); + + + final private static Property.Maker s_Maker = new Property.Maker( "."); + + @@ -109,8 +249,13 @@ public class extends protected Property.Maker getSubpropMaker(String subprop) { + + + + + if (subprop.equals("")) - return s_Maker; + return s_Maker; return super.getSubpropMaker(subprop); } @@ -120,13 +265,13 @@ public class extends val = (()baseProp).get(); - - - + + + if (subpropName.equals("")) - val.set(subProp.get()); + val.set(subProp.get(), false); else return super.setSubprop(baseProp, subpropName, subProp); @@ -137,22 +282,110 @@ public class extends val = (()baseProp).get(); - - - + + + if (subpropName.equals("")) return new Property( - val.get()); + val.get()); return super.getSubpropValue(baseProp, subpropName); } - - - + + + + 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("").make(pList, + getDefaultFor(), fo); + p.set(subProp.get(), true); + + return new (p); + } + + + + + + + + + protected String getDefaultFor() { + + return ""; + + return ""; + + + } + + + /** Set the appropriate components when the "base" property is set. */ + protected Property convertProperty(Property p, PropertyList pList,FObj fo) + throws FOPException + { + + + + + + + spval=p.get(); + if (spval == null) { + // NOTE: must convert to the component datatype, not compound! + Property pconv = convertPropertyDatatype(p, pList, fo); + if (pconv != null) { + spval=pconv.get(); + } + } + if (spval != null) { + Property prop = makeCompound(pList, fo); + pval = prop.get(); + + + + + pval.set(spval, false); + + return prop; + } + else { + // throw some kind of exception! + throw new FOPException("Can't convert value to type"); + } + } + + public boolean isInherited() { return ; } @@ -165,55 +398,6 @@ public class extends - static class PropLengthBase extends LengthBase { - private FObj fo; - private PropertyList propertyList ; - - public PropLengthBase(FObj fo, PropertyList plist) { - this.fo = fo; - // get from FO???? - this.propertyList = plist; - //this.propertyList = fo.getProperties(); - } - - public int getBaseLength() { - - - return propertyList.get("font-size").getLength().mvalue(); - - - return propertyList.getInherited("font-size").getLength().mvalue(); - - - - return fo.getContainingWidth(); - - - return ; - - - } - } - - /** Return instance of internal class to calculate base Length - * for percent specifications. - */ - public PercentBase getPercentBase(final FObj fo, - final PropertyList propertyList) { - return new PropLengthBase(fo, propertyList); - } - - - - - protected boolean isAutoLengthAllowed() { - return true; - } - - - protected Property findConstant(String value) { @@ -224,62 +408,6 @@ public class extends - protected String checkValueKeywords(String value) { - - if (value.equals("")) { - return new String(""); - } - - return super.checkValueKeywords(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); - } - - - - public Property make(PropertyList propertyList, boolean bForceNew) throws FOPException { - - return make(propertyList, "", null); - - if (bForceNew) { - // Make a new property instead of using the static default - return make(propertyList, "", null); - } - if (m_defaultProp == null) - m_defaultProp=make(propertyList, "", null); - return m_defaultProp; - - } - - public Property compute(PropertyList propertyList) { @@ -296,6 +424,7 @@ public class extends } @@ -304,6 +433,22 @@ public class extends - - + + + + + + + + Conflict between subproperty datatypes: + != + + + + + + -- 2.39.5