123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- #if DOTNET_4
- using FastReport.SVG;
- #endif
- using FastReport.Utils;
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Globalization;
- using System.IO;
- using FastReport.AdvMatrix;
- using System.Text;
- namespace FastReport.Export.Html
- {
- public partial class HTMLExport
- {
- private void ExportHTMLPageBegin(object data)
- {
- HTMLData d = (HTMLData)data;
- if (layers)
- ExportHTMLPageLayeredBegin(d);
- else
- ExportHTMLPageTabledBegin(d);
- }
- private void ExportHTMLPageEnd(object data)
- {
- HTMLData d = (HTMLData)data;
- if (layers)
- ExportHTMLPageLayeredEnd(d);
- else
- ExportHTMLPageTabledEnd(d);
- }
- private string GetHrefAdvMatrixButton(ReportComponentBase obj, string href)
- {
- if (obj is MatrixButton)
- {
- MatrixButton matrixButton = obj as MatrixButton;
- string url = String.Format("{0},{1},{2}",
- EncodeURL(matrixButton.Name), // object name for security reasons
- CurPage,
- matrixButton.Index);
- string onClick = String.Format(OnClickTemplate, ReportID, "advmatrix_click", url);
- href = String.Format("<a onclick=\"{0}\">", onClick);
- }
- return href;
- }
- private void SetExportableAdvMatrix(Base c)
- {
- if (c is MatrixButton)
- {
- MatrixButton matrixButton = c as MatrixButton;
- matrixButton.Exportable = true;
- }
- }
- /// <inheritdoc/>
- protected override void ExportBand(BandBase band)
- {
- if (ExportMode == ExportType.Export)
- base.ExportBand(band);
- else
- band.UpdateWidth();
- //
- if (Layers)
- ExportBandLayers(band);
- else
- ExportBandTable(band);
- }
- private bool HasExtendedExport(ReportComponentBase obj)
- {
- #if DOTNET_4
- return obj is SVGObject;
- #else
- return false;
- #endif
- }
- private void ExtendExport(FastString Page, ReportComponentBase obj, FastString text)
- {
- #if DOTNET_4
- if (obj is SVGObject)
- LayerSVG(htmlPage, obj as SVGObject, null);
- #endif
- }
- #if DOTNET_4
- #region svg
- private string GetLayerSVG(SVGObject svg, out float Width, out float Height)
- {
- Width = 0;
- Height = 0;
- if (svg != null)
- {
- if (pictures)
- {
- Width = svg.Width == 0 ? svg.Border.LeftLine.Width : svg.Width;
- Height = svg.Height == 0 ? svg.Border.TopLine.Width : svg.Height;
- if (Math.Abs(Width) * Zoom < 1 && Zoom > 0)
- Width = 1 / Zoom;
- if (Math.Abs(Height) * Zoom < 1 && Zoom > 0)
- Height = 1 / Zoom;
- MemoryStream svgStream = new MemoryStream();
- if (svg.Grayscale)
- svg.SVGGrayscale.Write(svgStream);
- else
- svg.SvgDocument.Write(svgStream);
- svgStream.Position = 0;
- string result = HTMLGetImage(0, 0, 0, Crypter.ComputeHash(svgStream), true, null, svgStream, true);
- return result;
- }
- }
- return null;
- }
- private void LayerSVG(FastString Page, SVGObject obj, FastString text)
- {
- if (!pictures)
- return;
- float Width, Height;
- string svg = GetLayerSVG(obj, out Width, out Height);
- FastString addstyle = new FastString(64);
- addstyle.Append("position:absolute;");
- addstyle.Append(" background: url('").Append(svg).Append("') center center no-repeat !important;-webkit-print-color-adjust:exact;");
- if (obj.Angle != 0)
- {
- addstyle.Append($"transform: rotate({obj.Angle}deg);");
- }
- float x = obj.Width > 0 ? obj.AbsLeft : (obj.AbsLeft + obj.Width);
- float y = obj.Height > 0 ? hPos + obj.AbsTop : (hPos + obj.AbsTop + obj.Height);
- Layer(Page, obj, x, y, obj.Width, obj.Height, text, null, addstyle);
- // cleanup SVG
- obj.Dispose();
- }
- #endregion
- #endif
- }
- }
|