Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:27:02

0001 /*
0002  * Licensed to the Apache Software Foundation (ASF) under one or more
0003  * contributor license agreements.  See the NOTICE file distributed with
0004  * this work for additional information regarding copyright ownership.
0005  * The ASF licenses this file to You under the Apache License, Version 2.0
0006  * (the "License"); you may not use this file except in compliance with
0007  * the License.  You may obtain a copy of the License at
0008  * 
0009  *      http://www.apache.org/licenses/LICENSE-2.0
0010  * 
0011  * Unless required by applicable law or agreed to in writing, software
0012  * distributed under the License is distributed on an "AS IS" BASIS,
0013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014  * See the License for the specific language governing permissions and
0015  * limitations under the License.
0016  */
0017 
0018  /*
0019  * $Id$
0020  */
0021 
0022 #if !defined(XERCESC_INCLUDE_GUARD_DOMRANGEIMPL_HPP)
0023 #define XERCESC_INCLUDE_GUARD_DOMRANGEIMPL_HPP
0024 
0025 //
0026 //  This file is part of the internal implementation of the C++ XML DOM.
0027 //  It should NOT be included or used directly by application programs.
0028 //
0029 //  Applications should include the file <xercesc/dom/DOM.hpp> for the entire
0030 //  DOM API, or xercesc/dom/DOM*.hpp for individual DOM classes, where the class
0031 //  name is substituded for the *.
0032 //
0033 
0034 #include <xercesc/util/XercesDefs.hpp>
0035 #include <xercesc/dom/DOMRange.hpp>
0036 #include <xercesc/util/PlatformUtils.hpp>
0037 
0038 XERCES_CPP_NAMESPACE_BEGIN
0039 
0040 
0041 
0042 class       DOMNode;
0043 class       DOMDocumentFragment;
0044 class       DOMDocument;
0045 class       DOMText;
0046 class       MemoryManager;
0047 
0048 class CDOM_EXPORT DOMRangeImpl: public DOMRange {
0049 protected:
0050     enum TraversalType {
0051         EXTRACT_CONTENTS = 1,
0052         CLONE_CONTENTS   = 2,
0053         DELETE_CONTENTS  = 3
0054     };
0055 
0056     enum TraversePoint {
0057         BEFORE  = -1,
0058         START   = 0,
0059         AFTER   = 1
0060     };
0061 
0062     //private data
0063 
0064     DOMNode*     fStartContainer;
0065     XMLSize_t    fStartOffset;
0066     DOMNode*     fEndContainer;
0067     XMLSize_t    fEndOffset;
0068     bool         fCollapsed;
0069     DOMDocument* fDocument;
0070     bool         fDetached;
0071 
0072     DOMNode*     fRemoveChild;
0073     MemoryManager* fMemoryManager;
0074 
0075 public:
0076     //c'tor
0077     DOMRangeImpl(DOMDocument* doc, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0078     DOMRangeImpl(const DOMRangeImpl& other);
0079 
0080     //d'tor
0081     ~DOMRangeImpl();
0082 
0083     //getter functions
0084     virtual DOMNode* getStartContainer() const;
0085     virtual XMLSize_t getStartOffset() const;
0086     virtual DOMNode* getEndContainer() const;
0087     virtual XMLSize_t getEndOffset() const;
0088     virtual bool getCollapsed() const;
0089     virtual const DOMNode* getCommonAncestorContainer() const;
0090 
0091     //setter functions
0092     virtual void setStart(const DOMNode *parent, XMLSize_t offset);
0093     virtual void setEnd(const DOMNode *parent, XMLSize_t offset);
0094 
0095     virtual void setStartBefore(const DOMNode *refNode);
0096     virtual void setStartAfter(const DOMNode *refNode);
0097     virtual void setEndBefore(const DOMNode *refNode);
0098     virtual void setEndAfter(const DOMNode *refNode);
0099 
0100     //misc functions
0101     virtual void collapse(bool toStart);
0102     virtual void selectNode(const DOMNode *node);
0103     virtual void selectNodeContents(const DOMNode *node);
0104 
0105     //Functions related to comparing range Boundrary-Points
0106     virtual short compareBoundaryPoints(CompareHow how, const DOMRange* range) const;
0107     virtual void deleteContents();
0108     virtual DOMDocumentFragment* extractContents();
0109     virtual DOMDocumentFragment* cloneContents() const;
0110     virtual void insertNode(DOMNode* node);
0111 
0112     //Misc functions
0113     virtual void surroundContents(DOMNode *node);
0114     virtual DOMRange* cloneRange() const;
0115     virtual const XMLCh* toString() const;
0116     virtual void detach();
0117     virtual void release();
0118 
0119     //getter functions
0120     DOMDocument*         getDocument();
0121 
0122     // functions to inform all existing valid ranges about a change
0123     void updateSplitInfo(DOMNode* oldNode, DOMNode* startNode, XMLSize_t offset);
0124     void updateRangeForInsertedNode(DOMNode* node);
0125     void receiveReplacedText(DOMNode* node);
0126     void updateRangeForDeletedText(DOMNode* node, XMLSize_t offset, XMLSize_t count);
0127     void updateRangeForInsertedText(DOMNode* node, XMLSize_t offset, XMLSize_t count);
0128     void updateRangeForDeletedNode(DOMNode* node);
0129 
0130 protected:
0131     //setter functions
0132     void        setStartContainer(const DOMNode* node);
0133     void        setStartOffset(XMLSize_t offset) ;
0134     void        setEndContainer(const DOMNode* node);
0135     void        setEndOffset(XMLSize_t offset) ;
0136 
0137     //misc functions
0138     void        validateNode(const DOMNode* node) const;
0139     bool        isValidAncestorType(const DOMNode* node) const;
0140     bool        hasLegalRootContainer(const DOMNode* node) const;
0141     bool        isLegalContainedNode(const DOMNode* node ) const;
0142     void        checkIndex(const DOMNode* node, XMLSize_t offset) const;
0143     static bool isAncestorOf(const DOMNode* a, const DOMNode* b);
0144 
0145     XMLSize_t   indexOf(const DOMNode* child, const DOMNode* parent) const;
0146 
0147     const DOMNode*       commonAncestorOf(const DOMNode* pointA, const DOMNode* pointB) const;
0148     DOMNode*             nextNode(const DOMNode* node, bool visitChildren) const;
0149     DOMDocumentFragment* traverseContents(TraversalType type);
0150     void                  checkReadOnly(DOMNode* start, DOMNode* end,
0151                                   XMLSize_t starOffset, XMLSize_t endOffset);
0152     void                  recurseTreeAndCheck(DOMNode* start, DOMNode* end);
0153     DOMNode*             removeChild(DOMNode* parent, DOMNode* child);
0154 
0155     DOMDocumentFragment* traverseSameContainer( int how );
0156     DOMDocumentFragment* traverseCommonStartContainer( DOMNode *endAncestor, int how );
0157     DOMDocumentFragment* traverseCommonEndContainer( DOMNode *startAncestor, int how );
0158     DOMDocumentFragment* traverseCommonAncestors( DOMNode *startAncestor, DOMNode *endAncestor, int how );
0159     DOMNode*    traverseRightBoundary( DOMNode *root, int how );
0160     DOMNode*    traverseLeftBoundary( DOMNode *root, int how );
0161     DOMNode*    traverseNode( DOMNode *n, bool isFullySelected, bool isLeft, int how );
0162     DOMNode*    traverseFullySelected( DOMNode *n, int how );
0163     DOMNode*    traversePartiallySelected( DOMNode *n, int how );
0164     DOMNode*    traverseTextNode( DOMNode *n, bool isLeft, int how );
0165     DOMNode*    getSelectedNode( DOMNode *container, int offset );
0166 
0167 private:
0168     // -----------------------------------------------------------------------
0169     // Unimplemented constructors and operators
0170     // -----------------------------------------------------------------------
0171     DOMRangeImpl & operator = (const DOMRangeImpl &);
0172 };
0173 
0174 XERCES_CPP_NAMESPACE_END
0175 
0176 #endif