diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/RowItem.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/RowItem.cs index 7d1be5edd4..dc19f7aca9 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/RowItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/RowItem.cs @@ -48,7 +48,7 @@ namespace SharpReportCore{ #region overrides - protected RectangleF PrepareRectangle (ReportPageEventArgs e) { + protected RectangleF PrepareRectangle () { SizeF measureSize = new SizeF ((SizeF)this.Size); RectangleF rect = base.DrawingRectangle (measureSize); return rect; @@ -62,7 +62,7 @@ namespace SharpReportCore{ } base.Render(rpea); - RectangleF rect = PrepareRectangle (rpea); + RectangleF rect = PrepareRectangle (); shape.FillShape(rpea.PrintPageEventArgs.Graphics, new SolidFillPattern(this.BackColor), diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Globals/GlobalEnums.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Globals/GlobalEnums.cs index a12fab0ce7..fe763fce6d 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Globals/GlobalEnums.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Globals/GlobalEnums.cs @@ -99,6 +99,9 @@ namespace SharpReportCore { /// type to its internal representation. public static object StringToEnum( Type type, string value ) { + if (type == null) { + throw new ArgumentNullException("type"); + } foreach ( FieldInfo fi in type.GetFields() ){ if ( fi.Name == value ){ return fi.GetValue( null ); diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractRenderer.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractRenderer.cs index 5daf0a4566..3f3656f7f5 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractRenderer.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractRenderer.cs @@ -36,7 +36,7 @@ namespace SharpReportCore { public event EventHandler Rendering; public event EventHandler SectionRendered; - private Page page; + private SectionBounds sectionBounds; protected AbstractRenderer(ReportModel model){ if (model == null) { @@ -180,7 +180,7 @@ namespace SharpReportCore { e.Graphics.DrawString(this.reportSettings.NoDataMessage, this.ReportSettings.DefaultFont, new SolidBrush(Color.Black), - page.DetailArea); + sectionBounds.DetailArea); } @@ -196,23 +196,24 @@ namespace SharpReportCore { } rpea.Graphics.DrawRectangle (Pens.Black,rectangle); } - - public void DebugFooterRectangle (ReportPageEventArgs rpea) { - Rectangle r = new Rectangle( this.page.ReportFooterRectangle.Left, + /* + public void old_DebugFooterRectangle (ReportPageEventArgs rpea) { + + Rectangle r = new Rectangle( this.pageBounderys.ReportFooterRectangle.Left, rpea.LocationAfterDraw.Y, - this.page.ReportFooterRectangle.Width, - this.page.ReportFooterRectangle.Height); + this.pageBounderys.ReportFooterRectangle.Width, + this.pageBounderys.ReportFooterRectangle.Height); - Rectangle s = new Rectangle (this.page.ReportFooterRectangle.Left, + Rectangle s = new Rectangle (this.pageBounderys.ReportFooterRectangle.Left, rpea.LocationAfterDraw.Y, - this.page.ReportFooterRectangle.Width, - this.page.PageFooterRectangle.Top - rpea.LocationAfterDraw.Y -1); + this.pageBounderys.ReportFooterRectangle.Width, + this.pageBounderys.PageFooterRectangle.Top - rpea.LocationAfterDraw.Y -1); AbstractRenderer.DebugRectangle(rpea.PrintPageEventArgs,r); AbstractRenderer.DebugRectangle(rpea.PrintPageEventArgs,s); } - + */ #endregion protected Rectangle MeasureReportHeader (PrintPageEventArgs ppea) { @@ -228,7 +229,7 @@ namespace SharpReportCore { if (this.CurrentSection.Items.Count > 0) { this.CurrentSection.SectionOffset = reportSettings.DefaultMargins.Top; - FitSectionToItems (this.CurrentSection,ppea); + AbstractRenderer.FitSectionToItems (this.CurrentSection,ppea); rect = new Rectangle(reportSettings.DefaultMargins.Left, reportSettings.DefaultMargins.Top, @@ -264,7 +265,7 @@ namespace SharpReportCore { this.CurrentSection.SectionOffset = reportSettings.DefaultMargins.Top; } - FitSectionToItems (this.CurrentSection,rpea); + AbstractRenderer.FitSectionToItems (this.CurrentSection,rpea); return new Rectangle (startAfter.Left, startAfter.Bottom + Gap, rpea.MarginBounds.Width, @@ -276,7 +277,7 @@ namespace SharpReportCore { sectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportPageFooter, CultureInfo.InvariantCulture); this.CurrentSection.SectionOffset = reportSettings.PageSettings.Bounds.Height - reportSettings.DefaultMargins.Top - reportSettings.DefaultMargins.Bottom; - FitSectionToItems (this.CurrentSection,e); + AbstractRenderer.FitSectionToItems (this.CurrentSection,e); return new Rectangle(reportSettings.DefaultMargins.Left, this.CurrentSection.SectionOffset, e.MarginBounds.Width, @@ -289,7 +290,7 @@ namespace SharpReportCore { private Rectangle MeasureReportFooter (PrintPageEventArgs ppea) { sectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportFooter, CultureInfo.InvariantCulture); - FitSectionToItems (this.CurrentSection,ppea); + AbstractRenderer.FitSectionToItems (this.CurrentSection,ppea); return new Rectangle (reportSettings.DefaultMargins.Left, this.CurrentSection.SectionOffset, ppea.MarginBounds.Width, @@ -297,16 +298,16 @@ namespace SharpReportCore { } protected bool IsRoomForFooter(Point loc) { - Rectangle r = new Rectangle( this.page.ReportFooterRectangle.Left, + Rectangle r = new Rectangle( this.sectionBounds.ReportFooterRectangle.Left, loc.Y, - this.page.ReportFooterRectangle.Width, - this.page.ReportFooterRectangle.Height); + this.sectionBounds.ReportFooterRectangle.Width, + this.sectionBounds.ReportFooterRectangle.Height); - Rectangle s = new Rectangle (this.page.ReportFooterRectangle.Left, + Rectangle s = new Rectangle (this.sectionBounds.ReportFooterRectangle.Left, loc.Y, - this.page.ReportFooterRectangle.Width, - this.page.PageFooterRectangle.Top - loc.Y -1); + this.sectionBounds.ReportFooterRectangle.Width, + this.sectionBounds.PageFooterRectangle.Top - loc.Y -1); return s.Contains(r); } @@ -349,7 +350,7 @@ namespace SharpReportCore { } #region privates - protected void FitSectionToItems (BaseSection section,PrintPageEventArgs rpea){ + protected static void FitSectionToItems (BaseSection section,PrintPageEventArgs rpea){ if (section == null) { throw new ArgumentNullException("section"); } @@ -440,7 +441,7 @@ namespace SharpReportCore { #region PrintDocument Events private void ReportPageStart (object sender, PrintPageEventArgs e) { - if (this.page == null) { + if (this.sectionBounds == null) { throw new ArgumentException("page"); } @@ -448,26 +449,26 @@ namespace SharpReportCore { if (this.reportDocument.PageNumber == 1) { r1 = this.MeasureReportHeader(e); - page.ReportHeaderRectangle = r1; + sectionBounds.ReportHeaderRectangle = r1; } else { r1 = new Rectangle (reportSettings.DefaultMargins.Left, reportSettings.DefaultMargins.Top, e.MarginBounds.Width, 0); } - page.ReportHeaderRectangle = r1; - page.PageHeaderRectangle = this.MeasurePageHeader(r1,e); - page.PageFooterRectangle = this.MeasurePageFooter (e); - page.ReportFooterRectangle = this.MeasureReportFooter(e); + sectionBounds.ReportHeaderRectangle = r1; + sectionBounds.PageHeaderRectangle = this.MeasurePageHeader(r1,e); + sectionBounds.PageFooterRectangle = this.MeasurePageFooter (e); + sectionBounds.ReportFooterRectangle = this.MeasureReportFooter(e); } protected virtual void ReportQueryPage (object sender,QueryPageSettingsEventArgs qpea) { qpea.PageSettings.Margins = reportSettings.DefaultMargins; if (this.reportDocument.PageNumber == 1) { - page = new Page (true); + sectionBounds = new SectionBounds (true); } else { - page = new Page (false); + sectionBounds = new SectionBounds (false); } } @@ -536,12 +537,12 @@ namespace SharpReportCore { } } - protected Page Page { + protected SectionBounds SectionBounds { get { - return page; + return sectionBounds; } set { - page = value; + sectionBounds = value; } } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Graphics/BaseShape.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Graphics/BaseShape.cs index e8dccddff6..e41d5cd546 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Graphics/BaseShape.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Graphics/BaseShape.cs @@ -63,6 +63,9 @@ namespace SharpReportCore { if (graphics == null) { throw new ArgumentNullException("graphics"); } + if (line == null) { + throw new ArgumentNullException("line"); + } using (Pen pen = line.CreatePen()){ if (pen != null){ this.new_DrawShape(graphics, pen, rectangle); diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs index 59c5bfe848..53cf7a8033 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs @@ -75,7 +75,7 @@ namespace SharpReportCore { } private void DoPageHeader (ReportPageEventArgs rpea){ - this.CurrentSection.SectionOffset = base.Page.PageHeaderRectangle.Location.Y; + this.CurrentSection.SectionOffset = base.SectionBounds.PageHeaderRectangle.Location.Y; base.RenderSection (rpea); base.DoItems(rpea); } @@ -83,7 +83,7 @@ namespace SharpReportCore { private void DoPageEnd (ReportPageEventArgs rpea){ - this.CurrentSection.SectionOffset = base.Page.PageFooterRectangle.Location.Y; + this.CurrentSection.SectionOffset = base.SectionBounds.PageFooterRectangle.Location.Y; base.RenderSection (rpea); base.DoItems(rpea); } @@ -162,7 +162,7 @@ namespace SharpReportCore { PrintNoDataMessage(rpea.PrintPageEventArgs); } - base.CurrentSection.SectionOffset = (int)base.Page.DetailStart.Y + AbstractRenderer.Gap; + base.CurrentSection.SectionOffset = (int)base.SectionBounds.DetailStart.Y + AbstractRenderer.Gap; } @@ -192,14 +192,14 @@ namespace SharpReportCore { } - base.FitSectionToItems (base.CurrentSection,rpea.PrintPageEventArgs); + AbstractRenderer.FitSectionToItems (base.CurrentSection,rpea.PrintPageEventArgs); sectionRect = new Rectangle (rpea.PrintPageEventArgs.MarginBounds.Left, base.CurrentSection.SectionOffset, rpea.PrintPageEventArgs.MarginBounds.Width, base.CurrentSection.Size.Height); - if (!base.Page.DetailArea.Contains(sectionRect)) { + if (!base.SectionBounds.DetailArea.Contains(sectionRect)) { AbstractRenderer.PageBreak(rpea); System.Console.WriteLine("DataRenderer:RemoveEvents reason "); this.RemoveSectionEvents(); diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderFormSheetReport.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderFormSheetReport.cs index ad33d7336b..45b2eaca59 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderFormSheetReport.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderFormSheetReport.cs @@ -59,7 +59,7 @@ namespace SharpReportCore { protected override void PrintPageHeader (object sender, ReportPageEventArgs rpea) { base.PrintPageHeader (sender,rpea); - this.CurrentSection.SectionOffset = base.Page.PageHeaderRectangle.Location.Y; + this.CurrentSection.SectionOffset = base.SectionBounds.PageHeaderRectangle.Location.Y; base.RenderSection (rpea); } @@ -74,7 +74,7 @@ namespace SharpReportCore { protected override void PrintDetail(object sender, ReportPageEventArgs rpea){ base.PrintDetail(sender, rpea); - this.CurrentSection.SectionOffset = base.Page.PageHeaderRectangle.Bottom; + this.CurrentSection.SectionOffset = base.SectionBounds.PageHeaderRectangle.Bottom; base.RenderSection(rpea); base.RemoveSectionEvents(); base.ReportDocument.DetailsDone = true; @@ -100,7 +100,7 @@ namespace SharpReportCore { protected override void PrintPageEnd(object sender, ReportPageEventArgs rpea) { base.PrintPageEnd(this,rpea); - this.CurrentSection.SectionOffset = base.Page.PageFooterRectangle.Location.Y; + this.CurrentSection.SectionOffset = base.SectionBounds.PageFooterRectangle.Location.Y; base.RenderSection (rpea); } #endregion diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Page.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/SectionBounds.cs similarity index 56% rename from src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Page.cs rename to src/AddIns/Misc/SharpReport/SharpReportCore/Printing/SectionBounds.cs index b42d998101..90aa5cca71 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Page.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/SectionBounds.cs @@ -14,7 +14,7 @@ namespace SharpReportCore{ /// /// Description of Page. /// - public class Page{ + public class SectionBounds{ Rectangle reportHeaderRectangle; Rectangle pageHeaderRectangle; Rectangle detailRectangle; @@ -23,7 +23,7 @@ namespace SharpReportCore{ bool firstpage; - public Page(bool firstPage){ + public SectionBounds(bool firstPage){ this.firstpage = firstPage; } @@ -86,43 +86,8 @@ namespace SharpReportCore{ return new Point(this.pageFooterRectangle.Left,this.pageFooterRectangle.Top); } } - /* - /// - /// Calculates the rectangle wich can be used by Detail - /// - /// - protected Rectangle old_DetailRectangle (ReportPageEventArgs rpea) { - if (rpea == null) { - throw new ArgumentNullException("rpea"); - } - - sectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportDetail, - CultureInfo.InvariantCulture); - Rectangle rect = new Rectangle (rpea.PrintPageEventArgs.MarginBounds.Left, - this.page.DetailStart.Y , - rpea.PrintPageEventArgs.MarginBounds.Width, - page.DetailEnds.Y - this.page.DetailStart.Y - (3 * gap)); - System.Console.WriteLine("Page DetRec {0} base DetRec {1}",page.DetailArea,rect); - return rect; - } - */ - /* - protected int CalculateDrawAreaHeight(ReportPageEventArgs rpea){ - if (rpea == null) { - throw new ArgumentNullException("rpea"); - } - int to = rpea.PrintPageEventArgs.MarginBounds.Height ; - if (this.reportDocument.PageNumber == 1){ - to -= sections[Convert.ToInt16(GlobalEnums.enmSection.ReportHeader,CultureInfo.InvariantCulture)].Size.Height; - } - - to -= sections[Convert.ToInt16(GlobalEnums.enmSection.ReportPageHeader,CultureInfo.InvariantCulture)].Size.Height; - - to -= sections[Convert.ToInt16(GlobalEnums.enmSection.ReportPageFooter,CultureInfo.InvariantCulture)].Size.Height; - return to; - } - */ + /// /// This rectangle starts directly after PageHeader and ends bevore PageFooter /// @@ -133,7 +98,12 @@ namespace SharpReportCore{ this.pageHeaderRectangle.Width, (this.pageFooterRectangle.Top -1) - (this.pageHeaderRectangle.Bottom + 1)); } + } + public bool Firstpage { + get { + return firstpage; + } } } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Text/StandardFormatter.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Text/StandardFormatter.cs index 3f0a70fb77..5e5f7766e9 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Text/StandardFormatter.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Text/StandardFormatter.cs @@ -32,6 +32,10 @@ namespace SharpReportCore { return retValue; } + if (String.IsNullOrEmpty(valueToFormat)) { + return nullValue; + } + switch (typeCode) { case TypeCode.Int16: case TypeCode.Int32: diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/ReportModel.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/ReportModel.cs index 91aca93122..15e9fc241a 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/ReportModel.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/ReportModel.cs @@ -55,6 +55,9 @@ namespace SharpReportCore { #region SharpReport.DelegatesInterfaces.IModel interface implementation public void Accept(IModelVisitor visitor) { + if (visitor == null) { + throw new ArgumentNullException("visitor"); + } visitor.Visit (this); } #endregion diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Visitors/AbstractModelVisitor.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Visitors/AbstractModelVisitor.cs index af44945261..2a95fee994 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Visitors/AbstractModelVisitor.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Visitors/AbstractModelVisitor.cs @@ -47,6 +47,9 @@ namespace SharpReportCore { protected BaseReportItem MakeItem (XmlElement elem,IContainerItem parent, BaseSection section,IItemRenderer itemRenderer) { + if (section == null) { + throw new ArgumentNullException("section"); + } BaseReportItem item = (BaseReportItem)itemRenderer; item.SuspendLayout(); XmlHelper.SetReportItemValues (xmlFormReader,elem,item); diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Xml/XmlHelper.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Xml/XmlHelper.cs index 0aa06fe4e9..de3e0de61d 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Xml/XmlHelper.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Xml/XmlHelper.cs @@ -100,6 +100,10 @@ namespace SharpReportCore { public static void SetSectionValues (XmlFormReader reader, XmlElement element, BaseReportObject section) { + + if (element == null) { + throw new ArgumentNullException("element"); + } XmlNodeList nodeList = element.ChildNodes; foreach (XmlNode node in nodeList) { @@ -124,6 +128,10 @@ namespace SharpReportCore { XmlElement ctrlElem, BaseReportItem item) { + if (item == null) { + throw new ArgumentNullException("item"); + } + item.SuspendLayout(); try { XmlNodeList nodeList = ctrlElem.ChildNodes;