.getAttribute(IHTMLConstants.ATTR_ALIGN))) {
((Element) parentNode)
.removeAttribute(IHTMLConstants.ATTR_ALIGN);
IDOMPosition startPos = new DOMPosition(parentNode, 0);
IDOMPosition endPos = new DOMRefPosition(endNode, true);
return new DOMRange(startPos, endPos);
}
// else replace the align attribute
/**
* this._applyingNode.appendChild(startNode);
* parentNode.getParentNode().replaceChild(this._applyingNode,
* parentNode);
*/
String align = this.getApplyingNode()
.getAttribute(IHTMLConstants.ATTR_ALIGN);
((Element) parentNode).setAttribute(IHTMLConstants.ATTR_ALIGN,
align);
IDOMPosition startPos = new DOMPosition(parentNode, 0);
IDOMPosition endPos = new DOMRefPosition(endNode, true);
return new DOMRange(startPos, endPos);
}
} else {
if (parentNode != null
&& parentNode.getNodeName().equalsIgnoreCase(
IHTMLConstants.TAG_P)
&& parentNode.getChildNodes().getLength() == len) {
if (this.getApplyingNode()
.getAttribute(IHTMLConstants.ATTR_ALIGN)
.equals(
((Element) parentNode)
.getAttribute(IHTMLConstants.ATTR_ALIGN))) {
((Element) parentNode)
.removeAttribute(IHTMLConstants.ATTR_ALIGN);
IDOMPosition startPos = new DOMPosition(parentNode, 0);
IDOMPosition endPos = new DOMRefPosition(endNode, true);
return new DOMRange(startPos, endPos);
}
/**
* Node sibling = startNode.getNextSibling();
* this._applyingNode.appendChild(startNode); Node
* endNodeSibling = endNode.getNextSibling(); while (sibling !=
* null && startNode != endNode && sibling != endNodeSibling) {
* Node tempNode = sibling.getNextSibling();
* this._applyingNode.appendChild(sibling); sibling = tempNode; }
* parentNode.getParentNode().replaceChild(this._applyingNode,
* parentNode);
*/
String align = this.getApplyingNode()
.getAttribute(IHTMLConstants.ATTR_ALIGN);
((Element) parentNode).setAttribute(IHTMLConstants.ATTR_ALIGN,
align);
IDOMPosition startPos = new DOMPosition(parentNode, 0);
IDOMPosition endPos = new DOMRefPosition(endNode, true);
return new DOMRange(startPos, endPos);
}
}
return null;
}