KHtml

dom2_rangeimpl.h
1 /*
2  * This file is part of the DOM implementation for KDE.
3  *
4  * Copyright (C) 1999 Lars Knoll <[email protected]>
5  * Copyright (C) 2000 Gunnstein Lye <[email protected]>
6  * Copyright (C) 2000 Frederik Holljen <[email protected]>
7  * Copyright (C) 2001 Peter Kelly <[email protected]>
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  */
25 
26 #ifndef _DOM2_RangeImpl_h_
27 #define _DOM2_RangeImpl_h_
28 
29 #include "dom/dom2_range.h"
30 #include "misc/shared.h"
31 
32 namespace DOM
33 {
34 
35 class RangeImpl : public khtml::Shared<RangeImpl>
36 {
37  friend class DocumentImpl;
38 public:
39  RangeImpl(DocumentImpl *_ownerDocument);
40  RangeImpl(DocumentImpl *_ownerDocument,
41  NodeImpl *_startContainer, long _startOffset,
42  NodeImpl *_endContainer, long _endOffset);
43 
44  ~RangeImpl();
45 
46  NodeImpl *startContainer(int &exceptioncode) const;
47  long startOffset(int &exceptioncode) const;
48  NodeImpl *endContainer(int &exceptioncode) const;
49  long endOffset(int &exceptioncode) const;
50  bool collapsed(int &exceptioncode) const;
51 
52  NodeImpl *commonAncestorContainer(int &exceptioncode);
53  static NodeImpl *commonAncestorContainer(NodeImpl *containerA, NodeImpl *containerB);
54  void setStart(NodeImpl *refNode, long offset, int &exceptioncode);
55  void setEnd(NodeImpl *refNode, long offset, int &exceptioncode);
56  void collapse(bool toStart, int &exceptioncode);
57  short compareBoundaryPoints(Range::CompareHow how, RangeImpl *sourceRange, int &exceptioncode);
58  static short compareBoundaryPoints(NodeImpl *containerA, long offsetA, NodeImpl *containerB, long offsetB);
59  bool boundaryPointsValid();
60  void deleteContents(int &exceptioncode);
61  DocumentFragmentImpl *extractContents(int &exceptioncode);
62  DocumentFragmentImpl *cloneContents(int &exceptioncode);
63  void insertNode(NodeImpl *newNode, int &exceptioncode);
64  DOMString toString(int &exceptioncode);
65  /** Converts the selection to HTML. The returned string will have matching
66  * tags, and all td, tr, etc tags will be inside a table tag. CSS is not
67  * used at this stage - This needs to be fixed.
68  *
69  * This is guaranteed to produce an xml valid snippet, no matter how crappy the input
70  * html page is. It will have html and body tags.
71  *
72  * Any urls in images or links will be expanded to full urls <em>with passwords stripped</em>
73  * for security reasons.
74  *
75  * Note: Originally this function didn't have the exceptioncode argument. I added it
76  * since all the other functions do. If this is correct, please remove this comment.
77  *
78  * @param exceptioncode This will be set if m_detached is true.
79  * @return A string with html tags for this range.
80  */
81  DOMString toHTML(int &exceptioncode);
82 
83  DocumentFragment createContextualFragment(const DOMString &html, int &exceptioncode);
84 
85  void detach(int &exceptioncode);
86  bool isDetached() const;
87  RangeImpl *cloneRange(int &exceptioncode);
88 
89  void setStartAfter(NodeImpl *refNode, int &exceptioncode);
90  void setEndBefore(NodeImpl *refNode, int &exceptioncode);
91  void setEndAfter(NodeImpl *refNode, int &exceptioncode);
92  void selectNode(NodeImpl *refNode, int &exceptioncode);
93  void selectNodeContents(NodeImpl *refNode, int &exceptioncode);
94  void surroundContents(NodeImpl *newParent, int &exceptioncode);
95  void setStartBefore(NodeImpl *refNode, int &exceptioncode);
96 
97  enum ActionType {
98  DELETE_CONTENTS,
99  EXTRACT_CONTENTS,
100  CLONE_CONTENTS
101  };
102  DocumentFragmentImpl *processContents(ActionType action, int &exceptioncode);
103 
104  bool readOnly()
105  {
106  return false;
107  }
108 
109  DocumentImpl *ownerDocument()
110  {
111  return m_ownerDocument;
112  }
113 
114 protected:
115  DocumentImpl *m_ownerDocument;
116  NodeImpl *m_startContainer;
117  unsigned long m_startOffset;
118  NodeImpl *m_endContainer;
119  unsigned long m_endOffset;
120  bool m_detached;
121 
122 private:
123  void checkNodeWOffset(NodeImpl *n, int offset, int &exceptioncode) const;
124  void checkNodeBA(NodeImpl *n, int &exceptioncode) const;
125  void setStartContainer(NodeImpl *_startContainer);
126  void setEndContainer(NodeImpl *_endContainer);
127  void checkDeleteExtract(int &exceptioncode);
128  bool containedByReadOnly();
129  unsigned long maxEndOffset() const;
130  unsigned long maxStartOffset() const;
131 };
132 
133 } // namespace
134 
135 #endif
136 
This library provides a full-featured HTML parser and widget.
char * toString(const T &value)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Oct 15 2021 22:48:03 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.