public InsertEntry ( string textEntry, int outLineLevel ) : void | ||
textEntry | string | The text entry. |
outLineLevel | int | The outline level possible 1-10. |
return | void |
public void TableOfContentsTest() { //Create new Document TextDocument textDocument = new TextDocument(); textDocument.New(); //Create a new Table of contents TableOfContents tableOfContents = new TableOfContents( textDocument, "Table_Of_Contents", false, false, "Table of Contents"); //Add the toc textDocument.Content.Add(tableOfContents); //Create a new heading, there's no need of the chapter number string sHeading = "A first headline"; //The corresponding text entry, here you need to set the //chapter number string sTocEntry = "1. A first headline"; Header header = new Header( textDocument, Headings.Heading_20_1); header.OutLineLevel = "1"; header.TextContent.Add(new SimpleText(textDocument, sHeading)); //add the header to the content textDocument.Content.Add(header); //add the toc entry text as entry to the Table of contents tableOfContents.InsertEntry(sTocEntry, 1); //Add some text to this chapter Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(textDocument); paragraph.TextContent.Add(new SimpleText(textDocument, "I'm the text for the first chapter!")); textDocument.Content.Add(paragraph); //Add a sub header to the first chapter //Create a new heading, there's no need of the chapter number sHeading = "A first sub headline"; //The corresponding text entry, here you need to set the //chapter number sTocEntry = "1.1. A first sub headline"; header = new Header( textDocument, Headings.Heading_20_2); header.OutLineLevel = "2"; header.TextContent.Add(new SimpleText(textDocument, sHeading)); //add the header to the content textDocument.Content.Add(header); //add the toc entry text as entry to the Table of contents tableOfContents.InsertEntry(sTocEntry, 2); //Add some text to this sub chapter paragraph = ParagraphBuilder.CreateStandardTextParagraph(textDocument); paragraph.TextContent.Add(new SimpleText(textDocument, "I'm the text for the subchapter chapter!")); textDocument.Content.Add(paragraph); // ListStyle listStyle = new ListStyle(textDocument, "TOC_LIST"); // listStyle.AutomaticAddListLevelStyles(ListStyles.Number); // textDocument.Styles.Add(listStyle); //Save it textDocument.SaveTo(AARunMeFirstAndOnce.outPutFolder+"toc.odt"); }