Example #1
0
 /**
  * Create a default set of listlevels
  * @since 2.1.3
  */
 protected void CreateDefaultLevels()
 {
     this.listLevels = new ArrayList();  // listlevels
     for (int i = 0; i <= 8; i++)
     {
         // create a list level
         RtfListLevel ll = new RtfListLevel(this.document);
         ll.SetListType(RtfListLevel.LIST_TYPE_NUMBERED);
         ll.SetFirstIndent(0);
         ll.SetLeftIndent(0);
         ll.SetLevelTextNumber(i);
         ll.SetTentative(true);
         ll.CorrectIndentation();
         this.listLevels.Add(ll);
     }
 }
Example #2
0
 /**
 * Create a default set of listlevels
 * @since 2.1.3
 */
 protected void CreateDefaultLevels()
 {
     this.listLevels = new ArrayList();  // listlevels
     for (int i=0; i<=8; i++) {
         // create a list level
         RtfListLevel ll = new RtfListLevel(this.document);
         ll.SetListType(RtfListLevel.LIST_TYPE_NUMBERED);
         ll.SetFirstIndent(0);
         ll.SetLeftIndent(0);
         ll.SetLevelTextNumber(i);
         ll.SetTentative(true);
         ll.CorrectIndentation();
         this.listLevels.Add(ll);
     }
 }
Example #3
0
        /**
         * Constructs a new RtfList for the specified List.
         *
         * @param doc The RtfDocument this RtfList belongs to
         * @param list The List this RtfList is based on
         * @since 2.1.3
         */
        public RtfList(RtfDocument doc, Legacy.Text.List list) : base(doc)
        {
            // setup the listlevels
            // Then, setup the list data below

            // setup 1 listlevel if it's a simple list
            // setup 9 if it's a regular list
            // setup 9 if it's a hybrid list (default)
            CreateDefaultLevels();

            this.items = new ArrayList();       // list content
            RtfListLevel ll = (RtfListLevel)this.listLevels[0];

            // get the list number or create a new one adding it to the table
            this.listNumber = document.GetDocumentHeader().GetListNumber(this);

            if (list.SymbolIndent > 0 && list.IndentationLeft > 0)
            {
                ll.SetFirstIndent((int)(list.SymbolIndent * RtfElement.TWIPS_FACTOR * -1));
                ll.SetLeftIndent((int)((list.IndentationLeft + list.SymbolIndent) * RtfElement.TWIPS_FACTOR));
            }
            else if (list.SymbolIndent > 0)
            {
                ll.SetFirstIndent((int)(list.SymbolIndent * RtfElement.TWIPS_FACTOR * -1));
                ll.SetLeftIndent((int)(list.SymbolIndent * RtfElement.TWIPS_FACTOR));
            }
            else if (list.IndentationLeft > 0)
            {
                ll.SetFirstIndent(0);
                ll.SetLeftIndent((int)(list.IndentationLeft * RtfElement.TWIPS_FACTOR));
            }
            else
            {
                ll.SetFirstIndent(0);
                ll.SetLeftIndent(0);
            }
            ll.SetRightIndent((int)(list.IndentationRight * RtfElement.TWIPS_FACTOR));
            ll.SetSymbolIndent((int)((list.SymbolIndent + list.IndentationLeft) * RtfElement.TWIPS_FACTOR));
            ll.CorrectIndentation();
            ll.SetTentative(false);

            if (list is RomanList)
            {
                if (list.Lowercase)
                {
                    ll.SetListType(RtfListLevel.LIST_TYPE_LOWER_ROMAN);
                }
                else
                {
                    ll.SetListType(RtfListLevel.LIST_TYPE_UPPER_ROMAN);
                }
            }
            else if (list.Numbered)
            {
                ll.SetListType(RtfListLevel.LIST_TYPE_NUMBERED);
            }
            else if (list.Lettered)
            {
                if (list.Lowercase)
                {
                    ll.SetListType(RtfListLevel.LIST_TYPE_LOWER_LETTERS);
                }
                else
                {
                    ll.SetListType(RtfListLevel.LIST_TYPE_UPPER_LETTERS);
                }
            }
            else
            {
                //          Paragraph p = new Paragraph();
                //          p.Add(new Chunk(list.GetPreSymbol()) );
                //          p.Add(list.GetSymbol());
                //          p.Add(new Chunk(list.GetPostSymbol()) );
                //          ll.SetBulletChunk(list.GetSymbol());
                ll.SetBulletCharacter(list.PreSymbol + list.Symbol.Content + list.PostSymbol);
                ll.SetListType(RtfListLevel.LIST_TYPE_BULLET);
            }

            // now setup the actual list contents.
            for (int i = 0; i < list.Items.Count; i++)
            {
                try {
                    IElement element = (IElement)list.Items[i];

                    if (element.Type == Element.CHUNK)
                    {
                        element = new ListItem((Chunk)element);
                    }
                    if (element is ListItem)
                    {
                        ll.SetAlignment(((ListItem)element).Alignment);
                    }
                    IRtfBasicElement[] rtfElements = doc.GetMapper().MapElement(element);
                    for (int j = 0; j < rtfElements.Length; j++)
                    {
                        IRtfBasicElement rtfElement = rtfElements[j];
                        if (rtfElement is RtfList)
                        {
                            ((RtfList)rtfElement).SetParentList(this);
                        }
                        else if (rtfElement is RtfListItem)
                        {
                            ((RtfListItem)rtfElement).SetParent(ll);
                        }
                        ll.SetFontNumber(new RtfFont(document, new Font(Font.TIMES_ROMAN, 10, Font.NORMAL, new Color(0, 0, 0))));
                        if (list.Symbol != null && list.Symbol.Font != null && !list.Symbol.Content.StartsWith("-") && list.Symbol.Content.Length > 0)
                        {
                            // only set this to bullet symbol is not default
                            ll.SetBulletFont(list.Symbol.Font);
                            ll.SetBulletCharacter(list.Symbol.Content.Substring(0, 1));
                        }
                        else
                        if (list.Symbol != null && list.Symbol.Font != null)
                        {
                            ll.SetBulletFont(list.Symbol.Font);
                        }
                        else
                        {
                            ll.SetBulletFont(new Font(Font.SYMBOL, 10, Font.NORMAL, new Color(0, 0, 0)));
                        }
                        items.Add(rtfElement);
                    }
                } catch (DocumentException) {
                }
            }
        }