Browse Source

Small changes from FxCop, modifid ConnectionObject.cs

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1125 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Peter Forstmeier 20 years ago
parent
commit
c247d4b9a4
  1. 72
      src/AddIns/Misc/SharpReport/SharpReport/Designer/Ruler/ctrlRuler.cs
  2. 2
      src/AddIns/Misc/SharpReport/SharpReport/ReportItems/Functions/MiscFunctions/PageNumber.cs
  3. 8
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseDataItem.cs
  4. 8
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseFunction.cs
  5. 4
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportObject.cs
  6. 25
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Functions/BasePageNumber.cs
  7. 14
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Functions/BaseToday.cs
  8. 1
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseCircleItem.cs
  9. 1
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseLineItem.cs
  10. 1
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseRectangleItem.cs
  11. 17
      src/AddIns/Misc/SharpReport/SharpReportCore/Collections/Collections.cs
  12. 52
      src/AddIns/Misc/SharpReport/SharpReportCore/ConnectionObject.cs
  13. 6
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/Comparer/GroupComparer.cs
  14. 6
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/Comparer/SortComparer.cs
  15. 3
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListHandling/ExtendedPropertyDescriptor.cs
  16. 10
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListHandling/SharpArrayList.cs
  17. 3
      src/AddIns/Misc/SharpReport/SharpReportCore/Factories/BaseItemFactory.cs
  18. 16
      src/AddIns/Misc/SharpReport/SharpReportCore/Factories/DisplayNameAttribute.cs
  19. 18
      src/AddIns/Misc/SharpReport/SharpReportCore/Factories/RendererFactory.cs
  20. 4
      src/AddIns/Misc/SharpReport/SharpReportCore/Factories/SectionFactory.cs
  21. 48
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractRenderer.cs
  22. 10
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Graphics/EllipseShape.cs
  23. 7
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Graphics/LineShape.cs
  24. 14
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Graphics/RectangleShape.cs
  25. 66
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/PrintingUtilities.cs
  26. 14
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs
  27. 1
      src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportCore.csproj
  28. 27
      src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportEngine.cs
  29. 16
      src/AddIns/Misc/SharpReport/SharpReportCore/Visitors/LoadModelVisitor.cs

72
src/AddIns/Misc/SharpReport/SharpReport/Designer/Ruler/ctrlRuler.cs

@ -111,25 +111,20 @@ namespace Ruler
endValue = paperSize.Height; endValue = paperSize.Height;
} }
try {
int i = 0;
int drawPos = 0;
while (i < this.Height) {
drawPos = i * bigStep;
g.DrawString ((i + start).ToString(),this.Font,brush,3,drawPos);
Line (g,pen,0,drawPos,bLine,drawPos);
Line (g,pen,
0,drawPos - smallStep,
sLine,drawPos - smallStep);
i ++;
}
} catch (Exception e) { int i = 0;
MessageBox.Show (e.Message); int drawPos = 0;
} finally { while (i < this.Height) {
pen.Dispose(); drawPos = i * bigStep;
brush.Dispose(); g.DrawString ((i + start).ToString(),this.Font,brush,3,drawPos);
Line (g,pen,0,drawPos,bLine,drawPos);
Line (g,pen,
0,drawPos - smallStep,
sLine,drawPos - smallStep);
i ++;
} }
pen.Dispose();
brush.Dispose();
} }
void PaintHorizontal (Graphics g){ void PaintHorizontal (Graphics g){
@ -166,38 +161,29 @@ namespace Ruler
g.DrawRectangle (pen,0,0,(this.Width - 1) * size.Width,(this.Height - 1) * size.Width); g.DrawRectangle (pen,0,0,(this.Width - 1) * size.Width,(this.Height - 1) * size.Width);
} }
try {
int i = 0;
int drawPos = 0;
while (i < (int)((endValue / 10) + 1)) { int i = 0;
drawPos = i * bigStep; int drawPos = 0;
g.DrawString ((i + start).ToString(),this.Font,brush,drawPos,sLine);
Line (g,pen,drawPos,0,i * bigStep,bLine); while (i < (int)((endValue / 10) + 1)) {
Line (g,pen,drawPos - smallStep,0,drawPos - smallStep,sLine); drawPos = i * bigStep;
i ++; g.DrawString ((i + start).ToString(),this.Font,brush,drawPos,sLine);
} Line (g,pen,drawPos,0,i * bigStep,bLine);
// MarginMarker Line (g,pen,drawPos - smallStep,0,drawPos - smallStep,sLine);
if (leftMargin > 0) { i ++;
}
// MarginMarker
if (leftMargin > 0) {
// g.DrawString ("L",this.Font,brush,leftMargin * size.Width,sLine); // g.DrawString ("L",this.Font,brush,leftMargin * size.Width,sLine);
// Line (g, // Line (g,
// (int)(leftMargin * size.Width),0, // (int)(leftMargin * size.Width),0,
// (int)(leftMargin * size.Width),bLine); // (int)(leftMargin * size.Width),bLine);
Line (g, Line (g,
(int)(leftMargin),0, (int)(leftMargin),0,
(int)(leftMargin),bLine); (int)(leftMargin),bLine);
}
// if (rightMargin > 0) {
// g.DrawString ("R",font,brush,leftMargin * size.Width,sLine);
// }
} catch (Exception e) {
MessageBox.Show (e.Message);
} finally {
pen.Dispose();
brush.Dispose();
} }
pen.Dispose();
brush.Dispose();
} }
#endregion #endregion

2
src/AddIns/Misc/SharpReport/SharpReport/ReportItems/Functions/MiscFunctions/PageNumber.cs

@ -51,9 +51,7 @@ namespace SharpReport.ReportItems.Functions {
GrapFromBase(); GrapFromBase();
this.initDone = true; this.initDone = true;
} }
private void tt (object sender, PropertyChangedEventArgs e) {
}
private void GrapFromBase() { private void GrapFromBase() {
this.visualControl.SuspendLayout(); this.visualControl.SuspendLayout();
visualControl.StringFormat = base.StandartStringFormat; visualControl.StringFormat = base.StandartStringFormat;

8
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseDataItem.cs

@ -43,12 +43,12 @@ namespace SharpReportCore {
this.columnName = columnName; this.columnName = columnName;
} }
public override void Render(SharpReportCore.ReportPageEventArgs e) { public override void Render(SharpReportCore.ReportPageEventArgs rpea) {
// this.DbValue is formatted in the BeforePrintEvent catched in AbstractRenderer // this.DbValue is formatted in the BeforePrintEvent catched in AbstractRenderer
string formattedString = base.FireFormatOutput(this.dbValue,this.FormatString,""); string formattedString = base.FireFormatOutput(this.dbValue,this.FormatString,"");
RectangleF rect = base.PrepareRectangle (e,formattedString); RectangleF rect = base.PrepareRectangle (rpea,formattedString);
base.PrintTheStuff (e,formattedString,rect); base.PrintTheStuff (rpea,formattedString,rect);
base.NotiyfyAfterPrint (e.LocationAfterDraw); base.NotiyfyAfterPrint (rpea.LocationAfterDraw);
} }
public override string ToString() { public override string ToString() {

8
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseFunction.cs

@ -31,9 +31,15 @@ namespace SharpReportCore {
this.localisedName = friendlyName; this.localisedName = friendlyName;
} }
public override string ToString()
{
return "BaseFunction";
}
#region properties #region properties
public virtual string LocalisedName { public string LocalisedName {
get { get {
return localisedName; return localisedName;
} }

4
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportObject.cs

@ -34,7 +34,7 @@ namespace SharpReportCore {
private bool canShrink ; private bool canShrink ;
private bool pageBreakBefore; private bool pageBreakBefore;
private bool pageBreakAfter; private bool pageBreakAfter;
private bool suspend = true; private bool suspend;
private Size size; private Size size;
private Point location; private Point location;
@ -51,7 +51,7 @@ namespace SharpReportCore {
#endregion #endregion
public BaseReportObject() { public BaseReportObject() {
suspend = false;
} }

25
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Functions/BasePageNumber.cs

@ -30,41 +30,32 @@ namespace SharpReportCore {
} }
public override void Render(ReportPageEventArgs e) { public override void Render(ReportPageEventArgs rpea) {
base.Render(e); base.Render(rpea);
string formattedString = base.FireFormatOutput(e.PageNumber.ToString(CultureInfo.InvariantCulture), string formattedString = base.FireFormatOutput(rpea.PageNumber.ToString(CultureInfo.InvariantCulture),
base.FormatString,""); base.FormatString,"");
RectangleF rect = base.PrepareRectangle (e,formattedString); RectangleF rect = base.PrepareRectangle (rpea,formattedString);
//Printout the textpart //Printout the textpart
base.PrintTheStuff (e,this.Text,rect); base.PrintTheStuff (rpea,this.Text,rect);
//here we print the functionpart //here we print the functionpart
StringFormat fmt = StandartStringFormat; StringFormat fmt = StandartStringFormat;
fmt.Alignment = StringAlignment.Far; fmt.Alignment = StringAlignment.Far;
fmt.LineAlignment = StringAlignment.Near; fmt.LineAlignment = StringAlignment.Near;
e.PrintPageEventArgs.Graphics.DrawString(e.PageNumber.ToString(CultureInfo.InvariantCulture), rpea.PrintPageEventArgs.Graphics.DrawString(rpea.PageNumber.ToString(CultureInfo.InvariantCulture),
this.Font, this.Font,
Brushes.Black, Brushes.Black,
rect, rect,
fmt); fmt);
base.NotiyfyAfterPrint (e.LocationAfterDraw); base.NotiyfyAfterPrint (rpea.LocationAfterDraw);
} }
public override string ToString() { public override string ToString() {
return "PageNumber"; return "BasePageNumber";
} }
public override string LocalisedName {
get {
return base.LocalisedName;
}
}
} }
} }

14
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Functions/BaseToday.cs

@ -26,33 +26,33 @@ namespace SharpReportCore {
} }
public override void Render(ReportPageEventArgs e) { public override void Render(ReportPageEventArgs rpea) {
base.Render(e); base.Render(rpea);
string formattedString = FormatAsDate(System.DateTime.Now.ToString(),base.FormatString); string formattedString = FormatAsDate(System.DateTime.Now.ToString(),base.FormatString);
RectangleF rect = base.PrepareRectangle (e,formattedString); RectangleF rect = base.PrepareRectangle (rpea,formattedString);
//Printout the textPart //Printout the textPart
base.PrintTheStuff (e,this.Text,rect); base.PrintTheStuff (rpea,this.Text,rect);
//here we print the functionpart allway's with Stringalignment.Far //here we print the functionpart allway's with Stringalignment.Far
StringFormat fmt = StandartStringFormat; StringFormat fmt = StandartStringFormat;
fmt.Alignment = StringAlignment.Far; fmt.Alignment = StringAlignment.Far;
fmt.LineAlignment = StringAlignment.Near; fmt.LineAlignment = StringAlignment.Near;
e.PrintPageEventArgs.Graphics.DrawString(formattedString, rpea.PrintPageEventArgs.Graphics.DrawString(formattedString,
this.Font, this.Font,
Brushes.Black, Brushes.Black,
rect, rect,
fmt); fmt);
// goon // goon
base.NotiyfyAfterPrint (e.LocationAfterDraw); base.NotiyfyAfterPrint (rpea.LocationAfterDraw);
} }
public override string ToString() { public override string ToString() {
return "Today"; return "BaseToday";
} }

1
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseCircleItem.cs

@ -27,7 +27,6 @@ namespace SharpReportCore {
public override void Render(ReportPageEventArgs rpea) { public override void Render(ReportPageEventArgs rpea) {
base.Render (rpea); base.Render (rpea);
SizeF measureSize = base.MeasureReportItem (rpea,this);
RectangleF rect = base.DrawingRectangle (rpea,this.Size); RectangleF rect = base.DrawingRectangle (rpea,this.Size);
shape.FillShape(rpea.PrintPageEventArgs.Graphics, shape.FillShape(rpea.PrintPageEventArgs.Graphics,

1
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseLineItem.cs

@ -30,7 +30,6 @@ namespace SharpReportCore {
public override void Render(ReportPageEventArgs rpea) { public override void Render(ReportPageEventArgs rpea) {
base.Render (rpea); base.Render (rpea);
SizeF measureSize = base.MeasureReportItem (rpea,this);
RectangleF rect = base.DrawingRectangle (rpea,this.Size); RectangleF rect = base.DrawingRectangle (rpea,this.Size);
shape.DrawShape (rpea.PrintPageEventArgs.Graphics, shape.DrawShape (rpea.PrintPageEventArgs.Graphics,
new BaseLine (this.ForeColor,base.DashStyle,base.Thickness), new BaseLine (this.ForeColor,base.DashStyle,base.Thickness),

1
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseRectangleItem.cs

@ -34,7 +34,6 @@ namespace SharpReportCore {
public override void Render(ReportPageEventArgs rpea) { public override void Render(ReportPageEventArgs rpea) {
base.Render(rpea); base.Render(rpea);
SizeF measureSize = base.MeasureReportItem (rpea,this);
RectangleF rect = base.DrawingRectangle (rpea,this.Size); RectangleF rect = base.DrawingRectangle (rpea,this.Size);
shape.FillShape(rpea.PrintPageEventArgs.Graphics, shape.FillShape(rpea.PrintPageEventArgs.Graphics,

17
src/AddIns/Misc/SharpReport/SharpReportCore/Collections/Collections.cs

@ -36,21 +36,21 @@ namespace SharpReportCore{
/// (Line by Line) /// (Line by Line)
/// </summary> /// </summary>
public class LocationSorter : IComparer<IItemRenderer> { public class LocationSorter : IComparer<IItemRenderer> {
public int Compare(IItemRenderer left, IItemRenderer right){ public int Compare(IItemRenderer x, IItemRenderer y){
if (left == null){ if (x == null){
if (right == null){ if (y == null){
return 0; return 0;
} }
return -1; return -1;
} }
if (right == null){ if (y == null){
return 1; return 1;
} }
if (left.Location.Y == right.Location.Y){ if (x.Location.Y == y.Location.Y){
return left.Location.X - right.Location.X; return x.Location.X - y.Location.X;
} }
return left.Location.Y - right.Location.Y; return x.Location.Y - y.Location.Y;
} }
} }
@ -68,9 +68,6 @@ namespace SharpReportCore{
public void SortByLocation () { public void SortByLocation () {
if (this.Count > 1) { if (this.Count > 1) {
this.Sort(new LocationSorter()); this.Sort(new LocationSorter());
for (int i = 0;i < this.Count ; i ++) {
IItemRenderer col = this[i];
}
} }
} }

52
src/AddIns/Misc/SharpReport/SharpReportCore/ConnectionObject.cs

@ -9,6 +9,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
using System; using System;
using System.Data; using System.Data;
using System.Data.Common;
using System.Data.OleDb; using System.Data.OleDb;
/// <summary> /// <summary>
@ -22,64 +23,39 @@ using System.Data.OleDb;
namespace SharpReportCore { namespace SharpReportCore {
public class ConnectionObject : object,IDisposable { public class ConnectionObject : object,IDisposable {
IDbConnection connection; IDbConnection connection;
string password; OleDbConnectionStringBuilder oleDbConnectionStringBuilder;
string username;
string connectionString; string connectionString;
public ConnectionObject(string connectionString):this(connectionString,"","") { public ConnectionObject(string connectionString) {
}
public ConnectionObject(string connectionString, string password, string username)
{
if (String.IsNullOrEmpty(connectionString)) { if (String.IsNullOrEmpty(connectionString)) {
throw new ArgumentNullException("connectionString"); throw new ArgumentNullException("connectionString");
} }
this.connectionString = connectionString; this.connectionString = connectionString;
this.password = password;
this.username = username;
this.connection = new OleDbConnection (this.connectionString); this.connection = new OleDbConnection (this.connectionString);
} }
public ConnectionObject(IDbConnection connection, string password, string username) public ConnectionObject( OleDbConnectionStringBuilder oleDbConnectionStringBuilder){
{ this.oleDbConnectionStringBuilder = oleDbConnectionStringBuilder;
try {
this.connection = new OleDbConnection (this.oleDbConnectionStringBuilder.ConnectionString);
} catch (Exception ) {
throw;
}
}
public ConnectionObject(IDbConnection connection){
this.connection = connection; this.connection = connection;
this.password = password;
this.username = username;
this.connectionString = this.connection.ConnectionString; this.connectionString = this.connection.ConnectionString;
} }
public IDbConnection Connection { public IDbConnection Connection {
get { get {
return connection; return connection;
} }
set {
connection = value;
}
}
public string Password {
get {
return password;
}
set {
password = value;
}
}
public string Username {
get {
return username;
}
set {
username = value;
}
} }
// public string ConnectionString {
// get {
// return connectionString;
// }
// }
public void Dispose(){ public void Dispose(){
if (this.connection != null) { if (this.connection != null) {
if (this.connection.State == ConnectionState.Open) { if (this.connection.State == ConnectionState.Open) {

6
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/Comparer/GroupComparer.cs

@ -92,9 +92,9 @@ namespace SharpReportCore {
public override int CompareTo(object value) { public override int CompareTo(object obj) {
base.CompareTo(value); base.CompareTo(obj);
return this.CompareTo((GroupComparer)value); return this.CompareTo((GroupComparer)obj);
} }

6
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/Comparer/SortComparer.cs

@ -83,9 +83,9 @@ namespace SharpReportCore {
// Gleich Werte, dann Index bercksichtigen // Gleich Werte, dann Index bercksichtigen
return this.ListIndex.CompareTo(value.ListIndex); return this.ListIndex.CompareTo(value.ListIndex);
} }
public override int CompareTo(object value) { public override int CompareTo(object obj) {
base.CompareTo(value); base.CompareTo(obj);
return this.CompareTo((SortComparer)value); return this.CompareTo((SortComparer)obj);
} }

3
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListHandling/ExtendedPropertyDescriptor.cs

@ -8,7 +8,7 @@ namespace SharpReportCore {
/// This class supports data binding /// This class supports data binding
/// </summary> /// </summary>
public class SharpPropertyDescriptor : PropertyDescriptor{ public class SharpPropertyDescriptor : PropertyDescriptor{
bool readOnly = false; bool readOnly;
Type componentType; Type componentType;
Type propertyType; Type propertyType;
PropertyInfo prop; PropertyInfo prop;
@ -18,6 +18,7 @@ namespace SharpReportCore {
{ {
this.componentType = componentType; this.componentType = componentType;
this.propertyType = propertyType; this.propertyType = propertyType;
this.readOnly= false;
} }

10
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListHandling/SharpArrayList.cs

@ -225,20 +225,20 @@ namespace SharpReportCore
#endregion #endregion
#region overrides #region overrides
public override int Add(object val) { public override int Add(object value) {
if (this.elementType.GetType().IsAssignableFrom (val.GetType())) { if (this.elementType.GetType().IsAssignableFrom (value.GetType())) {
System.Console.WriteLine("type ok"); System.Console.WriteLine("type ok");
} }
if ((val.GetType().IsSubclassOf(this.elementType))||( val.GetType() == this.elementType)){ if ((value.GetType().IsSubclassOf(this.elementType))||( value.GetType() == this.elementType)){
if (this.allowNew) { if (this.allowNew) {
int i = base.Add(val); int i = base.Add(value);
this.OnListChange (new ListChangedEventArgs(ListChangedType.ItemAdded,i)); this.OnListChange (new ListChangedEventArgs(ListChangedType.ItemAdded,i));
return i; return i;
} else { } else {
throw new NotSupportedException("SharpArrayList:Add(object)"); throw new NotSupportedException("SharpArrayList:Add(object)");
} }
} else { } else {
string str = String.Format("Add:Wrong Type {0} {1}",this.elementType,val.GetType()); string str = String.Format("Add:Wrong Type {0} {1}",this.elementType,value.GetType());
throw new ArgumentException(str); throw new ArgumentException(str);
} }
} }

3
src/AddIns/Misc/SharpReport/SharpReportCore/Factories/BaseItemFactory.cs

@ -33,7 +33,8 @@ namespace SharpReportCore {
} }
public new BaseReportItem Create (string name){ public new BaseReportItem Create (string name){
if (String.IsNullOrEmpty(name)) { if (String.IsNullOrEmpty(name)) {
throw new ArgumentNullException("name"); String str = String.Format("<{0}>",name);
throw new UnkownItemException(str);
} }
if (name.LastIndexOf('.') > 0) { if (name.LastIndexOf('.') > 0) {
StringBuilder b = new StringBuilder (name); StringBuilder b = new StringBuilder (name);

16
src/AddIns/Misc/SharpReport/SharpReportCore/Factories/DisplayNameAttribute.cs

@ -1,16 +1,16 @@
using System; using System;
namespace SharpReportCore namespace SharpReportCore{
{
public class DisplayNameAttribute : Attribute
{ public sealed class DisplayNameAttribute : Attribute{
string name; string name;
public string Name
{ public string Name{
get { return name; } get { return name; }
} }
public DisplayNameAttribute(string name)
{ public DisplayNameAttribute(string name){
this.name = name; this.name = name;
} }
} }

18
src/AddIns/Misc/SharpReport/SharpReportCore/Factories/RendererFactory.cs

@ -32,15 +32,17 @@ namespace SharpReportCore {
typeof (AbstractRenderer)){ typeof (AbstractRenderer)){
} }
public AbstractRenderer Create(ReportModel model,DataManager container) { public AbstractRenderer Create(ReportModel model,DataManager container) {
switch (model.ReportSettings.ReportType) { if (model != null) {
case GlobalEnums.enmReportType.FormSheet :{ switch (model.ReportSettings.ReportType) {
return new RenderFormSheetReport(model); case GlobalEnums.enmReportType.FormSheet :{
} return new RenderFormSheetReport(model);
case GlobalEnums.enmReportType.DataReport:{ }
return new RenderDataReport(model,container); case GlobalEnums.enmReportType.DataReport:{
} return new RenderDataReport(model,container);
}
}
} }
return null; throw new MissingModelException();
} }
} }
} }

4
src/AddIns/Misc/SharpReport/SharpReportCore/Factories/SectionFactory.cs

@ -27,6 +27,10 @@ namespace SharpReportCore {
} }
public new BaseSection Create(string name) { public new BaseSection Create(string name) {
if (String.IsNullOrEmpty(name)) {
String str = String.Format("<{0}>",name);
throw new UnkownItemException(str);
}
return new BaseSection(name); return new BaseSection(name);
} }

48
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractRenderer.cs

@ -55,6 +55,9 @@ namespace SharpReportCore {
protected AbstractRenderer(ReportModel model){ protected AbstractRenderer(ReportModel model){
if (model == null) {
throw new MissingModelException();
}
this.reportSettings = model.ReportSettings; this.reportSettings = model.ReportSettings;
this.sections = model.SectionCollection; this.sections = model.SectionCollection;
Init(); Init();
@ -86,16 +89,18 @@ namespace SharpReportCore {
protected int CalculateDrawAreaHeight(ReportPageEventArgs rpea){ protected int CalculateDrawAreaHeight(ReportPageEventArgs rpea){
if (rpea == null) {
throw new ArgumentNullException("rpea");
}
int to = rpea.PrintPageEventArgs.MarginBounds.Height ; int to = rpea.PrintPageEventArgs.MarginBounds.Height ;
if (rpea.PageNumber ==1) { if (rpea.PageNumber ==1) {
to -= sections[Convert.ToInt16(GlobalEnums.enmSection.ReportHeader,CultureInfo.InvariantCulture)].Size.Height; to -= sections[Convert.ToInt16(GlobalEnums.enmSection.ReportHeader,CultureInfo.InvariantCulture)].Size.Height;
} }
to -= sections[Convert.ToInt16(GlobalEnums.enmSection.ReportPageHeader)].Size.Height; to -= sections[Convert.ToInt16(GlobalEnums.enmSection.ReportPageHeader,CultureInfo.InvariantCulture)].Size.Height;
to -= sections[Convert.ToInt16(GlobalEnums.enmSection.ReportPageFooter)].Size.Height; to -= sections[Convert.ToInt16(GlobalEnums.enmSection.ReportPageFooter,CultureInfo.InvariantCulture)].Size.Height;
return to; return to;
} }
@ -103,7 +108,13 @@ namespace SharpReportCore {
/// Use this function to draw controlling rectangles /// Use this function to draw controlling rectangles
/// </summary> /// </summary>
protected void DebugRectangle (ReportPageEventArgs e,Rectangle rect) { protected void DebugRectangle (ReportPageEventArgs rpea,Rectangle rectangle) {
// if (rpea == null) {
// throw new ArgumentNullException("rpea");
// }
// if (rectangle == null) {
// throw new ArgumentNullException("rectangle");
// }
// e.PrintPageEventArgs.Graphics.DrawRectangle (Pens.Black,rect); // e.PrintPageEventArgs.Graphics.DrawRectangle (Pens.Black,rect);
} }
@ -203,25 +214,35 @@ namespace SharpReportCore {
// Called by FormatOutPutEvent of the BaseReportItem // Called by FormatOutPutEvent of the BaseReportItem
void FormatBaseReportItem (object sender, FormatOutputEventArgs e) { void FormatBaseReportItem (object sender, FormatOutputEventArgs rpea) {
if (sender is BaseDataItem) { BaseDataItem baseDataItem = sender as BaseDataItem;
BaseDataItem i = (BaseDataItem)sender; if (baseDataItem != null) {
e.FormatedValue = defaultFormatter.FormatItem (i); rpea.FormatedValue = defaultFormatter.FormatItem (baseDataItem);
} }
// if (sender is BaseDataItem) {
// BaseDataItem i = (BaseDataItem)sender;
// e.FormatedValue = defaultFormatter.FormatItem (i);
// }
} }
#region privates #region privates
protected void FitSectionToItems (BaseSection section,ReportPageEventArgs e){ protected void FitSectionToItems (BaseSection section,ReportPageEventArgs rpea){
Rectangle orgRect = new Rectangle (e.PrintPageEventArgs.MarginBounds.Left, if (section == null) {
throw new ArgumentNullException("section");
}
if (rpea == null) {
throw new ArgumentNullException("rpea");
}
Rectangle orgRect = new Rectangle (rpea.PrintPageEventArgs.MarginBounds.Left,
section.SectionOffset, section.SectionOffset,
e.PrintPageEventArgs.MarginBounds.Width, rpea.PrintPageEventArgs.MarginBounds.Width,
section.Size.Height); section.Size.Height);
if ((section.CanGrow == true)||(section.CanShrink == true)) { if ((section.CanGrow == true)||(section.CanShrink == true)) {
AdjustSection (section,e); AdjustSection (section,rpea);
} else { } else {
AdjustItems (section,e); AdjustItems (section,rpea);
} }
} }
@ -393,6 +414,7 @@ namespace SharpReportCore {
} }
} }
#endregion #endregion
#region IDispoable #region IDispoable
public void Dispose(){ public void Dispose(){
if (this.reportDocument != null) { if (this.reportDocument != null) {

10
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Graphics/EllipseShape.cs

@ -37,18 +37,18 @@ namespace SharpReportCore {
} }
public override void DrawShape(Graphics g, BaseLine baseLine, RectangleF rectangle) { public override void DrawShape(Graphics graphics, BaseLine baseLine, RectangleF rectangle) {
base.DrawShape(g,baseLine,rectangle); base.DrawShape(graphics,baseLine,rectangle);
using (Pen p = new Pen(baseLine.Color,baseLine.Thickness)) { using (Pen p = new Pen(baseLine.Color,baseLine.Thickness)) {
p.DashStyle = baseLine.DashStyle; p.DashStyle = baseLine.DashStyle;
g.DrawEllipse(p, graphics.DrawEllipse(p,
rectangle); rectangle);
} }
} }
public override void FillShape(Graphics g, AbstractFillPattern fillPattern, RectangleF rectangle) { public override void FillShape(Graphics graphics, AbstractFillPattern fillPattern, RectangleF rectangle) {
g.FillEllipse(fillPattern.Brush, graphics.FillEllipse(fillPattern.Brush,
rectangle); rectangle);
} }

7
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Graphics/LineShape.cs

@ -38,13 +38,13 @@ namespace SharpReportCore {
public LineShape() { public LineShape() {
} }
public override void DrawShape(Graphics g, BaseLine baseLine, RectangleF rectangle) { public override void DrawShape(Graphics graphics, BaseLine baseLine, RectangleF rectangle) {
base.DrawShape(g,baseLine,rectangle); base.DrawShape(graphics,baseLine,rectangle);
using (Pen p = new Pen(baseLine.Color,baseLine.Thickness)) { using (Pen p = new Pen(baseLine.Color,baseLine.Thickness)) {
p.DashStyle = baseLine.DashStyle; p.DashStyle = baseLine.DashStyle;
float halfRect = rectangle.Top + (rectangle.Height / 2); float halfRect = rectangle.Top + (rectangle.Height / 2);
g.DrawLine (p, graphics.DrawLine (p,
rectangle.X, rectangle.X,
halfRect, halfRect,
rectangle.X + rectangle.Width, rectangle.X + rectangle.Width,
@ -52,5 +52,6 @@ namespace SharpReportCore {
} }
} }
} }
} }

14
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Graphics/RectangleShape.cs

@ -35,24 +35,24 @@ namespace SharpReportCore {
} }
public override void DrawShape(Graphics g, BaseLine baseLine, RectangleF rectangle) { public override void DrawShape(Graphics graphics, BaseLine baseLine, RectangleF rectangle) {
base.DrawShape(g,baseLine,rectangle); base.DrawShape(graphics,baseLine,rectangle);
using (Pen p = new Pen(baseLine.Color,baseLine.Thickness)) { using (Pen p = new Pen(baseLine.Color,baseLine.Thickness)) {
p.DashStyle = baseLine.DashStyle; p.DashStyle = baseLine.DashStyle;
g.DrawRectangle (p,rectangle.Left, graphics.DrawRectangle (p,rectangle.Left,
rectangle.Top, rectangle.Top,
rectangle.Width, rectangle.Width,
rectangle.Height); rectangle.Height);
} }
} }
public override void FillShape(Graphics g, AbstractFillPattern fillPattern, RectangleF rectangle) { public override void FillShape(Graphics graphics, AbstractFillPattern fillPattern, RectangleF rectangle) {
g.FillRectangle(fillPattern.Brush, graphics.FillRectangle(fillPattern.Brush,
rectangle); rectangle);
} }
public override void FillShape(Graphics g, Brush brush, RectangleF rectangle) { public override void FillShape(Graphics graphics, Brush brush, RectangleF rectangle) {
g.FillRectangle(brush, rectangle); graphics.FillRectangle(brush, rectangle);
} }

66
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/PrintingUtilities.cs

@ -1,66 +0,0 @@
//
// SharpDevelop ReportEditor
//
// Copyright (C) 2005 Peter Forstmeier
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Peter Forstmeier (Peter.Forstmeier@t-online.de)
using System;
using System.Drawing;
/// <summary>
/// Utility Class to help with printing
/// </summary>
/// <remarks>
/// created by - Forstmeier Peter
/// created on - 26.03.2005 10:08:23
/// </remarks>
namespace SharpReportCore {
public class a_PrintingUtilities : object {
/// <summary>
/// Measure the Size of the String
/// </summary>
/// <param name="item">ReportItem to Measure</param>
/// <param name="e">ReportPageEventArgs</param>
/// <returns>SizeF</returns>
public static System.Drawing.SizeF a_MeasureReportItem(IItemRenderer item,
ReportPageEventArgs e) {
SizeF sizeF = new SizeF ();
BaseTextItem myItem = item as BaseTextItem;
if (myItem != null) {
string str = String.Empty;
if (item is BaseTextItem) {
BaseTextItem it = item as BaseTextItem;
str = it.Text;
} else if(item is BaseDataItem) {
BaseDataItem it = item as BaseDataItem;
str = it.DbValue;
}
// TODO need a much better way
sizeF = e.PrintPageEventArgs.Graphics.MeasureString(str,
myItem.Font,
myItem.Size.Width,
GlobalValues.StandartStringFormat());
} else {
sizeF = new SizeF (item.Size.Width,item.Size.Height);
}
return sizeF;
}
}
}

14
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs

@ -68,19 +68,21 @@ namespace SharpReportCore {
} }
} }
protected override void BeginPrintPage(object sender, ReportPageEventArgs e) { protected override void BeginPrintPage(object sender, ReportPageEventArgs rpea) {
if (rpea == null) {
base.BeginPrintPage (sender,e); throw new ArgumentNullException("rpea");
}
base.BeginPrintPage (sender,rpea);
//Draw ReportHeader //Draw ReportHeader
currentPoint = base.DrawReportHeader (e); currentPoint = base.DrawReportHeader (rpea);
if (base.CurrentSection.PageBreakAfter) { if (base.CurrentSection.PageBreakAfter) {
base.PageBreak(e,base.CurrentSection); base.PageBreak(rpea,base.CurrentSection);
base.CurrentSection.PageBreakAfter = false; base.CurrentSection.PageBreakAfter = false;
return; return;
} }
//Draw Pageheader //Draw Pageheader
currentPoint = base.DrawPageheader (currentPoint,e); currentPoint = base.DrawPageheader (currentPoint,rpea);
base.DetailStart = new Point ((int)currentPoint.X,(int)currentPoint.Y); base.DetailStart = new Point ((int)currentPoint.X,(int)currentPoint.Y);
} }

1
src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportCore.csproj

@ -102,7 +102,6 @@
<Compile Include="Printing\Text\TextDrawer.cs" /> <Compile Include="Printing\Text\TextDrawer.cs" />
<Compile Include="Printing\AbstractRenderer.cs" /> <Compile Include="Printing\AbstractRenderer.cs" />
<Compile Include="Printing\FormatOutputEventArgs.cs" /> <Compile Include="Printing\FormatOutputEventArgs.cs" />
<Compile Include="Printing\PrintingUtilities.cs" />
<Compile Include="Printing\RenderDataReport.cs" /> <Compile Include="Printing\RenderDataReport.cs" />
<Compile Include="Printing\RenderFormSheetReport.cs" /> <Compile Include="Printing\RenderFormSheetReport.cs" />
<Compile Include="Printing\ReportDocument.cs" /> <Compile Include="Printing\ReportDocument.cs" />

27
src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportEngine.cs

@ -59,7 +59,7 @@ namespace SharpReportCore {
if (this.connectionObject == null) { if (this.connectionObject == null) {
if (model.ReportSettings.ConnectionString != "") { if (model.ReportSettings.ConnectionString != "") {
this.connectionObject = new ConnectionObject (model.ReportSettings.ConnectionString,"",""); this.connectionObject = new ConnectionObject (model.ReportSettings.ConnectionString);
} }
if (reportParameters != null) { if (reportParameters != null) {
@ -113,8 +113,11 @@ namespace SharpReportCore {
private void ApplyReportParameters (ReportModel model,ReportParameters parameters){ private void ApplyReportParameters (ReportModel model,ReportParameters parameters){
if ((model == null)||(parameters == null )){ if (model == null) {
throw new ArgumentNullException("SharpReportEngine:ApplyReportParameters"); throw new MissingModelException();
}
if (parameters == null ){
throw new ArgumentNullException("parameters");
} }
SetSqlParameters (model,parameters.SqlParameters); SetSqlParameters (model,parameters.SqlParameters);
@ -152,8 +155,8 @@ namespace SharpReportCore {
} }
} }
catch (System.Data.OleDb.OleDbException e) { catch (System.Data.OleDb.OleDbException) {
throw e; throw ;
} }
catch (Exception) { catch (Exception) {
throw; throw;
@ -261,7 +264,7 @@ namespace SharpReportCore {
protected AbstractRenderer AbstractRenderer (ReportModel model) { protected AbstractRenderer AbstractRenderer (ReportModel model) {
if (model == null) { if (model == null) {
throw new ArgumentNullException("PrintableDocument:ReportModel"); throw new MissingModelException();
} }
AbstractRenderer abstr = SetupStandartRenderer(model); AbstractRenderer abstr = SetupStandartRenderer(model);
return abstr; return abstr;
@ -274,8 +277,8 @@ namespace SharpReportCore {
/// this is an easy way to ask the report for desired paramaters</see></summary> /// this is an easy way to ask the report for desired paramaters</see></summary>
public ReportParameters LoadParameters (string fileName) { public ReportParameters LoadParameters (string fileName) {
if (fileName.Length == 0) { if (String.IsNullOrEmpty(fileName)) {
throw new ArgumentNullException("PreviewPushDataReport FileName"); throw new ArgumentNullException("fileName");
} }
ReportModel model = null; ReportModel model = null;
try { try {
@ -304,7 +307,7 @@ namespace SharpReportCore {
public void PreviewStandartReport (string fileName) { public void PreviewStandartReport (string fileName) {
if (fileName.Length == 0) { if (fileName.Length == 0) {
throw new ArgumentNullException("PreviewPushDataReport FileName"); throw new ArgumentNullException("fileName");
} }
PreviewStandartReport (fileName,null); PreviewStandartReport (fileName,null);
} }
@ -312,7 +315,7 @@ namespace SharpReportCore {
public void PreviewStandartReport (string fileName,ReportParameters reportParameters) { public void PreviewStandartReport (string fileName,ReportParameters reportParameters) {
if (fileName.Length == 0) { if (fileName.Length == 0) {
throw new ArgumentNullException("PreviewPushDataReport:FileName"); throw new ArgumentNullException("fileName");
} }
ReportModel model = null; ReportModel model = null;
@ -373,7 +376,7 @@ namespace SharpReportCore {
doc = renderer.ReportDocument; doc = renderer.ReportDocument;
using (PrintDialog dlg = new PrintDialog()) { using (PrintDialog dlg = new PrintDialog()) {
dlg.Document = doc; dlg.Document = doc;
MessageBox.Show (model.ReportSettings.UseStandartPrinter.ToString()); // MessageBox.Show (model.ReportSettings.UseStandartPrinter.ToString());
if (model.ReportSettings.UseStandartPrinter == true) { if (model.ReportSettings.UseStandartPrinter == true) {
dlg.Document.Print(); dlg.Document.Print();
} else { } else {
@ -497,7 +500,7 @@ namespace SharpReportCore {
/// <returns><see cref="ReportModel"></see></returns> /// <returns><see cref="ReportModel"></see></returns>
protected ReportModel ModelFromFile (string fileName) { protected ReportModel ModelFromFile (string fileName) {
if (fileName.Length == 0) { if (String.IsNullOrEmpty(fileName)) {
throw new ArgumentNullException("fileName"); throw new ArgumentNullException("fileName");
} }

16
src/AddIns/Misc/SharpReport/SharpReportCore/Visitors/LoadModelVisitor.cs

@ -38,21 +38,21 @@ namespace SharpReportCore {
#region overrides #region overrides
public override void Visit(ReportModel model) { public override void Visit(ReportModel reportModel) {
if (model != null) { if (reportModel == null) {
throw new MissingModelException();
} else {
XmlDocument xmlDoc; XmlDocument xmlDoc;
try { try {
xmlDoc = XmlHelper.OpenSharpReport (fileName); xmlDoc = XmlHelper.OpenSharpReport (fileName);
xmlFormReader = new XmlFormReader(); xmlFormReader = new XmlFormReader();
model.ReportSettings.SetSettings ((XmlElement)xmlDoc.DocumentElement.FirstChild); reportModel.ReportSettings.SetSettings ((XmlElement)xmlDoc.DocumentElement.FirstChild);
SetSections (xmlDoc); SetSections (xmlDoc);
} catch (Exception ) { } catch (Exception ) {
throw; throw;
} }
} else {
System.ArgumentNullException e = new System.ArgumentNullException ("LoadModelVisitor:Visit -> No valid Model");
throw e;
} }
} }
#endregion #endregion
@ -87,8 +87,8 @@ namespace SharpReportCore {
rpt.Visible = true; rpt.Visible = true;
rpt.ResumeLayout(); rpt.ResumeLayout();
} else { } else {
UnkownItemException e = new UnkownItemException(); String str = String.Format("< {0}>",ctrlElem.GetAttribute("basetype"));
throw e; throw new UnkownItemException(str);
} }
} catch (Exception ) { } catch (Exception ) {
throw; throw;

Loading…
Cancel
Save