AODL example 9

From Apache OpenOffice Wiki
Jump to: navigation, search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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.

Personal tools