Ejemplo n.º 1
0
		internal void RunPage(Pages pgs, Row row)
		{
			// Start each row in the same location
			//   e.g. if there are two embedded tables in cells they both start at same location
			Page savepg = pgs.CurrentPage;
			float savey = savepg.YOffset;
			Page maxpg = savepg;
			float maxy = savey;

			foreach (TableCell tc in _Items)
			{
				tc.RunPage(pgs, row);
				if (maxpg != pgs.CurrentPage)
				{	// a page break
					if (maxpg.PageNumber < pgs.CurrentPage.PageNumber)
					{
						maxpg = pgs.CurrentPage;
						maxy = maxpg.YOffset;
					}
				}
				else if (maxy > pgs.CurrentPage.YOffset)
				{
					// maxy = maxy;      TODO what was this meant to do
				}
				// restore the beginning start of the row
				pgs.CurrentPage = savepg;
				savepg.YOffset = savey;
			}
			pgs.CurrentPage = maxpg;
			savepg.YOffset = maxy;
			return ;
		}
Ejemplo n.º 2
0
		override internal void RunPage(Pages pgs, Row row)
		{
			Report r = pgs.Report;
            bool bHidden = IsHidden(r, row);

			SetPagePositionBegin(pgs);
			PageLine pl = new PageLine();
            SetPagePositionAndStyle(r, pl, row);
            if (!bHidden)
			    pgs.CurrentPage.AddObject(pl);
			SetPagePositionEnd(pgs, pl.Y);
		}
Ejemplo n.º 3
0
        private int printCurrentPage;		// current page to print

        public RdlPrint()
        {
            _SourceFileName = null;
            _SourceRdl = null;
            _Parameters = null;				// parameters to run the report
            _pgs = null;						// the pages of the report to view
            _loadFailed = false;
            _PageWidth = 0;
            _PageHeight = 0;
            _ReportDescription = null;
            _ReportAuthor = null;
            _ReportName = null;
        }
Ejemplo n.º 4
0
		internal void RunPage(Pages pgs, Row row)
		{

			Page p = pgs.CurrentPage;
			if (p.YOffset + HeightOfRows(pgs, row) > pgs.BottomOfPage)
			{
				p = OwnerTable.RunPageNew(pgs, p);
				OwnerTable.RunPageHeader(pgs, row, false, null);
			}
			_TableRows.RunPage(pgs, row);

			return;
		}
Ejemplo n.º 5
0
        public void RunPages(Pages pgs)
        {
            //TODO : Why Cairo is broken when CurrentThread.CurrentCulture is set to local ?
            //At Linux when CurrentCulture is set to local culture, Cairo rendering is serious broken
            CultureInfo oldci = Thread.CurrentThread.CurrentCulture;
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            try {
                foreach (Page p in pgs) {
                    ProcessPage (g, p);
                    break;
                }
            } finally {
                Thread.CurrentThread.CurrentCulture = oldci;
            }
        }
Ejemplo n.º 6
0
        public PageDrawing(Pages pgs)
        {
            // Set up the tooltip
            _tt = new ToolTip();
            _tt.Active = false;
            _tt.ShowAlways = true;

            _HitList = new List<HitListEntry>();
            _SelectList = new List<PageItem>();
            _LastZoom = 1;

            _pgs = pgs;

            // Get our graphics DPI
            Graphics ga = null;
            try
            {
                ga = this.CreateGraphics();
                DpiX = ga.DpiX;
                DpiY = ga.DpiY;
            }
            catch
            {
                DpiX = DpiY = 96;
            }
            finally
            {
                if (ga != null)
                    ga.Dispose();
            }
            // force to double buffering for smoother drawing
            //this.SetStyle(ControlStyles.DoubleBuffer |
            //    ControlStyles.UserPaint |
            //    ControlStyles.AllPaintingInWmPaint,
            //    true);

            this.DoubleBuffered = true;
        }
Ejemplo n.º 7
0
		override internal void RunPage(Pages pgs, Row row)
		{
			Report r = pgs.Report;
			if (IsHidden(r, row))
				return;

			SetPagePositionBegin(pgs);
			PageLine pl = new PageLine();
            SetPagePositionAndStyle(r, pl, row);
            //pl.X = GetOffsetCalc(r) + LeftCalc(r);
            //if (Top != null)
            //    pl.Y = Top.Points;
            //pl.Y2 = Y2;
            //pl.X2 = GetX2(pgs.Report);

            //if (Style != null)
            //    pl.SI = Style.GetStyleInfo(r, row);
            //else
            //    pl.SI = new StyleInfo();	// this will just default everything

			pgs.CurrentPage.AddObject(pl);
			SetPagePositionEnd(pgs, pl.Y);
		}
Ejemplo n.º 8
0
Archivo: Header.cs Proyecto: mnisl/OD
		internal void RunPage(Pages pgs, Row row)
		{
			WorkClass wc = this.GetValue(pgs.Report);

			if (wc.OutputRow == row && wc.OutputPage == pgs.CurrentPage)
				return;

			Page p = pgs.CurrentPage;

			float height = p.YOffset + HeightOfRows(pgs, row);
			if (height > pgs.BottomOfPage)
			{
				Table t = OwnerTable;
				p = t.RunPageNew(pgs, p);
				t.RunPageHeader(pgs, row, false, null);
				if (this.RepeatOnNewPage)
					return;		// should already be on the page
			}

			_TableRows.RunPage(pgs, row);
			wc.OutputRow = row;
			wc.OutputPage = pgs.CurrentPage;
			return;
		}
Ejemplo n.º 9
0
Archivo: List.cs Proyecto: mnisl/OD
		override internal void RunPage(Pages pgs, Row row)
		{
			Report r = pgs.Report;
			if (IsHidden(r, row))
				return;

			WorkClass wc = GetValue(r);
			wc.Data = GetFilteredData(r, row);

			SetPagePositionBegin(pgs);

			if (!AnyRowsPage(pgs, wc.Data))		// if no rows return
				return;						//   nothing left to do

			RunPageRegionBegin(pgs);

			RunSetGrouping(pgs.Report, wc);

			RunPageGroups(pgs, wc, wc.Groups);

			RunPageRegionEnd(pgs);
			SetPagePositionEnd(pgs, pgs.CurrentPage.YOffset);
			RemoveValue(r);
		}
Ejemplo n.º 10
0
 internal float HeightOfRows(Pages pgs, Row r)
 {
     return(_TableRows.HeightOfRows(pgs, r));
 }
Ejemplo n.º 11
0
        private void RunPageGroups(Pages pgs, WorkClass wc, List <GroupEntry> groupEntries)
        {
            Report rpt        = pgs.Report;
            Page   p          = pgs.CurrentPage;
            float  pagebottom = OwnerReport.BottomOfPage;

//			p.YOffset += (Top == null? 0: this.Top.Points);
            p.YOffset += this.RelativeY(rpt);
            float listoffset = GetOffsetCalc(pgs.Report) + LeftCalc(pgs.Report);

            float height;
            Row   row;

            foreach (GroupEntry ge in groupEntries)
            {
                // set the group entry value
                int index;
                if (ge.Group != null)                   // groups?
                {
                    ge.Group.ResetHideDuplicates(rpt);  // reset duplicate checking
                    index = ge.Group.GetIndex(rpt);     // yes
                }
                else                                    // no; must be main dataset
                {
                    index = 0;
                }
                wc.Data.CurrentGroups[index] = ge;
                if (ge.NestedGroup.Count > 0)
                {
                    RunGroupsSetGroups(rpt, wc, ge.NestedGroup);
                }

                if (ge.Group == null)
                {                       // need to run all the rows since no group defined
                    for (int r = ge.StartRow; r <= ge.EndRow; r++)
                    {
                        row    = wc.Data.Data[r];
                        height = HeightOfList(rpt, pgs.G, row);

                        if (p.YOffset + height > pagebottom && !p.IsEmpty()) // need another page for this row?
                        {
                            p = RunPageNew(pgs, p);                          // yes; if at end this page is empty
                        }
                        float saveYoffset = p.YOffset;                       // this can be affected by other page items

                        if (_ReportItems != null)
                        {
                            _ReportItems.RunPage(pgs, row, listoffset);
                        }

                        if (p == pgs.CurrentPage) // did subitems force new page?
                        {                         // no use the height of the list
                            p.YOffset = saveYoffset + height;
                        }
                        else
                        {                        // got forced to new page; just add the padding on
                            p = pgs.CurrentPage; // set to new page
                            if (this.Style != null)
                            {
                                p.YOffset += this.Style.EvalPaddingBottom(rpt, row);
                            }
                        }
                    }
                }
                else
                {                       // need to process just whole group as a List entry
                    if (ge.Group.PageBreakAtStart && !p.IsEmpty())
                    {
                        p = RunPageNew(pgs, p);
                    }

                    // pass the first row of the group
                    row    = wc.Data.Data[ge.StartRow];
                    height = HeightOfList(rpt, pgs.G, row);

                    if (p.YOffset + height > pagebottom && !p.IsEmpty()) // need another page for this row?
                    {
                        p = RunPageNew(pgs, p);                          // yes; if at end this page is empty
                    }
                    float saveYoffset = p.YOffset;                       // this can be affected by other page items

                    if (_ReportItems != null)
                    {
                        _ReportItems.RunPage(pgs, row, listoffset);
                    }


                    if (p == pgs.CurrentPage) // did subitems force new page?
                    {                         // no use the height of the list
                        p.YOffset = saveYoffset + height;
                    }
                    else
                    {                        // got forced to new page; just add the padding on
                        p = pgs.CurrentPage; // set to new page
                        if (this.Style != null)
                        {
                            p.YOffset += this.Style.EvalPaddingBottom(rpt, row);
                        }
                    }

                    if (ge.Group.PageBreakAtEnd ||                                      // need another page for next group?
                        p.YOffset + height > pagebottom)
                    {
                        p = RunPageNew(pgs, p);                                                                 // yes; if at end empty page will be cleaned up later
                    }
                }
                RemoveWC(rpt);
            }
        }
Ejemplo n.º 12
0
 // we don't have paging turned on for html
 public void RunPages(Pages pgs)
 {
 }
Ejemplo n.º 13
0
		internal void RunPageRegionEnd(Pages pgs)
		{
			if (this.TC == null && this.PageBreakAtEnd && !pgs.CurrentPage.IsEmpty())
			{	// force page break at beginning of dataregion
				pgs.NextOrNew();
				pgs.CurrentPage.YOffset = OwnerReport.TopOfPage;
			}
		}
Ejemplo n.º 14
0
        // this does all the work
        public void RunPages(Pages pgs)
        {
            foreach (Page p in pgs)
            {
                PageSize = new PdfPageSize((int)_report.ReportDefinition.PageWidth.ToPoints(),
                                       (int)_report.ReportDefinition.PageHeight.ToPoints());

                //Create a Page
                CreatePage();
                ProcessPage(pgs, p);
                // after a page
                AfterProcessPage();
            }
            return;
        }
Ejemplo n.º 15
0
        internal void RunPage(Pages pgs, Row row)
        {
            if (this.Visibility != null && Visibility.IsHidden(pgs.Report, row))
                return;

            _TableCells.RunPage(pgs, row);

            WorkClass wc = GetWC(pgs.Report);
            pgs.CurrentPage.YOffset += wc.CalcHeight;
            return ;
        }
Ejemplo n.º 16
0
 internal virtual void RunPage(Pages pgs, Row row)
 {
     return;
 }
Ejemplo n.º 17
0
        override internal void RunPage(Pages pgs, Row row)
        {
            Report r = pgs.Report;

            if (IsHidden(r, row))
            {
                return;
            }

            base.RunPage(pgs, row);

            // need to save the owner report and nest in this defintion
            ReportDefn   saveReport = r.ReportDefinition;
            NeedPassword np         = r.GetDataSourceReferencePassword; // get current password

            r.SetReportDefinition(_ReportDefn);
            r.Folder = _ReportDefn.ParseFolder;                         // folder needs to get set since the id of the report is used by the cache
            r.GetDataSourceReferencePassword = np;

            DataSourcesDefn saveDS = r.ParentConnections;

            if (this.MergeTransactions)
            {
                r.ParentConnections = saveReport.DataSourcesDefn;
            }
            else
            {
                r.ParentConnections = null;
            }

            r.SubreportDataRetrievalTriggerEvent();

            bool bRows = true;

            if (_Parameters == null)
            {                   // When no parameters we only retrieve data once
                SubreportWorkClass wc = r.Cache.Get(this, "report") as SubreportWorkClass;

                if (wc == null)
                {                                                                   // run report first time;
                    bRows = r.RunGetData(null);
                    if (!r.IsSubreportDataRetrievalDefined)                         // if use has defined subreportdataretrieval they might set data
                    {
                        r.Cache.Add(this, "report", new SubreportWorkClass(bRows)); // so we can't cache
                    }
                }
                else
                {
                    bRows = wc.bRows;
                }
            }
            else
            {
                SetSubreportParameters(r, row);                         // apply the parameters
                bRows = r.RunGetData(null);
            }

            SetPageLeft(r);                                     // Set the Left attribute since this will be the margin for this report

            SetPagePositionBegin(pgs);

            float yOffset;

            if (bRows)  // Only run subreport if have a row in some Dataset
            {
                //
                // Run the subreport -- this is the major effort in creating the display objects in the page
                //
                r.ReportDefinition.Body.RunPage(pgs);           // create a the subreport items
                yOffset = pgs.CurrentPage.YOffset;
            }
            else
            {   // Handle NoRows message
                string msg;
                if (this.NoRows != null)
                {
                    msg = this.NoRows.EvaluateString(pgs.Report, null);
                }
                else
                {
                    msg = null;
                }

                if (msg != null)
                {
                    PageText pt = new PageText(msg);
                    SetPagePositionAndStyle(pgs.Report, pt, null);

                    if (pt.SI.BackgroundImage != null)
                    {
                        pt.SI.BackgroundImage.H = pt.H;         //   and in the background image
                    }
                    pgs.CurrentPage.AddObject(pt);

                    yOffset = pt.Y + pt.H;
                }
                else
                {
                    yOffset = pgs.CurrentPage.YOffset;
                }
            }

            r.SetReportDefinition(saveReport);                                  // restore the current report
            r.ParentConnections = saveDS;                                       // restore the data connnections

            SetPagePositionEnd(pgs, yOffset);
        }
        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 = RdlEngineConfig.CreateCustomReportItem(_Type);
                SetProperties(pgs.Report, row, cri);

                int width = WidthCalc(rpt, pgs.G) -
                            (Style == null? 0 :
                             (Style.EvalPaddingLeftPx(rpt, row) + Style.EvalPaddingRightPx(rpt, row)));
                int height = RSize.PixelsFromPoints(this.HeightOrOwnerHeight) -
                             (Style == null? 0 :
                              (Style.EvalPaddingTopPx(rpt, row) + Style.EvalPaddingBottomPx(rpt, row)));
                bm = Bitmap.CreateBitmap(width, height, PixelFormat.Format16bppRgb565);// Bitmap.Config.Rgb565);
                cri.DrawImage(ref 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;
        }
Ejemplo n.º 19
0
 public void RunPages(Pages pgs)         // we don't have paging turned on for xml
 {
     return;
 }
Ejemplo n.º 20
0
 public void RunPages(Pages pgs)         // we don't have paging turned on for html
 {
 }
Ejemplo n.º 21
0
        override internal void RunPage(Pages pgs, Row row)
        {
            Report r = pgs.Report;

            if (IsHidden(r, row))
            {
                return;
            }

            WorkClass wc    = GetWC(r);
            string    mtype = null;
            Stream    strm  = null;

            System.Drawing.Image im = null;

            SetPagePositionBegin(pgs);
            if (wc.PgImage != null)
            {                                // have we already generated this one
                                             // reuse most of the work; only position will likely change
                PageImage pi = new PageImage(wc.PgImage.ImgFormat, wc.PgImage.ImageData, wc.PgImage.SamplesW, wc.PgImage.SamplesH);
                pi.Name   = wc.PgImage.Name; // this is name it will be shared under
                pi.Sizing = this._Sizing;
                this.SetPagePositionAndStyle(r, pi, row);
                pgs.CurrentPage.AddObject(pi);
                SetPagePositionEnd(pgs, pi.Y + pi.H);
                return;
            }

            try
            {
                strm = GetImageStream(r, row, out mtype);
                im   = System.Drawing.Image.FromStream(strm);
                int          height = im.Height;
                int          width  = im.Width;
                MemoryStream ostrm  = new MemoryStream();
                ImageFormat  imf;
                //				if (mtype.ToLower() == "image/jpeg")    //TODO: how do we get png to work
                //					imf = ImageFormat.Jpeg;
                //				else
                imf = ImageFormat.Jpeg;
                im.Save(ostrm, imf);
                byte[] ba = ostrm.ToArray();
                ostrm.Close();
                PageImage pi = new PageImage(imf, ba, width, height);
                pi.Sizing = this._Sizing;
                this.SetPagePositionAndStyle(r, pi, row);

                pgs.CurrentPage.AddObject(pi);
                if (_ConstantImage)
                {
                    wc.PgImage = pi;
                    // create unique name; PDF generation uses this to optimize the saving of the image only once
                    pi.Name = "pi" + Interlocked.Increment(ref Parser.Counter).ToString();                      // create unique name
                }

                SetPagePositionEnd(pgs, pi.Y + pi.H);
            }
            catch (Exception e)
            {
                // image failed to load, continue processing
                r.rl.LogError(4, "Image load failed.  " + e.Message);
            }
            finally
            {
                if (strm != null)
                {
                    strm.Close();
                }
                if (im != null)
                {
                    im.Dispose();
                }
            }
            return;
        }
Ejemplo n.º 22
0
 internal float HeightOfRow(Pages pgs, Row r)
 {
     return(HeightOfRow(pgs.Report, pgs.G, r));
 }
Ejemplo n.º 23
0
Archivo: List.cs Proyecto: mnisl/OD
		private void RunPageGroups(Pages pgs, WorkClass wc, List<GroupEntry> groupEntries)
		{
			Report rpt = pgs.Report;
			Page p = pgs.CurrentPage;
			float pagebottom = OwnerReport.BottomOfPage;
			p.YOffset += (Top == null? 0: this.Top.Points); 
			float listoffset = GetOffsetCalc(pgs.Report)+LeftCalc(pgs.Report);

			float height;	
			Row row;

			foreach (GroupEntry ge in groupEntries)
			{
				// set the group entry value
				int index;
				if (ge.Group != null)	// groups?
				{
					ge.Group.ResetHideDuplicates(rpt);	// reset duplicate checking
					index = ge.Group.GetIndex(rpt);	// yes
				}
				else					// no; must be main dataset
					index = 0;
				wc.Data.CurrentGroups[index] = ge;
				if (ge.NestedGroup.Count > 0)
					RunGroupsSetGroups(rpt, wc, ge.NestedGroup);

				if (ge.Group == null)
				{	// need to run all the rows since no group defined
					for (int r=ge.StartRow; r <= ge.EndRow; r++)
					{
						row = wc.Data.Data[r];
						height = HeightOfList(rpt, pgs.G, row);
                        float saveYoffset = p.YOffset;              // this can be affected by other page items
						_ReportItems.RunPage(pgs, row, listoffset);
                        p.YOffset = saveYoffset + height;
						if (p.YOffset + height > pagebottom)		// need another page for next row?
						{
							p = RunPageNew(pgs, p);					// yes; if at end this page is empty
						}											// and will be cleaned up later				
					}
				}
				else
				{	// need to process just whole group as a List entry
					if (ge.Group.PageBreakAtStart && !p.IsEmpty())
						p = RunPageNew(pgs, p);

					// pass the first row of the group
					row = wc.Data.Data[ge.StartRow];
					height = HeightOfList(rpt, pgs.G, row);
                    float saveYoffset = p.YOffset;              // this can be affected by other page items
                    _ReportItems.RunPage(pgs, row, listoffset);
					p.YOffset = saveYoffset + height;
					if (ge.Group.PageBreakAtEnd ||					// need another page for next group?
						p.YOffset + height > pagebottom)
					{
						p = RunPageNew(pgs, p);						// yes; if at end empty page will be cleaned up later
					}
				}
			}
		}
Ejemplo n.º 24
0
        override internal void RunPage(Pages pgs, Row row)
        {
            Report r       = pgs.Report;
            bool   bHidden = IsHidden(r, row);

            WorkClass wc    = GetWC(r);
            string    mtype = null;
            Stream    strm  = null;

            System.Drawing.Bitmap im = null;

            SetPagePositionBegin(pgs);
            if (bHidden)
            {
                PageImage pi = new PageImage(ImageFormat.Jpeg, null, 0, 0);
                this.SetPagePositionAndStyle(r, pi, row);
                SetPagePositionEnd(pgs, pi.Y + pi.H);
                return;
            }

            if (wc.PgImage != null)
            {   // have we already generated this one
                // reuse most of the work; only position will likely change
                PageImage pi = new PageImage(wc.PgImage.ImgFormat, wc.PgImage.ImageData, wc.PgImage.SamplesW, wc.PgImage.SamplesH);
                pi.Name   = wc.PgImage.Name;                            // this is name it will be shared under
                pi.Sizing = this._Sizing;
                this.SetPagePositionAndStyle(r, pi, row);
                pgs.CurrentPage.AddObject(pi);
                SetPagePositionEnd(pgs, pi.Y + pi.H);
                return;
            }

            try
            {
                strm = GetImageStream(r, row, out mtype);
                if (strm == null)
                {
                    r.rl.LogError(4, string.Format("Unable to load image {0}.", this.Name.Nm));
                    return;
                }
                im = System.Drawing.Bitmap.FromStream(strm);
                int          height = im.Height;
                int          width  = im.Width;
                MemoryStream ostrm  = new MemoryStream();
                // 140208AJM Better JPEG Encoding

                ImageFormat imf;
                //				if (mtype.ToLower() == "image/jpeg")    //TODO: how do we get png to work
                //					imf = ImageFormat.Jpeg;
                //				else
                imf = ImageFormat.Jpeg;
                System.Drawing.Imaging.ImageCodecInfo[] info;
                info = ImageCodecInfo.GetImageEncoders();
                EncoderParameters encoderParameters;
                encoderParameters          = new EncoderParameters(1);
                encoderParameters.Param[0] = new EncoderParameter(Encoder.Quality, ImageQualityManager.EmbeddedImageQuality);
                System.Drawing.Imaging.ImageCodecInfo codec = null;
                for (int i = 0; i < info.Length; i++)
                {
                    if (info[i].FormatDescription == "JPEG")
                    {
                        codec = info[i];
                        break;
                    }
                }
                im.Save(ostrm, codec, encoderParameters);

                // im.Save(ostrm, imf, encoderParameters);

                //END 140208AJM
                byte[] ba = ostrm.ToArray();
                ostrm.Close();
                PageImage pi = new PageImage(imf, ba, width, height);
                pi.Sizing = this._Sizing;
                this.SetPagePositionAndStyle(r, pi, row);

                pgs.CurrentPage.AddObject(pi);
                if (_ConstantImage)
                {
                    wc.PgImage = pi;
                    // create unique name; PDF generation uses this to optimize the saving of the image only once
                    pi.Name = "pi" + Interlocked.Increment(ref Parser.Counter).ToString();      // create unique name
                }

                SetPagePositionEnd(pgs, pi.Y + pi.H);
            }
            catch (Exception e)
            {
                // image failed to load, continue processing
                r.rl.LogError(4, "Image load failed.  " + e.Message);
            }
            finally
            {
                if (strm != null)
                {
                    strm.Close();
                }
                if (im != null)
                {
                    im.Dispose();
                }
            }
            return;
        }
Ejemplo n.º 25
0
		override internal void RunPage(Pages pgs, Row row)
		{
			Report r = pgs.Report;
			if (IsHidden(r, row))
				return;

			base.RunPage(pgs, row);

			// need to save the owner report and nest in this defintion
			ReportDefn saveReport = r.ReportDefinition;
            NeedPassword np = r.GetDataSourceReferencePassword;   // get current password

			r.SetReportDefinition(_ReportDefn);
			r.Folder = _ReportDefn.ParseFolder;		// folder needs to get set since the id of the report is used by the cache
            r.GetDataSourceReferencePassword = np;

			DataSourcesDefn saveDS = r.ParentConnections;
			if (this.MergeTransactions)
				r.ParentConnections = saveReport.DataSourcesDefn;
			else
			    r.ParentConnections = null;

            r.SubreportDataRetrievalTriggerEvent();

            bool bRows = true;
			if (_Parameters == null)
			{	// When no parameters we only retrieve data once
                SubreportWorkClass wc = r.Cache.Get(this, "report") as SubreportWorkClass;

				if (wc == null)
				{   // run report first time; 
					bRows = r.RunGetData(null);
                    if (!r.IsSubreportDataRetrievalDefined)       // if use has defined subreportdataretrieval they might set data
                        r.Cache.Add(this, "report", new SubreportWorkClass(bRows));	    // so we can't cache
				}
                else
                    bRows = wc.bRows;
			}
			else
			{
				SetSubreportParameters(r, row);		// apply the parameters
				bRows = r.RunGetData(null);
			}

			SetPageLeft(r);				// Set the Left attribute since this will be the margin for this report

			SetPagePositionBegin(pgs);

            float yOffset;

            if (bRows)  // Only run subreport if have a row in some Dataset
            {
                //
                // Run the subreport -- this is the major effort in creating the display objects in the page
                //
                r.ReportDefinition.Body.RunPage(pgs);		// create a the subreport items
                yOffset = pgs.CurrentPage.YOffset;
            }
            else
            {   // Handle NoRows message 
                string msg;
                if (this.NoRows != null)
                    msg = this.NoRows.EvaluateString(pgs.Report, null);
                else
                    msg = null;

                if (msg != null)
                {
                    PageText pt = new PageText(msg);
                    SetPagePositionAndStyle(pgs.Report, pt, null);

                    if (pt.SI.BackgroundImage != null)
                        pt.SI.BackgroundImage.H = pt.H;		//   and in the background image

                    pgs.CurrentPage.AddObject(pt);

                    yOffset = pt.Y + pt.H;
                }
                else
                    yOffset = pgs.CurrentPage.YOffset;
            }

			r.SetReportDefinition(saveReport);			// restore the current report
			r.ParentConnections = saveDS;				// restore the data connnections

			SetPagePositionEnd(pgs, yOffset);
		}
Ejemplo n.º 26
0
 // we don't have paging turned on for xml
 public void RunPages(Pages pgs)
 {
     return;
 }
Ejemplo n.º 27
0
 internal float HeightOfRow(Pages pgs, Row r)
 {
     return HeightOfRow(pgs.Report, pgs.G, r);
 }
Ejemplo n.º 28
0
		internal Page RunPageNew(Pages pgs, Page p)
		{
			if (p.IsEmpty())			// if the page is empty it won't help to create another one
				return p;

			// Do we need a new page or have should we fill out more body columns
			Body b = OwnerReport.Body;
			int ccol = b.IncrCurrentColumn(pgs.Report);	// bump to next column

			float top = OwnerReport.TopOfPage;	// calc top of page

			if (ccol < b.Columns)
			{		// Stay on same page but move to new column
				p.XOffset = 
					((OwnerReport.Width.Points + b.ColumnSpacing.Points) * ccol);
				p.YOffset = top;
				p.SetEmpty();			// consider this page empty
			}
			else
			{		// Go to new page
				b.SetCurrentColumn(pgs.Report, 0);
				pgs.NextOrNew();
				p = pgs.CurrentPage;
				p.YOffset = top;
				p.XOffset = 0;
			}

			return p;
		}
        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 = RdlEngineConfig.CreateCustomReportItem(_Type);
                SetProperties(pgs.Report, row, cri);
                
                int width = WidthCalc(rpt, pgs.G) - 
                    (Style == null? 0 :
                        (Style.EvalPaddingLeftPx(rpt, row) + Style.EvalPaddingRightPx(rpt, row)));
                int height = RSize.PixelsFromPoints(this.HeightOrOwnerHeight) -
                    (Style == null? 0 :
                        (Style.EvalPaddingTopPx(rpt, row) + Style.EvalPaddingBottomPx(rpt, row)));
                bm = Bitmap.CreateBitmap(width, height, PixelFormat.Format16bppRgb565);// Bitmap.Config.Rgb565);
                cri.DrawImage(ref 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;
        }
Ejemplo n.º 30
0
		internal void SetPagePositionEnd(Pages pgs, float pos)
		{
			if (_TC != null || _InMatrix)			// don't mess with page if part of a table or in a matrix
				return;
			WorkClass wc = GetWC(pgs.Report);
			wc.CurrentPage = pgs.CurrentPage;
			wc.BottomPosition = pos;
		}
Ejemplo n.º 31
0
        public void RunPages(Pages pgs)	// this does all the work
        {
            foreach (Page p in pgs)
            {
                //Create a Page Dictionary representing a visible page
                page = new PdfPage(anchor);
                content = new PdfContent(anchor);

                PdfPageSize pSize = new PdfPageSize((int)r.ReportDefinition.PageWidth.ToPoints(),
                                    (int)r.ReportDefinition.PageHeight.ToPoints());
                _pSize = pSize;
                page.CreatePage(pageTree.objectNum, pSize);
                pageTree.AddPage(page.objectNum);
                if (r.ItextPDF)
                {
                    //Itextsharp pdf handler, set pagesize
                    pdfdocument.SetPageSize(new iTextSharp.text.Rectangle(r.ReportDefinition.PageWidth.ToPoints(), r.ReportDefinition.PageHeight.ToPoints()));
                    pdfdocument.NewPage();
                }
                //Create object that presents the elements in the page
                elements = new PdfElements(page, pSize);

                ProcessPage(pgs, p);

                // after a page
                content.SetStream(elements.EndElements());

                page.AddResource(fonts, content.objectNum);
                page.AddResource(patterns, content.objectNum);
                //get the pattern colorspace...
                PatternObj po = new PatternObj(anchor);
                page.AddResource(po, content.objectNum);
                if (r.ItextPDF == false)
                {
                    int size = 0;
                    tw.Write(page.GetPageDict(filesize, out size), 0, size);
                    filesize += size;

                    tw.Write(content.GetContentDict(filesize, out size), 0, size);
                    filesize += size;

                    tw.Write(po.GetPatternObj(filesize, out size), 0, size);
                    filesize += size;
                }
            }
            return;
        }
Ejemplo n.º 32
0
        override internal void RunPage(Pages pgs, Row row)
        {
            Report rpt = pgs.Report;

            if (IsHidden(pgs.Report, row))
            {
                return;
            }

            _ChartMatrix.RunReset(rpt);
            Rows _Data = GetFilteredData(rpt, row);

            SetMyData(rpt, _Data);

            SetPagePositionBegin(pgs);

            if (!AnyRowsPage(pgs, _Data))                       // if no rows return
            {
                return;                                         //   nothing left to do
            }
            // Build the Chart bitmap, along with data regions
            Page      p  = pgs.CurrentPage;
            ChartBase cb = null;

            try
            {
                cb = RunChartBuild(rpt, row);                                   // Build the chart
                System.Drawing.Image im = cb.Image(rpt);                        // Grab the image
                int height = im.Height;                                         // save height and width
                int width  = im.Width;

                MemoryStream ostrm = new MemoryStream();
                im.Save(ostrm, IMAGEFORMAT);                    // generate a jpeg   TODO: get png to work with pdf

                byte[] ba = ostrm.ToArray();
                ostrm.Close();
                PageImage pi = new PageImage(IMAGEFORMAT, ba, width, height);                   // Create an image

                RunPageRegionBegin(pgs);

                SetPagePositionAndStyle(rpt, pi, row);
                pi.SI.BackgroundImage = null;                   // chart already has the background image

                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 Chart handling.\n{0}\n{1}", ex.Message, ex.StackTrace));
            }
            finally
            {
                if (cb != null)
                {
                    cb.Dispose();
                }
            }

            return;
        }
Ejemplo n.º 33
0
		internal bool AnyRowsPage(Pages pgs, Rows data)
		{
			if (data != null && data.Data != null &&
				data.Data.Count > 0)
				return true;

			string msg;
			if (this.NoRows != null)
				msg = this.NoRows.EvaluateString(pgs.Report, null);
			else
				msg = null;

			if (msg == null)
				return false;

			// OK we have a message we need to put out
			RunPageRegionBegin(pgs);				// still perform page break if needed

			PageText pt = new PageText(msg);
			SetPagePositionAndStyle(pgs.Report, pt, null);

			if (pt.SI.BackgroundImage != null)
				pt.SI.BackgroundImage.H = pt.H;		//   and in the background image

			pgs.CurrentPage.AddObject(pt);

			RunPageRegionEnd(pgs);					// perform end page break if needed
			return false;
		}
Ejemplo n.º 34
0
 internal void RunPage(Pages pgs, Row row)
 {
     RunPage(pgs, row, false);
 }
Ejemplo n.º 35
0
		internal virtual void RunPage(Pages pgs, Row row)
		{
			return;
		}
Ejemplo n.º 36
0
        // this does all the work
        public void RunPages(Pages pgs)
        {
            foreach (Page p in pgs)
            {
                //Create a Page Dictionary representing a visible page
                page=new PdfPage(anchor);
                content=new PdfContent(anchor);

                PdfPageSize pSize=new PdfPageSize((int) r.ReportDefinition.PageWidth.Points,
                                    (int) r.ReportDefinition.PageHeight.Points);
                page.CreatePage(pageTree.objectNum,pSize);
                pageTree.AddPage(page.objectNum);

                //Create object that presents the elements in the page
                elements=new PdfElements(page, pSize);

                ProcessPage(pgs, p);

                // after a page
                content.SetStream(elements.EndElements());

                page.AddResource(fonts,content.objectNum);
                page.AddResource(patterns,content.objectNum);
                //get the pattern colorspace...
                PatternObj po = new PatternObj(anchor);
                page.AddResource(po,content.objectNum);

                int size=0;
                tw.Write(page.GetPageDict(filesize,out size),0,size);
                filesize += size;

                tw.Write(content.GetContentDict(filesize,out size),0,size);
                filesize += size;

                tw.Write(po.GetPatternObj(filesize, out size),0,size);
                filesize += size;
            }
            return;
        }
Ejemplo n.º 37
0
		/// <summary>
		/// Updates the current page and location based on the ReportItems 
		/// that are above it in the report.
		/// </summary>
		/// <param name="pgs"></param>
		internal void SetPagePositionBegin(Pages pgs)
		{
			// Update the current page
			if (this._YParents != null)
			{	
				ReportItem saveri=GetReportItemAbove(pgs.Report);
				if (saveri != null)
				{
					WorkClass wc = saveri.GetWC(pgs.Report);
					pgs.CurrentPage = wc.CurrentPage;
					pgs.CurrentPage.YOffset = wc.BottomPosition;
				}
			}
			else if (this.Parent.Parent is PageHeader)
			{
				pgs.CurrentPage.YOffset = OwnerReport.TopMargin.Points;

			}
			else if (this.Parent.Parent is PageFooter)
			{
				pgs.CurrentPage.YOffset = OwnerReport.PageHeight.Points 
					- OwnerReport.BottomMargin.Points
					- OwnerReport.PageFooter.Height.Points;
			}
			else if (!(this.Parent.Parent is Body))
			{	// if not body then we don't need to do anything
			}
			else if (this.OwnerReport.Subreport != null)
			{
				//				pgs.CurrentPage = this.OwnerReport.Subreport.FirstPage;
				//				pgs.CurrentPage.YOffset = top;
			}
			else
			{
				pgs.CurrentPage =  pgs.FirstPage;	// if nothing above it (in body) then it goes on first page
				pgs.CurrentPage.YOffset = OwnerReport.TopOfPage;
			}

			return;
		}
Ejemplo n.º 38
0
        void RefreshReport()
        {
            SetParametersFromControls();
            report.RunGetData(Parameters);
            pages = report.BuildPages();

            foreach (Gtk.Widget w in vboxPages.AllChildren)
            {
                vboxPages.Remove(w);
            }

            for (int pageCount = 0; pageCount < pages.Count; pageCount++)
            {
                ReportArea area = new ReportArea();
                area.SetReport(report, pages[pageCount]);
                //area.Scale
                vboxPages.Add(area);
            }
            this.ShowAll();

            SetErrorMessages (report.ErrorItems);

            if (report.ErrorMaxSeverity == 0)
                show_errors = false;

            errorsAction.VisibleHorizontal = report.ErrorMaxSeverity > 0;

            //			Title = string.Format ("RDL report viewer - {0}", report.Name);
            EnableActions();
            CheckVisibility();
        }
Ejemplo n.º 39
0
 internal void RunPage(Pages pgs, Row row, float xOffset)
 {
     SetXOffset(pgs.Report, xOffset);
     foreach (ReportItem ri in _Items)
     {
         ri.RunPage(pgs, row);
     }
     return;
 }
Ejemplo n.º 40
0
        override internal void RunPage(Pages pgs, Row row)
        {
            Report         r   = pgs.Report;
            TextboxRuntime tbr = TextboxRuntime.GetTextboxRuntime(r, this);

            tbr.RunCount++;                     // Increment the run count

            bool bHidden = IsHidden(r, row);

            SetPagePositionBegin(pgs);

            string t;

            if (bHidden)
            {
                t = "";
            }
            else
            {
                t = RunText(r, row);    // get the text
            }
            bool bDup = RunTextIsDuplicate(tbr, t, pgs.CurrentPage);

            if (bDup)
            {
                if (!(this.IsTableOrMatrixCell(r)))                     // don't put out anything if not in Table or Matrix
                {
                    bHidden = true;
                }
                t = "";                         // still need to put out the cell
            }
            PageText     pt;
            PageTextHtml pth = null;

            if (IsHtml(r, row))
            {
                pt = pth = new PageTextHtml(t);
            }
            else
            {
                pt = new PageText(t);
            }
            SetPagePositionAndStyle(r, pt, row);
            if (this.CanGrow && tbr.RunHeight == 0)             // when textbox is in a DataRegion this will already be called
            {
                this.RunTextCalcHeight(r, pgs.G, row, pt is PageTextHtml? pt as PageTextHtml: null);
            }
            pt.H = Math.Max(pt.H, tbr.RunHeight);                       // reset height
            if (pt.SI.BackgroundImage != null)
            {
                pt.SI.BackgroundImage.H = pt.H;                         //   and in the background image
            }
            pt.CanGrow = this.CanGrow;

            // check TextAlign: if General then correct based on data type
            if (pt.SI.TextAlign == TextAlignEnum.General)
            {
                if (DataType.IsNumeric(this.Value.GetTypeCode()))
                {
                    pt.SI.TextAlign = TextAlignEnum.Right;
                }
            }

            // Hidden objects don't affect the current page?
            if (!bHidden)
            {
                // Force page break if it doesn't fit on a page
                if (this.IsInBody &&                                             // Only force page when object directly in body
                    pgs.CurrentPage.YOffset + pt.Y + pt.H >= pgs.BottomOfPage && // running off end of page
                    !pgs.CurrentPage.IsEmpty())                                  // if page is already empty don't force new
                {                                                                // force page break if it doesn't fit on the page
                    pgs.NextOrNew();
                    pgs.CurrentPage.YOffset = OwnerReport.TopOfPage;
                    if (this.YParents != null)
                    {
                        pt.Y = 0;
                    }
                }

                Page p = pgs.CurrentPage;
                RecordPageReference(r, p, row);                 // save information for late page header/footer references
                p.AddObject(pt);
                if (!bDup)
                {
                    tbr.PreviousText = t;       // previous text displayed
                    tbr.PreviousPage = p;       //  page previous text was shown on
                }
            }

            SetPagePositionEnd(pgs, pt.Y + pt.H);
            if (pth != null)
            {
                pth.Reset();
            }
            if (this.CanGrow && !Value.IsConstant())
            {
                tbr.RunHeight = 0;                                                      // need to recalculate
            }
        }
Ejemplo n.º 41
0
        // render all the objects in a page in PDF
        private void ProcessPage(Pages pgs, IEnumerable items)
        {
            foreach (PageItem pi in items)
            {
                if (pi.SI.BackgroundImage != null)
                {	// put out any background image
                    PageImage bgImg = pi.SI.BackgroundImage;
                    //					elements.AddImage(images, i.Name, content.objectNum, i.SI, i.ImgFormat,
                    //						pi.X, pi.Y, pi.W, pi.H, i.ImageData,i.SamplesW, i.SamplesH, null);

                    //Duc Phan modified 10 Dec, 2007 to support on background image
                    float imW = RSize.PointsFromPixels(pgs.G, bgImg.SamplesW);
                    float imH = RSize.PointsFromPixels(pgs.G, bgImg.SamplesH);
                    int repeatX = 0;
                    int repeatY = 0;
                    float itemW = pi.W - (pi.SI.PaddingLeft + pi.SI.PaddingRight);
                    float itemH = pi.H - (pi.SI.PaddingTop + pi.SI.PaddingBottom);
                    switch (bgImg.Repeat)
                    {
                        case ImageRepeat.Repeat:
                            repeatX = (int)Math.Floor(itemW / imW);
                            repeatY = (int)Math.Floor(itemH / imH);
                            break;
                        case ImageRepeat.RepeatX:
                            repeatX = (int)Math.Floor(itemW / imW);
                            repeatY = 1;
                            break;
                        case ImageRepeat.RepeatY:
                            repeatY = (int)Math.Floor(itemH / imH);
                            repeatX = 1;
                            break;
                        case ImageRepeat.NoRepeat:
                        default:
                            repeatX = repeatY = 1;
                            break;
                    }

                    //make sure the image is drawn at least 1 times
                    repeatX = Math.Max(repeatX, 1);
                    repeatY = Math.Max(repeatY, 1);

                    float currX = pi.X + pi.SI.PaddingLeft;
                    float currY = pi.Y + pi.SI.PaddingTop;
                    float startX = currX;
                    float startY = currY;
                    for (int i = 0; i < repeatX; i++)
                    {
                        for (int j = 0; j < repeatY; j++)
                        {
                            currX = startX + i * imW;
                            currY = startY + j * imH;
                            elements.AddImage(images, bgImg.Name,
                                              content.objectNum, bgImg.SI, bgImg.ImgFormat,
                                              currX, currY, imW, imH, RectangleF.Empty, bgImg.ImageData, bgImg.SamplesW, bgImg.SamplesH, null,pi.Tooltip);
                        }
                    }
                }

                if (pi is PageTextHtml)
                {
                    PageTextHtml pth = pi as PageTextHtml;
                    pth.Build(pgs.G);
                    ProcessPage(pgs, pth);
                    continue;
                }

                if (pi is PageText)
                {
                    PageText pt = pi as PageText;
                    float[] textwidth;
                    string[] sa = MeasureString(pt, pgs.G, out textwidth);
                    elements.AddText(pt.X, pt.Y, pt.H, pt.W, sa, pt.SI,
                        fonts, textwidth, pt.CanGrow, pt.HyperLink, pt.NoClip,pt.Tooltip);
                    if (pt.Bookmark != null)
                    {
                        outline.Bookmarks.Add(new PdfOutlineEntry(anchor, page.objectNum, pt.Bookmark, pt.X, elements.PageSize.yHeight - pt.Y));
                    }
                    continue;
                }

                if (pi is PageLine)
                {
                    PageLine pl = pi as PageLine;
                    elements.AddLine(pl.X, pl.Y, pl.X2, pl.Y2, pl.SI);
                    continue;
                }

                if (pi is PageEllipse)
                {
                    PageEllipse pe = pi as PageEllipse;
                    elements.AddEllipse(pe.X, pe.Y, pe.H, pe.W, pe.SI, pe.HyperLink);
                    continue;
                }

                    if (pi is PageImage)
                    {
                        //PageImage i = pi as PageImage;
                        //float x = i.X + i.SI.PaddingLeft;
                        //float y = i.Y + i.SI.PaddingTop;
                        //float w = i.W - i.SI.PaddingLeft - i.SI.PaddingRight;
                        //float h = i.H - i.SI.PaddingTop - i.SI.PaddingBottom;
                        //elements.AddImage(images, i.Name, content.objectNum, i.SI, i.ImgFormat,
                        //    x, y, w, h, i.ImageData,i.SamplesW, i.SamplesH, i.HyperLink);
                        //continue;
                        PageImage i = pi as PageImage;

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

                        RectangleF adjustedRect;   // work rectangle
                        RectangleF clipRect = RectangleF.Empty;
                        switch (i.Sizing)
                        {
                            case ImageSizingEnum.AutoSize:
                                adjustedRect = new RectangleF(r2.Left, r2.Top,
                                              r2.Width, r2.Height);
                                break;
                            case ImageSizingEnum.Clip:
                                adjustedRect = new RectangleF(r2.Left, r2.Top,
                                               RSize.PointsFromPixels(pgs.G, i.SamplesW), RSize.PointsFromPixels(pgs.G,i.SamplesH));
                                clipRect = new RectangleF(r2.Left, r2.Top,
                                              r2.Width, r2.Height);
                                break;
                            case ImageSizingEnum.FitProportional:
                                float height;
                                float width;
                                float ratioIm = (float)i.SamplesH / i.SamplesW;
                                float ratioR = r2.Height / r2.Width;
                                height = r2.Height;
                                width = r2.Width;
                                if (ratioIm > ratioR)
                                {   // this means the rectangle width must be corrected
                                    width = height * (1 / ratioIm);
                                }
                                else if (ratioIm < ratioR)
                                {   // this means the rectangle height must be corrected
                                    height = width * ratioIm;
                                }
                                adjustedRect = new RectangleF(r2.X, r2.Y, width, height);
                                break;
                            case ImageSizingEnum.Fit:
                            default:
                                adjustedRect = r2;
                                break;
                        }
                        if (i.ImgFormat == System.Drawing.Imaging.ImageFormat.Wmf || i.ImgFormat == System.Drawing.Imaging.ImageFormat.Emf)
                        {
                            //We dont want to add it - its already been broken down into page items;
                        }
                        else
                        {
                            elements.AddImage(images, i.Name, content.objectNum, i.SI, i.ImgFormat,
                               adjustedRect.X, adjustedRect.Y, adjustedRect.Width, adjustedRect.Height, clipRect, i.ImageData, i.SamplesW, i.SamplesH, i.HyperLink,i.Tooltip);
                        }
                        continue;
                    }

                    if (pi is PageRectangle)
                    {
                        PageRectangle pr = pi as PageRectangle;
                        elements.AddRectangle(pr.X, pr.Y, pr.H, pr.W, pi.SI, pi.HyperLink, patterns, pi.Tooltip);
                        continue;
                    }
                    if (pi is PagePie)
                    {   // TODO
                        PagePie pp = pi as PagePie;
                       // elements.AddPie(pr.X, pr.Y, pr.H, pr.W, pi.SI, pi.HyperLink, patterns, pi.Tooltip);
                        continue;
                    }
                    if (pi is PagePolygon)
                    {
                        PagePolygon ppo = pi as PagePolygon;
                        elements.AddPolygon(ppo.Points, pi.SI, pi.HyperLink, patterns);
                        continue;
                    }
                    if (pi is PageCurve)
                    {
                        PageCurve pc = pi as PageCurve;

                        elements.AddCurve(pc.Points, pi.SI);
                        continue;
                    }

                }
        }
Ejemplo n.º 42
0
		override internal void RunPage(Pages pgs, Row row)
		{
			Report r = pgs.Report;
            bool bHidden = IsHidden(r, row);

			WorkClass wc = GetWC(r);
			string mtype=null; 
			Stream strm=null;
			System.Drawing.Image im=null;

			SetPagePositionBegin(pgs);
            if (bHidden)
            {
                PageImage pi = new PageImage(ImageFormat.Jpeg, null, 0, 0);
                this.SetPagePositionAndStyle(r, pi, row);
                SetPagePositionEnd(pgs, pi.Y + pi.H);
                return;
            }

			if (wc.PgImage != null)
			{	// have we already generated this one
				// reuse most of the work; only position will likely change
				PageImage pi = new PageImage(wc.PgImage.ImgFormat, wc.PgImage.ImageData, wc.PgImage.SamplesW, wc.PgImage.SamplesH);
				pi.Name = wc.PgImage.Name;				// this is name it will be shared under
				pi.Sizing = this._Sizing;
				this.SetPagePositionAndStyle(r, pi, row);
				pgs.CurrentPage.AddObject(pi);
                SetPagePositionEnd(pgs, pi.Y + pi.H);
				return;
			}

			try 
			{
				strm = GetImageStream(r, row, out mtype);
                if (strm == null)
                {
                    r.rl.LogError(4, string.Format("Unable to load image {0}.", this.Name.Nm));
                    return;
                }
				im = System.Drawing.Image.FromStream(strm);
				int height = im.Height;
				int width = im.Width;
				MemoryStream ostrm = new MemoryStream();
				strm.Position = 0;
				ImageFormat imf;
				switch(mtype.ToLower())
				{	
					case "image/jpeg" :
						imf = ImageFormat.Jpeg;
						CopyStream(strm, ostrm);
						break;
					case "image/png":
						imf = ImageFormat.Png;
						CopyStream(strm, ostrm);
						break;
					default: // from old code where all images convert to jpeg, i don't know why. May be need delete it and add all support formats.
						imf = ImageFormat.Jpeg;
						System.Drawing.Imaging.ImageCodecInfo[] info;
						info = ImageCodecInfo.GetImageEncoders();
						EncoderParameters encoderParameters;
						encoderParameters = new EncoderParameters(1);
						encoderParameters.Param[0] = new EncoderParameter(Encoder.Quality, ImageQualityManager.EmbeddedImageQuality);
						System.Drawing.Imaging.ImageCodecInfo codec = null;
						for (int i = 0; i < info.Length; i++)
						{
							if (info[i].FormatDescription == "JPEG")
							{
								codec = info[i];
								break;
							}
						}
						im.Save(ostrm, codec, encoderParameters);
						break;
				}

				byte[] ba = ostrm.ToArray();
				ostrm.Close();
				PageImage pi = new PageImage(imf, ba, width, height);
				pi.Sizing = this._Sizing;
				this.SetPagePositionAndStyle(r, pi, row);

				pgs.CurrentPage.AddObject(pi);
				if (_ConstantImage)
				{
					wc.PgImage = pi;
					// create unique name; PDF generation uses this to optimize the saving of the image only once
					pi.Name = "pi" + Interlocked.Increment(ref Parser.Counter).ToString();	// create unique name
				}

                SetPagePositionEnd(pgs, pi.Y + pi.H);
            }
			catch (Exception e)
			{	
				// image failed to load, continue processing
				r.rl.LogError(4, "Image load failed.  " + e.Message);
			}
			finally
			{
				if (strm != null)
					strm.Close();
				if (im != null)
					im.Dispose();
			}
			return;
		}
Ejemplo n.º 43
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 = RdlEngineConfig.CreateCustomReportItem(_Type);
                SetProperties(pgs.Report, row, cri);
                
                int width = WidthCalc(rpt, pgs.G) - 
                    (Style == null? 0 :
                        (Style.EvalPaddingLeftPx(rpt, row) + Style.EvalPaddingRightPx(rpt, row)));
                int height = RSize.PixelsFromPoints(this.HeightOrOwnerHeight) -
                    (Style == null? 0 :
                        (Style.EvalPaddingTopPx(rpt, row) + Style.EvalPaddingBottomPx(rpt, row)));
                bm = new Bitmap(width, height);
                cri.DrawImage(bm);

                MemoryStream ostrm = new MemoryStream();
                bm.Save(ostrm, IMAGEFORMAT);	// generate a jpeg   TODO: get png to work with pdf

                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;
        }
Ejemplo n.º 44
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 = RdlEngineConfig.CreateCustomReportItem(_Type);
                SetProperties(pgs.Report, row, cri);

                int width = WidthCalc(rpt, pgs.G) -
                            (Style == null? 0 :
                             (Style.EvalPaddingLeftPx(rpt, row) + Style.EvalPaddingRightPx(rpt, row)));
                int height = RSize.PixelsFromPoints(this.HeightOrOwnerHeight) -
                             (Style == null? 0 :
                              (Style.EvalPaddingTopPx(rpt, row) + Style.EvalPaddingBottomPx(rpt, row)));
                bm = new Bitmap(width, height);
                cri.DrawImage(bm);

                MemoryStream ostrm = new MemoryStream();
                bm.Save(ostrm, IMAGEFORMAT);    // generate a jpeg   TODO: get png to work with pdf

                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;
        }