Browse Source

SinglePageFixture.cs

pull/15/head^2
peterforstmeier 15 years ago
parent
commit
8673fb979a
  1. 14
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/SectionBounds.cs
  2. 1
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/DataPageBuilder.cs
  3. 106
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Test/ICSharpCode.Reports.Core.Test/Printing/SectionBoundFixture.cs
  4. 76
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Test/ICSharpCode.Reports.Core.Test/Printing/SinglePageFixture.cs

14
src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/SectionBounds.cs

@ -161,8 +161,13 @@ namespace ICSharpCode.Reports.Core.BaseClasses @@ -161,8 +161,13 @@ namespace ICSharpCode.Reports.Core.BaseClasses
}
// The reportFooter is set On Top of PageFooter
// this.reportFooterRectangle = new Rectangle (this.printableArea.Left,
// this.PageFooterRectangle.Top - section.Size.Height ,
// this.marginBounds.Width,
// section.Size.Height);
this.reportFooterRectangle = new Rectangle (this.printableArea.Left,
this.PageFooterRectangle.Top - section.Size.Height - 3 * GlobalValues.GapBetweenContainer,
this.PageFooterRectangle.Top - section.Size.Height - GlobalValues.GapBetweenContainer,
this.marginBounds.Width,
section.Size.Height);
section.SectionOffset = this.reportFooterRectangle.Top;
@ -235,9 +240,9 @@ namespace ICSharpCode.Reports.Core.BaseClasses @@ -235,9 +240,9 @@ namespace ICSharpCode.Reports.Core.BaseClasses
{
get {
// return new Point(this.pageHeaderRectangle.Left,
// this.pageHeaderRectangle.Bottom + 3 * GlobalValues.GapBetweenContainer);
// this.pageHeaderRectangle.Bottom + 3 * );
return new Point(this.pageHeaderRectangle.Left,
this.pageHeaderRectangle.Bottom );
this.pageHeaderRectangle.Bottom + GlobalValues.GapBetweenContainer );
}
}
@ -246,7 +251,8 @@ namespace ICSharpCode.Reports.Core.BaseClasses @@ -246,7 +251,8 @@ namespace ICSharpCode.Reports.Core.BaseClasses
public Point DetailEnds
{
get {
return new Point(this.pageFooterRectangle.Left,this.pageFooterRectangle.Top - 3 * GlobalValues.GapBetweenContainer);
// return new Point(this.pageFooterRectangle.Left,this.pageFooterRectangle.Top - 3 * GlobalValues.GapBetweenContainer);
return new Point(this.pageFooterRectangle.Left,this.pageFooterRectangle.Top - GlobalValues.GapBetweenContainer);
}
}

1
src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/DataPageBuilder.cs

@ -7,7 +7,6 @@ using ICSharpCode.Reports.Core.BaseClasses.Printing; @@ -7,7 +7,6 @@ using ICSharpCode.Reports.Core.BaseClasses.Printing;
using ICSharpCode.Reports.Core.Events;
using ICSharpCode.Reports.Core.Globals;
using ICSharpCode.Reports.Core.Interfaces;
using ICSharpCode.Reports.Expressions.ReportingLanguage;
namespace ICSharpCode.Reports.Core.Exporter
{

106
src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Test/ICSharpCode.Reports.Core.Test/Printing/SectionBoundFixture.cs

@ -105,7 +105,6 @@ namespace ICSharpCode.Reports.Core.Test.Printing @@ -105,7 +105,6 @@ namespace ICSharpCode.Reports.Core.Test.Printing
}
[Test]
public void PageHeader_Location_One_Point_Under_ReportHeader()
{
@ -113,7 +112,7 @@ namespace ICSharpCode.Reports.Core.Test.Printing @@ -113,7 +112,7 @@ namespace ICSharpCode.Reports.Core.Test.Printing
BaseSection pageHeader = CreateSection();
Sut.MeasureReportHeader(reportHeader);
Sut.MeasurePageHeader(pageHeader);
Assert.That (pageHeader.SectionOffset,Is.GreaterThan(Sut.ReportHeaderRectangle.Bottom));
Assert.That (pageHeader.SectionOffset,Is.EqualTo(Sut.ReportHeaderRectangle.Bottom + 1));
}
@ -134,21 +133,26 @@ namespace ICSharpCode.Reports.Core.Test.Printing @@ -134,21 +133,26 @@ namespace ICSharpCode.Reports.Core.Test.Printing
{
var setting = new ReportSettings();
SectionBounds sectionBounds = new SectionBounds(new ReportSettings(),true);
BaseSection baseSection = new BaseSection();
baseSection.Location = new Point (50,50);
baseSection.Size = new Size (727,60);
sectionBounds.MeasurePageFooter(baseSection);
//sectionBounds.MeasurePageFooter(Sut);
Assert.AreEqual(baseSection.Size.Height,
sectionBounds.PageFooterRectangle.Size.Height);
Assert.AreEqual(sectionBounds.MarginBounds.Width,
sectionBounds.PageFooterRectangle.Width);
//int i = sectionBounds.PageSize.Height - setting.BottomMargin;
//Assert.AreEqual(i,sectionBounds.PageFooterRectangle.Location.Y);
BaseSection pageFootter = CreateSection();
sectionBounds.MeasurePageFooter(pageFootter);
Size expectedSize = pageFootter.Size;
Assert.That(expectedSize,Is.EqualTo(sectionBounds.PageFooterRectangle.Size));
}
[Test]
public void PageFooter_From_PageEnd_Uppward()
{
SectionBounds sectionBounds = new SectionBounds(new ReportSettings(),true);
BaseSection pageFootter = CreateSection();
sectionBounds.MeasurePageFooter(pageFootter);
int top = sectionBounds.MarginBounds.Bottom - pageFootter.Size.Height;
Assert.That(sectionBounds.PageFooterRectangle.Top,Is.EqualTo(top));
}
#endregion
#region MeasureReportFooter
@ -160,64 +164,56 @@ namespace ICSharpCode.Reports.Core.Test.Printing @@ -160,64 +164,56 @@ namespace ICSharpCode.Reports.Core.Test.Printing
Sut.MeasureReportFooter(null);
}
[Test]
public void MeasureReportFooterNoPageFooterCalculated()
public void ReportFooter_No_PageFooter_Is_Calculated()
{
SectionBounds sectionBounds = new SectionBounds(new ReportSettings(),true);
BaseSection baseSection = new BaseSection();
baseSection.Location = new Point (50,50);
baseSection.Size = new Size (727,60);
sectionBounds.MeasureReportFooter(baseSection);
Assert.AreEqual(baseSection.Size.Height ,sectionBounds.ReportFooterRectangle.Size.Height);
Assert.AreEqual(sectionBounds.MarginBounds.Width,
sectionBounds.ReportFooterRectangle.Width);
BaseSection reportFootter = CreateSection();
sectionBounds.MeasureReportFooter(reportFootter);
Size expectedSize = reportFootter.Size;
Assert.That(sectionBounds.ReportFooterRectangle.Size,Is.EqualTo(expectedSize));
}
[Test]
public void MeasureReportFooterPageFooterIsCalculated()
{
SectionBounds sectionBounds = new SectionBounds(new ReportSettings(),true);
BaseSection baseSection = new BaseSection();
baseSection.Location = new Point (50,50);
baseSection.Size = new Size (727,60);
sectionBounds.MeasurePageFooter(baseSection);
sectionBounds.MeasureReportFooter(baseSection);
BaseSection pageFootter = CreateSection();
BaseSection reportFootter = CreateSection();
sectionBounds.MeasurePageFooter(pageFootter);
sectionBounds.MeasureReportFooter(reportFootter);
int top = sectionBounds.MarginBounds.Bottom - pageFootter.Size.Height - reportFootter.Size.Height -1;
Assert.That(sectionBounds.ReportFooterRectangle.Top,Is.EqualTo(top));
Assert.AreEqual(baseSection.Size.Height , sectionBounds.ReportFooterRectangle.Size.Height,
"ItemsCollection is empty, so Size.Height should be '0'");
Assert.AreEqual(sectionBounds.MarginBounds.Width,
sectionBounds.ReportFooterRectangle.Width);
}
#endregion
[Test]
public void DetailStart ()
public void DetailStart_One_Below_PageHeader ()
{
/*
SectionBounds sectionBounds = new SectionBounds(new ReportSettings(),true);
BaseSection baseSection = new BaseSection();
baseSection.Location = new Point (50,50);
baseSection.Size = new Size (727,60);
sectionBounds.MeasurePageHeader(baseSection);
Point p = new Point(sectionBounds.PageHeaderRectangle.Left,sectionBounds.PageHeaderRectangle.Bottom + sectionBounds.Gap );
Assert.AreEqual(p,sectionBounds.DetailStart);
*/
BaseSection pageHeader = new BaseSection();
sectionBounds.MeasurePageHeader(pageHeader);
Point p = new Point(sectionBounds.PageHeaderRectangle.Left,sectionBounds.PageHeaderRectangle.Bottom +1 );
Assert.That(sectionBounds.DetailStart,Is.EqualTo(p));
}
[Test]
public void DetailEnds ()
public void DetailEnds_One_Above_PageFootter ()
{
/*
SectionBounds sectionBounds = new SectionBounds(new ReportSettings(),true);
BaseSection baseSection = new BaseSection();
baseSection.Location = new Point (50,50);
baseSection.Size = new Size (727,60);
sectionBounds.MeasurePageFooter(baseSection);
Point p = new Point(sectionBounds.PageFooterRectangle.Left,sectionBounds.PageFooterRectangle.Top - sectionBounds.Gap);
Assert.AreEqual(p,sectionBounds.DetailEnds);
*/
BaseSection pageFootter = CreateSection();
sectionBounds.MeasurePageFooter(pageFootter);
Point p = new Point(sectionBounds.PageFooterRectangle.Left,sectionBounds.PageFooterRectangle.Top -1);
Assert.That(sectionBounds.DetailEnds,Is.EqualTo(p));
}
public override void Setup()
@ -231,12 +227,6 @@ namespace ICSharpCode.Reports.Core.Test.Printing @@ -231,12 +227,6 @@ namespace ICSharpCode.Reports.Core.Test.Printing
var sec = new BaseSection();
sec.Location = new Point (50,50);
sec.Size = new Size (727,60);
/*
sec.Items.Add (new BaseTextItem()
{
Text = "mytext";
}
*/
return sec;
}
}

76
src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Test/ICSharpCode.Reports.Core.Test/Printing/SinglePageFixture.cs

@ -48,41 +48,77 @@ namespace ICSharpCode.Reports.Core.Test.Printing @@ -48,41 +48,77 @@ namespace ICSharpCode.Reports.Core.Test.Printing
[Test]
public void Calculate_Page_If_Firstpage ()
public void Calculate_ReportHeader ()
{
Size defSize = new Size (727,60);
IReportModel model = ReportModel.Create();
ISinglePage singlePage = CreateSinglePage(model,0);
singlePage.CalculatePageBounds(model);
Point expectedLocation = new Point(model.ReportSettings.LeftMargin,model.ReportSettings.TopMargin);
Assert.That(singlePage.SectionBounds.ReportHeaderRectangle.Location,Is.EqualTo(expectedLocation));
}
[Test]
public void Calculate_PageHeader ()
{
IReportModel model = ReportModel.Create();
ISinglePage singlePage = CreateSinglePage(model,0);
singlePage.CalculatePageBounds(model);
Point expectedLocation = new Point(model.ReportSettings.LeftMargin,model.ReportSettings.TopMargin + singlePage.SectionBounds.ReportHeaderRectangle.Size.Height + 1);
Assert.That(singlePage.SectionBounds.PageHeaderRectangle.Location,Is.EqualTo(expectedLocation));
}
[Test]
public void Calculate_PageFooter ()
{
IReportModel model = ReportModel.Create();
model.ReportHeader.Size = defSize;
ISinglePage singlePage = CreateSinglePage(model,0);
singlePage.CalculatePageBounds(model);
Point expectedLocation = new Point(model.ReportSettings.LeftMargin,
model.ReportSettings.PageSize.Height - model.ReportSettings.BottomMargin - singlePage.SectionBounds.PageFooterRectangle.Height);
Assert.That(singlePage.SectionBounds.PageFooterRectangle.Location,Is.EqualTo(expectedLocation));
}
IReportModel CreateModel ()
{
Size defaultSectionSize = new Size (727,60);
IReportModel model = ReportModel.Create();
model.ReportHeader.Size = defaultSectionSize;
model.ReportHeader.Location = new Point(50,50);
model.PageHeader.Size = defSize;
model.PageHeader.Size = defaultSectionSize;
model.PageHeader.Location = new Point(50,125);
model.DetailSection.Size = defSize;
model.DetailSection.Size = defaultSectionSize;
model.DetailSection.Location = new Point(50,200);
model.PageFooter.Size = defSize;
model.PageFooter.Size = defaultSectionSize;
model.ReportFooter.Location = new Point(50,275);
model.ReportFooter.Size = defSize;
model.ReportFooter.Size = defaultSectionSize;
model.ReportFooter.Location = new Point(50,350);
return model;
}
ISinglePage CreateSinglePage(IReportModel model,int pageNumber)
{
Size defaultSectionSize = new Size (727,60);
var s = new SectionBounds(model.ReportSettings,true);
var s = new SectionBounds(new ReportSettings(),true);
SinglePage sp = new SinglePage(s,0);
sp.CalculatePageBounds(model);
Console.WriteLine();
Console.WriteLine("ReportHeader {0} - {1}",sp.SectionBounds.ReportHeaderRectangle,sp.SectionBounds.ReportHeaderRectangle.Location.Y + sp.SectionBounds.ReportHeaderRectangle.Height);
Console.WriteLine("PageHeader {0} - {1}",sp.SectionBounds.PageHeaderRectangle,sp.SectionBounds.PageHeaderRectangle.Location.Y +sp.SectionBounds.PageHeaderRectangle.Height );
Console.WriteLine("DetailSection {0} - {1} ",sp.SectionBounds.DetailSectionRectangle,sp.SectionBounds.DetailSectionRectangle.Location.Y + sp.SectionBounds.DetailSectionRectangle.Height);
Console.WriteLine("\tDetailStart {0} ",sp.SectionBounds.DetailStart);
Console.WriteLine("\tDetailEnd {0} ",sp.SectionBounds.DetailEnds);
Console.WriteLine("\tDetailArea {0} ",sp.SectionBounds.DetailArea);
Console.WriteLine("PageFooter {0} - {1} ",sp.SectionBounds.PageFooterRectangle,sp.SectionBounds.PageFooterRectangle.Location.Y + sp.SectionBounds.PageFooterRectangle.Height);
Console.WriteLine("ReportFooter {0} - {1}",sp.SectionBounds.ReportFooterRectangle,sp.SectionBounds.ReportFooterRectangle.Location.Y + sp.SectionBounds.ReportFooterRectangle.Height);
Console.WriteLine();
return sp;
}
#region Setup/Teardown

Loading…
Cancel
Save