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
} }
// The reportFooter is set On Top of PageFooter // 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.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, this.marginBounds.Width,
section.Size.Height); section.Size.Height);
section.SectionOffset = this.reportFooterRectangle.Top; section.SectionOffset = this.reportFooterRectangle.Top;
@ -235,9 +240,9 @@ namespace ICSharpCode.Reports.Core.BaseClasses
{ {
get { get {
// return new Point(this.pageHeaderRectangle.Left, // return new Point(this.pageHeaderRectangle.Left,
// this.pageHeaderRectangle.Bottom + 3 * GlobalValues.GapBetweenContainer); // this.pageHeaderRectangle.Bottom + 3 * );
return new Point(this.pageHeaderRectangle.Left, return new Point(this.pageHeaderRectangle.Left,
this.pageHeaderRectangle.Bottom ); this.pageHeaderRectangle.Bottom + GlobalValues.GapBetweenContainer );
} }
} }
@ -246,7 +251,8 @@ namespace ICSharpCode.Reports.Core.BaseClasses
public Point DetailEnds public Point DetailEnds
{ {
get { 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;
using ICSharpCode.Reports.Core.Events; using ICSharpCode.Reports.Core.Events;
using ICSharpCode.Reports.Core.Globals; using ICSharpCode.Reports.Core.Globals;
using ICSharpCode.Reports.Core.Interfaces; using ICSharpCode.Reports.Core.Interfaces;
using ICSharpCode.Reports.Expressions.ReportingLanguage;
namespace ICSharpCode.Reports.Core.Exporter 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
} }
[Test] [Test]
public void PageHeader_Location_One_Point_Under_ReportHeader() public void PageHeader_Location_One_Point_Under_ReportHeader()
{ {
@ -113,7 +112,7 @@ namespace ICSharpCode.Reports.Core.Test.Printing
BaseSection pageHeader = CreateSection(); BaseSection pageHeader = CreateSection();
Sut.MeasureReportHeader(reportHeader); Sut.MeasureReportHeader(reportHeader);
Sut.MeasurePageHeader(pageHeader); Sut.MeasurePageHeader(pageHeader);
Assert.That (pageHeader.SectionOffset,Is.GreaterThan(Sut.ReportHeaderRectangle.Bottom));
Assert.That (pageHeader.SectionOffset,Is.EqualTo(Sut.ReportHeaderRectangle.Bottom + 1)); Assert.That (pageHeader.SectionOffset,Is.EqualTo(Sut.ReportHeaderRectangle.Bottom + 1));
} }
@ -134,21 +133,26 @@ namespace ICSharpCode.Reports.Core.Test.Printing
{ {
var setting = new ReportSettings(); var setting = new ReportSettings();
SectionBounds sectionBounds = new SectionBounds(new ReportSettings(),true); SectionBounds sectionBounds = new SectionBounds(new ReportSettings(),true);
BaseSection baseSection = new BaseSection(); BaseSection pageFootter = CreateSection();
baseSection.Location = new Point (50,50);
baseSection.Size = new Size (727,60); sectionBounds.MeasurePageFooter(pageFootter);
sectionBounds.MeasurePageFooter(baseSection); Size expectedSize = pageFootter.Size;
//sectionBounds.MeasurePageFooter(Sut);
Assert.AreEqual(baseSection.Size.Height, Assert.That(expectedSize,Is.EqualTo(sectionBounds.PageFooterRectangle.Size));
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);
} }
[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 #endregion
#region MeasureReportFooter #region MeasureReportFooter
@ -160,64 +164,56 @@ namespace ICSharpCode.Reports.Core.Test.Printing
Sut.MeasureReportFooter(null); Sut.MeasureReportFooter(null);
} }
[Test] [Test]
public void MeasureReportFooterNoPageFooterCalculated() public void ReportFooter_No_PageFooter_Is_Calculated()
{ {
SectionBounds sectionBounds = new SectionBounds(new ReportSettings(),true); SectionBounds sectionBounds = new SectionBounds(new ReportSettings(),true);
BaseSection baseSection = new BaseSection(); BaseSection reportFootter = CreateSection();
baseSection.Location = new Point (50,50); sectionBounds.MeasureReportFooter(reportFootter);
baseSection.Size = new Size (727,60); Size expectedSize = reportFootter.Size;
sectionBounds.MeasureReportFooter(baseSection); Assert.That(sectionBounds.ReportFooterRectangle.Size,Is.EqualTo(expectedSize));
Assert.AreEqual(baseSection.Size.Height ,sectionBounds.ReportFooterRectangle.Size.Height);
Assert.AreEqual(sectionBounds.MarginBounds.Width,
sectionBounds.ReportFooterRectangle.Width);
} }
[Test] [Test]
public void MeasureReportFooterPageFooterIsCalculated() public void MeasureReportFooterPageFooterIsCalculated()
{ {
SectionBounds sectionBounds = new SectionBounds(new ReportSettings(),true); SectionBounds sectionBounds = new SectionBounds(new ReportSettings(),true);
BaseSection baseSection = new BaseSection(); BaseSection pageFootter = CreateSection();
baseSection.Location = new Point (50,50); BaseSection reportFootter = CreateSection();
baseSection.Size = new Size (727,60);
sectionBounds.MeasurePageFooter(baseSection); sectionBounds.MeasurePageFooter(pageFootter);
sectionBounds.MeasureReportFooter(baseSection); 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 #endregion
[Test] [Test]
public void DetailStart () public void DetailStart_One_Below_PageHeader ()
{ {
/*
SectionBounds sectionBounds = new SectionBounds(new ReportSettings(),true); SectionBounds sectionBounds = new SectionBounds(new ReportSettings(),true);
BaseSection baseSection = new BaseSection(); BaseSection pageHeader = new BaseSection();
baseSection.Location = new Point (50,50);
baseSection.Size = new Size (727,60); sectionBounds.MeasurePageHeader(pageHeader);
sectionBounds.MeasurePageHeader(baseSection); Point p = new Point(sectionBounds.PageHeaderRectangle.Left,sectionBounds.PageHeaderRectangle.Bottom +1 );
Point p = new Point(sectionBounds.PageHeaderRectangle.Left,sectionBounds.PageHeaderRectangle.Bottom + sectionBounds.Gap ); Assert.That(sectionBounds.DetailStart,Is.EqualTo(p));
Assert.AreEqual(p,sectionBounds.DetailStart);
*/
} }
[Test] [Test]
public void DetailEnds () public void DetailEnds_One_Above_PageFootter ()
{ {
/*
SectionBounds sectionBounds = new SectionBounds(new ReportSettings(),true); SectionBounds sectionBounds = new SectionBounds(new ReportSettings(),true);
BaseSection baseSection = new BaseSection(); BaseSection pageFootter = CreateSection();
baseSection.Location = new Point (50,50);
baseSection.Size = new Size (727,60); sectionBounds.MeasurePageFooter(pageFootter);
sectionBounds.MeasurePageFooter(baseSection); Point p = new Point(sectionBounds.PageFooterRectangle.Left,sectionBounds.PageFooterRectangle.Top -1);
Point p = new Point(sectionBounds.PageFooterRectangle.Left,sectionBounds.PageFooterRectangle.Top - sectionBounds.Gap); Assert.That(sectionBounds.DetailEnds,Is.EqualTo(p));
Assert.AreEqual(p,sectionBounds.DetailEnds);
*/
} }
public override void Setup() public override void Setup()
@ -231,12 +227,6 @@ namespace ICSharpCode.Reports.Core.Test.Printing
var sec = new BaseSection(); var sec = new BaseSection();
sec.Location = new Point (50,50); sec.Location = new Point (50,50);
sec.Size = new Size (727,60); sec.Size = new Size (727,60);
/*
sec.Items.Add (new BaseTextItem()
{
Text = "mytext";
}
*/
return sec; 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
[Test] [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(); 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.ReportHeader.Location = new Point(50,50);
model.PageHeader.Size = defSize; model.PageHeader.Size = defaultSectionSize;
model.PageHeader.Location = new Point(50,125); model.PageHeader.Location = new Point(50,125);
model.DetailSection.Size = defSize; model.DetailSection.Size = defaultSectionSize;
model.DetailSection.Location = new Point(50,200); model.DetailSection.Location = new Point(50,200);
model.PageFooter.Size = defSize; model.PageFooter.Size = defaultSectionSize;
model.ReportFooter.Location = new Point(50,275); model.ReportFooter.Location = new Point(50,275);
model.ReportFooter.Size = defSize; model.ReportFooter.Size = defaultSectionSize;
model.ReportFooter.Location = new Point(50,350); 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); SinglePage sp = new SinglePage(s,0);
sp.CalculatePageBounds(model); sp.CalculatePageBounds(model);
Console.WriteLine(); return sp;
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();
} }
#region Setup/Teardown #region Setup/Teardown

Loading…
Cancel
Save