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

KHTML

dom2_range.h

Go to the documentation of this file.
00001 /*
00002  * This file is part of the DOM implementation for KDE.
00003  *
00004  * Copyright 1999 Lars Knoll (knoll@kde.org)
00005  * Copyright 2000 Gunnstein Lye (gunnstein@netcom.no)
00006  * Copyright 2000 Frederik Holljen (frederik.holljen@hig.no)
00007  * Copyright 2001 Peter Kelly (pmk@post.com)
00008  *
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Library General Public
00011  * License as published by the Free Software Foundation; either
00012  * version 2 of the License, or (at your option) any later version.
00013  *
00014  * This library is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017  * Library General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU Library General Public License
00020  * along with this library; see the file COPYING.LIB.  If not, write to
00021  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00022  * Boston, MA 02110-1301, USA.
00023  *
00024  * This file includes excerpts from the Document Object Model (DOM)
00025  * Level 2 Specification (Candidate Recommendation)
00026  * http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510/
00027  * Copyright © 2000 W3C® (MIT, INRIA, Keio), All Rights Reserved.
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 // Introduced in DOM Level 2:
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 
00069     DOMString codeAsString() const;
00070 
00072     static DOMString codeAsString(int rangeCode);
00073 
00075     static bool isRangeExceptionCode(int exceptioncode);
00076 };
00077 
00078 
00079 class KHTML_EXPORT Range
00080 {
00081     friend class DocumentImpl;
00082     friend class Document;
00083     friend class RangeImpl;
00084 public:
00085     Range();
00086     Range(const Document rootContainer);
00087     Range(const Range &other);
00088     Range(const Node startContainer, const long startOffset, const Node endContainer, const long endOffset);
00089 
00090     Range & operator = (const Range &other);
00091 
00092     ~Range();
00093 
00098     Node startContainer() const;
00099 
00104     long startOffset() const;
00105 
00110     Node endContainer() const;
00111 
00116     long endOffset() const;
00117 
00122     bool collapsed() const;
00123 
00129     // ### BIC make const in the next release
00130     Node commonAncestorContainer();
00131 
00153     void setStart ( const Node &refNode, long offset );
00154 
00173     void setEnd ( const Node &refNode, long offset );
00174 
00189     void setStartBefore ( const Node &refNode );
00190 
00205     void setStartAfter ( const Node &refNode );
00206 
00221     void setEndBefore ( const Node &refNode );
00222 
00237     void setEndAfter ( const Node &refNode );
00238 
00248     void collapse ( bool toStart );
00249 
00264     void selectNode ( const Node &refNode );
00265 
00279     void selectNodeContents ( const Node &refNode );
00280 
00281     enum CompareHow {
00282     START_TO_START = 0,
00283     START_TO_END = 1,
00284     END_TO_END = 2,
00285     END_TO_START = 3
00286     };
00287 
00304     short compareBoundaryPoints ( CompareHow how, const Range &sourceRange );
00305 
00317     bool boundaryPointsValid (  );
00318 
00332     void deleteContents (  );
00333 
00349     DocumentFragment extractContents (  );
00350 
00362     DocumentFragment cloneContents (  );
00363 
00390     void insertNode ( const Node &newNode );
00391 
00424     void surroundContents ( const Node &newParent );
00425 
00433     Range cloneRange (  );
00434 
00441     DOMString toString (  );
00442 
00446     DOMString toHTML (  );
00447 
00448     /* Mozilla extension - only works for HTML documents. */
00449     DocumentFragment createContextualFragment (const DOMString &html);
00450 
00459     void detach (  );
00460 
00466     bool isDetached() const;
00467 
00472     RangeImpl *handle() const;
00473     bool isNull() const;
00474     Range(RangeImpl *i);
00475 protected:
00476     RangeImpl *impl;
00477 private:
00478     void throwException(int exceptioncode) const;
00479 };
00480 
00481 } // namespace
00482 
00483 #endif

KHTML

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal