You can use an AODLWarning instead of an AODLException if the whole result isn't really in danger.
Inheritance: AODLException
Ejemplo n.º 1
0
 private void TextContentProcessor_OnWarning(AODL.Document.Exceptions.AODLWarning warning)
 {
     this._importError.Add(warning);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates the formated text.
        /// </summary>
        /// <param name="document">The document.</param>
        /// <param name="node">The node.</param>
        /// <returns></returns>
        public FormatedText CreateFormatedText(IDocument document, XmlNode node)
        {
            try
            {
                //Create a new FormatedText object
                FormatedText formatedText		= new FormatedText(document, node);
                ITextCollection iTextColl		= new ITextCollection();
                formatedText.Document			= document;
                formatedText.Node				= node;
                //Recieve a TextStyle

                IStyle textStyle				= document.Styles.GetStyleByName(formatedText.StyleName);

                if(textStyle != null)
                    formatedText.Style			= textStyle;
                else
                {
                    IStyle iStyle				= document.CommonStyles.GetStyleByName(formatedText.StyleName);
                    if(iStyle == null)
                    {
                        if(OnWarning != null)
                        {
                            AODLWarning warning			= new AODLWarning("A TextStyle for the FormatedText object wasn't found.");
                            warning.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
                            warning.Node				= node;
                            OnWarning(warning);
                        }
                    }
                }

                //Ceck for more IText object
                foreach(XmlNode iTextNode in node.ChildNodes)
                {
                    IText iText						= this.CreateTextObject(document, iTextNode.CloneNode(true));
                    if(iText != null)
                    {
                        iTextColl.Add(iText);
                    }
                    else
                        iTextColl.Add(new UnknownTextContent(document, iTextNode) as IText);
                }

                formatedText.Node.InnerText			= "";

                foreach(IText iText in iTextColl)
                    formatedText.TextContent.Add(iText);

                return formatedText;
            }
            catch(Exception ex)
            {
                throw;
            }
        }
		/// <summary>
		/// Gets the mixed content as HTML.
		/// </summary>
		/// <param name="mixedContent">ArrayList of objects. The objects could be
		/// IContent or IText.</param>
		/// <param name="paragraphStyle">The paragraph style.</param>
		/// <returns></returns>
		public string GetMixedContentAsHTML(ArrayList mixedContent, ParagraphStyle paragraphStyle)
		{
			string html					= "";
			int tabStopCnt				= 0;

			try
			{
				if (mixedContent != null)
				{
					foreach(object ob in mixedContent)
					{
						//determine type text content types
						if (ob is SimpleText)
						{
							html			+= this.ReplaceControlNodes(((IText)ob).Node.InnerText);
						}
						else if (ob is FormatedText)
							html			+= this.GetFormatedTextAsHtml(ob as FormatedText);
						else if (ob is WhiteSpace)
							html			+= this.GetWhiteSpacesAsHtml(ob as WhiteSpace);
						else if (ob is TabStop)
						{
							html			+= this.GetTabStopAsHtml(ob as TabStop, tabStopCnt, html, paragraphStyle);
							tabStopCnt++;
						}
						else if (ob is XLink)
							html			+= this.GetXLinkAsHtml(ob as XLink);
						else if (ob is LineBreak)
							html			+= this.GetLineBreakAsHtml();
						else if (ob is UnknownTextContent)
							html			+= this.GetUnknowTextContentAsHtml(ob as UnknownTextContent);
							//determine type
						else if (ob is Table)
							html			+= this.GetTableAsHtml(ob as Table);
						else if (ob is Paragraph)
							html			+= this.GetParagraphAsHtml(ob as Paragraph);
						else if (ob is List)
							html			+= this.GetListAsHtml(ob as List);
						else if (ob is Frame)
							html			+= this.GetDrawFrameAsHtml(ob as Frame);
						else if (ob is Graphic)
							html			+= this.GetGraphicAsHtml(ob as Graphic);
						else if (ob is ListItem)
							html			+= this.GetListItemAsHtml(ob as ListItem);
						else if (ob is Field)
							html			+= this.GetFieldAsHtml(ob as Field);
						else if (ob is ODFControlRef)
							html			+= this.GetODFControlAsHtml(ob as ODFControlRef);
						else if (ob is Header)
							html			+= this.GetHeadingAsHtml(ob as Header);
						else if (ob is UnknownContent)
							html			+= this.GetUnknowContentAsHtml(ob as UnknownContent);
						else
							//this should never happens, because all not implemented elements 
							//are unknwon content
							if (OnWarning != null)
						{
							AODLWarning warning			= new AODLWarning("Finding total unknown content in mixed content. This should (could) never happen.");
							//warning.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
							OnWarning(warning);
						}
					}
				}
			}
			catch(Exception ex)
			{
				throw new AODLException("Exception while trying to build a HTML string from an ITextCollection.", ex);
			}

			return html;			
		}
Ejemplo n.º 4
0
		private void OnWarning(AODLWarning warning)
		{
			if (Warning != null) {
				Warning(warning);
			}
		}
		/// <summary>
		/// Gets the anchor link.
		/// </summary>
		/// <param name="outlineLinkTarget">The outline link target.</param>
		/// <param name="xLink">The x link.</param>
		/// <returns></returns>
		private string GetAnchorLink(string outlineLinkTarget, XLink xLink)
		{
			try
			{
				string replaceMent			= "|outline";
				outlineLinkTarget			= outlineLinkTarget.Replace(replaceMent, "");
				//Get only the last part of the target and try to match a header 
				//beginning afer char index 6 should be a good decision
				//TODO: Build the outline numbering via the outline element from the global styles
				outlineLinkTarget			= outlineLinkTarget.Substring(6);
				
				if (xLink.Document != null)
					if (xLink.Document.Content != null)
							foreach(IContent iContent in xLink.Document.Content)
								if (iContent is Header)
									if (((Header)iContent).OutLineLevel != null)
									{
										string headerText		= "";
										//Get text only
										foreach(IText iText in ((Header)iContent).TextContent)
											if (iText.Text != null)
												headerText		+= iText.Text;
										if (headerText.EndsWith(outlineLinkTarget))
											return headerText;
									}
			}
			catch(Exception ex)
			{
				if (OnWarning != null)
				{
					AODLWarning warning			= new AODLWarning("Exception while trying to get an anchor string from a XLink object.", ex);
					//warning.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
					//warning.OriginalException	= ex;
					warning.Node				= xLink.Node;
					OnWarning(warning);
				}
			}

			return null;
		}
		/// <summary>
		/// Gets the white spaces as HTML.
		/// </summary>
		/// <param name="whiteSpace">The white space.</param>
		/// <returns></returns>
		public string GetWhiteSpacesAsHtml(WhiteSpace whiteSpace)
		{
			string html					= "";
			int count					= 0;
			try
			{
				if (whiteSpace.Count != null)
					count				= Convert.ToInt32(whiteSpace.Count);

				for(int i=0; i<count; i++)
					html				+= "&nbsp;";
			}
			catch(Exception ex)
			{
				//send warning
				if (OnWarning != null)
				{
					AODLWarning warning			= new AODLWarning("Exception while trying to build HTML whitespaces.", ex);
					//warning.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));				
					//warning.OriginalException	= ex;
					OnWarning(warning);
				}
			}

			return html;
		}
Ejemplo n.º 7
0
        /// <summary>
        /// Creates the frame.
        /// </summary>
        /// <param name="frameNode">The framenode.</param>
        /// <returns>The Frame object.</returns>
        public Frame CreateFrame(XmlNode frameNode)
        {
            try
            {
                #region Old code Todo: delete
                //				Frame frame					= null;
                //				XmlNode graphicnode			= null;
                //				XmlNode graphicproperties	= null;
                //				string realgraphicname		= "";
                //				string stylename			= "";
                //				stylename					= this.GetStyleName(framenode.OuterXml);
                //				XmlNode stylenode			= this.GetAStyleNode("style:style", stylename);
                //				realgraphicname				= this.GetAValueFromAnAttribute(framenode, "@draw:name");
                //
                //				//Console.WriteLine("frame: {0}", framenode.OuterXml);
                //
                //				//Up to now, the only sopported, inner content of a frame is a graphic
                //				if(framenode.ChildNodes.Count > 0)
                //					if(framenode.ChildNodes.Item(0).OuterXml.StartsWith("<draw:image"))
                //						graphicnode			= framenode.ChildNodes.Item(0).CloneNode(true);
                //
                //				//If not graphic, it could be text-box, ole or something else
                //				//try to find graphic frame inside
                //				if(graphicnode == null)
                //				{
                //					XmlNode child		= framenode.SelectSingleNode("//draw:frame", this._document.NamespaceManager);
                //					if(child != null)
                //						frame		= this.CreateFrame(child);
                //					return frame;
                //				}
                //
                //				string graphicpath			= this.GetAValueFromAnAttribute(graphicnode, "@xlink:href");
                //
                //				if(stylenode != null)
                //					if(stylenode.ChildNodes.Count > 0)
                //						if(stylenode.ChildNodes.Item(0).OuterXml.StartsWith("<style:graphic-properties"))
                //							graphicproperties	= stylenode.ChildNodes.Item(0).CloneNode(true);
                //
                //				if(stylename.Length > 0 && stylenode != null && realgraphicname.Length > 0
                //					&& graphicnode != null && graphicpath.Length > 0 && graphicproperties != null)
                //				{
                //					graphicpath				= graphicpath.Replace("Pictures", "");
                //					graphicpath				= OpenDocumentTextImporter.dirpics+graphicpath.Replace("/", @"\");
                //
                //					frame					= new Frame(this._document, stylename,
                //												realgraphicname, graphicpath);
                //
                //					frame.Style.Node		= stylenode;
                //					frame.Graphic.Node		= graphicnode;
                //					((FrameStyle)frame.Style).GraphicProperties.Node = graphicproperties;
                //
                //					XmlNode nodeSize		= framenode.SelectSingleNode("@svg:height",
                //						this._document.NamespaceManager);
                //
                //					if(nodeSize != null)
                //						if(nodeSize.InnerText != null)
                //							frame.GraphicHeight	= nodeSize.InnerText;
                //
                //					nodeSize		= framenode.SelectSingleNode("@svg:width",
                //						this._document.NamespaceManager);
                //
                //					if(nodeSize != null)
                //						if(nodeSize.InnerText != null)
                //							frame.GraphicWidth	= nodeSize.InnerText;
                //				}
                #endregion

                //Create a new Frame
                Frame frame					= new Frame(this._document, null);
                frame.Node					= frameNode;
                IContentCollection iColl	= new IContentCollection();
                //Revieve the FrameStyle
                IStyle frameStyle			= this._document.Styles.GetStyleByName(frame.StyleName);

                if(frameStyle != null)
                    frame.Style					= frameStyle;
                else
                {
                    if(this.OnWarning != null)
                    {
                        AODLWarning warning			= new AODLWarning("Couldn't recieve a FrameStyle.");
                        warning.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
                        warning.Node				= frameNode;
                        this.OnWarning(warning);
                    }
                }

                //Create the frame content
                foreach(XmlNode nodeChild in frame.Node.ChildNodes)
                {
                    IContent iContent				= this.CreateContent(nodeChild);
                    if(iContent != null)
                        iColl.Add(iContent);
                    else
                    {
                        if(this.OnWarning != null)
                        {
                            AODLWarning warning			= new AODLWarning("Couldn't create a IContent object for a frame.");
                            warning.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
                            warning.Node				= nodeChild;
                            this.OnWarning(warning);
                        }
                    }
                }

                frame.Node.InnerXml					= "";

                foreach(IContent iContent in iColl)
                {
                    frame.Content.Add(iContent);
                    if(iContent is Graphic)
                    {
                        frame.LoadImageFromFile(((Graphic)iContent).GraphicRealPath);
                    }
                }

                return frame;
            }
            catch(Exception ex)
            {
                AODLException exception		= new AODLException("Exception while trying to create a Frame.");
                exception.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
                exception.Node				= frameNode;
                exception.OriginalException	= ex;

                throw exception;
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Cleans the up read and write directories.
        /// </summary>
        internal static void CleanUpReadAndWriteDirectories()
        {
            try
            {
                if(Directory.Exists(OpenDocumentImporter.dir))
                    Directory.Delete(OpenDocumentImporter.dir, true);
                if(Directory.Exists(OpenDocumentImporter.dir))
                    Directory.Delete(OpenDocumentImporter.dir, true);
                if(Directory.Exists(OpenDocumentTextExporter.dir))
                    Directory.Delete(OpenDocumentTextExporter.dir, true);
            }
            catch(Exception ex)
            {
                AODLWarning aodlWarning				= new AODLWarning("An exception ouccours while trying to remove the temp read directories.");
                aodlWarning.InMethod				= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
                aodlWarning.OriginalException		= ex;

                throw ex;
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Creates the table row.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <returns></returns>
        private Row CreateTableRow(XmlNode node)
        {
            try
            {
                //Create a new Row
                Row row						= new Row(this._document, node);
                IContentCollection iColl	= new IContentCollection();
                //Recieve RowStyle
                IStyle rowStyle				= this._document.Styles.GetStyleByName(row.StyleName);

                if(rowStyle != null)
                    row.Style				= rowStyle;
                //No need for a warning

                //Create the cells
                foreach(XmlNode nodeChild in row.Node.ChildNodes)
                {
                    IContent iContent		= this.CreateContent(nodeChild);

                    if(iContent != null)
                    {
                        iColl.Add(iContent);
                    }
                    else
                    {
                        if(this.OnWarning != null)
                        {
                            AODLWarning warning			= new AODLWarning("Couldn't create IContent from a table row.");
                            warning.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
                            warning.Node				= nodeChild;
                            this.OnWarning(warning);
                        }
                    }
                }

                row.Node.InnerXml			= "";

                foreach(IContent iContent in iColl)
                {
                    if(iContent is Cell)
                    {
                        ((Cell)iContent).Row		= row;
                        row.CellCollection.Add(iContent as Cell);
                    }
                    else if(iContent is CellSpan)
                    {
                        ((CellSpan)iContent).Row	= row;
                        row.CellSpanCollection.Add(iContent as CellSpan);
                    }
                    else
                    {
                        if(this.OnWarning != null)
                        {
                            AODLWarning warning			= new AODLWarning("Couldn't create IContent from a row node. Content is unknown table row content!");
                            warning.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
                            warning.Node				= iContent.Node;
                            this.OnWarning(warning);
                        }
                    }
                }

                return row;
            }
            catch(Exception ex)
            {
                AODLException exception		= new AODLException("Exception while trying to create a Table Row.");
                exception.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
                exception.Node				= node;
                exception.OriginalException	= ex;

                throw exception;
            }
        }
Ejemplo n.º 10
0
        /// <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;
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Creates the table of contents.
        /// </summary>
        /// <param name="tocNode">The toc node.</param>
        /// <returns></returns>
        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
                    {
                        if(this.OnWarning != null)
                        {
                            AODLWarning warning			= new AODLWarning("A SectionStyle for the TableOfContents object wasn't found.");
                            warning.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
                            warning.Node				= tocNode;
                            this.OnWarning(warning);
                        }
                    }

                    //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;
                    IContentCollection pCollection	= new IContentCollection();

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

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

                    return tableOfContents;
                }

                return null;
            }
            catch(Exception ex)
            {
                AODLException exception		= new AODLException("Exception while trying to create a TableOfContents.");
                exception.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
                exception.Node				= tocNode;
                exception.OriginalException	= ex;

                throw exception;
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Creates the table cell.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <returns></returns>
        private Cell CreateTableCell(XmlNode node)
        {
            try
            {
                //Create a new Cel
                Cell cell					= new Cell(this._document, node);
                IContentCollection iColl	= new IContentCollection();
                //Recieve CellStyle
                IStyle cellStyle			= this._document.Styles.GetStyleByName(cell.StyleName);

                if(cellStyle != null)
                {
                    int i=0;
                    cell.Style				= cellStyle;
                    if(cellStyle.StyleName == "ce244")
                        i=1;
                }
                //No need for a warning

                //Create the cells content
                foreach(XmlNode nodeChild in cell.Node.ChildNodes)
                {
                    IContent iContent		= this.CreateContent(nodeChild);

                    if(iContent != null)
                    {
                        iColl.Add(iContent);
                    }
                    else
                    {
                        if(this.OnWarning != null)
                        {
                            AODLWarning warning			= new AODLWarning("Couldn't create IContent from a table cell.");
                            warning.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
                            warning.Node				= nodeChild;
                            this.OnWarning(warning);
                        }
                    }
                }

                cell.Node.InnerXml			= "";

                foreach(IContent iContent in iColl)
                    cell.Content.Add(iContent);
                return cell;
            }
            catch(Exception ex)
            {
                AODLException exception		= new AODLException("Exception while trying to create a Table Row.");
                exception.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
                exception.Node				= node;
                exception.OriginalException	= ex;

                throw exception;
            }
        }
Ejemplo n.º 13
0
		/// <summary>
		/// Imports the specified filename.
		/// </summary>
		/// <param name="document">The TextDocument to fill.</param>
		/// <param name="filename">The filename.</param>
		/// <returns>The created TextDocument</returns>
		public void Import(IDocument document, string filename)
		{
			this._document			= document;
			ArrayList lines			= this.GetFileContent(filename);
			
			if (lines.Count > 0)
				this.CreateTables(lines);
			else
			{
				AODLWarning warning	= new AODLWarning("Empty file. ["+filename+"]");
				this.ImportError.Add(warning);
			}
		}
Ejemplo n.º 14
0
		/// <summary>
		/// Gets the table style as HTML.
		/// </summary>
		/// <param name="tableStyle">The table style.</param>
		/// <returns></returns>
		public string GetTableStyleAsHtml(TableStyle tableStyle)
		{
			string style		= "";

			try
			{
				if (tableStyle != null)
				{
					if (tableStyle.TableProperties != null)
					{
						if (tableStyle.TableProperties.Width != null)
						{
							string width	= tableStyle.TableProperties.Width;
							if (width.EndsWith("cm"))
								width		= width.Replace("cm", "");
							else if (width.EndsWith("in"))
								width		= width.Replace("in", "");

							try
							{
								double wd	= Convert.ToDouble(width, System.Globalization.NumberFormatInfo.InvariantInfo);
								string wdPx	= "";
								if (tableStyle.TableProperties.Width.EndsWith("cm"))
									wdPx	= SizeConverter.CmToPixelAsString(wd);
								else if (tableStyle.TableProperties.Width.EndsWith("in"))
									wdPx	= SizeConverter.InchToPixelAsString(wd);

								if (wdPx.Length > 0)
									style	= "width=\""+wdPx.Replace("px", "")+"\" ";
							}
							catch(Exception ex)
							{
								if (this.OnWarning != null)
								{
									AODLWarning warning			= new AODLWarning("Exception while trying to build a table width width.: "
										+ tableStyle.TableProperties.Width, ex);
									//warning.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
									//warning.OriginalException	= ex;
									OnWarning(warning);
								}
							}
						}
						if (tableStyle.TableProperties.Align != null)
							if (tableStyle.TableProperties.Align != "margin")
								if (tableStyle.TableProperties.Align == "center")
									style	+= "align=\"center\" ";
								else if (tableStyle.TableProperties.Align == "right")
									style	+= "align=\"center\" "; //Because display prob by some browser
					}
				}
			}
			catch(Exception ex)
			{
				throw new AODLException("Exception while trying to build a HTML style string from a TableStyle.", ex);
			}

			return style;
		}
Ejemplo n.º 15
0
        /// <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;
        }
Ejemplo n.º 16
0
		/// <summary>
		/// Gets the frame style as HTML.
		/// </summary>
		/// <param name="frame">The frame.</param>
		/// <returns></returns>
		public string GetFrameStyleAsHtml(Frame frame)
		{
			string style		= "";

			try
			{
				if (frame != null)
				{
					string width		= frame.SvgWidth;
					if (width != null)
						if (width.EndsWith("cm"))
							width		= width.Replace("cm", "");
						else if (width.EndsWith("in"))
							width		= width.Replace("in", "");

					string height		= frame.SvgHeight;
					if (height != null)
						if (height.EndsWith("cm"))
							height		= height.Replace("cm", "");
						else if (height.EndsWith("in"))
							height		= height.Replace("in", "");

					try
					{
						if (width != null)
						{
							double wd	= Convert.ToDouble(width, System.Globalization.NumberFormatInfo.InvariantInfo);
							string wdPx	= "";
							if (frame.SvgWidth.EndsWith("cm"))
								wdPx	= SizeConverter.CmToPixelAsString(wd);
							else if (frame.SvgWidth.EndsWith("in"))
								wdPx	= SizeConverter.InchToPixelAsString(wd);

							if (wdPx.Length > 0)
								style	= "width=\""+wdPx+"\" ";
						}

						if (height != null)
						{
							double wd	= Convert.ToDouble(height, System.Globalization.NumberFormatInfo.InvariantInfo);
							string wdPx	= "";
							if (frame.SvgHeight.EndsWith("cm"))
								wdPx	= SizeConverter.CmToPixelAsString(wd);
							else if (frame.SvgHeight.EndsWith("in"))
								wdPx	= SizeConverter.InchToPixelAsString(wd);

							if (wdPx.Length > 0)
								style	= "height=\""+wdPx+"\" ";
						}
					}
					catch(Exception ex)
					{
						if (this.OnWarning != null)
						{
							AODLWarning warning			= new AODLWarning("Exception while trying to build a graphic width & height.: "
								+ frame.SvgWidth + "/" + frame.SvgHeight, ex);
							//warning.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
							//warning.OriginalException	= ex;
							OnWarning(warning);
						}
					}
				}
			}
			catch(Exception ex)
			{
				throw new AODLException("Exception while trying to build a HTML style string from a FrameStyle.", ex);
			}

			return style;
		}
Ejemplo n.º 17
0
        /// <summary>
        /// Creates the content.
        /// </summary>
        /// <param name="node">The node.</param>
        public void CreateMainContent(XmlNode node)
        {
            try
            {
                foreach(XmlNode nodeChild in node.ChildNodes)
                {
                    IContent iContent		= this.CreateContent(nodeChild.CloneNode(true));

                    if(iContent != null)
                        this._document.Content.Add(iContent);
                    else
                    {
                        if(this.OnWarning != null)
                        {
                            AODLWarning warning			= new AODLWarning("A couldn't create any content from an an first level node!.");
                            warning.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
                            warning.Node				= nodeChild;
                            this.OnWarning(warning);
                        }
                    }
                }
            }
            catch(Exception ex)
            {
                AODLException exception		= new AODLException("Exception while processing a content node.");
                exception.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
                exception.Node				= node;
                exception.OriginalException	= ex;

                throw exception;
            }
        }
		/// <summary>
		/// Gets the I content collection as HTML.
		/// </summary>
		/// <param name="iContentCollection">The i content collection.</param>
		/// <returns></returns>
		public string GetIContentCollectionAsHtml(ContentCollection iContentCollection)
		{
			string html					= "";

			try
			{
				if (iContentCollection != null)
				{
					foreach(IContent iContent in iContentCollection)
					{
						//determine type
						if (iContent is Table)
							html			+= this.GetTableAsHtml(iContent as Table);
						else if (iContent is ODFControlRef)
							html			+= this.GetODFControlAsHtml(iContent as ODFControlRef);
						else if (iContent is Field)
							html			+= this.GetFieldAsHtml(iContent as Field);
						else if (iContent is Paragraph)
							html			+= this.GetParagraphAsHtml(iContent as Paragraph);
						else if (iContent is List)
							html			+= this.GetListAsHtml(iContent as List);
						else if (iContent is Frame)
							html			+= this.GetDrawFrameAsHtml(iContent as Frame);
						else if (iContent is DrawTextBox)
							html			+= this.GetDrawTextBoxAsHtml(iContent as DrawTextBox);
						else if (iContent is Graphic)
							html			+= this.GetGraphicAsHtml(iContent as Graphic);
						else if (iContent is ListItem)
							html			+= this.GetListItemAsHtml(iContent as ListItem);
						else if (iContent is Header)
							html			+= this.GetHeadingAsHtml(iContent as Header);
						else if (iContent is TableOfContents)
							html			+= this.GetTableOfContentsAsHtml(iContent as TableOfContents);
						else if (iContent is UnknownContent)
							html			+= this.GetUnknowContentAsHtml(iContent as UnknownContent);
						else if (iContent is ImageMap)
							html			+= this.GetImageMapAsHtml(iContent as ImageMap);
						else if (iContent is DrawArea)
							html			+= this.GetDrawAreaAsHtml(iContent as DrawArea);
						else
							//this should never happens, because all not implemented elements 
							//are unknwon content
							if (OnWarning != null)
						{
							AODLWarning warning			= new AODLWarning("Finding total unknown content. This should (could) never happen.");
							//warning.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
							OnWarning(warning);
						}
					}
				}
			}
			catch(Exception ex)
			{
				throw new AODLException("Exception while trying to build a HTML string from an IContentCollection.", ex);
			}

			return html;
		}
Ejemplo n.º 19
0
        /// <summary>
        /// Creates the paragraph.
        /// </summary>
        /// <param name="paragraphNode">The paragraph node.</param>
        public Paragraph CreateParagraph(XmlNode paragraphNode)
        {
            try
            {
                //Create a new Paragraph
                Paragraph paragraph				= new Paragraph(paragraphNode, this._document);
                //Recieve the ParagraphStyle
                IStyle paragraphStyle			= this._document.Styles.GetStyleByName(paragraph.StyleName);

                if(paragraphStyle != null)
                {
                    paragraph.Style				= paragraphStyle;
                }
                else if(paragraph.StyleName != "Standard"
                    && paragraph.StyleName != "Table_20_Contents"
                    && paragraph.StyleName != "Text_20_body"
                    && this._document is TextDocument)
                {
                    //Check if it's a user defined style
                    IStyle commonStyle			= this._document.CommonStyles.GetStyleByName(paragraph.StyleName);
                    if(commonStyle == null)
                    {
                        if(this.OnWarning != null)
                        {
                            AODLWarning warning			= new AODLWarning("A ParagraphStyle wasn't found.");
                            warning.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
                            warning.Node				= paragraphNode;
                            this.OnWarning(warning);
                        }
                        #region Old code Todo: delete
                        //					XmlNode styleNode		= this._document.XmlDoc.SelectSingleNode(
                        //						"/office:document-content/office:automatic-styles/style:style[@style:name='"+p.Stylename+"']",
                        //						this._document.NamespaceManager);
                        //
                        //					XmlNode styles			= this._document.XmlDoc.SelectSingleNode(
                        //						"/office:document-content/office:automatic-styles",
                        //						this._document.NamespaceManager);
                        //
                        //					if(styleNode != null)
                        //					{
                        //						ParagraphStyle pstyle		= new ParagraphStyle(p, styleNode);
                        //
                        //						XmlNode propertieNode		= styleNode.SelectSingleNode("style:paragraph-properties",
                        //							this._document.NamespaceManager);
                        //
                        //						XmlNode txtpropertieNode	= styleNode.SelectSingleNode("style:text-properties",
                        //							this._document.NamespaceManager);
                        //
                        //						ParagraphProperties pp		= null;
                        //
                        //						XmlNode tabstyles			= null;
                        //
                        //						if(propertieNode != null)
                        //						{
                        //							tabstyles				= styleNode.SelectSingleNode("style:tab-stops",
                        //								this._document.NamespaceManager);
                        //							pp	= new ParagraphProperties(pstyle, propertieNode);
                        //						}
                        //						else
                        //							pp	= new ParagraphProperties(pstyle);
                        //
                        //						pstyle.Properties			= pp;
                        //						if(tabstyles != null)
                        //							pstyle.Properties.TabStopStyleCollection	= this.GetTabStopStyles(tabstyles);
                        //						p.Style						= pstyle;
                        //
                        //						if(txtpropertieNode != null)
                        //						{
                        //							TextProperties tt		= new TextProperties(p.Style);
                        //							tt.Node					= txtpropertieNode;
                        //							((ParagraphStyle)p.Style).Textproperties = tt;
                        //						}
                        //					}
                        #endregion
                    }
                }

                return this.ReadParagraphTextContent(paragraph);
            }
            catch(Exception ex)
            {
                AODLException exception		= new AODLException("Exception while trying to create a Paragraph.");
                exception.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
                exception.Node				= paragraphNode;
                exception.OriginalException	= ex;

                throw exception;
            }
        }
		/// <summary>
		/// Gets the tab stop as HTML.
		/// Because of the fact that no tabstop html element exist,
		/// AODL will try to simulate this with a the non breaking 
		/// line entity.
		/// </summary>
		/// <param name="tabStop">The tab stop.</param>
		/// <param name="tabStopIndex">The tab stop position from all tabstops from the textcollectio,
		/// where this tabstop belongs to.</param>
		/// <param name="htmlStringBefore">The complete html string before this tabstop.</param>
		/// <param name="paragraphStyle">The paragraph style from the enclosing paragraph.</param>
		/// <returns></returns>
		public string GetTabStopAsHtml(TabStop tabStop, int tabStopIndex, string htmlStringBefore, ParagraphStyle paragraphStyle)
		{
			//simulate a tabstop in html
			string htmlTab				= "&nbsp;&nbsp;&nbsp;&nbsp;";
			string html					= "";

			try
			{
				if (paragraphStyle != null)
					if (paragraphStyle.ParagraphProperties != null)
						if (paragraphStyle.ParagraphProperties.TabStopStyleCollection != null)
							if (paragraphStyle.ParagraphProperties.TabStopStyleCollection.Count-1 <= tabStopIndex)
							{
								TabStopStyle tabStopStyle = paragraphStyle.ParagraphProperties.TabStopStyleCollection[tabStopIndex];
								
								string leadingChar			= "&nbsp;";								
								if (tabStopStyle.LeaderText != null)
									leadingChar				= tabStopStyle.LeaderText;
								
								string[] grabInt			= tabStopStyle.Position.Split('.');
								if (grabInt.Length == 2)
								{
									double position			= Convert.ToDouble(grabInt[0]);
									//expecting that one displaying character will ~ .5cm
									if (htmlStringBefore != null)
									{
										for(int i=0; i<htmlStringBefore.Length; i++)
											position		-= 0.5;
									}
									
									if (position > 0.5)
										for(double i=0; i<position; i+=0.25)
											html			+= leadingChar;
								}
							}
			}
			catch(Exception ex)
			{
				if (OnWarning != null)
				{
					AODLWarning warning			= new AODLWarning("Exception while trying to build a simulated html tabstop.", ex);
					//warning.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
					//warning.OriginalException	= ex;
					OnWarning(warning);
				}
			}

			if (html.Length == 0)
				html				= htmlTab;

			return html;
		}
Ejemplo n.º 21
0
        /// <summary>
        /// Creates the draw text box.
        /// </summary>
        /// <param name="drawTextBoxNode">The draw text box node.</param>
        /// <returns></returns>
        private DrawTextBox CreateDrawTextBox(XmlNode drawTextBoxNode)
        {
            try
            {
                DrawTextBox drawTextBox		= new DrawTextBox(this._document, drawTextBoxNode);
                IContentCollection iColl	= new IContentCollection();

                foreach(XmlNode nodeChild in drawTextBox.Node.ChildNodes)
                {
                    IContent iContent				= this.CreateContent(nodeChild);
                    if(iContent != null)
                        iColl.Add(iContent);
                    else
                    {
                        if(this.OnWarning != null)
                        {
                            AODLWarning warning			= new AODLWarning("Couldn't create a IContent object for a DrawTextBox.");
                            warning.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
                            warning.Node				= nodeChild;
                            this.OnWarning(warning);
                        }
                    }
                }

                drawTextBox.Node.InnerXml					= "";

                foreach(IContent iContent in iColl)
                    drawTextBox.Content.Add(iContent);

                return drawTextBox;
            }
            catch(Exception ex)
            {
                AODLException exception		= new AODLException("Exception while trying to create a Graphic.");
                exception.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
                exception.Node				= drawTextBoxNode;
                exception.OriginalException	= ex;

                throw exception;
            }
        }
		/// <summary>
		/// Gets the I text collection as HTML.
		/// </summary>
		/// <param name="iTextCollection">The i text collection.</param>
		/// <param name="paragraphStyle">The paragraph style.</param>
		/// <returns></returns>
		public string GetITextCollectionAsHtml(ITextCollection iTextCollection, ParagraphStyle paragraphStyle)
		{
			string html					= "";
			int tabStopCnt				= 0;

			try
			{
				if (iTextCollection != null)
				{
					foreach(IText iText in iTextCollection)
					{
						//determine type
						if (iText is SimpleText)
						{
							string textContent	= iText.Node.InnerText;
							html				+= this.ReplaceControlNodes(textContent);
						}
						else if (iText is FormatedText)
							html			+= this.GetFormatedTextAsHtml(iText as FormatedText);
						else if (iText is WhiteSpace)
							html			+= this.GetWhiteSpacesAsHtml(iText as WhiteSpace);
						else if (iText is TabStop)
						{
							html			+= this.GetTabStopAsHtml(iText as TabStop, tabStopCnt, html, paragraphStyle);
							tabStopCnt++;
						}
						else if (iText is XLink)
							html			+= this.GetXLinkAsHtml(iText as XLink);
						else if (iText is LineBreak)
							html			+= this.GetLineBreakAsHtml();
						else if (iText is UnknownTextContent)
							html			+= this.GetUnknowTextContentAsHtml(iText as UnknownTextContent);
						else
							//this should never happens, because all not implemented elements 
							//are unknwon content
							if (OnWarning != null)
						{
							AODLWarning warning			= new AODLWarning("Finding total unknown text content. This should (could) never happen.");
							//warning.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
							OnWarning(warning);
						}
					}
				}
			}
			catch(Exception ex)
			{
				throw new AODLException("Exception while trying to build a HTML string from an ITextCollection.", ex);
			}

			return html;
		}
Ejemplo n.º 23
0
        /// <summary>
        /// Creates the list item.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <returns></returns>
        private ListItem CreateListItem(XmlNode node)
        {
            try
            {

                ListItem listItem			= new ListItem(this._document);
                IContentCollection iColl	= new IContentCollection();
                listItem.Node				= node;

                foreach(XmlNode nodeChild in listItem.Node.ChildNodes)
                {
                    IContent iContent		= this.CreateContent(nodeChild);
                    if(iContent != null)
                        iColl.Add(iContent);
                    else
                    {
                        if(this.OnWarning != null)
                        {
                            AODLWarning warning			= new AODLWarning("Couldn't create a IContent object for a ListItem.");
                            warning.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
                            warning.Node				= nodeChild;
                            this.OnWarning(warning);
                        }
                    }
                }

                listItem.Node.InnerXml		= "";

                foreach(IContent iContent in iColl)
                    listItem.Content.Add(iContent);

                return listItem;
            }
            catch(Exception ex)
            {
                AODLException exception		= new AODLException("Exception while trying to create a ListItem.");
                exception.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
                exception.Node				= node;
                exception.OriginalException	= ex;

                throw exception;
            }
        }
		/// <summary>
		/// Gets the outline string.
		/// </summary>
		/// <param name="header">The header.</param>
		/// <returns></returns>
		private string GetOutlineString(Header header)
		{
			try
			{
				int outline1		= 0;
				int outline2		= 0;
				int outline3		= 0;
				int outline4		= 0;
				int outline5		= 0;
				int outline6		= 0;

				if (header.Document != null)
				{
					if (header.Document is TextDocuments.TextDocument && header.Document.Content != null)
					{
						foreach(IContent content in header.Document.Content)
							if (content is Header)
								if (((Header)content).OutLineLevel != null)
								{
									int no	= Convert.ToInt32(((Header)content).OutLineLevel);
									if (no == 1)
									{
										outline1++;
										outline2	= 0;
										outline3	= 0;
										outline4	= 0;
										outline5	= 0;
										outline6	= 0;
									}
									else if (no == 2)
										outline2++;
									else if (no == 3)
										outline3++;
									else if (no == 4)
										outline4++;
									else if (no == 5)
										outline5++;
									else if (no == 6)
										outline6++;

									if (content == header)
									{
										string sNumber		= outline1.ToString()+".";
										string sNumber1		= "";
										if (outline6 != 0)
											sNumber1		= "."+outline6.ToString()+".";
										if (outline5 != 0)
											sNumber1		= sNumber1+"."+outline5.ToString()+".";
										if (outline4 != 0)
											sNumber1		= sNumber1+"."+outline4.ToString()+".";
										if (outline3 != 0)
											sNumber1		= sNumber1+"."+outline3.ToString()+".";
										if (outline2 != 0)
											sNumber1		= sNumber1+"."+outline2.ToString()+".";
								
										sNumber				+= sNumber1;

										return sNumber.Replace("..",".");
									}
								}
					}
				}
			}
			catch(Exception ex)
			{
				if (OnWarning != null)
				{
					AODLWarning warning			= new AODLWarning("Exception while trying to get a outline string for a heading.", ex);
					//warning.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
					//warning.OriginalException	= ex;
					warning.Node				= header.Node;
					OnWarning(warning);
				}
			}
			return null;
		}
Ejemplo n.º 25
0
        /// <summary>
        /// Creates the table.
        /// </summary>
        /// <param name="tableNode">The tablenode.</param>
        /// <returns></returns>
        private Table CreateTable(XmlNode tableNode)
        {
            try
            {
                //Create a new table
                Table table					= new Table(this._document, tableNode);
                IContentCollection iColl	= new IContentCollection();
                //Recieve the table style
                IStyle tableStyle		= this._document.Styles.GetStyleByName(table.StyleName);

                if(tableStyle != null)
                    table.Style				= tableStyle;
                else
                {
                    if(this.OnWarning != null)
                    {
                        AODLWarning warning			= new AODLWarning("Couldn't recieve a TableStyle.");
                        warning.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
                        warning.Node				= tableNode;
                        this.OnWarning(warning);
                    }
                }

                //Create the table content
                foreach(XmlNode nodeChild in table.Node.ChildNodes)
                {
                    IContent iContent				= this.CreateContent(nodeChild);

                    if(iContent != null)
                    {
                        iColl.Add(iContent);
                    }
                    else
                    {
                        if(this.OnWarning != null)
                        {
                            AODLWarning warning			= new AODLWarning("Couldn't create IContent from a table node. Content is unknown table content!");
                            warning.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
                            warning.Node				= iContent.Node;
                            this.OnWarning(warning);
                        }
                    }
                }

                table.Node.InnerText					= "";

                foreach(IContent iContent in iColl)
                {
                    if(iContent is Column)
                    {
                        ((Column)iContent).Table	= table;
                        table.ColumnCollection.Add(iContent as Column);
                    }
                    else if(iContent is Row)
                    {
                        ((Row)iContent).Table		= table;
                        table.RowCollection.Add(iContent as Row);
                    }
                    else if(iContent is RowHeader)
                    {
                        ((RowHeader)iContent).Table	= table;
                        table.RowHeader			= iContent as RowHeader;
                    }
                    else
                    {
                        if(this.OnWarning != null)
                        {
                            AODLWarning warning			= new AODLWarning("Couldn't create IContent from a table node.");
                            warning.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
                            warning.Node				= tableNode;
                            this.OnWarning(warning);
                            table.Node.AppendChild(iContent.Node);
                        }
                    }
                }

                return table;
            }
            catch(Exception ex)
            {
                AODLException exception		= new AODLException("Exception while trying to create a Table.");
                exception.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
                exception.Node				= tableNode;
                exception.OriginalException	= ex;

                throw exception;
            }
        }
Ejemplo n.º 26
0
 /// <summary>
 /// MCP_s the on warning.
 /// </summary>
 /// <param name="warning">The warning.</param>
 private void mcp_OnWarning(AODL.Document.Exceptions.AODLWarning warning)
 {
     this._importError.Add(warning);
 }
Ejemplo n.º 27
0
		/// <summary>
		/// Gets the column style as HTML.
		/// </summary>
		/// <param name="columnStyle">The column style.</param>
		/// <returns></returns>
		public string GetColumnStyleAsHtml(ColumnStyle columnStyle)
		{
			string style		= "";

			try
			{
				if (columnStyle != null)
				{
					if (columnStyle.ColumnProperties != null)
					{
						if (columnStyle.ColumnProperties.Width != null)
						{
							string width	= columnStyle.ColumnProperties.Width;
							if (width.EndsWith("cm"))
								width		= width.Replace("cm", "");
							else if (width.EndsWith("in"))
								width		= width.Replace("in", "");

							try
							{
								double wd	= Convert.ToDouble(width, System.Globalization.NumberFormatInfo.InvariantInfo);
								string wdPx	= "";
								if (columnStyle.ColumnProperties.Width.EndsWith("cm"))
									wdPx	= SizeConverter.CmToPixelAsString(wd);
								else if (columnStyle.ColumnProperties.Width.EndsWith("in"))
									wdPx	= SizeConverter.InchToPixelAsString(wd);

								if (wdPx.Length > 0)
									style	= "width=\""+wdPx+"\" ";
							}
							catch(Exception ex)
							{
								if (this.OnWarning != null)
								{
									AODLWarning warning			= new AODLWarning("Exception while trying to build a column width.: "
										+ columnStyle.ColumnProperties.Width, ex);
									//warning.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
									//warning.OriginalException	= ex;
									OnWarning(warning);
								}
							}							
						}
					}
				}
			}
			catch(Exception ex)
			{
				throw new AODLException("Exception while trying to build a HTML style string from a CellStyle.", ex);
			}

			return style;
		}
Ejemplo n.º 28
0
		/// <summary>
		/// Imports the specified filename.
		/// </summary>
		/// <param name="document">The TextDocument to fill.</param>
		/// <param name="filename">The filename.</param>
		/// <returns>The created TextDocument</returns>
		public void Import(IDocument document, string filename)
		{
			this._document			= document;
			string text				= this.ReadContentFromFile(filename);
			
			if (text.Length > 0)
				this.ReadTextToDocument(text);
			else
			{
				AODLWarning warning	= new AODLWarning("Empty file. ["+filename+"]");
				this.ImportError.Add(warning);
			}
		}
Ejemplo n.º 29
0
		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);
			}
		}