コード例 #1
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);
        }
コード例 #2
0
ファイル: PropertyListBuilder.cs プロジェクト: nholik/Fo.Net
        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;
        }