00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
#ifndef _dom2_range_h_
00031
#define _dom2_range_h_
00032
00033
#include <dom/dom_doc.h>
00034
#include <dom/dom_misc.h>
00035
00036
namespace DOM {
00037
00038
class DocumentFragment;
00039
class Node;
00040
class DOMString;
00041
class DocumentImpl;
00042
class RangeImpl;
00043
00044
class DOMException;
00045
00046
00047
class KHTML_EXPORT RangeException {
00048
public:
00049 RangeException(
unsigned short _code) { code = _code; }
00050 RangeException(
const RangeException &other) { code = other.code; }
00051
00052 RangeException & operator = (
const RangeException &other)
00053 { code = other.code;
return *
this; }
00054
00055
virtual ~RangeException() {}
00060
enum RangeExceptionCode {
00061 BAD_BOUNDARYPOINTS_ERR = 1,
00062 INVALID_NODE_TYPE_ERR = 2,
00063 _EXCEPTION_OFFSET = 2000,
00064 _EXCEPTION_MAX = 2999
00065 };
00066
unsigned short code;
00067 };
00068
00069
00070
class KHTML_EXPORT Range
00071 {
00072
friend class DocumentImpl;
00073
friend class Document;
00074
friend class RangeImpl;
00075
public:
00076 Range();
00077 Range(
const Document rootContainer);
00078 Range(
const Range &other);
00079 Range(
const Node startContainer,
const long startOffset,
const Node endContainer,
const long endOffset);
00080
00081 Range & operator = (
const Range &other);
00082
00083 ~Range();
00084
00089
Node startContainer() const;
00090
00095
long startOffset() const;
00096
00101
Node endContainer() const;
00102
00107
long endOffset() const;
00108
00113
bool collapsed() const;
00114
00120
00121
Node commonAncestorContainer();
00122
00144
void setStart ( const
Node &refNode,
long offset );
00145
00164
void setEnd ( const
Node &refNode,
long offset );
00165
00180
void setStartBefore ( const
Node &refNode );
00181
00196
void setStartAfter ( const
Node &refNode );
00197
00212
void setEndBefore ( const
Node &refNode );
00213
00228
void setEndAfter ( const
Node &refNode );
00229
00239
void collapse (
bool toStart );
00240
00255
void selectNode ( const
Node &refNode );
00256
00270
void selectNodeContents ( const
Node &refNode );
00271
00272 enum CompareHow {
00273 START_TO_START = 0,
00274 START_TO_END = 1,
00275 END_TO_END = 2,
00276 END_TO_START = 3
00277 };
00278
00295
short compareBoundaryPoints ( CompareHow how,
const Range &sourceRange );
00296
00308
bool boundaryPointsValid ( );
00309
00323
void deleteContents ( );
00324
00340
DocumentFragment extractContents ( );
00341
00353
DocumentFragment cloneContents ( );
00354
00381
void insertNode (
const Node &newNode );
00382
00415
void surroundContents (
const Node &newParent );
00416
00424 Range cloneRange ( );
00425
00432
DOMString toString ( );
00433
00437
DOMString toHTML ( );
00438
00439
00440
DocumentFragment createContextualFragment (
const DOMString &html);
00441
00450
void detach ( );
00451
00457
bool isDetached() const;
00458
00463 RangeImpl *handle() const;
00464
bool isNull() const;
00465
00466 protected:
00467 RangeImpl *impl;
00468 Range(RangeImpl *i);
00469 private:
00470
void throwException(
int exceptioncode) const;
00471 };
00472
00473 }
00474
00475 #endif