Difference between revisions of "AODL example 10"

From Apache OpenOffice Wiki
Jump to: navigation, search
 
m
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
 
<b>Create a Paragraph Collection from a long string by using the ParagraphBuilder</b>
 
<b>Create a Paragraph Collection from a long string by using the ParagraphBuilder</b>
  
<pre>
+
<syntaxhighlight lang="c">
 
//some text e.g read from a TextBox
 
//some text e.g read from a TextBox
 
string someText    = "Max Mustermann\nMustermann Str. 300\n22222 Hamburg\n\n\n\n"
 
string someText    = "Max Mustermann\nMustermann Str. 300\n22222 Hamburg\n\n\n\n"
Line 28: Line 28:
 
//save
 
//save
 
document.SaveTo("Letter.odt");
 
document.SaveTo("Letter.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:41, 22 May 2022

Create a Paragraph Collection from a long string by using the ParagraphBuilder

//some text e.g read from a TextBox
string someText     = "Max Mustermann\nMustermann Str. 300\n22222 Hamburg\n\n\n\n"
                        +"Heinz Willi\nDorfstr. 1\n22225 Hamburg\n\n\n\n"
                        +"Offer for 200 Intel Pentium 4 CPU's\n\n\n\n"
                        +"Dear Mr. Willi,\n\n\n\n"
                        +"thank you for your request. \tWe can "
                        +"offer you the 200 Intel Pentium IV 3 Ghz CPU's for a price of "
                        +"79,80 € per unit."
                        +"This special offer is valid to 31.10.2005. If you accept, we "
                        +"can deliver within 24 hours.\n\n\n\n"
                        +"Best regards \nMax Mustermann";
 
//Create new TextDocument
TextDocument document = new TextDocument();
document.New();
//Use the ParagraphBuilder to split the string into ParagraphCollection
ParagraphCollection pCollection  = ParagraphBuilder.CreateParagraphCollection(
                                     document,
                                     someText,
                                     true,
                                     ParagraphBuilder.ParagraphSeperator);
//Add the paragraph collection
foreach(Paragraph paragraph in pCollection)
    document.Content.Add(paragraph);
//save
document.SaveTo("Letter.odt");

Back to the AODL examples overview.

Personal tools