<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.openoffice.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Andrewb</id>
	<title>Apache OpenOffice Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.openoffice.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Andrewb"/>
	<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/wiki/Special:Contributions/Andrewb"/>
	<updated>2026-10-19T06:46:33Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.14</generator>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/BASIC_Guide/Editing_Text_Documents&amp;diff=155126</id>
		<title>Documentation/BASIC Guide/Editing Text Documents</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/BASIC_Guide/Editing_Text_Documents&amp;diff=155126"/>
		<updated>2010-01-17T11:33:13Z</updated>

		<summary type="html">&lt;p&gt;Andrewb: /* Navigating within a Text */ whitespace defnition improved. Thanks to TJ Frazier&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/BASICGuideTOC/v2&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|ShowPrevPage=block&lt;br /&gt;
|PrevPage=Documentation/BASIC Guide/Structure of Text Documents&lt;br /&gt;
|NextPage=Documentation/BASIC Guide/More Than Text&lt;br /&gt;
|textdocs=block&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Editing Text Documents}}&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
The previous section has already discussed a whole range of options for editing text documents, focusing on the &amp;lt;idl&amp;gt;com.sun.star.text.TextPortion&amp;lt;/idl&amp;gt; and &amp;lt;idl&amp;gt;com.sun.star.text.Paragraph&amp;lt;/idl&amp;gt; services, which grant access to paragraph portions as well as paragraphs. These services are appropriate for applications in which the content of a text is to be edited in one pass through a loop. However, this is not sufficient for many problems. {{OOo}} provides the &amp;lt;idl&amp;gt;com.sun.star.text.TextCursor&amp;lt;/idl&amp;gt; service for more complicated tasks, including navigating backward within a document or navigating based on sentences and words rather than &amp;lt;tt&amp;gt;TextPortions&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== The TextCursor ==&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; in the {{OOo}} API is comparable with the visible cursor used in a {{OOo}} document. It marks a certain point within a text document and can be navigated in various directions through the use of commands. The &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; objects available in {{OOo}} Basic should not, however, be confused with the visible cursor. These are two very different things.&lt;br /&gt;
&lt;br /&gt;
{{Documentation/VBAnote|Terminology differs from that used in VBA: In terms of scope of function, the Range object from VBA can be compared with the TextCursor object in {{OOo}} and not — as the name possibly suggests — with the Range object in {{OOo}}.}}&lt;br /&gt;
&lt;br /&gt;
The TextCursor object in {{OOo}}, for example, provides methods for navigating and changing text which are included in the Range object in VBA (for example, MoveStart, MoveEnd, InsertBefore, InsertAfter). The corresponding counterparts of the TextCursor object in {{OOo}} are described in the following sections.&lt;br /&gt;
&lt;br /&gt;
=== Navigating within a Text  ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; object in {{OOo}} Basic acts independently from the visible cursor in a text document. A program-controlled position change of a &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; object has no impact whatsoever on the visible cursor. Several &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; objects can even be opened for the same document and used in various positions, which are independent of one another. &lt;br /&gt;
&lt;br /&gt;
A &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; object is created using the &amp;lt;tt&amp;gt;createTextCursor&amp;lt;/tt&amp;gt; call: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
Dim Cursor As Object&lt;br /&gt;
&lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
Cursor = Doc.Text.createTextCursor()&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
The Cursor object created in this way supports the &amp;lt;tt&amp;gt;com.sun.star.text.TextCursor&amp;lt;/tt&amp;gt; service, which in turn provides a whole range of methods for navigating within text documents. The following example first moves the &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; ten characters to the left and then three characters to the right: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;Cursor.goLeft(10, False)&lt;br /&gt;
Cursor.goRight(3, False)&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
A &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; can highlight a complete area. This can be compared with highlighting a point in the text using the mouse. The &amp;lt;tt&amp;gt;False&amp;lt;/tt&amp;gt; parameter in the previous function call specifies whether the area passed over with the cursor movement is highlighted. For example, the &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; in the following example &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Cursor.goRight(10, False)&lt;br /&gt;
Cursor.goLeft(3, True)&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
first moves ten characters to the right without highlighting, and then moves back three characters and highlights this. The area highlighted by the &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; therefore begins after the seventh character in the text and ends after the tenth character. &lt;br /&gt;
&lt;br /&gt;
Here are the central methods that the &amp;lt;idl&amp;gt;com.sun.star.text.TextCursor&amp;lt;/idl&amp;gt; service provides for navigation: &lt;br /&gt;
&lt;br /&gt;
;&amp;lt;tt&amp;gt;goLeft (Count, Expand)&amp;lt;/tt&amp;gt; &lt;br /&gt;
:jumps Count characters to the left. &lt;br /&gt;
;&amp;lt;tt&amp;gt;goRight (Count, Expand)&amp;lt;/tt&amp;gt; &lt;br /&gt;
:jumps Count characters to the right. &lt;br /&gt;
;&amp;lt;tt&amp;gt;gotoStart (Expand)&amp;lt;/tt&amp;gt; &lt;br /&gt;
:jumps to the start of the text document. &lt;br /&gt;
;&amp;lt;tt&amp;gt;gotoEnd (Expand)&amp;lt;/tt&amp;gt; &lt;br /&gt;
:jumps to the end of the text document. &lt;br /&gt;
;&amp;lt;tt&amp;gt;gotoRange (TextRange, Expand)&amp;lt;/tt&amp;gt; &lt;br /&gt;
:jumps to the specified &amp;lt;tt&amp;gt;TextRange&amp;lt;/tt&amp;gt;-Object. &lt;br /&gt;
;&amp;lt;tt&amp;gt;gotoStartOfWord (Expand)&amp;lt;/tt&amp;gt; &lt;br /&gt;
:jumps to the start of the current word. &lt;br /&gt;
;&amp;lt;tt&amp;gt;gotoEndOfWord (Expand)&amp;lt;/tt&amp;gt; &lt;br /&gt;
:jumps to the end of the current word. &lt;br /&gt;
;&amp;lt;tt&amp;gt;gotoNextWord (Expand)&amp;lt;/tt&amp;gt; &lt;br /&gt;
:jumps to the start of the next word. &lt;br /&gt;
;&amp;lt;tt&amp;gt;gotoPreviousWord (Expand)&amp;lt;/tt&amp;gt; &lt;br /&gt;
:jumps to the start of the previous word. &lt;br /&gt;
;&amp;lt;tt&amp;gt;isStartOfWord ()&amp;lt;/tt&amp;gt; &lt;br /&gt;
:returns &amp;lt;tt&amp;gt;True&amp;lt;/tt&amp;gt; if the &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; is at the start of a word. &lt;br /&gt;
;&amp;lt;tt&amp;gt;isEndOfWord ()&amp;lt;/tt&amp;gt; &lt;br /&gt;
:returns &amp;lt;tt&amp;gt;True&amp;lt;/tt&amp;gt; if the &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; is at the end of a word. &lt;br /&gt;
;&amp;lt;tt&amp;gt;gotoStartOfSentence (Expand)&amp;lt;/tt&amp;gt; &lt;br /&gt;
:jumps to the start of the current sentence. &lt;br /&gt;
;&amp;lt;tt&amp;gt;gotoEndOfSentence (Expand)&amp;lt;/tt&amp;gt; &lt;br /&gt;
:jumps to the end of the current sentence. &lt;br /&gt;
;&amp;lt;tt&amp;gt;gotoNextSentence (Expand)&amp;lt;/tt&amp;gt; &lt;br /&gt;
:jumps to the start of the next sentence. &lt;br /&gt;
;&amp;lt;tt&amp;gt;gotoPreviousSentence (Expand)&amp;lt;/tt&amp;gt; &lt;br /&gt;
:jumps to the start of the previous sentence. &lt;br /&gt;
;&amp;lt;tt&amp;gt;isStartOfSentence ()&amp;lt;/tt&amp;gt; &lt;br /&gt;
:returns &amp;lt;tt&amp;gt;True&amp;lt;/tt&amp;gt; if the &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; is at the start of a sentence. &lt;br /&gt;
;&amp;lt;tt&amp;gt;isEndOfSentence ()&amp;lt;/tt&amp;gt; &lt;br /&gt;
:returns &amp;lt;tt&amp;gt;True&amp;lt;/tt&amp;gt; if the &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; is at the end of a sentence. &lt;br /&gt;
;&amp;lt;tt&amp;gt;gotoStartOfParagraph (Expand)&amp;lt;/tt&amp;gt; &lt;br /&gt;
:jumps to the start of the current paragraph. &lt;br /&gt;
;&amp;lt;tt&amp;gt;gotoEndOfParagraph (Expand)&amp;lt;/tt&amp;gt; &lt;br /&gt;
:jumps to the end of the current paragraph. &lt;br /&gt;
;&amp;lt;tt&amp;gt;gotoNextParagraph (Expand)&amp;lt;/tt&amp;gt; &lt;br /&gt;
:jumps to the start of the next paragraph. &lt;br /&gt;
;&amp;lt;tt&amp;gt;gotoPreviousParagraph (Expand)&amp;lt;/tt&amp;gt; &lt;br /&gt;
:jumps to the start of the previous paragraph. &lt;br /&gt;
;&amp;lt;tt&amp;gt;isStartOfParagraph ()&amp;lt;/tt&amp;gt; &lt;br /&gt;
:returns &amp;lt;tt&amp;gt;True&amp;lt;/tt&amp;gt; if the &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; is at the start of a paragraph. &lt;br /&gt;
;&amp;lt;tt&amp;gt;isEndOfParagraph ()&amp;lt;/tt&amp;gt; &lt;br /&gt;
:returns &amp;lt;tt&amp;gt;True&amp;lt;/tt&amp;gt; if the &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; is at the end of a paragraph.&lt;br /&gt;
&lt;br /&gt;
The text is divided into sentences on the basis of sentence symbols. Periods  are, for example, interpreted as symbols indicating the end of sentences. (In English, at least, they must be followed by a space, tab, or return for this to work.) &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;Expand&amp;lt;/tt&amp;gt; parameter is a Boolean value which specifies whether the area passed over during navigation is to be highlighted. All navigation methods furthermore return a Boolean parameter which specifies whether the navigation was successful or whether the action was terminated for lack of text. &lt;br /&gt;
&lt;br /&gt;
The following is a list of several methods for editing highlighted areas using a &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; and which also support the &amp;lt;idl&amp;gt;com.sun.star.text.TextCursor&amp;lt;/idl&amp;gt; service: &lt;br /&gt;
&lt;br /&gt;
;&amp;lt;tt&amp;gt;collapseToStart ()&amp;lt;/tt&amp;gt; &lt;br /&gt;
:resets the highlighting and positions the &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; at the start of the previously highlighted area. &lt;br /&gt;
;&amp;lt;tt&amp;gt;collapseToEnd ()&amp;lt;/tt&amp;gt; &lt;br /&gt;
:resets the highlighting and positions the &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; at the end of the previously highlighted area. &lt;br /&gt;
;&amp;lt;tt&amp;gt;isCollapsed ()&amp;lt;/tt&amp;gt; &lt;br /&gt;
:returns &amp;lt;tt&amp;gt;True&amp;lt;/tt&amp;gt; if the &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; does not cover any highlighting at present.&lt;br /&gt;
&lt;br /&gt;
=== Formatting Text with TextCursor ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;idl&amp;gt;com.sun.star.text.TextCursor&amp;lt;/idl&amp;gt; service supports all the character and paragraph properties that were presented at the start of this chapter. &lt;br /&gt;
&lt;br /&gt;
The following example shows how these can be used in conjunction with a &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt;. It passes through a complete document and formats the first word of every sentence in bold type. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object   &lt;br /&gt;
Dim Cursor As Object&lt;br /&gt;
Dim Proceed As Boolean&lt;br /&gt;
&lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
Cursor = Doc.Text.createTextCursor&lt;br /&gt;
&lt;br /&gt;
Do &lt;br /&gt;
  Cursor.gotoEndOfWord(True)&lt;br /&gt;
  Cursor.CharWeight = com.sun.star.awt.FontWeight.BOLD&lt;br /&gt;
  Proceed = Cursor.gotoNextSentence(False)&lt;br /&gt;
  Cursor.gotoNextWord(False)&lt;br /&gt;
Loop While Proceed &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example first creates a document object for the text that has just been opened. Then it iterates through the entire text, sentence by sentence, and highlights each of the first words and formats this in bold.&lt;br /&gt;
&lt;br /&gt;
=== Retrieving and Modifying Text Contents ===&lt;br /&gt;
&lt;br /&gt;
If a &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; contains a highlighted area, then this text is available by means of the &amp;lt;tt&amp;gt;String&amp;lt;/tt&amp;gt; property of the &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; object. The following example uses the &amp;lt;tt&amp;gt;String&amp;lt;/tt&amp;gt; property to display the first words of a sentence in a message box:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object   &lt;br /&gt;
Dim Cursor As Object&lt;br /&gt;
Dim Proceed As Boolean&lt;br /&gt;
&lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
Cursor = Doc.Text.createTextCursor&lt;br /&gt;
&lt;br /&gt;
Do &lt;br /&gt;
  Cursor.gotoEndOfWord(True)&lt;br /&gt;
  MsgBox Cursor.String&lt;br /&gt;
  Proceed = Cursor.gotoNextSentence(False)&lt;br /&gt;
  Cursor.gotoNextWord(False)&lt;br /&gt;
Loop While Proceed &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first word of each sentence can be modified in the same way using the &amp;lt;tt&amp;gt;String&amp;lt;/tt&amp;gt; property: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object   &lt;br /&gt;
Dim Cursor As Object&lt;br /&gt;
Dim Proceed As Boolean&lt;br /&gt;
&lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
Cursor = Doc.Text.createTextCursor&lt;br /&gt;
&lt;br /&gt;
Do &lt;br /&gt;
  Cursor.gotoEndOfWord(True)&lt;br /&gt;
  Cursor.String = &amp;quot;Ups&amp;quot;&lt;br /&gt;
  Proceed = Cursor.gotoNextSentence(False)&lt;br /&gt;
  Cursor.gotoNextWord(False)&lt;br /&gt;
Loop While Proceed &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; contains a highlighted area, an assignment to the &amp;lt;tt&amp;gt;String&amp;lt;/tt&amp;gt; property replaces this with the new text. If there is no highlighted area, the text is inserted at the present &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; position.&lt;br /&gt;
&lt;br /&gt;
=== Inserting Control Codes ===&lt;br /&gt;
&lt;br /&gt;
In some situations, it is not the actual text of a document, but rather its structure that needs modifying. {{OOo}} provides control codes for this purpose. These are inserted in the text and influence its structure. The control codes are defined in the &amp;lt;idl&amp;gt;com.sun.star.text.ControlCharacter&amp;lt;/idl&amp;gt; group of constants. The following control codes are available in {{OOo}}:&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;tt&amp;gt;PARAGRAPH_BREAK&amp;lt;/tt&amp;gt;:paragraph break.&lt;br /&gt;
;&amp;lt;tt&amp;gt;LINE_BREAK&amp;lt;/tt&amp;gt;:line break within a paragraph.&lt;br /&gt;
;&amp;lt;tt&amp;gt;SOFT_HYPHEN&amp;lt;/tt&amp;gt;:possible point for syllabification.&lt;br /&gt;
;&amp;lt;tt&amp;gt;HARD_HYPHEN&amp;lt;/tt&amp;gt;:obligatory point for syllabification.&lt;br /&gt;
;&amp;lt;tt&amp;gt;HARD_SPACE&amp;lt;/tt&amp;gt;:protected space that is not spread out or compressed in justified text.&lt;br /&gt;
&lt;br /&gt;
To insert the control codes, you need not only the cursor but also the associated text document objects. The following example inserts a paragraph after the 20th character of a text:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object   &lt;br /&gt;
Dim Cursor As Object&lt;br /&gt;
Dim Proceed As Boolean&lt;br /&gt;
&lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
Cursor = Doc.Text.createTextCursor&lt;br /&gt;
Cursor.goRight(20, False)&lt;br /&gt;
Doc.Text.insertControlCharacter(Cursor, _&lt;br /&gt;
    com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, False)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;False&amp;lt;/tt&amp;gt; parameter in the call of the &amp;lt;tt&amp;gt;insertControlCharacter&amp;lt;/tt&amp;gt; method ensures that the area currently highlighted by the &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; remains after the insert operation. If the &amp;lt;tt&amp;gt;True&amp;lt;/tt&amp;gt; parameter is passed here, then &amp;lt;tt&amp;gt;insertControlCharacter&amp;lt;/tt&amp;gt; replaces the current text.&lt;br /&gt;
&lt;br /&gt;
== Searching for Text Portions ==&lt;br /&gt;
&lt;br /&gt;
In many instances, it is the case that a text is to be searched for a particular term and the corresponding point needs to be edited. All {{OOo}} documents provide a special interface for this purpose, and this interface always functions in accordance with the same principle: Before a search process, what is commonly referred to as a &amp;lt;tt&amp;gt;SearchDescriptor&amp;lt;/tt&amp;gt; must first be created. This defines what {{OOo}} searches for in a document. A &amp;lt;tt&amp;gt;SearchDescriptor&amp;lt;/tt&amp;gt; is an object which supports the &amp;lt;tt&amp;gt;com.sun.star.util.&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;SearchDescriptor&amp;lt;/tt&amp;gt; service and can be created by means of the &amp;lt;tt&amp;gt;createSearchDescriptor&amp;lt;/tt&amp;gt; method of a document: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim SearchDesc As Object&lt;br /&gt;
SearchDesc = Doc.createSearchDescriptor&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once the &amp;lt;tt&amp;gt;SearchDescriptor&amp;lt;/tt&amp;gt; has been created, it receives the text to be searched for:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
SearchDesc.searchString=&amp;quot;any text&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In terms of its function, the &amp;lt;tt&amp;gt;SearchDescriptor&amp;lt;/tt&amp;gt; is best compared with the search dialog from {{OOo}}. In a similar way to the search window, the settings needed for a search can be set in the &amp;lt;tt&amp;gt;SearchDescriptor&amp;lt;/tt&amp;gt; object. &lt;br /&gt;
&lt;br /&gt;
The properties are provided by the &amp;lt;idl&amp;gt;com.sun.star.util.SearchDescriptor&amp;lt;/idl&amp;gt; service: &lt;br /&gt;
&lt;br /&gt;
;&amp;lt;tt&amp;gt;SearchBackwards (Boolean)&amp;lt;/tt&amp;gt;:searches through the text backward rather than forward.&lt;br /&gt;
;&amp;lt;tt&amp;gt;SearchCaseSensitive (Boolean)&amp;lt;/tt&amp;gt;:takes uppercase and lowercase characters into consideration during the search.&lt;br /&gt;
;&amp;lt;tt&amp;gt;SearchRegularExpression (Boolean)&amp;lt;/tt&amp;gt;:treats the search expression like a regular expression.&lt;br /&gt;
;&amp;lt;tt&amp;gt;SearchStyles (Boolean)&amp;lt;/tt&amp;gt;:searches through the text for the specified paragraph template.&lt;br /&gt;
;&amp;lt;tt&amp;gt;SearchWords (Boolean)&amp;lt;/tt&amp;gt;:only searches for complete words.&lt;br /&gt;
&lt;br /&gt;
The {{OOo}} &amp;lt;tt&amp;gt;SearchSimilarity&amp;lt;/tt&amp;gt; (or “fuzzy match”) function is also available in {{OOo}} Basic. With this function, {{OOo}} searches for an expression that may be similar to but not exactly the same as the search expression. The number of additional, deleted and modified characters for these expressions can be defined individually. Here are the associated properties of the &amp;lt;tt&amp;gt;com.sun.star.util.SearchDescriptor&amp;lt;/tt&amp;gt; service:&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;tt&amp;gt;SearchSimilarity (Boolean)&amp;lt;/tt&amp;gt;:performs a similarity search.&lt;br /&gt;
;&amp;lt;tt&amp;gt;SearchSimilarityAdd (Short)&amp;lt;/tt&amp;gt;:number of characters which may be added for a similarity search.&lt;br /&gt;
;&amp;lt;tt&amp;gt;SearchSimilarityExchange (Short)&amp;lt;/tt&amp;gt;:number of characters which may be replaced as part of a similarity search.&lt;br /&gt;
;&amp;lt;tt&amp;gt;SearchSimilarityRemove (Short)&amp;lt;/tt&amp;gt;:number of characters which may be removed as part of a similarity search.&lt;br /&gt;
;&amp;lt;tt&amp;gt;SearchSimilarityRelax (Boolean)&amp;lt;/tt&amp;gt;:takes all deviation rules into consideration at the same time for the search expression.&lt;br /&gt;
&lt;br /&gt;
Once the &amp;lt;tt&amp;gt;SearchDescriptor&amp;lt;/tt&amp;gt; has been prepared as requested, it can be applied to the text document. The {{OOo}} documents provide the &amp;lt;tt&amp;gt;findFirst&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;findNext&amp;lt;/tt&amp;gt; methods for this purpose: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Found = Doc.findFirst (SearchDesc)&lt;br /&gt;
&lt;br /&gt;
Do Until IsNull(Found)&lt;br /&gt;
  &amp;#039; Edit search results...&lt;br /&gt;
  Found = Doc.findNext( Found.End, SearchDesc)&lt;br /&gt;
Loop&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example finds all matches in a loop and returns a &amp;lt;tt&amp;gt;TextRange&amp;lt;/tt&amp;gt; object, which refers to the found text passage.&lt;br /&gt;
&lt;br /&gt;
=== Example: Similarity Search  ===&lt;br /&gt;
&lt;br /&gt;
This example shows how a text can be searched for the word &amp;quot;turnover&amp;quot; and the results formatted in bold type. A similarity search is used so that not only the word “turnover”, but also the plural form &amp;quot;turnovers&amp;quot; and declinations such as &amp;quot;turnover&amp;#039;s&amp;quot; are found. The found expressions differ by up to two letters from the search expression:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim SearchDesc As Object&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
&lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
SearchDesc = Doc.createSearchDescriptor&lt;br /&gt;
SearchDesc.SearchString=&amp;quot;turnover&amp;quot;&lt;br /&gt;
SearchDesc.SearchSimilarity = True&lt;br /&gt;
SearchDesc.SearchSimilarityAdd = 2&lt;br /&gt;
SearchDesc.SearchSimilarityExchange = 2&lt;br /&gt;
SearchDesc.SearchSimilarityRemove = 2&lt;br /&gt;
SearchDesc.SearchSimilarityRelax = False&lt;br /&gt;
Found = Doc.findFirst (SearchDesc)&lt;br /&gt;
&lt;br /&gt;
Do Until IsNull(Found)&lt;br /&gt;
  Found.CharWeight = com.sun.star.awt.FontWeight.BOLD&lt;br /&gt;
  Found = Doc.findNext( Found.End, SearchDesc)&lt;br /&gt;
Loop&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Documentation/VBAnote|The basic idea of search and replace in {{OOo}} is comparable to that used in VBA. Both interfaces provide you with an object, through which the properties for searching and replacing can be defined. This object is then applied to the required text area in order to perform the action. Whereas the responsible auxiliary object in VBA can be reached through the Find property of the Range object, in {{OOo}} Basic it is created by the &amp;lt;tt&amp;gt;createSearchDescriptor&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;createReplaceDescriptor&amp;lt;/tt&amp;gt; call of the document object. Even the search properties and methods available differ.}}&lt;br /&gt;
&lt;br /&gt;
As in the old API from {{OOo}}, searching and replacing text in the new API is also performed using the document object. Whereas previously there was an object called &amp;lt;tt&amp;gt;SearchSettings&amp;lt;/tt&amp;gt; especially for defining the search options, in the new object searches are now performed using a &amp;lt;tt&amp;gt;SearchDescriptor&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;ReplaceDescriptor&amp;lt;/tt&amp;gt; object for automatically replacing text. These objects cover not only the options, but also the current search text and, if necessary, the associated text replacement. The descriptor objects are created using the document object, completed in accordance with the relevant requests, and then transferred back to the document object as parameters for the search methods.&lt;br /&gt;
&lt;br /&gt;
== Replacing Text Portions ==&lt;br /&gt;
&lt;br /&gt;
Just as with the search function, the replacement function from {{OOo}} is also available in {{OOo}} Basic. The two functions are handled identically. A special object which records the parameters for the process is also first needed for a replacement process. It is called a &amp;lt;tt&amp;gt;ReplaceDescriptor&amp;lt;/tt&amp;gt; and supports the &amp;lt;idl&amp;gt;com.sun.star.util.ReplaceDescriptor&amp;lt;/idl&amp;gt; service. All the properties of the &amp;lt;tt&amp;gt;SearchDescriptor&amp;lt;/tt&amp;gt; described in the previous paragraph are also supported by &amp;lt;tt&amp;gt;ReplaceDescriptor.&amp;lt;/tt&amp;gt; For example, during a replacement process, case sensitivity can also be activated and deactivated, and similarity searches can be performed. &lt;br /&gt;
&lt;br /&gt;
The following example demonstrates the use of &amp;lt;tt&amp;gt;ReplaceDescriptors&amp;lt;/tt&amp;gt; for a search within a {{OOo}} document.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim I As Long&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
Dim Replace As Object&lt;br /&gt;
Dim BritishWords(5) As String&lt;br /&gt;
Dim USWords(5) As String&lt;br /&gt;
&lt;br /&gt;
BritishWords() = Array(&amp;quot;colour&amp;quot;, &amp;quot;neighbour&amp;quot;, &amp;quot;centre&amp;quot;, &amp;quot;behaviour&amp;quot;, _&lt;br /&gt;
   &amp;quot;metre&amp;quot;, &amp;quot;through&amp;quot;)&lt;br /&gt;
USWords() = Array(&amp;quot;color&amp;quot;, &amp;quot;neighbor&amp;quot;, &amp;quot;center&amp;quot;, &amp;quot;behavior&amp;quot;, _&lt;br /&gt;
   &amp;quot;meter&amp;quot;, &amp;quot;thru&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
Replace = Doc.createReplaceDescriptor&lt;br /&gt;
&lt;br /&gt;
For I = 0 To 5&lt;br /&gt;
  Replace.SearchString = BritishWords(I)&lt;br /&gt;
  Replace.ReplaceString = USWords(I)&lt;br /&gt;
  Doc.replaceAll(Replace)&lt;br /&gt;
Next I&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The expressions for searching and replacing are set using the &amp;lt;tt&amp;gt;SearchString&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;ReplaceString&amp;lt;/tt&amp;gt; properties of the &amp;lt;tt&amp;gt;ReplaceDescriptors&amp;lt;/tt&amp;gt;. The actual replacement process is finally implemented using the &amp;lt;tt&amp;gt;replaceAll&amp;lt;/tt&amp;gt; method of the document object, which replaces all occurrences of the search expression. &lt;br /&gt;
&lt;br /&gt;
=== Example: searching and replacing text with regular expressions ===&lt;br /&gt;
&lt;br /&gt;
The replacement function of {{OOo}} is particularly effective when used in conjunction with regular expressions. These provide the option of defining a variable search expression with place holders and special characters rather than a fixed value. &lt;br /&gt;
&lt;br /&gt;
The regular expressions supported by {{OOo}} are described in detail in the online help section for {{OOo}}. Here are a few examples:&lt;br /&gt;
&lt;br /&gt;
* A period within a search expression stands for any character. The search expression sh.rt therefore can stand for both for &amp;lt;tt&amp;gt;shirt&amp;lt;/tt&amp;gt; and for &amp;lt;tt&amp;gt;short&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* The character ^ marks the start of a paragraph. All occurrences of the name &amp;lt;tt&amp;gt;Peter&amp;lt;/tt&amp;gt; that are at the start of a paragraph can therefore be found using the search expression &amp;lt;tt&amp;gt;^Peter&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* The character $ marks a paragraph end. All occurrences of the name &amp;lt;tt&amp;gt;Peter&amp;lt;/tt&amp;gt; that are at the end of a paragraph can therefore be found using the search expression &amp;lt;tt&amp;gt;Peter$&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* A * indicates that the preceding character may be repeated any number of times. It can be combined with the period as a place holder for any character. The &amp;lt;tt&amp;gt;temper.*e&amp;lt;/tt&amp;gt; expression, for example, can stand for the expressions &amp;lt;tt&amp;gt;temperance&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;temperature&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The following example shows how all empty lines in a text document can be removed with the help of the regular expression ^$:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
Dim Replace As Object&lt;br /&gt;
Dim I As Long&lt;br /&gt;
&lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
Replace = Doc.createReplaceDescriptor&lt;br /&gt;
Replace.SearchRegularExpression = True&lt;br /&gt;
Replace.SearchString = &amp;quot;^$&amp;quot;&lt;br /&gt;
Replace.ReplaceString = &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Doc.replaceAll(Replace)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
{{InterWiki Languages BasicGuide|articletitle=Documentation/BASIC Guide/Editing Text Documents}}&lt;br /&gt;
{{PDL1}}&lt;/div&gt;</summary>
		<author><name>Andrewb</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/BASIC_Guide/Editing_Text_Documents&amp;diff=155066</id>
		<title>Documentation/BASIC Guide/Editing Text Documents</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/BASIC_Guide/Editing_Text_Documents&amp;diff=155066"/>
		<updated>2010-01-17T06:15:12Z</updated>

		<summary type="html">&lt;p&gt;Andrewb: /* Navigating within a Text */  clarified definition of a period as sentence marker&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/BASICGuideTOC/v2&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|ShowPrevPage=block&lt;br /&gt;
|PrevPage=Documentation/BASIC Guide/Structure of Text Documents&lt;br /&gt;
|NextPage=Documentation/BASIC Guide/More Than Text&lt;br /&gt;
|textdocs=block&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Editing Text Documents}}&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
The previous section has already discussed a whole range of options for editing text documents, focusing on the &amp;lt;idl&amp;gt;com.sun.star.text.TextPortion&amp;lt;/idl&amp;gt; and &amp;lt;idl&amp;gt;com.sun.star.text.Paragraph&amp;lt;/idl&amp;gt; services, which grant access to paragraph portions as well as paragraphs. These services are appropriate for applications in which the content of a text is to be edited in one pass through a loop. However, this is not sufficient for many problems. {{OOo}} provides the &amp;lt;idl&amp;gt;com.sun.star.text.TextCursor&amp;lt;/idl&amp;gt; service for more complicated tasks, including navigating backward within a document or navigating based on sentences and words rather than &amp;lt;tt&amp;gt;TextPortions&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== The TextCursor ==&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; in the {{OOo}} API is comparable with the visible cursor used in a {{OOo}} document. It marks a certain point within a text document and can be navigated in various directions through the use of commands. The &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; objects available in {{OOo}} Basic should not, however, be confused with the visible cursor. These are two very different things.&lt;br /&gt;
&lt;br /&gt;
{{Documentation/VBAnote|Terminology differs from that used in VBA: In terms of scope of function, the Range object from VBA can be compared with the TextCursor object in {{OOo}} and not — as the name possibly suggests — with the Range object in {{OOo}}.}}&lt;br /&gt;
&lt;br /&gt;
The TextCursor object in {{OOo}}, for example, provides methods for navigating and changing text which are included in the Range object in VBA (for example, MoveStart, MoveEnd, InsertBefore, InsertAfter). The corresponding counterparts of the TextCursor object in {{OOo}} are described in the following sections.&lt;br /&gt;
&lt;br /&gt;
=== Navigating within a Text  ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; object in {{OOo}} Basic acts independently from the visible cursor in a text document. A program-controlled position change of a &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; object has no impact whatsoever on the visible cursor. Several &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; objects can even be opened for the same document and used in various positions, which are independent of one another. &lt;br /&gt;
&lt;br /&gt;
A &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; object is created using the &amp;lt;tt&amp;gt;createTextCursor&amp;lt;/tt&amp;gt; call: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
Dim Cursor As Object&lt;br /&gt;
&lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
Cursor = Doc.Text.createTextCursor()&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
The Cursor object created in this way supports the &amp;lt;tt&amp;gt;com.sun.star.text.TextCursor&amp;lt;/tt&amp;gt; service, which in turn provides a whole range of methods for navigating within text documents. The following example first moves the &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; ten characters to the left and then three characters to the right: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;Cursor.goLeft(10, False)&lt;br /&gt;
Cursor.goRight(3, False)&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
A &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; can highlight a complete area. This can be compared with highlighting a point in the text using the mouse. The &amp;lt;tt&amp;gt;False&amp;lt;/tt&amp;gt; parameter in the previous function call specifies whether the area passed over with the cursor movement is highlighted. For example, the &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; in the following example &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Cursor.goRight(10, False)&lt;br /&gt;
Cursor.goLeft(3, True)&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
first moves ten characters to the right without highlighting, and then moves back three characters and highlights this. The area highlighted by the &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; therefore begins after the seventh character in the text and ends after the tenth character. &lt;br /&gt;
&lt;br /&gt;
Here are the central methods that the &amp;lt;idl&amp;gt;com.sun.star.text.TextCursor&amp;lt;/idl&amp;gt; service provides for navigation: &lt;br /&gt;
&lt;br /&gt;
;&amp;lt;tt&amp;gt;goLeft (Count, Expand)&amp;lt;/tt&amp;gt; &lt;br /&gt;
:jumps Count characters to the left. &lt;br /&gt;
;&amp;lt;tt&amp;gt;goRight (Count, Expand)&amp;lt;/tt&amp;gt; &lt;br /&gt;
:jumps Count characters to the right. &lt;br /&gt;
;&amp;lt;tt&amp;gt;gotoStart (Expand)&amp;lt;/tt&amp;gt; &lt;br /&gt;
:jumps to the start of the text document. &lt;br /&gt;
;&amp;lt;tt&amp;gt;gotoEnd (Expand)&amp;lt;/tt&amp;gt; &lt;br /&gt;
:jumps to the end of the text document. &lt;br /&gt;
;&amp;lt;tt&amp;gt;gotoRange (TextRange, Expand)&amp;lt;/tt&amp;gt; &lt;br /&gt;
:jumps to the specified &amp;lt;tt&amp;gt;TextRange&amp;lt;/tt&amp;gt;-Object. &lt;br /&gt;
;&amp;lt;tt&amp;gt;gotoStartOfWord (Expand)&amp;lt;/tt&amp;gt; &lt;br /&gt;
:jumps to the start of the current word. &lt;br /&gt;
;&amp;lt;tt&amp;gt;gotoEndOfWord (Expand)&amp;lt;/tt&amp;gt; &lt;br /&gt;
:jumps to the end of the current word. &lt;br /&gt;
;&amp;lt;tt&amp;gt;gotoNextWord (Expand)&amp;lt;/tt&amp;gt; &lt;br /&gt;
:jumps to the start of the next word. &lt;br /&gt;
;&amp;lt;tt&amp;gt;gotoPreviousWord (Expand)&amp;lt;/tt&amp;gt; &lt;br /&gt;
:jumps to the start of the previous word. &lt;br /&gt;
;&amp;lt;tt&amp;gt;isStartOfWord ()&amp;lt;/tt&amp;gt; &lt;br /&gt;
:returns &amp;lt;tt&amp;gt;True&amp;lt;/tt&amp;gt; if the &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; is at the start of a word. &lt;br /&gt;
;&amp;lt;tt&amp;gt;isEndOfWord ()&amp;lt;/tt&amp;gt; &lt;br /&gt;
:returns &amp;lt;tt&amp;gt;True&amp;lt;/tt&amp;gt; if the &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; is at the end of a word. &lt;br /&gt;
;&amp;lt;tt&amp;gt;gotoStartOfSentence (Expand)&amp;lt;/tt&amp;gt; &lt;br /&gt;
:jumps to the start of the current sentence. &lt;br /&gt;
;&amp;lt;tt&amp;gt;gotoEndOfSentence (Expand)&amp;lt;/tt&amp;gt; &lt;br /&gt;
:jumps to the end of the current sentence. &lt;br /&gt;
;&amp;lt;tt&amp;gt;gotoNextSentence (Expand)&amp;lt;/tt&amp;gt; &lt;br /&gt;
:jumps to the start of the next sentence. &lt;br /&gt;
;&amp;lt;tt&amp;gt;gotoPreviousSentence (Expand)&amp;lt;/tt&amp;gt; &lt;br /&gt;
:jumps to the start of the previous sentence. &lt;br /&gt;
;&amp;lt;tt&amp;gt;isStartOfSentence ()&amp;lt;/tt&amp;gt; &lt;br /&gt;
:returns &amp;lt;tt&amp;gt;True&amp;lt;/tt&amp;gt; if the &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; is at the start of a sentence. &lt;br /&gt;
;&amp;lt;tt&amp;gt;isEndOfSentence ()&amp;lt;/tt&amp;gt; &lt;br /&gt;
:returns &amp;lt;tt&amp;gt;True&amp;lt;/tt&amp;gt; if the &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; is at the end of a sentence. &lt;br /&gt;
;&amp;lt;tt&amp;gt;gotoStartOfParagraph (Expand)&amp;lt;/tt&amp;gt; &lt;br /&gt;
:jumps to the start of the current paragraph. &lt;br /&gt;
;&amp;lt;tt&amp;gt;gotoEndOfParagraph (Expand)&amp;lt;/tt&amp;gt; &lt;br /&gt;
:jumps to the end of the current paragraph. &lt;br /&gt;
;&amp;lt;tt&amp;gt;gotoNextParagraph (Expand)&amp;lt;/tt&amp;gt; &lt;br /&gt;
:jumps to the start of the next paragraph. &lt;br /&gt;
;&amp;lt;tt&amp;gt;gotoPreviousParagraph (Expand)&amp;lt;/tt&amp;gt; &lt;br /&gt;
:jumps to the start of the previous paragraph. &lt;br /&gt;
;&amp;lt;tt&amp;gt;isStartOfParagraph ()&amp;lt;/tt&amp;gt; &lt;br /&gt;
:returns &amp;lt;tt&amp;gt;True&amp;lt;/tt&amp;gt; if the &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; is at the start of a paragraph. &lt;br /&gt;
;&amp;lt;tt&amp;gt;isEndOfParagraph ()&amp;lt;/tt&amp;gt; &lt;br /&gt;
:returns &amp;lt;tt&amp;gt;True&amp;lt;/tt&amp;gt; if the &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; is at the end of a paragraph.&lt;br /&gt;
&lt;br /&gt;
The text is divided into sentences on the basis of sentence symbols. Periods  are, for example, interpreted as symbols indicating the end of sentences. (In English, at least, they must be followed by a space for this to work.) &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;Expand&amp;lt;/tt&amp;gt; parameter is a Boolean value which specifies whether the area passed over during navigation is to be highlighted. All navigation methods furthermore return a Boolean parameter which specifies whether the navigation was successful or whether the action was terminated for lack of text. &lt;br /&gt;
&lt;br /&gt;
The following is a list of several methods for editing highlighted areas using a &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; and which also support the &amp;lt;idl&amp;gt;com.sun.star.text.TextCursor&amp;lt;/idl&amp;gt; service: &lt;br /&gt;
&lt;br /&gt;
;&amp;lt;tt&amp;gt;collapseToStart ()&amp;lt;/tt&amp;gt; &lt;br /&gt;
:resets the highlighting and positions the &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; at the start of the previously highlighted area. &lt;br /&gt;
;&amp;lt;tt&amp;gt;collapseToEnd ()&amp;lt;/tt&amp;gt; &lt;br /&gt;
:resets the highlighting and positions the &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; at the end of the previously highlighted area. &lt;br /&gt;
;&amp;lt;tt&amp;gt;isCollapsed ()&amp;lt;/tt&amp;gt; &lt;br /&gt;
:returns &amp;lt;tt&amp;gt;True&amp;lt;/tt&amp;gt; if the &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; does not cover any highlighting at present.&lt;br /&gt;
&lt;br /&gt;
=== Formatting Text with TextCursor ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;idl&amp;gt;com.sun.star.text.TextCursor&amp;lt;/idl&amp;gt; service supports all the character and paragraph properties that were presented at the start of this chapter. &lt;br /&gt;
&lt;br /&gt;
The following example shows how these can be used in conjunction with a &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt;. It passes through a complete document and formats the first word of every sentence in bold type. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object   &lt;br /&gt;
Dim Cursor As Object&lt;br /&gt;
Dim Proceed As Boolean&lt;br /&gt;
&lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
Cursor = Doc.Text.createTextCursor&lt;br /&gt;
&lt;br /&gt;
Do &lt;br /&gt;
  Cursor.gotoEndOfWord(True)&lt;br /&gt;
  Cursor.CharWeight = com.sun.star.awt.FontWeight.BOLD&lt;br /&gt;
  Proceed = Cursor.gotoNextSentence(False)&lt;br /&gt;
  Cursor.gotoNextWord(False)&lt;br /&gt;
Loop While Proceed &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example first creates a document object for the text that has just been opened. Then it iterates through the entire text, sentence by sentence, and highlights each of the first words and formats this in bold.&lt;br /&gt;
&lt;br /&gt;
=== Retrieving and Modifying Text Contents ===&lt;br /&gt;
&lt;br /&gt;
If a &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; contains a highlighted area, then this text is available by means of the &amp;lt;tt&amp;gt;String&amp;lt;/tt&amp;gt; property of the &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; object. The following example uses the &amp;lt;tt&amp;gt;String&amp;lt;/tt&amp;gt; property to display the first words of a sentence in a message box:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object   &lt;br /&gt;
Dim Cursor As Object&lt;br /&gt;
Dim Proceed As Boolean&lt;br /&gt;
&lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
Cursor = Doc.Text.createTextCursor&lt;br /&gt;
&lt;br /&gt;
Do &lt;br /&gt;
  Cursor.gotoEndOfWord(True)&lt;br /&gt;
  MsgBox Cursor.String&lt;br /&gt;
  Proceed = Cursor.gotoNextSentence(False)&lt;br /&gt;
  Cursor.gotoNextWord(False)&lt;br /&gt;
Loop While Proceed &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first word of each sentence can be modified in the same way using the &amp;lt;tt&amp;gt;String&amp;lt;/tt&amp;gt; property: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object   &lt;br /&gt;
Dim Cursor As Object&lt;br /&gt;
Dim Proceed As Boolean&lt;br /&gt;
&lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
Cursor = Doc.Text.createTextCursor&lt;br /&gt;
&lt;br /&gt;
Do &lt;br /&gt;
  Cursor.gotoEndOfWord(True)&lt;br /&gt;
  Cursor.String = &amp;quot;Ups&amp;quot;&lt;br /&gt;
  Proceed = Cursor.gotoNextSentence(False)&lt;br /&gt;
  Cursor.gotoNextWord(False)&lt;br /&gt;
Loop While Proceed &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; contains a highlighted area, an assignment to the &amp;lt;tt&amp;gt;String&amp;lt;/tt&amp;gt; property replaces this with the new text. If there is no highlighted area, the text is inserted at the present &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; position.&lt;br /&gt;
&lt;br /&gt;
=== Inserting Control Codes ===&lt;br /&gt;
&lt;br /&gt;
In some situations, it is not the actual text of a document, but rather its structure that needs modifying. {{OOo}} provides control codes for this purpose. These are inserted in the text and influence its structure. The control codes are defined in the &amp;lt;idl&amp;gt;com.sun.star.text.ControlCharacter&amp;lt;/idl&amp;gt; group of constants. The following control codes are available in {{OOo}}:&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;tt&amp;gt;PARAGRAPH_BREAK&amp;lt;/tt&amp;gt;:paragraph break.&lt;br /&gt;
;&amp;lt;tt&amp;gt;LINE_BREAK&amp;lt;/tt&amp;gt;:line break within a paragraph.&lt;br /&gt;
;&amp;lt;tt&amp;gt;SOFT_HYPHEN&amp;lt;/tt&amp;gt;:possible point for syllabification.&lt;br /&gt;
;&amp;lt;tt&amp;gt;HARD_HYPHEN&amp;lt;/tt&amp;gt;:obligatory point for syllabification.&lt;br /&gt;
;&amp;lt;tt&amp;gt;HARD_SPACE&amp;lt;/tt&amp;gt;:protected space that is not spread out or compressed in justified text.&lt;br /&gt;
&lt;br /&gt;
To insert the control codes, you need not only the cursor but also the associated text document objects. The following example inserts a paragraph after the 20th character of a text:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object   &lt;br /&gt;
Dim Cursor As Object&lt;br /&gt;
Dim Proceed As Boolean&lt;br /&gt;
&lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
Cursor = Doc.Text.createTextCursor&lt;br /&gt;
Cursor.goRight(20, False)&lt;br /&gt;
Doc.Text.insertControlCharacter(Cursor, _&lt;br /&gt;
    com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, False)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;False&amp;lt;/tt&amp;gt; parameter in the call of the &amp;lt;tt&amp;gt;insertControlCharacter&amp;lt;/tt&amp;gt; method ensures that the area currently highlighted by the &amp;lt;tt&amp;gt;TextCursor&amp;lt;/tt&amp;gt; remains after the insert operation. If the &amp;lt;tt&amp;gt;True&amp;lt;/tt&amp;gt; parameter is passed here, then &amp;lt;tt&amp;gt;insertControlCharacter&amp;lt;/tt&amp;gt; replaces the current text.&lt;br /&gt;
&lt;br /&gt;
== Searching for Text Portions ==&lt;br /&gt;
&lt;br /&gt;
In many instances, it is the case that a text is to be searched for a particular term and the corresponding point needs to be edited. All {{OOo}} documents provide a special interface for this purpose, and this interface always functions in accordance with the same principle: Before a search process, what is commonly referred to as a &amp;lt;tt&amp;gt;SearchDescriptor&amp;lt;/tt&amp;gt; must first be created. This defines what {{OOo}} searches for in a document. A &amp;lt;tt&amp;gt;SearchDescriptor&amp;lt;/tt&amp;gt; is an object which supports the &amp;lt;tt&amp;gt;com.sun.star.util.&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;SearchDescriptor&amp;lt;/tt&amp;gt; service and can be created by means of the &amp;lt;tt&amp;gt;createSearchDescriptor&amp;lt;/tt&amp;gt; method of a document: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim SearchDesc As Object&lt;br /&gt;
SearchDesc = Doc.createSearchDescriptor&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once the &amp;lt;tt&amp;gt;SearchDescriptor&amp;lt;/tt&amp;gt; has been created, it receives the text to be searched for:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
SearchDesc.searchString=&amp;quot;any text&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In terms of its function, the &amp;lt;tt&amp;gt;SearchDescriptor&amp;lt;/tt&amp;gt; is best compared with the search dialog from {{OOo}}. In a similar way to the search window, the settings needed for a search can be set in the &amp;lt;tt&amp;gt;SearchDescriptor&amp;lt;/tt&amp;gt; object. &lt;br /&gt;
&lt;br /&gt;
The properties are provided by the &amp;lt;idl&amp;gt;com.sun.star.util.SearchDescriptor&amp;lt;/idl&amp;gt; service: &lt;br /&gt;
&lt;br /&gt;
;&amp;lt;tt&amp;gt;SearchBackwards (Boolean)&amp;lt;/tt&amp;gt;:searches through the text backward rather than forward.&lt;br /&gt;
;&amp;lt;tt&amp;gt;SearchCaseSensitive (Boolean)&amp;lt;/tt&amp;gt;:takes uppercase and lowercase characters into consideration during the search.&lt;br /&gt;
;&amp;lt;tt&amp;gt;SearchRegularExpression (Boolean)&amp;lt;/tt&amp;gt;:treats the search expression like a regular expression.&lt;br /&gt;
;&amp;lt;tt&amp;gt;SearchStyles (Boolean)&amp;lt;/tt&amp;gt;:searches through the text for the specified paragraph template.&lt;br /&gt;
;&amp;lt;tt&amp;gt;SearchWords (Boolean)&amp;lt;/tt&amp;gt;:only searches for complete words.&lt;br /&gt;
&lt;br /&gt;
The {{OOo}} &amp;lt;tt&amp;gt;SearchSimilarity&amp;lt;/tt&amp;gt; (or “fuzzy match”) function is also available in {{OOo}} Basic. With this function, {{OOo}} searches for an expression that may be similar to but not exactly the same as the search expression. The number of additional, deleted and modified characters for these expressions can be defined individually. Here are the associated properties of the &amp;lt;tt&amp;gt;com.sun.star.util.SearchDescriptor&amp;lt;/tt&amp;gt; service:&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;tt&amp;gt;SearchSimilarity (Boolean)&amp;lt;/tt&amp;gt;:performs a similarity search.&lt;br /&gt;
;&amp;lt;tt&amp;gt;SearchSimilarityAdd (Short)&amp;lt;/tt&amp;gt;:number of characters which may be added for a similarity search.&lt;br /&gt;
;&amp;lt;tt&amp;gt;SearchSimilarityExchange (Short)&amp;lt;/tt&amp;gt;:number of characters which may be replaced as part of a similarity search.&lt;br /&gt;
;&amp;lt;tt&amp;gt;SearchSimilarityRemove (Short)&amp;lt;/tt&amp;gt;:number of characters which may be removed as part of a similarity search.&lt;br /&gt;
;&amp;lt;tt&amp;gt;SearchSimilarityRelax (Boolean)&amp;lt;/tt&amp;gt;:takes all deviation rules into consideration at the same time for the search expression.&lt;br /&gt;
&lt;br /&gt;
Once the &amp;lt;tt&amp;gt;SearchDescriptor&amp;lt;/tt&amp;gt; has been prepared as requested, it can be applied to the text document. The {{OOo}} documents provide the &amp;lt;tt&amp;gt;findFirst&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;findNext&amp;lt;/tt&amp;gt; methods for this purpose: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Found = Doc.findFirst (SearchDesc)&lt;br /&gt;
&lt;br /&gt;
Do Until IsNull(Found)&lt;br /&gt;
  &amp;#039; Edit search results...&lt;br /&gt;
  Found = Doc.findNext( Found.End, SearchDesc)&lt;br /&gt;
Loop&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example finds all matches in a loop and returns a &amp;lt;tt&amp;gt;TextRange&amp;lt;/tt&amp;gt; object, which refers to the found text passage.&lt;br /&gt;
&lt;br /&gt;
=== Example: Similarity Search  ===&lt;br /&gt;
&lt;br /&gt;
This example shows how a text can be searched for the word &amp;quot;turnover&amp;quot; and the results formatted in bold type. A similarity search is used so that not only the word “turnover”, but also the plural form &amp;quot;turnovers&amp;quot; and declinations such as &amp;quot;turnover&amp;#039;s&amp;quot; are found. The found expressions differ by up to two letters from the search expression:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim SearchDesc As Object&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
&lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
SearchDesc = Doc.createSearchDescriptor&lt;br /&gt;
SearchDesc.SearchString=&amp;quot;turnover&amp;quot;&lt;br /&gt;
SearchDesc.SearchSimilarity = True&lt;br /&gt;
SearchDesc.SearchSimilarityAdd = 2&lt;br /&gt;
SearchDesc.SearchSimilarityExchange = 2&lt;br /&gt;
SearchDesc.SearchSimilarityRemove = 2&lt;br /&gt;
SearchDesc.SearchSimilarityRelax = False&lt;br /&gt;
Found = Doc.findFirst (SearchDesc)&lt;br /&gt;
&lt;br /&gt;
Do Until IsNull(Found)&lt;br /&gt;
  Found.CharWeight = com.sun.star.awt.FontWeight.BOLD&lt;br /&gt;
  Found = Doc.findNext( Found.End, SearchDesc)&lt;br /&gt;
Loop&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Documentation/VBAnote|The basic idea of search and replace in {{OOo}} is comparable to that used in VBA. Both interfaces provide you with an object, through which the properties for searching and replacing can be defined. This object is then applied to the required text area in order to perform the action. Whereas the responsible auxiliary object in VBA can be reached through the Find property of the Range object, in {{OOo}} Basic it is created by the &amp;lt;tt&amp;gt;createSearchDescriptor&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;createReplaceDescriptor&amp;lt;/tt&amp;gt; call of the document object. Even the search properties and methods available differ.}}&lt;br /&gt;
&lt;br /&gt;
As in the old API from {{OOo}}, searching and replacing text in the new API is also performed using the document object. Whereas previously there was an object called &amp;lt;tt&amp;gt;SearchSettings&amp;lt;/tt&amp;gt; especially for defining the search options, in the new object searches are now performed using a &amp;lt;tt&amp;gt;SearchDescriptor&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;ReplaceDescriptor&amp;lt;/tt&amp;gt; object for automatically replacing text. These objects cover not only the options, but also the current search text and, if necessary, the associated text replacement. The descriptor objects are created using the document object, completed in accordance with the relevant requests, and then transferred back to the document object as parameters for the search methods.&lt;br /&gt;
&lt;br /&gt;
== Replacing Text Portions ==&lt;br /&gt;
&lt;br /&gt;
Just as with the search function, the replacement function from {{OOo}} is also available in {{OOo}} Basic. The two functions are handled identically. A special object which records the parameters for the process is also first needed for a replacement process. It is called a &amp;lt;tt&amp;gt;ReplaceDescriptor&amp;lt;/tt&amp;gt; and supports the &amp;lt;idl&amp;gt;com.sun.star.util.ReplaceDescriptor&amp;lt;/idl&amp;gt; service. All the properties of the &amp;lt;tt&amp;gt;SearchDescriptor&amp;lt;/tt&amp;gt; described in the previous paragraph are also supported by &amp;lt;tt&amp;gt;ReplaceDescriptor.&amp;lt;/tt&amp;gt; For example, during a replacement process, case sensitivity can also be activated and deactivated, and similarity searches can be performed. &lt;br /&gt;
&lt;br /&gt;
The following example demonstrates the use of &amp;lt;tt&amp;gt;ReplaceDescriptors&amp;lt;/tt&amp;gt; for a search within a {{OOo}} document.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim I As Long&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
Dim Replace As Object&lt;br /&gt;
Dim BritishWords(5) As String&lt;br /&gt;
Dim USWords(5) As String&lt;br /&gt;
&lt;br /&gt;
BritishWords() = Array(&amp;quot;colour&amp;quot;, &amp;quot;neighbour&amp;quot;, &amp;quot;centre&amp;quot;, &amp;quot;behaviour&amp;quot;, _&lt;br /&gt;
   &amp;quot;metre&amp;quot;, &amp;quot;through&amp;quot;)&lt;br /&gt;
USWords() = Array(&amp;quot;color&amp;quot;, &amp;quot;neighbor&amp;quot;, &amp;quot;center&amp;quot;, &amp;quot;behavior&amp;quot;, _&lt;br /&gt;
   &amp;quot;meter&amp;quot;, &amp;quot;thru&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
Replace = Doc.createReplaceDescriptor&lt;br /&gt;
&lt;br /&gt;
For I = 0 To 5&lt;br /&gt;
  Replace.SearchString = BritishWords(I)&lt;br /&gt;
  Replace.ReplaceString = USWords(I)&lt;br /&gt;
  Doc.replaceAll(Replace)&lt;br /&gt;
Next I&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The expressions for searching and replacing are set using the &amp;lt;tt&amp;gt;SearchString&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;ReplaceString&amp;lt;/tt&amp;gt; properties of the &amp;lt;tt&amp;gt;ReplaceDescriptors&amp;lt;/tt&amp;gt;. The actual replacement process is finally implemented using the &amp;lt;tt&amp;gt;replaceAll&amp;lt;/tt&amp;gt; method of the document object, which replaces all occurrences of the search expression. &lt;br /&gt;
&lt;br /&gt;
=== Example: searching and replacing text with regular expressions ===&lt;br /&gt;
&lt;br /&gt;
The replacement function of {{OOo}} is particularly effective when used in conjunction with regular expressions. These provide the option of defining a variable search expression with place holders and special characters rather than a fixed value. &lt;br /&gt;
&lt;br /&gt;
The regular expressions supported by {{OOo}} are described in detail in the online help section for {{OOo}}. Here are a few examples:&lt;br /&gt;
&lt;br /&gt;
* A period within a search expression stands for any character. The search expression sh.rt therefore can stand for both for &amp;lt;tt&amp;gt;shirt&amp;lt;/tt&amp;gt; and for &amp;lt;tt&amp;gt;short&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* The character ^ marks the start of a paragraph. All occurrences of the name &amp;lt;tt&amp;gt;Peter&amp;lt;/tt&amp;gt; that are at the start of a paragraph can therefore be found using the search expression &amp;lt;tt&amp;gt;^Peter&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* The character $ marks a paragraph end. All occurrences of the name &amp;lt;tt&amp;gt;Peter&amp;lt;/tt&amp;gt; that are at the end of a paragraph can therefore be found using the search expression &amp;lt;tt&amp;gt;Peter$&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* A * indicates that the preceding character may be repeated any number of times. It can be combined with the period as a place holder for any character. The &amp;lt;tt&amp;gt;temper.*e&amp;lt;/tt&amp;gt; expression, for example, can stand for the expressions &amp;lt;tt&amp;gt;temperance&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;temperature&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The following example shows how all empty lines in a text document can be removed with the help of the regular expression ^$:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
Dim Replace As Object&lt;br /&gt;
Dim I As Long&lt;br /&gt;
&lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
Replace = Doc.createReplaceDescriptor&lt;br /&gt;
Replace.SearchRegularExpression = True&lt;br /&gt;
Replace.SearchString = &amp;quot;^$&amp;quot;&lt;br /&gt;
Replace.ReplaceString = &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Doc.replaceAll(Replace)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
{{InterWiki Languages BasicGuide|articletitle=Documentation/BASIC Guide/Editing Text Documents}}&lt;br /&gt;
{{PDL1}}&lt;/div&gt;</summary>
		<author><name>Andrewb</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Non-code_extensions&amp;diff=147336</id>
		<title>Non-code extensions</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Non-code_extensions&amp;diff=147336"/>
		<updated>2009-11-19T06:05:07Z</updated>

		<summary type="html">&lt;p&gt;Andrewb: /* AutoText Extensions */ very small colloquialisations&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Extensions}}&lt;br /&gt;
[[Category:Extensions]]&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= OOo Extensions: Basic Principles =&lt;br /&gt;
&lt;br /&gt;
OpenOffice.org was designed to be extendable from its very beginning. At first every extension was something that contained code (e.g. written in Java or OOo Basic). It was integrated into OOo by our component technology called UNO, so the file containing such an extension was called a &amp;quot;UNO package&amp;quot;. Meanwhile OOo extension have reached the world of end users and so we thought that it&amp;#039;s time to change our terminology a bit. The following documentation takes this into account. It tries to avoid the more technical term &amp;quot;UNO package&amp;quot; where possible as the purpose of this documentation is to provide an overview and an explanation of the basic concepts. If you want to learn more about UNO you can check our [http://wiki.services.openoffice.org/wiki/Uno UNO wiki] or the web pages of the [http://udk.openoffice.org UDK project]. &lt;br /&gt;
&lt;br /&gt;
The OpenOffice.org extension concept is not limited to code, it also allows to install other things like templates, autotexts etc. in handy single files. Here&amp;#039;s a short explanation how this basically works. It is targeted to advanced end users, administrators and development newbies. All information provided here describes what is found in OpenOffice.org 2.0.4. Differences to older versions are not explained though it is explicitly mentioned when something has been added in 2.0.4 first. &lt;br /&gt;
&lt;br /&gt;
If you are not interested in development at all you might want to skip the section about code extensions. &lt;br /&gt;
&lt;br /&gt;
The section about the Configuration Manager gives you some ideas how you can use OOo extensions for customization purposes. &lt;br /&gt;
&lt;br /&gt;
If you are only interested in knowing how to create non-code extensions without really knowing how this works you can go right to the section about &amp;quot;Path Settings&amp;quot;. You should read at least this introducing section though. &lt;br /&gt;
&lt;br /&gt;
Please send feedback to [[Image:Ooo-email.PNG]].&lt;br /&gt;
In case you have an account for this wiki you can of course also use the &amp;quot;Discussion&amp;quot; tab at the top of this page.&lt;br /&gt;
&lt;br /&gt;
OOo Extensions are more or less zip containers with some additional data and meta data describing its content. They can be deployed by the built-in Extension Manager GUI (“Tools – Package Manager”, it will become renamed to &amp;quot;Tools-Extension Manager&amp;quot; in 2.0.5). It installs the extension for the current user using OpenOffice.org. The same can be done by using the command line tool “unopkg” that is located in the OOo program folder. This tool also allows to deploy an extension not only for a single user but for all of them by using the “--shared” parameter. &lt;br /&gt;
&lt;br /&gt;
When extensions are installed their content is copied to some well defined though private places below “share/uno_packages” or “user/uno_packages”, depending on the scope of the extension installation (whole installation or single user). &amp;quot;Private&amp;quot; means: don&amp;#039;t write any code that relies on the particular structure of an unpacked extension, access to unpacked files must use a defined API that handles the details for the caller. Files outside the &amp;quot;uno_packages&amp;quot; folders are not touched at all, with a single exception that can be seen as a [http://www.openoffice.org/issues/show_bug.cgi?id=70283 bug]: Basic macros in OOo extensions still need to be registered in xlc-files in one of the &amp;quot;basic&amp;quot; directories. &lt;br /&gt;
&lt;br /&gt;
OOo extensions also support &amp;quot;Live deployment&amp;quot;. This is different to e.g. Firefox where you always have to restart the application to make the extension available. In OpenOffice.org you can basically use the extension right after its installation. There is a restriction though: it is possible that the OpenOffice.org code using whatever is installed by the extension might &amp;quot;cache&amp;quot; what it finds when it is executed the first time and does not update this cached information when external influences (like the installation of an extension) actually would make it invalid. So at least either opening a new window or document or restarting the application can be necessary. In most cases this can be seen as a bug. As an example, in OpenOffice.org 2.0.4 templates extensions can be installed whenever wanted, but gallery extensions should be installed before the gallery is used the first time.&lt;br /&gt;
&lt;br /&gt;
== Extensions containing UNO services (code) ==&lt;br /&gt;
&lt;br /&gt;
If an OOo extension contains a UNO component written in Java, C++ or Python this component must publish its functionality to become usable for OpenOffice.org. In UNO based development a defined set of functionality is called a &amp;quot;service&amp;quot;. A service is identified and accessed by its service name. So a component implementing such services must tell the world how they are named. Nowadays all components export a function that unopkg can call to force the component to write the necessary information into a service registry file that is created and maintained inside the „uno_packages“ folder. When OpenOffice.org uses its Service Manager to look for available UNO services it will scan not only the service registry (services.rdb) in its program directory (containing information about all &amp;quot;internal&amp;quot; services) but also all registry files inside the “uno_packages” folders.&lt;br /&gt;
&lt;br /&gt;
Of course OOo can only instantiate UNO services by their names if it knows them. This is easy for services that replace already existing &amp;quot;internal&amp;quot; ones as OOo surely knows them and uses them, but as most components provide new services there must be something else that enables OOo to use them though they are not known at its compile time. So in these cases UNO components must provide additional data about when a particular service they implement should be loaded. The „additional component data“ is provided in OOo configuration files. &lt;br /&gt;
&lt;br /&gt;
An example for this is a document filter component where the additional data that needs to be provided is (amongst other things) the file type that the filter can load. A particular filter component might register itself for being able to load Word Perfect files. So if a user selected this filter to load a file OOo would find the registered data by searching for any data containing the desired file type (wps), instantiate the filter component by its service name found in this data and use it to load the file. Each built-in filter has its own configuration data and document filters in extensions provide their own configuration data that extends the preinstalled data. So the Configuration Manager must be able to locate them and integrate their content in the suitable way.&lt;br /&gt;
&lt;br /&gt;
== Extension support in the Configuration Manager ==&lt;br /&gt;
The Configuration Manager has a similar ability as the UNO Service Manager, it can scan a set of folders for data and puts them all together. The list of folders is extendable itself (through configmanager.ini) so that the Config Manager can get additional &amp;quot;layers&amp;quot;. It even has the ability to use other backends than the file system for additional layers but I leave this out here. &lt;br /&gt;
&lt;br /&gt;
The configuration data is arranged in a tree structure, data can be filled into this structure in every layer. The Configuration Manager scans the layers (folders) in a way that the data in &amp;quot;higher&amp;quot; layers either replaces or extends the data in &amp;quot;lower&amp;quot; layers, pretty much like the Windows registry does. Whether data is replaced or extended depends on the type of the data and is explained in the discussion of the [[Configuration_schema_path_settings|configuration schema for our path settings.]]&lt;br /&gt;
&lt;br /&gt;
By default OpenOffice.org has two layers you already know: &amp;quot;share&amp;quot; and &amp;quot;user&amp;quot;. The former contains preinstalled data, the latter takes all settings a particular users created by himself. Configuration files in OOo extensions create two new layers, &amp;quot;share/uno_packages&amp;quot; and &amp;quot;user/uno_packages&amp;quot;. They lie in between the default layers, in the obvious order of priority &amp;quot;share&amp;quot; - &amp;quot;share/uno_packages&amp;quot; - &amp;quot;user/uno_packages&amp;quot; - &amp;quot;user&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
So an extension can extend or change the OpenOffice.org configuration by providing xcu files that overwrite or extend (merge) configuration settings of OpenOffice.org. It can also have its own configuration settings if it provides schema (xcs) files for them.&lt;br /&gt;
&lt;br /&gt;
There is another (pretty obvious) use case for the layering concept of the Configuration Manager: overwriting the preinstalled OpenOffice.org configuration settings on the &amp;quot;all users&amp;quot; level. An administrator can customize the OpenOffice.org installation in his own account, take the created xcu files containing these customizations and bundle them in an extension that he installs with &amp;quot;unopkg add --shared&amp;quot; each time he installs, reinstalls or updates OpenOffice.org. No need to edit the xcu files in &amp;quot;share/registry&amp;quot; by hand!&lt;br /&gt;
&lt;br /&gt;
The layering concept of the service registry and the configuration are the basic principles that create the power of OOo extensions.&lt;br /&gt;
&lt;br /&gt;
= Path Settings =&lt;br /&gt;
Some data in OpenOffice.org is not stored in xcu configuration files but somewhere else in the file system, e.g. document templates, autotexts, gallery content etc. Of course this content also should be deployable as extensions, so the access to these files must have a layering concept that allows extensions to meddle in the access to the files. OpenOffice.org has some components that manage the access to the files. We could have extended these components in the same way as we have extended the Configuration Manager or the Service Manager (by enabling them to use layers explicitly), but we decided to reuse the already available capability of the Configuration Manager. &lt;br /&gt;
&lt;br /&gt;
The place where these files are looked for is defined in the configuration, in our path settings. Each &amp;quot;path&amp;quot; in any OOo version prior to 2.0.4 either was a single string describing a folder or a list of strings describing a list of folders (&amp;quot;multipath&amp;quot;). Unfortunately such a list can only be &amp;#039;&amp;#039;&amp;#039;overwritten&amp;#039;&amp;#039;&amp;#039; in upper layers, but not &amp;#039;&amp;#039;&amp;#039;extended&amp;#039;&amp;#039;&amp;#039;, so we needed a [[Configuration_schema_path_settings|new configuration schema]] for paths that uses &amp;quot;sets&amp;quot; of strings instead of &amp;quot;string lists&amp;quot; as sets are extendable. We use this new schema for path settings starting with [http://specs.openoffice.org/appwide/options_settings/OOoPaths.odt OpenOffice.org 2.0.4]. We kept the old schema and its data for compatibility reasons and migrate its settings to the new data. The old schema will be removed in OpenOffice.org 3.0.&lt;br /&gt;
&lt;br /&gt;
In earlier versions of OOo you usually could see the two &amp;quot;templates&amp;quot; folders in the &amp;quot;share&amp;quot; and &amp;quot;user&amp;quot; trees of OpenOffice.org. You also could see any additional folders that either the user of the administrator might have added. &lt;br /&gt;
&lt;br /&gt;
If you look on the “Paths” settings in the “Options” Dialog in OOo2.0.4 you will notice that not all parts of the multipaths are shown here, only the folders from the &amp;quot;UserPaths&amp;quot; and &amp;quot;WritePath&amp;quot; elements from the [[Configuration_schema_path_settings|new configuration schema]]. As the former is empty in a default installation usually only one folder is visible per path setting.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Dialog Tools - Options - Paths&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
       [[Image:Dialog_Tools_Options_204.png]]&lt;br /&gt;
&lt;br /&gt;
Have a look on the path for templates. You can see &amp;quot;user/template&amp;quot; as this is the &amp;quot;WritePath&amp;quot; element and another folder (&amp;quot;g:\Departement Templates&amp;quot;) that has been added as part of the &amp;quot;UserPaths&amp;quot; element, either by an administrator or by the user himself. You don&amp;#039;t see the &amp;quot;share/templates&amp;quot; folder here as it is part of the &amp;quot;InternalPaths&amp;quot; element whose content intentionally isn&amp;#039;t shown in the dialog. This element is the extendable part of the path setting and it contains all folders that are added either by the OOo installation itself or by the installation of an extension. As they have been added by deployement they shouldn&amp;#039;t be controlled by the user, removing them is a task for those who have added them.&lt;br /&gt;
&lt;br /&gt;
An improvement for the users as well as for the OpenOffice.org code is that now the folder that a user can put own data in is selected explicitly by marking it with a radio button. In older versions it was always a little bit unclear which folder OpenOffice.org whould choose. In most cases it was the last one of the list but now everything is unmistakable.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Dialog Tools - Options - Paths - Edit&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
       [[Image:Dialog_Tools_Options_Edit_204.png]]&lt;br /&gt;
&lt;br /&gt;
= Templates Extensions =&lt;br /&gt;
&lt;br /&gt;
An extension for document templates is quite simple. It mainly contains just the templates, organized in directories that define template categories for the Document Templates Manager. Additionally a Paths.xcu file has to be provided that registers the extension in the set of document templates folders. This file contains the URL of the folder where the templates in the extension will be unpacked to. As this is something that isn&amp;#039;t known the creation time of the extension a variable is used in the URL that is replaced by the extension manager when he copies the xcu file to the final location. The good thing is that this variable will always be the same for each templates extension so there is no need for the creator of such an extension to create by himself:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Paths.xcu&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;#039;1.0&amp;#039; encoding=&amp;#039;UTF-8&amp;#039;?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;oor:component-data oor:package=&amp;quot;org.openoffice.Office&amp;quot; &lt;br /&gt;
    oor:name=&amp;quot;Paths&amp;quot; xmlns:install=&amp;quot;http://openoffice.org/2004/installation&amp;quot; &lt;br /&gt;
    xmlns:oor=&amp;quot;http://openoffice.org/2001/registry&amp;quot; &lt;br /&gt;
    xmlns:xs=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot; &lt;br /&gt;
    xmlns:xsi=&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;node oor:name=&amp;quot;Paths&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;node oor:name=&amp;quot;Template&amp;quot; oor:op=&amp;quot;fuse&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;node oor:name=&amp;quot;InternalPaths&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;node oor:name=&amp;quot;%origin%/template&amp;quot; oor:op=&amp;quot;fuse&amp;quot;/&amp;gt;&lt;br /&gt;
			&amp;lt;/node&amp;gt;&lt;br /&gt;
		&amp;lt;/node&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;/node&amp;gt;&lt;br /&gt;
&amp;lt;/oor:component-data&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you compare this data with the data in [[Configuration_schema_path_settings#Data_based_on_new_schema|the installation]] you can see that both files contain something in the &amp;quot;InternalPaths&amp;quot; that the configuration merges into its name container representing this element. Merging is caused by the &amp;quot;fuse&amp;quot; keyword that defines the operation &amp;quot;add me to the container or create a new container if it doesn&amp;#039;t exist&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
[http://framework.openoffice.org/files/documents/25/3702/TemplatePackage.oxt Here] is an &amp;quot;empty extension&amp;quot; for document templates that is ready to be filled with templates.&lt;br /&gt;
&lt;br /&gt;
The zip container has a folder called “templates”. Any sub folder of it you create will appear as a template category in the OOo templates dialogs. Templates can be put into those sub folders. The title of the template will be taken from the document metadata (document properties) or from the file name if the title in the metadata is not set. If one of your sub folders has the same name as an existing template category the templates in the extension will be merged into this category by the OpenOffice.org templates component. Just try it out, it&amp;#039;s simpler to do it than to explain it.&lt;br /&gt;
&lt;br /&gt;
== Localization of templates and template categories ==&lt;br /&gt;
The titles of the categories and templates can be taken from the file and folder names. These names can be localized and use any characters that the zip container and the target file systems(s) allow. It is possible that templates are installed on file systems that have problems with localized category (=folder) names so the Document Templates component allows to provide these localized names in a different file. The localized document template names can be stored in the document meta data (Document Properties) so they don&amp;#039;t create a problem here.&lt;br /&gt;
&lt;br /&gt;
The localization file is called &amp;quot;groupuinames.xml&amp;quot; and it is placed in the &amp;quot;templates&amp;quot; sub directory of the zip container. Its content is pretty straightforward. Here&amp;#039;s an example for a german localization of some folders that use english file names:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;groupuinames.xml&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;groupuinames:template-group-list xmlns:groupuinames=&amp;quot;http://openoffice.org/2006/groupuinames&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;groupuinames:template-group groupuinames:name=&amp;quot;educate&amp;quot; &lt;br /&gt;
                groupuinames:default-ui-name=&amp;quot;Bildung&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;groupuinames:template-group groupuinames:name=&amp;quot;layout&amp;quot; &lt;br /&gt;
                groupuinames:default-ui-name=&amp;quot;Präsentationshintergründe&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;groupuinames:template-group groupuinames:name=&amp;quot;misc&amp;quot; &lt;br /&gt;
                groupuinames:default-ui-name=&amp;quot;Diverses&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;groupuinames:template-group groupuinames:name=&amp;quot;officorr&amp;quot; &lt;br /&gt;
                groupuinames:default-ui-name=&amp;quot;Geschäftliche Korrespondenz&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;groupuinames:template-group groupuinames:name=&amp;quot;offimisc&amp;quot; &lt;br /&gt;
                groupuinames:default-ui-name=&amp;quot;Sonstige geschäftliche Dokumente&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;groupuinames:template-group groupuinames:name=&amp;quot;personal&amp;quot; &lt;br /&gt;
                groupuinames:default-ui-name=&amp;quot;Private Korrespondenz und Dokumente&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;groupuinames:template-group groupuinames:name=&amp;quot;presnt&amp;quot; &lt;br /&gt;
                groupuinames:default-ui-name=&amp;quot;Präsentationen&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/groupuinames:template-group-list&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Multi language templates extensions ==&lt;br /&gt;
Multi language templates extensions are also possible, they need a small modification in line no. 13 of the Paths.xcu file:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Paths.xcu&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;#039;1.0&amp;#039; encoding=&amp;#039;UTF-8&amp;#039;?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;oor:component-data oor:package=&amp;quot;org.openoffice.Office&amp;quot; oor:name=&amp;quot;Paths&amp;quot;     &lt;br /&gt;
    xmlns:install=&amp;quot;http://openoffice.org/2004/installation&amp;quot; &lt;br /&gt;
    xmlns:oor=&amp;quot;http://openoffice.org/2001/registry&amp;quot; &lt;br /&gt;
    xmlns:xs=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot; &lt;br /&gt;
    xmlns:xsi=&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;node oor:name=&amp;quot;Paths&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;node oor:name=&amp;quot;Template&amp;quot; oor:op=&amp;quot;fuse&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;node oor:name=&amp;quot;InternalPaths&amp;quot;&amp;gt;&lt;br /&gt;
                                &amp;lt;node oor:name=&amp;quot;%origin%/template/$(vlang)&amp;quot; oor:op=&amp;quot;fuse&amp;quot;/&amp;gt;&lt;br /&gt;
			&amp;lt;/node&amp;gt;&lt;br /&gt;
		&amp;lt;/node&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;/node&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/oor:component-data&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and additional directories need to be created be the &amp;quot;templates&amp;quot; folder that have the ISO language codes supported by the OOo language packs as their names. I have created a [http://framework.openoffice.org/files/documents/25/3706/MultiLanguageTemplatePackage.oxt second empty extension file] that provides the infrastructure. Take it and put german templates into the &amp;quot;de&amp;quot; folder, english ones into &amp;quot;en-US&amp;quot;, french ones into &amp;quot;fr&amp;quot; etc. Empty folders are not a problem. The localization files (groupuinames.xml) now need to be placed into the language specific folders, not directly into the &amp;quot;templates&amp;quot; folder as in the single language extension.&lt;br /&gt;
&lt;br /&gt;
If you create an extension this way you can always only use the templates of the current GUI language. This is caused by the &amp;quot;$(vlang)&amp;quot; variable in the path. A solution that allows to switch the template language independently is [http://qa.openoffice.org/issues/show_bug.cgi?id=72005 still missing].&lt;br /&gt;
&lt;br /&gt;
= AutoText Extensions =&lt;br /&gt;
&lt;br /&gt;
Everything said about extensions for templates also applies to extensions for autotexts. The Paths.xcu of course now doesn&amp;#039;t contain a value for the &amp;quot;Template&amp;quot; path but for the &amp;quot;AutoText&amp;quot; path. Again [http://framework.openoffice.org/files/documents/25/3710/AutoTextPackage.oxt here] is an example that can be filled with autotext files. Since there is currently no exporter you can manually copy any &amp;quot;.bau&amp;quot; files you have created into the extension. Creating extensions with localized autotexts works the same way: put the files into sub folders with names created from ISO language codes like you can see in the &amp;quot;share/autotext&amp;quot; folder. Unlike the template path the autotext path doesn&amp;#039;t need to contain &amp;quot;$(vlang)&amp;quot; for multi language extensions as the autotext management component implements the language dependent access internally.&lt;br /&gt;
&lt;br /&gt;
There is a tricky part here when you deploy autotext extensions: currently the autotext GUI allows to save autotexts to arbitrary locations. This is a [http://www.openoffice.org/issues/show_bug.cgi?id=70410 bug] that needs to be fixed. Any changes applied to autotexts in an extension will get lost when the extension is deinstalled. Extension content is not meant to be changed directly!&lt;br /&gt;
&lt;br /&gt;
= Gallery Extensions =&lt;br /&gt;
&lt;br /&gt;
Everything told about templates extensions also applies to extensions for gallery items. The Paths.xcu of course now doesn&amp;#039;t contain a value for the &amp;quot;Template&amp;quot; path but for the &amp;quot;Gallery&amp;quot; path. Again [http://framework.openoffice.org/files/documents/25/3711/GalleryPackage.oxt here] is an example that can be filled with gallery themes you have created by yourself. As this is a little bit tricky and the gallery code currently is prone to name clashes of the theme files it is not recommended to use gallery extensions until the [http://www.openoffice.org/issues/show_bug.cgi?id=70412 issue] about these problems is fixed.&lt;br /&gt;
&lt;br /&gt;
Another unsolved problem is the [http://qa.openoffice.org/issues/show_bug.cgi?id=71705  localization of gallery items].&lt;br /&gt;
&lt;br /&gt;
= Extensions for dictionaries =&lt;br /&gt;
&lt;br /&gt;
The linguistic tools and dictionaries configuration has been reworked and now dictionaries as extensions are possible. In the upcoming OOo3.0 beta both ways (dictionaries as extensions, dictionaries as single files installed by dictionary.lst) are supported but support for dictionary.lst will be dropped in OOo 3.0 final. More can be found [[Extension_Dictionaries | here]].&lt;/div&gt;</summary>
		<author><name>Andrewb</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=OOo_3_Beta_feedback&amp;diff=78787</id>
		<title>OOo 3 Beta feedback</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=OOo_3_Beta_feedback&amp;diff=78787"/>
		<updated>2008-05-27T05:06:38Z</updated>

		<summary type="html">&lt;p&gt;Andrewb: /* bugs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= OpenOffice.org 3.0 Beta feedback =&lt;br /&gt;
&lt;br /&gt;
The intention of this page is to collect the beta feedback from the various mailing list, forums, press, issues and come at the end to a prioritized list of most import bugs we need to fix for 3.0.&lt;br /&gt;
&lt;br /&gt;
Also this is the chance to collect complains of most missed features so that we are able to develop a roadmap for the upcoming releases.&lt;br /&gt;
&lt;br /&gt;
== good stuff ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
I wonder if you might like to include on your marketing page OOo&lt;br /&gt;
3.0&amp;#039;s concerted attempt to finally get word count right. This has&lt;br /&gt;
been a major bugbear for professional writers, and work is underway&lt;br /&gt;
right now to get OOo to mimic MS Word in this regard. This is a huge&lt;br /&gt;
deal for a significant portion of your user base, and a major&lt;br /&gt;
success worth trumpeting.&lt;br /&gt;
&lt;br /&gt;
The master bug for this issue is 80815, if you&amp;#039;re interested.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== bugs ==&lt;br /&gt;
&lt;br /&gt;
* File -&amp;gt; Save As in Vista SP1 broken =&amp;gt; http://www.openoffice.org/issues/show_bug.cgi?id=87244&lt;br /&gt;
* MS Office 2007 XML filter issues&lt;br /&gt;
* Impress drag text box not working http://www.openoffice.org/issues/show_bug.cgi?id=89484&lt;br /&gt;
* Strange 600% limitation in Chart2, when changing space width between rectangles , like on this Snapshot [http://www.progressioo.fr/Capture.png]&lt;br /&gt;
* [Mac Aqua] writer crashes opening word documents with comments inside {{issue|89243}}&lt;br /&gt;
* There&amp;#039;s [http://www.openoffice.org/issues/show_bug.cgi?id=87092 a nasty confirmed regression] in the search and replace which should be fixed before this is released. &amp;quot;x&amp;quot;s are randomly added at the end of replacement strings when formatting is changed.&lt;br /&gt;
&lt;br /&gt;
== MS-O 2007 support ==&lt;br /&gt;
* [http://arstechnica.com/news.ars/post/20080507-first-look-openoffice-org-3-0-beta-a-big-step-forward.html file format support a mixed bag]&lt;br /&gt;
* [http://www.pcworld.com/article/id,145667-c,starofficeopenofficeorg/article.html OpenOffice.org Beta Fails the Office 2007 Test]&lt;br /&gt;
* [http://blogs.zdnet.com/hardware/?p=1822&amp;amp;page=1 what I’m seeing now doesn’t give me much hope that I’ll be able to replace Microsoft Office 2007 with OO.o 3.0]&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html converted this reference .docx document with mediocre quality]...  ([http://katana.oooninja.com/w/reference_sample_documents the document])&lt;br /&gt;
&lt;br /&gt;
== missing features ==&lt;br /&gt;
&lt;br /&gt;
* Outline mode writer&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1207459620000#c279673438955276192 OpenType font support] is limited&lt;br /&gt;
* MacOSX: use system spell checking&lt;br /&gt;
* 1rst startup performance&lt;br /&gt;
* svg import&lt;br /&gt;
* 64k row limit in Calc needs to get extended.&lt;br /&gt;
* polish up mailmerge and mailmerge perfomance [http://www.openoffice.org/issues/show_bug.cgi?id=87104 issue].&lt;br /&gt;
* copy table from Calc to writer and vice versa.&lt;br /&gt;
* Add a &amp;#039;&amp;#039;&amp;#039;place&amp;#039;&amp;#039;&amp;#039; to the gallery (place could be a local folder or a website)&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1206470580000#c5668163814393029595 envelope printing]&lt;br /&gt;
&lt;br /&gt;
== Microsoft Office  2003 compatibility ==&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1207485720000#c975697398253531650 Please better compatibility with .doc, .xls and .ppt files! ]&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1205936040000#c8960868027842246741 you must have 99.9% compatibility in a business setting. ]&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1205972700000#c2373903312098222544 JUST FIX ALL THE COMPATIBILITY ISSUES!]&lt;br /&gt;
&lt;br /&gt;
== interface ==&lt;br /&gt;
&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1206380760000#c8706859352622147396 Interface, when I see OO, I think, OMG this sucks! Office 2007 is really brilliant in this.]&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1205959680000#c3178094417039109525 when will the interface look more modern?]&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1205966640000#c539276019792587786 i thought OOo were going to improve the interface. but it looks identical to me!]&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1206181380000#c3180074046942643850 Ugly, none intuitive interface.]&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1206296040000#c839572984313633681 I don&amp;#039;t like the OpenOffice interface, it seems to poor for me.]&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1206387900000#c126994644901918987 the interface could be more modern...]&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1207156980000#c2313822810772180354 MS Office 2007 interface is one of the best I&amp;#039;ve ever seen - please, implement this kind of interface in 3.0..]&lt;br /&gt;
** [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1207252980000#c3008808206925922967 Oh no!!! Please not!]&lt;br /&gt;
* etc etc&lt;/div&gt;</summary>
		<author><name>Andrewb</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=OOo_3_Beta_feedback&amp;diff=78786</id>
		<title>OOo 3 Beta feedback</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=OOo_3_Beta_feedback&amp;diff=78786"/>
		<updated>2008-05-27T05:04:44Z</updated>

		<summary type="html">&lt;p&gt;Andrewb: /* MS-O 2007 support */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= OpenOffice.org 3.0 Beta feedback =&lt;br /&gt;
&lt;br /&gt;
The intention of this page is to collect the beta feedback from the various mailing list, forums, press, issues and come at the end to a prioritized list of most import bugs we need to fix for 3.0.&lt;br /&gt;
&lt;br /&gt;
Also this is the chance to collect complains of most missed features so that we are able to develop a roadmap for the upcoming releases.&lt;br /&gt;
&lt;br /&gt;
== good stuff ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
I wonder if you might like to include on your marketing page OOo&lt;br /&gt;
3.0&amp;#039;s concerted attempt to finally get word count right. This has&lt;br /&gt;
been a major bugbear for professional writers, and work is underway&lt;br /&gt;
right now to get OOo to mimic MS Word in this regard. This is a huge&lt;br /&gt;
deal for a significant portion of your user base, and a major&lt;br /&gt;
success worth trumpeting.&lt;br /&gt;
&lt;br /&gt;
The master bug for this issue is 80815, if you&amp;#039;re interested.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== bugs ==&lt;br /&gt;
&lt;br /&gt;
* File -&amp;gt; Save As in Vista SP1 broken =&amp;gt; http://www.openoffice.org/issues/show_bug.cgi?id=87244&lt;br /&gt;
* MS Office 2007 XML filter issues&lt;br /&gt;
* Impress drag text box not working http://www.openoffice.org/issues/show_bug.cgi?id=89484&lt;br /&gt;
* Strange 600% limitation in Chart2, when changing space width between rectangles , like on this Snapshot [http://www.progressioo.fr/Capture.png]&lt;br /&gt;
* [Mac Aqua] writer crashes opening word documents with comments inside {{issue|89243}}&lt;br /&gt;
&lt;br /&gt;
== MS-O 2007 support ==&lt;br /&gt;
* [http://arstechnica.com/news.ars/post/20080507-first-look-openoffice-org-3-0-beta-a-big-step-forward.html file format support a mixed bag]&lt;br /&gt;
* [http://www.pcworld.com/article/id,145667-c,starofficeopenofficeorg/article.html OpenOffice.org Beta Fails the Office 2007 Test]&lt;br /&gt;
* [http://blogs.zdnet.com/hardware/?p=1822&amp;amp;page=1 what I’m seeing now doesn’t give me much hope that I’ll be able to replace Microsoft Office 2007 with OO.o 3.0]&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html converted this reference .docx document with mediocre quality]...  ([http://katana.oooninja.com/w/reference_sample_documents the document])&lt;br /&gt;
&lt;br /&gt;
== missing features ==&lt;br /&gt;
&lt;br /&gt;
* Outline mode writer&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1207459620000#c279673438955276192 OpenType font support] is limited&lt;br /&gt;
* MacOSX: use system spell checking&lt;br /&gt;
* 1rst startup performance&lt;br /&gt;
* svg import&lt;br /&gt;
* 64k row limit in Calc needs to get extended.&lt;br /&gt;
* polish up mailmerge and mailmerge perfomance [http://www.openoffice.org/issues/show_bug.cgi?id=87104 issue].&lt;br /&gt;
* copy table from Calc to writer and vice versa.&lt;br /&gt;
* Add a &amp;#039;&amp;#039;&amp;#039;place&amp;#039;&amp;#039;&amp;#039; to the gallery (place could be a local folder or a website)&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1206470580000#c5668163814393029595 envelope printing]&lt;br /&gt;
&lt;br /&gt;
== Microsoft Office  2003 compatibility ==&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1207485720000#c975697398253531650 Please better compatibility with .doc, .xls and .ppt files! ]&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1205936040000#c8960868027842246741 you must have 99.9% compatibility in a business setting. ]&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1205972700000#c2373903312098222544 JUST FIX ALL THE COMPATIBILITY ISSUES!]&lt;br /&gt;
&lt;br /&gt;
== interface ==&lt;br /&gt;
&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1206380760000#c8706859352622147396 Interface, when I see OO, I think, OMG this sucks! Office 2007 is really brilliant in this.]&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1205959680000#c3178094417039109525 when will the interface look more modern?]&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1205966640000#c539276019792587786 i thought OOo were going to improve the interface. but it looks identical to me!]&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1206181380000#c3180074046942643850 Ugly, none intuitive interface.]&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1206296040000#c839572984313633681 I don&amp;#039;t like the OpenOffice interface, it seems to poor for me.]&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1206387900000#c126994644901918987 the interface could be more modern...]&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1207156980000#c2313822810772180354 MS Office 2007 interface is one of the best I&amp;#039;ve ever seen - please, implement this kind of interface in 3.0..]&lt;br /&gt;
** [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1207252980000#c3008808206925922967 Oh no!!! Please not!]&lt;br /&gt;
* etc etc&lt;/div&gt;</summary>
		<author><name>Andrewb</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=OOo_3_Beta_feedback&amp;diff=78785</id>
		<title>OOo 3 Beta feedback</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=OOo_3_Beta_feedback&amp;diff=78785"/>
		<updated>2008-05-27T05:04:05Z</updated>

		<summary type="html">&lt;p&gt;Andrewb: /* MS-O 2007 support */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= OpenOffice.org 3.0 Beta feedback =&lt;br /&gt;
&lt;br /&gt;
The intention of this page is to collect the beta feedback from the various mailing list, forums, press, issues and come at the end to a prioritized list of most import bugs we need to fix for 3.0.&lt;br /&gt;
&lt;br /&gt;
Also this is the chance to collect complains of most missed features so that we are able to develop a roadmap for the upcoming releases.&lt;br /&gt;
&lt;br /&gt;
== good stuff ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
I wonder if you might like to include on your marketing page OOo&lt;br /&gt;
3.0&amp;#039;s concerted attempt to finally get word count right. This has&lt;br /&gt;
been a major bugbear for professional writers, and work is underway&lt;br /&gt;
right now to get OOo to mimic MS Word in this regard. This is a huge&lt;br /&gt;
deal for a significant portion of your user base, and a major&lt;br /&gt;
success worth trumpeting.&lt;br /&gt;
&lt;br /&gt;
The master bug for this issue is 80815, if you&amp;#039;re interested.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== bugs ==&lt;br /&gt;
&lt;br /&gt;
* File -&amp;gt; Save As in Vista SP1 broken =&amp;gt; http://www.openoffice.org/issues/show_bug.cgi?id=87244&lt;br /&gt;
* MS Office 2007 XML filter issues&lt;br /&gt;
* Impress drag text box not working http://www.openoffice.org/issues/show_bug.cgi?id=89484&lt;br /&gt;
* Strange 600% limitation in Chart2, when changing space width between rectangles , like on this Snapshot [http://www.progressioo.fr/Capture.png]&lt;br /&gt;
* [Mac Aqua] writer crashes opening word documents with comments inside {{issue|89243}}&lt;br /&gt;
&lt;br /&gt;
== MS-O 2007 support ==&lt;br /&gt;
* [http://arstechnica.com/news.ars/post/20080507-first-look-openoffice-org-3-0-beta-a-big-step-forward.html file format support a mixed bag]&lt;br /&gt;
* [http://www.pcworld.com/article/id,145667-c,starofficeopenofficeorg/article.html OpenOffice.org Beta Fails the Office 2007 Test]&lt;br /&gt;
* [http://blogs.zdnet.com/hardware/?p=1822&amp;amp;page=1 what I’m seeing now doesn’t give me much hope that I’ll be able to replace Microsoft Office 2007 with OO.o 3.0]&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html converted this reference .docx document with mediocre quality]...  ([http://katana.oooninja.com/w/reference_sample_documents the document])&lt;br /&gt;
* There&amp;#039;s [http://www.openoffice.org/issues/show_bug.cgi?id=87092 a nasty regression] in the search and replace which should be fixed before this is released.&lt;br /&gt;
&lt;br /&gt;
== missing features ==&lt;br /&gt;
&lt;br /&gt;
* Outline mode writer&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1207459620000#c279673438955276192 OpenType font support] is limited&lt;br /&gt;
* MacOSX: use system spell checking&lt;br /&gt;
* 1rst startup performance&lt;br /&gt;
* svg import&lt;br /&gt;
* 64k row limit in Calc needs to get extended.&lt;br /&gt;
* polish up mailmerge and mailmerge perfomance [http://www.openoffice.org/issues/show_bug.cgi?id=87104 issue].&lt;br /&gt;
* copy table from Calc to writer and vice versa.&lt;br /&gt;
* Add a &amp;#039;&amp;#039;&amp;#039;place&amp;#039;&amp;#039;&amp;#039; to the gallery (place could be a local folder or a website)&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1206470580000#c5668163814393029595 envelope printing]&lt;br /&gt;
&lt;br /&gt;
== Microsoft Office  2003 compatibility ==&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1207485720000#c975697398253531650 Please better compatibility with .doc, .xls and .ppt files! ]&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1205936040000#c8960868027842246741 you must have 99.9% compatibility in a business setting. ]&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1205972700000#c2373903312098222544 JUST FIX ALL THE COMPATIBILITY ISSUES!]&lt;br /&gt;
&lt;br /&gt;
== interface ==&lt;br /&gt;
&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1206380760000#c8706859352622147396 Interface, when I see OO, I think, OMG this sucks! Office 2007 is really brilliant in this.]&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1205959680000#c3178094417039109525 when will the interface look more modern?]&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1205966640000#c539276019792587786 i thought OOo were going to improve the interface. but it looks identical to me!]&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1206181380000#c3180074046942643850 Ugly, none intuitive interface.]&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1206296040000#c839572984313633681 I don&amp;#039;t like the OpenOffice interface, it seems to poor for me.]&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1206387900000#c126994644901918987 the interface could be more modern...]&lt;br /&gt;
* [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1207156980000#c2313822810772180354 MS Office 2007 interface is one of the best I&amp;#039;ve ever seen - please, implement this kind of interface in 3.0..]&lt;br /&gt;
** [http://www.oooninja.com/2008/03/openofficeorg-30-new-features.html?showComment=1207252980000#c3008808206925922967 Oh no!!! Please not!]&lt;br /&gt;
* etc etc&lt;/div&gt;</summary>
		<author><name>Andrewb</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=PyUNO_samples&amp;diff=70570</id>
		<title>PyUNO samples</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=PyUNO_samples&amp;diff=70570"/>
		<updated>2008-03-18T12:44:03Z</updated>

		<summary type="html">&lt;p&gt;Andrewb: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/Candidate}}&lt;br /&gt;
OpenOffice.org comes with a set of scripts that work as a sample on how to programmatically generate certain tasks using PyUNO.&lt;br /&gt;
&lt;br /&gt;
=== Hello World.py ===&lt;br /&gt;
This script print a Hello World in an Writer document. This uses the [http://api.openoffice.org/docs/common/ref/com/sun/star/text/XText.html XText] interface, the actual content is on the String value of the [http://api.openoffice.org/docs/common/ref/com/sun/star/text/XTextRange.html XTextRange]. &lt;br /&gt;
&lt;br /&gt;
First step we define the HelloWorldPython() class, then we call the XSCRIPTCONTEXT which will let us work within a sub-environment from UNO. Notice we didn&amp;#039;t import uno and we don&amp;#039;t need to connect to OOo through the socket. Also we have the uno enviroment by calling getDocument(). &lt;br /&gt;
&lt;br /&gt;
Then we call the XText interface to call on the END and STRING methods to write up the &amp;quot;Hello World (in Python)&amp;quot;.&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
# HelloWorld python script for the scripting framework&lt;br /&gt;
&lt;br /&gt;
def HelloWorldPython( ):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Prints the string &amp;#039;Hello World(in Python)&amp;#039; into the current document&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
#get the doc from the scripting context which is made available to all scripts&lt;br /&gt;
    model = XSCRIPTCONTEXT.getDocument()&lt;br /&gt;
#get the XText interface&lt;br /&gt;
    text = model.Text&lt;br /&gt;
#create an XTextRange at the end of the document&lt;br /&gt;
    tRange = text.End&lt;br /&gt;
#and set the string&lt;br /&gt;
    tRange.String = &amp;quot;Hello World (in Python)&amp;quot;&lt;br /&gt;
    return None&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Capitalize.py ===&lt;br /&gt;
This script will show how to modify existing content in a document. More specifically manipulate the format values from the text. We use common python string menthods like &amp;#039;&amp;#039;&amp;#039;isupper, upper, len and lower&amp;#039;&amp;#039;&amp;#039;. And we use XSCRIPTCONTEXT (Learn about the [http://api.openoffice.org/docs/DevelopersGuide/ScriptingFramework/ScriptingFramework.xhtml XSCRIPTCONTEXT]) for the positioning of the text ([http://api.openoffice.org/docs/common/ref/com/sun/star/text/XText.html XText] and [http://api.openoffice.org/docs/common/ref/com/sun/star/text/XTextRange.html XTextRange] ), the control of the cursor ([http://api.openoffice.org/docs/common/ref/com/sun/star/text/XWordCursor.html xWordCursor]).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
# helper function&lt;br /&gt;
def getNewString( theString ) :&lt;br /&gt;
    if( not theString or len(theString) ==0) :&lt;br /&gt;
        return &amp;quot;&amp;quot;&lt;br /&gt;
    # should we tokenize on &amp;quot;.&amp;quot;?&lt;br /&gt;
    if theString[0].isupper() and len(theString)&amp;gt;=2 and theString[1].isupper() :&lt;br /&gt;
	# first two chars are UC =&amp;gt; first UC, rest LC&lt;br /&gt;
        newString=theString[0:1].upper() + theString[1:].lower();&lt;br /&gt;
    elif theString[0].isupper():&lt;br /&gt;
	# first char UC =&amp;gt; all to LC&lt;br /&gt;
        newString=theString.lower()&lt;br /&gt;
    else: # all to UC.&lt;br /&gt;
        newString=theString.upper()&lt;br /&gt;
    return newString;&lt;br /&gt;
&lt;br /&gt;
def capitalisePython( ): &lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Change the case of a selection, or current word from upper case, to first char upper case, to all lower case to upper case...&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    import string&lt;br /&gt;
&lt;br /&gt;
    # The context variable is of type XScriptContext and is available to&lt;br /&gt;
    # all BeanShell scripts executed by the Script Framework&lt;br /&gt;
    xModel = XSCRIPTCONTEXT.getDocument()&lt;br /&gt;
&lt;br /&gt;
    #the writer controller impl supports the css.view.XSelectionSupplier interface&lt;br /&gt;
    xSelectionSupplier = xModel.getCurrentController()&lt;br /&gt;
&lt;br /&gt;
    #see section 7.5.1 of developers&amp;#039; guide&lt;br /&gt;
    xIndexAccess = xSelectionSupplier.getSelection()&lt;br /&gt;
    count = xIndexAccess.getCount();&lt;br /&gt;
    if(count&amp;gt;=1):  #ie we have a selection&lt;br /&gt;
        i=0&lt;br /&gt;
	while i &amp;lt; count :&lt;br /&gt;
            xTextRange = xIndexAccess.getByIndex(i);&lt;br /&gt;
            #print &amp;quot;string: &amp;quot; + xTextRange.getString();&lt;br /&gt;
            theString = xTextRange.getString();&lt;br /&gt;
            if len(theString)==0 :&lt;br /&gt;
                # sadly we can have a selection where nothing is selected&lt;br /&gt;
                # in this case we get the XWordCursor and make a selection!&lt;br /&gt;
                xText = xTextRange.getText();&lt;br /&gt;
                xWordCursor = xText.createTextCursorByRange(xTextRange);&lt;br /&gt;
                if not xWordCursor.isStartOfWord():&lt;br /&gt;
                    xWordCursor.gotoStartOfWord(False);&lt;br /&gt;
                xWordCursor.gotoNextWord(True);&lt;br /&gt;
                theString = xWordCursor.getString();&lt;br /&gt;
                newString = getNewString(theString);&lt;br /&gt;
                if newString :&lt;br /&gt;
                    xWordCursor.setString(newString);&lt;br /&gt;
                    xSelectionSupplier.select(xWordCursor);&lt;br /&gt;
            else :&lt;br /&gt;
&lt;br /&gt;
                newString = getNewString( theString );&lt;br /&gt;
                if newString:&lt;br /&gt;
                    xTextRange.setString(newString);&lt;br /&gt;
                    xSelectionSupplier.select(xTextRange);&lt;br /&gt;
	    i+= 1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# lists the scripts, that shall be visible inside OOo. Can be omitted, if&lt;br /&gt;
# all functions shall be visible, however here getNewString shall be surpressed&lt;br /&gt;
g_exportedScripts = capitalisePython,&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== TableSample.py ===&lt;br /&gt;
&lt;br /&gt;
On this script we abandon the XSCRIPTCONTEXT and use the UNO module. We also use nested modules from Text, AWT, and LANG. Since we using the UNO module we have to import what we need straight from the com.sun.star path. &lt;br /&gt;
&lt;br /&gt;
The first step is to get the functions for generating the document, and the other for manipulating the content. The document and content is under the &amp;#039;&amp;#039;&amp;#039;createTable()&amp;#039;&amp;#039;&amp;#039;, while &amp;#039;&amp;#039;&amp;#039;insertTextIntoCell()&amp;#039;&amp;#039;&amp;#039; will handle the positioning within the table.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
import uno&lt;br /&gt;
&lt;br /&gt;
# a UNO struct later needed to create a document&lt;br /&gt;
from com.sun.star.text.ControlCharacter import PARAGRAPH_BREAK&lt;br /&gt;
from com.sun.star.text.TextContentAnchorType import AS_CHARACTER&lt;br /&gt;
from com.sun.star.awt import Size&lt;br /&gt;
&lt;br /&gt;
from com.sun.star.lang import XMain&lt;br /&gt;
&lt;br /&gt;
def insertTextIntoCell( table, cellName, text, color ):&lt;br /&gt;
    tableText = table.getCellByName( cellName )&lt;br /&gt;
    cursor = tableText.createTextCursor()&lt;br /&gt;
    cursor.setPropertyValue( &amp;quot;CharColor&amp;quot;, color )&lt;br /&gt;
    tableText.setString( text )&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def createTable():&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;creates a new writer document and inserts a table with some data (also known as the SWriter sample)&amp;quot;&amp;quot;&amp;quot; &lt;br /&gt;
    ctx = uno.getComponentContext()&lt;br /&gt;
    smgr = ctx.ServiceManager&lt;br /&gt;
    desktop = smgr.createInstanceWithContext( &amp;quot;com.sun.star.frame.Desktop&amp;quot;,ctx)&lt;br /&gt;
    &lt;br /&gt;
    # open a writer document&lt;br /&gt;
    doc = desktop.loadComponentFromURL( &amp;quot;private:factory/swriter&amp;quot;,&amp;quot;_blank&amp;quot;, 0, () )&lt;br /&gt;
    &lt;br /&gt;
    text = doc.Text&lt;br /&gt;
    cursor = text.createTextCursor()&lt;br /&gt;
    text.insertString( cursor, &amp;quot;The first line in the newly created text document.\n&amp;quot;, 0 )&lt;br /&gt;
    text.insertString( cursor, &amp;quot;Now we are in the second line\n&amp;quot; , 0 )&lt;br /&gt;
    &lt;br /&gt;
    # create a text table&lt;br /&gt;
    table = doc.createInstance( &amp;quot;com.sun.star.text.TextTable&amp;quot; )&lt;br /&gt;
&lt;br /&gt;
    # with 4 rows and 4 columns&lt;br /&gt;
    table.initialize( 4,4)&lt;br /&gt;
&lt;br /&gt;
    text.insertTextContent( cursor, table, 0 )&lt;br /&gt;
    rows = table.Rows&lt;br /&gt;
&lt;br /&gt;
    table.setPropertyValue( &amp;quot;BackTransparent&amp;quot;, uno.Bool(0) )&lt;br /&gt;
    table.setPropertyValue( &amp;quot;BackColor&amp;quot;, 13421823 )&lt;br /&gt;
    row = rows.getByIndex(0)&lt;br /&gt;
    row.setPropertyValue( &amp;quot;BackTransparent&amp;quot;, uno.Bool(0) )&lt;br /&gt;
    row.setPropertyValue( &amp;quot;BackColor&amp;quot;, 6710932 )&lt;br /&gt;
&lt;br /&gt;
    textColor = 16777215&lt;br /&gt;
&lt;br /&gt;
    insertTextIntoCell( table, &amp;quot;A1&amp;quot;, &amp;quot;FirstColumn&amp;quot;, textColor )&lt;br /&gt;
    insertTextIntoCell( table, &amp;quot;B1&amp;quot;, &amp;quot;SecondColumn&amp;quot;, textColor )&lt;br /&gt;
    insertTextIntoCell( table, &amp;quot;C1&amp;quot;, &amp;quot;ThirdColumn&amp;quot;, textColor )&lt;br /&gt;
    insertTextIntoCell( table, &amp;quot;D1&amp;quot;, &amp;quot;SUM&amp;quot;, textColor )&lt;br /&gt;
&lt;br /&gt;
    values = ( (22.5,21.5,121.5),&lt;br /&gt;
              (5615.3,615.3,-615.3),&lt;br /&gt;
              (-2315.7,315.7,415.7) )&lt;br /&gt;
    table.getCellByName(&amp;quot;A2&amp;quot;).setValue(22.5)&lt;br /&gt;
    table.getCellByName(&amp;quot;B2&amp;quot;).setValue(5615.3)&lt;br /&gt;
    table.getCellByName(&amp;quot;C2&amp;quot;).setValue(-2315.7)&lt;br /&gt;
    table.getCellByName(&amp;quot;D2&amp;quot;).setFormula(&amp;quot;sum &amp;lt;A2:C2&amp;gt;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    table.getCellByName(&amp;quot;A3&amp;quot;).setValue(21.5)&lt;br /&gt;
    table.getCellByName(&amp;quot;B3&amp;quot;).setValue(615.3)&lt;br /&gt;
    table.getCellByName(&amp;quot;C3&amp;quot;).setValue(-315.7)&lt;br /&gt;
    table.getCellByName(&amp;quot;D3&amp;quot;).setFormula(&amp;quot;sum &amp;lt;A3:C3&amp;gt;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    table.getCellByName(&amp;quot;A4&amp;quot;).setValue(121.5)&lt;br /&gt;
    table.getCellByName(&amp;quot;B4&amp;quot;).setValue(-615.3)&lt;br /&gt;
    table.getCellByName(&amp;quot;C4&amp;quot;).setValue(415.7)&lt;br /&gt;
    table.getCellByName(&amp;quot;D4&amp;quot;).setFormula(&amp;quot;sum &amp;lt;A4:C4&amp;gt;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    cursor.setPropertyValue( &amp;quot;CharColor&amp;quot;, 255 )&lt;br /&gt;
    cursor.setPropertyValue( &amp;quot;CharShadowed&amp;quot;, uno.Bool(1) )&lt;br /&gt;
&lt;br /&gt;
    text.insertControlCharacter( cursor, PARAGRAPH_BREAK, 0 )&lt;br /&gt;
    text.insertString( cursor, &amp;quot; This is a colored Text - blue with shadow\n&amp;quot; , 0 )&lt;br /&gt;
    text.insertControlCharacter( cursor, PARAGRAPH_BREAK, 0 )&lt;br /&gt;
&lt;br /&gt;
    textFrame = doc.createInstance( &amp;quot;com.sun.star.text.TextFrame&amp;quot; )&lt;br /&gt;
    textFrame.setSize( Size(15000,400))&lt;br /&gt;
    textFrame.setPropertyValue( &amp;quot;AnchorType&amp;quot; , AS_CHARACTER )&lt;br /&gt;
&lt;br /&gt;
    text.insertTextContent( cursor, textFrame, 0 )&lt;br /&gt;
&lt;br /&gt;
    textInTextFrame = textFrame.getText()&lt;br /&gt;
    cursorInTextFrame = textInTextFrame.createTextCursor()&lt;br /&gt;
    textInTextFrame.insertString( cursorInTextFrame, &amp;quot;The first line in the newly created text frame.&amp;quot;, 0 )&lt;br /&gt;
    textInTextFrame.insertString( cursorInTextFrame, &amp;quot;\nWith this second line the height of the rame raises.&amp;quot;,0)&lt;br /&gt;
    text.insertControlCharacter( cursor, PARAGRAPH_BREAK, 0 )&lt;br /&gt;
&lt;br /&gt;
    cursor.setPropertyValue( &amp;quot;CharColor&amp;quot;, 65536 )&lt;br /&gt;
    cursor.setPropertyValue( &amp;quot;CharShadowed&amp;quot;, uno.Bool(0) )&lt;br /&gt;
&lt;br /&gt;
    text.insertString( cursor, &amp;quot; That&amp;#039;s all for now !!&amp;quot; , 0 )&lt;br /&gt;
&lt;br /&gt;
g_exportedScripts = createTable,&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First step to understand is that the UNO module will give us the IDL binding from the API. We will then import specific things from the UNO module. For tht we need to specify the path from com.sun.star and import the interfaces and services. &lt;br /&gt;
&lt;br /&gt;
The nested modules [http://api.openoffice.org/docs/common/ref/com/sun/star/text/module-ix.html text] we had: [http://api.openoffice.org/docs/common/ref/com/sun/star/text/ControlCharacter.html ControlCharacter], [http://api.openoffice.org/docs/common/ref/com/sun/star/text/TextContentAnchorType.html TextContentAnchorType] and import [http://api.openoffice.org/docs/common/ref/com/sun/star/text/ControlCharacter.html#PARAGRAPH_BREAK PARAGRAPH_BREAK], [http://api.openoffice.org/docs/common/ref/com/sun/star/text/TextContentAnchorType.html#AS_CHARACTER AS_CHARACTER].&lt;br /&gt;
&lt;br /&gt;
From [http://api.openoffice.org/docs/common/ref/com/sun/star/awt/module-ix.html awt] which is a user interface toolkit had: [http://api.openoffice.org/docs/common/ref/com/sun/star/awt/Size.html Size]&lt;br /&gt;
&lt;br /&gt;
Finally [http://api.openoffice.org/docs/common/ref/com/sun/star/lang/module-ix.html lang] nested module which is about , we import [http://api.openoffice.org/docs/common/ref/com/sun/star/lang/XMain.html XMain].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
import uno&lt;br /&gt;
&lt;br /&gt;
# a UNO struct later needed to create a document&lt;br /&gt;
from com.sun.star.text.ControlCharacter import PARAGRAPH_BREAK&lt;br /&gt;
from com.sun.star.text.TextContentAnchorType import AS_CHARACTER&lt;br /&gt;
from com.sun.star.awt import Size&lt;br /&gt;
&lt;br /&gt;
from com.sun.star.lang import XMain&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== createTable() ====&lt;br /&gt;
&lt;br /&gt;
We can divide this class into the process of:&lt;br /&gt;
* creating a new window&lt;br /&gt;
* creating a writer document &lt;br /&gt;
* inserting text (previously seen on the Hello World Script).&lt;br /&gt;
* Creating a table within the writer document &lt;br /&gt;
* manipulate the format and finally the content &lt;br /&gt;
* Then we insert a frame with text in it&lt;br /&gt;
* insert a string&lt;br /&gt;
&lt;br /&gt;
This let us analyze in more detail the interfaces and methods from the cursor, table, text, textFrame and textInTextFrame. All this documentation can be found on the IDL reference. Following this script will allow us to use the IDL to our benefit and explore other nested modules for different porpouse.&lt;br /&gt;
&lt;br /&gt;
The following values goes extract from the following:&lt;br /&gt;
&lt;br /&gt;
* doc = desktop.&amp;#039;&amp;#039;&amp;#039;loadComponentFromURL( &amp;quot;private:factory/swriter&amp;quot;,&amp;quot;_blank&amp;quot;, 0, () )&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* text = doc.Text&lt;br /&gt;
* cursor = text.&amp;#039;&amp;#039;&amp;#039;createTextCursor()&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* table = doc.&amp;#039;&amp;#039;&amp;#039;createInstance( &amp;quot;com.sun.star.text.TextTable&amp;quot; )&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The &amp;#039;&amp;#039;&amp;#039;loadcomponentFromURL()&amp;#039;&amp;#039;&amp;#039; creates and load the Writer document by generating the variable. Text is a variable that will get the document object with the module of Text. The function of &amp;#039;&amp;#039;&amp;#039;createTextCursor()&amp;#039;&amp;#039;&amp;#039; acording with the IDL &amp;#039;&amp;#039;a new instance of a TextCursor service which can be used to travel in the given text context&amp;#039;&amp;#039;.&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;creates a new writer document and inserts a table with some data (also known as the SWriter sample)&amp;quot;&amp;quot;&amp;quot; &lt;br /&gt;
    ctx = uno.getComponentContext()&lt;br /&gt;
    smgr = ctx.ServiceManager&lt;br /&gt;
    desktop = smgr.createInstanceWithContext( &amp;quot;com.sun.star.frame.Desktop&amp;quot;,ctx)&lt;br /&gt;
    &lt;br /&gt;
    # open a writer document&lt;br /&gt;
    doc = desktop.loadComponentFromURL( &amp;quot;private:factory/swriter&amp;quot;,&amp;quot;_blank&amp;quot;, 0, () )&lt;br /&gt;
    &lt;br /&gt;
    text = doc.Text&lt;br /&gt;
    cursor = text.createTextCursor()&lt;br /&gt;
    text.insertString( cursor, &amp;quot;The first line in the newly created text document.\n&amp;quot;, 0 )&lt;br /&gt;
    text.insertString( cursor, &amp;quot;Now we are in the second line\n&amp;quot; , 0 )&amp;lt;/source&amp;gt;&lt;br /&gt;
The next instance is the creation of the table instance within the table variable. We use the function of &amp;#039;&amp;#039;&amp;#039;createTextCursor()&amp;#039;&amp;#039;&amp;#039;, the path to the module is &amp;#039;&amp;#039;&amp;#039;com.sun.star.text.TextTable&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
    # create a text table&lt;br /&gt;
    table = doc.createInstance( &amp;quot;com.sun.star.text.TextTable&amp;quot; )&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We create our table by using the method &amp;#039;&amp;#039;&amp;#039;initialize&amp;#039;&amp;#039;&amp;#039; on the line 35 of the code &amp;#039;&amp;#039;&amp;#039;table.initialize( 4,4)&amp;#039;&amp;#039;&amp;#039;. Now we will deal with the properties of the table as well as the methods and objects from the table like rows, cursor and values. First step after initialize the table, we use the function &amp;#039;&amp;#039;&amp;#039;insertTextContent( cursor, table, 0 )&amp;#039;&amp;#039;&amp;#039;, if you think that this will put a cursor in the table, then you are RIGHT. TextContent is basically an object which can be anchored in a text, like instances of TextFrame or TextFields. In our case we will deal with Cells rather than Frames or Fields.&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    # with 4 rows and 4 columns&lt;br /&gt;
    table.initialize( 4,4)&lt;br /&gt;
&lt;br /&gt;
    text.insertTextContent( cursor, table, 0 )&lt;br /&gt;
    rows = table.Rows&amp;lt;/source&amp;gt;&lt;br /&gt;
The next point is we will focus on the &amp;#039;&amp;#039;&amp;#039;styles&amp;#039;&amp;#039;&amp;#039; of the table and have methods such as &amp;#039;&amp;#039;&amp;#039;setPropertyValue&amp;#039;&amp;#039;&amp;#039; which could might as well be setStyleValue being implemented to the text, for example &amp;#039;&amp;#039;&amp;#039;setPropertyValue( &amp;quot;BackTransparent&amp;quot;, uno.Bool(0) )&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;setPropertyValue( &amp;quot;BackColor&amp;quot;, 6710932 )&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
    table.setPropertyValue( &amp;quot;BackTransparent&amp;quot;, uno.Bool(0) )&lt;br /&gt;
    table.setPropertyValue( &amp;quot;BackColor&amp;quot;, 13421823 )&lt;br /&gt;
    row = rows.getByIndex(0)&lt;br /&gt;
    row.setPropertyValue( &amp;quot;BackTransparent&amp;quot;, uno.Bool(0) )&lt;br /&gt;
    row.setPropertyValue( &amp;quot;BackColor&amp;quot;, 6710932 )&amp;lt;/source&amp;gt;&lt;br /&gt;
The next step is to get the header of the table which will use the other class and will insert the values that we need, we get &amp;#039;&amp;#039;&amp;#039;insertTextIntoCell( table, &amp;quot;A1&amp;quot;, &amp;quot;FirstColumn&amp;quot;, textColor )&amp;#039;&amp;#039;&amp;#039; put color and content into the specific cells from the table object. The syntax is rather straight forward by stating object, cell position, text content and finally text color value which in this cas is a variable of the hex color 16777215.&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
    textColor = 16777215&lt;br /&gt;
&lt;br /&gt;
    insertTextIntoCell( table, &amp;quot;A1&amp;quot;, &amp;quot;FirstColumn&amp;quot;, textColor )&lt;br /&gt;
    insertTextIntoCell( table, &amp;quot;B1&amp;quot;, &amp;quot;SecondColumn&amp;quot;, textColor )&lt;br /&gt;
    insertTextIntoCell( table, &amp;quot;C1&amp;quot;, &amp;quot;ThirdColumn&amp;quot;, textColor )&lt;br /&gt;
    insertTextIntoCell( table, &amp;quot;D1&amp;quot;, &amp;quot;SUM&amp;quot;, textColor )&amp;lt;/source&amp;gt;&lt;br /&gt;
Now we will insert the content of our table including the numerical value and &amp;#039;&amp;#039;&amp;#039;formula&amp;#039;&amp;#039;&amp;#039;. We use an array of values and then generate a series of inserting the &amp;#039;&amp;#039;&amp;#039;values()&amp;#039;&amp;#039;&amp;#039; within the the &amp;#039;&amp;#039;&amp;#039;getCellByName()&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;setValue()&amp;#039;&amp;#039;&amp;#039; and &amp;#039;&amp;#039;&amp;#039;setFormula&amp;#039;&amp;#039;&amp;#039;. &lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
    values = ( (22.5,21.5,121.5),&lt;br /&gt;
              (5615.3,615.3,-615.3),&lt;br /&gt;
              (-2315.7,315.7,415.7) )&lt;br /&gt;
    table.getCellByName(&amp;quot;A2&amp;quot;).setValue(22.5)&lt;br /&gt;
    table.getCellByName(&amp;quot;B2&amp;quot;).setValue(5615.3)&lt;br /&gt;
    table.getCellByName(&amp;quot;C2&amp;quot;).setValue(-2315.7)&lt;br /&gt;
    table.getCellByName(&amp;quot;D2&amp;quot;).setFormula(&amp;quot;sum &amp;lt;A2:C2&amp;gt;&amp;quot;)&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== insertTextIntoCell() ====&lt;br /&gt;
This is a sub-process class which brings the services and methods for the table manipulation. The function uses the method getCellbyName, createTextCursor and createPropertyValue.&lt;br /&gt;
&lt;br /&gt;
This insertTextIntoCell() function will bring a structure to format the header of the table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Python]]&lt;br /&gt;
[[Category:Uno]]&lt;br /&gt;
[[Category:Tutorial]]&lt;/div&gt;</summary>
		<author><name>Andrewb</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=PyUNOServer&amp;diff=70449</id>
		<title>PyUNOServer</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=PyUNOServer&amp;diff=70449"/>
		<updated>2008-03-17T08:31:56Z</updated>

		<summary type="html">&lt;p&gt;Andrewb: code to source tags&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:Py-uno_128.png|right|PyUNO Logo]]&lt;br /&gt;
The PyUNOServer is a script that works as an XML server for OpenOffice.org Calc where it can exchange data through XML calls. This means that can get data from other apps that are XML compliant. You can download the script from [http://es.openoffice.org/files/documents/73/2929/pyUnoServer.tar.gz this mirror] since the original site seems to be down.&lt;br /&gt;
&lt;br /&gt;
The zip file contains 3 files: &lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;PyUNOServerV2.py&amp;#039;&amp;#039;&amp;#039; - The Python Script&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;PyUNOServerV2.pyc&amp;#039;&amp;#039;&amp;#039; - compiled version&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;PyUNOServer.sh2&amp;#039;&amp;#039;&amp;#039; - the script to conect to the service&lt;br /&gt;
&lt;br /&gt;
The script have just 1 script called &amp;#039;&amp;#039;&amp;#039;PyUNOServerV2.py&amp;#039;&amp;#039;&amp;#039; however there is a faster, bytecode-compiled script. It also includes a bash script which loads the path to the openoffice.org application.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;NOTE: This script will work on just certain distros since the location of OpenOffice.org might vary. We recomend to load the path manually.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
This script uses the following libraries:&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;OS&amp;#039;&amp;#039;&amp;#039; - This module provides a more portable way of using operating system dependent functionality than importing a operating system dependent built-in module like posix or nt.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;UNO&amp;#039;&amp;#039;&amp;#039; - Python UNO implementation module, this can used by python 2.3.4 &amp;#039;&amp;#039;&amp;#039;only&amp;#039;&amp;#039;&amp;#039; which is the python provided within openoffice.org. It provides all the interfaces from OpenOffice.org into python.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;SYS&amp;#039;&amp;#039;&amp;#039; - This module provides access to some variables used or maintained by the interpreter and to functions that interact strongly with the interpreter. It is always available.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;time&amp;#039;&amp;#039;&amp;#039; - This module provides various time-related functions. It is always available, but not all functions are available on all platforms. Most of the functions defined in this module call platform C library functions with the same name. It may sometimes be helpful to consult the platform documentation, because the semantics of these functions varies among platforms.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;logging&amp;#039;&amp;#039;&amp;#039; - Logging is performed by calling methods on instances of the Logger class (hereafter called loggers). Each instance has a name, and they are conceptually arranged in a name space hierarchy using dots (periods) as separators.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;urllib&amp;#039;&amp;#039;&amp;#039; - This module provides a high-level interface for fetching data across the World Wide Web. In particular, the urlopen() function is similar to the built-in function open(), but accepts Universal Resource Locators (URLs) instead of filenames. Some restrictions apply -- it can only open URLs for reading, and no seek operations are available.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;SimpleXMLRPCServer&amp;#039;&amp;#039;&amp;#039; - The SimpleXMLRPCServer module provides a basic server framework for XML-RPC servers written in Python. Servers can either be free standing, using SimpleXMLRPCServer, or embedded in a CGI environment, using CGIXMLRPCRequestHandler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
# -*- coding: iso-8859-1 -*-&lt;br /&gt;
#&lt;br /&gt;
# pyUnoServer - version 2.0&lt;br /&gt;
from SimpleXMLRPCServer import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler&lt;br /&gt;
import os&lt;br /&gt;
import uno&lt;br /&gt;
import sys&lt;br /&gt;
import time&lt;br /&gt;
import logging&lt;br /&gt;
import urllib&lt;br /&gt;
&lt;br /&gt;
class PyUNOServer(SimpleXMLRPCServer):&lt;br /&gt;
&lt;br /&gt;
	def _dispatch(self, method, params):&lt;br /&gt;
&lt;br /&gt;
		try:&lt;br /&gt;
			func = getattr(self, &amp;#039;&amp;#039; + method)&lt;br /&gt;
		except:&lt;br /&gt;
			self.logger.error(&amp;quot;El Metodo &amp;#039;&amp;quot;+method+&amp;quot;&amp;#039; no esta soportado!&amp;quot;)&lt;br /&gt;
			raise Exception(&amp;#039;method &amp;quot;%s&amp;quot; is not supported&amp;#039; % method)&lt;br /&gt;
		else:&lt;br /&gt;
			try:&lt;br /&gt;
				ret = func(*params)&lt;br /&gt;
				self.logger.info(&amp;quot;Llamada: &amp;quot;+str(method)+str(params)+&amp;quot; | Retorno: &amp;quot;+str(ret))&lt;br /&gt;
				return ret&lt;br /&gt;
			except:&lt;br /&gt;
				self.logger.info(&amp;quot;Llamada: &amp;quot;+str(method)+str(params))&lt;br /&gt;
				self.logger.error(&amp;quot;Error: &amp;quot;+str(sys.exc_type)+&amp;quot;:&amp;quot;+str(sys.exc_value))&lt;br /&gt;
&lt;br /&gt;
	def init(self):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		This method	starts an Openoffice session and initializes the XMLRPC server&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	&lt;br /&gt;
		# Generate some useful constants&lt;br /&gt;
		self.EMPTY = uno.Enum(&amp;quot;com.sun.star.table.CellContentType&amp;quot;, &amp;quot;EMPTY&amp;quot;)&lt;br /&gt;
		self.TEXT = uno.Enum(&amp;quot;com.sun.star.table.CellContentType&amp;quot;, &amp;quot;TEXT&amp;quot;)&lt;br /&gt;
		self.FORMULA = uno.Enum(&amp;quot;com.sun.star.table.CellContentType&amp;quot;, &amp;quot;FORMULA&amp;quot;)&lt;br /&gt;
		self.VALUE = uno.Enum(&amp;quot;com.sun.star.table.CellContentType&amp;quot;, &amp;quot;VALUE&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
		# Generate a Logger&lt;br /&gt;
		self.logger = logging.getLogger(&amp;#039;pyUnoServer&amp;#039;)&lt;br /&gt;
		hdlr = logging.FileHandler(&amp;#039;./pyUnoServer.log&amp;#039;)&lt;br /&gt;
		formatter = logging.Formatter(&amp;#039;%(asctime)s %(levelname)s -- %(message)s&amp;#039;)&lt;br /&gt;
		hdlr.setFormatter(formatter)&lt;br /&gt;
		self.logger.addHandler(hdlr) &lt;br /&gt;
		self.logger.setLevel(logging.INFO)&lt;br /&gt;
&lt;br /&gt;
		self.sessions = []&lt;br /&gt;
		self.sessionSerial = 0&lt;br /&gt;
&lt;br /&gt;
		# Start Calc and grep the PID&lt;br /&gt;
		self.PID = os.spawnlp(os.P_NOWAIT,&amp;quot;/usr/bin/oocalc&amp;quot;,&amp;quot;&amp;quot;,&amp;quot;-accept=socket,host=localhost,port=2002;urp;&amp;quot;)&lt;br /&gt;
		&lt;br /&gt;
		self.logger.info(&amp;quot;OOCalc Iniciado con el PID &amp;quot;+str(self.PID))&lt;br /&gt;
&lt;br /&gt;
		while 1:&lt;br /&gt;
			try: &lt;br /&gt;
				localContext = uno.getComponentContext()&lt;br /&gt;
				resolver = localContext.ServiceManager.createInstanceWithContext(&amp;quot;com.sun.star.bridge.UnoUrlResolver&amp;quot;, localContext )&lt;br /&gt;
				smgr = resolver.resolve( &amp;quot;uno:socket,host=localhost,port=2002;urp;StarOffice.ServiceManager&amp;quot; )&lt;br /&gt;
				remoteContext = smgr.getPropertyValue( &amp;quot;DefaultContext&amp;quot; )&lt;br /&gt;
				self.desktop = smgr.createInstanceWithContext( &amp;quot;com.sun.star.frame.Desktop&amp;quot;,remoteContext)&lt;br /&gt;
				self.logger.info(&amp;quot;Sistema conectado al socket de UNO&amp;quot;)&lt;br /&gt;
				break&lt;br /&gt;
			except:&lt;br /&gt;
				time.sleep(0.5)&lt;br /&gt;
&lt;br /&gt;
	def openSession(self, session):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		This method opens a new session.&lt;br /&gt;
		Sample usage from PHP:&lt;br /&gt;
		 - $sessionString is your a session ID provided by your program):&lt;br /&gt;
&lt;br /&gt;
			$openSession = array( new XML_RPC_VALUE($sessionString, &amp;quot;string&amp;quot;));&lt;br /&gt;
			$sessionID = queryXMLRPC($client, &amp;quot;openSession&amp;quot;, $openSession);&lt;br /&gt;
			return $sessionID;&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
		currentSerial = -1&lt;br /&gt;
&lt;br /&gt;
		for i in range(0,len(self.sessions)):&lt;br /&gt;
			if self.sessions[i][0] == session:&lt;br /&gt;
				currentSerial = i&lt;br /&gt;
				break&lt;br /&gt;
		&lt;br /&gt;
		if currentSerial == -1:&lt;br /&gt;
			self.sessions.append([session,[]])&lt;br /&gt;
			currentSerial = len(self.sessions)-1&lt;br /&gt;
&lt;br /&gt;
		return currentSerial&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
	def getSessions(self):&lt;br /&gt;
		return self.sessions&lt;br /&gt;
&lt;br /&gt;
	def openBook(self, session, bookPath):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		This method opens a new Openoffice spreadsheet book.&lt;br /&gt;
		Sample usage from PHP:&lt;br /&gt;
		 - $sessionID is the session&amp;#039;s ID returned by openSession()&lt;br /&gt;
		 - $path is the path to the book in the server&amp;#039;s filesystem&lt;br /&gt;
&lt;br /&gt;
		$openBookQuery = array( new XML_RPC_VALUE($sessionID, &amp;quot;int&amp;quot;), new XML_RPC_VALUE($path,&amp;quot;string&amp;quot;) );&lt;br /&gt;
		$bookID = queryXMLRPC($client, &amp;quot;openBook&amp;quot;, $openBookQuery);&lt;br /&gt;
		return $bookID;&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
		currentSerial = session&lt;br /&gt;
		bookPath = bookPath.strip()&lt;br /&gt;
		print bookPath&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
		exists = os.path.exists(bookPath)&lt;br /&gt;
		if exists == False:&lt;br /&gt;
			raise Exception(&amp;#039;El libro %s no existe&amp;#039;, bookPath)&lt;br /&gt;
		else:&lt;br /&gt;
			self.logger.info(&amp;quot;se ha encontrado el libro!&amp;quot;)&lt;br /&gt;
		&lt;br /&gt;
		currentBook = -1&lt;br /&gt;
		&lt;br /&gt;
		for i in range(0, len(self.sessions[currentSerial][1])):&lt;br /&gt;
			try:&lt;br /&gt;
&lt;br /&gt;
				book = self.sessions[currentSerial][1][i]&lt;br /&gt;
			&lt;br /&gt;
				bookname = book[0]&lt;br /&gt;
				bookhandler = book[1]&lt;br /&gt;
				bookmodtime = book[2]&lt;br /&gt;
			&lt;br /&gt;
				if bookname == bookPath:&lt;br /&gt;
					modtime = os.path.getmtime(bookPath)&lt;br /&gt;
					if (modtime &amp;gt; bookmodtime):&lt;br /&gt;
						book[1].dispose()&lt;br /&gt;
						self.sessions[currentSerial][1].remove(book)&lt;br /&gt;
					else:&lt;br /&gt;
						currentBook = i&lt;br /&gt;
					break&lt;br /&gt;
			except:&lt;br /&gt;
				self.logger.error(&amp;quot;El libro &amp;quot;+currentBook+&amp;quot; no existe!&amp;quot;)&lt;br /&gt;
				&lt;br /&gt;
&lt;br /&gt;
		if (currentBook &amp;lt; 0 ):&lt;br /&gt;
			handler = self.desktop.loadComponentFromURL( &amp;quot;file://&amp;quot; + bookPath ,&amp;quot;_blank&amp;quot;,0,())&lt;br /&gt;
&lt;br /&gt;
			if(handler == None):&lt;br /&gt;
				raise Exception(&amp;#039;El libro no existe o tiene caracteres extraños...&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
			modtime = os.path.getmtime(bookPath)&lt;br /&gt;
			&lt;br /&gt;
			estruct = [bookPath,handler,modtime]&lt;br /&gt;
			self.sessions[currentSerial][1].append(estruct)&lt;br /&gt;
			currentBook = len(self.sessions[currentSerial][1])-1&lt;br /&gt;
			&lt;br /&gt;
		return currentBook&lt;br /&gt;
&lt;br /&gt;
	def closeBook(self, sessionID, bookID):&lt;br /&gt;
		&lt;br /&gt;
		books = self.sessions[sessionID][1]&lt;br /&gt;
		&lt;br /&gt;
		# Close the document. It doesn&amp;#039;t look very elegant but thats the way is documented.&lt;br /&gt;
		books[bookID][1].dispose()&lt;br /&gt;
		self.sessions[sessionID][1].remove(books[bookID])&lt;br /&gt;
		&lt;br /&gt;
		return 1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	def getBookSheets(self, sessionID, bookID):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		This method return an array with the book&amp;#039;s worksheets.&lt;br /&gt;
		Sample usage from PHP:&lt;br /&gt;
		 - $sessionID is the session&amp;#039;s ID returned by openSession()&lt;br /&gt;
		 - $bookID is the book&amp;#039;s ID returned by openBook()&lt;br /&gt;
&lt;br /&gt;
		$sheetsQuery = array( new XML_RPC_VALUE($sessionID, &amp;quot;int&amp;quot;), new XML_RPC_VALUE($bookID, &amp;quot;int&amp;quot;) );&lt;br /&gt;
		$sheets = queryXMLRPC($client, &amp;quot;getBookSheets&amp;quot; , $sheetsQuery);&lt;br /&gt;
		return $sheets;&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		&lt;br /&gt;
		sheets = self.sessions[sessionID][1][bookID][1].getSheets().createEnumeration()&lt;br /&gt;
		&lt;br /&gt;
		container = []&lt;br /&gt;
		while(sheets.hasMoreElements()):&lt;br /&gt;
			currentSheet = sheets.nextElement()&lt;br /&gt;
			container.append(currentSheet.getName().encode(&amp;quot;UTF-8&amp;quot;))&lt;br /&gt;
			&lt;br /&gt;
		return container&lt;br /&gt;
&lt;br /&gt;
	def getCellValue (self,sheet,x,y):&lt;br /&gt;
&lt;br /&gt;
		cell = sheet.getCellByPosition(x,y)&lt;br /&gt;
		cellType  = cell.getType()&lt;br /&gt;
&lt;br /&gt;
		if cellType == self.TEXT :&lt;br /&gt;
			data = cell.getString().encode(&amp;quot;UTF-8&amp;quot;)&lt;br /&gt;
			if data == None:&lt;br /&gt;
				return &amp;quot;&amp;quot;&lt;br /&gt;
			return data.encode(&amp;quot;UTF-8&amp;quot;)&lt;br /&gt;
			&lt;br /&gt;
		if cellType == self.FORMULA or cellType == self.VALUE :&lt;br /&gt;
			data = cell.getValue()&lt;br /&gt;
			if data == None:&lt;br /&gt;
				return 0&lt;br /&gt;
			return cell.getValue()&lt;br /&gt;
&lt;br /&gt;
		if cellType == self.EMPTY :&lt;br /&gt;
			return &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	def getCell(self, session, book, sheet, x, y):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		This method returns the content of a cell.&lt;br /&gt;
		Sample usage from PHP:&lt;br /&gt;
		 - $sessionID is the session&amp;#039;s ID returned by openSession()&lt;br /&gt;
		 - $bookID is the book&amp;#039;s ID returned by openBook()&lt;br /&gt;
		 - $sheet is the sheet&amp;#039;s ID as returned by getBookSheets()&lt;br /&gt;
&lt;br /&gt;
		$query = array(	&lt;br /&gt;
						new XML_RPC_Value($sessionID, &amp;quot;int&amp;quot;), &lt;br /&gt;
						new XML_RPC_VALUE($bookID, &amp;quot;int&amp;quot;), &lt;br /&gt;
						new XML_RPC_VALUE($sheet, &amp;quot;int&amp;quot;), &lt;br /&gt;
						new XML_RPC_Value($x, &amp;quot;int&amp;quot;), &lt;br /&gt;
						new XML_RPC_Value($y, &amp;quot;string&amp;quot;)&lt;br /&gt;
					);&lt;br /&gt;
&lt;br /&gt;
		$result = queryXMLRPC($client, &amp;quot;getCell&amp;quot;, $query);&lt;br /&gt;
		return $result;&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
		sheetref = self.sessions[session][1][book][1].getSheets().getByIndex(sheet)&lt;br /&gt;
		valor = self.getCellValue(sheetref,x,y)&lt;br /&gt;
		return valor&lt;br /&gt;
		&lt;br /&gt;
	def setCell(self,session,book,sheet,x,y,value):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		This method sets the content of a cell.&lt;br /&gt;
		Sample usage from PHP:&lt;br /&gt;
		 - $sessionID is the session&amp;#039;s ID returned by openSession()&lt;br /&gt;
		 - $bookID is the book&amp;#039;s ID returned by openBook()&lt;br /&gt;
		 - $sheet is the sheet&amp;#039;s ID as returned by getBookSheets()&lt;br /&gt;
&lt;br /&gt;
		$query = array(&lt;br /&gt;
						new XML_RPC_Value($sessionID, &amp;quot;int&amp;quot;), &lt;br /&gt;
						new XML_RPC_VALUE($bookID, &amp;quot;int&amp;quot;), &lt;br /&gt;
						new XML_RPC_VALUE($sheet, &amp;quot;int&amp;quot;), &lt;br /&gt;
						new XML_RPC_Value($x, &amp;quot;int&amp;quot;), &lt;br /&gt;
						new XML_RPC_Value($y, &amp;quot;int&amp;quot;),&lt;br /&gt;
						new XML_RPC_Value($value, &amp;quot;string&amp;quot;)&lt;br /&gt;
					);&lt;br /&gt;
&lt;br /&gt;
		$result = queryXMLRPC($client, &amp;quot;setCell&amp;quot;, $query);&lt;br /&gt;
		return $result;&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		&lt;br /&gt;
		bookObject = self.sessions[session][1][book][1]&lt;br /&gt;
		cell = bookObject.getSheets().getByIndex(sheet).getCellByPosition(x,y)&lt;br /&gt;
		cell.setValue(value)&lt;br /&gt;
		return 1&lt;br /&gt;
&lt;br /&gt;
	#what will change? mmm...&lt;br /&gt;
	def massiveSetCell(self, data):&lt;br /&gt;
			for valores in data:&lt;br /&gt;
				session,sheetid,x,y,valor = valores.split(&amp;quot;|&amp;quot;)&lt;br /&gt;
				code = self.setCell(self.trim(session),self.trim(sheetid),self.trim(x),self.trim(y),valor)&lt;br /&gt;
				if code &amp;lt; 0:&lt;br /&gt;
					return code&lt;br /&gt;
			return 1&lt;br /&gt;
&lt;br /&gt;
	def getSheetPreview(self,session,book,sheet):&lt;br /&gt;
&lt;br /&gt;
		sheet = self.sessions[session][1][book][1].getSheets().getByIndex(sheet)&lt;br /&gt;
		range = sheet.getCellRangeByPosition(0,0,8,23).getDataArray()&lt;br /&gt;
		return range&lt;br /&gt;
		&lt;br /&gt;
&lt;br /&gt;
	def trim(self, cadena):&lt;br /&gt;
		return cadena.strip()&lt;br /&gt;
	&lt;br /&gt;
server = PyUNOServer((&amp;quot;localhost&amp;quot;, 8000))&lt;br /&gt;
&lt;br /&gt;
server.init()&lt;br /&gt;
server.logger.info(&amp;quot;Servicio Inicializado...&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
	server.serve_forever()&lt;br /&gt;
except KeyboardInterrupt:&lt;br /&gt;
	server.logger.info(&amp;quot;Cerrando el socket...&amp;quot;)&lt;br /&gt;
	server.server_close()&lt;br /&gt;
	os.kill(server.PID,1)&lt;br /&gt;
	server.logger.info(&amp;quot;Socket cerrado.&amp;quot;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==startPyUnoServer.sh2==&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/openoffice/program/&lt;br /&gt;
export PYTHONPATH=$PYTHONPATH:/usr/lib/openoffice/program&lt;br /&gt;
export DISPLAY=localhost:1&lt;br /&gt;
echo &amp;quot;Logging en pyUnoServer.log&amp;quot;&lt;br /&gt;
python pyUnoServerV2.py&lt;br /&gt;
echo &amp;quot;Ciao!&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Python]]&lt;/div&gt;</summary>
		<author><name>Andrewb</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=PyUNO_bridge&amp;diff=70448</id>
		<title>PyUNO bridge</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=PyUNO_bridge&amp;diff=70448"/>
		<updated>2008-03-17T08:26:58Z</updated>

		<summary type="html">&lt;p&gt;Andrewb: replace &amp;lt;code&amp;gt; woth &amp;lt;source&amp;gt; markup&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Translations ==&lt;br /&gt;
&lt;br /&gt;
Find here a shortened Spanish version of this document. &lt;br /&gt;
===Introduction===&lt;br /&gt;
&lt;br /&gt;
The Python-UNO bridge allows to &lt;br /&gt;
* use the standard OpenOffice.org API from the well known python scripting language. &lt;br /&gt;
* to develop UNO components in python, thus python UNO components may be run within the OpenOffice.org process and can be called from Java, C++ or the built in StarBasic scripting language.&lt;br /&gt;
* create and invoke scripts with the office scripting framework (OOo 2.0 and later).&lt;br /&gt;
&lt;br /&gt;
You can find the most current version of this document from http://udk.openoffice.org/python/python-bridge.html &lt;br /&gt;
=====Download =====&lt;br /&gt;
&lt;br /&gt;
You can also download this documentation for offline work.&lt;br /&gt;
&lt;br /&gt;
Download [http://udk.openoffice.org/python/pyuno-doc.zip pyuno-doc.zip] ( less than 0.5 MB). &lt;br /&gt;
=====State =====&lt;br /&gt;
&lt;br /&gt;
The &amp;#039;&amp;#039;&amp;#039;Python-UNO bridge&amp;#039;&amp;#039;&amp;#039; is feature complete, but has not been used extensively, so it may contain some bugs. It is now integrated in the OpenOffice.org source trees. (OpenOffice.org 1.0.x is not supported.) &lt;br /&gt;
&lt;br /&gt;
The documentation in its current state is targeted at developers who have already some experience with &amp;#039;&amp;#039;&amp;#039;OpenOffice.org API&amp;#039;&amp;#039;&amp;#039; and with some other programming language (Java/C++/StarBasic). It is recommended that you read that some background information from the &amp;#039;&amp;#039;&amp;#039;developer manual&amp;#039;&amp;#039;&amp;#039; before looking at the specifics of python.&lt;br /&gt;
&lt;br /&gt;
===PyUNO tutorial for OpenOffice.org ===&lt;br /&gt;
This tutorial shows, how the &amp;#039;&amp;#039;&amp;#039;PyUNO bridge&amp;#039;&amp;#039;&amp;#039; can be used to automate OpenOffice.org. This is not an OpenOffice.org tutorial, there is lots of resources available in the office development kit and the developer manual. &lt;br /&gt;
=====PyUNO Installation =====&lt;br /&gt;
Since OpenOffice.org 1.1, &amp;#039;&amp;#039;&amp;#039;PyUNO&amp;#039;&amp;#039;&amp;#039; is included in the default installation. &lt;br /&gt;
=====PyUNO bridge modes =====&lt;br /&gt;
&lt;br /&gt;
PyUNO can be used in three different modes: &lt;br /&gt;
* Inside the OpenOffice.org process within the scripting framework (OOo 2.0 and later only !!), &lt;br /&gt;
* Inside the python executable (and outside the OOo process)&lt;br /&gt;
[[Image:Mode_ipc.png]]&lt;br /&gt;
&lt;br /&gt;
Use this mode, when you &lt;br /&gt;
* begin to use PyUNO (as it is the more intuitive approach). &lt;br /&gt;
* want to trigger script execution by starting a separate process (e.g. a cgi-script within a http-server). &lt;br /&gt;
* want the shortest turnaround times (code - execute - code - execute ...)&lt;br /&gt;
&lt;br /&gt;
=====Hello World =====&lt;br /&gt;
&lt;br /&gt;
Make sure, that OpenOffice.org is not running (note that on windows you must also terminate the &amp;#039;&amp;#039;&amp;#039;quick starter&amp;#039;&amp;#039;&amp;#039; in the &amp;#039;&amp;#039;&amp;#039;system tray&amp;#039;&amp;#039;&amp;#039; at the right bottom of your desktop). Start a &amp;#039;&amp;#039;&amp;#039;system shell&amp;#039;&amp;#039;&amp;#039; ( cmd on Win NT/2000/XP, command on Win9x, &amp;#039;&amp;#039;&amp;#039;tcsh or bash&amp;#039;&amp;#039;&amp;#039; on Unix). Switch to the &amp;#039;&amp;#039;&amp;#039;Office program directory&amp;#039;&amp;#039;&amp;#039; (e.g. C:\Program Files\OpenOffice.org 2.4\program ) and start the office with the following &amp;#039;&amp;#039;&amp;#039;command line&amp;#039;&amp;#039;&amp;#039; parameters&lt;br /&gt;
&lt;br /&gt;
   c:\Program Files\OpenOffice.org 2.4\program&amp;gt;  soffice &amp;quot;-accept=socket,host=localhost,port=2002;urp;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now use your favourite text editor to create the following &amp;#039;&amp;#039;&amp;#039;hello_world.py&amp;#039;&amp;#039;&amp;#039; sample program:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
import uno&lt;br /&gt;
&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot; Here is the sequence of things the lines do:&lt;br /&gt;
1.  get the uno component context from the PyUNO runtime&lt;br /&gt;
2.  create the UnoUrlResolver&lt;br /&gt;
3.  get the central desktop object&lt;br /&gt;
4.  Declare the ServiceManager&lt;br /&gt;
5.  get the central desktop object&lt;br /&gt;
6.  access the current writer document&lt;br /&gt;
7.  access the document&amp;#039;s text property&lt;br /&gt;
8.  create a cursor&lt;br /&gt;
9.  insert the text into the document &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
localContext = uno.getComponentContext()&lt;br /&gt;
resolver = localContext.ServiceManager.createInstanceWithContext(&lt;br /&gt;
				&amp;quot;com.sun.star.bridge.UnoUrlResolver&amp;quot;, localContext )&lt;br /&gt;
ctx = resolver.resolve( &amp;quot;uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext&amp;quot; )&lt;br /&gt;
smgr = ctx.ServiceManager&lt;br /&gt;
desktop = smgr.createInstanceWithContext( &amp;quot;com.sun.star.frame.Desktop&amp;quot;,ctx)&lt;br /&gt;
model = desktop.getCurrentComponent()&lt;br /&gt;
text = model.Text&lt;br /&gt;
cursor = text.createTextCursor()&lt;br /&gt;
&lt;br /&gt;
text.insertString( cursor, &amp;quot;Hello World&amp;quot;, 0 )&lt;br /&gt;
&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot; Do a nasty thing before exiting the python process. In case the&lt;br /&gt;
 last call is a oneway call (e.g. see idl-spec of insertString),&lt;br /&gt;
 it must be forced out of the remote-bridge caches before python&lt;br /&gt;
 exits the process. Otherwise, the oneway call may or may not reach&lt;br /&gt;
 the target object.&lt;br /&gt;
 I do this here by calling a cheap synchronous call (getPropertyValue).&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
ctx.ServiceManager&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now start the above script with the &amp;#039;&amp;#039;&amp;#039;python script&amp;#039;&amp;#039;&amp;#039; located in the program directory&lt;br /&gt;
&lt;br /&gt;
  c:\Program Files\OpenOffice1.1\program&amp;gt; .\python hello_world.py&lt;br /&gt;
&lt;br /&gt;
Note: You must use the script/batch file in the program directory to &amp;#039;&amp;#039;&amp;#039;start python&amp;#039;&amp;#039;&amp;#039;, simply starting the &amp;#039;&amp;#039;&amp;#039;python executable&amp;#039;&amp;#039;&amp;#039; in the runtime directory (or from &amp;#039;&amp;#039;&amp;#039;python installation&amp;#039;&amp;#039;&amp;#039; installed somewhere else on your machine) will not work. &lt;br /&gt;
&lt;br /&gt;
This scripts prints &amp;quot;Hello World&amp;quot; into the &amp;#039;&amp;#039;&amp;#039;current writer document&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Mode_component.png]]&lt;br /&gt;
[[Category:Python]]&lt;/div&gt;</summary>
		<author><name>Andrewb</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=PrinttoWriter.py&amp;diff=70447</id>
		<title>PrinttoWriter.py</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=PrinttoWriter.py&amp;diff=70447"/>
		<updated>2008-03-17T08:21:56Z</updated>

		<summary type="html">&lt;p&gt;Andrewb: changed [code] to &amp;lt;source&amp;gt; markup&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Danny.OOo.PrintToWriter.py ==&lt;br /&gt;
&lt;br /&gt;
This makes it easy and convenient to &amp;#039;&amp;#039;&amp;#039;print&amp;#039;&amp;#039;&amp;#039; a bunch of text into a Writer document. &lt;br /&gt;
&lt;br /&gt;
See the example routine in the module that shows how easy this module is to use, and how useful it can be. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
#********************************************************************** &lt;br /&gt;
#   If you make changes, please append to the change log below. &lt;br /&gt;
# &lt;br /&gt;
#   Change Log &lt;br /&gt;
#   Danny Brewer         Revised 2004-06-05-01 &lt;br /&gt;
# &lt;br /&gt;
#********************************************************************** &lt;br /&gt;
&lt;br /&gt;
# OOo&amp;#039;s libraries &lt;br /&gt;
import uno &lt;br /&gt;
&lt;br /&gt;
# Danny&amp;#039;s libraries &lt;br /&gt;
from Danny.OOo.OOoLib import StarDesktop &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
com_sun_star_text_ControlCharacter_PARAGRAPH_BREAK  = uno.getConstantByName( &amp;quot;com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK&amp;quot; ) &lt;br /&gt;
com_sun_star_text_ControlCharacter_LINE_BREAK       = uno.getConstantByName( &amp;quot;com.sun.star.text.ControlCharacter.LINE_BREAK&amp;quot; ) &lt;br /&gt;
com_sun_star_text_ControlCharacter_HARD_HYPHEN      = uno.getConstantByName( &amp;quot;com.sun.star.text.ControlCharacter.HARD_HYPHEN&amp;quot; ) &lt;br /&gt;
com_sun_star_text_ControlCharacter_SOFT_HYPHEN      = uno.getConstantByName( &amp;quot;com.sun.star.text.ControlCharacter.SOFT_HYPHEN&amp;quot; ) &lt;br /&gt;
com_sun_star_text_ControlCharacter_HARD_SPACE       = uno.getConstantByName( &amp;quot;com.sun.star.text.ControlCharacter.HARD_SPACE&amp;quot; ) &lt;br /&gt;
com_sun_star_text_ControlCharacter_APPEND_PARAGRAPH = uno.getConstantByName( &amp;quot;com.sun.star.text.ControlCharacter.APPEND_PARAGRAPH&amp;quot; ) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class PrintToWriter: &lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;A class which allows conveniently printing stuff into a Writer document. &lt;br /&gt;
    Very useful for debugging, general output purposes, or even for creating reports.&amp;quot;&amp;quot;&amp;quot; &lt;br /&gt;
    def __init__( self ): &lt;br /&gt;
        self.oWriterDoc = StarDesktop.loadComponentFromURL( &amp;quot;private:factory/swriter&amp;quot;, &amp;quot;_blank&amp;quot;, 0, () ) &lt;br /&gt;
        self.oWriterText = self.oWriterDoc.getText() &lt;br /&gt;
        self.oWriterCursor = self.oWriterText.createTextCursor() &lt;br /&gt;
&lt;br /&gt;
    def writeLn( self, *args ): &lt;br /&gt;
        if len( args ) &amp;gt; 0: &lt;br /&gt;
            apply( self.write, args ) &lt;br /&gt;
        self.writeParagraphBreak() &lt;br /&gt;
&lt;br /&gt;
    def write( self, arg1, *argsRest ): &lt;br /&gt;
        self.writeOne( arg1 ) &lt;br /&gt;
        for arg in argsRest: &lt;br /&gt;
            self.writeTab() &lt;br /&gt;
            self.writeOne( arg ) &lt;br /&gt;
&lt;br /&gt;
    def writeOne( self, arg, bAbsorb=False ): &lt;br /&gt;
        self.writeString( str( arg ), bAbsorb ) &lt;br /&gt;
&lt;br /&gt;
    def writeTab( self, bAbsorb=False ): &lt;br /&gt;
        self.writeString( &amp;quot;\t&amp;quot;, bAbsorb ) &lt;br /&gt;
&lt;br /&gt;
    def writeParagraphBreak( self, bAbsorb=False ): &lt;br /&gt;
        self.writeControlCharacter( com_sun_star_text_ControlCharacter_PARAGRAPH_BREAK, bAbsorb ) &lt;br /&gt;
&lt;br /&gt;
    def writeString( self, cString, bAbsorb=False ): &lt;br /&gt;
        self.oWriterText.insertString( self.oWriterCursor, cString, bAbsorb ) &lt;br /&gt;
&lt;br /&gt;
    def writeControlCharacter( self, nCtrlChar, bAbsorb=False ): &lt;br /&gt;
        self.oWriterText.insertControlCharacter( self.oWriterCursor, nCtrlChar, bAbsorb ) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def example_PrintToWriter(): &lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;An example of how to use the PrintToWriter class to trivially create &lt;br /&gt;
    a new Writer document, and write out text into it.&amp;quot;&amp;quot;&amp;quot; &lt;br /&gt;
    oOutput = PrintToWriter() &lt;br /&gt;
    oOutput.writeLn( &amp;quot;Hello World&amp;quot; ) &lt;br /&gt;
    oOutput.write( &amp;quot;String&amp;quot;, 123, 456.23, True ) &lt;br /&gt;
    oOutput.writeLn() &lt;br /&gt;
    oOutput.writeLn() &lt;br /&gt;
&lt;br /&gt;
    oOutput.writeLn( &amp;quot;Tab delimited values...&amp;quot; ) &lt;br /&gt;
    &lt;br /&gt;
    oOutput.write( 123 ) &lt;br /&gt;
    oOutput.writeTab() &lt;br /&gt;
    oOutput.write( 456 ) &lt;br /&gt;
    oOutput.writeTab() &lt;br /&gt;
    oOutput.write( 789 ) &lt;br /&gt;
    oOutput.writeLn() &lt;br /&gt;
    &lt;br /&gt;
    oOutput.write( 465 ) &lt;br /&gt;
    oOutput.writeTab() &lt;br /&gt;
    oOutput.write( 522 ) &lt;br /&gt;
    oOutput.writeTab() &lt;br /&gt;
    oOutput.write( 835 ) &lt;br /&gt;
    oOutput.writeLn() &lt;br /&gt;
    &lt;br /&gt;
    oOutput.write( 886 ) &lt;br /&gt;
    oOutput.writeTab() &lt;br /&gt;
    oOutput.write( 164 ) &lt;br /&gt;
    oOutput.writeTab() &lt;br /&gt;
    oOutput.write( 741 ) &lt;br /&gt;
    oOutput.writeLn()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
== How it Works ==&lt;br /&gt;
PrintToWriter.py code is really just a way to:&lt;br /&gt;
* create the enviroment&lt;br /&gt;
* create a document&lt;br /&gt;
* generate the content&lt;br /&gt;
* insert it within a document&lt;br /&gt;
&lt;br /&gt;
So first we need to create the &amp;#039;&amp;#039;&amp;#039;enviroment&amp;#039;&amp;#039;&amp;#039; so that we don&amp;#039;t generate a verbose code, we need to insert it into variable.&lt;br /&gt;
&lt;br /&gt;
To create the enviroment we need a couple of things, first we import a library, which already save us a bunch of code in order to reference to UNO. The next step is to choose the fomat element we will need to input. For tha we use the uno.getConstantByName and point to the [http://api.openoffice.org/docs/common/ref/com/sun/star/text/ControlCharacter.html ControlCharacter] component which includes all the format we need. &lt;br /&gt;
&lt;br /&gt;
* Paragraph Break - Insert a paragraph break&lt;br /&gt;
* Line Break - Inserts a line break inside of the paragraph&lt;br /&gt;
* Hard Hyphen - A character that appears like a dash, but prevents hyphenation at its position&lt;br /&gt;
* Soft Hyphen - Marks a preferred position for hyphenation&lt;br /&gt;
* Hard Space - A character that appears like a space, but prevents hyphenation at this point&lt;br /&gt;
* Append Paragraph - A new paragraph is appended &lt;br /&gt;
&lt;br /&gt;
The next step is to generate the class for &amp;#039;&amp;#039;&amp;#039;PrintToWriter&amp;#039;&amp;#039;&amp;#039;, this is the class that this file is about. Then we need to load the writer component, on like 59. We use the &amp;#039;&amp;#039;&amp;#039;getText()&amp;#039;&amp;#039;&amp;#039; function so we can access the text area from the writer&amp;#039;s component. Once we are there, we explicity activate the Cursor.&lt;br /&gt;
&lt;br /&gt;
We go on using the following functions:&lt;br /&gt;
&lt;br /&gt;
* writeLn = Insert a break on end of Line&lt;br /&gt;
* write = &lt;br /&gt;
* writeOne = Write String&lt;br /&gt;
* writeTab = Insert a &amp;#039;&amp;#039;&amp;#039;\t&amp;#039;&amp;#039;&amp;#039; value as a string&lt;br /&gt;
* writeParagraphBreak =  we call on the PARAGRAPH_BREAK component&lt;br /&gt;
* writeString = We use cString after the Cursor&lt;br /&gt;
* writeControlCharacter = nCtrlChar&lt;br /&gt;
&lt;br /&gt;
The example_PrinterToWrite is basically we execute the functtons we create under the &amp;#039;&amp;#039;&amp;#039;PrintToWriter class&amp;#039;&amp;#039;&amp;#039;. This will be enough for you to see how we can use the functions to insert content and how it works the different funmction.&lt;br /&gt;
&lt;br /&gt;
[[Category:Python]]&lt;/div&gt;</summary>
		<author><name>Andrewb</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Python_as_a_macro_language&amp;diff=70444</id>
		<title>Python as a macro language</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Python_as_a_macro_language&amp;diff=70444"/>
		<updated>2008-03-17T08:04:03Z</updated>

		<summary type="html">&lt;p&gt;Andrewb: minor grammar cleanups. One question added.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Pyuno supports the OOo scripting framework which first shipped with OOo 2.0. The current support is limited to the &amp;#039;&amp;#039;&amp;#039;core framework&amp;#039;&amp;#039;&amp;#039;, meaning that execution and assigning of macros via the standard Tools/Macro dialog works fine, but editing and debugging macros is not integrated in OpenOffice.org&amp;#039;s UI (simply because of the lack of development resources). Use your favourite text editor to create and modify python scripts.&lt;br /&gt;
&lt;br /&gt;
== Script Location ==&lt;br /&gt;
Scripts to be excuted in OpenOffice.org can be stored within the following locations:&lt;br /&gt;
[[Image:Macro_run_dlg.PNG]]&lt;br /&gt;
&lt;br /&gt;
===OpenOffice.org&amp;#039;s user directory===&lt;br /&gt;
&lt;br /&gt;
This is the standard place for self written python scripts. The script files are simply stored within the file system. On windows, the directory can typically be found in:&lt;br /&gt;
&lt;br /&gt;
* windows - &amp;#039;&amp;#039;&amp;#039;C:\Documents and Settings\&amp;lt;current-user\&amp;gt;Application Data\OpenOffice.org 2.0\user\Scripts\python&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* unix - &amp;#039;&amp;#039;&amp;#039;~/.openoffice.org.2.0/user/Scripts/python&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Note, that the last python subdirectory may need to be created initially. Make sure, the python is completly written lowercase. You can add arbitrary deeply nested subdirectories, the names of these directories are reflected in the UI. &lt;br /&gt;
&lt;br /&gt;
Example: The [http://udk.openoffice.org/python/scriptingframework/dynamicDialog.py dynamicDialog.py] file can simply be placed in the above directory. Afterwards, open the &amp;#039;&amp;#039;Tools/Macros/Run macro dialog&amp;#039;&amp;#039; and navigate to the position shown in the above picture. Click on Run to execute the python script, which opens another dialog with a push button and a label field. Clicking the button will increase the number within the label field. The dialog can be closed by pressing ESC.&lt;br /&gt;
&lt;br /&gt;
===OpenOffice.org&amp;#039;s share directory===&lt;br /&gt;
&lt;br /&gt;
Scripts that shall be shared throughout all users of a concrete OpenOffice.org installation can be stored with the share directory. All default scripts coming with OpenOffice.org are located here. In general, this directory should not be used for script deployment (see later uno-packages). &lt;br /&gt;
&lt;br /&gt;
The script files are simply stored within the file system. The directory can typically be found in &lt;br /&gt;
* windows &amp;#039;&amp;#039;&amp;#039;C:\Program Files\OpenOffice.org 2.0\share\Scripts\python&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* unix	&amp;#039;&amp;#039;&amp;#039;/usr/lib/openoffice/share/Scripts/python&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
===Embedded within an OpenOffice.org&amp;#039;s document===&lt;br /&gt;
&lt;br /&gt;
An OpenOffice.org document is a zip-File, which contains different files. Python scripts within documents are stored in Scripts/python subdirectory. &lt;br /&gt;
&lt;br /&gt;
If you want to ship your self written python scripts within a document, you should first develop your scripts in the (above mentioned) user directory and then finally move the scripts into the document with your favorite zip tool. However, note that you must reassign every binding you did before to the script instances in the document. Ideally, you move away the scripts from the user directory and do a regression test on the document&amp;#039;s functionality.&lt;br /&gt;
&lt;br /&gt;
After moving the script files into the document, you have to add some lines (boldly printed) to the &amp;#039;&amp;#039;META-INF/manifest.xml&amp;#039;&amp;#039; file:&lt;br /&gt;
&amp;lt;source lang=xml&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE manifest:manifest PUBLIC &amp;quot;-//OpenOffice.org//DTD Manifest 1.0//EN&amp;quot; &amp;quot;Manifest.dtd&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;manifest:manifest xmlns:manifest=&amp;quot;http://openoffice.org/2001/manifest&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;application/vnd.oasis.opendocument.text&amp;quot; manifest:full-path=&amp;quot;/&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;application/vnd.sun.xml.ui.configuration&amp;quot; manifest:full-path=&amp;quot;Configurations2/&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;&amp;quot; manifest:full-path=&amp;quot;Pictures/&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;text/xml&amp;quot; manifest:full-path=&amp;quot;content.xml&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry :media-type=&amp;quot;text/xml&amp;quot; manifest:full-path=&amp;quot;styles.xml&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;text/xml&amp;quot; manifest:full-path=&amp;quot;meta.xml&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;&amp;quot; manifest:full-path=&amp;quot;Thumbnails/thumbnail.png&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;&amp;quot; manifest:full-path=&amp;quot;Thumbnails/&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;text/xml&amp;quot; manifest:full-path=&amp;quot;settings.xml&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;&amp;quot; manifest:full-path=&amp;quot;Scripts/python/push_me.py&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;application/binary&amp;quot; manifest:full-path=&amp;quot;Scripts/python/&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;application/binary&amp;quot; manifest:full-path=&amp;quot;Scripts/&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/manifest:manifest&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
When you open the document afterwards, the OpenOffice.org&amp;#039;s UI should warn you about script content within the document (when this is not the case, you either have switched off the warning in the options or you did something wrong).&lt;br /&gt;
&lt;br /&gt;
Example:To see how it works, download push_me_python4.odt. The document contains a push button and a multi line edit control. Pressing the button adds a new line with the current time stamp to the multi line edit control.&lt;br /&gt;
&lt;br /&gt;
===Embedded within a uno-package in OpenOffice.org&amp;#039;s user directory (read only)===&lt;br /&gt;
&lt;br /&gt;
Often, distributing scripts in documents is not what you want (for instance when you want to modify the application itself or you want to use the same scripts with multiple documents ). Therefor you can place your scripts simply within uno-packages. &lt;br /&gt;
&lt;br /&gt;
A uno-package is a zip-file. Its name must end with .pkg, otherwise it does not work. file, where you must define the subdirectory (required!) that shall contain scripts. For instance the sample [http://udk.openoffice.org/python/scriptingframework/pyhello2.uno.pkg pyhello2.uno.pkg] has the following file structure:&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
META-INF/&lt;br /&gt;
META-INF/manifest.xml&lt;br /&gt;
package/&lt;br /&gt;
package/hallo.py&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The hallo.py contains the scripts. How to write scripts is explained below. However, in order to make a script work within a uno package, you must add some dummy code.&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
# ... here is the python script code&lt;br /&gt;
&lt;br /&gt;
# this must be added to every script file (the&lt;br /&gt;
# name org.openoffice.script.DummyImplementationForPythonScripts should be changed to something&lt;br /&gt;
# different (must be unique within an office installation !)&lt;br /&gt;
# --- faked component, dummy to allow registration with unopkg, no functionality expected&lt;br /&gt;
import unohelper&lt;br /&gt;
g_ImplementationHelper = unohelper.ImplementationHelper()&lt;br /&gt;
g_ImplementationHelper.addImplementation( \&lt;br /&gt;
	None,&amp;quot;org.openoffice.script.DummyImplementationForPythonScripts&amp;quot;, \&lt;br /&gt;
    (&amp;quot;org.openoffice.script.DummyServiceForPythonScripts&amp;quot;,),)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
By default, every .py-file is interpreted as a UNO component. Not having the above lines within the .py file would raise errors during deployment. &lt;br /&gt;
&lt;br /&gt;
The directory name (here package) can be choosen freely. A uno-package with a python script must contain a META-INF/manifest.xml, which needs to point to the freely chosen directory name.&lt;br /&gt;
&amp;lt;source lang=xml&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE manifest:manifest PUBLIC &amp;quot;-//OpenOffice.org//DTD Manifest 1.0//EN&amp;quot; &amp;quot;Manifest.dtd&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;manifest:manifest xmlns:manifest=&amp;quot;http://openoffice.org/2001/manifest&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;manifest:file-entry manifest:media-type=&amp;quot;application/vnd.sun.star.framework-script&amp;quot; manifest:full-path=&amp;quot;package&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/manifest:manifest&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Every user can add packages via the package manager (Tools/Package manager). Note, that content within the package is by design readonly, it is really a pure deployment, not a development mechanism. This might be the reason, why scripts in packages cannot be viewed via Tools/Macros/Organize macros/Python dialog. &lt;br /&gt;
Embedded within a uno-package in OpenOffice.org&amp;#039;s share directory (read only) &lt;br /&gt;
&lt;br /&gt;
Packages can be added by an administrator to a complete OpenOffice.org installation, so that every user can use run the macros located within the package. This can be done with the unopkg tool.&lt;br /&gt;
&lt;br /&gt;
==Script coding==&lt;br /&gt;
A python script within the OpenOffice.org&amp;#039;s scripting framework is a function (introduced by the def keyword) within a .py file. For execution via the &amp;#039;&amp;#039;Tools/Macros/Run macro dialog&amp;#039;&amp;#039;, the script must have an empty argument list. For typical event listeners, the function must have exactly one argument (the event). In general, the number of arguments depend on the context where the function shall be used. Currently, the .py file must use unix line feeds, this will be changed in future. &lt;br /&gt;
&lt;br /&gt;
A single .py file may contain an arbitrary number of function definitions. By default, all function definitions are exported ( = shown in the macro selection dialog). As this may become tedious, exports can be limited to a smaller set of functions by having a global variable named g_exportedScripts, which is a tuple of function definitions. &lt;br /&gt;
&lt;br /&gt;
At the current integration level, .py files can only import python modules which are within the python PYTHONPATH. By default this is just the python runtime with its standard libraries and the uno bridge files. This means that python macros cannot reference other python macro files. This limitation may be changed in future but exists currently. Python macros can, of course, import from any module you place in the PYTHONPATH; but you must do that yourself and the results will not be portable.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;(a reader wonders: couldn&amp;#039;t the pythonloader automatically append the OOo scripting dirs to PYTHONPATH?)&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Before executing the source code within the module, the global variable XSCRIPTCONTEXT is inserted as global variable within the module (this variable also exists e.g. for javascript and beanshell, it is offered here for consistency reasons). It has three members (Document,Desktop and ComponentContext). &lt;br /&gt;
&lt;br /&gt;
The comment of a function (introduced and ended by three &amp;quot;) is shown as description in the macros&amp;#039; selection dialog. &lt;br /&gt;
&lt;br /&gt;
The compiled python script files are not added to sys.modules. There may exist multiple instances of the same module at the same time.&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;source lang=python&amp;gt; &lt;br /&gt;
# HelloWorld python script for the scripting framework&lt;br /&gt;
&lt;br /&gt;
def HelloWorldPython( ):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Prints the string &amp;#039;Hello World(in Python)&amp;#039; into the current document&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    #get the doc from the scripting context which is made available to all scripts&lt;br /&gt;
    model = XSCRIPTCONTEXT.getDocument()&lt;br /&gt;
    text = model.Text&lt;br /&gt;
    cursor = text.createTextCursor()&lt;br /&gt;
    text.insertString( cursor, &amp;quot;Hello World(in Python)&amp;quot;, 0 )&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
==Error handling and debugging==&lt;br /&gt;
Errors during compilation or execution of the scripts are passed as exceptions to the scripting framework where possible. The scripting framework in general opens a popup box and displays the message of the thrown exception. &lt;br /&gt;
&lt;br /&gt;
However, sometimes this is not possible and an error gets silently ignored. The user realizes these errors, when&lt;br /&gt;
* his python script file does not appear where it is expected to be &lt;br /&gt;
* the name of the script file appears, but it does not contain any scripts &lt;br /&gt;
* only part of the script gets executed.&lt;br /&gt;
&lt;br /&gt;
You can get to know these problems by changing some flags in the &amp;#039;&amp;#039;&amp;#039;OpenOffice.org 2.0/program/pythonscript.py&amp;#039;&amp;#039;&amp;#039; file :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
# Configuration ----------------------------------------------------&lt;br /&gt;
LogLevel.use = LogLevel.NONE                # alternavly use LogLevel.ERROR or LogLevel.DEBUG&lt;br /&gt;
LOG_STDOUT = False                          # True, writes to stdout&lt;br /&gt;
                                            # False, writes to user/Scripts/python/log.txt&lt;br /&gt;
ENABLE_EDIT_DIALOG=False                    # offers a minimal editor for editing.&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Attaching a python debugger is currently not supported.&lt;br /&gt;
&lt;br /&gt;
==Credits==&lt;br /&gt;
The python binding of the scripting framework is developed and maintained by Joerg Budischewski in his spare time. Many, many thanks to Tomas O&amp;#039;Connor from Sun for his great support and his code additions to the framework which made this binding possible. Please put low level questions about the binding to dev@udk.openoffice.org. Questions about the OpenOffice.org&amp;#039;s API should be put to dev@api.openoffice.org.&lt;br /&gt;
&lt;br /&gt;
[[Category:Python]]&lt;br /&gt;
[[Category:Uno]]&lt;/div&gt;</summary>
		<author><name>Andrewb</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Python_as_a_macro_language&amp;diff=70405</id>
		<title>Python as a macro language</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Python_as_a_macro_language&amp;diff=70405"/>
		<updated>2008-03-16T20:47:43Z</updated>

		<summary type="html">&lt;p&gt;Andrewb: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Pyuno supports the OOo scripting framework, that is first shipped with OOo 2.0. The current support is limited to the &amp;#039;&amp;#039;&amp;#039;core framework&amp;#039;&amp;#039;&amp;#039;, meaning that execution and assigning of macros via the standard Tools/Macro dialog works fine, but editing and debugging macros is not integrated in OpenOffice.org&amp;#039;s UI (simply because of the lack of development resources). Use your favourite text editor to create and modify python scripts.&lt;br /&gt;
&lt;br /&gt;
== Script Location ==&lt;br /&gt;
Scripts to be excuted in OpenOffice.org can be stored within the following locations:&lt;br /&gt;
[[Image:Macro_run_dlg.PNG]]&lt;br /&gt;
&lt;br /&gt;
===OpenOffice.org&amp;#039;s user directory===&lt;br /&gt;
&lt;br /&gt;
This is the standard place for self written python scripts. The script files are simply stored within the file system. On windows, the directory can typically be found in:&lt;br /&gt;
&lt;br /&gt;
* windows - &amp;#039;&amp;#039;&amp;#039;C:\Documents and Settings\&amp;lt;current-user\&amp;gt;Application Data\OpenOffice.org 2.0\user\Scripts\python&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* unix - &amp;#039;&amp;#039;&amp;#039;~/.openoffice.org.2.0/user/Scripts/python&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Note, that the last python subdirectory may need to be created initially. Make sure, the python is completly written lowercase. You can add arbitrary deeply nested subdirectories, the names of these directories are reflected in the UI. &lt;br /&gt;
&lt;br /&gt;
Example: The [http://udk.openoffice.org/python/scriptingframework/dynamicDialog.py dynamicDialog.py] file can simply be placed in the above directory. Afterwards, open the &amp;#039;&amp;#039;Tools/Macros/Run macro dialog&amp;#039;&amp;#039; and navigate to the position shown in the above picture. Click on Run to execute the python script, which opens another dialog with a push button and a label field. Clicking the button will increase the number within the label field. The dialog can be closed by pressing ESC.&lt;br /&gt;
&lt;br /&gt;
===OpenOffice.org&amp;#039;s share directory===&lt;br /&gt;
&lt;br /&gt;
Scripts that shall be shared throughout all users of a concrete OpenOffice.org installation can be stored with the share directory. All default scripts coming with OpenOffice.org are located here. In general, this directory should not be used for script deployment (see later uno-packages). &lt;br /&gt;
&lt;br /&gt;
The script files are simply stored within the file system. The directory can typically be found in &lt;br /&gt;
* windows &amp;#039;&amp;#039;&amp;#039;C:\Program Files\OpenOffice.org 2.0\share\Scripts\python&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* unix	&amp;#039;&amp;#039;&amp;#039;/usr/lib/openoffice/share/Scripts/python&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
===Embedded within an OpenOffice.org&amp;#039;s document===&lt;br /&gt;
&lt;br /&gt;
An OpenOffice.org document is a zip-File, which contains different files. Python scripts within documents are stored in Scripts/python subdirectory. &lt;br /&gt;
&lt;br /&gt;
If you want to ship your self written python scripts within a document, you should first develop your scripts in the (above mentioned) user directory and then finally move the scripts into the document with your favorite zip tool. However, note that you must reassign every binding you did before to the script instances in the document. Ideally, you move away the scripts from the user directory and do a regression test on the document&amp;#039;s functionality.&lt;br /&gt;
&lt;br /&gt;
After moving the script files into the document, you have to add some lines (boldly printed) to the &amp;#039;&amp;#039;META-INF/manifest.xml&amp;#039;&amp;#039; file:&lt;br /&gt;
&amp;lt;source lang=xml&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE manifest:manifest PUBLIC &amp;quot;-//OpenOffice.org//DTD Manifest 1.0//EN&amp;quot; &amp;quot;Manifest.dtd&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;manifest:manifest xmlns:manifest=&amp;quot;http://openoffice.org/2001/manifest&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;application/vnd.oasis.opendocument.text&amp;quot; manifest:full-path=&amp;quot;/&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;application/vnd.sun.xml.ui.configuration&amp;quot; manifest:full-path=&amp;quot;Configurations2/&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;&amp;quot; manifest:full-path=&amp;quot;Pictures/&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;text/xml&amp;quot; manifest:full-path=&amp;quot;content.xml&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry :media-type=&amp;quot;text/xml&amp;quot; manifest:full-path=&amp;quot;styles.xml&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;text/xml&amp;quot; manifest:full-path=&amp;quot;meta.xml&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;&amp;quot; manifest:full-path=&amp;quot;Thumbnails/thumbnail.png&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;&amp;quot; manifest:full-path=&amp;quot;Thumbnails/&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;text/xml&amp;quot; manifest:full-path=&amp;quot;settings.xml&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;&amp;quot; manifest:full-path=&amp;quot;Scripts/python/push_me.py&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;application/binary&amp;quot; manifest:full-path=&amp;quot;Scripts/python/&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;application/binary&amp;quot; manifest:full-path=&amp;quot;Scripts/&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/manifest:manifest&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
When you open the document afterwards, the OpenOffice.org&amp;#039;s UI should warn you about script content within the document (when this is not the case, you either have switched off the warning in the options or you did something wrong).&lt;br /&gt;
&lt;br /&gt;
Example:To see how it works, download push_me_python4.odt. The document contains a push button and a multi line edit control. Pressing the button adds a new line with the current time stamp to the multi line edit control.&lt;br /&gt;
&lt;br /&gt;
===Embedded within a uno-package in OpenOffice.org&amp;#039;s user directory (read only)===&lt;br /&gt;
&lt;br /&gt;
Often, distributing scripts in documents is not what you want (for instance when you want to modify the application itself or you want to use the same scripts with multiple documents ). Therefor you can place your scripts simply within uno-packages. &lt;br /&gt;
&lt;br /&gt;
A uno-package is a zip-file. Its name must end with .pkg, otherwise it does not work. file, where you must define the subdirectory (required!) that shall contain scripts. For instance the sample [http://udk.openoffice.org/python/scriptingframework/pyhello2.uno.pkg pyhello2.uno.pkg] has the following file structure:&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
META-INF/&lt;br /&gt;
META-INF/manifest.xml&lt;br /&gt;
package/&lt;br /&gt;
package/hallo.py&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The hallo.py contains the scripts. How to write scripts is explained below. However, in order to make a script work within a uno package, you must add some dummy code.&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
# ... here is the python script code&lt;br /&gt;
&lt;br /&gt;
# this must be added to every script file (the&lt;br /&gt;
# name org.openoffice.script.DummyImplementationForPythonScripts should be changed to something&lt;br /&gt;
# different (must be unique within an office installation !)&lt;br /&gt;
# --- faked component, dummy to allow registration with unopkg, no functionality expected&lt;br /&gt;
import unohelper&lt;br /&gt;
g_ImplementationHelper = unohelper.ImplementationHelper()&lt;br /&gt;
g_ImplementationHelper.addImplementation( \&lt;br /&gt;
	None,&amp;quot;org.openoffice.script.DummyImplementationForPythonScripts&amp;quot;, \&lt;br /&gt;
    (&amp;quot;org.openoffice.script.DummyServiceForPythonScripts&amp;quot;,),)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
By default, every .py-file is interpreted as a UNO component. Not having the above lines within the .py file would raise errors during deployment. &lt;br /&gt;
&lt;br /&gt;
The directory name (here package) can be choosen freely. A uno-package with a python script must contain a META-INF/manifest.xml, which needs to point to the freely chosen directory name.&lt;br /&gt;
&amp;lt;source lang=xml&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE manifest:manifest PUBLIC &amp;quot;-//OpenOffice.org//DTD Manifest 1.0//EN&amp;quot; &amp;quot;Manifest.dtd&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;manifest:manifest xmlns:manifest=&amp;quot;http://openoffice.org/2001/manifest&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;manifest:file-entry manifest:media-type=&amp;quot;application/vnd.sun.star.framework-script&amp;quot; manifest:full-path=&amp;quot;package&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/manifest:manifest&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Every user can add packages via the package manager (Tools/Package manager). Note, that content within the package is by design readonly, it is really a pure deployment, not a development mechanism. This might be the reason, why scripts in packages cannot be viewed via Tools/Macros/Organize macros/Python dialog. &lt;br /&gt;
Embedded within a uno-package in OpenOffice.org&amp;#039;s share directory (read only) &lt;br /&gt;
&lt;br /&gt;
Packages can be added by an administrator to a complete OpenOffice.org installation, so that every user can use run the macros located within the package. This can be done with the unopkg tool.&lt;br /&gt;
&lt;br /&gt;
==Script coding==&lt;br /&gt;
A python script within the OpenOffice.org&amp;#039;s scripting framework is a function (introduced by the def keyword) within a .py file. For execution via the &amp;#039;&amp;#039;Tools/Macros/Run macro dialog&amp;#039;&amp;#039;, the script must have an empty argument list. For typical event listeners, the function must have exactly one argument (the event). In general, the number of arguments depend on the context where the function shall be used. Currently, the .py file must use unix line feeds, this will be changed in future. &lt;br /&gt;
&lt;br /&gt;
A single .py file may contain an arbitrary number of function definitions. By default, all function definitions are exported ( = shown in the macro selection dialog). As this may become tedious, exports can be limited to a smaller set of functions by having a global variable named g_exportedScripts, which is a tuple of function definitions. &lt;br /&gt;
&lt;br /&gt;
At the current integration level, .py files can only import python modules, which are within the python PYTHONPATH, by default this is just the python runtime and the uno bridge files. This means, that it cannot reference other python macro files. This limitation may be changed in future but exists currently. &lt;br /&gt;
&lt;br /&gt;
Before executing the source code within the module, the global variable XSCRIPTCONTEXT is inserted as global variable within the module (this variable also exists e.g. for javascript and beanshell, it is offered here for consistency reasons). It has three members (Document,Desktop and ComponentContext). &lt;br /&gt;
&lt;br /&gt;
The comment of a function (introduced and ended by three &amp;quot;) is shown as description in the macros&amp;#039; selection dialog. &lt;br /&gt;
&lt;br /&gt;
The compiled python script files are not added to sys.modules. There may exist multiple instances of the same module at the same time.&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;source lang=python&amp;gt; &lt;br /&gt;
# HelloWorld python script for the scripting framework&lt;br /&gt;
&lt;br /&gt;
def HelloWorldPython( ):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Prints the string &amp;#039;Hello World(in Python)&amp;#039; into the current document&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    #get the doc from the scripting context which is made available to all scripts&lt;br /&gt;
    model = XSCRIPTCONTEXT.getDocument()&lt;br /&gt;
    text = model.Text&lt;br /&gt;
    cursor = text.createTextCursor()&lt;br /&gt;
    text.insertString( cursor, &amp;quot;Hello World(in Python)&amp;quot;, 0 )&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
==Error handling and debugging==&lt;br /&gt;
Errors during compilation or execution of the scripts are passed as exceptions to the scripting framework where possible. The scripting framework in general opens a popup box and displays the message of the thrown exception. &lt;br /&gt;
&lt;br /&gt;
However, sometimes this is not possible and an error gets silently ignored. The user realizes these errors, when&lt;br /&gt;
* his python script file does not appear where it is expected to be &lt;br /&gt;
* the name of the script file appears, but it does not contain any scripts &lt;br /&gt;
* only part of the script gets executed.&lt;br /&gt;
&lt;br /&gt;
You can get to know these problems by changing some flags in the &amp;#039;&amp;#039;&amp;#039;OpenOffice.org 2.0/program/pythonscript.py&amp;#039;&amp;#039;&amp;#039; file :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
# Configuration ----------------------------------------------------&lt;br /&gt;
LogLevel.use = LogLevel.NONE                # alternavly use LogLevel.ERROR or LogLevel.DEBUG&lt;br /&gt;
LOG_STDOUT = False                          # True, writes to stdout&lt;br /&gt;
                                            # False, writes to user/Scripts/python/log.txt&lt;br /&gt;
ENABLE_EDIT_DIALOG=False                    # offers a minimal editor for editing.&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Attaching a python debugger is currently not supported.&lt;br /&gt;
&lt;br /&gt;
==Credits==&lt;br /&gt;
The python binding of the scripting framework is developed and maintained by Joerg Budischewski in his spare time. Many, many thanks to Tomas O&amp;#039;Connor from Sun for his great support and his code additions to the framework which made this binding possible. Please put low level questions about the binding to dev@udk.openoffice.org. Questions about the OpenOffice.org&amp;#039;s API should be put to dev@api.openoffice.org.&lt;br /&gt;
&lt;br /&gt;
[[Category:Python]]&lt;br /&gt;
[[Category:Uno]]&lt;/div&gt;</summary>
		<author><name>Andrewb</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Python_as_a_macro_language&amp;diff=70404</id>
		<title>Python as a macro language</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Python_as_a_macro_language&amp;diff=70404"/>
		<updated>2008-03-16T20:45:59Z</updated>

		<summary type="html">&lt;p&gt;Andrewb: cleaned code markup&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Pyuno supports the OOo scripting framework, that is first shipped with OOo 2.0. The current support is limited to the &amp;#039;&amp;#039;&amp;#039;core framework&amp;#039;&amp;#039;&amp;#039;, meaning that execution and assigning of macros via the standard Tools/Macro dialog works fine, but editing and debugging macros is not integrated in OpenOffice.org&amp;#039;s UI (simply because of the lack of development resources). Use your favourite text editor to create and modify python scripts.&lt;br /&gt;
&lt;br /&gt;
== Script Location ==&lt;br /&gt;
Scripts to be excuted in OpenOffice.org can be stored within the following locations:&lt;br /&gt;
[[Image:Macro_run_dlg.PNG]]&lt;br /&gt;
&lt;br /&gt;
===OpenOffice.org&amp;#039;s user directory===&lt;br /&gt;
&lt;br /&gt;
This is the standard place for self written python scripts. The script files are simply stored within the file system. On windows, the directory can typically be found in:&lt;br /&gt;
&lt;br /&gt;
* windows - &amp;#039;&amp;#039;&amp;#039;C:\Documents and Settings\&amp;lt;current-user\&amp;gt;Application Data\OpenOffice.org 2.0\user\Scripts\python&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* unix - &amp;#039;&amp;#039;&amp;#039;~/.openoffice.org.2.0/user/Scripts/python&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Note, that the last python subdirectory may need to be created initially. Make sure, the python is completly written lowercase. You can add arbitrary deeply nested subdirectories, the names of these directories are reflected in the UI. &lt;br /&gt;
&lt;br /&gt;
Example: The [http://udk.openoffice.org/python/scriptingframework/dynamicDialog.py dynamicDialog.py] file can simply be placed in the above directory. Afterwards, open the &amp;#039;&amp;#039;Tools/Macros/Run macro dialog&amp;#039;&amp;#039; and navigate to the position shown in the above picture. Click on Run to execute the python script, which opens another dialog with a push button and a label field. Clicking the button will increase the number within the label field. The dialog can be closed by pressing ESC.&lt;br /&gt;
&lt;br /&gt;
===OpenOffice.org&amp;#039;s share directory===&lt;br /&gt;
&lt;br /&gt;
Scripts that shall be shared throughout all users of a concrete OpenOffice.org installation can be stored with the share directory. All default scripts coming with OpenOffice.org are located here. In general, this directory should not be used for script deployment (see later uno-packages). &lt;br /&gt;
&lt;br /&gt;
The script files are simply stored within the file system. The directory can typically be found in &lt;br /&gt;
* windows &amp;#039;&amp;#039;&amp;#039;C:\Program Files\OpenOffice.org 2.0\share\Scripts\python&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* unix	&amp;#039;&amp;#039;&amp;#039;/usr/lib/openoffice/share/Scripts/python&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
===Embedded within an OpenOffice.org&amp;#039;s document===&lt;br /&gt;
&lt;br /&gt;
An OpenOffice.org document is a zip-File, which contains different files. Python scripts within documents are stored in Scripts/python subdirectory. &lt;br /&gt;
&lt;br /&gt;
If you want to ship your self written python scripts within a document, you should first develop your scripts in the (above mentioned) user directory and then finally move the scripts into the document with your favorite zip tool. However, note that you must reassign every binding you did before to the script instances in the document. Ideally, you move away the scripts from the user directory and do a regression test on the document&amp;#039;s functionality.&lt;br /&gt;
&lt;br /&gt;
After moving the script files into the document, you have to add some lines (boldly printed) to the &amp;#039;&amp;#039;META-INF/manifest.xml&amp;#039;&amp;#039; file:&lt;br /&gt;
&amp;lt;source lang=xml&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE manifest:manifest PUBLIC &amp;quot;-//OpenOffice.org//DTD Manifest 1.0//EN&amp;quot; &amp;quot;Manifest.dtd&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;manifest:manifest xmlns:manifest=&amp;quot;http://openoffice.org/2001/manifest&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;application/vnd.oasis.opendocument.text&amp;quot; manifest:full-path=&amp;quot;/&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;application/vnd.sun.xml.ui.configuration&amp;quot; manifest:full-path=&amp;quot;Configurations2/&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;&amp;quot; manifest:full-path=&amp;quot;Pictures/&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;text/xml&amp;quot; manifest:full-path=&amp;quot;content.xml&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry :media-type=&amp;quot;text/xml&amp;quot; manifest:full-path=&amp;quot;styles.xml&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;text/xml&amp;quot; manifest:full-path=&amp;quot;meta.xml&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;&amp;quot; manifest:full-path=&amp;quot;Thumbnails/thumbnail.png&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;&amp;quot; manifest:full-path=&amp;quot;Thumbnails/&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;text/xml&amp;quot; manifest:full-path=&amp;quot;settings.xml&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;&amp;quot; manifest:full-path=&amp;quot;Scripts/python/push_me.py&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;application/binary&amp;quot; manifest:full-path=&amp;quot;Scripts/python/&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;manifest:file-entry manifest:media-type=&amp;quot;application/binary&amp;quot; manifest:full-path=&amp;quot;Scripts/&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/manifest:manifest&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
When you open the document afterwards, the OpenOffice.org&amp;#039;s UI should warn you about script content within the document (when this is not the case, you either have switched off the warning in the options or you did something wrong).&lt;br /&gt;
&lt;br /&gt;
Example:To see how it works, download push_me_python4.odt. The document contains a push button and a multi line edit control. Pressing the button adds a new line with the current time stamp to the multi line edit control.&lt;br /&gt;
&lt;br /&gt;
===Embedded within a uno-package in OpenOffice.org&amp;#039;s user directory (read only)===&lt;br /&gt;
&lt;br /&gt;
Often, distributing scripts in documents is not what you want (for instance when you want to modify the application itself or you want to use the same scripts with multiple documents ). Therefor you can place your scripts simply within uno-packages. &lt;br /&gt;
&lt;br /&gt;
A uno-package is a zip-file. Its name must end with .pkg, otherwise it does not work. file, where you must define the subdirectory (required!) that shall contain scripts. For instance the sample [http://udk.openoffice.org/python/scriptingframework/pyhello2.uno.pkg pyhello2.uno.pkg] has the following file structure:&lt;br /&gt;
&amp;lt;code&amp;gt;[bash]&lt;br /&gt;
META-INF/&lt;br /&gt;
META-INF/manifest.xml&lt;br /&gt;
package/&lt;br /&gt;
package/hallo.py&amp;lt;/code&amp;gt;&lt;br /&gt;
The hallo.py contains the scripts. How to write scripts is explained below. However, in order to make a script work within a uno package, you must add some dummy code.&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
# ... here is the python script code&lt;br /&gt;
&lt;br /&gt;
# this must be added to every script file (the&lt;br /&gt;
# name org.openoffice.script.DummyImplementationForPythonScripts should be changed to something&lt;br /&gt;
# different (must be unique within an office installation !)&lt;br /&gt;
# --- faked component, dummy to allow registration with unopkg, no functionality expected&lt;br /&gt;
import unohelper&lt;br /&gt;
g_ImplementationHelper = unohelper.ImplementationHelper()&lt;br /&gt;
g_ImplementationHelper.addImplementation( \&lt;br /&gt;
	None,&amp;quot;org.openoffice.script.DummyImplementationForPythonScripts&amp;quot;, \&lt;br /&gt;
    (&amp;quot;org.openoffice.script.DummyServiceForPythonScripts&amp;quot;,),)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
By default, every .py-file is interpreted as a UNO component. Not having the above lines within the .py file would raise errors during deployment. &lt;br /&gt;
&lt;br /&gt;
The directory name (here package) can be choosen freely. A uno-package with a python script must contain a META-INF/manifest.xml, which needs to point to the freely chosen directory name.&lt;br /&gt;
&amp;lt;source=xml&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE manifest:manifest PUBLIC &amp;quot;-//OpenOffice.org//DTD Manifest 1.0//EN&amp;quot; &amp;quot;Manifest.dtd&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;manifest:manifest xmlns:manifest=&amp;quot;http://openoffice.org/2001/manifest&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;manifest:file-entry manifest:media-type=&amp;quot;application/vnd.sun.star.framework-script&amp;quot; manifest:full-path=&amp;quot;package&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/manifest:manifest&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Every user can add packages via the package manager (Tools/Package manager). Note, that content within the package is by design readonly, it is really a pure deployment, not a development mechanism. This might be the reason, why scripts in packages cannot be viewed via Tools/Macros/Organize macros/Python dialog. &lt;br /&gt;
Embedded within a uno-package in OpenOffice.org&amp;#039;s share directory (read only) &lt;br /&gt;
&lt;br /&gt;
Packages can be added by an administrator to a complete OpenOffice.org installation, so that every user can use run the macros located within the package. This can be done with the unopkg tool.&lt;br /&gt;
&lt;br /&gt;
==Script coding==&lt;br /&gt;
A python script within the OpenOffice.org&amp;#039;s scripting framework is a function (introduced by the def keyword) within a .py file. For execution via the &amp;#039;&amp;#039;Tools/Macros/Run macro dialog&amp;#039;&amp;#039;, the script must have an empty argument list. For typical event listeners, the function must have exactly one argument (the event). In general, the number of arguments depend on the context where the function shall be used. Currently, the .py file must use unix line feeds, this will be changed in future. &lt;br /&gt;
&lt;br /&gt;
A single .py file may contain an arbitrary number of function definitions. By default, all function definitions are exported ( = shown in the macro selection dialog). As this may become tedious, exports can be limited to a smaller set of functions by having a global variable named g_exportedScripts, which is a tuple of function definitions. &lt;br /&gt;
&lt;br /&gt;
At the current integration level, .py files can only import python modules, which are within the python PYTHONPATH, by default this is just the python runtime and the uno bridge files. This means, that it cannot reference other python macro files. This limitation may be changed in future but exists currently. &lt;br /&gt;
&lt;br /&gt;
Before executing the source code within the module, the global variable XSCRIPTCONTEXT is inserted as global variable within the module (this variable also exists e.g. for javascript and beanshell, it is offered here for consistency reasons). It has three members (Document,Desktop and ComponentContext). &lt;br /&gt;
&lt;br /&gt;
The comment of a function (introduced and ended by three &amp;quot;) is shown as description in the macros&amp;#039; selection dialog. &lt;br /&gt;
&lt;br /&gt;
The compiled python script files are not added to sys.modules. There may exist multiple instances of the same module at the same time.&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;source lang=python&amp;gt; &lt;br /&gt;
# HelloWorld python script for the scripting framework&lt;br /&gt;
&lt;br /&gt;
def HelloWorldPython( ):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Prints the string &amp;#039;Hello World(in Python)&amp;#039; into the current document&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    #get the doc from the scripting context which is made available to all scripts&lt;br /&gt;
    model = XSCRIPTCONTEXT.getDocument()&lt;br /&gt;
    text = model.Text&lt;br /&gt;
    cursor = text.createTextCursor()&lt;br /&gt;
    text.insertString( cursor, &amp;quot;Hello World(in Python)&amp;quot;, 0 )&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
==Error handling and debugging==&lt;br /&gt;
Errors during compilation or execution of the scripts are passed as exceptions to the scripting framework where possible. The scripting framework in general opens a popup box and displays the message of the thrown exception. &lt;br /&gt;
&lt;br /&gt;
However, sometimes this is not possible and an error gets silently ignored. The user realizes these errors, when&lt;br /&gt;
* his python script file does not appear where it is expected to be &lt;br /&gt;
* the name of the script file appears, but it does not contain any scripts &lt;br /&gt;
* only part of the script gets executed.&lt;br /&gt;
&lt;br /&gt;
You can get to know these problems by changing some flags in the &amp;#039;&amp;#039;&amp;#039;OpenOffice.org 2.0/program/pythonscript.py&amp;#039;&amp;#039;&amp;#039; file :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
# Configuration ----------------------------------------------------&lt;br /&gt;
LogLevel.use = LogLevel.NONE                # alternavly use LogLevel.ERROR or LogLevel.DEBUG&lt;br /&gt;
LOG_STDOUT = False                          # True, writes to stdout&lt;br /&gt;
                                            # False, writes to user/Scripts/python/log.txt&lt;br /&gt;
ENABLE_EDIT_DIALOG=False                    # offers a minimal editor for editing.&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Attaching a python debugger is currently not supported.&lt;br /&gt;
&lt;br /&gt;
==Credits==&lt;br /&gt;
The python binding of the scripting framework is developed and maintained by Joerg Budischewski in his spare time. Many, many thanks to Tomas O&amp;#039;Connor from Sun for his great support and his code additions to the framework which made this binding possible. Please put low level questions about the binding to dev@udk.openoffice.org. Questions about the OpenOffice.org&amp;#039;s API should be put to dev@api.openoffice.org.&lt;br /&gt;
&lt;br /&gt;
[[Category:Python]]&lt;br /&gt;
[[Category:Uno]]&lt;/div&gt;</summary>
		<author><name>Andrewb</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=UNO_component_packaging&amp;diff=69578</id>
		<title>UNO component packaging</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=UNO_component_packaging&amp;diff=69578"/>
		<updated>2008-03-08T18:30:58Z</updated>

		<summary type="html">&lt;p&gt;Andrewb: code prettied; rewrote and corrected note about importing classes&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Python UNO component=&lt;br /&gt;
This page shows you how to pack and deploy already written UNO component. I&amp;#039;m using my &amp;#039;&amp;#039;Wavelet&amp;#039;&amp;#039; class as an example of a very simple component. &lt;br /&gt;
&lt;br /&gt;
More detailed info is in the [[http://api.openoffice.org/docs/DevelopersGuide/Components/Components.htm Developers Guide]]. &lt;br /&gt;
&lt;br /&gt;
=Python loader=&lt;br /&gt;
The Python loader is not able load classes that are not it its own path. Thus it&amp;#039;s necessary to copy any classes or modules you will use into the OPenOffice Python lib directory, and it may be necessary to restart OOo before they are picked up. &lt;br /&gt;
&lt;br /&gt;
=Sample Python component=&lt;br /&gt;
&lt;br /&gt;
==Wavelet class==&lt;br /&gt;
We will use my sample &amp;#039;&amp;#039;Wavelet&amp;#039;&amp;#039; class which replaces space with non breaking space before the Czech prepositions. Put the following code in the &amp;#039;&amp;#039;Wavelet.py&amp;#039;&amp;#039; file. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import uno&lt;br /&gt;
import unohelper&lt;br /&gt;
import string&lt;br /&gt;
from com.sun.star.task import XJobExecutor&lt;br /&gt;
&lt;br /&gt;
class Wavelet( unohelper.Base, XJobExecutor ):&lt;br /&gt;
    def __init__( self, ctx ):&lt;br /&gt;
        self.ctx = ctx&lt;br /&gt;
 &lt;br /&gt;
    def trigger( self, args ):&lt;br /&gt;
        desktop = self.ctx.ServiceManager.createInstanceWithContext(&lt;br /&gt;
            &amp;quot;com.sun.star.frame.Desktop&amp;quot;, self.ctx )&lt;br /&gt;
 &lt;br /&gt;
        doc = desktop.getCurrentComponent()&lt;br /&gt;
 &lt;br /&gt;
        try:&lt;br /&gt;
            search = doc.createSearchDescriptor()&lt;br /&gt;
            search.SearchRegularExpression = True&lt;br /&gt;
            search.SearchString = &amp;quot;\\&amp;lt;(k|s|v|z|o|u|i|a) &amp;quot;&lt;br /&gt;
            &lt;br /&gt;
            found = doc.findFirst( search )&lt;br /&gt;
            while found:&lt;br /&gt;
                found.String = string.replace( found.String, &amp;quot; &amp;quot;, u&amp;quot;\xa0&amp;quot; )&lt;br /&gt;
                found = doc.findNext( found.End, search)&lt;br /&gt;
 &lt;br /&gt;
        except:&lt;br /&gt;
            pass&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Wavelet class registration==&lt;br /&gt;
You have to tell the OpenOffice.org what is the main class of your component. Put the following code at the end of your &amp;#039;&amp;#039;Wavelet.py&amp;#039;&amp;#039; file. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
g_ImplementationHelper = unohelper.ImplementationHelper()&lt;br /&gt;
g_ImplementationHelper.addImplementation(&lt;br /&gt;
        Wavelet,&lt;br /&gt;
        &amp;quot;name.vojta.openoffice.Wavelet&amp;quot;,&lt;br /&gt;
        (&amp;quot;com.sun.star.task.Job&amp;quot;,),)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Component integration=&lt;br /&gt;
&lt;br /&gt;
==Icons==&lt;br /&gt;
You can create your own icons for the Menu item or the Toolbar button. The easiest way is to create two true color BMP files - the first one should be 26×26 and the second one should be 16×16. &lt;br /&gt;
&lt;br /&gt;
If you want to use alpha (transparent color), use &amp;#039;&amp;#039;#FF00FF&amp;#039;&amp;#039; (RGB) color. &lt;br /&gt;
&lt;br /&gt;
This possibility is optional and you&amp;#039;re not forced to create icons. &lt;br /&gt;
&lt;br /&gt;
==Addons.xcu==&lt;br /&gt;
Component integration configuration is in the &amp;#039;&amp;#039;Addons.xcu&amp;#039;&amp;#039; file. &lt;br /&gt;
&lt;br /&gt;
===Header===&lt;br /&gt;
The header of this file should contain: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=xml&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;oor:component-data xmlns:oor=&amp;quot;http://openoffice.org/2001/registry&amp;quot;&lt;br /&gt;
  xmlns:xs=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot; oor:name=&amp;quot;Addons&amp;quot;&lt;br /&gt;
  oor:package=&amp;quot;org.openoffice.Office&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
    &amp;lt;node oor:name=&amp;quot;AddonUI&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Office Menu Bar===&lt;br /&gt;
Following part creates new menu item &amp;#039;&amp;#039;Czech&amp;#039;&amp;#039; (or &amp;#039;&amp;#039;Cestina&amp;#039;&amp;#039;, depends on the UI language) and the &amp;#039;&amp;#039;Wavelet&amp;#039;&amp;#039; menu item. &lt;br /&gt;
&lt;br /&gt;
This menu item is associated with the &amp;#039;&amp;#039;name.vojta.openoffice.Wavelet?execute&amp;#039;&amp;#039; &amp;#039;&amp;#039;URL&amp;#039;&amp;#039;. It means, that when you click on the menuitem, &amp;#039;&amp;#039;Wavelet.trigger&amp;#039;&amp;#039; method will be executed with the &amp;#039;&amp;#039;execute&amp;#039;&amp;#039; as an argument. &lt;br /&gt;
&lt;br /&gt;
This menu will be visible in the OpenOffice.org Writer only. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=xml&amp;gt;&lt;br /&gt;
        &amp;lt;node oor:name=&amp;quot;OfficeMenuBar&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;node oor:name=&amp;quot;name.vojta.openoffice.Wavelet&amp;quot; oor:op=&amp;quot;replace&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;prop oor:name=&amp;quot;Title&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                    &amp;lt;value/&amp;gt;&lt;br /&gt;
                    &amp;lt;value xml:lang=&amp;quot;en-US&amp;quot;&amp;gt;Czech&amp;lt;/value&amp;gt;&lt;br /&gt;
                    &amp;lt;value xml:lang=&amp;quot;cs&amp;quot;&amp;gt;Cestina&amp;lt;/value&amp;gt;&lt;br /&gt;
                &amp;lt;/prop&amp;gt;&lt;br /&gt;
                &amp;lt;prop oor:name=&amp;quot;Target&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                    &amp;lt;value&amp;gt;_self&amp;lt;/value&amp;gt;&lt;br /&gt;
                &amp;lt;/prop&amp;gt;&lt;br /&gt;
                &amp;lt;prop oor:name=&amp;quot;ImageIdentifier&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                    &amp;lt;value/&amp;gt;&lt;br /&gt;
                &amp;lt;/prop&amp;gt;&lt;br /&gt;
                &amp;lt;node oor:name=&amp;quot;Submenu&amp;quot;&amp;gt;&lt;br /&gt;
                    &amp;lt;node oor:name=&amp;quot;m1&amp;quot; oor:op=&amp;quot;replace&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;prop oor:name=&amp;quot;URL&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                            &amp;lt;value&amp;gt;service:name.vojta.openoffice.Wavelet?execute&amp;lt;/value&amp;gt;&lt;br /&gt;
                        &amp;lt;/prop&amp;gt;&lt;br /&gt;
                        &amp;lt;prop oor:name=&amp;quot;Title&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                            &amp;lt;value/&amp;gt;&lt;br /&gt;
                            &amp;lt;value xml:lang=&amp;quot;en-US&amp;quot;&amp;gt;Wavelet&amp;lt;/value&amp;gt;&lt;br /&gt;
                            &amp;lt;value xml:lang=&amp;quot;cs&amp;quot;&amp;gt;Vlnka&amp;lt;/value&amp;gt;&lt;br /&gt;
                        &amp;lt;/prop&amp;gt;&lt;br /&gt;
                        &amp;lt;prop oor:name=&amp;quot;Target&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                            &amp;lt;value&amp;gt;_self&amp;lt;/value&amp;gt;&lt;br /&gt;
                        &amp;lt;/prop&amp;gt;&lt;br /&gt;
                        &amp;lt;prop oor:name=&amp;quot;Context&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                            &amp;lt;value&amp;gt;com.sun.star.text.TextDocument&amp;lt;/value&amp;gt;&lt;br /&gt;
                        &amp;lt;/prop&amp;gt;&lt;br /&gt;
                    &amp;lt;/node&amp;gt;&lt;br /&gt;
                &amp;lt;/node&amp;gt;&lt;br /&gt;
            &amp;lt;/node&amp;gt;&lt;br /&gt;
&amp;lt;/node&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Office Toolbar===&lt;br /&gt;
Following part creates new toolbar (with name &amp;#039;&amp;#039;Add-on 1&amp;#039;&amp;#039;, &amp;#039;&amp;#039;Add-on 2&amp;#039;&amp;#039;, …) and one button. This button is associated with the &amp;#039;&amp;#039;name.vojta.openoffice.Wavelet?execute&amp;#039;&amp;#039; &amp;#039;&amp;#039;URL&amp;#039;&amp;#039;. It means that the &amp;#039;&amp;#039;Wavelet.trigger&amp;#039;&amp;#039; method will be executed when you click on the button on the toolbar. &amp;#039;&amp;#039;execute&amp;#039;&amp;#039; will be passed as an argument. &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Note:&amp;#039;&amp;#039;&amp;#039; You can&amp;#039;t rename the toolbar. It&amp;#039;s due to the backwards compatibility with the 1.1.x version. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=xml&amp;gt;&lt;br /&gt;
        &amp;lt;node oor:name=&amp;quot;OfficeToolBar&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;node oor:name=&amp;quot;name.vojta.openoffice.Wavelet&amp;quot; oor:op=&amp;quot;replace&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;node oor:name=&amp;quot;m1&amp;quot; oor:op=&amp;quot;replace&amp;quot;&amp;gt;&lt;br /&gt;
                    &amp;lt;prop oor:name=&amp;quot;URL&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;value&amp;gt;service:name.vojta.openoffice.Wavelet?execute&amp;lt;/value&amp;gt;&lt;br /&gt;
                    &amp;lt;/prop&amp;gt;&lt;br /&gt;
                    &amp;lt;prop oor:name=&amp;quot;ImageIdentifier&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;value/&amp;gt;&lt;br /&gt;
                    &amp;lt;/prop&amp;gt;&lt;br /&gt;
                    &amp;lt;prop oor:name=&amp;quot;Title&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;value/&amp;gt;&lt;br /&gt;
                        &amp;lt;value xml:lang=&amp;quot;en-US&amp;quot;&amp;gt;Wavelet&amp;lt;/value&amp;gt;&lt;br /&gt;
                        &amp;lt;value xml:lang=&amp;quot;cs&amp;quot;&amp;gt;Vlnka&amp;lt;/value&amp;gt;&lt;br /&gt;
                    &amp;lt;/prop&amp;gt;&lt;br /&gt;
                    &amp;lt;prop oor:name=&amp;quot;Target&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;value&amp;gt;_self&amp;lt;/value&amp;gt;&lt;br /&gt;
                    &amp;lt;/prop&amp;gt;&lt;br /&gt;
                    &amp;lt;prop oor:name=&amp;quot;Context&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;value&amp;gt;com.sun.star.text.TextDocument&amp;lt;/value&amp;gt;&lt;br /&gt;
                    &amp;lt;/prop&amp;gt;&lt;br /&gt;
                &amp;lt;/node&amp;gt;&lt;br /&gt;
            &amp;lt;/node&amp;gt;&lt;br /&gt;
&amp;lt;/node&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Icons===&lt;br /&gt;
You can associate your icons with any &amp;#039;&amp;#039;URL&amp;#039;&amp;#039;. We will associate our icons with &amp;#039;&amp;#039;name.vojta.openoffice.Wavelet?execute&amp;#039;&amp;#039; &amp;#039;&amp;#039;URL&amp;#039;&amp;#039;. It means that all controls (menu item, button, …) associated with the same &amp;#039;&amp;#039;URL&amp;#039;&amp;#039; will use these icons. &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Note:&amp;#039;&amp;#039;&amp;#039; %origin% is the UNO component package. We will explain it later. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=xml&amp;gt;&lt;br /&gt;
        &amp;lt;node oor:name=&amp;quot;Images&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;node oor:name=&amp;quot;name.vojta.openoffice.Wavelet.image1&amp;quot; oor:op=&amp;quot;replace&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;prop oor:name=&amp;quot;URL&amp;quot;&amp;gt;&lt;br /&gt;
                    &amp;lt;value&amp;gt;service:name.vojta.openoffice.Wavelet?execute&amp;lt;/value&amp;gt;&lt;br /&gt;
                &amp;lt;/prop&amp;gt;&lt;br /&gt;
                &amp;lt;node oor:name=&amp;quot;UserDefinedImages&amp;quot;&amp;gt;&lt;br /&gt;
                    &amp;lt;prop oor:name=&amp;quot;ImageSmallURL&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;value&amp;gt;%origin%/images/WaveletSmall.bmp&amp;lt;/value&amp;gt;&lt;br /&gt;
                    &amp;lt;/prop&amp;gt;&lt;br /&gt;
                    &amp;lt;prop oor:name=&amp;quot;ImageBigURL&amp;quot; oor:type=&amp;quot;xs:string&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;value&amp;gt;%origin%/images/WaveletBig.bmp&amp;lt;/value&amp;gt;&lt;br /&gt;
                    &amp;lt;/prop&amp;gt;&lt;br /&gt;
                &amp;lt;/node&amp;gt;&lt;br /&gt;
            &amp;lt;/node&amp;gt;&lt;br /&gt;
&amp;lt;/node&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Footer===&lt;br /&gt;
Close all opened sections. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=xml&amp;gt;&lt;br /&gt;
    &amp;lt;/node&amp;gt;&lt;br /&gt;
 &amp;lt;/oor:component-data&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=UNO component package=&lt;br /&gt;
UNO component package is a simple ZIP file. Obviously it contains the &amp;#039;&amp;#039;Addons.xcu&amp;#039;&amp;#039; file, &amp;#039;&amp;#039;images&amp;#039;&amp;#039; directory with icons and the Python component implementation. &lt;br /&gt;
&lt;br /&gt;
==Packing==&lt;br /&gt;
You can pack our sample package with the following command: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
zip -r Wavelet.uno.zip Addons.xcu Wavelet.py images&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The final &amp;#039;&amp;#039;Wavelet.uno.zip&amp;#039;&amp;#039; package should contain these files: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
Wavelet.uno.zip&lt;br /&gt;
  Addons.xcu&lt;br /&gt;
  Wavelet.py&lt;br /&gt;
  images/WaveletBig.bmp&lt;br /&gt;
  images/WaveletSmall.bmp&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Note:&amp;#039;&amp;#039;&amp;#039; The &amp;#039;&amp;#039;%origin%&amp;#039;&amp;#039; is &amp;#039;&amp;#039;Wavelet.uno.zip&amp;#039;&amp;#039;, thus the &amp;#039;&amp;#039;%origin%/images/WaveletBig.bmp&amp;#039;&amp;#039; points to the &amp;#039;&amp;#039;WaveletBig.bmp&amp;#039;&amp;#039; file in your &amp;#039;&amp;#039;Wavelet.uno.zip&amp;#039;&amp;#039; file. &lt;br /&gt;
&lt;br /&gt;
==Installation==&lt;br /&gt;
You can install your UNO component with the Extension manager (somewhere in the &amp;#039;&amp;#039;Tools&amp;#039;&amp;#039; menu) or with the &amp;#039;&amp;#039;unopkg&amp;#039;&amp;#039; tool. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
/opt/openoffice.org1.9.103/program/unopkg add Wavelet.uno.zip&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Uninstallation==&lt;br /&gt;
You can uninstall your UNO component with the Extension manager (somewhere in the &amp;#039;&amp;#039;Tools&amp;#039;&amp;#039; menu) or with the &amp;#039;&amp;#039;unopkg&amp;#039;&amp;#039; tool. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
/opt/openoffice.org1.9.103/program/unopkg remove Wavelet.uno.zip&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Python component testing=&lt;br /&gt;
It&amp;#039;s not necessary to install the Python UNO component to test it. You can connect to the running OpenOffice.org instance and test your UNO component directly. &lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
Append the following code at the end of the &amp;#039;&amp;#039;Wavelet.py&amp;#039;&amp;#039; file. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
    import os&lt;br /&gt;
 &lt;br /&gt;
    # Start OpenOffice.org, listen for connections and open testing document&lt;br /&gt;
    os.system( &amp;quot;/etc/openoffice.org-1.9/program/soffice &amp;#039;-accept=socket,host=localhost,port=2002;urp;&amp;#039; -writer ./WaveletTest.odt &amp;amp;&amp;quot; )&lt;br /&gt;
 &lt;br /&gt;
    # Get local context info&lt;br /&gt;
    localContext = uno.getComponentContext()&lt;br /&gt;
    resolver = localContext.ServiceManager.createInstanceWithContext(&lt;br /&gt;
        &amp;quot;com.sun.star.bridge.UnoUrlResolver&amp;quot;, localContext )&lt;br /&gt;
 &lt;br /&gt;
    ctx = None&lt;br /&gt;
 &lt;br /&gt;
    # Wait until the OO.o starts and connection is established&lt;br /&gt;
    while ctx == None:&lt;br /&gt;
        try:&lt;br /&gt;
            ctx = resolver.resolve(&lt;br /&gt;
                &amp;quot;uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext&amp;quot; )&lt;br /&gt;
        except:&lt;br /&gt;
            pass&lt;br /&gt;
 &lt;br /&gt;
    # Trigger our job&lt;br /&gt;
    wavelet = Wavelet( ctx )&lt;br /&gt;
    wavelet.trigger( () )&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
To test your UNO component, just run your &amp;#039;&amp;#039;Wavelet.py&amp;#039;&amp;#039; in the Python interpreter. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
/opt/openoffice.org1.9.103/program/python ./Wavelet.py&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Resume==&lt;br /&gt;
This part does this: &lt;br /&gt;
&lt;br /&gt;
starts OpenOffice.org and opens the &amp;#039;&amp;#039;WaveletTest.odt&amp;#039;&amp;#039; file &lt;br /&gt;
&lt;br /&gt;
loop until the connection will be established &lt;br /&gt;
&lt;br /&gt;
start your component in the running OpenOffice.org context &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Note:&amp;#039;&amp;#039;&amp;#039; Do not forget to remove this part before real UNO component packaging. Or comment it out.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=See also=&lt;br /&gt;
* [http://api.openoffice.org/docs/DevelopersGuide/Extensions/Extensions.xhtml Extensions] chapter of the Developers Guide&lt;br /&gt;
* Using C++ with OOo SDK : [[Constructing_Components| Constructing Component in C++]]&lt;br /&gt;
*[[Tutorial_UNO_Library|UNO tutorial]]&lt;br /&gt;
*[[Tutorial_UNO_IDL|UNO IDL]]&lt;br /&gt;
* [[Uno/Article/Types%26Reflection]]&lt;br /&gt;
* Daniel Bölzle&amp;#039;s [http://udk.openoffice.org/cpp/man/component_tutorial.html tutorial] : Writing a simple UNO component.&lt;br /&gt;
* [[UNO_component_packaging|Component with Python]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Uno]]&lt;br /&gt;
[[Category:Extensions]]&lt;/div&gt;</summary>
		<author><name>Andrewb</name></author>
	</entry>
</feed>