-
Notifications
You must be signed in to change notification settings - Fork 662
Expand file tree
/
Copy pathReport.cs
More file actions
2545 lines (2317 loc) · 88.3 KB
/
Report.cs
File metadata and controls
2545 lines (2317 loc) · 88.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using FastReport.Code;
using FastReport.CrossView;
using FastReport.Data;
using FastReport.Dialog;
using FastReport.Engine;
using FastReport.Export;
using FastReport.Utils;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Text;
using System.IO;
using System.Security;
using System.Text;
namespace FastReport
{
/// <summary>
/// Specifies the language of the report's script.
/// </summary>
public enum Language
{
/// <summary>
/// The C# language.
/// </summary>
CSharp,
/// <summary>
/// The VisualBasic.Net language.
/// </summary>
Vb
}
/// <summary>
/// Specifies the quality of text rendering.
/// </summary>
public enum TextQuality
{
/// <summary>
/// The default text quality, depends on system settings.
/// </summary>
Default,
/// <summary>
/// The regular quality.
/// </summary>
Regular,
/// <summary>
/// The "ClearType" quality.
/// </summary>
ClearType,
/// <summary>
/// The AntiAlias quality. This mode may be used to produce the WYSIWYG text.
/// </summary>
AntiAlias,
/// <summary>
/// The "SingleBitPerPixel" quality.
/// </summary>
SingleBPP,
/// <summary>
/// The "SingleBitPerPixelGridFit" quality.
/// </summary>
SingleBPPGridFit
}
/// <summary>
/// Specifies the report operation.
/// </summary>
public enum ReportOperation
{
/// <summary>
/// Specifies no operation.
/// </summary>
None,
/// <summary>
/// The report is running.
/// </summary>
Running,
/// <summary>
/// The report is printing.
/// </summary>
Printing,
/// <summary>
/// The report is exporting.
/// </summary>
Exporting
}
/// <summary>
/// Specifies the page range to print/export.
/// </summary>
public enum PageRange
{
/// <summary>
/// Print all pages.
/// </summary>
All,
/// <summary>
/// Print current page.
/// </summary>
Current,
/// <summary>
/// Print pages specified in the <b>PageNumbers</b> property of the <b>PrintSettings</b>.
/// </summary>
PageNumbers
}
/// <summary>
/// Represents a report object.
/// </summary>
/// <remarks>
/// <para>The instance of this class contains a report. Here are some common
/// actions that can be performed with this object:</para>
/// <list type="bullet">
/// <item>
/// <description>To load a report, use the <see cref="Load(string)"/>
/// method or call static <see cref="FromFile"/> method. </description>
/// </item>
/// <item>
/// <description>To save a report, call the <see cref="Save(string)"/> method.</description>
/// </item>
/// <item>
/// <description>To register application dataset for use it in a report, call one of the
/// <b>RegisterData</b> methods.</description>
/// </item>
/// <item>
/// <description>To pass some parameter to a report, use the
/// <see cref="SetParameterValue"/> method.</description>
/// </item>
/// <item>
/// <description>To design a report, call the <see cref="Design()"/> method.</description>
/// </item>
/// <item>
/// <description>To run a report and preview it, call the <see cref="Show()"/> method.
/// Another way is to call the <see cref="Prepare()"/> method, then call the
/// <see cref="ShowPrepared()"/> method.</description>
/// </item>
/// <item>
/// <description>To run a report and print it, call the <see cref="Print"/> method.
/// Another way is to call the <see cref="Prepare()"/> method, then call the
/// <see cref="PrintPrepared()"/> method.</description>
/// </item>
/// <item>
/// <description>To load/save prepared report, use one of the <b>LoadPrepared</b> and
/// <b>SavePrepared</b> methods.</description>
/// </item>
/// <item>
/// <description>To set up some global properties, use the <see cref="Config"/> static class
/// or <see cref="EnvironmentSettings"/> component that you can use in the Visual Studio IDE.
/// </description>
/// </item>
/// </list>
/// <para/>The report consists of one or several report pages (pages of the
/// <see cref="ReportPage"/> type) and/or dialog forms (pages of the <see cref="DialogPage"/> type).
/// They are stored in the <see cref="Pages"/> collection. In turn, each page may contain report
/// objects. See the example below how to create a simple report in code.
/// </remarks>
/// <example>This example shows how to create a report instance, load it from a file,
/// register the application data, run and preview.
/// <code>
/// Report report = new Report();
/// report.Load("reportfile.frx");
/// report.RegisterData(application_dataset);
/// report.Show();
/// </code>
/// <para/>This example shows how to create simple report in code.
/// <code>
/// Report report = new Report();
/// // create the report page
/// ReportPage page = new ReportPage();
/// page.Name = "ReportPage1";
/// // set paper width and height. Note: these properties are measured in millimeters.
/// page.PaperWidth = 210;
/// page.PaperHeight = 297;
/// // add a page to the report
/// report.Pages.Add(page);
/// // create report title
/// page.ReportTitle = new ReportTitleBand();
/// page.ReportTitle.Name = "ReportTitle1";
/// page.ReportTitle.Height = Units.Millimeters * 10;
/// // create Text object and put it to the title
/// TextObject text = new TextObject();
/// text.Name = "Text1";
/// text.Bounds = new RectangleF(0, 0, Units.Millimeters * 100, Units.Millimeters * 5);
/// page.ReportTitle.Objects.Add(text);
/// // create data band
/// DataBand data = new DataBand();
/// data.Name = "Data1";
/// data.Height = Units.Millimeters * 10;
/// // add data band to a page
/// page.Bands.Add(data);
/// </code>
/// </example>
public partial class Report : Base, IParent, ISupportInitialize
{
#region Fields
private PageCollection pages;
private Dictionary dictionary;
private ReportInfo reportInfo;
private string baseReport;
private Report baseReportObject;
private string fileName;
private string scriptText;
private Language scriptLanguage;
private bool compressed;
private bool useFileCache;
private TextQuality textQuality;
private bool smoothGraphics;
private string password;
private bool convertNulls;
private bool doublePass;
private bool autoFillDataSet;
private int initialPageNumber;
private int maxPages;
private string startReportEvent;
private string finishReportEvent;
private StyleCollection styles;
private CodeHelperBase codeHelper;
private GraphicCache graphicCache;
private string[] referencedAssemblies;
private Hashtable cachedDataItems;
private AssemblyCollection assemblies;
private FastReport.Preview.PreparedPages preparedPages;
private ReportEngine engine;
private bool aborted;
private bool modified;
private Bitmap measureBitmap;
private Graphics measureGraphics;
private bool storeInResources;
private PermissionSet scriptRestrictions;
private ReportOperation operation;
private int tickCount;
private bool needCompile;
private bool needRefresh;
private bool initializing;
private object initializeData;
private string initializeDataName;
private object tag;
#endregion Fields
#region Properties
/// <summary>
/// Occurs when calc execution is started.
/// </summary>
public event CustomCalcEventHandler CustomCalc;
/// <summary>
/// Occurs when report is inherited and trying to load a base report.
/// </summary>
/// <remarks>
/// Typical use of this event is to load the base report from a database instead of a file.
/// </remarks>
public event CustomLoadEventHandler LoadBaseReport;
/// <summary>
/// Occurs when report execution is started.
/// </summary>
public event EventHandler StartReport;
/// <summary>
/// Occurs when report execution is finished.
/// </summary>
public event EventHandler FinishReport;
/// <summary>
/// Occurs before export to set custom export parameters.
/// </summary>
public event EventHandler<ExportParametersEventArgs> ExportParameters;
/// <summary>
/// Gets the pages contained in this report.
/// </summary>
/// <remarks>
/// This property contains pages of all types (report and dialog). Use the <b>is/as</b> operators
/// if you want to work with pages of <b>ReportPage</b> type.
/// </remarks>
/// <example>The following code demonstrates how to access the first report page:
/// <code>
/// ReportPage page1 = report1.Pages[0] as ReportPage;
/// </code>
/// </example>
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public PageCollection Pages
{
get { return pages; }
}
/// <summary>
/// Gets the report's data.
/// </summary>
/// <remarks>
/// The dictionary contains all data items such as connections, data sources, parameters,
/// system variables.
/// </remarks>
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public Dictionary Dictionary
{
get { return dictionary; }
set
{
SetProp(dictionary, value);
dictionary = value;
}
}
/// <summary>
/// Gets the collection of report parameters.
/// </summary>
/// <remarks>
/// <para>Parameters are displayed in the "Data" window under the "Parameters" node.</para>
/// <para>Typical use of parameters is to pass some static data from the application to the report.
/// You can print such data, use it in the data row filter, script etc. </para>
/// <para>Another way to use parameters is to define some reusable piece of code, for example,
/// to define an expression that will return the concatenation of first and second employee name.
/// In this case, you set the parameter's <b>Expression</b> property to something like this:
/// [Employees.FirstName] + " " + [Employees.LastName]. Now this parameter may be used in the report
/// to print full employee name. Each time you access such parameter, it will calculate the expression
/// and return its value. </para>
/// <para>You can create nested parameters. To do this, add the new <b>Parameter</b> to the
/// <b>Parameters</b> collection of the root parameter. To access the nested parameter, you may use the
/// <see cref="GetParameter"/> method.</para>
/// <para>To get or set the parameter's value, use the <see cref="GetParameterValue"/> and
/// <see cref="SetParameterValue"/> methods. To set the parameter's expression, use the
/// <see cref="GetParameter"/> method that returns a <b>Parameter</b> object and set its
/// <b>Expression</b> property.</para>
/// </remarks>
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public ParameterCollection Parameters
{
get { return dictionary.Parameters; }
}
/// <summary>
/// Gets or sets the report information such as report name, author, description etc.
/// </summary>
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[SRCategory("Design")]
public ReportInfo ReportInfo
{
get { return reportInfo; }
set { reportInfo = value; }
}
/// <summary>
/// Gets or sets the base report file name.
/// </summary>
/// <remarks>
/// This property contains the name of a report file this report is inherited from.
/// <b>Note:</b> setting this property to non-empty value will clear the report and
/// load the base file into it.
/// </remarks>
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public string BaseReport
{
get { return baseReport; }
set { SetBaseReport(value); }
}
/// <summary>
/// Gets or sets the name of a file the report was loaded from.
/// </summary>
/// <remarks>
/// This property is used to support the FastReport.Net infrastructure;
/// typically you don't need to use it.
/// </remarks>
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public string FileName
{
get { return fileName; }
set { fileName = value; }
}
/// <summary>
/// Gets or sets the report script.
/// </summary>
/// <remarks>
/// <para>The script contains the <b>ReportScript</b> class that contains all report objects'
/// event handlers and own items such as private fields, properties, methods etc. The script
/// contains only items written by you. Unlike other report generators, the script does not
/// contain report objects declarations, initialization code. It is added automatically when
/// you run the report.</para>
/// <para>By default this property contains an empty script text. You may see it in the designer
/// when you switch to the Code window.</para>
/// <para>If you set this property programmatically, you have to declare the <b>FastReport</b>
/// namespace and the <b>ReportScript</b> class in it. Do not declare report items (such as bands,
/// objects, etc) in the <b>ReportScript</b> class: the report engine does this automatically when
/// you run the report.</para>
/// <para><b>Security note:</b> since the report script is compiled into .NET assembly, it allows
/// you to do ANYTHING. For example, you may create a script that will read/write files from/to a disk.
/// To restrict such operations, use the <see cref="ScriptRestrictions"/> property.</para>
/// </remarks>
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public string ScriptText
{
get { return scriptText; }
set { scriptText = value; }
}
/// <summary>
/// Gets or sets the script language of this report.
/// </summary>
/// <remarks>
/// Note: changing this property will reset the report script to default empty script.
/// </remarks>
[DefaultValue(Language.CSharp)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[SRCategory("Script")]
public Language ScriptLanguage
{
get { return scriptLanguage; }
set
{
bool needClear = scriptLanguage != value;
scriptLanguage = value;
if (scriptLanguage == Language.CSharp)
codeHelper = new CsCodeHelper(this);
else
codeHelper = new VbCodeHelper(this);
if (needClear)
scriptText = codeHelper.EmptyScript();
}
}
/// <summary>
/// Gets or sets a value indicating whether the null DB value must be converted to zero, false or
/// empty string depending on the data column type.
/// </summary>
/// <remarks>
/// This property is <b>true</b> by default. If you set it to <b>false</b>, you should check
/// the DB value before you do something with it (for example, typecast it to any type, use it
/// in a expression etc.)
/// </remarks>
[DefaultValue(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[SRCategory("Engine")]
public bool ConvertNulls
{
get { return convertNulls; }
set { convertNulls = value; }
}
/// <summary>
/// Gets or sets a value that specifies whether the report engine should perform the second pass.
/// </summary>
/// <remarks>
/// <para>Typically the second pass is necessary to print the number of total pages. It also
/// may be used to perform some calculations on the first pass and print its results on the
/// second pass.</para>
/// <para>Use the <b>Engine.FirstPass</b>, <b>Engine.FinalPass</b> properties to determine which
/// pass the engine is performing now.</para>
/// </remarks>
[DefaultValue(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[SRCategory("Engine")]
public bool DoublePass
{
get { return doublePass; }
set { doublePass = value; }
}
/// <summary>
/// Gets or sets a value that specifies whether to compress the report file.
/// </summary>
/// <remarks>
/// The report file is compressed using the Gzip algorithm. So you can open the
/// compressed report in any zip-compatible archiver.
/// </remarks>
[DefaultValue(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[SRCategory("Misc")]
public bool Compressed
{
get { return compressed; }
set { compressed = value; }
}
/// <summary>
/// Gets or sets a value that specifies whether to use the file cache rather than memory
/// to store the prepared report pages.
/// </summary>
[DefaultValue(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[SRCategory("Engine")]
public bool UseFileCache
{
get { return useFileCache; }
set { useFileCache = value; }
}
/// <summary>
/// Gets or sets a value that specifies the quality of text rendering.
/// </summary>
/// <remarks>
/// <b>Note:</b> the default property value is <b>TextQuality.Default</b>. That means the report
/// may look different depending on OS settings. This property does not affect the printout.
/// </remarks>
[DefaultValue(TextQuality.Default)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[SRCategory("Misc")]
public TextQuality TextQuality
{
get { return textQuality; }
set { textQuality = value; }
}
/// <summary>
/// Gets or sets a value that specifies if the graphic objects such as bitmaps
/// and shapes should be displayed smoothly.
/// </summary>
[DefaultValue(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[SRCategory("Misc")]
public bool SmoothGraphics
{
get { return smoothGraphics; }
set { smoothGraphics = value; }
}
/// <summary>
/// Gets or sets the report password.
/// </summary>
/// <remarks>
/// <para>When you try to load the password-protected report, you will be asked
/// for a password. You also may specify the password in this property before loading
/// the report. In this case the report will load silently.</para>
/// <para>Password-protected report file is crypted using Rijndael algorithm.
/// Do not forget your password! It will be hard or even impossible to open
/// the protected file in this case.</para>
/// </remarks>
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public string Password
{
get { return password; }
set { password = value; }
}
/// <summary>
/// Gets or sets a value indicating whether it is necessary to automatically fill
/// DataSet registered with <b>RegisterData</b> call.
/// </summary>
/// <remarks>
/// If this property is <b>true</b> (by default), FastReport will automatically fill
/// the DataSet with data when you trying to run a report. Set it to <b>false</b> if
/// you want to fill the DataSet by yourself.
/// </remarks>
[DefaultValue(true)]
[SRCategory("Misc")]
public bool AutoFillDataSet
{
get { return autoFillDataSet; }
set { autoFillDataSet = value; }
}
/// <summary>
/// Gets or sets the maximum number of generated pages in a prepared report.
/// </summary>
/// <remarks>
/// Use this property to limit the number of pages in a prepared report.
/// </remarks>
[DefaultValue(0)]
[SRCategory("Misc")]
public int MaxPages
{
get { return maxPages; }
set { maxPages = value; }
}
/// <summary>
/// Gets or sets the collection of styles used in this report.
/// </summary>
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[SRCategory("Misc")]
public StyleCollection Styles
{
get { return styles; }
set { styles = value; }
}
/// <summary>
/// Gets or sets an array of assembly names that will be used to compile the report script.
/// </summary>
/// <remarks>
/// By default this property contains the following assemblies: "System.dll", "System.Drawing.dll",
/// "System.Windows.Forms.dll", "System.Data.dll", "System.Xml.dll". If your script uses some types
/// from another assemblies, you have to add them to this property.
/// </remarks>
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[SRCategory("Script")]
public string[] ReferencedAssemblies
{
get { return referencedAssemblies; }
set { referencedAssemblies = value; }
}
/// <summary>
/// Gets or sets a script event name that will be fired when the report starts.
/// </summary>
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[SRCategory("Build")]
public string StartReportEvent
{
get { return startReportEvent; }
set { startReportEvent = value; }
}
/// <summary>
/// Gets or sets a script event name that will be fired when the report is finished.
/// </summary>
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[SRCategory("Build")]
public string FinishReportEvent
{
get { return finishReportEvent; }
set { finishReportEvent = value; }
}
/// <summary>
/// Gets a value indicating that report execution was aborted.
/// </summary>
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool Aborted
{
get
{
Config.DoEvent();
return aborted;
}
}
/// <summary>
/// Gets or sets a value that determines whether to store the report in the application resources.
/// Use this property in the MS Visual Studio IDE only.
/// </summary>
/// <remarks>
/// By default this property is <b>true</b>. When set to <b>false</b>, you should store your report
/// in a file.
/// </remarks>
[DefaultValue(true)]
[SRCategory("Design")]
public bool StoreInResources
{
get { return storeInResources; }
set { storeInResources = value; }
}
/// <summary>
/// Gets or sets the resource string that contains the report.
/// </summary>
/// <remarks>
/// This property is used by the MS Visual Studio to store the report. Do not use it directly.
/// </remarks>
[Browsable(false)]
[Localizable(true)]
public string ReportResourceString
{
get
{
if (!StoreInResources)
return "";
return SaveToString();
}
set
{
if (String.IsNullOrEmpty(value))
{
Clear();
return;
}
LoadFromString(value);
}
}
/// <summary>
/// Gets a value indicating that this report contains dialog forms.
/// </summary>
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool HasDialogs
{
get
{
foreach (PageBase page in Pages)
{
if (page is DialogPage)
return true;
}
return false;
}
}
/// <summary>
/// Gets or sets a set of permissions that will be restricted for the script code.
/// </summary>
/// <remarks>
/// Since the report script is compiled into .NET assembly, it allows you to do ANYTHING.
/// For example, you may create a script that will read/write files from/to a disk. This property
/// is used to restrict such operations.
/// <example>This example shows how to restrict the file IO operations in a script:
/// <code>
/// using System.Security;
/// using System.Security.Permissions;
/// ...
/// PermissionSet ps = new PermissionSet(PermissionState.None);
/// ps.AddPermission(new FileIOPermission(PermissionState.Unrestricted));
/// report1.ScriptRestrictions = ps;
/// report1.Prepare();
/// </code>
/// </example>
/// </remarks>
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public PermissionSet ScriptRestrictions
{
get { return scriptRestrictions; }
set { scriptRestrictions = value; }
}
/// <summary>
/// Gets a reference to the graphics cache for this report.
/// </summary>
/// <remarks>
/// This property is used to support the FastReport.Net infrastructure. Do not use it directly.
/// </remarks>
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public GraphicCache GraphicCache
{
get { return graphicCache; }
}
/// <summary>
/// Gets a pages of the prepared report.
/// </summary>
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public Preview.PreparedPages PreparedPages
{
get { return preparedPages; }
}
/// <summary>
/// Gets a reference to the report engine.
/// </summary>
/// <remarks>
/// This property can be used when report is running. In other cases it returns <b>null</b>.
/// </remarks>
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public ReportEngine Engine
{
get { return engine; }
}
/// <summary>
/// Gets or sets the initial page number for PageN/PageNofM system variables.
/// </summary>
[DefaultValue(1)]
[SRCategory("Engine")]
public int InitialPageNumber
{
get { return initialPageNumber; }
set { initialPageNumber = value; }
}
/// <summary>
/// This property is not relevant to this class.
/// </summary>
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public new string Name
{
get { return base.Name; }
}
/// <summary>
/// This property is not relevant to this class.
/// </summary>
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public new Restrictions Restrictions
{
get { return base.Restrictions; }
set { base.Restrictions = value; }
}
/// <summary>
/// Gets the report operation that is currently performed.
/// </summary>
[Browsable(false)]
public ReportOperation Operation
{
get { return operation; }
}
/// <summary>
/// Gets or sets the Tag object of the report.
/// </summary>
[Browsable(false)]
public object Tag
{
get { return tag; }
set { tag = value; }
}
private string[] DefaultAssemblies
{
get
{
return new string[] {
"System.dll",
"System.Drawing.dll",
"System.Data.dll",
"System.Xml.dll",
#if NETSTANDARD
"FastReport.Compat.dll",
#else
"System.Windows.Forms.dll",
#endif
#if NETSTANDARD || NETCOREAPP
"System.Drawing.Primitives",
#endif
#if MSCHART
"FastReport.DataVisualization.dll"
#endif
};
}
}
internal CodeHelperBase CodeHelper
{
get { return codeHelper; }
}
internal Graphics MeasureGraphics
{
get
{
if (measureGraphics == null)
{
#if NETSTANDARD2_0 || NETSTANDARD2_1 || MONO
measureBitmap = new Bitmap(1, 1);
measureGraphics = Graphics.FromImage(measureBitmap);
#else
measureGraphics = Graphics.FromHwnd(IntPtr.Zero);
#endif
}
return measureGraphics;
}
}
internal string GetReportName
{
get
{
string result = ReportInfo.Name;
if (String.IsNullOrEmpty(result))
result = Path.GetFileNameWithoutExtension(FileName);
return result;
}
}
/// <summary>
/// Gets or sets the flag for refresh.
/// </summary>
public bool NeedRefresh
{
get { return needRefresh; }
set { needRefresh = value; }
}
internal ObjectCollection AllNamedObjects
{
get
{
ObjectCollection allObjects = AllObjects;
// data objects are not included into AllObjects list. Include named items separately.
foreach (Base c in Dictionary.AllObjects)
{
if (c is DataConnectionBase || c is DataSourceBase || c is Relation || c is CubeSourceBase)
allObjects.Add(c);
}
return allObjects;
}
}
#endregion Properties
#region Private Methods
private bool ShouldSerializeReferencedAssemblies()
{
return Converter.ToString(ReferencedAssemblies) != Converter.ToString(DefaultAssemblies);
}
// convert absolute path to the base report to relative path (based on the main report path).
private string GetRelativePathToBaseReport()
{
string path = "";
if (!String.IsNullOrEmpty(FileName))
{
try
{
path = Path.GetDirectoryName(FileName);
}
catch
{
}
}
if (!String.IsNullOrEmpty(path))
{
try
{
return FileUtils.GetRelativePath(BaseReport, path);
}
catch
{
}
}
return BaseReport;
}
private void SetBaseReport(string value)
{
baseReport = value;
if (baseReportObject != null)
{
baseReportObject.Dispose();
baseReportObject = null;
}
// detach the base report
if (String.IsNullOrEmpty(value))
{
foreach (Base c in AllObjects)
{
c.SetAncestor(false);
}
SetAncestor(false);
return;
}
string saveFileName = fileName;
if (LoadBaseReport != null)
{
LoadBaseReport(this, new CustomLoadEventArgs(value, this));
}
else
{
// convert the relative path to absolute path (based on the main report path).
if (!Path.IsPathRooted(value))
value = Path.GetFullPath(Path.GetDirectoryName(FileName) + Path.DirectorySeparatorChar + value);
Load(value);
}
fileName = saveFileName;
baseReport = "";
Password = "";
baseReportObject = Activator.CreateInstance(GetType()) as Report;
baseReportObject.AssignAll(this, true);
// set Ancestor & CanChangeParent flags
foreach (Base c in AllObjects)
{
c.SetAncestor(true);
}
SetAncestor(true);
baseReport = value;
}
private void GetDiff(object sender, DiffEventArgs e)
{
if (baseReportObject != null)
{
if (e.Object is Report)
e.DiffObject = baseReportObject;
else if (e.Object is Base)
e.DiffObject = baseReportObject.FindObject((e.Object as Base).Name);
}
}
private void StartPerformanceCounter()
{