diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/DebugExporter.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/DebugExporter.cs index 01d5a04ef0..5cc57c42ae 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/DebugExporter.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/DebugExporter.cs @@ -31,11 +31,12 @@ namespace ICSharpCode.Reporting.Exporter public override void Run () { foreach (var page in Pages) { ShowDebug(page); + Console.WriteLine("-----------PageBreak---------"); } } - void ShowDebug(IExportContainer container) + void ShowDebug(IExportContainer container) { foreach (var item in container.ExportedItems) { var exportContainer = item as IExportContainer; diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/BasePageBuilder.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/BasePageBuilder.cs index f6fbe71c28..06222b3652 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/BasePageBuilder.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/BasePageBuilder.cs @@ -98,7 +98,7 @@ namespace ICSharpCode.Reporting.PageBuilder this.BuildReportHeader(); BuildPageHeader(); BuildPageFooter(); - BuildReportFooter(); +// BuildReportFooter(); } protected IExportContainer CreateSection(IReportContainer section,Point location) diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/DataPageBuilder.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/DataPageBuilder.cs index 0d60fbd260..f20e69b92e 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/DataPageBuilder.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/DataPageBuilder.cs @@ -55,63 +55,66 @@ namespace ICSharpCode.Reporting.PageBuilder CurrentLocation, collectionSource); - detail = CreateContainerForSection(); + detail = CreateContainerForSection(DetailStart); var position = Point.Empty; do { collectionSource.Fill(Container.Items); var r = converter.Convert(Container as ExportContainer,position); - if (ExeedPage(r)) { + if (PageFull(r)) { detail.ExportedItems.AddRange(r); CurrentPage.ExportedItems.Insert(2,detail); Pages.Add(CurrentPage); -// CurrentLocation = DetailStart; position = Point.Empty; CurrentPage = CreateNewPage(); WriteStandardSections(); CurrentLocation = DetailStart; - detail = CreateContainerForSection(); + detail = CreateContainerForSection(DetailStart); } else { detail.ExportedItems.AddRange(r); position = new Point(Container.Location.Y,position.Y + Container.Size.Height); } - - } + while (collectionSource.MoveNext()); - if (Pages.Count == 0) { - CurrentPage.ExportedItems.Insert(2,detail); - } else { - CurrentPage.ExportedItems.Insert(1,detail); - } + InsertDetailAtPosition(detail); + base.BuildReportFooter(); - var a = base.Pages; } else { - detail = base.CreateSection(Container,CurrentLocation); + detail = CreateContainerForSection(DetailStart); + InsertDetailAtPosition(detail); + base.BuildReportFooter(); } } - IExportContainer CreateContainerForSection( ) + + IExportContainer CreateContainerForSection(Point location ) { var detail = (ExportContainer)Container.CreateExportColumn(); - detail.Location = CurrentLocation; + detail.Location = location; return detail; } - bool ExeedPage(System.Collections.Generic.List r) + bool PageFull(System.Collections.Generic.List column) { - var rect = new Rectangle(r[0].Location,r[0].Size); + var rect = new Rectangle(column[0].Location,column[0].Size); if (rect.Contains(new Point(100,500))) { - Console.WriteLine("PageBreak"); return true; } - Console.WriteLine("contains {0} - {1}",rect,DetailEnds); return false; } + void InsertDetailAtPosition(IExportContainer container) + { + if (Pages.Count == 0) { + CurrentPage.ExportedItems.Insert(2, container); + } else { + CurrentPage.ExportedItems.Insert(1, container); + } + } internal IReportContainer Container { get; private set; } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/FormPageBuilder.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/FormPageBuilder.cs index 2551cbf855..6bd1296096 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/FormPageBuilder.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/FormPageBuilder.cs @@ -37,21 +37,10 @@ namespace ICSharpCode.Reporting.PageBuilder void BuilDetail() { - Console.WriteLine(" Build DetailSection {0} - {1}",DetailStart,DetailEnds); CurrentLocation = DetailStart; var detail = CreateSection(ReportModel.DetailSection,CurrentLocation); detail.Parent = CurrentPage; CurrentPage.ExportedItems.Insert(2,detail); } - - -// protected override void CreatePage() -// { -// CurrentPage = base.CreatePage(); -//// WriteStandardSections(); -//// BuilDetail(); -//// base.AddPage(CurrentPage); -// Console.WriteLine("------{0}---------",ReportModel.ReportSettings.PageSize); -// } } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/BaseConvertFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/BaseConvertFixture.cs index 14acb06d4e..82af9873d2 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/BaseConvertFixture.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/BaseConvertFixture.cs @@ -24,7 +24,7 @@ namespace ICSharpCode.Reporting.Test.PageBuilder public void CurrentPageContainFiveItems() { reportCreator.BuildExportList(); var page = reportCreator.Pages[0]; - Assert.That(page.ExportedItems.Count, Is.EqualTo(5)); + Assert.That(page.ExportedItems.Count, Is.EqualTo(4)); } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/PageLayoutFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/PageLayoutFixture.cs index 93c8eb2b3d..cd6ef117cd 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/PageLayoutFixture.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/PageLayoutFixture.cs @@ -25,14 +25,14 @@ namespace ICSharpCode.Reporting.Test.PageBuilder private IReportCreator reportCreator; [Test] - public void PageContainsFiveSections() + public void FormsReportContains_4_Sections() { reportCreator.BuildExportList(); var x = reportCreator.Pages[0].ExportedItems; var y = from s in x where s.GetType() == typeof(ExportContainer) select s; - Assert.That(y.ToList().Count,Is.EqualTo(5)); + Assert.That(y.ToList().Count,Is.EqualTo(4)); Console.WriteLine("-------PageLayoutFixture:ShowDebug---------"); var ex = new DebugExporter(reportCreator.Pages); ex.Run(); diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Reportingfactory/PushModelFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Reportingfactory/PushModelFixture.cs index d2e3a32c78..8977091b94 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Reportingfactory/PushModelFixture.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Reportingfactory/PushModelFixture.cs @@ -36,16 +36,25 @@ namespace ICSharpCode.Reporting.Test.Reportingfactory [Test] - public void PageContainsFiveSections() + public void FirstPageContains_4_Sections() { reportCreator.BuildExportList(); var exporteditems = reportCreator.Pages[0].ExportedItems; var sections = from s in exporteditems where s.GetType() == typeof(ExportContainer) select s; - Assert.That(sections.ToList().Count,Is.EqualTo(5)); + Assert.That(sections.ToList().Count,Is.EqualTo(4)); } + public void LastPageContains_4_Sections() + { + reportCreator.BuildExportList(); + var exporteditems = reportCreator.Pages[1].ExportedItems; + var sections = from s in exporteditems + where s.GetType() == typeof(ExportContainer) + select s; + Assert.That(sections.ToList().Count,Is.EqualTo(4)); + } [Test] public void DetailContainsOneDataItem() { @@ -58,8 +67,8 @@ namespace ICSharpCode.Reporting.Test.Reportingfactory var result = section.ExportedItems[0]; Assert.That(result,Is.AssignableFrom(typeof(ExportText))); Console.WriteLine("-------PageLayoutFixture:ShowDebug---------"); -// var ex = new DebugExporter(reportCreator.Pages); -// ex.Run(); + var ex = new DebugExporter(reportCreator.Pages); + ex.Run(); }