Browse Source

Fixed http://community.sharpdevelop.net/forums/thread/9098.aspx and broken build as well

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1523 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Peter Forstmeier 19 years ago
parent
commit
b69e3277b2
  1. 81
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseClasses/DataTypeHelper.cs
  2. 14
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseDataItem.cs
  3. 3
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseFunction.cs
  4. 18
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportItem.cs
  5. 20
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseTextItem.cs
  6. 21
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Functions/BasePageNumber.cs
  7. 53
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Functions/BaseToday.cs
  8. 2
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractDataRenderer.cs
  9. 18
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractRenderer.cs
  10. 2
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs
  11. 190
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Text/StandartFormatter.cs
  12. 3
      src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportCore.csproj

81
src/AddIns/Misc/SharpReport/SharpReportCore/BaseClasses/DataTypeHelper.cs

@ -0,0 +1,81 @@ @@ -0,0 +1,81 @@
/*
* Created by SharpDevelop.
* User: Forstmeier Helmut
* Date: 27.06.2006
* Time: 09:12
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
namespace SharpReportCore
{
/// <summary>
/// Description of DataType.
/// </summary>
internal class DataTypeHelper{
//TODO why not use
// TypeCode tc = Type.GetTypeCode( Type.GetType("System.String"));
internal static TypeCode TypeCodeFromString (string type) {
TypeCode tc;
if (type == null) {
type = "System.String";
}
if (type.StartsWith("System.")){
type = type.Substring(7);
}
switch (type){
case "DateTime":
tc = TypeCode.DateTime;
break;
case "Boolean":
tc = TypeCode.Boolean;
break;
case "String":
case "Char":
tc = TypeCode.String;
break;
case "Decimal":
tc = TypeCode.Decimal;
break;
case "Integer":
case "Int16":
case "Int32":
tc = TypeCode.Int32;
break;
case "Float":
case "Single":
case "Double":
tc = TypeCode.Double;
break;
default:
tc = TypeCode.Object;
break;
}
return tc;
}
static internal bool IsNumber(TypeCode tc){
switch (tc){
case TypeCode.Int32:
case TypeCode.Double:
case TypeCode.Decimal:
return true;
default: // user error
return false;
}
}
}
}

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

@ -33,13 +33,16 @@ namespace SharpReportCore { @@ -33,13 +33,16 @@ namespace SharpReportCore {
private string dataType;
private string nullValue;
#region Constructor
public BaseDataItem():base() {
this.dataType = "System.String";
}
public BaseDataItem(string columnName):base(){
this.columnName = columnName;
this.dataType = "System.String";
}
#endregion
@ -63,12 +66,17 @@ namespace SharpReportCore { @@ -63,12 +66,17 @@ namespace SharpReportCore {
public override void Render(SharpReportCore.ReportPageEventArgs rpea) {
// this.DbValue is formatted in the BeforePrintEvent catched in AbstractRenderer
// TypeCode tc = Type.GetTypeCode( Type.GetType(this.dataType));
// TODO this.DbValue should beformatted in the BeforePrintEvent
string toPrint = CheckForNullValue();
base.Text = base.FireFormatOutput(toPrint,this.FormatString,"");
// System.Console.WriteLine("\tBaseDataItem <{0}> / <{1}>",this.Name,this.Text);
base.Text = base.FormatOutput(toPrint,
this.FormatString,
DataTypeHelper.TypeCodeFromString (this.dataType),
this.nullValue);
base.Render (rpea);
}

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

@ -26,6 +26,7 @@ namespace SharpReportCore { @@ -26,6 +26,7 @@ namespace SharpReportCore {
public BaseFunction():base() {
this.localisedName = "SharpReport.Toolbar.Functions";
}
public BaseFunction(string friendlyName)
{
this.localisedName = friendlyName;
@ -38,7 +39,7 @@ namespace SharpReportCore { @@ -38,7 +39,7 @@ namespace SharpReportCore {
#region properties
[Browsable(false)]
public string LocalisedName {
get {
return localisedName;

18
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportItem.cs

@ -31,7 +31,7 @@ namespace SharpReportCore { @@ -31,7 +31,7 @@ namespace SharpReportCore {
public event EventHandler<BeforePrintEventArgs> ItemPrinting;
public event EventHandler<AfterPrintEventArgs> ItemPrinted;
public event EventHandler <FormatOutputEventArgs> FormatOutput;
// public event EventHandler <FormatOutputEventArgs> FormatOutput;
public event EventHandler Disposed;
public BaseReportItem() :base(){
@ -46,14 +46,14 @@ namespace SharpReportCore { @@ -46,14 +46,14 @@ namespace SharpReportCore {
/// <param name="formatString">the formatString</param>
/// <param name="nullValue">Value to return when there is null in toFormat</param>
/// <returns></returns>
protected string FireFormatOutput(string toFormat,string format, string nullValue) {
if (FormatOutput != null) {
FormatOutputEventArgs ea = new FormatOutputEventArgs (toFormat,
format,
nullValue);
FormatOutput (this,ea);
return ea.FormatedValue;
}
protected string old_FireFormatOutput(string toFormat,string format, string nullValue) {
// if (FormatOutput != null) {
// FormatOutputEventArgs ea = new FormatOutputEventArgs (toFormat,
// format,
// nullValue);
// FormatOutput (this,ea);
// return ea.FormatedValue;
// }
return toFormat;
}

20
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseTextItem.cs

@ -28,20 +28,30 @@ namespace SharpReportCore { @@ -28,20 +28,30 @@ namespace SharpReportCore {
private string formatString = String.Empty;
private StringFormat stringFormat;
private StringTrimming stringTrimming;
private TextDrawer textDrawer = new TextDrawer();
private TextDrawer textDrawer;
private StandardFormatter standartFormatter;
private ContentAlignment contentAlignment;
private RectangleShape shape = new RectangleShape();
#region Constructor
public BaseTextItem():base() {
this.stringFormat = StringFormat.GenericTypographic;
this.contentAlignment = ContentAlignment.MiddleLeft;
this.stringTrimming = StringTrimming.EllipsisCharacter;
this.stringFormat = StringFormat.GenericTypographic;
this.contentAlignment = ContentAlignment.MiddleLeft;
this.stringTrimming = StringTrimming.EllipsisCharacter;
this.textDrawer = new TextDrawer();
this.standartFormatter = new StandardFormatter();
}
#endregion
protected string FormatOutput(string valueToFormat,string formatString,
TypeCode typeCode, string nullValue ){
return standartFormatter.FormatItem(valueToFormat,formatString,
typeCode,nullValue);
}
public override void Render(ReportPageEventArgs rpea) {
@ -164,7 +174,7 @@ namespace SharpReportCore { @@ -164,7 +174,7 @@ namespace SharpReportCore {
}
[Category("Appearance")]
public System.Drawing.ContentAlignment ContentAlignment {
public virtual System.Drawing.ContentAlignment ContentAlignment {
get {
return this.contentAlignment;
}

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

@ -33,10 +33,11 @@ namespace SharpReportCore { @@ -33,10 +33,11 @@ namespace SharpReportCore {
public override void Render(ReportPageEventArgs rpea) {
base.Render(rpea);
string formattedString = base.FireFormatOutput(rpea.PageNumber.ToString(CultureInfo.InvariantCulture),
base.FormatString,"");
string formattedString = base.FormatOutput(rpea.PageNumber.ToString(CultureInfo.InvariantCulture),
this.FormatString,
TypeCode.Int32,
"xxxx");
RectangleF rect = base.PrepareRectangle (rpea,formattedString);
//Printout the textpart
base.PrintTheStuff (rpea,this.Text,rect);
@ -44,13 +45,13 @@ namespace SharpReportCore { @@ -44,13 +45,13 @@ namespace SharpReportCore {
StringFormat fmt = StringFormat;
fmt.Alignment = StringAlignment.Far;
fmt.LineAlignment = StringAlignment.Near;
rpea.PrintPageEventArgs.Graphics.DrawString(rpea.PageNumber.ToString(CultureInfo.InvariantCulture),
this.Font,
Brushes.Black,
rect,
fmt);
fmt.LineAlignment = StringAlignment.Center;
rpea.PrintPageEventArgs.Graphics.DrawString(formattedString,
this.Font,
Brushes.Black,
rect,
fmt);
base.NotiyfyAfterPrint (rpea.LocationAfterDraw);
}

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

@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
//------------------------------------------------------------------------------
using System;
using System.Drawing;
using System.ComponentModel;
using System.Globalization;
/// <summary>
/// BaseClass for Today's Date
@ -28,9 +29,17 @@ namespace SharpReportCore { @@ -28,9 +29,17 @@ namespace SharpReportCore {
public override void Render(ReportPageEventArgs rpea) {
base.Render(rpea);
string formattedString = FormatAsDate(System.DateTime.Now.ToString(),base.FormatString);
string f;
if (String.IsNullOrEmpty(this.FormatString)) {
f = "d";
} else {
f = this.FormatString;
}
string formattedString = base.FormatOutput(System.DateTime.Now.ToString(CultureInfo.CurrentCulture),
f,
TypeCode.DateTime,
"");
RectangleF rect = base.PrepareRectangle (rpea,formattedString);
//Printout the textPart
@ -39,42 +48,30 @@ namespace SharpReportCore { @@ -39,42 +48,30 @@ namespace SharpReportCore {
//here we print the functionpart allway's with Stringalignment.Far
StringFormat fmt = StringFormat;
fmt.Alignment = StringAlignment.Far;
fmt.LineAlignment = StringAlignment.Near;
fmt.LineAlignment = StringAlignment.Center;
rpea.PrintPageEventArgs.Graphics.DrawString(formattedString,
this.Font,
Brushes.Black,
rect,
fmt);
this.Font,
Brushes.Black,
rect,
fmt);
// goon
// goon
base.NotiyfyAfterPrint (rpea.LocationAfterDraw);
}
public override string ToString() {
return "BaseToday";
}
#region privates
private string FormatAsDate (string toFormat,string formatWith) {
if (toFormat.Length == 0) {
return String.Empty;
}
if (formatWith.Length == 0) {
return toFormat;
[Browsable(false)]
public override ContentAlignment ContentAlignment {
get {
return base.ContentAlignment;
}
try {
DateTime date = DateTime.Parse (toFormat.Trim(),
CultureInfo.CurrentCulture.DateTimeFormat);
string str = date.ToString(formatWith,
DateTimeFormatInfo.CurrentInfo);
return str;
} catch (Exception) {
throw;
set {
base.ContentAlignment = value;
}
}
#endregion
}
}

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

@ -72,7 +72,7 @@ namespace SharpReportCore{ @@ -72,7 +72,7 @@ namespace SharpReportCore{
item.Parent = section;
}
item.SectionOffset = section.SectionOffset;
base.DrawSingleItem (rpea,item);
item.Render(rpea);
drawPoint.Y = section.SectionOffset + section.Size.Height;
rpea.LocationAfterDraw = new PointF (rpea.LocationAfterDraw.X,section.SectionOffset + section.Size.Height);

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

@ -37,7 +37,7 @@ namespace SharpReportCore { @@ -37,7 +37,7 @@ namespace SharpReportCore {
private Point detailStart;
private Point detailEnds;
private StandartFormatter standartFormatter;
private StandardFormatter standartFormatter;
private bool cancel;
public event EventHandler<SectionRenderEventArgs> SectionRendering;
@ -50,7 +50,7 @@ namespace SharpReportCore { @@ -50,7 +50,7 @@ namespace SharpReportCore {
this.reportSettings = model.ReportSettings;
this.sections = model.SectionCollection;
Init();
standartFormatter = new StandartFormatter();
standartFormatter = new StandardFormatter();
}
public virtual void SetupRenderer () {
@ -276,8 +276,7 @@ namespace SharpReportCore { @@ -276,8 +276,7 @@ namespace SharpReportCore {
item.Parent = this.CurrentSection;
}
item.SectionOffset = this.CurrentSection.SectionOffset;
this.DrawSingleItem (rpea,item);
item.Render(rpea);
drawPoint.Y = this.CurrentSection.SectionOffset + this.CurrentSection.Size.Height;
rpea.LocationAfterDraw = new PointF (rpea.LocationAfterDraw.X,this.CurrentSection.SectionOffset + this.CurrentSection.Size.Height);
@ -292,16 +291,9 @@ namespace SharpReportCore { @@ -292,16 +291,9 @@ namespace SharpReportCore {
return drawPoint.Y;
}
protected void DrawSingleItem (ReportPageEventArgs rpea,BaseReportItem item){
item.SuspendLayout();
item.FormatOutput -= new EventHandler<FormatOutputEventArgs> (FormatBaseReportItem);
item.FormatOutput += new EventHandler<FormatOutputEventArgs> (FormatBaseReportItem);
item.Render(rpea);
item.ResumeLayout();
}
// Called by FormatOutPutEvent of the BaseReportItem
/*
void FormatBaseReportItem (object sender, FormatOutputEventArgs rpea) {
BaseDataItem baseDataItem = sender as BaseDataItem;
@ -314,7 +306,7 @@ namespace SharpReportCore { @@ -314,7 +306,7 @@ namespace SharpReportCore {
}
}
}
*/
#region privates
protected void FitSectionToItems (BaseSection section,ReportPageEventArgs rpea){

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

@ -131,7 +131,7 @@ namespace SharpReportCore { @@ -131,7 +131,7 @@ namespace SharpReportCore {
}
protected override void PrintReportFooter(object sender, ReportPageEventArgs rpea){
System.Console.WriteLine("DataRenderer:PrintReportFooter");
// System.Console.WriteLine("DataRenderer:PrintReportFooter");
base.PrintReportFooter(sender, rpea);
DoReportFooter (new PointF(0,base.CurrentSection.SectionOffset + base.CurrentSection.Size.Height),
rpea);

190
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Text/StandartFormatter.cs

@ -14,162 +14,138 @@ using System.Globalization; @@ -14,162 +14,138 @@ using System.Globalization;
/// Type and DbValue
/// </summary>
namespace SharpReportCore {
public class StandartFormatter : object {
public class StandardFormatter : object {
public StandartFormatter() {
public StandardFormatter() {
}
///<summary>Looks witch formatting Class to use, call the approbiate formatter
/// and update the DbValue with the formatted String value
/// </summary>
///<param name="item">A ReportDataItem</param>
///
public string FormatItem (BaseDataItem item) {
public string FormatItem (string valueToFormat,string formatString,
TypeCode typeCode,string nullValue) {
string retValue = String.Empty;
if (item == null) {
throw new ArgumentNullException("item");
if (String.IsNullOrEmpty(formatString)) {
retValue = valueToFormat;
return retValue;
}
string retValue = String.Empty;
switch (item.DataType) {
case "System.DateTime" :
retValue = DateValues(item.DbValue,item.FormatString);
switch (typeCode) {
case TypeCode.Int16:
case TypeCode.Int32:
retValue = IntegerValues (valueToFormat,formatString);
break;
case "System.Int16":
retValue = IntegerValues ("16",item.DbValue,item.FormatString);
case TypeCode.DateTime:
retValue = DateValues(valueToFormat,formatString);
break;
case "System.Int32" :
retValue = IntegerValues ("32",item.DbValue,item.FormatString);
case TypeCode.Boolean:
retValue = BoolValue (valueToFormat,formatString);
break;
case "System.Decimal":
retValue = DecimalValues (item.DbValue,item.FormatString);
case TypeCode.Decimal:
retValue = DecimalValues (valueToFormat,formatString);
break;
case "System.Boolean":
retValue = BoolValue (item.DbValue,item.FormatString);
case TypeCode.Double:
case TypeCode.Single:
break;
case TypeCode.String:
case TypeCode.Char:
retValue = valueToFormat;
break;
default:
retValue = item.DbValue;
retValue = valueToFormat;
break;
}
return retValue;
}
///<summary>Looks witch formatting Class to use, call the approbiate formatter
/// and update the DbValue with the formatted String value
/// </summary>
///<param name="item">A ReportDataItem</param>
///
public string FormatItem (BaseDataItem item) {
if (item == null) {
throw new ArgumentNullException("item");
}
return FormatItem(item.DbValue,item.FormatString,
Type.GetTypeCode( Type.GetType(item.DataType)),
item.NullValue);
}
public string BoolValue (string toFormat, string format){
private string BoolValue (string toFormat, string format){
string str = String.Empty;
if (StandartFormatter.CheckFormat(format) == true) {
if (StandartFormatter.CheckValue (toFormat)) {
try {
bool b = bool.Parse (toFormat);
str = b.ToString (CultureInfo.CurrentCulture);
} catch (System.FormatException) {
try {
bool b = bool.Parse (toFormat);
str = b.ToString (CultureInfo.CurrentCulture);
} catch (System.FormatException) {
// string s = String.Format("\tBool Value < {0} > {1}",toFormat,e.Message);
// System.Console.WriteLine("\t\t{0}",s);
}
}
} else {
str = toFormat;
}
return str;
}
public string IntegerValues(string valueType,string toFormat, string format) {
private string IntegerValues(string toFormat, string format) {
string str = String.Empty;
if (StandartFormatter.CheckFormat(format) == true) {
if (StandartFormatter.CheckValue (toFormat)) {
try {
int number;
switch (valueType) {
case "16":
number = Int16.Parse (toFormat,
System.Globalization.NumberStyles.Any,
CultureInfo.CurrentCulture.NumberFormat);
break;
case "32" :
number = Int32.Parse (toFormat,
System.Globalization.NumberStyles.Any,
CultureInfo.CurrentCulture.NumberFormat);
break;
default:
throw new ArgumentException("DefaultFormater:IntegerValues Unknown intType ");
}
str = number.ToString (format,CultureInfo.CurrentCulture);
} catch (System.FormatException) {
if (StandardFormatter.CheckValue (toFormat)) {
try {
int number = Int32.Parse (toFormat,
System.Globalization.NumberStyles.Any,
CultureInfo.CurrentCulture.NumberFormat);
str = number.ToString (format,CultureInfo.CurrentCulture);
} catch (System.FormatException) {
// string s = String.Format("\tDecimalValue < {0} > {1}",toFormat,e.Message);
// System.Console.WriteLine("\t{0}",s);
}
return str;
} else {
str = (0.0M).ToString(CultureInfo.CurrentCulture);
}
return str;
} else {
str = toFormat;
str = (0.0M).ToString(CultureInfo.CurrentCulture);
}
return str;
}
public string DecimalValues(string toFormat, string format) {
private string DecimalValues(string toFormat, string format) {
string str = String.Empty;
if (StandartFormatter.CheckFormat(format) == true) {
if (StandartFormatter.CheckValue (toFormat)) {
try {
decimal dec = Decimal.Parse(toFormat,
System.Globalization.NumberStyles.Any,
CultureInfo.CurrentCulture.NumberFormat);
str = dec.ToString (format,CultureInfo.CurrentCulture);
} catch (System.FormatException) {
if (StandardFormatter.CheckValue (toFormat)) {
try {
decimal dec = Decimal.Parse(toFormat,
System.Globalization.NumberStyles.Any,
CultureInfo.CurrentCulture.NumberFormat);
str = dec.ToString (format,CultureInfo.CurrentCulture);
} catch (System.FormatException) {
// string s = String.Format("\tDecimalValue < {0} > {1}",toFormat,e.Message);
// System.Console.WriteLine("\t{0}",s);
}
return str;
} else {
str = (0.0M).ToString(CultureInfo.CurrentCulture);
}
return str;
} else {
str = toFormat;
str = (0.0M).ToString(CultureInfo.CurrentCulture);
}
return str;
}
public string DateValues(string toFormat, string format) {
if (StandartFormatter.CheckFormat(format) == true) {
try {
DateTime date = DateTime.Parse (toFormat.Trim(),
CultureInfo.CurrentCulture.DateTimeFormat);
string str = date.ToString(format,
DateTimeFormatInfo.CurrentInfo);
return str.Trim();
} catch (System.FormatException) {
private string DateValues(string toFormat, string format) {
try {
DateTime date = DateTime.Parse (toFormat.Trim(),
CultureInfo.CurrentCulture.DateTimeFormat);
string str = date.ToString(format,
DateTimeFormatInfo.CurrentInfo);
return str.Trim();
} catch (System.FormatException) {
// string s = String.Format("< {0} > {1}",toFormat,e.Message);
// System.Console.WriteLine("\t\tDateValue {0}",s);
}
} else {
return toFormat.Trim();
}
return toFormat.Trim();
}
private static bool CheckFormat (string format) {
if (String.IsNullOrEmpty(format)) {
return false;
}
return true;
}
private static bool CheckValue (string toFormat) {
if (String.IsNullOrEmpty(toFormat)) {
return false;

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

@ -82,8 +82,6 @@ @@ -82,8 +82,6 @@
<Compile Include="Interfaces\IItemRenderer.cs" />
<Compile Include="Interfaces\IOutputStrategy.cs" />
<Compile Include="Interfaces\IStoreable.cs" />
<Compile Include="Printing\Formatter\AbstractFormatter.cs" />
<Compile Include="Printing\Formatter\DefaultFormatter.cs" />
<Compile Include="Printing\Graphics\BaseLine.cs" />
<Compile Include="Printing\Graphics\BaseShape.cs" />
<Compile Include="Printing\Graphics\Border.cs" />
@ -133,6 +131,7 @@ @@ -133,6 +131,7 @@
<Compile Include="Exceptions\IllegalQueryException.cs" />
<Compile Include="Events\SectionRenderEventArgs.cs" />
<Compile Include="Printing\Text\StandartFormatter.cs" />
<Compile Include="BaseClasses\DataTypeHelper.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="BaseItems" />

Loading…
Cancel
Save