From 3fae35bff9ad6d00b9fbb3685397cbccd37c45a5 Mon Sep 17 00:00:00 2001 From: Peter Forstmeier Date: Fri, 14 Jun 2013 12:47:12 +0200 Subject: [PATCH] DataContainerConverter.cs --- .../Src/Exporter/DebugExporter.cs | 2 -- .../Src/Exporter/Visitors/DebugVisitor.cs | 4 ++- .../Converter/ContainerConverter.cs | 7 ++-- .../Converter/DataContainerConverter.cs | 34 ++++++++++++++++--- .../Src/PageBuilder/DataPageBuilder.cs | 4 +-- .../Src/PageBuilder/FormPageBuilder.cs | 1 - .../Src/ReportingFactory.cs | 15 ++++---- .../src/PageBuilder/DataPageBuilderFixture.cs | 3 -- .../src/Reportingfactory/PushModelFixture.cs | 10 ++++-- 9 files changed, 53 insertions(+), 27 deletions(-) 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 f663d8ff8b..0fe17df655 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/DebugExporter.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/DebugExporter.cs @@ -42,13 +42,11 @@ namespace ICSharpCode.Reporting.Exporter var acceptor = item as IAcceptor; if (exportContainer != null) { if (acceptor != null) { -// Console.WriteLine("--container--"); acceptor.Accept(visitor); } ShowDebug(item as IExportContainer); } else { if (acceptor != null) { -// Console.WriteLine("..Item..."); acceptor.Accept(visitor); } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/DebugVisitor.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/DebugVisitor.cs index 34af5a218d..12dd3e636c 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/DebugVisitor.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/DebugVisitor.cs @@ -29,7 +29,9 @@ namespace ICSharpCode.Reporting.Exporter.Visitors public override void Visit(ExportContainer exportColumn) { - Console.WriteLine("Visit ExportContainer {0} - {1} - {2}", exportColumn.Name,exportColumn.Size,exportColumn.Location); + Console.WriteLine("Start Container"); + Console.WriteLine("Visit ExportContainer {0} - {1} - {2} - Items {3}", + exportColumn.Name,exportColumn.Size,exportColumn.Location,exportColumn.ExportedItems.Count); } public override void Visit(ExportText exportColumn) diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/Converter/ContainerConverter.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/Converter/ContainerConverter.cs index 1430c56f56..8a5ea58b5d 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/Converter/ContainerConverter.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/Converter/ContainerConverter.cs @@ -43,7 +43,7 @@ namespace ICSharpCode.Reporting.PageBuilder.Converter var exportContainer = CreateExportContainer(); - var itemsList = CreateConvertedList(exportContainer); + var itemsList = CreateConvertedList(exportContainer,Point.Empty); exportContainer.ExportedItems.AddRange(itemsList); @@ -63,12 +63,13 @@ namespace ICSharpCode.Reporting.PageBuilder.Converter } - protected List CreateConvertedList(ExportContainer exportContainer) + protected List CreateConvertedList(ExportContainer exportContainer,Point position) { var itemsList = new List(); foreach (var element in Container.Items) { var exportColumn = ExportColumnFactory.CreateItem(element); exportColumn.Parent = exportContainer; + exportColumn.Location = new Point(element.Location.X,element.Location.Y + position.Y); exportColumn.DesiredSize = Measure(element); itemsList.Add(exportColumn); Console.WriteLine("Size {0} DesiredSize {1}", exportColumn.Size, exportColumn.DesiredSize); @@ -93,7 +94,7 @@ namespace ICSharpCode.Reporting.PageBuilder.Converter internal IReportContainer Container { get; private set; } - internal Point CurrentLocation { get; private set; } + protected Point CurrentLocation { get; set; } internal Graphics Graphics {get;private set;} } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/Converter/DataContainerConverter.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/Converter/DataContainerConverter.cs index 3ea2c693ea..24e7a78009 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/Converter/DataContainerConverter.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/Converter/DataContainerConverter.cs @@ -42,14 +42,39 @@ namespace ICSharpCode.Reporting.PageBuilder.Converter this.collectionSource = collectionSource; } + public override IExportContainer Convert(){ + if (collectionSource.Count == 0) { + return base.Convert(); + } + + var exportContainer = CreateExportContainer(); + Console.WriteLine(""); + Console.WriteLine("start CurrentLocation {0}",CurrentLocation); + var position = Point.Empty; + do { + collectionSource.Fill(Container.Items); +// Console.WriteLine(((BaseDataItem)Container.Items[0]).DBValue); + var itemsList = CreateConvertedList(exportContainer,position); + exportContainer.ExportedItems.AddRange(itemsList); +// CurrentLocation = new Point(CurrentLocation.X,CurrentLocation.Y + Container.Size.Height); + position = new Point(Container.Location.X,position.Y + Container.Size.Height); + } + while (collectionSource.MoveNext()); + Console.WriteLine("end CurrentLocation {0}",CurrentLocation); + Console.WriteLine(""); + ArrangeContainer(exportContainer); + return exportContainer; + } + /* public override IExportContainer Convert(){ if (collectionSource.Count == 0) { return base.Convert(); } var exportContainer = CreateExportContainer(); - + Console.WriteLine(""); + Console.WriteLine("start CurrentLocation {0}",CurrentLocation); do { collectionSource.Fill(Container.Items); Console.WriteLine(((BaseDataItem)Container.Items[0]).DBValue); @@ -57,12 +82,11 @@ namespace ICSharpCode.Reporting.PageBuilder.Converter exportContainer.ExportedItems.AddRange(itemsList); } while (collectionSource.MoveNext()); - -// Console.WriteLine("calling Container-Arrange"); -// var exportArrange = exportContainer.GetArrangeStrategy(); -// exportArrange.Arrange(exportContainer); + Console.WriteLine("end CurrentLocation {0}",CurrentLocation); + Console.WriteLine(""); ArrangeContainer(exportContainer); return exportContainer; } + */ } } 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 0c98a28060..22a07d3775 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/DataPageBuilder.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/DataPageBuilder.cs @@ -38,8 +38,8 @@ namespace ICSharpCode.Reporting.PageBuilder var collectionSource = new CollectionSource(List,ElementType,ReportModel.ReportSettings); collectionSource.Bind(); CurrentLocation = DetailStart; - var dc = new DataContainerConverter(base.Graphics,ReportModel.DetailSection,CurrentLocation,collectionSource); - var detail = dc.Convert(); + var converter = new DataContainerConverter(base.Graphics,ReportModel.DetailSection,CurrentLocation,collectionSource); + var detail = converter.Convert(); CurrentPage.ExportedItems.Insert(2,detail); } 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 80cd9d41ae..b26f0d23d2 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/FormPageBuilder.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/FormPageBuilder.cs @@ -39,7 +39,6 @@ namespace ICSharpCode.Reporting.PageBuilder { Console.WriteLine("FormPageBuilder - Build DetailSection {0} - {1} - {2}",ReportModel.ReportSettings.PageSize.Width,ReportModel.ReportSettings.LeftMargin,ReportModel.ReportSettings.RightMargin); CurrentLocation = DetailStart; - var detail = CreateSection(ReportModel.DetailSection,CurrentLocation); detail.Parent = CurrentPage; CurrentPage.ExportedItems.Insert(2,detail); diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/ReportingFactory.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/ReportingFactory.cs index 148e0bbc43..4dc16950dc 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/ReportingFactory.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/ReportingFactory.cs @@ -40,26 +40,25 @@ namespace ICSharpCode.Reporting } - internal IReportCreator ReportCreator (Stream stream) + public IReportCreator ReportCreator (Stream stream,Type listType,IEnumerable list) { - IReportModel reportModel = LoadReportModel (stream); + ReportModel = LoadReportModel (stream); IReportCreator builder = null; - builder = ReportCreatorFactory.ExporterFactory(reportModel); + builder = new DataPageBuilder(ReportModel,listType,list ); return builder; } - internal IReportCreator ReportCreator (Stream stream,IList list) + internal IReportCreator ReportCreator (Stream stream) { IReportModel reportModel = LoadReportModel (stream); IReportCreator builder = null; - builder = new DataPageBuilder(reportModel,typeof(T),list ); + builder = ReportCreatorFactory.ExporterFactory(reportModel); return builder; } - - internal ReportModel LoadReportModel (Stream stream) + public ReportModel LoadReportModel (Stream stream) { var doc = new XmlDocument(); doc.Load(stream); @@ -78,5 +77,7 @@ namespace ICSharpCode.Reporting } return model; } + + public ReportModel ReportModel {get;private set;} } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/DataPageBuilderFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/DataPageBuilderFixture.cs index 8af26b5235..1e055033d2 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/DataPageBuilderFixture.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/DataPageBuilderFixture.cs @@ -55,9 +55,6 @@ namespace ICSharpCode.Reporting.Test.PageBuilder where s.GetType() == typeof(ExportContainer) select s; Assert.That(sections.ToList().Count,Is.EqualTo(5)); - 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 59393d8938..ad1ee11d77 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 @@ -7,10 +7,12 @@ * To change this template use Tools | Options | Coding | Edit Standard Headers. */ using System; +using System.Collections.Generic; using System.IO; -using System.Reflection; using System.Linq; -using System.Collections.Generic; +using System.Reflection; + +using ICSharpCode.Reporting.Exporter; using ICSharpCode.Reporting.Interfaces; using ICSharpCode.Reporting.PageBuilder; using ICSharpCode.Reporting.PageBuilder.ExportColumns; @@ -38,12 +40,14 @@ namespace ICSharpCode.Reporting.Test.Reportingfactory reportCreator.BuildExportList(); var exporteditems = reportCreator.Pages[0].ExportedItems; var sections = from s in exporteditems - where s.GetType() == typeof(ExportContainer) select s; var section = sections.ToList()[2] as ExportContainer; var result = section.ExportedItems[0]; Assert.That(result,Is.AssignableFrom(typeof(ExportText))); + Console.WriteLine("-------PageLayoutFixture:ShowDebug---------"); + var ex = new DebugExporter(reportCreator.Pages); + ex.Run(); }