Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:14:51

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_DOMRANGE_HPP)
0023 #define XERCESC_INCLUDE_GUARD_DOMRANGE_HPP
0024 
0025 #include <xercesc/util/XercesDefs.hpp>
0026 
0027 XERCES_CPP_NAMESPACE_BEGIN
0028 
0029 class DOMNode;
0030 class DOMDocumentFragment;
0031 
0032 /**
0033  * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Traversal-Range-20001113'>Document Object Model (DOM) Level 2 Traversal and Range Specification</a>.
0034  * @since DOM Level 2
0035  */
0036 class CDOM_EXPORT DOMRange {
0037 protected:
0038     // -----------------------------------------------------------------------
0039     //  Hidden constructors
0040     // -----------------------------------------------------------------------
0041     /** @name Hidden constructors */
0042     //@{    
0043     DOMRange() {}
0044     DOMRange(const DOMRange &) {}
0045     //@}
0046 
0047 private:
0048     // -----------------------------------------------------------------------
0049     // Unimplemented constructors and operators
0050     // -----------------------------------------------------------------------
0051     /** @name Unimplemented operators */
0052     //@{
0053     DOMRange & operator = (const DOMRange &);
0054     //@}
0055 
0056 public:
0057     // -----------------------------------------------------------------------
0058     //  All constructors are hidden, just the destructor is available
0059     // -----------------------------------------------------------------------
0060     /** @name Destructor */
0061     //@{
0062     /**
0063      * Destructor
0064      *
0065      */
0066     virtual ~DOMRange() {};
0067     //@}
0068 
0069     // -----------------------------------------------------------------------
0070     //  Class Types
0071     // -----------------------------------------------------------------------
0072     /** @name Public Constants */
0073     //@{
0074     /**
0075      * Constants CompareHow.
0076      *
0077      * <p><code>START_TO_START:</code>
0078      * Compare start boundary-point of <code>sourceRange</code> to start
0079      * boundary-point of Range on which <code>compareBoundaryPoints</code>
0080      * is invoked.</p>
0081      *
0082      * <p><code>START_TO_END:</code>
0083      * Compare start boundary-point of <code>sourceRange</code> to end
0084      * boundary-point of Range on which <code>compareBoundaryPoints</code>
0085      * is invoked.</p>
0086      *
0087      * <p><code>END_TO_END:</code>
0088      * Compare end boundary-point of <code>sourceRange</code> to end
0089      * boundary-point of Range on which <code>compareBoundaryPoints</code>
0090      * is invoked.</p>
0091      *
0092      * <p><code>END_TO_START:</code>
0093      * Compare end boundary-point of <code>sourceRange</code> to start
0094      * boundary-point of Range on which <code>compareBoundaryPoints</code>
0095      * is invoked.</p>
0096      *
0097      * @since DOM Level 2
0098      */
0099     enum CompareHow {
0100         START_TO_START  = 0,
0101         START_TO_END    = 1,
0102         END_TO_END      = 2,
0103         END_TO_START    = 3
0104     };
0105 
0106     //@}
0107 
0108     // -----------------------------------------------------------------------
0109     //  Virtual DOMRange interface
0110     // -----------------------------------------------------------------------
0111     /** @name Functions introduced in DOM Level 2 */
0112     //@{
0113     // -----------------------------------------------------------------------
0114     //  Getter methods
0115     // -----------------------------------------------------------------------
0116     /**
0117      * DOMNode within which the Range begins
0118      * @exception DOMException
0119      *   INVALID_STATE_ERR: Raised if <code>detach()</code> has already been
0120      *   invoked on this object.
0121      *
0122      * @since DOM Level 2
0123      */
0124     virtual DOMNode* getStartContainer() const = 0;
0125 
0126     /**
0127      * Offset within the starting node of the Range.
0128      * @exception DOMException
0129      *   INVALID_STATE_ERR: Raised if <code>detach()</code> has already been
0130      *   invoked on this object.
0131      *
0132      * @since DOM Level 2
0133      */
0134     virtual XMLSize_t getStartOffset() const = 0;
0135 
0136     /**
0137      * DOMNode within which the Range ends
0138      * @exception DOMException
0139      *   INVALID_STATE_ERR: Raised if <code>detach()</code> has already been
0140      *   invoked on this object.
0141      *
0142      * @since DOM Level 2
0143      */
0144     virtual DOMNode* getEndContainer() const = 0;
0145 
0146     /**
0147      * Offset within the ending node of the Range.
0148      * @exception DOMException
0149      *   INVALID_STATE_ERR: Raised if <code>detach()</code> has already been
0150      *   invoked on this object.
0151      *
0152      * @since DOM Level 2
0153      */
0154     virtual XMLSize_t getEndOffset() const = 0;
0155 
0156     /**
0157      * TRUE if the Range is collapsed
0158      * @exception DOMException
0159      *   INVALID_STATE_ERR: Raised if <code>detach()</code> has already been
0160      *   invoked on this object.
0161      *
0162      * @since DOM Level 2
0163      */
0164     virtual bool getCollapsed() const = 0;
0165 
0166     /**
0167      * The deepest common ancestor container of the Range's two
0168      * boundary-points.
0169      * @exception DOMException
0170      *   INVALID_STATE_ERR: Raised if <code>detach()</code> has already been
0171      *   invoked on this object.
0172      *
0173      * @since DOM Level 2
0174      */
0175     virtual const DOMNode* getCommonAncestorContainer() const = 0;
0176 
0177     // -----------------------------------------------------------------------
0178     //  Setter methods
0179     // -----------------------------------------------------------------------
0180     /**
0181      * Sets the attributes describing the start of the Range.
0182      * @param refNode The <code>refNode</code> value. This parameter must be
0183      *   different from <code>null</code>.
0184      * @param offset The <code>startOffset</code> value.
0185      * @exception DOMRangeException
0186      *   INVALID_NODE_TYPE_ERR: Raised if <code>refNode</code> or an ancestor
0187      *   of <code>refNode</code> is an DOMEntity, DOMNotation, or DOMDocumentType
0188      *   node.
0189      * @exception DOMException
0190      *   INDEX_SIZE_ERR: Raised if <code>offset</code> is negative or greater
0191      *   than the number of child units in <code>refNode</code>. Child units
0192      *   are 16-bit units if <code>refNode</code> is a type of DOMCharacterData
0193      *   node (e.g., a DOMText or DOMComment node) or a DOMProcessingInstruction
0194      *   node. Child units are Nodes in all other cases.
0195      *   <br>INVALID_STATE_ERR: Raised if <code>detach()</code> has already
0196      *   been invoked on this object.
0197      *   <br>WRONG_DOCUMENT_ERR: Raised if <code>refNode</code> was created
0198      *   from a different document than the one that created this range.
0199      *
0200      * @since DOM Level 2
0201      */
0202     virtual void setStart(const DOMNode *refNode, XMLSize_t offset) = 0;
0203 
0204     /**
0205      * Sets the attributes describing the end of a Range.
0206      * @param refNode The <code>refNode</code> value. This parameter must be
0207      *   different from <code>null</code>.
0208      * @param offset The <code>endOffset</code> value.
0209      * @exception DOMRangeException
0210      *   INVALID_NODE_TYPE_ERR: Raised if <code>refNode</code> or an ancestor
0211      *   of <code>refNode</code> is an DOMEntity, DOMNotation, or DOMDocumentType
0212      *   node.
0213      * @exception DOMException
0214      *   INDEX_SIZE_ERR: Raised if <code>offset</code> is negative or greater
0215      *   than the number of child units in <code>refNode</code>. Child units
0216      *   are 16-bit units if <code>refNode</code> is a type of DOMCharacterData
0217      *   node (e.g., a DOMText or DOMComment node) or a DOMProcessingInstruction
0218      *   node. Child units are Nodes in all other cases.
0219      *   <br>INVALID_STATE_ERR: Raised if <code>detach()</code> has already
0220      *   been invoked on this object.
0221      *   <br>WRONG_DOCUMENT_ERR: Raised if <code>refNode</code> was created
0222      *   from a different document than the one that created this range.
0223      *
0224      * @since DOM Level 2
0225      */
0226     virtual void setEnd(const DOMNode *refNode, XMLSize_t offset) = 0;
0227 
0228     /**
0229      * Sets the start position to be before a node
0230      * @param refNode Range starts before <code>refNode</code>
0231      * @exception DOMRangeException
0232      *   INVALID_NODE_TYPE_ERR: Raised if the root container of
0233      *   <code>refNode</code> is not an DOMAttr, DOMDocument, or DOMDocumentFragment
0234      *   node or if <code>refNode</code> is a DOMDocument, DOMDocumentFragment,
0235      *   DOMAttr, DOMEntity, or DOMNotation node.
0236      * @exception DOMException
0237      *   INVALID_STATE_ERR: Raised if <code>detach()</code> has already been
0238      *   invoked on this object.
0239      *   <br>WRONG_DOCUMENT_ERR: Raised if <code>refNode</code> was created
0240      *   from a different document than the one that created this range.
0241      *
0242      * @since DOM Level 2
0243      */
0244     virtual void setStartBefore(const DOMNode *refNode) = 0;
0245 
0246     /**
0247      * Sets the start position to be after a node
0248      * @param refNode Range starts after <code>refNode</code>
0249      * @exception DOMRangeException
0250      *   INVALID_NODE_TYPE_ERR: Raised if the root container of
0251      *   <code>refNode</code> is not an DOMAttr, DOMDocument, or DOMDocumentFragment
0252      *   node or if <code>refNode</code> is a DOMDocument, DOMDocumentFragment,
0253      *   DOMAttr, DOMEntity, or DOMNotation node.
0254      * @exception DOMException
0255      *   INVALID_STATE_ERR: Raised if <code>detach()</code> has already been
0256      *   invoked on this object.
0257      *   <br>WRONG_DOCUMENT_ERR: Raised if <code>refNode</code> was created
0258      *   from a different document than the one that created this range.
0259      *
0260      * @since DOM Level 2
0261      */
0262     virtual void setStartAfter(const DOMNode *refNode) = 0;
0263 
0264     /**
0265      * Sets the end position to be before a node.
0266      * @param refNode Range ends before <code>refNode</code>
0267      * @exception DOMRangeException
0268      *   INVALID_NODE_TYPE_ERR: Raised if the root container of
0269      *   <code>refNode</code> is not an DOMAttr, DOMDocument, or DOMDocumentFragment
0270      *   node or if <code>refNode</code> is a DOMDocument, DOMDocumentFragment,
0271      *   DOMAttr, DOMEntity, or DOMNotation node.
0272      * @exception DOMException
0273      *   INVALID_STATE_ERR: Raised if <code>detach()</code> has already been
0274      *   invoked on this object.
0275      *   <br>WRONG_DOCUMENT_ERR: Raised if <code>refNode</code> was created
0276      *   from a different document than the one that created this range.
0277      *
0278      * @since DOM Level 2
0279      */
0280     virtual void setEndBefore(const DOMNode *refNode) = 0;
0281 
0282     /**
0283      * Sets the end of a Range to be after a node
0284      * @param refNode Range ends after <code>refNode</code>.
0285      * @exception DOMRangeException
0286      *   INVALID_NODE_TYPE_ERR: Raised if the root container of
0287      *   <code>refNode</code> is not a DOMAttr, DOMDocument or DOMDocumentFragment
0288      *   node or if <code>refNode</code> is a DOMDocument, DOMDocumentFragment,
0289      *   DOMAttr, DOMEntity, or DOMNotation node.
0290      * @exception DOMException
0291      *   INVALID_STATE_ERR: Raised if <code>detach()</code> has already been
0292      *   invoked on this object.
0293      *   <br>WRONG_DOCUMENT_ERR: Raised if <code>refNode</code> was created
0294      *   from a different document than the one that created this range.
0295      *
0296      * @since DOM Level 2
0297      */
0298     virtual void setEndAfter(const DOMNode *refNode) = 0;
0299 
0300     // -----------------------------------------------------------------------
0301     //  Misc methods
0302     // -----------------------------------------------------------------------
0303     /**
0304      * Collapse a Range onto one of its boundary-points
0305      * @param toStart If TRUE, collapses the Range onto its start; if FALSE,
0306      *   collapses it onto its end.
0307      * @exception DOMException
0308      *   INVALID_STATE_ERR: Raised if <code>detach()</code> has already been
0309      *   invoked on this object.
0310      *
0311      * @since DOM Level 2
0312      */
0313     virtual void collapse(bool toStart) = 0;
0314 
0315     /**
0316      * Select a node and its contents
0317      * @param refNode The node to select.
0318      * @exception DOMRangeException
0319      *   INVALID_NODE_TYPE_ERR: Raised if an ancestor of <code>refNode</code>
0320      *   is an DOMEntity, DOMNotation or DOMDocumentType node or if
0321      *   <code>refNode</code> is a DOMDocument, DOMDocumentFragment, DOMAttr, DOMEntity,
0322      *   or DOMNotation node.
0323      * @exception DOMException
0324      *   INVALID_STATE_ERR: Raised if <code>detach()</code> has already been
0325      *   invoked on this object.
0326      *   <br>WRONG_DOCUMENT_ERR: Raised if <code>refNode</code> was created
0327      *   from a different document than the one that created this range.
0328      *
0329      * @since DOM Level 2
0330      */
0331     virtual void selectNode(const DOMNode *refNode) = 0;
0332 
0333     /**
0334      * Select the contents within a node
0335      * @param refNode DOMNode to select from
0336      * @exception DOMRangeException
0337      *   INVALID_NODE_TYPE_ERR: Raised if <code>refNode</code> or an ancestor
0338      *   of <code>refNode</code> is an DOMEntity, DOMNotation or DOMDocumentType node.
0339      * @exception DOMException
0340      *   INVALID_STATE_ERR: Raised if <code>detach()</code> has already been
0341      *   invoked on this object.
0342      *   <br>WRONG_DOCUMENT_ERR: Raised if <code>refNode</code> was created
0343      *   from a different document than the one that created this range.
0344      *
0345      * @since DOM Level 2
0346      */
0347     virtual void selectNodeContents(const DOMNode *refNode) = 0;
0348 
0349     /**
0350      * Compare the boundary-points of two Ranges in a document.
0351      * @param how A code representing the type of comparison, as defined
0352      *   above.
0353      * @param sourceRange The <code>Range</code> on which this current
0354      *   <code>Range</code> is compared to.
0355      * @return  -1, 0 or 1 depending on whether the corresponding
0356      *   boundary-point of the Range is respectively before, equal to, or
0357      *   after the corresponding boundary-point of <code>sourceRange</code>.
0358      * @exception DOMException
0359      *   WRONG_DOCUMENT_ERR: Raised if the two Ranges are not in the same
0360      *   DOMDocument or DOMDocumentFragment.
0361      *   <br>INVALID_STATE_ERR: Raised if <code>detach()</code> has already
0362      *   been invoked on this object.
0363      *
0364      * @since DOM Level 2
0365      */
0366     virtual short compareBoundaryPoints(CompareHow how, const DOMRange* sourceRange) const = 0;
0367 
0368     /**
0369      * Removes the contents of a Range from the containing document or
0370      * document fragment without returning a reference to the removed
0371      * content.
0372      * @exception DOMException
0373      *   NO_MODIFICATION_ALLOWED_ERR: Raised if any portion of the content of
0374      *   the Range is read-only or any of the nodes that contain any of the
0375      *   content of the Range are read-only.
0376      *   <br>INVALID_STATE_ERR: Raised if <code>detach()</code> has already
0377      *   been invoked on this object.
0378      *
0379      * @since DOM Level 2
0380      */
0381     virtual void deleteContents() = 0;
0382 
0383     /**
0384      * Moves the contents of a Range from the containing document or document
0385      * fragment to a new DOMDocumentFragment.
0386      * @return A DOMDocumentFragment containing the extracted contents.
0387      * @exception DOMException
0388      *   NO_MODIFICATION_ALLOWED_ERR: Raised if any portion of the content of
0389      *   the Range is read-only or any of the nodes which contain any of the
0390      *   content of the Range are read-only.
0391      *   <br>HIERARCHY_REQUEST_ERR: Raised if a DOMDocumentType node would be
0392      *   extracted into the new DOMDocumentFragment.
0393      *   <br>INVALID_STATE_ERR: Raised if <code>detach()</code> has already
0394      *   been invoked on this object.
0395      *
0396      * @since DOM Level 2
0397      */
0398     virtual DOMDocumentFragment* extractContents() = 0;
0399 
0400     /**
0401      * Duplicates the contents of a Range
0402      * @return A DOMDocumentFragment that contains content equivalent to this
0403      *   Range.
0404      * @exception DOMException
0405      *   HIERARCHY_REQUEST_ERR: Raised if a DOMDocumentType node would be
0406      *   extracted into the new DOMDocumentFragment.
0407      *   <br>INVALID_STATE_ERR: Raised if <code>detach()</code> has already
0408      *   been invoked on this object.
0409      *
0410      * @since DOM Level 2
0411      */
0412     virtual DOMDocumentFragment* cloneContents() const = 0;
0413 
0414     /**
0415      * Inserts a node into the DOMDocument or DOMDocumentFragment at the start of
0416      * the Range. If the container is a DOMText node, this will be split at the
0417      * start of the Range (as if the DOMText node's splitText method was
0418      * performed at the insertion point) and the insertion will occur
0419      * between the two resulting DOMText nodes. Adjacent DOMText nodes will not be
0420      * automatically merged. If the node to be inserted is a
0421      * DOMDocumentFragment node, the children will be inserted rather than the
0422      * DOMDocumentFragment node itself.
0423      * @param newNode The node to insert at the start of the Range
0424      * @exception DOMException
0425      *   NO_MODIFICATION_ALLOWED_ERR: Raised if an ancestor container of the
0426      *   start of the Range is read-only.
0427      *   <br>WRONG_DOCUMENT_ERR: Raised if <code>newNode</code> and the
0428      *   container of the start of the Range were not created from the same
0429      *   document.
0430      *   <br>HIERARCHY_REQUEST_ERR: Raised if the container of the start of
0431      *   the Range is of a type that does not allow children of the type of
0432      *   <code>newNode</code> or if <code>newNode</code> is an ancestor of
0433      *   the container.
0434      *   <br>INVALID_STATE_ERR: Raised if <code>detach()</code> has already
0435      *   been invoked on this object.
0436      * @exception DOMRangeException
0437      *   INVALID_NODE_TYPE_ERR: Raised if <code>newNode</code> is an DOMAttr,
0438      *   DOMEntity, DOMNotation, or DOMDocument node.
0439      *
0440      * @since DOM Level 2
0441      */
0442     virtual void insertNode(DOMNode *newNode) = 0;
0443 
0444     /**
0445      * Reparents the contents of the Range to the given node and inserts the
0446      * node at the position of the start of the Range.
0447      * @param newParent The node to surround the contents with.
0448      * @exception DOMException
0449      *   NO_MODIFICATION_ALLOWED_ERR: Raised if an ancestor container of
0450      *   either boundary-point of the Range is read-only.
0451      *   <br>WRONG_DOCUMENT_ERR: Raised if <code> newParent</code> and the
0452      *   container of the start of the Range were not created from the same
0453      *   document.
0454      *   <br>HIERARCHY_REQUEST_ERR: Raised if the container of the start of
0455      *   the Range is of a type that does not allow children of the type of
0456      *   <code>newParent</code> or if <code>newParent</code> is an ancestor
0457      *   of the container or if <code>node</code> would end up with a child
0458      *   node of a type not allowed by the type of <code>node</code>.
0459      *   <br>INVALID_STATE_ERR: Raised if <code>detach()</code> has already
0460      *   been invoked on this object.
0461      * @exception DOMRangeException
0462      *   BAD_BOUNDARYPOINTS_ERR: Raised if the Range partially selects a
0463      *   non-text node.
0464      *   <br>INVALID_NODE_TYPE_ERR: Raised if <code> node</code> is an DOMAttr,
0465      *   DOMEntity, DOMDocumentType, DOMNotation, DOMDocument, or DOMDocumentFragment node.
0466      *
0467      * @since DOM Level 2
0468      */
0469     virtual void surroundContents(DOMNode *newParent) = 0;
0470 
0471     /**
0472      * Produces a new Range whose boundary-points are equal to the
0473      * boundary-points of the Range.
0474      * @return The duplicated Range.
0475      * @exception DOMException
0476      *   INVALID_STATE_ERR: Raised if <code>detach()</code> has already been
0477      *   invoked on this object.
0478      *
0479      * @since DOM Level 2
0480      */
0481     virtual DOMRange* cloneRange() const = 0;
0482 
0483     /**
0484      * Returns the contents of a Range as a string. This string contains only
0485      * the data characters, not any markup.
0486      * @return The contents of the Range.
0487      * @exception DOMException
0488      *   INVALID_STATE_ERR: Raised if <code>detach()</code> has already been
0489      *   invoked on this object.
0490      *
0491      * @since DOM Level 2
0492      */
0493     virtual const XMLCh* toString() const = 0;
0494 
0495     /**
0496      * Called to indicate that the Range is no longer in use and that the
0497      * implementation may relinquish any resources associated with this
0498      * Range. Subsequent calls to any methods or attribute getters on this
0499      * Range will result in a <code>DOMException</code> being thrown with an
0500      * error code of <code>INVALID_STATE_ERR</code>.
0501      * @exception DOMException
0502      *   INVALID_STATE_ERR: Raised if <code>detach()</code> has already been
0503      *   invoked on this object.
0504      *
0505      * @since DOM Level 2
0506      */
0507     virtual void detach() = 0;
0508 
0509     //@}
0510 
0511     // -----------------------------------------------------------------------
0512     //  Non-standard Extension
0513     // -----------------------------------------------------------------------
0514     /** @name Non-standard Extension */
0515     //@{
0516     /**
0517      * Called to indicate that this Range is no longer in use
0518      * and that the implementation may relinquish any resources associated with it.
0519      * (release() will call detach() where appropriate)
0520      *
0521      * Access to a released object will lead to unexpected result.
0522      */
0523     virtual void release() = 0;
0524     //@}
0525 };
0526 
0527 
0528 XERCES_CPP_NAMESPACE_END
0529 
0530 #endif