예제 #1
0
 public static CssBox CreateListItemBox(CssBox parent, HtmlElement childElement)
 {
     var spec = childElement.Spec;
     var newBox = new CssBoxListItem(spec, parent.RootGfx);
     newBox.SetController(childElement);
     parent.AppendChild(newBox);
     if (spec.ListStyleType != CssListStyleType.None)
     {
         //create sub item collection 
         var itemBulletBox = new CssBox(spec.GetAnonVersion(), parent.RootGfx);
         newBox.BulletBox = itemBulletBox;
         CssBox.UnsafeSetParent(itemBulletBox, newBox);
         CssBox.ChangeDisplayType(itemBulletBox, CssDisplay.Inline);
         //---------------------------------------------------------------
         //set content of bullet 
         char[] text_content = null;
         switch (spec.ListStyleType)
         {
             case CssListStyleType.Disc:
                 {
                     text_content = discItem;
                 }
                 break;
             case CssListStyleType.Circle:
                 {
                     text_content = circleItem;
                 }
                 break;
             case CssListStyleType.Square:
                 {
                     text_content = squareItem;
                 }
                 break;
             case CssListStyleType.Decimal:
                 {
                     text_content = (GetIndexForList(newBox, childElement).ToString(CultureInfo.InvariantCulture) + ".").ToCharArray();
                 }
                 break;
             case CssListStyleType.DecimalLeadingZero:
                 {
                     text_content = (GetIndexForList(newBox, childElement).ToString("00", CultureInfo.InvariantCulture) + ".").ToCharArray();
                 }
                 break;
             default:
                 {
                     text_content = (BulletNumberFormatter.ConvertToAlphaNumber(GetIndexForList(newBox, childElement), spec.ListStyleType) + ".").ToCharArray();
                 }
                 break;
         }
         //--------------------------------------------------------------- 
         CssBox.UnsafeSetTextBuffer(itemBulletBox, text_content);
         List<CssRun> runlist = new List<CssRun>();
         bool hasSomeCharacter;
         splitter.ParseWordContent(text_content, spec, itemBulletBox.IsBlock, runlist, out hasSomeCharacter);
         RunListHelper.AddRunList(itemBulletBox, spec, runlist, text_content, false);
     }
     return newBox;
 }
        public static CssBox CreateListItemBox(CssBox parent, HtmlElement childElement)
        {
            var spec   = childElement.Spec;
            var newBox = new CssBoxListItem(spec, parent.RootGfx);

            newBox.SetController(childElement);
            parent.AppendChild(newBox);
            if (spec.ListStyleType != CssListStyleType.None)
            {
                //create sub item collection
                var itemBulletBox = new CssBox(spec.GetAnonVersion(), parent.RootGfx);
                newBox.BulletBox = itemBulletBox;
                CssBox.UnsafeSetParent(itemBulletBox, newBox);
                CssBox.ChangeDisplayType(itemBulletBox, CssDisplay.Inline);
                //---------------------------------------------------------------
                //set content of bullet
                char[] text_content = null;
                switch (spec.ListStyleType)
                {
                case CssListStyleType.Disc:
                {
                    text_content = discItem;
                }
                break;

                case CssListStyleType.Circle:
                {
                    text_content = circleItem;
                }
                break;

                case CssListStyleType.Square:
                {
                    text_content = squareItem;
                }
                break;

                case CssListStyleType.Decimal:
                {
                    text_content = (GetIndexForList(newBox, childElement).ToString(CultureInfo.InvariantCulture) + ".").ToCharArray();
                }
                break;

                case CssListStyleType.DecimalLeadingZero:
                {
                    text_content = (GetIndexForList(newBox, childElement).ToString("00", CultureInfo.InvariantCulture) + ".").ToCharArray();
                }
                break;

                default:
                {
                    text_content = (BulletNumberFormatter.ConvertToAlphaNumber(GetIndexForList(newBox, childElement), spec.ListStyleType) + ".").ToCharArray();
                }
                break;
                }
                //---------------------------------------------------------------
                CssBox.UnsafeSetTextBuffer(itemBulletBox, text_content);
                List <CssRun> runlist = new List <CssRun>();
                bool          hasSomeCharacter;
                splitter.ParseWordContent(text_content, spec, itemBulletBox.IsBlock, runlist, out hasSomeCharacter);
                RunListHelper.AddRunList(itemBulletBox, spec, runlist, text_content, false);
            }
            return(newBox);
        }