RSize _Width; // Width of the row header

        #endregion Fields

        #region Constructors

        internal 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.");
        }
        RSize _Width; // Width of the column

        #endregion Fields

        #region Constructors

        internal 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.");
        }
Beispiel #3
0
        MarkerTypeEnum _Type; // Defines the marker type for values. Default: none

        #endregion Fields

        #region Constructors

        //  properties for the marker(s).
        internal 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;
                }
            }
        }
        StaticColumns _StaticColumns; // Static column headings for this grouping

        #endregion Fields

        #region Constructors

        internal 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.");
        }
        MatrixCells _MatrixCells; // The set of cells in a row in the detail section of the Matrix.

        #endregion Fields

        #region Constructors

        internal 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.");
        }
        StaticColumns _StaticColumns;   // Static column headings for this grouping

        internal 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; // Style information for the page footer

        #endregion Fields

        #region Constructors

        internal 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.");
        }
Beispiel #8
0
        Style _Style; // Default style information for the body

        #endregion Fields

        #region Constructors

        internal Body(ReportDefn r, ReportLink p, XmlNode xNode)
            : base(r, p)
        {
            _ReportItems = null;
            _Height = null;
            _Columns = 1;
            _ColumnSpacing=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 "ReportItems":
                        _ReportItems = new ReportItems(r, this, xNodeLoop);	// need a class for this
                        break;
                    case "Height":
                        _Height = new RSize(r, xNodeLoop);
                        break;
                    case "Columns":
                        _Columns = XmlUtil.Integer(xNodeLoop.InnerText);
                        break;
                    case "ColumnSpacing":
                        _ColumnSpacing = new RSize(r, xNodeLoop);
                        break;
                    case "Style":
                        _Style = new Style(r, this, xNodeLoop);
                        break;
                    default:
                        // don't know this element - log it
                        OwnerReport.rl.LogError(4, "Unknown Body element '" + xNodeLoop.Name + "' ignored.");
                        break;
                }
            }
            if (_Height == null)
                OwnerReport.rl.LogError(8, "Body Height not specified.");
        }
        RSize _Width; // Width of each detail cell in this column

        #endregion Fields

        #region Constructors

        internal 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;
                }
            }
        }
Beispiel #10
0
        StaticRows _StaticRows;   // Static row headings for this grouping

        internal 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>
        private static WordStartFinish[] MeasureString32(string s, Graphics g, System.Drawing.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

        internal 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.");
            }
        }
Beispiel #13
0
        Visibility _Visibility; // Indicates if the row should be hidden

        #endregion Fields

        #region Constructors

        internal 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.");
        }
Beispiel #14
0
        internal 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);
        }
Beispiel #15
0
        RSize _Width;                   // Width of each detail cell in this column

        internal 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;
                }
            }
        }
        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);
        }
        Type _CodeType;                         // used for parsing of expressions; DONT USE AT RUNTIME

        // Constructor
        internal ReportDefn(XmlNode xNode, ReportLog replog, string folder, NeedPassword getpswd, int objcount, IRdlSourceLoader sourceLoader) // report has no parents
        {
            rl            = replog;                                                                                                            // used for error reporting
            _ObjectCount  = objcount;                                                                                                          // starting number for objects in this report; 0 other than for subreports
            _SourceLoader = sourceLoader;
            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 = 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 static string[] MeasureString(PageText pt, Graphics g, out float[] width)
        {
            StyleInfo si = pt.SI;
            string    s  = pt.Text;

            System.Drawing.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 System.Drawing.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();
                }
            }
        }
Beispiel #19
0
        internal 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;
        }
        // return points
        internal float EvalTop(Report rpt, Row r)
        {
            if (_Top == null)
                return EvalDefault(rpt, r);

            string sw = _Top.EvaluateString(rpt, r);
            RSize rs = new RSize(this.OwnerReport, sw);
            return rs.Points;
        }
 internal 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 = 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;
 }
Beispiel #22
0
        static public float PointSize(string v)
        {
            RSize rs = new RSize(null, v);

            return(rs.Points);
        }
Beispiel #23
0
 private int GetTwipsFromPixels(int pixels)
 {
     return((int)Math.Round(RSize.PointsFromPixels(GetGraphics, pixels) * 20, 0));
 }
Beispiel #24
0
        internal 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 = 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);
        }
Beispiel #25
0
        internal float EvalPaddingTop(Report rpt, Row row)
        {
            if (_PaddingTop == null)
                return 0;

            string v = _PaddingTop.EvaluateString(rpt, row);
            RSize rz = new RSize(OwnerReport, v);
            return rz.Points;
        }
Beispiel #26
0
        internal int EvalPaddingTopPx(Report rpt, Row row)
        {
            if (_PaddingTop == null)
                return 0;

            string v = _PaddingTop.EvaluateString(rpt, row);
            RSize rz = new RSize(OwnerReport, v);
            return rz.PixelsY;
        }
        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();
                }
            }
        }
        int _ZIndex; // Drawing order of the report item within the

        #endregion Fields

        #region Constructors

        internal 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;
                }
            }
        }
Beispiel #29
0
        internal 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;
        }
 internal 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");
 }
Beispiel #31
0
        /// <summary>
        /// Render all the objects in a page
        /// </summary>
        private void processPage(Pages pages, IEnumerable page)
        {
            //loop thru the items in the page
            foreach (PageItem pageItem in page)
            {
                if (pageItem.SI.BackgroundImage != null)
                {
                    //put out any background image
                    PageImage backgroundImage = pageItem.SI.BackgroundImage;

                    float imageWidth  = RSize.PointsFromPixels(pages.G, backgroundImage.SamplesW);
                    float imageHeight = RSize.PointsFromPixels(pages.G, backgroundImage.SamplesH);
                    int   repeatX     = 0;
                    int   repeatY     = 0;
                    float itemWidth   = pageItem.W - (pageItem.SI.PaddingLeft + pageItem.SI.PaddingRight);
                    float itemHeight  = pageItem.H - (pageItem.SI.PaddingTop + pageItem.SI.PaddingBottom);

                    switch (backgroundImage.Repeat)
                    {
                    case ImageRepeat.Repeat:
                        repeatX = (int)Math.Floor(itemWidth / imageWidth);
                        repeatY = (int)Math.Floor(itemHeight / imageHeight);
                        break;

                    case ImageRepeat.RepeatX:
                        repeatX = (int)Math.Floor(itemWidth / imageWidth);
                        repeatY = 1;
                        break;

                    case ImageRepeat.RepeatY:
                        repeatY = (int)Math.Floor(itemHeight / imageHeight);
                        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  = pageItem.X + pageItem.SI.PaddingLeft;
                    float currY  = pageItem.Y + pageItem.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 * imageWidth;
                            currY = startY + j * imageHeight;

                            addImage(backgroundImage.SI, currX, currY, imageWidth, imageHeight, RectangleF.Empty,
                                     backgroundImage.ImageData, null, pageItem.Tooltip);
                        }
                    }
                }
                else if (pageItem is PageTextHtml)
                {
                    PageTextHtml pageTextHtml = pageItem as PageTextHtml;
                    pageTextHtml.Build(pages.G);
                    processPage(pages, pageTextHtml);
                    continue;
                }
                else if (pageItem is PageText)
                {
                    PageText pageText = pageItem as PageText;
                    float[]  textwidth;
                    string[] measureStrings = RenderUtility.MeasureString(pageText, pages.G, out textwidth);
                    addText(pageText.X, pageText.Y, pageText.W, pageText.H, measureStrings, pageText.SI, textwidth, pageText.CanGrow, pageText.HyperLink, pageText.NoClip, pageText.Tooltip);
                    continue;
                }
                else if (pageItem is PageLine)
                {
                    PageLine pageLine = pageItem as PageLine;
                    addLine(pageLine.X, pageLine.Y, pageLine.X2, pageLine.Y2, pageLine.SI);
                    continue;
                }
                else if (pageItem is PageEllipse)
                {
                    PageEllipse pageEllipse = pageItem as PageEllipse;
                    addEllipse(pageEllipse.X, pageEllipse.Y, pageEllipse.W, pageEllipse.H, pageEllipse.SI, pageEllipse.HyperLink);
                    continue;
                }
                else if (pageItem is PageImage)
                {
                    PageImage pageImage = pageItem as PageImage;

                    //Duc Phan added 20 Dec, 2007 to support sized image
                    RectangleF r2 = new RectangleF(pageImage.X + pageImage.SI.PaddingLeft, pageImage.Y + pageImage.SI.PaddingTop,
                                                   pageImage.W - pageImage.SI.PaddingLeft - pageImage.SI.PaddingRight, pageImage.H - pageImage.SI.PaddingTop - pageImage.SI.PaddingBottom);

                    //work rectangle
                    RectangleF adjustedRect;
                    RectangleF clipRect = RectangleF.Empty;
                    switch (pageImage.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(pages.G, pageImage.SamplesW),
                                                      RSize.PointsFromPixels(pages.G, pageImage.SamplesH));
                        clipRect = new RectangleF(r2.Left, r2.Top, r2.Width, r2.Height);
                        break;

                    case ImageSizingEnum.FitProportional:
                        float height;
                        float width;
                        float ratioIm = (float)pageImage.SamplesH / pageImage.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 (pageImage.ImgFormat != System.Drawing.Imaging.ImageFormat.Wmf && pageImage.ImgFormat != System.Drawing.Imaging.ImageFormat.Emf)
                    {
                        addImage(pageImage.SI, adjustedRect.X, adjustedRect.Y, adjustedRect.Width, adjustedRect.Height,
                                 clipRect, pageImage.ImageData, pageImage.HyperLink, pageImage.Tooltip);
                    }
                    continue;
                }
                else if (pageItem is PageRectangle)
                {
                    PageRectangle pageRectangle = pageItem as PageRectangle;
                    addRectangle(pageRectangle.X, pageRectangle.Y, pageRectangle.W, pageRectangle.H, pageItem.SI, pageItem.HyperLink, pageItem.Tooltip);
                    continue;
                }
                else if (pageItem is PagePie)
                {
                    PagePie pagePie = pageItem as PagePie;
                    addPie(pagePie.X, pagePie.Y, pagePie.W, pagePie.H, pageItem.SI, pageItem.HyperLink, pageItem.Tooltip);
                    continue;
                }
                else if (pageItem is PagePolygon)
                {
                    PagePolygon pagePolygon = pageItem as PagePolygon;
                    addPolygon(pagePolygon.Points, pageItem.SI, pageItem.HyperLink);
                    continue;
                }
                else if (pageItem is PageCurve)
                {
                    PageCurve pageCurve = pageItem as PageCurve;
                    addCurve(pageCurve.Points, pageItem.SI);
                    continue;
                }
            }
        }
        // return points
        internal float EvalDefault(Report rpt, Row r)
        {
            if (_Default == null)
                return 1;

            string sw;
            sw = _Default.EvaluateString(rpt, r);

            RSize rs = new RSize(this.OwnerReport, sw);
            return rs.Points;
        }
Beispiel #33
0
 public static float PointSize(string v)
 {
     RSize rs = new RSize(null, v);
     return rs.Points;
 }
Beispiel #34
0
        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 + _LastCategoryWidth/2)
                Layout.RightMargin = min + _LastCategoryWidth/2;
            if (Layout.LeftMargin < min)
                Layout.LeftMargin = min;
            if (Layout.TopMargin < min)
                Layout.TopMargin = min;
            if (Layout.BottomMargin < min)
                Layout.BottomMargin = min;
        }
Beispiel #35
0
        internal 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);
        }
Beispiel #36
0
        override internal 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 = EngineConfig.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;
        }
        RSize _Width; // Width of the report

        #endregion Fields

        #region Constructors

        // report has no parents
        // Constructor
        internal ReportDefn(XmlNode xNode, ReportLog replog, string folder, NeedPassword getpswd, int objcount, IRdlSourceLoader sourceLoader)
        {
            rl = replog;				// used for error reporting
            _ObjectCount = objcount;	// starting number for objects in this report; 0 other than for subreports
            _SourceLoader = sourceLoader;
            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 = 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);
        }