26#include "dom/dom_exception.h"
27#include "xml/dom_docimpl.h"
28#include "xml/dom2_rangeimpl.h"
38Range::Range(
const Document rootContainer)
40 if(rootContainer.handle())
42 impl =
new RangeImpl(rootContainer.handle()->docPtr());
49Range::Range(
const Range &other)
52 if (impl) impl->ref();
55Range::Range(
const Node startContainer,
const long startOffset,
const Node endContainer,
const long endOffset)
61 if (!startContainer.handle()->getDocument() ||
62 startContainer.handle()->getDocument() != endContainer.handle()->getDocument()) {
66 impl =
new RangeImpl(startContainer.handle()->docPtr(),startContainer.handle(),startOffset,endContainer.handle(),endOffset);
70Range::Range(RangeImpl *i)
73 if (impl) impl->ref();
76Range &Range::operator = (
const Range &other)
78 if ( impl != other.impl ) {
79 if (impl) impl->deref();
81 if (impl) impl->ref();
88 if (impl) impl->deref();
91Node Range::startContainer()
const
96 int exceptioncode = 0;
97 NodeImpl *r = impl->startContainer(exceptioncode);
98 throwException(exceptioncode);
102long Range::startOffset()
const
107 int exceptioncode = 0;
108 long r = impl->startOffset(exceptioncode);
109 throwException(exceptioncode);
114Node Range::endContainer()
const
119 int exceptioncode = 0;
120 NodeImpl *r = impl->endContainer(exceptioncode);
121 throwException(exceptioncode);
125long Range::endOffset()
const
130 int exceptioncode = 0;
131 long r = impl->endOffset(exceptioncode);
132 throwException(exceptioncode);
136bool Range::collapsed()
const
141 int exceptioncode = 0;
142 bool r = impl->collapsed(exceptioncode);
143 throwException(exceptioncode);
147Node Range::commonAncestorContainer()
152 int exceptioncode = 0;
153 NodeImpl *r = impl->commonAncestorContainer(exceptioncode);
154 throwException(exceptioncode);
158void Range::setStart(
const Node &refNode,
long offset )
163 int exceptioncode = 0;
164 impl->setStart(refNode.handle(),offset,exceptioncode);
165 throwException(exceptioncode);
168void Range::setEnd(
const Node &refNode,
long offset )
173 int exceptioncode = 0;
174 impl->setEnd(refNode.handle(),offset,exceptioncode);
175 throwException(exceptioncode);
178void Range::setStartBefore(
const Node &refNode )
184 int exceptioncode = 0;
185 impl->setStartBefore(refNode.handle(),exceptioncode);
186 throwException(exceptioncode);
189void Range::setStartAfter(
const Node &refNode )
194 int exceptioncode = 0;
195 impl->setStartAfter(refNode.handle(),exceptioncode);
196 throwException(exceptioncode);
199void Range::setEndBefore(
const Node &refNode )
204 int exceptioncode = 0;
205 impl->setEndBefore(refNode.handle(),exceptioncode);
206 throwException(exceptioncode);
209void Range::setEndAfter(
const Node &refNode )
214 int exceptioncode = 0;
215 impl->setEndAfter(refNode.handle(),exceptioncode);
216 throwException(exceptioncode);
219void Range::collapse(
bool toStart )
224 int exceptioncode = 0;
225 impl->collapse(toStart,exceptioncode);
226 throwException(exceptioncode);
229void Range::selectNode(
const Node &refNode )
234 int exceptioncode = 0;
235 impl->selectNode(refNode.handle(),exceptioncode);
236 throwException(exceptioncode);
239void Range::selectNodeContents(
const Node &refNode )
244 int exceptioncode = 0;
245 impl->selectNodeContents(refNode.handle(),exceptioncode);
246 throwException(exceptioncode);
249short Range::compareBoundaryPoints( CompareHow how,
const Range &sourceRange )
254 int exceptioncode = 0;
255 short r = impl->compareBoundaryPoints(how,sourceRange.handle(),exceptioncode);
256 throwException(exceptioncode);
260bool Range::boundaryPointsValid( )
265 return impl->boundaryPointsValid();
268void Range::deleteContents( )
273 int exceptioncode = 0;
274 impl->deleteContents(exceptioncode);
275 throwException(exceptioncode);
283 int exceptioncode = 0;
284 DocumentFragmentImpl *r = impl->extractContents(exceptioncode);
285 throwException(exceptioncode);
294 int exceptioncode = 0;
295 DocumentFragmentImpl *r = impl->cloneContents(exceptioncode);
296 throwException(exceptioncode);
300void Range::insertNode(
const Node &newNode )
305 int exceptioncode = 0;
306 impl->insertNode(newNode.handle(),exceptioncode);
307 throwException(exceptioncode);
310void Range::surroundContents(
const Node &newParent )
315 int exceptioncode = 0;
316 impl->surroundContents(newParent.handle(),exceptioncode);
317 throwException(exceptioncode);
320Range Range::cloneRange( )
325 int exceptioncode = 0;
326 RangeImpl *r = impl->cloneRange(exceptioncode);
327 throwException(exceptioncode);
336 int exceptioncode = 0;
337 DOMString r = impl->toString(exceptioncode);
338 throwException(exceptioncode);
347 int exceptioncode = 0;
348 DOMString r = impl->toHTML(exceptioncode);
349 throwException(exceptioncode);
358 int exceptioncode = 0;
360 throwException(exceptioncode);
370 int exceptioncode = 0;
371 impl->detach(exceptioncode);
372 throwException(exceptioncode);
375bool Range::isDetached()
const
380 return impl->isDetached();
383RangeImpl *Range::handle()
const
388bool Range::isNull()
const
393void Range::throwException(
int exceptioncode)
const
399 if (exceptioncode >= RangeException::_EXCEPTION_OFFSET && exceptioncode <= RangeException::_EXCEPTION_MAX)
400 throw RangeException(
static_cast<RangeException::RangeExceptionCode
>(exceptioncode-RangeException::_EXCEPTION_OFFSET));
DOM operations only raise exceptions in "exceptional" circumstances, i.e., when an operation is impos...
This class implements the basic string we use in the DOM.
DocumentFragment is a "lightweight" or "minimal" Document object.
The Document interface represents the entire HTML or XML document.
The Node interface is the primary datatype for the entire Document Object Model.
bool isNull() const
tests if this Node is 0.
The Document Object Model (DOM) is divided into two parts, the COREDOM core DOM, specifying some core...