public XMLCursorPos Clone() { XMLCursorPos xMLCursorPos = new XMLCursorPos(); xMLCursorPos.CursorSetzen(this._aktNode, this._posAmNode, this._posImTextnode); return(xMLCursorPos); }
public void SelektionOptimieren() { if (this._startPos.AktNode == null) { return; } if (this._startPos.AktNode == this._endPos.AktNode) { if (this._startPos.PosAmNode > this._endPos.PosAmNode) { XMLCursorPositionen posAmNode = this._startPos.PosAmNode; int posImTextnode = this._startPos.PosImTextnode; this._startPos.CursorSetzen(this._endPos.AktNode, this._endPos.PosAmNode, this._endPos.PosImTextnode); this._endPos.CursorSetzen(this._endPos.AktNode, posAmNode, posImTextnode); } else if (this._startPos.PosAmNode == XMLCursorPositionen.CursorInnerhalbDesTextNodes && this._endPos.PosAmNode == XMLCursorPositionen.CursorInnerhalbDesTextNodes && this._startPos.PosImTextnode > this._endPos.PosImTextnode) { int posImTextnode = this._startPos.PosImTextnode; this._startPos.CursorSetzen(this._startPos.AktNode, XMLCursorPositionen.CursorInnerhalbDesTextNodes, this._endPos.PosImTextnode); this._endPos.CursorSetzen(this._startPos.AktNode, XMLCursorPositionen.CursorInnerhalbDesTextNodes, posImTextnode); } } else { if (ToolboxXML.Node1LiegtVorNode2(this._endPos.AktNode, this._startPos.AktNode)) { XMLCursorPos startPos = this._startPos; this._startPos = this._endPos; this._endPos = startPos; } if (ToolboxXML.IstChild(this._endPos.AktNode, this._startPos.AktNode)) { this.BeideCursorPosSetzen(this._startPos.AktNode, XMLCursorPositionen.CursorAufNodeSelbstVorderesTag); } if (this._startPos.AktNode.ParentNode != this._endPos.AktNode.ParentNode) { XmlNode xmlNode = this.TiefsterGemeinsamerParent(this._startPos.AktNode, this._endPos.AktNode); XmlNode aktNode1 = this._startPos.AktNode; while (aktNode1.ParentNode != xmlNode) { aktNode1 = aktNode1.ParentNode; } XmlNode aktNode2 = this._endPos.AktNode; while (aktNode2.ParentNode != xmlNode) { aktNode2 = aktNode2.ParentNode; } this._startPos.CursorSetzen(aktNode1, XMLCursorPositionen.CursorAufNodeSelbstVorderesTag); this._endPos.CursorSetzen(aktNode2, XMLCursorPositionen.CursorAufNodeSelbstVorderesTag); } } }
public bool Equals(XMLCursorPos zweitePos) { if (this.AktNode != zweitePos.AktNode) { return(false); } if (this.PosAmNode != zweitePos.PosAmNode) { return(false); } if (this._posImTextnode != zweitePos._posImTextnode) { return(false); } return(true); }
public void TextEinfuegen(string text, XMLRegelwerk regelwerk) { XMLCursor xmlCursor = this.Clone(); xmlCursor.SelektionOptimieren(); XMLCursorPos neueCursorPosNachLoeschen; XMLCursorPos xmlCursorPos = !xmlCursor.SelektionLoeschen(out neueCursorPosNachLoeschen) ? this.StartPos.Clone() : neueCursorPosNachLoeschen; XmlNode ersatzNode = (XmlNode)null; xmlCursorPos.TextEinfuegen(text, regelwerk, out ersatzNode); if (ersatzNode != null) { xmlCursorPos.InsertXMLNode(ersatzNode, regelwerk, false); } this.BeideCursorPosSetzen(xmlCursorPos.AktNode, xmlCursorPos.PosAmNode, xmlCursorPos.PosImTextnode); }
public void XMLNodeEinfuegen(XmlNode node, XMLRegelwerk regelwerk, bool neueCursorPosAufJedenFallHinterDenEingefuegtenNodeSetzen) { XMLCursor xMLCursor = this.Clone(); xMLCursor.SelektionOptimieren(); XMLCursorPos xMLCursorPos = default(XMLCursorPos); if (xMLCursor.SelektionLoeschen(out xMLCursorPos)) { this.BeideCursorPosSetzen(xMLCursorPos.AktNode, xMLCursorPos.PosAmNode, xMLCursorPos.PosImTextnode); } if (this._startPos.InsertXMLNode(node, regelwerk, neueCursorPosAufJedenFallHinterDenEingefuegtenNodeSetzen)) { this.EndPos.CursorSetzen(this.StartPos.AktNode, this.StartPos.PosAmNode, this.StartPos.PosImTextnode); } }
public void TextEinfuegen(string text, XMLRegelwerk regelwerk) { XMLCursor xMLCursor = this.Clone(); xMLCursor.SelektionOptimieren(); XMLCursorPos xMLCursorPos = default(XMLCursorPos); XMLCursorPos xMLCursorPos2 = (!xMLCursor.SelektionLoeschen(out xMLCursorPos)) ? this.StartPos.Clone() : xMLCursorPos; XmlNode xmlNode = null; xMLCursorPos2.TextEinfuegen(text, regelwerk, out xmlNode); if (xmlNode != null) { xMLCursorPos2.InsertXMLNode(xmlNode, regelwerk, false); } this.BeideCursorPosSetzen(xMLCursorPos2.AktNode, xMLCursorPos2.PosAmNode, xMLCursorPos2.PosImTextnode); }
public XMLCursor() { this._endPos = new XMLCursorPos(); this._startPos = new XMLCursorPos(); this.UnterEventsAnmelden(); }
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)); } }
public bool Equals(XMLCursorPos zweitePos) { return(this.AktNode == zweitePos.AktNode && this.PosAmNode == zweitePos.PosAmNode && this._posImTextnode == zweitePos._posImTextnode); }