Difference between revisions of "AODL example 8"
From Apache OpenOffice Wiki
| Line 21: | Line 21: | ||
</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
Don't do things twice. Create deep clones of any IContent object.
TextDocument document = new TextDocument();
document.New();
Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document);
paragraph.TextContent.Add(new SimpleText(document, "Some text"));
Paragraph paragraphClone = (Paragraph)paragraph.Clone();
ParagraphStyle paragraphStyle = new ParagraphStyle(document, "P1");
paragraphStyle.TextProperties.Bold = "bold";
//Add paragraph style to the document,
//only automaticaly created styles will be added also automaticaly
document.Styles.Add(paragraphStyle);
paragraphClone.ParagraphStyle = paragraphStyle;
//Clone the clone
Paragraph paragraphClone2 = (Paragraph)paragraphClone.Clone();
document.Content.Add(paragraph);
document.Content.Add(paragraphClone);
document.Content.Add(paragraphClone2);
document.SaveTo("clonedParagraphs.odt");
Back to the AODL examples overview.