/// <summary> /// create the main content of the chart /// </summary> /// <param name="node"></param> public void CreateMainContent(XmlNode node) { try { foreach (XmlNode nodeChild in node.ChildNodes) { IContent iContent = this.CreateContent(nodeChild.CloneNode(true)); if (iContent != null) { AddToCollection(iContent, this.Chart.Content); } //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) { throw new AODLException("Exception while processing a content node.", ex); } }
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); } }
// /// <summary> // /// Cleans the up directory. // /// </summary> // /// <param name="directory">The directory.</param> // private void CleanUpDirectory(string directory) // { // string dirpics = Environment.CurrentDirectory+@"\PicturesRead\"; // // try // { // foreach(string d in this._directories) // Directory.Delete(directory+@"\"+d, true); // //// if(Directory.Exists(OpenDocumentTextImporter.dirpics)) //// Directory.Delete(OpenDocumentTextImporter.dirpics, true); // if(Directory.Exists(dirpics)) // Directory.Delete(dirpics, true); // // File.Delete(directory+DocumentMetadata.FileName); // File.Delete(directory+DocumentSetting.FileName); // File.Delete(directory+DocumentStyles.FileName); // File.Delete(directory+"content.xml"); // } // catch(Exception ex) // { // throw; // } // } #endregion /// <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; } }
/// <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> /// 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); } }
/// <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); } }
/// <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); }
/// <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); }
/// <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); }
private void TextContentProcessor_OnWarning(AODLWarning warning) { _importError.Add(warning); }
/// <summary> /// MCP_s the on warning. /// </summary> /// <param name="warning">The warning.</param> private void mcp_OnWarning(AODLWarning warning) { _importError.Add(warning); }