Beispiel #1
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);
        }
Beispiel #2
0
        public virtual Paragraph InsertParagraph(string text, bool trackChanges, Formatting formatting)
        {
            var 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);
            }

            this.Xml.Add(newParagraph);

            var newParagraphAdded = new Paragraph(this.Document, newParagraph, 0);
            var cell = this as Cell;

            if (cell != null)
            {
                newParagraphAdded.PackagePart = cell.PackagePart;
            }
            else
            {
                var docx = this as DocX;
                if (docx != null)
                {
                    newParagraphAdded.PackagePart = this.Document.PackagePart;
                }
                else
                {
                    var footer = this as Footer;
                    if (footer != null)
                    {
                        newParagraphAdded.PackagePart = footer.PackagePart;
                    }
                    else
                    {
                        var header = this as Header;
                        if (header != null)
                        {
                            newParagraphAdded.PackagePart = header.PackagePart;
                        }
                        else
                        {
                            newParagraphAdded.PackagePart = this.Document.PackagePart;
                        }
                    }
                }
            }

            this.SetParentContainer(newParagraphAdded);

            return(newParagraphAdded);
        }