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)
57 if (startContainer.isNull() || endContainer.isNull()) {
58 throw DOMException(DOMException::NOT_FOUND_ERR);
61 if (!startContainer.handle()->getDocument() ||
62 startContainer.handle()->getDocument() != endContainer.handle()->getDocument()) {
63 throw DOMException(DOMException::WRONG_DOCUMENT_ERR);
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
94 throw DOMException(DOMException::INVALID_STATE_ERR);
96 int exceptioncode = 0;
97 NodeImpl *r = impl->startContainer(exceptioncode);
98 throwException(exceptioncode);
102long Range::startOffset()
const
105 throw DOMException(DOMException::INVALID_STATE_ERR);
107 int exceptioncode = 0;
108 long r = impl->startOffset(exceptioncode);
109 throwException(exceptioncode);
114Node Range::endContainer()
const
117 throw DOMException(DOMException::INVALID_STATE_ERR);
119 int exceptioncode = 0;
120 NodeImpl *r = impl->endContainer(exceptioncode);
121 throwException(exceptioncode);
125long Range::endOffset()
const
128 throw DOMException(DOMException::INVALID_STATE_ERR);
130 int exceptioncode = 0;
131 long r = impl->endOffset(exceptioncode);
132 throwException(exceptioncode);
136bool Range::collapsed()
const
139 throw DOMException(DOMException::INVALID_STATE_ERR);
141 int exceptioncode = 0;
142 bool r = impl->collapsed(exceptioncode);
143 throwException(exceptioncode);
147Node Range::commonAncestorContainer()
150 throw DOMException(DOMException::INVALID_STATE_ERR);
152 int exceptioncode = 0;
153 NodeImpl *r = impl->commonAncestorContainer(exceptioncode);
154 throwException(exceptioncode);
158void Range::setStart(
const Node &refNode,
long offset )
161 throw DOMException(DOMException::INVALID_STATE_ERR);
163 int exceptioncode = 0;
164 impl->setStart(refNode.handle(),offset,exceptioncode);
165 throwException(exceptioncode);
168void Range::setEnd(
const Node &refNode,
long offset )
171 throw DOMException(DOMException::INVALID_STATE_ERR);
173 int exceptioncode = 0;
174 impl->setEnd(refNode.handle(),offset,exceptioncode);
175 throwException(exceptioncode);
178void Range::setStartBefore(
const Node &refNode )
181 throw DOMException(DOMException::INVALID_STATE_ERR);
184 int exceptioncode = 0;
185 impl->setStartBefore(refNode.handle(),exceptioncode);
186 throwException(exceptioncode);
189void Range::setStartAfter(
const Node &refNode )
192 throw DOMException(DOMException::INVALID_STATE_ERR);
194 int exceptioncode = 0;
195 impl->setStartAfter(refNode.handle(),exceptioncode);
196 throwException(exceptioncode);
199void Range::setEndBefore(
const Node &refNode )
202 throw DOMException(DOMException::INVALID_STATE_ERR);
204 int exceptioncode = 0;
205 impl->setEndBefore(refNode.handle(),exceptioncode);
206 throwException(exceptioncode);
209void Range::setEndAfter(
const Node &refNode )
212 throw DOMException(DOMException::INVALID_STATE_ERR);
214 int exceptioncode = 0;
215 impl->setEndAfter(refNode.handle(),exceptioncode);
216 throwException(exceptioncode);
219void Range::collapse(
bool toStart )
222 throw DOMException(DOMException::INVALID_STATE_ERR);
224 int exceptioncode = 0;
225 impl->collapse(toStart,exceptioncode);
226 throwException(exceptioncode);
229void Range::selectNode(
const Node &refNode )
232 throw DOMException(DOMException::INVALID_STATE_ERR);
234 int exceptioncode = 0;
235 impl->selectNode(refNode.handle(),exceptioncode);
236 throwException(exceptioncode);
239void Range::selectNodeContents(
const Node &refNode )
242 throw DOMException(DOMException::INVALID_STATE_ERR);
244 int exceptioncode = 0;
245 impl->selectNodeContents(refNode.handle(),exceptioncode);
246 throwException(exceptioncode);
249short Range::compareBoundaryPoints( CompareHow how,
const Range &sourceRange )
252 throw DOMException(DOMException::INVALID_STATE_ERR);
254 int exceptioncode = 0;
255 short r = impl->compareBoundaryPoints(how,sourceRange.handle(),exceptioncode);
256 throwException(exceptioncode);
260bool Range::boundaryPointsValid( )
263 throw DOMException(DOMException::INVALID_STATE_ERR);
265 return impl->boundaryPointsValid();
268void Range::deleteContents( )
271 throw DOMException(DOMException::INVALID_STATE_ERR);
273 int exceptioncode = 0;
274 impl->deleteContents(exceptioncode);
275 throwException(exceptioncode);
281 throw DOMException(DOMException::INVALID_STATE_ERR);
283 int exceptioncode = 0;
284 DocumentFragmentImpl *r = impl->extractContents(exceptioncode);
285 throwException(exceptioncode);
292 throw DOMException(DOMException::INVALID_STATE_ERR);
294 int exceptioncode = 0;
295 DocumentFragmentImpl *r = impl->cloneContents(exceptioncode);
296 throwException(exceptioncode);
300void Range::insertNode(
const Node &newNode )
303 throw DOMException(DOMException::INVALID_STATE_ERR);
305 int exceptioncode = 0;
306 impl->insertNode(newNode.handle(),exceptioncode);
307 throwException(exceptioncode);
310void Range::surroundContents(
const Node &newParent )
313 throw DOMException(DOMException::INVALID_STATE_ERR);
315 int exceptioncode = 0;
316 impl->surroundContents(newParent.handle(),exceptioncode);
317 throwException(exceptioncode);
320Range Range::cloneRange( )
323 throw DOMException(DOMException::INVALID_STATE_ERR);
325 int exceptioncode = 0;
326 RangeImpl *r = impl->cloneRange(exceptioncode);
327 throwException(exceptioncode);
334 throw DOMException(DOMException::INVALID_STATE_ERR);
336 int exceptioncode = 0;
337 DOMString r = impl->toString(exceptioncode);
338 throwException(exceptioncode);
346 throw DOMException(DOMException::INVALID_STATE_ERR);
347 int exceptioncode = 0;
348 DOMString r = impl->toHTML(exceptioncode);
349 throwException(exceptioncode);
356 throw DOMException(DOMException::INVALID_STATE_ERR);
358 int exceptioncode = 0;
359 DocumentFragment r = impl->createContextualFragment(html, exceptioncode);
360 throwException(exceptioncode);
368 throw DOMException(DOMException::INVALID_STATE_ERR);
370 int exceptioncode = 0;
371 impl->detach(exceptioncode);
372 throwException(exceptioncode);
375bool Range::isDetached()
const
378 throw DOMException(DOMException::INVALID_STATE_ERR);
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));
402 throw DOMException(exceptioncode);
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.
The Document Object Model (DOM) is divided into two parts, the COREDOM core DOM, specifying some core...