Example #1
0
        public XMLCursorPos Clone()
        {
            XMLCursorPos xMLCursorPos = new XMLCursorPos();

            xMLCursorPos.CursorSetzen(this._aktNode, this._posAmNode, this._posImTextnode);
            return(xMLCursorPos);
        }
Example #2
0
        public bool SelektionLoeschen(out XMLCursorPos neueCursorPosNachLoeschen)
        {
            if (!this.IstEtwasSelektiert)
            {
                neueCursorPosNachLoeschen = this.StartPos.Clone();
                return(false);
            }
            if (this.StartPos.AktNode == this.EndPos.AktNode)
            {
                switch (this.StartPos.PosAmNode)
                {
                case XMLCursorPositionen.CursorVorDemNode:
                    if (ToolboxXML.IstTextOderKommentarNode(this.StartPos.AktNode))
                    {
                        this.StartPos.CursorSetzen(this.StartPos.AktNode, XMLCursorPositionen.CursorInnerhalbDesTextNodes, 0);
                        return(this.SelektionLoeschen(out neueCursorPosNachLoeschen));
                    }
                    this.BeideCursorPosSetzen(this.StartPos.AktNode, XMLCursorPositionen.CursorAufNodeSelbstVorderesTag);
                    return(this.SelektionLoeschen(out neueCursorPosNachLoeschen));

                case XMLCursorPositionen.CursorAufNodeSelbstVorderesTag:
                case XMLCursorPositionen.CursorAufNodeSelbstHinteresTag:
                    XmlNode aktNode         = this.StartPos.AktNode;
                    XmlNode previousSibling = aktNode.PreviousSibling;
                    XmlNode nextSibling     = aktNode.NextSibling;
                    neueCursorPosNachLoeschen = new XMLCursorPos();
                    if (previousSibling != null && nextSibling != null && (previousSibling is XmlText && nextSibling is XmlText))
                    {
                        neueCursorPosNachLoeschen.CursorSetzen(previousSibling, XMLCursorPositionen.CursorInnerhalbDesTextNodes, previousSibling.InnerText.Length);
                        previousSibling.InnerText += nextSibling.InnerText;
                        aktNode.ParentNode.RemoveChild(aktNode);
                        nextSibling.ParentNode.RemoveChild(nextSibling);
                        return(true);
                    }
                    if (previousSibling != null)
                    {
                        neueCursorPosNachLoeschen.CursorSetzen(previousSibling, XMLCursorPositionen.CursorHinterDemNode);
                    }
                    else if (nextSibling != null)
                    {
                        neueCursorPosNachLoeschen.CursorSetzen(nextSibling, XMLCursorPositionen.CursorVorDemNode);
                    }
                    else
                    {
                        neueCursorPosNachLoeschen.CursorSetzen(aktNode.ParentNode, XMLCursorPositionen.CursorInDemLeeremNode);
                    }
                    aktNode.ParentNode.RemoveChild(aktNode);
                    return(true);

                case XMLCursorPositionen.CursorInDemLeeremNode:
                    if (this.EndPos.PosAmNode != XMLCursorPositionen.CursorHinterDemNode && this.EndPos.PosAmNode != XMLCursorPositionen.CursorVorDemNode)
                    {
                        throw new ApplicationException("AuswahlLoeschen:#6363S undefined Endpos " + (object)this.EndPos.PosAmNode + "!");
                    }
                    XMLCursor xmlCursor1 = new XMLCursor();
                    xmlCursor1.BeideCursorPosSetzen(this.StartPos.AktNode, XMLCursorPositionen.CursorAufNodeSelbstVorderesTag, 0);
                    return(xmlCursor1.SelektionLoeschen(out neueCursorPosNachLoeschen));

                case XMLCursorPositionen.CursorInnerhalbDesTextNodes:
                    int posImTextnode = this.StartPos.PosImTextnode;
                    int num           = this.EndPos.PosImTextnode;
                    if (this.EndPos.PosAmNode == XMLCursorPositionen.CursorHinterDemNode)
                    {
                        num = this.StartPos.AktNode.InnerText.Length;
                    }
                    if (posImTextnode == 0 && num >= this.StartPos.AktNode.InnerText.Length)
                    {
                        XMLCursor xmlCursor2 = new XMLCursor();
                        xmlCursor2.BeideCursorPosSetzen(this.StartPos.AktNode, XMLCursorPositionen.CursorAufNodeSelbstVorderesTag);
                        return(xmlCursor2.SelektionLoeschen(out neueCursorPosNachLoeschen));
                    }
                    this.StartPos.AktNode.InnerText = this.StartPos.AktNode.InnerText.Remove(posImTextnode, num - posImTextnode);
                    neueCursorPosNachLoeschen       = new XMLCursorPos();
                    if (posImTextnode == 0)
                    {
                        neueCursorPosNachLoeschen.CursorSetzen(this.StartPos.AktNode, XMLCursorPositionen.CursorVorDemNode);
                    }
                    else
                    {
                        neueCursorPosNachLoeschen.CursorSetzen(this.StartPos.AktNode, XMLCursorPositionen.CursorInnerhalbDesTextNodes, posImTextnode);
                    }
                    return(true);

                case XMLCursorPositionen.CursorHinterDemNode:
                    if (ToolboxXML.IstTextOderKommentarNode(this.StartPos.AktNode))
                    {
                        this.StartPos.CursorSetzen(this.StartPos.AktNode, XMLCursorPositionen.CursorInnerhalbDesTextNodes, this.StartPos.AktNode.InnerText.Length);
                        return(this.SelektionLoeschen(out neueCursorPosNachLoeschen));
                    }
                    this.BeideCursorPosSetzen(this.StartPos.AktNode, XMLCursorPositionen.CursorAufNodeSelbstVorderesTag);
                    return(this.SelektionLoeschen(out neueCursorPosNachLoeschen));

                default:
                    throw new ApplicationException("AuswahlLoeschen:#63346 StartPos.PosAmNode " + (object)this.StartPos.PosAmNode + " not allowed!");
                }
            }
            else
            {
                while (this.StartPos.AktNode.NextSibling != this.EndPos.AktNode)
                {
                    this.StartPos.AktNode.ParentNode.RemoveChild(this.StartPos.AktNode.NextSibling);
                }
                XMLCursor xmlCursor2 = this.Clone();
                xmlCursor2.StartPos.CursorSetzen(this.EndPos.AktNode, XMLCursorPositionen.CursorVorDemNode);
                XMLCursorPos neueCursorPosNachLoeschen1;
                xmlCursor2.SelektionLoeschen(out neueCursorPosNachLoeschen1);
                this.EndPos.CursorSetzen(this.StartPos.AktNode, XMLCursorPositionen.CursorHinterDemNode);
                return(this.SelektionLoeschen(out neueCursorPosNachLoeschen));
            }
        }