Browse Source

Move handling of pageBreak to BaseConverter.cs

Signed-off-by: peterforstmeier <peter.forstmeier@t-online.de>
pull/1/head
peterforstmeier 15 years ago
parent
commit
98174d6c3a
  1. 13
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/PrintHelper.cs
  2. 17
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/BaseConverter.cs
  3. 44
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/GroupedRowConverter.cs
  4. 11
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/TableConverter.cs

13
src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/PrintHelper.cs

@ -12,8 +12,9 @@ using System.Drawing;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using ICSharpCode.Reports.Core.Interfaces; using ICSharpCode.Reports.Core.Events;
using ICSharpCode.Reports.Core.Exporter; using ICSharpCode.Reports.Core.Exporter;
using ICSharpCode.Reports.Core.Interfaces;
using ICSharpCode.Reports.Expressions.ReportingLanguage; using ICSharpCode.Reports.Expressions.ReportingLanguage;
namespace ICSharpCode.Reports.Core.BaseClasses.Printing namespace ICSharpCode.Reports.Core.BaseClasses.Printing
@ -148,6 +149,14 @@ namespace ICSharpCode.Reports.Core.BaseClasses.Printing
container; container;
} }
#region PageBreak
public static Rectangle CalculatePageBreakRectangle(BaseReportItem simpleContainer,Point curPos)
{
return new Rectangle(new Point (simpleContainer.Location.X,curPos.Y), simpleContainer.Size);
}
public static bool IsPageFull (Rectangle rectangle,SectionBounds bounds) public static bool IsPageFull (Rectangle rectangle,SectionBounds bounds)
{ {
if (rectangle.Bottom > bounds.PageFooterRectangle.Top) { if (rectangle.Bottom > bounds.PageFooterRectangle.Top) {
@ -157,6 +166,8 @@ namespace ICSharpCode.Reports.Core.BaseClasses.Printing
} }
#endregion
public static IExpressionEvaluatorFacade CreateEvaluator (ISinglePage singlePage,IDataNavigator dataNavigator) public static IExpressionEvaluatorFacade CreateEvaluator (ISinglePage singlePage,IDataNavigator dataNavigator)
{ {
if (singlePage == null) { if (singlePage == null) {

17
src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/BaseConverter.cs

@ -8,7 +8,6 @@
*/ */
using System; using System;
using System.Drawing; using System.Drawing;
using System.Linq;
using ICSharpCode.Reports.Core.BaseClasses.Printing; using ICSharpCode.Reports.Core.BaseClasses.Printing;
using ICSharpCode.Reports.Core.Events; using ICSharpCode.Reports.Core.Events;
using ICSharpCode.Reports.Core.Interfaces; using ICSharpCode.Reports.Core.Interfaces;
@ -58,11 +57,24 @@ namespace ICSharpCode.Reports.Core.Exporter
} }
#region PageBreak
protected void BuildNewPage(ExporterCollection myList,BaseSection section)
{
FirePageFull(myList);
section.SectionOffset = SinglePage.SectionBounds.PageHeaderRectangle.Location.Y;
myList.Clear();
}
protected void FirePageFull (ExporterCollection items) protected void FirePageFull (ExporterCollection items)
{ {
EventHelper.Raise<NewPageEventArgs>(PageFull,this,new NewPageEventArgs(items)); EventHelper.Raise<NewPageEventArgs>(PageFull,this,new NewPageEventArgs(items));
} }
#endregion
protected void FireSectionRendering (BaseSection section) protected void FireSectionRendering (BaseSection section)
{ {
@ -143,11 +155,13 @@ namespace ICSharpCode.Reports.Core.Exporter
get {return this.saveSize;} get {return this.saveSize;}
} }
protected IExpressionEvaluatorFacade Evaluator protected IExpressionEvaluatorFacade Evaluator
{ {
get {return this.evaluator;} get {return this.evaluator;}
} }
protected void FillRow (ISimpleContainer row) protected void FillRow (ISimpleContainer row)
{ {
DataNavigator.Fill(row.Items); DataNavigator.Fill(row.Items);
@ -170,7 +184,6 @@ namespace ICSharpCode.Reports.Core.Exporter
} }
protected static Point BaseConvert(ExporterCollection myList,ISimpleContainer container,int leftPos,Point curPos) protected static Point BaseConvert(ExporterCollection myList,ISimpleContainer container,int leftPos,Point curPos)
{ {
ExporterCollection ml = BaseConverter.ConvertItems (container, curPos); ExporterCollection ml = BaseConverter.ConvertItems (container, curPos);

44
src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/GroupedRowConverter.cs

@ -40,6 +40,7 @@ namespace ICSharpCode.Reports.Core.Exporter
if (item == null) { if (item == null) {
throw new ArgumentNullException("item"); throw new ArgumentNullException("item");
} }
ISimpleContainer simpleContainer = item as ISimpleContainer; ISimpleContainer simpleContainer = item as ISimpleContainer;
this.parent = parent; this.parent = parent;
@ -67,7 +68,7 @@ namespace ICSharpCode.Reports.Core.Exporter
int defaultLeftPos = parent.Location.X; int defaultLeftPos = parent.Location.X;
Rectangle curRect = Rectangle.Empty; Rectangle pageBreakRect = Rectangle.Empty;
do { do {
@ -90,27 +91,26 @@ namespace ICSharpCode.Reports.Core.Exporter
do { do {
currentPosition = ConvertGroupChilds (exporterCollection,section,simpleContainer,defaultLeftPos,currentPosition); currentPosition = ConvertGroupChilds (exporterCollection,section,simpleContainer,defaultLeftPos,currentPosition);
curRect = PageBreakRectangle((BaseReportItem)section.Items[1],currentPosition,section); pageBreakRect = PrintHelper.CalculatePageBreakRectangle((BaseReportItem)section.Items[1],currentPosition);
if (PrintHelper.IsPageFull(curRect,base.SectionBounds )) { if (PrintHelper.IsPageFull(pageBreakRect,base.SectionBounds )) {
BuildNewPage(exporterCollection,section); base.BuildNewPage(exporterCollection,section);
currentPosition = CalculateStartPosition (); currentPosition = CalculateStartPosition ();
} }
} }
while ( base.DataNavigator.ChildMoveNext()); while ( base.DataNavigator.ChildMoveNext());
} }
} }
else else
{ {
// No Grouping // No Grouping at all
currentPosition = ConvertStandardRow (exporterCollection,section,simpleContainer,defaultLeftPos,currentPosition); currentPosition = ConvertStandardRow (exporterCollection,section,simpleContainer,defaultLeftPos,currentPosition);
} }
curRect = PageBreakRectangle((BaseReportItem)section.Items[0],currentPosition,section);
//PageBreakNeeded(exporterCollection,section,curRect,currentPosition); pageBreakRect = PrintHelper.CalculatePageBreakRectangle((BaseReportItem)section.Items[0],currentPosition);
if (PrintHelper.IsPageFull(curRect,base.SectionBounds)) { if (PrintHelper.IsPageFull(pageBreakRect,base.SectionBounds)) {
BuildNewPage(exporterCollection,section); base.BuildNewPage(exporterCollection,section);
currentPosition = CalculateStartPosition (); currentPosition = CalculateStartPosition();
} }
ShouldDrawBorder (section,exporterCollection); ShouldDrawBorder (section,exporterCollection);
@ -126,28 +126,18 @@ namespace ICSharpCode.Reports.Core.Exporter
} }
Rectangle PageBreakRectangle(BaseReportItem simpleContainer,Point curPos,BaseSection section) // private Point PerformPageBreak (ExporterCollection exporterCollection,BaseSection section)
{ // {
return new Rectangle(new Point (simpleContainer.Location.X,curPos.Y), simpleContainer.Size); // BuildNewPage(exporterCollection,section);
} // return CalculateStartPosition();
// }
//
private Point CalculateStartPosition() private Point CalculateStartPosition()
{ {
return new Point(base.SectionBounds.PageHeaderRectangle.X,base.SectionBounds.PageHeaderRectangle.Y); return new Point(base.SectionBounds.PageHeaderRectangle.X,base.SectionBounds.PageHeaderRectangle.Y);
} }
private void BuildNewPage(ExporterCollection myList,BaseSection section)
{
base.FirePageFull(myList);
section.SectionOffset = base.SinglePage.SectionBounds.PageHeaderRectangle.Location.Y;
myList.Clear();
}
private Point ConvertGroupHeader(ExporterCollection mylist,BaseSection section,ISimpleContainer simpleContainer,int leftPos,Point offset) private Point ConvertGroupHeader(ExporterCollection mylist,BaseSection section,ISimpleContainer simpleContainer,int leftPos,Point offset)
{ {
Point retVal = Point.Empty; Point retVal = Point.Empty;

11
src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/TableConverter.cs

@ -90,13 +90,16 @@ namespace ICSharpCode.Reports.Core.Exporter
base.PrepareContainerForConverting(null,simpleContainer); base.PrepareContainerForConverting(null,simpleContainer);
if (PrintHelper.IsPageFull(new Rectangle(new Point (simpleContainer.Location.X,currentPosition.Y),simpleContainer.Size),base.SectionBounds)) { Rectangle pageBreakRect = PrintHelper.CalculatePageBreakRectangle((BaseReportItem)simpleContainer,currentPosition);
base.FirePageFull(mylist);
mylist.Clear(); if (PrintHelper.IsPageFull(pageBreakRect,base.SectionBounds))
{
base.BuildNewPage(mylist,section);
currentPosition = BaseConverter.BaseConvert(mylist,headerContainer, currentPosition = BaseConverter.BaseConvert(mylist,headerContainer,
defaultLeftPos, defaultLeftPos,
base.SectionBounds.ReportHeaderRectangle.Location); base.SectionBounds.ReportHeaderRectangle.Location);
} }
currentPosition = BaseConverter.BaseConvert(mylist,simpleContainer,defaultLeftPos,currentPosition); currentPosition = BaseConverter.BaseConvert(mylist,simpleContainer,defaultLeftPos,currentPosition);
@ -117,4 +120,4 @@ namespace ICSharpCode.Reports.Core.Exporter
return mylist; return mylist;
} }
} }
} }

Loading…
Cancel
Save