Difference between revisions of "AODL example 8"
From Apache OpenOffice Wiki
m |
|||
| Line 1: | Line 1: | ||
<b>Don't do things twice. Create deep clones of any IContent object.</b> | <b>Don't do things twice. Create deep clones of any IContent object.</b> | ||
| − | < | + | <syntaxhighlight lang="c">> |
TextDocument document = new TextDocument(); | TextDocument document = new TextDocument(); | ||
document.New(); | document.New(); | ||
| Line 19: | Line 19: | ||
document.Content.Add(paragraphClone2); | document.Content.Add(paragraphClone2); | ||
document.SaveTo("clonedParagraphs.odt"); | document.SaveTo("clonedParagraphs.odt"); | ||
| − | </ | + | </syntaxhighlight> |
Back to the [[AODL_examples|AODL examples]] overview. | Back to the [[AODL_examples|AODL examples]] overview. | ||
[[category:Summer of Code 2007]][[category:AODL]] | [[category:Summer of Code 2007]][[category:AODL]] | ||
Revision as of 12:38, 22 May 2022
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.