• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KHTML

  • sources
  • kde-4.12
  • kdelibs
  • khtml
  • dom
dom2_range.h
Go to the documentation of this file.
1 /*
2  * This file is part of the DOM implementation for KDE.
3  *
4  * Copyright 1999 Lars Knoll (knoll@kde.org)
5  * Copyright 2000 Gunnstein Lye (gunnstein@netcom.no)
6  * Copyright 2000 Frederik Holljen (frederik.holljen@hig.no)
7  * Copyright 2001 Peter Kelly (pmk@post.com)
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Library General Public
11  * License as published by the Free Software Foundation; either
12  * version 2 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Library General Public License for more details.
18  *
19  * You should have received a copy of the GNU Library General Public License
20  * along with this library; see the file COPYING.LIB. If not, write to
21  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22  * Boston, MA 02110-1301, USA.
23  *
24  * This file includes excerpts from the Document Object Model (DOM)
25  * Level 2 Specification (Candidate Recommendation)
26  * http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510/
27  * Copyright © 2000 W3C® (MIT, INRIA, Keio), All Rights Reserved.
28  *
29  */
30 #ifndef _dom2_range_h_
31 #define _dom2_range_h_
32 
33 #include <dom/dom_doc.h>
34 #include <dom/dom_misc.h>
35 
36 namespace DOM {
37 
38 class DocumentFragment;
39 class Node;
40 class DOMString;
41 class DocumentImpl;
42 class RangeImpl;
43 
44 class DOMException;
45 
46 // Introduced in DOM Level 2:
47 class KHTML_EXPORT RangeException {
48 public:
49  RangeException(unsigned short _code) { code = _code; }
50  RangeException(const RangeException &other) { code = other.code; }
51 
52  RangeException & operator = (const RangeException &other)
53  { code = other.code; return *this; }
54 
55  virtual ~RangeException() {}
60  enum RangeExceptionCode {
61  BAD_BOUNDARYPOINTS_ERR = 1,
62  INVALID_NODE_TYPE_ERR = 2,
63  _EXCEPTION_OFFSET = 2000,
64  _EXCEPTION_MAX = 2999
65  };
66  unsigned short code;
67 
69  DOMString codeAsString() const;
70 
72  static DOMString codeAsString(int rangeCode);
73 
75  static bool isRangeExceptionCode(int exceptioncode);
76 };
77 
78 
79 class KHTML_EXPORT Range
80 {
81  friend class DocumentImpl;
82  friend class Document;
83  friend class RangeImpl;
84 public:
85  Range();
86  Range(const Document rootContainer);
87  Range(const Range &other);
88  Range(const Node startContainer, const long startOffset, const Node endContainer, const long endOffset);
89 
90  Range & operator = (const Range &other);
91 
92  ~Range();
93 
98  Node startContainer() const;
99 
104  long startOffset() const;
105 
110  Node endContainer() const;
111 
116  long endOffset() const;
117 
122  bool collapsed() const;
123 
129  // ### BIC make const in the next release
130  Node commonAncestorContainer();
131 
153  void setStart ( const Node &refNode, long offset );
154 
173  void setEnd ( const Node &refNode, long offset );
174 
189  void setStartBefore ( const Node &refNode );
190 
205  void setStartAfter ( const Node &refNode );
206 
221  void setEndBefore ( const Node &refNode );
222 
237  void setEndAfter ( const Node &refNode );
238 
248  void collapse ( bool toStart );
249 
264  void selectNode ( const Node &refNode );
265 
279  void selectNodeContents ( const Node &refNode );
280 
281  enum CompareHow {
282  START_TO_START = 0,
283  START_TO_END = 1,
284  END_TO_END = 2,
285  END_TO_START = 3
286  };
287 
304  short compareBoundaryPoints ( CompareHow how, const Range &sourceRange );
305 
317  bool boundaryPointsValid ( );
318 
332  void deleteContents ( );
333 
349  DocumentFragment extractContents ( );
350 
362  DocumentFragment cloneContents ( );
363 
390  void insertNode ( const Node &newNode );
391 
424  void surroundContents ( const Node &newParent );
425 
433  Range cloneRange ( );
434 
441  DOMString toString ( );
442 
446  DOMString toHTML ( );
447 
448  /* Mozilla extension - only works for HTML documents. */
449  DocumentFragment createContextualFragment (const DOMString &html);
450 
459  void detach ( );
460 
466  bool isDetached() const;
467 
472  RangeImpl *handle() const;
473  bool isNull() const;
474  Range(RangeImpl *i);
475 protected:
476  RangeImpl *impl;
477 private:
478  void throwException(int exceptioncode) const;
479 };
480 
481 } // namespace
482 
483 #endif
dom_doc.h
DOM::Node
The Node interface is the primary datatype for the entire Document Object Model.
Definition: dom_node.h:270
DOM::RangeException::RangeExceptionCode
RangeExceptionCode
An integer indicating the type of error generated.
Definition: dom2_range.h:60
DOM::DocumentFragment
DocumentFragment is a "lightweight" or "minimal" Document object.
Definition: dom_doc.h:1041
DOM::RangeException::RangeException
RangeException(unsigned short _code)
Definition: dom2_range.h:49
DOM::Range::CompareHow
CompareHow
Definition: dom2_range.h:281
DOM::DOMString
This class implements the basic string we use in the DOM.
Definition: dom_string.h:43
DOM::Document
The Document interface represents the entire HTML or XML document.
Definition: dom_doc.h:245
DOM::Range::impl
RangeImpl * impl
Definition: dom2_range.h:476
DOM::RangeException::RangeException
RangeException(const RangeException &other)
Definition: dom2_range.h:50
dom_misc.h
DOM::RangeException::~RangeException
virtual ~RangeException()
Definition: dom2_range.h:55
DOM::Range
Definition: dom2_range.h:79
DOM::RangeException
Definition: dom2_range.h:47
DOM::RangeException::code
unsigned short code
Definition: dom2_range.h:66
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:51:20 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KHTML

Skip menu "KHTML"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal