Repository navigation
Expand file tree
/
Copy pathComponentsFactory.cs
More file actions
607 lines (560 loc) · 24.1 KB
/
Copy pathComponentsFactory.cs
File metadata and controls
607 lines (560 loc) · 24.1 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
using FastReport.Table;
using FastReport.Matrix;
using FastReport.Barcode;
using FastReport.Gauge.Linear;
using FastReport.Gauge.Simple;
using FastReport.Data;
#if !CROSSPLATFORM
using System.CodeDom.Compiler;
#endif
namespace FastReport.Import
{
/// <summary>
/// The components factory.
/// </summary>
public static partial class ComponentsFactory
{
#region Private Methods
private static bool IsValidIdentifier(string identifier)
{
#if !CROSSPLATFORM
if (!CodeGenerator.IsValidLanguageIndependentIdentifier(identifier))
return false;
#endif
return true;
}
#endregion // Private Methods
#region Pages
/// <summary>
/// Creates a ReportPage instance in the specified Report.
/// </summary>
/// <param name="report">The Report instance.</param>
/// <returns>The ReportPage instance.</returns>
public static ReportPage CreateReportPage(Report report)
{
ReportPage page = new ReportPage();
report.Pages.Add(page);
page.CreateUniqueName();
return page;
}
/// <summary>
/// Creates a ReportPage instance in the specified Report with the cpecified name.
/// </summary>
/// <param name="name">The name of page.</param>
/// <param name="report">The Report instance.</param>
/// <returns>The ReportPage instance.</returns>
public static ReportPage CreateReportPage(string name, Report report)
{
ReportPage page = new ReportPage();
page.Name = name;
report.Pages.Add(page);
if (!IsValidIdentifier(page.Name))
page.CreateUniqueName();
return page;
}
#endregion // Pages
#region Bands
/// <summary>
/// Creates a ReportTitleBand instance in the specified ReportPage.
/// </summary>
/// <param name="page">The ReportPage instance.</param>
/// <returns>The ReportTitleBand instance.</returns>
public static ReportTitleBand CreateReportTitleBand(ReportPage page)
{
ReportTitleBand reportTitle = new ReportTitleBand();
page.ReportTitle = reportTitle;
reportTitle.CreateUniqueName();
return reportTitle;
}
/// <summary>
/// Creates a ReportSummaryBand instance in the specified ReportPage.
/// </summary>
/// <param name="page">The ReportPage instance.</param>
/// <returns>The ReportSummaryBand instance.</returns>
public static ReportSummaryBand CreateReportSummaryBand(ReportPage page)
{
ReportSummaryBand reportSummary = new ReportSummaryBand();
page.ReportSummary = reportSummary;
reportSummary.CreateUniqueName();
return reportSummary;
}
/// <summary>
/// Creates a PageHeaderBand instance in the specified ReportPage.
/// </summary>
/// <param name="page">The ReportPage instance.</param>
/// <returns>The PageHeaderBand instance.</returns>
public static PageHeaderBand CreatePageHeaderBand(ReportPage page)
{
PageHeaderBand pageHeader = new PageHeaderBand();
page.PageHeader = pageHeader;
pageHeader.CreateUniqueName();
return pageHeader;
}
/// <summary>
/// Creates a PageFooterBand instance in the specified ReportPage.
/// </summary>
/// <param name="page">The ReportPage instance.</param>
/// <returns>The PageFooterBand instance.</returns>
public static PageFooterBand CreatePageFooterBand(ReportPage page)
{
PageFooterBand pageFooter = new PageFooterBand();
page.PageFooter = pageFooter;
pageFooter.CreateUniqueName();
return pageFooter;
}
/// <summary>
/// Creates a ColumnHeaderBand instance in the specified ReportPage.
/// </summary>
/// <param name="page">The ReportPage instance.</param>
/// <returns>The ColumnHeaderBand instance.</returns>
public static ColumnHeaderBand CreateColumnHeaderBand(ReportPage page)
{
ColumnHeaderBand columnHeader = new ColumnHeaderBand();
page.ColumnHeader = columnHeader;
columnHeader.CreateUniqueName();
return columnHeader;
}
/// <summary>
/// Creates a ColumnFooterBand instance in the specified ReportPage.
/// </summary>
/// <param name="page">The ReportPage instance.</param>
/// <returns>The ColumnFooterBand instance.</returns>
public static ColumnFooterBand CreateColumnFooterBand(ReportPage page)
{
ColumnFooterBand columnFooter = new ColumnFooterBand();
page.ColumnFooter = columnFooter;
columnFooter.CreateUniqueName();
return columnFooter;
}
/// <summary>
/// Creates a DataHeaderBand instance in the specified DataBand.
/// </summary>
/// <param name="data">The DataBand instance.</param>
/// <returns>The DataHeaderBand instance.</returns>
public static DataHeaderBand CreateDataHeaderBand(DataBand data)
{
DataHeaderBand dataHeader = new DataHeaderBand();
data.Header = dataHeader;
dataHeader.CreateUniqueName();
return dataHeader;
}
/// <summary>
/// Creates a DataBand instance in the specified ReportPage.
/// </summary>
/// <param name="page">The ReportPage instance.</param>
/// <returns>The DataBand instance.</returns>
public static DataBand CreateDataBand(ReportPage page)
{
DataBand band = new DataBand();
page.Bands.Add(band);
band.CreateUniqueName();
return band;
}
/// <summary>
/// Creates a DataFooterBand instance in the specified DataBand.
/// </summary>
/// <param name="data">The DataBand instance.</param>
/// <returns>The DataFooterBand instance.</returns>
public static DataFooterBand CreateDataFooterBand(DataBand data)
{
DataFooterBand dataFooter = new DataFooterBand();
data.Footer = dataFooter;
dataFooter.CreateUniqueName();
return dataFooter;
}
/// <summary>
/// Creates a GroupHeaderBand instance in the specified ReportPage.
/// </summary>
/// <param name="page">The ReportPage instance.</param>
/// <returns>The GroupHeaderBand instance.</returns>
public static GroupHeaderBand CreateGroupHeaderBand(ReportPage page)
{
GroupHeaderBand groupHeader = new GroupHeaderBand();
page.Bands.Add(groupHeader);
groupHeader.CreateUniqueName();
return groupHeader;
}
/// <summary>
/// Creates a GroupFooterBand instance in the cpecified ReportPage.
/// </summary>
/// <param name="page">The ReportPage instance.</param>
/// <returns>The GroupFooterBand instance.</returns>
public static GroupFooterBand CreateGroupFooterBand(ReportPage page)
{
GroupFooterBand groupFooter = new GroupFooterBand();
page.Bands.Add(groupFooter);
groupFooter.CreateUniqueName();
return groupFooter;
}
/// <summary>
/// Creates a GroupFooterBand instance in the cpecified GroupHeaderBand.
/// </summary>
/// <param name="groupHeaderBand">The GroupHeaderBand instance.</param>
/// <returns>The GroupFooterBand instance.</returns>
public static GroupFooterBand CreateGroupFooterBand(GroupHeaderBand groupHeaderBand)
{
GroupFooterBand groupFooter = new GroupFooterBand();
groupHeaderBand.GroupFooter = groupFooter;
groupFooter.CreateUniqueName();
return groupFooter;
}
/// <summary>
/// Creates a ChildBand instance in the specified BandBase.
/// </summary>
/// <param name="parent">The BandBase instance.</param>
/// <returns>The ChildBand instance.</returns>
public static ChildBand CreateChildBand(BandBase parent)
{
ChildBand child = new ChildBand();
parent.AddChild(child);
child.CreateUniqueName();
return child;
}
/// <summary>
/// Creates an OverlayBand in the specified ReportPage.
/// </summary>
/// <param name="page">The ReportPage instance.</param>
/// <returns>The OverlayBand instance.</returns>
public static OverlayBand CreateOverlayBand(ReportPage page)
{
OverlayBand overlay = new OverlayBand();
page.Overlay = overlay;
overlay.CreateUniqueName();
return overlay;
}
#endregion // Bands
#region Objects
/// <summary>
/// Creates a Style instance with specified name.
/// </summary>
/// <param name="name">The name of the Style instance.</param>
/// <param name="report">The report to add style to.</param>
/// <returns>The Style instance.</returns>
public static Style CreateStyle(string name, Report report)
{
Style style = new Style();
style.Name = name;
report.Styles.Add(style);
return style;
}
/// <summary>
/// Creates a TextObject instance with specified name and parent.
/// </summary>
/// <param name="name">The name of the TextObject instance.</param>
/// <param name="parent">The parent of the TextObject instance.</param>
/// <returns>The TextObject instance.</returns>
public static TextObject CreateTextObject(string name, Base parent)
{
TextObject text = new TextObject();
text.Name = name;
if ((parent as IParent).CanContain(text))
text.Parent = parent;
if (!IsValidIdentifier(text.Name))
text.CreateUniqueName();
return text;
}
/// <summary>
/// Creates a PictureObject instance with specified name and parent.
/// </summary>
/// <param name="name">The name of the PictureObject instance.</param>
/// <param name="parent">The parent of the PictureObject instance.</param>
/// <returns>The PictureObject instance.</returns>
public static PictureObject CreatePictureObject(string name, Base parent)
{
PictureObject picture = new PictureObject();
picture.Name = name;
if ((parent as IParent).CanContain(picture))
picture.Parent = parent;
if (!IsValidIdentifier(picture.Name))
picture.CreateUniqueName();
return picture;
}
/// <summary>
/// Creates a LineObject instance with specified name and parent.
/// </summary>
/// <param name="name">The name of the LineObject instance.</param>
/// <param name="parent">The parent of the LineObject instance.</param>
/// <returns>The LineObject instance.</returns>
public static LineObject CreateLineObject(string name, Base parent)
{
LineObject line = new LineObject();
line.Name = name;
if ((parent as IParent).CanContain(line))
line.Parent = parent;
if (!IsValidIdentifier(line.Name))
line.CreateUniqueName();
return line;
}
/// <summary>
/// Creates a ShapeObject instance with specified name and parent.
/// </summary>
/// <param name="name">The name of the ShapeObject instance.</param>
/// <param name="parent">The parent of the ShapeObject instance.</param>
/// <returns>The ShapeObject instance.</returns>
public static ShapeObject CreateShapeObject(string name, Base parent)
{
ShapeObject shape = new ShapeObject();
shape.Name = name;
if ((parent as IParent).CanContain(shape))
shape.Parent = parent;
if (!IsValidIdentifier(shape.Name))
shape.CreateUniqueName();
return shape;
}
/// <summary>
/// Creates a PolyLineObject instance with specified name and parent.
/// </summary>
/// <param name="name">The name of the PolyLineObject instance.</param>
/// <param name="parent">The parent of the PolyLineObject instance.</param>
/// <returns>The PolyLineObject instance.</returns>
public static PolyLineObject CreatePolyLineObject(string name, Base parent)
{
PolyLineObject polyLine = new PolyLineObject();
polyLine.Name = name;
if ((parent as IParent).CanContain(polyLine))
polyLine.Parent = parent;
if (!IsValidIdentifier(polyLine.Name))
polyLine.CreateUniqueName();
return polyLine;
}
/// <summary>
/// Creates a PolygonObject instance with specified name and parent.
/// </summary>
/// <param name="name">The name of the PolygonObject instance.</param>
/// <param name="parent">The parent of the PolygonObject instance.</param>
/// <returns>The PolygonObject instance.</returns>
public static PolygonObject CreatePolygonObject(string name, Base parent)
{
PolygonObject polygon = new PolygonObject();
polygon.Name = name;
if ((parent as IParent).CanContain(polygon))
polygon.Parent = parent;
if (!IsValidIdentifier(polygon.Name))
polygon.CreateUniqueName();
return polygon;
}
/// <summary>
/// Creates a SubreportObject instance with specified name and parent.
/// </summary>
/// <param name="name">The name of the SubreportObject instance.</param>
/// <param name="parent">The parent of the SubreportObject instance.</param>
/// <returns>The SubreportObject instance.</returns>
public static SubreportObject CreateSubreportObject(string name, Base parent)
{
SubreportObject subreport = new SubreportObject();
subreport.Name = name;
if ((parent as IParent).CanContain(subreport))
subreport.Parent = parent;
if (!IsValidIdentifier(subreport.Name))
subreport.CreateUniqueName();
return subreport;
}
/// <summary>
/// Creates a ContainerObject instance with specified name and parent.
/// </summary>
/// <param name="name">The name of the ContainerObject instance.</param>
/// <param name="parent">The parent of the ContainerObject instance.</param>
/// <returns>The ContainerObject instance.</returns>
public static ContainerObject CreateContainerObject(string name, Base parent)
{
ContainerObject container = new ContainerObject();
container.Name = name;
if ((parent as IParent).CanContain(container))
container.Parent = parent;
if (!IsValidIdentifier(container.Name))
container.CreateUniqueName();
return container;
}
/// <summary>
/// Creates a CheckBoxObject instance with specified name and parent.
/// </summary>
/// <param name="name">The name of the CheckBoxObject instance.</param>
/// <param name="parent">The parent of the CheckBoxObject instance.</param>
/// <returns>The CheckBoxObject instance.</returns>
public static CheckBoxObject CreateCheckBoxObject(string name, Base parent)
{
CheckBoxObject checkBox = new CheckBoxObject();
checkBox.Name = name;
if ((parent as IParent).CanContain(checkBox))
checkBox.Parent = parent;
if (!IsValidIdentifier(checkBox.Name))
checkBox.CreateUniqueName();
return checkBox;
}
/// <summary>
/// Creates a HtmlObject instance with specified name and parent.
/// </summary>
/// <param name="name">The name of the HtmlObject instance.</param>
/// <param name="parent">The parent of the HtmlObject instance.</param>
/// <returns>The HtmlObject instance.</returns>
public static HtmlObject CreateHtmlObject(string name, Base parent)
{
HtmlObject html = new HtmlObject();
html.Name = name;
if ((parent as IParent).CanContain(html))
html.Parent = parent;
if (!IsValidIdentifier(html.Name))
html.CreateUniqueName();
return html;
}
/// <summary>
/// Creates a TableObject instance with specified name and parent.
/// </summary>
/// <param name="name">The name of the TableObject instance.</param>
/// <param name="parent">The parent of the TableObject instance.</param>
/// <returns>The TableObject instance.</returns>
public static TableObject CreateTableObject(string name, Base parent)
{
TableObject table = new TableObject();
table.Name = name;
if ((parent as IParent).CanContain(table))
table.Parent = parent;
if (!IsValidIdentifier(table.Name))
table.CreateUniqueName();
return table;
}
/// <summary>
/// Creates a MatrixObject instance with specified name and parent.
/// </summary>
/// <param name="name">The name of the MatrixObject instance.</param>
/// <param name="parent">The parent of the MatrixObject instance.</param>
/// <returns>The MatrixObject instance.</returns>
public static MatrixObject CreateMatrixObject(string name, Base parent)
{
MatrixObject matrix = new MatrixObject();
matrix.Name = name;
if ((parent as IParent).CanContain(matrix))
matrix.Parent = parent;
if (!IsValidIdentifier(matrix.Name))
matrix.CreateUniqueName();
return matrix;
}
/// <summary>
/// Creates a BarcodeObject instance with specified name and parent.
/// </summary>
/// <param name="name">The name of the BarcodeObject instance.</param>
/// <param name="parent">The parent of the BarcodeObject instance.</param>
/// <returns>The BarcodeObject instance.</returns>
public static BarcodeObject CreateBarcodeObject(string name, Base parent)
{
BarcodeObject barcode = new BarcodeObject();
barcode.Name = name;
if ((parent as IParent).CanContain(barcode))
barcode.Parent = parent;
if (!IsValidIdentifier(barcode.Name))
barcode.CreateUniqueName();
return barcode;
}
/// <summary>
/// Creates a ZipCodeObject instance with specified name and parent.
/// </summary>
/// <param name="name">The name of the ZipCodeObject instance.</param>
/// <param name="parent">The parent of the ZipCodeObject instance.</param>
/// <returns>The ZipCodeObject instance.</returns>
public static ZipCodeObject CreateZipCodeObject(string name, Base parent)
{
ZipCodeObject zipCode = new ZipCodeObject();
zipCode.Name = name;
if ((parent as IParent).CanContain(zipCode))
zipCode.Parent = parent;
if (!IsValidIdentifier(zipCode.Name))
zipCode.CreateUniqueName();
return zipCode;
}
/// <summary>
/// Creates a CellularTextObject instance with specified name and parent.
/// </summary>
/// <param name="name">The name of the CellularTextObject instance.</param>
/// <param name="parent">The parent ot the CellularTextObject instance.</param>
/// <returns>The CellularTextObject instance.</returns>
public static CellularTextObject CreateCellularTextObject(string name, Base parent)
{
CellularTextObject cellularText = new CellularTextObject();
cellularText.Name = name;
if ((parent as IParent).CanContain(cellularText))
cellularText.Parent = parent;
if (!IsValidIdentifier(cellularText.Name))
cellularText.CreateUniqueName();
return cellularText;
}
/// <summary>
/// Creates a LinearGauge instance with specified name and parent.
/// </summary>
/// <param name="name">The name of the LinearGauge instance.</param>
/// <param name="parent">The parent of the LinearGauge instance.</param>
/// <returns>The LinearGauge instance.</returns>
public static LinearGauge CreateLinearGauge(string name, Base parent)
{
LinearGauge gauge = new LinearGauge();
gauge.Name = name;
if ((parent as IParent).CanContain(gauge))
gauge.Parent = parent;
if (!IsValidIdentifier(gauge.Name))
gauge.CreateUniqueName();
return gauge;
}
/// <summary>
/// Creates a SimpleGauge instance with specified name and parent.
/// </summary>
/// <param name="name">The name of the SimpleGauge instance.</param>
/// <param name="parent">The parent of the SimpleGauge instance.</param>
/// <returns>The SimpleGauge instance.</returns>
public static SimpleGauge CreateSimpleGauge(string name, Base parent)
{
SimpleGauge gauge = new SimpleGauge();
gauge.Name = name;
if ((parent as IParent).CanContain(gauge))
gauge.Parent = parent;
if (!IsValidIdentifier(gauge.Name))
gauge.CreateUniqueName();
return gauge;
}
/// <summary>
/// Creates a RadialGauge instance with specified name and parent.
/// </summary>
/// <param name="name">The name of the RadialGauge instance.</param>
/// <param name="parent">The parent of the RadialGauge instance.</param>
/// <returns>The RadialGauge instance.</returns>
public static Gauge.Radial.RadialGauge CreateRadialGauge(string name, Base parent)
{
Gauge.Radial.RadialGauge gauge = new Gauge.Radial.RadialGauge();
gauge.Name = name;
if ((parent as IParent).CanContain(gauge))
gauge.Parent = parent;
if (!IsValidIdentifier(gauge.Name))
gauge.CreateUniqueName();
return gauge;
}
/// <summary>
/// Creates a SimpleProgressGauge instance with specified name and parent.
/// </summary>
/// <param name="name">The name of the SimpleProgressGauge instance.</param>
/// <param name="parent">The parent of the SimpleProgressGauge instance.</param>
/// <returns>The SimpleProgressGauge instance.</returns>
public static Gauge.Simple.Progress.SimpleProgressGauge CreateSimpleProgressGauge(string name, Base parent)
{
Gauge.Simple.Progress.SimpleProgressGauge gauge = new Gauge.Simple.Progress.SimpleProgressGauge();
gauge.Name = name;
if ((parent as IParent).CanContain(gauge))
gauge.Parent = parent;
if (!IsValidIdentifier(gauge.Name))
gauge.CreateUniqueName();
return gauge;
}
#endregion // Objects
#region Dictionary Elements
/// <summary>
/// Creates a Parameter instance with specified name and parent.
/// </summary>
/// <param name="name">The name of the Parameter instance.</param>
/// <param name="report">The parent Report for the new Parameter.</param>
/// <returns>The Parameter instance.</returns>
public static Parameter CreateParameter(string name, Report report)
{
Parameter parameter = new Parameter(name);
report.Parameters.Add(parameter);
return parameter;
}
#endregion Dictionary Elements
}
}