From 1fd0f95112eacdd665bf341dd72ec082b1fe93c0 Mon Sep 17 00:00:00 2001 From: Peter Forstmeier Date: Thu, 17 Jun 2010 18:22:27 +0000 Subject: [PATCH] Refactoring to start with SubReports git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/reports@5967 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Project/BaseItems/BaseTableItem.cs | 3 +- .../Project/BaseItems/BaseTextItem.cs | 5 + .../Project/Printing/AbstractDataRenderer.cs | 106 ++++++++++++------ .../Project/Printing/AbstractRenderer.cs | 43 +++++++ .../Project/Printing/RenderDataReport.cs | 6 +- .../old_Exporter/ExportColumns/ExportText.cs | 1 + 6 files changed, 128 insertions(+), 36 deletions(-) diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseItems/BaseTableItem.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseItems/BaseTableItem.cs index 1c9d11eae2..a7009d24b3 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseItems/BaseTableItem.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseItems/BaseTableItem.cs @@ -84,7 +84,7 @@ namespace ICSharpCode.Reports.Core { if (rpea == null) { throw new ArgumentNullException("rpea"); } -// + Point saveLocation = this.Location; Point currentPosition = new Point(this.startSection.Location.X,this.startSection.Location.Y); Point tableStart = currentPosition; @@ -174,6 +174,7 @@ namespace ICSharpCode.Reports.Core { } + public void RenderTable (BaseReportItem parent,SectionBounds sectionBounds,ReportPageEventArgs rpea,ILayouter layouter) { diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseItems/BaseTextItem.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseItems/BaseTextItem.cs index a94b77c36c..d55866f7fe 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseItems/BaseTextItem.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseItems/BaseTextItem.cs @@ -111,6 +111,8 @@ namespace ICSharpCode.Reports.Core if (rpea == null) { throw new ArgumentNullException("rpea"); } + + TextDrawer.DrawString(rpea.PrintPageEventArgs.Graphics, toPrint,this.Font, new SolidBrush(this.ForeColor), @@ -118,6 +120,9 @@ namespace ICSharpCode.Reports.Core this.stringTrimming,this.contentAlignment); + + //TextDrawer.DrawString(rpea.PrintPageEventArgs.Graphics,toPrint,CreateItemStyle()); + rpea.LocationAfterDraw = new Point (this.Location.X + this.Size.Width, this.Location.Y + this.Size.Height); } diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Printing/AbstractDataRenderer.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Printing/AbstractDataRenderer.cs index dd8517a59d..f996243d9c 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Printing/AbstractDataRenderer.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Printing/AbstractDataRenderer.cs @@ -55,6 +55,69 @@ namespace ICSharpCode.Reports.Core #endregion + + protected void RenderTable (BaseReportItem parent,ITableContainer tableContainer,ReportPageEventArgs rpea) + { + if (rpea == null) { + throw new ArgumentNullException("rpea"); + } + + Point saveLocation = tableContainer.Location; + + Point currentPosition = new Point(this.CurrentSection.Location.X,this.CurrentSection.Location.Y); + + Point tableStart = currentPosition; + +// base.Render(rpea); + + int defaultLeftPos = PrintHelper.DrawingAreaRelativeToParent(parent,tableContainer).Left; + + tableContainer.Items.SortByLocation(); + + rpea.SinglePage.StartRow = this.dataNavigator.CurrentRow; + foreach (BaseRowItem row in tableContainer.Items) + { + if (row != null) + { + row.Parent = tableContainer as BaseReportItem; + if (PrintHelper.IsTextOnlyRow(row) ) + { +// currentPosition = this.PrintTextRow (rpea,row,defaultLeftPos,currentPosition); +// currentPosition = this.RenderContainer(parent,tableContainer,rpea); + + this.RenderContainer(parent,row,rpea); + + tableContainer.Location = saveLocation; + } + else { + do { + if (PrintHelper.IsPageFull(new Rectangle(currentPosition,row.Size),this.SectionBounds)) { + tableContainer.Location = saveLocation; + + rpea.SinglePage.EndRow = this.dataNavigator.CurrentRow; + AbstractRenderer.PageBreak(rpea); + return; + } +// currentPosition = this.PrintDataRow (rpea,row,defaultLeftPos,currentPosition); + } + while (this.dataNavigator.MoveNext()); + } + } + } + /* + if (this.DrawBorder) { + Border border = new Border(new BaseLine (this.ForeColor,System.Drawing.Drawing2D.DashStyle.Solid,1)); + border.DrawBorder(rpea.PrintPageEventArgs.Graphics, + new Rectangle(parent.Location.X,tableStart.Y, + parent.Size.Width,currentPosition.Y + 5)); + } + */ + rpea.LocationAfterDraw = new Point(rpea.LocationAfterDraw.X,rpea.LocationAfterDraw.Y + 20); +// base.NotifyAfterPrint (rpea.LocationAfterDraw); + } + + + protected Point RenderItems (ReportPageEventArgs rpea) { base.SinglePage.IDataNavigator = this.dataNavigator; @@ -70,7 +133,7 @@ namespace ICSharpCode.Reports.Core } } if (hasContainer) { - return RenderSimpleContainer(this.CurrentSection,container,rpea); + return RenderSectionWithSimpleContainer(this.CurrentSection,container,rpea); } else { return base.RenderSection(rpea); @@ -80,10 +143,10 @@ namespace ICSharpCode.Reports.Core - - private Point RenderSimpleContainer (BaseSection section, + private Point RenderSectionWithSimpleContainer (BaseSection section, ISimpleContainer container, ReportPageEventArgs rpea) + { Point drawPoint = Point.Empty; if (section.Visible){ @@ -113,12 +176,13 @@ namespace ICSharpCode.Reports.Core ISimpleContainer cont = item as ISimpleContainer; - RenderChilds (this.CurrentSection,cont,rpea); + RenderContainer (this.CurrentSection,cont,rpea); item.Location = saveLocation; drawPoint = new Point(item.Location.X, section.SectionOffset + section.Size.Height); + rpea.LocationAfterDraw = new Point (rpea.LocationAfterDraw.X,section.SectionOffset + section.Size.Height); } @@ -135,43 +199,19 @@ namespace ICSharpCode.Reports.Core - void RenderChilds (BaseReportItem parent,ISimpleContainer simpleContainer,ReportPageEventArgs rpea) + private void RenderContainer (BaseReportItem parent,ISimpleContainer simpleContainer,ReportPageEventArgs rpea) { if (simpleContainer != null) { BaseReportItem item = simpleContainer as BaseReportItem; - if ((simpleContainer.Items != null) && (simpleContainer.Items.Count > 0)) { + if (simpleContainer.Items != null) { + + base.RenderPlainCollection(item,simpleContainer.Items,new Point(parent.Location.X + simpleContainer.Location.X, + item.SectionOffset + item.Location.Y),rpea); - foreach (BaseReportItem child in simpleContainer.Items) { - child.Parent = item; - - Point saveLocation = new Point (child.Location.X,child.Location.Y); - - - child.Location = new Point(parent.Location.X + simpleContainer.Location.X + child.Location.X, - item.SectionOffset + item.Location.Y + child.Location.Y); - - - if (item.BackColor != GlobalValues.DefaultBackColor) { - child.BackColor = item.BackColor; - } - - BaseTextItem textItem = child as BaseTextItem; - - if (textItem != null) { - string str = textItem.Text; - textItem.Text = Evaluator.Evaluate(textItem.Text); - textItem.Render(rpea); - textItem.Text = str; - } else { - child.Render (rpea); - } - child.Location = saveLocation; - } } - } } diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Printing/AbstractRenderer.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Printing/AbstractRenderer.cs index 4686e624b9..793cfcf0a7 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Printing/AbstractRenderer.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Printing/AbstractRenderer.cs @@ -230,6 +230,11 @@ namespace ICSharpCode.Reports.Core // PrintHelper.DebugRectangle(rpea.PrintPageEventArgs.Graphics,Pens.Blue,new Rectangle(CurrentSection.Location,CurrentSection.Size)); } + + RenderPlainCollection (this.CurrentSection,this.CurrentSection.Items,new Point(this.CurrentSection.Location.X, + this.CurrentSection.SectionOffset),rpea); + + /* foreach (BaseReportItem item in this.CurrentSection.Items) { if (item.Parent == null) { item.Parent = this.CurrentSection; @@ -249,6 +254,8 @@ namespace ICSharpCode.Reports.Core } + */ + if ((this.CurrentSection.CanGrow == false)&& (this.CurrentSection.CanShrink == false)) { return new Point(this.CurrentSection.Location.X, this.CurrentSection.Size.Height); @@ -259,6 +266,42 @@ namespace ICSharpCode.Reports.Core } + + protected void RenderPlainCollection (BaseReportItem parent,ReportItemCollection items, Point offset,ReportPageEventArgs rpea) + { + + if (items.Count > 0) { + + foreach (BaseReportItem child in items) { + child.Parent = parent; + + Point saveLocation = new Point (child.Location.X,child.Location.Y); + + + child.Location = new Point(offset.X + child.Location.X, + offset.Y + child.Location.Y); + + + if (parent.BackColor != GlobalValues.DefaultBackColor) { + child.BackColor = parent.BackColor; + } + + BaseTextItem textItem = child as BaseTextItem; + + if (textItem != null) { + string str = textItem.Text; + textItem.Text = Evaluator.Evaluate(textItem.Text); + textItem.Render(rpea); + textItem.Text = str; + } else { + child.Render (rpea); + } + child.Location = saveLocation; + } + } + } + + #region PrintDocument Events private void CalculatePageBounds () diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Printing/RenderDataReport.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Printing/RenderDataReport.cs index dfd6c2d6d1..b02cfd781f 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Printing/RenderDataReport.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Printing/RenderDataReport.cs @@ -163,10 +163,12 @@ namespace ICSharpCode.Reports.Core { tableContainer.StartLayoutAt(base.Sections[0]); } -// base.RenderTable(base.CurrentSection,this.SectionBounds,rpea,this.Layout); - tableContainer.RenderTable(base.CurrentSection,this.SectionBounds,rpea,this.Layout); + tableContainer.RenderTable(this.CurrentSection,this.SectionBounds,rpea,this.Layout); + base.RenderTable (base.CurrentSection,tableContainer,rpea); + + this.ReportDocument.DetailsDone = true; } diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/old_Exporter/ExportColumns/ExportText.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/old_Exporter/ExportColumns/ExportText.cs index 1b7ae9934b..42c900bae4 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/old_Exporter/ExportColumns/ExportText.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/old_Exporter/ExportColumns/ExportText.cs @@ -32,6 +32,7 @@ namespace ICSharpCode.Reports.Core.old_Exporter { #region overrides + public override void DrawItem(PdfWriter pdfWriter, ICSharpCode.Reports.Core.old_Exporter.ExportRenderer.PdfUnitConverter converter) {