Browse Source

Cleanup Arrange

reports
Peter Forstmeier 12 years ago
parent
commit
1463d684b1
  1. 8
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Arrange/ArrangeStrategy.cs
  2. 8
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/ExpressionVisitor.cs
  3. 4
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/Ast/AstExtensions.cs
  4. 26
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/BasePageBuilder.cs
  5. 28
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/DataPageBuilder.cs
  6. 1
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/ICSharpCode.Reporting.Test.csproj
  7. 63
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IntegrationTests/AggregatesGroupesFixture.cs

8
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Arrange/ArrangeStrategy.cs

@ -62,7 +62,13 @@ namespace ICSharpCode.Reporting.Arrange
} }
if (!containerRectangle.Contains(elementRectangle)) { if (!containerRectangle.Contains(elementRectangle)) {
containerRectangle = Rectangle.Union(containerRectangle,elementRectangle);
containerRectangle = new Rectangle(containerRectangle.Left,
containerRectangle.Top ,
containerRectangle.Width,
element.Location.Y + elementRectangle.Size.Height + 5);
// containerRectangle = Rectangle.Union(containerRectangle,elementRectangle);
} }
} }
return containerRectangle.Size; return containerRectangle.Size;

8
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/ExpressionVisitor.cs

@ -1,14 +1,13 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using System.Collections.ObjectModel;
using ICSharpCode.Reporting.DataManager.Listhandling; using ICSharpCode.Reporting.DataManager.Listhandling;
using ICSharpCode.Reporting.Expressions; using ICSharpCode.Reporting.Expressions;
using ICSharpCode.Reporting.Expressions.Irony; using ICSharpCode.Reporting.Expressions.Irony;
using ICSharpCode.Reporting.Expressions.Irony.Ast; using ICSharpCode.Reporting.Expressions.Irony.Ast;
using ICSharpCode.Reporting.Items; using ICSharpCode.Reporting.Items;
using ICSharpCode.Reporting.PageBuilder.ExportColumns; using ICSharpCode.Reporting.PageBuilder.ExportColumns;
using System.Collections.Generic;
namespace ICSharpCode.Reporting.Exporter.Visitors namespace ICSharpCode.Reporting.Exporter.Visitors
{ {
/// <summary> /// <summary>
@ -20,7 +19,6 @@ namespace ICSharpCode.Reporting.Exporter.Visitors
readonly ReportingExpressionEvaluator evaluator; readonly ReportingExpressionEvaluator evaluator;
public ExpressionVisitor(ReportSettings reportSettings,CollectionDataSource dataSource) { public ExpressionVisitor(ReportSettings reportSettings,CollectionDataSource dataSource) {
grammar = new ReportingLanguageGrammer(); grammar = new ReportingLanguageGrammer();
evaluator = new ReportingExpressionEvaluator(grammar); evaluator = new ReportingExpressionEvaluator(grammar);
@ -28,6 +26,10 @@ namespace ICSharpCode.Reporting.Exporter.Visitors
if (dataSource != null) { if (dataSource != null) {
evaluator.AddDataSource(dataSource); evaluator.AddDataSource(dataSource);
} }
}
public void SetSourceList (IEnumerable<object> list) {
} }

4
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/Ast/AstExtensions.cs

@ -80,9 +80,7 @@ namespace ICSharpCode.Reporting.Expressions.Irony.Ast
} }
// public static CollectionSource GetDataSource (this ScriptThread thread){
// return (CollectionSource)thread.App.Globals["DataSource"];
// }
#endregion #endregion
} }
} }

26
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/BasePageBuilder.cs

@ -7,7 +7,6 @@
* To change this template use Tools | Options | Coding | Edit Standard Headers. * To change this template use Tools | Options | Coding | Edit Standard Headers.
*/ */
using System; using System;
using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
@ -15,7 +14,6 @@ using System.Linq;
using ICSharpCode.Reporting.BaseClasses; using ICSharpCode.Reporting.BaseClasses;
using ICSharpCode.Reporting.DataManager.Listhandling; using ICSharpCode.Reporting.DataManager.Listhandling;
using ICSharpCode.Reporting.Exporter; using ICSharpCode.Reporting.Exporter;
using ICSharpCode.Reporting.Exporter.Visitors;
using ICSharpCode.Reporting.Expressions; using ICSharpCode.Reporting.Expressions;
using ICSharpCode.Reporting.Globals; using ICSharpCode.Reporting.Globals;
using ICSharpCode.Reporting.Interfaces; using ICSharpCode.Reporting.Interfaces;
@ -98,34 +96,14 @@ namespace ICSharpCode.Reporting.PageBuilder
BuildPageFooter(); BuildPageFooter();
} }
/*
protected bool PageFull (Rectangle rect) {
var sectionRect = new Rectangle(0,0,DetailsRectangle.Width,DetailsRectangle.Height);
var testRect = new Rectangle(1,rect.Location.Y,rect.Width -2,rect.Height);
if (sectionRect.Contains(testRect)) {
return false;
} else {
Console.WriteLine("PageBreak");
return true;
}
}
*/
protected bool PageFull(IExportContainer container) { protected bool PageFull(IExportContainer container) {
int pos; if (container.DisplayRectangle.Bottom > DetailEnds.Y) {
if (container.ExportedItems.Count > 0) {
pos = container.Location.Y + container.ExportedItems.Last().Location.Y + container.ExportedItems.Last().Size.Height;
} else {
pos = container.Location.Y + container.Size.Height;
}
if (pos > DetailEnds.Y) {
return true; return true;
} }
return false; return false;
} }
#endregion #endregion

28
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/DataPageBuilder.cs

@ -98,15 +98,9 @@ namespace ICSharpCode.Reporting.PageBuilder
List<IExportColumn> convertedItems = FillAndConvert(sectionContainer, child, dataItems, converter); List<IExportColumn> convertedItems = FillAndConvert(sectionContainer, child, dataItems, converter);
AdjustLocationInSection(sectionPosition, convertedItems); AdjustLocationInSection(sectionPosition, convertedItems);
// var rr = new Rectangle(sectionContainer.DisplayRectangle.X,sectionContainer.DisplayRectangle.Y,sectionContainer.Size.Width, sectionContainer.ExportedItems.AddRange(convertedItems);
// sectionContainer.Size.Height + convertedItems[0].Size.Height ); MeasureAndArrangeContainer(sectionContainer);
// keep this for 'KeepTogether'
// var rr = new Rectangle(sectionContainer.DisplayRectangle.X,sectionContainer.DisplayRectangle.Y,sectionContainer.Size.Width,
// sectionContainer.Size.Height + convertedItems[0].Size.Height );
// if (PageFull(rr)) {
if (PageFull(sectionContainer)) { if (PageFull(sectionContainer)) {
PerformPageBreak(); PerformPageBreak();
@ -115,8 +109,6 @@ namespace ICSharpCode.Reporting.PageBuilder
sectionContainer.Location = DetailStart; sectionContainer.Location = DetailStart;
} }
sectionContainer.ExportedItems.AddRange(convertedItems);
MeasureAndArrangeContainer(sectionContainer);
sectionPosition = new Point(CurrentSection.Location.X, sectionPosition.Y + convertedItems[0].DisplayRectangle.Size.Height + 5); sectionPosition = new Point(CurrentSection.Location.X, sectionPosition.Y + convertedItems[0].DisplayRectangle.Size.Height + 5);
sectionContainer.Size = new Size(sectionContainer.Size.Width,sectionContainer.Size.Height + convertedItems[0].Size.Height); sectionContainer.Size = new Size(sectionContainer.Size.Width,sectionContainer.Size.Height + convertedItems[0].Size.Height);
} }
@ -134,6 +126,9 @@ namespace ICSharpCode.Reporting.PageBuilder
foreach (var element in DataSource.SortedList) { foreach (var element in DataSource.SortedList) {
var sectionContainer = CreateContainerForSection(CurrentPage, pagePosition); var sectionContainer = CreateContainerForSection(CurrentPage, pagePosition);
var convertedItems = FillAndConvert(sectionContainer,element,ReportModel.DetailSection.Items,converter); var convertedItems = FillAndConvert(sectionContainer,element,ReportModel.DetailSection.Items,converter);
sectionContainer.ExportedItems.AddRange(convertedItems);
MeasureAndArrangeContainer(sectionContainer);
if (PageFull(sectionContainer)) { if (PageFull(sectionContainer)) {
InsertExportRows(exportRows); InsertExportRows(exportRows);
@ -143,8 +138,9 @@ namespace ICSharpCode.Reporting.PageBuilder
sectionContainer.Location = pagePosition; sectionContainer.Location = pagePosition;
} }
sectionContainer.ExportedItems.AddRange(convertedItems); // sectionContainer.ExportedItems.AddRange(convertedItems);
MeasureAndArrangeContainer(sectionContainer); // MeasureAndArrangeContainer(sectionContainer);
exportRows.Add(sectionContainer); exportRows.Add(sectionContainer);
pagePosition = new Point(CurrentSection.Location.X, pagePosition.Y + sectionContainer.DesiredSize.Height + 1); pagePosition = new Point(CurrentSection.Location.X, pagePosition.Y + sectionContainer.DesiredSize.Height + 1);
} }
@ -159,7 +155,6 @@ namespace ICSharpCode.Reporting.PageBuilder
CurrentPage = CreateNewPage(); CurrentPage = CreateNewPage();
WriteStandardSections(); WriteStandardSections();
CurrentLocation = DetailStart; CurrentLocation = DetailStart;
// ResetPosition();
} }
@ -192,11 +187,6 @@ namespace ICSharpCode.Reporting.PageBuilder
return false; return false;
} }
/*
Point ResetPosition () {
return new Point(DetailStart.X,1);
}
*/
static void AdjustLocationInSection(Point sectionPosition,List<IExportColumn> convertedItems) static void AdjustLocationInSection(Point sectionPosition,List<IExportColumn> convertedItems)
{ {

1
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/ICSharpCode.Reporting.Test.csproj

@ -68,6 +68,7 @@
<Compile Include="src\DataSource\DataSourceFixture.cs" /> <Compile Include="src\DataSource\DataSourceFixture.cs" />
<Compile Include="src\Expressions\Aggregates\AggregateFuctionHelper.cs" /> <Compile Include="src\Expressions\Aggregates\AggregateFuctionHelper.cs" />
<Compile Include="src\Expressions\Aggregates\SumAggregate.cs" /> <Compile Include="src\Expressions\Aggregates\SumAggregate.cs" />
<Compile Include="src\Expressions\IntegrationTests\AggregatesGroupesFixture.cs" />
<Compile Include="src\Expressions\IntegrationTests\FieldsFixture.cs" /> <Compile Include="src\Expressions\IntegrationTests\FieldsFixture.cs" />
<Compile Include="src\Expressions\IntegrationTests\GlobalsFixture.cs" /> <Compile Include="src\Expressions\IntegrationTests\GlobalsFixture.cs" />
<Compile Include="src\Expressions\IntegrationTests\StandardTests.cs" /> <Compile Include="src\Expressions\IntegrationTests\StandardTests.cs" />

63
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IntegrationTests/AggregatesGroupesFixture.cs

@ -0,0 +1,63 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using ICSharpCode.Reporting.DataManager.Listhandling;
using ICSharpCode.Reporting.Exporter.Visitors;
using ICSharpCode.Reporting.Items;
using ICSharpCode.Reporting.PageBuilder.ExportColumns;
using ICSharpCode.Reporting.Test.DataSource;
using NUnit.Framework;
namespace ICSharpCode.Reporting.Test.Expressions.IntegrationTests
{
[TestFixture]
public class AggregatesGroupesFixture
{
Collection<ExportText> collection;
CollectionDataSource dataSource;
ContributorCollection list;
ExpressionVisitor visitor;
ReportSettings reportSettings;
[Test]
public void TestMethod()
{
visitor = new ExpressionVisitor(reportSettings,null);
var script = "= sum('doubleValue')";
collection[0].Text = script;
foreach (IGrouping<object, object> grouping in dataSource.GroupedList) {
Console.WriteLine("key {0}",grouping.Key);
//Childs
foreach (var child in grouping) {
var c = (Contributor)child;
Console.WriteLine("\tContributor {0}, {1}",c.Firstname,c.Lastname);
}
}
}
[SetUp]
public void CreateExportlist() {
collection = new Collection<ExportText>();
collection.Add(new ExportText()
{
Text = String.Empty
});
var contributorList = new ContributorsList();
list = contributorList.ContributorCollection;
reportSettings = new ReportSettings();
reportSettings.GroupColumnsCollection.Add(
new GroupColumn("groupItem",1,ListSortDirection.Ascending )
);
dataSource = new CollectionDataSource(list,reportSettings);
dataSource.Bind();
}
}
}
Loading…
Cancel
Save