Difference between revisions of "AODL example 9"
From Apache OpenOffice Wiki
m |
m |
||
Line 9: | Line 9: | ||
Assert.IsTrue(style is ParagraphStyle, "style must be a ParagraphStyle"); | Assert.IsTrue(style is ParagraphStyle, "style must be a ParagraphStyle"); | ||
((ParagraphStyle)style).TextProperties.FontName = FontFamilies.BroadwayBT; | ((ParagraphStyle)style).TextProperties.FontName = FontFamilies.BroadwayBT; | ||
− | //Create a header that | + | //Create a header that uses the standard style Heading_20_1 |
Header header = new Header(document, Headings.Heading_20_1); | Header header = new Header(document, Headings.Heading_20_1); | ||
//Add some text | //Add some text |
Latest revision as of 12:40, 22 May 2022
Accessing and manipulating common styles (style templates)
TextDocument document = new TextDocument(); document.New(); //Find a Header template IStyle style = document.CommonStyles.GetStyleByName("Heading_20_1"); Assert.IsNotNull(style, "Style with name Heading_20_1 must exist"); Assert.IsTrue(style is ParagraphStyle, "style must be a ParagraphStyle"); ((ParagraphStyle)style).TextProperties.FontName = FontFamilies.BroadwayBT; //Create a header that uses the standard style Heading_20_1 Header header = new Header(document, Headings.Heading_20_1); //Add some text header.TextContent.Add(new SimpleText(document, "I am the header text and my style template was modified :)")); //Add header to the document document.Content.Add(header); //save the document document.SaveTo("modifiedCommonStyle.odt");
Back to the AODL examples overview.