diff --git a/SharpDevelop.Tests.sln b/SharpDevelop.Tests.sln index 95241db5bd..4f12187384 100644 --- a/SharpDevelop.Tests.sln +++ b/SharpDevelop.Tests.sln @@ -1,7 +1,9 @@  -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 # SharpDevelop 5.0 +VisualStudioVersion = 12.0.20827.3 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Main", "Main", "{256F5C28-532C-44C0-8AB8-D8EC5E492E01}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.BuildWorker35", "src\Main\ICSharpCode.SharpDevelop.BuildWorker35\ICSharpCode.SharpDevelop.BuildWorker35.csproj", "{B5F54272-49F0-40DB-845A-8D837875D3BA}" @@ -148,6 +150,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Reports.Core.Te EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Irony", "src\AddIns\Misc\Reports\Irony\Irony.csproj", "{D81F5C91-D7DB-46E5-BC99-49488FB6814C}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Reporting", "src\AddIns\Misc\Reporting\ICSharpCode.Reporting\ICSharpCode.Reporting.csproj", "{40CA84D4-ACFC-4646-9CDD-B87262D34093}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Reporting.Test", "src\AddIns\Misc\Reporting\ICSharpCode.Reporting\Test\ICSharpCode.Reporting.Test\ICSharpCode.Reporting.Test.csproj", "{97CA9CE5-B966-48DF-BB59-F00FFC534B1F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Reporting.Addin", "src\AddIns\Misc\Reporting\ICSharpCode.Reporting.Addin\ICSharpCode.Reporting.Addin.csproj", "{0502FCF7-72F4-4587-936B-D0238CD0E072}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Display Bindings", "Display Bindings", "{11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvalonEdit.AddIn", "src\AddIns\DisplayBindings\AvalonEdit.AddIn\AvalonEdit.AddIn.csproj", "{0162E499-42D0-409B-AA25-EED21F75336B}" @@ -490,6 +498,18 @@ Global {D81F5C91-D7DB-46E5-BC99-49488FB6814C}.Debug|Any CPU.Build.0 = Debug|Any CPU {D81F5C91-D7DB-46E5-BC99-49488FB6814C}.Release|Any CPU.ActiveCfg = Release|Any CPU {D81F5C91-D7DB-46E5-BC99-49488FB6814C}.Release|Any CPU.Build.0 = Release|Any CPU + {40CA84D4-ACFC-4646-9CDD-B87262D34093}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {40CA84D4-ACFC-4646-9CDD-B87262D34093}.Debug|Any CPU.Build.0 = Debug|Any CPU + {40CA84D4-ACFC-4646-9CDD-B87262D34093}.Release|Any CPU.ActiveCfg = Release|Any CPU + {40CA84D4-ACFC-4646-9CDD-B87262D34093}.Release|Any CPU.Build.0 = Release|Any CPU + {97CA9CE5-B966-48DF-BB59-F00FFC534B1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {97CA9CE5-B966-48DF-BB59-F00FFC534B1F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {97CA9CE5-B966-48DF-BB59-F00FFC534B1F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {97CA9CE5-B966-48DF-BB59-F00FFC534B1F}.Release|Any CPU.Build.0 = Release|Any CPU + {0502FCF7-72F4-4587-936B-D0238CD0E072}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0502FCF7-72F4-4587-936B-D0238CD0E072}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0502FCF7-72F4-4587-936B-D0238CD0E072}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0502FCF7-72F4-4587-936B-D0238CD0E072}.Release|Any CPU.Build.0 = Release|Any CPU {0162E499-42D0-409B-AA25-EED21F75336B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0162E499-42D0-409B-AA25-EED21F75336B}.Debug|Any CPU.Build.0 = Debug|Any CPU {0162E499-42D0-409B-AA25-EED21F75336B}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -717,6 +737,9 @@ Global {4B2239FF-8FD6-431D-9D22-1B8049BA6917} = {FEDD3FD9-0480-43CC-913C-4E0876DDA852} {E16B73CA-3603-47EE-915E-6F8B2A07304B} = {FEDD3FD9-0480-43CC-913C-4E0876DDA852} {D81F5C91-D7DB-46E5-BC99-49488FB6814C} = {FEDD3FD9-0480-43CC-913C-4E0876DDA852} + {40CA84D4-ACFC-4646-9CDD-B87262D34093} = {FEDD3FD9-0480-43CC-913C-4E0876DDA852} + {97CA9CE5-B966-48DF-BB59-F00FFC534B1F} = {FEDD3FD9-0480-43CC-913C-4E0876DDA852} + {0502FCF7-72F4-4587-936B-D0238CD0E072} = {FEDD3FD9-0480-43CC-913C-4E0876DDA852} {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} = {39327899-ED91-4F7F-988C-4FE4E17C014D} {0162E499-42D0-409B-AA25-EED21F75336B} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} {E618A9CD-A39F-4925-A538-E8A3FEF24E54} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} diff --git a/SharpDevelop.sln b/SharpDevelop.sln index e4a9a90f01..61cb69ef74 100644 --- a/SharpDevelop.sln +++ b/SharpDevelop.sln @@ -1,7 +1,9 @@  -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 # SharpDevelop 5.0 +VisualStudioVersion = 12.0.20827.3 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Main", "Main", "{256F5C28-532C-44C0-8AB8-D8EC5E492E01}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.BuildWorker35", "src\Main\ICSharpCode.SharpDevelop.BuildWorker35\ICSharpCode.SharpDevelop.BuildWorker35.csproj", "{B5F54272-49F0-40DB-845A-8D837875D3BA}" @@ -117,6 +119,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Reports.Core", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Irony", "src\AddIns\Misc\Reports\Irony\Irony.csproj", "{D81F5C91-D7DB-46E5-BC99-49488FB6814C}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Reporting", "src\AddIns\Misc\Reporting\ICSharpCode.Reporting\ICSharpCode.Reporting.csproj", "{40CA84D4-ACFC-4646-9CDD-B87262D34093}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Reporting.Addin", "src\AddIns\Misc\Reporting\ICSharpCode.Reporting.Addin\ICSharpCode.Reporting.Addin.csproj", "{0502FCF7-72F4-4587-936B-D0238CD0E072}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Display Bindings", "Display Bindings", "{11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvalonEdit.AddIn", "src\AddIns\DisplayBindings\AvalonEdit.AddIn\AvalonEdit.AddIn.csproj", "{0162E499-42D0-409B-AA25-EED21F75336B}" @@ -381,6 +387,10 @@ Global {D81F5C91-D7DB-46E5-BC99-49488FB6814C}.Debug|Any CPU.Build.0 = Debug|Any CPU {D81F5C91-D7DB-46E5-BC99-49488FB6814C}.Release|Any CPU.ActiveCfg = Release|Any CPU {D81F5C91-D7DB-46E5-BC99-49488FB6814C}.Release|Any CPU.Build.0 = Release|Any CPU + {40CA84D4-ACFC-4646-9CDD-B87262D34093}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {40CA84D4-ACFC-4646-9CDD-B87262D34093}.Debug|Any CPU.Build.0 = Debug|Any CPU + {40CA84D4-ACFC-4646-9CDD-B87262D34093}.Release|Any CPU.ActiveCfg = Release|Any CPU + {40CA84D4-ACFC-4646-9CDD-B87262D34093}.Release|Any CPU.Build.0 = Release|Any CPU {0162E499-42D0-409B-AA25-EED21F75336B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0162E499-42D0-409B-AA25-EED21F75336B}.Debug|Any CPU.Build.0 = Debug|Any CPU {0162E499-42D0-409B-AA25-EED21F75336B}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -505,6 +515,10 @@ Global {3DF4060F-5EE0-41CF-8096-F27355FD5511}.Debug|Any CPU.Build.0 = Debug|Any CPU {3DF4060F-5EE0-41CF-8096-F27355FD5511}.Release|Any CPU.ActiveCfg = Release|Any CPU {3DF4060F-5EE0-41CF-8096-F27355FD5511}.Release|Any CPU.Build.0 = Release|Any CPU + {0502FCF7-72F4-4587-936B-D0238CD0E072}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0502FCF7-72F4-4587-936B-D0238CD0E072}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0502FCF7-72F4-4587-936B-D0238CD0E072}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0502FCF7-72F4-4587-936B-D0238CD0E072}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -563,6 +577,8 @@ Global {35D002D7-C78B-44FB-92AA-104BEB431678} = {4ABB8D1E-3439-44C8-ACCE-1FA678ABBFB3} {4B2239FF-8FD6-431D-9D22-1B8049BA6917} = {4ABB8D1E-3439-44C8-ACCE-1FA678ABBFB3} {D81F5C91-D7DB-46E5-BC99-49488FB6814C} = {4ABB8D1E-3439-44C8-ACCE-1FA678ABBFB3} + {40CA84D4-ACFC-4646-9CDD-B87262D34093} = {4ABB8D1E-3439-44C8-ACCE-1FA678ABBFB3} + {0502FCF7-72F4-4587-936B-D0238CD0E072} = {4ABB8D1E-3439-44C8-ACCE-1FA678ABBFB3} {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} = {39327899-ED91-4F7F-988C-4FE4E17C014D} {0162E499-42D0-409B-AA25-EED21F75336B} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} {E618A9CD-A39F-4925-A538-E8A3FEF24E54} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} diff --git a/src/AddIns/Analysis/CodeQuality/CodeQuality.addin b/src/AddIns/Analysis/CodeQuality/CodeQuality.addin index 0945fa92dd..c63ccf1bd9 100644 --- a/src/AddIns/Analysis/CodeQuality/CodeQuality.addin +++ b/src/AddIns/Analysis/CodeQuality/CodeQuality.addin @@ -6,7 +6,7 @@ - + diff --git a/src/AddIns/Analysis/CodeQuality/CodeQuality.csproj b/src/AddIns/Analysis/CodeQuality/CodeQuality.csproj index 30689a7bd5..6f26ee88e3 100644 --- a/src/AddIns/Analysis/CodeQuality/CodeQuality.csproj +++ b/src/AddIns/Analysis/CodeQuality/CodeQuality.csproj @@ -111,6 +111,7 @@ Never + @@ -172,10 +173,9 @@ ICSharpCode.SharpDevelop.Widgets False - - {7C3579BC-2A64-4108-82B5-3D07ADA079E7} - ICSharpCode.Reports.Core - False + + {40CA84D4-ACFC-4646-9CDD-B87262D34093} + ICSharpCode.Reporting diff --git a/src/AddIns/Analysis/CodeQuality/Gui/MainView.xaml b/src/AddIns/Analysis/CodeQuality/Gui/MainView.xaml index 9508b9a7f6..5417c973ae 100644 --- a/src/AddIns/Analysis/CodeQuality/Gui/MainView.xaml +++ b/src/AddIns/Analysis/CodeQuality/Gui/MainView.xaml @@ -4,8 +4,8 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:gui="clr-namespace:ICSharpCode.CodeQuality.Gui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:rep="clr-namespace:ICSharpCode.Reports.Core.WpfReportViewer;assembly=ICSharpCode.Reports.Core"> - + xmlns:reporting="clr-namespace:ICSharpCode.Reporting.WpfReportViewer;assembly=ICSharpCode.Reporting"> + @@ -40,8 +40,7 @@ x:Name="reportTab" Visibility="Hidden"> - + diff --git a/src/AddIns/Analysis/CodeQuality/Gui/MainView.xaml.cs b/src/AddIns/Analysis/CodeQuality/Gui/MainView.xaml.cs index 2a6a9c967f..cb57e1cc98 100644 --- a/src/AddIns/Analysis/CodeQuality/Gui/MainView.xaml.cs +++ b/src/AddIns/Analysis/CodeQuality/Gui/MainView.xaml.cs @@ -19,18 +19,13 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Text; using System.Windows; using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; +using ICSharpCode.Reporting.WpfReportViewer; using ICSharpCode.CodeQuality.Engine; using ICSharpCode.CodeQuality.Engine.Dom; using ICSharpCode.CodeQuality.Reporting; -using ICSharpCode.Reports.Core.WpfReportViewer; using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Project; using Microsoft.Win32; @@ -125,6 +120,7 @@ namespace ICSharpCode.CodeQuality.Gui var previewViewModel = new PreviewViewModel(dependencyReport.ReportSettings,reportCreator.Pages); viewer.SetBinding(previewViewModel); ActivateReportTab(); + } void ActivateReportTab() diff --git a/src/AddIns/Analysis/CodeQuality/Reporting/BaseReport.cs b/src/AddIns/Analysis/CodeQuality/Reporting/BaseReport.cs index caaf9d16bb..00c55cadd0 100644 --- a/src/AddIns/Analysis/CodeQuality/Reporting/BaseReport.cs +++ b/src/AddIns/Analysis/CodeQuality/Reporting/BaseReport.cs @@ -18,10 +18,8 @@ using System; using System.Collections.Generic; -using System.IO; -using System.Reflection; +using ICSharpCode.Reporting.Items; -using ICSharpCode.Reports.Core; namespace ICSharpCode.CodeQuality.Reporting { diff --git a/src/AddIns/Analysis/CodeQuality/Reporting/DependencyReport - Kopie.srd b/src/AddIns/Analysis/CodeQuality/Reporting/DependencyReport - Kopie.srd new file mode 100644 index 0000000000..1a92920d07 --- /dev/null +++ b/src/AddIns/Analysis/CodeQuality/Reporting/DependencyReport - Kopie.srd @@ -0,0 +1,308 @@ + + + + + DependencyReport + FormSheet + 50 + 50 + 50 + 50 + 827, 1169 + False + Millimeter + 5, 5, 5, 5 + + + + + Ascending + False + Name + System.String + + + + + + + Text + FormSheet + No Data for this Report + Microsoft Sans Serif, 10pt + True + + + + + 50, 50 + 727, 60 + White + 0 + 0 + False + False + + + 157, 3 + 414, 40 + White + Segoe UI, 18pt, style=Bold + None + TopLeft + False + False + No + SharpDevelop CodeQuality Analysis + False + Black + Black + BaseTextItem2147483637 + + + Black + ReportHeader + + + 50, 125 + 727, 69 + White + 0 + 0 + False + False + + + 22, 47 + 660, 10 + White + Black + 10, 5 + 647, 5 + Flat + Flat + Flat + Solid + 4 + BaseLineItem1 + + + 222, 3 + 257, 26 + White + Microsoft Sans Serif, 15.75pt + None + TopLeft + False + False + System.String + No + Analysis Overview Report + False + Black + Black + Overview + + + 563, 3 + 100, 26 + White + Segoe UI, 15.75pt + None + TopLeft + False + False + No + =Today() + False + Black + ControlText + BaseTextItem2147483638 + + + Black + ReportPageHeader + + + 50, 209 + 727, 115 + White + 0 + 0 + False + False + + + 31, 72 + 641, 30 + White + False + Black + Black + + + 443, 4 + 71, 20 + White + Segoe UI, 9pt + None + MiddleRight + False + False + No + BaseDataItem2147483646 + False + Black + Black + ReferenceCount + BaseDataItem2147483646 + + + 254, 4 + 156, 20 + White + Microsoft Sans Serif, 10pt + None + TopLeft + False + False + No + References + False + Black + Black + References + BaseDataItem2 + + + + 0 + BaseRowItem1 + + + 31, 22 + 641, 30 + LightGray + False + Black + Black + + + 414, 7 + 100, 20 + White + Segoe UI, 9.75pt + None + MiddleRight + False + False + No + # of References + False + Black + Black + BaseTextItem2147483646 + + + 254, 2 + 100, 20 + White + Microsoft Sans Serif, 10pt + None + TopLeft + False + False + No + References + False + Black + Black + BaseTextItem2147483636 + + + 12, 3 + 211, 20 + White + Microsoft Sans Serif, 10pt + None + TopLeft + False + False + No + BaseDataItem1 + False + Black + Black + Name + BaseDataItem1 + + + + 0 + False + GroupHeader1 + + + Black + ReportDetail + + + 50, 339 + 727, 36 + White + 0 + 0 + False + False + + + 31, 5 + 555, 20 + White + Segoe UI, 9.75pt + None + TopLeft + False + False + No + = Globals!ReportFolder + Globals!ReportName + False + Black + ControlText + BaseTextItem2147483641 + + + 624, 5 + 100, 20 + White + Microsoft Sans Serif, 10pt + None + TopLeft + False + False + System.String + No + = 'Page : ' + Globals!PageNumber + False + Black + Black + PageNumber1 + + + Black + ReportPageFooter + + + 50, 390 + 727, 60 + White + 0 + 0 + False + False + + Black + ReportFooter + + + \ No newline at end of file diff --git a/src/AddIns/Analysis/CodeQuality/Reporting/DependencyReport.cs b/src/AddIns/Analysis/CodeQuality/Reporting/DependencyReport.cs index 769857069c..700e44ac4b 100644 --- a/src/AddIns/Analysis/CodeQuality/Reporting/DependencyReport.cs +++ b/src/AddIns/Analysis/CodeQuality/Reporting/DependencyReport.cs @@ -19,10 +19,13 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.ComponentModel; using System.Reflection; +using ICSharpCode.Reporting; +using ICSharpCode.Reporting.Interfaces; +using ICSharpCode.Reporting.Items; using ICSharpCode.CodeQuality.Engine.Dom; -using ICSharpCode.Reports.Core; namespace ICSharpCode.CodeQuality.Reporting { @@ -31,43 +34,45 @@ namespace ICSharpCode.CodeQuality.Reporting /// public class DependencyReport:BaseReport { - private const string overviewReport = "DependencyReport.srd"; + const string overviewReport = "DependencyReport.srd"; public DependencyReport(List fileNames):base(fileNames) { } public IReportCreator Run(ReadOnlyCollection list) - { - System.Reflection.Assembly asm = Assembly.GetExecutingAssembly(); - System.IO.Stream stream = asm.GetManifestResourceStream("ICSharpCode.CodeQuality.Reporting.DependencyReport.srd"); - var model = ReportEngine.LoadReportModel(stream); - ReportSettings = model.ReportSettings; + { var newList = MakeList (list); - - IReportCreator creator = ReportEngine.CreatePageBuilder(model,newList,null); - creator.BuildExportList(); - return creator; + var asm = Assembly.GetExecutingAssembly(); + var stream = asm.GetManifestResourceStream("ICSharpCode.CodeQuality.Reporting.DependencyReport.srd"); + var reportingFactory = new ReportingFactory(); + var reportCreator = reportingFactory.ReportCreator (stream,newList); + ReportSettings = reportingFactory.ReportModel.ReportSettings; + var groupColumn = (GroupColumn)ReportSettings.GroupColumnsCollection[0]; + groupColumn.GroupSortColumn = new SortColumn() { + ColumnName = "ReferenceCount", + SortDirection = ListSortDirection.Ascending + }; + reportCreator.BuildExportList(); + return reportCreator; } + - - private List MakeList (ReadOnlyCollection list) + List MakeList (ReadOnlyCollection list) { var newList = new List(); foreach (var baseNode in list) { foreach (var element in list) { if (baseNode.Name != element.Name) { - - - var referenceCount = baseNode.GetUses(element); - if (referenceCount > 0) { - newList.Add(new DependencyViewModel() - { - Node = baseNode, - References = element.Name, - ReferenceCount = referenceCount - }); - } + var referenceCount = baseNode.GetUses(element); + if (referenceCount > 0) { + newList.Add(new DependencyViewModel() + { + Node = baseNode, + References = element.Name, + ReferenceCount = referenceCount + }); + } } } } @@ -76,7 +81,7 @@ namespace ICSharpCode.CodeQuality.Reporting } - internal class DependencyViewModel:ReportViewModel + class DependencyViewModel:ReportViewModel { public DependencyViewModel() { diff --git a/src/AddIns/Analysis/CodeQuality/Reporting/DependencyReport.srd b/src/AddIns/Analysis/CodeQuality/Reporting/DependencyReport.srd index f48751f89d..6bdfacaf4b 100644 --- a/src/AddIns/Analysis/CodeQuality/Reporting/DependencyReport.srd +++ b/src/AddIns/Analysis/CodeQuality/Reporting/DependencyReport.srd @@ -17,6 +17,7 @@ Ascending + False Name System.String @@ -37,7 +38,6 @@ 50, 50 727, 60 White - False 0 0 False @@ -47,7 +47,6 @@ 157, 3 414, 40 White - True Segoe UI, 18pt, style=Bold None TopLeft @@ -68,7 +67,6 @@ 50, 125 727, 69 White - False 0 0 False @@ -78,7 +76,6 @@ 22, 47 660, 10 White - True Black 10, 5 647, 5 @@ -93,7 +90,6 @@ 222, 3 257, 26 White - True Microsoft Sans Serif, 15.75pt None TopLeft @@ -111,14 +107,15 @@ 563, 3 100, 26 White - True Segoe UI, 15.75pt + dd/MM/yyyy None TopLeft False False + System.DateTime No - =Today() + =Today False Black ControlText @@ -132,67 +129,49 @@ 50, 209 727, 115 White - False 0 0 False False - - 31, 72 - 641, 30 + + 445, 72 + 71, 20 White - True + Segoe UI, 9pt + None + MiddleRight + False + False + No + BaseDataItem2147483646 False + Black Black + ReferenceCount + BaseDataItem2147483646 + + + 256, 72 + 156, 20 + White + Microsoft Sans Serif, 10pt + None + TopLeft + False + False + No + References + False Black - - - 443, 4 - 71, 20 - White - True - Segoe UI, 9pt - None - MiddleRight - False - False - No - BaseDataItem2147483646 - False - Black - Black - ReferenceCount - BaseDataItem2147483646 - - - 254, 4 - 156, 20 - White - True - Microsoft Sans Serif, 10pt - None - TopLeft - False - False - No - References - False - Black - Black - References - BaseDataItem2 - - - - 0 - BaseRowItem1 - + Black + References + BaseDataItem2 + 31, 22 641, 30 LightGray - True False Black Black @@ -201,7 +180,6 @@ 414, 7 100, 20 White - True Segoe UI, 9.75pt None MiddleRight @@ -218,7 +196,6 @@ 254, 2 100, 20 White - True Microsoft Sans Serif, 10pt None TopLeft @@ -235,7 +212,6 @@ 12, 3 211, 20 White - True Microsoft Sans Serif, 10pt None TopLeft @@ -263,7 +239,6 @@ 50, 339 727, 36 White - False 0 0 False @@ -271,9 +246,8 @@ 31, 5 - 555, 20 + 365, 20 White - True Segoe UI, 9.75pt None TopLeft @@ -287,10 +261,9 @@ BaseTextItem2147483641 - 624, 5 - 100, 20 + 526, 5 + 198, 20 White - True Microsoft Sans Serif, 10pt None TopLeft @@ -312,7 +285,6 @@ 50, 390 727, 60 White - False 0 0 False diff --git a/src/AddIns/Analysis/CodeQuality/Reporting/OverviewReport.cs b/src/AddIns/Analysis/CodeQuality/Reporting/OverviewReport.cs index 155ff6bbde..f066ae6c70 100644 --- a/src/AddIns/Analysis/CodeQuality/Reporting/OverviewReport.cs +++ b/src/AddIns/Analysis/CodeQuality/Reporting/OverviewReport.cs @@ -23,9 +23,11 @@ using System.IO; using System.Linq; using System.Reflection; -using ICSharpCode.CodeQuality.Engine.Dom; using ICSharpCode.NRefactory.Utils; -using ICSharpCode.Reports.Core; +using ICSharpCode.Reporting; +using ICSharpCode.Reporting.Interfaces; +using ICSharpCode.Reporting.Items; +using ICSharpCode.CodeQuality.Engine.Dom; namespace ICSharpCode.CodeQuality.Reporting { @@ -35,6 +37,7 @@ namespace ICSharpCode.CodeQuality.Reporting public class OverviewReport:BaseReport { private const string overviewReport = "OverviewReport.srd"; + ReadOnlyCollection list; public OverviewReport(List fileNames):base(fileNames) { @@ -42,27 +45,69 @@ namespace ICSharpCode.CodeQuality.Reporting public IReportCreator Run(ReadOnlyCollection list) { - System.Reflection.Assembly asm = Assembly.GetExecutingAssembly(); - System.IO.Stream stream = asm.GetManifestResourceStream("ICSharpCode.CodeQuality.Reporting.Overviewreport.srd"); - var model = ReportEngine.LoadReportModel(stream); - ReportSettings = model.ReportSettings; - - var r = from c in list - select new OverviewViewModel { Node = c}; + this.list = list; + var asm = Assembly.GetExecutingAssembly(); + var stream = asm.GetManifestResourceStream("ICSharpCode.CodeQuality.Reporting.Overviewreport.srd"); - var p = new ReportParameters(); - p.Parameters.Add(new BasicParameter ("param1",base.FileNames[0])); - p.Parameters.Add(new BasicParameter ("param2",list.Count.ToString())); + var viewModelList = CreateViewModel(list); - IReportCreator creator = ReportEngine.CreatePageBuilder(model,r.ToList(),p); - creator.BuildExportList(); - return creator; + var reportingFactory = new ReportingFactory(); + var reportCreator = reportingFactory.ReportCreator (stream,viewModelList); + ReportSettings = reportingFactory.ReportModel.ReportSettings; +// var reportParameters = new ParameterCollection(); +// reportParameters.Add(new BasicParameter ("param1",base.FileNames[0])); +// reportParameters.Add(new BasicParameter ("param2",list.Count.ToString())); +// +// ReportSettings.ParameterCollection.AddRange(reportParameters); + reportCreator.SectionRendering += HandleSectionEvents; + reportCreator.BuildExportList(); + return reportCreator; + } + + + static IEnumerable CreateViewModel(ReadOnlyCollection list) + { + var newList = from c in list + select new OverviewViewModel { + Node = c + }; + return newList; } + + void HandleSectionEvents(object sender, SectionEventArgs e) + { + var sectionName = e.Section.Name; + if (sectionName == ReportSectionNames.ReportHeader) { + + var param1 = (BaseTextItem)e.Section.Items.FirstOrDefault(n => n.Name == "Param1"); +// FileInfo fi =new FileInfo(FileNames[0]); +// var s = fi..Directory + fi.Name; + param1.Text = FileNames[0]; + var param2 = (BaseTextItem)e.Section.Items.FirstOrDefault(n => n.Name == "Param2"); + param2.Text = list.Count.ToString(); + } + + else if (sectionName == ReportSectionNames.ReportPageHeader) { + Console.WriteLine("PushPrinting :" +ReportSectionNames .ReportPageHeader); + } + + else if (sectionName == ReportSectionNames.ReportDetail){ +// Console.WriteLine("PushPrinting :" + ReportSectionNames.ReportDetail); + } + + else if (sectionName == ReportSectionNames.ReportPageFooter){ +// Console.WriteLine("PushPrinting :" + ReportSectionNames.ReportPageFooter); + } + + else if (sectionName == ReportSectionNames.ReportFooter){ +// Console.WriteLine("PushPrinting :" + ReportSectionNames.ReportFooter); + } + } } - internal class OverviewViewModel:ReportViewModel + class OverviewViewModel:ReportViewModel { public OverviewViewModel () { diff --git a/src/AddIns/Analysis/CodeQuality/Reporting/Overviewreport.srd b/src/AddIns/Analysis/CodeQuality/Reporting/Overviewreport.srd index 47025247ea..bd125d8502 100644 --- a/src/AddIns/Analysis/CodeQuality/Reporting/Overviewreport.srd +++ b/src/AddIns/Analysis/CodeQuality/Reporting/Overviewreport.srd @@ -15,15 +15,7 @@ - - - param1 - System.String - - - param2 - - + @@ -39,7 +31,6 @@ 50, 50 727, 168 White - False 0 0 False @@ -49,7 +40,6 @@ 122, 13 414, 40 White - True Segoe UI, 18pt, style=Bold None TopLeft @@ -64,16 +54,17 @@ 601, 59 - 100, 26 + 100, 34 White - True Segoe UI, 15.75pt + dd/MM/yyyy None TopLeft False False + System.DateTime No - =Today() + =Today False Black ControlText @@ -83,7 +74,6 @@ 12, 145 680, 10 White - True ControlText 10, 5 669, 6 @@ -98,24 +88,22 @@ 139, 118 108, 20 White - True Segoe UI, 9pt None TopLeft False False No - =Parameters!param2 + Parameters!param2 False Black ControlText - BaseTextItem2147483639 + Param2 27, 118 106, 20 White - True Segoe UI, 9pt None TopLeft @@ -130,16 +118,15 @@ 139, 91 - 438, 20 + 377, 20 White - True Segoe UI, 9pt None TopLeft - False + True False No - =Parameters!param1 + Parameters!param1 False Black ControlText @@ -149,7 +136,6 @@ 27, 91 106, 20 White - True Segoe UI, 9pt None TopLeft @@ -166,7 +152,6 @@ 195, 59 257, 26 White - True Microsoft Sans Serif, 15.75pt None TopLeft @@ -188,7 +173,6 @@ 50, 233 727, 60 White - False 0 0 False @@ -198,7 +182,6 @@ 14, 16 658, 30 LightGray - True False ControlText Black @@ -207,7 +190,6 @@ 571, 7 41, 20 White - True Segoe UI, 9pt None MiddleRight @@ -224,7 +206,6 @@ 501, 7 53, 20 White - True Segoe UI, 9pt None MiddleRight @@ -241,7 +222,6 @@ 425, 7 55, 20 White - True Segoe UI, 9pt None MiddleRight @@ -258,7 +238,6 @@ 347, 7 52, 20 White - True Segoe UI, 9pt None MiddleRight @@ -275,7 +254,6 @@ 267, 7 55, 20 White - True Segoe UI, 9pt None MiddleRight @@ -292,7 +270,6 @@ 4, 7 100, 20 White - True Segoe UI, 9pt None TopLeft @@ -318,7 +295,6 @@ 50, 308 727, 60 White - False 0 0 False @@ -328,7 +304,6 @@ 14, 14 658, 30 White - True False Black Black @@ -337,7 +312,6 @@ 571, 3 41, 20 White - True Segoe UI, 9pt None MiddleRight @@ -355,7 +329,6 @@ 501, 3 53, 20 White - True Segoe UI, 9pt None MiddleRight @@ -373,7 +346,6 @@ 425, 3 55, 20 White - True Segoe UI, 9pt None MiddleRight @@ -391,7 +363,6 @@ 347, 3 52, 20 White - True Segoe UI, 9pt None MiddleRight @@ -409,7 +380,6 @@ 268, 3 54, 20 White - True Segoe UI, 9pt 0 None @@ -429,7 +399,6 @@ 4, 3 258, 20 White - True Microsoft Sans Serif, 10pt None TopLeft @@ -456,7 +425,6 @@ 50, 383 727, 37 White - False 0 0 False @@ -466,7 +434,6 @@ 14, 3 573, 20 White - True Segoe UI, 9.75pt None TopLeft @@ -483,7 +450,6 @@ 614, 3 100, 20 White - True Microsoft Sans Serif, 10pt None TopLeft @@ -505,7 +471,6 @@ 50, 435 727, 60 White - False 0 0 False diff --git a/src/AddIns/DisplayBindings/Data/ICSharpCode.Data.SQLServer/SQLServerDatabaseDriver.cs b/src/AddIns/DisplayBindings/Data/ICSharpCode.Data.SQLServer/SQLServerDatabaseDriver.cs index 1477ffda1a..c8121bfa9f 100644 --- a/src/AddIns/DisplayBindings/Data/ICSharpCode.Data.SQLServer/SQLServerDatabaseDriver.cs +++ b/src/AddIns/DisplayBindings/Data/ICSharpCode.Data.SQLServer/SQLServerDatabaseDriver.cs @@ -154,7 +154,9 @@ namespace ICSharpCode.Data.Core.DatabaseDrivers.SQLServer public override string ODBCProviderName { - get { return "SQLNCLI10.1"; } + // SqlServer 2012 + get { return "SQLNCLI10.1"; } +// get { return "SQLNCLI11.0"; } } public override void PopulateDatasources() diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/Commands/ViewCommands.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/Commands/ViewCommands.cs new file mode 100644 index 0000000000..d4911867ec --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/Commands/ViewCommands.cs @@ -0,0 +1,36 @@ +/* + * Created by SharpDevelop. + * User: Peter Forstmeier + * Date: 17.02.2014 + * Time: 20:07 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +using System; +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop.Workbench; + +namespace ICSharpCode.Reporting.Addin.Commands +{ + /// + /// Description of ViewCommands. + /// + public class CreateDesignerCommand : AbstractMenuCommand + { + readonly OpenedFile openedFile; + + public CreateDesignerCommand (OpenedFile openedFile) { + if (openedFile == null) + throw new ArgumentNullException("openedFile"); + this.openedFile = openedFile; + } + + public override void Run(){ +// var generator = new ReportDesignerGenerator(); +// DesignerView = new ReportDesignerView(openedFile, generator); + MessageService.ShowMessage("ReportDesigner not available at the Moment","New ReportDesigner"); + } + +// public ReportDesignerView DesignerView {get; private set;} + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/Configuration/AssemblyInfo.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/Configuration/AssemblyInfo.cs new file mode 100644 index 0000000000..aa3d0a9cc4 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/Configuration/AssemblyInfo.cs @@ -0,0 +1,16 @@ +/* + * Created by SharpDevelop. + * User: Peter Forstmeier + * Date: 10.02.2014 + * Time: 20:24 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System.Reflection; + +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] \ No newline at end of file diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/DesignerBinding/DesignerBinding.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/DesignerBinding/DesignerBinding.cs new file mode 100644 index 0000000000..7009e0ba9d --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/DesignerBinding/DesignerBinding.cs @@ -0,0 +1,64 @@ +/* + * Created by SharpDevelop. + * User: Peter Forstmeier + * Date: 11.02.2014 + * Time: 20:19 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.IO; +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Workbench; +using ICSharpCode.Reporting.Addin.Commands; + +namespace ICSharpCode.Reporting.Addin.DesignerBinding { + + + public class ReportDesignerBinding:IDisplayBinding { + + + public bool IsPreferredBindingForFile(FileName fileName) + { + return true; + } + + + public bool CanCreateContentForFile(FileName fileName) + { + return Path.GetExtension(fileName).Equals(".srd", StringComparison.OrdinalIgnoreCase); + } + + + public double AutoDetectFileContent(FileName fileName, System.IO.Stream fileContent, string detectedMimeType) + { + throw new System.NotImplementedException(); + } + + + public IViewContent CreateContentForFile(OpenedFile file) + { + // MessageService.ShowMessage("ReportDesigner not available at the Moment","New ReportDesigner"); + // return null; + + if (file.IsDirty) { + MessageService.ShowMessage("ReportWizard not available at the Moment","New ReportDesigner"); + return null; + // var cmd = new ReportWizardCommand(file); + // cmd.Run(); + // if (cmd.Canceled) { + // return null; + // } + // file.SetData(cmd.GeneratedReport.ToArray()); + } + + var viewCmd = new CreateDesignerCommand(file); + viewCmd.Run(); + // return viewCmd.DesignerView; + return null; + + } + } +} \ No newline at end of file diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/EmptyReport.xft b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/EmptyReport.xft new file mode 100644 index 0000000000..2df9438229 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/EmptyReport.xft @@ -0,0 +1,19 @@ + + + diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/ICSharpCode.Reporting.Addin.csproj b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/ICSharpCode.Reporting.Addin.csproj new file mode 100644 index 0000000000..31efb742fb --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/ICSharpCode.Reporting.Addin.csproj @@ -0,0 +1,100 @@ + + + + {0502FCF7-72F4-4587-936B-D0238CD0E072} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Debug + AnyCPU + Library + ICSharpCode.Reporting.Addin + ICSharpCode.Reporting.Addin + Properties + False + False + False + False + obj\$(Configuration)\ + 4 + v4.5 + + + + x86 + 4194304 + False + Auto + 4096 + + + ..\..\..\..\..\AddIns\Misc\SharpDevelopReporting\ + True + Full + False + True + DEBUG;TRACE + obj\ + + + bin\Release\ + False + None + True + False + TRACE + + + + 4.0 + + + + 3.5 + + + + 3.5 + + + + 3.5 + + + + + + + + + + Configuration\GlobalAssemblyInfo.cs + + + + + + + + Always + + + Always + + + + + {2748AD25-9C63-4E12-877B-4DCE96FBED54} + ICSharpCode.SharpDevelop + False + + + {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} + ICSharpCode.Core + False + + + {40CA84D4-ACFC-4646-9CDD-B87262D34093} + ICSharpCode.Reporting + + + + \ No newline at end of file diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/ICSharpCode.Reporting.addin b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/ICSharpCode.Reporting.addin new file mode 100644 index 0000000000..b971024ca0 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/ICSharpCode.Reporting.addin @@ -0,0 +1,181 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj index 0351c2a900..4b230cf91a 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj @@ -44,6 +44,15 @@ TRACE + + ..\Libraries\Irony.dll + + + ..\Libraries\Irony.Interpreter.dll + + + ..\Libraries\PdfSharp.dll + 3.0 @@ -54,6 +63,7 @@ 3.5 + 3.5 @@ -70,16 +80,18 @@ + + Src\Configuration\GlobalAssemblyInfo.cs + - - + + - - + @@ -88,22 +100,39 @@ + + + + + - + + - - + + + + + + + + + + + - - + + + + @@ -113,24 +142,47 @@ + + + + + + + + + + + + + + + + + + + + + + + WpfReportViewer.xaml Code @@ -141,6 +193,9 @@ + + + @@ -152,19 +207,31 @@ - + + + + + + + + + {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} + ICSharpCode.Core + false + + \ No newline at end of file diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Arrange/ArrangeStrategy.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Arrange/ArrangeStrategy.cs index 42849e95f5..fa56c5c805 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Arrange/ArrangeStrategy.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Arrange/ArrangeStrategy.cs @@ -17,9 +17,10 @@ // DEALINGS IN THE SOFTWARE. using System; +using System.Collections; using System.Drawing; using System.Linq; - +using System.Collections.Generic; using ICSharpCode.Reporting.Interfaces.Export; namespace ICSharpCode.Reporting.Arrange @@ -29,65 +30,97 @@ namespace ICSharpCode.Reporting.Arrange /// /// public interface IArrangeStrategy - { - void Arrange(IExportColumn exportColumn); - } + { + void Arrange(IExportColumn exportColumn); + } internal class ContainerArrangeStrategy:IArrangeStrategy { - public ContainerArrangeStrategy() - { - } - - public void Arrange(IExportColumn exportColumn) - { + public void Arrange(IExportColumn exportColumn){ if (exportColumn == null) throw new ArgumentNullException("exportColumn"); var container = exportColumn as IExportContainer; if ((container != null) && (container.ExportedItems.Count > 0)) { + List canGrowItems = CreateCanGrowList(container); + if (canGrowItems.Count > 0) { + var containerSize = ArrangeInternal(container); + if (containerSize.Height > container.DesiredSize.Height) { + container.DesiredSize = new Size(containerSize.Width,containerSize.Height); + } + } + } + } + + + static Size ArrangeInternal(IExportContainer container) + { + var containerRectangle = container.DisplayRectangle; + Rectangle elementRectangle = Rectangle.Empty; + + foreach (var element in container.ExportedItems) { + var con = element as IExportContainer; + if (con != null) { + var keep = containerRectangle; + con.DesiredSize = ArrangeInternal(con); + elementRectangle = AdujstRectangles(keep,con.DisplayRectangle); + containerRectangle = keep; + + } else { + elementRectangle = AdujstRectangles(containerRectangle,element.DisplayRectangle); + } - - FindBiggestRectangle(container); - var resizeable = from resize in container.ExportedItems - where ((resize.CanGrow == true)) - select resize; - - if (resizeable.Any()) { - if (!BiggestRectangle.IsEmpty) { - var containerRectangle = new Rectangle(container.Location,container.Size); - var desiredRectangle = Rectangle.Union(containerRectangle,BiggestRectangle); - container.DesiredSize = new Size(container.Size.Width,desiredRectangle.Size.Height + 5); - } + if (!containerRectangle.Contains(elementRectangle)) { + + containerRectangle = new Rectangle(containerRectangle.Left, + containerRectangle.Top , + containerRectangle.Width, + element.Location.Y + elementRectangle.Size.Height + 5); + +// containerRectangle = Rectangle.Union(containerRectangle,elementRectangle); } } + return containerRectangle.Size; + } + + + static Rectangle AdujstRectangles (Rectangle container,Rectangle element) { + return new Rectangle(container.Left + element.Left, + container.Top + element.Top, + element.Size.Width, + element.Size.Height); } - private void FindBiggestRectangle (IExportContainer container) + + static List CreateCanGrowList(IExportContainer container) { - BiggestRectangle = Rectangle.Empty; - /* - foreach (var item in container.ExportedItems) - { - if (item.DesiredSize.Height > BiggestRectangle.Size.Height) - { - BiggestRectangle = new Rectangle(new Point(container.Location.X + item.Location.X, - container.Location.Y + item.Location.Y) - , item.DesiredSize); - } - } - */ - foreach (var item in container.ExportedItems - .Where(item => item.DesiredSize.Height > BiggestRectangle.Size.Height)) - { - BiggestRectangle = new Rectangle(new Point(container.Location.X + item.Location.X, - container.Location.Y + item.Location.Y) - ,item.DesiredSize); - } + var l1 = new List(); + foreach (var element in container.Descendents()) { + if (element.CanGrow) { + l1.Add(element); + } + } + return l1; } - - public Rectangle BiggestRectangle {get; private set;} } + + static class Extensions { + + public static IEnumerable Descendents(this IExportContainer node) { + if (node == null) throw new ArgumentNullException("node"); + if(node.ExportedItems.Count > 0) { + foreach (var child in node.ExportedItems) { + var cont = child as IExportContainer; + if (cont != null) { + foreach (var desc in Descendents(cont)) { + yield return desc; + } + } + yield return child; + } + } + } + } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Arrange/MeasurementStrategy.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Arrange/MeasurementStrategy.cs index 9cab307e3a..7dcf2f3b08 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Arrange/MeasurementStrategy.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Arrange/MeasurementStrategy.cs @@ -19,8 +19,8 @@ using System; using System.Drawing; using ICSharpCode.Reporting.Globals; -using ICSharpCode.Reporting.Interfaces; -using ICSharpCode.Reporting.Items; +using ICSharpCode.Reporting.Interfaces.Export; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; namespace ICSharpCode.Reporting.Arrange { @@ -29,28 +29,38 @@ namespace ICSharpCode.Reporting.Arrange /// public interface IMeasurementStrategy { - Size Measure(IPrintableObject reportItem,Graphics graphics); + Size Measure(IExportColumn exportColumn,Graphics graphics); } - internal class ContainerMeasurementStrategy:IMeasurementStrategy + class ContainerMeasurementStrategy:IMeasurementStrategy { - public ContainerMeasurementStrategy() - { - } - public Size Measure(IPrintableObject reportItem,Graphics graphics) + public Size Measure(IExportColumn exportColumn,Graphics graphics) { - return reportItem.Size; + var items = ((ExportContainer)exportColumn).ExportedItems; + + foreach (var element in items) { + if (element is IExportContainer) { + Measure(element,graphics); + } + var tbi = element as IExportText; + if (tbi != null) { + element.DesiredSize = MeasurementService.Measure(tbi,graphics); + } + } + exportColumn.DesiredSize = exportColumn.Size; + return exportColumn.DesiredSize; } } - internal class TextBasedMeasurementStrategy:IMeasurementStrategy + + class TextBasedMeasurementStrategy:IMeasurementStrategy { - public Size Measure(IPrintableObject reportItem, Graphics graphics) + public Size Measure(IExportColumn exportColumn, Graphics graphics) { - return MeasurementService.Measure((ITextItem)reportItem,graphics); + return MeasurementService.Measure((IExportText)exportColumn,graphics); } } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/BasicParameter.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/BasicParameter.cs new file mode 100644 index 0000000000..08ac722859 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/BasicParameter.cs @@ -0,0 +1,40 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +namespace ICSharpCode.Reporting +{ + /// + /// Description of BasicParameter. + /// + public class BasicParameter + { + public BasicParameter (){ + } + + public BasicParameter(string parameterName,string parameterValue){ + this.ParameterName = parameterName; + this.ParameterValue = parameterValue; + } + + public string ParameterName {get;set;} + + public string Type {get;set;} + + public string ParameterValue {get;set;} + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/ExtensionMethods.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/ExtensionMethods.cs new file mode 100644 index 0000000000..6458759e5a --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/ExtensionMethods.cs @@ -0,0 +1,110 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Windows; +using System.Windows.Media; +namespace ICSharpCode.Reporting.BaseClasses +{ + /// + /// Description of ExtensionMethodes. + /// Copy from D:\git_Sharpdevelop_Reporting\src\AddIns\Misc\Reports\ICSharpCode.Reports.Core\Project\WPF\ExtensionMethodes.cs + /// + /// (this IEnumerable input, Action action) + { + if (input == null) + throw new ArgumentNullException("input"); + foreach (T element in input) { + action(element); + } + } + + #endregion + + #region system.drawing -> Wpf + + public static Point ToWpf(this System.Drawing.Point p) + { + return new Point(p.X, p.Y); + } + + public static Size ToWpf(this System.Drawing.Size s) + { + return new Size(s.Width, s.Height); + } + + public static Rect ToWpf(this System.Drawing.Rectangle rect) + { + return new Rect(rect.Location.ToWpf(), rect.Size.ToWpf()); + } + + public static System.Windows.Media.Color ToWpf(this System.Drawing.Color c) + { + return System.Windows.Media.Color.FromArgb(c.A, c.R, c.G, c.B); + } + + #endregion + + #region DPI independence + public static Rect TransformToDevice(this Rect rect, Visual visual) + { + Matrix matrix = PresentationSource.FromVisual(visual).CompositionTarget.TransformToDevice; + return Rect.Transform(rect, matrix); + } + + public static Rect TransformFromDevice(this Rect rect, Visual visual) + { + Matrix matrix = PresentationSource.FromVisual(visual).CompositionTarget.TransformFromDevice; + return Rect.Transform(rect, matrix); + } + + public static Size TransformToDevice(this Size size, Visual visual) + { + Matrix matrix = PresentationSource.FromVisual(visual).CompositionTarget.TransformToDevice; + return new Size(size.Width * matrix.M11, size.Height * matrix.M22); + } + + public static Size TransformFromDevice(this Size size, Visual visual) + { + Matrix matrix = PresentationSource.FromVisual(visual).CompositionTarget.TransformFromDevice; + return new Size(size.Width * matrix.M11, size.Height * matrix.M22); + } + + public static Point TransformToDevice(this Point point, Visual visual) + { + Matrix matrix = PresentationSource.FromVisual(visual).CompositionTarget.TransformToDevice; + return new Point(point.X * matrix.M11, point.Y * matrix.M22); + } + + public static Point TransformFromDevice(this Point point, Visual visual) + { + Matrix matrix = PresentationSource.FromVisual(visual).CompositionTarget.TransformFromDevice; + return new Point(point.X * matrix.M11, point.Y * matrix.M22); + } + #endregion + + + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/Page.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/Page.cs deleted file mode 100644 index d803f070ff..0000000000 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/Page.cs +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of this -// software and associated documentation files (the "Software"), to deal in the Software -// without restriction, including without limitation the rights to use, copy, modify, merge, -// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons -// to whom the Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all copies or -// substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE -// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -using System; -using System.Collections.Generic; -using System.Drawing; - -using ICSharpCode.Reporting.Interfaces; -using ICSharpCode.Reporting.Interfaces.Export; - -namespace ICSharpCode.Reporting.BaseClasses -{ - /// - /// Description of Page. - /// - /// - - public class Page:IExportContainer,IPage - { - public Page(IPageInfo pageInfo,Size pageSize) - { - if (pageInfo == null) { - throw new ArgumentNullException("pageInfo"); - } - PageInfo = pageInfo; - Name = "Page"; - Size = pageSize; - exportedItems = new List(); - } - - public bool IsFirstPage {get;set;} - - - public IPageInfo PageInfo {get;private set;} - - - public string Name {get;set;} - - - public System.Drawing.Size Size {get;set;} - - - public System.Drawing.Point Location {get;set;} - - - public List exportedItems; - - public List ExportedItems { - get { return exportedItems; } - } - - - public IExportContainer CreateExportColumn() - { - throw new NotImplementedException(); - } - - public ICSharpCode.Reporting.Arrange.IArrangeStrategy GetArrangeStrategy() - { - throw new NotImplementedException(); - } - - public Size DesiredSize { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } - - public Color ForeColor { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } - - public Color BackColor { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } - - - public Color FrameColor { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } - - - public IExportColumn Parent { - get { - return null; - } - set { - throw new NotImplementedException(); - } - } - - public bool CanGrow {get;set;} - - public bool CanShrink {get;set;} - - public Rectangle DisplayRectangle { - get { - return new Rectangle(Location,Size); - } - } - } -} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Collections.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Collections.cs index 5ddac20cc9..5bc4688209 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Collections.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Collections.cs @@ -27,15 +27,9 @@ using ICSharpCode.Reporting.Items; namespace ICSharpCode.Reporting { - /// - /// Description of Collections. - /// - public class ColumnCollection: Collection{ - - public ColumnCollection() - { - } + public class SortColumnCollection: Collection + { public AbstractColumn Find (string columnName) { @@ -43,33 +37,22 @@ namespace ICSharpCode.Reporting throw new ArgumentNullException("columnName"); } - return this.FirstOrDefault(x => 0 == String.Compare(x.ColumnName,columnName,true,CultureInfo.InvariantCulture)); + return this.FirstOrDefault(x => 0 == String.Compare(x.ColumnName,columnName,StringComparison.OrdinalIgnoreCase)); } - public void AddRange (IEnumerable items) + public void AddRange (IEnumerable items) { - foreach (AbstractColumn item in items){ + foreach (SortColumn item in items){ this.Add(item); } } - - - /// - /// The Culture is used for direct String Comparison - /// - - public static CultureInfo Culture - { - get { return CultureInfo.CurrentCulture;} - } } - - public class SortColumnCollection: ColumnCollection + public class GroupColumnCollection: SortColumnCollection { - public SortColumnCollection() + public GroupColumnCollection() { } @@ -79,49 +62,38 @@ namespace ICSharpCode.Reporting throw new ArgumentNullException("columnName"); } - return this.FirstOrDefault(x => 0 == String.Compare(x.ColumnName,columnName,true,CultureInfo.InvariantCulture)); - } - - - public void AddRange (IEnumerable items) - { - foreach (SortColumn item in items){ - this.Add(item); - } + return this.FirstOrDefault(x => 0 == String.Compare(x.ColumnName,columnName,StringComparison.OrdinalIgnoreCase)); } } - public class GroupColumnCollection: SortColumnCollection - { - public GroupColumnCollection() - { + public class ParameterCollection: Collection{ + + public ParameterCollection() + { } - public new AbstractColumn Find (string columnName) + + public BasicParameter Find (string parameterName) { - if (String.IsNullOrEmpty(columnName)) { - throw new ArgumentNullException("columnName"); + if (String.IsNullOrEmpty(parameterName)) { + throw new ArgumentNullException("parameterName"); } - - return this.FirstOrDefault(x => 0 == String.Compare(x.ColumnName,columnName,true,CultureInfo.InvariantCulture)); + return this.FirstOrDefault(x => 0 == String.Compare(x.ParameterName,parameterName,StringComparison.OrdinalIgnoreCase)); } - } - - - public class ReportItemCollection : Collection - { - // Trick to get the inner list as List (InnerList always has that type because we only use - // the parameterless constructor on Collection) - private List InnerList { - get { return (List)base.Items; } + public static CultureInfo Culture + { + get { return System.Globalization.CultureInfo.CurrentCulture; } } - private void Sort(IComparer comparer) + + public void AddRange (IEnumerable items) { - InnerList.Sort(comparer); + foreach (BasicParameter item in items){ + this.Add(item); + } } } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/CollectionDataSource.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/CollectionDataSource.cs new file mode 100644 index 0000000000..eed7ca2ad0 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/CollectionDataSource.cs @@ -0,0 +1,233 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Linq; + +using ICSharpCode.Reporting.BaseClasses; +using ICSharpCode.Reporting.DataSource; +using ICSharpCode.Reporting.Interfaces; +using ICSharpCode.Reporting.Interfaces.Data; +using ICSharpCode.Reporting.Items; + +namespace ICSharpCode.Reporting.DataManager.Listhandling +{ + /// + /// Description of DataSource. + /// + public enum OrderGroup { + AsIs, + Sorted, + Grouped + } + + public class CollectionDataSource:IDataSource + { + readonly DataCollection baseList; + readonly ReportSettings reportSettings; +// readonly Type elementType; + readonly PropertyDescriptorCollection listProperties; + + + public CollectionDataSource(IEnumerable list, ReportSettings reportSettings) + { + if (list == null) + throw new ArgumentNullException("list"); + if (reportSettings == null) + throw new ArgumentNullException("reportSettings"); + baseList = CreateBaseList(list); + CurrentList = baseList; + + this.reportSettings = reportSettings; + this.listProperties = this.baseList.GetItemProperties(null); + OrderGroup = OrderGroup.AsIs; + } + + + [Obsolete("use public CollectionDataSource(IEnumerable list, ReportSettings reportSettings")] + public CollectionDataSource(IEnumerable list, Type elementType, ReportSettings reportSettings) + { + if (list == null) + throw new ArgumentNullException("list"); + if (reportSettings == null) + throw new ArgumentNullException("reportSettings"); + + baseList = CreateBaseList(list); + CurrentList = baseList; + this.reportSettings = reportSettings; + this.listProperties = this.baseList.GetItemProperties(null); + OrderGroup = OrderGroup.AsIs; + } + + + + public Collection AvailableFields { + get { + var availableFields = new Collection(); + foreach (PropertyDescriptor p in this.listProperties){ + availableFields.Add (new AbstractColumn(p.Name,p.PropertyType)); + } + return availableFields; + } + } + + + public IList CurrentList {get;private set;} + + + public int Count { + get {return baseList.Count;} + } + + public object Current {get; private set;} + + public OrderGroup OrderGroup {get; private set;} + + public IEnumerable SortedList {get; private set;} + + public IEnumerable> GroupedList {get;private set;} + + #region Sort + + void Sort() + { + if (reportSettings.SortColumnsCollection.Count > 0) { + SortedList = SortInternal(); + OrderGroup = OrderGroup.Sorted; + } else { + OrderGroup = OrderGroup.AsIs; + SortedList = CurrentList; + } + + } + + + IEnumerable SortInternal (){ + IEnumerable sortedList = null; + var sortProperty = listProperties.Find(reportSettings.SortColumnsCollection[0].ColumnName,true); + if(reportSettings.SortColumnsCollection.Count == 1) { + sortedList = baseList.OrderBy(o => o.GetType().GetProperty(sortProperty.Name).GetValue(o, null) ); + } + return sortedList; + } + + #endregion + + + #region Grouping + + void Group() + { + OrderGroup = OrderGroup.Grouped; + GroupedList = GroupInternal(); + } + + + IEnumerable> GroupInternal () { + PropertyDescriptor sortProperty = null; + var groupProperty = listProperties.Find(reportSettings.GroupColumnsCollection[0].ColumnName,true); + var groupColumn = (GroupColumn)reportSettings.GroupColumnsCollection[0]; + + if (groupColumn.GroupSortColumn != null) { + sortProperty = listProperties.Find(groupColumn.GroupSortColumn.ColumnName,true); + } + IEnumerable> groupedList; + if (sortProperty == null) { + groupedList = baseList.GroupBy(a => a.GetType().GetProperty(groupProperty.Name).GetValue(a, null)).OrderBy(c => c.Key); + } else { + groupedList = baseList.OrderBy(o => o.GetType().GetProperty(sortProperty.Name).GetValue(o, null) ) + .GroupBy(a => a.GetType().GetProperty(groupProperty.Name).GetValue(a, null)).OrderBy(c => c.Key); + } + return groupedList; + } + + #endregion + + public void Bind() + { + if (reportSettings.GroupColumnsCollection.Any()) { + Group(); + } else { + Sort(); + } + } + + + #region Fill + + public void Fill (List collection, object current) { + Current = current; + foreach (var element in collection) { + var container = element as ReportContainer; + if (container != null) { + FillFromList(container.Items); + } else { + FillInternal(element); + } + } + } + + void FillFromList(List collection) + { + foreach (IPrintableObject item in collection) { + FillInternal(item); + } + } + + + void FillInternal(IPrintableObject item) + { + var dbItem = item as IDataItem; + if (dbItem != null) { + dbItem.DBValue = String.Empty; + dbItem.DBValue = ReadValueFromProperty(dbItem.ColumnName); + if (String.IsNullOrEmpty(dbItem.DataType)) { + dbItem.DataType = SetTypeFromProperty(dbItem.ColumnName).ToString(); + } + } + } + + + string ReadValueFromProperty (string columnName) { + var propertyPath = Current.ParsePropertyPath(columnName); + var val = propertyPath.Evaluate(Current); + return val.ToString(); + } + + + Type SetTypeFromProperty (string columnName) { + var p = listProperties.Find(columnName,true); + return p.PropertyType; + } + + #endregion + + + static DataCollection CreateBaseList(IEnumerable source) + { + Type elementType = source.AsQueryable().ElementType; + var list = new DataCollection(elementType); + list.AddRange(source); + return list; + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/CollectionSource.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/CollectionSource.cs deleted file mode 100644 index 40d6635998..0000000000 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/CollectionSource.cs +++ /dev/null @@ -1,416 +0,0 @@ -// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of this -// software and associated documentation files (the "Software"), to deal in the Software -// without restriction, including without limitation the rights to use, copy, modify, merge, -// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons -// to whom the Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all copies or -// substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE -// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.ComponentModel; -using System.Globalization; -using System.Linq; -using System.Reflection; - -using ICSharpCode.Reporting.BaseClasses; -using ICSharpCode.Reporting.DataManager.Listhandling; -using ICSharpCode.Reporting.DataSource; -using ICSharpCode.Reporting.DataSource.Comparer; -using ICSharpCode.Reporting.Interfaces; -using ICSharpCode.Reporting.Interfaces.Data; -using ICSharpCode.Reporting.Items; - -namespace ICSharpCode.Reporting.DataManager.Listhandling -{ - /// - /// Description of CollectionHandling. - /// - internal class CollectionSource:IDataViewHandling - { - - private PropertyDescriptorCollection listProperties; - private DataCollection baseList; - private ReportSettings reportSettings; - private Type itemType; - - public CollectionSource(IList list,ReportSettings reportSettings) - { - - if (list.Count > 0) { - itemType = list[0].GetType(); - this.baseList = new DataCollection (itemType); - this.baseList.AddRange(list); - } - this.reportSettings = reportSettings; - this.listProperties = this.baseList.GetItemProperties(null); - IndexList = new IndexList(); - } - - public int Count - { - get { - return this.baseList.Count; - } - } - - public Collection AvailableFields { - get { - var availableFields = new Collection(); - foreach (PropertyDescriptor p in this.listProperties){ - availableFields.Add (new AbstractColumn(p.Name,p.PropertyType)); - } - return availableFields; - } - } - - public object Current { - get { - return baseList[((BaseComparer)IndexList[CurrentPosition]).ListIndex]; - } - } - - -// public object CurrentFromPosition(int pos) -// { - // BaseComparer bc = GetComparer(value); -// Current = baseList[bc.ListIndex]; -// return baseList[((BaseComparer)IndexList[CurrentPosition]).ListIndex]; -// } - - - public int CurrentPosition { - - get { - return IndexList.CurrentPosition; - } - set { - if ((value > -1)|| (value > this.IndexList.Count)){ - this.IndexList.CurrentPosition = value; - } - -// BaseComparer bc = GetComparer(value); -// Current = baseList[bc.ListIndex]; - -// current = this.baseList[((BaseComparer)IndexList[value]).ListIndex]; - } - } - - - public bool MoveNext() - { - this.IndexList.CurrentPosition ++; - return this.IndexList.CurrentPosition a.ObjectArray[0]); - var x = sorted.GroupBy(a => a.ObjectArray[0]); - - Console.WriteLine("GroupBy()"); - foreach (var element in x) { - Console.WriteLine("{0} - {1} ",element.Key.ToString(),element is BaseComparer); - foreach (var xx in element) { - Console.WriteLine("...{0}",((BaseComparer)xx).ObjectArray[0].ToString()); - } - } - - Console.WriteLine("--------------- "); - - var aa = BuildGroup_1(unsortedList,reportSettings.GroupColumnCollection); -// ShowIndexList(IndexList); - } - - - private Dictionary BuildGroup_1 (IndexList list,GroupColumnCollection groups) { - var dictionary = new Dictionary(); - PropertyDescriptor[] groupProperties = BuildSortProperties (groups); - foreach (var element in list) { - string groupValue = ExtractValue (element,groupProperties); - if (!dictionary.ContainsKey(groupValue)) { - dictionary[groupValue] = new IndexList(); - } - - dictionary[groupValue].Add(element); - } - - Console.WriteLine("Dictonary "); - foreach (var el in dictionary.Values) { - Console.WriteLine(el.Count.ToString()); - foreach (var element in el) { - Console.WriteLine("-- {0}",element.ToString()); - } - } - return dictionary; - } - - - private IndexList BuildGroup (IndexList source,GroupColumnCollection groups) - { - string compareValue = String.Empty; - var idlist = new IndexList(); - - PropertyDescriptor[] groupProperties = BuildSortProperties (groups); - - GroupComparer groupComparer = null; - - foreach (BaseComparer element in source) { - var groupValue = ExtractValue(element,groupProperties); -// var query2 = idlist.FirstOrDefault( s => ((GroupComparer)s).ObjectArray[0] == groupValue) as GroupComparer; -// if (query2 == null) { -// groupComparer = CreateGroupHeader(element); -// idlist.Add(groupComparer); -// } else { -// Console.WriteLine("xx"); -// } - if (compareValue != groupValue) { - groupComparer = CreateGroupHeader(element); - idlist.Add(groupComparer); - } - groupComparer.IndexList.Add(element); - - compareValue = groupValue; - } - ShowGrouping(ref idlist); - return idlist; - } - - - void ShowGrouping(ref IndexList idlist) - { - Console.WriteLine("----ShowGrouping---"); - foreach (GroupComparer el in idlist) { - Console.WriteLine("{0}", el.ToString()); - if (el.IndexList.Any()) { - foreach (var element in el.IndexList) { - Console.WriteLine("--{0}", element.ToString()); - } - } - } - } - - - string ExtractValue(BaseComparer element,PropertyDescriptor[] groupProperties) - { - var rowItem = baseList[element.ListIndex]; - var values = FillComparer(groupProperties, rowItem); -// return element.ObjectArray[0].ToString(); - return values[0].ToString(); - } - - - static GroupComparer CreateGroupHeader (BaseComparer sc) - { - var gc = new GroupComparer(sc.ColumnCollection,sc.ListIndex,sc.ObjectArray); - gc.IndexList = new IndexList(); - return gc; - } - - #endregion - - #region BuildIndexList - - IndexList BuildSortIndex(Collection sortColumnsCollection) - { - - IndexList indexList = BuildIndexInternal(sortColumnsCollection); - - if (indexList[0].ObjectArray.GetLength(0) == 1) { - - IEnumerable sortedList = GenericSorter (indexList); - indexList.Clear(); - indexList.AddRange(sortedList); - } - else { - indexList.Sort(); - } - return indexList; - } - - - - IndexList BuildIndexInternal(Collection sortColumnsCollection) - { - var indexList = new IndexList(); - PropertyDescriptor[] sortProperties = BuildSortProperties(sortColumnsCollection); - for (int rowIndex = 0; rowIndex < this.baseList.Count; rowIndex++) { - var rowItem = this.baseList[rowIndex]; - var values = FillComparer(sortProperties, rowItem); - indexList.Add(new SortComparer(sortColumnsCollection, rowIndex, values)); - } - return indexList; - } - - #endregion - - #region Sorting delegates - - public void Sort() - { - if ((this.reportSettings.SortColumnsCollection != null)) { - if (this.reportSettings.SortColumnsCollection.Count > 0) { - IndexList = this.BuildSortIndex (reportSettings.SortColumnsCollection); - } else { - IndexList = this.BuildIndexInternal(reportSettings.SortColumnsCollection); - } - } - } - - static IEnumerable GenericSorter (List list) - { - - List sortedList = null; - ListSortDirection sortDirection = GetSortDirection(list); - - sortedList = sortDirection == ListSortDirection.Ascending ? list.AsQueryable().AscendingOrder().ToList() : list.AsQueryable().DescendingOrder().ToList(); - return sortedList; - } - - - static ListSortDirection GetSortDirection(List list) - { - BaseComparer bc = list[0]; - var sortColumn = bc.ColumnCollection[0] as SortColumn; - ListSortDirection sd = sortColumn.SortDirection; - return sd; - } - - - Object[] FillComparer(PropertyDescriptor[] sortProperties, object rowItem) - { - object[] values = new object[sortProperties.Length]; - for (int criteriaIndex = 0; criteriaIndex < sortProperties.Length; criteriaIndex++) { - object value = sortProperties[criteriaIndex].GetValue(rowItem); - if (value != null && value != DBNull.Value) { - if (!(value is IComparable)) { - throw new InvalidOperationException("ReportDataSource:BuildSortArray - > This type doesn't support IComparable." + value.ToString()); - } - values[criteriaIndex] = value; - } - } - return values; - } - - private PropertyDescriptor[] BuildSortProperties (Collection sortColumnCollection) - { - var sortProperties = new PropertyDescriptor[sortColumnCollection.Count]; - var descriptorCollection = this.baseList.GetItemProperties(null); - - for (var criteriaIndex = 0; criteriaIndex < sortColumnCollection.Count; criteriaIndex++){ - var descriptor = descriptorCollection.Find (sortColumnCollection[criteriaIndex].ColumnName,true); - - if (descriptor == null){ - throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, - "Die Liste enthält keine Spalte [{0}].", - sortColumnCollection[criteriaIndex].ColumnName)); - } - sortProperties[criteriaIndex] = descriptor; - } - return sortProperties; - } - - - BaseComparer GetComparer(int position) - { - var bc = (BaseComparer)IndexList[position]; - return bc; - } - - #endregion - - #region Debug Code - - private static void ShowIndexList (IndexList list) - { - foreach (BaseComparer element in list) { - var groupComparer = element as GroupComparer; - if (groupComparer == null) continue; - if (groupComparer.IndexList.Any()) { - var ss = String.Format("{0} with {1} Children",element.ObjectArray[0],groupComparer.IndexList.Count); - System.Console.WriteLine(ss); - foreach (BaseComparer c in groupComparer.IndexList) { - Console.WriteLine("---- {0}",c.ObjectArray[0]); - } - } - } - } - - static string WrongColumnName(string propertyName) - { - return String.Format(CultureInfo.InvariantCulture, "Error : <{0}> missing!", propertyName); - } - - #endregion - - - public void Reset() - { - throw new NotImplementedException(); - } - } -} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/IndexList.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/IndexList.cs index 021700916d..6903e29e97 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/IndexList.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/IndexList.cs @@ -27,11 +27,7 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling /// public class IndexList :List { - - public IndexList() - { - } - + public int CurrentPosition {get;set;} } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/Comparer/GroupComparer.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/Comparer/GroupComparer.cs index 7cb791d18a..fa54526ae8 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/Comparer/GroupComparer.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/Comparer/GroupComparer.cs @@ -34,6 +34,6 @@ namespace ICSharpCode.Reporting.DataSource.Comparer IndexList = new IndexList(); } - public IndexList IndexList {get;set;} + public IndexList IndexList {get;private set;} } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/Comparer/SortComparer.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/Comparer/SortComparer.cs index b4524b571b..1e17a96e0e 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/Comparer/SortComparer.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/Comparer/SortComparer.cs @@ -22,6 +22,7 @@ using System.ComponentModel; using System.Globalization; using ICSharpCode.Reporting.BaseClasses; +using ICSharpCode.Reporting.Items; namespace ICSharpCode.Reporting.DataSource.Comparer { diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/DataCollection.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/DataCollection.cs index 1c187c6163..2e1338acc7 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/DataCollection.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/DataCollection.cs @@ -30,7 +30,7 @@ namespace ICSharpCode.Reporting.DataSource /// /// Description of DataCollection. /// - internal class DataCollection : IList,ITypedList + class DataCollection : IList,ITypedList { Collection list = new Collection(); Type elementType; @@ -89,7 +89,7 @@ namespace ICSharpCode.Reporting.DataSource } - public void AddRange(IList range) + public void AddRange(IEnumerable range) { foreach(T t in range) { Add(t); @@ -207,7 +207,7 @@ namespace ICSharpCode.Reporting.DataSource } [DebuggerStepThrough] - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + IEnumerator System.Collections.IEnumerable.GetEnumerator() { return list.GetEnumerator(); } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/ExtendedPropertyDescriptor.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/ExtendedPropertyDescriptor.cs index c802c1b7ab..3a97b541df 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/ExtendedPropertyDescriptor.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/ExtendedPropertyDescriptor.cs @@ -26,7 +26,7 @@ namespace ICSharpCode.Reporting.DataSource /// /// Description of ExtendedPropertyDescriptor. /// - internal class ExtendedPropertyDescriptor : PropertyDescriptor + class ExtendedPropertyDescriptor : PropertyDescriptor { Type componentType; diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/ExtendedTypeDescriptor.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/ExtendedTypeDescriptor.cs index e042d65204..0b41f0c2da 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/ExtendedTypeDescriptor.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/ExtendedTypeDescriptor.cs @@ -26,7 +26,7 @@ namespace ICSharpCode.Reporting.DataSource /// /// Description of ExtendedTypeDescriptor. /// - internal class ExtendedTypeDescriptor + class ExtendedTypeDescriptor { private static Hashtable collections = new Hashtable(); diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/FieldMemberAccessor.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/FieldMemberAccessor.cs new file mode 100644 index 0000000000..483c4082a0 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/FieldMemberAccessor.cs @@ -0,0 +1,51 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Reflection; + +namespace ICSharpCode.Reporting.DataSource +{ + /// + /// Description of FieldMemberAccessor. + /// + public class FieldMemberAccessor : IMemberAccessor + { + private readonly FieldInfo _field; + + public FieldMemberAccessor(FieldInfo field) + { + _field = field; + } + + public object GetValue(object target) + { + return _field.GetValue(target); + } + + public bool IsStatic + { + get { return _field.IsStatic; } + } + + public Type MemberType + { + get { return _field.FieldType;} + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/PropertyMemberAccessore.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/PropertyMemberAccessore.cs new file mode 100644 index 0000000000..2a96339eaa --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/PropertyMemberAccessore.cs @@ -0,0 +1,58 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Reflection; + +namespace ICSharpCode.Reporting.DataSource +{ + /// + /// Description of PropertyMemberAccessore. + /// + public interface IMemberAccessor + { + object GetValue(object target); + bool IsStatic { get; } + Type MemberType { get; } + } + + public class PropertyMemberAccessor : IMemberAccessor + { + private readonly PropertyInfo _prop; + + public PropertyMemberAccessor(PropertyInfo prop) + { + _prop = prop; + } + + public object GetValue(object target) + { + return _prop.GetValue(target, null); + } + + public bool IsStatic + { + get { return _prop.GetGetMethod().IsStatic; } + } + + public Type MemberType + { + get { return _prop.PropertyType;} + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/PropertyPath.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/PropertyPath.cs new file mode 100644 index 0000000000..19293cc925 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/PropertyPath.cs @@ -0,0 +1,104 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Text; + +namespace ICSharpCode.Reporting.DataSource +{ + public class PropertyPath + { + private readonly Type _rootType; + private readonly IMemberAccessor[] _properties; + private readonly bool _rootIsStatic; + + private PropertyPath(Type rootType,IMemberAccessor[] props) + { + _properties = props; + _rootType = rootType; + + if (_properties[0].IsStatic) + _rootIsStatic = true; + } + + public object Evaluate(object target) + { + if (target == null && _rootIsStatic == false) + return null; + +// Type s = target.GetType(); + + if (target != null && _rootType.IsAssignableFrom(target.GetType()) == false) + return null; + + + object current = target; + foreach (IMemberAccessor prop in _properties) + { + current = prop.GetValue(current); + if (current == null) + return null; + } + return current; + } + + public static PropertyPath Parse(Type targetType,string propPath) + { + if (String.IsNullOrEmpty(propPath)) + return null; + + string[] parts = propPath.Split('.'); + return Compile(targetType, parts); + + } + + public static PropertyPath Compile(Type targetType,string[] pathParts) + { + var accessors = new IMemberAccessor[pathParts.Length]; + + Type currentType = targetType; + for (int i = 0; i < pathParts.Length; i++) + { + string part = pathParts[i]; + + IMemberAccessor accessor = currentType.FindAccessor(part); + if (accessor == null) + return null; + + + accessors[i] = accessor; + currentType = accessor.MemberType; + } + + return new PropertyPath(targetType, accessors); + } + + public static string GetCacheKey(Type targetType,string[] name) + { + var key = new StringBuilder(); + key.Append(targetType.FullName); + foreach (string namePart in name) + key.Append(namePart); + return key.ToString(); + } + + + + } + +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/PropertyTypeHash.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/PropertyTypeHash.cs index 9c84f25141..7f0fa5c26e 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/PropertyTypeHash.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/PropertyTypeHash.cs @@ -24,7 +24,7 @@ namespace ICSharpCode.Reporting.DataSource /// /// Description of PropertyTypeHash. /// - internal class PropertyTypeHash + class PropertyTypeHash { static PropertyTypeHash instance = new PropertyTypeHash(); @@ -56,7 +56,7 @@ namespace ICSharpCode.Reporting.DataSource } } - private PropertyTypeHash() + PropertyTypeHash() { } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/ReflectionExtension.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/ReflectionExtension.cs new file mode 100644 index 0000000000..cd9695c18a --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/ReflectionExtension.cs @@ -0,0 +1,69 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Reflection; + + +namespace ICSharpCode.Reporting.DataSource +{ + /// + /// Description of ReflectionExtension. + /// + /// + + + + public static class ReflectionExtensions + { + public static PropertyPath ParsePropertyPath(this object target,string propertyPath) + { + if (target == null || String.IsNullOrEmpty(propertyPath)) + return null; + + return PropertyPath.Parse(target.GetType(), propertyPath); + } + + + public static object EvaluatePropertyPath(this object target,string propertyPath) + { + PropertyPath path = ParsePropertyPath(target, propertyPath); + if (path != null) + return path.Evaluate(target); + return null; + } + + + public static IMemberAccessor FindAccessor(this Type type, string accessorName) + { + PropertyInfo prop = type.GetProperty(accessorName, + BindingFlags.IgnoreCase | BindingFlags.NonPublic | + BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance); + if (prop != null) + return new PropertyMemberAccessor(prop); + + FieldInfo field = type.GetField(accessorName, + BindingFlags.IgnoreCase | BindingFlags.NonPublic | + BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance); + if (field != null) + return new FieldMemberAccessor(field); + + return null; + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Events/SectionEvent.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Events/SectionEvent.cs new file mode 100644 index 0000000000..69f415e7dc --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Events/SectionEvent.cs @@ -0,0 +1,30 @@ +/* + * Created by SharpDevelop. + * User: Peter Forstmeier + * Date: 05.02.2014 + * Time: 20:33 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +using System; +using ICSharpCode.Reporting.Interfaces; + +namespace ICSharpCode.Reporting +{ + /// + /// Description of SectionEvent. + /// + public class SectionEventArgs : EventArgs + { + + + public SectionEventArgs(IReportContainer section){ + if (section == null) + throw new ArgumentNullException("section"); + Section = section; + } + + public IReportContainer Section {get;private set;} + + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/ExportRenderer/FixedDocumentCreator.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/ExportRenderer/FixedDocumentCreator.cs deleted file mode 100644 index b8a0c1ffcf..0000000000 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/ExportRenderer/FixedDocumentCreator.cs +++ /dev/null @@ -1,186 +0,0 @@ -// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of this -// software and associated documentation files (the "Software"), to deal in the Software -// without restriction, including without limitation the rights to use, copy, modify, merge, -// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons -// to whom the Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all copies or -// substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE -// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -using System; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Documents; -using System.Windows.Media; - -using ICSharpCode.Reporting.Items; -using ICSharpCode.Reporting.PageBuilder.ExportColumns; -using Brush = System.Windows.Media.Brush; -using FontFamily = System.Windows.Media.FontFamily; -using Image = System.Windows.Controls.Image; -using Pen = System.Windows.Media.Pen; -using Size = System.Windows.Size; - -namespace ICSharpCode.Reporting.ExportRenderer -{ - /// - /// Description of FixedDocumentCreator. - /// - internal class FixedDocumentCreator - { - BrushConverter brushConverter ; - ReportSettings reportSettings; - - public FixedDocumentCreator(ReportSettings reportSettings) - { - if (reportSettings == null) - throw new ArgumentNullException("reportSettings"); - this.reportSettings = reportSettings; - Console.WriteLine("FixedDocumentCreator()"); - brushConverter = new BrushConverter(); - } - - - public UIElement CreateContainer(ExportContainer container) - { -// http://tech.pro/tutorial/736/wpf-tutorial-creating-a-custom-panel-control - - var canvas = CreateCanvas(container); -// canvas.Measure(new Size(reportSettings.PageSize.Width,reportSettings.PageSize.Height)); - - var size = new Size(container.DesiredSize.Width,container.DesiredSize.Height); - - canvas.Measure(size); - -// canvas.Arrange(new Rect(new System.Windows.Point(),new Size(reportSettings.PageSize.Width,reportSettings.PageSize.Height) )); - - canvas.Arrange(new Rect(new System.Windows.Point(),size )); - - canvas.UpdateLayout(); - - return canvas; - - } - - public TextBlock CreateTextBlock(ExportText exportText) - { - var textBlock = new TextBlock(); - textBlock.Text = exportText.Text; - textBlock.Foreground = ConvertBrush(exportText.ForeColor); - SetFont(textBlock,exportText); - textBlock.TextWrapping = TextWrapping.WrapWithOverflow; - -// string [] inlines = exportText.Text.Split(System.Environment.NewLine.ToCharArray()); - //string [] inlines = "jmb,.n,knn-.n.-n.n-.n.n.-"; -// for (int i = 0; i < inlines.Length; i++) { -// if (inlines[i].Length > 0) { -// textBlock.Inlines.Add(new Run(inlines[i])); - //// textBlock.Inlines.Add(new LineBreak()); -// } -// } -// var li = textBlock.Inlines.LastInline; -// textBlock.Inlines.Remove(li); -// SetDimension(textBlock,exportText.StyleDecorator); -// textBlock.Background = ConvertBrush(exportText.StyleDecorator.BackColor); -// SetContendAlignment(textBlock,exportText.StyleDecorator); - SetPosition(textBlock,exportText); - SetDimension(textBlock,exportText); - textBlock.Background = ConvertBrush(exportText.BackColor); - return textBlock; - } - - - Canvas CreateCanvas(ExportContainer container) - { - var canvas = new Canvas(); - SetDimension(canvas, container); - SetPosition(canvas,container); - canvas.Background = ConvertBrush(System.Drawing.Color.Red); - return canvas; - } - - - static void SetDimension (FrameworkElement element,ExportColumn exportColumn) - { - element.Width = exportColumn.DesiredSize.Width; - element.Height = exportColumn.DesiredSize.Height; - } - - - static void SetPosition (FrameworkElement element,ExportColumn exportColumn) { - FixedPage.SetLeft(element,exportColumn.Location.X ); - FixedPage.SetTop(element,exportColumn.Location.Y); - } - - void SetFont(TextBlock textBlock,ExportText exportText) - { - textBlock.FontFamily = new FontFamily(exportText.Font.FontFamily.Name); - - textBlock.FontSize = exportText.Font.Size * 96/72; - - if (exportText.Font.Bold) { - textBlock.FontWeight = FontWeights.Bold; - } - if (exportText.Font.Underline) { - CreateUnderline(textBlock,exportText); - } - - if (exportText.Font.Italic) { - textBlock.FontStyle = System.Windows.FontStyles.Italic ; - } - if (exportText.Font.Strikeout) { - CreateStrikeout(textBlock,exportText); - } - } - - - void CreateStrikeout (TextBlock textBlock,ExportColumn exportColumn ) - { - var strikeOut = new TextDecoration(); - strikeOut.Location = TextDecorationLocation.Strikethrough; - - Pen p = CreateWpfPen(exportColumn); - strikeOut.Pen = p ; - strikeOut.PenThicknessUnit = TextDecorationUnit.FontRecommended; - textBlock.TextDecorations.Add(strikeOut); - } - - - void CreateUnderline(TextBlock textBlock,ExportColumn exportColumn) - { - var underLine = new TextDecoration(); - Pen p = CreateWpfPen(exportColumn); - underLine.Pen = p ; - underLine.PenThicknessUnit = TextDecorationUnit.FontRecommended; - textBlock.TextDecorations.Add(underLine); - } - - - Pen CreateWpfPen(ExportColumn exportColumn) - { - var myPen = new Pen(); - myPen.Brush = ConvertBrush(exportColumn.ForeColor); - myPen.Thickness = 1.5; - return myPen; - } - - - Brush ConvertBrush(System.Drawing.Color color) - { - if (brushConverter.IsValid(color.Name)){ - return brushConverter.ConvertFromString(color.Name) as SolidColorBrush; - } else{ - return brushConverter.ConvertFromString("Black") as SolidColorBrush; - } - } - } -} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/BaseExporter.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/BaseExporter.cs index 62604fa16b..31d48982b3 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/BaseExporter.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/BaseExporter.cs @@ -18,7 +18,7 @@ using System; using System.Collections.ObjectModel; -using ICSharpCode.Reporting.Interfaces.Export; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; namespace ICSharpCode.Reporting.Exporter { @@ -27,7 +27,7 @@ namespace ICSharpCode.Reporting.Exporter /// public class BaseExporter { - public BaseExporter(Collection pages) + public BaseExporter(Collection pages) { if (pages == null) { throw new ArgumentException("pages"); @@ -41,6 +41,6 @@ namespace ICSharpCode.Reporting.Exporter } - protected Collection Pages {get; set;} + protected Collection Pages {get;private set;} } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/DebugExporter.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/DebugExporter.cs index 03361286b9..1a9f61185a 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/DebugExporter.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/DebugExporter.cs @@ -17,53 +17,27 @@ // DEALINGS IN THE SOFTWARE. using System; -using System.Collections.Generic; using System.Collections.ObjectModel; - using ICSharpCode.Reporting.Exporter.Visitors; -using ICSharpCode.Reporting.Interfaces.Export; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; namespace ICSharpCode.Reporting.Exporter { /// /// Description of DebugExporter. /// - public class DebugExporter:BaseExporter + class DebugExporter:BaseExporter { private DebugVisitor visitor; - public DebugExporter(Collection pages):base(pages) + public DebugExporter(Collection pages):base(pages) { visitor = new DebugVisitor(); } public override void Run () { - foreach (var page in Pages) { - ShowDebug(page); - } - } - - - void ShowDebug(IExportContainer container) - { - foreach (var item in container.ExportedItems) { - var exportContainer = item as IExportContainer; - var acceptor = item as IAcceptor; - if (exportContainer != null) { - if (acceptor != null) { - Console.WriteLine("--container--"); - acceptor.Accept(visitor); - } - ShowDebug(item as IExportContainer); - } else { - if (acceptor != null) { - Console.WriteLine("..Item..."); - acceptor.Accept(visitor); - } - } - } + visitor.Run(Pages); } - } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/AbstractVisitor.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/AbstractVisitor.cs index 8a77b133f2..48842dd1cd 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/AbstractVisitor.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/AbstractVisitor.cs @@ -17,7 +17,9 @@ // DEALINGS IN THE SOFTWARE. using System; -using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Drawing; + using ICSharpCode.Reporting.PageBuilder.ExportColumns; namespace ICSharpCode.Reporting.Exporter.Visitors @@ -25,10 +27,63 @@ namespace ICSharpCode.Reporting.Exporter.Visitors /// /// Description of AbstractVisitor. /// - public abstract class AbstractVisitor : IVisitor - { - public abstract void Visit(ExportColumn exportColumn); - public abstract void Visit(ExportContainer exportColumn); - public abstract void Visit(ExportText exportColumn); + /// + class AbstractVisitor : IVisitor{ + + public virtual void Run (Collection pages) { + if (pages == null) + throw new ArgumentNullException("pages"); + Pages = pages; + foreach (var page in pages) { + Visit(page); + } + } + + + public virtual void Visit (ExportPage page) { + + foreach (var element in page.ExportedItems) { + var ac = element as IAcceptor; + ac.Accept(this); + } + } + + + public virtual void Visit (ExportContainer exportContainer) { + foreach (var element in exportContainer.ExportedItems) { + + var ac = element as IAcceptor; + ac.Accept(this); + } + } + + + public virtual void Visit(ExportText exportColumn) + { + } + + + public virtual void Visit(ExportLine exportGraphics) + { + } + + public virtual void Visit (ExportRectangle exportRectangle) { + + } + + + public virtual void Visit (ExportCircle exportCircle) { + + } + + + protected static bool ShouldSetBackcolor (ExportColumn exportColumn) { + return exportColumn.BackColor != Color.White; + } + + + protected Collection Pages {get; private set;} + + } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/DebugVisitor.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/DebugVisitor.cs index 8971e2cc1e..6c6bc2620e 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/DebugVisitor.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/DebugVisitor.cs @@ -17,7 +17,6 @@ // DEALINGS IN THE SOFTWARE. using System; -using System.Collections.Generic; using ICSharpCode.Reporting.PageBuilder.ExportColumns; namespace ICSharpCode.Reporting.Exporter.Visitors @@ -28,24 +27,29 @@ namespace ICSharpCode.Reporting.Exporter.Visitors // http://www.remondo.net/strategy-pattern-example-csharp/ - public class DebugVisitor : AbstractVisitor + class DebugVisitor : AbstractVisitor { - public override void Visit(ExportColumn exportColumn) + + public override void Visit(ExportPage page) { - Console.WriteLine("Visit ExportColumn {0} - {1} - {2}", exportColumn.Name,exportColumn.Size,exportColumn.Location); + base.Visit(page); } - - public override void Visit(ExportContainer exportColumn) + public override void Visit(ExportContainer exportContainer) { - Console.WriteLine("Visit ExportContainer {0} - {1} - {2}", exportColumn.Name,exportColumn.Size,exportColumn.Location); + base.Visit(exportContainer); } + public override void Visit(ExportText exportColumn) { - Console.WriteLine("Visit ExportText {0} - {1} - {2}", exportColumn.Name,exportColumn.Size,exportColumn.Location); + } + + public override void Visit(ExportLine exportGraphics) + { +// base.Visit(exportGraphics); + Console.WriteLine("Line from {0} size {1}",exportGraphics.Location,exportGraphics.Size.Width); } } - } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/ExpressionVisitor.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/ExpressionVisitor.cs new file mode 100644 index 0000000000..f1dbfe3d9f --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/ExpressionVisitor.cs @@ -0,0 +1,94 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Globalization; +using ICSharpCode.Reporting.Expressions; +using ICSharpCode.Reporting.Expressions.Irony; +using ICSharpCode.Reporting.Expressions.Irony.Ast; +using ICSharpCode.Reporting.Items; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; + +namespace ICSharpCode.Reporting.Exporter.Visitors +{ + /// + /// Description of ExpressionVisitor. + /// + class ExpressionVisitor: AbstractVisitor + { + readonly ReportingLanguageGrammer grammar; + readonly ReportingExpressionEvaluator evaluator; + + public ExpressionVisitor(ReportSettings reportSettings) { + grammar = new ReportingLanguageGrammer(); + evaluator = new ReportingExpressionEvaluator(grammar); + evaluator.AddReportSettings(reportSettings); + } + + + public void SetCurrentDataSource (IEnumerable dataSource) { + evaluator.SetCurrentDataSource(dataSource); + } + + + public override void Visit(ExportPage page) + { + evaluator.AddPageInfo(page.PageInfo); + base.Visit(page); + } + + + public override void Visit(ExportContainer exportContainer) + { + evaluator.AddCurrentContainer(exportContainer); + base.Visit(exportContainer); + } + + + public override void Visit(ExportText exportColumn) + { + if (ExpressionHelper.CanEvaluate(exportColumn.Text)) { + try { + object result = Evaluate(exportColumn); + exportColumn.Text = result.ToString(); + } catch (Exception e) { + var s = String.Format(CultureInfo.CurrentCulture,"SharpReport.Expressions -> {0} for {1}",e.Message,exportColumn.Text); + Console.WriteLine(s); + } + } + } + + public override void Visit(ExportLine exportGraphics) + { +// base.Visit(exportGraphics); + } + + object Evaluate(ExportText exportColumn) + { + var str = ExpressionHelper.ExtractExpressionPart(exportColumn.Text); + var result = evaluator.Evaluate(str); + return result; + } + + public ReportingExpressionEvaluator Evaluator { + get { return evaluator; } + } + + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/FormatVisitor.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/FormatVisitor.cs new file mode 100644 index 0000000000..c60ce00cce --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/FormatVisitor.cs @@ -0,0 +1,51 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Collections.ObjectModel; +using ICSharpCode.Reporting.Globals; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; + +namespace ICSharpCode.Reporting.Exporter.Visitors +{ + /// + /// Description of FormatVisitor. + /// + class FormatVisitor: AbstractVisitor + { + + + public override void Visit(ExportContainer exportContainer) + { + foreach (var element in exportContainer.ExportedItems) { + var te = element as ExportText; + if (te != null) { + Visit(te); + } + } + } + + + public override void Visit(ExportText exportColumn) + { + if (!String.IsNullOrEmpty(exportColumn.FormatString)) { + StandardFormatter.FormatOutput(exportColumn); + } + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/IVisitor.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/IVisitor.cs index 0cde6074f5..1da0365574 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/IVisitor.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/IVisitor.cs @@ -17,15 +17,17 @@ // DEALINGS IN THE SOFTWARE. using System; -using System.Collections.Generic; using ICSharpCode.Reporting.PageBuilder.ExportColumns; namespace ICSharpCode.Reporting.Exporter.Visitors { public interface IVisitor { - void Visit(ExportColumn exportColumn); + void Visit(ExportPage page); void Visit(ExportContainer exportColumn); void Visit(ExportText exportColumn); + void Visit(ExportLine exportGraphics); + void Visit (ExportRectangle exportRectangle); + void Visit (ExportCircle exportCircle); } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/WpfVisitor.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/WpfVisitor.cs deleted file mode 100644 index ad389c4ccc..0000000000 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/WpfVisitor.cs +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of this -// software and associated documentation files (the "Software"), to deal in the Software -// without restriction, including without limitation the rights to use, copy, modify, merge, -// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons -// to whom the Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all copies or -// substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE -// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -using System; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Documents; -using System.Windows.Media; - -using ICSharpCode.Reporting.ExportRenderer; -using ICSharpCode.Reporting.Interfaces.Export; -using ICSharpCode.Reporting.Items; -using ICSharpCode.Reporting.PageBuilder.ExportColumns; - -namespace ICSharpCode.Reporting.Exporter.Visitors -{ - /// - /// Description of WpfVisitor. - /// - internal class WpfVisitor: AbstractVisitor - { - private readonly FixedDocumentCreator documentCreator; - private readonly ReportSettings reportSettings; - - public WpfVisitor(ReportSettings reportSettings) - { - if (reportSettings == null) - throw new ArgumentNullException("reportSettings"); - this.reportSettings = reportSettings; - documentCreator = new FixedDocumentCreator(reportSettings); - } - - public override void Visit(ExportColumn exportColumn) - { -// Console.WriteLine("Wpf-Visit ExportColumn {0} - {1} - {2}", exportColumn.Name,exportColumn.Size,exportColumn.Location); - } - - - public override void Visit(ExportContainer exportColumn) - { -// Console.WriteLine("Wpf-Visit ExportContainer {0} - {1} - {2}", exportColumn.Name,exportColumn.Size,exportColumn.Location); - var canvas = documentCreator.CreateContainer(exportColumn); - UIElement = canvas; - } - - - public override void Visit(ExportText exportColumn) - { -// Console.WriteLine("Wpf-Visit ExportText {0} - {1} - {2}", exportColumn.Name,exportColumn.Size,exportColumn.DesiredSize); - var textBlock = documentCreator.CreateTextBlock(exportColumn); - UIElement = textBlock; - } - - - public UIElement UIElement {get; private set;} - - } -} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/WpfExporter.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/WpfExporter.cs deleted file mode 100644 index ad6daee2e9..0000000000 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/WpfExporter.cs +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of this -// software and associated documentation files (the "Software"), to deal in the Software -// without restriction, including without limitation the rights to use, copy, modify, merge, -// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons -// to whom the Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all copies or -// substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE -// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -using System; -using System.Collections.ObjectModel; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Documents; - -using ICSharpCode.Reporting.Exporter.Visitors; -using ICSharpCode.Reporting.Interfaces.Export; -using ICSharpCode.Reporting.Items; -using ICSharpCode.Reporting.PageBuilder.ExportColumns; - -namespace ICSharpCode.Reporting.Exporter -{ - /// - /// Description of PrintExporter. - /// - public class WpfExporter:BaseExporter - { - private WpfVisitor visitor; - private ReportSettings reportSettings; - - public WpfExporter(ReportSettings reportSettings,Collection pages):base(pages) - { - if (reportSettings == null) - throw new ArgumentNullException("reportSettings"); - this.reportSettings = reportSettings; - visitor = new WpfVisitor(reportSettings); - } - - - public override void Run () { - InitFixedPage(); - foreach (var page in Pages) { - InternalRun(page); - } - } - - - void InitFixedPage() - { - fixedPage = new FixedPage(); - fixedPage.Width = reportSettings.PageSize.Width; - fixedPage.Height = reportSettings.PageSize.Height; - } - - FixedPage fixedPage; - - public FixedPage FixedPage { - get { return fixedPage; } - } - - - void InternalRun(IExportContainer container) - { - Canvas canvas = null ; - foreach (var item in container.ExportedItems) { - var exportContainer = item as IExportContainer; - var acceptor = item as IAcceptor; - if (exportContainer != null) { - if (acceptor != null) { - acceptor.Accept(visitor); - canvas = (Canvas)visitor.UIElement; - fixedPage.Children.Add(canvas); - foreach (IAcceptor element in exportContainer.ExportedItems) { - element.Accept(visitor); - var ui = visitor.UIElement; - Canvas.SetLeft(ui,((IExportColumn)element).Location.X); - Canvas.SetTop(ui, ((IExportColumn)element).Location.Y); - canvas.Children.Add(ui); - } -// var size = new Size(exportContainer.DesiredSize.Width,exportContainer.DesiredSize.Height); -// canvas.Measure(size); -// canvas.Arrange(new Rect(new System.Windows.Point(exportContainer.Location.X,exportContainer.Location.Y),size )); -// canvas.UpdateLayout(); -// var exportArrange = exportContainer.GetArrangeStrategy(); -// exportArrange.Arrange(exportContainer); - } -// InternalRun(item as IExportContainer); - } else { - if (acceptor != null) { - Console.WriteLine("..Item..."); - acceptor.Accept(visitor); - var uiElement = visitor.UIElement; - if (canvas != null) { - Canvas.SetLeft(uiElement, item.Location.X - exportContainer.Location.X); - Canvas.SetTop(uiElement, item.Location.Y - exportContainer.Location.Y); - canvas.Children.Add(uiElement); - } - fixedPage.Children.Add(uiElement); - } - } - } - } - } -} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/ExpressionHelper.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/ExpressionHelper.cs new file mode 100644 index 0000000000..e7baac9ca6 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/ExpressionHelper.cs @@ -0,0 +1,52 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Globalization; +using ICSharpCode.Reporting.Globals; +using Irony.Interpreter.Ast; + +namespace ICSharpCode.Reporting.Expressions +{ + /// + /// Description of ExpressionHelper. + /// + class ExpressionHelper + { + + public static string ExtractExpressionPart (string src) + { + char v = Convert.ToChar("=",CultureInfo.CurrentCulture ); + return StringHelper.RightOf(src,v).Trim(); + } + + + public static bool CanEvaluate (string expression) + { + if ((!String.IsNullOrEmpty(expression)) && (expression.StartsWith("=",StringComparison.OrdinalIgnoreCase))) { + return true; + } + return false; + } + + + public static string ComposeAstNodeError (string branch,AstNode node) { + return String.Format (CultureInfo.CurrentCulture,"Missing {0} <{1}>",branch,node.AsString); + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/ExpressionRunner.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/ExpressionRunner.cs new file mode 100644 index 0000000000..3f41d86d62 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/ExpressionRunner.cs @@ -0,0 +1,65 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System.Collections.ObjectModel; +using ICSharpCode.Reporting.DataManager.Listhandling; +using ICSharpCode.Reporting.Exporter.Visitors; +using ICSharpCode.Reporting.Items; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; + +namespace ICSharpCode.Reporting.Expressions +{ + /// + /// Description of ExpressionRunner. + /// + class ExpressionRunner + { + +// http://www.killswtch.net/2013/08/01/time-arithmetic-with-irony/ +// http://blog.miraclespain.com/archive/2009/Oct-07.html +// + readonly Collection pages; + readonly ReportSettings reportSettings; + readonly CollectionDataSource dataSource; + + public ExpressionRunner(Collection pages,ReportSettings reportSettings,CollectionDataSource dataSource) + { + this.pages = pages; + this.dataSource = dataSource; + this.reportSettings = reportSettings; + Visitor = new ExpressionVisitor(reportSettings); + } + + + public void Run() + { +// Visitor = new ExpressionVisitor (reportSettings); + if (dataSource != null) { + if (dataSource.SortedList != null) { + Visitor.SetCurrentDataSource(dataSource.SortedList); + } + if (dataSource.GroupedList != null) { + Visitor.SetCurrentDataSource(dataSource.GroupedList); + } + } + Visitor.Run(pages); + } + + public ExpressionVisitor Visitor {get; private set;} + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/Ast/AstExtensions.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/Ast/AstExtensions.cs new file mode 100644 index 0000000000..b18b5111e6 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/Ast/AstExtensions.cs @@ -0,0 +1,102 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Collections.Generic; +using ICSharpCode.Reporting.DataManager.Listhandling; +using ICSharpCode.Reporting.Interfaces.Export; +using ICSharpCode.Reporting.Items; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; +using Irony.Interpreter; + +namespace ICSharpCode.Reporting.Expressions.Irony.Ast +{ + /// + /// Description of AstExtensions. + /// + public static class AstExtensions + { + #region Globals + public static void AddPageInfo (this ReportingExpressionEvaluator app,IPageInfo pageInfo) { + if (pageInfo == null) + throw new ArgumentNullException("pageInfo"); + + if (!app.Globals.ContainsKey("PageInfo")) { + app.Globals.Add("PageInfo",pageInfo); + } else { + app.Globals["PageInfo"] = pageInfo; + } + } + + + public static IPageInfo GetPageInfo (this ScriptThread thread){ + var pi = (IPageInfo)thread.App.Globals["PageInfo"]; + return pi; + } + #endregion + + + #region Parameters + + public static ParameterCollection GetParametersCollection (this ScriptThread thread){ + var rs = (ReportSettings)thread.App.Globals["ReportSettings"]; + return rs.ParameterCollection; + } + + + public static void AddReportSettings (this ReportingExpressionEvaluator app,ReportSettings reportSettings) { + if (reportSettings == null) + throw new ArgumentNullException("reportSettings"); + app.Globals.Add("ReportSettings",reportSettings); + } + + #endregion + + #region current Container + + public static void AddCurrentContainer (this ReportingExpressionEvaluator app,ExportContainer container){ + if (container == null) + throw new ArgumentNullException("container"); + if (!app.Globals.ContainsKey("CurrentContainer")) { + app.Globals.Add("CurrentContainer",container); + } else { + app.Globals["CurrentContainer"] = container; + } + } + + public static ExportContainer GetCurrentContainer (this ScriptThread thread){ + return (ExportContainer)thread.App.Globals["CurrentContainer"]; + } + + #endregion + + #region DataSource + + public static void SetCurrentDataSource (this ReportingExpressionEvaluator app,IEnumerable dataSource){ + if (dataSource == null) + throw new ArgumentNullException("dataSource"); + if (!app.Globals.ContainsKey("DataSource")) { + app.Globals.Add("DataSource",dataSource); + } else { + app.Globals["DataSource"] = dataSource; + } + } + + #endregion + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/Ast/FieldsNode.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/Ast/FieldsNode.cs new file mode 100644 index 0000000000..e3959201e6 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/Ast/FieldsNode.cs @@ -0,0 +1,54 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System.Linq; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; +using Irony.Ast; +using Irony.Interpreter; +using Irony.Interpreter.Ast; +using Irony.Parsing; + +namespace ICSharpCode.Reporting.Expressions.Irony.Ast +{ + /// + /// Description of FieldsNode. + /// + public class FieldsNode: AstNode + { + AstNode fieldNode; + + public override void Init(AstContext context,ParseTreeNode treeNode) + { + base.Init(context, treeNode); + var nodes = treeNode.GetMappedChildNodes(); + fieldNode = AddChild("Args", nodes[2]); + } + + + protected override object DoEvaluate(ScriptThread thread) + { + thread.CurrentNode = this; //standard prolog + var container = thread.GetCurrentContainer(); + var column = (ExportText)container.ExportedItems.Where(x => x.Name == fieldNode.AsString).FirstOrDefault(); + if (column == null) { + return ExpressionHelper.ComposeAstNodeError("Fields",fieldNode); + } + return column.Text; + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/Ast/GlobalsNode.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/Ast/GlobalsNode.cs new file mode 100644 index 0000000000..51e6239e82 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/Ast/GlobalsNode.cs @@ -0,0 +1,67 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Linq; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; +using Irony.Ast; +using Irony.Interpreter; +using Irony.Interpreter.Ast; +using Irony.Parsing; + +namespace ICSharpCode.Reporting.Expressions.Irony.Ast +{ + /// + /// Description of GlobalsNode. + /// + public class GlobalsNode: AstNode + { + AstNode globalNode; + + public override void Init(AstContext context, ParseTreeNode treeNode) + { + base.Init(context, treeNode); + var nodes = treeNode.GetMappedChildNodes(); + globalNode = AddChild("Args", nodes[2]); + } + + + protected override object DoEvaluate(ScriptThread thread) + { + thread.CurrentNode = this; //standard prolog + var pi = thread.GetPageInfo(); + + var test = globalNode.AsString.ToLower(); + if ( test == "pagenumber") { + return pi.PageNumber; + } else if (test == "pages") { + return pi.TotalPages; + } else if (test == "reportname") { + return pi.ReportName; + } else if (test == "reportfolder") { + return pi.ReportFolder; + } else if (test == "reportfilename") { + return pi.ReportFileName; + } + + else { + return String.Format("Syntaxerror in Globals <{0}>",globalNode.AsString); + } + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/Ast/ParametersCallNode.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/Ast/ParametersCallNode.cs new file mode 100644 index 0000000000..f8ff4c08e0 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/Ast/ParametersCallNode.cs @@ -0,0 +1,53 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using Irony.Ast; +using Irony.Interpreter; +using Irony.Interpreter.Ast; +using Irony.Parsing; +using ICSharpCode.Reporting.BaseClasses; + +namespace ICSharpCode.Reporting.Expressions.Irony.Ast +{ + /// + /// Description of ParametersCallNode. + /// + public class ParametersCallNode: AstNode + { + AstNode parameterNode; + + public override void Init(AstContext context, ParseTreeNode treeNode) + { + base.Init(context, treeNode); + var nodes = treeNode.GetMappedChildNodes(); + parameterNode = AddChild("Args", nodes[2]); + } + + + protected override object DoEvaluate(ScriptThread thread) + { + BasicParameter result = null; + thread.CurrentNode = this; //standard prolog + var parametersCollection = thread.GetParametersCollection(); + result = parametersCollection.Find(parameterNode.AsString); + if (result == null) + return ExpressionHelper.ComposeAstNodeError("Parameters",parameterNode); + return result.ParameterValue; + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/ExpressionEvaluator.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/ExpressionEvaluator.cs new file mode 100644 index 0000000000..1621c0b707 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/ExpressionEvaluator.cs @@ -0,0 +1,73 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System.Collections.Generic; +using Irony.Interpreter; +using Irony.Parsing; + +namespace ICSharpCode.Reporting.Expressions.Irony +{ + /// + /// Description of ReportingLanguageEvaluator. + /// + public class ReportingExpressionEvaluator + { + public InterpretedLanguageGrammar Grammar {get; private set;} + public Parser Parser {get; private set;} + public LanguageData Language {get; private set;} + public LanguageRuntime Runtime {get; private set;} + public ScriptApp App {get; private set;} + + public IDictionary Globals { + get { return App.Globals; } + } + + + //Default constructor, creates default evaluator + public ReportingExpressionEvaluator(InterpretedLanguageGrammar grammar) { + Grammar = grammar; + Language = new LanguageData(Grammar); + Parser = new Parser(Language); + Runtime = Grammar.CreateRuntime(Language); + App = new ScriptApp(Runtime); + } + + public object Evaluate(string script) { + var result = App.Evaluate(script); + return result; + } + + public object Evaluate(ParseTree parsedScript) { + var result = App.Evaluate(parsedScript); + return result; + } + + //Evaluates again the previously parsed/evaluated script + public object Evaluate() { + return App.Evaluate(); + } + /* + public void ClearOutput() { + App.ClearOutputBuffer(); + } + public string GetOutput() { + return App.GetOutput(); + } + */ + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/Imports/ImportAggregates.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/Imports/ImportAggregates.cs new file mode 100644 index 0000000000..9322ae4356 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/Imports/ImportAggregates.cs @@ -0,0 +1,99 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Linq; + +using ICSharpCode.Reporting.DataSource; +using Irony.Interpreter; +using Irony.Interpreter.Ast; + +namespace ICSharpCode.Reporting.Expressions.Irony.Imports +{ + /// + /// Description of ImportAggregates. + /// + public static class ImportExtensions + { + public static IEnumerable GetDataSource (this ScriptThread thread){ + return (IEnumerable)thread.App.Globals["DataSource"]; + } + + + } + + static class ImportAggregateHelper { + + public static bool FieldExist (object current,string fieldName) { + var property1 = current.ParsePropertyPath(fieldName); + if (property1 == null) { + return false; + } + return true; + } + + public static IEnumerable> IsGrouped (IEnumerable listToConvert) { + var grouped = listToConvert as IEnumerable>; + if (grouped != null) { + return grouped; + } + return null; + } + } + + + public static class ImportAggregates + { + public static object Sum(ScriptThread thread, AstNode[] childNodes) { + double sum = 0; + var fieldName = childNodes[0].Evaluate(thread).ToString(); + + var dataSource = thread.GetDataSource(); + + var grouped = ImportAggregateHelper.IsGrouped(dataSource); + + if (grouped != null) { + + foreach (var element in grouped) { + var s = element.Sum(o => { + var v = ReadValueFromObject(fieldName, o); + return TypeNormalizer.EnsureType(v); + }); + sum = sum + s; + } + } else { + if (ImportAggregateHelper.FieldExist(dataSource.FirstOrDefault(),fieldName)) { + sum = dataSource.Sum(o => { + var v = ReadValueFromObject(fieldName, o); + return TypeNormalizer.EnsureType(v); + }); + } + } + return sum.ToString(); + } + + + static object ReadValueFromObject(string fieldName, object currentObject) + { + var propertyPath = currentObject.ParsePropertyPath(fieldName); + var evaluated = propertyPath.Evaluate(currentObject); + return evaluated; + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/ReportingLanguageGrammer.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/ReportingLanguageGrammer.cs new file mode 100644 index 0000000000..96276b0acf --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/ReportingLanguageGrammer.cs @@ -0,0 +1,187 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using ICSharpCode.Reporting.Expressions.Irony.Ast; +using Irony.Interpreter; +using Irony.Interpreter.Ast; +using Irony.Parsing; + +namespace ICSharpCode.Reporting.Expressions.Irony +{ + /// + /// Description of ReportingLanguageGrammer. + /// + public class ReportingLanguageGrammer:InterpretedLanguageGrammar + { + private const string exclamationMark = "!"; + public ReportingLanguageGrammer() :base(caseSensitive : false) { + + this.GrammarComments = +@"Irony expression evaluator. Case-insensitive. Supports big integers, float data types, variables, assignments, +arithmetic operations, augmented assignments (+=, -=), inc/dec (++,--), strings with embedded expressions; +bool operations &,&&, |, ||; ternary '?:' operator." ; + + // 1. Terminals + var number = new NumberLiteral("number"); + //Let's allow big integers (with unlimited number of digits): + number.DefaultIntTypes = new TypeCode[] { TypeCode.Int32, TypeCode.Int64, NumberLiteral.TypeCodeBigInt }; + var identifier = new IdentifierTerminal("identifier"); + var comment = new CommentTerminal("comment", "#", "\n", "\r"); + //comment must be added to NonGrammarTerminals list; it is not used directly in grammar rules, + // so we add it to this list to let Scanner know that it is also a valid terminal. + base.NonGrammarTerminals.Add(comment); + var comma = ToTerm(","); + + //String literal with embedded expressions ------------------------------------------------------------------ + var stringLit = new StringLiteral("string", "\"", StringOptions.AllowsAllEscapes | StringOptions.IsTemplate); + stringLit.AddStartEnd("'", StringOptions.AllowsAllEscapes | StringOptions.IsTemplate); + stringLit.AstConfig.NodeType = typeof(StringTemplateNode); + var Expr = new NonTerminal("Expr"); //declare it here to use in template definition + var templateSettings = new StringTemplateSettings(); //by default set to Ruby-style settings + templateSettings.ExpressionRoot = Expr; //this defines how to evaluate expressions inside template + this.SnippetRoots.Add(Expr); + stringLit.AstConfig.Data = templateSettings; + //-------------------------------------------------------------------------------------------------------- + + // 2. Non-terminals + var Term = new NonTerminal("Term"); + var BinExpr = new NonTerminal("BinExpr", typeof(BinaryOperationNode)); + var ParExpr = new NonTerminal("ParExsumpr"); + var UnExpr = new NonTerminal("UnExpr", typeof(UnaryOperationNode)); + var TernaryIfExpr = new NonTerminal("TernaryIf", typeof(IfNode)); + var ArgList = new NonTerminal("ArgList", typeof(ExpressionListNode)); + var FunctionCall = new NonTerminal("FunctionCall", typeof(FunctionCallNode)); + + // SharpReporting + var ParametersSection = new NonTerminal("ParametersCall",typeof(ParametersCallNode)); + var FieldsSection = new NonTerminal("FieldsCall",typeof(FieldsNode)); + var GlobalSection = new NonTerminal("GlobalCall",typeof(GlobalsNode)); + + // end of SharpReporting + + var MemberAccess = new NonTerminal("MemberAccess", typeof(MemberAccessNode)); + + + var IndexedAccess = new NonTerminal("IndexedAccess", typeof(IndexedAccessNode)); + var ObjectRef = new NonTerminal("ObjectRef"); // foo, foo.bar or f['bar'] + var UnOp = new NonTerminal("UnOp"); + var BinOp = new NonTerminal("BinOp", "operator"); + var PrefixIncDec = new NonTerminal("PrefixIncDec", typeof(IncDecNode)); + var PostfixIncDec = new NonTerminal("PostfixIncDec", typeof(IncDecNode)); + var IncDecOp = new NonTerminal("IncDecOp"); + var AssignmentStmt = new NonTerminal("AssignmentStmt", typeof(AssignmentNode)); + var AssignmentOp = new NonTerminal("AssignmentOp", "assignment operator"); + var Statement = new NonTerminal("Statement"); + var Program = new NonTerminal("Program", typeof(StatementListNode)); + + // 3. BNF rules + Expr.Rule = Term | UnExpr | BinExpr | PrefixIncDec | PostfixIncDec | TernaryIfExpr + | ParametersSection + | GlobalSection + | FieldsSection; + + Term.Rule = number | ParExpr | stringLit | FunctionCall | identifier | MemberAccess | IndexedAccess; + + ParExpr.Rule = "(" + Expr + ")"; + UnExpr.Rule = UnOp + Term + ReduceHere(); + UnOp.Rule = ToTerm("+") | "-" | "!"; + BinExpr.Rule = Expr + BinOp + Expr; + BinOp.Rule = ToTerm("+") | "-" | "*" | "/" | "**" | "==" | "<" | "<=" | ">" | ">=" | "!=" | "&&" | "||" | "&" | "|"; + PrefixIncDec.Rule = IncDecOp + identifier; + PostfixIncDec.Rule = identifier + PreferShiftHere() + IncDecOp; + IncDecOp.Rule = ToTerm("++") | "--"; + TernaryIfExpr.Rule = Expr + "?" + Expr + ":" + Expr; + MemberAccess.Rule = Expr + PreferShiftHere() + "." + identifier; + AssignmentStmt.Rule = ObjectRef + AssignmentOp + Expr; + AssignmentOp.Rule = ToTerm("=") | "+=" | "-=" | "*=" | "/="; + Statement.Rule = AssignmentStmt | Expr | Empty; + ArgList.Rule = MakeStarRule(ArgList, comma, Expr); + FunctionCall.Rule = Expr + PreferShiftHere() + "(" + ArgList + ")"; + + // SharpReporting + + ParametersSection.Rule = ToTerm("Parameters") + exclamationMark + identifier; + FieldsSection.Rule = ToTerm("Fields") + exclamationMark + identifier; + + GlobalSection.Rule = ToTerm("Globals") + exclamationMark + identifier; + + // end of SharpReporting + + FunctionCall.NodeCaptionTemplate = "call #{0}(...)"; + + ObjectRef.Rule = identifier | MemberAccess | IndexedAccess; + IndexedAccess.Rule = Expr + PreferShiftHere() + "[" + Expr + "]"; + + Program.Rule = MakePlusRule(Program, NewLine, Statement); + + this.Root = Program; // Set grammar root + + // 4. Operators precedence + RegisterOperators(10, "?"); + RegisterOperators(15, "&", "&&", "|", "||"); + RegisterOperators(20, "==", "<", "<=", ">", ">=", "!="); + RegisterOperators(30, "+", "-"); + RegisterOperators(40, "*", "/"); + RegisterOperators(50, Associativity.Right, "**"); + RegisterOperators(60, "!"); + // For precedence to work, we need to take care of one more thing: BinOp. + //For BinOp which is or-combination of binary operators, we need to either + // 1) mark it transient or 2) set flag TermFlags.InheritPrecedence + // We use first option, making it Transient. + + // 5. Punctuation and transient terms + MarkPunctuation("(", ")", "?", ":", "[", "]"); + RegisterBracePair("(", ")"); + RegisterBracePair("[", "]"); + MarkTransient(Term, Expr, Statement, BinOp, UnOp, IncDecOp, AssignmentOp, ParExpr, ObjectRef); + + // 7. Syntax error reporting + MarkNotReported("++", "--"); + AddToNoReportGroup("(", "++", "--"); + AddToNoReportGroup(NewLine); + AddOperatorReportGroup("operator"); + AddTermsReportGroup("assignment operator", "=", "+=", "-=", "*=", "/="); + + //8. Console + ConsoleTitle = "Irony Expression Evaluator"; + ConsoleGreeting = +@"Irony Expression Evaluator + + Supports variable assignments, arithmetic operators (+, -, *, /), + augmented assignments (+=, -=, etc), prefix/postfix operators ++,--, string operations. + Supports big integer arithmetics, string operations. + Supports strings with embedded expressions : ""name: #{name}"" + +Press Ctrl-C to exit the program at any time. +"; + ConsolePrompt = "?"; + ConsolePromptMoreInput = "?"; + + //9. Language flags. + // Automatically add NewLine before EOF so that our BNF rules work correctly when there's no final line break in source + this.LanguageFlags = LanguageFlags.NewLineBeforeEOF | LanguageFlags.CreateAst | LanguageFlags.SupportsBigInt; + } + + + public override LanguageRuntime CreateRuntime(LanguageData language) + { + return new ReportingLanguageRuntime(language); + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/ReportingLanguageRuntime.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/ReportingLanguageRuntime.cs new file mode 100644 index 0000000000..33312814fc --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/ReportingLanguageRuntime.cs @@ -0,0 +1,83 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Linq; +using ICSharpCode.Reporting.Expressions.Irony.Imports; +using Irony.Interpreter; +using Irony.Parsing; + +namespace ICSharpCode.Reporting.Expressions.Irony +{ + /// + /// Description of ReportingLanguageRuntime. + /// + public class ReportingLanguageRuntime:LanguageRuntime + { + public ReportingLanguageRuntime(LanguageData language):base(language) + { + } + + public override void Init() + { + base.Init(); + //add built-in methods, special form IIF, import Math and Environment methods +// BuiltIns.AddMethod(BuiltInPrintMethod, "print"); +// BuiltIns.AddMethod(BuiltInFormatMethod, "format"); + BuiltIns.AddSpecialForm(SpecialFormsLibrary.Iif, "iif", 3, 3); + BuiltIns.ImportStaticMembers(typeof(System.Math)); + BuiltIns.ImportStaticMembers(typeof(Environment)); + BuiltIns.ImportStaticMembers(typeof(System.DateTime)); + //Aggregates + BuiltIns.AddSpecialForm(ImportAggregates.Sum,"sum",1,1); + } + + /* + private object BuiltInPrintMethod(ScriptThread thread, object[] args) { + string text = string.Empty; + switch(args.Length) { + case 1: + text = string.Empty + args[0]; //compact and safe conversion ToString() + break; + case 0: + break; + default: + text = string.Join(" ", args); + break; + } + thread.App.WriteLine(text); + return null; + } + */ + + /* + private object BuiltInFormatMethod(ScriptThread thread, object[] args) { + if (args == null || args.Length == 0) return null; + var template = args[0] as string; + if (template == null) + this.ThrowScriptError("Format template must be a string."); + if (args.Length == 1) return template; + //create formatting args array + var formatArgs = args.Skip(1).ToArray(); + var text = string.Format(template, formatArgs); + return text; + + } + */ + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/TypeNormalizer.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/TypeNormalizer.cs new file mode 100644 index 0000000000..c0de51f39a --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/TypeNormalizer.cs @@ -0,0 +1,122 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Globalization; + +namespace ICSharpCode.Reporting.Expressions +{ + /// + /// Description of TypeNormalizer. + /// + public class TypeNormalizer + { + /* + public static void NormalizeTypes(ref object left,ref object right) + { + NormalizeTypes(ref left,ref right,0); + } + + public static void NormalizeTypes(ref object left,ref object right,object nullValue) + { + if (left == null) + left = 0; + if (right == null) + right = 0; + + if (left.GetType() == right.GetType()) + return; + + try + { + right = Convert.ChangeType(right,left.GetType(),CultureInfo.CurrentCulture); + } + catch + { + try + { + left = Convert.ChangeType(left, right.GetType(),CultureInfo.CurrentCulture); + } + catch + { + throw new Exception(String.Format("Error converting from {0} type to {1}", left.GetType().FullName, right.GetType().FullName)); + } + } + } + + public static void EnsureTypes(ref object[] values,Type targetType) + { + object nullValue = null; + if (targetType.IsValueType) + nullValue = Activator.CreateInstance(targetType); + EnsureTypes(ref values,targetType,nullValue); + + } + + public static void EnsureTypes(ref object[] values,Type targetType,object nullValue) + { + for (int i=0;i(object value) + { + return EnsureType(value, default(T)); + } + + public static T EnsureType(object value,object nullValue) + { + return (T) EnsureType(value, typeof (T), nullValue); + } + + public static object EnsureType(object value, Type targetType) + { + if (value != null && value.GetType() == targetType) + return value; + + object defaultValue = null; + if (targetType.IsValueType) + defaultValue = Activator.CreateInstance(targetType); + return EnsureType(value, targetType, defaultValue); + } + + public static object EnsureType(object value,Type targetType,object nullValue) + { + if (value == null) + return nullValue; + + if (targetType == typeof(object)) + return value; + + if (value.GetType() == targetType) + return value; + + try { + return Convert.ChangeType(value, targetType,CultureInfo.CurrentCulture); + } catch (Exception e) { + + Console.WriteLine("TypeNormalizer {0} - {1}",value.ToString(),e.Message); + return value.ToString(); + //throw new Exception()String.Format("TypeNormalizer for <{0}> - {1}",value.ToString(),e.Message)); + } + } + + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Factories/ReportCreatorFactory.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Factories/ReportCreatorFactory.cs index c062ed9375..2c3d1119e8 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Factories/ReportCreatorFactory.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Factories/ReportCreatorFactory.cs @@ -46,6 +46,7 @@ namespace ICSharpCode.Reporting.Factories case GlobalEnums.PushPullModel.PushData: { + break; } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/CreateGraphics.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/CreateGraphics.cs index 5a88e48516..78005c76f5 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/CreateGraphics.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/CreateGraphics.cs @@ -24,7 +24,7 @@ namespace ICSharpCode.Reporting.Globals /// /// Description of CreateGraphics. /// - public class CreateGraphics + internal class CreateGraphics { public static Graphics FromSize (Size size){ if (size == null) { diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/GlobalEnums.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/GlobalEnums.cs index 2a8c9cf390..a883afc1c3 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/GlobalEnums.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/GlobalEnums.cs @@ -23,8 +23,11 @@ namespace ICSharpCode.Reporting.Globals /// /// Description of GlobalEnums. /// - public class GlobalEnums + public sealed class GlobalEnums { + GlobalEnums() { + } + /* public enum ReportSection { ReportHeader, ReportPageHeader, @@ -32,7 +35,7 @@ namespace ICSharpCode.Reporting.Globals ReportPageFooter, ReportFooter } - + */ ///Technics to get the data /// Push : report get's a ready filld dataset or something tah implements IList /// Pull : report has to fill data by themself diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/MeasurementService.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/MeasurementService.cs index 200fcb7da5..6b5f61572a 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/MeasurementService.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/MeasurementService.cs @@ -18,36 +18,33 @@ using System; using System.Drawing; -using ICSharpCode.Reporting.Items; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; namespace ICSharpCode.Reporting.Globals { /// /// Description of MeasurementService. /// - internal class MeasurementService + static class MeasurementService { - public MeasurementService() - { - } - public static Size Measure (ITextItem item,Graphics graphics) { - + public static Size Measure (IExportText item,Graphics graphics) { if (!item.CanGrow) { return item.Size; } + var sf = new StringFormat(); + sf.FormatFlags = StringFormatFlags.MeasureTrailingSpaces; if (!String.IsNullOrEmpty(item.Text)) { - SizeF size = graphics.MeasureString(item.Text.TrimEnd(), + SizeF sizeF = graphics.MeasureString(item.Text.TrimEnd(), item.Font, item.Size.Width); - var i = (int)size.Height/item.Font.Height; - if (size.Height < item.Size.Height) { + + if (sizeF.Height < item.Size.Height) { return item.Size; } - return new Size(item.Size.Width,(int)Math.Ceiling(size.Height)); + return new Size(item.Size.Width,(int)Math.Ceiling(sizeF.Height)); } - return item.Size; } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/StandardFormatter.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/StandardFormatter.cs new file mode 100644 index 0000000000..9e684ac60a --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/StandardFormatter.cs @@ -0,0 +1,168 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Globalization; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; + +namespace ICSharpCode.Reporting.Globals +{ + /// + /// Description of StandardFormatter. + /// + class StandardFormatter + { + public static void FormatOutput (IExportText textColumn) { + if (!String.IsNullOrEmpty(textColumn.FormatString)) { + TypeCode typeCode = TypeHelper.TypeCodeFromString(textColumn.DataType); + textColumn.Text = FormatItem(textColumn.Text,textColumn.FormatString,typeCode); + } + } + + /* + public static string FormatOutput(string valueToFormat,string format, + string dataType, string nullValue ) + { + if (String.IsNullOrEmpty(format)) { + return valueToFormat; + } + + if (String.IsNullOrEmpty(valueToFormat)) { + return nullValue; + } + + TypeCode typeCode = TypeHelper.TypeCodeFromString(dataType); + return FormatItem(valueToFormat,format,typeCode,nullValue); + } + */ + +// private static string FormatItem (string valueToFormat,string format, +// TypeCode typeCode,string nullValue) + private static string FormatItem (string valueToFormat,string format, + TypeCode typeCode) + { + string retValue = String.Empty; + + switch (typeCode) { + case TypeCode.Int16: + case TypeCode.Int32: + retValue = FormatIntegers (valueToFormat,format); + break; + case TypeCode.DateTime: + retValue = FormatDate(valueToFormat,format); + break; + case TypeCode.Boolean: + retValue = FormatBool (valueToFormat); + break; + case TypeCode.Decimal: + retValue = FormatDecimal (valueToFormat,format); + break; + + case TypeCode.Double: + case TypeCode.Single: + break; + + case TypeCode.String: + case TypeCode.Char: + retValue = valueToFormat; + break; + default: + retValue = valueToFormat; + break; + } + + return retValue; + } + + + private static string FormatBool (string toFormat) + { + if (CheckValue(toFormat)) { + bool b = bool.Parse (toFormat); + return b.ToString (CultureInfo.CurrentCulture); + } + return toFormat; + } + + private static string FormatIntegers(string toFormat, string format) + { + string str = String.Empty; + if (CheckValue (toFormat)) { + int number = Int32.Parse(toFormat, System.Globalization.NumberStyles.Any, CultureInfo.CurrentCulture.NumberFormat); + str = number.ToString(format, CultureInfo.CurrentCulture); + return str; + } else { + str = (0.0M).ToString(CultureInfo.CurrentCulture); + } + return str; + } + + + private static string FormatDecimal(string toFormat, string format) + { + string str = String.Empty; + if (CheckValue (toFormat)) { + try { + decimal dec = Decimal.Parse(toFormat, + System.Globalization.NumberStyles.Any, + CultureInfo.CurrentCulture.NumberFormat); + str = dec.ToString (format,CultureInfo.CurrentCulture); + + } catch (FormatException) { + throw ; + } + return str; + } else { + str = (0.0M).ToString(CultureInfo.CurrentCulture); + } + return str; + } + +// http://stackoverflow.com/questions/4710455/i-need-code-to-validate-any-time-in-c-sharp-in-hhmmss-format + + private static string FormatDate(string toFormat, string format) + { + DateTime date; + if (DateTime.TryParse(toFormat, out date)) + { + string str = date.ToString(format, + DateTimeFormatInfo.CurrentInfo); + return str.Trim(); + } + + TimeSpan time; + bool valid = TimeSpan.TryParseExact(toFormat, + "g", + CultureInfo.CurrentCulture, + out time); + if (valid) { + return time.ToString("g",DateTimeFormatInfo.CurrentInfo); + } + return toFormat; + } + + + private static bool CheckValue (string toFormat) + { + if (String.IsNullOrEmpty(toFormat)) { + return false; + } + return true; + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/StringHelper.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/StringHelper.cs new file mode 100644 index 0000000000..710fb994ef --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/StringHelper.cs @@ -0,0 +1,154 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +namespace ICSharpCode.Reporting.Globals +{ + /// + /// Description of StringHelper. + /// + class StringHelper + { + /// + /// Left of the first occurance of c + /// + /// + /// + /// + public static string LeftOf(string src, char c) + { + int idx=src.IndexOf(c); + if (idx==-1) + { + return src; + } + + return src.Substring(0, idx); + } + + /// + /// Left of the n'th occurance of c + /// + /// + /// + /// + /// + public static string LeftOf(string src, char c, int n) + { + int idx=-1; + while (n != 0) + { + idx=src.IndexOf(c, idx+1); + if (idx==-1) + { + return src; + } + --n; + } + return src.Substring(0, idx); + } + + /// + /// Right of the first occurance of c + /// + /// + /// + /// + public static string RightOf(string src, char c) + { + int idx=src.IndexOf(c); + if (idx==-1) + { + return ""; + } + + return src.Substring(idx+1); + } + + /// + /// Right of the n'th occurance of c + /// + /// + /// + /// + public static string RightOf(string src, char c, int n) + { + int idx=-1; + while (n != 0) + { + idx=src.IndexOf(c, idx+1); + if (idx==-1) + { + return ""; + } + --n; + } + + return src.Substring(idx+1); + } + + public static string LeftOfRightmostOf(string src, char c) + { + int idx=src.LastIndexOf(c); + if (idx==-1) + { + return src; + } + return src.Substring(0, idx); + } + + public static string RightOfRightmostOf(string src, char c) + { + int idx=src.LastIndexOf(c); + if (idx==-1) + { + return src; + } + return src.Substring(idx+1); + } + + public static string Between(string src, char start, char end) + { + string res=String.Empty; + int idxStart=src.IndexOf(start); + if (idxStart != -1) + { + ++idxStart; + int idxEnd=src.IndexOf(end, idxStart); + if (idxEnd != -1) + { + res=src.Substring(idxStart, idxEnd-idxStart); + } + } + return res; + } + + public static int Count(string src, char find) + { + int ret=0; + foreach(char s in src) + { + if (s==find) + { + ++ret; + } + } + return ret; + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/TypeHelper.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/TypeHelper.cs new file mode 100644 index 0000000000..644ffab2aa --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/TypeHelper.cs @@ -0,0 +1,84 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Data; + +namespace ICSharpCode.Reporting.Globals +{ + /// + /// Description of TypeHelper. + /// + class TypeHelper + { + public static DbType DbTypeFromStringRepresenation(string type) + { + switch (type.ToLower()) + { + case "int": + return DbType.Int16; + case "int16": + return DbType.Int16; + case "int32": + return DbType.Int32; + case "int64": + return DbType.Int64; + case "uint16": + return DbType.UInt16; + case "uint32": + return DbType.UInt32; + case "uint64": + return DbType.UInt64; + case "single": + return DbType.Single; + case "double": + return DbType.Double; + case "decimal": + return DbType.Decimal; + case "datetime" : + return DbType.DateTime; + case "datetime2" : + return DbType.DateTime2; + case "boolean" : + return DbType.Boolean; + case "nvarchar": + return DbType.String; + case "varchar": + return DbType.AnsiString; + case "binary": + return DbType.Binary; + case "currency": + return DbType.Currency; + case "guid": + return DbType.Guid; + case "xml": + return DbType.Xml; + default: + return DbType.Object; + } + } + + public static TypeCode TypeCodeFromString (string type) { + if (type == null) + type = "System.String"; + var x = Type.GetTypeCode( Type.GetType(type)); + + return x; + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/Data/IDataViewHandling.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/Data/IDataSource.cs similarity index 73% rename from src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/Data/IDataViewHandling.cs rename to src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/Data/IDataSource.cs index 07aeaace4f..66f6486356 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/Data/IDataViewHandling.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/Data/IDataSource.cs @@ -18,7 +18,9 @@ using System; using System.Collections; +using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Linq; using ICSharpCode.Reporting.BaseClasses; using ICSharpCode.Reporting.DataManager.Listhandling; @@ -28,34 +30,14 @@ namespace ICSharpCode.Reporting.Interfaces.Data /// /// Description of IDataViewHandling. /// - public interface IDataViewHandling:IEnumerator{ - - void Sort (); - - void Group(); + public interface IDataSource{ void Bind(); - -// void Fill (int position,ReportItemCollection collection); - - //rausnehmen -// void Fill (IDataItem item); - - void Fill(ReportItemCollection collection); - - IndexList IndexList {get;} - -// object CurrentFromPosition(int pos); - -// CurrentItemsCollection FillDataRow(); -// CurrentItemsCollection FillDataRow(int pos); - // + void Fill(List collection,object current); Collection AvailableFields {get;} - + IList CurrentList {get;} int Count {get;} - - int CurrentPosition {get;set;} - -// IExpressionEvaluatorFacade ExpressionEvaluator {get;} + object Current {get;} + OrderGroup OrderGroup {get;} } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/Export/IExportColumn.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/Export/IExportColumn.cs index 183d6c2aaf..c0f4fa3b1c 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/Export/IExportColumn.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/Export/IExportColumn.cs @@ -19,8 +19,6 @@ using System; using System.Drawing; using ICSharpCode.Reporting.Arrange; -using ICSharpCode.Reporting.BaseClasses; -using ICSharpCode.Reporting.Exporter; namespace ICSharpCode.Reporting.Interfaces.Export { @@ -30,6 +28,7 @@ namespace ICSharpCode.Reporting.Interfaces.Export public interface IExportColumn:IReportObject { IArrangeStrategy GetArrangeStrategy(); + IMeasurementStrategy MeasurementStrategy (); Size DesiredSize {get;set;} IExportColumn Parent {get;set;} Rectangle DisplayRectangle {get;} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/Export/IExportContainer.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/Export/IExportContainer.cs index 41144a67b5..29b0e1b79c 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/Export/IExportContainer.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/Export/IExportContainer.cs @@ -18,7 +18,6 @@ using System; using System.Collections.Generic; -using ICSharpCode.Reporting.PageBuilder.ExportColumns; namespace ICSharpCode.Reporting.Interfaces.Export { diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/Export/IPage.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/Export/IPage.cs index 4beb5e1317..6392cc92d1 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/Export/IPage.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/Export/IPage.cs @@ -17,7 +17,6 @@ // DEALINGS IN THE SOFTWARE. using System; -using System.Collections.Generic; namespace ICSharpCode.Reporting.Interfaces.Export { diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/IPrintableObject.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/IPrintableObject.cs index 24c9bce94b..ef9b611da8 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/IPrintableObject.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/IPrintableObject.cs @@ -33,14 +33,13 @@ namespace ICSharpCode.Reporting.Interfaces Color ForeColor {get;set;} Color BackColor {get;set;} Color FrameColor{get;set;} + bool DrawBorder {get;set;} bool CanGrow {get;set;} } public interface IPrintableObject:IReportObject { IExportColumn CreateExportColumn(); - IMeasurementStrategy MeasurementStrategy (); - } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/IReportContainer.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/IReportContainer.cs index dd5a47f333..a543a941df 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/IReportContainer.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/IReportContainer.cs @@ -18,8 +18,6 @@ using System; using System.Collections.Generic; -using ICSharpCode.Reporting.Interfaces.Export; -using ICSharpCode.Reporting.Items; namespace ICSharpCode.Reporting.Interfaces { diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/IReportCreator.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/IReportCreator.cs index 9f47e3dd9f..e437681d6a 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/IReportCreator.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/IReportCreator.cs @@ -17,11 +17,9 @@ // DEALINGS IN THE SOFTWARE. using System; -using System.Collections.Generic; using System.Collections.ObjectModel; -using ICSharpCode.Reporting.BaseClasses; -using ICSharpCode.Reporting.Interfaces.Export; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; namespace ICSharpCode.Reporting.Interfaces { @@ -31,8 +29,8 @@ namespace ICSharpCode.Reporting.Interfaces public interface IReportCreator { void BuildExportList (); - Collection Pages {get;} - + Collection Pages {get;} + event EventHandler SectionRendering; // PagesCollection Pages{get;} // event EventHandler PageCreated; // event EventHandler SectionRendering; diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/IReportModel.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/IReportModel.cs index c0b3fbf47a..9930c30320 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/IReportModel.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/IReportModel.cs @@ -18,6 +18,8 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; + using ICSharpCode.Reporting.Items; namespace ICSharpCode.Reporting.Interfaces @@ -28,16 +30,8 @@ namespace ICSharpCode.Reporting.Interfaces public interface IReportModel { ReportSettings ReportSettings {get;set;} - List SectionCollection {get;} - /* - ISection ReportHeader {get;} - ISection PageHeader {get;} - ISection DetailSection {get;} - ISection PageFooter {get;} - ISection ReportFooter {get;} + Collection SectionCollection {get;} - GlobalEnums.PushPullModel DataModel {get;} - */ IReportContainer ReportHeader {get;} IReportContainer PageHeader {get;} IReportContainer DetailSection {get;} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseDataItem.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseDataItem.cs index 8f9cd572ef..7c2334ddba 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseDataItem.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseDataItem.cs @@ -18,6 +18,8 @@ using System; using ICSharpCode.Reporting.Interfaces; +using ICSharpCode.Reporting.Interfaces.Export; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; namespace ICSharpCode.Reporting.Items { @@ -30,11 +32,19 @@ namespace ICSharpCode.Reporting.Items { } + public override IExportColumn CreateExportColumn() + { + var exCol = (IExportText)base.CreateExportColumn(); + exCol.Text = DBValue; + return exCol; + } + + public virtual string DBValue {get;set;} public virtual string ColumnName {get;set;} - public string DataType {get;set;} +// public string DataType {get;set;} } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Factories/SectionFactory.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseRowItem.cs similarity index 75% rename from src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Factories/SectionFactory.cs rename to src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseRowItem.cs index 346817691a..a54ad72d41 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Factories/SectionFactory.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseRowItem.cs @@ -16,25 +16,21 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -using System; -using ICSharpCode.Reporting.Items; - -namespace ICSharpCode.Reporting.Factories +namespace ICSharpCode.Reporting.Items { /// - /// Description of SectionFactory. + /// Description of BaseRowItem. /// - internal sealed class SectionFactory + public class BaseRowItem:ReportContainer { - private SectionFactory () + public BaseRowItem() { - } - public static BaseSection Create(string sectionName) { - if (String.IsNullOrEmpty(sectionName)) { - throw new ArgumentException("sectionName"); - } - return new BaseSection(sectionName); + } + + public class GroupHeader :BaseRowItem + { + public GroupHeader() { } } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseSection.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseSection.cs index 98f7747680..55bc14706f 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseSection.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseSection.cs @@ -17,10 +17,8 @@ // DEALINGS IN THE SOFTWARE. using System; -using System.Collections.Generic; +using System.Drawing; using ICSharpCode.Reporting.Interfaces; -using ICSharpCode.Reporting.Interfaces.Export; -using ICSharpCode.Reporting.PageBuilder.ExportColumns; namespace ICSharpCode.Reporting.Items { @@ -28,7 +26,7 @@ namespace ICSharpCode.Reporting.Items /// Description of BaseSection. /// -public class BaseSection:ReportContainer,IReportContainer + public class BaseSection:ReportContainer,IReportContainer { #region Constructors @@ -36,10 +34,6 @@ public class BaseSection:ReportContainer,IReportContainer { } - public BaseSection (string name) { - Name = name; - } - #endregion } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseTextItem.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseTextItem.cs index 24ab20d14e..b9e0068025 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseTextItem.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseTextItem.cs @@ -18,7 +18,6 @@ using System; using System.Drawing; -using ICSharpCode.Reporting.Arrange; using ICSharpCode.Reporting.Globals; using ICSharpCode.Reporting.Interfaces; using ICSharpCode.Reporting.Interfaces.Export; @@ -33,6 +32,10 @@ namespace ICSharpCode.Reporting.Items { Font Font {get;set;} string Text {get;set;} + ContentAlignment ContentAlignment {get;set;} + string FormatString {get;set;} + string DataType {get;set;} + } public class BaseTextItem:PrintableItem,ITextItem @@ -47,6 +50,26 @@ namespace ICSharpCode.Reporting.Items public string Text {get;set;} + public string FormatString {get;set;} + + public ContentAlignment ContentAlignment {get;set;} + + string dataType; + + public string DataType + { + get { + if (String.IsNullOrEmpty(this.dataType)) { + this.dataType = typeof(System.String).ToString(); + } + return dataType; + } + set { + dataType = value; + } + } + + public override IExportColumn CreateExportColumn() { var ex = new ExportText(); @@ -58,14 +81,12 @@ namespace ICSharpCode.Reporting.Items ex.Size = Size; ex.Font = Font; ex.Text = Text; + ex.FormatString = FormatString; + ex.ContentAlignment = ContentAlignment; + ex.DataType = DataType; ex.CanGrow = CanGrow; + ex.DrawBorder = DrawBorder; return ex; - } - - public override ICSharpCode.Reporting.Arrange.IMeasurementStrategy MeasurementStrategy() - { - return new TextBasedMeasurementStrategy(); - } - + } } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/Graphics/BaseCircleItem.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/Graphics/BaseCircleItem.cs new file mode 100644 index 0000000000..0381da0ae7 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/Graphics/BaseCircleItem.cs @@ -0,0 +1,46 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using ICSharpCode.Reporting.Interfaces.Export; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; + +namespace ICSharpCode.Reporting.Items +{ + /// + /// Description of BaseCircleItem. + /// + public class BaseCircleItem:BaseGraphics + { + public BaseCircleItem() + { + } + + public override IExportColumn CreateExportColumn() + { + var ex = new ExportCircle(); + ex.Location = Location; + ex.ForeColor = ForeColor; + ex.BackColor = BackColor; + ex.Size = Size; + ex.DesiredSize = Size; + ex.Thickness = Thickness; + ex.DashStyle = DashStyle; + return ex; + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/Graphics/BaseGraphics.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/Graphics/BaseGraphics.cs new file mode 100644 index 0000000000..0d752e15f5 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/Graphics/BaseGraphics.cs @@ -0,0 +1,43 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System.Drawing.Drawing2D; + +namespace ICSharpCode.Reporting.Items +{ + /// + /// Description of BaseGraphics. + /// + public class BaseGraphics:PrintableItem + { + public BaseGraphics() + { + this.Thickness = 1; + DashStyle = DashStyle.Solid; + } + + + public virtual int Thickness {get;set;} + + public virtual DashStyle DashStyle {get;set;} + + public virtual LineCap StartLineCap {get;set;} + + public virtual LineCap EndLineCap {get;set;} + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/Graphics/BaseLineItem.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/Graphics/BaseLineItem.cs new file mode 100644 index 0000000000..866c4c5b22 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/Graphics/BaseLineItem.cs @@ -0,0 +1,47 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using ICSharpCode.Reporting.Interfaces.Export; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; + +namespace ICSharpCode.Reporting.Items{ + /// + /// Description of BaseLineItem. + /// + public class BaseLineItem:BaseGraphics + { + public BaseLineItem() + { + } + + public override IExportColumn CreateExportColumn() + { + var ex = new ExportLine(); + ex.Location = Location; + ex.ForeColor = ForeColor; + ex.BackColor = BackColor; + ex.Size = Size; + ex.DesiredSize = Size; + ex.Thickness = Thickness; + ex.DashStyle = DashStyle; + ex.StartLineCap = StartLineCap; + ex.EndLineCap = EndLineCap; + return ex; + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/Graphics/BaseRectangleItem.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/Graphics/BaseRectangleItem.cs new file mode 100644 index 0000000000..9a60d78fac --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/Graphics/BaseRectangleItem.cs @@ -0,0 +1,49 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using ICSharpCode.Reporting.Interfaces.Export; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; + +namespace ICSharpCode.Reporting.Items +{ + /// + /// Description of BaseRectangleItem. + /// + public class BaseRectangleItem:BaseGraphics + { + public BaseRectangleItem() + { + } + + + public override IExportColumn CreateExportColumn() + { + var ex = new ExportRectangle(); + ex.Location = Location; + ex.ForeColor = ForeColor; + ex.BackColor = BackColor; + ex.Size = Size; + ex.DesiredSize = Size; + ex.Thickness = Thickness; + ex.DashStyle = DashStyle; + ex.StartLineCap = StartLineCap; + ex.EndLineCap = EndLineCap; + return ex; + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/GroupColumn.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/GroupColumn.cs similarity index 95% rename from src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/GroupColumn.cs rename to src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/GroupColumn.cs index 7de5da2d2d..3c913fadf7 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/GroupColumn.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/GroupColumn.cs @@ -19,7 +19,7 @@ using System; using System.ComponentModel; -namespace ICSharpCode.Reporting.BaseClasses +namespace ICSharpCode.Reporting.Items { /// /// Description of GroupColumn. @@ -43,6 +43,6 @@ namespace ICSharpCode.Reporting.BaseClasses public int GroupLevel {get;private set;} - + public SortColumn GroupSortColumn {get;set;} } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/PrintableItem.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/PrintableItem.cs index 8cb49544c6..ec72ea1005 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/PrintableItem.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/PrintableItem.cs @@ -18,7 +18,6 @@ using System; using System.Drawing; -using ICSharpCode.Reporting.Arrange; using ICSharpCode.Reporting.Interfaces; using ICSharpCode.Reporting.Interfaces.Export; @@ -26,6 +25,12 @@ namespace ICSharpCode.Reporting.Items { public class PrintableItem : IPrintableObject { + public PrintableItem() { + ForeColor = Color.Black; + FrameColor = Color.Black; + BackColor = Color.White; + } + public string Name { get; set; } public Point Location { get; set; } @@ -38,11 +43,6 @@ namespace ICSharpCode.Reporting.Items return null; } - public virtual IMeasurementStrategy MeasurementStrategy () - { - return null; - } - public Color ForeColor {get;set;} public Color BackColor {get;set;} @@ -51,5 +51,7 @@ namespace ICSharpCode.Reporting.Items public bool CanGrow {get;set;} + public bool DrawBorder {get;set;} + } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/ReportContainer.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/ReportContainer.cs index 7731274abf..127522cee3 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/ReportContainer.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/ReportContainer.cs @@ -18,8 +18,6 @@ using System; using System.Collections.Generic; -using ICSharpCode.Reporting.Arrange; -using ICSharpCode.Reporting.Exporter; using ICSharpCode.Reporting.Interfaces; using ICSharpCode.Reporting.Interfaces.Export; using ICSharpCode.Reporting.PageBuilder.ExportColumns; @@ -51,13 +49,9 @@ namespace ICSharpCode.Reporting.Items Size = this.Size, Location = this.Location, CanGrow = this.CanGrow, + BackColor = this.BackColor, + DesiredSize = this.Size }; } - - - public override IMeasurementStrategy MeasurementStrategy() - { - return new ContainerMeasurementStrategy(); - } } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/ReportModel.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/ReportModel.cs index 9883a5b026..99c4805dcb 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/ReportModel.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/ReportModel.cs @@ -17,9 +17,8 @@ // DEALINGS IN THE SOFTWARE. using System; -using System.Collections.Generic; -using ICSharpCode.Reporting.Factories; -using ICSharpCode.Reporting.Globals; +using System.Collections.ObjectModel; + using ICSharpCode.Reporting.Interfaces; namespace ICSharpCode.Reporting.Items @@ -31,7 +30,7 @@ namespace ICSharpCode.Reporting.Items { public ReportModel() { - SectionCollection = new List(); + SectionCollection = new Collection(); } @@ -93,6 +92,6 @@ namespace ICSharpCode.Reporting.Items } } - public List SectionCollection {get; private set;} + public Collection SectionCollection {get; private set;} } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/ReportSettings.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/ReportSettings.cs index c78bce4eb5..5cde4defba 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/ReportSettings.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/ReportSettings.cs @@ -33,7 +33,7 @@ namespace ICSharpCode.Reporting.Items public ReportSettings() { - this.pageSize = Globals.GlobalValues.DefaultPageSize; + this.pageSize = GlobalValues.DefaultPageSize; BaseValues(); } @@ -61,9 +61,9 @@ namespace ICSharpCode.Reporting.Items // this.availableFields = new AvailableFieldsCollection(); // this.groupingsCollection = new GroupColumnCollection(); this.SortColumnsCollection = new SortColumnCollection(); - GroupColumnCollection = new GroupColumnCollection(); + this.GroupColumnsCollection = new GroupColumnCollection(); // this.sqlParameters = new SqlParameterCollection(); -// this.parameterCollection = new ParameterCollection(); + ParameterCollection = new ParameterCollection(); // this.NoDataMessage = "No Data for this Report"; } @@ -147,8 +147,15 @@ namespace ICSharpCode.Reporting.Items // [Browsable(true), Category("Base Settings")] public GlobalEnums.ReportType ReportType {get;set;} + +// [Category("Parameters")] +// [EditorAttribute ( typeof(ParameterCollectionEditor), +// typeof(System.Drawing.Design.UITypeEditor) )] + + public ParameterCollection ParameterCollection {get; private set;} + public SortColumnCollection SortColumnsCollection {get;private set;} - public GroupColumnCollection GroupColumnCollection {get;private set;} + public GroupColumnCollection GroupColumnsCollection {get;private set;} } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/SortColumn.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/SortColumn.cs similarity index 91% rename from src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/SortColumn.cs rename to src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/SortColumn.cs index 68b0d25b80..df4165bcd8 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/SortColumn.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/SortColumn.cs @@ -18,8 +18,9 @@ using System; using System.ComponentModel; +using ICSharpCode.Reporting.BaseClasses; -namespace ICSharpCode.Reporting.BaseClasses +namespace ICSharpCode.Reporting.Items { /// /// Description of SortColumn. @@ -27,8 +28,6 @@ namespace ICSharpCode.Reporting.BaseClasses public class SortColumn : AbstractColumn { private ListSortDirection sortDirection = ListSortDirection.Ascending; - private bool caseSensitive; - public SortColumn():this(String.Empty,ListSortDirection.Ascending,typeof(System.String),false) { @@ -40,9 +39,9 @@ namespace ICSharpCode.Reporting.BaseClasses } - public SortColumn(string columnName, ListSortDirection sortDirection, Type type,bool caseSensitive ):base (columnName,type) + public SortColumn(string columnName, ListSortDirection sortDirection, Type type,bool caseSensitive ):base (columnName,type) { - this.caseSensitive = caseSensitive; + CaseSensitive = caseSensitive; this.sortDirection = sortDirection; } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/BasePageBuilder.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/BasePageBuilder.cs index 3c72db9ac8..69ba6520cf 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/BasePageBuilder.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/BasePageBuilder.cs @@ -17,16 +17,20 @@ // DEALINGS IN THE SOFTWARE. using System; -using System.Collections.Generic; using System.Collections.ObjectModel; using System.Drawing; using System.Linq; using ICSharpCode.Reporting.BaseClasses; +using ICSharpCode.Reporting.DataManager.Listhandling; +using ICSharpCode.Reporting.Exporter; +using ICSharpCode.Reporting.Expressions; using ICSharpCode.Reporting.Globals; using ICSharpCode.Reporting.Interfaces; using ICSharpCode.Reporting.Interfaces.Export; +using ICSharpCode.Reporting.Items; using ICSharpCode.Reporting.PageBuilder.Converter; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; namespace ICSharpCode.Reporting.PageBuilder { @@ -35,101 +39,123 @@ namespace ICSharpCode.Reporting.PageBuilder /// public class BasePageBuilder:IReportCreator { - Graphics graphics; - public BasePageBuilder(IReportModel reportModel) - { + public event EventHandler SectionRendering; + + public BasePageBuilder(IReportModel reportModel){ if (reportModel == null) { throw new ArgumentNullException("reportModel"); } ReportModel = reportModel; - Pages = new Collection(); - graphics = CreateGraphics.FromSize(reportModel.ReportSettings.PageSize); - } - - - protected IPage InitNewPage(){ - var pi = CreatePageInfo(); - return new Page(pi,ReportModel.ReportSettings.PageSize); + Pages = new Collection(); + Graphics = CreateGraphics.FromSize(reportModel.ReportSettings.PageSize); } - #region create Sections + #region create Report Sections - protected void BuildReportHeader() - { + void BuildReportHeader(){ if (Pages.Count == 0) { var header = CreateSection(ReportModel.ReportHeader,CurrentLocation); - var r = new Rectangle(header.Location.X,header.Location.Y,header.Size.Width,header.Size.Height); + var r = new Rectangle(header.Location.X, header.Location.Y, header.Size.Width, header.Size.Height); CurrentLocation = new Point (ReportModel.ReportSettings.LeftMargin,r.Bottom + 1); AddSectionToPage(header); } } + static void Raise (EventHandler handler, object sender, T e) + where T: EventArgs{ + // Copy to a temporary variable to be thread-safe. + EventHandler temp = handler; - protected void BuildPageHeader() - { - + if (temp != null) { + temp(sender, e); + } + } + + void BuildPageHeader(){ var pageHeader = CreateSection(ReportModel.PageHeader,CurrentLocation); - DetailStart = new Point(ReportModel.ReportSettings.LeftMargin,pageHeader.Location.Y + pageHeader.Size.Height +1); + DetailStart = new Point(ReportModel.ReportSettings.LeftMargin,pageHeader.Location.Y + pageHeader.DesiredSize.Height +1); AddSectionToPage(pageHeader); } - protected void BuildPageFooter() - { - Console.WriteLine("FormPageBuilder - Build PageFooter {0} - {1}",ReportModel.ReportSettings.PageSize.Height,ReportModel.ReportSettings.BottomMargin); + void BuildPageFooter(){ CurrentLocation = new Point(ReportModel.ReportSettings.LeftMargin, ReportModel.ReportSettings.PageSize.Height - ReportModel.ReportSettings.BottomMargin - ReportModel.PageFooter.Size.Height); - var pageFooter = CreateSection(ReportModel.PageFooter,CurrentLocation); + + var pageFooter = CreateSection(ReportModel.PageFooter,CurrentLocation); + DetailEnds = new Point(pageFooter.Location.X + pageFooter.Size.Width,pageFooter.Location.Y -1); AddSectionToPage(pageFooter); } - protected void BuildReportFooter() - { - Console.WriteLine("FormPageBuilder - Build ReportFooter {0} - {1}",ReportModel.ReportSettings.PageSize.Height,ReportModel.ReportSettings.BottomMargin); + void AddSectionToPage(IExportContainer header){ + header.Parent = CurrentPage; + CurrentPage.ExportedItems.Add(header); + } + + + + + protected void BuildReportFooter(){ var lastSection = CurrentPage.ExportedItems.Last(); CurrentLocation = new Point(ReportModel.ReportSettings.LeftMargin, - lastSection.Location.Y - lastSection.Size.Height - 1); - - var reportFooter = CreateSection(ReportModel.ReportFooter,CurrentLocation); - AddSectionToPage(reportFooter); + lastSection.Location.Y - ReportModel.ReportFooter.Size.Height - 2); + var reportFooter = CreateSection(ReportModel.ReportFooter,CurrentLocation); + if (reportFooter.ExportedItems.Any()) { + AddSectionToPage(reportFooter); + } } - #endregion - protected virtual void WritePages() - { - CurrentPage = InitNewPage(); - CurrentLocation = new Point(ReportModel.ReportSettings.LeftMargin,ReportModel.ReportSettings.TopMargin); - this.BuildReportHeader(); + protected void WriteStandardSections() { + BuildReportHeader(); BuildPageHeader(); BuildPageFooter(); -// BuilDetail(); - BuildReportFooter(); -// base.AddPage(CurrentPage); -// Console.WriteLine("------{0}---------",ReportModel.ReportSettings.PageSize); } - protected IExportContainer CreateSection(IReportContainer section,Point location) - { - var containerConverter = new ContainerConverter(graphics, section, location); - var header = containerConverter.Convert(); - return header; + protected bool PageFull(IExportContainer container) { + return container.DisplayRectangle.Bottom > DetailEnds.Y; } + + #endregion + protected IExportContainer CreateSection(IReportContainer container,Point location){ + var sea = new SectionEventArgs(container); + Raise (SectionRendering,this,sea); + var containerConverter = new ContainerConverter(location); + var convertedContainer = containerConverter.ConvertToExportContainer(container); + + var list = containerConverter.CreateConvertedList(container.Items); + + containerConverter.SetParent(convertedContainer,list); + convertedContainer.ExportedItems.AddRange(list); + + convertedContainer.DesiredSize = MeasureElement(convertedContainer); + ArrangeContainer(convertedContainer); + return convertedContainer; + } - protected void AddSectionToPage(IExportContainer header) - { - header.Parent = CurrentPage; - CurrentPage.ExportedItems.Add(header); + #region Arrange and Measure + + protected Size MeasureElement (IExportColumn element) { + var measureStrategy = element.MeasurementStrategy(); + return measureStrategy.Measure(element, Graphics); } + + protected static void ArrangeContainer(IExportContainer exportContainer){ + var exportArrange = exportContainer.GetArrangeStrategy(); + exportArrange.Arrange(exportContainer); + } + + #endregion + + #region Pagehandling - IPageInfo CreatePageInfo() - { + IPageInfo CreatePageInfo(){ var pi = new PageInfo(); pi.PageNumber = Pages.Count +1; pi.ReportName = ReportModel.ReportSettings.ReportName; @@ -137,8 +163,19 @@ namespace ICSharpCode.Reporting.PageBuilder return pi; } - - protected virtual void AddPage(IPage page) { + ExportPage InitNewPage(){ + var pi = CreatePageInfo(); + return new ExportPage(pi,ReportModel.ReportSettings.PageSize); + } + + + protected virtual ExportPage CreateNewPage(){ + var page = InitNewPage(); + CurrentLocation = new Point(ReportModel.ReportSettings.LeftMargin,ReportModel.ReportSettings.TopMargin); + return page; + } + + protected virtual void AddPage(ExportPage page) { if (Pages.Count == 0) { page.IsFirstPage = true; } @@ -146,20 +183,60 @@ namespace ICSharpCode.Reporting.PageBuilder } - public virtual void BuildExportList() - { - this.Pages.Clear(); + public virtual void BuildExportList(){ + Pages.Clear(); + CurrentPage = CreateNewPage (); + WriteStandardSections(); + CurrentLocation = DetailStart; + } + + + protected void UpdatePageInfo() { + foreach (var page in Pages) { + page.PageInfo.TotalPages = Pages.Count; + } + } + + #endregion + + #region Visitors + + protected void SetupExpressionRunner (ReportSettings reportsettings,CollectionDataSource dataSource){ + ExpressionRunner = new ExpressionRunner(Pages,reportsettings,dataSource); + } + + + protected void RunDebugVisitor(){ + var debugExporter = new DebugExporter(Pages); + debugExporter.Run(); } + #endregion + protected IReportModel ReportModel {get; private set;} protected Point CurrentLocation {get; set;} - protected IPage CurrentPage {get; set;} + protected ExportPage CurrentPage {get; set;} - protected Point DetailStart {get;private set;} + protected Graphics Graphics {get;private set;} + + internal Point DetailStart {get;private set;} + + internal Point DetailEnds {get; private set;} + + internal ExpressionRunner ExpressionRunner {get;private set;} + + + internal Rectangle DetailsRectangle { + get { + var s = new Size(DetailEnds.X - DetailStart.X,DetailEnds.Y - DetailStart.Y); + return new Rectangle(DetailStart,s); + } + } + - public Collection Pages {get; private set;} + public Collection Pages {get; private set;} } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/Converter/ContainerConverter.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/Converter/ContainerConverter.cs index e441f4cbb3..42341e0ffa 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/Converter/ContainerConverter.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/Converter/ContainerConverter.cs @@ -30,54 +30,45 @@ namespace ICSharpCode.Reporting.PageBuilder.Converter /// /// Description of SectionConverter. /// - internal class ContainerConverter + class ContainerConverter : IContainerConverter { - private Graphics graphics; - - public ContainerConverter(Graphics graphics,IReportContainer reportContainer,Point currentLocation ) + public ContainerConverter(Point currentLocation) { - if (graphics == null) { - throw new ArgumentNullException("graphics"); - } - if (reportContainer == null) { - throw new ArgumentNullException("reportContainer"); - } - - this.graphics = graphics; - Container = reportContainer; CurrentLocation = currentLocation; } - - - public IExportContainer Convert() { - var containerStrategy = Container.MeasurementStrategy (); - var exportContainer = (ExportContainer)Container.CreateExportColumn(); - + + + public virtual IExportContainer ConvertToExportContainer(IReportContainer reportContainer) + { + var exportContainer = (ExportContainer)reportContainer.CreateExportColumn(); exportContainer.Location = CurrentLocation; - exportContainer.DesiredSize = containerStrategy.Measure(Container,graphics); - + return exportContainer; + } + + + public List CreateConvertedList(List items){ var itemsList = new List(); - - foreach (var element in Container.Items) { - var item = ExportColumnFactory.CreateItem(element); - item.Parent = exportContainer; - var measureStrategy = element.MeasurementStrategy(); - item.DesiredSize = measureStrategy.Measure(element,graphics); + foreach (var element in items) { + var exportColumn = ExportColumnFactory.CreateItem(element); + var ec = element as IReportContainer; + if (ec != null) { + var l = CreateConvertedList(ec.Items); + ((IExportContainer)exportColumn).ExportedItems.AddRange(l); + } - itemsList.Add(item); - Console.WriteLine("Size {0} DesiredSize {1}",item.Size,item.DesiredSize); + itemsList.Add(exportColumn); + } + return itemsList; + } + + + public void SetParent(IExportContainer parent, List convertedItems) + { + foreach (var item in convertedItems) { + item.Parent = parent; } - exportContainer.ExportedItems.AddRange(itemsList); - - Console.WriteLine("calling Container-Arrange"); - var exportArrange = exportContainer.GetArrangeStrategy(); - exportArrange.Arrange(exportContainer); - - return exportContainer; } - - internal IReportContainer Container {get; private set;} - internal Point CurrentLocation {get; private set;} + protected Point CurrentLocation { get; set; } } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/Converter/IContainerConverter.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/Converter/IContainerConverter.cs new file mode 100644 index 0000000000..70df90361f --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/Converter/IContainerConverter.cs @@ -0,0 +1,32 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Collections.Generic; +using ICSharpCode.Reporting.Interfaces; +using ICSharpCode.Reporting.Interfaces.Export; + +namespace ICSharpCode.Reporting.PageBuilder.Converter +{ + internal interface IContainerConverter + { + IExportContainer ConvertToExportContainer(IReportContainer reportContainer); + List CreateConvertedList(List items); + void SetParent(IExportContainer parent, List convertedItems); + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/DataPageBuilder.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/DataPageBuilder.cs index ef421e63fd..98ca29edc3 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/DataPageBuilder.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/DataPageBuilder.cs @@ -17,17 +17,30 @@ // DEALINGS IN THE SOFTWARE. using System; +using System.Collections; using System.Collections.Generic; +using System.Drawing; +using System.Linq; + +using ICSharpCode.Reporting.DataManager.Listhandling; +using ICSharpCode.Reporting.Exporter.Visitors; +using ICSharpCode.Reporting.Interfaces; +using ICSharpCode.Reporting.Interfaces.Export; using ICSharpCode.Reporting.Items; +using ICSharpCode.Reporting.PageBuilder.Converter; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; namespace ICSharpCode.Reporting.PageBuilder { /// /// Description of DataPageBuilder. /// + public class DataPageBuilder:BasePageBuilder { - public DataPageBuilder(ReportModel reportModel, IEnumerable list):base(reportModel) + + + public DataPageBuilder(IReportModel reportModel,IEnumerable list):base(reportModel) { List = list; } @@ -35,32 +48,212 @@ namespace ICSharpCode.Reporting.PageBuilder public override void BuildExportList() { + CreateDataSource(); + SetupExpressionRunner(ReportModel.ReportSettings,DataSource); base.BuildExportList(); - WritePages (); + BuildDetail(); + BuildReportFooter(); + AddPage(CurrentPage); + UpdatePageInfo(); + ExpressionRunner.Run(); + var formatVisitor = new FormatVisitor(); + formatVisitor.Run(Pages); + var dv = new DebugVisitor(); + dv.Run(Pages); } - void BuilDetail() + void BuildDetail() { - Console.WriteLine("FormPageBuilder - Build DetailSection {0} - {1} - {2}",ReportModel.ReportSettings.PageSize.Width,ReportModel.ReportSettings.LeftMargin,ReportModel.ReportSettings.RightMargin); - CurrentLocation = DetailStart; + CurrentSection = ReportModel.DetailSection; + if(DataSourceContainsData()) { + CurrentLocation = DetailStart; + var converter = new ContainerConverter(DetailStart); + if (IsGrouped()) { + BuildGroupedDetails(converter,DetailStart); + } else { + BuildSortedDetails(converter,DetailStart); + } + } + } + + + void BuildGroupedDetails (IContainerConverter converter,Point startPosition) { + var pagePosition = startPosition; + var sectionPosition = pagePosition; - var detail = CreateSection(ReportModel.DetailSection,CurrentLocation); - detail.Parent = CurrentPage; - CurrentPage.ExportedItems.Insert(2,detail); + foreach (IGrouping grouping in DataSource.GroupedList) { + + var groupHeader = (BaseRowItem)CurrentSection.Items.Where(p => p.GetType() == typeof(GroupHeader)).FirstOrDefault(); + var sectionContainer = CreateContainerForSection(CurrentPage, pagePosition); + + DataSource.Fill(groupHeader.Items,grouping.FirstOrDefault()); + + var headerRow = converter.ConvertToExportContainer(groupHeader); + + headerRow.Location = new Point(headerRow.Location.X,groupHeader.Location.Y); + + var headerItems = converter.CreateConvertedList(groupHeader.Items); + converter.SetParent(sectionContainer, headerItems); + + headerRow.ExportedItems.AddRange(headerItems); + headerRow.Parent = sectionContainer; + sectionContainer.ExportedItems.Add(headerRow); + + EvaluateExpressionsInGroups(sectionContainer,grouping); + + pagePosition = new Point(CurrentSection.Location.X, pagePosition.Y + sectionContainer.DesiredSize.Height + 1); + + // Set Position Child Elements + + sectionPosition = new Point(pagePosition.X,headerRow.Location.Y + headerRow.Size.Height + 3); + + //Childs + foreach (var child in grouping) { + var dataItems = CurrentSection.Items.Where(p => p.GetType() == typeof(BaseDataItem)).ToList(); + List convertedItems = FillAndConvert(sectionContainer, child, dataItems, converter); + + AdjustLocationInSection(sectionPosition, convertedItems); + + sectionContainer.ExportedItems.AddRange(convertedItems); + MeasureAndArrangeContainer(sectionContainer); + + if (PageFull(sectionContainer)) { + PerformPageBreak(); + InsertContainer(sectionContainer); + pagePosition = DetailStart; + sectionContainer.Location = DetailStart; + } + + sectionPosition = new Point(CurrentSection.Location.X, sectionPosition.Y + convertedItems[0].DisplayRectangle.Size.Height + 5); + sectionContainer.Size = new Size(sectionContainer.Size.Width,sectionContainer.Size.Height + convertedItems[0].Size.Height); + } + MeasureAndArrangeContainer(sectionContainer); + InsertContainer(sectionContainer); + pagePosition = new Point(pagePosition.X,sectionContainer.DisplayRectangle.Bottom + 1); + } } + + void EvaluateExpressionsInGroups(ExportContainer sectionContainer, IGrouping grouping) + { + ExpressionRunner.Visitor.SetCurrentDataSource(grouping); + ExpressionRunner.Visitor.Visit(sectionContainer); + } + - protected override void WritePages() + void BuildSortedDetails(IContainerConverter converter,Point startPosition){ + + var exportRows = new List(); + var pagePosition = startPosition; + foreach (var element in DataSource.SortedList) { + var sectionContainer = CreateContainerForSection(CurrentPage, pagePosition); + var convertedItems = FillAndConvert(sectionContainer,element,ReportModel.DetailSection.Items,converter); + + sectionContainer.ExportedItems.AddRange(convertedItems); + MeasureAndArrangeContainer(sectionContainer); + + if (PageFull(sectionContainer)) { + InsertExportRows(exportRows); + exportRows.Clear(); + PerformPageBreak(); + pagePosition = DetailStart; + sectionContainer.Location = pagePosition; + } + + exportRows.Add(sectionContainer); + pagePosition = new Point(CurrentSection.Location.X, pagePosition.Y + sectionContainer.DesiredSize.Height + 1); + } + + InsertExportRows(exportRows); + } + + + void PerformPageBreak(){ + CurrentPage.PageInfo.PageNumber = Pages.Count + 1; + Pages.Add(CurrentPage); + CurrentPage = CreateNewPage(); + WriteStandardSections(); + CurrentLocation = DetailStart; + } + + + bool IsGrouped(){ + return DataSource.OrderGroup == OrderGroup.Grouped; + } + + + List FillAndConvert(ExportContainer parent, object current, List dataItems, IContainerConverter converter) { - base.WritePages(); - BuilDetail(); - base.AddPage(CurrentPage); - Console.WriteLine("------{0}---------",ReportModel.ReportSettings.PageSize); + DataSource.Fill(dataItems, current); + var convertedItems = converter.CreateConvertedList(dataItems.ToList()); + converter.SetParent(parent, convertedItems); + return convertedItems; } + void CreateDataSource(){ + DataSource = new CollectionDataSource(List, ReportModel.ReportSettings); + if (DataSourceContainsData()) { + DataSource.Bind(); + } + } + + + bool DataSourceContainsData () { + if (DataSource.Count > 0) { + return true; + } + return false; + } + + + static void AdjustLocationInSection(Point sectionPosition,List convertedItems) + { + foreach (var element in convertedItems) { + element.Location = new Point(element.Location.X, sectionPosition.Y); + } + } + + + void MeasureAndArrangeContainer(IExportContainer container){ + container.DesiredSize = MeasureElement(container); + ArrangeContainer(container); + } + + + ExportContainer CreateContainerForSection(ExportPage parent,Point location ){ + var detail = (ExportContainer)CurrentSection.CreateExportColumn(); + detail.Location = location; + detail.Parent = parent; + return detail; + } + + + void InsertContainer(ExportContainer sectionContainer) + { + if (Pages.Count == 0) { + CurrentPage.ExportedItems.Insert(2, sectionContainer); + } else { + CurrentPage.ExportedItems.Insert(1, sectionContainer); + } + } + + + void InsertExportRows(List list){ + if (Pages.Count == 0) { + CurrentPage.ExportedItems.InsertRange(2, list); + } else { + CurrentPage.ExportedItems.InsertRange(1, list); + } + } + + + internal CollectionDataSource DataSource {get; private set;} + + internal IEnumerable List {get; private set;} + + protected IReportContainer CurrentSection { get; private set; } - public IEnumerable List {get; private set;} } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportCircle.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportCircle.cs new file mode 100644 index 0000000000..899cd5e67c --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportCircle.cs @@ -0,0 +1,54 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Drawing.Drawing2D; +using ICSharpCode.Reporting.Exporter.Visitors; + +namespace ICSharpCode.Reporting.PageBuilder.ExportColumns +{ + /// + /// Description of ExportCircle. + /// + public class ExportCircle:ExportColumn,IExportGraphics,IAcceptor + { + public ExportCircle() + { + } + + + public void Accept(IVisitor visitor) + { + visitor.Visit(this); + } + + + public override ICSharpCode.Reporting.Arrange.IMeasurementStrategy MeasurementStrategy() + { + throw new NotImplementedException(); + } + + public int Thickness {get;set;} + + public DashStyle DashStyle {get;set;} + + public LineCap StartLineCap {get;set;} + + public LineCap EndLineCap {get;set;} + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportColumn.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportColumn.cs index 1c3bdd01a5..e0911e4684 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportColumn.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportColumn.cs @@ -19,9 +19,6 @@ using System; using System.Drawing; using ICSharpCode.Reporting.Arrange; -using ICSharpCode.Reporting.BaseClasses; -using ICSharpCode.Reporting.Exporter; -using ICSharpCode.Reporting.Interfaces; using ICSharpCode.Reporting.Interfaces.Export; namespace ICSharpCode.Reporting.PageBuilder.ExportColumns @@ -31,6 +28,12 @@ namespace ICSharpCode.Reporting.PageBuilder.ExportColumns /// public class ExportColumn:IExportColumn { + public ExportColumn() { + ForeColor = Color.Black; + FrameColor = Color.Black; + BackColor = Color.White; + } + public string Name {get;set;} @@ -55,11 +58,17 @@ namespace ICSharpCode.Reporting.PageBuilder.ExportColumns public bool CanGrow {get;set;} + public bool DrawBorder {get;set;} public Rectangle DisplayRectangle { get { - return new Rectangle(Location,Size); + return new Rectangle(Location,DesiredSize); } } + + public virtual IMeasurementStrategy MeasurementStrategy() + { + throw new NotImplementedException(); + } } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportContainer.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportContainer.cs index 738985d44d..931dc67a1b 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportContainer.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportContainer.cs @@ -19,7 +19,6 @@ using System; using System.Collections.Generic; using ICSharpCode.Reporting.Arrange; -using ICSharpCode.Reporting.Exporter; using ICSharpCode.Reporting.Exporter.Visitors; using ICSharpCode.Reporting.Interfaces.Export; @@ -41,14 +40,21 @@ namespace ICSharpCode.Reporting.PageBuilder.ExportColumns get { return exportedItems; } } - public void Accept(IVisitor visitor) + + + public override IArrangeStrategy GetArrangeStrategy() { - visitor.Visit(this); + return new ContainerArrangeStrategy(); } - public override ICSharpCode.Reporting.Arrange.IArrangeStrategy GetArrangeStrategy() + public override IMeasurementStrategy MeasurementStrategy() { - return new ContainerArrangeStrategy(); + return new ContainerMeasurementStrategy(); + } + + public void Accept(IVisitor visitor) + { + visitor.Visit(this); } } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportLine.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportLine.cs new file mode 100644 index 0000000000..3e4aa40d33 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportLine.cs @@ -0,0 +1,64 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Drawing.Drawing2D; +using ICSharpCode.Reporting.Exporter.Visitors; +using ICSharpCode.Reporting.Interfaces.Export; + +namespace ICSharpCode.Reporting.PageBuilder.ExportColumns +{ + /// + /// Description of ExportGraphics. + /// + /// + public interface IExportGraphics:IExportColumn { + int Thickness {get;set;} + DashStyle DashStyle {get;set;} + LineCap StartLineCap {get;set;} + LineCap EndLineCap {get;set;} + } + + + public class ExportLine:ExportColumn,IExportGraphics,IAcceptor + { + public ExportLine() + { + } + + + public void Accept(IVisitor visitor) + { + visitor.Visit(this); + } + + + public override ICSharpCode.Reporting.Arrange.IMeasurementStrategy MeasurementStrategy() + { + throw new NotImplementedException(); + } + + public int Thickness {get;set;} + + public DashStyle DashStyle {get;set;} + + public LineCap StartLineCap {get;set;} + + public LineCap EndLineCap {get;set;} + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportPage.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportPage.cs new file mode 100644 index 0000000000..8fa4f9a5c4 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportPage.cs @@ -0,0 +1,68 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Drawing; + +using ICSharpCode.Reporting.Exporter.Visitors; +using ICSharpCode.Reporting.Interfaces.Export; + +namespace ICSharpCode.Reporting.PageBuilder.ExportColumns +{ + /// + /// Description of Page. + /// + /// + + public class ExportPage:ExportColumn,IPage,IAcceptor + { + public ExportPage(IPageInfo pageInfo,Size pageSize):base() + { + if (pageInfo == null) { + throw new ArgumentNullException("pageInfo"); + } + PageInfo = pageInfo; + Name = "Page"; + Size = pageSize; + exportedItems = new List(); + } + + + public bool IsFirstPage {get;set;} + + + public IPageInfo PageInfo {get;private set;} + + + public bool CanShrink {get;set;} + + + public void Accept(IVisitor visitor) + { + visitor.Visit(this as ExportPage); + } + + + List exportedItems; + + public List ExportedItems { + get { return exportedItems; } + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportRectangle.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportRectangle.cs new file mode 100644 index 0000000000..9527513624 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportRectangle.cs @@ -0,0 +1,55 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Drawing.Drawing2D; +using ICSharpCode.Reporting.Exporter.Visitors; +using ICSharpCode.Reporting.Interfaces.Export; + +namespace ICSharpCode.Reporting.PageBuilder.ExportColumns +{ + /// + /// Description of ExportRectangle. + /// + public class ExportRectangle:ExportColumn,IExportGraphics,IAcceptor + { + public ExportRectangle() + { + } + + + public void Accept(IVisitor visitor) + { + visitor.Visit(this); + } + + + public override ICSharpCode.Reporting.Arrange.IMeasurementStrategy MeasurementStrategy() + { + throw new NotImplementedException(); + } + + public int Thickness {get;set;} + + public DashStyle DashStyle {get;set;} + + public LineCap StartLineCap {get;set;} + + public LineCap EndLineCap {get;set;} + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportText.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportText.cs index 39bca7c45f..2304ba1e4c 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportText.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportText.cs @@ -18,6 +18,7 @@ using System; using System.Drawing; +using ICSharpCode.Reporting.Arrange; using ICSharpCode.Reporting.Exporter; using ICSharpCode.Reporting.Exporter.Visitors; using ICSharpCode.Reporting.Interfaces.Export; @@ -32,6 +33,9 @@ namespace ICSharpCode.Reporting.PageBuilder.ExportColumns { Font Font {get;set;} string Text {get;set;} + ContentAlignment ContentAlignment {get;set;} + string DataType {get;set;} + string FormatString {get;set;} } @@ -50,6 +54,16 @@ namespace ICSharpCode.Reporting.PageBuilder.ExportColumns public string Text {get;set;} - + + public string FormatString {get;set;} + + public ContentAlignment ContentAlignment {get;set;} + + public string DataType {get;set;} + + public override ICSharpCode.Reporting.Arrange.IMeasurementStrategy MeasurementStrategy() + { + return new TextBasedMeasurementStrategy(); + } } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/FormPageBuilder.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/FormPageBuilder.cs index ddcc6fd549..b34b72cd00 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/FormPageBuilder.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/FormPageBuilder.cs @@ -17,12 +17,8 @@ // DEALINGS IN THE SOFTWARE. using System; -using System.Drawing; using System.Linq; - -using ICSharpCode.Reporting.Globals; using ICSharpCode.Reporting.Interfaces; -using ICSharpCode.Reporting.Interfaces.Export; namespace ICSharpCode.Reporting.PageBuilder { @@ -34,37 +30,28 @@ namespace ICSharpCode.Reporting.PageBuilder public FormPageBuilder(IReportModel reportModel):base(reportModel) { - } public override void BuildExportList() { + SetupExpressionRunner(ReportModel.ReportSettings,null); base.BuildExportList(); - WritePages (); + BuildDetail(); + BuildReportFooter(); + AddPage(CurrentPage); + UpdatePageInfo(); +// RunDebugVisitor(); + ExpressionRunner.Run(); } + - - - void BuilDetail() + void BuildDetail() { - Console.WriteLine("FormPageBuilder - Build DetailSection {0} - {1} - {2}",ReportModel.ReportSettings.PageSize.Width,ReportModel.ReportSettings.LeftMargin,ReportModel.ReportSettings.RightMargin); CurrentLocation = DetailStart; - var detail = CreateSection(ReportModel.DetailSection,CurrentLocation); detail.Parent = CurrentPage; CurrentPage.ExportedItems.Insert(2,detail); } - - - protected override void WritePages() - { - base.WritePages(); - BuilDetail(); - base.AddPage(CurrentPage); - Console.WriteLine("------{0}---------",ReportModel.ReportSettings.PageSize); - } - - } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Pdf/PdfExporter.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Pdf/PdfExporter.cs new file mode 100644 index 0000000000..3e06cd72fa --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Pdf/PdfExporter.cs @@ -0,0 +1,72 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Collections.ObjectModel; +using System.Diagnostics; + +using PdfSharp.Pdf; +using ICSharpCode.Reporting.Exporter; +using ICSharpCode.Reporting.Exporter.Visitors; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; + +namespace ICSharpCode.Reporting.Pdf +{ + /// + /// Description of PdfExporter. + /// + public class PdfExporter:BaseExporter{ + + PdfVisitor visitor; + PdfDocument pdfDocument; + + + public PdfExporter(Collection pages):base(pages){ + } + + public override void Run() + { + pdfDocument = new PdfDocument(); + visitor = new PdfVisitor(pdfDocument); + SetDocumentTitle(Pages[0].PageInfo.ReportName); + foreach (var page in Pages) { + var acceptor = page as IAcceptor; + if (acceptor != null) { + visitor.Visit(page); + } + } + + const string filename = "HelloWorld.pdf"; + + pdfDocument.Save(filename); + + // ...and start a viewer. + + Process.Start(filename); + } + + void SetDocumentTitle(string reportName) + { + pdfDocument.Info.Title = reportName; + } + + public PdfDocument PdfDocument { + get { return pdfDocument; } + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Pdf/PdfExtensions.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Pdf/PdfExtensions.cs new file mode 100644 index 0000000000..4cfa83229f --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Pdf/PdfExtensions.cs @@ -0,0 +1,55 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System.Drawing; +using PdfSharp.Drawing; + +namespace ICSharpCode.Reporting.Pdf +{ + /// + /// Description of PdfExtensions. + /// + public static class PdfExtensions + { + + public static XSize ToXSize(this Size size) { + return new XSize(Convert(size.Width), Convert(size.Height)); + } + + + public static XPoint ToXPoints(this Point point) { + var p = new XPoint(Convert(point.X),Convert(point.Y)); + return p; + } + + + public static XRect ToXRect( this Rectangle rectangle) { + return new XRect(rectangle.Location.ToXPoints(),rectangle.Size.ToXSize()); + } + + + public static float ToPoint (this int value) { + return Convert(value); + } + + + static float Convert(int toConvert) { + return toConvert * 72 / 100; + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Pdf/PdfHelper.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Pdf/PdfHelper.cs new file mode 100644 index 0000000000..a7b03d1699 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Pdf/PdfHelper.cs @@ -0,0 +1,119 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Drawing; +using ICSharpCode.Reporting.Interfaces.Export; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; +using PdfSharp.Drawing; +using System.Drawing.Drawing2D; +using PdfSharp.Drawing.Layout; + +namespace ICSharpCode.Reporting.Pdf +{ + /// + /// Description of PdfHelper. + /// + public static class PdfHelper + { + + public static void WriteText(XTextFormatter textFormatter,Point columnLocation, ExportText exportColumn) + { + XFont font = PdfHelper.CreatePdfFont(exportColumn); + var rect = new Rectangle(columnLocation,exportColumn.DesiredSize).ToXRect(); + textFormatter.DrawString(exportColumn.Text, + font, + new XSolidBrush(ToXColor(exportColumn.ForeColor)), + rect, XStringFormats.TopLeft); + } + + + static XFont CreatePdfFont(IExportColumn exportColumn) + { + var textColumn = (ExportText)exportColumn; + return new XFont(textColumn.Font.FontFamily.Name, textColumn.Font.Size); + } + + + static XColor ToXColor (Color color){ + return XColor.FromArgb(color.R,color.G,color.B); + } + + + public static XRect CreateDisplayRectangle(IExportColumn column) { + return column.DisplayRectangle.ToXRect(); + } + + + public static void DrawRectangle (IExportColumn column, XGraphics graphics) { + FillRectangle(column.DisplayRectangle,column.FrameColor,graphics); + } + + + public static void FillRectangle(Rectangle rect,Color color,XGraphics graphics) { + var r = rect.ToXRect(); + graphics.DrawRectangle(new XSolidBrush(ToXColor(color)),r); + } + + + public static XPen PdfPen(IExportGraphics column) { + return new XPen(ToXColor(column.ForeColor),column.Thickness); + } + + + public static XLineCap LineCap (IExportGraphics column) { + return XLineCap.Round; + + } + + + public static XDashStyle DashStyle (IExportGraphics column) { + XDashStyle style = XDashStyle.Solid; + + switch (column.DashStyle) { + case System.Drawing.Drawing2D.DashStyle.Solid: + style = XDashStyle.Solid; + break; + case System.Drawing.Drawing2D.DashStyle.Dash: + style = XDashStyle.Dash; + break; + case System.Drawing.Drawing2D.DashStyle.Dot: + style = XDashStyle.Dot; + break; + case System.Drawing.Drawing2D.DashStyle.DashDot: + style = XDashStyle.DashDot; + break; + case System.Drawing.Drawing2D.DashStyle.DashDotDot: + style = XDashStyle.DashDotDot; + break; + case System.Drawing.Drawing2D.DashStyle.Custom: + + break; + default: + throw new Exception("Invalid value for DashStyle"); + } + return style; + } + + + public static Point LocationRelToParent (ExportColumn column) { + return new Point(column.Parent.Location.X + column.Location.X, + column.Parent.Location.Y + column.Location.Y); + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Pdf/PdfVisitor.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Pdf/PdfVisitor.cs new file mode 100644 index 0000000000..b7f3962c8e --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Pdf/PdfVisitor.cs @@ -0,0 +1,116 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System.Drawing; +using ICSharpCode.Reporting.Exporter.Visitors; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; +using PdfSharp.Drawing; +using PdfSharp.Drawing.Layout; +using PdfSharp.Pdf; + +namespace ICSharpCode.Reporting.Pdf +{ + /// + /// Description of PdfVisitor. + /// + class PdfVisitor: AbstractVisitor + { + readonly PdfDocument pdfDocument; + XGraphics gfx; + XTextFormatter textFormatter; + Point containerLocation; + + public PdfVisitor(PdfDocument pdfDocument) + { + this.pdfDocument = pdfDocument; + } + + public override void Visit(ExportPage page) + { + PdfPage = pdfDocument.AddPage(); + gfx = XGraphics.FromPdfPage(PdfPage); + textFormatter = new XTextFormatter(gfx); + base.Visit(page); + } + + + public override void Visit(ExportContainer exportContainer) + { + foreach (var element in exportContainer.ExportedItems) { + var container = element as ExportContainer; + if (container != null) { + containerLocation = PdfHelper.LocationRelToParent(container); + var r = new Rectangle(containerLocation,container.DisplayRectangle.Size); + PdfHelper.FillRectangle(r,container.BackColor,gfx); + Visit(container); + } + containerLocation = PdfHelper.LocationRelToParent(exportContainer); + var ac = element as IAcceptor; + ac.Accept(this); + } + } + + + public override void Visit(ExportText exportText) + { + var columnLocation = containerLocation; + columnLocation.Offset(exportText.Location); + if (ShouldSetBackcolor(exportText)) { + var r = new Rectangle(columnLocation,exportText.DisplayRectangle.Size); + PdfHelper.FillRectangle(r,exportText.BackColor,gfx); + } + + PdfHelper.WriteText(textFormatter,columnLocation, exportText); + } + + + + public override void Visit(ExportLine exportLine) + { + var columnLocation = containerLocation; + columnLocation.Offset(exportLine.Location); + var pen = PdfHelper.PdfPen(exportLine); + pen.DashStyle = PdfHelper.DashStyle(exportLine); + pen.LineCap = PdfHelper.LineCap(exportLine); + gfx.DrawLine(pen,columnLocation.ToXPoints(),new Point(exportLine.Size.Width,columnLocation.Y).ToXPoints()); + } + + + public override void Visit (ExportRectangle exportRectangle) { + var columnLocation = containerLocation; + columnLocation.Offset(exportRectangle.Location); + var pen = PdfHelper.PdfPen(exportRectangle); + pen.DashStyle = PdfHelper.DashStyle(exportRectangle); + gfx.DrawRectangle(pen,new XRect(columnLocation.ToXPoints(), + exportRectangle.Size.ToXSize())); + } + + + public override void Visit(ExportCircle exportCircle){ + var columnLocation = containerLocation; + columnLocation.Offset(exportCircle.Location); + var pen = PdfHelper.PdfPen(exportCircle); + pen.DashStyle = PdfHelper.DashStyle(exportCircle); + gfx.DrawEllipse(pen,new XRect(columnLocation.ToXPoints(), + exportCircle.Size.ToXSize())); + } + + + public PdfPage PdfPage {get; private set;} + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/ReportSectionNames.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/ReportSectionNames.cs new file mode 100644 index 0000000000..b860f6f0ff --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/ReportSectionNames.cs @@ -0,0 +1,53 @@ +/* + * Created by SharpDevelop. + * User: Peter Forstmeier + * Date: 08.02.2014 + * Time: 18:30 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +using System; + +namespace ICSharpCode.Reporting +{ + /// + /// Description of ReportSectionNames. + /// + /// + public enum ReportSection { + ReportHeader, + ReportPageHeader, + ReportDetail, + ReportPageFooter, + ReportFooter + } + + public static class ReportSectionNames + { + public static string ReportHeader + { + get{ return ReportSection.ReportHeader.ToString();} + } + + public static string ReportPageHeader + { + get{ return ReportSection.ReportPageHeader.ToString();} + } + + + public static string ReportDetail + { + get { return ReportSection.ReportDetail.ToString();} + } + + public static string ReportPageFooter + { + get { return ReportSection.ReportPageFooter.ToString();} + } + + public static string ReportFooter + { + get{ return ReportSection.ReportFooter.ToString();} + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/ReportingFactory.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/ReportingFactory.cs index 10423a05b4..7a41d44e24 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/ReportingFactory.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/ReportingFactory.cs @@ -18,12 +18,9 @@ using System; using System.Collections; -using System.Collections.Generic; using System.IO; using System.Xml; -using ICSharpCode.Reporting.Factories; -using ICSharpCode.Reporting.Globals; using ICSharpCode.Reporting.Interfaces; using ICSharpCode.Reporting.Items; using ICSharpCode.Reporting.PageBuilder; @@ -34,57 +31,53 @@ namespace ICSharpCode.Reporting /// /// Description of Reporting. /// + + public class ReportingFactory { - public ReportingFactory() - { - } - public IReportCreator ReportCreator (ReportModel reportModel) { - if (reportModel == null) - throw new ArgumentNullException("reportModel"); - IReportCreator builder = null; - if (reportModel.ReportSettings.DataModel == GlobalEnums.PushPullModel.FormSheet) { - builder = new FormPageBuilder(reportModel); - } + + public IReportCreator ReportCreator (Stream stream,IEnumerable list) + { + ReportModel = LoadReportModel (stream); + var builder = new DataPageBuilder(ReportModel,list ); return builder; } - - - - internal IReportCreator ReportCreator (Stream stream) + + public IReportCreator ReportCreator (Stream stream) { - IReportModel reportModel = LoadReportModel (stream); - IReportCreator builder = null; - builder = ReportCreatorFactory.ExporterFactory(reportModel); + ReportModel = LoadReportModel (stream); + var builder = new FormPageBuilder(ReportModel); return builder; } - object ExporterFactory(IReportModel reportModel) - { - throw new NotImplementedException(); + + public IReportCreator ReportCreator (ReportModel reportModel) { + ReportModel = reportModel; + var builder = new FormPageBuilder(ReportModel); + return builder; } - + internal ReportModel LoadReportModel (Stream stream) { var doc = new XmlDocument(); doc.Load(stream); - var rm = LoadModel(doc); - return rm; + ReportModel = LoadModel(doc); + return ReportModel; } + static ReportModel LoadModel(XmlDocument doc) { var loader = new ModelLoader(); object root = loader.Load(doc.DocumentElement); - var model = root as ReportModel; - if (model == null) { -// throw new IllegalFileFormatException("ReportModel"); - } return model; } + + + public ReportModel ReportModel {get;private set;} } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/PreviewViewModel.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/PreviewViewModel.cs index 311601c6db..10eb532ca6 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/PreviewViewModel.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/PreviewViewModel.cs @@ -19,14 +19,11 @@ using System; using System.Collections.ObjectModel; using System.ComponentModel; -using System.Diagnostics; using System.Windows.Documents; -using System.Windows.Markup; -using ICSharpCode.Reporting.Exporter; -using ICSharpCode.Reporting.ExportRenderer; -using ICSharpCode.Reporting.Interfaces.Export; using ICSharpCode.Reporting.Items; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; +using ICSharpCode.Reporting.WpfReportViewer.Visitor; namespace ICSharpCode.Reporting.WpfReportViewer { @@ -36,37 +33,38 @@ namespace ICSharpCode.Reporting.WpfReportViewer public class PreviewViewModel:INotifyPropertyChanged { - private FixedDocument document ; + FixedDocument document ; - public PreviewViewModel(ReportSettings reportSettings, Collection pages) + public PreviewViewModel(ReportSettings reportSettings, Collection pages) { if (pages == null) throw new ArgumentNullException("pages"); if (reportSettings == null) throw new ArgumentNullException("reportSettings"); - Document = new FixedDocument(); - var s = Document.DocumentPaginator.PageSize; - Document.DocumentPaginator.PageSize = new System.Windows.Size(reportSettings.PageSize.Width,reportSettings.PageSize.Height); - var wpfExporter = new WpfExporter(reportSettings,pages); + + Document = CreateFixedDocument(reportSettings); + + var wpfExporter = new WpfExporter(pages); wpfExporter.Run(); - var fixedPage = wpfExporter.FixedPage; - AddPageToDocument(Document,fixedPage); + this.document = wpfExporter.Document; } - - static void AddPageToDocument(FixedDocument fixedDocument,FixedPage page) + + static FixedDocument CreateFixedDocument(ReportSettings reportSettings) { - var pageContent = new PageContent(); - ((IAddChild)pageContent).AddChild(page); - fixedDocument.Pages.Add(pageContent); + var document = new FixedDocument(); + document.DocumentPaginator.PageSize = new System.Windows.Size(reportSettings.PageSize.Width, + reportSettings.PageSize.Height); + return document; } + public FixedDocument Document { get {return document;} set { this.document = value; OnNotifyPropertyChanged ("Document"); - } + } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/CanvasExtension.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/CanvasExtension.cs new file mode 100644 index 0000000000..b769cfd224 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/CanvasExtension.cs @@ -0,0 +1,55 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System.Windows; +using System.Windows.Controls; + +namespace ICSharpCode.Reporting.WpfReportViewer.Visitor +{ + /// + /// Description of CanvasExtension. + /// http://denisvuyka.wordpress.com/2007/12/15/wpf-simplify-your-life-with-linq-extension-methods-canvas-and-visual-tree-helpers/ + /// + public static class CanvasExtension + { + + public static void AddChild(this Panel panel, T element) + { + var uiElement = element as UIElement; + if (uiElement != null && !panel.Children.Contains(uiElement)) + panel.Children.Add(uiElement); + } + + + public static void RemoveChild(this Panel panel, T element) + { + var uiElement = element as UIElement; + if (uiElement != null && panel.Children.Contains(uiElement)) + panel.Children.Remove(uiElement); + } + + + public static void InsertChild(this Panel panel, int index, T element) + { + var uiElement = element as UIElement; + if (uiElement != null && !panel.Children.Contains(uiElement)) + panel.Children.Insert(index, uiElement); + } + } + +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/CanvasHelper.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/CanvasHelper.cs new file mode 100644 index 0000000000..8c3611030c --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/CanvasHelper.cs @@ -0,0 +1,85 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Windows; +using System.Windows.Controls; + + +namespace ICSharpCode.Reporting.WpfReportViewer.Visitor +{ + /// + /// Description of CanvasHelper. + /// http://denisvuyka.wordpress.com/2007/12/15/wpf-simplify-your-life-with-linq-extension-methods-canvas-and-visual-tree-helpers/ + /// + /// + internal static class CanvasHelper + { + public static double GetLeft(T element) + { + UIElement uiElement = element as UIElement; + if (uiElement == null) + throw new ArgumentNullException("element"); + return (double)uiElement.GetValue(Canvas.LeftProperty); + } + + public static double GetTop(T element) + { + UIElement uiElement = element as UIElement; + if (uiElement == null) + throw new ArgumentNullException("element"); + return (double)uiElement.GetValue(Canvas.TopProperty); + } + + public static Point GetPosition(T element) + { + UIElement uiElement = element as UIElement; + if (uiElement == null) + throw new ArgumentNullException("element"); + + return new Point( + (double)uiElement.GetValue(Canvas.LeftProperty), + (double)uiElement.GetValue(Canvas.TopProperty)); + } + + public static void SetLeft(T element, double length) + { + UIElement uiElement = element as UIElement; + if (uiElement == null) + throw new ArgumentNullException("element"); + uiElement.SetValue(Canvas.LeftProperty, length); + } + + public static void SetTop(T element, double length) + { + UIElement uiElement = element as UIElement; + if (uiElement == null) + throw new ArgumentNullException("element"); + uiElement.SetValue(Canvas.TopProperty, length); + } + + public static void SetPosition(T element, Point value) + { + UIElement uiElement = element as UIElement; + if (uiElement == null) + throw new ArgumentNullException("element"); + uiElement.SetValue(Canvas.LeftProperty, value.X); + uiElement.SetValue(Canvas.TopProperty, value.Y); + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/FixedDocumentCreator.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/FixedDocumentCreator.cs new file mode 100644 index 0000000000..3e12f16f93 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/FixedDocumentCreator.cs @@ -0,0 +1,383 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Documents; +using System.Windows.Media; + +using ICSharpCode.Reporting.BaseClasses; +using ICSharpCode.Reporting.Interfaces; +using ICSharpCode.Reporting.Interfaces.Export; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; +using Brush = System.Windows.Media.Brush; +using FontFamily = System.Windows.Media.FontFamily; +using Pen = System.Windows.Media.Pen; +using Size = System.Windows.Size; + +namespace ICSharpCode.Reporting.WpfReportViewer.Visitor +{ + /// + /// Description of FixedDocumentCreator. + /// + static class FixedDocumentCreator + { + + + public static FixedPage CreateFixedPage(ExportPage exportPage) { + var fixedPage = new FixedPage(); + fixedPage.Width = exportPage.Size.ToWpf().Width; + fixedPage.Height = exportPage.Size.ToWpf().Height; + fixedPage.Background = new SolidColorBrush(System.Drawing.Color.White.ToWpf()); + return fixedPage; + } + + + public static Canvas CreateContainer(ExportContainer container) { + var canvas = CreateCanvas(container); + var size = container.DesiredSize.ToWpf(); + canvas.Measure(size); + canvas.Arrange(new Rect(new Point(),size )); + canvas.UpdateLayout(); + return canvas; + } + + /* + public static TextBlock CreateTextBlock(ExportText exportText,bool setBackcolor){ + + var textBlock = new TextBlock(); + + textBlock.Foreground = ConvertBrush(exportText.ForeColor); + + if (setBackcolor) { + textBlock.Background = ConvertBrush(exportText.BackColor); + } + + SetFont(textBlock,exportText); + + textBlock.TextWrapping = TextWrapping.Wrap; + + CheckForNewLine (textBlock,exportText); + SetContentAlignment(textBlock,exportText); + MeasureTextBlock (textBlock,exportText); + return textBlock; + } + */ + + /* + static void CheckForNewLine(TextBlock textBlock,ExportText exportText) { + string [] inlines = exportText.Text.Split(Environment.NewLine.ToCharArray()); + for (int i = 0; i < inlines.Length; i++) { + if (inlines[i].Length > 0) { + textBlock.Inlines.Add(new Run(inlines[i])); + textBlock.Inlines.Add(new LineBreak()); + } + } + var li = textBlock.Inlines.LastInline; + textBlock.Inlines.Remove(li); + } + + + static void MeasureTextBlock(TextBlock textBlock,ExportText exportText) + { + var wpfSize = MeasureTextInWpf(exportText); + textBlock.Width = wpfSize.Width; + textBlock.Height = wpfSize.Height; + } + + */ + + /* + static Size MeasureTextInWpf(ExportText exportText){ + + if (exportText.CanGrow) { + var formattedText = NewMethod(exportText); + + formattedText.MaxTextWidth = exportText.DesiredSize.Width * 96.0 / 72.0; + + formattedText.SetFontSize(Math.Floor(exportText.Font.Size * 96.0 / 72.0)); + + var size = new Size { + Width = formattedText.WidthIncludingTrailingWhitespace, + Height = formattedText.Height + 6}; + return size; + } + return new Size(exportText.Size.Width,exportText.Size.Height); + } + + */ + + + public static FormattedText CreateFormattedText(ExportText exportText) + { + var formattedText = new FormattedText(exportText.Text, + CultureInfo.CurrentCulture, + FlowDirection.LeftToRight, + new Typeface(exportText.Font.FontFamily.Name), + exportText.Font.Size, + new SolidColorBrush(exportText.ForeColor.ToWpf()), null, TextFormattingMode.Display); + + formattedText.MaxTextWidth = exportText.DesiredSize.Width * 96.0 / 72.0; + formattedText.SetFontSize(Math.Floor(exportText.Font.Size * 96.0 / 72.0)); + + var td = new TextDecorationCollection() ; + CheckUnderline(td,exportText); + formattedText.SetTextDecorations(td); + return formattedText; + } + + static void CheckUnderline(TextDecorationCollection td, ExportText exportText) + { + if (exportText.Font.Underline) { + td.Add(new TextDecoration{Location = TextDecorationLocation.Underline}); + } + } + + + static Canvas CreateCanvas(ExportContainer container){ + var canvas = new Canvas(); + SetPositionAndSize(canvas,container); + + canvas.Name = container.Name; + canvas.Background = ConvertBrush(container.BackColor); + return canvas; + } + + + static void SetPositionAndSize(FrameworkElement element,ExportColumn column) { + if (column == null) + throw new ArgumentNullException("column"); + SetPosition(element,column); + SetDimension(element,column); + } + + + static void SetDimension (FrameworkElement element,IExportColumn exportColumn){ + element.Width = exportColumn.DesiredSize.Width; + element.Height = exportColumn.DesiredSize.Height; + } + + + static void SetPosition (UIElement element,IExportColumn exportColumn) { + FixedPage.SetLeft(element,exportColumn.Location.X ); + FixedPage.SetTop(element,exportColumn.Location.Y); + } + + /* + static void SetFont(TextBlock textBlock,IExportText exportText){ + textBlock.FontFamily = new FontFamily(exportText.Font.FontFamily.Name); + + //http://www.codeproject.com/Articles/441009/Drawing-Formatted-Text-in-a-Windows-Forms-Applicat + + textBlock.FontSize = Math.Floor(exportText.Font.Size * 96/72); + + if (exportText.Font.Bold) { + textBlock.FontWeight = FontWeights.Bold; + } + if (exportText.Font.Underline) { + CreateUnderline(textBlock,exportText); + } + + if (exportText.Font.Italic) { + textBlock.FontStyle = FontStyles.Italic ; + } + if (exportText.Font.Strikeout) { + CreateStrikeout(textBlock,exportText); + } + } + */ + + static void SetContentAlignment(TextBlock textBlock,ExportText exportText) + { + // http://social.msdn.microsoft.com/Forums/vstudio/en-US/e480abb9-a86c-4f78-8955-dddb866bcfef/vertical-text-alignment-in-textblock?forum=wpf + //Vertical alignment not working + + switch (exportText.ContentAlignment) { + case System.Drawing.ContentAlignment.TopLeft: + textBlock.VerticalAlignment = VerticalAlignment.Top; + textBlock.TextAlignment = TextAlignment.Left; + break; + case System.Drawing.ContentAlignment.TopCenter: + textBlock.VerticalAlignment = VerticalAlignment.Top; + textBlock.TextAlignment = TextAlignment.Center; + break; + case System.Drawing.ContentAlignment.TopRight: + textBlock.VerticalAlignment = VerticalAlignment.Top; + textBlock.TextAlignment = TextAlignment.Right; + break; + // Middle + case System.Drawing.ContentAlignment.MiddleLeft: + textBlock.VerticalAlignment = VerticalAlignment.Center; + textBlock.TextAlignment = TextAlignment.Left; + break; + case System.Drawing.ContentAlignment.MiddleCenter: + textBlock.VerticalAlignment = VerticalAlignment.Center; + textBlock.TextAlignment = TextAlignment.Center; + break; + case System.Drawing.ContentAlignment.MiddleRight: + textBlock.VerticalAlignment = VerticalAlignment.Center; + textBlock.TextAlignment = TextAlignment.Right; + break; + //Bottom + case System.Drawing.ContentAlignment.BottomLeft: + textBlock.VerticalAlignment = VerticalAlignment.Bottom; + textBlock.TextAlignment = TextAlignment.Left; + break; + case System.Drawing.ContentAlignment.BottomCenter: + textBlock.VerticalAlignment = VerticalAlignment.Bottom; + textBlock.TextAlignment = TextAlignment.Center; + break; + case System.Drawing.ContentAlignment.BottomRight: + textBlock.VerticalAlignment = VerticalAlignment.Bottom; + textBlock.TextAlignment = TextAlignment.Right; + break; + } + } + + + static void CreateStrikeout (TextBlock textBlock,IExportText exportColumn ){ + if (textBlock == null) + throw new ArgumentNullException("textBlock"); + if (exportColumn == null) + throw new ArgumentNullException("exportColumn"); + var strikeOut = new TextDecoration(); + strikeOut.Location = TextDecorationLocation.Strikethrough; + + Pen p = CreateWpfPen(exportColumn); + strikeOut.Pen = p ; + strikeOut.PenThicknessUnit = TextDecorationUnit.FontRecommended; + textBlock.TextDecorations.Add(strikeOut); + } + + /* + static void CreateUnderline(TextBlock textBlock,IExportText exportColumn){ + if (exportColumn == null) + throw new ArgumentNullException("exportColumn"); + if (textBlock == null) + throw new ArgumentNullException("textBlock"); + var underLine = new TextDecoration(); + Pen p = CreateWpfPen(exportColumn); + underLine.Pen = p ; + underLine.PenThicknessUnit = TextDecorationUnit.FontRecommended; + textBlock.TextDecorations.Add(underLine); + } + */ + + public static Pen CreateWpfPen(IReportObject exportColumn){ + if (exportColumn == null) + throw new ArgumentNullException("exportColumn"); + var pen = new Pen(); + pen.Brush = ConvertBrush(exportColumn.ForeColor); + pen.Thickness = 1; + + var exportGraphics = exportColumn as IExportGraphics; + if (exportGraphics != null) { + pen.Thickness = exportGraphics.Thickness; + pen.DashStyle = FixedDocumentCreator.DashStyle(exportGraphics); + pen.StartLineCap = FixedDocumentCreator.LineCap(exportGraphics.StartLineCap); + pen.EndLineCap = FixedDocumentCreator.LineCap(exportGraphics.EndLineCap); + } + return pen; + } + + + public static Brush ConvertBrush(System.Drawing.Color color){ + var b = new BrushConverter(); + if (b.IsValid(color.Name)){ + return b.ConvertFromString(color.Name) as SolidColorBrush; + } else{ + return b.ConvertFromString("Black") as SolidColorBrush; + } + } + + + public static PenLineCap LineCap (System.Drawing.Drawing2D.LineCap lineCap) { + var penLineCap = PenLineCap.Flat; + switch (lineCap) { + case System.Drawing.Drawing2D.LineCap.Flat: + penLineCap = PenLineCap.Flat; + break; + case System.Drawing.Drawing2D.LineCap.Square: + penLineCap = PenLineCap.Square; + break; + case System.Drawing.Drawing2D.LineCap.Round: + penLineCap = PenLineCap.Round; + break; + case System.Drawing.Drawing2D.LineCap.Triangle: + penLineCap = PenLineCap.Triangle; + break; + case System.Drawing.Drawing2D.LineCap.NoAnchor: + penLineCap = PenLineCap.Flat; + break; + case System.Drawing.Drawing2D.LineCap.SquareAnchor: + penLineCap = PenLineCap.Flat; + break; + case System.Drawing.Drawing2D.LineCap.RoundAnchor: + penLineCap = PenLineCap.Flat; + break; + case System.Drawing.Drawing2D.LineCap.DiamondAnchor: + penLineCap = PenLineCap.Flat; + break; + case System.Drawing.Drawing2D.LineCap.ArrowAnchor: + penLineCap = PenLineCap.Flat; + break; + case System.Drawing.Drawing2D.LineCap.Custom: + penLineCap = PenLineCap.Flat; + break; + case System.Drawing.Drawing2D.LineCap.AnchorMask: + + break; + default: + throw new Exception("Invalid value for LineCap"); + + } + return penLineCap; + } + + public static DashStyle DashStyle (IExportGraphics exportGraphics) { + var dashStyle = DashStyles.Solid; + + switch (exportGraphics.DashStyle) { + case System.Drawing.Drawing2D.DashStyle.Solid: + dashStyle = DashStyles.Solid; + break; + case System.Drawing.Drawing2D.DashStyle.Dash: + dashStyle = DashStyles.Dash; + break; + case System.Drawing.Drawing2D.DashStyle.Dot: + dashStyle = DashStyles.Dot; + break; + case System.Drawing.Drawing2D.DashStyle.DashDot: + dashStyle = DashStyles.DashDot; + break; + case System.Drawing.Drawing2D.DashStyle.DashDotDot: + dashStyle = DashStyles.DashDotDot; + break; + case System.Drawing.Drawing2D.DashStyle.Custom: + dashStyle = DashStyles.Solid; + break; + default: + throw new Exception("Invalid value for DashStyle"); + } + return dashStyle; + } + + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/Graphics/ExtendedLine.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/Graphics/ExtendedLine.cs new file mode 100644 index 0000000000..bb7cce992d --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/Graphics/ExtendedLine.cs @@ -0,0 +1,63 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Windows; +using System.Windows.Media; + +using ICSharpCode.Reporting.PageBuilder.ExportColumns; + +namespace ICSharpCode.Reporting.WpfReportViewer.Visitor.Graphics +{ + class DrawingElement : FrameworkElement{ + + private VisualCollection children; + + public DrawingElement(DrawingVisual visual) { + children = new VisualCollection(this); + children.Add(visual); + } + + /* + public ExtendedLine(ExportLine exportGraphics,Pen pen){ + children = new VisualCollection(this); + var visual = new DrawingVisual(); + children.Add(visual); + using (var dc = visual.RenderOpen()) + { + dc.DrawLine(pen, + new Point(exportGraphics.Location.X, exportGraphics.Location.Y), + new Point(exportGraphics.Location.X + exportGraphics.Size.Width,exportGraphics.Location.Y)); + } + } + */ + + protected override int VisualChildrenCount{ + get { return children.Count; } + } + + protected override Visual GetVisualChild(int index){ + if (index < 0 || index >= children.Count) + { + throw new ArgumentOutOfRangeException("index"); + } + + return children[index]; + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/WpfExporter.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/WpfExporter.cs new file mode 100644 index 0000000000..d7c1d38983 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/WpfExporter.cs @@ -0,0 +1,63 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Collections.ObjectModel; +using System.Windows.Documents; +using System.Windows.Markup; + +using ICSharpCode.Reporting.Exporter; +using ICSharpCode.Reporting.Exporter.Visitors; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; + +namespace ICSharpCode.Reporting.WpfReportViewer.Visitor { + /// + /// Description of PrintExporter. + /// + /// + class WpfExporter:BaseExporter { + + readonly WpfVisitor visitor; + + public WpfExporter(Collection pages):base(pages){ + visitor = new WpfVisitor(); + } + + + public override void Run () { + Document = new FixedDocument(); + foreach (var page in Pages) { + IAcceptor acceptor = page as IAcceptor; + if (acceptor != null) { + visitor.Visit(page); + } + AddPageToDocument(Document,visitor.FixedPage); + } + } + + + static void AddPageToDocument(FixedDocument fixedDocument,FixedPage page){ + PageContent pageContent = new PageContent(); + ((IAddChild)pageContent).AddChild(page); + + fixedDocument.Pages.Add(pageContent); + } + + public FixedDocument Document {get;private set;} + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/WpfVisitor.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/WpfVisitor.cs new file mode 100644 index 0000000000..6db045ce50 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/WpfVisitor.cs @@ -0,0 +1,166 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Documents; +using System.Windows.Media; + +using ICSharpCode.Reporting.Exporter.Visitors; +using ICSharpCode.Reporting.Interfaces.Export; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; +using ICSharpCode.Reporting.WpfReportViewer.Visitor.Graphics; + +namespace ICSharpCode.Reporting.WpfReportViewer.Visitor +{ + /// + /// Description of WpfVisitor. + /// + /// + class WpfVisitor: AbstractVisitor { + + FixedPage fixedPage; + Canvas sectionCanvas; + + + public override void Visit(ExportPage page){ + fixedPage = FixedDocumentCreator.CreateFixedPage(page); + FixedPage = fixedPage; + foreach (var element in page.ExportedItems) { + var acceptor = element as IAcceptor; + acceptor.Accept(this); + fixedPage.Children.Add(sectionCanvas); + } + } + + + public override void Visit(ExportContainer exportContainer){ + + sectionCanvas = FixedDocumentCreator.CreateContainer(exportContainer); + sectionCanvas.Name = exportContainer.Name; + CanvasHelper.SetPosition(sectionCanvas,new Point(exportContainer.Location.X,exportContainer.Location.Y)); + PerformList(sectionCanvas,exportContainer.ExportedItems); + } + + + void PerformList(Canvas myCanvas, System.Collections.Generic.List exportedItems) + { + foreach (var element in exportedItems) { + var container = element as ExportContainer; + if (container != null) { + var containerCanvas = FixedDocumentCreator.CreateContainer(container); + CanvasHelper.SetPosition(containerCanvas,new Point(container.Location.X,container.Location.Y)); + myCanvas.Children.Add(containerCanvas); + PerformList(containerCanvas,container.ExportedItems); + } else { + var acceptor = element as IAcceptor; + acceptor.Accept(this); + myCanvas.Children.Add(UIElement); + } + } + } + + + public override void Visit(ExportText exportColumn){ + /* + var textBlock = FixedDocumentCreator.CreateTextBlock((ExportText)exportColumn,ShouldSetBackcolor(exportColumn)); + CanvasHelper.SetPosition(textBlock,new Point(exportColumn.Location.X,exportColumn.Location.Y)); + UIElement = textBlock; + */ + + var ft = FixedDocumentCreator.CreateFormattedText((ExportText)exportColumn); + var visual = new DrawingVisual(); + var location = new Point(exportColumn.Location.X,exportColumn.Location.Y); + using (var dc = visual.RenderOpen()){ + if (ShouldSetBackcolor(exportColumn)) { + dc.DrawRectangle(FixedDocumentCreator.ConvertBrush(exportColumn.BackColor), + null, + new Rect(location,new Size(exportColumn.Size.Width,exportColumn.Size.Height))); + } + dc.DrawText(ft,location); + } + var dragingElement = new DrawingElement(visual); + UIElement = dragingElement; + + } + + + public override void Visit(ExportLine exportGraphics) + { + var pen = FixedDocumentCreator.CreateWpfPen(exportGraphics); + var visual = new DrawingVisual(); + using (var dc = visual.RenderOpen()){ + dc.DrawLine(pen, + new Point(exportGraphics.Location.X, exportGraphics.Location.Y), + new Point(exportGraphics.Location.X + exportGraphics.Size.Width,exportGraphics.Location.Y)); + } + var dragingElement = new DrawingElement(visual); + UIElement = dragingElement; + } + + + public override void Visit(ExportRectangle exportRectangle) + { + var pen = FixedDocumentCreator.CreateWpfPen(exportRectangle); + + var visual = new DrawingVisual(); + using (var dc = visual.RenderOpen()){ + dc.DrawRectangle(FixedDocumentCreator.ConvertBrush(exportRectangle.BackColor), + pen, + new Rect(exportRectangle.Location.X,exportRectangle.Location.Y, + exportRectangle.Size.Width,exportRectangle.Size.Height)); + } + var dragingElement = new DrawingElement(visual); + UIElement = dragingElement; + } + + public override void Visit(ExportCircle exportCircle) + { + var pen = FixedDocumentCreator.CreateWpfPen(exportCircle); + var rad = CalcRad(exportCircle.Size); + + var visual = new DrawingVisual(); + using (var dc = visual.RenderOpen()){ + + dc.DrawEllipse(FixedDocumentCreator.ConvertBrush(exportCircle.BackColor), + pen, + new Point(exportCircle.Location.X + rad.X, + exportCircle.Location.Y + rad.Y), + rad.X, + rad.Y); + + + } + var dragingElement = new DrawingElement(visual); + UIElement = dragingElement; + } + + static Point CalcRad(System.Drawing.Size size) { + return new Point(size.Width /2,size.Height /2); + } + + protected UIElement UIElement {get;private set;} + + + public FixedPage FixedPage {get; private set;} + } + + + +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/WpfReportViewer/WpfReportViewer.xaml b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/WpfReportViewer/WpfReportViewer.xaml new file mode 100644 index 0000000000..a637ee69a1 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/WpfReportViewer/WpfReportViewer.xaml @@ -0,0 +1,17 @@ + + + + + + + \ No newline at end of file diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Xml/ModelLoader.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Xml/ModelLoader.cs index 25a7155acc..4ec238b61c 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Xml/ModelLoader.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Xml/ModelLoader.cs @@ -26,15 +26,9 @@ namespace ICSharpCode.Reporting.Xml /// internal class ModelLoader: MycroParser { - protected override Type GetTypeByName(string ns, string name) { -// var b = typeof(BaseSection).Assembly.GetType("ICSharpCode.Reporting.Items" + "." + name); - var s = typeof(BaseSection).Assembly.GetType(typeof(BaseSection).Namespace + "." + name); - Console.WriteLine("getTypeByname <{0}>",s.Name); return typeof(BaseSection).Assembly.GetType(typeof(BaseSection).Namespace + "." + name); - } - } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Xml/MycroParser.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Xml/MycroParser.cs index 209a507514..7e2402bbe6 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Xml/MycroParser.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Xml/MycroParser.cs @@ -58,23 +58,23 @@ namespace ICSharpCode.Reporting.Xml // instantiate the class string ns=node.Prefix; string cname=node.LocalName; + Console.WriteLine ("ProcessNode(XmlNode node, object parent) {0}",cname); + Type t=GetTypeByName(ns, cname); - if (t == null) { - Console.WriteLine("\t Not found {0}",t.FullName); -// t = GetTypeByName (ns,"ErrorItem"); - } - - Trace.Assert(t != null, "Type "+cname+" could not be determined."); + +// Trace.Assert(t != null, "Type "+cname+" could not be determined."); // Debug.WriteLine("Looking for " + cname + " and got " + t.FullName); - Console.WriteLine("Looking for " + cname + " and got " + t.FullName); +// Console.WriteLine("Looking for " + cname + " and got " + t.FullName); try { ret=Activator.CreateInstance(t); } - catch(Exception e) + catch(Exception) { - Trace.Fail("Type "+cname+" could not be instantiated:\r\n"+e.Message); + Console.WriteLine("MycroParser:"); + Console.WriteLine("\t Not found {0}",cname); +// Trace.Fail("Type "+cname+" could not be instantiated:\r\n"+e.Message); } // support the ISupportInitialize interface @@ -107,8 +107,10 @@ namespace ICSharpCode.Reporting.Xml return ret; } + protected void ProcessChildProperties(XmlNode node, object parent) { + var t=parent.GetType(); // children of a class must always be properties @@ -116,6 +118,7 @@ namespace ICSharpCode.Reporting.Xml { if (!(child is XmlElement)) continue; string pname=child.LocalName; + var pi=t.GetProperty(pname); if (pi==null) @@ -218,7 +221,6 @@ namespace ICSharpCode.Reporting.Xml static void SetPropertyToString(object obj, PropertyInfo pi, string value) { - Console.WriteLine("MP - SetPropertyToString {0} - {1}",pi.Name,value.ToString()); // it's string, so use a type converter. TypeConverter tc=TypeDescriptor.GetConverter(pi.PropertyType); try diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/ICSharpCode.Reporting.Test.csproj b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/ICSharpCode.Reporting.Test.csproj index 4dbb3adcf2..dd90c264d9 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/ICSharpCode.Reporting.Test.csproj +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/ICSharpCode.Reporting.Test.csproj @@ -44,6 +44,12 @@ TRACE + + ..\..\..\Libraries\Irony.dll + + + ..\..\..\Libraries\Irony.Interpreter.dll + ..\..\..\..\..\..\Tools\NUnit\nunit.framework.dll @@ -59,26 +65,42 @@ - - - - + + + + + + + + + + + + - - - - + + + + + + + + + + + + @@ -95,5 +117,14 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/CollectionHandlingFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/CollectionHandlingFixture.cs deleted file mode 100644 index 118d0665f0..0000000000 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/CollectionHandlingFixture.cs +++ /dev/null @@ -1,206 +0,0 @@ -// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of this -// software and associated documentation files (the "Software"), to deal in the Software -// without restriction, including without limitation the rights to use, copy, modify, merge, -// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons -// to whom the Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all copies or -// substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE -// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using ICSharpCode.Reporting.BaseClasses; -using ICSharpCode.Reporting.DataManager.Listhandling; -using ICSharpCode.Reporting.DataSource; -using ICSharpCode.Reporting.Items; -using NUnit.Framework; - -namespace ICSharpCode.Reporting.Test.DataSource -{ - [TestFixture] - public class CollectionHandlingFixture - { - - private ContributorCollection list; - - [Test] - public void CanInitDataCollection() - { - var collectionSource = new CollectionSource (list,new ReportSettings()); - Assert.That(collectionSource,Is.Not.Null); - } - - [Test] - public void CurrentpositionShouldZeroAfterBind () { - var collectionSource = new CollectionSource (list,new ReportSettings()); - collectionSource.Bind(); - Assert.That(collectionSource.CurrentPosition,Is.EqualTo(0)); - } - - [Test] - public void CurrentPositionIsTwo () { - var collectionSource = new CollectionSource (list,new ReportSettings()); - collectionSource.Bind(); - collectionSource.MoveNext(); - collectionSource.MoveNext(); - Assert.That(collectionSource.CurrentPosition,Is.EqualTo(2)); - } - - [Test] - public void CollectionCountIsEqualToListCount() { - var collectionSource = new CollectionSource (list,new ReportSettings()); - Assert.That(collectionSource.Count,Is.EqualTo(list.Count)); - } - - - [Test] - public void AvailableFieldsEqualContibutorsPropertyCount() { - var collectionSource = new CollectionSource (list,new ReportSettings()); - Assert.That(collectionSource.AvailableFields.Count,Is.EqualTo(6)); - } - - #region Fill - - [Test] - public void TypeOfReportItemIsString () { - var ric = new ReportItemCollection(){ - new BaseDataItem(){ - ColumnName = "Lastname" - - }, - new BaseDataItem(){ - ColumnName = "Firstname" - } - }; - var collectionSource = new CollectionSource (list,new ReportSettings()); - collectionSource.Bind(); - collectionSource.Fill(ric); - foreach (BaseDataItem element in ric) { - Assert.That(element.DataType,Is.EqualTo("System.String")); - } - } - - - [Test] - public void FillReportItemCollection () { - var ric = new ReportItemCollection(){ - new BaseDataItem(){ - ColumnName = "Lastname" - - }, - new BaseDataItem(){ - ColumnName = "Firstname" - } - }; - var collectionSource = new CollectionSource (list,new ReportSettings()); - collectionSource.Bind(); - collectionSource.Fill(ric); - foreach (BaseDataItem element in ric) { - Assert.That(element.DBValue,Is.Not.EqualTo(String.Empty)); - } - } - - #endregion - - - #region Grouping - - [Test] - public void GroupbyOneColumn () { - var rs = new ReportSettings(); - rs.GroupColumnCollection.Add( new GroupColumn("GroupItem",1,ListSortDirection.Ascending)); - var collectionSource = new CollectionSource (list,rs); - collectionSource.Bind(); - } - - - [Test] - public void bla () { - var s = list.OrderBy(a => a.Lastname); - var x = s.GroupBy(y => y.GroupItem); - foreach (var group in x) { - Console.WriteLine("{0} - {1}",group.Key,group.GetType().ToString()); - foreach (var element in group) { - Console.WriteLine(element.Firstname); - } - } - } - #endregion - - #region Sort - - - [Test] - public void CreateUnsortedIndex() { - var collectionSource = new CollectionSource (list,new ReportSettings()); - collectionSource.Bind(); - Assert.That(collectionSource.IndexList.Count,Is.EqualTo(collectionSource.Count)); - Assert.That(collectionSource.IndexList.CurrentPosition,Is.EqualTo(0)); - } - - - [Test] - [ExpectedException(typeof(InvalidOperationException))] - public void SortColumnNotExist() { - var rs = new ReportSettings(); - rs.SortColumnsCollection.Add(new SortColumn("aa",ListSortDirection.Ascending)); - var collectionSource = new CollectionSource (list,rs); - collectionSource.Bind(); - Assert.That(collectionSource.IndexList,Is.Not.Null); - Assert.That(collectionSource.IndexList.Count,Is.EqualTo(0)); - } - - - [Test] - public void SortOneColumnAscending() { - var rs = new ReportSettings(); - rs.SortColumnsCollection.Add(new SortColumn("Lastname",ListSortDirection.Ascending)); - var collectionSource = new CollectionSource (list,rs); - collectionSource.Bind(); - string compare = collectionSource.IndexList[0].ObjectArray[0].ToString(); - foreach (var element in collectionSource.IndexList) { - string result = String.Format("{0} - {1}",element.ListIndex,element.ObjectArray[0]); - Console.WriteLine(result); - Assert.That(compare,Is.LessThanOrEqualTo(element.ObjectArray[0].ToString())); - compare = element.ObjectArray[0].ToString(); - } - } - - - [Test] - public void SortTwoColumnsAscending() { - var rs = new ReportSettings(); - rs.SortColumnsCollection.Add(new SortColumn("Lastname",ListSortDirection.Ascending)); - rs.SortColumnsCollection.Add(new SortColumn("RandomInt",ListSortDirection.Ascending)); - var collectionSource = new CollectionSource (list,rs); - collectionSource.Bind(); - string compare = collectionSource.IndexList[0].ObjectArray[0].ToString(); - foreach (var element in collectionSource.IndexList) { - string result = String.Format("{0} - {1} - {2}",element.ListIndex,element.ObjectArray[0],element.ObjectArray[1].ToString()); - Console.WriteLine(result); - Assert.That(compare,Is.LessThanOrEqualTo(element.ObjectArray[0].ToString())); - compare = element.ObjectArray[0].ToString(); - } - } - - #endregion - - - [SetUp] - public void CreateList() { - var contributorList = new ContributorsList(); - list = contributorList.ContributorCollection; - } - } -} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/ContributorsList.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/ContributorsList.cs index 24ae9eb7c4..e767ef061f 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/ContributorsList.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/ContributorsList.cs @@ -26,17 +26,23 @@ namespace ICSharpCode.Reporting.Test.DataSource /// public class ContributorsList { - ContributorCollection contributorCollection; + public ContributorsList() { - this.contributorCollection = CreateContributorsList(); + ContributorCollection = CreateContributorsList(); } - public ContributorCollection ContributorCollection { - get { return contributorCollection; } - } + public ContributorCollection ContributorCollection {get; private set;} + +// list.Add(new Contributor("Ifko","Kovacka","",31,d3,"A")); +// list.Add(new Contributor("Nathan","Allen","",5,d3,"A")); + +// list.Add(new Contributor("Dickon","Field","DBTools",10,d3,"U")); +// list.Add(new Contributor("Roman","Taranchenko","",2,d2,"U")); +// list.Add(new Contributor("Denis","Erchoff","",13,d2,"U")); + private ContributorCollection CreateContributorsList () { DateTime d1 = new DateTime(2000,11,11); @@ -47,8 +53,6 @@ namespace ICSharpCode.Reporting.Test.DataSource list.Add(new Contributor("Christoph","Wille","Senior Project Wrangler",17,new DateTime(1960,12,8),"F")); list.Add(new Contributor("Bernhard","Spuida","Senior Project Wrangler",25,new DateTime(1962,2,24),"D")); - - list.Add(new Contributor("Daniel","Grunwald","Technical Lead",12,d1,"F")); list.Add(new Contributor("Matt","Ward","NUnit",7,d1,"F")); @@ -58,15 +62,19 @@ namespace ICSharpCode.Reporting.Test.DataSource list.Add(new Contributor("Alexander","Zeitler","SharpDevelop.Reports",3,d2,"D")); list.Add(new Contributor("Markus","Palme","Prg.",6,d2,"R")); list.Add(new Contributor("Georg","Brandl","Prg.",5,d2,"R")); + list.Add(new Contributor("Roman","Taranchenko","",2,d2,"U")); list.Add(new Contributor("Denis","Erchoff","",13,d2,"U")); - list.Add(new Contributor("Ifko","Kovacka","",31,d3,"A")); + list.Add(new Contributor("Nathan","Allen","",5,d3,"A")); list.Add(new Contributor("Dickon","Field","DBTools",10,d3,"U")); - list.Add(new Contributor("Troy","Simpson","Prg.",9,d3,"C")); + list.Add(new Contributor("David","Alpert","Prg.",6,d3,"C")); + list.Add(new Contributor("Mike","Krüger","Mono",9,d3,"C")); + list.Add(new Contributor("Andrea","Krüger","Mono",9,d3,"C")); + list.Add(new Contributor("Andreas","Weizel","Prg.",9,d3,"C")); return list; } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/DataSourceFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/DataSourceFixture.cs new file mode 100644 index 0000000000..fbfaef24ea --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/DataSourceFixture.cs @@ -0,0 +1,298 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.ComponentModel; +using ICSharpCode.Reporting.BaseClasses; +using ICSharpCode.Reporting.DataManager.Listhandling; +using ICSharpCode.Reporting.Interfaces; +using ICSharpCode.Reporting.Items; +using NUnit.Framework; +using System.Linq; + +namespace ICSharpCode.Reporting.Test.DataSource +{ + [TestFixture] + public class CollectionDataSourceFixture + { + ContributorCollection list; + + [Test] + public void CollectionCountIsEqualToListCount() { + var collectionSource = new CollectionDataSource (list,new ReportSettings()); + Assert.That(collectionSource.Count,Is.EqualTo(list.Count)); + } + + + [Test] + public void AvailableFieldsEqualContibutorsPropertyCount() { + var collectionSource = new CollectionDataSource (list,new ReportSettings()); + Assert.That(collectionSource.AvailableFields.Count,Is.EqualTo(6)); + } + + + [Test] + public void GroupbyOneColumnSortSubList () { + var rs = new ReportSettings(); + var gc = new GroupColumn() { + ColumnName ="GroupItem", + SortDirection = ListSortDirection.Ascending, + GroupSortColumn = new SortColumn() { + ColumnName = "Randomint", + SortDirection = ListSortDirection.Ascending + } + }; + rs.GroupColumnsCollection.Add(gc); + var collectionSource = new CollectionDataSource (list,rs); + collectionSource.Bind(); + var testKey = String.Empty; + var testSubKey = -1; + var groupedList = collectionSource.GroupedList; + foreach (var element in groupedList) { + Assert.That(element.Key,Is.GreaterThan(testKey)); + testKey = element.Key.ToString(); + foreach (Contributor sub in element) { + Assert.That(sub.RandomInt,Is.GreaterThanOrEqualTo(testSubKey)); + testSubKey = sub.RandomInt; + } + testSubKey = -1; + } + } + + + [Test] + public void GroupbyOneColumn () { + var rs = new ReportSettings(); + rs.GroupColumnsCollection.Add( new GroupColumn("GroupItem",1,ListSortDirection.Ascending)); + var collectionSource = new CollectionDataSource (list,rs); + collectionSource.Bind(); + var testKey = String.Empty; + var groupedList = collectionSource.GroupedList; + foreach (var element in groupedList) { + Assert.That(element.Key,Is.GreaterThan(testKey)); + testKey = element.Key.ToString(); + } + } + + + [Test] + public void TypeOfReportItemIsString () { + var ric = new System.Collections.Generic.List(){ + new BaseDataItem(){ + ColumnName = "Lastname" + + }, + new BaseDataItem(){ + ColumnName = "Firstname" + } + }; + var collectionSource = new CollectionDataSource (list,new ReportSettings()); + collectionSource.Bind(); + var result = collectionSource.SortedList.FirstOrDefault(); + collectionSource.Fill(ric,result); + foreach (BaseDataItem element in ric) { + Assert.That(element.DataType,Is.EqualTo("System.String")); + } + } + + + [Test] + public void SortOneColumnAscending() { + var ric = new System.Collections.Generic.List(){ + new BaseDataItem(){ + ColumnName = "Lastname" + }, + new BaseDataItem(){ + ColumnName = "Firstname" + } + }; + + var rs = new ReportSettings(); + rs.SortColumnsCollection.Add(new SortColumn("Lastname",ListSortDirection.Ascending)); + var collectionSource = new CollectionDataSource (list,rs); + collectionSource.Bind(); + string compare = String.Empty; + int i = 0; + foreach (var element in collectionSource.SortedList) { + collectionSource.Fill(ric,element); + Console.WriteLine("first : <{0}> Last <{1}> ",((BaseDataItem)ric[0]).DBValue,((BaseDataItem)ric[1]).DBValue); + + Assert.That(((BaseDataItem)ric[0]).DBValue,Is.GreaterThanOrEqualTo(compare)); + + compare = ((BaseDataItem)ric[0]).DBValue; + i++; + } + /* + do { + collectionSource.Fill(ric); + Console.WriteLine("first : <{0}> Last <{1}> ",((BaseDataItem)ric[0]).DBValue, + ((BaseDataItem)ric[1]).DBValue); + Assert.That(((BaseDataItem)ric[0]).DBValue,Is.GreaterThanOrEqualTo(compare)); + compare = ((BaseDataItem)ric[0]).DBValue; + + i ++; + }while (collectionSource.MoveNext()); + + */ + Assert.That(i,Is.EqualTo(collectionSource.Count)); + } + + + [Test] + public void GroupbyOneColumnAndFill () { + var dataItemsCollection = CreateDataItems(); + var reportsettings = new ReportSettings(); + reportsettings.GroupColumnsCollection.Add( new GroupColumn("GroupItem",1,ListSortDirection.Ascending)); + //repiortsettings.GroupColumnsCollection.Add( new GroupColumn("RandomInt",1,ListSortDirection.Ascending)); + + var collectionSource = new CollectionDataSource (list,reportsettings); + collectionSource.Bind(); + int i = 0; + + foreach (var element in collectionSource.GroupedList) { + Console.WriteLine("Key {0} ",element.Key); + foreach (var l in element) { + collectionSource.Fill(dataItemsCollection,l); + Console.WriteLine("first : <{0}> Last <{1}> Group <{2}> Randomint <{3}>",((BaseDataItem)dataItemsCollection[0]).DBValue, + ((BaseDataItem)dataItemsCollection[1]).DBValue, + ((BaseDataItem)dataItemsCollection[2]).DBValue, + ((BaseDataItem)dataItemsCollection[3]).DBValue); + i++; + } + } + /* + do { + collectionSource.Fill(dataItemsCollection); + Console.WriteLine("first : <{0}> Last <{1}> Group <{2}> Randomint <{3}>",((BaseDataItem)dataItemsCollection[0]).DBValue, + ((BaseDataItem)dataItemsCollection[1]).DBValue, + ((BaseDataItem)dataItemsCollection[2]).DBValue, + ((BaseDataItem)dataItemsCollection[3]).DBValue); + i ++; + }while (collectionSource.MoveNext()); + */ + Assert.That(i,Is.EqualTo(collectionSource.Count)); + } + + + [Test] + public void FillDataIncludedInRow() { + + var baseRow = new BaseRowItem(); + var dataItemsCollection = CreateDataItems(); + baseRow.Items.AddRange(dataItemsCollection); + + var row = new System.Collections.Generic.List(); + row.Add(baseRow); + var reportSettings = new ReportSettings(); + var collectionSource = new CollectionDataSource (list,reportSettings); + collectionSource.Bind(); + int i = 0; + foreach (var element in collectionSource.SortedList) { + collectionSource.Fill(row,element); + var r = (BaseRowItem)row[0]; + foreach (var result in r.Items) { + Assert.That(((BaseDataItem)result).DBValue,Is.Not.Empty); + } + i ++; + } + /* + do { + collectionSource.Fill(row); + var r = (BaseRowItem)row[0]; + foreach (var element in r.Items) { + Assert.That(((BaseDataItem)element).DBValue,Is.Not.Empty); + } + i ++; + }while (collectionSource.MoveNext()); + */ + Assert.That(i,Is.EqualTo(collectionSource.Count)); + } + + + [Test] + public void RowContainsRowAndItem() { + var row = new System.Collections.Generic.List(); + var gItem = new BaseDataItem(){ + ColumnName = "GroupItem" + }; + row.Add(gItem); + + var baseRow = new BaseRowItem(); + + var ric = new System.Collections.Generic.List(){ + new BaseDataItem(){ + ColumnName = "Lastname" + + }, + new BaseDataItem(){ + ColumnName = "Firstname" + } + }; + baseRow.Items.AddRange(ric); + row.Add(baseRow); + var rs = new ReportSettings(); + var collectionSource = new CollectionDataSource (list,rs); + collectionSource.Bind(); + int i = 0; + foreach (var element in collectionSource.SortedList) { + collectionSource.Fill(row,element); + var res = (BaseDataItem)row.Find(c => ((BaseDataItem)c).ColumnName == "GroupItem"); + Assert.That(res.DBValue,Is.Not.Empty); + i ++; + } + + /* + do { + collectionSource.Fill(row); + var res = (BaseDataItem)row.Find(c => ((BaseDataItem)c).ColumnName == "GroupItem"); + Assert.That(res.DBValue,Is.Not.Empty); + i ++; + }while (collectionSource.MoveNext()); + */ + Assert.That(i,Is.EqualTo(collectionSource.Count)); + } + + + System.Collections.Generic.List CreateDataItems() { + var ric = new System.Collections.Generic.List(){ + new BaseDataItem(){ + ColumnName = "Lastname" + + }, + new BaseDataItem(){ + ColumnName = "Firstname" + }, + + new BaseDataItem(){ + ColumnName = "GroupItem" + }, + new BaseDataItem(){ + ColumnName = "RandomInt" + } + }; + return ric; + } + + + [SetUp] + public void CreateList() { + var contributorList = new ContributorsList(); + list = contributorList.ContributorCollection; + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/Aggregates/AggregateFuctionHelper.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/Aggregates/AggregateFuctionHelper.cs new file mode 100644 index 0000000000..2bb61926a1 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/Aggregates/AggregateFuctionHelper.cs @@ -0,0 +1,61 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System.Collections.Generic; + +namespace ICSharpCode.Reporting.Test.Expressions.Aggregates +{ + /// + /// Description of AggregateFuctionHelper. + /// + internal class AggregateFuctionHelper + { + + public AggregateFuctionHelper() + { + this.AggregateCollection = new AggregateCollection(); + this.AggregateCollection.Add (new Aggregate("Value1",1,1.5)); + this.AggregateCollection.Add (new Aggregate("Value2",2,2.5)); + this.AggregateCollection.Add (new Aggregate("Value3",3,3.5)); + this.AggregateCollection.Add (new Aggregate("Value400",400,400.75)); + } + + + public AggregateCollection AggregateCollection {get; private set;} + + } + + + class AggregateCollection: List + { + } + + + class Aggregate { + public Aggregate (string name,int intValue, double amount) + { + this.Name = name; + this.IntValue = intValue; + this.DoubleValue = amount; + } + + public string Name {get;set;} + public int IntValue {get;set;} + public double DoubleValue {get;set;} + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/Aggregates/SumAggregateFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/Aggregates/SumAggregateFixture.cs new file mode 100644 index 0000000000..a34768ac5d --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/Aggregates/SumAggregateFixture.cs @@ -0,0 +1,91 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Collections.ObjectModel; +using ICSharpCode.Reporting.DataManager.Listhandling; +using ICSharpCode.Reporting.Exporter.Visitors; +using ICSharpCode.Reporting.Items; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; +using NUnit.Framework; + +namespace ICSharpCode.Reporting.Test.Expressions.Aggregates +{ + [TestFixture] + public class SumAggregate + { + + Collection collection; + AggregateCollection aggregateCollection; + AggregateFuctionHelper helper; + CollectionDataSource dataSource; + ExpressionVisitor visitor; + + [Test] + public void CanSum_Int_WholeCollection() + { + var script = "= sum('intValue')"; + var result = Evaluate(script); + Assert.That (result.Text,Is.EqualTo("406")); + Assert.That(Convert.ToInt32(result.Text),Is.TypeOf(typeof(int))); + } + + + [Test] + public void CanSum_Double_WholeCollection() + { + var script = "= sum('doubleValue')"; + var result = Evaluate(script); + Assert.That (result.Text,Is.EqualTo("408,25")); + Assert.That(Convert.ToDouble(result.Text),Is.TypeOf(typeof(double))); + } + + + [Test] + public void CanSum_Double_With_String_Concat() + { + var script = "= 'myText ' + sum('doubleValue')"; + var result = Evaluate(script); + Assert.That (result.Text,Is.EqualTo("myText 408,25")); + } + + + ExportText Evaluate (string script) { + collection[0].Text = script; + visitor.Visit(collection[0]); + return collection[0]; + } + + [SetUp] + public void CreateExportlist() { + collection = new Collection(); + collection.Add(new ExportText() + { + Text = String.Empty + }); + + helper = new AggregateFuctionHelper(); + aggregateCollection = helper.AggregateCollection; + dataSource = new CollectionDataSource(aggregateCollection,new ReportSettings()); + dataSource.Bind(); + visitor = new ExpressionVisitor(new ReportSettings()); + visitor.SetCurrentDataSource(dataSource.SortedList); + } + + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IntegrationTests/AggregatesGroupesFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IntegrationTests/AggregatesGroupesFixture.cs new file mode 100644 index 0000000000..247e6b43e0 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IntegrationTests/AggregatesGroupesFixture.cs @@ -0,0 +1,114 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Linq; + +using ICSharpCode.Reporting.DataManager.Listhandling; +using ICSharpCode.Reporting.Exporter.Visitors; +using ICSharpCode.Reporting.Items; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; +using ICSharpCode.Reporting.Test.DataSource; +using NUnit.Framework; + +namespace ICSharpCode.Reporting.Test.Expressions.IntegrationTests +{ + [TestFixture] + public class AggregatesGroupesFixture + { + Collection collection; + CollectionDataSource dataSource; + ContributorCollection list; + ReportSettings reportSettings; + + [Test] + public void SumGroupedList() + { + var visitor = new ExpressionVisitor (reportSettings); + visitor.SetCurrentDataSource(dataSource.GroupedList); + var script = "= sum('randomint')"; + collection[0].Text = script; + visitor.Visit(collection[0]); + var result = list.Sum(x => x.RandomInt); + Assert.That(Convert.ToDouble(collection[0].Text),Is.EqualTo(result)); + } + + + [Test] + public void SumOneGroup () { + + var container = new ExportContainer(); + + var script = "= sum('randomint')"; + collection[0].Text = script; + container.ExportedItems.AddRange(collection); + + var visitor = new ExpressionVisitor (reportSettings); + visitor.SetCurrentDataSource(dataSource.GroupedList); + var group = dataSource.GroupedList.FirstOrDefault(); + + visitor.SetCurrentDataSource(group); + visitor.Visit(container); + + var result = list.Where(k => k.GroupItem == group.Key.ToString()).Sum(x => x.RandomInt); + Assert.That(Convert.ToDouble(collection[0].Text),Is.EqualTo(result)); + } + + + [Test] + public void SumAllGroups () { + var container = new ExportContainer(); + container.ExportedItems.AddRange(collection); + + var visitor = new ExpressionVisitor (reportSettings); + visitor.SetCurrentDataSource(dataSource.GroupedList); + foreach (var group in dataSource.GroupedList) { + var script = "= sum('randomint')"; + collection[0].Text = script; + visitor.SetCurrentDataSource(group); + visitor.Visit(container); + + var result = list.Where(k => k.GroupItem == group.Key.ToString()).Sum(x => x.RandomInt); + Assert.That(Convert.ToDouble(collection[0].Text),Is.EqualTo(result)); + } + } + + + [SetUp] + public void CreateExportlist() { + collection = new Collection(); + collection.Add(new ExportText() + { + Text = String.Empty + }); + + var contributorList = new ContributorsList(); + list = contributorList.ContributorCollection; + reportSettings = new ReportSettings(); + reportSettings.GroupColumnsCollection.Add( + + new GroupColumn("groupItem",1,ListSortDirection.Ascending ) + ); + + dataSource = new CollectionDataSource(list,reportSettings); + dataSource.Bind(); + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IntegrationTests/DateTimeFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IntegrationTests/DateTimeFixture.cs new file mode 100644 index 0000000000..d1c285c228 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IntegrationTests/DateTimeFixture.cs @@ -0,0 +1,84 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using NUnit.Framework; +using System.Collections.ObjectModel; +using ICSharpCode.Reporting.Exporter.Visitors; +using ICSharpCode.Reporting.Items; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; + +namespace ICSharpCode.Reporting.Test.Expressions.IntegrationTests +{ + + [TestFixture] + public class DateTimeFixture + { + Collection collection; + ExpressionVisitor expressionVisitor; + + [Test] + public void CanHandleToday(){ + + var script = "= Today.ToShortDateString()"; + var resultColumn = Evaluate(script); + Assert.That(resultColumn.Text,Is.EqualTo(System.DateTime.Now.ToShortDateString())); + } + + [Test] + public void CanHandleDateAdd() { + var expected = DateTime.Today.AddDays(2).ToShortDateString(); + var script = "=Today.AddDays(2).ToShortDateString()"; + var resultColumn = Evaluate(script); + Assert.That(resultColumn.Text,Is.EqualTo(expected)); + } + + + + + [Test] + public void CanHandleDayOfWeek () { + var expected = DateTime.Today.Day.ToString(); + var script ="=Today.Day"; + var resultColumn = Evaluate(script); + Assert.That(resultColumn.Text,Is.EqualTo(expected)); + } + + + ExportText Evaluate(string script) + { + collection[0].Text = script; + var exportContainer = new ExportContainer(); + exportContainer.ExportedItems.Add(collection[0]); + expressionVisitor.Visit(exportContainer); + var resultColumn = (ExportText)exportContainer.ExportedItems[0]; + return resultColumn; + } + + + [SetUp] + public void CreateSut() { + collection = new Collection(); + collection.Add(new ExportText() + { + Text = String.Empty + }); + expressionVisitor = new ExpressionVisitor(new ReportSettings()); + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IntegrationTests/FieldsFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IntegrationTests/FieldsFixture.cs new file mode 100644 index 0000000000..ee22fe567c --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IntegrationTests/FieldsFixture.cs @@ -0,0 +1,89 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System.Collections.ObjectModel; +using ICSharpCode.Reporting.Exporter.Visitors; +using ICSharpCode.Reporting.Items; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; +using NUnit.Framework; + +namespace ICSharpCode.Reporting.Test.Expressions.InterationTests +{ + [TestFixture] + public class FieldsFixture + { + Collection collection; + ExpressionVisitor visitor; + + [Test] + public void FieldsInContainer() { + var script = "=Fields!myfield1 + Fields!myfield2"; + collection[0].Text = script; + collection.Add(new ExportText() + { + Text = "Sharpdevelop", + Name = "myfield1" + }); + collection.Add(new ExportText() + { + Text = " is great", + Name = "myfield2" + }); + + var exportContainer = new ExportContainer(); + exportContainer.ExportedItems.Add(collection[0]); + exportContainer.ExportedItems.Add(collection[1]); + exportContainer.ExportedItems.Add(collection[2]); + + visitor.Visit(exportContainer); + Assert.That (collection[0].Text,Is.EqualTo("Sharpdevelop is great")); + } + + + [Test] + public void FieldNotExist() { + var script = "=Fields!myfieldNotExist"; + collection[0].Text = script; + collection.Add(new ExportText() + { + Text = "Sharpdevelop", + Name = "myfield1" + }); + + var exportContainer = new ExportContainer(); + exportContainer.ExportedItems.Add(collection[0]); + exportContainer.ExportedItems.Add(collection[1]); + + visitor.Visit(exportContainer); + Assert.That (collection[0].Text.StartsWith("Missing")); + Assert.That (collection[0].Text.Contains("myfieldNotExist")); + } + + + [SetUp] + public void CreateExportlist() { + collection = new Collection(); + collection.Add(new ExportText() + { + Text = "myExporttextColumn" + }); + visitor = new ExpressionVisitor (new ReportSettings()); + } + + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IntegrationTests/GlobalsFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IntegrationTests/GlobalsFixture.cs new file mode 100644 index 0000000000..c1a7bd2949 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IntegrationTests/GlobalsFixture.cs @@ -0,0 +1,124 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System.Collections.ObjectModel; +using System.Reflection; + +using ICSharpCode.Reporting.Exporter.Visitors; +using ICSharpCode.Reporting.Interfaces; +using ICSharpCode.Reporting.Items; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; +using NUnit.Framework; + +namespace ICSharpCode.Reporting.Test.Expressions.InterationTests +{ + [TestFixture] +// [Ignore] + public class GlobalsFixture + { + IReportCreator reportCreator; + Collection collection; + + [Test] + public void CanReadPageNumber() + { + reportCreator.BuildExportList(); + var page = reportCreator.Pages[0]; + var sec = (ExportContainer)page.ExportedItems[3]; + var s = (ExportText)sec.ExportedItems[1]; + Assert.That (s.Text.Contains("1")); + Assert.That(s.Text.Contains("Page")); + } + + + [Test] + public void CanEvaluateTotalPages () { + reportCreator.BuildExportList(); + var page = reportCreator.Pages[0]; + var sec = (ExportContainer)page.ExportedItems[1]; + var s = (ExportText)sec.ExportedItems[0]; + Assert.That (s.Text.Contains("1")); + Assert.That(s.Text.Contains("Pages")); + } + + + [Test] + public void CanEvaluateReportName() { + reportCreator.BuildExportList(); + var page = reportCreator.Pages[0]; + var sec = (ExportContainer)page.ExportedItems[2]; + var s = (ExportText)sec.ExportedItems[0]; + Assert.That (s.Text.Contains("Report1")); + Assert.That(s.Text.Contains("ReportName")); + } + + + [Test] + public void CanEvaluateReportFolder() { + reportCreator.BuildExportList(); + var page = reportCreator.Pages[0]; + var sec = (ExportContainer)page.ExportedItems[0]; + var s = (ExportText)sec.ExportedItems[1]; + Assert.That (s.Text.Contains(@"\UnitTests")); + Assert.That(s.Text.Contains("ReportFolder")); + } + + + [Test] + public void CanEvaluateReportFileName () { + reportCreator.BuildExportList(); + var page = reportCreator.Pages[0]; + var sec = (ExportContainer)page.ExportedItems[0]; + var s = (ExportText)sec.ExportedItems[0]; + Assert.That (s.Text.Contains(@"\UnitTests\Report1.srd")); + Assert.That(s.Text.Contains("ReportFileName")); + } + + + [Test] + public void SyntaxErrorInGlobals () { + reportCreator.BuildExportList(); + var page = reportCreator.Pages[0]; + var sec = (ExportContainer)page.ExportedItems[3]; + var s = (ExportText)sec.ExportedItems[0]; + Assert.That (s.Text.Contains("Syntaxerror in Globals")); + Assert.That(s.Text.Contains("SyntaxError")); + } + + + [SetUp] + public void CreateExportlist() { + collection = new Collection(); + collection.Add(new ExportText() + { + Text = "myExporttextColumn" + }); + } + + + [SetUp] + public void LoadModelFromStream() + { + Assembly asm = Assembly.GetExecutingAssembly(); + var stream = asm.GetManifestResourceStream(TestHelper.TestForGlobals); + var rf = new ReportingFactory(); + var reportingFactory = new ReportingFactory(); + reportCreator = reportingFactory.ReportCreator(stream); + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IntegrationTests/ParametersFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IntegrationTests/ParametersFixture.cs new file mode 100644 index 0000000000..244865c129 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IntegrationTests/ParametersFixture.cs @@ -0,0 +1,102 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System.Collections.ObjectModel; +using ICSharpCode.Reporting.BaseClasses; +using ICSharpCode.Reporting.Exporter.Visitors; +using ICSharpCode.Reporting.Items; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; +using NUnit.Framework; + +namespace ICSharpCode.Reporting.Test.Expressions.InterationTests +{ + [TestFixture] + public class ParametersFixture + { + Collection collection; + + + [Test] + public void CanConcatParameter () { + + var parameters = new ParameterCollection(); + parameters.Add(new BasicParameter() { + ParameterName = "param1", + ParameterValue = "SharpDevelop" + } + ); + + parameters.Add(new BasicParameter() { + ParameterName = "param2", + ParameterValue = " is " + } + ); + parameters.Add(new BasicParameter() { + ParameterName = "param3", + ParameterValue = "great" + } + ); + + var reportSettings = CreateReportSettings(parameters); + var visitor = new ExpressionVisitor(reportSettings); + + var script = "=Parameters!param1 + Parameters!param2 + Parameters!param3"; + collection[0].Text = script; + visitor.Visit(collection[0]); + Assert.That (collection[0].Text,Is.EqualTo("SharpDevelop is great")); + } + + + [Test] + public void ParameterNotExist() { + var parameters = new ParameterCollection(); + parameters.Add(new BasicParameter() { + ParameterName = "param1", + ParameterValue = "SharpDevelop" + } + ); + var reportSettings = CreateReportSettings(parameters); + var visitor = new ExpressionVisitor(reportSettings); + + var script = "=Parameters!paramNotExist"; + collection[0].Text = script; + visitor.Visit(collection[0]); + Assert.That (collection[0].Text.StartsWith("Missing")); + Assert.That (collection[0].Text.Contains("paramNotExist")); + } + + + ReportSettings CreateReportSettings(ParameterCollection parameters) + { + var reportSettings = new ReportSettings(); + reportSettings.ParameterCollection.AddRange(parameters); + return reportSettings; + } + + + [SetUp] + public void CreateExportlist() { + collection = new Collection(); + collection.Add(new ExportText() + { + Text = "myExporttextColumn" + }); + } + + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IntegrationTests/StandardTests.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IntegrationTests/StandardTests.cs new file mode 100644 index 0000000000..b4ea6dfb9f --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IntegrationTests/StandardTests.cs @@ -0,0 +1,109 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Collections.ObjectModel; +using ICSharpCode.Reporting.Exporter.Visitors; +using ICSharpCode.Reporting.Items; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; +using NUnit.Framework; + +namespace ICSharpCode.Reporting.Test.Expressions.InterationTests { + + [TestFixture] + public class StandardTests + { + Collection collection; + ExpressionVisitor expressionVisitor; + + [Test] + public void ExpressionMustStartWithEqualChar() + { + collection[0].Text = "myText"; + var result = collection[0].Text; + expressionVisitor.Visit(collection[0]); + Assert.That(result,Is.EqualTo(collection[0].Text)); + } + + + [Test] + + public void ReportSyntaxError() { + collection[0].Text = "= myText"; + expressionVisitor.Visit(collection[0]); + } + + + + [Test] + public void SimpleStringHandling () { + var script = "='Sharpdevelop' + ' is great'"; + collection[0].Text = script; + expressionVisitor.Visit(collection[0]); + Assert.That(collection[0].Text,Is.EqualTo("Sharpdevelop is great")); + } + + + #region Convert inside Container + [Test] + public void SimpleStringHandlingInContainer () { + var script = "='Sharpdevelop' + ' is great'"; + + collection[0].Text = script; + var exportContainer = new ExportContainer(); + exportContainer.ExportedItems.Add(collection[0]); + expressionVisitor.Visit(exportContainer); + + var resultColumn = (ExportText)exportContainer.ExportedItems[0]; + Assert.That(resultColumn.Text,Is.EqualTo("Sharpdevelop is great")); + } + + #endregion + + + #region System.Math + + [Test] + public void CanRunSystemMath () { + //Using methods imported from System.Math class + var script = @"=abs(-1.0) + Log10(100.0) + sqrt(9) + floor(4.5) + sin(PI/2)"; + collection[0].Text = script; + expressionVisitor.Visit(collection[0]); + var res = Convert.ToDouble(collection[0].Text); + Assert.That(collection[0].Text,Is.EqualTo("11")); + } + #endregion + + + [SetUp] + public void CreateExportlist() { + collection = new Collection(); + collection.Add(new ExportText() + { + Text = "myExporttextColumn" + }); + } + + + [TestFixtureSetUp] + public void Setup() { + expressionVisitor = new ExpressionVisitor(new ReportSettings()); + } + + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IronyGeneral.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IronyGeneral.cs new file mode 100644 index 0000000000..47baa935ef --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IronyGeneral.cs @@ -0,0 +1,90 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using ICSharpCode.Reporting.Expressions.Irony; +using Irony.Interpreter.Evaluator; +using NUnit.Framework; + +namespace ICSharpCode.Reporting.Test.Expressions +{ + [TestFixture] + public class IronyBasics + { + + ReportingLanguageGrammer grammar; + ReportingExpressionEvaluator evaluator; + + #region Calculation + + [Test] + public void CanAddNumber() { + + var script = "2 + 3"; + var result = evaluator.Evaluate(script); + Assert.That(result,Is.EqualTo(5)); + } + + #endregion + + + #region Stringhandling + + [Test] + public void CanConcatString() { + var result = evaluator.Evaluate("'SharpDevelop' + ' ' + 'is great'"); + Assert.That(result,Is.EqualTo("SharpDevelop is great")); + } + #endregion + + #region System.Environment + + [Test] + public void CanUserSystemEnvironment() { + + //Using methods imported from System.Environment + var script = @"report = '#{MachineName}-#{OSVersion}-#{UserName}'"; + var result = evaluator.Evaluate(script); + var expected = string.Format("{0}-{1}-{2}", Environment.MachineName, Environment.OSVersion, Environment.UserName); + Assert.AreEqual(expected, result, "Unexpected computation result"); + } + + #endregion + + + #region System.Math + + [Test] + public void CanRunSystemMath () { + //Using methods imported from System.Math class + var script = @"abs(-1.0) + Log10(100.0) + sqrt(9) + floor(4.5) + sin(PI/2)"; + var result = evaluator.Evaluate(script); + Assert.IsTrue(result is double, "Result is not double."); + Assert.AreEqual(11.0, (double) result, 0.001, "Unexpected computation result"); + } + + + #endregion + + [SetUp] + public void Initialize() { + grammar = new ReportingLanguageGrammer(); + evaluator = new ReportingExpressionEvaluator(grammar); + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/ContainerArrangeStrategyFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/MeasureArrange/ContainerArrangeStrategyFixture.cs similarity index 54% rename from src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/ContainerArrangeStrategyFixture.cs rename to src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/MeasureArrange/ContainerArrangeStrategyFixture.cs index 8e3d951466..e9f8c25343 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/ContainerArrangeStrategyFixture.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/MeasureArrange/ContainerArrangeStrategyFixture.cs @@ -18,16 +18,21 @@ using System; using System.Drawing; +using System.Linq; + using ICSharpCode.Reporting.Arrange; +using ICSharpCode.Reporting.Globals; using ICSharpCode.Reporting.Interfaces.Export; using ICSharpCode.Reporting.PageBuilder.ExportColumns; using NUnit.Framework; -namespace ICSharpCode.Reporting.Test.PageBuilder +namespace ICSharpCode.Reporting.Test.MeasureArrange { [TestFixture] public class ContainerArrangeStrategyFixture { + readonly Graphics graphics = CreateGraphics.FromSize (new Size(1000,1000)); + ContainerArrangeStrategy strategy; [Test] @@ -38,101 +43,121 @@ namespace ICSharpCode.Reporting.Test.PageBuilder Assert.That(param.Size, Is.EqualTo(size)); } + [Test] public void ItemAtTopOfContainer() { var container = CreateContainer(); - container.ExportedItems[0].Location = container.Location; + + container.ExportedItems[0].Location = Point.Empty; + Measure(container); strategy.Arrange(container); var containerRect = new Rectangle(container.Location,container.DesiredSize); - var itemRect = new Rectangle(container.ExportedItems[0].Location,container.ExportedItems[0].Size); - -// Console.WriteLine("{0} - {1} - {2} - {3}",containerRect,containerRect.Bottom,itemRect,itemRect.Bottom); - Assert.That(containerRect.Contains(itemRect)); - - } - - - [Test] - public void ItemAtTopBottomOfContainer() { - var container = CreateContainer(); - container.ExportedItems[0].Location = new Point (container.Location.X, - container.Location.Y + container.DesiredSize.Height - container.ExportedItems[0].Size.Height); - strategy.Arrange(container); - - var containerRect = new Rectangle(container.Location,container.DesiredSize); - var itemRect = new Rectangle(container.ExportedItems[0].Location,container.ExportedItems[0].Size); - -// Console.WriteLine("{0} - {1} - {2} - {3}",containerRect,containerRect.Bottom,itemRect,itemRect.Bottom); - Assert.That(containerRect.Contains(itemRect)); + + var arrangedRect = CreateItemRectangle(container); + Assert.That(containerRect.Contains(arrangedRect)); } [Test] - public void FindBiggestRectangle () { + public void ContainerNotResizeIfCanGrowEqualFalse () { var container = CreateContainer(); - var secondItem = CreateCanGrowText(container); - container.ExportedItems.Add(secondItem); - + Measure(container); strategy.Arrange(container); - var expected = new Rectangle(new Point(container.Location.X + secondItem.Location.X, - container.Location.Y + secondItem.Location.Y), - secondItem.Size); - Assert.That(strategy.BiggestRectangle,Is.EqualTo(expected)); + + Assert.That(container.Size,Is.EqualTo(container.DesiredSize)); } [Test] public void ContainerResizeIfItemCanGrow () { - var container = CreateContainer(); - container.ExportedItems.Add(CreateCanGrowText(container)); + var container = CreateContainer(); + MakeCangGrow(container); + Measure(container); strategy.Arrange(container); + var containerRect = new Rectangle(container.Location,container.DesiredSize); - var arrangeRect = new Rectangle(new Point(container.Location.X + strategy.BiggestRectangle.Left, - strategy.BiggestRectangle.Top), - strategy.BiggestRectangle.Size); -// Console.WriteLine("{0} - {1} - {2} - {3}",containerRect,containerRect.Bottom,strategy.BiggestRectangle,strategy.BiggestRectangle.Bottom); - Assert.That(containerRect.Contains(arrangeRect)); - Assert.That(containerRect.Bottom,Is.EqualTo(arrangeRect.Bottom + 5)); + var arrangedRect = CreateItemRectangle(container); + Assert.That(containerRect.Contains(arrangedRect)); } + [Test] public void ResizedContainerExeed5Points() { var container = CreateContainer(); - container.ExportedItems.Add(CreateCanGrowText(container)); + MakeCangGrow(container); + Measure(container); strategy.Arrange(container); var containerRect = new Rectangle(container.Location,container.DesiredSize); - var arrangeRect = new Rectangle(new Point(container.Location.X + strategy.BiggestRectangle.Left, - strategy.BiggestRectangle.Top), - strategy.BiggestRectangle.Size); + var item = container.ExportedItems[0]; + + var arrangedRect = CreateItemRectangle(container); - Assert.That(containerRect.Bottom,Is.EqualTo(arrangeRect.Bottom + 5)); + Assert.That(containerRect.Bottom,Is.EqualTo(arrangedRect.Bottom + 5)); } - private IExportText CreateCanGrowText(IExportContainer container) { - var secondItem = new ExportText(){ - Name = "Item1", - Location = new Point(80,10), - Size = new Size (20,70), - DesiredSize = new Size (20,70), + [Test] + public void ContainerContainsTwoItems_OneCanGrow () { + var container = CreateContainer(); + var item1 = new ExportText(){ CanGrow = true, + Name = "Item1", + Location = new Point(80,20), + Size = new Size (60,70), Parent = container }; - return secondItem; + container.ExportedItems.Add(item1); + + Measure(container); + strategy.Arrange(container); + + foreach (var element in container.ExportedItems) { + var arrangedRect = new Rectangle(container.Location.X + element.Location.X,container.Location.Y + element.Location.Y, + element.Size.Width,element.Size.Height); + + Assert.That(container.DisplayRectangle.IntersectsWith(arrangedRect)); + Assert.That(container.DisplayRectangle.Contains(arrangedRect)); + } } - private IExportContainer CreateContainer () { - + Rectangle CreateItemRectangle(IExportContainer container) + { + var containerRect = new Rectangle(container.Location,container.DesiredSize); + var child = container.ExportedItems[0]; + var childLocation = new Point(containerRect.Left + child.Location.X, containerRect.Top + child.Location.Y); + var childRect = new Rectangle(childLocation, child.DesiredSize); + return childRect; + } + + + static void MakeCangGrow(IExportContainer container) + { + container.ExportedItems[0].Location = new Point(80, 10); + container.ExportedItems[0].Size = new Size(20, 70); + container.ExportedItems[0].CanGrow = true; + } + + + + void Measure(IExportColumn container) + { + var mes = container.MeasurementStrategy(); + container.DesiredSize = mes.Measure(container, graphics); + } + + + IExportContainer CreateContainer () { + var container = new ExportContainer(){ Size = new Size (720,60), Location = new Point(50,50), Name ="Section" }; - + var item1 = new ExportText(){ Name = "Item1", Location = new Point(10,10), @@ -141,10 +166,9 @@ namespace ICSharpCode.Reporting.Test.PageBuilder }; container.ExportedItems.Add(item1); - container.DesiredSize = container.Size; return container; } - + [TestFixtureSetUp] public void Init() { diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Model/Report_FromListFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Model/Report_FromListFixture.cs new file mode 100644 index 0000000000..aa8101e507 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Model/Report_FromListFixture.cs @@ -0,0 +1,63 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Drawing; +using System.Reflection; + +using ICSharpCode.Reporting.Items; +using NUnit.Framework; + +namespace ICSharpCode.Reporting.Test.Model +{ + [TestFixture] + public class Report_FromListFixture + { + private ReportModel model; + + [Test] + public void ReportHeaderContainsOneItem () { + var section = model.ReportHeader; + Assert.That(section.Items.Count,Is.EqualTo(1)); + } + + + [Test] + public void PageHeaderContainsOneItem () { + var section = model.ReportHeader; + Assert.That(section.Items.Count,Is.EqualTo(1)); + } + + + [Test] + public void DetailContainsOneDataItem() { + var section = model.DetailSection; + Assert.That(section.Items.Count,Is.EqualTo(2)); + } + + + [SetUp] + public void LoadModelFromStream() + { + System.Reflection.Assembly asm = Assembly.GetExecutingAssembly(); + var stream = asm.GetManifestResourceStream(TestHelper.ReportFromList); + var rf = new ReportingFactory(); + model = rf.LoadReportModel(stream); + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Model/Report_TwoItemsFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Model/Report_TwoItemsFixture.cs index 8aea5638b2..75d01c457a 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Model/Report_TwoItemsFixture.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Model/Report_TwoItemsFixture.cs @@ -18,7 +18,6 @@ using System; using System.Drawing; -using System.IO; using System.Reflection; using ICSharpCode.Reporting.Items; @@ -70,7 +69,7 @@ namespace ICSharpCode.Reporting.Test.Model [SetUp] public void LoadModelFromStream() { - System.Reflection.Assembly asm = Assembly.GetExecutingAssembly(); + Assembly asm = Assembly.GetExecutingAssembly(); var stream = asm.GetManifestResourceStream(TestHelper.RepWithTwoItems); var rf = new ReportingFactory(); model = rf.LoadReportModel(stream); diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/BaseConvertFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/BaseConvertFixture.cs index f7c9b075c5..6da9eeb1cb 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/BaseConvertFixture.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/BaseConvertFixture.cs @@ -19,7 +19,7 @@ using System; using System.Reflection; using ICSharpCode.Reporting.Interfaces; -using ICSharpCode.Reporting.PageBuilder; +using ICSharpCode.Reporting.Items; using ICSharpCode.Reporting.PageBuilder.ExportColumns; using NUnit.Framework; @@ -28,14 +28,14 @@ namespace ICSharpCode.Reporting.Test.PageBuilder [TestFixture] public class BaseConvertFixture { - private IReportCreator reportCreator; + IReportCreator reportCreator; [Test] public void CurrentPageContainFiveItems() { reportCreator.BuildExportList(); var page = reportCreator.Pages[0]; - Assert.That(page.ExportedItems.Count, Is.EqualTo(5)); + Assert.That(page.ExportedItems.Count, Is.EqualTo(4)); } @@ -57,10 +57,22 @@ namespace ICSharpCode.Reporting.Test.PageBuilder } + [Test] + public void SectionRenderingCalledFromEachSection() { + int i = 0; + reportCreator.SectionRendering += (sender, e) => { +// Console.WriteLine("Hi with from {0} with {1}",e.ToString(),e.Section.Name); + i ++; + }; + reportCreator.BuildExportList(); + var p = reportCreator.Pages[0]; +// Assert.That(i,Is.EqualTo(p.ExportedItems.Count -1)); + } + [SetUp] public void LoadFromStream() { - System.Reflection.Assembly asm = Assembly.GetExecutingAssembly(); + var asm = Assembly.GetExecutingAssembly(); var stream = asm.GetManifestResourceStream(TestHelper.RepWithTwoItems); var reportingFactory = new ReportingFactory(); reportCreator = reportingFactory.ReportCreator(stream); diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/PageBuilderFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/FormBuilderFixture.cs similarity index 93% rename from src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/PageBuilderFixture.cs rename to src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/FormBuilderFixture.cs index 3027d0d232..f744f79ef8 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/PageBuilderFixture.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/FormBuilderFixture.cs @@ -17,13 +17,15 @@ // DEALINGS IN THE SOFTWARE. using System; +using System.Drawing; using System.IO; using System.Reflection; -using ICSharpCode.Reporting.BaseClasses; -using ICSharpCode.Reporting.Exporter; +using ICSharpCode.Reporting.Factories; +using ICSharpCode.Reporting.Globals; using ICSharpCode.Reporting.Interfaces; using ICSharpCode.Reporting.Interfaces.Export; +using ICSharpCode.Reporting.Items; using ICSharpCode.Reporting.PageBuilder; using NUnit.Framework; @@ -40,7 +42,7 @@ namespace ICSharpCode.Reporting.Test.PageBuilder { Assert.IsNotNull(reportCreator); } - + #region Pages @@ -73,6 +75,7 @@ namespace ICSharpCode.Reporting.Test.PageBuilder #endregion + [Test] public void ParentOfSectionsIsPage() { reportCreator.BuildExportList(); @@ -82,11 +85,12 @@ namespace ICSharpCode.Reporting.Test.PageBuilder Assert.That(element.Parent,Is.AssignableTo(typeof(IPage))); } } - + + [SetUp] public void LoadFromStream() { - System.Reflection.Assembly asm = Assembly.GetExecutingAssembly(); + var asm = Assembly.GetExecutingAssembly(); var stream = asm.GetManifestResourceStream(TestHelper.RepWithTwoItems); var reportingFactory = new ReportingFactory(); reportCreator = reportingFactory.ReportCreator(stream); diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/PageFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/PageFixture.cs index e8c915b73f..0037e3812f 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/PageFixture.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/PageFixture.cs @@ -20,11 +20,9 @@ using System; using System.IO; using System.Reflection; using System.Drawing; -using ICSharpCode.Reporting.Exporter; using ICSharpCode.Reporting.Globals; using ICSharpCode.Reporting.Interfaces; using ICSharpCode.Reporting.Interfaces.Export; -using ICSharpCode.Reporting.PageBuilder; using NUnit.Framework; namespace ICSharpCode.Reporting.Test.PageBuilder @@ -79,7 +77,7 @@ namespace ICSharpCode.Reporting.Test.PageBuilder [SetUp] public void LoadFromStream() { - System.Reflection.Assembly asm = Assembly.GetExecutingAssembly(); + Assembly asm = Assembly.GetExecutingAssembly(); var stream = asm.GetManifestResourceStream(TestHelper.RepWithTwoItems); var reportingFactory = new ReportingFactory(); reportCreator = reportingFactory.ReportCreator(stream); diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/PageLayoutFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/PageLayoutFixture.cs index 9d6d021f9d..0b67b5568a 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/PageLayoutFixture.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/PageLayoutFixture.cs @@ -23,7 +23,6 @@ using System.Reflection; using ICSharpCode.Reporting.Exporter; using ICSharpCode.Reporting.Interfaces; -using ICSharpCode.Reporting.Interfaces.Export; using ICSharpCode.Reporting.PageBuilder.ExportColumns; using NUnit.Framework; @@ -35,15 +34,15 @@ namespace ICSharpCode.Reporting.Test.PageBuilder private IReportCreator reportCreator; [Test] - public void PageContainsFiveSections() + public void FormsReportContains_4_Sections() { reportCreator.BuildExportList(); var x = reportCreator.Pages[0].ExportedItems; var y = from s in x where s.GetType() == typeof(ExportContainer) select s; - Assert.That(y.ToList().Count,Is.EqualTo(5)); - Console.WriteLine("-------ShowDebug---------"); + Assert.That(y.ToList().Count,Is.EqualTo(4)); + Console.WriteLine("-------PageLayoutFixture:ShowDebug---------"); var ex = new DebugExporter(reportCreator.Pages); ex.Run(); } @@ -58,8 +57,6 @@ namespace ICSharpCode.Reporting.Test.PageBuilder reportCreator.BuildExportList(); foreach (var item in reportCreator.Pages[0].ExportedItems) { var p2 = new Point(item.Location.X,item.Location.Y); - - Console.WriteLine("{0} - {1} - {2}- <{3}>",p2,item.Size.Height,item.Name,item.DisplayRectangle); if (item.Name != "ReportFooter") { Assert.That(p2.Y,Is.GreaterThan(referencePoint.Y),item.Name); var t = referenceRect.IntersectsWith(item.DisplayRectangle); @@ -74,7 +71,7 @@ namespace ICSharpCode.Reporting.Test.PageBuilder [SetUp] public void LoadFromStream() { - System.Reflection.Assembly asm = Assembly.GetExecutingAssembly(); + Assembly asm = Assembly.GetExecutingAssembly(); var stream = asm.GetManifestResourceStream(TestHelper.RepWithTwoItems); var reportingFactory = new ReportingFactory(); reportCreator = reportingFactory.ReportCreator(stream); diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/ContainerConverterFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/SectionConverterFixture.cs similarity index 68% rename from src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/ContainerConverterFixture.cs rename to src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/SectionConverterFixture.cs index b5d89c2762..42dba39876 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/ContainerConverterFixture.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/SectionConverterFixture.cs @@ -27,47 +27,52 @@ using NUnit.Framework; namespace ICSharpCode.Reporting.Test.PageBuilder { [TestFixture] - public class ContainerConverterFixture + public class SectionConverterFixture { - private IReportContainer container; - private Graphics graphics; + IReportContainer container; + Graphics graphics; [Test] public void ConverterReturnExportContainer() { - var converter = new ContainerConverter(graphics,container,new Point(30,30)); - var result = converter.Convert(); + var converter = new ContainerConverter(new Point(30,30)); + var result = converter.ConvertToExportContainer(container); Assert.That(result,Is.InstanceOf(typeof(IExportContainer))); } [Test] - public void ConverterReturnExportContainerwithTwoItems() + public void ConverterReturnExportContainerWithTwoItems() { - var converter = new ContainerConverter(graphics,container,new Point(30,30)); - var result = converter.Convert(); + var converter = new ContainerConverter(new Point(30,30)); + var result = converter.ConvertToExportContainer(container); + var list = converter.CreateConvertedList(container.Items); + result.ExportedItems.AddRange(list); Assert.That(result.ExportedItems.Count,Is.EqualTo(2)); } [Test] public void LocationIsAdjusted() { - var location = new Point(30,30); - var converter = new ContainerConverter(graphics,container,location); - var result = converter.Convert(); - Assert.That(result.Location,Is.EqualTo(location)); + var converter = new ContainerConverter(new Point(30,30)); + var result = converter.ConvertToExportContainer(container); + Assert.That(result.Location,Is.EqualTo(new Point(30,30))); } + [Test] public void ParentInChildsIsSet () { - var converter = new ContainerConverter(graphics,container,container.Location); - var result = converter.Convert(); - foreach (var element in result.ExportedItems) { + var converter = new ContainerConverter(container.Location); + var convertedContainer = converter.ConvertToExportContainer(container); + var convertedList = converter.CreateConvertedList(container.Items); + converter.SetParent(convertedContainer,convertedList); + convertedContainer.ExportedItems.AddRange(convertedList); + foreach (var element in convertedContainer.ExportedItems) { Assert.That(element.Parent,Is.Not.Null); } } - - - [TestFixtureSetUp] + + + [SetUp] public void Init() { container = new BaseSection(){ diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/DataPageBuilderFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/SectionWithContainerFixture.cs similarity index 51% rename from src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/DataPageBuilderFixture.cs rename to src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/SectionWithContainerFixture.cs index bfbaff0c86..bb62563bd9 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/DataPageBuilderFixture.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/SectionWithContainerFixture.cs @@ -17,55 +17,69 @@ // DEALINGS IN THE SOFTWARE. using System; -using System.Linq; -using System.Reflection; -using ICSharpCode.Reporting.Exporter; +using System.Drawing; using ICSharpCode.Reporting.Interfaces; using ICSharpCode.Reporting.Items; -using ICSharpCode.Reporting.PageBuilder; +using ICSharpCode.Reporting.PageBuilder.Converter; using ICSharpCode.Reporting.PageBuilder.ExportColumns; using NUnit.Framework; namespace ICSharpCode.Reporting.Test.PageBuilder { [TestFixture] - public class DataPageBuilderFixture + public class SectionWithContainerFixture { - private IReportCreator reportCreator; + IReportContainer section; + Graphics graphics; [Test] - public void CanInitDataPageBuilder() - { - var dpb = new DataPageBuilder (new ReportModel(),new System.Collections.Generic.List()); -// dpb.DataSource(new ReportModel(),new System.Collections.Generic.List()); - Assert.That(dpb,Is.Not.Null); + public void SectionContainsRowWithName() { + Assert.That(section.Items[0],Is.AssignableTo(typeof(BaseRowItem))); + Assert.That(section.Items[0].Name,Is.EqualTo("Row1")); } [Test] - public void PageContainsFiveSections() - { - reportCreator.BuildExportList(); - var x = reportCreator.Pages[0].ExportedItems; - var y = from s in x - where s.GetType() == typeof(ExportContainer) - select s; - Assert.That(y.ToList().Count,Is.EqualTo(5)); - Console.WriteLine("-------ShowDebug---------"); - var ex = new DebugExporter(reportCreator.Pages); - ex.Run(); + public void SectionContainsOneItemThatIsRow() { + var converter = new ContainerConverter(section.Location); + var list = converter.CreateConvertedList(section.Items); + Assert.That(list.Count,Is.EqualTo(1)); + } + + + [Test] + public void RowContainsOneItem() { + var converter = new ContainerConverter(section.Location); + var list = converter.CreateConvertedList(section.Items); + var item = list[0] as ExportContainer; + var text = item.ExportedItems[0]; + Assert.That(text,Is.AssignableTo(typeof(ExportText))); } [SetUp] - public void LoadFromStream() + public void Init() { - System.Reflection.Assembly asm = Assembly.GetExecutingAssembly(); - var stream = asm.GetManifestResourceStream(TestHelper.RepWithTwoItems); - var reportingFactory = new ReportingFactory(); -// reportCreator = reportingFactory.ReportCreator(stream); - var model = reportingFactory.LoadReportModel (stream); - reportCreator = new DataPageBuilder(model,new System.Collections.Generic.List()); + section = new BaseSection(){ + Size = new Size (720,60), + Location = new Point(50,50), + Name ="Section" + }; + + var row = new BaseRowItem(){ + Name = "Row1" + }; + + row.Items.Add(new BaseTextItem(){ + Name = "Item1", + Location = new Point(10,10), + Size = new Size (60,20) + }); + + + section.Items.Add(row); + Bitmap bitmap = new Bitmap(700,1000); + graphics = Graphics.FromImage(bitmap); } } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Reportingfactory/FormPageFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Reportingfactory/FormPageFixture.cs new file mode 100644 index 0000000000..adaa550be3 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Reportingfactory/FormPageFixture.cs @@ -0,0 +1,52 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.IO; +using System.Reflection; + +using ICSharpCode.Reporting.PageBuilder; +using NUnit.Framework; +using ICSharpCode.Reporting.Test; + +namespace ICSharpCode.Reporting.Test.Reportingfactory +{ + [TestFixture] + public class FormSheetFixture + { + Stream stream; + + + [Test] + public void CanCreateReportCreatorFromFormSheet () { + var reportingFactory = new ReportingFactory(); + var rc = reportingFactory.ReportCreator(stream); + Assert.That(rc,Is.Not.Null); + Assert.That(rc,Is.TypeOf(typeof(FormPageBuilder))); + } + + + + [SetUp] + public void LoadFromStream() + { + var asm = Assembly.GetExecutingAssembly(); + stream = asm.GetManifestResourceStream(TestHelper.PlainReportFileName); + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Reportingfactory/GeneralReportLoading.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Reportingfactory/GeneralReportLoading.cs new file mode 100644 index 0000000000..b1c1d5d25c --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Reportingfactory/GeneralReportLoading.cs @@ -0,0 +1,92 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.IO; +using System.Reflection; +using ICSharpCode.Reporting.Globals; +using NUnit.Framework; + +namespace ICSharpCode.Reporting.Test.Reportingfactory +{ + [TestFixture] + public class GeneralReportLoading + { + private Stream stream; + + [Test] + public void CanLoadFromResource() + { + Assert.IsNotNull(stream); + } + + + [Test] + public void LoadPlainModel() + { + var rf = new ReportingFactory(); + var model = rf.LoadReportModel(stream); + Assert.IsNotNull(model); + } + + + [Test] + public void ReportSettingsFromPlainModel() + { + var rf = new ReportingFactory(); + var model = rf.LoadReportModel(stream); + Assert.That(model.ReportSettings,Is.Not.Null); + } + + + [Test] + public void ReportSettingsReportName() + { + var rf = new ReportingFactory(); + var model = rf.LoadReportModel(stream); + Assert.That(model.ReportSettings.ReportName,Is.EqualTo(GlobalValues.DefaultReportName)); + } + + + [Test] + public void ReportSettingsDataModelFormSheet() + { + var rf = new ReportingFactory(); + var model = rf.LoadReportModel(stream); + Assert.That(model.ReportSettings.DataModel,Is.EqualTo(GlobalEnums.PushPullModel.FormSheet)); + } + + + [Test] + public void ReportSettingsPageSize() + { + var rf = new ReportingFactory(); + var model = rf.LoadReportModel(stream); + Assert.That(model.ReportSettings.PageSize,Is.EqualTo(Globals.GlobalValues.DefaultPageSize)); + } + + + + [SetUp] + public void LoadFromStream() + { + var asm = Assembly.GetExecutingAssembly(); + stream = asm.GetManifestResourceStream(TestHelper.PlainReportFileName); + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Reportingfactory/GroupedPushModel.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Reportingfactory/GroupedPushModel.cs new file mode 100644 index 0000000000..291988bfa1 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Reportingfactory/GroupedPushModel.cs @@ -0,0 +1,55 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System.Reflection; +using ICSharpCode.Reporting.Interfaces; +using ICSharpCode.Reporting.PageBuilder; +using ICSharpCode.Reporting.Test.DataSource; +using NUnit.Framework; + +namespace ICSharpCode.Reporting.Test.Reportingfactory +{ + [TestFixture] + public class GroupedPushModel + { + IReportCreator reportCreator; + + [Test] + public void TestMethod() + { + reportCreator.BuildExportList(); + // Only a test value + Assert.That(reportCreator.Pages.Count,Is.EqualTo(2)); + } + + + [SetUp] + public void LoadFromStream() + { + var contributorList = new ContributorsList(); + var list = contributorList.ContributorCollection; + + var asm = Assembly.GetExecutingAssembly(); + var stream = asm.GetManifestResourceStream(TestHelper.GroupedList); + + var reportingFactory = new ReportingFactory(); + var model = reportingFactory.LoadReportModel (stream); + reportCreator = new DataPageBuilder(model,list); + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Reportingfactory/PushModelFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Reportingfactory/PushModelFixture.cs new file mode 100644 index 0000000000..dbff31d260 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Reportingfactory/PushModelFixture.cs @@ -0,0 +1,187 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Reflection; + +using ICSharpCode.Reporting.Exporter; +using ICSharpCode.Reporting.Interfaces; +using ICSharpCode.Reporting.Interfaces.Export; +using ICSharpCode.Reporting.Items; +using ICSharpCode.Reporting.PageBuilder; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; +using ICSharpCode.Reporting.Test.DataSource; +using NUnit.Framework; + +namespace ICSharpCode.Reporting.Test.Reportingfactory +{ + [TestFixture] + public class PushModelFixture + { + + private IReportCreator reportCreator; + + + [Test] + public void DataSourceIsSet() { + var dataPageBuilder = new DataPageBuilder (new ReportModel(),new System.Collections.Generic.List()); + Assert.That(dataPageBuilder.List,Is.Not.Null); + } + + + [Test] + public void CanInitDataPageBuilder() + { + var dpb = new DataPageBuilder (new ReportModel(), + new System.Collections.Generic.List()); + Assert.That(dpb,Is.Not.Null); + } + + + [Test] + public void CanCreateReportCreatorFromList () { + var contributorList = new ContributorsList(); + var list = contributorList.ContributorCollection; + + var asm = Assembly.GetExecutingAssembly(); + var stream = asm.GetManifestResourceStream(TestHelper.ReportFromList); + + var reportingFactory = new ReportingFactory(); + var rc = reportingFactory.ReportCreator(stream,list); + Assert.That(rc,Is.Not.Null); + Assert.That(rc,Is.TypeOf(typeof(DataPageBuilder))); + } + + + [Test] + public void InitPushModelReport() + { + reportCreator.BuildExportList(); + Assert.That(reportCreator.Pages.Count,Is.GreaterThan(0)); + } + + + [Test] + public void PageContainsContainers() + { + reportCreator.BuildExportList(); + var exporteditems = reportCreator.Pages[0].ExportedItems; + var sections = from s in exporteditems + where s.GetType() == typeof(ExportContainer) + select s; + Assert.That(sections.ToList().Count,Is.GreaterThan(0)); +// var ex = new DebugExporter(reportCreator.Pages); +// ex.Run(); + } + + + [Test] + public void ReportContains_2_Pages () { + reportCreator.BuildExportList(); + Assert.That(reportCreator.Pages.Count,Is.EqualTo(2)); + } + + + [Test] + public void LastElementInEveryPageIsPageFooter() { + reportCreator.BuildExportList(); + + var firstPage = reportCreator.Pages[1].ExportedItems; + var firstElement = firstPage.Last(); + Assert.That(firstElement.Name,Is.EqualTo("ReportFooter")); + + var lastPage = reportCreator.Pages[1].ExportedItems; + var lastElement = lastPage.Last(); + Assert.That(lastElement.Name,Is.EqualTo("ReportFooter")); + } + + + [Test] + public void FirstElementOnSecondPageIsReportHeader() { + reportCreator.BuildExportList(); + var exporteditems = reportCreator.Pages[1].ExportedItems; + var result = exporteditems[0]; + Assert.That(result.Name,Is.EqualTo("ReportPageHeader")); + } + + + [Test] + public void RowsHasGapOfOne () { + reportCreator.BuildExportList(); + var exporteditems = reportCreator.Pages[0].ExportedItems; + for (int i = 1; i < exporteditems.Count -1; i++) { + Assert.That(exporteditems[i].Location.Y,Is.EqualTo(exporteditems[i-1].DisplayRectangle.Bottom +1)); + } + } + + + [Test] + public void DetailContainsOneDataItem() { + reportCreator.BuildExportList(); + var exporteditems = reportCreator.Pages[0].ExportedItems; + var sections = from s in exporteditems + where s.GetType() == typeof(ExportContainer) + select s; + var section = sections.ToList()[2] as ExportContainer; + var result = section.ExportedItems[0]; + Assert.That(result,Is.AssignableFrom(typeof(ExportText))); + } + + + [Test] + public void ParentOfSectionsIsPage() { + reportCreator.BuildExportList(); + var page = reportCreator.Pages[0]; + foreach (var element in page.ExportedItems) { + Assert.That(element.Parent,Is.Not.Null); + Assert.That(element.Parent,Is.AssignableTo(typeof(IPage))); + } + } + + + [Test] + public void HandleEmptyList () { + var asm = Assembly.GetExecutingAssembly(); + var stream = asm.GetManifestResourceStream(TestHelper.ReportFromList); + + var reportingFactory = new ReportingFactory(); + var model = reportingFactory.LoadReportModel (stream); + reportCreator = new DataPageBuilder(model,new List()); + reportCreator.BuildExportList(); + Assert.That(reportCreator.Pages[0].ExportedItems.Count,Is.EqualTo(4)); + } + + + [SetUp] + public void LoadFromStream() + { + var contributorList = new ContributorsList(); + var list = contributorList.ContributorCollection; + + var asm = Assembly.GetExecutingAssembly(); + var stream = asm.GetManifestResourceStream(TestHelper.ReportFromList); + + var reportingFactory = new ReportingFactory(); + var model = reportingFactory.LoadReportModel (stream); + reportCreator = new DataPageBuilder(model,list); + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/TestHelper.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/TestHelper.cs index 2137a8d55a..41d1a73c9f 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/TestHelper.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/TestHelper.cs @@ -28,17 +28,34 @@ namespace ICSharpCode.Reporting.Test /// public static class TestHelper { - private const string nameSpace = "ICSharpCode.Reporting.Test.src.TestReports."; - private const string plainReportName = "PlainModel.srd"; - private const string rr = "ReportWithTwoItems.srd"; - + const string nameSpace = "ICSharpCode.Reporting.Test.src.TestReports."; + const string plainReportName = "PlainModel.srd"; + const string withTwoItems = "ReportWithTwoItems.srd"; + const string fromList = "FromList.srd"; + const string groupedList = "GroupedList.srd"; + const string globalsTestReport = "TestForGlobals.srd"; public static string PlainReportFileName{ get{return nameSpace + plainReportName;} } + public static string RepWithTwoItems { - get {return nameSpace + rr;} + get {return nameSpace + withTwoItems;} + } + + + public static string ReportFromList { + get {return nameSpace + fromList;} + } + + public static string GroupedList { + get {return nameSpace + groupedList;} + } + + + public static string TestForGlobals { + get {return nameSpace + globalsTestReport;} } @@ -55,7 +72,6 @@ namespace ICSharpCode.Reporting.Test } ShowDebug(container); } else { -// var b = item as IAcceptor; if (acceptor != null) { acceptor.Accept(visitor); diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/TestReports/FromList.srd b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/TestReports/FromList.srd new file mode 100644 index 0000000000..82eaf62d9a --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/TestReports/FromList.srd @@ -0,0 +1,182 @@ + + + + + Report1 + DataReport + 50 + 50 + 50 + 50 + 827, 1169 + False + Millimeter + 5, 5, 5, 5 + + + + + + + + Text + PushData + No Data for this Report + Microsoft Sans Serif, 10pt + True + + + + + 50, 50 + 727, 60 + White + 0 + 0 + False + False + + + 313, 5 + 100, 20 + White + Microsoft Sans Serif, 10pt + None + TopLeft + False + False + System.String + No + Report1 + False + Black + Black + Report1 + + + Black + ReportHeader + + + 50, 125 + 727, 60 + White + 0 + 0 + False + False + + Black + ReportPageHeader + + + 50, 200 + 727, 60 + LightGray + 0 + 0 + False + False + + + 384, 13 + 100, 20 + White + Segoe UI, 9pt + #,##0.00 + None + MiddleRight + False + False + System.Decimal + No + BaseDataItem2 + False + Black + ControlText + RandomInt + BaseDataItem2 + + + 29, 14 + 100, 20 + White + Microsoft Sans Serif, 10pt + None + TopLeft + False + False + System.String + No + BaseDataItem1 + False + Black + Black + Firstname + BaseDataItem1 + + + LightGray + ReportDetail + + + 50, 275 + 727, 60 + White + 0 + 0 + False + False + + + 622, 5 + 100, 20 + White + Microsoft Sans Serif, 10pt + None + TopLeft + False + False + System.String + No + =Globals!PageNumber + False + Black + Black + PageNumber1 + + + Black + ReportPageFooter + + + 50, 350 + 727, 60 + White + 0 + 0 + False + False + + + 298, 4 + 100, 20 + White + Segoe UI, 9pt + None + TopLeft + False + False + No + = sum('RandomInt') + False + Black + ControlText + BaseTextItem2147483646 + + + Black + ReportFooter + + + \ No newline at end of file diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/TestReports/GroupedList.srd b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/TestReports/GroupedList.srd new file mode 100644 index 0000000000..757350cc95 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/TestReports/GroupedList.srd @@ -0,0 +1,219 @@ + + + + + Report1 + DataReport + 50 + 50 + 50 + 50 + 827, 1169 + False + Millimeter + 5, 5, 5, 5 + + + + + Ascending + GroupItem + System.String + + + + + + + Text + PushData + No Data for this Report + Microsoft Sans Serif, 10pt + True + + + + + 50, 50 + 727, 60 + White + 0 + 0 + False + False + + + 313, 5 + 100, 20 + White + Microsoft Sans Serif, 10pt + None + TopLeft + False + False + System.String + No + Report1 + False + Black + Black + Report1 + + + Black + ReportHeader + + + 50, 125 + 727, 60 + White + 0 + 0 + False + False + + Black + ReportPageHeader + + + 50, 200 + 727, 100 + LightGray + 0 + 0 + False + False + + + 38, 20 + 473, 30 + White + False + ControlText + Black + + + 21, 4 + 100, 20 + White + Segoe UI, 9pt + None + TopLeft + False + False + No + BaseDataItem3 + False + Black + ControlText + GroupItem + BaseDataItem3 + + + + 0 + False + GroupHeader1 + + + 289, 56 + 100, 20 + White + Segoe UI, 9pt + #,##0.00 + None + MiddleRight + False + False + System.Decimal + No + BaseDataItem2 + False + Black + ControlText + RandomInt + BaseDataItem2 + + + 75, 56 + 100, 20 + White + Microsoft Sans Serif, 10pt + None + TopLeft + False + False + System.String + No + BaseDataItem1 + False + Black + Black + Firstname + BaseDataItem1 + + + LightGray + ReportDetail + + + 50, 315 + 727, 60 + White + 0 + 0 + False + False + + + 622, 5 + 100, 20 + White + Microsoft Sans Serif, 10pt + None + TopLeft + False + False + System.String + No + =Globals!PageNumber + False + Black + Black + PageNumber1 + + + Black + ReportPageFooter + + + 50, 390 + 727, 60 + White + 0 + 0 + False + False + + + 298, 4 + 100, 20 + White + Segoe UI, 9pt + None + TopLeft + False + False + No + = sum('RandomInt') + False + Black + ControlText + BaseTextItem2147483646 + + + Black + ReportFooter + + + \ No newline at end of file diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/TestReports/PlainModel.srd b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/TestReports/PlainModel.srd new file mode 100644 index 0000000000..d6306dd40f --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/TestReports/PlainModel.srd @@ -0,0 +1,86 @@ + + + + + Microsoft Sans Serif, 10pt + FormSheet + D:\SharpDevelop3.0_CHECKOUT\SharpDevelop\bin\Raaaaaeport1.srd + 50 + True + + + No Data for this Report + 50 + 827, 1169 + 5, 5, 5, 5 + 50 + Text + + False + Report1 + 50 + + Millimeter + + FormSheet + + + + + + 727, 60 + ReportHeader + False + 0 + 0 + White + + 50, 50 + False + + + 727, 60 + ReportPageHeader + False + 0 + 0 + White + + 50, 125 + False + + + 727, 60 + ReportDetail + False + 0 + 0 + White + + 50, 200 + False + + + 727, 60 + ReportPageFooter + False + 0 + 0 + White + + 50, 275 + False + + + 727, 60 + ReportFooter + False + 0 + 0 + White + + 50, 350 + False + + + \ No newline at end of file diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/TestReports/ReportWithTwoItems.srd b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/TestReports/ReportWithTwoItems.srd index 76739e303c..74d55d6d2c 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/TestReports/ReportWithTwoItems.srd +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/TestReports/ReportWithTwoItems.srd @@ -66,22 +66,35 @@ False False - - 26, 22 - 100, 20 + + 149, 22 + 310, 30 White - Microsoft Sans Serif, 10pt - None - TopLeft - True - False - No - TestText for Item in PageHeader False + ControlText Black - Black - BaseTextItem2147483646 - + + + 13, 7 + 100, 20 + White + Microsoft Sans Serif, 10pt + None + TopLeft + True + False + No + TestText for Item in PageHeader + False + Black + Black + BaseTextItem2147483646 + + + + 0 + BaseRowItem1 + Black ReportPageHeader @@ -118,7 +131,7 @@ False System.String No - =Globals!PageNumber + ='Page ' + Globals!PageNumber False Black Black diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/TestReports/TestForGlobals.srd b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/TestReports/TestForGlobals.srd new file mode 100644 index 0000000000..3581112111 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/TestReports/TestForGlobals.srd @@ -0,0 +1,193 @@ + + + + + Report1 + FormSheet + 50 + 50 + 50 + 50 + 827, 1169 + False + Millimeter + 5, 5, 5, 5 + + + + + + + + Text + FormSheet + No Data for this Report + Microsoft Sans Serif, 10pt + True + + + + + 50, 50 + 727, 60 + White + 0 + 0 + False + False + + + 383, 17 + 277, 20 + White + Segoe UI, 9pt + None + TopLeft + False + False + No + = 'ReportFileName : ' + Globals!reportfilename + False + Black + ControlText + BaseTextItem2147483644 + + + 16, 17 + 264, 20 + White + Microsoft Sans Serif, 10pt + None + TopLeft + False + False + System.String + No + = 'ReportFolder :' + Globals!ReportFolder + False + Black + Black + Report1 + + + Black + ReportHeader + + + 50, 125 + 727, 60 + White + 0 + 0 + False + False + + + 16, 4 + 264, 20 + White + Segoe UI, 9pt + None + TopLeft + False + False + No + ='Pages ' + Globals!Pages + False + Black + ControlText + BaseTextItem2147483646 + + + Black + ReportPageHeader + + + 50, 200 + 727, 60 + White + 0 + 0 + False + False + + + 16, 4 + 264, 20 + White + Segoe UI, 9pt + None + TopLeft + False + False + No + = 'ReportName : ' + Globals!ReportName + False + Black + ControlText + BaseTextItem2147483645 + + + Black + ReportDetail + + + 50, 275 + 727, 60 + White + 0 + 0 + False + False + + + 16, 4 + 176, 20 + White + Segoe UI, 9pt + None + TopLeft + False + False + No + =Globals!SyntaxError + False + Black + ControlText + BaseTextItem2147483646 + + + 499, 5 + 223, 20 + White + Microsoft Sans Serif, 10pt + None + TopLeft + False + False + System.String + No + ='Page ' + Globals!PageNumber + False + Black + Black + PageNumber1 + + + Black + ReportPageFooter + + + 50, 350 + 727, 60 + White + 0 + 0 + False + False + + Black + ReportFooter + + + \ No newline at end of file diff --git a/src/AddIns/Misc/Reporting/Libraries/Irony.Interpreter.dll b/src/AddIns/Misc/Reporting/Libraries/Irony.Interpreter.dll new file mode 100644 index 0000000000..63c5a3e20d Binary files /dev/null and b/src/AddIns/Misc/Reporting/Libraries/Irony.Interpreter.dll differ diff --git a/src/AddIns/Misc/Reporting/Libraries/Irony.dll b/src/AddIns/Misc/Reporting/Libraries/Irony.dll new file mode 100644 index 0000000000..64ef17359a Binary files /dev/null and b/src/AddIns/Misc/Reporting/Libraries/Irony.dll differ diff --git a/src/AddIns/Misc/Reporting/Libraries/PdfSharp.dll b/src/AddIns/Misc/Reporting/Libraries/PdfSharp.dll new file mode 100644 index 0000000000..2b54688a52 Binary files /dev/null and b/src/AddIns/Misc/Reporting/Libraries/PdfSharp.dll differ diff --git a/src/AddIns/Misc/Reporting/Packages/Irony/Irony_2013_09_24.zip b/src/AddIns/Misc/Reporting/Packages/Irony/Irony_2013_09_24.zip new file mode 100644 index 0000000000..29d33dae7e Binary files /dev/null and b/src/AddIns/Misc/Reporting/Packages/Irony/Irony_2013_09_24.zip differ diff --git a/src/AddIns/Misc/Reporting/Packages/PdfSharp/PDFSharp-MigraDocFoundation-1_32.zip b/src/AddIns/Misc/Reporting/Packages/PdfSharp/PDFSharp-MigraDocFoundation-1_32.zip new file mode 100644 index 0000000000..10dd0ec1b7 Binary files /dev/null and b/src/AddIns/Misc/Reporting/Packages/PdfSharp/PDFSharp-MigraDocFoundation-1_32.zip differ diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/ICSharpCode.ReportDesigner.addin b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/ICSharpCode.ReportDesigner.addin index 60b527d591..f74a282607 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/ICSharpCode.ReportDesigner.addin +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/ICSharpCode.ReportDesigner.addin @@ -4,38 +4,38 @@ description = "Reporting Tool For SharpDevelop" addInManagerHidden = "preinstalled"> - + + - + - + @@ -182,14 +182,15 @@ label="${res:SharpReport.FieldsExplorer.Parameters}" class="ICSharpCode.Reports.Addin.Commands.ParameterEditorCommand"/> + - + diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/ICSharpCode.Reports.Addin.csproj b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/ICSharpCode.Reports.Addin.csproj index 9a7f744bf8..cd246e1c41 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/ICSharpCode.Reports.Addin.csproj +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/ICSharpCode.Reports.Addin.csproj @@ -119,10 +119,7 @@ - Always - - - Always + Never @@ -260,6 +257,7 @@ ReportViewerSecondaryView.cs + @@ -336,7 +334,6 @@ {4B2239FF-8FD6-431D-9D22-1B8049BA6917} ICSharpCode.Reports.Core - False diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Commands/ViewCommands.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Commands/ViewCommands.cs index 3aaaaaf7eb..26e2b2742e 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Commands/ViewCommands.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Commands/ViewCommands.cs @@ -50,7 +50,6 @@ namespace ICSharpCode.Reports.Addin.Commands } - public class CollectParametersCommand :AbstractCommand { readonly ReportSettings reportSettings; diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Designer/ImageDesigner.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Designer/ImageDesigner.cs index 531bc5c47b..d3d9f9e78f 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Designer/ImageDesigner.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Designer/ImageDesigner.cs @@ -19,7 +19,6 @@ using System; using System.ComponentModel; using System.ComponentModel.Design; -using System.Windows.Forms; using System.Windows.Forms.Design; namespace ICSharpCode.Reports.Addin.Designer @@ -30,8 +29,8 @@ namespace ICSharpCode.Reports.Addin.Designer /// public class ImageDesigner:ControlDesigner { - private ISelectionService selectionService; - private IComponentChangeService componentChangeService; + ISelectionService selectionService; + IComponentChangeService componentChangeService; public ImageDesigner() { diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/DesignerBinding/ReportDesignerDisplayBinding.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/DesignerBinding/ReportDesignerDisplayBinding.cs index 9f6bd9d4c5..e14154a9f0 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/DesignerBinding/ReportDesignerDisplayBinding.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/DesignerBinding/ReportDesignerDisplayBinding.cs @@ -53,6 +53,7 @@ namespace ICSharpCode.Reports.Addin return viewCmd.DesignerView; } + public bool IsPreferredBindingForFile(ICSharpCode.Core.FileName fileName) { return true; diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/DesignerBinding/ReportDesignerGenerator.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/DesignerBinding/ReportDesignerGenerator.cs index 9fb085756d..1d3b284d55 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/DesignerBinding/ReportDesignerGenerator.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/DesignerBinding/ReportDesignerGenerator.cs @@ -111,6 +111,7 @@ namespace ICSharpCode.Reports.Addin foreach (IComponent component in viewContent.Host.Container.Components) { BaseSection b = component as BaseSection; if (b != null) { + Console.WriteLine(b.BackColor.ToString()); rpd.Save(component,xml); } } diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/ReportDesignerView.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/ReportDesignerView.cs index 0bc75ae00d..646327c5b4 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/ReportDesignerView.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/ReportDesignerView.cs @@ -28,18 +28,18 @@ using System.Text; using System.Windows.Forms; using ICSharpCode.Core; -using ICSharpCode.Reports.Addin.Commands; -using ICSharpCode.Reports.Addin.Designer; -using ICSharpCode.Reports.Addin.SecondaryViews; - using ICSharpCode.Reports.Core; using ICSharpCode.Reports.Core.Exporter; using ICSharpCode.Reports.Core.Exporter.ExportRenderer; + using ICSharpCode.Reports.Core.Globals; using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.WinForms; using ICSharpCode.SharpDevelop.Workbench; +using ICSharpCode.Reports.Addin.Commands; +using ICSharpCode.Reports.Addin.Designer; +using ICSharpCode.Reports.Addin.SecondaryViews; namespace ICSharpCode.Reports.Addin { @@ -49,26 +49,22 @@ namespace ICSharpCode.Reports.Addin public class ReportDesignerView : AbstractViewContent, IHasPropertyContainer, IClipboardHandler,IUndoHandler, IToolsHost,IPrintable { - - private bool IsFormsDesignerVisible; - private bool tabOrderMode; - private bool hasUnmergedChanges; - private bool unloading; - - private string reportFileContent; - - private Panel panel; - private ReportDesignerLoader loader; - - private IDesignerGenerator generator; - private DesignSurface designSurface; - private DefaultServiceContainer defaultServiceContainer; - private ReportDesignerUndoEngine undoEngine; - - private XmlView xmlView; - private ReportPreview reportPreview; - private ReportViewerSecondaryView reportViewer; -// private TestWPFReportPreview testView; + readonly IDesignerGenerator generator; + bool IsFormsDesignerVisible; + bool tabOrderMode; + bool hasUnmergedChanges; + bool unloading; + string reportFileContent; + Panel panel; + ReportDesignerLoader loader; + DesignSurface designSurface; + DefaultServiceContainer defaultServiceContainer; + ReportDesignerUndoEngine undoEngine; + + XmlView xmlView; + ReportPreview reportPreview; + ReportViewerSecondaryView reportViewer; +// TestWPFReportPreview testView; #region Constructor @@ -79,14 +75,16 @@ namespace ICSharpCode.Reports.Addin public ReportDesignerView(OpenedFile openedFile, IDesignerGenerator generator):base (openedFile) { if (openedFile == null) { - throw new ArgumentNullException("opendFile"); + throw new ArgumentNullException("openedFile"); } if (generator == null) { throw new ArgumentNullException("generator"); } Console.WriteLine("ReportDesignerView"); + this.generator = generator; this.generator.Attach(this); + base.TabPageText = ResourceService.GetString("SharpReport.Design"); ReportingSideTabProvider.AddViewContent(this); } @@ -104,8 +102,7 @@ namespace ICSharpCode.Reports.Addin private void SetupSecondaryView () { - Console.WriteLine("SetupSecondaryView ()"); - + LoggingService.Info("Form Designer: SetupSecondaryView "); xmlView = new XmlView(generator,this); SecondaryViewContents.Add(xmlView); @@ -115,8 +112,8 @@ namespace ICSharpCode.Reports.Addin reportViewer = new ReportViewerSecondaryView(loader,this); SecondaryViewContents.Add(reportViewer); -// var wpfViewer = new WPFReportPreview(loader,this); -// SecondaryViewContents.Add(wpfViewer); + var wpfViewer = new WPFReportPreview(loader,this); + SecondaryViewContents.Add(wpfViewer); // testView = new TestWPFReportPreview(loader,this); // SecondaryViewContents.Add(testView); @@ -129,8 +126,7 @@ namespace ICSharpCode.Reports.Addin private void LoadDesigner(Stream stream) { - Console.WriteLine("LoadDesigner(Stream stream)"); - LoggingService.Info("Form Designer: BEGIN INITIALIZE"); + LoggingService.Info("Form Designer: LoadDesigner"); CreatePanel(); defaultServiceContainer = new DefaultServiceContainer(); @@ -260,7 +256,7 @@ namespace ICSharpCode.Reports.Addin private static string FormatLoadErrors(DesignSurface designSurface) { - StringBuilder sb = new StringBuilder(); + var sb = new StringBuilder(); foreach(Exception le in designSurface.LoadErrors) { sb.AppendLine(le.ToString()); sb.AppendLine(); @@ -272,8 +268,7 @@ namespace ICSharpCode.Reports.Addin private void MergeFormChanges() { LoggingService.Info("MergeFormChanges()"); - System.Diagnostics.Trace.WriteLine("View:MergeFormChanges()"); - this.designSurface.Flush(); + designSurface.Flush(); generator.MergeFormChanges(null); LoggingService.Info("Finished merging form changes"); hasUnmergedChanges = false; @@ -303,7 +298,7 @@ namespace ICSharpCode.Reports.Addin private void ReportExplorer_PropertyChanged (object sender,System.ComponentModel.PropertyChangedEventArgs e) { - Console.WriteLine("ReportExplorer_PropertyChanged"); + LoggingService.Info("ReportExplorer_PropertyChanged"); this.MakeDirty(); ReportExplorerPad explorerPad = CheckReportExplorer(); IComponentChangeService change = Host.GetService(typeof(IComponentChangeService)) as IComponentChangeService; @@ -326,11 +321,11 @@ namespace ICSharpCode.Reports.Addin private void SelectionChangedHandler(object sender, EventArgs args) { - ISelectionService ser = (ISelectionService)sender; - AbstractItem it = ser.PrimarySelection as AbstractItem; - if (it != null) { - if (String.IsNullOrEmpty(it.Site.Name)) { - it.Site.Name = it.Name; + var selectionService = (ISelectionService)sender; + var item = selectionService.PrimarySelection as AbstractItem; + if (item != null) { + if (String.IsNullOrEmpty(item.Site.Name)) { + item.Site.Name = item.Name; } } UpdatePropertyPadSelection((ISelectionService)sender); @@ -345,10 +340,7 @@ namespace ICSharpCode.Reports.Addin void TransactionClose(object sender, DesignerTransactionCloseEventArgs e) { if (shouldUpdateSelectableObjects) { - // update the property pad after the transaction is *really* finished - // (including updating the selection) -// WorkbenchSingleton.SafeThreadAsyncCall(UpdatePropertyPad); - SD.MainThread.InvokeAsync(null).FireAndForget(); + SD.MainThread.InvokeAsync(UpdatePropertyPad).FireAndForget(); shouldUpdateSelectableObjects = false; } } @@ -360,7 +352,7 @@ namespace ICSharpCode.Reports.Addin private void OnComponentChanged (object sender, ComponentChangedEventArgs e) { - BaseImageItem item = e.Component as BaseImageItem; + var item = e.Component as BaseImageItem; if (item != null) { item.ReportFileName = this.loader.ReportModel.ReportSettings.FileName; @@ -399,8 +391,8 @@ namespace ICSharpCode.Reports.Addin { Console.WriteLine("UpdatePropertyPad()"); if (IsFormsDesignerVisible && Host != null) { - propertyContainer.Host = Host; - propertyContainer.SelectableObjects = Host.Container.Components; + PropertyContainer.Host = Host; + PropertyContainer.SelectableObjects = Host.Container.Components; ISelectionService selectionService = (ISelectionService)this.designSurface.GetService(typeof(ISelectionService)); if (selectionService != null) { UpdatePropertyPadSelection(selectionService); @@ -414,7 +406,7 @@ namespace ICSharpCode.Reports.Addin ICollection selection = selectionService.GetSelectedComponents(); object[] selArray = new object[selection.Count]; selection.CopyTo(selArray, 0); - propertyContainer.SelectedObjects = selArray; + PropertyContainer.SelectedObjects = selArray; } @@ -422,7 +414,6 @@ namespace ICSharpCode.Reports.Addin #region IHasPropertyContainer impementation -// PropertyContainer propertyContainer = new PropertyContainer(); PropertyContainer propertyContainer; public PropertyContainer PropertyContainer { @@ -640,9 +631,9 @@ namespace ICSharpCode.Reports.Addin public void TogglePageMargin () { - IDesignerHost h = (IDesignerHost)this.designSurface.GetService(typeof(IDesignerHost)); - RootReportModel r = (RootReportModel)h.RootComponent; - r.Toggle(); + IDesignerHost designerHost = (IDesignerHost)this.designSurface.GetService(typeof(IDesignerHost)); + RootReportModel rootReportModel = (RootReportModel)designerHost.RootComponent; + rootReportModel.Toggle(); } #endregion @@ -658,7 +649,7 @@ namespace ICSharpCode.Reports.Addin public virtual void ShowTabOrder() { if (!IsTabOrderMode) { - IMenuCommandService menuCommandService = (IMenuCommandService)designSurface.GetService(typeof(IMenuCommandService)); + var menuCommandService = (IMenuCommandService)designSurface.GetService(typeof(IMenuCommandService)); menuCommandService.GlobalInvoke(StandardCommands.TabOrder); tabOrderMode = true; } @@ -667,7 +658,7 @@ namespace ICSharpCode.Reports.Addin public virtual void HideTabOrder() { if (IsTabOrderMode) { - IMenuCommandService menuCommandService = (IMenuCommandService)designSurface.GetService(typeof(IMenuCommandService)); + var menuCommandService = (IMenuCommandService)designSurface.GetService(typeof(IMenuCommandService)); menuCommandService.GlobalInvoke(StandardCommands.TabOrder); tabOrderMode = false; } diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/SecondaryViews/TestView/TestWPFReportPreview.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/SecondaryViews/TestView/TestWPFReportPreview.cs deleted file mode 100644 index 024bbf915f..0000000000 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/SecondaryViews/TestView/TestWPFReportPreview.cs +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of this -// software and associated documentation files (the "Software"), to deal in the Software -// without restriction, including without limitation the rights to use, copy, modify, merge, -// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons -// to whom the Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all copies or -// substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE -// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -using System; -using System.Collections.ObjectModel; -using System.Xml; - -using ICSharpCode.Reporting; -using ICSharpCode.Reporting.BaseClasses; -using ICSharpCode.Reporting.Exporter; -using ICSharpCode.Reporting.Globals; -using ICSharpCode.Reporting.Interfaces; -using ICSharpCode.Reporting.Interfaces.Export; -using ICSharpCode.Reporting.Items; -using ICSharpCode.Reporting.WpfReportViewer; -using ICSharpCode.Reporting.Xml; -using ICSharpCode.SharpDevelop; -using ICSharpCode.SharpDevelop.Gui; -using ICSharpCode.SharpDevelop.Workbench; - -//using ICSharpCode.Reports.Addin.Commands; -//using ICSharpCode.Reports.Core; -//using ICSharpCode.Reports.Core.Exporter.ExportRenderer; -//using ICSharpCode.Reports.Core.Globals; -//using ICSharpCode.Reports.Core.WpfReportViewer; - - - - -namespace ICSharpCode.Reports.Addin.SecondaryViews -{ - /// - /// Description of WPFReportPreview. - /// - public class TestWPFReportPreview: AbstractSecondaryViewContent - { - ReportDesignerLoader designerLoader; - - ICSharpCode.Reporting.WpfReportViewer.IWpfReportViewer viewer; - -// IExportRunner exportRunner = new ExportRunner(); - - public TestWPFReportPreview(ReportDesignerLoader loader,IViewContent content):base(content) - { - this.designerLoader = loader; - viewer = new ICSharpCode.Reporting.WpfReportViewer.WpfReportViewer(); - base.TabPageText = "TestWpf View"; - Pages = new Collection(); - } - - - public Collection Pages{get;private set;} - - - protected override void LoadFromPrimary() - { - Pages.Clear(); - var xmDoc = designerLoader.CreateXmlModel(); - var modulLoader = new ModelLoader(); - ReportModel model = (ReportModel)modulLoader.Load(xmDoc.DocumentElement); - - var reportingFactory = new ReportingFactory(); - var reportCreator = reportingFactory.ReportCreator(model); - reportCreator.BuildExportList(); - - PreviewViewModel previewViewModel = new PreviewViewModel (model.ReportSettings,reportCreator.Pages); - viewer.SetBinding(previewViewModel); - } - - protected override void SaveToPrimary() - { -// throw new NotImplementedException(); - } - - - public override object Control { - get { - return viewer; - } - } - } -} diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/SecondaryViews/WPFReportPreview.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/SecondaryViews/WPFReportPreview.cs index fed724e132..62844968cc 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/SecondaryViews/WPFReportPreview.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/SecondaryViews/WPFReportPreview.cs @@ -17,14 +17,12 @@ // DEALINGS IN THE SOFTWARE. using System; -using ICSharpCode.Reporting.Xml; using ICSharpCode.Reports.Addin.Commands; using ICSharpCode.Reports.Core; using ICSharpCode.Reports.Core.Exporter.ExportRenderer; using ICSharpCode.Reports.Core.Globals; using ICSharpCode.Reports.Core.WpfReportViewer; using ICSharpCode.SharpDevelop; -using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Workbench; namespace ICSharpCode.Reports.Addin.SecondaryViews diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseItems/Graphics/BaseImageItem.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseItems/Graphics/BaseImageItem.cs index 19f79c0b38..b11f3c11c0 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseItems/Graphics/BaseImageItem.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseItems/Graphics/BaseImageItem.cs @@ -16,13 +16,6 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -/// -/// Handles the drawing of Images like Bitmap's and so on -/// -/// -/// created by - Forstmeier Peter -/// created on - 04.10.2005 11:17:29 -/// using System; using System.Drawing; using System.Globalization; diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Events/PrintEventArgs.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Events/PrintEventArgs.cs index 3fad2cc8c1..bf40d973c4 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Events/PrintEventArgs.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Events/PrintEventArgs.cs @@ -20,14 +20,7 @@ using System; using System.Drawing; - /// - /// Handles BeforPrint and AfterPrint Events - /// - /// - /// created by - Forstmeier Peter - /// created on - 22.11.2004 13:06:44 - /// - + namespace ICSharpCode.Reports.Core { public class SectionEventArgs : EventArgs diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/ExportColumns/ExportText.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/ExportColumns/ExportText.cs index 07995c522a..a07a64b255 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/ExportColumns/ExportText.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/ExportColumns/ExportText.cs @@ -140,6 +140,7 @@ namespace ICSharpCode.Reports.Core.Exporter { } + internal class CalculatePdfFormat { public static int PdfAlignment(TextStyleDecorator textDecorator) diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Globals/GlobalLists.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Globals/GlobalLists.cs index f415ba22fc..bc16fe66c5 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Globals/GlobalLists.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Globals/GlobalLists.cs @@ -81,7 +81,8 @@ namespace ICSharpCode.Reports.Core.Globals "System.DateTime", "System.TimeSpan", "System.Decimal", - "System.Int"}; + "System.Int16", + "System.Int32"}; #endregion #region Aggregates diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/WPF/FixedDocumentCreator.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/WPF/FixedDocumentCreator.cs index d2a24d5407..831ad4afc8 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/WPF/FixedDocumentCreator.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/WPF/FixedDocumentCreator.cs @@ -94,19 +94,19 @@ namespace ICSharpCode.Reports.Core.WPF var text = column as ExportText; if (text != null) { - var t = CreateTextBlock(text); + var textBlock = CreateTextBlock(text); if (column.StyleDecorator.DrawBorder) { border = CreateBorder(column.StyleDecorator as BaseStyleDecorator, GlobalValues.DefaultBorderThickness, GlobalValues.DefaultCornerRadius ); - border.Child = t; + border.Child = textBlock; element = border; } else { - element = t; + element = textBlock; } } diff --git a/src/Setup/Files.wxs b/src/Setup/Files.wxs index d0d88da2eb..dd9e6d9e24 100644 --- a/src/Setup/Files.wxs +++ b/src/Setup/Files.wxs @@ -1485,26 +1485,25 @@ - + diff --git a/src/Setup/Setup.wxs b/src/Setup/Setup.wxs index 9e03485954..dbdbd1846b 100644 --- a/src/Setup/Setup.wxs +++ b/src/Setup/Setup.wxs @@ -448,12 +448,11 @@ - + diff --git a/src/Tools/CheckFileHeaders/Main.cs b/src/Tools/CheckFileHeaders/Main.cs index 0f4021f51d..f0a7a623d9 100644 --- a/src/Tools/CheckFileHeaders/Main.cs +++ b/src/Tools/CheckFileHeaders/Main.cs @@ -118,9 +118,7 @@ namespace CheckFileHeaders string content = GetFileContent(file); int lastLine; int headerType = AnalyzeHeader(content, out lastLine); - if (headerType == 8 || headerType == 9) - return; - if (headerType != 7) + if (headerType == 0 || headerType == 8 || headerType == 9) return; if (headerType == 4) { Console.WriteLine("unknown file: " + file);