Ejemplo n.º 1
0
        public static HyperlinkTextSource ReadXml(XmlReader reader)
        {
            HyperlinkTextSource psr = new HyperlinkTextSource();

            if (reader.HasAttributes)
            {
                psr.Self   = reader.GetAttribute("Self");
                psr.Name   = reader.GetAttribute("Name");
                psr.Hidden = Parser.ParseBoolean(reader.GetAttribute("Hidden"));
                psr.AppliedCharacterStyle = reader.GetAttribute("AppliedCharacterStyle");
            }

            if (reader.IsEmptyElement)
            {
                return(psr);
            }

            while (reader.Read())
            {
                switch (reader.Name)
                {
                case "Footnote":
                    psr.Children.Add(Footnote.ReadXml(reader));
                    break;

                case "GaijiOwnedItemObject":
                    psr.Children.Add(GaijiOwnedItemObject.ReadXml(reader));
                    break;

                case "Note":
                    psr.Children.Add(Note.ReadNote(reader));
                    break;

                case "Table":
                    psr.Children.Add(Table.ReadXml(reader));
                    break;

                case "TextVariableInstance":
                    psr.Children.Add(TextVariableInstance.ReadXml(reader));
                    break;

                case "HiddenText":
                    psr.Children.Add(HiddenText.ReadXml(reader));
                    break;

                case "XMLElement":
                    psr.Children.Add(XmlElement.ReadXml(reader));
                    break;

                case "CharacterStyleRange":
                    psr.Children.Add(CharacterStyleRange.ReadXml(reader));
                    break;

                case "Content":
                    psr.Children.Add(new Content(reader.ReadString()));
                    break;

                case "Br":
                    psr.Children.Add(new Br());
                    break;

                case "HyperlinkTextSource":
                    if (reader.NodeType == XmlNodeType.EndElement)
                    {
                        goto exit1;
                    }
                    break;

                default:
                    Debug.WriteLine("Unrecognized element: {0} in element: {1}", reader.Name, "HyperlinkTextSource");
                    break;
                }
            }

exit1:
            return(psr);
        }
Ejemplo n.º 2
0
        public static CharacterStyleRange ReadXml(XmlReader reader)
        {
            CharacterStyleRange csr = new CharacterStyleRange();

            if (reader.HasAttributes)
            {
                csr.AppliedCharacterStyle = reader.GetAttribute("AppliedCharacterStyle");
                csr.FillColor             = reader.GetAttribute("FillColor");
                csr.FontStyle             = reader.GetAttribute("FontStyle");
                csr.PointSize             = reader.GetAttribute("PointSize");
                csr.PositionValue         = (Position?)Parser.ParseEnum <Position>(reader.GetAttribute("Position"));
            }

            if (reader.IsEmptyElement)
            {
                return(csr);
            }

            while (reader.Read())
            {
                switch (reader.Name)
                {
                case "Properties":
                    while (reader.Read())
                    {
                        switch (reader.Name)
                        {
                        case "Leading":
                            csr.Leading = reader.ReadString();
                            break;

                        case "AppliedFont":
                            csr.AppliedFont = reader.ReadString();
                            break;

                        case "Properties":
                            if (reader.NodeType == XmlNodeType.EndElement)
                            {
                                goto exit1;
                            }

                            break;

                        default:
                            Debug.WriteLine("Unrecognized element: {0} in element: {1}", reader.Name, "CharacterStyleRange -> Properties");
                            break;
                        }
                    }
exit1:
                    break;

                case "Footnote":
                    csr.Children.Add(Footnote.ReadXml(reader));
                    break;

                case "GaijiOwnedItemObject":
                    csr.Children.Add(GaijiOwnedItemObject.ReadXml(reader));
                    break;

                case "Note":
                    csr.Children.Add(Note.ReadNote(reader));
                    break;

                case "Table":
                    csr.Children.Add(Table.ReadXml(reader));
                    break;

                case "TextVariableInstance":
                    csr.Children.Add(TextVariableInstance.ReadXml(reader));
                    break;

                //add more cases here
                case "XMLElement":
                    csr.Children.Add(XmlElement.ReadXml(reader));
                    break;

                case "HiddenText":
                    csr.Children.Add(HiddenText.ReadXml(reader));
                    break;

                case "Content":
                    csr.Children.Add(new Content(reader.ReadString()));
                    break;

                case "Br":
                    csr.Children.Add(new Br());
                    break;

                case "HyperlinkTextSource":
                    csr.Children.Add(HyperlinkTextSource.ReadXml(reader));
                    break;

                case "CharacterStyleRange":
                    if (reader.NodeType == XmlNodeType.EndElement)
                    {
                        goto exit2;
                    }
                    break;

                default:
                    Debug.WriteLine("Unrecognized element: {0} in element: {1}", reader.Name, "CharacterStyleRange");
                    break;
                }
            }

exit2:
            return(csr);
        }