I am using Java to iterate over all Paragraphs and TextPortions within a XText object.
When I check the TextPortionType:
XPropertySet props= UnoRuntime.queryInferface(XPropertySet.class, portion);
String portionType= (String)props.getPropertyValue("TextPortionType");
if(portionType.equals("Annotation"))
{
// get com.sun.star.text.textfield.Annotation
}
and encounter an Annotation
or AnnotationEnd
, I would like to access the corresponding Annotation (and later create some myself).
I know of the service com.sun.star.text.textfield.Annotation, however Annotation
indicates via XServiceInfo
that it does not support it. How do I obtain a reference to the Annotation
from the Annotation I encounter in a TextPortion?
How do I create Annotations myself?
I am using OpenOffice 4.1.1.
The LibreOffice API docs show that service
com.sun.star.text.textfield.Annotation
provides a single interface:XTextField
. Although "Annotation" is not documented as a possible value forTextPortionType
, the value of property "TextField" is the Annotation service.In order to access Annotation properties, do:
Ohter attributes of service Annotation are:
The PropertyValue "TextField" is not set for TextPortionType "AnnotationEnd". There is also no service
AnnotationEnd
.Annotations can be created as follows:
Annotations can be removed too. Be careful when trying to remove Annotations with Change Tracking enabled:
getPropertyValue("TextPortionType")
may raise a RuntimeException on ApacheOO 4.1.1. Also for some reason I have not debugged yet, the removal does nothing on my LibreOffice 4.2.7.2