Package mf.org.w3c.dom

Examples of mf.org.w3c.dom.DocumentFragment


             throw new RangeExceptionImpl(
        RangeException.BAD_BOUNDARYPOINTS_ERR,
                DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "BAD_BOUNDARYPOINTS_ERR", null));
        }

      DocumentFragment frag = extractContents();
      insertNode(newParent);
      newParent.appendChild(frag);
      selectNode(newParent);
    }
View Full Code Here


     *         parameter was <code>DELETE_CONTENTS</code>, the
     *         return value is null.
     */
    private DocumentFragment traverseSameContainer( int how )
    {
        DocumentFragment frag = null;
        if (how != DELETE_CONTENTS) {
            frag = fDocument.createDocumentFragment();
        }

        // If selection is empty, just return the fragment
        if (fStartOffset == fEndOffset) {
            return frag;
        }

        // Text, CDATASection, Comment and ProcessingInstruction nodes need special case handling
        final short nodeType = fStartContainer.getNodeType();
        if (nodeType == Node.TEXT_NODE ||
            nodeType == Node.CDATA_SECTION_NODE ||
            nodeType == Node.COMMENT_NODE ||
            nodeType == Node.PROCESSING_INSTRUCTION_NODE) {
            // get the substring
            String s = fStartContainer.getNodeValue();
            String sub = s.substring(fStartOffset, fEndOffset);

            // set the original text node to its new value
            if (how != CLONE_CONTENTS) {
                ((CharacterDataImpl)fStartContainer).deleteData(fStartOffset,
                     fEndOffset-fStartOffset);
                // Nothing is partially selected, so collapse to start point
                collapse(true);
            }
            if (how == DELETE_CONTENTS) {
                return null;
            }
            if (nodeType == Node.TEXT_NODE) {
                frag.appendChild(fDocument.createTextNode(sub));
            }
            else if (nodeType == Node.CDATA_SECTION_NODE) {
                frag.appendChild(fDocument.createCDATASection(sub));
            }
            else if (nodeType == Node.COMMENT_NODE) {
                frag.appendChild(fDocument.createComment(sub));
            }
            else { // nodeType == Node.PROCESSING_INSTRUCTION_NODE
                frag.appendChild(fDocument.createProcessingInstruction(fStartContainer.getNodeName(), sub));
            }
            return frag;
        }

        // Copy nodes between the start/end offsets.
        Node n = getSelectedNode( fStartContainer, fStartOffset );
        int cnt = fEndOffset - fStartOffset;
        while( cnt > 0 ) {
            Node sibling = n.getNextSibling();
            Node xferNode = traverseFullySelected( n, how );
            if ( frag!=null )
                frag.appendChild( xferNode );
            --cnt;
            n = sibling;
        }

        // Nothing is partially selected, so collapse to start point
View Full Code Here

     *         return value is null.
     */
    private DocumentFragment
        traverseCommonStartContainer( Node endAncestor, int how )
    {
        DocumentFragment frag = null;
        if ( how!=DELETE_CONTENTS)
            frag = fDocument.createDocumentFragment();
        Node n = traverseRightBoundary( endAncestor, how );
        if ( frag!=null )
            frag.appendChild( n );

        int endIdx = indexOf( endAncestor, fStartContainer );
        int cnt = endIdx - fStartOffset;
        if ( cnt <=0 )
        {
            // Collapse to just before the endAncestor, which
            // is partially selected.
            if ( how != CLONE_CONTENTS )
            {
                setEndBefore( endAncestor );
                collapse( false );
            }
            return frag;
        }

        n = endAncestor.getPreviousSibling();
        while( cnt > 0 )
        {
            Node sibling = n.getPreviousSibling();
            Node xferNode = traverseFullySelected( n, how );
            if ( frag!=null )
                frag.insertBefore( xferNode, frag.getFirstChild() );
            --cnt;
            n = sibling;
        }
        // Collapse to just before the endAncestor, which
        // is partially selected.
View Full Code Here

     *         return value is null.
     */
    private DocumentFragment
        traverseCommonEndContainer( Node startAncestor, int how )
    {
        DocumentFragment frag = null;
        if ( how!=DELETE_CONTENTS)
            frag = fDocument.createDocumentFragment();
        Node n = traverseLeftBoundary( startAncestor, how );
        if ( frag!=null )
            frag.appendChild( n );
        int startIdx = indexOf( startAncestor, fEndContainer );
        ++startIdx;  // Because we already traversed it....

        int cnt = fEndOffset - startIdx;
        n = startAncestor.getNextSibling();
        while( cnt > 0 )
        {
            Node sibling = n.getNextSibling();
            Node xferNode = traverseFullySelected( n, how );
            if ( frag!=null )
                frag.appendChild( xferNode );
            --cnt;
            n = sibling;
        }

        if ( how != CLONE_CONTENTS )
View Full Code Here

     *         return value is null.
     */
    private DocumentFragment
        traverseCommonAncestors( Node startAncestor, Node endAncestor, int how )
    {
        DocumentFragment frag = null;
        if ( how!=DELETE_CONTENTS)
            frag = fDocument.createDocumentFragment();

        Node n = traverseLeftBoundary( startAncestor, how );
        if ( frag!=null )
            frag.appendChild( n );

        Node commonParent = startAncestor.getParentNode();
        int startOffset = indexOf( startAncestor, commonParent );
        int endOffset = indexOf( endAncestor, commonParent );
        ++startOffset;

        int cnt = endOffset - startOffset;
        Node sibling = startAncestor.getNextSibling();

        while( cnt > 0 )
        {
            Node nextSibling = sibling.getNextSibling();
            n = traverseFullySelected( sibling, how );
            if ( frag!=null )
                frag.appendChild( n );
            sibling = nextSibling;
            --cnt;
        }

        n = traverseRightBoundary( endAncestor, how );
        if ( frag!=null )
            frag.appendChild( n );

        if ( how != CLONE_CONTENTS )
        {
            setStartAfter( startAncestor );
            collapse( true );
View Full Code Here

TOP

Related Classes of mf.org.w3c.dom.DocumentFragment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.