@reportman/engine 0.0.0-stage → 4.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +373 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/data/columns.d.ts +50 -0
- package/dist/data/columns.d.ts.map +1 -0
- package/dist/data/columns.js +385 -0
- package/dist/data/columns.js.map +1 -0
- package/dist/data/databaseinfo.d.ts +41 -0
- package/dist/data/databaseinfo.d.ts.map +1 -0
- package/dist/data/databaseinfo.js +145 -0
- package/dist/data/databaseinfo.js.map +1 -0
- package/dist/data/datainfo.d.ts +82 -0
- package/dist/data/datainfo.d.ts.map +1 -0
- package/dist/data/datainfo.js +449 -0
- package/dist/data/datainfo.js.map +1 -0
- package/dist/data/errors.d.ts +8 -0
- package/dist/data/errors.d.ts.map +1 -0
- package/dist/data/errors.js +14 -0
- package/dist/data/errors.js.map +1 -0
- package/dist/data/host.d.ts +132 -0
- package/dist/data/host.d.ts.map +1 -0
- package/dist/data/host.js +108 -0
- package/dist/data/host.js.map +1 -0
- package/dist/data/op.d.ts +21 -0
- package/dist/data/op.d.ts.map +1 -0
- package/dist/data/op.js +97 -0
- package/dist/data/op.js.map +1 -0
- package/dist/data/reportdataset.d.ts +116 -0
- package/dist/data/reportdataset.d.ts.map +1 -0
- package/dist/data/reportdataset.js +396 -0
- package/dist/data/reportdataset.js.map +1 -0
- package/dist/data/transfer.d.ts +46 -0
- package/dist/data/transfer.d.ts.map +1 -0
- package/dist/data/transfer.js +100 -0
- package/dist/data/transfer.js.map +1 -0
- package/dist/data/union.d.ts +88 -0
- package/dist/data/union.d.ts.map +1 -0
- package/dist/data/union.js +733 -0
- package/dist/data/union.js.map +1 -0
- package/dist/eval/chinesetables.d.ts +5 -0
- package/dist/eval/chinesetables.d.ts.map +1 -0
- package/dist/eval/chinesetables.js +8 -0
- package/dist/eval/chinesetables.js.map +1 -0
- package/dist/eval/evaluator.d.ts +100 -0
- package/dist/eval/evaluator.d.ts.map +1 -0
- package/dist/eval/evaluator.js +667 -0
- package/dist/eval/evaluator.js.map +1 -0
- package/dist/eval/exception.d.ts +9 -0
- package/dist/eval/exception.d.ts.map +1 -0
- package/dist/eval/exception.js +15 -0
- package/dist/eval/exception.js.map +1 -0
- package/dist/eval/fields.d.ts +60 -0
- package/dist/eval/fields.d.ts.map +1 -0
- package/dist/eval/fields.js +104 -0
- package/dist/eval/fields.js.map +1 -0
- package/dist/eval/functions.d.ts +27 -0
- package/dist/eval/functions.d.ts.map +1 -0
- package/dist/eval/functions.js +810 -0
- package/dist/eval/functions.js.map +1 -0
- package/dist/eval/identifiers.d.ts +100 -0
- package/dist/eval/identifiers.d.ts.map +1 -0
- package/dist/eval/identifiers.js +195 -0
- package/dist/eval/identifiers.js.map +1 -0
- package/dist/eval/parser.d.ts +47 -0
- package/dist/eval/parser.d.ts.map +1 -0
- package/dist/eval/parser.js +336 -0
- package/dist/eval/parser.js.map +1 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +42 -0
- package/dist/index.js.map +1 -0
- package/dist/params/param.d.ts +92 -0
- package/dist/params/param.d.ts.map +1 -0
- package/dist/params/param.js +358 -0
- package/dist/params/param.js.map +1 -0
- package/dist/params/parameters.d.ts +87 -0
- package/dist/params/parameters.d.ts.map +1 -0
- package/dist/params/parameters.js +499 -0
- package/dist/params/parameters.js.map +1 -0
- package/dist/report/barcode/barcodeitem.d.ts +76 -0
- package/dist/report/barcode/barcodeitem.d.ts.map +1 -0
- package/dist/report/barcode/barcodeitem.js +864 -0
- package/dist/report/barcode/barcodeitem.js.map +1 -0
- package/dist/report/barcode/code128.d.ts +18 -0
- package/dist/report/barcode/code128.d.ts.map +1 -0
- package/dist/report/barcode/code128.js +187 -0
- package/dist/report/barcode/code128.js.map +1 -0
- package/dist/report/barcode/netutil.d.ts +30 -0
- package/dist/report/barcode/netutil.d.ts.map +1 -0
- package/dist/report/barcode/netutil.js +65 -0
- package/dist/report/barcode/netutil.js.map +1 -0
- package/dist/report/barcode/pdf417.d.ts +17 -0
- package/dist/report/barcode/pdf417.d.ts.map +1 -0
- package/dist/report/barcode/pdf417.js +782 -0
- package/dist/report/barcode/pdf417.js.map +1 -0
- package/dist/report/barcode/pdf417tables.d.ts +11 -0
- package/dist/report/barcode/pdf417tables.d.ts.map +1 -0
- package/dist/report/barcode/pdf417tables.js +880 -0
- package/dist/report/barcode/pdf417tables.js.map +1 -0
- package/dist/report/barcode/qrcode.d.ts +14 -0
- package/dist/report/barcode/qrcode.d.ts.map +1 -0
- package/dist/report/barcode/qrcode.js +214 -0
- package/dist/report/barcode/qrcode.js.map +1 -0
- package/dist/report/barcode/zxingwidth.d.ts +4 -0
- package/dist/report/barcode/zxingwidth.d.ts.map +1 -0
- package/dist/report/barcode/zxingwidth.js +247 -0
- package/dist/report/barcode/zxingwidth.js.map +1 -0
- package/dist/report/chart/chartidens.d.ts +70 -0
- package/dist/report/chart/chartidens.d.ts.map +1 -0
- package/dist/report/chart/chartidens.js +162 -0
- package/dist/report/chart/chartidens.js.map +1 -0
- package/dist/report/chart/chartitem.d.ts +110 -0
- package/dist/report/chart/chartitem.d.ts.map +1 -0
- package/dist/report/chart/chartitem.js +403 -0
- package/dist/report/chart/chartitem.js.map +1 -0
- package/dist/report/chart/series.d.ts +65 -0
- package/dist/report/chart/series.d.ts.map +1 -0
- package/dist/report/chart/series.js +74 -0
- package/dist/report/chart/series.js.map +1 -0
- package/dist/report/chart/vectorchart.d.ts +18 -0
- package/dist/report/chart/vectorchart.d.ts.map +1 -0
- package/dist/report/chart/vectorchart.js +356 -0
- package/dist/report/chart/vectorchart.js.map +1 -0
- package/dist/report/convert.d.ts +4 -0
- package/dist/report/convert.d.ts.map +1 -0
- package/dist/report/convert.js +162 -0
- package/dist/report/convert.js.map +1 -0
- package/dist/report/errors.d.ts +13 -0
- package/dist/report/errors.d.ts.map +1 -0
- package/dist/report/errors.js +20 -0
- package/dist/report/errors.js.map +1 -0
- package/dist/report/identifiers.d.ts +91 -0
- package/dist/report/identifiers.d.ts.map +1 -0
- package/dist/report/identifiers.js +404 -0
- package/dist/report/identifiers.js.map +1 -0
- package/dist/report/imageitem.d.ts +66 -0
- package/dist/report/imageitem.d.ts.map +1 -0
- package/dist/report/imageitem.js +190 -0
- package/dist/report/imageitem.js.map +1 -0
- package/dist/report/items.d.ts +219 -0
- package/dist/report/items.d.ts.map +1 -0
- package/dist/report/items.js +1015 -0
- package/dist/report/items.js.map +1 -0
- package/dist/report/report.d.ts +221 -0
- package/dist/report/report.d.ts.map +1 -0
- package/dist/report/report.js +1974 -0
- package/dist/report/report.js.map +1 -0
- package/dist/report/run.d.ts +87 -0
- package/dist/report/run.d.ts.map +1 -0
- package/dist/report/run.js +121 -0
- package/dist/report/run.js.map +1 -0
- package/dist/report/section.d.ts +86 -0
- package/dist/report/section.d.ts.map +1 -0
- package/dist/report/section.js +325 -0
- package/dist/report/section.js.map +1 -0
- package/dist/report/subreport.d.ts +49 -0
- package/dist/report/subreport.d.ts.map +1 -0
- package/dist/report/subreport.js +220 -0
- package/dist/report/subreport.js.map +1 -0
- package/dist/util/base64.d.ts +9 -0
- package/dist/util/base64.d.ts.map +1 -0
- package/dist/util/base64.js +60 -0
- package/dist/util/base64.js.map +1 -0
- package/dist/util/chars.d.ts +45 -0
- package/dist/util/chars.d.ts.map +1 -0
- package/dist/util/chars.js +194 -0
- package/dist/util/chars.js.map +1 -0
- package/dist/util/compositeformat.d.ts +3 -0
- package/dist/util/compositeformat.d.ts.map +1 -0
- package/dist/util/compositeformat.js +99 -0
- package/dist/util/compositeformat.js.map +1 -0
- package/dist/util/culture.d.ts +84 -0
- package/dist/util/culture.d.ts.map +1 -0
- package/dist/util/culture.js +59 -0
- package/dist/util/culture.js.map +1 -0
- package/dist/util/cultures.generated.d.ts +3 -0
- package/dist/util/cultures.generated.d.ts.map +1 -0
- package/dist/util/cultures.generated.js +1043 -0
- package/dist/util/cultures.generated.js.map +1 -0
- package/dist/util/dateformat.d.ts +21 -0
- package/dist/util/dateformat.d.ts.map +1 -0
- package/dist/util/dateformat.js +439 -0
- package/dist/util/dateformat.js.map +1 -0
- package/dist/util/dateparse.d.ts +12 -0
- package/dist/util/dateparse.d.ts.map +1 -0
- package/dist/util/dateparse.js +1212 -0
- package/dist/util/dateparse.js.map +1 -0
- package/dist/util/datetime.d.ts +70 -0
- package/dist/util/datetime.d.ts.map +1 -0
- package/dist/util/datetime.js +265 -0
- package/dist/util/datetime.js.map +1 -0
- package/dist/util/decimal.d.ts +54 -0
- package/dist/util/decimal.d.ts.map +1 -0
- package/dist/util/decimal.js +365 -0
- package/dist/util/decimal.js.map +1 -0
- package/dist/util/delphidateformat.d.ts +34 -0
- package/dist/util/delphidateformat.d.ts.map +1 -0
- package/dist/util/delphidateformat.js +247 -0
- package/dist/util/delphidateformat.js.map +1 -0
- package/dist/util/delphiformatsettings.generated.d.ts +3 -0
- package/dist/util/delphiformatsettings.generated.d.ts.map +1 -0
- package/dist/util/delphiformatsettings.generated.js +15 -0
- package/dist/util/delphiformatsettings.generated.js.map +1 -0
- package/dist/util/delphitext.d.ts +40 -0
- package/dist/util/delphitext.d.ts.map +1 -0
- package/dist/util/delphitext.js +408 -0
- package/dist/util/delphitext.js.map +1 -0
- package/dist/util/doubleutil.d.ts +30 -0
- package/dist/util/doubleutil.d.ts.map +1 -0
- package/dist/util/doubleutil.js +651 -0
- package/dist/util/doubleutil.js.map +1 -0
- package/dist/util/inflate.d.ts +7 -0
- package/dist/util/inflate.d.ts.map +1 -0
- package/dist/util/inflate.js +256 -0
- package/dist/util/inflate.js.map +1 -0
- package/dist/util/netexception.d.ts +59 -0
- package/dist/util/netexception.d.ts.map +1 -0
- package/dist/util/netexception.js +94 -0
- package/dist/util/netexception.js.map +1 -0
- package/dist/util/numberformat.d.ts +14 -0
- package/dist/util/numberformat.d.ts.map +1 -0
- package/dist/util/numberformat.js +828 -0
- package/dist/util/numberformat.js.map +1 -0
- package/dist/util/numberparse.d.ts +49 -0
- package/dist/util/numberparse.d.ts.map +1 -0
- package/dist/util/numberparse.js +568 -0
- package/dist/util/numberparse.js.map +1 -0
- package/dist/util/reportmanres.en.generated.d.ts +2 -0
- package/dist/util/reportmanres.en.generated.d.ts.map +1 -0
- package/dist/util/reportmanres.en.generated.js +2082 -0
- package/dist/util/reportmanres.en.generated.js.map +1 -0
- package/dist/util/reportmanres.es.generated.d.ts +2 -0
- package/dist/util/reportmanres.es.generated.d.ts.map +1 -0
- package/dist/util/reportmanres.es.generated.js +2082 -0
- package/dist/util/reportmanres.es.generated.js.map +1 -0
- package/dist/util/translator.d.ts +29 -0
- package/dist/util/translator.d.ts.map +1 -0
- package/dist/util/translator.js +79 -0
- package/dist/util/translator.js.map +1 -0
- package/dist/variant/coercion.d.ts +9 -0
- package/dist/variant/coercion.d.ts.map +1 -0
- package/dist/variant/coercion.js +298 -0
- package/dist/variant/coercion.js.map +1 -0
- package/dist/variant/context.d.ts +30 -0
- package/dist/variant/context.d.ts.map +1 -0
- package/dist/variant/context.js +22 -0
- package/dist/variant/context.js.map +1 -0
- package/dist/variant/variant.d.ts +193 -0
- package/dist/variant/variant.d.ts.map +1 -0
- package/dist/variant/variant.js +1235 -0
- package/dist/variant/variant.js.map +1 -0
- package/package.json +35 -4
- package/README.md +0 -3
|
@@ -0,0 +1,1015 @@
|
|
|
1
|
+
// Ports of the runtime part of Reportman.Reporting.PrintItem, PrintPosItem, PrintItemText,
|
|
2
|
+
// LabelItem, ExpressionItem and ShapeItem: how an item measures itself (GetExtension) and draws
|
|
3
|
+
// itself into the metafile (Print / DoPrint) while a report is laid out.
|
|
4
|
+
import { AlignmentFlags, HtmlTextParser, roundHalfEven, MetaFile, MetaFileVersion, MetaObjectDraw, MetaObjectText, MetaObjectType, } from '@reportman/metafile';
|
|
5
|
+
import { toUpperNet, trimNet } from '../util/chars.js';
|
|
6
|
+
import { messageOf } from '../util/netexception.js';
|
|
7
|
+
import { standardDeviation } from '../util/doubleutil.js';
|
|
8
|
+
import { Variant, VariantType } from '../variant/variant.js';
|
|
9
|
+
import { NotSupportedYetError } from '../data/errors.js';
|
|
10
|
+
import { ReportException } from './errors.js';
|
|
11
|
+
import { EvalIdenExpression } from './identifiers.js';
|
|
12
|
+
/** The notifications a subreport sends to its sections and items (SubReportEvent). */
|
|
13
|
+
export var SubReportEvent;
|
|
14
|
+
(function (SubReportEvent) {
|
|
15
|
+
SubReportEvent[SubReportEvent["Start"] = 0] = "Start";
|
|
16
|
+
SubReportEvent[SubReportEvent["DataChange"] = 1] = "DataChange";
|
|
17
|
+
SubReportEvent[SubReportEvent["GroupChange"] = 2] = "GroupChange";
|
|
18
|
+
SubReportEvent[SubReportEvent["PageChange"] = 3] = "PageChange";
|
|
19
|
+
SubReportEvent[SubReportEvent["InvalidateValue"] = 4] = "InvalidateValue";
|
|
20
|
+
SubReportEvent[SubReportEvent["SubReportStart"] = 5] = "SubReportStart";
|
|
21
|
+
SubReportEvent[SubReportEvent["SubReportEnd"] = 6] = "SubReportEnd";
|
|
22
|
+
})(SubReportEvent || (SubReportEvent = {}));
|
|
23
|
+
/** PrintItemAlign. */
|
|
24
|
+
export var PrintItemAlign;
|
|
25
|
+
(function (PrintItemAlign) {
|
|
26
|
+
PrintItemAlign[PrintItemAlign["None"] = 0] = "None";
|
|
27
|
+
PrintItemAlign[PrintItemAlign["Bottom"] = 1] = "Bottom";
|
|
28
|
+
PrintItemAlign[PrintItemAlign["Right"] = 2] = "Right";
|
|
29
|
+
PrintItemAlign[PrintItemAlign["BottomRight"] = 3] = "BottomRight";
|
|
30
|
+
PrintItemAlign[PrintItemAlign["LeftRight"] = 4] = "LeftRight";
|
|
31
|
+
PrintItemAlign[PrintItemAlign["TopBottom"] = 5] = "TopBottom";
|
|
32
|
+
PrintItemAlign[PrintItemAlign["AllClient"] = 6] = "AllClient";
|
|
33
|
+
})(PrintItemAlign || (PrintItemAlign = {}));
|
|
34
|
+
/** A C# Point (a struct): copied on assignment. */
|
|
35
|
+
export function pt(x, y) {
|
|
36
|
+
return { x, y };
|
|
37
|
+
}
|
|
38
|
+
/** PrintItem: an item with a size, a print condition and the before/after print expressions. */
|
|
39
|
+
export class PrintItem {
|
|
40
|
+
report;
|
|
41
|
+
name;
|
|
42
|
+
width;
|
|
43
|
+
height;
|
|
44
|
+
printCondition;
|
|
45
|
+
doBeforePrint;
|
|
46
|
+
doAfterPrint;
|
|
47
|
+
/** The size of the last print. */
|
|
48
|
+
printWidth = 0;
|
|
49
|
+
printHeight = 0;
|
|
50
|
+
/** The extent of the last measurement. */
|
|
51
|
+
lastExtent = pt(0, 0);
|
|
52
|
+
constructor(report, model) {
|
|
53
|
+
this.report = report;
|
|
54
|
+
this.name = model.name;
|
|
55
|
+
this.width = model.width;
|
|
56
|
+
this.height = model.height;
|
|
57
|
+
this.printCondition = model.printCondition ?? '';
|
|
58
|
+
this.doBeforePrint = model.doBeforePrint ?? '';
|
|
59
|
+
this.doAfterPrint = model.doAfterPrint ?? '';
|
|
60
|
+
}
|
|
61
|
+
/** EvaluatePrintCondition: true when the condition is empty or evaluates to true. */
|
|
62
|
+
evaluatePrintCondition() {
|
|
63
|
+
if (this.printCondition.length === 0)
|
|
64
|
+
return true;
|
|
65
|
+
const fevaluator = this.report.evaluator;
|
|
66
|
+
try {
|
|
67
|
+
fevaluator.expression = this.printCondition;
|
|
68
|
+
fevaluator.evaluate();
|
|
69
|
+
return fevaluator.result.toBool(fevaluator.context);
|
|
70
|
+
}
|
|
71
|
+
catch (e) {
|
|
72
|
+
throw new ReportException(messageOf(e) + '\n' + this.name + ' Prop:PrintCondition \n' + this.printCondition, this.name, 'PrintCondition');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/** A subreport event (the base item does nothing). */
|
|
76
|
+
subReportChanged(_newstate, _newgroup) { }
|
|
77
|
+
getExtension(_adriver, _maxExtent, _forcePartial) {
|
|
78
|
+
const aresult = pt(this.width, this.height);
|
|
79
|
+
this.lastExtent = { ...aresult };
|
|
80
|
+
return aresult;
|
|
81
|
+
}
|
|
82
|
+
doPrint(_adriver, _aposx, _aposy, newwidth, newheight, _metafile, _maxExtent, partialPrint) {
|
|
83
|
+
this.printWidth = newwidth >= 0 ? newwidth : this.width;
|
|
84
|
+
this.printHeight = newheight >= 0 ? newheight : this.height;
|
|
85
|
+
partialPrint.value = false;
|
|
86
|
+
}
|
|
87
|
+
/** Print: the print condition, the before print expression, the item, the after print expression. */
|
|
88
|
+
print(adriver, aposx, aposy, newwidth, newheight, metafile, maxExtent, partialPrint) {
|
|
89
|
+
if (!this.evaluatePrintCondition())
|
|
90
|
+
return;
|
|
91
|
+
this.executeBeforePrint();
|
|
92
|
+
this.doPrint(adriver, aposx, aposy, newwidth, newheight, metafile, { ...maxExtent }, partialPrint);
|
|
93
|
+
this.executeAfterPrint();
|
|
94
|
+
}
|
|
95
|
+
executeBeforePrint() {
|
|
96
|
+
if (this.doBeforePrint.length > 0) {
|
|
97
|
+
try {
|
|
98
|
+
const fevaluator = this.report.evaluator;
|
|
99
|
+
fevaluator.expression = this.doBeforePrint;
|
|
100
|
+
fevaluator.evaluate();
|
|
101
|
+
}
|
|
102
|
+
catch (e) {
|
|
103
|
+
throw new ReportException(messageOf(e) + '\n' + this.name + ' Prop:BeforePrint', this.name, 'BeforePrint');
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
executeAfterPrint() {
|
|
108
|
+
if (this.doAfterPrint.length > 0) {
|
|
109
|
+
try {
|
|
110
|
+
const fevaluator = this.report.evaluator;
|
|
111
|
+
fevaluator.expression = this.doAfterPrint;
|
|
112
|
+
fevaluator.evaluate();
|
|
113
|
+
}
|
|
114
|
+
catch (e) {
|
|
115
|
+
throw new ReportException(messageOf(e) + '\n' + this.name + ' Prop:AfterPrint', this.name, 'AfterPrint');
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/** PrintPosItem: an item placed in a section. */
|
|
121
|
+
export class PrintPosItem extends PrintItem {
|
|
122
|
+
hidden;
|
|
123
|
+
posX;
|
|
124
|
+
posY;
|
|
125
|
+
align;
|
|
126
|
+
/** Print it at the last page of a partial print (aligned to bottom). */
|
|
127
|
+
partialFlag;
|
|
128
|
+
annotationExpression;
|
|
129
|
+
constructor(report, model) {
|
|
130
|
+
super(report, model);
|
|
131
|
+
this.hidden = model.hidden;
|
|
132
|
+
this.posX = model.posX;
|
|
133
|
+
this.posY = model.posY;
|
|
134
|
+
this.align = model.align;
|
|
135
|
+
this.partialFlag = model.partialFlag;
|
|
136
|
+
this.annotationExpression = model.annotationExpression ?? null;
|
|
137
|
+
}
|
|
138
|
+
getExtension(_adriver, _maxExtent, _forcePartial) {
|
|
139
|
+
const aresult = pt(0, 0);
|
|
140
|
+
if (this.align !== PrintItemAlign.LeftRight)
|
|
141
|
+
aresult.x = this.width;
|
|
142
|
+
if (this.align !== PrintItemAlign.TopBottom)
|
|
143
|
+
aresult.y = this.height;
|
|
144
|
+
this.lastExtent = { ...aresult };
|
|
145
|
+
return aresult;
|
|
146
|
+
}
|
|
147
|
+
/** FillAnnotation: the annotation expression of the item, attached to its object. */
|
|
148
|
+
fillAnnotation(meta, page) {
|
|
149
|
+
if (this.annotationExpression === null || this.annotationExpression.length === 0)
|
|
150
|
+
return;
|
|
151
|
+
try {
|
|
152
|
+
const fevaluator = this.report.evaluator;
|
|
153
|
+
const newValue = fevaluator.evaluateText(this.annotationExpression);
|
|
154
|
+
if (newValue.varType === VariantType.String) {
|
|
155
|
+
const annotation = newValue.toImplicitString(fevaluator.context) ?? '';
|
|
156
|
+
if (annotation.length > 0) {
|
|
157
|
+
const pos = page.addString(annotation);
|
|
158
|
+
meta.annotationP = pos;
|
|
159
|
+
meta.annotationS = annotation.length;
|
|
160
|
+
if (page.metaFile.version < MetaFileVersion.MetaVersion4_0)
|
|
161
|
+
page.metaFile.version = MetaFileVersion.MetaVersion4_0;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
catch (e) {
|
|
166
|
+
throw new ReportException(messageOf(e) + '\n' + this.name + ' Prop:AnnotationExpression', this.name, 'AnnotationExpression');
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/** The bidirectional mode of a text in a language (BidiModeType). */
|
|
171
|
+
var BidiModeType;
|
|
172
|
+
(function (BidiModeType) {
|
|
173
|
+
BidiModeType[BidiModeType["No"] = 0] = "No";
|
|
174
|
+
BidiModeType[BidiModeType["Partial"] = 1] = "Partial";
|
|
175
|
+
BidiModeType[BidiModeType["Full"] = 2] = "Full";
|
|
176
|
+
})(BidiModeType || (BidiModeType = {}));
|
|
177
|
+
/** PrintItemText: an item with a text, its font and format. */
|
|
178
|
+
export class PrintItemText extends PrintPosItem {
|
|
179
|
+
wFontName;
|
|
180
|
+
lFontName;
|
|
181
|
+
fontSize;
|
|
182
|
+
fontRotation;
|
|
183
|
+
fontStyle;
|
|
184
|
+
fontColor;
|
|
185
|
+
backColor;
|
|
186
|
+
transparent;
|
|
187
|
+
cutText;
|
|
188
|
+
wordWrap;
|
|
189
|
+
isHtml;
|
|
190
|
+
alignment;
|
|
191
|
+
vAlignment;
|
|
192
|
+
singleLine;
|
|
193
|
+
type1Font;
|
|
194
|
+
multiPage;
|
|
195
|
+
printStep;
|
|
196
|
+
bidiModes;
|
|
197
|
+
constructor(report, model) {
|
|
198
|
+
super(report, model);
|
|
199
|
+
this.wFontName = model.wFontName;
|
|
200
|
+
this.lFontName = model.lFontName;
|
|
201
|
+
this.fontSize = model.fontSize;
|
|
202
|
+
this.fontRotation = model.fontRotation;
|
|
203
|
+
this.fontStyle = model.fontStyle;
|
|
204
|
+
this.fontColor = model.fontColor;
|
|
205
|
+
this.backColor = model.backColor;
|
|
206
|
+
this.transparent = model.transparent;
|
|
207
|
+
this.cutText = model.cutText;
|
|
208
|
+
this.wordWrap = model.wordWrap;
|
|
209
|
+
this.isHtml = model.isHtml;
|
|
210
|
+
this.alignment = model.alignment;
|
|
211
|
+
this.vAlignment = model.vAlignment;
|
|
212
|
+
this.singleLine = model.singleLine;
|
|
213
|
+
this.type1Font = model.type1Font;
|
|
214
|
+
this.multiPage = model.multiPage;
|
|
215
|
+
this.printStep = model.printStep;
|
|
216
|
+
this.bidiModes = [...model.bidiModes];
|
|
217
|
+
}
|
|
218
|
+
/** The index of the report language in BidiModes: Language + 1, 0 out of range. */
|
|
219
|
+
bidiLanguageIndex() {
|
|
220
|
+
let langindex = this.report.language + 1;
|
|
221
|
+
if (langindex < 0 || langindex > 256)
|
|
222
|
+
langindex = 0;
|
|
223
|
+
return langindex;
|
|
224
|
+
}
|
|
225
|
+
get bidiMode() {
|
|
226
|
+
const langindex = this.bidiLanguageIndex();
|
|
227
|
+
if (this.bidiModes.length > langindex) {
|
|
228
|
+
if (this.bidiModes[langindex] === 'BidiPartial')
|
|
229
|
+
return BidiModeType.Partial;
|
|
230
|
+
if (this.bidiModes[langindex] === 'BidiFull')
|
|
231
|
+
return BidiModeType.Full;
|
|
232
|
+
}
|
|
233
|
+
return BidiModeType.No;
|
|
234
|
+
}
|
|
235
|
+
/** Right to left text in the current report language. */
|
|
236
|
+
get rightToLeft() {
|
|
237
|
+
return this.bidiMode !== BidiModeType.No;
|
|
238
|
+
}
|
|
239
|
+
/** PrintAlignment: the horizontal alignment flags, mirrored for BidiFull. */
|
|
240
|
+
get printAlignment() {
|
|
241
|
+
let aresult = 0;
|
|
242
|
+
// TextAlignType: Left 0, Right 1, Center 2, Justify 3
|
|
243
|
+
if (this.alignment === 1)
|
|
244
|
+
aresult = AlignmentFlags.AlignRight;
|
|
245
|
+
else if (this.alignment === 2)
|
|
246
|
+
aresult = AlignmentFlags.AlignHCenter;
|
|
247
|
+
else if (this.alignment === 3)
|
|
248
|
+
aresult = AlignmentFlags.AlignHJustify;
|
|
249
|
+
if (this.bidiMode === BidiModeType.Full) {
|
|
250
|
+
if (this.alignment === 0)
|
|
251
|
+
aresult = AlignmentFlags.AlignRight;
|
|
252
|
+
else if (this.alignment === 1)
|
|
253
|
+
aresult = AlignmentFlags.AlignLeft;
|
|
254
|
+
}
|
|
255
|
+
return aresult;
|
|
256
|
+
}
|
|
257
|
+
/** VPrintAlignment: the vertical alignment flags (TextAlignVerticalType: Top 0, Bottom 1, Center 2). */
|
|
258
|
+
get vPrintAlignment() {
|
|
259
|
+
let aresult = 0;
|
|
260
|
+
if (this.vAlignment === 2)
|
|
261
|
+
aresult = AlignmentFlags.AlignVCenter;
|
|
262
|
+
else if (this.vAlignment === 1)
|
|
263
|
+
aresult = AlignmentFlags.AlignBottom;
|
|
264
|
+
return aresult;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* HTML text needs a device that lays it out (the TrueType provider of the PDF device: the
|
|
268
|
+
* FreeType driver); with the standard 14 fonts it fails clearly, where the C# standard driver
|
|
269
|
+
* fails with a NullReferenceException.
|
|
270
|
+
*/
|
|
271
|
+
checkHtml(adriver = null) {
|
|
272
|
+
if (!this.isHtml)
|
|
273
|
+
return;
|
|
274
|
+
const driver = this.report.driver ?? adriver;
|
|
275
|
+
if (driver === null || !driver.supportsHtmlText())
|
|
276
|
+
throw new NotSupportedYetError('HTML text (the item ' + this.name + ')');
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Replaces the {{expression}} placeholders of an HTML text with their values
|
|
280
|
+
* (EvaluateHtmlExpressions); a placeholder that fails to evaluate is kept as it is.
|
|
281
|
+
*/
|
|
282
|
+
evaluateHtmlExpressions(text) {
|
|
283
|
+
if (text === '')
|
|
284
|
+
return text;
|
|
285
|
+
const ev = this.report.evaluator;
|
|
286
|
+
let sb = '';
|
|
287
|
+
let pos = 0;
|
|
288
|
+
while (pos < text.length) {
|
|
289
|
+
const start = text.indexOf('{{', pos);
|
|
290
|
+
if (start < 0) {
|
|
291
|
+
sb += text.substring(pos);
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
const end = text.indexOf('}}', start + 2);
|
|
295
|
+
if (end < 0) {
|
|
296
|
+
sb += text.substring(pos);
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
299
|
+
sb += text.substring(pos, start);
|
|
300
|
+
const expr = trimNet(text.substring(start + 2, end));
|
|
301
|
+
try {
|
|
302
|
+
const result = ev.evaluateText(expr);
|
|
303
|
+
sb += result.toString(ev.context);
|
|
304
|
+
}
|
|
305
|
+
catch {
|
|
306
|
+
sb += text.substring(start, end + 2);
|
|
307
|
+
}
|
|
308
|
+
pos = end + 2;
|
|
309
|
+
}
|
|
310
|
+
return sb;
|
|
311
|
+
}
|
|
312
|
+
textObject(text) {
|
|
313
|
+
let aalign = this.printAlignment | this.vPrintAlignment;
|
|
314
|
+
if (this.singleLine)
|
|
315
|
+
aalign = aalign | AlignmentFlags.SingleLine;
|
|
316
|
+
return {
|
|
317
|
+
text,
|
|
318
|
+
lFontName: this.lFontName,
|
|
319
|
+
wFontName: this.wFontName,
|
|
320
|
+
fontSize: this.fontSize,
|
|
321
|
+
fontRotation: this.fontRotation,
|
|
322
|
+
fontStyle: (this.fontStyle << 16) >> 16,
|
|
323
|
+
type1Font: this.type1Font,
|
|
324
|
+
fontColor: this.fontColor,
|
|
325
|
+
cutText: this.cutText,
|
|
326
|
+
alignment: aalign,
|
|
327
|
+
wordWrap: this.wordWrap,
|
|
328
|
+
rightToLeft: this.rightToLeft,
|
|
329
|
+
printStep: this.printStep,
|
|
330
|
+
isHtml: this.isHtml,
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
/** LabelItem: a fixed text, one per report language. */
|
|
335
|
+
export class LabelItem extends PrintItemText {
|
|
336
|
+
allStrings;
|
|
337
|
+
constructor(report, model) {
|
|
338
|
+
super(report, model);
|
|
339
|
+
this.allStrings = [...model.allStrings];
|
|
340
|
+
}
|
|
341
|
+
/** The text of the report language (item Language + 1), else the default one. */
|
|
342
|
+
get text() {
|
|
343
|
+
let lang = this.report.language + 1;
|
|
344
|
+
if (lang < 0)
|
|
345
|
+
lang = 0;
|
|
346
|
+
if (lang < this.allStrings.length)
|
|
347
|
+
return this.allStrings[lang];
|
|
348
|
+
if (this.allStrings.length > 0)
|
|
349
|
+
return this.allStrings[0];
|
|
350
|
+
return '';
|
|
351
|
+
}
|
|
352
|
+
doPrint(adriver, aposx, aposy, newwidth, newheight, metafile, maxExtent, partialPrint) {
|
|
353
|
+
super.doPrint(adriver, aposx, aposy, newwidth, newheight, metafile, maxExtent, partialPrint);
|
|
354
|
+
this.checkHtml(adriver);
|
|
355
|
+
const apage = metafile.pages.get(metafile.currentPage);
|
|
356
|
+
const metaobj = new MetaObjectText();
|
|
357
|
+
this.fillAnnotation(metaobj, apage);
|
|
358
|
+
const finalText = this.isHtml ? this.evaluateHtmlExpressions(this.text) : this.text;
|
|
359
|
+
metaobj.textP = apage.addString(finalText);
|
|
360
|
+
metaobj.textS = finalText.length;
|
|
361
|
+
metaobj.lFontNameP = apage.addString(this.lFontName);
|
|
362
|
+
metaobj.lFontNameS = this.lFontName.length;
|
|
363
|
+
metaobj.wFontNameP = apage.addString(this.wFontName);
|
|
364
|
+
metaobj.wFontNameS = this.wFontName.length;
|
|
365
|
+
metaobj.fontSize = this.fontSize;
|
|
366
|
+
metaobj.backColor = this.backColor;
|
|
367
|
+
metaobj.fontRotation = this.fontRotation;
|
|
368
|
+
metaobj.fontStyle = (this.fontStyle << 16) >> 16;
|
|
369
|
+
metaobj.fontColor = this.fontColor;
|
|
370
|
+
metaobj.type1Font = this.type1Font;
|
|
371
|
+
metaobj.cutText = this.cutText;
|
|
372
|
+
metaobj.transparent = this.transparent;
|
|
373
|
+
metaobj.wordWrap = this.wordWrap;
|
|
374
|
+
metaobj.top = aposy;
|
|
375
|
+
metaobj.left = aposx;
|
|
376
|
+
metaobj.width = this.printWidth;
|
|
377
|
+
metaobj.height = this.printHeight;
|
|
378
|
+
metaobj.rightToLeft = this.rightToLeft;
|
|
379
|
+
metaobj.printStep = this.printStep;
|
|
380
|
+
metaobj.isHtml = this.isHtml;
|
|
381
|
+
let aalign = this.printAlignment | this.vPrintAlignment;
|
|
382
|
+
if (this.singleLine)
|
|
383
|
+
aalign = aalign | AlignmentFlags.SingleLine;
|
|
384
|
+
metaobj.alignment = aalign;
|
|
385
|
+
apage.objects.push(metaobj);
|
|
386
|
+
}
|
|
387
|
+
getExtension(adriver, maxExtent, forcePartial) {
|
|
388
|
+
this.checkHtml(adriver);
|
|
389
|
+
const atext = this.textObject(this.isHtml ? this.evaluateHtmlExpressions(this.text) : this.text);
|
|
390
|
+
let aresult = super.getExtension(adriver, maxExtent, forcePartial);
|
|
391
|
+
aresult = adriver.textExtent(atext, aresult);
|
|
392
|
+
this.lastExtent = { ...aresult };
|
|
393
|
+
return aresult;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
/** Aggregate and AggregateType of an expression item. */
|
|
397
|
+
export var Aggregate;
|
|
398
|
+
(function (Aggregate) {
|
|
399
|
+
Aggregate[Aggregate["None"] = 0] = "None";
|
|
400
|
+
Aggregate[Aggregate["Group"] = 1] = "Group";
|
|
401
|
+
Aggregate[Aggregate["Page"] = 2] = "Page";
|
|
402
|
+
Aggregate[Aggregate["General"] = 3] = "General";
|
|
403
|
+
})(Aggregate || (Aggregate = {}));
|
|
404
|
+
export var AggregateType;
|
|
405
|
+
(function (AggregateType) {
|
|
406
|
+
AggregateType[AggregateType["Summary"] = 0] = "Summary";
|
|
407
|
+
AggregateType[AggregateType["Minimum"] = 1] = "Minimum";
|
|
408
|
+
AggregateType[AggregateType["Maximum"] = 2] = "Maximum";
|
|
409
|
+
AggregateType[AggregateType["Average"] = 3] = "Average";
|
|
410
|
+
AggregateType[AggregateType["StandardDeviation"] = 4] = "StandardDeviation";
|
|
411
|
+
})(AggregateType || (AggregateType = {}));
|
|
412
|
+
const PAGE_COUNT_PLACEHOLDER = ' ';
|
|
413
|
+
/** ExpressionItem: the formatted value of an expression, with aggregates and multipage text. */
|
|
414
|
+
export class ExpressionItem extends PrintItemText {
|
|
415
|
+
fValues = [];
|
|
416
|
+
idenExpression;
|
|
417
|
+
fIsPartial = false;
|
|
418
|
+
// C# parity: FForcedPartial is only ever cleared, so a forced partial measurement (a section
|
|
419
|
+
// that does not fit an empty page) is not printed partially.
|
|
420
|
+
fForcedPartial = false;
|
|
421
|
+
fOldString = '';
|
|
422
|
+
/** The rest of an HTML text that continues on the next page (FHtmlPartialText). */
|
|
423
|
+
fHtmlPartialText = null;
|
|
424
|
+
fUpdated = false;
|
|
425
|
+
fDataCount = 0;
|
|
426
|
+
fSumValue = Variant.null;
|
|
427
|
+
expression;
|
|
428
|
+
groupName;
|
|
429
|
+
aggregate;
|
|
430
|
+
agType;
|
|
431
|
+
identifier;
|
|
432
|
+
autoExpand;
|
|
433
|
+
autoContract;
|
|
434
|
+
displayFormat;
|
|
435
|
+
exportDisplayFormat;
|
|
436
|
+
dataType;
|
|
437
|
+
value = Variant.null;
|
|
438
|
+
agIniValue;
|
|
439
|
+
printOnlyOne;
|
|
440
|
+
printNulls;
|
|
441
|
+
partialPos = 0;
|
|
442
|
+
exportExpression;
|
|
443
|
+
isPageCount = false;
|
|
444
|
+
isGroupPageCount = false;
|
|
445
|
+
lastMetaIndex = 0;
|
|
446
|
+
constructor(report, model) {
|
|
447
|
+
super(report, model);
|
|
448
|
+
this.expression = model.expression;
|
|
449
|
+
this.groupName = model.groupName;
|
|
450
|
+
this.aggregate = model.aggregate;
|
|
451
|
+
this.agType = model.agType;
|
|
452
|
+
this.identifier = model.identifier;
|
|
453
|
+
this.autoExpand = model.autoExpand;
|
|
454
|
+
this.autoContract = model.autoContract;
|
|
455
|
+
this.displayFormat = model.displayFormat;
|
|
456
|
+
this.exportDisplayFormat = model.exportDisplayFormat;
|
|
457
|
+
this.dataType = model.dataType;
|
|
458
|
+
this.agIniValue = model.agIniValue;
|
|
459
|
+
this.printOnlyOne = model.printOnlyOne;
|
|
460
|
+
this.printNulls = model.printNulls;
|
|
461
|
+
this.exportExpression = model.exportExpression;
|
|
462
|
+
this.updateIsPageCount();
|
|
463
|
+
this.idenExpression = new EvalIdenExpression(null, () => {
|
|
464
|
+
this.evaluate();
|
|
465
|
+
return this.value;
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
/** The text was cut and the rest prints in the next page. */
|
|
469
|
+
get isPartial() {
|
|
470
|
+
return this.fIsPartial;
|
|
471
|
+
}
|
|
472
|
+
updateIsPageCount() {
|
|
473
|
+
this.isPageCount = false;
|
|
474
|
+
this.isGroupPageCount = false;
|
|
475
|
+
const astring = toUpperNet(trimNet(this.expression));
|
|
476
|
+
if (astring === 'PAGECOUNT')
|
|
477
|
+
this.isPageCount = true;
|
|
478
|
+
else if (astring === 'GROUPPAGECOUNT')
|
|
479
|
+
this.isGroupPageCount = true;
|
|
480
|
+
}
|
|
481
|
+
/** Evaluate: the value of the expression, cached until the item is invalidated. */
|
|
482
|
+
evaluate() {
|
|
483
|
+
if (this.fUpdated)
|
|
484
|
+
return;
|
|
485
|
+
const fevaluator = this.report.evaluator;
|
|
486
|
+
try {
|
|
487
|
+
this.value = fevaluator.evaluateText(this.expression);
|
|
488
|
+
this.fUpdated = true;
|
|
489
|
+
}
|
|
490
|
+
catch (e) {
|
|
491
|
+
throw new ReportException(messageOf(e) + '\n' + this.name + ' Prop:Expression', this.name, 'Expression');
|
|
492
|
+
}
|
|
493
|
+
if (this.exportExpression.length > 0) {
|
|
494
|
+
try {
|
|
495
|
+
// C# parity: the export expression is assigned to Value, not to the export value.
|
|
496
|
+
this.value = fevaluator.evaluateText(this.exportExpression);
|
|
497
|
+
}
|
|
498
|
+
catch (e) {
|
|
499
|
+
throw new ReportException(messageOf(e) + '\n' + this.name + ' Prop:ExportExpression', this.name, 'ExportExpression');
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
getText() {
|
|
504
|
+
const expre = trimNet(this.expression);
|
|
505
|
+
if (expre.length === 0)
|
|
506
|
+
return '';
|
|
507
|
+
if (this.isPageCount || this.isGroupPageCount)
|
|
508
|
+
return PAGE_COUNT_PLACEHOLDER;
|
|
509
|
+
let aresult;
|
|
510
|
+
try {
|
|
511
|
+
this.evaluate();
|
|
512
|
+
aresult = this.value.toFormatString(this.report.evaluator.context, this.displayFormat, this.dataType, this.printNulls);
|
|
513
|
+
if (this.isHtml)
|
|
514
|
+
aresult = this.evaluateHtmlExpressions(aresult);
|
|
515
|
+
}
|
|
516
|
+
catch (e) {
|
|
517
|
+
if (e instanceof ReportException)
|
|
518
|
+
throw e;
|
|
519
|
+
throw new ReportException(messageOf(e) + '\n' + this.name + ' Prop:Expression', this.name, 'Expression');
|
|
520
|
+
}
|
|
521
|
+
// The rest of an HTML text that continues on this page
|
|
522
|
+
if (this.isHtml && this.fIsPartial && this.fHtmlPartialText !== null)
|
|
523
|
+
return this.fHtmlPartialText;
|
|
524
|
+
if (this.isPartial) {
|
|
525
|
+
if (this.partialPos < aresult.length && (aresult.charAt(this.partialPos) === ' ' || aresult.charCodeAt(this.partialPos) === 10))
|
|
526
|
+
this.partialPos++;
|
|
527
|
+
if (this.partialPos > aresult.length)
|
|
528
|
+
this.partialPos = aresult.length;
|
|
529
|
+
aresult = aresult.substring(this.partialPos);
|
|
530
|
+
}
|
|
531
|
+
return aresult;
|
|
532
|
+
}
|
|
533
|
+
getTextObject() {
|
|
534
|
+
this.checkHtml();
|
|
535
|
+
return this.textObject(this.getText());
|
|
536
|
+
}
|
|
537
|
+
doPrint(adriver, aposx, aposy, newwidth, newheight, metafile, maxExtent, partialPrint) {
|
|
538
|
+
super.doPrint(adriver, aposx, aposy, newwidth, newheight, metafile, maxExtent, partialPrint);
|
|
539
|
+
this.lastMetaIndex = -1;
|
|
540
|
+
const textObj = this.getTextObject();
|
|
541
|
+
if (this.printOnlyOne) {
|
|
542
|
+
if (this.fOldString === textObj.text)
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
this.fOldString = textObj.text;
|
|
546
|
+
if (this.multiPage || this.fForcedPartial) {
|
|
547
|
+
const extent = { ...maxExtent, x: this.printWidth };
|
|
548
|
+
if (this.isHtml) {
|
|
549
|
+
let split = this.trySplitHtmlForMultipage(adriver, textObj, extent);
|
|
550
|
+
if (split === null)
|
|
551
|
+
split = { current: textObj.text, remaining: '' };
|
|
552
|
+
textObj.text = split.current;
|
|
553
|
+
if (split.remaining !== '') {
|
|
554
|
+
this.fIsPartial = true;
|
|
555
|
+
partialPrint.value = true;
|
|
556
|
+
this.fHtmlPartialText = split.remaining;
|
|
557
|
+
}
|
|
558
|
+
else {
|
|
559
|
+
this.fIsPartial = false;
|
|
560
|
+
this.fForcedPartial = false;
|
|
561
|
+
this.fHtmlPartialText = null;
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
else {
|
|
565
|
+
this.fHtmlPartialText = null;
|
|
566
|
+
const driver = this.report.driver;
|
|
567
|
+
if (driver === null)
|
|
568
|
+
throw new Error('Object reference not set to an instance of an object.');
|
|
569
|
+
const newposition = MetaFile.calcTextExtent(driver, extent, textObj);
|
|
570
|
+
if (newposition < textObj.text.length) {
|
|
571
|
+
if (!this.fIsPartial)
|
|
572
|
+
this.partialPos = 0;
|
|
573
|
+
this.fIsPartial = true;
|
|
574
|
+
partialPrint.value = true;
|
|
575
|
+
this.partialPos = this.partialPos + newposition;
|
|
576
|
+
textObj.text = textObj.text.substring(0, newposition);
|
|
577
|
+
}
|
|
578
|
+
else {
|
|
579
|
+
this.fIsPartial = false;
|
|
580
|
+
this.fForcedPartial = false;
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
const apage = metafile.pages.get(metafile.currentPage);
|
|
585
|
+
const aobj = new MetaObjectText();
|
|
586
|
+
this.fillAnnotation(aobj, apage);
|
|
587
|
+
aobj.metaType = MetaObjectType.Text;
|
|
588
|
+
aobj.left = aposx;
|
|
589
|
+
aobj.top = aposy;
|
|
590
|
+
aobj.width = this.printWidth;
|
|
591
|
+
aobj.height = this.printHeight;
|
|
592
|
+
aobj.alignment = textObj.alignment;
|
|
593
|
+
aobj.printStep = this.printStep;
|
|
594
|
+
aobj.backColor = this.backColor;
|
|
595
|
+
aobj.transparent = this.transparent;
|
|
596
|
+
aobj.cutText = this.cutText;
|
|
597
|
+
aobj.fontColor = this.fontColor;
|
|
598
|
+
aobj.fontRotation = this.fontRotation;
|
|
599
|
+
aobj.type1Font = this.type1Font;
|
|
600
|
+
aobj.fontSize = this.fontSize;
|
|
601
|
+
aobj.fontStyle = (this.fontStyle << 16) >> 16;
|
|
602
|
+
aobj.textP = apage.addString(textObj.text);
|
|
603
|
+
aobj.textS = textObj.text.length;
|
|
604
|
+
aobj.wordWrap = this.wordWrap;
|
|
605
|
+
aobj.lFontNameP = apage.addString(this.lFontName);
|
|
606
|
+
aobj.lFontNameS = this.lFontName.length;
|
|
607
|
+
aobj.wFontNameP = apage.addString(this.wFontName);
|
|
608
|
+
aobj.wFontNameS = this.wFontName.length;
|
|
609
|
+
aobj.rightToLeft = textObj.rightToLeft;
|
|
610
|
+
aobj.isHtml = textObj.isHtml;
|
|
611
|
+
apage.objects.push(aobj);
|
|
612
|
+
this.lastMetaIndex = apage.objects.length - 1;
|
|
613
|
+
// Is Total pages variable?
|
|
614
|
+
if (this.isPageCount)
|
|
615
|
+
this.report.addTotalPagesItem(metafile.currentPage, apage.objects.length - 1, this.displayFormat);
|
|
616
|
+
// C# parity: DoPrint tests the ExportValue property, which nothing assigns (Evaluate keeps the
|
|
617
|
+
// export value in a field of its own), so no export object is ever written.
|
|
618
|
+
}
|
|
619
|
+
subReportChanged(newstate, newgroup) {
|
|
620
|
+
super.subReportChanged(newstate, newgroup);
|
|
621
|
+
const ev = this.report.evaluator;
|
|
622
|
+
const iniValue = () => {
|
|
623
|
+
try {
|
|
624
|
+
ev.expression = this.agIniValue;
|
|
625
|
+
ev.evaluate();
|
|
626
|
+
this.value = ev.result;
|
|
627
|
+
this.fSumValue = this.value;
|
|
628
|
+
this.fUpdated = true;
|
|
629
|
+
}
|
|
630
|
+
catch (e) {
|
|
631
|
+
throw new ReportException(messageOf(e) + '\n' + this.name + ' Prop:AgIniValue', this.name, 'AgIniValue');
|
|
632
|
+
}
|
|
633
|
+
};
|
|
634
|
+
switch (newstate) {
|
|
635
|
+
case SubReportEvent.Start:
|
|
636
|
+
this.fIsPartial = false;
|
|
637
|
+
this.fForcedPartial = false;
|
|
638
|
+
this.fHtmlPartialText = null;
|
|
639
|
+
this.fOldString = '';
|
|
640
|
+
this.fUpdated = false;
|
|
641
|
+
this.fDataCount = 0;
|
|
642
|
+
if (this.aggregate !== Aggregate.None)
|
|
643
|
+
iniValue();
|
|
644
|
+
break;
|
|
645
|
+
case SubReportEvent.SubReportStart:
|
|
646
|
+
this.fIsPartial = false;
|
|
647
|
+
this.fForcedPartial = false;
|
|
648
|
+
this.fHtmlPartialText = null;
|
|
649
|
+
this.fOldString = '';
|
|
650
|
+
this.fUpdated = false;
|
|
651
|
+
this.fDataCount = 0;
|
|
652
|
+
if (this.aggregate !== Aggregate.None && this.aggregate !== Aggregate.General)
|
|
653
|
+
iniValue();
|
|
654
|
+
break;
|
|
655
|
+
case SubReportEvent.DataChange:
|
|
656
|
+
this.fIsPartial = false;
|
|
657
|
+
this.fForcedPartial = false;
|
|
658
|
+
this.fHtmlPartialText = null;
|
|
659
|
+
this.fUpdated = false;
|
|
660
|
+
this.fDataCount++;
|
|
661
|
+
if (this.aggregate !== Aggregate.None) {
|
|
662
|
+
try {
|
|
663
|
+
ev.expression = this.expression;
|
|
664
|
+
ev.evaluate();
|
|
665
|
+
const ctx = ev.context;
|
|
666
|
+
const result = ev.result;
|
|
667
|
+
switch (this.agType) {
|
|
668
|
+
case AggregateType.Summary:
|
|
669
|
+
if (result.varType !== VariantType.Null)
|
|
670
|
+
this.value = Variant.add(this.value, result, ctx);
|
|
671
|
+
break;
|
|
672
|
+
case AggregateType.Minimum:
|
|
673
|
+
if (result.varType !== VariantType.Null) {
|
|
674
|
+
if (Variant.greaterThan(this.value, result, ctx))
|
|
675
|
+
this.value = result;
|
|
676
|
+
}
|
|
677
|
+
break;
|
|
678
|
+
case AggregateType.Maximum:
|
|
679
|
+
if (result.varType !== VariantType.Null) {
|
|
680
|
+
if (Variant.lessThan(this.value, result, ctx))
|
|
681
|
+
this.value = result;
|
|
682
|
+
}
|
|
683
|
+
break;
|
|
684
|
+
case AggregateType.Average:
|
|
685
|
+
if (result.varType === VariantType.Null)
|
|
686
|
+
this.fDataCount--;
|
|
687
|
+
else {
|
|
688
|
+
this.fSumValue = Variant.add(this.fSumValue, result, ctx);
|
|
689
|
+
this.value = Variant.div(this.fSumValue, Variant.fromInteger(this.fDataCount), ctx);
|
|
690
|
+
}
|
|
691
|
+
break;
|
|
692
|
+
case AggregateType.StandardDeviation:
|
|
693
|
+
if (result.varType === VariantType.Null)
|
|
694
|
+
this.fDataCount--;
|
|
695
|
+
else {
|
|
696
|
+
// C# parity: the list of values is never cleared, not even by a group change
|
|
697
|
+
this.fValues.push(result.toDouble(ctx));
|
|
698
|
+
this.value = Variant.fromDouble(standardDeviation(this.fValues));
|
|
699
|
+
}
|
|
700
|
+
break;
|
|
701
|
+
}
|
|
702
|
+
this.fUpdated = true;
|
|
703
|
+
}
|
|
704
|
+
catch (e) {
|
|
705
|
+
throw new ReportException(messageOf(e) + '\n' + this.name + ' Prop:Expression', this.name, 'Expression');
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
break;
|
|
709
|
+
case SubReportEvent.GroupChange:
|
|
710
|
+
this.fIsPartial = false;
|
|
711
|
+
this.fForcedPartial = false;
|
|
712
|
+
this.fHtmlPartialText = null;
|
|
713
|
+
this.fUpdated = false;
|
|
714
|
+
this.fOldString = '';
|
|
715
|
+
if (this.aggregate === Aggregate.Group) {
|
|
716
|
+
if (toUpperNet(this.groupName) === toUpperNet(newgroup))
|
|
717
|
+
iniValue();
|
|
718
|
+
}
|
|
719
|
+
break;
|
|
720
|
+
case SubReportEvent.PageChange:
|
|
721
|
+
this.fOldString = '';
|
|
722
|
+
// Page variable must be recalculated
|
|
723
|
+
if (this.aggregate === Aggregate.None)
|
|
724
|
+
this.fUpdated = false;
|
|
725
|
+
if (this.aggregate === Aggregate.Page) {
|
|
726
|
+
iniValue();
|
|
727
|
+
this.subReportChanged(SubReportEvent.DataChange, '');
|
|
728
|
+
}
|
|
729
|
+
break;
|
|
730
|
+
case SubReportEvent.InvalidateValue:
|
|
731
|
+
this.fIsPartial = false;
|
|
732
|
+
this.fForcedPartial = false;
|
|
733
|
+
this.fHtmlPartialText = null;
|
|
734
|
+
this.fOldString = '';
|
|
735
|
+
this.fUpdated = false;
|
|
736
|
+
break;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
getExtension(adriver, maxExtent, forcePartial) {
|
|
740
|
+
const atext = this.getTextObject();
|
|
741
|
+
// Items printed only one time, have no extension
|
|
742
|
+
if (this.printOnlyOne) {
|
|
743
|
+
if (this.fOldString === atext.text)
|
|
744
|
+
return pt(0, 0);
|
|
745
|
+
}
|
|
746
|
+
let isPartial = false;
|
|
747
|
+
let aresult = super.getExtension(adriver, maxExtent, forcePartial);
|
|
748
|
+
if (this.multiPage || forcePartial) {
|
|
749
|
+
const extent = { ...maxExtent, x: aresult.x };
|
|
750
|
+
if (this.isHtml) {
|
|
751
|
+
let split = this.trySplitHtmlForMultipage(adriver, atext, extent);
|
|
752
|
+
if (split === null)
|
|
753
|
+
split = { current: atext.text, remaining: '' };
|
|
754
|
+
isPartial = split.remaining !== '';
|
|
755
|
+
atext.text = split.current;
|
|
756
|
+
aresult = adriver.textExtent(atext, aresult);
|
|
757
|
+
if (isPartial)
|
|
758
|
+
aresult.y = extent.y;
|
|
759
|
+
}
|
|
760
|
+
else {
|
|
761
|
+
const aposition = MetaFile.calcTextExtent(adriver, extent, atext);
|
|
762
|
+
if (aposition < atext.text.length)
|
|
763
|
+
isPartial = true;
|
|
764
|
+
atext.text = atext.text.substring(0, aposition);
|
|
765
|
+
aresult = adriver.textExtent(atext, aresult);
|
|
766
|
+
if (isPartial)
|
|
767
|
+
aresult.y = extent.y;
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
else
|
|
771
|
+
aresult = adriver.textExtent(atext, aresult);
|
|
772
|
+
this.lastExtent = { ...aresult };
|
|
773
|
+
return aresult;
|
|
774
|
+
}
|
|
775
|
+
/**
|
|
776
|
+
* The part of an HTML text that fits the height of the extent and the rest (TrySplitHtmlForMultipage):
|
|
777
|
+
* the lines of the layout that fit give the length of plain text that fits, the runs are split
|
|
778
|
+
* there, a blank at the start of the rest is skipped and both parts are written again as HTML.
|
|
779
|
+
* Null when the text cannot be split (the whole text then goes on this page).
|
|
780
|
+
*/
|
|
781
|
+
trySplitHtmlForMultipage(adriver, textObj, maxExtent) {
|
|
782
|
+
const all = { current: textObj.text, remaining: '' };
|
|
783
|
+
if (textObj.text === '' || maxExtent.y <= 0)
|
|
784
|
+
return all;
|
|
785
|
+
const measureExtent = { ...maxExtent };
|
|
786
|
+
if (measureExtent.x <= 0)
|
|
787
|
+
measureExtent.x = this.printWidth;
|
|
788
|
+
const lines = adriver.textExtentLineInfo(textObj, measureExtent).lines;
|
|
789
|
+
if (lines === null || lines.length === 0)
|
|
790
|
+
return null;
|
|
791
|
+
let visibleLength = 0;
|
|
792
|
+
let consumedHeight = 0;
|
|
793
|
+
for (const line of lines) {
|
|
794
|
+
const lineHeight = line.height > 0 ? line.height : roundHalfEven(line.lineHeight);
|
|
795
|
+
if (lineHeight <= 0)
|
|
796
|
+
continue;
|
|
797
|
+
if (consumedHeight + lineHeight > maxExtent.y)
|
|
798
|
+
break;
|
|
799
|
+
consumedHeight += lineHeight;
|
|
800
|
+
const lineEnd = line.position + line.size;
|
|
801
|
+
if (lineEnd > visibleLength)
|
|
802
|
+
visibleLength = lineEnd;
|
|
803
|
+
}
|
|
804
|
+
if (visibleLength <= 0)
|
|
805
|
+
return null;
|
|
806
|
+
const runs = HtmlTextParser.parse(textObj.text, this.wFontName);
|
|
807
|
+
let totalPlainLength = 0;
|
|
808
|
+
for (const run of runs)
|
|
809
|
+
totalPlainLength += run.text.length;
|
|
810
|
+
if (totalPlainLength <= 0)
|
|
811
|
+
return all;
|
|
812
|
+
if (visibleLength >= totalPlainLength)
|
|
813
|
+
return all;
|
|
814
|
+
const currentRuns = [];
|
|
815
|
+
const remainingRuns = [];
|
|
816
|
+
let remainingVisible = visibleLength;
|
|
817
|
+
for (const run of runs) {
|
|
818
|
+
const runText = run.text;
|
|
819
|
+
if (remainingVisible <= 0) {
|
|
820
|
+
if (runText.length > 0)
|
|
821
|
+
remainingRuns.push({ ...run });
|
|
822
|
+
continue;
|
|
823
|
+
}
|
|
824
|
+
if (runText.length <= remainingVisible) {
|
|
825
|
+
if (runText.length > 0)
|
|
826
|
+
currentRuns.push({ ...run });
|
|
827
|
+
remainingVisible -= runText.length;
|
|
828
|
+
continue;
|
|
829
|
+
}
|
|
830
|
+
currentRuns.push({ ...run, text: runText.substring(0, remainingVisible) });
|
|
831
|
+
remainingRuns.push({ ...run, text: runText.substring(remainingVisible) });
|
|
832
|
+
remainingVisible = 0;
|
|
833
|
+
}
|
|
834
|
+
// A blank at the start of the rest is skipped
|
|
835
|
+
for (let index = 0; index < remainingRuns.length; index++) {
|
|
836
|
+
const run = remainingRuns[index];
|
|
837
|
+
if (run.text === '')
|
|
838
|
+
continue;
|
|
839
|
+
const first = run.text.charAt(0);
|
|
840
|
+
if (first === ' ' || first === '\n') {
|
|
841
|
+
run.text = run.text.substring(1);
|
|
842
|
+
if (run.text === '')
|
|
843
|
+
remainingRuns.splice(index, 1);
|
|
844
|
+
}
|
|
845
|
+
break;
|
|
846
|
+
}
|
|
847
|
+
if (!hasPrintableHtmlContent(remainingRuns))
|
|
848
|
+
return all;
|
|
849
|
+
const current = buildHtmlFromRuns(currentRuns);
|
|
850
|
+
const remaining = buildHtmlFromRuns(remainingRuns);
|
|
851
|
+
if (current === '' || remaining === '')
|
|
852
|
+
return null;
|
|
853
|
+
return { current, remaining };
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
/** Whether runs have a character that is not white space (HasPrintableHtmlContent). */
|
|
857
|
+
function hasPrintableHtmlContent(runs) {
|
|
858
|
+
for (const run of runs) {
|
|
859
|
+
for (const ch of run.text) {
|
|
860
|
+
const c = ch.charCodeAt(0);
|
|
861
|
+
const white = c === 0x20 || (c >= 0x09 && c <= 0x0d) || c === 0x85 || c === 0xa0 || c === 0x1680 || (c >= 0x2000 && c <= 0x200a) || c === 0x2028 || c === 0x2029 || c === 0x202f || c === 0x205f || c === 0x3000;
|
|
862
|
+
if (!white && c !== 0xa0)
|
|
863
|
+
return true;
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
return false;
|
|
867
|
+
}
|
|
868
|
+
function hex2(v) {
|
|
869
|
+
return (v & 0xff).toString(16).toUpperCase().padStart(2, '0');
|
|
870
|
+
}
|
|
871
|
+
/** The HTML of styled runs (BuildHtmlFromRuns). */
|
|
872
|
+
function buildHtmlFromRuns(runs) {
|
|
873
|
+
let builder = '';
|
|
874
|
+
for (const run of runs) {
|
|
875
|
+
if (run.text === '')
|
|
876
|
+
continue;
|
|
877
|
+
let segment = encodeHtmlText(run.text);
|
|
878
|
+
if (segment === '')
|
|
879
|
+
continue;
|
|
880
|
+
if (run.hasColor)
|
|
881
|
+
segment = '<font color="#' + hex2(run.color) + hex2(run.color >> 8) + hex2(run.color >> 16) + '">' + segment + '</font>';
|
|
882
|
+
if (run.hasFontSize)
|
|
883
|
+
segment = '<span style="font-size:' + formatSize(run.fontSize) + 'pt">' + segment + '</span>';
|
|
884
|
+
if (run.fontFamily !== null && run.fontFamily !== '')
|
|
885
|
+
segment = '<font face="' + encodeHtmlAttribute(run.fontFamily) + '">' + segment + '</font>';
|
|
886
|
+
if (run.strikeOut)
|
|
887
|
+
segment = '<strike>' + segment + '</strike>';
|
|
888
|
+
if (run.underline)
|
|
889
|
+
segment = '<u>' + segment + '</u>';
|
|
890
|
+
if (run.italic)
|
|
891
|
+
segment = '<i>' + segment + '</i>';
|
|
892
|
+
if (run.bold)
|
|
893
|
+
segment = '<b>' + segment + '</b>';
|
|
894
|
+
builder += segment;
|
|
895
|
+
}
|
|
896
|
+
return builder;
|
|
897
|
+
}
|
|
898
|
+
/** float.ToString("0.##"): at most two decimals, rounded half away from zero, no trailing zeros. */
|
|
899
|
+
function formatSize(v) {
|
|
900
|
+
const r = Math.round(Math.abs(v) * 100) / 100;
|
|
901
|
+
let s = r.toFixed(2).replace(/\.?0+$/, '');
|
|
902
|
+
if (v < 0 && s !== '0')
|
|
903
|
+
s = '-' + s;
|
|
904
|
+
return s;
|
|
905
|
+
}
|
|
906
|
+
function encodeHtmlText(text) {
|
|
907
|
+
let b = '';
|
|
908
|
+
for (const ch of text) {
|
|
909
|
+
switch (ch) {
|
|
910
|
+
case '&':
|
|
911
|
+
b += '&';
|
|
912
|
+
break;
|
|
913
|
+
case '<':
|
|
914
|
+
b += '<';
|
|
915
|
+
break;
|
|
916
|
+
case '>':
|
|
917
|
+
b += '>';
|
|
918
|
+
break;
|
|
919
|
+
case '"':
|
|
920
|
+
b += '"';
|
|
921
|
+
break;
|
|
922
|
+
case '\r':
|
|
923
|
+
break;
|
|
924
|
+
case '\n':
|
|
925
|
+
b += '<br>';
|
|
926
|
+
break;
|
|
927
|
+
case ' ':
|
|
928
|
+
b += ' ';
|
|
929
|
+
break;
|
|
930
|
+
default:
|
|
931
|
+
b += ch;
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
return b;
|
|
935
|
+
}
|
|
936
|
+
function encodeHtmlAttribute(value) {
|
|
937
|
+
return value.replaceAll('&', '&').replaceAll('"', '"').replaceAll('<', '<').replaceAll('>', '>');
|
|
938
|
+
}
|
|
939
|
+
/** ShapeItem: a rectangle, an ellipse, a line... */
|
|
940
|
+
export class ShapeItem extends PrintPosItem {
|
|
941
|
+
brushStyle;
|
|
942
|
+
brushColor;
|
|
943
|
+
penStyle;
|
|
944
|
+
shape;
|
|
945
|
+
penWidth;
|
|
946
|
+
penColor;
|
|
947
|
+
// C# parity: the reader never reads BrushColorExpression, so it is always empty
|
|
948
|
+
brushColorExpression = '';
|
|
949
|
+
constructor(report, model) {
|
|
950
|
+
super(report, model);
|
|
951
|
+
this.brushStyle = model.brushStyle;
|
|
952
|
+
this.brushColor = model.brushColor;
|
|
953
|
+
this.penStyle = model.penStyle;
|
|
954
|
+
this.shape = model.shape;
|
|
955
|
+
this.penWidth = model.penWidth;
|
|
956
|
+
this.penColor = model.penColor;
|
|
957
|
+
}
|
|
958
|
+
doPrint(adriver, aposx, aposy, newwidth, newheight, metafile, maxExtent, partialPrint) {
|
|
959
|
+
super.doPrint(adriver, aposx, aposy, newwidth, newheight, metafile, maxExtent, partialPrint);
|
|
960
|
+
const apage = metafile.pages.get(metafile.currentPage);
|
|
961
|
+
const metaobj = new MetaObjectDraw();
|
|
962
|
+
this.fillAnnotation(metaobj, apage);
|
|
963
|
+
metaobj.metaType = MetaObjectType.Draw;
|
|
964
|
+
metaobj.top = aposy;
|
|
965
|
+
metaobj.left = aposx;
|
|
966
|
+
metaobj.width = this.printWidth;
|
|
967
|
+
metaobj.height = this.printHeight;
|
|
968
|
+
metaobj.drawStyle = this.shape;
|
|
969
|
+
metaobj.brushStyle = this.brushStyle;
|
|
970
|
+
metaobj.penStyle = this.penStyle;
|
|
971
|
+
metaobj.penWidth = this.penWidth;
|
|
972
|
+
metaobj.penColor = this.penColor;
|
|
973
|
+
if (this.brushColorExpression.length > 0) {
|
|
974
|
+
try {
|
|
975
|
+
const ev = this.report.evaluator;
|
|
976
|
+
metaobj.brushColor = ev.evaluateText(this.brushColorExpression).toInt(ev.context);
|
|
977
|
+
}
|
|
978
|
+
catch {
|
|
979
|
+
metaobj.brushColor = this.brushColor;
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
else
|
|
983
|
+
metaobj.brushColor = this.brushColor;
|
|
984
|
+
apage.objects.push(metaobj);
|
|
985
|
+
}
|
|
986
|
+
getExtension(adriver, maxExtent, forcePartial) {
|
|
987
|
+
const aresult = super.getExtension(adriver, maxExtent, forcePartial);
|
|
988
|
+
// ShapeType.HorzLine
|
|
989
|
+
if (this.shape === 6)
|
|
990
|
+
aresult.y = this.penWidth;
|
|
991
|
+
this.lastExtent = { ...aresult };
|
|
992
|
+
return aresult;
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
/**
|
|
996
|
+
* An item the TypeScript engine does not draw yet (images, charts): the report fails
|
|
997
|
+
* with a clear error when the item is measured or printed, instead of printing something else.
|
|
998
|
+
*/
|
|
999
|
+
export class UnsupportedItem extends PrintPosItem {
|
|
1000
|
+
what;
|
|
1001
|
+
constructor(report, model, what) {
|
|
1002
|
+
super(report, model);
|
|
1003
|
+
this.what = what;
|
|
1004
|
+
}
|
|
1005
|
+
fail() {
|
|
1006
|
+
throw new NotSupportedYetError(this.what + ' (the item ' + this.name + ')');
|
|
1007
|
+
}
|
|
1008
|
+
getExtension(_adriver, _maxExtent, _forcePartial) {
|
|
1009
|
+
this.fail();
|
|
1010
|
+
}
|
|
1011
|
+
doPrint() {
|
|
1012
|
+
this.fail();
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
//# sourceMappingURL=items.js.map
|