private bool IsMemo(ReportComponentBase Obj) { if (Obj is TextObject) { TextObject aObj = Obj as TextObject; return((aObj.Angle == 0) && (aObj.FontWidthRatio == 1) && (!aObj.TextOutline.Enabled) && (!aObj.Underlines)); } return(false); }
internal bool CanPrint(ReportComponentBase obj) { if (!obj.Visible || !obj.FlagPreviewVisible) { return(false); } bool isFirstPage = CurPage == firstReportPage; bool isLastPage = CurPage == TotalPages - 1; bool isRepeated = obj.Band != null && obj.Band.Repeated; bool canPrint = false; if ((obj.PrintOn & PrintOn.OddPages) > 0 && CurPage % 2 == 1) { canPrint = true; } if ((obj.PrintOn & PrintOn.EvenPages) > 0 && CurPage % 2 == 0) { canPrint = true; } if (isLastPage) { if ((obj.PrintOn & PrintOn.LastPage) == 0) { canPrint = false; } if (obj.PrintOn == PrintOn.LastPage || obj.PrintOn == (PrintOn.LastPage | PrintOn.SinglePage) || obj.PrintOn == (PrintOn.FirstPage | PrintOn.LastPage)) { canPrint = true; } } if (isFirstPage) { if ((obj.PrintOn & PrintOn.FirstPage) == 0) { canPrint = false; } if (obj.PrintOn == PrintOn.FirstPage || obj.PrintOn == (PrintOn.FirstPage | PrintOn.SinglePage) || obj.PrintOn == (PrintOn.FirstPage | PrintOn.LastPage)) { canPrint = true; } } if (isFirstPage && isLastPage) { canPrint = (obj.PrintOn & PrintOn.SinglePage) > 0; } if (isRepeated) { canPrint = (obj.PrintOn & PrintOn.RepeatedBand) > 0; } return(canPrint); }
private void DoDetailedReport(string objectName, string paramName, string paramValue) { if (!String.IsNullOrEmpty(objectName)) { Report tabReport = new Report(); ReportComponentBase obj = Report.FindObject(objectName) as ReportComponentBase; if (obj != null && obj.Hyperlink.Kind == HyperlinkKind.DetailReport) { string fileName = obj.Hyperlink.DetailReportName; if (File.Exists(fileName)) { tabReport.Load(fileName); Data.Parameter param = tabReport.Parameters.FindByName(paramName); if (param != null && param.ChildObjects.Count > 0) { string[] paramValues = paramValue.Split(obj.Hyperlink.ValuesSeparator[0]); if (paramValues.Length > 0) { int i = 0; foreach (Data.Parameter childParam in param.ChildObjects) { childParam.Value = paramValues[i++]; if (i >= paramValues.Length) { break; } } } } else { tabReport.SetParameterValue(paramName, paramValue); } Report.Dictionary.ReRegisterData(tabReport.Dictionary); tabReport.PreparePhase1(); tabReport.PreparePhase2(); Tabs.Add(new ReportTab() { Name = paramValue, Report = tabReport, ReportPrepared = true, Closeable = true, NeedParent = false }); int prevTab = CurrentTabIndex; CurrentTabIndex = Tabs.Count - 1; //Prop.PreviousTab = prevTab; } } } }
private void DoDetailedPage(string objectName, string paramName, string paramValue) { if (!String.IsNullOrEmpty(objectName)) { Report currentReport = CurrentTab.NeedParent ? Tabs[0].Report : Report; ReportComponentBase obj = currentReport.FindObject(objectName) as ReportComponentBase; if (obj != null && obj.Hyperlink.Kind == HyperlinkKind.DetailPage) { ReportPage reportPage = currentReport.FindObject(obj.Hyperlink.DetailPageName) as ReportPage; if (reportPage != null) { Data.Parameter param = currentReport.Parameters.FindByName(paramName); if (param != null && param.ChildObjects.Count > 0) { string[] paramValues = paramValue.Split(obj.Hyperlink.ValuesSeparator[0]); if (paramValues.Length > 0) { int i = 0; foreach (Data.Parameter childParam in param.ChildObjects) { childParam.Value = paramValues[i++]; if (i >= paramValues.Length) { break; } } } } else { currentReport.SetParameterValue(paramName, paramValue); } PreparedPages oldPreparedPages = currentReport.PreparedPages; PreparedPages pages = new PreparedPages(currentReport); currentReport.SetPreparedPages(pages); currentReport.PreparePage(reportPage); Report tabReport = new Report(); tabReport.SetPreparedPages(currentReport.PreparedPages); Tabs.Add(new ReportTab() { Name = paramValue, Report = tabReport, ReportPrepared = true, Closeable = true, NeedParent = true }); int prevTab = CurrentTabIndex; currentReport.SetPreparedPages(oldPreparedPages); CurrentTabIndex = Tabs.Count - 1; //Prop.PreviousTab = prevTab; } } } }
private void Click(ReportComponentBase c, int pageN, ReportPage page) { c.OnClick(null); if (Report.NeedRefresh) { Report.InteractiveRefresh(); } else { Report.PreparedPages.ModifyPage(pageN, page); } }
/// <inheritdoc/> public override void RestoreState() { OnAfterPrint(EventArgs.Empty); base.RestoreState(); if (Objects != null) { for (int i = 0; i < Objects.Count; i++) { ReportComponentBase c = Objects[i]; c.OnAfterPrint(EventArgs.Empty); c.RestoreState(); } } }
private int UpdateCSSTable(ReportComponentBase obj) { string style; if (obj is TextObject) { TextObject textObj = obj as TextObject; style = GetStyle(textObj.Font, textObj.TextColor, textObj.FillColor, textObj.RightToLeft, textObj.HorzAlign, textObj.Border); } else { style = GetStyle(null, Color.White, obj.FillColor, false, HorzAlign.Center, obj.Border); } return(UpdateCSSTable(style)); }
private BandBase CloneBand(BandBase band) { // clone a band and all its objects BandBase cloneBand = Activator.CreateInstance(band.GetType()) as BandBase; cloneBand.Assign(band); cloneBand.SetReport(Report); cloneBand.SetRunning(true); foreach (ReportComponentBase obj in band.Objects) { ReportComponentBase cloneObj = Activator.CreateInstance(obj.GetType()) as ReportComponentBase; cloneObj.AssignAll(obj); cloneBand.Objects.Add(cloneObj); } return(cloneBand); }
private void ApplyStyle(XmlNode node, ReportComponentBase component) { string stylename = GetAttribute(node, "StyleName"); XmlNode stylePriority = FindChildNoteByName(node, "StylePriority"); //if (stylePriority == null) // return; XmlNode styleNode = GetStyleNode(stylename); foreach (Style style in Report.Styles) { if (style.Name == stylename) { if (stylePriority == null || !AttributeExist(stylePriority, "UseFont")) { if (component as TextObject != null) { (component as TextObject).Font = style.Font; } } if (stylePriority == null || !AttributeExist(stylePriority, "UseTextAlignment")) { if (component as TextObject != null) { (component as TextObject).HorzAlign = UnitsConverter.ConvertTextAlignmentToHorzAlign(GetAttribute(styleNode, "TextAlignment")); (component as TextObject).VertAlign = UnitsConverter.ConvertTextAlignmentToVertAlign(GetAttribute(styleNode, "TextAlignment")); } } if (stylePriority == null || !AttributeExist(stylePriority, "UseBorder")) { component.Border = style.Border; } if (stylePriority == null || !AttributeExist(stylePriority, "UseForeColor")) { if (component as TextObject != null) { (component as TextObject).TextColor = (style.TextFill as SolidFill).Color; } } } } }
private void LayerPicture(FastString Page, ReportComponentBase obj, FastString text) { if (pictures) { int styleindex = UpdateCSSTable(obj); string old_text = String.Empty; if (IsMemo(obj)) { old_text = (obj as TextObject).Text; (obj as TextObject).Text = String.Empty; } float Width, Height; string pic = GetLayerPicture(obj, out Width, out Height); if (IsMemo(obj)) { (obj as TextObject).Text = old_text; } FastString picStyleBuilder = new FastString("background: url('") .Append(pic).Append("') no-repeat !important;-webkit-print-color-adjust:exact;"); int picStyleIndex = UpdateCSSTable(picStyleBuilder.ToString()); string style = String.Format("class=\"{0}s{1} {0}s{2}\"", stylePrefix, styleindex.ToString(), picStyleIndex.ToString()); //FastString addstyle = new FastString(128); //addstyle.Append(" background: url('").Append(pic).Append("') no-repeat !important;-webkit-print-color-adjust:exact;"); //if (String.IsNullOrEmpty(text)) // text = NBSP; float x = Width > 0 ? obj.AbsLeft : (obj.AbsLeft + Width); float y = Height > 0 ? hPos + obj.AbsTop : (hPos + obj.AbsTop + Height); Layer(Page, obj, x, y, Width, Height, text, style, null); } }
/// <summary> /// Assigns another <see cref="TableCellData"/> instance at run time. /// </summary> /// <param name="cell">The table cell data that used as a source.</param> /// <param name="copyChildren">This flag shows should children be copied or not.</param> /// <remarks>This method is called when we print a table. We should create a copy of the cell and set the style.</remarks> public void RunTimeAssign(TableCell cell, bool copyChildren) { Text = cell.Text; Value = cell.Value; HyperlinkValue = cell.Hyperlink.Value; // don't copy ColSpan, RowSpan - they will be handled in the TableHelper. //ColSpan = cell.ColSpan; //RowSpan = cell.RowSpan; // clone objects objects = null; if (cell.Objects != null && copyChildren) { objects = new ReportComponentCollection(); foreach (ReportComponentBase obj in cell.Objects) { if (obj.Visible) { ReportComponentBase cloneObj = Activator.CreateInstance(obj.GetType()) as ReportComponentBase; cloneObj.AssignAll(obj); cloneObj.Name = obj.Name; objects.Add(cloneObj); } } } // add the cell to the style list. If the list contains such style, // return the existing style; in other case, create new style based // on the given cell. SetStyle(cell); // FCell is used to reference the original cell. It is necessary to use Alias, OriginalComponent this.cell = cell; // reset object's location as if we set ColSpan and RowSpan to 1. // It is nesessary when printing spanned cells because the span of such cells will be corrected // when print new rows/columns and thus will move cell objects. if (objects != null) { UpdateLayout(Width, Height, Width - cell.CellData.Width, Height - cell.CellData.Height); } }
public void BeforeMoveVGuide(int guide) { FGuideLinks.Clear(); foreach (Base obj in Designer.Objects) { if (obj is ReportComponentBase && !(obj is BandBase)) { ReportComponentBase c = obj as ReportComponentBase; LinkPoint link = LinkPoint.None; if (Math.Abs(c.Left - Page.Guides[guide]) < 0.01) { link = LinkPoint.Left; } else if (Math.Abs(c.Right - Page.Guides[guide]) < 0.01) { link = LinkPoint.Right; } if (link != LinkPoint.None) { LinkInfo info = new LinkInfo(); info.Obj = c; info.Link = link; // check if object is also linked to another guide int i = Page.Guides.IndexOf(c.Left); if (i != -1 && i != guide) { info.DoubleLinked = true; } i = Page.Guides.IndexOf(c.Right); if (i != -1 && i != guide) { info.DoubleLinked = true; } FGuideLinks.Add(info); } } } }
public void BeforeMoveHGuide(BandBase band, int guide) { FGuideLinks.Clear(); foreach (Base obj in Designer.Objects) { if (obj is ReportComponentBase && !(obj is BandBase) && obj.Parent == band) { ReportComponentBase c = obj as ReportComponentBase; LinkPoint link = LinkPoint.None; if (Math.Abs(c.Top - band.Guides[guide]) < 0.01) { link = LinkPoint.Top; } else if (Math.Abs(c.Bottom - band.Guides[guide]) < 0.01) { link = LinkPoint.Bottom; } if (link != LinkPoint.None) { LinkInfo info = new LinkInfo(); info.Obj = c; info.Link = link; // check if object is also linked to another guide int i = band.Guides.IndexOf(c.Top); if (i != -1 && i != guide) { info.DoubleLinked = true; } i = band.Guides.IndexOf(c.Bottom); if (i != -1 && i != guide) { info.DoubleLinked = true; } FGuideLinks.Add(info); } } } }
private int UpdateCSSTable(ReportComponentBase obj) { string style; if (obj is TextObject) { TextObject textObj = obj as TextObject; style = GetStyle(textObj.Font, textObj.TextColor, textObj.FillColor, textObj.RightToLeft, textObj.HorzAlign, textObj.Border, textObj.WordWrap, textObj.LineHeight, textObj.Width, textObj.Height, textObj.Clip); } else if (obj is HtmlObject) { HtmlObject htmlObj = obj as HtmlObject; style = GetStyle(DrawUtils.DefaultTextObjectFont, Color.Black, htmlObj.FillColor, false, HorzAlign.Left, htmlObj.Border, true, 0, htmlObj.Width, htmlObj.Height, false); } else { style = GetStyle(null, Color.White, obj.FillColor, false, HorzAlign.Center, obj.Border, false, 0, obj.Width, obj.Height, false); } return(UpdateCSSTable(style)); }
private bool HTMLBorderWidthValues(ReportComponentBase obj, out float left, out float top, out float right, out float bottom) { Border border = obj.Border; left = 0; top = 0; right = 0; bottom = 0; if (border.Lines > 0) { if ((border.Lines & BorderLines.Left) > 0) { left += HTMLBorderWidth(border.LeftLine); } if ((border.Lines & BorderLines.Right) > 0) { right += HTMLBorderWidth(border.RightLine); } if ((border.Lines & BorderLines.Top) > 0) { top += HTMLBorderWidth(border.TopLine); } if ((border.Lines & BorderLines.Bottom) > 0) { bottom += HTMLBorderWidth(border.BottomLine); } return(true); } return(false); }
partial void ExtendExport(FastString Page, ReportComponentBase obj, FastString text);
/// <summary> /// Calculates height of the table cell. /// </summary> /// <param name="width">The width of the table cell.</param> /// <returns>The value of the table cell height.</returns> public float CalcHeight(float width) { TableCell cell = Cell; cell.SetReport(Table.Report); cell.Width = width; float cellHeight = cell.CalcHeight(); if (objects != null) { // pasted from BandBase.cs // sort objects by Top ReportComponentCollection sortedObjects = objects.SortByTop(); // calc height of each object float[] heights = new float[sortedObjects.Count]; for (int i = 0; i < sortedObjects.Count; i++) { ReportComponentBase obj = sortedObjects[i]; float height = obj.Height; if (obj.CanGrow || obj.CanShrink) { float height1 = obj.CalcHeight(); if ((obj.CanGrow && height1 > height) || (obj.CanShrink && height1 < height)) { height = height1; } } heights[i] = height; } // calc shift amounts float[] shifts = new float[sortedObjects.Count]; for (int i = 0; i < sortedObjects.Count; i++) { ReportComponentBase parent = sortedObjects[i]; float shift = heights[i] - parent.Height; if (shift == 0) { continue; } for (int j = i + 1; j < sortedObjects.Count; j++) { ReportComponentBase child = sortedObjects[j]; if (child.ShiftMode == ShiftMode.Never) { continue; } if (child.Top >= parent.Bottom - 1e-4) { if (child.ShiftMode == ShiftMode.WhenOverlapped && (child.Left > parent.Right - 1e-4 || parent.Left > child.Right - 1e-4)) { continue; } float parentShift = shifts[i]; float childShift = shifts[j]; if (shift > 0) { childShift = Math.Max(shift + parentShift, childShift); } else { childShift = Math.Min(shift + parentShift, childShift); } shifts[j] = childShift; } } } // update location and size of each component, calc max height float maxHeight = 0; for (int i = 0; i < sortedObjects.Count; i++) { ReportComponentBase obj = sortedObjects[i]; obj.Height = heights[i]; obj.Top += shifts[i]; if (obj.Bottom > maxHeight) { maxHeight = obj.Bottom; } } if (cellHeight < maxHeight) { cellHeight = maxHeight; } // perform grow to bottom foreach (ReportComponentBase obj in objects) { if (obj.GrowToBottom) { obj.Height = cellHeight - obj.Top; } } // ----------------------- } return(cellHeight); }
private string GetLayerPicture(ReportComponentBase obj, out float Width, out float Height) { string result = String.Empty; Width = 0; Height = 0; if (obj != null) { if (pictures) { MemoryStream PictureStream = new MemoryStream(); System.Drawing.Imaging.ImageFormat FPictureFormat = System.Drawing.Imaging.ImageFormat.Bmp; if (imageFormat == ImageFormat.Png) { FPictureFormat = System.Drawing.Imaging.ImageFormat.Png; } else if (imageFormat == ImageFormat.Jpeg) { FPictureFormat = System.Drawing.Imaging.ImageFormat.Jpeg; } else if (imageFormat == ImageFormat.Gif) { FPictureFormat = System.Drawing.Imaging.ImageFormat.Gif; } Width = obj.Width == 0 ? obj.Border.LeftLine.Width : obj.Width; Height = obj.Height == 0 ? obj.Border.TopLine.Width : obj.Height; if (Math.Abs(Width) * Zoom < 1 && Zoom > 0) { Width = 1 / Zoom; } if (Math.Abs(Height) * Zoom < 1 && Zoom > 0) { Height = 1 / Zoom; } int zoom = highQualitySVG ? 3 : 1; using (System.Drawing.Image image = new Bitmap( (int)(Math.Abs(Math.Round(Width * Zoom * zoom))), (int)(Math.Abs(Math.Round(Height * Zoom * zoom))) )) { using (Graphics g = Graphics.FromImage(image)) { if (obj is TextObjectBase) { g.Clear(Color.Transparent); } float Left = Width > 0 ? obj.AbsLeft : obj.AbsLeft + Width; float Top = Height > 0 ? obj.AbsTop : obj.AbsTop + Height; float dx = 0; float dy = 0; g.TranslateTransform((-Left - dx) * Zoom * zoom, (-Top - dy) * Zoom * zoom); BorderLines oldLines = obj.Border.Lines; obj.Border.Lines = BorderLines.None; obj.Draw(new FRPaintEventArgs(g, Zoom + zoom - 1, Zoom + zoom - 1, Report.GraphicCache)); obj.Border.Lines = oldLines; } using (Bitmap b = new Bitmap((int)Width, (int)Height)) { using (Graphics gr = Graphics.FromImage(b)) { gr.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; gr.DrawImage(image, 0, 0, (int)Width, (int)Height); } if (FPictureFormat == System.Drawing.Imaging.ImageFormat.Jpeg) { ExportUtils.SaveJpeg(b, PictureStream, 95); } else { b.Save(PictureStream, FPictureFormat); } } } PictureStream.Position = 0; string hash = String.Empty; if (obj is PictureObject) { PictureObject pic = (obj as PictureObject); if (pic.Image != null) { #if MONO using (MemoryStream picStr = new MemoryStream()) { ImageHelper.Save(pic.Image, picStr); using (StreamWriter picWriter = new StreamWriter(picStr)) { picWriter.Write(pic.Width); picWriter.Write(pic.Height); picWriter.Write(pic.Angle); picWriter.Write(pic.Transparency); picWriter.Write(pic.TransparentColor.ToArgb()); picWriter.Write(pic.CanShrink); picWriter.Write(pic.CanGrow); hash = Crypter.ComputeHash(picStr); } } #else hash = Crypter.ComputeHash(PictureStream); PictureStream.Position = 0; #endif } } else { hash = Crypter.ComputeHash(PictureStream); } result = HTMLGetImage(0, 0, 0, hash, true, null, PictureStream, false); } } return(result); }
private void BreakBand(BandBase band) { BandBase cloneBand = Activator.CreateInstance(band.GetType()) as BandBase; cloneBand.Assign(band); cloneBand.SetRunning(true); cloneBand.FlagMustBreak = band.FlagMustBreak; // clone band objects: // - remove bands that can break, convert them to Text objects if necessary // - skip subreports foreach (Base c in band.Objects) { if (c is BandBase && (c as BandBase).CanBreak) { BandBase b = c as BandBase; if (b.HasBorder || b.HasFill) { TextObject textObj = new TextObject(); textObj.Bounds = b.Bounds; textObj.Border = b.Border.Clone(); textObj.Fill = b.Fill.Clone(); cloneBand.Objects.Add(textObj); } foreach (ReportComponentBase obj in b.Objects) { if (!(obj is BandBase)) { ReportComponentBase cloneObj = Activator.CreateInstance(obj.GetType()) as ReportComponentBase; cloneObj.AssignAll(obj); cloneObj.Anchor = AnchorStyles.Left | AnchorStyles.Top; cloneObj.Dock = DockStyle.None; cloneObj.Left = obj.AbsLeft - band.AbsLeft; cloneObj.Top = obj.AbsTop - band.AbsTop; if (cloneObj is TextObject) { (cloneObj as TextObject).Highlight.Clear(); } cloneBand.Objects.Add(cloneObj); } } } else if (!(c is SubreportObject)) { Base cloneObj = Activator.CreateInstance(c.GetType()) as Base; cloneObj.AssignAll(c); cloneObj.Parent = cloneBand; } } BandBase breakTo = Activator.CreateInstance(band.GetType()) as BandBase; breakTo.Assign(band); breakTo.SetRunning(true); breakTo.Child = null; breakTo.CanGrow = true; breakTo.StartNewPage = false; breakTo.OutlineExpression = ""; breakTo.BeforePrintEvent = ""; breakTo.BeforeLayoutEvent = ""; breakTo.AfterPrintEvent = ""; breakTo.AfterLayoutEvent = ""; // breakTo must be breaked because it will print on a new page. breakTo.FlagMustBreak = true; // to allow clone and breaked bands to access Report cloneBand.SetReport(Report); breakTo.SetReport(Report); try { // (case: object with Anchor = bottom on a breakable band) // disable re-layout cloneBand.SetUpdatingLayout(true); cloneBand.Height = FreeSpace; cloneBand.SetUpdatingLayout(false); if (cloneBand.Break(breakTo)) { AddToPreparedPages(cloneBand); EndColumn(); ShowBand(breakTo, false); } else { if (cloneBand.FlagMustBreak) { // show band as is breakTo.FlagCheckFreeSpace = false; AddToPreparedPages(breakTo); } else { EndColumn(); ShowBand(breakTo, false); } } } finally { cloneBand.Dispose(); breakTo.Dispose(); } }
private string GetHref(ReportComponentBase obj) { string href = String.Empty; if (!String.IsNullOrEmpty(obj.Hyperlink.Value)) { string hrefStyle = String.Empty; if (obj is TextObject) { TextObject textObject = obj as TextObject; hrefStyle = String.Format("style=\"color:{0}{1}\"", ExportUtils.HTMLColor(textObject.TextColor), !textObject.Font.Underline ? ";text-decoration:none" : String.Empty ); } string url = EncodeURL(obj.Hyperlink.Value); if (obj.Hyperlink.Kind == HyperlinkKind.URL) { href = String.Format("<a {0} href=\"{1}\"" + (obj.Hyperlink.OpenLinkInNewTab ? "target=\"_blank\"" : "") + ">", hrefStyle, obj.Hyperlink.Value); } else if (obj.Hyperlink.Kind == HyperlinkKind.DetailReport) { url = String.Format("{0},{1},{2}", EncodeURL(obj.Name), // object name for security reasons EncodeURL(obj.Hyperlink.ReportParameter), EncodeURL(obj.Hyperlink.Value)); string onClick = String.Format(OnClickTemplate, ReportID, "detailed_report", url); href = String.Format("<a {0} href=\"#\" onclick=\"{1}\">", hrefStyle, onClick); } else if (obj.Hyperlink.Kind == HyperlinkKind.DetailPage) { url = String.Format("{0},{1},{2}", EncodeURL(obj.Name), EncodeURL(obj.Hyperlink.ReportParameter), EncodeURL(obj.Hyperlink.Value)); string onClick = String.Format(OnClickTemplate, ReportID, "detailed_page", url); href = String.Format("<a {0} href=\"#\" onclick=\"{1}\">", hrefStyle, onClick); } else if (SinglePage) { if (obj.Hyperlink.Kind == HyperlinkKind.Bookmark) { href = String.Format("<a {0} href=\"#{1}\">", hrefStyle, url); } else if (obj.Hyperlink.Kind == HyperlinkKind.PageNumber) { href = String.Format("<a {0} href=\"#PageN{1}\">", hrefStyle, url); } } else { string onClick = String.Empty; if (obj.Hyperlink.Kind == HyperlinkKind.Bookmark) { onClick = String.Format(OnClickTemplate, ReportID, "bookmark", url); } else if (obj.Hyperlink.Kind == HyperlinkKind.PageNumber) { onClick = String.Format(OnClickTemplate, ReportID, "goto", url); } if (onClick != String.Empty) { href = String.Format("<a {0} href=\"#\" onclick=\"{1}\">", hrefStyle, onClick); } } } return(href); }
internal bool CanPrint(ReportComponentBase obj) { // Apply visible expression if needed. if (!String.IsNullOrEmpty(obj.VisibleExpression)) { object expression = null; if (obj.VisibleExpression.StartsWith("[") && obj.VisibleExpression.EndsWith("]")) { string tempExpression = obj.VisibleExpression.Substring(1, obj.VisibleExpression.Length - 2); int firstOpen = tempExpression.IndexOf("["); int firstClose = tempExpression.IndexOf("]"); int lastOpen = tempExpression.LastIndexOf("["); int lastClose = tempExpression.LastIndexOf("]"); if ((firstOpen < 0 && firstClose >= 0) || (lastOpen >= 0 && lastClose < 0) || (firstOpen >= 0 && firstClose >= 0 && firstClose < firstOpen) || (lastOpen >= 0 && lastClose >= 0 && lastOpen > lastClose)) { expression = Report.Calc(obj.VisibleExpression); } else { expression = Report.Calc(tempExpression); } } else { expression = Report.Calc(obj.VisibleExpression); } if (expression is bool) { obj.Visible = (bool)expression; } } // Apply exportable expression if needed. if (!String.IsNullOrEmpty(obj.ExportableExpression)) { object expression = null; if (obj.ExportableExpression.StartsWith("[") && obj.ExportableExpression.EndsWith("]")) { string tempExpression = obj.ExportableExpression.Substring(1, obj.ExportableExpression.Length - 2); int firstOpen = tempExpression.IndexOf("["); int firstClose = tempExpression.IndexOf("]"); int lastOpen = tempExpression.LastIndexOf("["); int lastClose = tempExpression.LastIndexOf("]"); if ((firstOpen < 0 && firstClose >= 0) || (lastOpen >= 0 && lastClose < 0) || (firstOpen >= 0 && firstClose >= 0 && firstClose < firstOpen) || (lastOpen >= 0 && lastClose >= 0 && lastOpen > lastClose)) { expression = Report.Calc(obj.ExportableExpression); } else { expression = Report.Calc(tempExpression); } } else { expression = Report.Calc(obj.ExportableExpression); } if (expression is bool) { obj.Exportable = (bool)expression; } } // Apply printable expression if needed. if (!String.IsNullOrEmpty(obj.PrintableExpression)) { object expression = null; if (obj.PrintableExpression.StartsWith("[") && obj.PrintableExpression.EndsWith("]")) { string tempExpression = obj.PrintableExpression.Substring(1, obj.PrintableExpression.Length - 2); int firstOpen = tempExpression.IndexOf("["); int firstClose = tempExpression.IndexOf("]"); int lastOpen = tempExpression.LastIndexOf("["); int lastClose = tempExpression.LastIndexOf("]"); if ((firstOpen < 0 && firstClose >= 0) || (lastOpen >= 0 && lastClose < 0) || (firstOpen >= 0 && firstClose >= 0 && firstClose < firstOpen) || (lastOpen >= 0 && lastClose >= 0 && lastOpen > lastClose)) { expression = Report.Calc(obj.PrintableExpression); } else { expression = Report.Calc(tempExpression); } } else { expression = Report.Calc(obj.PrintableExpression); } if (expression is bool) { obj.Printable = (bool)expression; } } if (!obj.Visible || !obj.FlagPreviewVisible) { return(false); } bool isFirstPage = CurPage == firstReportPage; bool isLastPage = CurPage == TotalPages - 1; bool isRepeated = obj.Band != null && obj.Band.Repeated; bool canPrint = false; if ((obj.PrintOn & PrintOn.OddPages) > 0 && CurPage % 2 == 1) { canPrint = true; } if ((obj.PrintOn & PrintOn.EvenPages) > 0 && CurPage % 2 == 0) { canPrint = true; } if (isLastPage) { if ((obj.PrintOn & PrintOn.LastPage) == 0) { canPrint = false; } if (obj.PrintOn == PrintOn.LastPage || obj.PrintOn == (PrintOn.LastPage | PrintOn.SinglePage) || obj.PrintOn == (PrintOn.FirstPage | PrintOn.LastPage)) { canPrint = true; } } if (isFirstPage) { if ((obj.PrintOn & PrintOn.FirstPage) == 0) { canPrint = false; } if (obj.PrintOn == PrintOn.FirstPage || obj.PrintOn == (PrintOn.FirstPage | PrintOn.SinglePage) || obj.PrintOn == (PrintOn.FirstPage | PrintOn.LastPage)) { canPrint = true; } } if (isFirstPage && isLastPage) { canPrint = (obj.PrintOn & PrintOn.SinglePage) > 0; } if (isRepeated) { canPrint = (obj.PrintOn & PrintOn.RepeatedBand) > 0; } return(canPrint); }
private void ExtendExport(FastString Page, ReportComponentBase obj, FastString text) { }
private void DoClickObjectByParamID(string objectName, int pageN, float left, float top) { if (Report.PreparedPages != null) { bool found = false; while (pageN < Report.PreparedPages.Count && !found) { ReportPage page = Report.PreparedPages.GetPage(pageN); if (page != null) { ObjectCollection allObjects = page.AllObjects; System.Drawing.PointF point = new System.Drawing.PointF(left + 1, top + 1); foreach (Base obj in allObjects) { if (obj is ReportComponentBase) { ReportComponentBase c = obj as ReportComponentBase; if (c is TableBase) { TableBase table = c as TableBase; for (int i = 0; i < table.RowCount; i++) { for (int j = 0; j < table.ColumnCount; j++) { TableCell textcell = table[j, i]; if (textcell.Name == objectName) { System.Drawing.RectangleF rect = new System.Drawing.RectangleF(table.Columns[j].AbsLeft, table.Rows[i].AbsTop, textcell.Width, textcell.Height); if (rect.Contains(point)) { Click(textcell, pageN, page); found = true; break; } } } if (found) { break; } } } else if (c.Name == objectName && //#if FRCORE c.AbsBounds.Contains(point)) //#else // c.PointInObject(point)) //#endif { Click(c, pageN, page); found = true; break; } } } page.Dispose(); pageN++; } } } }
internal bool CanPrint(ReportComponentBase obj) { // Apply visible expression if needed. if (!String.IsNullOrEmpty(obj.VisibleExpression)) { object expression = null; // Calculate expressions with TotalPages only on FinalPass. if (!obj.VisibleExpression.Contains("TotalPages") || FinalPass) { expression = Report.Calc(Code.CodeUtils.FixExpressionWithBrackets(obj.VisibleExpression)); } if (expression != null && expression is bool) { if (!obj.VisibleExpression.Contains("TotalPages")) { obj.Visible = (bool)expression; } else if (FirstPass) { obj.Visible = true; } else { obj.Visible = (bool)expression; } } } // Apply exportable expression if needed. if (!String.IsNullOrEmpty(obj.ExportableExpression)) { object expression = null; expression = Report.Calc(Code.CodeUtils.FixExpressionWithBrackets(obj.ExportableExpression)); if (expression is bool) { obj.Exportable = (bool)expression; } } // Apply printable expression if needed. if (!String.IsNullOrEmpty(obj.PrintableExpression)) { object expression = null; expression = Report.Calc(Code.CodeUtils.FixExpressionWithBrackets(obj.PrintableExpression)); if (expression is bool) { obj.Printable = (bool)expression; } } if (!obj.Visible || !obj.FlagPreviewVisible) { return(false); } bool isFirstPage = CurPage == firstReportPage; bool isLastPage = CurPage == TotalPages - 1; bool isRepeated = obj.Band != null && obj.Band.Repeated; bool canPrint = false; if ((obj.PrintOn & PrintOn.OddPages) > 0 && CurPage % 2 == 1) { canPrint = true; } if ((obj.PrintOn & PrintOn.EvenPages) > 0 && CurPage % 2 == 0) { canPrint = true; } if (isLastPage) { if ((obj.PrintOn & PrintOn.LastPage) == 0) { canPrint = false; } if (obj.PrintOn == PrintOn.LastPage || obj.PrintOn == (PrintOn.LastPage | PrintOn.SinglePage) || obj.PrintOn == (PrintOn.FirstPage | PrintOn.LastPage)) { canPrint = true; } } if (isFirstPage) { if ((obj.PrintOn & PrintOn.FirstPage) == 0) { canPrint = false; } if (obj.PrintOn == PrintOn.FirstPage || obj.PrintOn == (PrintOn.FirstPage | PrintOn.SinglePage) || obj.PrintOn == (PrintOn.FirstPage | PrintOn.LastPage)) { canPrint = true; } } if (isFirstPage && isLastPage) { canPrint = (obj.PrintOn & PrintOn.SinglePage) > 0; } if (isRepeated) { canPrint = (obj.PrintOn & PrintOn.RepeatedBand) > 0; } return(canPrint); }
private bool HasExtendedExport(ReportComponentBase obj) { return(false); }
private void Layer(FastString Page, ReportComponentBase obj, float Left, float Top, float Width, float Height, FastString Text, string style, FastString addstyletag) { if (Page != null && obj != null) { string onclick = null; if (!String.IsNullOrEmpty(ReportID)) { if (!String.IsNullOrEmpty(obj.ClickEvent) || obj.HasClickListeners()) { onclick = "click"; } CheckBoxObject checkBoxObject = obj as CheckBoxObject; if (checkBoxObject != null && checkBoxObject.Editable) { onclick = "checkbox_click"; } TextObject textObject = obj as TextObject; if (textObject != null && textObject.Editable) { onclick = "text_edit"; } } // we need to adjust left, top, width and height values because borders take up space in html elements float borderLeft = 0; float borderRight = 0; float borderTop = 0; float borderBottom = 0; HTMLBorderWidthValues(obj, out borderLeft, out borderTop, out borderRight, out borderBottom); Page.Append("<div ").Append(style).Append(" style=\""). Append(onclick != null ? "cursor:pointer;" : ""). Append("left:").Append(Px((leftMargin + Left) * Zoom - borderLeft / 2f)). Append("top:").Append(Px((topMargin + Top) * Zoom - borderTop / 2f)). Append("width:").Append(Px(Width * Zoom - borderRight / 2f - borderLeft / 2f)). Append("height:").Append(Px(Height * Zoom - borderBottom / 2f - borderTop / 2f)); if (addstyletag != null) { Page.Append(addstyletag); } Page.Append("\""); if (onclick != null) { string eventParam = String.Format("{0},{1},{2},{3}", obj.Name, CurPage, obj.AbsLeft.ToString("#0"), obj.AbsTop.ToString("#0")); Page.Append(" onclick=\"") .AppendFormat(OnClickTemplate, ReportID, onclick, eventParam) .Append("\""); } Page.Append(">"); if (Text == null) { Page.Append(NBSP); } else { Page.Append(Text); } Page.AppendLine("</div>"); } }
public static void FindClickedObject <T>( this Report Report, string objectName, int pageN, float left, float top, Action <T, ReportPage, int> action ) where T : ComponentBase { if (Report.PreparedPages == null) { return; } bool found = false; while (pageN < Report.PreparedPages.Count && !found) { ReportPage page = Report.PreparedPages.GetPage(pageN); if (page != null) { ObjectCollection allObjects = page.AllObjects; var point = new System.Drawing.PointF(left + 1, top + 1); foreach (Base obj in allObjects) { if (obj is ReportComponentBase) { ReportComponentBase c = obj as ReportComponentBase; if (c is TableBase) { TableBase table = c as TableBase; for (int i = 0; i < table.RowCount; i++) { for (int j = 0; j < table.ColumnCount; j++) { TableCell textcell = table[j, i]; if (textcell.Name == objectName) { RectangleF rect = new RectangleF(table.Columns[j].AbsLeft, table.Rows[i].AbsTop, textcell.Width, textcell.Height); if (rect.Contains(point)) { action(textcell as T, page, pageN); found = true; break; } } } if (found) { break; } } } else if (c is T) { if (c.Name == objectName && c.AbsBounds.Contains(point)) { action(c as T, page, pageN); found = true; break; } } if (found) { break; } } } page.Dispose(); pageN++; } } }
private string GetLayerPicture(ReportComponentBase obj, out float Width, out float Height) { string result = String.Empty; Width = 0; Height = 0; if (obj != null) { if (pictures) { MemoryStream PictureStream = new MemoryStream(); System.Drawing.Imaging.ImageFormat FPictureFormat = System.Drawing.Imaging.ImageFormat.Bmp; if (imageFormat == ImageFormat.Png) { FPictureFormat = System.Drawing.Imaging.ImageFormat.Png; } else if (imageFormat == ImageFormat.Jpeg) { FPictureFormat = System.Drawing.Imaging.ImageFormat.Jpeg; } else if (imageFormat == ImageFormat.Gif) { FPictureFormat = System.Drawing.Imaging.ImageFormat.Gif; } Width = obj.Width == 0 ? obj.Border.LeftLine.Width : obj.Width; Height = obj.Height == 0 ? obj.Border.TopLine.Width : obj.Height; if (Math.Abs(Width) * Zoom < 1 && Zoom > 0) { Width = 1 / Zoom; } if (Math.Abs(Height) * Zoom < 1 && Zoom > 0) { Height = 1 / Zoom; } using (System.Drawing.Image image = new Bitmap( (int)(Math.Abs(Math.Round(Width * Zoom))), (int)(Math.Abs(Math.Round(Height * Zoom))) ) ) { using (Graphics g = Graphics.FromImage(image)) { if (obj is TextObjectBase) { g.Clear(Color.White); } float Left = Width > 0 ? obj.AbsLeft : obj.AbsLeft + Width; float Top = Height > 0 ? obj.AbsTop : obj.AbsTop + Height; float dx = 0; float dy = 0; g.TranslateTransform((-Left - dx) * Zoom, (-Top - dy) * Zoom); BorderLines oldLines = obj.Border.Lines; obj.Border.Lines = BorderLines.None; obj.Draw(new FRPaintEventArgs(g, Zoom, Zoom, Report.GraphicCache)); obj.Border.Lines = oldLines; } if (FPictureFormat == System.Drawing.Imaging.ImageFormat.Jpeg) { ExportUtils.SaveJpeg(image, PictureStream, 95); } else { image.Save(PictureStream, FPictureFormat); } } PictureStream.Position = 0; result = HTMLGetImage(0, 0, 0, Crypter.ComputeHash(PictureStream), true, null, PictureStream, false); } } return(result); }
public void EditPage() { if (Disabled) { return; } using (Report report = new Report()) { ReportPage page = FPreparedPages.GetPage(PageNo - 1); OverlayBand overlay = new OverlayBand(); overlay.Name = "Overlay"; overlay.Width = (page.PaperWidth - page.LeftMargin - page.RightMargin) * Units.Millimeters; overlay.Height = (page.PaperHeight - page.TopMargin - page.BottomMargin) * Units.Millimeters; // remove bands, convert them to Text objects if necessary ObjectCollection allObjects = page.AllObjects; foreach (Base c in allObjects) { if (c is BandBase) { BandBase band = c as BandBase; if (band.HasBorder || band.HasFill) { TextObject textObj = new TextObject(); textObj.Bounds = band.Bounds; textObj.Border = band.Border.Clone(); textObj.Fill = band.Fill.Clone(); overlay.Objects.Add(textObj); } for (int i = 0; i < band.Objects.Count; i++) { ReportComponentBase obj = band.Objects[i]; if (!(obj is BandBase)) { obj.Anchor = AnchorStyles.Left | AnchorStyles.Top; obj.Dock = DockStyle.None; obj.Left = obj.AbsLeft; obj.Top = obj.AbsTop; overlay.Objects.Add(obj); i--; } } } } page.Clear(); page.Overlay = overlay; report.Pages.Add(page); page.SetReport(report); page.SetRunning(false); if (report.DesignPreviewPage()) { page = report.Pages[0] as ReportPage; FPreparedPages.ModifyPage(PageNo - 1, page); Refresh(); } } }
private void ExportBandLayers(Base band) { LayerBack(htmlPage, band as ReportComponentBase, null); foreach (Base c in band.ForEachAllConvectedObjects(this)) { if (c is ReportComponentBase && (c as ReportComponentBase).Exportable) { ReportComponentBase obj = c as ReportComponentBase; // custom draw CustomDrawEventArgs e = new CustomDrawEventArgs(); e.report = Report; e.reportObject = obj; e.layers = Layers; e.zoom = Zoom; e.left = obj.AbsLeft; e.top = hPos + obj.AbsTop; e.width = obj.Width; e.height = obj.Height; OnCustomDraw(e); if (e.done) { css.Append(e.css); htmlPage.Append(e.html); } else { if (!String.IsNullOrEmpty(obj.Bookmark)) { htmlPage.Append("<a name=\"").Append(obj.Bookmark).Append("\"></a>"); } if (obj is CellularTextObject) { obj = (obj as CellularTextObject).GetTable(); } if (obj is TableCell) { continue; } else if (obj is TableBase) { TableBase table = obj as TableBase; if (table.ColumnCount > 0 && table.RowCount > 0) { using (TextObject tableback = new TextObject()) { tableback.Border = table.Border; tableback.Fill = table.Fill; tableback.FillColor = table.FillColor; tableback.Left = table.AbsLeft; tableback.Top = table.AbsTop; float tableWidth = 0; float tableHeight = 0; for (int i = 0; i < table.ColumnCount; i++) { tableWidth += table[i, 0].Width; } for (int i = 0; i < table.RowCount; i++) { tableHeight += table.Rows[i].Height; } tableback.Width = (tableWidth < table.Width) ? tableWidth : table.Width; tableback.Height = tableHeight; LayerText(htmlPage, tableback); } LayerTable(htmlPage, css, table); } } else if (IsMemo(obj)) { LayerText(htmlPage, obj as TextObject); } else if (obj is HtmlObject) { LayerHtml(htmlPage, obj as HtmlObject); } else if (obj is BandBase) { LayerBack(htmlPage, obj, null); } else if (obj is LineObject) { LayerPicture(htmlPage, obj, null); } else if (obj is ShapeObject && ((obj as ShapeObject).Shape == ShapeKind.Rectangle || (obj as ShapeObject).Shape == ShapeKind.RoundRectangle)) { LayerShape(htmlPage, obj as ShapeObject, null); } else if (HasExtendedExport(obj)) { ExtendExport(htmlPage, obj, null); } else { LayerBack(htmlPage, obj, null); LayerPicture(htmlPage, obj, null); } } } } }