/// <summary> /// Creates the header. /// </summary> /// <param name="headernode">The headernode.</param> /// <returns></returns> public Header CreateHeader(XmlNode headernode) { try { if (this._debugMode) this.LogNode(headernode, "Log header node before"); //Create a new Header Header header = new Header(headernode, this._document); //Create a ITextCollection ITextCollection textColl = new ITextCollection(); //Recieve the HeaderStyle IStyle headerStyle = this._document.Styles.GetStyleByName(header.StyleName); if (headerStyle != null) header.Style = headerStyle; //Create the IText content foreach(XmlNode nodeChild in header.Node.ChildNodes) { TextContentProcessor tcp = new TextContentProcessor(); IText iText = tcp.CreateTextObject(this._document, nodeChild); if (iText != null) textColl.Add(iText); else { this.OnWarning(new AODLWarning("Couldn't create IText object from header child node!.", nodeChild)); } } //Remove all header.Node.InnerXml = ""; foreach(IText iText in textColl) { if (this._debugMode) this.LogNode(iText.Node, "Log IText node read from header"); header.TextContent.Add(iText); } return header; } catch(Exception ex) { throw new AODLException("Exception while trying to create a Header.", ex); } }
/// <summary> /// Create a deep clone of this FormatedText object. /// </summary> /// <remarks>A possible Attached Style wouldn't be cloned!</remarks> /// <returns> /// A clone of this object. /// </returns> public object Clone() { FormatedText formatedTextClone = null; if (this.Document != null && this.Node != null) { TextContentProcessor tcp = new TextContentProcessor(); formatedTextClone = tcp.CreateFormatedText( this.Document, this.Node.CloneNode(true)); } return formatedTextClone; }
/// <summary> /// Create a deep clone of this Bookmark object. /// </summary> /// <remarks>A possible Attached Style wouldn't be cloned!</remarks> /// <returns> /// A clone of this object. /// </returns> public object Clone() { Bookmark bookmarkClone = null; if (this.Document != null && this.Node != null) { TextContentProcessor tcp = new TextContentProcessor(); bookmarkClone = tcp.CreateBookmark( this.Document, this.Node.CloneNode(true), this.BookmarkType); } return bookmarkClone; }
/// <summary> /// Reads the content of the paragraph text. /// </summary> /// <param name="paragraph">The paragraph.</param> /// <returns></returns> private Paragraph ReadParagraphTextContent(Paragraph paragraph) { try { if (this._debugMode) this.LogNode(paragraph.Node, "Log Paragraph node before"); ArrayList mixedContent = new ArrayList(); foreach(XmlNode nodeChild in paragraph.Node.ChildNodes) { //Check for IText content first TextContentProcessor tcp = new TextContentProcessor(); IText iText = tcp.CreateTextObject(this._document, nodeChild.CloneNode(true)); if (iText != null) mixedContent.Add(iText); else { //Check against IContent IContent iContent = this.CreateContent(nodeChild); if (iContent != null) mixedContent.Add(iContent); } } //Remove all paragraph.Node.InnerXml = ""; foreach(Object ob in mixedContent) { if (ob is IText) { if (this._debugMode) this.LogNode(((IText)ob).Node, "Log IText node read"); paragraph.TextContent.Add(ob as IText); } else if (ob is IContent) { if (this._debugMode) this.LogNode(((IContent)ob).Node, "Log IContent node read"); //paragraph.Content.Add(ob as IContent); AddToCollection(ob as IContent, paragraph.Content); } else { this.OnWarning(new AODLWarning("Couldn't determine the type of a paragraph child node!.", paragraph.Node)); } } if (this._debugMode) this.LogNode(paragraph.Node, "Log Paragraph node after"); return paragraph; } catch(Exception ex) { throw new AODLException("Exception while trying to create the Paragraph content.", ex); } }
/// <summary> /// Create a deep clone of this XLink object. /// </summary> /// <remarks>A possible Attached Style wouldn't be cloned!</remarks> /// <returns> /// A clone of this object. /// </returns> public object Clone() { XLink xLinkClone = null; if (this.Document != null && this.Node != null) { TextContentProcessor tcp = new TextContentProcessor(); xLinkClone = tcp.CreateXLink(this.Document, this.Node.CloneNode(true)); } return xLinkClone; }
/// <summary> /// Create a deep clone of this SimpleText object. /// </summary> /// <remarks>A possible Attached Style wouldn't be cloned!</remarks> /// <returns> /// A clone of this object. /// </returns> public object Clone() { SimpleText simpleTextClone = null; if(this.Document != null && this.Node != null) { TextContentProcessor tcp = new TextContentProcessor(); simpleTextClone = (SimpleText)tcp.CreateTextObject( this.Document, this.Node.CloneNode(true)); } return simpleTextClone; }
/// <summary> /// Creates the header. /// </summary> /// <param name="headernode">The headernode.</param> /// <returns></returns> public Header CreateHeader(XmlNode headernode) { try { #region Old code Todo: delete // XmlNode node = headernode.SelectSingleNode("//@text:style-name", this._document.NamespaceManager); // if(node != null) // { // if(!node.InnerText.StartsWith("Heading")) // { // //Check if a the referenced paragraphstyle reference a heading as parentstyle // XmlNode stylenode = this._document.XmlDoc.SelectSingleNode("//style:style[@style:name='"+node.InnerText+"']", this._document.NamespaceManager); // if(stylenode != null) // { // XmlNode parentstyle = stylenode.SelectSingleNode("@style:parent-style-name", // this._document.NamespaceManager); // if(parentstyle != null) // if(parentstyle.InnerText.StartsWith("Heading")) // headernode.SelectSingleNode("@text:style-name", // this._document.NamespaceManager).InnerText = parentstyle.InnerText; // } // } // } #endregion if(this._debugMode) this.LogNode(headernode, "Log header node before"); //Create a new Header Header header = new Header(headernode, this._document); //Create a ITextCollection ITextCollection textColl = new ITextCollection(); //Recieve the HeaderStyle IStyle headerStyle = this._document.Styles.GetStyleByName(header.StyleName); if(headerStyle != null) header.Style = headerStyle; //Create the IText content foreach(XmlNode nodeChild in header.Node.ChildNodes) { TextContentProcessor tcp = new TextContentProcessor(); IText iText = tcp.CreateTextObject(this._document, nodeChild); if(iText != null) textColl.Add(iText); else { if(this.OnWarning != null) { AODLWarning warning = new AODLWarning("Couldn't create IText object from header child node!."); warning.InMethod = AODLException.GetExceptionSourceInfo(new StackFrame(1, true)); warning.Node = nodeChild; this.OnWarning(warning); } } } //Remove all header.Node.InnerXml = ""; foreach(IText iText in textColl) { if(this._debugMode) this.LogNode(iText.Node, "Log IText node read from header"); header.TextContent.Add(iText); } return header; } catch(Exception ex) { AODLException exception = new AODLException("Exception while trying to create a Header."); exception.InMethod = AODLException.GetExceptionSourceInfo(new StackFrame(1, true)); exception.Node = headernode; exception.OriginalException = ex; throw exception; } return null; }
/// <summary> /// Reads the content of the paragraph text. /// </summary> /// <param name="paragraph">The paragraph.</param> /// <returns></returns> private Paragraph ReadParagraphTextContent(Paragraph paragraph) { try { if(this._debugMode) this.LogNode(paragraph.Node, "Log Paragraph node before"); ArrayList mixedContent = new ArrayList(); foreach(XmlNode nodeChild in paragraph.Node.ChildNodes) { //Check for IText content first TextContentProcessor tcp = new TextContentProcessor(); IText iText = tcp.CreateTextObject(this._document, nodeChild.CloneNode(true)); if(iText != null) mixedContent.Add(iText); else { //Check against IContent IContent iContent = this.CreateContent(nodeChild); if(iContent != null) mixedContent.Add(iContent); } } //Remove all paragraph.Node.InnerXml = ""; foreach(Object ob in mixedContent) { if(ob is IText) { if(this._debugMode) this.LogNode(((IText)ob).Node, "Log IText node read"); paragraph.TextContent.Add(ob as IText); } else if(ob is IContent) { if(this._debugMode) this.LogNode(((IContent)ob).Node, "Log IContent node read"); paragraph.Content.Add(ob as IContent); } else { if(this.OnWarning != null) { AODLWarning warning = new AODLWarning("Couldn't determine the type of a paragraph child node!."); warning.InMethod = AODLException.GetExceptionSourceInfo(new StackFrame(1, true)); warning.Node = paragraph.Node; this.OnWarning(warning); } } } if(this._debugMode) this.LogNode(paragraph.Node, "Log Paragraph node after"); return paragraph; } catch(Exception ex) { AODLException exception = new AODLException("Exception while trying to create the Paragraph content."); exception.InMethod = AODLException.GetExceptionSourceInfo(new StackFrame(1, true)); exception.Node = paragraph.Node; exception.OriginalException = ex; throw exception; } }
private Paragraph ReadParagraphTextContent(Paragraph paragraph) { try { ArrayList mixedContent = new ArrayList(); foreach(XmlNode nodeChild in paragraph.Node.ChildNodes) { //Check for IText content first TextContentProcessor tcp = new TextContentProcessor(); IText iText = tcp.CreateTextObject(this.Chart .Document, nodeChild.CloneNode(true)); if (iText != null) mixedContent.Add(iText); else { //Check against IContent IContent iContent = this.CreateContent(nodeChild); if (iContent != null) mixedContent.Add(iContent); } } //Remove all paragraph.Node.InnerXml = ""; foreach(Object ob in mixedContent) { if (ob is IText) { XmlNode node=this.Chart.ChartDoc .ImportNode (((IText)ob).Node,true); paragraph.Node.AppendChild(node); } else if (ob is IContent) { //paragraph.Content.Add(ob as IContent); AddToCollection(ob as IContent, paragraph.Content); } else { if (this.OnWarning != null) { AODLWarning warning = new AODLWarning("Couldn't determine the type of a paragraph child node!."); //warning.InMethod = AODLException.GetExceptionSourceInfo(new StackFrame(1, true)); warning.Node = paragraph.Node; this.OnWarning(warning); } } } return paragraph; } catch(Exception ex) { throw new AODLException("Exception while trying to create the Paragraph content.", ex); } }