private StyleProp InsertProperty(StyleProp props, string name, string val)
		{
			StyleProp first, prev, prop;
			int cmp;
			
			prev = null;
			first = props;
			
			while (props != null)
			{
				cmp = props.Name.CompareTo(name);
				if (cmp == 0)
				{
					/* this property is already defined, ignore new value */
					return first;
				}
				else if (cmp > 0)
				{
					// props.name > name
					/* insert before this */
					
					prop = new StyleProp(name, val, props);
					
					if (prev != null)
					{
						prev.Next = prop;
					}
					else
					{
						first = prop;
					}
					
					return first;
				}
				
				prev = props;
				props = props.Next;
			}
			
			prop = new StyleProp(name, val);
			if (prev != null)
			{
				prev.Next = prop;
			}
			else
			{
				first = prop;
			}

			return first;
		}
Пример #2
0
        /*
        Create sorted linked list of properties from style string
        It temporarily places nulls in place of ':' and ';' to
        delimit the strings for the property name and value.
        Some systems don't allow you to null literal strings,
        so to avoid this, a copy is made first.
        */
        private StyleProp CreateProps(StyleProp prop, string style)
        {
            int name_end;
            int value_end;
            int value_start = 0;
            int name_start = 0;
            bool more;

            name_start = 0;
            while (name_start < style.Length)
            {
                while (name_start < style.Length && style[name_start] == ' ')
                {
                    ++name_start;
                }

                name_end = name_start;

                while (name_end < style.Length)
                {
                    if (style[name_end] == ':')
                    {
                        value_start = name_end + 1;
                        break;
                    }

                    ++name_end;
                }

                if (name_end >= style.Length || style[name_end] != ':')
                {
                    break;
                }

                while (value_start < style.Length && style[value_start] == ' ')
                {
                    ++value_start;
                }

                value_end = value_start;
                more = false;

                while (value_end < style.Length)
                {
                    if (style[value_end] == ';')
                    {
                        more = true;
                        break;
                    }

                    ++value_end;
                }

                prop = InsertProperty(prop, style.Substring(name_start, (name_end) - (name_start)), style.Substring(value_start, (value_end) - (value_start)));

                if (more)
                {
                    name_start = value_end + 1;
                    continue;
                }

                break;
            }

            return prop;
        }
Пример #3
0
        private string CreatePropString(StyleProp props)
        {
            string style = "";
            int len;
            StyleProp prop;

            /* compute length */

            for (len = 0, prop = props; prop != null; prop = prop.Next)
            {
                len += prop.Name.Length + 2;
                len += prop.Val.Length + 2;
            }

            for (prop = props; prop != null; prop = prop.Next)
            {
                style = string.Concat(style, prop.Name);
                style = string.Concat(style, ": ");

                style = string.Concat(style, prop.Val);

                if (prop.Next == null)
                {
                    break;
                }

                style = string.Concat(style, "; ");
            }

            return style;
        }
Пример #4
0
 public StyleProp(string name, string val, StyleProp next)
 {
     _name = name;
     _val  = val;
     _next = next;
 }
Пример #5
0
 public StyleProp(string name, string val, StyleProp next)
 {
     _name = name;
     _val = val;
     _next = next;
 }