// set date
String dcDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(new Date());
DcDateElement dcDateElement = annotationElement.newDcDateElement();
dcDateElement.setTextContent(dcDate);
TextPElement notePElement = annotationElement.newTextPElement();
TextSpanElement noteSpanElement = notePElement.newTextSpanElement();
// set comment style
OdfOfficeAutomaticStyles styles = null;
if (dom instanceof OdfContentDom) {
styles = ((OdfContentDom) dom).getAutomaticStyles();
} else if (dom instanceof OdfStylesDom) {
styles = ((OdfStylesDom) dom).getAutomaticStyles();
}
OdfStyle textStyle = styles.newStyle(OdfStyleFamily.Text);
StyleTextPropertiesElement styleTextPropertiesElement = textStyle.newStyleTextPropertiesElement(null);
styleTextPropertiesElement.setStyleFontNameAttribute("Tahoma");
styleTextPropertiesElement.setFoFontSizeAttribute("10pt");
styleTextPropertiesElement.setStyleFontNameAsianAttribute("Lucida Sans Unicode");
styleTextPropertiesElement.setStyleFontSizeAsianAttribute("12pt");
noteSpanElement.setStyleName(textStyle.getStyleNameAttribute());
// set comment content
noteSpanElement.setTextContent(content);
// insert comment to its position
insertOdfElement(annotationElement, mIndexInContainer, parentElement);
// three text length plus two '\r'
int offset = content.length() + 1 + dcDate.length() + 1 + creator.length();
SelectionManager.refresh(getContainerElement(), offset, getIndex());