dom2_range.h
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
00031 #ifndef _dom2_range_h_
00032 #define _dom2_range_h_
00033
00034 #include <dom/dom_doc.h>
00035 #include <dom/dom_misc.h>
00036
00037 namespace DOM {
00038
00039 class DocumentFragment;
00040 class Node;
00041 class DOMString;
00042 class DocumentImpl;
00043 class RangeImpl;
00044
00045 class DOMException;
00046
00047
00048 class RangeException {
00049 public:
00050 RangeException(unsigned short _code) { code = _code; }
00051 RangeException(const RangeException &other) { code = other.code; }
00052
00053 RangeException & operator = (const RangeException &other)
00054 { code = other.code; return *this; }
00055
00056 virtual ~RangeException() {}
00061 enum RangeExceptionCode {
00062 BAD_BOUNDARYPOINTS_ERR = 1,
00063 INVALID_NODE_TYPE_ERR = 2,
00064 _EXCEPTION_OFFSET = 2000,
00065 _EXCEPTION_MAX = 2999
00066 };
00067 unsigned short code;
00068 };
00069
00070
00071 class Range
00072 {
00073 friend class DocumentImpl;
00074 friend class Document;
00075 friend class RangeImpl;
00076 public:
00077 Range();
00078 Range(const Document rootContainer);
00079 Range(const Range &other);
00080 Range(const Node startContainer, const long startOffset, const Node endContainer, const long endOffset);
00081
00082 Range & operator = (const Range &other);
00083
00084 ~Range();
00085
00090 Node startContainer() const;
00091
00096 long startOffset() const;
00097
00102 Node endContainer() const;
00103
00108 long endOffset() const;
00109
00114 bool collapsed() const;
00115
00121
00122 Node commonAncestorContainer();
00123
00146 void setStart ( const Node &refNode, long offset );
00147
00167 void setEnd ( const Node &refNode, long offset );
00168
00183 void setStartBefore ( const Node &refNode );
00184
00199 void setStartAfter ( const Node &refNode );
00200
00215 void setEndBefore ( const Node &refNode );
00216
00231 void setEndAfter ( const Node &refNode );
00232
00242 void collapse ( bool toStart );
00243
00258 void selectNode ( const Node &refNode );
00259
00273 void selectNodeContents ( const Node &refNode );
00274
00275 enum CompareHow {
00276 START_TO_START = 0,
00277 START_TO_END = 1,
00278 END_TO_END = 2,
00279 END_TO_START = 3
00280 };
00281
00298 short compareBoundaryPoints ( CompareHow how, const Range &sourceRange );
00299
00311 bool boundaryPointsValid ( );
00312
00326 void deleteContents ( );
00327
00343 DocumentFragment extractContents ( );
00344
00356 DocumentFragment cloneContents ( );
00357
00384 void insertNode ( const Node &newNode );
00385
00418 void surroundContents ( const Node &newParent );
00419
00427 Range cloneRange ( );
00428
00435 DOMString toString ( );
00436
00440 DOMString toHTML ( );
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
This file is part of the documentation for kdelibs Version 3.1.5.