Approved
Last Updated: 31 Oct 2018 07:53 by Björn
ADMIN
Petya
Created on: 30 Jan 2014 17:31
Category: RichTextBox
Type: Feature Request
2
RichTextBox: UI and simpler API for associating Heading styles with lists
This includes:

- Create multilevel list template for Heading styles

- Add button in the ribbon list styles gallery for applying this list template

-  TOC generated from heading styles associated with list should also include the numbering of the headings (see the related bug 91763). This is not absolutely required for the current item.

--------------------
Currently such list can be added using the following code:
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            ListStyle listStyle = CreateHierarchicalListStyle();

            for (int i = 0; i < 9; i++)
            {
                ListLevelStyle listLevel = listStyle.Levels[i];
                listLevel.HangingIndent = 0;
                listLevel.Indent = 0;
                listLevel.StyleName = RadDocumentDefaultStyles.GetHeadingStyleNameByIndex(i + 1);
            }

            DocumentList documentList = new DocumentList(listStyle, this.radRichTextBox.Document);

            for (int i = 0; i < 9; i++)
            {
                string headingStyleName = RadDocumentDefaultStyles.GetHeadingStyleNameByIndex(i + 1);

                StyleDefinition headingStyle = this.radRichTextBox.Document.StyleRepository.GetValueOrNull(headingStyleName);

                headingStyle.ParagraphStyle.ListId = documentList.ID;
                headingStyle.ParagraphStyle.ListLevel = i;
            }
        }

        private static ListStyle CreateHierarchicalListStyle()
        {
            ListStyle listStyle = new ListStyle();

            for (int i = 0; i < ListStyle.ListLevels; ++i)
            {
                StringBuilder levelText = new StringBuilder();
                for (int j = 0; j < i + 1; ++j)
                {
                    levelText.Append("{" + j + "}.");
                }

                listStyle.Levels.Add(new ListLevelStyle()
                {
                    StartingIndex = 1,
                    NumberingFormat = ListNumberingFormat.Decimal,
                    LevelText = levelText.ToString(),
                });
            }

            return listStyle;
        }
(Total attached files size should be smaller than 20mb. Allowed extensions: .zip, .rar, .jpg, .png, .gif)
1 comment
Björn
Posted on: 22 Mar 2016 09:34
Numbering of headings in the TOC is a must-have for comprehensive documents. I hope it will be included soon.