示例#1
0
        private Property FindProperty(string propertyName, bool bTryInherit)
        {
            PropertyMaker maker = builder.FindMaker(propertyName);

            Property p = null;

            if (maker.IsCorrespondingForced(this))
            {
                p = ComputeProperty(this, maker);
            }
            else
            {
                p = GetExplicitBaseProperty(propertyName);

                if (p == null)
                {
                    p = ComputeProperty(this, maker);
                }

                if (p == null)
                {
                    p = maker.GetShorthand(this);
                }

                if (p == null && bTryInherit)
                {
                    if (this.parentPropertyList != null && maker.IsInherited())
                    {
                        p = parentPropertyList.FindProperty(propertyName, true);
                    }
                }
            }
            return(p);
        }
 protected virtual Property convertValueForProperty(
     string propName, PropertyMaker maker, PropertyList propertyList)
 {
     foreach (Property p in list)
     {
         Property prop = maker.ConvertShorthandProperty(propertyList, p, null);
         if (prop != null)
         {
             return(prop);
         }
     }
     return(null);
 }
示例#3
0
        private bool IsInherited(string propertyName)
        {
            PropertyMaker propertyMaker = builder.FindMaker(propertyName);

            if (propertyMaker != null)
            {
                return(propertyMaker.IsInherited());
            }
            else
            {
                FonetDriver.ActiveDriver.FireFonetError("Unknown property : " + propertyName);
                return(true);
            }
        }
示例#4
0
        internal Property GetShorthand(PropertyList propertyList, string propertyName)
        {
            PropertyMaker propertyMaker = FindMaker(propertyName);

            if (propertyMaker != null)
            {
                return(propertyMaker.GetShorthand(propertyList));
            }
            else
            {
                FonetDriver.ActiveDriver.FireFonetError("No maker for " + propertyName);
                return(null);
            }
        }
示例#5
0
        internal Property GetSubpropValue(
            string propertyName, Property p, string subpropName)
        {
            PropertyMaker maker = FindMaker(propertyName);

            if (maker != null)
            {
                return(maker.GetSubpropValue(p, subpropName));
            }
            else
            {
                return(null);
            }
        }
 public Property GetValueForProperty(string propName,
                                     PropertyMaker maker,
                                     PropertyList propertyList)
 {
     if (count() == 1)
     {
         string sval = ((Property)list[0]).GetString();
         if (sval != null && sval.Equals("inherit"))
         {
             return(propertyList.GetFromParentProperty(propName));
         }
     }
     return(convertValueForProperty(propName, maker, propertyList));
 }
示例#7
0
        private Property ComputeProperty(
            PropertyList propertyList, PropertyMaker propertyMaker)
        {
            Property p = null;

            try
            {
                p = propertyMaker.Compute(propertyList);
            }
            catch (FonetException e)
            {
                FonetDriver.ActiveDriver.FireFonetError(e.Message);
            }
            return(p);
        }
示例#8
0
        internal Property MakeProperty(PropertyList propertyList, string propertyName)
        {
            Property      p             = null;
            PropertyMaker propertyMaker = FindMaker(propertyName);

            if (propertyMaker != null)
            {
                p = propertyMaker.Make(propertyList);
            }
            else
            {
                FonetDriver.ActiveDriver.FireFonetWarning("property " + propertyName + " ignored");
            }
            return(p);
        }
示例#9
0
        /// <summary>
        ///     Return a property value for a compound property. If the property
        ///     value is already partially initialized, this method will modify it.
        /// </summary>
        /// <param name="baseProp">
        ///     The Property object representing the compound property, such as
        ///     SpaceProperty.
        /// </param>
        /// <param name="partName">The name of the component whose value is specified.</param>
        /// <param name="propertyList">The propertyList being built.</param>
        /// <param name="value"></param>
        /// <param name="fo">The FO whose properties are being set.</param>
        /// <returns>A compound property object.</returns>
        public Property Make(Property baseProp, string partName,
                             PropertyList propertyList, string value,
                             FObj fo)
        {
            if (baseProp == null)
            {
                baseProp = MakeCompound(propertyList, fo);
            }
            PropertyMaker spMaker = GetSubpropMaker(partName);

            if (spMaker != null)
            {
                Property p = spMaker.Make(propertyList, value, fo);
                if (p != null)
                {
                    return(SetSubprop(baseProp, partName, p));
                }
            }
            return(baseProp);
        }
示例#10
0
        internal PropertyList MakeList(
            string ns,
            string elementName,
            Attributes attributes,
            FObj parentFO)
        {
            Debug.Assert(ns != null, "Namespace should never be null.");

            string space = "http://www.w3.org/TR/1999/XSL/Format";

            if (ns != null)
            {
                space = ns;
            }

            PropertyList parentPropertyList = parentFO != null ? parentFO.properties : null;
            PropertyList par = null;

            if (parentPropertyList != null && space.Equals(parentPropertyList.GetNameSpace()))
            {
                par = parentPropertyList;
            }

            PropertyList p = new PropertyList(par, space, elementName);

            p.SetBuilder(this);

            StringCollection propsDone = new StringCollection();

            string fontsizeval = attributes.getValue(FONTSIZEATTR);

            if (fontsizeval != null)
            {
                PropertyMaker propertyMaker = FindMaker(FONTSIZEATTR);
                if (propertyMaker != null)
                {
                    try
                    {
                        p.Add(FONTSIZEATTR,
                              propertyMaker.Make(p, fontsizeval, parentFO));
                    }
                    catch (FonetException) { }
                }
                propsDone.Add(FONTSIZEATTR);
            }

            for (int i = 0; i < attributes.getLength(); i++)
            {
                string   attributeName = attributes.getQName(i);
                int      sepchar       = attributeName.IndexOf('.');
                string   propName      = attributeName;
                string   subpropName   = null;
                Property propVal       = null;
                if (sepchar > -1)
                {
                    propName    = attributeName.Substring(0, sepchar);
                    subpropName = attributeName.Substring(sepchar + 1);
                }
                else if (propsDone.Contains(propName))
                {
                    continue;
                }

                PropertyMaker propertyMaker = FindMaker(propName);

                if (propertyMaker != null)
                {
                    try
                    {
                        if (subpropName != null)
                        {
                            Property baseProp = p.GetExplicitBaseProperty(propName);
                            if (baseProp == null)
                            {
                                string baseValue = attributes.getValue(propName);
                                if (baseValue != null)
                                {
                                    baseProp = propertyMaker.Make(p, baseValue, parentFO);
                                    propsDone.Add(propName);
                                }
                            }
                            propVal = propertyMaker.Make(baseProp, subpropName,
                                                         p,
                                                         attributes.getValue(i),
                                                         parentFO);
                        }
                        else
                        {
                            propVal = propertyMaker.Make(p,
                                                         attributes.getValue(i),
                                                         parentFO);
                        }
                        if (propVal != null)
                        {
                            p[propName] = propVal;
                        }
                    }
                    catch (FonetException e)
                    {
                        FonetDriver.ActiveDriver.FireFonetError(e.Message);
                    }
                }
                else
                {
                    if (!attributeName.StartsWith("xmlns"))
                    {
                        FonetDriver.ActiveDriver.FireFonetWarning(
                            "property " + attributeName + " ignored");
                    }
                }
            }

            return(p);
        }