Пример #1
0
        /// <summary>
        /// Creates a simple text content and adds it to the provided content collection.
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="content"></param>
        /// <param name="value">The value to write. May be null.</param>
        protected static void CreateAddSimpleText(IDocument doc, IContentCollection content, object value)
        {
            Paragraph p = ParagraphBuilder.CreateStandardTextParagraph(doc);
            p.TextContent.Add(new SimpleText(doc, Convert.ToString(value ?? string.Empty)));

            content.Add(p);
        }
Пример #2
0
 /// <summary>
 /// Convert a AODL IContentCollection into an ArrayList of IElement iText objects.
 /// </summary>
 /// <param name="iContentCollection">The i content collection.</param>
 /// <returns>An ArrayList of iText IElement objects.</returns>
 public static ArrayList GetMixedPdfContent(IContentCollection iContentCollection)
 {
     try
     {
         ArrayList mixedPdfContent = new ArrayList();
         foreach(IContent content in iContentCollection)
         {
             if(content is AODL.Document.Content.Text.Paragraph)
             {
                 if(((AODL.Document.Content.Text.Paragraph)content).MixedContent != null
                     && ((AODL.Document.Content.Text.Paragraph)content).MixedContent.Count > 0)
                         mixedPdfContent.Add(ParagraphConverter.Convert(
                             content as AODL.Document.Content.Text.Paragraph));
                 else
                     mixedPdfContent.Add(iTextSharp.text.Chunk.NEWLINE);
             }
             else if(content is AODL.Document.Content.Text.Header)
             {
                 mixedPdfContent.Add(HeadingConverter.Convert(
                     content as AODL.Document.Content.Text.Header));
             }
             else if(content is AODL.Document.Content.Tables.Table)
             {
                 TableConverter tc = new TableConverter();
                 mixedPdfContent.Add(tc.Convert(
                     content as AODL.Document.Content.Tables.Table));
             }
             else if(content is AODL.Document.Content.Draw.Frame)
             {
                 DrawFrameConverter dfc = new DrawFrameConverter();
                 mixedPdfContent.Add(dfc.Convert(
                     content as AODL.Document.Content.Draw.Frame));
             }
             else if(content is AODL.Document.Content.Draw.Graphic)
             {
                  ImageConverter ic = new ImageConverter();
                 mixedPdfContent.Add(ic.Convert(
                     content as AODL.Document.Content.Draw.Graphic));
             }
         }
         return mixedPdfContent;
     }
     catch(Exception ex)
     {
         throw;
     }
 }
Пример #3
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;
            }
        }
Пример #4
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;
            }
        }
Пример #5
0
        /// <summary>
        /// Creates the list.
        /// </summary>
        /// <param name="listNode">The list node.</param>
        /// <returns>The List object</returns>
        private List CreateList(XmlNode listNode)
        {
            try
            {
                #region Old code Todo: delete
                //				string stylename				= null;
                //				XmlNode	stylenode				= null;
                //				ListStyles liststyles			= ListStyles.Bullet; //as default
                //				string paragraphstylename		= null;
                //
                //				if(outerlist == null)
                //				{
                //					stylename			= this.GetStyleName(listNode.OuterXml);
                //					stylenode			= this.GetAStyleNode("text:list-style", stylename);
                //					liststyles			= this.GetListStyle(listNode);
                //				}
                //				List list					= null;
                //
                //				if(listNode.ChildNodes.Count > 0)
                //				{
                //					try
                //					{
                //						paragraphstylename	= this.GetAValueFromAnAttribute(listNode.ChildNodes.Item(0).ChildNodes.Item(0), "@style:style-name");
                //					}
                //					catch(Exception ex)
                //					{
                //						paragraphstylename	= "P1";
                //					}
                //				}
                #endregion
                //Create a new List
                List list					= new List(this._document, listNode);
                IContentCollection iColl	= new IContentCollection();
                //Revieve the ListStyle
                IStyle listStyle			= this._document.Styles.GetStyleByName(list.StyleName);

                if(listStyle != null)
                    list.Style				= listStyle;

                foreach(XmlNode nodeChild in list.Node.ChildNodes)
                {
                    IContent iContent		= this.CreateContent(nodeChild);

                    if(iContent != null)
                        iColl.Add(iContent);
                }

                list.Node.InnerXml			= "";

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

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

                throw exception;
            }
        }
Пример #6
0
        /// <summary>
        /// Creates the image map.
        /// </summary>
        /// <param name="imageMapNode">The image map node.</param>
        /// <returns></returns>
        private ImageMap CreateImageMap(XmlNode imageMapNode)
        {
            try
            {
                ImageMap imageMap			= new ImageMap(this._document, imageMapNode);
                IContentCollection iCol		= new IContentCollection();

                if(imageMap.Node != null)
                    foreach(XmlNode nodeChild in imageMap.Node.ChildNodes)
                    {
                        IContent iContent	= this.CreateContent(nodeChild);
                        if(iContent != null)
                            iCol.Add(iContent);
                    }

                imageMap.Node.InnerXml		= "";

                foreach(IContent iContent in iCol)
                    imageMap.Content.Add(iContent);

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

                throw exception;
            }
        }
Пример #7
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;
            }
        }
Пример #8
0
        /// <summary>
        /// Creates the draw area rectangle.
        /// </summary>
        /// <param name="drawAreaRectangleNode">The draw area rectangle node.</param>
        /// <returns></returns>
        private DrawAreaRectangle CreateDrawAreaRectangle(XmlNode drawAreaRectangleNode)
        {
            try
            {
                DrawAreaRectangle dAreaRec	= new DrawAreaRectangle(this._document, drawAreaRectangleNode);
                IContentCollection iCol		= new IContentCollection();

                if(dAreaRec.Node != null)
                    foreach(XmlNode nodeChild in dAreaRec.Node.ChildNodes)
                    {
                        IContent iContent	= this.CreateContent(nodeChild);
                        if(iContent != null)
                            iCol.Add(iContent);
                    }

                dAreaRec.Node.InnerXml		= "";

                foreach(IContent iContent in iCol)
                    dAreaRec.Content.Add(iContent);

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

                throw exception;
            }
        }
Пример #9
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;
            }
        }
Пример #10
0
        /// <summary>
        /// Creates the event listeners.
        /// </summary>
        /// <param name="eventListenersNode">The event listeners node.</param>
        /// <returns></returns>
        public EventListeners CreateEventListeners(XmlNode eventListenersNode)
        {
            try
            {
                EventListeners eventList	= new EventListeners(this._document, eventListenersNode);
                IContentCollection iCol		= new IContentCollection();

                if(eventList.Node != null)
                    foreach(XmlNode nodeChild in eventList.Node.ChildNodes)
                    {
                        IContent iContent	= this.CreateContent(nodeChild);
                        if(iContent != null)
                            iCol.Add(iContent);
                    }

                eventList.Node.InnerXml		= "";

                foreach(IContent iContent in iCol)
                    eventList.Content.Add(iContent);

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

                throw exception;
            }
        }
Пример #11
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;
            }
        }
Пример #12
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;
            }
        }
Пример #13
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;
            }
        }
Пример #14
0
        /// <summary>
        /// Gets the I content collection as HTML.
        /// </summary>
        /// <param name="iContentCollection">The i content collection.</param>
        /// <returns></returns>
        public string GetIContentCollectionAsHtml(IContentCollection 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 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)
            {
                AODLException exception		= new AODLException("Exception while trying to build a HTML string from an IContentCollection.");
                exception.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
                exception.OriginalException	= ex;

                throw exception;
            }

            return html;
        }
Пример #15
0
        /// <summary>
        /// Appends the HTML.
        /// </summary>
        /// <param name="contentlist">The contentlist.</param>
        /// <param name="template">The template.</param>
        /// <returns>The filled template string</returns>
        private string AppendHtml(IContentCollection contentlist, string template)
        {
            try
            {
                HTMLContentBuilder htmlContentBuilder	= new HTMLContentBuilder();
                htmlContentBuilder.GraphicTargetFolder	= this._imgFolder;
                string htmlBody							= htmlContentBuilder.GetIContentCollectionAsHtml(this._document.Content);
                template								+= htmlBody;

            //				foreach(IContent content in contentlist)
            //					if(content is IHtml)
            //						template	+= this.ReplaceControlNodes(((IHtml)content).GetHtml());

                template		+= "</body>\n</html>";

                template		= this.SetMetaContent(template);

                return template;
            }
            catch(Exception ex)
            {
                throw;
            }
        }
Пример #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextPageFooter"/> class.
 /// </summary>
 protected TextPageHeaderFooterBase()
 {
     this._contentCollection = new IContentCollection();
 }