 | OO-Snippets: Insert an annotation fieldCommons| Keywords | insert, note, field, annotation |
|---|
| Language | ooRexx |
|---|
| Application | Writer |
|---|
| Authors | Josef Frysak (initial)
|
|---|
| Supported Versions | 2.4.1 |
|---|
| Supported OS | All |
|---|
| Question | How to insert a Note Field?
|
|---|
| Answer | With the documents "XMultiServiceFactory" interface create a new "TextField.Annotation" object. Set the author and as well as the content of the note field by accessing and changing the objects properties. Next create a "Date" structure and enter the date of creation. Apply the "Date" structure as "date" property to the note object too. Finally add the note object to the document, by using the "insertTextContent" function. For further details see http://wi.wu-wien.ac.at/rgf/diplomarbeiten/BakkStuff/2008/200809_Frysak/200809_Frysak_Automating_OOo_ooRexx_Nutshells.pdf. |
|---|
x_ScriptContext = uno.getScriptContext()
if (x_ScriptContext <> .nil) then
do
x_ComponentContext = x_ScriptContext~getComponentContext
x_Desktop = x_ScriptContext~getDesktop
x_Document = x_ScriptContext~getDocument
end
else
do
x_ComponentContext = UNO.connect()
service = "com.sun.star.frame.Desktop"
s_Desktop = x_ComponentContext~getServiceManager~XMultiServiceFactory~createInstance(service)
x_Desktop = s_Desktop~XDesktop
x_Document = x_Desktop~getCurrentComponent()
end
x_TextDocument = x_Document~XTextDocument
x_Text = x_TextDocument~getText
s_CurrentController = x_TextDocument~getCurrentController()
x_TextViewCursorSupplier = s_CurrentController~XTextViewCursorSupplier
x_CurrentCursor = x_TextViewCursorSupplier~getViewCursor()
x_TextCursor = x_Text~createTextCursorByRange(x_CurrentCursor~getStart())
x_MultiServiceFactory = x_Document~XMultiServiceFactory
s_Annotation = x_MultiServiceFactory~createInstance("com.sun.star.text.TextField.Annotation")
x_AnnotationProperties = s_Annotation~XPropertySet
x_AnnotationProperties~setPropertyValue("Author", "JF")
x_AnnotationProperties~setPropertyValue("Content", "Thats right, Mr. Pitonyak")
currentdate = DATE("S",,,"/")
PARSE VAR currentdate year "/" month "/" day
date = .bsf~new("com.sun.star.util.Date")
date~bsf.setFieldValue("Day", day)
date~bsf.setFieldValue("Month", month)
date~bsf.setFieldValue("Year", year)
x_AnnotationProperties~setPropertyValue("Date", date)
x_TextContent = s_Annotation~XTextContent
x_Text~insertTextContent(x_TextCursor, x_TextContent, .true)
::requires UNO.CLS
|
Changelog| Date | User | Modification |
|---|
| 2008-10-14 | 1 | Initial version |
|