void CharacterDataImpl::deleteData(unsigned int offset, unsigned int count) { if (isReadOnly()) throw DOM_DOMException( DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, null); // Note: the C++ DOMString operation throws the correct DOMExceptions // when parameter values are bad. // data.deleteData(offset, count); if (this->getOwnerDocument() != null) { typedef RefVectorOf<RangeImpl> RangeImpls; RangeImpls* ranges = this->getOwnerDocument()->getRanges(); if (ranges != null) { unsigned int sz = ranges->size(); if (sz != 0) { for (unsigned int i =0; i<sz; i++) { DOM_Node dn = DOM_Node(this); ranges->elementAt(i)->updateRangeForDeletedText( dn, offset, count); } } } } };
void RangeImpl::updateRangeForInsertedNode(NodeImpl* node) { if (node == null) return; if (node->getParentNode() == fStartContainer.fImpl) { unsigned int index = indexOf(DOM_Node(node), fStartContainer); if (index < fStartOffset) { fStartOffset++; } } if (node->getParentNode() == fEndContainer.fImpl) { unsigned int index = indexOf(DOM_Node(node), fEndContainer); if (index < fEndOffset) { fEndOffset++; } } }
const DOM_Node RangeImpl::commonAncestorOf(const DOM_Node& pointA, const DOM_Node& pointB) const { if (fDetached) throw DOM_DOMException(DOM_DOMException::INVALID_STATE_ERR, null); if (pointA.getOwnerDocument() != pointB.getOwnerDocument()) throw DOM_DOMException( DOM_DOMException::WRONG_DOCUMENT_ERR, null ); //if the containers are same then it itself is its common ancestor. if (pointA == pointB) return pointA; typedef RefVectorOf<NodeImpl> VectorNodes; VectorNodes* startV= new (((DocumentImpl*)fDocument.fImpl)->getMemoryManager()) VectorNodes(1, false, ((DocumentImpl*)fDocument.fImpl)->getMemoryManager()); DOM_Node node; for (node=fStartContainer; node != null; node=node.getParentNode()) { startV->addElement(node.fImpl); } VectorNodes* endV = new (((DocumentImpl*)fDocument.fImpl)->getMemoryManager()) VectorNodes(1, false, ((DocumentImpl*)fDocument.fImpl)->getMemoryManager()); for (node=fEndContainer; node != null; node=node.getParentNode()) { endV->addElement(node.fImpl); } int s = startV->size()-1; int e = endV->size()-1; NodeImpl* commonAncestor = 0; while (s>=0 && e>=0) { if (startV->elementAt(s) == endV->elementAt(e)) { commonAncestor = startV->elementAt(s); } else break; --s; --e; } delete startV; delete endV; return DOM_Node(commonAncestor); }
DOM_Node DOM_Entity::getPreviousSibling() const { return DOM_Node(((EntityImpl*)fImpl)->getPreviousSibling()); };
DOM_Node DOM_Entity::getLastChild() const { return DOM_Node(((EntityImpl*)fImpl)->getLastChild()); };
DOM_Node DOM_Entity::getNextSibling() const { return DOM_Node(((EntityImpl*)fImpl)->getNextSibling()); };
DOM_Node DOM_Document::importNode(const DOM_Node &importedNode, bool deep) { return DOM_Node(((DocumentImpl *)fImpl)->importNode(importedNode.fImpl, deep)); };
DOM_Node DOM_NodeList::item(unsigned int index) const { return DOM_Node(fImpl->item(index)); }