ParagraphItemCollection

Namespace: Spire.Doc
We found 10 examples in language CSharp for this search. You will see 47 fragments of code.

        internal void method_22(ParagraphItemCollection A_0)
        {
            int num = 0;
            int count = base.Count;
            while (num < count)
            {
                ParagraphBase base2 = (ParagraphBase) this[num].Clone();
                if (base2 != null)
                {
                    base2.method_0(A_0.Owner);
                    A_0.method_25(base2);
                }
                num++;
            }
        }


    private static void smethod_7(ParagraphItemCollection A_0, int A_1, int A_2)
    {
        int num = A_1;
        int count = A_0.Count;
        while (num < count)
        {
            ParagraphBase base2 = A_0[num];
            base2.StartPos += A_2;
            num++;
        }
    }

        BookmarkEnd AppendBookmarkEnd(string name);
        BookmarkStart AppendBookmarkStart(string name);
        Break AppendBreak(BreakType breakType);
        CheckBoxFormField AppendCheckBox();
        CheckBoxFormField AppendCheckBox(string checkBoxName, bool defaultCheckBoxValue);
        Comment AppendComment(string text);


        internal override bool Accept(Class420 visitor)
        {
            return base.method_9(visitor);
        }

        internal override VisitorAction AcceptEnd(Class420 visitor)
        {
            return visitor.vmethod_45(this);
        }

        internal override VisitorAction AcceptStart(Class420 visitor)
        {
            return visitor.vmethod_44(this);
        }

        protected override object CloneImpl()
        {
            StructureDocumentTagInline inline = (StructureDocumentTagInline) base.CloneImpl();
            inline.sdtproperties_0 = this.SDTProperties.method_9();
            inline.sdtproperties_0.method_7(inline);
            inline.sdtinlineContent_0 = this.SDTContent.method_25();
            inline.sdtinlineContent_0.method_0(inline);
            inline.bool_9 = false;
            return inline;
        }

        internal StructureDocumentTagInline method_30()
        {
            return (StructureDocumentTagInline) this.CloneImpl();
        }

        internal void method_31()
        {
            IParagraphStyle style = base.OwnerParagraph.GetStyle();
            if (style != null)
            {
                this.CharacterFormat.ApplyBase(style.CharacterFormat);
                for (int i = 0; i < this.SDTContent.Items.Count; i++)
                {
                    this.SDTContent.Items[i].CharacterFormat.ApplyBase(style.CharacterFormat);
                }
            }
        }


        internal override bool Accept(Class420 visitor)
        {
            return base.method_9(visitor);
        }

        public void ApplyCharacterFormat(Spire.Doc.Formatting.CharacterFormat charFormat)
        {
            if (charFormat != null)
            {
                this.m_charFormat = charFormat.method_23() as Spire.Doc.Formatting.CharacterFormat;
                this.m_charFormat.method_0(this);
            }
        }

        public void ApplyStyle(string styleName)
        {
            int num = 10;
            Class11 style = base.Document.Styles.FindByName(styleName, StyleType.CharacterStyle) as Class11;
            if ((style == null) && (styleName.ToLower() == BookmarkStart.b("启圱刳圵䴷嘹䠻ḽ〿⍁㙃❅⽇㡉ⵋ㹍㡏牑㉓㥕㙗⹙", num)))
            {
                style = (Class11) Style.CreateBuiltinStyle(BuiltinStyle.DefaultParagraphFont, base.Document);
                base.Document.Styles.Add(style);
            }
            if (style == null)
            {
                throw new ArgumentException(BookmarkStart.b("匯娱唳䐵夷夹䠻嬽㈿扁㝃㉅ㅇ♉⥋湍㍏㍑㩓癕㙗㕙⡛繝ɟݡ䑣eݧὩɫ੭幯", num));
            }
            this.method_23(style);
        }

        internal virtual void Attach(Paragraph owner, int itemPos)
        {
            int num = 14;
            if (owner == null)
            {
                throw new ArgumentNullException(BookmarkStart.b("嬳䄵嘷弹主", num));
            }
            if (owner != this.OwnerParagraph)
            {
                throw new InvalidOperationException();
            }
            if (this.ItemDetached)
            {
                throw new InvalidOperationException();
            }
            if (this.OwnerParagraph.BreakCharacterFormat.BaseFormat != null)
            {
                this.CharacterFormat.ApplyBase(this.OwnerParagraph.BreakCharacterFormat.BaseFormat);
            }
            this.StartPos = itemPos;
        }

        internal virtual void Attach(SDTInlineContent owner, int itemPos)
        {
            int num = 1;
            if (owner == null)
            {
                throw new ArgumentNullException(BookmarkStart.b("䠦帨䔪䠬崮", num));
            }
            if (this.ItemDetached)
            {
                throw new InvalidOperationException();
            }
            if (owner.OwnerParagraph.BreakCharacterFormat.BaseFormat != null)
            {
                this.CharacterFormat.ApplyBase(owner.OwnerParagraph.BreakCharacterFormat.BaseFormat);
            }
            this.StartPos = itemPos;
        }

        protected override object CloneImpl()
        {
            ParagraphBase base2 = (ParagraphBase) base.CloneImpl();
            if (this.m_charFormat != null)
            {
                base2.m_charFormat = new Spire.Doc.Formatting.CharacterFormat(base.Document);
                base2.m_charFormat.ImportContainer(this.m_charFormat);
                base2.m_charFormat.method_21(this.m_charFormat);
                base2.m_charFormat.method_0(base2);
            }
            base2.interface23_0 = null;
            return base2;
        }


        internal override bool Accept(Class420 visitor)
        {
            return base.method_9(visitor);
        }

        internal override void AcceptCChanges()
        {
            if (this.characterFormat_0 != null)
            {
                this.characterFormat_0.AcceptChanges();
            }
        }

        internal override VisitorAction AcceptEnd(Class420 visitor)
        {
            return visitor.vmethod_9(this);
        }

        internal override void AcceptPChanges()
        {
            if (this.m_prFormat != null)
            {
                this.m_prFormat.AcceptChanges();
            }
        }

        internal override VisitorAction AcceptStart(Class420 visitor)
        {
            return visitor.vmethod_8(this);
        }

        public BookmarkEnd AppendBookmarkEnd(string name)
        {
            BookmarkEnd entity = new BookmarkEnd(base.Document, name);
            this.Items.Add(entity);
            return entity;
        }

        #endregion

        #region Internal Methods
        internal void Remove()
        {
            if (_paragraph != null) _paragraph.Remove();
        }
        #endregion

        #region Private Methods
        private IEnumerable<DocumentElement> ChildObjectsPrivate()
        {
            foreach (O.OpenXmlElement ele in _paragraph.ChildElements)
            {
                if (ele.GetType() == typeof(W.Run))
                    yield return new TextRange(_doc, ele as W.Run);
            }
        }

        /// <summary>
        /// 添加批注
        /// </summary>
        /// <param name="author">作者</param>
        /// <param name="content">内容</param>
        private void AppendComment(string author, string content)
        {
            int id = 0; // 新批注Id
            P.WordprocessingCommentsPart part = _doc.Package.MainDocumentPart.WordprocessingCommentsPart;
            if (part == null)
            {
                part = _doc.Package.MainDocumentPart.AddNewPart<P.WordprocessingCommentsPart>();
                part.Comments = new W.Comments();
            }
            W.Comments comments = part.Comments;
            // Id 值为当前批注最大值加1
            List<int> ids = new List<int>();
            foreach (W.Comment c in comments)
                ids.Add(c.Id.Value.ToInt());
            if (ids.Count > 0)
            {
                ids.Sort();
                id = ids.Last() + 1;
            }
            // 设置批注内容
            W.Paragraph paragraph = new W.Paragraph(new W.Run(new W.Text(content)));
            W.Comment comment = new W.Comment(paragraph) { Id = id.ToString(), Author = author };
            comments.AppendChild(comment);
            // 插入批注标记
            W.CommentRangeStart start = new W.CommentRangeStart() { Id = id.ToString() };
            W.Run run = new W.Run(new W.CommentReference() { Id = id.ToString() });
            W.CommentRangeEnd end = new W.CommentRangeEnd() { Id = id.ToString() };
            _paragraph.InsertAt(start, 0);
            _paragraph.AppendChild(end);
            _paragraph.AppendChild(run);
        }

        # region Page Load
        /// <summary>
        /// Handles page load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        # endregion

        # region Events
        /// <summary>
        /// Creates spreadsheet
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button1_Click(object sender, EventArgs e)
        {
            //Loads the template document.
            WordDocument document = new WordDocument(Path.Combine(ResolveApplicationDataPath(string.Empty), @"TemplateUpdateFields.docx"));

            //Initialize DataSet object.
            DataSet ds = new DataSet();

            //Load data from the xml document.
            ds.ReadXml(Path.Combine(ResolveApplicationDataPath(string.Empty), @"StockDetails.xml"));

            // Execute Mail Merge with groups.
            document.MailMerge.ExecuteGroup(ds.Tables["StockDetails"]);

            //Update fields in the document.
            document.UpdateDocumentFields();

            //Unlink the fields in Word document when UnlinkFields is enable.
            if (UnlinkCheckBox.Checked)
                UnlinkFieldsInDocument(document);

            if (rdButtonDoc.Checked)
            {
                //Save as .doc format
                document.Save("Update Fields.doc", FormatType.Doc, Response, HttpContentDisposition.Attachment);
            }
            //Save as .docx format
            else if (rdButtonDocx.Checked)
            {
                try
                {
                    document.Save("Update Fields.docx", FormatType.Docx, Response, HttpContentDisposition.Attachment);
                }
                catch (Win32Exception ex)
                {
                    Response.Write("Microsoft Word Viewer or Microsoft Word is not installed in this system");
                    Console.WriteLine(ex.ToString());
                }
            }
            //Save as .xml(WordML) format
            else if (rdButtonWordML.Checked)
            {
                try
                {
                    document.Save("Update Fields.xml", FormatType.WordML, Response, HttpContentDisposition.Attachment);
                }
                catch (Win32Exception ex)
                {
                    Response.Write("Microsoft Word Viewer or Microsoft Word is not installed in this system");
                    Console.WriteLine(ex.ToString());
                }
            }
            //Save as .pdf format
            else if (rdButtonPdf.Checked)
            {
                try
                {
                DocToPDFConverter converter = new DocToPDFConverter();
                PdfDocument pdfDoc = converter.ConvertToPDF(document);

                pdfDoc.Save("Update Fields.pdf", Response, HttpReadType.Save);
                }
                catch (Win32Exception ex)
                {
                    Response.Write("PDF Viewer is not installed in this system");
                    Console.WriteLine(ex.ToString());
                }
            }
        }
        #region Iterates into document for removing field codes.       
        /// <summary>
        /// Iterates to document elements and get fields.
        /// </summary>
        /// <param name="document">Input Word document.</param>
        /// <param name="fieldType">Type of the field to find in document.</param>
        private void UnlinkFieldsInDocument(WordDocument document)
        {
            //Iterates each section and get the tables.
            foreach (WSection section in document.Sections)
            {
                RemoveFieldCodesInTextBody(section.Body);
            }
        }

        /// <summary>
        /// Iterates into body items.
        /// </summary>
        private void RemoveFieldCodesInTextBody(WTextBody textBody)
        {
            for (int i = 0; i < textBody.ChildEntities.Count; i++)
            {
                //IEntity is the basic unit in DocIO DOM.                 
                IEntity bodyItemEntity = textBody.ChildEntities[i];

                //A Text body has 3 types of elements - Paragraph, Table, and Block Content Control
                //Decides the element type by using EntityType
                switch (bodyItemEntity.EntityType)
                {
                    case EntityType.Paragraph:
                        WParagraph paragraph = bodyItemEntity as WParagraph;
                        //Iterates into paragraph items.
                        RemoveFieldCodesInParagraph(paragraph.Items);
                        break;

                    case EntityType.Table:
                        //Table is a collection of rows and cells
                        //Iterates through table's DOM                        
                        RemoveFieldCodesInTable(bodyItemEntity as WTable);
                        break;

                    case EntityType.BlockContentControl:
                        BlockContentControl blockContentControl = bodyItemEntity as BlockContentControl;
                        //Iterates to the body items of Block Content Control.
                        RemoveFieldCodesInTextBody(blockContentControl.TextBody);
                        break;
                }
            }
        }

        /// <summary>
        /// Iterates into paragraph items.
        /// </summary>
        /// <param name="paragraph">The paragraph.</param>
        /// <param name="fieldType">Type of field.</param>
        private void RemoveFieldCodesInParagraph(ParagraphItemCollection paraItems)
        {
            for (int i = 0; i < paraItems.Count; i++)
            {
                if (paraItems[i] is WField)
                {
                    WField field = paraItems[i] as WField;
                   field.Unlink();
                }
                else if (paraItems[i] is WTextBox)
                {
                    //If paragraph item is textbox, iterates into textbody of textbox.
                    WTextBox textBox = paraItems[i] as WTextBox;
                    RemoveFieldCodesInTextBody(textBox.TextBoxBody);
                }
                else if (paraItems[i] is Shape)
                {
                    //If paragraph item is shape, iterates into textbody of shape.
                    Shape shape = paraItems[i] as Shape;
                    RemoveFieldCodesInTextBody(shape.TextBody);
                }
                else if (paraItems[i] is InlineContentControl)
                {
                    //If paragraph item is inline content control, iterates into its item.
                    InlineContentControl inlineContentControl = paraItems[i] as InlineContentControl;
                    RemoveFieldCodesInParagraph(inlineContentControl.ParagraphItems);
                }
            }
        }
        /// <summary>
        /// Iterates into table.
        /// </summary>
        /// <param name="table">The table.</param>
        /// <param name="fieldType">Type of Field.</param>
        private void RemoveFieldCodesInTable(WTable table)
        {
            //Iterates the row collection in a table
            foreach (WTableRow row in table.Rows)
            {
                //Iterates the cell collection in a table row
                foreach (WTableCell cell in row.Cells)
                {
                    RemoveFieldCodesInTextBody(cell);
                }
            }
        }

        #region Update Fields
        public ActionResult UpdateFields(string Group1, string Button, string UnlinkFields)
        {
            string basePath = _hostingEnvironment.WebRootPath;         
            string dataPath = basePath + @"/DocIO/TemplateUpdateFields.docx";
            FileStream fileStream = new FileStream(dataPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            if (Group1 == null)
                return View();
            string contenttype1 = "application/vnd.ms-word.document.12";
            if (Button == "View Template")
            {
                return File(fileStream, contenttype1, "TemplateUpdateFields.docx");
            }
            //Loads the template document.
            string dataPathField = basePath + @"/DocIO/TemplateUpdateFields.docx";
            FileStream fileStreamField = new FileStream(dataPathField, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            WordDocument document = new WordDocument(fileStreamField,FormatType.Docx);
            fileStreamField.Dispose();
            fileStreamField = null;
            
            //Create MailMergeDataTable
            MailMergeDataTable mailMergeDataTableStock = GetMailMergeDataTableStock();
            // Execute Mail Merge with groups.
            document.MailMerge.ExecuteGroup(mailMergeDataTableStock);

            //Update fields in the document.
            document.UpdateDocumentFields();

            //Unlink the fields in Word document when UnlinkFields is enable.
            if (UnlinkFields == "UnlinkFields")
                UnlinkFieldsInDocument(document);

            FormatType type = FormatType.Docx;
            string filename = "Update Fields.docx";
            string contenttype = "application/vnd.ms-word.document.12";
            #region Document SaveOption
            //Save as .doc format
            if (Group1 == "WordDoc")
            {
                type = FormatType.Doc;
                filename = "Update Fields.doc";
                contenttype = "application/msword";
            }
            //Save as .xml format
            else if (Group1 == "WordML")
            {
                type = FormatType.WordML;
                filename = "Update Fields.xml";
                contenttype = "application/msword";
            }
            #endregion Document SaveOption
            MemoryStream ms = new MemoryStream();
            document.Save(ms, type);
            document.Close();
            ms.Position = 0;
            return File(ms, contenttype, filename);
        }
        #endregion Update Fields

        #region Iterates into document for removing field codes.       
        /// <summary>
        /// Iterates to document elements and get fields.
        /// </summary>
        /// <param name="document">Input Word document.</param>
        /// <param name="fieldType">Type of the field to find in document.</param>
        private void UnlinkFieldsInDocument(WordDocument document)
        {
            //Iterates each section and get the tables.
            foreach (WSection section in document.Sections)
            {
                RemoveFieldCodesInTextBody(section.Body);
            }
        }

        /// <summary>
        /// Iterates into body items.
        /// </summary>
        private void RemoveFieldCodesInTextBody(WTextBody textBody)
        {
            for (int i = 0; i < textBody.ChildEntities.Count; i++)
            {
                //IEntity is the basic unit in DocIO DOM.                 
                IEntity bodyItemEntity = textBody.ChildEntities[i];

                //A Text body has 3 types of elements - Paragraph, Table, and Block Content Control
                //Decides the element type by using EntityType
                switch (bodyItemEntity.EntityType)
                {
                    case EntityType.Paragraph:
                        WParagraph paragraph = bodyItemEntity as WParagraph;
                        //Iterates into paragraph items.
                        RemoveFieldCodesInParagraph(paragraph.Items);
                        break;

                    case EntityType.Table:
                        //Table is a collection of rows and cells
                        //Iterates through table's DOM                        
                        RemoveFieldCodesInTable(bodyItemEntity as WTable);
                        break;

                    case EntityType.BlockContentControl:
                        BlockContentControl blockContentControl = bodyItemEntity as BlockContentControl;
                        //Iterates to the body items of Block Content Control.
                        RemoveFieldCodesInTextBody(blockContentControl.TextBody);
                        break;
                }
            }
        }

        /// <summary>
        /// Iterates into paragraph items.
        /// </summary>
        /// <param name="paragraph">The paragraph.</param>
        /// <param name="fieldType">Type of field.</param>
        private void RemoveFieldCodesInParagraph(ParagraphItemCollection paraItems)
        {
            for (int i = 0; i < paraItems.Count; i++)
            {
                if (paraItems[i] is WField)
                {
                    WField field = paraItems[i] as WField;
                    field.Unlink();
                }
                else if (paraItems[i] is WTextBox)
                {
                    //If paragraph item is textbox, iterates into textbody of textbox.
                    WTextBox textBox = paraItems[i] as WTextBox;
                    RemoveFieldCodesInTextBody(textBox.TextBoxBody);
                }
                else if (paraItems[i] is Shape)
                {
                    //If paragraph item is shape, iterates into textbody of shape.
                    Shape shape = paraItems[i] as Shape;
                    RemoveFieldCodesInTextBody(shape.TextBody);
                }
                else if (paraItems[i] is InlineContentControl)
                {
                    //If paragraph item is inline content control, iterates into its item.
                    InlineContentControl inlineContentControl = paraItems[i] as InlineContentControl;
                    RemoveFieldCodesInParagraph(inlineContentControl.ParagraphItems);
                }
            }
        }
        /// <summary>
        /// Iterates into table.
        /// </summary>
        /// <param name="table">The table.</param>
        /// <param name="fieldType">Type of Field.</param>
        private void RemoveFieldCodesInTable(WTable table)
        {
            //Iterates the row collection in a table
            foreach (WTableRow row in table.Rows)
            {
                //Iterates the cell collection in a table row
                foreach (WTableCell cell in row.Cells)
                {
                    RemoveFieldCodesInTextBody(cell);
                }
            }
        }
        #endregion

        /// <summary>
        /// Gets the mail merge data table.
        /// </summary>       
        private MailMergeDataTable GetMailMergeDataTableStock()
        {
            List<StockDetails> stockDetails = new List<StockDetails>();
            FileStream fs = new FileStream(_hostingEnvironment.WebRootPath + @"/DocIO/StockDetails.xml", FileMode.Open, FileAccess.Read);
            XmlReader reader = XmlReader.Create(fs);
            if (reader == null)
                throw new Exception("reader");
            while (reader.NodeType != XmlNodeType.Element)
                reader.Read();
            if (reader.LocalName != "StockMarket")
                throw new XmlException("Unexpected xml tag " + reader.LocalName);
            reader.Read();
            while (reader.NodeType == XmlNodeType.Whitespace)
                reader.Read();
            while (reader.LocalName != "StockMarket")
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.LocalName)
                    {
                        case "StockDetails":
                            stockDetails.Add(GetStockDetails(reader));
                            break;
                    }
                }
                else
                {
                    reader.Read();
                    if ((reader.LocalName == "StockMarket") && reader.NodeType == XmlNodeType.EndElement)
                        break;
                }
            }
            MailMergeDataTable dataTable = new MailMergeDataTable("StockDetails", stockDetails);
            reader.Dispose();
            fs.Dispose();
            return dataTable;
        }

        # region Page Load
        /// <summary>
        /// Handles page load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        # endregion

        # region Events
        /// <summary>
        /// Creates spreadsheet
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button1_Click(object sender, EventArgs e)
        {
            //Loads the template document.
            WordDocument document = new WordDocument(Path.Combine(ResolveApplicationDataPath(string.Empty), @"TemplateUpdateFields.docx"));

            //Initialize DataSet object.
            DataSet ds = new DataSet();

            //Load data from the xml document.
            ds.ReadXml(Path.Combine(ResolveApplicationDataPath(string.Empty), @"StockDetails.xml"));

            // Execute Mail Merge with groups.
            document.MailMerge.ExecuteGroup(ds.Tables["StockDetails"]);

            //Update fields in the document.
            document.UpdateDocumentFields();

            //Unlink the fields in Word document when UnlinkFields is enable.
            if (UnlinkCheckBox.Checked)
                UnlinkFieldsInDocument(document);

            if (rdButtonDoc.Checked)
            {
                //Save as .doc format
                document.Save("Update Fields.doc", FormatType.Doc, Response, HttpContentDisposition.Attachment);
            }
            //Save as .docx format
            else if (rdButtonDocx.Checked)
            {
                try
                {
                    document.Save("Update Fields.docx", FormatType.Docx, Response, HttpContentDisposition.Attachment);
                }
                catch (Win32Exception ex)
                {
                    Response.Write("Microsoft Word Viewer or Microsoft Word is not installed in this system");
                    Console.WriteLine(ex.ToString());
                }
            }
            //Save as .xml(WordML) format
            else if (rdButtonWordML.Checked)
            {
                try
                {
                    document.Save("Update Fields.xml", FormatType.WordML, Response, HttpContentDisposition.Attachment);
                }
                catch (Win32Exception ex)
                {
                    Response.Write("Microsoft Word Viewer or Microsoft Word is not installed in this system");
                    Console.WriteLine(ex.ToString());
                }
            }
            //Save as .pdf format
            else if (rdButtonPdf.Checked)
            {
                try
                {
                DocToPDFConverter converter = new DocToPDFConverter();
                PdfDocument pdfDoc = converter.ConvertToPDF(document);

                pdfDoc.Save("Update Fields.pdf", Response, HttpReadType.Save);
                }
                catch (Win32Exception ex)
                {
                    Response.Write("PDF Viewer is not installed in this system");
                    Console.WriteLine(ex.ToString());
                }
            }
        }
        #region Iterates into document for removing field codes.       
        /// <summary>
        /// Iterates to document elements and get fields.
        /// </summary>
        /// <param name="document">Input Word document.</param>
        /// <param name="fieldType">Type of the field to find in document.</param>
        private void UnlinkFieldsInDocument(WordDocument document)
        {
            //Iterates each section and get the tables.
            foreach (WSection section in document.Sections)
            {
                RemoveFieldCodesInTextBody(section.Body);
            }
        }

        /// <summary>
        /// Iterates into body items.
        /// </summary>
        private void RemoveFieldCodesInTextBody(WTextBody textBody)
        {
            for (int i = 0; i < textBody.ChildEntities.Count; i++)
            {
                //IEntity is the basic unit in DocIO DOM.                 
                IEntity bodyItemEntity = textBody.ChildEntities[i];

                //A Text body has 3 types of elements - Paragraph, Table, and Block Content Control
                //Decides the element type by using EntityType
                switch (bodyItemEntity.EntityType)
                {
                    case EntityType.Paragraph:
                        WParagraph paragraph = bodyItemEntity as WParagraph;
                        //Iterates into paragraph items.
                        RemoveFieldCodesInParagraph(paragraph.Items);
                        break;

                    case EntityType.Table:
                        //Table is a collection of rows and cells
                        //Iterates through table's DOM                        
                        RemoveFieldCodesInTable(bodyItemEntity as WTable);
                        break;

                    case EntityType.BlockContentControl:
                        BlockContentControl blockContentControl = bodyItemEntity as BlockContentControl;
                        //Iterates to the body items of Block Content Control.
                        RemoveFieldCodesInTextBody(blockContentControl.TextBody);
                        break;
                }
            }
        }

        /// <summary>
        /// Iterates into paragraph items.
        /// </summary>
        /// <param name="paragraph">The paragraph.</param>
        /// <param name="fieldType">Type of field.</param>
        private void RemoveFieldCodesInParagraph(ParagraphItemCollection paraItems)
        {
            for (int i = 0; i < paraItems.Count; i++)
            {
                if (paraItems[i] is WField)
                {
                    WField field = paraItems[i] as WField;
                   field.Unlink();
                }
                else if (paraItems[i] is WTextBox)
                {
                    //If paragraph item is textbox, iterates into textbody of textbox.
                    WTextBox textBox = paraItems[i] as WTextBox;
                    RemoveFieldCodesInTextBody(textBox.TextBoxBody);
                }
                else if (paraItems[i] is Shape)
                {
                    //If paragraph item is shape, iterates into textbody of shape.
                    Shape shape = paraItems[i] as Shape;
                    RemoveFieldCodesInTextBody(shape.TextBody);
                }
                else if (paraItems[i] is InlineContentControl)
                {
                    //If paragraph item is inline content control, iterates into its item.
                    InlineContentControl inlineContentControl = paraItems[i] as InlineContentControl;
                    RemoveFieldCodesInParagraph(inlineContentControl.ParagraphItems);
                }
            }
        }
        /// <summary>
        /// Iterates into table.
        /// </summary>
        /// <param name="table">The table.</param>
        /// <param name="fieldType">Type of Field.</param>
        private void RemoveFieldCodesInTable(WTable table)
        {
            //Iterates the row collection in a table
            foreach (WTableRow row in table.Rows)
            {
                //Iterates the cell collection in a table row
                foreach (WTableCell cell in row.Cells)
                {
                    RemoveFieldCodesInTextBody(cell);
                }
            }
        }

Spire.Doc.Collections.ParagraphItemCollection : IEnumerable, IXDLSSerializableCollection, IDocumentObjectCollection, ICollectionBase

Constructors :

public ParagraphItemCollection(Document doc = )

Methods :

public ParagraphBase get_Item(Int32 index = )
public DocumentObject get_Item(Int32 index = )
public DocumentObject get_FirstItem()
public DocumentObject get_LastItem()
public Int32 Add(IDocumentObject entity = )
public Void Clear()
public Boolean Contains(IDocumentObject entity = )
public Int32 IndexOf(IDocumentObject entity = )
public Void Insert(Int32 index = , IDocumentObject entity = )
public Void Remove(IDocumentObject entity = )
public Void RemoveAt(Int32 index = )
public Int32 get_Count()
public IEnumerator GetEnumerator()
public Document get_Document()
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()

Other methods

Other methods