File indexing completed on 2025-01-30 10:27:02
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #if !defined(XERCESC_INCLUDE_GUARD_DOMRANGEIMPL_HPP)
0023 #define XERCESC_INCLUDE_GUARD_DOMRANGEIMPL_HPP
0024
0025
0026
0027
0028
0029
0030
0031
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
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
0077 DOMRangeImpl(DOMDocument* doc, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0078 DOMRangeImpl(const DOMRangeImpl& other);
0079
0080
0081 ~DOMRangeImpl();
0082
0083
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
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
0101 virtual void collapse(bool toStart);
0102 virtual void selectNode(const DOMNode *node);
0103 virtual void selectNodeContents(const DOMNode *node);
0104
0105
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
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
0120 DOMDocument* getDocument();
0121
0122
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
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
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
0170
0171 DOMRangeImpl & operator = (const DOMRangeImpl &);
0172 };
0173
0174 XERCES_CPP_NAMESPACE_END
0175
0176 #endif