Difference between revisions of "AODL example 9"

From Apache OpenOffice Wiki
Jump to: navigation, search
 
Line 19: Line 19:
 
</pre>
 
</pre>
 
Back to the [[AODL_examples|AODL examples]] overview.
 
Back to the [[AODL_examples|AODL examples]] overview.
 +
[[category:Summer of Code 2007]][[category:AODL]]

Revision as of 22:26, 25 June 2007

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 use 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