Difference between revisions of "AODL example 9"

From Apache OpenOffice Wiki
Jump to: navigation, search
 
m
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
<b>Accessing and manipulating common styles (style templates)</b>
 
<b>Accessing and manipulating common styles (style templates)</b>
  
<pre>
+
<syntaxhighlight lang="c">
 
TextDocument document = new TextDocument();
 
TextDocument document = new TextDocument();
 
document.New();
 
document.New();
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 use the standard style Heading_20_1
+
//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
Line 17: Line 17:
 
//save the document
 
//save the document
 
document.SaveTo("modifiedCommonStyle.odt");
 
document.SaveTo("modifiedCommonStyle.odt");
</pre>
+
</syntaxhighlight>
 
Back to the [[AODL_examples|AODL examples]] overview.
 
Back to the [[AODL_examples|AODL examples]] overview.
 +
[[category:Summer of Code 2007]][[category:AODL]]

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.

Personal tools