OO-Snippets: Insert Annotation

Commons

Keywordsannotation, annotations, insert annotation
LanguageooRexx
ApplicationWriter
AuthorsMatthias Prem (initial)
Supported Versions2.0.x  
Supported OSAll  
QuestionHow can I insert an annotation?
Answer

Code-Snippet-Listing (snippet-source)

/* InsertAnnotation.rex */
/* Macro */

/* get the script context, the XModel and the XTextDocument interface */
xScriptContext=uno.getScriptContext()
oDoc=xScriptContext~getDocument
xTextDoc=oDoc~XTextDocument
xText=xTextDoc~getText()

/* get the XMultiServiceFactory needed for textfields */
xServiceManager=oDoc~XMultiServiceFactory

/* create an annotation */
annotation=xServiceManager~createInstance("com.sun.star.text.TextField.Annotation")
annotationTC=annotation~XTextContent()

/* set author and content of the annotation */
annotationPS=annotation~XPropertySet()
annotationPS~setPropertyValue("Author", "ooRexx")
annotationPS~setPropertyValue("Content", "I was here.")

/* insert annotation at cursor position */
xCursor=xTextDoc~getText~createTextCursor()
xText~insertTextContent(xCursor, annotationTC, .false)

::requires UNO.CLS

Changelog

DateUserModification
2006-07-10matthiaspremInitial version

and