Summary for TextMasterPage.
Example #1
0
 /// <summary>
 /// Create a new TextPageFooter object.
 /// !!NOTICE: The TextPageLayout of the TextMasterPage object must exist!
 /// </summary>
 /// <param name="textMasterPage">The text master page.</param>
 /// <param name="typeName">Name of the type to create header or footer.</param>
 /// <remarks>The TextPageLayout of the TextMasterPage object must exist!</remarks>
 protected void New(TextMasterPage textMasterPage, string typeName)
 {
     _textMasterPage = textMasterPage;
     _textDocument   = textMasterPage.TextDocument;
     StyleNode       = new XElement(Ns.Style + "footer-style");
     _textMasterPage.TextPageLayout.StyleNode.Add(StyleNode);
 }
		/// <summary>
		/// Create a new TextPageFooter object within the passed text master page.
		/// </summary>
		/// <param name="textMasterPage">The text master page.</param>
		public void New(TextMasterPage textMasterPage)
		{
			try
			{
				base.New(textMasterPage, "footer");
			}
			catch(Exception)
			{
				throw;
			}
		}
Example #3
0
 /// <summary>
 /// Create a new TextPageHeader object within the passed text master page.
 /// </summary>
 /// <param name="textMasterPage">The text master page.</param>
 public void New(TextMasterPage textMasterPage)
 {
     try
     {
         base.New(textMasterPage, "header");
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #4
0
 /// <summary>
 /// Create a new TextPageFooter object.
 /// !!NOTICE: The TextPageLayout of the TextMasterPage object must exist!
 /// </summary>
 /// <param name="textMasterPage">The text master page.</param>
 /// <param name="typeName">Name of the type to create header or footer.</param>
 /// <remarks>The TextPageLayout of the TextMasterPage object must exist!</remarks>
 protected void New(TextMasterPage textMasterPage, string typeName)
 {
     try
     {
         this._textMasterPage = textMasterPage;
         this._textDocument   = textMasterPage.TextDocument;
         this._styleNode      = this.TextDocument.DocumentStyles.CreateNode(
             "footer-style", "style", this.TextDocument);
         this._textMasterPage.TextPageLayout.StyleNode.AppendChild(this._styleNode);
     }
     catch (Exception)
     {
         throw;
     }
 }
		/// <summary>
		/// Create a new TextPageFooter object.
		/// !!NOTICE: The TextPageLayout of the TextMasterPage object must exist!
		/// </summary>
		/// <param name="textMasterPage">The text master page.</param>
		/// <param name="typeName">Name of the type to create header or footer.</param>
		/// <remarks>The TextPageLayout of the TextMasterPage object must exist!</remarks>
		protected void New(TextMasterPage textMasterPage, string typeName)
		{
			try
			{
				this._textMasterPage = textMasterPage;
				this._textDocument = textMasterPage.TextDocument;
				this._styleNode = this.TextDocument.CreateNode(
					"footer-style", "style");
				this._textMasterPage.TextPageLayout.StyleNode.AppendChild(this._styleNode);
			}
			catch(Exception)
			{
				throw;
			}
		}
		/// <summary>
		/// Fill/read the existing master page styles.
		/// </summary>
		/// <param name="textDocument">The owner text document.</param>
		public void FillFromXMLDocument(TextDocument textDocument)
		{
			try
			{
				TextMasterPageCollection txtMPCollection = new TextMasterPageCollection();
				XmlNodeList masterPageNodes = textDocument.XmlDoc.SelectNodes(
					"//style:master-page", textDocument.NamespaceManager);
				if (masterPageNodes != null)
				{
					foreach(XmlNode mpNode in masterPageNodes)
					{
						// Build the master page
						TextMasterPage txtMasterPage = new TextMasterPage(textDocument, mpNode);
						// Even if there is no usage of header within the master page style,
						// but of course there exists the header:style node, so we create
						// the TextPageHeader.
						txtMasterPage.TextPageHeader = new TextPageHeader();
						txtMasterPage.TextPageHeader.TextDocument = textDocument;
						txtMasterPage.TextPageHeader.TextMasterPage = txtMasterPage;
						// see comment above its the same procedure
						txtMasterPage.TextPageFooter = new TextPageFooter();
						txtMasterPage.TextPageFooter.TextDocument = textDocument;
						txtMasterPage.TextPageFooter.TextMasterPage = txtMasterPage;
						
						// Build header content
						XmlNode headerNode = mpNode.SelectSingleNode("//style:header", textDocument.NamespaceManager);
						if (headerNode != null)
						{
							txtMasterPage.TextPageHeader.ContentNode = headerNode;
							ContentCollection contents = GetContentHeaderFooter(headerNode, textDocument);
							if (contents != null) 
							{
								headerNode.RemoveAll();
								foreach(IContent iContent in contents) 
								{
									txtMasterPage.TextPageHeader.ContentCollection.Add(iContent);
								}
							}
						}

						// Build footer content
						XmlNode footerNode = mpNode.SelectSingleNode("//style:footer", textDocument.NamespaceManager);
						if (footerNode != null)
						{
							txtMasterPage.TextPageFooter.ContentNode = footerNode;
							ContentCollection contents = GetContentHeaderFooter(footerNode, textDocument);
							if (contents != null) 
							{
								footerNode.RemoveAll();
								foreach(IContent iContent in contents) 
								{
									txtMasterPage.TextPageFooter.ContentCollection.Add(iContent);
								}
							}
						}

						// Build master page layout
						XmlNode txtPageLayoutNode = textDocument.XmlDoc.SelectSingleNode(
							"//style:page-layout[@style:name='"+txtMasterPage.PageLayoutName+"']",
							textDocument.NamespaceManager);
						if (txtPageLayoutNode != null)
						{
							// Build master page layout properties
							XmlNode txtPageLayoutPropNode = txtPageLayoutNode.SelectSingleNode(
								"//style:page-layout-properties", textDocument.NamespaceManager);
							if (txtPageLayoutPropNode != null)
							{
								TextPageLayout txtPageLayout = new TextPageLayout(
									textDocument, txtPageLayoutNode, txtPageLayoutPropNode);
								txtMasterPage.TextPageLayout = txtPageLayout;
							}
							// Build master page header layout
							XmlNode txtHeaderStyleNode = txtPageLayoutNode.SelectSingleNode(
								"//style:header-style", textDocument.NamespaceManager);
							if (txtHeaderStyleNode != null)
							{
								txtMasterPage.TextPageHeader.StyleNode = txtHeaderStyleNode;
								if (txtHeaderStyleNode.FirstChild != null
									&& txtHeaderStyleNode.FirstChild.Name == "style:header-footer-properties")
									txtMasterPage.TextPageHeader.PropertyNode = txtHeaderStyleNode.FirstChild;
							}
							// Build master page footer layout
							XmlNode txtFooterStyleNode = txtPageLayoutNode.SelectSingleNode(
								"//style:footer-style", textDocument.NamespaceManager);
							if (txtFooterStyleNode != null)
							{
								txtMasterPage.TextPageFooter.StyleNode = txtFooterStyleNode;
								if (txtFooterStyleNode.FirstChild != null
									&& txtFooterStyleNode.FirstChild.Name == "style:header-footer-properties")
									txtMasterPage.TextPageFooter.PropertyNode = txtFooterStyleNode.FirstChild;
							}
						}
						
						txtMPCollection.Add(txtMasterPage);
					}
				}
				textDocument.TextMasterPageCollection = txtMPCollection;
			}
			catch(Exception)
			{
				throw;
			}
		}
Example #7
0
        /// <summary>
        /// Fill/read the existing master page styles.
        /// </summary>
        /// <param name="textDocument">The owner text document.</param>
        public void FillFromXMLDocument(TextDocument textDocument)
        {
            TextMasterPageCollection txtMPCollection = new TextMasterPageCollection();
            IEnumerable <XElement>   masterPageNodes = textDocument.DocumentStyles.Styles.Descendants(Ns.Style + "master-page");

            if (masterPageNodes != null)
            {
                foreach (XElement mpNode in masterPageNodes)
                {
                    // Build the master page
                    TextMasterPage txtMasterPage = new TextMasterPage(textDocument, mpNode);
                    // Even if there is no usage of header within the master page style,
                    // but of course there exists the header:style node, so we create
                    // the TextPageHeader.
                    txtMasterPage.TextPageHeader = new TextPageHeader();
                    txtMasterPage.TextPageHeader.TextDocument   = textDocument;
                    txtMasterPage.TextPageHeader.TextMasterPage = txtMasterPage;
                    // see comment above its the same procedure
                    txtMasterPage.TextPageFooter = new TextPageFooter();
                    txtMasterPage.TextPageFooter.TextDocument   = textDocument;
                    txtMasterPage.TextPageFooter.TextMasterPage = txtMasterPage;

                    // Build header content
                    XElement headerNode = mpNode.Descendants(Ns.Style + "header").FirstOrDefault();
                    if (headerNode != null)
                    {
                        txtMasterPage.TextPageHeader.ContentNode = headerNode;
                        ContentCollection contents = GetContentHeaderFooter(headerNode, textDocument);
                        if (contents != null)
                        {
                            headerNode.RemoveAll();
                            foreach (IContent iContent in contents)
                            {
                                txtMasterPage.TextPageHeader.ContentCollection.Add(iContent);
                            }
                        }
                    }

                    // Build footer content
                    XElement footerNode = mpNode.Descendants(Ns.Style + "footer").FirstOrDefault();
                    if (footerNode != null)
                    {
                        txtMasterPage.TextPageFooter.ContentNode = footerNode;
                        ContentCollection contents = GetContentHeaderFooter(footerNode, textDocument);
                        if (contents != null)
                        {
                            footerNode.RemoveAll();
                            foreach (IContent iContent in contents)
                            {
                                txtMasterPage.TextPageFooter.ContentCollection.Add(iContent);
                            }
                        }
                    }

                    // Build master page layout
                    XElement txtPageLayoutNode = textDocument.DocumentStyles.Styles.Descendants(Ns.Style + "page-layout")
                                                 .Where(
                        e => string.Equals((string)e.Attribute(Ns.Style + "name"), txtMasterPage.PageLayoutName)).
                                                 FirstOrDefault();
                    if (txtPageLayoutNode != null)
                    {
                        // Build master page layout properties
                        XElement txtPageLayoutPropNode =
                            txtPageLayoutNode.Descendants(Ns.Style + "page-layout-properties").FirstOrDefault();
                        if (txtPageLayoutPropNode != null)
                        {
                            TextPageLayout txtPageLayout = new TextPageLayout(
                                textDocument, txtPageLayoutNode, txtPageLayoutPropNode);
                            txtMasterPage.TextPageLayout = txtPageLayout;
                        }
                        // Build master page header layout
                        XElement txtHeaderStyleNode =
                            txtPageLayoutNode.Descendants(Ns.Style + "header-style").FirstOrDefault();
                        if (txtHeaderStyleNode != null)
                        {
                            txtMasterPage.TextPageHeader.StyleNode = txtHeaderStyleNode;
                            if (txtHeaderStyleNode.FirstNode != null
                                &&
                                ((XElement)txtHeaderStyleNode.FirstNode).Name ==
                                Ns.Style + "header-footer-properties")
                            {
                                txtMasterPage.TextPageHeader.PropertyNode = (XElement)txtHeaderStyleNode.FirstNode;
                            }
                        }
                        // Build master page footer layout
                        XElement txtFooterStyleNode =
                            txtPageLayoutNode.Descendants(Ns.Style + "footer-style").FirstOrDefault();
                        if (txtFooterStyleNode != null)
                        {
                            txtMasterPage.TextPageFooter.StyleNode = txtFooterStyleNode;
                            if (txtFooterStyleNode.FirstNode != null
                                &&
                                ((XElement)txtFooterStyleNode.FirstNode).Name ==
                                Ns.Style + "header-footer-properties")
                            {
                                txtMasterPage.TextPageFooter.PropertyNode = (XElement)txtFooterStyleNode.FirstNode;
                            }
                        }
                    }

                    txtMPCollection.Add(txtMasterPage);
                }
            }
            textDocument.TextMasterPageCollection = txtMPCollection;
        }
Example #8
0
        /// <summary>
        /// Fill/read the existing master page styles.
        /// </summary>
        /// <param name="textDocument">The owner text document.</param>
        public void FillFromXMLDocument(TextDocument textDocument)
        {
            try
            {
                TextMasterPageCollection txtMPCollection = new TextMasterPageCollection();
                XmlNodeList masterPageNodes = textDocument.XmlDoc.SelectNodes(
                    "//style:master-page", textDocument.NamespaceManager);

                if (masterPageNodes != null)
                {
                    foreach (XmlNode mpNode in masterPageNodes)
                    {
                        // Build the master page
                        TextMasterPage txtMasterPage = new TextMasterPage(textDocument, mpNode);
                        // Even if there is no usage of header within the master page style,
                        // but of course there exists the header:style node, so we create
                        // the TextPageHeader.
                        txtMasterPage.TextPageHeader = new TextPageHeader();
                        txtMasterPage.TextPageHeader.TextDocument   = textDocument;
                        txtMasterPage.TextPageHeader.TextMasterPage = txtMasterPage;
                        // see comment above its the same procedure
                        txtMasterPage.TextPageFooter = new TextPageFooter();
                        txtMasterPage.TextPageFooter.TextDocument   = textDocument;
                        txtMasterPage.TextPageFooter.TextMasterPage = txtMasterPage;

                        // Build header content
                        XmlNode headerNode = mpNode.SelectSingleNode(".//style:header", textDocument.NamespaceManager);
                        if (headerNode != null)
                        {
                            txtMasterPage.TextPageHeader.ContentNode = headerNode;
                            ContentCollection contents = GetContentHeaderFooter(headerNode, textDocument);
                            if (contents != null)
                            {
                                headerNode.RemoveAll();
                                foreach (IContent iContent in contents)
                                {
                                    txtMasterPage.TextPageHeader.ContentCollection.Add(iContent);
                                }
                            }
                        }

                        // Build footer content
                        XmlNode footerNode = mpNode.SelectSingleNode(".//style:footer", textDocument.NamespaceManager);
                        if (footerNode != null)
                        {
                            txtMasterPage.TextPageFooter.ContentNode = footerNode;
                            ContentCollection contents = GetContentHeaderFooter(footerNode, textDocument);
                            if (contents != null)
                            {
                                footerNode.RemoveAll();
                                foreach (IContent iContent in contents)
                                {
                                    txtMasterPage.TextPageFooter.ContentCollection.Add(iContent);
                                }
                            }
                        }

                        // Build master page layout
                        XmlNode txtPageLayoutNode = textDocument.XmlDoc.SelectSingleNode(
                            "//style:page-layout[@style:name='" + txtMasterPage.PageLayoutName + "']",
                            textDocument.NamespaceManager);
                        if (txtPageLayoutNode != null)
                        {
                            // Build master page layout properties
                            XmlNode txtPageLayoutPropNode = txtPageLayoutNode.SelectSingleNode(
                                "//style:page-layout-properties", textDocument.NamespaceManager);
                            if (txtPageLayoutPropNode != null)
                            {
                                TextPageLayout txtPageLayout = new TextPageLayout(
                                    textDocument, txtPageLayoutNode, txtPageLayoutPropNode);
                                txtMasterPage.TextPageLayout = txtPageLayout;
                            }
                            // Build master page header layout
                            XmlNode txtHeaderStyleNode = txtPageLayoutNode.SelectSingleNode(
                                "//style:header-style", textDocument.NamespaceManager);
                            if (txtHeaderStyleNode != null)
                            {
                                txtMasterPage.TextPageHeader.StyleNode = txtHeaderStyleNode;
                                if (txtHeaderStyleNode.FirstChild != null &&
                                    txtHeaderStyleNode.FirstChild.Name == "style:header-footer-properties")
                                {
                                    txtMasterPage.TextPageHeader.PropertyNode = txtHeaderStyleNode.FirstChild;
                                }
                            }
                            // Build master page footer layout
                            XmlNode txtFooterStyleNode = txtPageLayoutNode.SelectSingleNode(
                                "//style:footer-style", textDocument.NamespaceManager);
                            if (txtFooterStyleNode != null)
                            {
                                txtMasterPage.TextPageFooter.StyleNode = txtFooterStyleNode;
                                if (txtFooterStyleNode.FirstChild != null &&
                                    txtFooterStyleNode.FirstChild.Name == "style:header-footer-properties")
                                {
                                    txtMasterPage.TextPageFooter.PropertyNode = txtFooterStyleNode.FirstChild;
                                }
                            }
                        }

                        txtMPCollection.Add(txtMasterPage);
                    }
                }
                textDocument.TextMasterPageCollection = txtMPCollection;
            }
            catch (Exception)
            {
                throw;
            }
        }