Browse Source

Fixed http://community.sharpdevelop.net/forums/thread/8438.aspx and some changes from

FxCop

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1479 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Peter Forstmeier 19 years ago
parent
commit
2b9b0cde11
  1. 5
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseSection.cs
  2. 4
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/DataManager.cs
  3. 37
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractDataRenderer.cs
  4. 39
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractRenderer.cs
  5. 12
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Formatter/AbstractFormatter.cs
  6. 2
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Formatter/DefaultFormatter.cs
  7. 5
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Graphics/BaseShape.cs
  8. 6
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Graphics/Border.cs
  9. 4
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs
  10. 10
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderFormSheetReport.cs
  11. 11
      src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportEngine.cs
  12. 3
      src/AddIns/Misc/SharpReport/SharpReportCore/Xml/XmlHelper.cs
  13. 21
      src/AddIns/Misc/SharpReport/SharpReportWizard/WizardPanels/BaseSettingsPanel.cs

5
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseSection.cs

@ -33,11 +33,12 @@ namespace SharpReportCore { @@ -33,11 +33,12 @@ namespace SharpReportCore {
#region Constructors
public BaseSection(): base() {
this.Name = String.Empty;
// this.Name = String.Empty;
base.Name = String.Empty;
}
public BaseSection (string sectionName) :base(){
this.Name = sectionName;
base.Name = sectionName;
}
#endregion

4
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/DataManager.cs

@ -32,11 +32,8 @@ namespace SharpReportCore { @@ -32,11 +32,8 @@ namespace SharpReportCore {
ConnectionObject connectionObject;
IDbConnection connection;
IDataViewStrategy dataViewStrategy;
GroupSeperator groupSeperator;
public event EventHandler <ListChangedEventArgs> ListChanged;
// public event EventHandler <GroupChangedEventArgs> GroupChanged;
// public event EventHandler <EventArgs> GroupChanging;
/// <summary>
/// use this Constructor for PullDataReports
@ -287,7 +284,6 @@ namespace SharpReportCore { @@ -287,7 +284,6 @@ namespace SharpReportCore {
}
private void OnGroupChange (object sender,GroupChangedEventArgs e) {
this.groupSeperator = e.GroupSeperator;
this.NotifyGroupChanging();
}
#endregion

37
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractDataRenderer.cs

@ -52,22 +52,7 @@ namespace SharpReportCore{ @@ -52,22 +52,7 @@ namespace SharpReportCore{
return base.RenderSection(this.CurrentSection, rpea);
}
}
protected int old_DoItems (BaseSection section, ReportPageEventArgs rpea) {
IContainerItem container = null;
bool hasContainer = false;
foreach (BaseReportItem item in section.Items) {
container = item as IContainerItem;
if (container != null) {
hasContainer = true;
break;
}
}
if (hasContainer) {
return DoContainerControl(section,container,rpea);
} else {
return base.RenderSection(section, rpea);
}
}
private int DoContainerControl (BaseSection section,
IContainerItem container,
@ -115,16 +100,18 @@ namespace SharpReportCore{ @@ -115,16 +100,18 @@ namespace SharpReportCore{
#endregion
#region IDisposable
public override void Dispose()
{
if (this.dataManager != null) {
this.dataManager.Dispose();
this.dataManager = null;
}
if (this.navigator != null) {
this.navigator= null;
public override void Dispose(){
try {
if (this.dataManager != null) {
this.dataManager.Dispose();
this.dataManager = null;
}
if (this.navigator != null) {
this.navigator= null;
}
} finally {
base.Dispose();
}
base.Dispose();
}
#endregion
}

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

@ -88,6 +88,9 @@ namespace SharpReportCore { @@ -88,6 +88,9 @@ namespace SharpReportCore {
#endregion
protected void PageBreak(ReportPageEventArgs pea) {
if (pea == null) {
throw new ArgumentNullException("pea");
}
pea.PrintPageEventArgs.HasMorePages = true;
pea.ForceNewPage = true;
}
@ -129,25 +132,31 @@ namespace SharpReportCore { @@ -129,25 +132,31 @@ namespace SharpReportCore {
/// Calculates the rectangle wich can be used by Detail
/// </summary>
/// <returns></returns>
protected Rectangle DetailRectangle (ReportPageEventArgs e) {
protected Rectangle DetailRectangle (ReportPageEventArgs rpea) {
if (rpea == null) {
throw new ArgumentNullException("rpea");
}
sectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportDetail,
CultureInfo.InvariantCulture);
Rectangle rect = new Rectangle (e.PrintPageEventArgs.MarginBounds.Left,
Rectangle rect = new Rectangle (rpea.PrintPageEventArgs.MarginBounds.Left,
this.detailStart.Y ,
e.PrintPageEventArgs.MarginBounds.Width,
rpea.PrintPageEventArgs.MarginBounds.Width,
detailEnds.Y - detailStart.Y - (3 * gap));
return rect;
}
protected PointF MeasureReportHeader (ReportPageEventArgs e) {
protected PointF MeasureReportHeader (ReportPageEventArgs rpea) {
if (rpea == null) {
throw new ArgumentNullException("rpea");
}
PointF endAt = new PointF();
if (e.PageNumber == 1) {
if (rpea.PageNumber == 1) {
sectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportHeader,
CultureInfo.InvariantCulture);
if (this.CurrentSection.Items.Count > 0) {
this.CurrentSection.SectionOffset = reportSettings.DefaultMargins.Top;
FitSectionToItems (this.CurrentSection,e);
FitSectionToItems (this.CurrentSection,rpea);
endAt = new PointF (0,
reportSettings.DefaultMargins.Top + this.CurrentSection.Size.Height + Gap);
} else {
@ -162,18 +171,20 @@ namespace SharpReportCore { @@ -162,18 +171,20 @@ namespace SharpReportCore {
///</summary>
/// <param name="startAt">Section start at this PointF</param>
/// <param name="e">ReportPageEventArgs</param>
protected PointF MeasurePageHeader (PointF startat,ReportPageEventArgs e) {
protected PointF MeasurePageHeader (PointF startat,ReportPageEventArgs rpea) {
if (rpea == null) {
throw new ArgumentNullException("rpea");
}
sectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportPageHeader,
CultureInfo.InvariantCulture);
if (e.PageNumber == 1) {
if (rpea.PageNumber == 1) {
this.CurrentSection.SectionOffset = (int)startat.Y + Gap;
} else {
this.CurrentSection.SectionOffset = reportSettings.DefaultMargins.Top;
}
FitSectionToItems (this.CurrentSection,e);
FitSectionToItems (this.CurrentSection,rpea);
return new PointF (0,
this.CurrentSection.SectionOffset + this.CurrentSection.Size.Height + Gap);
}
@ -344,23 +355,23 @@ namespace SharpReportCore { @@ -344,23 +355,23 @@ namespace SharpReportCore {
}
protected virtual void ReportBegin (object sender,PrintEventArgs e) {
protected virtual void ReportBegin (object sender,PrintEventArgs pea) {
// System.Console.WriteLine("\tAbstract - ReportBegin");
}
protected virtual void PrintBodyStart (object sender,ReportPageEventArgs e) {
protected virtual void PrintBodyStart (object sender,ReportPageEventArgs rpea) {
// System.Console.WriteLine("\tAbstract - PrintBodyStart");
this.SectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportDetail,
CultureInfo.InvariantCulture);
}
protected virtual void PrintBodyEnd (object sender,ReportPageEventArgs e) {
protected virtual void PrintBodyEnd (object sender,ReportPageEventArgs rpea) {
// System.Console.WriteLine("\tAbstarct - PrintBodyEnd");
}
protected virtual void PrintPageEnd (object sender,ReportPageEventArgs e) {
protected virtual void PrintPageEnd (object sender,ReportPageEventArgs rpea) {
// System.Console.WriteLine("\tAbstract - PrintPageEnd");
// BaseSection section = null;
// section = CurrentSection;

12
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Formatter/AbstractFormatter.cs

@ -39,19 +39,17 @@ namespace SharpReportCore { @@ -39,19 +39,17 @@ namespace SharpReportCore {
}
protected bool CheckFormat (string format) {
if (format.Length > 0) {
return true;
} else {
if (String.IsNullOrEmpty(format)) {
return false;
}
}
return true;
}
protected bool CheckValue (string toFormat) {
if ((toFormat == null)||(toFormat.Length == 0) ) {
if (String.IsNullOrEmpty(toFormat)) {
return false;
} else {
return true;
}
return true;
}
}
}

2
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Formatter/DefaultFormatter.cs

@ -43,7 +43,7 @@ namespace SharpReportCore{ @@ -43,7 +43,7 @@ namespace SharpReportCore{
///<param name="item">A ReportDataItem</param>
///
public string FormatItem (BaseDataItem item) {
System.Console.WriteLine("FormatItem {0} / {1}",item.DataType,item.FormatString);
if (item == null) {
throw new ArgumentNullException("item");
}

5
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Graphics/BaseShape.cs

@ -33,11 +33,6 @@ namespace SharpReportCore { @@ -33,11 +33,6 @@ namespace SharpReportCore {
public abstract class BaseShape : object {
public BaseShape() {
}
public void FillShape (Graphics graphics, Brush brush,RectangleF rectangle) {
GraphicsPath path1 = this.CreatePath(rectangle);

6
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Graphics/Border.cs

@ -44,6 +44,9 @@ namespace SharpReportCore { @@ -44,6 +44,9 @@ namespace SharpReportCore {
}
public void DrawBorder (Graphics graphics, RectangleF rectangle) {
if (graphics == null) {
throw new ArgumentNullException("graphics");
}
using (Pen p = new Pen(baseLine.Color,baseLine.Thickness)) {
p.DashStyle = baseLine.DashStyle;
graphics.DrawRectangle (p,rectangle.Left,
@ -54,6 +57,9 @@ namespace SharpReportCore { @@ -54,6 +57,9 @@ namespace SharpReportCore {
}
public void DrawBorder (Graphics graphics, Rectangle rectangle ) {
if (graphics == null) {
throw new ArgumentNullException("graphics");
}
using (Pen p = new Pen(baseLine.Color,baseLine.Thickness)) {
p.DashStyle = baseLine.DashStyle;
graphics.DrawRectangle (p,rectangle);

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

@ -169,9 +169,9 @@ namespace SharpReportCore { @@ -169,9 +169,9 @@ namespace SharpReportCore {
base.ReportQueryPage (sender,qpea);
}
protected override void ReportBegin(object sender, PrintEventArgs rpea) {
protected override void ReportBegin(object sender, PrintEventArgs pea) {
System.Console.WriteLine("ReportBegin (BeginPrint)");
base.ReportBegin (sender,rpea);
base.ReportBegin (sender,pea);
base.DataManager.ListChanged += new EventHandler<ListChangedEventArgs> (OnListChanged);
dataNavigator = base.DataManager.GetNavigator;
dataNavigator.ListChanged += new EventHandler<ListChangedEventArgs> (OnListChanged);

10
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderFormSheetReport.cs

@ -158,14 +158,14 @@ namespace SharpReportCore { @@ -158,14 +158,14 @@ namespace SharpReportCore {
protected override void PrintBodyStart (object sender,ReportPageEventArgs rpea) {
base.PrintBodyStart (sender,rpea);
BaseSection section = base.CurrentSection;
section.SectionOffset = (int)this.currentPoint.Y + base.Gap;
// BaseSection section = base.CurrentSection;
base.CurrentSection.SectionOffset = (int)this.currentPoint.Y + base.Gap;
Rectangle detailRect = base.DetailRectangle (rpea);
FitSectionToItems (section,rpea);
FitSectionToItems (base.CurrentSection,rpea);
this.AddSectionEvents();
base.RenderSection (section,rpea);
base.RenderSection (base.CurrentSection,rpea);
this.RemoveSectionEvents();
}
/// <summary>

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

@ -59,7 +59,7 @@ namespace SharpReportCore { @@ -59,7 +59,7 @@ namespace SharpReportCore {
if (model.ReportSettings.ReportType != GlobalEnums.enmReportType.FormSheet) {
if (this.connectionObject == null) {
if (model.ReportSettings.ConnectionString != "") {
if (String.IsNullOrEmpty(model.ReportSettings.ConnectionString)) {
this.connectionObject = new ConnectionObject (model.ReportSettings.ConnectionString);
}
@ -229,6 +229,9 @@ namespace SharpReportCore { @@ -229,6 +229,9 @@ namespace SharpReportCore {
protected SharpReportCore.AbstractRenderer SetupPushDataRenderer (ReportModel model,
DataTable dataTable) {
if (model == null) {
throw new ArgumentNullException("model");
}
if (model.ReportSettings.ReportType != GlobalEnums.enmReportType.DataReport) {
throw new ArgumentException("SetupPushDataRenderer <No valid ReportModel>");
}
@ -305,7 +308,7 @@ namespace SharpReportCore { @@ -305,7 +308,7 @@ namespace SharpReportCore {
/// <param name="fileName">Path to ReportFile</param>
public void PreviewStandartReport (string fileName) {
if (fileName.Length == 0) {
if (String.IsNullOrEmpty(fileName)) {
throw new ArgumentNullException("fileName");
}
PreviewStandartReport (fileName,null);
@ -313,7 +316,7 @@ namespace SharpReportCore { @@ -313,7 +316,7 @@ namespace SharpReportCore {
public void PreviewStandartReport (string fileName,ReportParameters reportParameters) {
if (fileName.Length == 0) {
if (String.IsNullOrEmpty(fileName)) {
throw new ArgumentNullException("fileName");
}
@ -462,7 +465,7 @@ namespace SharpReportCore { @@ -462,7 +465,7 @@ namespace SharpReportCore {
/// <param name="fileName"></param>
/// <param name="dataTable"></param>
public void PrintPushDataReport (string fileName,DataTable dataTable) {
if (fileName.Length == 0) {
if (String.IsNullOrEmpty(fileName)) {
throw new ArgumentNullException("fileName");
}
if (dataTable == null) {

3
src/AddIns/Misc/SharpReport/SharpReportCore/Xml/XmlHelper.cs

@ -43,6 +43,9 @@ namespace SharpReportCore { @@ -43,6 +43,9 @@ namespace SharpReportCore {
/// <returns>"Report is SharpReport or not</returns>/returns>
///
public static bool IsSharpReport (XmlElement elem) {
if (elem == null) {
throw new ArgumentNullException("elem");
}
return (elem.Name.Equals (SharpReportCore.GlobalValues.SharpReportString));
}

21
src/AddIns/Misc/SharpReport/SharpReportWizard/WizardPanels/BaseSettingsPanel.cs

@ -30,7 +30,7 @@ namespace ReportGenerator{ @@ -30,7 +30,7 @@ namespace ReportGenerator{
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.TextBox txtReportName;
private System.Windows.Forms.ComboBox cboReportType;
// private System.Windows.Forms.ComboBox cboReportType;
private System.Windows.Forms.ComboBox cboGraphicsUnit;
private System.Windows.Forms.TextBox txtFileName;
private System.Windows.Forms.TextBox txtPath;
@ -118,11 +118,8 @@ namespace ReportGenerator{ @@ -118,11 +118,8 @@ namespace ReportGenerator{
void DoInit(){
txtFileName.Text = GlobalValues.SharpReportPlainFileName;
txtReportName.Text = GlobalValues.SharpReportStandartFileName;
cboReportType.Items.AddRange(Enum.GetNames (typeof(GlobalEnums.enmReportType)));
cboReportType.SelectedIndex = cboReportType.FindString(GlobalEnums.enmReportType.DataReport.ToString());
cboGraphicsUnit.Items.Add (GraphicsUnit.Millimeter);
cboGraphicsUnit.Items.Add (GraphicsUnit.Inch);
this.cboGraphicsUnit.Items.AddRange(Enum.GetNames(typeof (GraphicsUnit)));
cboGraphicsUnit.SelectedIndex = cboGraphicsUnit.FindString(GraphicsUnit.Millimeter.ToString());
this.radioPullModell.Checked = true;
@ -140,7 +137,8 @@ namespace ReportGenerator{ @@ -140,7 +137,8 @@ namespace ReportGenerator{
}
generator.Path = this.txtPath.Text;
generator.GraphicsUnit = (GraphicsUnit)Enum.Parse(typeof(GraphicsUnit),this.cboGraphicsUnit.Text);
generator.GraphicsUnit = (GraphicsUnit)Enum.Parse(typeof(GraphicsUnit),
this.cboGraphicsUnit.Text);
SetSuccessor (this,new EventArgs());
}
}
@ -204,7 +202,7 @@ namespace ReportGenerator{ @@ -204,7 +202,7 @@ namespace ReportGenerator{
this.txtPath = new System.Windows.Forms.TextBox();
this.txtFileName = new System.Windows.Forms.TextBox();
this.cboGraphicsUnit = new System.Windows.Forms.ComboBox();
this.cboReportType = new System.Windows.Forms.ComboBox();
// this.cboReportType = new System.Windows.Forms.ComboBox();
this.txtReportName = new System.Windows.Forms.TextBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
@ -285,16 +283,19 @@ namespace ReportGenerator{ @@ -285,16 +283,19 @@ namespace ReportGenerator{
this.cboGraphicsUnit.Size = new System.Drawing.Size(248, 21);
this.cboGraphicsUnit.TabIndex = 17;
this.cboGraphicsUnit.TextChanged += new System.EventHandler(this.ChangedEvent);
this.cboGraphicsUnit.DropDownStyle = ComboBoxStyle.DropDownList;
//
// cboReportType
//
/*
this.cboReportType.Location = new System.Drawing.Point(112, 120);
this.cboReportType.Name = "cboReportType";
this.cboReportType.Size = new System.Drawing.Size(248, 21);
this.cboReportType.TabIndex = 16;
this.cboReportType.Visible = false;
this.cboReportType.SelectedIndexChanged += new System.EventHandler(this.ChangedEvent);
//
*/
//
// txtReportName
//
this.txtReportName.Location = new System.Drawing.Point(120, 40);
@ -309,7 +310,7 @@ namespace ReportGenerator{ @@ -309,7 +310,7 @@ namespace ReportGenerator{
this.groupBox1.Controls.Add(this.groupBox2);
this.groupBox1.Controls.Add(this.button1);
this.groupBox1.Controls.Add(this.cboGraphicsUnit);
this.groupBox1.Controls.Add(this.cboReportType);
// this.groupBox1.Controls.Add(this.cboReportType);
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.txtPath);

Loading…
Cancel
Save