FormatInput() static private method

static private FormatInput ( string text, System.Xml.Linq.XElement rPr ) : List
text string
rPr System.Xml.Linq.XElement
return List
示例#1
0
文件: Container.cs 项目: ruo2012/DocX
        public virtual Paragraph InsertParagraph(string text, bool trackChanges, Formatting formatting)
        {
            XElement newParagraph = new XElement
                                    (
                XName.Get("p", DocX.w.NamespaceName), new XElement(XName.Get("pPr", DocX.w.NamespaceName)), HelperFunctions.FormatInput(text, formatting.Xml)
                                    );

            if (trackChanges)
            {
                newParagraph = HelperFunctions.CreateEdit(EditType.ins, DateTime.Now, newParagraph);
            }
            Xml.Add(newParagraph);
            var paragraphAdded = new Paragraph(Document, newParagraph, 0);

            if (this is Cell)
            {
                var cell = this as Cell;
                paragraphAdded.PackagePart = cell.mainPart;
            }
            else if (this is DocX)
            {
                paragraphAdded.PackagePart = Document.mainPart;
            }
            else if (this is Footer)
            {
                var f = this as Footer;
                paragraphAdded.mainPart = f.mainPart;
            }
            else if (this is Header)
            {
                var h = this as Header;
                paragraphAdded.mainPart = h.mainPart;
            }
            else
            {
                Console.WriteLine("No idea what we are {0}", this);
                paragraphAdded.PackagePart = Document.mainPart;
            }


            GetParent(paragraphAdded);

            return(paragraphAdded);
        }
示例#2
0
        public virtual Paragraph InsertParagraph(string text, bool trackChanges, Formatting formatting)
        {
            XElement xElement = new XElement(XName.Get("p", DocX.w.NamespaceName), new XElement(XName.Get("pPr", DocX.w.NamespaceName)), HelperFunctions.FormatInput(text, formatting.Xml));

            if (trackChanges)
            {
                xElement = HelperFunctions.CreateEdit(EditType.ins, DateTime.Now, xElement);
            }
            base.Xml.Add(xElement);
            Paragraph paragraph = new Paragraph(base.Document, xElement, 0);

            if (this is Cell)
            {
                Cell cell = this as Cell;
                paragraph.PackagePart = cell.mainPart;
            }
            else if (this is DocX)
            {
                paragraph.PackagePart = base.Document.mainPart;
            }
            else if (this is Footer)
            {
                Footer footer = this as Footer;
                paragraph.mainPart = footer.mainPart;
            }
            else if (this is Header)
            {
                Header header = this as Header;
                paragraph.mainPart = header.mainPart;
            }
            else
            {
                Console.WriteLine("No idea what we are {0}", this);
                paragraph.PackagePart = base.Document.mainPart;
            }
            GetParent(paragraph);
            return(paragraph);
        }
示例#3
0
        public virtual Paragraph InsertParagraphAfterSelf(string text, bool trackChanges, Formatting formatting)
        {
            XElement newParagraph = new XElement
                                    (
                XName.Get("p", DocX.w.NamespaceName), new XElement(XName.Get("pPr", DocX.w.NamespaceName)), HelperFunctions.FormatInput(text, formatting.Xml)
                                    );

            if (trackChanges)
            {
                newParagraph = Paragraph.CreateEdit(EditType.ins, DateTime.Now, newParagraph);
            }

            Xml.AddAfterSelf(newParagraph);
            XElement newlyInserted = Xml.ElementsAfterSelf().First();

            Paragraph p = new Paragraph(Document, newlyInserted, -1);

            return(p);
        }
示例#4
0
        public virtual Paragraph InsertParagraph(string text, bool trackChanges, Formatting formatting)
        {
            XElement newParagraph = new XElement
                                    (
                XName.Get("p", DocX.w.NamespaceName), new XElement(XName.Get("pPr", DocX.w.NamespaceName)), HelperFunctions.FormatInput(text, formatting.Xml)
                                    );

            if (trackChanges)
            {
                newParagraph = HelperFunctions.CreateEdit(EditType.ins, DateTime.Now, newParagraph);
            }

            Xml.Add(newParagraph);

            var paragraphAdded = Paragraphs.Last();

            GetParent(paragraphAdded);

            return(paragraphAdded);
        }
示例#5
0
        public virtual Paragraph InsertParagraphAfterSelf(string text, bool trackChanges, Formatting formatting)
        {
            XElement content = new XElement(XName.Get("p", DocX.w.NamespaceName), new XElement(XName.Get("pPr", DocX.w.NamespaceName)), HelperFunctions.FormatInput(text, formatting.Xml));

            if (trackChanges)
            {
                content = Paragraph.CreateEdit(EditType.ins, DateTime.Now, content);
            }
            base.Xml.AddAfterSelf(content);
            XElement xml = base.Xml.ElementsAfterSelf().First();

            return(new Paragraph(base.Document, xml, -1));
        }