Difference between revisions of "AODL example 8"
From Apache OpenOffice Wiki
m |
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" | + | <syntaxhighlight lang="c"> |
TextDocument document = new TextDocument(); | TextDocument document = new TextDocument(); | ||
document.New(); | document.New(); |
Latest revision as of 12:39, 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.