| # khtml Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# dom2_range.h

    00001 /*
    00002  * This file is part of the DOM implementation for KDE.
    00003  *
    00004  * (C) 1999 Lars Knoll (knoll@kde.org)
    00005  * (C) 2000 Gunnstein Lye (gunnstein@netcom.no)
    00006  * (C) 2000 Frederik Holljen (frederik.holljen@hig.no)
    00007  * (C) 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., 59 Temple Place - Suite 330,
    00022  * Boston, MA 02111-1307, 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 };
    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     // ### BIC make const in the next release
    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     /* Mozilla extension - only works for HTML documents. */
    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 } // namespace
    00474
    00475 #endif

This file is part of the documentation for khtml Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:33:09 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003