 | OO-Snippets: insert remove annotationsCommons| Keywords | annotation, note, text content |
|---|
| Language | OOBasic |
|---|
| Application | Writer |
|---|
| Authors | Paolo Mantovani (initial)
|
|---|
| Supported Versions | 1.0.x 1.1.x 2.0.x |
|---|
| Supported OS | All |
|---|
| Question | How to insert and remove annotations in text documents?
|
|---|
| Answer | Text annotations are a special type of text fields, therefore, in order to insert and remove annotations you must proceed in the same manner as for other kind of text contents See the example below: The first routine shows how to add an annotation The second shows how to find and remove all annotations in a document |
|---|
Sub Example_InsertAnnotation
oDoc = ThisComponent
oTextCursor = oDoc.Text.createTextCursor
oTextCursor.goToEnd(False)
Dim oDate As New com.sun.star.util.Date
With oDate
.Day = Day(Now)
.Month = Month(Now)
.Year = Year(Now)
End With
oTextAnnotation = oDoc.createInstance("com.sun.star.text.TextField.Annotation")
With oTextAnnotation
.Content = "Paolo was here!!"
.Author = "PM"
.Date = oDate
End With
oDoc.Text.insertTextContent( oTextCursor, oTextAnnotation, True)
End Sub
Sub Example_RemoveAllAnnotations
oDoc = ThisComponent
oEnum = oDoc.TextFields.createEnumeration
Do While oEnum.hasMoreElements
oTField = oEnum.nextElement
If oTField.supportsService("com.sun.star.text.TextField.Annotation") Then
MsgBox oTField.Content, 16,"Annotation detected!!"
oDoc.Text.removeTextContent(oTField)
MsgBox "Annotation Removed!!"
End If
Loop
End Sub
|
Changelog| Date | User | Modification |
|---|
| 2005-05-31 | paolomantovani | Initial version |
|