*/
public void setTextContent(String content) {
if (content != null) {
Node child = listItemElement.getFirstChild();
Node positionNode = null;
TextPElement pElement = null;
while (child != null) {
if (child instanceof TextNumberElement) {
positionNode = child.getNextSibling();
child = child.getNextSibling();
} else if ((child instanceof TextPElement) && (pElement == null)) {
pElement = (TextPElement) child;
child = child.getNextSibling();
} else if ((child instanceof TextListElement) && (positionNode == null)) {
positionNode = child;
child = child.getNextSibling();
} else {
Node tmp = child;
child = child.getNextSibling();
listItemElement.removeChild(tmp);
}
}
if (pElement == null) {
if (positionNode == null) {
pElement = listItemElement.newTextPElement();
} else {
pElement = ((OdfFileDom) listItemElement.getOwnerDocument()).newOdfElement(TextPElement.class);
listItemElement.insertBefore(pElement, positionNode);
}
}
pElement.setTextContent(content);
if (paragraphDecorator != null) {
paragraphDecorator.decorateListItem(this);
} else {
// paragraphDecorator is null when the owner List is constructed
// by List(TextListElement).
Node previousSibling = listItemElement.getPreviousSibling();
String pElementStyleName = null;
while (previousSibling != null) {
if (previousSibling instanceof TextListItemElement) {
Node previousChild = previousSibling.getFirstChild();
while (previousChild != null) {
if (previousChild instanceof TextPElement) {
TextPElement previousPElement = (TextPElement) previousChild;
pElementStyleName = previousPElement.getTextStyleNameAttribute();
break;
}
previousChild = previousChild.getNextSibling();
}
break;