AODL.Document.Import.OpenDocument.NodeProcessors.MainContentProcessor.CreateTableOfContents C# (CSharp) Метод

CreateTableOfContents() приватный Метод

Creates the table of contents.
private CreateTableOfContents ( XmlNode tocNode ) : TableOfContents
tocNode System.Xml.XmlNode The toc node.
Результат AODL.Document.Content.Text.Indexes.TableOfContents
		private TableOfContents CreateTableOfContents(XmlNode tocNode)
		{
			try
			{
				if (this._document is TextDocument)
				{
					//Create the TableOfContents object
					TableOfContents tableOfContents		= new TableOfContents(
						((TextDocument)this._document), tocNode);
					//Recieve the Section style
					IStyle sectionStyle					= this._document.Styles.GetStyleByName(tableOfContents.StyleName);

					if (sectionStyle != null)
						tableOfContents.Style				= sectionStyle;
					else
					{
						OnWarning(new AODLWarning("A SectionStyle for the TableOfContents object wasn't found.", tocNode));
					}
					
					//Create the text entries
					XmlNodeList paragraphNodeList	= tocNode.SelectNodes(
						"text:index-body/text:p", this._document.NamespaceManager);
					XmlNode indexBodyNode			= tocNode.SelectSingleNode("text:index-body",
					                                                   this._document.NamespaceManager);
					tableOfContents.IndexBodyNode	= indexBodyNode;
					ContentCollection pCollection	= new ContentCollection();

					foreach(XmlNode paragraphnode in paragraphNodeList)
					{
						Paragraph paragraph			= this.CreateParagraph(paragraphnode);
						if (indexBodyNode != null)
							indexBodyNode.RemoveChild(paragraphnode);
						//pCollection.Add(paragraph);
						AddToCollection(paragraph, pCollection);
					}

					foreach(IContent content in pCollection)
						AddToCollection(content, tableOfContents.Content);
					//tableOfContents.Content.Add(content);

					return tableOfContents;
				}

				return null;
			}
			catch(Exception ex)
			{
				throw new AODLException("Exception while trying to create a TableOfContents.", ex);
			}
		}