/// <summary> /// Gets the content for headers and footers. /// </summary> /// <param name="contentNode">The content node.</param> /// <param name="textDocument">The text document.</param> /// <returns>The contents as IContentCollection.</returns> public ContentCollection GetContentHeaderFooter(XmlNode contentNode, TextDocument textDocument) { ContentCollection contents = new ContentCollection(); if (contentNode != null && contentNode.HasChildNodes) { XmlNode node = null; if (textDocument.XmlDoc != contentNode.OwnerDocument) { node = textDocument.XmlDoc.ImportNode(contentNode, true); } else { node = contentNode; } MainContentProcessor mcp = new MainContentProcessor(textDocument); foreach (XmlNode nodeChild in node.ChildNodes) { IContent iContent = mcp.CreateContent(nodeChild); if (iContent != null) { if (iContent is AODL.Document.Content.Tables.Table) { ((AODL.Document.Content.Tables.Table)iContent).BuildNode(); } contents.Add(iContent); } } } return(contents); }
private void CopyCellContens(Cell source, Cell destination) { foreach (IContent content in source.Content) { IContent clonedContent = new MainContentProcessor(content.Document) .CreateContent(content.Node); destination.Content.Add(clonedContent); } }
/// <summary> /// Create a deep clone of this Header object. /// </summary> /// <remarks>A possible Attached Style wouldn't be cloned!</remarks> /// <returns> /// A clone of this object. /// </returns> public object Clone() { Header headerClone = null; if (this.Document != null && this.Node != null) { MainContentProcessor mcp = new MainContentProcessor(this.Document); headerClone = mcp.CreateHeader(this.Node.CloneNode(true)); } return(headerClone); }
// /// <summary> // /// Contents the collection_ inserted. // /// </summary> // /// <param name="index">The index.</param> // /// <param name="value">The value.</param> // protected void ContentCollection_Inserted(int index, object value) // { // this.Node.AppendChild(((IContent)value).Node); // } #region IContent Member old // private TextDocument _document; // /// <summary> // /// The TextDocument to which this draw-area is bound. // /// </summary> // public TextDocument Document // { // get // { // return this._document; // } // set // { // this._document = value; // } // } // // private XmlNode _node; // /// <summary> // /// The XmlNode. // /// </summary> // public XmlNode Node // { // get // { // return this._node; // } // set // { // this._node = value; // } // } // // /// <summary> // /// A draw:area-rectangle doesn't have a style-name. // /// </summary> // /// <value>The name</value> // public string Stylename // { // get // { // return null; // } // set // { // } // } // // /// <summary> // /// A draw:area-rectangle doesn't have a style. // /// </summary> // public IStyle Style // { // get // { // return null; // } // set // { // } // } // // /// <summary> // /// A draw:area-rectangle doesn't contain text. // /// </summary> // public ITextCollection TextContent // { // get // { // return null; // } // set // { // } // } #endregion #region ICloneable Member /// <summary> /// Create a deep clone of this EventListener object. /// </summary> /// <remarks>A possible Attached Style wouldn't be cloned!</remarks> /// <returns> /// A clone of this object. /// </returns> public object Clone() { EventListener eventListenerClone = null; if (this.Document != null && this.Node != null) { MainContentProcessor mcp = new MainContentProcessor(this.Document); eventListenerClone = mcp.CreateEventListener(this.Node.CloneNode(true)); } return(eventListenerClone); }
/// <summary> /// Create a deep clone of this paragraph object. /// </summary> /// <remarks>A possible Attached Style wouldn't be cloned!</remarks> /// <returns> /// A clone of this object. /// </returns> public object Clone() { Paragraph pargaphClone = null; if (this.Document != null && this.Node != null) { MainContentProcessor mcp = new MainContentProcessor(this.Document); pargaphClone = mcp.CreateParagraph(this.Node.CloneNode(true)); } return(pargaphClone); }
/// <summary> /// Create a deep clone of this paragraph object. /// </summary> /// <remarks>A possible Attached Style wouldn't be cloned!</remarks> /// <returns> /// A clone of this object. /// </returns> public object Clone() { Paragraph pargaphClone = null; if (Document != null && Node != null) { MainContentProcessor mcp = new MainContentProcessor(Document); pargaphClone = mcp.CreateParagraph(new XElement(Node)); } return(pargaphClone); }
/// <summary> /// Create a deep clone of this EventListeners object. /// </summary> /// <remarks>A possible Attached Style wouldn't be cloned!</remarks> /// <returns> /// A clone of this object. /// </returns> public object Clone() { EventListeners eventListenersClone = null; if (Document != null && Node != null) { MainContentProcessor mcp = new MainContentProcessor(Document); eventListenersClone = mcp.CreateEventListeners(new XElement(Node)); } return(eventListenersClone); }
/// <summary> /// Create a deep clone of this Header object. /// </summary> /// <remarks>A possible Attached Style wouldn't be cloned!</remarks> /// <returns> /// A clone of this object. /// </returns> public object Clone() { Header headerClone = null; if (Document != null && Node != null) { MainContentProcessor mcp = new MainContentProcessor(Document); headerClone = mcp.CreateHeader(new XElement(Node)); } return(headerClone); }
/// <summary> /// Reads the content. /// </summary> private void ReadContent() { try { this._document.XmlDoc = new XmlDocument(); this._document.XmlDoc.Load(dir + "\\content.xml"); // Apply tweaks to fix compatibility issues. This currently does the following: // 1. Expands repeated rows and columns. //Assembly ass = Assembly.GetExecutingAssembly(); //using ( Stream str = ass.GetManifestResourceStream( "AODL.Resources.OD.tweakcontent.xsl" ) ) //using ( XmlReader xr = XmlReader.Create( str ) ) //using ( MemoryStream ms = new MemoryStream() ) //{ // XslCompiledTransform xsl = new XslCompiledTransform(); // xsl.Load( xr ); // using ( XmlWriter xw = XmlWriter.Create( ms ) ) // { // xsl.Transform( _document.XmlDoc, xw ); // } // ms.Position = 0; // _document.XmlDoc.Load( ms ); //} //Read local styles LocalStyleProcessor lsp = new LocalStyleProcessor(this._document, false); lsp.ReadStyles(); //Import common styles and read common styles //this.ImportCommonStyles(); lsp = new LocalStyleProcessor(this._document, true); //lsp.ReadStyles(); MainContentProcessor mcp = new MainContentProcessor(this._document); mcp.OnWarning += new AODL.Document.Import.OpenDocument.NodeProcessors.MainContentProcessor.Warning(mcp_OnWarning); TextContentProcessor.OnWarning += new AODL.Document.Import.OpenDocument.NodeProcessors.TextContentProcessor.Warning(TextContentProcessor_OnWarning); mcp.ReadContentNodes(); } catch (Exception ex) { throw; } }
/// <summary> /// Gets the content for headers and footers. /// </summary> /// <param name="contentNode">The content node.</param> /// <param name="textDocument">The text document.</param> /// <returns>The contents as IContentCollection.</returns> public ContentCollection GetContentHeaderFooter(XElement contentNode, TextDocument textDocument) { ContentCollection contents = new ContentCollection(); if (contentNode != null && contentNode.HasElements) { XElement node = textDocument.XmlDoc != contentNode.Document ? new XElement(contentNode) : contentNode; MainContentProcessor mcp = new MainContentProcessor(textDocument); foreach (XElement nodeChild in node.Elements()) { IContent iContent = mcp.CreateContent(nodeChild); if (iContent != null) { if (iContent is Table) { ((Table)iContent).BuildNode(); } contents.Add(iContent); } } } return(contents); }
/// <summary> /// Reads the content. /// </summary> private void ReadContent() { /* * NOTICE: * Do not change this order! */ // 1. load content file this._document.XmlDoc = new XmlDocument(); this._document.XmlDoc.Load(Path.Combine(m_dirInfo.Dir, "content.xml")); // 2. Read local styles LocalStyleProcessor lsp = new LocalStyleProcessor(this._document, false); lsp.ReadStyles(); // 3. Import common styles and read common styles this.ImportCommonStyles(); lsp = new LocalStyleProcessor(this._document, true); lsp.ReadStyles(); if (_document is TextDocument) { FormsProcessor fp = new FormsProcessor(this._document); fp.ReadFormNodes(); TextDocument td = _document as TextDocument; td.VariableDeclarations.Clear(); XmlNode nodeText = td.XmlDoc.SelectSingleNode( TextDocumentHelper.OfficeTextPath, td.NamespaceManager); if (nodeText != null) { XmlNode nodeVarDecls = nodeText.SelectSingleNode("text:variable-decls", td.NamespaceManager); if (nodeVarDecls != null) { foreach (XmlNode vd in nodeVarDecls.CloneNode(true).SelectNodes("text:variable-decl", td.NamespaceManager)) { td.VariableDeclarations.Add(new VariableDecl(td, vd)); } nodeVarDecls.InnerXml = ""; } } } // 4. Register warnig events MainContentProcessor mcp = new MainContentProcessor(this._document); mcp.Warning += mcp_OnWarning; // 5. Read the content mcp.ReadContentNodes(); // 6.1 load master pages and styles for TextDocument if (this._document is TextDocument) { MasterPageFactory.RenameMasterStyles( ((TextDocument)this._document).DocumentStyles.Styles, this._document.XmlDoc, this._document.NamespaceManager); // Read the moved and renamed styles lsp = new LocalStyleProcessor(this._document, false); lsp.ReReadKnownAutomaticStyles(); new MasterPageFactory(m_dirInfo).FillFromXMLDocument(this._document as TextDocument); } }
/// <summary> /// Reads the content. /// </summary> private void ReadContent() { /* * NOTICE: * Do not change this order! */ // 1. load content file using (TextReader reader = new StreamReader(_packageReader.Open("content.xml"))) { _document.XmlDoc = XDocument.Load(reader); } // 2. Read local styles LocalStyleProcessor lsp = new LocalStyleProcessor(_document, false); lsp.ReadStyles(); // 3. Import common styles and read common styles ImportCommonStyles(); lsp = new LocalStyleProcessor(_document, true); lsp.ReadStyles(); if (_document is TextDocument) { FormsProcessor fp = new FormsProcessor(_document); fp.ReadFormNodes(); TextDocument td = _document as TextDocument; td.VariableDeclarations.Clear(); XElement nodeText = td.XmlDoc.Elements(Ns.Office + "document-content") .Elements(Ns.Office + "body") .Elements(Ns.Office + "text").FirstOrDefault(); if (nodeText != null) { XElement nodeVarDecls = nodeText.Element(Ns.Text + "variable-decls"); if (nodeVarDecls != null) { foreach (XElement vd in new XElement(nodeVarDecls).Elements(Ns.Text + "variable-decl")) { td.VariableDeclarations.Add(new VariableDecl(td, vd)); } nodeVarDecls.Value = ""; } } } // 4. Register warnig events MainContentProcessor mcp = new MainContentProcessor(_document); mcp.Warning += mcp_OnWarning; // 5. Read the content mcp.ReadContentNodes(); // 6.1 load master pages and styles for TextDocument if (_document is TextDocument) { MasterPageFactory.RenameMasterStyles( ((TextDocument)_document).DocumentStyles.Styles, _document.XmlDoc); // Read the moved and renamed styles lsp = new LocalStyleProcessor(_document, false); lsp.ReReadKnownAutomaticStyles(); new MasterPageFactory().FillFromXMLDocument(_document as TextDocument); } }