Main Page   Class Hierarchy   Compound List   File List   Compound Members  

IDRangeImpl.hpp

00001 #ifndef IDRangeImpl_HEADER_GUARD_
00002 #define IDRangeImpl_HEADER_GUARD_
00003 /*
00004  * The Apache Software License, Version 1.1
00005  *
00006  * Copyright (c) 2001 The Apache Software Foundation.  All rights
00007  * reserved.
00008  *
00009  * Redistribution and use in source and binary forms, with or without
00010  * modification, are permitted provided that the following conditions
00011  * are met:
00012  *
00013  * 1. Redistributions of source code must retain the above copyright
00014  *    notice, this list of conditions and the following disclaimer.
00015  *
00016  * 2. Redistributions in binary form must reproduce the above copyright
00017  *    notice, this list of conditions and the following disclaimer in
00018  *    the documentation and/or other materials provided with the
00019  *    distribution.
00020  *
00021  * 3. The end-user documentation included with the redistribution,
00022  *    if any, must include the following acknowledgment:
00023  *       "This product includes software developed by the
00024  *        Apache Software Foundation (http://www.apache.org/)."
00025  *    Alternately, this acknowledgment may appear in the software itself,
00026  *    if and wherever such third-party acknowledgments normally appear.
00027  *
00028  * 4. The names "Xerces" and "Apache Software Foundation" must
00029  *    not be used to endorse or promote products derived from this
00030  *    software without prior written permission. For written
00031  *    permission, please contact apache\@apache.org.
00032  *
00033  * 5. Products derived from this software may not be called "Apache",
00034  *    nor may "Apache" appear in their name, without prior written
00035  *    permission of the Apache Software Foundation.
00036  *
00037  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
00038  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00039  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00040  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
00041  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00042  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00043  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
00044  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00045  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00046  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
00047  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00048  * SUCH DAMAGE.
00049  * ====================================================================
00050  *
00051  * This software consists of voluntary contributions made by many
00052  * individuals on behalf of the Apache Software Foundation, and was
00053  * originally based on software copyright (c) 2001, International
00054  * Business Machines, Inc., http://www.ibm.com .  For more information
00055  * on the Apache Software Foundation, please see
00056  * <http://www.apache.org/>.
00057  */
00058 
00059  /*
00060  * $Id: IDRangeImpl.hpp,v 1.1 2002/05/11 20:16:19 bhavani Exp $
00061  */
00062 
00063 #include <xercesc/util/XercesDefs.hpp>
00064 
00065 #include "IDOM_Range.hpp"
00066 
00067 class       IDOM_Node;
00068 class       IDOM_DocumentFragment;
00069 class       IDOM_Text;
00070 
00071 class CDOM_EXPORT IDRangeImpl: public IDOM_Range {
00072 private:
00073     enum TraversalType {
00074         EXTRACT_CONTENTS = 1,
00075         CLONE_CONTENTS   = 2,
00076         DELETE_CONTENTS  = 3
00077     };
00078 
00079     enum TraversePoint {
00080         BEFORE  = -1,
00081         START   = 0,
00082         AFTER   = 1
00083     };
00084 
00085     //private data
00086 
00087     IDOM_Node       *fStartContainer;
00088     unsigned int    fStartOffset;
00089     IDOM_Node       *fEndContainer;
00090     unsigned int    fEndOffset;
00091     bool            fCollapsed;
00092     IDOM_Document   *fDocument;
00093     bool            fDetached;
00094 
00095     IDOM_Node       *fRemoveChild;
00096 
00097 public:
00098     //c'tor
00099     IDRangeImpl(IDOM_Document* doc);
00100     IDRangeImpl(const IDRangeImpl& other);
00101 
00102     //d'tor
00103     ~IDRangeImpl();
00104 
00105     //getter functions
00106     virtual IDOM_Node* getStartContainer() const;
00107     virtual unsigned int getStartOffset() const;
00108     virtual IDOM_Node* getEndContainer() const;
00109     virtual unsigned int getEndOffset() const;
00110     virtual bool getCollapsed() const;
00111     virtual const IDOM_Node* getCommonAncestorContainer() const;
00112 
00113     //setter functions
00114     virtual void setStart(const IDOM_Node *parent, unsigned int offset);
00115     virtual void setEnd(const IDOM_Node *parent, unsigned int offset);
00116 
00117     virtual void setStartBefore(const IDOM_Node *refNode);
00118     virtual void setStartAfter(const IDOM_Node *refNode);
00119     virtual void setEndBefore(const IDOM_Node *refNode);
00120     virtual void setEndAfter(const IDOM_Node *refNode);
00121 
00122     //misc functions
00123     virtual void collapse(bool toStart);
00124     virtual void selectNode(const IDOM_Node *node);
00125     virtual void selectNodeContents(const IDOM_Node *node);
00126 
00127     //Functions related to comparing range Boundrary-Points
00128     virtual short compareBoundaryPoints(CompareHow how, const IDOM_Range* range) const;
00129     virtual void deleteContents();
00130     virtual IDOM_DocumentFragment* extractContents();
00131     virtual IDOM_DocumentFragment* cloneContents() const;
00132     virtual void insertNode(IDOM_Node* node);
00133 
00134     //Misc functions
00135     virtual void surroundContents(IDOM_Node *node);
00136     virtual IDOM_Range* cloneRange() const;
00137     virtual const XMLCh* toString() const;
00138     virtual void detach();
00139 
00140     //getter functions
00141     IDOM_Document*         getDocument();
00142 
00143     // functions to inform all existing valid ranges about a change
00144     void updateSplitInfo(IDOM_Text* oldNode, IDOM_Text* startNode, unsigned int offset);
00145     void updateRangeForInsertedNode(IDOM_Node* node);
00146     void receiveReplacedText(IDOM_Node* node);
00147     void updateRangeForDeletedText(IDOM_Node* node, unsigned int offset, int count);
00148     void updateRangeForDeletedNode(IDOM_Node* node);
00149 
00150 private:
00151     //setter functions
00152     void        setStartContainer(const IDOM_Node* node);
00153     void        setStartOffset(unsigned int offset) ;
00154     void        setEndContainer(const IDOM_Node* node);
00155     void        setEndOffset(unsigned int offset) ;
00156 
00157     //misc functions
00158     void        validateNode(const IDOM_Node* node) const;
00159     bool        isValidAncestorType(const IDOM_Node* node) const;
00160     bool        hasLegalRootContainer(const IDOM_Node* node) const;
00161     bool        isLegalContainedNode(const IDOM_Node* node ) const;
00162     void        checkIndex(const IDOM_Node* node, unsigned int offset) const;
00163     static bool isAncestorOf(const IDOM_Node* a, const IDOM_Node* b);
00164 
00165     unsigned short        indexOf(const IDOM_Node* child, const IDOM_Node* parent) const;
00166 
00167     const IDOM_Node*       commonAncestorOf(const IDOM_Node* pointA, const IDOM_Node* pointB) const;
00168     IDOM_Node*             nextNode(const IDOM_Node* node, bool visitChildren) const;
00169     IDOM_DocumentFragment* traverseContents(TraversalType type);
00170     void                  checkReadOnly(IDOM_Node* start, IDOM_Node* end,
00171                                   unsigned int starOffset, unsigned int endOffset);
00172     void                  recurseTreeAndCheck(IDOM_Node* start, IDOM_Node* end);
00173     IDOM_Node*             removeChild(IDOM_Node* parent, IDOM_Node* child);
00174 
00175     IDOM_DocumentFragment* traverseSameContainer( int how );
00176     IDOM_DocumentFragment* traverseCommonStartContainer( IDOM_Node *endAncestor, int how );
00177     IDOM_DocumentFragment* traverseCommonEndContainer( IDOM_Node *startAncestor, int how );
00178     IDOM_DocumentFragment* traverseCommonAncestors( IDOM_Node *startAncestor, IDOM_Node *endAncestor, int how );
00179     IDOM_Node*    traverseRightBoundary( IDOM_Node *root, int how );
00180     IDOM_Node*    traverseLeftBoundary( IDOM_Node *root, int how );
00181     IDOM_Node*    traverseNode( IDOM_Node *n, bool isFullySelected, bool isLeft, int how );
00182     IDOM_Node*    traverseFullySelected( IDOM_Node *n, int how );
00183     IDOM_Node*    traversePartiallySelected( IDOM_Node *n, int how );
00184     IDOM_Node*    traverseTextNode( IDOM_Node *n, bool isLeft, int how );
00185     IDOM_Node*    getSelectedNode( IDOM_Node *container, int offset );
00186 
00187 };
00188 
00189 #endif

Generated on Tue Nov 19 09:36:31 2002 by doxygen1.3-rc1