StaticColumns _StaticColumns; // Static column headings for this grouping public ColumnGrouping(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p) { _Height=null; _DynamicColumns=null; _StaticColumns=null; // Loop thru all the child nodes foreach(XmlNode xNodeLoop in xNode.ChildNodes) { if (xNodeLoop.NodeType != XmlNodeType.Element) continue; switch (xNodeLoop.Name) { case "Height": _Height = new RSize(r, xNodeLoop); break; case "DynamicColumns": _DynamicColumns = new DynamicColumns(r, this, xNodeLoop); break; case "StaticColumns": _StaticColumns = new StaticColumns(r, this, xNodeLoop); break; default: break; } } if (_Height == null) OwnerReport.rl.LogError(8, "ColumnGrouping requires the Height element to be specified."); if ((_DynamicColumns != null && _StaticColumns != null) || (_DynamicColumns == null && _StaticColumns == null)) OwnerReport.rl.LogError(8, "ColumnGrouping requires either the DynamicColumns element or StaticColumns element but not both."); }
Style _Style; // Defines the border and background style // properties for the marker(s). public Marker(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p) { _Type=MarkerTypeEnum.None; _Size=null; _Style=null; // Loop thru all the child nodes foreach(XmlNode xNodeLoop in xNode.ChildNodes) { if (xNodeLoop.NodeType != XmlNodeType.Element) continue; switch (xNodeLoop.Name) { case "Type": _Type = MarkerType.GetStyle(xNodeLoop.InnerText, OwnerReport.rl); break; case "Size": _Size = new RSize(r, xNodeLoop); break; case "Style": _Style = new Style(r, this, xNodeLoop); break; default: break; } } }
List<Textbox> _GrowList; // list of TextBox's that need to be checked for growth public TableRow(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p) { _TableCells=null; _Height=null; _Visibility=null; _CanGrow = false; _GrowList = null; // Loop thru all the child nodes foreach(XmlNode xNodeLoop in xNode.ChildNodes) { if (xNodeLoop.NodeType != XmlNodeType.Element) continue; switch (xNodeLoop.Name) { case "TableCells": _TableCells = new TableCells(r, this, xNodeLoop); break; case "Height": _Height = new RSize(r, xNodeLoop); break; case "Visibility": _Visibility = new Visibility(r, this, xNodeLoop); break; default: // don't know this element - log it OwnerReport.rl.LogError(4, "Unknown TableRow element '" + xNodeLoop.Name + "' ignored."); break; } } if (_TableCells == null) OwnerReport.rl.LogError(8, "TableRow requires the TableCells element."); if (_Height == null) OwnerReport.rl.LogError(8, "TableRow requires the Height element."); }
StaticRows _StaticRows; // Static row headings for this grouping public RowGrouping(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p) { _Width=null; _DynamicRows=null; _StaticRows=null; // Loop thru all the child nodes foreach(XmlNode xNodeLoop in xNode.ChildNodes) { if (xNodeLoop.NodeType != XmlNodeType.Element) continue; switch (xNodeLoop.Name) { case "Width": _Width = new RSize(r, xNodeLoop); break; case "DynamicRows": _DynamicRows = new DynamicRows(r, this, xNodeLoop); break; case "StaticRows": _StaticRows = new StaticRows(r, this, xNodeLoop); break; default: // don't know this element - log it OwnerReport.rl.LogError(4, "Unknown RowGrouping element '" + xNodeLoop.Name + "' ignored."); break; } } if (_Width == null) OwnerReport.rl.LogError(8, "RowGrouping requires the Width element."); }
MatrixCells _MatrixCells; // The set of cells in a row in the detail section of the Matrix. public MatrixRow(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p) { _Height=null; _MatrixCells=null; // Loop thru all the child nodes foreach(XmlNode xNodeLoop in xNode.ChildNodes) { if (xNodeLoop.NodeType != XmlNodeType.Element) continue; switch (xNodeLoop.Name) { case "Height": _Height = new RSize(r, xNodeLoop); break; case "MatrixCells": _MatrixCells = new MatrixCells(r, this, xNodeLoop); break; default: break; } } if (_MatrixCells == null) OwnerReport.rl.LogError(8, "MatrixRow requires the MatrixCells element."); }
RSize _Width; // Width of each detail cell in this column public MatrixColumn(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p) { _Width=null; // Loop thru all the child nodes foreach(XmlNode xNodeLoop in xNode.ChildNodes) { if (xNodeLoop.NodeType != XmlNodeType.Element) continue; switch (xNodeLoop.Name) { case "Width": _Width = new RSize(r, xNodeLoop); break; default: // don't know this element - log it OwnerReport.rl.LogError(4, "Unknown MatrixColumn element '" + xNodeLoop.Name + "' ignored."); break; } } }
Style _Style; // Style information for the page footer public PageFooter(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p) { _Height=null; _PrintOnFirstPage=false; _PrintOnLastPage=false; _ReportItems=null; _Style=null; // Loop thru all the child nodes foreach(XmlNode xNodeLoop in xNode.ChildNodes) { if (xNodeLoop.NodeType != XmlNodeType.Element) continue; switch (xNodeLoop.Name) { case "Height": _Height = new RSize(r, xNodeLoop); break; case "PrintOnFirstPage": _PrintOnFirstPage = XmlUtil.Boolean(xNodeLoop.InnerText, OwnerReport.rl); break; case "PrintOnLastPage": _PrintOnLastPage = XmlUtil.Boolean(xNodeLoop.InnerText, OwnerReport.rl); break; case "ReportItems": _ReportItems = new ReportItems(r, this, xNodeLoop); break; case "Style": _Style = new Style(r, this, xNodeLoop); break; default: // don't know this element - log it OwnerReport.rl.LogError(4, "Unknown PageFooter element '" + xNodeLoop.Name + "' ignored."); break; } } if (_Height == null) OwnerReport.rl.LogError(8, "PageFooter Height is required."); }
StaticRows _StaticRows; // Static row headings for this grouping public RowGrouping(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p) { _Width = null; _DynamicRows = null; _StaticRows = null; // Loop thru all the child nodes foreach (XmlNode xNodeLoop in xNode.ChildNodes) { if (xNodeLoop.NodeType != XmlNodeType.Element) { continue; } switch (xNodeLoop.Name) { case "Width": _Width = new RSize(r, xNodeLoop); break; case "DynamicRows": _DynamicRows = new DynamicRows(r, this, xNodeLoop); break; case "StaticRows": _StaticRows = new StaticRows(r, this, xNodeLoop); break; default: // don't know this element - log it OwnerReport.rl.LogError(4, "Unknown RowGrouping element '" + xNodeLoop.Name + "' ignored."); break; } } if (_Width == null) { OwnerReport.rl.LogError(8, "RowGrouping requires the Width element."); } }
/// <summary> /// Measures the location of words within a string; limited by .Net 1.1 to 32 words /// MEASUREMAX is a constant that defines that limit /// </summary> /// <param name="s"></param> /// <param name="g"></param> /// <param name="drawFont"></param> /// <param name="drawFormat"></param> /// <param name="cra"></param> /// <returns></returns> private WordStartFinish[] MeasureString32(string s, Graphics g, Font drawFont, StringFormat drawFormat, CharacterRange[] cra) { if (s == null || s.Length == 0) { return(null); } drawFormat.SetMeasurableCharacterRanges(cra); Region[] rs = new Region[cra.Length]; rs = g.MeasureCharacterRanges(s, drawFont, new RectangleF(0, 0, float.MaxValue, float.MaxValue), drawFormat); WordStartFinish[] sz = new WordStartFinish[cra.Length]; int isz = 0; foreach (Region r in rs) { RectangleF mr = r.GetBounds(g); sz[isz].start = RSize.PointsFromPixels(g, mr.Left); sz[isz].end = RSize.PointsFromPixels(g, mr.Right); isz++; } return(sz); }
bool _FixedHeader = false; // Header of this column should be display even when scrolled public TableColumn(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p) { _Width = null; _Visibility = null; // Loop thru all the child nodes foreach (XmlNode xNodeLoop in xNode.ChildNodes) { if (xNodeLoop.NodeType != XmlNodeType.Element) { continue; } switch (xNodeLoop.Name) { case "Width": _Width = new RSize(r, xNodeLoop); break; case "Visibility": _Visibility = new Visibility(r, this, xNodeLoop); break; case "FixedHeader": _FixedHeader = XmlUtil.Boolean(xNodeLoop.InnerText, OwnerReport.rl); break; default: // don't know this element - log it OwnerReport.rl.LogError(4, "Unknown TableColumn element '" + xNodeLoop.Name + "' ignored."); break; } } if (_Width == null) { OwnerReport.rl.LogError(8, "TableColumn requires the Width element."); } }
public int WidthCalc(Report rpt, Graphics g) { WorkClass wc = GetWC(rpt); int width; if (this._TC != null) { // must be part of a table Table t = _TC.OwnerTable; int colindex = _TC.ColIndex; // Calculate width: add up all columns within the column span width = 0; TableColumn tc; for (int ci = colindex; ci < colindex + _TC.ColSpan; ci++) { tc = (TableColumn)(t.TableColumns.Items[ci]); width += tc.Width.PixelsX; } } else if (wc.MC != null) { // must be part of a matrix width = g == null?RSize.PixelsFromPoints(wc.MC.Width) : RSize.PixelsFromPoints(g, wc.MC.Width); } else { // not part of a table or matrix if (Width != null) { width = Width.PixelsX; } else { width = RSize.PixelsFromPoints(WidthOrOwnerWidth(rpt)); } } return(width); }
RSize _Width; // Width of each detail cell in this column public MatrixColumn(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p) { _Width = null; // Loop thru all the child nodes foreach (XmlNode xNodeLoop in xNode.ChildNodes) { if (xNodeLoop.NodeType != XmlNodeType.Element) { continue; } switch (xNodeLoop.Name) { case "Width": _Width = new RSize(r, xNodeLoop); break; default: // don't know this element - log it OwnerReport.rl.LogError(4, "Unknown MatrixColumn element '" + xNodeLoop.Name + "' ignored."); break; } } }
public float EvalPaddingBottom(Report rpt, Row row) { if (_PaddingBottom == null) return 0; string v = _PaddingBottom.EvaluateString(rpt, row); RSize rz = new RSize(OwnerReport, v); return rz.Points; }
public int EvalPaddingRightPx(Report rpt, Row row) { if (_PaddingRight == null) return 0; string v = _PaddingRight.EvaluateString(rpt, row); RSize rz = new RSize(OwnerReport, v); return rz.PixelsX; }
static public float PointSize(string v) { RSize rs = new RSize(null, v); return(rs.Points); }
private string[] MeasureString(PageText pt, Graphics g, out float[] width) { StyleInfo si = pt.SI; string s = pt.Text; Font drawFont = null; StringFormat drawFormat = null; SizeF ms; string[] sa = null; width = null; try { // STYLE System.Drawing.FontStyle fs = 0; if (si.FontStyle == FontStyleEnum.Italic) { fs |= System.Drawing.FontStyle.Italic; } // WEIGHT switch (si.FontWeight) { case FontWeightEnum.Bold: case FontWeightEnum.Bolder: case FontWeightEnum.W500: case FontWeightEnum.W600: case FontWeightEnum.W700: case FontWeightEnum.W800: case FontWeightEnum.W900: fs |= System.Drawing.FontStyle.Bold; break; default: break; } drawFont = new Font(StyleInfo.GetFontFamily(si.FontFamilyFull), si.FontSize, fs); drawFormat = new StringFormat(); drawFormat.Alignment = StringAlignment.Near; // Measure string // pt.NoClip indicates that this was generated by PageTextHtml Build. It has already word wrapped. if (pt.NoClip || pt.SI.WritingMode == WritingModeEnum.tb_rl) // TODO: support multiple lines for vertical text { ms = MeasureString(s, g, drawFont, drawFormat); width = new float[1]; width[0] = RSize.PointsFromPixels(g, ms.Width); // convert to points from pixels sa = new string[1]; sa[0] = s; return(sa); } // handle multiple lines; // 1) split the string into the forced line breaks (ie "\n and \r") // 2) foreach of the forced line breaks; break these into words and recombine s = s.Replace("\r\n", "\n"); // don't want this to result in double lines string[] flines = s.Split(lineBreak); List <string> lines = new List <string>(); List <float> lineWidths = new List <float>(); // remove the size reserved for left and right padding float ptWidth = pt.W - pt.SI.PaddingLeft - pt.SI.PaddingRight; if (ptWidth <= 0) { ptWidth = 1; } foreach (string tfl in flines) { string fl; if (tfl.Length > 0 && tfl[tfl.Length - 1] == ' ') { fl = tfl.TrimEnd(' '); } else { fl = tfl; } // Check if entire string fits into a line ms = MeasureString(fl, g, drawFont, drawFormat); float tw = RSize.PointsFromPixels(g, ms.Width); if (tw <= ptWidth) { // line fits don't need to break it down further lines.Add(fl); lineWidths.Add(tw); continue; } // Line too long; need to break into multiple lines // 1) break line into parts; then build up again keeping track of word positions string[] parts = fl.Split(wordBreak); // this is the maximum split of lines StringBuilder sb = new StringBuilder(fl.Length); CharacterRange[] cra = new CharacterRange[parts.Length]; for (int i = 0; i < parts.Length; i++) { int sc = sb.Length; // starting character sb.Append(parts[i]); // endding character if (i != parts.Length - 1) // last item doesn't need blank { sb.Append(" "); } int ec = sb.Length; CharacterRange cr = new CharacterRange(sc, ec - sc); cra[i] = cr; // add to character array } // 2) Measure the word locations within the line string wfl = sb.ToString(); WordStartFinish[] wordLocations = MeasureString(wfl, g, drawFont, drawFormat, cra); if (wordLocations == null) { continue; } // 3) Loop thru creating new lines as needed int startLoc = 0; CharacterRange crs = cra[startLoc]; CharacterRange cre = cra[startLoc]; float cwidth = wordLocations[0].end; // length of the first float bwidth = wordLocations[0].start; // characters need a little extra on start string ts; bool bLine = true; for (int i = 1; i < cra.Length; i++) { cwidth = wordLocations[i].end - wordLocations[startLoc].start + bwidth; if (cwidth > ptWidth) { // time for a new line cre = cra[i - 1]; ts = wfl.Substring(crs.First, cre.First + cre.Length - crs.First); lines.Add(ts); lineWidths.Add(wordLocations[i - 1].end - wordLocations[startLoc].start + bwidth); // Find the first non-blank character of the next line while (i < cra.Length && cra[i].Length == 1 && fl[cra[i].First] == ' ') { i++; } if (i < cra.Length) // any lines left? { // yes, continue on startLoc = i; crs = cre = cra[startLoc]; cwidth = wordLocations[i].end - wordLocations[startLoc].start + bwidth; } else // no, we can stop { bLine = false; } // bwidth = wordLocations[startLoc].start - wordLocations[startLoc - 1].end; } else { cre = cra[i]; } } if (bLine) { ts = fl.Substring(crs.First, cre.First + cre.Length - crs.First); lines.Add(ts); lineWidths.Add(cwidth); } } // create the final array from the Lists string[] la = lines.ToArray(); width = lineWidths.ToArray(); return(la); } finally { if (drawFont != null) { drawFont.Dispose(); } if (drawFormat != null) { drawFont.Dispose(); } } }
public float EvalBottom(Report rpt, Row r) // return points { if (_Bottom == null) return EvalDefault(rpt, r); string sw = _Bottom.EvaluateString(rpt, r); RSize rs = new RSize(this.OwnerReport, sw); return rs.Points; }
public Font GetFont(Report rpt, Row r) { // Get the font information // FAMILY string ff; if (this.FontFamily != null) ff = this.FontFamily.EvaluateString(rpt, r); else ff = "Arial"; // STYLE System.Drawing.FontStyle fs = 0; if (this.FontStyle != null) { string fStyle = this.FontStyle.EvaluateString(rpt, r); if (fStyle == "Italic") fs |= System.Drawing.FontStyle.Italic; } if (this.TextDecoration != null) { string td = this.TextDecoration.EvaluateString(rpt, r); switch (td) { case "Underline": fs |= System.Drawing.FontStyle.Underline; break; case "Overline": // Don't support this break; case "LineThrough": fs |= System.Drawing.FontStyle.Strikeout; break; case "None": default: break; } } // WEIGHT if (this.FontWeight != null) { string weight = this.FontWeight.EvaluateString(rpt, r); switch(weight.ToLower()) { case "bold": case "bolder": case "500": case "600": case "700": case "800": case "900": fs |= System.Drawing.FontStyle.Bold; break; // Nothing to do otherwise since we don't have finer gradations case "normal": case "lighter": case "100": case "200": case "300": case "400": default: break; } } // SIZE float size; // Value is in points if (this.FontSize != null) { string lsize = this.FontSize.EvaluateString(rpt, r); RSize rs = new RSize(this.OwnerReport, lsize); size = rs.Points; } else size = 10; FontFamily fFamily = StyleInfo.GetFontFamily(ff); return new Font(fFamily, size, fs); }
Type _CodeType; // used for parsing of expressions; DONT USE AT RUNTIME // Constructor public ReportDefn(XmlNode xNode, ReportLog replog, string folder, NeedPassword getpswd, int objcount) // report has no parents { rl = replog; // used for error reporting _ObjectCount = objcount; // starting number for objects in this report; 0 other than for subreports GetDataSourceReferencePassword = getpswd; _ParseFolder = folder; _Description = null; _Author = null; _AutoRefresh = -1; _DataSourcesDefn = null; _DataSetsDefn = null; _Body = null; _Width = null; _PageHeader = null; _PageFooter = null; _PageHeight = null; _PageWidth = null; _LeftMargin = null; _RightMargin = null; _TopMargin = null; _BottomMargin = null; _EmbeddedImages = null; _Language = null; _CodeModules = null; _Code = null; _Classes = null; _DataTransform = null; _DataSchema = null; _DataElementName = null; _DataElementStyle = DataElementStyleEnum.AttributeNormal; _LUReportItems = new Hashtable(); // to hold all the textBoxes _LUAggrScope = new ListDictionary(); // to hold all dataset, dataregion, grouping names _LUEmbeddedImages = new ListDictionary(); // probably not very many _LUDynamicNames = new Hashtable(); _DataCache = new List <ICacheData>(); // Run thru the attributes foreach (XmlAttribute xAttr in xNode.Attributes) { switch (xAttr.Name) { case "Name": _Name = new Name(xAttr.Value); break; } } // Loop thru all the child nodes foreach (XmlNode xNodeLoop in xNode.ChildNodes) { if (xNodeLoop.NodeType != XmlNodeType.Element) { continue; } switch (xNodeLoop.Name) { case "Description": _Description = xNodeLoop.InnerText; break; case "Author": _Author = xNodeLoop.InnerText; break; case "AutoRefresh": _AutoRefresh = XmlUtil.Integer(xNodeLoop.InnerText); break; case "DataSources": _DataSourcesDefn = new DataSourcesDefn(this, null, xNodeLoop); break; case "DataSets": _DataSetsDefn = new DataSetsDefn(this, null, xNodeLoop); break; case "Body": _Body = new Body(this, null, xNodeLoop); break; case "ReportParameters": _ReportParameters = new ReportParameters(this, null, xNodeLoop); break; case "Width": _Width = new RSize(this, xNodeLoop); break; case "PageHeader": _PageHeader = new PageHeader(this, null, xNodeLoop); break; case "PageFooter": _PageFooter = new PageFooter(this, null, xNodeLoop); break; case "PageHeight": _PageHeight = new RSize(this, xNodeLoop); break; case "PageWidth": _PageWidth = new RSize(this, xNodeLoop); break; case "LeftMargin": _LeftMargin = new RSize(this, xNodeLoop); break; case "RightMargin": _RightMargin = new RSize(this, xNodeLoop); break; case "TopMargin": _TopMargin = new RSize(this, xNodeLoop); break; case "BottomMargin": _BottomMargin = new RSize(this, xNodeLoop); break; case "EmbeddedImages": _EmbeddedImages = new EmbeddedImages(this, null, xNodeLoop); break; case "Language": _Language = new Expression(this, null, xNodeLoop, ExpressionType.String); break; case "Code": _Code = new Code(this, null, xNodeLoop); break; case "CodeModules": _CodeModules = new CodeModules(this, null, xNodeLoop); break; case "Classes": _Classes = new Classes(this, null, xNodeLoop); break; case "DataTransform": _DataTransform = xNodeLoop.InnerText; break; case "DataSchema": _DataSchema = xNodeLoop.InnerText; break; case "DataElementName": _DataElementName = xNodeLoop.InnerText; break; case "DataElementStyle": _DataElementStyle = Oranikle.Report.Engine.DataElementStyle.GetStyle(xNodeLoop.InnerText, this.rl); break; default: // don't know this element - log it this.rl.LogError(4, "Unknown Report element '" + xNodeLoop.Name + "' ignored."); break; } } if (_Body == null) { rl.LogError(8, "Body not specified for report."); } if (_Width == null) { rl.LogError(4, "Width not specified for report. Assuming page width."); } if (rl.MaxSeverity <= 4) // don't do final pass if already have serious errors { FinalPass(folder); // call final parser pass for expression resolution } // Cleanup any dangling resources if (_DataSourcesDefn != null) { _DataSourcesDefn.CleanUp(null); } }
Type _CodeType; // used for parsing of expressions; DONT USE AT RUNTIME // Constructor public ReportDefn(XmlNode xNode, ReportLog replog, string folder, NeedPassword getpswd, int objcount) // report has no parents { rl = replog; // used for error reporting _ObjectCount = objcount; // starting number for objects in this report; 0 other than for subreports GetDataSourceReferencePassword = getpswd; _ParseFolder = folder; _Description = null; _Author = null; _AutoRefresh = -1; _DataSourcesDefn = null; _DataSetsDefn = null; _Body = null; _Width = null; _PageHeader = null; _PageFooter = null; _PageHeight = null; _PageWidth = null; _LeftMargin = null; _RightMargin = null; _TopMargin = null; _BottomMargin = null; _EmbeddedImages = null; _Language = null; _CodeModules = null; _Code = null; _Classes = null; _DataTransform = null; _DataSchema = null; _DataElementName = null; _DataElementStyle = DataElementStyleEnum.AttributeNormal; _LUReportItems = new Hashtable(); // to hold all the textBoxes _LUAggrScope = new ListDictionary(); // to hold all dataset, dataregion, grouping names _LUEmbeddedImages = new ListDictionary(); // probably not very many _LUDynamicNames = new Hashtable(); _DataCache = new List<ICacheData>(); // Run thru the attributes foreach(XmlAttribute xAttr in xNode.Attributes) { switch (xAttr.Name) { case "Name": _Name = new Name(xAttr.Value); break; } } // Loop thru all the child nodes foreach(XmlNode xNodeLoop in xNode.ChildNodes) { if (xNodeLoop.NodeType != XmlNodeType.Element) continue; switch (xNodeLoop.Name) { case "Description": _Description = xNodeLoop.InnerText; break; case "Author": _Author = xNodeLoop.InnerText; break; case "AutoRefresh": _AutoRefresh = XmlUtil.Integer(xNodeLoop.InnerText); break; case "DataSources": _DataSourcesDefn = new DataSourcesDefn(this, null, xNodeLoop); break; case "DataSets": _DataSetsDefn = new DataSetsDefn(this, null, xNodeLoop); break; case "Body": _Body = new Body(this, null, xNodeLoop); break; case "ReportParameters": _ReportParameters = new ReportParameters(this, null, xNodeLoop); break; case "Width": _Width = new RSize(this, xNodeLoop); break; case "PageHeader": _PageHeader = new PageHeader(this, null, xNodeLoop); break; case "PageFooter": _PageFooter = new PageFooter(this, null, xNodeLoop); break; case "PageHeight": _PageHeight = new RSize(this, xNodeLoop); break; case "PageWidth": _PageWidth = new RSize(this, xNodeLoop); break; case "LeftMargin": _LeftMargin = new RSize(this, xNodeLoop); break; case "RightMargin": _RightMargin = new RSize(this, xNodeLoop); break; case "TopMargin": _TopMargin = new RSize(this, xNodeLoop); break; case "BottomMargin": _BottomMargin = new RSize(this, xNodeLoop); break; case "EmbeddedImages": _EmbeddedImages = new EmbeddedImages(this, null, xNodeLoop); break; case "Language": _Language = new Expression(this, null, xNodeLoop, ExpressionType.String); break; case "Code": _Code = new Code(this, null, xNodeLoop); break; case "CodeModules": _CodeModules = new CodeModules(this, null, xNodeLoop); break; case "Classes": _Classes = new Classes(this, null, xNodeLoop); break; case "DataTransform": _DataTransform = xNodeLoop.InnerText; break; case "DataSchema": _DataSchema = xNodeLoop.InnerText; break; case "DataElementName": _DataElementName = xNodeLoop.InnerText; break; case "DataElementStyle": _DataElementStyle = Oranikle.Report.Engine.DataElementStyle.GetStyle(xNodeLoop.InnerText, this.rl); break; default: // don't know this element - log it this.rl.LogError(4, "Unknown Report element '" + xNodeLoop.Name + "' ignored."); break; } } if (_Body == null) rl.LogError(8, "Body not specified for report."); if (_Width == null) rl.LogError(4, "Width not specified for report. Assuming page width."); if (rl.MaxSeverity <= 4) // don't do final pass if already have serious errors { FinalPass(folder); // call final parser pass for expression resolution } // Cleanup any dangling resources if (_DataSourcesDefn != null) _DataSourcesDefn.CleanUp(null); }
public bool ReportItemElement(XmlNode xNodeLoop) { switch (xNodeLoop.Name) { case "Style": _Style = new Style(OwnerReport, this, xNodeLoop); break; case "Action": _Action = new Action(OwnerReport, this, xNodeLoop); break; case "Top": _Top = new RSize(OwnerReport, xNodeLoop); break; case "Left": _Left = new RSize(OwnerReport, xNodeLoop); break; case "Height": _Height = new RSize(OwnerReport, xNodeLoop); break; case "Width": _Width = new RSize(OwnerReport, xNodeLoop); break; case "ZIndex": _ZIndex = XmlUtil.Integer(xNodeLoop.InnerText); break; case "Visibility": _Visibility = new Visibility(OwnerReport, this, xNodeLoop); break; case "ToolTip": _ToolTip = new Expression(OwnerReport, this, xNodeLoop, ExpressionType.String); break; case "Label": _Label = new Expression(OwnerReport, this, xNodeLoop, ExpressionType.Variant); break; case "LinkToChild": _LinkToChild = xNodeLoop.InnerText; break; case "Bookmark": _Bookmark = new Expression(OwnerReport, this, xNodeLoop, ExpressionType.String); break; case "RepeatWith": _RepeatWith = xNodeLoop.InnerText; break; case "Custom": _Custom = new Custom(OwnerReport, this, xNodeLoop); break; case "DataElementName": _DataElementName = xNodeLoop.InnerText; break; case "DataElementOutput": _DataElementOutput = Oranikle.Report.Engine.DataElementOutput.GetStyle(xNodeLoop.InnerText, OwnerReport.rl); break; case "rd:DefaultName": break; // MS tag: we don't use but don't want to generate a warning default: return(false); // Not a report item element } return(true); }
public void SetPageLeft(Report rpt) { if (this._TC != null) { // must be part of a table Table t = _TC.OwnerTable; int colindex = _TC.ColIndex; TableColumn tc = (TableColumn) (t.TableColumns.Items[colindex]); Left = new RSize(OwnerReport, tc.GetXPosition(rpt).ToString() + "pt"); } else if (Left == null) Left = new RSize(OwnerReport, "0pt"); }
public bool ReportItemElement(XmlNode xNodeLoop) { switch (xNodeLoop.Name) { case "Style": _Style = new Style(OwnerReport, this, xNodeLoop); break; case "Action": _Action = new Action(OwnerReport, this, xNodeLoop); break; case "Top": _Top = new RSize(OwnerReport, xNodeLoop); break; case "Left": _Left = new RSize(OwnerReport, xNodeLoop); break; case "Height": _Height = new RSize(OwnerReport, xNodeLoop); break; case "Width": _Width = new RSize(OwnerReport, xNodeLoop); break; case "ZIndex": _ZIndex = XmlUtil.Integer(xNodeLoop.InnerText); break; case "Visibility": _Visibility = new Visibility(OwnerReport, this, xNodeLoop); break; case "ToolTip": _ToolTip = new Expression(OwnerReport, this, xNodeLoop, ExpressionType.String); break; case "Label": _Label = new Expression(OwnerReport, this, xNodeLoop, ExpressionType.Variant); break; case "LinkToChild": _LinkToChild = xNodeLoop.InnerText; break; case "Bookmark": _Bookmark = new Expression(OwnerReport, this, xNodeLoop, ExpressionType.String); break; case "RepeatWith": _RepeatWith = xNodeLoop.InnerText; break; case "Custom": _Custom = new Custom(OwnerReport, this, xNodeLoop); break; case "DataElementName": _DataElementName = xNodeLoop.InnerText; break; case "DataElementOutput": _DataElementOutput = Oranikle.Report.Engine.DataElementOutput.GetStyle(xNodeLoop.InnerText, OwnerReport.rl); break; case "rd:DefaultName": break; // MS tag: we don't use but don't want to generate a warning default: return false; // Not a report item element } return true; }
bool _InMatrix; // true if reportitem is in a matrix public ReportItem(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p) { _Name=null; _Style=null; _Action=null; _Top=null; _Left=null; _Height=null; _Width=null; _ZIndex=0; _Visibility=null; _ToolTip=null; _Label=null; _LinkToChild=null; _Bookmark=null; _RepeatWith=null; _Custom=null; _DataElementName=null; _DataElementOutput=DataElementOutputEnum.Auto; // Run thru the attributes foreach(XmlAttribute xAttr in xNode.Attributes) { switch (xAttr.Name) { case "Name": _Name = new Name(xAttr.Value); break; } } }
public int EvalPaddingBottomPx(Report rpt, Row row) { if (_PaddingBottom == null) return 0; string v = _PaddingBottom.EvaluateString(rpt, row); RSize rz = new RSize(OwnerReport, v); return rz.PixelsY; }
public float EvalLineHeight(Report rpt, Row r) { if (_LineHeight == null) return float.NaN; string sz = _LineHeight.EvaluateString(rpt, r); RSize rz = new RSize(OwnerReport, sz); return rz.Points; }
override public void RunPage(Pages pgs, Row row) { Report rpt = pgs.Report; if (IsHidden(pgs.Report, row)) { return; } SetPagePositionBegin(pgs); // Build the Chart bitmap, along with data regions Page p = pgs.CurrentPage; ICustomReportItem cri = null; Bitmap bm = null; try { cri = RdlEngineConfig.CreateCustomReportItem(_Type); SetProperties(pgs.Report, row, cri); int width = WidthCalc(rpt, pgs.G) - (Style == null? 0 : (Style.EvalPaddingLeftPx(rpt, row) + Style.EvalPaddingRightPx(rpt, row))); int height = RSize.PixelsFromPoints(this.HeightOrOwnerHeight) - (Style == null? 0 : (Style.EvalPaddingTopPx(rpt, row) + Style.EvalPaddingBottomPx(rpt, row))); bm = new Bitmap(width, height); cri.DrawImage(bm); MemoryStream ostrm = new MemoryStream(); // 06122007AJM Changed to use high quality JPEG encoding //bm.Save(ostrm, IMAGEFORMAT); // generate a jpeg TODO: get png to work with pdf System.Drawing.Imaging.ImageCodecInfo[] info; info = ImageCodecInfo.GetImageEncoders(); EncoderParameters encoderParameters; encoderParameters = new EncoderParameters(1); // 20022008 AJM GJL - Using centralised image quality encoderParameters.Param[0] = new EncoderParameter(Encoder.Quality, ImageQualityManager.CustomImageQuality); System.Drawing.Imaging.ImageCodecInfo codec = null; for (int i = 0; i < info.Length; i++) { if (info[i].FormatDescription == "JPEG") { codec = info[i]; break; } } bm.Save(ostrm, codec, encoderParameters); byte[] ba = ostrm.ToArray(); ostrm.Close(); PageImage pi = new PageImage(IMAGEFORMAT, ba, width, height); // Create an image pi.Sizing = ImageSizingEnum.Clip; // RunPageRegionBegin(pgs); SetPagePositionAndStyle(rpt, pi, row); if (pgs.CurrentPage.YOffset + pi.Y + pi.H >= pgs.BottomOfPage && !pgs.CurrentPage.IsEmpty()) { // force page break if it doesn't fit on the page pgs.NextOrNew(); pgs.CurrentPage.YOffset = OwnerReport.TopOfPage; if (this.YParents != null) { pi.Y = 0; } } p = pgs.CurrentPage; p.AddObject(pi); // Put image onto the current page // RunPageRegionEnd(pgs); if (!this.PageBreakAtEnd && !IsTableOrMatrixCell(rpt)) { float newY = pi.Y + pi.H; p.YOffset += newY; // bump the y location } SetPagePositionEnd(pgs, pi.Y + pi.H); } catch (Exception ex) { rpt.rl.LogError(8, string.Format("Exception in CustomReportItem handling: {0}", ex.Message)); } finally { if (cri != null) { cri.Dispose(); } } return; }
private int GetTwipsFromPixels(int pixels) { return((int)Math.Round(RSize.PointsFromPixels(GetGraphics, pixels) * 20, 0)); }
private SizeF MeasureString(string s, StyleInfo si, Graphics g, out float descent) { Font drawFont = null; StringFormat drawFormat = null; SizeF ms = SizeF.Empty; descent = 0; if (s == null || s.Length == 0) { return(ms); } try { // STYLE System.Drawing.FontStyle fs = 0; if (si.FontStyle == FontStyleEnum.Italic) { fs |= System.Drawing.FontStyle.Italic; } // WEIGHT switch (si.FontWeight) { case FontWeightEnum.Bold: case FontWeightEnum.Bolder: case FontWeightEnum.W500: case FontWeightEnum.W600: case FontWeightEnum.W700: case FontWeightEnum.W800: case FontWeightEnum.W900: fs |= System.Drawing.FontStyle.Bold; break; default: break; } try { FontFamily ff = si.GetFontFamily(); drawFont = new Font(ff, si.FontSize, fs); // following algorithm comes from the C# Font Metrics documentation float descentPixel = si.FontSize * ff.GetCellDescent(fs) / ff.GetEmHeight(fs); descent = RSize.PointsFromPixels(g, descentPixel); } catch { drawFont = new Font("Arial", si.FontSize, fs); // usually because font not found descent = 0; } drawFormat = new StringFormat(); drawFormat.Alignment = StringAlignment.Near; CharacterRange[] cr = { new CharacterRange(0, s.Length) }; drawFormat.SetMeasurableCharacterRanges(cr); Region[] rs = new Region[1]; rs = g.MeasureCharacterRanges(s, drawFont, new RectangleF(0, 0, float.MaxValue, float.MaxValue), drawFormat); RectangleF mr = rs[0].GetBounds(g); ms.Height = RSize.PointsFromPixels(g, mr.Height); // convert to points from pixels ms.Width = RSize.PointsFromPixels(g, mr.Width); // convert to points from pixels return(ms); } finally { if (drawFont != null) { drawFont.Dispose(); } if (drawFormat != null) { drawFont.Dispose(); } } }
public float EvalDefault(Report rpt, Row r) // return points { if (_Default == null) return 1; string sw; sw = _Default.EvaluateString(rpt, r); RSize rs = new RSize(this.OwnerReport, sw); return rs.Points; }
private PageImage BuildImage(Graphics g, string token, StyleInfo oldsi, PageText model) { PageTextHtmlCmdLexer hc = new PageTextHtmlCmdLexer(token.Substring(4)); Hashtable ht = hc.Lex(); string src = (string)ht["src"]; if (src == null || src.Length < 1) { return(null); } string alt = (string)ht["alt"]; string height = (string)ht["height"]; string width = (string)ht["width"]; string align = (string)ht["align"]; Stream strm = null; System.Drawing.Image im = null; PageImage pi = null; try { // Obtain the image stream if (src.StartsWith("http:") || src.StartsWith("file:") || src.StartsWith("https:")) { WebRequest wreq = WebRequest.Create(src); WebResponse wres = wreq.GetResponse(); strm = wres.GetResponseStream(); } else { strm = new FileStream(src, System.IO.FileMode.Open, FileAccess.Read); } im = System.Drawing.Image.FromStream(strm); int h = im.Height; int w = im.Width; MemoryStream ostrm = new MemoryStream(); ImageFormat imf; imf = ImageFormat.Jpeg; im.Save(ostrm, imf); byte[] ba = ostrm.ToArray(); ostrm.Close(); pi = new PageImage(imf, ba, w, h); pi.AllowSelect = false; pi.Page = this.Page; pi.HyperLink = model.HyperLink; pi.Tooltip = alt == null ? model.Tooltip : alt; pi.X = 0; pi.Y = 0; pi.W = RSize.PointsFromPixels(g, width != null? Convert.ToInt32(width): w); pi.H = RSize.PointsFromPixels(g, height != null? Convert.ToInt32(height): h); pi.SI = new StyleInfo(); } catch { pi = null; } finally { if (strm != null) { strm.Close(); } if (im != null) { im.Dispose(); } } return(pi); }
// render all the objects in a page in PDF private void ProcessPage(Pages pgs, IEnumerable items) { foreach (PageItem pi in items) { if (pi.SI.BackgroundImage != null) { // put out any background image PageImage bgImg = pi.SI.BackgroundImage; // elements.AddImage(images, i.Name, content.objectNum, i.SI, i.ImgFormat, // pi.X, pi.Y, pi.W, pi.H, i.ImageData,i.SamplesW, i.SamplesH, null); //Duc Phan modified 10 Dec, 2007 to support on background image float imW = RSize.PointsFromPixels(pgs.G, bgImg.SamplesW); float imH = RSize.PointsFromPixels(pgs.G, bgImg.SamplesH); int repeatX = 0; int repeatY = 0; float itemW = pi.W - (pi.SI.PaddingLeft + pi.SI.PaddingRight); float itemH = pi.H - (pi.SI.PaddingTop + pi.SI.PaddingBottom); switch (bgImg.Repeat) { case ImageRepeat.Repeat: repeatX = (int)Math.Floor(itemW / imW); repeatY = (int)Math.Floor(itemH / imH); break; case ImageRepeat.RepeatX: repeatX = (int)Math.Floor(itemW / imW); repeatY = 1; break; case ImageRepeat.RepeatY: repeatY = (int)Math.Floor(itemH / imH); repeatX = 1; break; case ImageRepeat.NoRepeat: default: repeatX = repeatY = 1; break; } //make sure the image is drawn at least 1 times repeatX = Math.Max(repeatX, 1); repeatY = Math.Max(repeatY, 1); float currX = pi.X + pi.SI.PaddingLeft; float currY = pi.Y + pi.SI.PaddingTop; float startX = currX; float startY = currY; for (int i = 0; i < repeatX; i++) { for (int j = 0; j < repeatY; j++) { currX = startX + i * imW; currY = startY + j * imH; elements.AddImage(images, bgImg.Name, content.objectNum, bgImg.SI, bgImg.ImgFormat, currX, currY, imW, imH, RectangleF.Empty, bgImg.ImageData, bgImg.SamplesW, bgImg.SamplesH, null, pi.Tooltip); } } } if (pi is PageTextHtml) { PageTextHtml pth = pi as PageTextHtml; pth.Build(pgs.G); ProcessPage(pgs, pth); continue; } if (pi is PageText) { PageText pt = pi as PageText; float[] textwidth; string[] sa = MeasureString(pt, pgs.G, out textwidth); elements.AddText(pt.X, pt.Y, pt.H, pt.W, sa, pt.SI, fonts, textwidth, pt.CanGrow, pt.HyperLink, pt.NoClip, pt.Tooltip); if (pt.Bookmark != null) { outline.Bookmarks.Add(new PdfOutlineEntry(anchor, page.objectNum, pt.Bookmark, pt.X, elements.PageSize.yHeight - pt.Y)); } continue; } if (pi is PageLine) { PageLine pl = pi as PageLine; elements.AddLine(pl.X, pl.Y, pl.X2, pl.Y2, pl.SI); continue; } if (pi is PageEllipse) { PageEllipse pe = pi as PageEllipse; elements.AddEllipse(pe.X, pe.Y, pe.H, pe.W, pe.SI, pe.HyperLink); continue; } if (pi is PageImage) { //PageImage i = pi as PageImage; //float x = i.X + i.SI.PaddingLeft; //float y = i.Y + i.SI.PaddingTop; //float w = i.W - i.SI.PaddingLeft - i.SI.PaddingRight; //float h = i.H - i.SI.PaddingTop - i.SI.PaddingBottom; //elements.AddImage(images, i.Name, content.objectNum, i.SI, i.ImgFormat, // x, y, w, h, i.ImageData,i.SamplesW, i.SamplesH, i.HyperLink); //continue; PageImage i = pi as PageImage; //Duc Phan added 20 Dec, 2007 to support sized image RectangleF r2 = new RectangleF(i.X + i.SI.PaddingLeft, i.Y + i.SI.PaddingTop, i.W - i.SI.PaddingLeft - i.SI.PaddingRight, i.H - i.SI.PaddingTop - i.SI.PaddingBottom); RectangleF adjustedRect; // work rectangle RectangleF clipRect = RectangleF.Empty; switch (i.Sizing) { case ImageSizingEnum.AutoSize: adjustedRect = new RectangleF(r2.Left, r2.Top, r2.Width, r2.Height); break; case ImageSizingEnum.Clip: adjustedRect = new RectangleF(r2.Left, r2.Top, RSize.PointsFromPixels(pgs.G, i.SamplesW), RSize.PointsFromPixels(pgs.G, i.SamplesH)); clipRect = new RectangleF(r2.Left, r2.Top, r2.Width, r2.Height); break; case ImageSizingEnum.FitProportional: float height; float width; float ratioIm = (float)i.SamplesH / i.SamplesW; float ratioR = r2.Height / r2.Width; height = r2.Height; width = r2.Width; if (ratioIm > ratioR) { // this means the rectangle width must be corrected width = height * (1 / ratioIm); } else if (ratioIm < ratioR) { // this means the rectangle height must be corrected height = width * ratioIm; } adjustedRect = new RectangleF(r2.X, r2.Y, width, height); break; case ImageSizingEnum.Fit: default: adjustedRect = r2; break; } if (i.ImgFormat == System.Drawing.Imaging.ImageFormat.Wmf || i.ImgFormat == System.Drawing.Imaging.ImageFormat.Emf) { //We dont want to add it - its already been broken down into page items; } else { elements.AddImage(images, i.Name, content.objectNum, i.SI, i.ImgFormat, adjustedRect.X, adjustedRect.Y, adjustedRect.Width, adjustedRect.Height, clipRect, i.ImageData, i.SamplesW, i.SamplesH, i.HyperLink, i.Tooltip); } continue; } if (pi is PageRectangle) { PageRectangle pr = pi as PageRectangle; elements.AddRectangle(pr.X, pr.Y, pr.H, pr.W, pi.SI, pi.HyperLink, patterns, pi.Tooltip); continue; } if (pi is PagePie) { // TODO PagePie pp = pi as PagePie; // elements.AddPie(pr.X, pr.Y, pr.H, pr.W, pi.SI, pi.HyperLink, patterns, pi.Tooltip); continue; } if (pi is PagePolygon) { PagePolygon ppo = pi as PagePolygon; elements.AddPolygon(ppo.Points, pi.SI, pi.HyperLink, patterns); continue; } if (pi is PageCurve) { PageCurve pc = pi as PageCurve; elements.AddCurve(pc.Points, pi.SI); continue; } } }
protected void AdjustMargins(System.Drawing.Rectangle legendRect, Report rpt, Graphics g) { // //110208AJM GJL Making room for second y axis // if (ShowRightYAxis(rpt) && !(IsLegendRight())) //{ // Layout.RightMargin = (int)(Layout.LeftMargin * 1.5); //} // Adjust the margins based on the legend if (!IsLegendInsidePlotArea()) // When inside plot area we don't adjust plot margins { if (IsLegendLeft()) Layout.LeftMargin += legendRect.Width; else if (IsLegendRight()) Layout.RightMargin += legendRect.Width; if (IsLegendTop()) Layout.TopMargin += legendRect.Height; else if (IsLegendBottom()) Layout.BottomMargin += legendRect.Height; } // Force some margins; if any are too small int min = new RSize(ChartDefn.OwnerReport, ".2 in").PixelsX; if (Layout.RightMargin < min + this._LastCategoryWidth/2) Layout.RightMargin = min + this._LastCategoryWidth/2; if (Layout.LeftMargin < min) Layout.LeftMargin = min; if (Layout.TopMargin < min) Layout.TopMargin = min; if (Layout.BottomMargin < min) Layout.BottomMargin = min; }
static public float PointSize(string v) { RSize rs = new RSize(null, v); return rs.Points; }
public float EvalFontSize(Report rpt, Row row) { if (_FontSize == null) return 10; string pts; pts = _FontSize.EvaluateString(rpt, row); RSize sz = new RSize(this.OwnerReport, pts); return sz.Points; }