Exemplo n.º 1
0
        public bool InsertXMLNode(
            XmlNode node,
            XMLRegelwerk regelwerk,
            bool neueCursorPosAufJedenFallHinterDenEingefuegtenNodeSetzen)
        {
            XmlNode parentNode = this.AktNode.ParentNode;

            switch (this.PosAmNode)
            {
            case XMLCursorPositionen.CursorVorDemNode:
                parentNode.InsertBefore(node, this.AktNode);
                break;

            case XMLCursorPositionen.CursorAufNodeSelbstVorderesTag:
            case XMLCursorPositionen.CursorAufNodeSelbstHinteresTag:
                parentNode.ReplaceChild(node, this.AktNode);
                break;

            case XMLCursorPositionen.CursorInDemLeeremNode:
                this.AktNode.AppendChild(node);
                break;

            case XMLCursorPositionen.CursorInnerhalbDesTextNodes:
                string  text1     = this.AktNode.InnerText.Substring(0, this.PosImTextnode);
                XmlNode textNode1 = (XmlNode)parentNode.OwnerDocument.CreateTextNode(text1);
                string  text2     = this.AktNode.InnerText.Substring(this.PosImTextnode, this.AktNode.InnerText.Length - this.PosImTextnode);
                XmlNode textNode2 = (XmlNode)parentNode.OwnerDocument.CreateTextNode(text2);
                parentNode.ReplaceChild(textNode1, this.AktNode);
                parentNode.InsertAfter(node, textNode1);
                parentNode.InsertAfter(textNode2, node);
                break;

            case XMLCursorPositionen.CursorHinterDemNode:
                parentNode.InsertAfter(node, this.AktNode);
                break;

            default:
                throw new ApplicationException(string.Format("InsertElementAnCursorPos: Unbekannte PosAmNode {0}", (object)this.PosAmNode));
            }
            if (neueCursorPosAufJedenFallHinterDenEingefuegtenNodeSetzen)
            {
                this.CursorSetzen(node, XMLCursorPositionen.CursorHinterDemNode);
            }
            else if (regelwerk.IstSchliessendesTagSichtbar(node))
            {
                this.CursorSetzen(node, XMLCursorPositionen.CursorInDemLeeremNode);
            }
            else
            {
                this.CursorSetzen(node, XMLCursorPositionen.CursorHinterDemNode);
            }
            return(true);
        }
Exemplo n.º 2
0
        public bool MoveRight(XmlNode rootnode, XMLRegelwerk regelwerk)
        {
            XmlNode aktNode = this.AktNode;

            switch (this.PosAmNode)
            {
            case XMLCursorPositionen.CursorAufNodeSelbstVorderesTag:
            case XMLCursorPositionen.CursorAufNodeSelbstHinteresTag:
                this.CursorSetzen(this.AktNode, XMLCursorPositionen.CursorHinterDemNode);
                goto IL_0208;

            case XMLCursorPositionen.CursorHinterDemNode:
                if (aktNode.NextSibling != null)
                {
                    this.CursorSetzen(aktNode.NextSibling, XMLCursorPositionen.CursorVorDemNode);
                    this.MoveRight(rootnode, regelwerk);
                    goto IL_0208;
                }
                if (aktNode.ParentNode != rootnode)
                {
                    this.CursorSetzen(aktNode.ParentNode, XMLCursorPositionen.CursorHinterDemNode);
                    if (!regelwerk.IstSchliessendesTagSichtbar(aktNode.ParentNode))
                    {
                        this.MoveRight(rootnode, regelwerk);
                    }
                    goto IL_0208;
                }
                return(false);

            case XMLCursorPositionen.CursorInDemLeeremNode:
                this.CursorSetzen(this.AktNode, XMLCursorPositionen.CursorHinterDemNode);
                goto IL_0208;

            case XMLCursorPositionen.CursorVorDemNode:
                if (ToolboxXML.IstTextOderKommentarNode(aktNode))
                {
                    if (ToolboxXML.TextAusTextNodeBereinigt(aktNode).Length > 1)
                    {
                        this.CursorSetzen(this.AktNode, XMLCursorPositionen.CursorInnerhalbDesTextNodes, 1);
                    }
                    else
                    {
                        this.CursorSetzen(this.AktNode, XMLCursorPositionen.CursorHinterDemNode);
                    }
                }
                else if (aktNode.ChildNodes.Count < 1)
                {
                    if (!regelwerk.IstSchliessendesTagSichtbar(aktNode))
                    {
                        this.CursorSetzen(this.AktNode, XMLCursorPositionen.CursorHinterDemNode);
                    }
                    else
                    {
                        this.CursorSetzen(this.AktNode, XMLCursorPositionen.CursorInDemLeeremNode);
                    }
                }
                else
                {
                    this.CursorSetzen(aktNode.FirstChild, XMLCursorPositionen.CursorVorDemNode);
                }
                goto IL_0208;

            case XMLCursorPositionen.CursorInnerhalbDesTextNodes:
                if (ToolboxXML.IstTextOderKommentarNode(aktNode))
                {
                    if (ToolboxXML.TextAusTextNodeBereinigt(aktNode).Length > this.PosImTextnode + 1)
                    {
                        this.CursorSetzen(this.AktNode, this.PosAmNode, this.PosImTextnode + 1);
                    }
                    else
                    {
                        this.CursorSetzen(this.AktNode, XMLCursorPositionen.CursorHinterDemNode);
                    }
                    goto IL_0208;
                }
                throw new ApplicationException(string.Format("XMLCurorPos.MoveRight: CursorPos ist XMLCursorPositionen.CursorInnerhalbDesTextNodes, es ist aber kein Textnode gewählt, sondern der Node {0}", aktNode.OuterXml));

            default:
            {
                throw new ApplicationException(string.Format("XMLCurorPos.MoveRight: Unbekannte CursorPos {0}", this.PosAmNode));
            }
IL_0208:
                return(true);
            }
        }
Exemplo n.º 3
0
        public bool MoveLeft(XmlNode rootnode, XMLRegelwerk regelwerk)
        {
            XmlNode aktNode = this.AktNode;

            switch (this.PosAmNode)
            {
            case XMLCursorPositionen.CursorVorDemNode:
                if (aktNode == rootnode)
                {
                    return(false);
                }
                if (aktNode.PreviousSibling != null)
                {
                    this.CursorSetzen(aktNode.PreviousSibling, XMLCursorPositionen.CursorHinterDemNode);
                    this.MoveLeft(rootnode, regelwerk);
                    break;
                }
                this.CursorSetzen(aktNode.ParentNode, XMLCursorPositionen.CursorVorDemNode);
                break;

            case XMLCursorPositionen.CursorAufNodeSelbstVorderesTag:
            case XMLCursorPositionen.CursorAufNodeSelbstHinteresTag:
                this.CursorSetzen(this.AktNode, XMLCursorPositionen.CursorVorDemNode);
                break;

            case XMLCursorPositionen.CursorInDemLeeremNode:
                this.CursorSetzen(this.AktNode, XMLCursorPositionen.CursorVorDemNode);
                break;

            case XMLCursorPositionen.CursorInnerhalbDesTextNodes:
                if (!ToolboxXML.IstTextOderKommentarNode(aktNode))
                {
                    throw new ApplicationException(string.Format("XMLCursorPos.MoveLeft: CursorPos ist XMLCursorPositionen.CursorInnerhalbDesTextNodes, es ist aber kein Textnode gewählt, sondern der Node {0}", (object)aktNode.OuterXml));
                }
                if (this.PosImTextnode > 1)
                {
                    this.CursorSetzen(this.AktNode, this.PosAmNode, this.PosImTextnode - 1);
                    break;
                }
                this.CursorSetzen(this.AktNode, XMLCursorPositionen.CursorVorDemNode);
                break;

            case XMLCursorPositionen.CursorHinterDemNode:
                if (ToolboxXML.IstTextOderKommentarNode(aktNode))
                {
                    this.CursorSetzen(aktNode, XMLCursorPositionen.CursorInnerhalbDesTextNodes, Math.Max(0, ToolboxXML.TextAusTextNodeBereinigt(aktNode).Length - 1));
                    break;
                }
                if (aktNode.ChildNodes.Count < 1)
                {
                    if (regelwerk.IstSchliessendesTagSichtbar(aktNode))
                    {
                        this.CursorSetzen(this.AktNode, XMLCursorPositionen.CursorInDemLeeremNode);
                    }
                    else
                    {
                        this.CursorSetzen(this.AktNode, XMLCursorPositionen.CursorVorDemNode);
                    }
                }
                else
                {
                    this.CursorSetzen(aktNode.LastChild, XMLCursorPositionen.CursorHinterDemNode);
                }
                break;

            default:
                throw new ApplicationException(string.Format("XMLCursorPos.MoveLeft: Unbekannte CursorPos {0}", (object)this.PosAmNode));
            }
            return(true);
        }