@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,1974 @@
|
|
|
1
|
+
// Port of the runtime part of Reportman.Reporting.BaseReport and Report: a report while it is
|
|
2
|
+
// laid out into a metafile (BeginPrint, the parameters, the datasets, PrintNextPage with its
|
|
3
|
+
// sections, groups, page headers and footers, columns, skips and page counts, EndPrint).
|
|
4
|
+
//
|
|
5
|
+
// The operations that may reach the data host are Ops (see data/op.ts); the rest, as the
|
|
6
|
+
// evaluator, is synchronous.
|
|
7
|
+
import { MetaFile, MetaObjectDraw, MetaObjectImage, MetaObjectText, MetaObjectType, MetaPage, PageSizeDetail, } from '@reportman/metafile';
|
|
8
|
+
import { Evaluator } from '../eval/evaluator.js';
|
|
9
|
+
import { DatasetAlias } from '../eval/fields.js';
|
|
10
|
+
import { EvalIdentifiers, IdenVariableParam } from '../eval/identifiers.js';
|
|
11
|
+
import { fromBase64String } from '../util/base64.js';
|
|
12
|
+
import { toUpperNet, trimNet, replaceNet } from '../util/chars.js';
|
|
13
|
+
import { CultureInfo } from '../util/culture.js';
|
|
14
|
+
import { formatDateTime, utcTimeZone } from '../util/dateformat.js';
|
|
15
|
+
import { messageOf, NamedException, nullReferenceException, UnNamedException } from '../util/netexception.js';
|
|
16
|
+
import { formatDecimal, formatDouble, formatInteger } from '../util/numberformat.js';
|
|
17
|
+
import { convertDoubleToInt32, NumberStyles, parseInt32 } from '../util/numberparse.js';
|
|
18
|
+
import { Translator } from '../util/translator.js';
|
|
19
|
+
import { ParamType, Variant, VariantType } from '../variant/variant.js';
|
|
20
|
+
import { DriverType } from '@reportman/lib';
|
|
21
|
+
import { ReportDatabase } from '../data/databaseinfo.js';
|
|
22
|
+
import { ReportDataInfo, sqlParameterName, variantDbType, variantParameterValue } from '../data/datainfo.js';
|
|
23
|
+
import { NotSupportedYetError } from '../data/errors.js';
|
|
24
|
+
import { runSync, wait } from '../data/op.js';
|
|
25
|
+
import { ReportDataset } from '../data/reportdataset.js';
|
|
26
|
+
import { ReportParam } from '../params/param.js';
|
|
27
|
+
import { NoDataToPrintException, ReportException } from './errors.js';
|
|
28
|
+
import { IdenBarcodeOp, IdenEof, IdenGetValueFromSQL, IdenGraphicOp, IdenImageOp, IdenOrientationOp, IdenPageOp, IdenParamInfo, IdenReOpen, IdenReportVar, IdenSetLanguage, IdenTextHeight, IdenTextOp, } from './identifiers.js';
|
|
29
|
+
import { ExpressionItem, LabelItem, pt, ShapeItem, SubReportEvent, } from './items.js';
|
|
30
|
+
import { SectionRuntime, SectionType, SkipType } from './section.js';
|
|
31
|
+
import { ImageItem } from './imageitem.js';
|
|
32
|
+
import { SubReportRuntime } from './subreport.js';
|
|
33
|
+
import { barcodeOp, BarcodeItem } from './barcode/barcodeitem.js';
|
|
34
|
+
import { ChartItem } from './chart/chartitem.js';
|
|
35
|
+
import { IdenGraphicBounds, IdenGraphicClear, IdenGraphicColor, IdenGraphicNew, IdenGraphicNewFunction, IdenGraphicNewXY, IdenGraphicSerieColor, } from './chart/chartidens.js';
|
|
36
|
+
/** BaseReport.MAX_PAGENUM. */
|
|
37
|
+
export const MAX_PAGENUM = 100000;
|
|
38
|
+
const INT_MAX = 2147483647;
|
|
39
|
+
const MILIS_PROGRESS_DEFAULT = 500;
|
|
40
|
+
/** PageSizeType. */
|
|
41
|
+
var PageSizeType;
|
|
42
|
+
(function (PageSizeType) {
|
|
43
|
+
PageSizeType[PageSizeType["Default"] = 0] = "Default";
|
|
44
|
+
PageSizeType[PageSizeType["Custom"] = 1] = "Custom";
|
|
45
|
+
PageSizeType[PageSizeType["User"] = 2] = "User";
|
|
46
|
+
})(PageSizeType || (PageSizeType = {}));
|
|
47
|
+
/** A mutable context: the culture changes per page with the report language, as the thread culture. */
|
|
48
|
+
class RunContext {
|
|
49
|
+
culture;
|
|
50
|
+
translator;
|
|
51
|
+
timeZone;
|
|
52
|
+
now;
|
|
53
|
+
fromDelphi;
|
|
54
|
+
constructor(culture, translator, now, timeZone, fromDelphi) {
|
|
55
|
+
this.culture = culture;
|
|
56
|
+
this.translator = translator;
|
|
57
|
+
this.now = now;
|
|
58
|
+
this.timeZone = timeZone;
|
|
59
|
+
this.fromDelphi = fromDelphi;
|
|
60
|
+
}
|
|
61
|
+
/** The masks of Delphi for the dates of a report converted from Delphi (convertedFromDelphi). */
|
|
62
|
+
get delphiDateMasks() {
|
|
63
|
+
return this.fromDelphi();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/** The culture of a report language while a page prints (PrintNextPage), undefined to keep it. */
|
|
67
|
+
function languageCulture(language) {
|
|
68
|
+
switch (language) {
|
|
69
|
+
case 0:
|
|
70
|
+
return CultureInfo.get('en-US');
|
|
71
|
+
case 1:
|
|
72
|
+
return CultureInfo.get('es-ES');
|
|
73
|
+
case 2:
|
|
74
|
+
// C# parity: C# selects the neutral culture "ca"; its formats are those of ca-ES
|
|
75
|
+
return CultureInfo.get('ca-ES');
|
|
76
|
+
}
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
export class ReportRuntime {
|
|
80
|
+
model;
|
|
81
|
+
host;
|
|
82
|
+
translator;
|
|
83
|
+
context;
|
|
84
|
+
evalHost;
|
|
85
|
+
/** DataTable.Locale of the datasets (the culture when the report was prepared). */
|
|
86
|
+
locale;
|
|
87
|
+
invariant = CultureInfo.invariant;
|
|
88
|
+
onProgress;
|
|
89
|
+
// The model, at run time
|
|
90
|
+
params = [];
|
|
91
|
+
databases = [];
|
|
92
|
+
dataInfos = [];
|
|
93
|
+
subReports = [];
|
|
94
|
+
expressionItems = [];
|
|
95
|
+
chartItems = [];
|
|
96
|
+
/**
|
|
97
|
+
* ChartingDriver: the device that draws the charts instead of the device the report prints
|
|
98
|
+
* with (null: that device draws them, with its drawChart or else the vector chart).
|
|
99
|
+
*/
|
|
100
|
+
chartingDriver = null;
|
|
101
|
+
/**
|
|
102
|
+
* Whether convertToDotNet converted the report from data drivers only the Delphi engine has
|
|
103
|
+
* (Zeos, IBX, FireDAC, BDE...): its parameters keep the meaning they have in Delphi.
|
|
104
|
+
*/
|
|
105
|
+
convertedFromDelphi = false;
|
|
106
|
+
// BaseReport state
|
|
107
|
+
metaFile;
|
|
108
|
+
evaluator;
|
|
109
|
+
fLanguage;
|
|
110
|
+
fDataAlias = new DatasetAlias();
|
|
111
|
+
evalIdens;
|
|
112
|
+
openingDatasets = new Set();
|
|
113
|
+
fDriver = null;
|
|
114
|
+
errorProcessing = false;
|
|
115
|
+
lastErrorProcessing = '';
|
|
116
|
+
pendingSections = [];
|
|
117
|
+
fGroupHeaders = [];
|
|
118
|
+
gHeaders = [];
|
|
119
|
+
gFooters = [];
|
|
120
|
+
fTotalPages = [];
|
|
121
|
+
mmfirst = 0;
|
|
122
|
+
fCompose;
|
|
123
|
+
lastPage = false;
|
|
124
|
+
section = null;
|
|
125
|
+
subreport = null;
|
|
126
|
+
printing = false;
|
|
127
|
+
fRecordCount = 0;
|
|
128
|
+
currentSubReportIndex = 0;
|
|
129
|
+
currentSectionIndex = 0;
|
|
130
|
+
oldprintedsectionext = pt(0, 0);
|
|
131
|
+
oldsubreport = null;
|
|
132
|
+
havepagefooters = false;
|
|
133
|
+
sectionextevaluated = false;
|
|
134
|
+
oldprintedsection = null;
|
|
135
|
+
pageposx = 0;
|
|
136
|
+
pageposy = 0;
|
|
137
|
+
pagespacex = 0;
|
|
138
|
+
pagefooters = null;
|
|
139
|
+
asection = null;
|
|
140
|
+
pagefooterpos = 0;
|
|
141
|
+
sectionext = pt(0, 0);
|
|
142
|
+
fintpageindex = 0;
|
|
143
|
+
printedSomething = false;
|
|
144
|
+
pageNum = 0;
|
|
145
|
+
pageNumGroup = 0;
|
|
146
|
+
internalPageWidth = 0;
|
|
147
|
+
internalPageHeight = 0;
|
|
148
|
+
freeSpace = 0;
|
|
149
|
+
currentOrientation;
|
|
150
|
+
updatePageSize = false;
|
|
151
|
+
initialPageDetail = null;
|
|
152
|
+
/** ExecuteSubReportIndexes. */
|
|
153
|
+
executeSubReportIndexes;
|
|
154
|
+
pageSizeIndex;
|
|
155
|
+
constructor(model, options) {
|
|
156
|
+
this.model = model;
|
|
157
|
+
this.host = options.host;
|
|
158
|
+
this.locale = options.culture;
|
|
159
|
+
this.translator = options.translator ?? Translator.forCulture(options.culture);
|
|
160
|
+
this.evalHost = options.evalHost;
|
|
161
|
+
this.context = new RunContext(options.culture, this.translator, () => this.evalHost.now(), options.timeZone ?? utcTimeZone, () => this.convertedFromDelphi);
|
|
162
|
+
this.onProgress = options.onProgress;
|
|
163
|
+
this.executeSubReportIndexes = options.subReportIndexes ?? null;
|
|
164
|
+
this.fCompose = options.compose !== undefined;
|
|
165
|
+
this.metaFile = options.compose ?? new MetaFile();
|
|
166
|
+
this.fLanguage = model.language;
|
|
167
|
+
this.pageSizeIndex = model.pageSizeIndex;
|
|
168
|
+
this.currentOrientation = model.pageOrientation;
|
|
169
|
+
// MetaFile settings the C# property setters copy at load time
|
|
170
|
+
this.metaFile.linesPerInch = model.linesPerInch;
|
|
171
|
+
this.metaFile.printerSelect = model.printerSelect;
|
|
172
|
+
for (const db of model.databaseInfo)
|
|
173
|
+
this.databases.push(new ReportDatabase(this, db));
|
|
174
|
+
for (const di of model.dataInfo)
|
|
175
|
+
this.dataInfos.push(new ReportDataInfo(this, di));
|
|
176
|
+
for (const p of model.params)
|
|
177
|
+
this.params.push(new ReportParam(this, p));
|
|
178
|
+
this.buildSubReports();
|
|
179
|
+
const iden = (name, i) => [name, i];
|
|
180
|
+
const idens = [
|
|
181
|
+
iden('PAGE', new IdenReportVar(this, 'PAGE')),
|
|
182
|
+
iden('PAGINA', new IdenReportVar(this, 'PAGE')),
|
|
183
|
+
iden('LANGUAGE', new IdenReportVar(this, 'LANGUAGE')),
|
|
184
|
+
iden('PAGENUM', new IdenReportVar(this, 'PAGENUM')),
|
|
185
|
+
iden('PAGEWIDTH', new IdenReportVar(this, 'PAGEWIDTH')),
|
|
186
|
+
iden('PAGEHEIGHT', new IdenReportVar(this, 'PAGEHEIGHT')),
|
|
187
|
+
iden('FREE_SPACE_CMS', new IdenReportVar(this, 'FREE_SPACE_CMS')),
|
|
188
|
+
iden('FREE_SPACE_INCH', new IdenReportVar(this, 'FREE_SPACE_INCH')),
|
|
189
|
+
iden('FREE_SPACE_TWIPS', new IdenReportVar(this, 'FREE_SPACE_TWIPS')),
|
|
190
|
+
iden('CURRENTGROUP', new IdenReportVar(this, 'CURRENTGROUP')),
|
|
191
|
+
iden('CURRENTPOSX', new IdenReportVar(this, 'CURRENTPOSX')),
|
|
192
|
+
iden('CURRENTPOSY', new IdenReportVar(this, 'CURRENTPOSY')),
|
|
193
|
+
iden('FIRSTSECTION', new IdenReportVar(this, 'FIRSTSECTION')),
|
|
194
|
+
iden('EOF', new IdenEof(this)),
|
|
195
|
+
iden('SETLANGUAGE', new IdenSetLanguage(this)),
|
|
196
|
+
iden('REOPEN', new IdenReOpen(this)),
|
|
197
|
+
iden('GRAPHICOP', new IdenGraphicOp(this)),
|
|
198
|
+
iden('IMAGEOP', new IdenImageOp(this)),
|
|
199
|
+
iden('BARCODEOP', new IdenBarcodeOp(this)),
|
|
200
|
+
iden('TEXTOP', new IdenTextOp(this)),
|
|
201
|
+
iden('TEXTHEIGHT', new IdenTextHeight(this)),
|
|
202
|
+
iden('PARAMINFO', new IdenParamInfo(this)),
|
|
203
|
+
iden('SETPAGESOURCE', new IdenPageOp(this)),
|
|
204
|
+
iden('SETPAGEORIENTATION', new IdenOrientationOp(this)),
|
|
205
|
+
iden('GETVALUEFROMSQL', new IdenGetValueFromSQL(this)),
|
|
206
|
+
iden('GRAPHICNEW', new IdenGraphicNew(this)),
|
|
207
|
+
iden('GRAPHICNEWXY', new IdenGraphicNewXY(this)),
|
|
208
|
+
iden('GRAPHICNEWFUNCTION', new IdenGraphicNewFunction(this)),
|
|
209
|
+
iden('GRAPHICCLEAR', new IdenGraphicClear(this)),
|
|
210
|
+
iden('GRAPHICCOLOR', new IdenGraphicColor(this)),
|
|
211
|
+
iden('GRAPHICSERIECOLOR', new IdenGraphicSerieColor(this)),
|
|
212
|
+
iden('GRAPHICBOUNDS', new IdenGraphicBounds(this)),
|
|
213
|
+
];
|
|
214
|
+
this.evalIdens = new EvalIdentifiers(options.culture.name);
|
|
215
|
+
for (const [k, v] of idens)
|
|
216
|
+
this.evalIdens.add(k, v);
|
|
217
|
+
this.initEvaluator();
|
|
218
|
+
}
|
|
219
|
+
// -------------------------------------------------------------------------------------------
|
|
220
|
+
// Construction
|
|
221
|
+
buildSubReports() {
|
|
222
|
+
const byName = new Map();
|
|
223
|
+
for (const sm of this.model.subReports) {
|
|
224
|
+
const sub = new SubReportRuntime(this, sm);
|
|
225
|
+
this.subReports.push(sub);
|
|
226
|
+
byName.set(toUpperNet(sm.name), sub);
|
|
227
|
+
for (const secm of sm.sections) {
|
|
228
|
+
const sec = new SectionRuntime(this, secm);
|
|
229
|
+
sub.sections.push(sec);
|
|
230
|
+
if (!byName.has(toUpperNet(secm.name)))
|
|
231
|
+
byName.set(toUpperNet(secm.name), sec);
|
|
232
|
+
for (const cm of secm.components) {
|
|
233
|
+
const item = this.newItem(cm);
|
|
234
|
+
sec.components.push(item);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
// Reload links (ReportReader): parents, child subreports and the subreport of each section
|
|
239
|
+
this.model.subReports.forEach((sm, i) => {
|
|
240
|
+
const sub = this.subReports[i];
|
|
241
|
+
if (sm.parentSub.length > 0)
|
|
242
|
+
sub.parentSubReport = byName.get(sm.parentSub) ?? null;
|
|
243
|
+
if (sm.parentSec.length > 0)
|
|
244
|
+
sub.parentSection = byName.get(sm.parentSec) ?? null;
|
|
245
|
+
sm.sections.forEach((secm, j) => {
|
|
246
|
+
const sec = sub.sections[j];
|
|
247
|
+
if (secm.childSubReportName.length > 0) {
|
|
248
|
+
const child = byName.get(secm.childSubReportName);
|
|
249
|
+
if (!(child instanceof SubReportRuntime))
|
|
250
|
+
throw new NamedException('ChildSubReport not found:' + secm.childSubReportName, secm.childSubReportName);
|
|
251
|
+
sec.childSubReport = child;
|
|
252
|
+
child.parentSection = sec;
|
|
253
|
+
// C# parity: the parent of a child subreport is set to the child itself (only tested for null)
|
|
254
|
+
child.parentSubReport = child;
|
|
255
|
+
}
|
|
256
|
+
if (secm.subReportName.length > 0)
|
|
257
|
+
sec.subReport = sub;
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
newItem(cm) {
|
|
262
|
+
switch (cm.className) {
|
|
263
|
+
case 'TRPLABEL':
|
|
264
|
+
return new LabelItem(this, cm);
|
|
265
|
+
case 'TRPEXPRESSION': {
|
|
266
|
+
const item = new ExpressionItem(this, cm);
|
|
267
|
+
this.expressionItems.push(item);
|
|
268
|
+
return item;
|
|
269
|
+
}
|
|
270
|
+
case 'TRPSHAPE':
|
|
271
|
+
return new ShapeItem(this, cm);
|
|
272
|
+
case 'TRPIMAGE':
|
|
273
|
+
return new ImageItem(this, cm);
|
|
274
|
+
case 'TRPBARCODE':
|
|
275
|
+
return new BarcodeItem(this, cm);
|
|
276
|
+
case 'TRPCHART': {
|
|
277
|
+
const item = new ChartItem(this, cm);
|
|
278
|
+
this.chartItems.push(item);
|
|
279
|
+
return item;
|
|
280
|
+
}
|
|
281
|
+
default:
|
|
282
|
+
throw new Error('Unknown report item class: ' + String(cm.className));
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
/** A new dataset buffer (DataInfo constructor: new ReportDataset). */
|
|
286
|
+
newDataset() {
|
|
287
|
+
return new ReportDataset(this.locale, () => this.context.culture, this.invariant, () => this.evalHost.now());
|
|
288
|
+
}
|
|
289
|
+
/** The current culture (changes per page with the report language). */
|
|
290
|
+
get culture() {
|
|
291
|
+
return this.context.culture;
|
|
292
|
+
}
|
|
293
|
+
get driver() {
|
|
294
|
+
return this.fDriver;
|
|
295
|
+
}
|
|
296
|
+
/** Language: the evaluator follows it. */
|
|
297
|
+
get language() {
|
|
298
|
+
return this.fLanguage;
|
|
299
|
+
}
|
|
300
|
+
set language(value) {
|
|
301
|
+
this.fLanguage = value;
|
|
302
|
+
if (this.evaluator !== undefined)
|
|
303
|
+
this.evaluator.language = value;
|
|
304
|
+
}
|
|
305
|
+
toUpper(s) {
|
|
306
|
+
return toUpperNet(s);
|
|
307
|
+
}
|
|
308
|
+
convertToInt32(value) {
|
|
309
|
+
return convertDoubleToInt32(value);
|
|
310
|
+
}
|
|
311
|
+
/** Int32.ToString(format) under the current culture, for the page counts. */
|
|
312
|
+
integerFormatter = (value, format) => formatInteger(value, format, this.context.culture.number, 32);
|
|
313
|
+
/** object.ToString() of a value of a dataset row, under the current culture. */
|
|
314
|
+
objectText(cell) {
|
|
315
|
+
const v = cell.value;
|
|
316
|
+
const nfi = this.context.culture.number;
|
|
317
|
+
switch (cell.type) {
|
|
318
|
+
case 'DBNull':
|
|
319
|
+
case 'Null':
|
|
320
|
+
return '';
|
|
321
|
+
case 'String':
|
|
322
|
+
return v;
|
|
323
|
+
case 'Int64':
|
|
324
|
+
case 'Int32':
|
|
325
|
+
case 'Byte':
|
|
326
|
+
return formatInteger(v, '', nfi);
|
|
327
|
+
case 'Double':
|
|
328
|
+
return formatDouble(v, '', nfi);
|
|
329
|
+
case 'Decimal':
|
|
330
|
+
return formatDecimal(v, '', nfi);
|
|
331
|
+
case 'Boolean':
|
|
332
|
+
return v ? 'True' : 'False';
|
|
333
|
+
case 'DateTime':
|
|
334
|
+
return formatDateTime(v, '', this.context.culture);
|
|
335
|
+
case 'Binary':
|
|
336
|
+
return 'System.Byte[]';
|
|
337
|
+
default:
|
|
338
|
+
return String(v);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
paramIndexOf(alias) {
|
|
342
|
+
for (let i = 0; i < this.params.length; i++)
|
|
343
|
+
if (this.params[i].alias === alias)
|
|
344
|
+
return i;
|
|
345
|
+
return -1;
|
|
346
|
+
}
|
|
347
|
+
paramByAlias(alias) {
|
|
348
|
+
const i = this.paramIndexOf(alias);
|
|
349
|
+
return i < 0 ? null : this.params[i];
|
|
350
|
+
}
|
|
351
|
+
/** DataInfos.IndexOf: by alias, case-sensitive. */
|
|
352
|
+
dataInfoIndexOf(alias) {
|
|
353
|
+
// Ignoring the case, as Delphi (TRpDataInfoList.IndexOf): a subreport may name its dataset in
|
|
354
|
+
// other case than the dataset itself
|
|
355
|
+
for (let i = 0; i < this.dataInfos.length; i++)
|
|
356
|
+
if (this.dataInfos[i].alias === alias)
|
|
357
|
+
return i;
|
|
358
|
+
const upper = toUpperNet(alias);
|
|
359
|
+
for (let i = 0; i < this.dataInfos.length; i++)
|
|
360
|
+
if (toUpperNet(this.dataInfos[i].alias) === upper)
|
|
361
|
+
return i;
|
|
362
|
+
return -1;
|
|
363
|
+
}
|
|
364
|
+
dataInfoByAlias(alias) {
|
|
365
|
+
const i = this.dataInfoIndexOf(alias);
|
|
366
|
+
return i < 0 ? null : this.dataInfos[i];
|
|
367
|
+
}
|
|
368
|
+
/** DatabaseInfos.IndexOf: by alias. */
|
|
369
|
+
databaseIndexOf(alias) {
|
|
370
|
+
for (let i = 0; i < this.databases.length; i++)
|
|
371
|
+
if (this.databases[i].alias === alias)
|
|
372
|
+
return i;
|
|
373
|
+
return -1;
|
|
374
|
+
}
|
|
375
|
+
/** Moves a dataset to its next record (its details may execute again). */
|
|
376
|
+
*next(data) {
|
|
377
|
+
return yield* data.next();
|
|
378
|
+
}
|
|
379
|
+
// -------------------------------------------------------------------------------------------
|
|
380
|
+
// Evaluator, parameters, datasets
|
|
381
|
+
/** InitEvaluator: a new evaluator, its dataset needed event and language. */
|
|
382
|
+
initEvaluator() {
|
|
383
|
+
this.evaluator = new Evaluator({ context: this.context, host: this.evalHost, language: this.fLanguage });
|
|
384
|
+
this.evaluator.onDatasetNeeded = (args) => this.onDatasetNeeded(args.dataset);
|
|
385
|
+
this.evaluator.language = this.fLanguage;
|
|
386
|
+
}
|
|
387
|
+
/** A field of a dataset that is not open: the dataset opens (inside the evaluation). */
|
|
388
|
+
onDatasetNeeded(dataset) {
|
|
389
|
+
if (this.openingDatasets.has(dataset))
|
|
390
|
+
return;
|
|
391
|
+
this.openingDatasets.add(dataset);
|
|
392
|
+
try {
|
|
393
|
+
const dinfo = this.dataInfoByAlias(dataset);
|
|
394
|
+
if (dinfo !== null) {
|
|
395
|
+
if (dinfo.dataReader === null) {
|
|
396
|
+
this.updateParamsBeforeOpen(this.dataInfoIndexOf(dataset), true);
|
|
397
|
+
runSync(dinfo.connect(), 'Opening the dataset ' + dataset + ' from an expression');
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
finally {
|
|
402
|
+
this.openingDatasets.delete(dataset);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
/** AddReportItemsToEvaluator: parameters, expression identifiers and the report identifiers. */
|
|
406
|
+
addReportItemsToEvaluator(ev) {
|
|
407
|
+
for (const p of this.params)
|
|
408
|
+
ev.addIden('M.' + p.alias, new IdenVariableParam(ev, p));
|
|
409
|
+
for (const item of this.expressionItems) {
|
|
410
|
+
if (item.identifier.length > 0) {
|
|
411
|
+
// EvalIdenExpression of C# keeps the evaluator of the report (for its error messages)
|
|
412
|
+
item.idenExpression.evalObject = ev;
|
|
413
|
+
ev.addVariable(item.identifier, item.idenExpression);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
for (const c of this.chartItems)
|
|
417
|
+
if (c.identifier.length > 0)
|
|
418
|
+
ev.addVariable(c.identifier, c.idenChart);
|
|
419
|
+
for (const aname of this.evalIdens.keys) {
|
|
420
|
+
const i = this.evalIdens.get(aname);
|
|
421
|
+
if (aname !== 'EOF')
|
|
422
|
+
ev.addVariable(aname, i);
|
|
423
|
+
else
|
|
424
|
+
ev.addIden(aname, i);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
/** InitializeParams: the report items in the evaluator and the value of every parameter. */
|
|
428
|
+
initializeParams() {
|
|
429
|
+
this.addReportItemsToEvaluator(this.evaluator);
|
|
430
|
+
const ctx = this.evaluator.context;
|
|
431
|
+
for (const p of this.params) {
|
|
432
|
+
p.updateInitialValue();
|
|
433
|
+
if (p.paramType === ParamType.ExpreB) {
|
|
434
|
+
const paramname = p.alias;
|
|
435
|
+
try {
|
|
436
|
+
if (p.value.varType !== VariantType.Null) {
|
|
437
|
+
const text = 'M.' + paramname + ':=(' + p.value.toString(ctx) + ')';
|
|
438
|
+
this.evaluator.evaluateText(text);
|
|
439
|
+
p.lastValue = this.evaluator.evaluateText(paramname);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
catch (e) {
|
|
443
|
+
throw new ReportException(messageOf(e) + 'Parameter error:' + p.alias, p.name, 'Value');
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
else
|
|
447
|
+
p.lastValue = p.listValue;
|
|
448
|
+
}
|
|
449
|
+
this.evaluator.language = this.fLanguage;
|
|
450
|
+
}
|
|
451
|
+
/** UpdateInitialValues: the initial expressions evaluated (what a parameters form shows). */
|
|
452
|
+
updateInitialValues() {
|
|
453
|
+
this.initEvaluator();
|
|
454
|
+
this.addReportItemsToEvaluator(this.evaluator);
|
|
455
|
+
for (const p of this.params)
|
|
456
|
+
p.updateInitialValue();
|
|
457
|
+
}
|
|
458
|
+
/** RestoreInitialValues: the initial expressions back. */
|
|
459
|
+
restoreInitialValues() {
|
|
460
|
+
for (const p of this.params)
|
|
461
|
+
p.restoreInitialValue();
|
|
462
|
+
}
|
|
463
|
+
/** CheckParameters: the alias of the first parameter whose validation fails ("" when none). */
|
|
464
|
+
checkParameters() {
|
|
465
|
+
let aresult = '';
|
|
466
|
+
this.initEvaluator();
|
|
467
|
+
this.addReportItemsToEvaluator(this.evaluator);
|
|
468
|
+
for (const p of this.params) {
|
|
469
|
+
p.updateInitialValue();
|
|
470
|
+
if (p.paramType !== ParamType.ExpreB)
|
|
471
|
+
p.lastValue = p.listValue;
|
|
472
|
+
}
|
|
473
|
+
for (const p of this.params) {
|
|
474
|
+
const validation = trimNet(p.validation);
|
|
475
|
+
if (validation.length > 0) {
|
|
476
|
+
const evalresult = this.evaluator.evaluateText(validation);
|
|
477
|
+
if (!evalresult.isNull) {
|
|
478
|
+
if (evalresult.isBoolean()) {
|
|
479
|
+
if (!evalresult.toBool(this.evaluator.context)) {
|
|
480
|
+
aresult = p.alias;
|
|
481
|
+
break;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
return aresult;
|
|
488
|
+
}
|
|
489
|
+
/** UpdateParamsBeforeOpen: the expressions to evaluate before a dataset opens. */
|
|
490
|
+
updateParamsBeforeOpen(index, doeval) {
|
|
491
|
+
const ctx = this.evaluator.context;
|
|
492
|
+
const alias = this.dataInfos[index].alias;
|
|
493
|
+
for (const aparam of this.params) {
|
|
494
|
+
if (aparam.datasets.indexOf(alias) >= 0 && aparam.paramType === ParamType.ExpreB) {
|
|
495
|
+
const paramname = aparam.alias;
|
|
496
|
+
if (aparam.value.varType !== VariantType.Null) {
|
|
497
|
+
if (doeval) {
|
|
498
|
+
this.evaluator.evaluateText('M.' + paramname + ':=(' + aparam.value.toString(ctx) + ')');
|
|
499
|
+
aparam.lastValue = this.evaluator.evaluateText('M.' + paramname);
|
|
500
|
+
}
|
|
501
|
+
else
|
|
502
|
+
aparam.lastValue = this.evaluator.evaluateText(aparam.value.toString(ctx));
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
for (const aparam of this.params) {
|
|
507
|
+
if (aparam.datasets.indexOf(alias) >= 0 &&
|
|
508
|
+
(aparam.paramType === ParamType.SubstExpre || aparam.paramType === ParamType.SubsExpreList)) {
|
|
509
|
+
const paramname = aparam.alias;
|
|
510
|
+
if (aparam.value.varType !== VariantType.Null) {
|
|
511
|
+
if (doeval && this.convertedFromDelphi && aparam.paramType === ParamType.SubsExpreList) {
|
|
512
|
+
// A report of the Delphi engine, as Delphi (TRpBaseReport.UpdateParamsBeforeOpen): the value
|
|
513
|
+
// chosen in the list is the text to substitute, a string is quoted before it is evaluated
|
|
514
|
+
// ('N' stays 'N'). A report of this engine evaluates the value itself, as it always did
|
|
515
|
+
const v = aparam.value;
|
|
516
|
+
const text = v.varType === VariantType.String ? "'" + v.toString(ctx).split("'").join("''") + "'" : v.toString(ctx);
|
|
517
|
+
this.evaluator.evaluateText('M.' + paramname + ':=(' + text + ')');
|
|
518
|
+
aparam.lastValue = this.evaluator.evaluateText('M.' + paramname);
|
|
519
|
+
}
|
|
520
|
+
else if (doeval) {
|
|
521
|
+
const oldvalue = aparam.lastValue;
|
|
522
|
+
this.evaluator.evaluateText('M.' + paramname + ':=(' + aparam.value.toString(ctx) + ')');
|
|
523
|
+
aparam.lastValue = oldvalue;
|
|
524
|
+
}
|
|
525
|
+
else
|
|
526
|
+
aparam.lastValue = this.evaluator.evaluateText(aparam.value.toString(ctx));
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
updateParamsAfterOpen(index, doeval) {
|
|
532
|
+
const ctx = this.evaluator.context;
|
|
533
|
+
const alias = this.dataInfos[index].alias;
|
|
534
|
+
for (const aparam of this.params) {
|
|
535
|
+
if (aparam.datasets.indexOf(alias) >= 0 && aparam.paramType === ParamType.ExpreA) {
|
|
536
|
+
const paramname = aparam.alias;
|
|
537
|
+
if (aparam.value.varType !== VariantType.Null) {
|
|
538
|
+
if (doeval) {
|
|
539
|
+
this.evaluator.evaluateText('M.' + paramname + ':=(' + aparam.value.toString(ctx) + ')');
|
|
540
|
+
aparam.lastValue = this.evaluator.evaluateText('M.' + paramname);
|
|
541
|
+
}
|
|
542
|
+
else
|
|
543
|
+
aparam.lastValue = this.evaluator.evaluateText(aparam.value.toString(ctx));
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
prepareParamsAfterOpen() {
|
|
549
|
+
for (let i = 0; i < this.dataInfos.length; i++)
|
|
550
|
+
this.updateParamsAfterOpen(i, false);
|
|
551
|
+
const ctx = this.evaluator.context;
|
|
552
|
+
for (const aparam of this.params) {
|
|
553
|
+
if (aparam.paramType === ParamType.ExpreA && aparam.datasets.length === 0) {
|
|
554
|
+
const paramname = aparam.alias;
|
|
555
|
+
if (aparam.value.varType !== VariantType.Null) {
|
|
556
|
+
this.evaluator.evaluateText('M.' + paramname + ':=(' + aparam.value.toString(ctx) + ')');
|
|
557
|
+
aparam.lastValue = this.evaluator.evaluateText('M.' + paramname);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
/** CheckIfDataAvailable: PrintOnlyIfDataAvailable and no subreport dataset has rows. */
|
|
563
|
+
checkIfDataAvailable() {
|
|
564
|
+
if (!this.model.printOnlyIfDataAvailable)
|
|
565
|
+
return;
|
|
566
|
+
let dataavail = false;
|
|
567
|
+
for (const sub of this.subReports) {
|
|
568
|
+
if (sub.alias.length > 0) {
|
|
569
|
+
const index = this.dataInfoIndexOf(sub.alias);
|
|
570
|
+
if (index >= 0) {
|
|
571
|
+
const data = this.dataInfos[index].data;
|
|
572
|
+
if (data.active && !data.eof) {
|
|
573
|
+
dataavail = true;
|
|
574
|
+
break;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
if (!dataavail) {
|
|
580
|
+
this.metaFile.empty = true;
|
|
581
|
+
throw new NoDataToPrintException(this.translator.translateStr(799));
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
/** DeActivateDatasets: every dataset and connection closed (connections commit). */
|
|
585
|
+
*deActivateDatasets() {
|
|
586
|
+
for (const d of this.dataInfos) {
|
|
587
|
+
d.disConnect();
|
|
588
|
+
d.disConnectMem();
|
|
589
|
+
}
|
|
590
|
+
for (const db of this.databases)
|
|
591
|
+
yield* db.disConnect();
|
|
592
|
+
}
|
|
593
|
+
/** Every connection closed, HTTP agents too (the end of a run). */
|
|
594
|
+
*closeAll() {
|
|
595
|
+
yield* this.deActivateDatasets();
|
|
596
|
+
for (const db of this.databases)
|
|
597
|
+
yield* db.close(true);
|
|
598
|
+
}
|
|
599
|
+
/** SubreportMustBeExecuted: the ExecuteSubReportIndexes filter. */
|
|
600
|
+
subreportMustBeExecuted(nsubreport) {
|
|
601
|
+
const list = this.executeSubReportIndexes;
|
|
602
|
+
if (list === null || list.length === 0)
|
|
603
|
+
return true;
|
|
604
|
+
const idx = this.subReports.indexOf(nsubreport);
|
|
605
|
+
for (const index of list)
|
|
606
|
+
if (index === idx)
|
|
607
|
+
return true;
|
|
608
|
+
return false;
|
|
609
|
+
}
|
|
610
|
+
/** ActivateDatasets: the datasets that open on start. */
|
|
611
|
+
*activateDatasets() {
|
|
612
|
+
try {
|
|
613
|
+
for (const d of this.dataInfos)
|
|
614
|
+
d.sqlOverride = '';
|
|
615
|
+
for (let i = 0; i < this.dataInfos.length; i++) {
|
|
616
|
+
const dinfo = this.dataInfos[i];
|
|
617
|
+
dinfo.sqlOverride = '';
|
|
618
|
+
if (dinfo.openOnStart) {
|
|
619
|
+
let openDataset = true;
|
|
620
|
+
const list = this.executeSubReportIndexes;
|
|
621
|
+
if (list !== null && list.length > 0) {
|
|
622
|
+
openDataset = false;
|
|
623
|
+
for (const subrep of this.subReports) {
|
|
624
|
+
if (subrep.alias === dinfo.alias && this.subreportMustBeExecuted(subrep))
|
|
625
|
+
openDataset = true;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
if (dinfo.dataReader === null && openDataset) {
|
|
629
|
+
this.updateParamsBeforeOpen(i, true);
|
|
630
|
+
yield* dinfo.connect();
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
for (const sub of this.subReports) {
|
|
635
|
+
const alias = sub.alias;
|
|
636
|
+
if (this.subreportMustBeExecuted(sub) && alias.length > 0) {
|
|
637
|
+
if (this.dataInfoIndexOf(alias) < 0)
|
|
638
|
+
throw new NamedException('Data alias not found:' + alias, alias);
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
catch (e) {
|
|
643
|
+
yield* this.deActivateDatasets();
|
|
644
|
+
throw e;
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
// -------------------------------------------------------------------------------------------
|
|
648
|
+
// Printing
|
|
649
|
+
checkProgress(finished) {
|
|
650
|
+
const mmlast = Date.now();
|
|
651
|
+
// C# parity: the milliseconds component of the elapsed time, not the total
|
|
652
|
+
const difmilis = (mmlast - this.mmfirst) % 1000;
|
|
653
|
+
if (difmilis >= MILIS_PROGRESS_DEFAULT || finished) {
|
|
654
|
+
this.mmfirst = Date.now();
|
|
655
|
+
if (this.onProgress !== undefined && this.onProgress(this.fRecordCount, this.metaFile.pages.currentCount) === true)
|
|
656
|
+
throw new UnNamedException(this.translator.translateStr(503));
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
/** AddTotalPagesItem: a text that prints the page count. */
|
|
660
|
+
addTotalPagesItem(apageindex, aobjectindex, adisplayformat) {
|
|
661
|
+
this.fTotalPages.push({ pageIndex: apageindex, objectIndex: aobjectindex, displayFormat: adisplayformat });
|
|
662
|
+
}
|
|
663
|
+
fillGlobalHeaders() {
|
|
664
|
+
this.gHeaders.length = 0;
|
|
665
|
+
this.gFooters.length = 0;
|
|
666
|
+
for (const subrep of this.subReports) {
|
|
667
|
+
let j = subrep.firstPageHeader;
|
|
668
|
+
for (let k = 0; k < subrep.pageHeaderCount; k++)
|
|
669
|
+
if (subrep.sections[j + k].global)
|
|
670
|
+
this.gHeaders.push(subrep.sections[j + k]);
|
|
671
|
+
j = subrep.firstPageFooter;
|
|
672
|
+
for (let k = 0; k < subrep.pageFooterCount; k++)
|
|
673
|
+
if (subrep.sections[j + k].global)
|
|
674
|
+
this.gFooters.push(subrep.sections[j + k]);
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
/** EndPrint: datasets closed, page counts written, the metafile finished. */
|
|
678
|
+
*endPrint() {
|
|
679
|
+
yield* this.deActivateDatasets();
|
|
680
|
+
this.section = null;
|
|
681
|
+
this.subreport = null;
|
|
682
|
+
this.printing = false;
|
|
683
|
+
this.fDriver = null;
|
|
684
|
+
this.metaFile.updateTotalPages(this.fTotalPages, this.integerFormatter);
|
|
685
|
+
this.metaFile.finish();
|
|
686
|
+
this.lastPage = true;
|
|
687
|
+
}
|
|
688
|
+
/**
|
|
689
|
+
* RequestPage: generates pages until the one asked for exists (every page for a two pass
|
|
690
|
+
* report); true when the report has finished.
|
|
691
|
+
*/
|
|
692
|
+
*requestPage(pageindex) {
|
|
693
|
+
if (pageindex === INT_MAX)
|
|
694
|
+
pageindex--;
|
|
695
|
+
if (this.lastPage)
|
|
696
|
+
return true;
|
|
697
|
+
if (this.model.twoPass)
|
|
698
|
+
pageindex = INT_MAX - 1;
|
|
699
|
+
if (pageindex < this.metaFile.pages.currentCount)
|
|
700
|
+
return this.lastPage;
|
|
701
|
+
this.fintpageindex = pageindex;
|
|
702
|
+
yield* this.doPrintInternal();
|
|
703
|
+
return this.lastPage;
|
|
704
|
+
}
|
|
705
|
+
*doPrintInternal() {
|
|
706
|
+
if (!this.lastPage) {
|
|
707
|
+
this.checkProgress(false);
|
|
708
|
+
while (!(yield* this.printNextPage())) {
|
|
709
|
+
this.checkProgress(false);
|
|
710
|
+
if (this.pageNum > MAX_PAGENUM)
|
|
711
|
+
throw new UnNamedException('Maximum number of pages reached' + String(MAX_PAGENUM));
|
|
712
|
+
if (this.pageNum >= this.fintpageindex)
|
|
713
|
+
break;
|
|
714
|
+
if (this.lastPage)
|
|
715
|
+
break;
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
this.checkProgress(false);
|
|
719
|
+
}
|
|
720
|
+
updateChildSubreportIndexes() {
|
|
721
|
+
const list = this.executeSubReportIndexes;
|
|
722
|
+
if (list === null || list.length === 0)
|
|
723
|
+
return;
|
|
724
|
+
this.updateExecuteSubreportIndexes([...list], 0);
|
|
725
|
+
}
|
|
726
|
+
updateExecuteSubreportIndexes(subreportIndexes, recCount) {
|
|
727
|
+
recCount++;
|
|
728
|
+
if (recCount > 100)
|
|
729
|
+
throw new Error('Circular childsubreport reference');
|
|
730
|
+
const list = this.executeSubReportIndexes;
|
|
731
|
+
for (const idx of subreportIndexes) {
|
|
732
|
+
const subreport = this.subReports[idx];
|
|
733
|
+
if (subreport === undefined)
|
|
734
|
+
throw new RangeError('Index was out of range. Must be non-negative and less than the size of the collection.');
|
|
735
|
+
for (const sec of subreport.sections) {
|
|
736
|
+
if (sec.childSubReport !== null) {
|
|
737
|
+
const newIdx = this.subReports.indexOf(sec.childSubReport);
|
|
738
|
+
if (!list.includes(newIdx))
|
|
739
|
+
list.push(newIdx);
|
|
740
|
+
this.updateExecuteSubreportIndexes([newIdx], recCount);
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
/** DoUpdatePageSize: the page size of a page, asked to the device when it changes. */
|
|
746
|
+
doUpdatePageSize(page, detail) {
|
|
747
|
+
if (detail === null)
|
|
748
|
+
throw nullReferenceException();
|
|
749
|
+
const nd = new PageSizeDetail();
|
|
750
|
+
page.pageDetail = nd;
|
|
751
|
+
nd.paperSource = detail.paperSource;
|
|
752
|
+
nd.duplex = detail.duplex;
|
|
753
|
+
nd.forcePaperName = detail.forcePaperName;
|
|
754
|
+
nd.physicWidth = detail.physicWidth;
|
|
755
|
+
nd.physicHeight = detail.physicHeight;
|
|
756
|
+
page.orientation = this.currentOrientation;
|
|
757
|
+
nd.index = detail.index;
|
|
758
|
+
nd.custom = detail.custom;
|
|
759
|
+
if (detail.custom) {
|
|
760
|
+
nd.customWidth = detail.customWidth;
|
|
761
|
+
nd.customHeight = detail.customHeight;
|
|
762
|
+
}
|
|
763
|
+
if (!this.updatePageSize)
|
|
764
|
+
return;
|
|
765
|
+
page.updatedPageSize = true;
|
|
766
|
+
const driver = this.requireDriver();
|
|
767
|
+
driver.setOrientation(this.currentOrientation);
|
|
768
|
+
let apagesize;
|
|
769
|
+
if (this.model.pageSize !== PageSizeType.Default)
|
|
770
|
+
apagesize = driver.setPageSize(page.pageDetail);
|
|
771
|
+
else {
|
|
772
|
+
const r = driver.getPageSize();
|
|
773
|
+
apagesize = r.size;
|
|
774
|
+
this.pageSizeIndex = r.indexqt;
|
|
775
|
+
}
|
|
776
|
+
this.internalPageWidth = apagesize.x;
|
|
777
|
+
this.pagespacex = this.internalPageWidth;
|
|
778
|
+
this.internalPageHeight = apagesize.y;
|
|
779
|
+
}
|
|
780
|
+
requireDriver() {
|
|
781
|
+
if (this.fDriver === null)
|
|
782
|
+
throw nullReferenceException();
|
|
783
|
+
return this.fDriver;
|
|
784
|
+
}
|
|
785
|
+
/** BeginPrint: the metafile, the page size, the parameters and the datasets; the first section. */
|
|
786
|
+
*beginPrint(driver) {
|
|
787
|
+
const model = this.model;
|
|
788
|
+
const list = this.executeSubReportIndexes;
|
|
789
|
+
if (list !== null && list.length > 0)
|
|
790
|
+
this.updateChildSubreportIndexes();
|
|
791
|
+
if (!this.fCompose)
|
|
792
|
+
this.fTotalPages.length = 0;
|
|
793
|
+
yield* this.endPrint();
|
|
794
|
+
if (model.twoPass)
|
|
795
|
+
this.metaFile.forwardOnly = false;
|
|
796
|
+
this.mmfirst = Date.now();
|
|
797
|
+
this.fDriver = driver;
|
|
798
|
+
const meta = this.metaFile;
|
|
799
|
+
if (!this.fCompose) {
|
|
800
|
+
meta.clear();
|
|
801
|
+
meta.pdfConformance = model.pdfConformance;
|
|
802
|
+
meta.pdfCompressed = model.pdfCompressed;
|
|
803
|
+
meta.docAuthor = model.docAuthor ?? null;
|
|
804
|
+
meta.docProducer = model.docProducer ?? null;
|
|
805
|
+
meta.docCreator = model.docCreator ?? null;
|
|
806
|
+
meta.docCreationDate = model.docCreationDate ?? null;
|
|
807
|
+
meta.docModificationDate = model.docModificationDate ?? null;
|
|
808
|
+
meta.docSubject = model.docSubject ?? null;
|
|
809
|
+
meta.docKeywords = model.docKeywords ?? null;
|
|
810
|
+
meta.docTitle = model.docTitle ?? null;
|
|
811
|
+
meta.docXMPContent = model.docXMPContent ?? null;
|
|
812
|
+
}
|
|
813
|
+
for (const efile of model.embeddedFiles) {
|
|
814
|
+
if (efile.streamBase64 === undefined)
|
|
815
|
+
throw nullReferenceException();
|
|
816
|
+
meta.newEmbeddedFile(efile.fileName ?? '', efile.mimeType ?? '', efile.afRelationShip, efile.description ?? '', efile.creationDate ?? '', efile.modificationDate ?? '', fromBase64String(efile.streamBase64));
|
|
817
|
+
}
|
|
818
|
+
meta.empty = false;
|
|
819
|
+
try {
|
|
820
|
+
meta.printerFonts = model.printerFonts;
|
|
821
|
+
this.updatePageSize = false;
|
|
822
|
+
this.fillGlobalHeaders();
|
|
823
|
+
this.pendingSections.length = 0;
|
|
824
|
+
this.errorProcessing = false;
|
|
825
|
+
meta.printerSelect = model.printerSelect;
|
|
826
|
+
driver.selectPrinter(model.printerSelect);
|
|
827
|
+
if (this.fCompose) {
|
|
828
|
+
meta.forwardOnly = false;
|
|
829
|
+
this.internalPageWidth = meta.customX;
|
|
830
|
+
this.internalPageHeight = meta.customY;
|
|
831
|
+
this.pageNum = meta.pages.currentCount - 2;
|
|
832
|
+
}
|
|
833
|
+
else {
|
|
834
|
+
let apagesize;
|
|
835
|
+
meta.empty = false;
|
|
836
|
+
meta.printerFonts = model.printerFonts;
|
|
837
|
+
meta.previewAbout = model.previewAbout;
|
|
838
|
+
meta.previewMargins = model.previewMargins;
|
|
839
|
+
meta.linesPerInch = model.linesPerInch;
|
|
840
|
+
meta.paperSource = model.paperSource;
|
|
841
|
+
// Sets page orientation
|
|
842
|
+
this.currentOrientation = model.pageOrientation;
|
|
843
|
+
if (model.pageOrientation !== 0)
|
|
844
|
+
driver.setOrientation(model.pageOrientation);
|
|
845
|
+
const pageDetail = new PageSizeDetail();
|
|
846
|
+
this.initialPageDetail = pageDetail;
|
|
847
|
+
pageDetail.paperSource = model.paperSource;
|
|
848
|
+
pageDetail.duplex = model.duplex;
|
|
849
|
+
pageDetail.forcePaperName = model.forcePaperName ?? null;
|
|
850
|
+
if (model.pageSize !== PageSizeType.Default) {
|
|
851
|
+
if (model.pageSize === PageSizeType.User) {
|
|
852
|
+
meta.pageSizeIndex = -1;
|
|
853
|
+
pageDetail.index = meta.pageSizeIndex;
|
|
854
|
+
pageDetail.custom = true;
|
|
855
|
+
pageDetail.customHeight = model.customPageHeight;
|
|
856
|
+
pageDetail.customWidth = model.customPageWidth;
|
|
857
|
+
meta.customX = model.customPageWidth;
|
|
858
|
+
meta.customY = model.customPageHeight;
|
|
859
|
+
pageDetail.physicHeight = model.customPageHeight;
|
|
860
|
+
pageDetail.physicWidth = model.customPageWidth;
|
|
861
|
+
}
|
|
862
|
+
else {
|
|
863
|
+
meta.pageSizeIndex = this.pageSizeIndex;
|
|
864
|
+
pageDetail.index = this.pageSizeIndex;
|
|
865
|
+
pageDetail.custom = false;
|
|
866
|
+
pageDetail.customWidth = model.customPageWidth;
|
|
867
|
+
pageDetail.customHeight = model.customPageHeight;
|
|
868
|
+
meta.customX = model.customPageWidth;
|
|
869
|
+
meta.customY = model.customPageHeight;
|
|
870
|
+
pageDetail.physicHeight = model.customPageHeight;
|
|
871
|
+
pageDetail.physicWidth = model.customPageWidth;
|
|
872
|
+
}
|
|
873
|
+
apagesize = driver.setPageSize(pageDetail);
|
|
874
|
+
}
|
|
875
|
+
else {
|
|
876
|
+
const r = driver.getPageSize();
|
|
877
|
+
apagesize = r.size;
|
|
878
|
+
meta.pageSizeIndex = r.indexqt;
|
|
879
|
+
meta.customX = model.customPageWidth;
|
|
880
|
+
meta.customY = model.customPageHeight;
|
|
881
|
+
pageDetail.physicHeight = apagesize.y;
|
|
882
|
+
pageDetail.physicWidth = apagesize.x;
|
|
883
|
+
}
|
|
884
|
+
this.internalPageWidth = apagesize.x;
|
|
885
|
+
this.internalPageHeight = apagesize.y;
|
|
886
|
+
meta.orientation = model.pageOrientation;
|
|
887
|
+
meta.backColor = model.pageBackColor;
|
|
888
|
+
meta.customX = this.internalPageWidth;
|
|
889
|
+
meta.customY = this.internalPageHeight;
|
|
890
|
+
this.pageNum = -1;
|
|
891
|
+
}
|
|
892
|
+
meta.printerSelect = model.printerSelect;
|
|
893
|
+
meta.autoScale = model.autoScale;
|
|
894
|
+
meta.previewWindow = model.previewWindow;
|
|
895
|
+
meta.openDrawerAfter = model.actionAfter;
|
|
896
|
+
meta.openDrawerBefore = model.actionBefore;
|
|
897
|
+
for (const sub of this.subReports)
|
|
898
|
+
sub.lastRecord = false;
|
|
899
|
+
this.lastPage = false;
|
|
900
|
+
this.initEvaluator();
|
|
901
|
+
this.pageNumGroup = -1;
|
|
902
|
+
this.fRecordCount = 0;
|
|
903
|
+
this.initializeParams();
|
|
904
|
+
this.fDataAlias.list.length = 0;
|
|
905
|
+
for (const d of this.dataInfos)
|
|
906
|
+
this.fDataAlias.add(d.alias, d.data);
|
|
907
|
+
try {
|
|
908
|
+
yield* this.activateDatasets();
|
|
909
|
+
}
|
|
910
|
+
catch (e) {
|
|
911
|
+
yield* this.deActivateDatasets();
|
|
912
|
+
throw e;
|
|
913
|
+
}
|
|
914
|
+
this.checkIfDataAvailable();
|
|
915
|
+
this.evaluator.aliasList = this.fDataAlias;
|
|
916
|
+
this.prepareParamsAfterOpen();
|
|
917
|
+
for (const sub of this.subReports)
|
|
918
|
+
if (this.subreportMustBeExecuted(sub))
|
|
919
|
+
sub.subReportChanged(SubReportEvent.Start, '');
|
|
920
|
+
this.currentSubReportIndex = -1;
|
|
921
|
+
let dataavail = false;
|
|
922
|
+
do {
|
|
923
|
+
do {
|
|
924
|
+
this.currentSubReportIndex++;
|
|
925
|
+
} while (this.currentSubReportIndex < this.subReports.length &&
|
|
926
|
+
!this.subreportMustBeExecuted(this.subReports[this.currentSubReportIndex]));
|
|
927
|
+
if (this.currentSubReportIndex >= this.subReports.length)
|
|
928
|
+
break;
|
|
929
|
+
const subrep = this.subReports[this.currentSubReportIndex];
|
|
930
|
+
if (subrep.parentSubReport === null) {
|
|
931
|
+
if (subrep.alias.length === 0)
|
|
932
|
+
dataavail = true;
|
|
933
|
+
else if (subrep.printOnlyIfDataAvailable) {
|
|
934
|
+
const index = this.dataInfoIndexOf(subrep.alias);
|
|
935
|
+
if (!this.dataInfos[index].data.eof)
|
|
936
|
+
dataavail = true;
|
|
937
|
+
}
|
|
938
|
+
else
|
|
939
|
+
dataavail = true;
|
|
940
|
+
}
|
|
941
|
+
if (dataavail) {
|
|
942
|
+
subrep.subReportChanged(SubReportEvent.SubReportStart, '');
|
|
943
|
+
subrep.subReportChanged(SubReportEvent.DataChange, '');
|
|
944
|
+
this.currentSectionIndex = -1;
|
|
945
|
+
subrep.currentGroupIndex = -subrep.groupCount;
|
|
946
|
+
if (subrep.currentGroupIndex < 0)
|
|
947
|
+
this.currentSectionIndex = subrep.firstDetail + subrep.currentGroupIndex - 1;
|
|
948
|
+
this.section = null;
|
|
949
|
+
this.subreport = null;
|
|
950
|
+
if (!(yield* this.nextSection(true)))
|
|
951
|
+
dataavail = false;
|
|
952
|
+
}
|
|
953
|
+
} while (!dataavail);
|
|
954
|
+
if (!dataavail) {
|
|
955
|
+
yield* this.endPrint();
|
|
956
|
+
meta.empty = true;
|
|
957
|
+
throw new NoDataToPrintException(this.translator.translateStr(799));
|
|
958
|
+
}
|
|
959
|
+
this.printing = true;
|
|
960
|
+
}
|
|
961
|
+
catch (e) {
|
|
962
|
+
meta.empty = true;
|
|
963
|
+
throw e;
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
*nextSection(child) {
|
|
967
|
+
let searchGroupHeader = false;
|
|
968
|
+
const oldsection = this.section;
|
|
969
|
+
this.section = null;
|
|
970
|
+
// If the old selected section has a child subreport then execute first
|
|
971
|
+
if (oldsection !== null && child) {
|
|
972
|
+
if (oldsection.childSubReport !== null) {
|
|
973
|
+
let dataavail = false;
|
|
974
|
+
const subrep = oldsection.childSubReport;
|
|
975
|
+
if (subrep.alias.length === 0)
|
|
976
|
+
dataavail = true;
|
|
977
|
+
else {
|
|
978
|
+
const index = this.dataInfoIndexOf(subrep.alias);
|
|
979
|
+
if (index < 0)
|
|
980
|
+
throw new NamedException('Data alias not found:' + subrep.alias, subrep.alias);
|
|
981
|
+
const dinfo = this.dataInfos[index];
|
|
982
|
+
if (dinfo.dataSource.length === 0) {
|
|
983
|
+
if (dinfo.getDbItem().driver === DriverType.Mybase && dinfo.data.currentView !== null) {
|
|
984
|
+
// A dataset of the MyBase connection (a union) is not built again, its first row is
|
|
985
|
+
// the current one (as the Delphi engine does): its datasets were read already
|
|
986
|
+
dinfo.goFirstMem();
|
|
987
|
+
}
|
|
988
|
+
else {
|
|
989
|
+
dinfo.disConnect();
|
|
990
|
+
this.updateParamsBeforeOpen(index, true);
|
|
991
|
+
yield* dinfo.connect();
|
|
992
|
+
dinfo.goFirstMem();
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
else if (dinfo.data.eof) {
|
|
996
|
+
if (subrep.reOpenOnPrint) {
|
|
997
|
+
dinfo.disConnect();
|
|
998
|
+
this.updateParamsBeforeOpen(index, true);
|
|
999
|
+
yield* dinfo.connect();
|
|
1000
|
+
dinfo.goFirstMem();
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
if (!dinfo.data.eof)
|
|
1004
|
+
dataavail = true;
|
|
1005
|
+
else
|
|
1006
|
+
searchGroupHeader = true;
|
|
1007
|
+
}
|
|
1008
|
+
subrep.lastRecord = !dataavail;
|
|
1009
|
+
if (dataavail || !subrep.printOnlyIfDataAvailable) {
|
|
1010
|
+
subrep.subReportChanged(SubReportEvent.SubReportStart, '');
|
|
1011
|
+
this.subreport = subrep;
|
|
1012
|
+
this.section = null;
|
|
1013
|
+
this.currentSectionIndex = -1;
|
|
1014
|
+
this.pendingSections.push(oldsection);
|
|
1015
|
+
this.currentSubReportIndex = this.subReports.indexOf(subrep);
|
|
1016
|
+
subrep.subReportChanged(SubReportEvent.DataChange, '');
|
|
1017
|
+
subrep.currentGroupIndex = -subrep.groupCount;
|
|
1018
|
+
if (subrep.currentGroupIndex < 0)
|
|
1019
|
+
this.currentSectionIndex = subrep.firstDetail + subrep.currentGroupIndex - 1;
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
else
|
|
1023
|
+
searchGroupHeader = true;
|
|
1024
|
+
}
|
|
1025
|
+
else
|
|
1026
|
+
searchGroupHeader = true;
|
|
1027
|
+
if (this.fGroupHeaders.length === 0)
|
|
1028
|
+
searchGroupHeader = false;
|
|
1029
|
+
if (searchGroupHeader) {
|
|
1030
|
+
const index = oldsection === null ? -1 : this.fGroupHeaders.indexOf(oldsection);
|
|
1031
|
+
if (index >= 0) {
|
|
1032
|
+
this.fGroupHeaders.splice(index, 1);
|
|
1033
|
+
if (this.fGroupHeaders.length > 0) {
|
|
1034
|
+
this.section = this.fGroupHeaders[0];
|
|
1035
|
+
const asec = this.lastPending();
|
|
1036
|
+
this.currentSubReportIndex = this.subReportIndexOf(asec.subReport);
|
|
1037
|
+
if (this.currentSubReportIndex < 0)
|
|
1038
|
+
throw new UnNamedException('SubReport not found');
|
|
1039
|
+
this.subreport = this.section.subReport;
|
|
1040
|
+
}
|
|
1041
|
+
else {
|
|
1042
|
+
this.section = this.lastPending();
|
|
1043
|
+
this.currentSubReportIndex = this.subReportIndexOf(this.section.subReport);
|
|
1044
|
+
if (this.currentSubReportIndex < 0)
|
|
1045
|
+
throw new UnNamedException('SubReport not found');
|
|
1046
|
+
this.pendingSections.pop();
|
|
1047
|
+
this.subreport = this.section.subReport;
|
|
1048
|
+
this.currentSectionIndex = this.subreport.sections.indexOf(this.section);
|
|
1049
|
+
if (this.currentSectionIndex < 0)
|
|
1050
|
+
throw new UnNamedException('Section not found');
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
if (this.section !== null)
|
|
1055
|
+
return true;
|
|
1056
|
+
// Check the condition
|
|
1057
|
+
while (this.currentSubReportIndex < this.subReports.length) {
|
|
1058
|
+
this.checkProgress(false);
|
|
1059
|
+
let subrep = this.subReports[this.currentSubReportIndex];
|
|
1060
|
+
// The first section are the group footers until CurrentGroup
|
|
1061
|
+
while (subrep.currentGroupIndex !== 0) {
|
|
1062
|
+
this.checkProgress(false);
|
|
1063
|
+
const lastdetail = subrep.lastDetail;
|
|
1064
|
+
const firstdetail = subrep.firstDetail;
|
|
1065
|
+
this.currentSectionIndex++;
|
|
1066
|
+
if (subrep.currentGroupIndex > 0) {
|
|
1067
|
+
if (subrep.currentGroupIndex < this.currentSectionIndex - lastdetail) {
|
|
1068
|
+
// Restore position, and the next will be group headers
|
|
1069
|
+
if (subrep.lastRecord) {
|
|
1070
|
+
this.currentSectionIndex = subrep.sections.length;
|
|
1071
|
+
subrep.currentGroupIndex = 0;
|
|
1072
|
+
break;
|
|
1073
|
+
}
|
|
1074
|
+
else {
|
|
1075
|
+
// Send Messages for each group
|
|
1076
|
+
subrep.initGroups(subrep.currentGroupIndex);
|
|
1077
|
+
// Restores position
|
|
1078
|
+
yield* this.nextRecord(true);
|
|
1079
|
+
this.currentSectionIndex = subrep.firstDetail - subrep.currentGroupIndex;
|
|
1080
|
+
subrep.currentGroupIndex = -subrep.currentGroupIndex;
|
|
1081
|
+
const sec = this.sectionOf(subrep, this.currentSectionIndex);
|
|
1082
|
+
if (sec.evaluatePrintCondition()) {
|
|
1083
|
+
this.section = sec;
|
|
1084
|
+
this.subreport = subrep;
|
|
1085
|
+
break;
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
else {
|
|
1090
|
+
const sec = this.sectionOf(subrep, this.currentSectionIndex);
|
|
1091
|
+
if (sec.evaluatePrintCondition()) {
|
|
1092
|
+
this.section = sec;
|
|
1093
|
+
this.subreport = subrep;
|
|
1094
|
+
break;
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
else {
|
|
1099
|
+
// Group headers
|
|
1100
|
+
if (this.currentSectionIndex < firstdetail) {
|
|
1101
|
+
const sec = this.sectionOf(subrep, this.currentSectionIndex);
|
|
1102
|
+
if (sec.evaluatePrintCondition()) {
|
|
1103
|
+
this.section = sec;
|
|
1104
|
+
this.subreport = subrep;
|
|
1105
|
+
break;
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
else {
|
|
1109
|
+
subrep.currentGroupIndex = 0;
|
|
1110
|
+
this.currentSectionIndex = -1;
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
if (this.section !== null)
|
|
1115
|
+
break;
|
|
1116
|
+
while (this.currentSectionIndex < subrep.sections.length) {
|
|
1117
|
+
this.checkProgress(false);
|
|
1118
|
+
if (this.currentSectionIndex < 0)
|
|
1119
|
+
this.currentSectionIndex = subrep.firstDetail;
|
|
1120
|
+
else
|
|
1121
|
+
this.currentSectionIndex++;
|
|
1122
|
+
if (!subrep.lastRecord) {
|
|
1123
|
+
if (this.currentSectionIndex > subrep.lastDetail) {
|
|
1124
|
+
if (yield* this.nextRecord(false)) {
|
|
1125
|
+
this.currentSectionIndex = subrep.lastDetail;
|
|
1126
|
+
break;
|
|
1127
|
+
}
|
|
1128
|
+
if (!subrep.lastRecord) {
|
|
1129
|
+
this.currentSectionIndex = subrep.firstDetail;
|
|
1130
|
+
const sec = this.sectionOf(subrep, this.currentSectionIndex);
|
|
1131
|
+
if (sec.evaluatePrintCondition()) {
|
|
1132
|
+
this.section = sec;
|
|
1133
|
+
this.subreport = subrep;
|
|
1134
|
+
break;
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
else {
|
|
1138
|
+
this.currentSectionIndex = subrep.lastDetail;
|
|
1139
|
+
subrep.currentGroupIndex = subrep.groupCount;
|
|
1140
|
+
break;
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
else if (this.currentSectionIndex <= subrep.lastDetail) {
|
|
1144
|
+
const sec = this.sectionOf(subrep, this.currentSectionIndex);
|
|
1145
|
+
if (sec.evaluatePrintCondition()) {
|
|
1146
|
+
this.section = sec;
|
|
1147
|
+
this.subreport = subrep;
|
|
1148
|
+
break;
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
if (this.section === null && subrep.currentGroupIndex === 0) {
|
|
1154
|
+
// If it's a child subreport, returns null section so pending will print
|
|
1155
|
+
if (subrep.parentSubReport !== null)
|
|
1156
|
+
break;
|
|
1157
|
+
for (;;) {
|
|
1158
|
+
subrep.subReportChanged(SubReportEvent.SubReportEnd, '');
|
|
1159
|
+
do {
|
|
1160
|
+
this.currentSubReportIndex++;
|
|
1161
|
+
} while (this.currentSubReportIndex < this.subReports.length &&
|
|
1162
|
+
!this.subreportMustBeExecuted(this.subReports[this.currentSubReportIndex]));
|
|
1163
|
+
if (this.currentSubReportIndex >= this.subReports.length)
|
|
1164
|
+
break;
|
|
1165
|
+
subrep = this.subReports[this.currentSubReportIndex];
|
|
1166
|
+
if (subrep.parentSubReport === null) {
|
|
1167
|
+
if (subrep.isDataAvailable()) {
|
|
1168
|
+
subrep.subReportChanged(SubReportEvent.SubReportStart, '');
|
|
1169
|
+
subrep.subReportChanged(SubReportEvent.DataChange, '');
|
|
1170
|
+
break;
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
if (this.currentSubReportIndex >= this.subReports.length)
|
|
1175
|
+
break;
|
|
1176
|
+
this.currentSectionIndex = subrep.firstDetail - subrep.groupCount - 1;
|
|
1177
|
+
subrep.currentGroupIndex = -subrep.groupCount;
|
|
1178
|
+
subrep.lastRecord = false;
|
|
1179
|
+
}
|
|
1180
|
+
else if (subrep.currentGroupIndex === 0)
|
|
1181
|
+
break;
|
|
1182
|
+
}
|
|
1183
|
+
const aresult = this.section !== null;
|
|
1184
|
+
// If there are still pending sections
|
|
1185
|
+
if (this.section === null) {
|
|
1186
|
+
if (this.pendingSections.length > 0) {
|
|
1187
|
+
this.section = this.lastPending();
|
|
1188
|
+
this.currentSubReportIndex = this.subReportIndexOf(this.section.subReport);
|
|
1189
|
+
if (this.currentSubReportIndex < 0)
|
|
1190
|
+
throw new UnNamedException('Subreport not found');
|
|
1191
|
+
this.pendingSections.pop();
|
|
1192
|
+
this.subreport = this.section.subReport;
|
|
1193
|
+
this.currentSectionIndex = this.subreport.sections.indexOf(this.section);
|
|
1194
|
+
if (this.currentSectionIndex < 0)
|
|
1195
|
+
throw new UnNamedException('Subreport not found');
|
|
1196
|
+
yield* this.nextSection(false);
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
return aresult;
|
|
1200
|
+
}
|
|
1201
|
+
lastPending() {
|
|
1202
|
+
const s = this.pendingSections[this.pendingSections.length - 1];
|
|
1203
|
+
if (s === undefined)
|
|
1204
|
+
throw new RangeError('Index was out of range. Must be non-negative and less than the size of the collection.');
|
|
1205
|
+
return s;
|
|
1206
|
+
}
|
|
1207
|
+
subReportIndexOf(sub) {
|
|
1208
|
+
return sub === null ? -1 : this.subReports.indexOf(sub);
|
|
1209
|
+
}
|
|
1210
|
+
sectionOf(subrep, index) {
|
|
1211
|
+
const s = subrep.sections[index];
|
|
1212
|
+
if (s === undefined)
|
|
1213
|
+
throw new RangeError('Index was out of range. Must be non-negative and less than the size of the collection.');
|
|
1214
|
+
return s;
|
|
1215
|
+
}
|
|
1216
|
+
skipToPageAndPosition() {
|
|
1217
|
+
const asection = this.asection;
|
|
1218
|
+
const ev = this.evaluator;
|
|
1219
|
+
const ctx = ev.context;
|
|
1220
|
+
let newposx = 0;
|
|
1221
|
+
let newposy = 0;
|
|
1222
|
+
try {
|
|
1223
|
+
// Go to page?
|
|
1224
|
+
if (asection.skipToPageExpre.length > 0) {
|
|
1225
|
+
if (!this.model.twoPass)
|
|
1226
|
+
throw new UnNamedException('Two pass report required for skip to feature');
|
|
1227
|
+
let newpage = convertDoubleToInt32(ev.evaluateText(asection.skipToPageExpre).toDouble(ctx));
|
|
1228
|
+
newpage = newpage - 1;
|
|
1229
|
+
if (newpage < 0)
|
|
1230
|
+
throw new UnNamedException('Can not combine skip to page');
|
|
1231
|
+
const meta = this.metaFile;
|
|
1232
|
+
while (newpage > meta.pages.currentCount) {
|
|
1233
|
+
meta.pages.add(new MetaPage(meta));
|
|
1234
|
+
const last = meta.pages.get(meta.pages.currentCount - 1);
|
|
1235
|
+
last.orientation = this.currentOrientation;
|
|
1236
|
+
this.doUpdatePageSize(last, last.pageDetail);
|
|
1237
|
+
this.checkProgress(false);
|
|
1238
|
+
}
|
|
1239
|
+
meta.currentPage = newpage;
|
|
1240
|
+
this.pageNum = meta.currentPage;
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
catch (e) {
|
|
1244
|
+
throw new ReportException(messageOf(e), asection.name, 'SkipToPage');
|
|
1245
|
+
}
|
|
1246
|
+
let moveh = false;
|
|
1247
|
+
try {
|
|
1248
|
+
if (asection.skipExpreH.length > 0) {
|
|
1249
|
+
newposx = convertDoubleToInt32(ev.evaluateText(asection.skipExpreH).toDouble(ctx));
|
|
1250
|
+
moveh = true;
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
catch (e) {
|
|
1254
|
+
throw new ReportException(messageOf(e), asection.name, 'SkipExpreH');
|
|
1255
|
+
}
|
|
1256
|
+
let movev = false;
|
|
1257
|
+
try {
|
|
1258
|
+
if (asection.skipExpreV.length > 0) {
|
|
1259
|
+
newposy = convertDoubleToInt32(ev.evaluateText(asection.skipExpreV).toDouble(ctx));
|
|
1260
|
+
movev = true;
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
catch (e) {
|
|
1264
|
+
throw new ReportException(messageOf(e), asection.name, 'SkipExpreV');
|
|
1265
|
+
}
|
|
1266
|
+
if (moveh) {
|
|
1267
|
+
if (asection.skipRelativeH)
|
|
1268
|
+
this.pageposx = this.pageposx + newposx;
|
|
1269
|
+
else
|
|
1270
|
+
this.pageposx = newposx;
|
|
1271
|
+
}
|
|
1272
|
+
if (movev) {
|
|
1273
|
+
if (asection.skipRelativeV)
|
|
1274
|
+
this.pageposy = this.pageposy + newposy;
|
|
1275
|
+
else
|
|
1276
|
+
this.pageposy = newposy;
|
|
1277
|
+
}
|
|
1278
|
+
this.freeSpace = this.pagefooterpos - this.pageposy;
|
|
1279
|
+
if (this.freeSpace < 0)
|
|
1280
|
+
this.freeSpace = 0;
|
|
1281
|
+
}
|
|
1282
|
+
checkSpace() {
|
|
1283
|
+
if (this.freeSpace === 0)
|
|
1284
|
+
return false;
|
|
1285
|
+
const maxExtent = pt(this.pagespacex, this.freeSpace);
|
|
1286
|
+
const asection = this.asection;
|
|
1287
|
+
const driver = this.requireDriver();
|
|
1288
|
+
if (!this.sectionextevaluated) {
|
|
1289
|
+
// Skip to page and position
|
|
1290
|
+
if (asection.skipType === SkipType.Before)
|
|
1291
|
+
this.skipToPageAndPosition();
|
|
1292
|
+
this.sectionext = asection.getExtension(driver, maxExtent, false);
|
|
1293
|
+
}
|
|
1294
|
+
let aresult = true;
|
|
1295
|
+
if (this.sectionext.y > this.freeSpace) {
|
|
1296
|
+
if (this.printedSomething)
|
|
1297
|
+
aresult = false;
|
|
1298
|
+
else {
|
|
1299
|
+
// Force partial print for expressions
|
|
1300
|
+
this.sectionext = asection.getExtension(driver, maxExtent, true);
|
|
1301
|
+
if (this.sectionext.y > this.freeSpace)
|
|
1302
|
+
throw new UnNamedException('No Espace to print SubReport ' + String(this.currentSubReportIndex) + ' Section ' + String(this.currentSectionIndex));
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
this.sectionextevaluated = false;
|
|
1306
|
+
return aresult;
|
|
1307
|
+
}
|
|
1308
|
+
printSection(datasection, partialPrint) {
|
|
1309
|
+
const section = this.section;
|
|
1310
|
+
const subreport = this.subreport;
|
|
1311
|
+
if (subreport.currentGroupIndex < 0) {
|
|
1312
|
+
if (section.groupName === this.sectionOf(subreport, subreport.firstDetail + subreport.currentGroupIndex).groupName) {
|
|
1313
|
+
if (section.iniNumPage)
|
|
1314
|
+
this.pageNumGroup = 0;
|
|
1315
|
+
section.firstPage = this.metaFile.currentPage;
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
this.pagefooterpos = this.pageposy + this.freeSpace;
|
|
1319
|
+
partialPrint.value = false;
|
|
1320
|
+
const maxExtent = pt(this.pagespacex, this.freeSpace);
|
|
1321
|
+
const asection = this.asection;
|
|
1322
|
+
if (datasection) {
|
|
1323
|
+
let ispagerepeat = false;
|
|
1324
|
+
if (asection.sectionType === SectionType.GroupHeader)
|
|
1325
|
+
ispagerepeat = asection.pageRepeat;
|
|
1326
|
+
if (!ispagerepeat) {
|
|
1327
|
+
this.oldprintedsection = section;
|
|
1328
|
+
this.oldprintedsectionext = { ...this.sectionext };
|
|
1329
|
+
if (this.fGroupHeaders.length < 1)
|
|
1330
|
+
this.printedSomething = true;
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
const driver = this.requireDriver();
|
|
1334
|
+
if (!asection.alignBottom) {
|
|
1335
|
+
asection.print(driver, this.pageposx, this.pageposy, -1, -1, this.metaFile, maxExtent, partialPrint);
|
|
1336
|
+
this.freeSpace = this.freeSpace - this.sectionext.y;
|
|
1337
|
+
this.pageposy = this.pageposy + this.sectionext.y;
|
|
1338
|
+
}
|
|
1339
|
+
else {
|
|
1340
|
+
// Align to bottom
|
|
1341
|
+
this.pageposy = this.pageposy + this.freeSpace - this.sectionext.y;
|
|
1342
|
+
asection.print(driver, this.pageposx, this.pageposy, -1, -1, this.metaFile, maxExtent, partialPrint);
|
|
1343
|
+
this.freeSpace = 0;
|
|
1344
|
+
}
|
|
1345
|
+
if (asection.skipType === SkipType.After)
|
|
1346
|
+
this.skipToPageAndPosition();
|
|
1347
|
+
}
|
|
1348
|
+
printFixedSections(headers) {
|
|
1349
|
+
const partialPrint = { value: false };
|
|
1350
|
+
const maxExtent = pt(this.pagespacex, this.freeSpace);
|
|
1351
|
+
const subreport = this.subreport;
|
|
1352
|
+
if (headers) {
|
|
1353
|
+
// First the global headers
|
|
1354
|
+
for (const psection of this.gHeaders) {
|
|
1355
|
+
if (psection.evaluatePrintCondition()) {
|
|
1356
|
+
this.asection = psection;
|
|
1357
|
+
this.checkSpace();
|
|
1358
|
+
this.printSection(false, partialPrint);
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
// Print the header fixed sections
|
|
1362
|
+
const pheader = subreport.firstPageHeader;
|
|
1363
|
+
const pheadercount = subreport.pageHeaderCount;
|
|
1364
|
+
for (let i = 0; i < pheadercount; i++) {
|
|
1365
|
+
const psection = this.sectionOf(subreport, i + pheader);
|
|
1366
|
+
if (!psection.global) {
|
|
1367
|
+
if (psection.evaluatePrintCondition()) {
|
|
1368
|
+
this.asection = psection;
|
|
1369
|
+
this.checkSpace();
|
|
1370
|
+
this.printSection(false, partialPrint);
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
const psubreports = [];
|
|
1375
|
+
for (const psection of this.pendingSections) {
|
|
1376
|
+
// C# parity: the subreport of a section without one (null) is added as null
|
|
1377
|
+
const sub = psection.subReport;
|
|
1378
|
+
if (sub === null)
|
|
1379
|
+
throw nullReferenceException();
|
|
1380
|
+
if (psubreports.indexOf(sub) < 0)
|
|
1381
|
+
psubreports.push(sub);
|
|
1382
|
+
}
|
|
1383
|
+
if (psubreports.indexOf(subreport) < 0)
|
|
1384
|
+
psubreports.push(subreport);
|
|
1385
|
+
// Now prints repeated group headers
|
|
1386
|
+
for (const subrep of psubreports) {
|
|
1387
|
+
const afirstdetail = subrep.firstDetail;
|
|
1388
|
+
for (let i = subrep.groupCount; i > 0; i--) {
|
|
1389
|
+
const psection = this.sectionOf(subrep, afirstdetail - i);
|
|
1390
|
+
if (psection.pageRepeat) {
|
|
1391
|
+
let dopagerepeat = false;
|
|
1392
|
+
// Allways if there is another active subreport
|
|
1393
|
+
if (subrep !== subreport)
|
|
1394
|
+
dopagerepeat = true;
|
|
1395
|
+
else if (this.section !== psection) {
|
|
1396
|
+
// Never if the current section is just the group header
|
|
1397
|
+
if (this.currentSectionIndex > subrep.firstDetail - i) {
|
|
1398
|
+
// If the section is enclosed between the header and the footer
|
|
1399
|
+
if (psection.forcePrint) {
|
|
1400
|
+
if (this.currentSectionIndex <= subrep.lastDetail + i)
|
|
1401
|
+
dopagerepeat = true;
|
|
1402
|
+
}
|
|
1403
|
+
else if (this.currentSectionIndex < subrep.lastDetail + i)
|
|
1404
|
+
dopagerepeat = true;
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
if (dopagerepeat && psection.evaluatePrintCondition()) {
|
|
1408
|
+
// Add group headers to be printed at the main print loop
|
|
1409
|
+
this.fGroupHeaders.push(psection);
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
this.pagefooterpos = this.pageposy + this.freeSpace;
|
|
1415
|
+
// Reserve space for page footers: print conditions for footers are evaluated at the
|
|
1416
|
+
// begining of the page
|
|
1417
|
+
for (const psection of this.gFooters) {
|
|
1418
|
+
this.asection = psection;
|
|
1419
|
+
this.checkSpace();
|
|
1420
|
+
this.pagefooterpos = this.pageposy + this.freeSpace - this.sectionext.y;
|
|
1421
|
+
this.freeSpace = this.freeSpace - this.sectionext.y;
|
|
1422
|
+
}
|
|
1423
|
+
const pfooter = subreport.firstPageFooter;
|
|
1424
|
+
const pfootercount = subreport.pageFooterCount;
|
|
1425
|
+
for (let i = 0; i < pfootercount; i++) {
|
|
1426
|
+
const psection = this.sectionOf(subreport, i + pfooter);
|
|
1427
|
+
if (!psection.global) {
|
|
1428
|
+
this.asection = psection;
|
|
1429
|
+
this.havepagefooters = true;
|
|
1430
|
+
this.checkSpace();
|
|
1431
|
+
this.pagefooters.push(psection);
|
|
1432
|
+
this.pagefooterpos = this.pageposy + this.freeSpace - this.sectionext.y;
|
|
1433
|
+
this.freeSpace = this.freeSpace - this.sectionext.y;
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
else {
|
|
1438
|
+
// Print page footers
|
|
1439
|
+
const pagefooters = this.pagefooters;
|
|
1440
|
+
if (this.gFooters.length > 0 || pagefooters.length > 0) {
|
|
1441
|
+
this.pageposy = this.pagefooterpos;
|
|
1442
|
+
const driver = this.requireDriver();
|
|
1443
|
+
for (const asection of pagefooters) {
|
|
1444
|
+
this.asection = asection;
|
|
1445
|
+
if (!asection.global) {
|
|
1446
|
+
let printit = true;
|
|
1447
|
+
if (!asection.forcePrint && this.section === null)
|
|
1448
|
+
printit = false;
|
|
1449
|
+
if (printit && asection.evaluatePrintCondition()) {
|
|
1450
|
+
this.sectionext = asection.getExtension(driver, maxExtent, false);
|
|
1451
|
+
this.printSection(false, partialPrint);
|
|
1452
|
+
this.freeSpace = 0;
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
// Global page footers
|
|
1457
|
+
for (const asection of this.gFooters) {
|
|
1458
|
+
this.asection = asection;
|
|
1459
|
+
let printit = true;
|
|
1460
|
+
if (!asection.forcePrint && this.section === null)
|
|
1461
|
+
printit = false;
|
|
1462
|
+
if (printit && asection.evaluatePrintCondition()) {
|
|
1463
|
+
this.sectionext = asection.getExtension(driver, maxExtent, false);
|
|
1464
|
+
this.printSection(false, partialPrint);
|
|
1465
|
+
this.freeSpace = 0;
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
*nextRecord(grouprestore) {
|
|
1472
|
+
let aresult = false;
|
|
1473
|
+
const subrep = this.subReports[this.currentSubReportIndex];
|
|
1474
|
+
if (subrep.alias.length === 0)
|
|
1475
|
+
subrep.lastRecord = true;
|
|
1476
|
+
else {
|
|
1477
|
+
const index = this.dataInfoIndexOf(subrep.alias);
|
|
1478
|
+
if (index < 0)
|
|
1479
|
+
throw new NamedException('Alias not exists' + subrep.alias, subrep.alias);
|
|
1480
|
+
const data = this.dataInfos[index].data;
|
|
1481
|
+
yield* data.next();
|
|
1482
|
+
// If its the last record no group change
|
|
1483
|
+
if (!grouprestore)
|
|
1484
|
+
subrep.lastRecord = data.eof;
|
|
1485
|
+
if (!subrep.lastRecord) {
|
|
1486
|
+
if (!grouprestore) {
|
|
1487
|
+
subrep.groupChanged();
|
|
1488
|
+
if (subrep.currentGroupIndex > 0) {
|
|
1489
|
+
aresult = true;
|
|
1490
|
+
yield* data.prior();
|
|
1491
|
+
}
|
|
1492
|
+
else
|
|
1493
|
+
subrep.subReportChanged(SubReportEvent.DataChange, '');
|
|
1494
|
+
}
|
|
1495
|
+
else
|
|
1496
|
+
subrep.subReportChanged(SubReportEvent.DataChange, '');
|
|
1497
|
+
}
|
|
1498
|
+
this.fRecordCount++;
|
|
1499
|
+
this.checkProgress(false);
|
|
1500
|
+
}
|
|
1501
|
+
return aresult;
|
|
1502
|
+
}
|
|
1503
|
+
/** PrintNextPage: generates the next page; true when it is the last one. */
|
|
1504
|
+
*printNextPage() {
|
|
1505
|
+
if (this.errorProcessing)
|
|
1506
|
+
throw new UnNamedException('Error processing\n' + this.lastErrorProcessing);
|
|
1507
|
+
const meta = this.metaFile;
|
|
1508
|
+
this.pageNum++;
|
|
1509
|
+
this.pageNumGroup++;
|
|
1510
|
+
// Updates page size, and orientation
|
|
1511
|
+
if (meta.pages.currentCount <= this.pageNum) {
|
|
1512
|
+
if (this.model.twoPass)
|
|
1513
|
+
meta.forwardOnly = false;
|
|
1514
|
+
meta.pages.add(new MetaPage(meta));
|
|
1515
|
+
}
|
|
1516
|
+
meta.currentPage = this.pageNum;
|
|
1517
|
+
const pageDetail = this.initialPageDetail;
|
|
1518
|
+
this.doUpdatePageSize(meta.pages.get(meta.pages.currentCount - 1), pageDetail);
|
|
1519
|
+
this.fGroupHeaders.length = 0;
|
|
1520
|
+
this.printedSomething = false;
|
|
1521
|
+
if (this.section === null)
|
|
1522
|
+
throw new UnNamedException('Last sectoin reached');
|
|
1523
|
+
if (this.subreport !== null)
|
|
1524
|
+
for (const sub of this.subReports)
|
|
1525
|
+
sub.subReportChanged(SubReportEvent.PageChange, '');
|
|
1526
|
+
this.havepagefooters = false;
|
|
1527
|
+
this.sectionextevaluated = false;
|
|
1528
|
+
this.oldprintedsection = null;
|
|
1529
|
+
const model = this.model;
|
|
1530
|
+
if (!this.fCompose) {
|
|
1531
|
+
this.freeSpace = this.internalPageHeight;
|
|
1532
|
+
this.freeSpace = this.freeSpace - model.topMargin - model.bottomMargin;
|
|
1533
|
+
this.pageposy = model.topMargin;
|
|
1534
|
+
this.pageposx = model.leftMargin;
|
|
1535
|
+
}
|
|
1536
|
+
else {
|
|
1537
|
+
if (this.gHeaders.length > 0 || this.subreport.pageHeaderCount > 0) {
|
|
1538
|
+
meta.pages.add(new MetaPage(meta));
|
|
1539
|
+
this.pageNum++;
|
|
1540
|
+
meta.currentPage = meta.pages.currentCount - 1;
|
|
1541
|
+
this.freeSpace = this.internalPageHeight;
|
|
1542
|
+
this.freeSpace = this.freeSpace - model.topMargin - model.bottomMargin;
|
|
1543
|
+
this.pageposy = model.topMargin;
|
|
1544
|
+
this.pageposx = model.leftMargin;
|
|
1545
|
+
this.doUpdatePageSize(meta.pages.get(meta.pages.currentCount - 1), pageDetail);
|
|
1546
|
+
}
|
|
1547
|
+
else
|
|
1548
|
+
this.printedSomething = true;
|
|
1549
|
+
}
|
|
1550
|
+
this.pagespacex = this.internalPageWidth;
|
|
1551
|
+
let oldhorzdespposition = model.leftMargin;
|
|
1552
|
+
const oldculture = this.context.culture;
|
|
1553
|
+
// Change culture
|
|
1554
|
+
const pageCulture = languageCulture(this.fLanguage);
|
|
1555
|
+
if (pageCulture !== undefined)
|
|
1556
|
+
this.context.culture = pageCulture;
|
|
1557
|
+
this.pagefooters = [];
|
|
1558
|
+
try {
|
|
1559
|
+
const partialPrint = { value: false };
|
|
1560
|
+
// Fills the page with fixed sections
|
|
1561
|
+
this.printFixedSections(true);
|
|
1562
|
+
// Group headers with child subreports
|
|
1563
|
+
if (this.fGroupHeaders.length > 0) {
|
|
1564
|
+
this.pendingSections.push(this.section);
|
|
1565
|
+
this.section = this.fGroupHeaders[0];
|
|
1566
|
+
}
|
|
1567
|
+
this.oldsubreport = this.subreport;
|
|
1568
|
+
const lastvertpos = pt(this.pageposx, this.pageposy);
|
|
1569
|
+
while (this.section !== null) {
|
|
1570
|
+
const section = this.section;
|
|
1571
|
+
if (this.printedSomething) {
|
|
1572
|
+
if (section.evaluateBeginPage())
|
|
1573
|
+
break;
|
|
1574
|
+
}
|
|
1575
|
+
this.asection = section;
|
|
1576
|
+
const driver = this.requireDriver();
|
|
1577
|
+
// Horz.Desp.
|
|
1578
|
+
const oldprinted = this.oldprintedsection;
|
|
1579
|
+
if (oldprinted !== null) {
|
|
1580
|
+
if (oldprinted.horzDesp) {
|
|
1581
|
+
if (section.horzDesp) {
|
|
1582
|
+
const maxExtent = pt(this.pagespacex, this.freeSpace);
|
|
1583
|
+
this.sectionext = section.getExtension(driver, maxExtent, false);
|
|
1584
|
+
this.sectionextevaluated = true;
|
|
1585
|
+
if (this.pageposx + this.oldprintedsectionext.x + this.sectionext.x <= this.pagespacex) {
|
|
1586
|
+
this.pageposx = this.pageposx + this.oldprintedsectionext.x;
|
|
1587
|
+
this.pageposy = this.pageposy - this.oldprintedsectionext.y;
|
|
1588
|
+
this.freeSpace = this.freeSpace + this.oldprintedsectionext.y;
|
|
1589
|
+
}
|
|
1590
|
+
else
|
|
1591
|
+
this.pageposx = model.leftMargin;
|
|
1592
|
+
}
|
|
1593
|
+
else
|
|
1594
|
+
this.pageposx = oldhorzdespposition;
|
|
1595
|
+
}
|
|
1596
|
+
else
|
|
1597
|
+
oldhorzdespposition = this.pageposx;
|
|
1598
|
+
}
|
|
1599
|
+
if (!this.checkSpace()) {
|
|
1600
|
+
// If the current section have vert desp, do a vertical and horz. desp if possible
|
|
1601
|
+
if (section.vertDesp) {
|
|
1602
|
+
// Go to old vertical position if fits horizontally
|
|
1603
|
+
const maxExtent = pt(this.pagespacex, lastvertpos.y - model.bottomMargin);
|
|
1604
|
+
this.sectionext = section.getExtension(driver, maxExtent, false);
|
|
1605
|
+
this.sectionextevaluated = true;
|
|
1606
|
+
if (this.pageposx + this.sectionext.x * 2 <= this.pagespacex) {
|
|
1607
|
+
this.freeSpace = this.freeSpace + (this.pageposy - lastvertpos.y);
|
|
1608
|
+
this.pageposx = this.pageposx + this.sectionext.x;
|
|
1609
|
+
this.pageposy = lastvertpos.y;
|
|
1610
|
+
}
|
|
1611
|
+
else {
|
|
1612
|
+
this.pageposx = model.leftMargin;
|
|
1613
|
+
break;
|
|
1614
|
+
}
|
|
1615
|
+
if (!this.checkSpace())
|
|
1616
|
+
break;
|
|
1617
|
+
}
|
|
1618
|
+
else
|
|
1619
|
+
break;
|
|
1620
|
+
}
|
|
1621
|
+
partialPrint.value = false;
|
|
1622
|
+
this.printSection(true, partialPrint);
|
|
1623
|
+
if (!partialPrint.value) {
|
|
1624
|
+
if (!section.vertDesp) {
|
|
1625
|
+
lastvertpos.x = this.pageposx;
|
|
1626
|
+
lastvertpos.y = this.pageposy;
|
|
1627
|
+
}
|
|
1628
|
+
yield* this.nextSection(true);
|
|
1629
|
+
if (this.section !== null) {
|
|
1630
|
+
if (!this.section.vertDesp) {
|
|
1631
|
+
lastvertpos.x = this.pageposx;
|
|
1632
|
+
lastvertpos.y = this.pageposy;
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
if (this.printedSomething) {
|
|
1637
|
+
if (this.asection.skipPage)
|
|
1638
|
+
break;
|
|
1639
|
+
}
|
|
1640
|
+
// if Subreport changed and has have pagefooter
|
|
1641
|
+
if (this.oldsubreport !== this.subreport && this.havepagefooters)
|
|
1642
|
+
break;
|
|
1643
|
+
this.oldsubreport = this.subreport;
|
|
1644
|
+
}
|
|
1645
|
+
// Fills the page with fixed sections
|
|
1646
|
+
if (this.printedSomething) {
|
|
1647
|
+
const oldprinted = this.oldprintedsection;
|
|
1648
|
+
if (oldprinted !== null && oldprinted.horzDesp)
|
|
1649
|
+
this.pageposx = oldhorzdespposition;
|
|
1650
|
+
}
|
|
1651
|
+
this.printFixedSections(false);
|
|
1652
|
+
this.pagefooters = null;
|
|
1653
|
+
this.context.culture = oldculture;
|
|
1654
|
+
}
|
|
1655
|
+
catch (e) {
|
|
1656
|
+
this.context.culture = oldculture;
|
|
1657
|
+
this.pagefooters = null;
|
|
1658
|
+
this.errorProcessing = true;
|
|
1659
|
+
this.lastErrorProcessing = messageOf(e);
|
|
1660
|
+
throw e;
|
|
1661
|
+
}
|
|
1662
|
+
const aresult = this.section === null;
|
|
1663
|
+
this.lastPage = aresult;
|
|
1664
|
+
if (this.lastPage) {
|
|
1665
|
+
meta.finish();
|
|
1666
|
+
this.checkProgress(true);
|
|
1667
|
+
}
|
|
1668
|
+
if (aresult)
|
|
1669
|
+
yield* this.endPrint();
|
|
1670
|
+
return aresult;
|
|
1671
|
+
}
|
|
1672
|
+
// -------------------------------------------------------------------------------------------
|
|
1673
|
+
// The operations of the report identifiers
|
|
1674
|
+
graphicOp(left, top, width, height, drawStyle, brushStyle, brushColor, penStyle, penWidth, penColor) {
|
|
1675
|
+
const obj = new MetaObjectDraw();
|
|
1676
|
+
obj.metaType = MetaObjectType.Draw;
|
|
1677
|
+
obj.top = top;
|
|
1678
|
+
obj.left = left;
|
|
1679
|
+
obj.height = height;
|
|
1680
|
+
obj.width = width;
|
|
1681
|
+
obj.drawStyle = drawStyle;
|
|
1682
|
+
obj.brushStyle = brushStyle;
|
|
1683
|
+
obj.brushColor = brushColor;
|
|
1684
|
+
obj.penStyle = penStyle;
|
|
1685
|
+
obj.penWidth = penWidth;
|
|
1686
|
+
obj.penColor = penColor;
|
|
1687
|
+
this.metaFile.pages.get(this.metaFile.currentPage).objects.push(obj);
|
|
1688
|
+
return true;
|
|
1689
|
+
}
|
|
1690
|
+
orientationOp(orientation) {
|
|
1691
|
+
if (orientation < 0 || orientation > 2)
|
|
1692
|
+
throw new UnNamedException('Invalid page orientation');
|
|
1693
|
+
this.currentOrientation = orientation;
|
|
1694
|
+
this.updatePageSize = true;
|
|
1695
|
+
const meta = this.metaFile;
|
|
1696
|
+
const page = meta.pages.get(meta.pages.currentCount - 1);
|
|
1697
|
+
this.doUpdatePageSize(page, page.pageDetail);
|
|
1698
|
+
}
|
|
1699
|
+
pageOp(pageIndex, custom, customwidth, customheight, papersource, forcepapername, duplex) {
|
|
1700
|
+
const meta = this.metaFile;
|
|
1701
|
+
// C# parity: Pages.Count generates every page first (a request of every page from inside an
|
|
1702
|
+
// expression); a page not generated yet is not supported here
|
|
1703
|
+
if (pageIndex >= meta.pages.currentCount && !meta.finished)
|
|
1704
|
+
throw new NotSupportedYetError('SETPAGESOURCE for a page that is not generated yet (page ' + String(pageIndex) + ')');
|
|
1705
|
+
if (pageIndex < meta.pages.currentCount) {
|
|
1706
|
+
const page = meta.pages.get(pageIndex);
|
|
1707
|
+
page.updatedPageSize = true;
|
|
1708
|
+
const d = page.pageDetail;
|
|
1709
|
+
// C# parity: the report's Duplex, not the one given
|
|
1710
|
+
void duplex;
|
|
1711
|
+
d.duplex = this.model.duplex;
|
|
1712
|
+
d.index = pageIndex;
|
|
1713
|
+
d.custom = custom;
|
|
1714
|
+
d.customHeight = customheight;
|
|
1715
|
+
d.customWidth = customwidth;
|
|
1716
|
+
d.paperSource = papersource;
|
|
1717
|
+
d.forcePaperName = forcepapername;
|
|
1718
|
+
}
|
|
1719
|
+
return true;
|
|
1720
|
+
}
|
|
1721
|
+
imageOp(left, top, width, height, drawStyle, dpires, previewOnly, image) {
|
|
1722
|
+
const astream = this.evaluator.getStreamFromExpression(image);
|
|
1723
|
+
if (astream !== null) {
|
|
1724
|
+
const obj = new MetaObjectImage();
|
|
1725
|
+
obj.metaType = MetaObjectType.Image;
|
|
1726
|
+
obj.top = top;
|
|
1727
|
+
obj.left = left;
|
|
1728
|
+
obj.height = height;
|
|
1729
|
+
obj.width = width;
|
|
1730
|
+
obj.drawImageStyle = drawStyle;
|
|
1731
|
+
obj.dpiRes = dpires;
|
|
1732
|
+
obj.previewOnly = previewOnly;
|
|
1733
|
+
const page = this.metaFile.pages.get(this.metaFile.currentPage);
|
|
1734
|
+
obj.streamPos = page.addStream(astream, false);
|
|
1735
|
+
obj.streamSize = astream.length;
|
|
1736
|
+
page.objects.push(obj);
|
|
1737
|
+
}
|
|
1738
|
+
// C# parity: ImageOp returns false
|
|
1739
|
+
return false;
|
|
1740
|
+
}
|
|
1741
|
+
/** BarcodeOp (BARCODEOP): a barcode drawn in the current page (barcode/barcodeitem.ts). */
|
|
1742
|
+
barcodeOp(left, top, width, height, expression, displayFormat, barType, modul, ratio, rotation, calcChecksum, brushColor) {
|
|
1743
|
+
return barcodeOp(this, left, top, width, height, expression, displayFormat, barType, modul, ratio, rotation, calcChecksum, brushColor);
|
|
1744
|
+
}
|
|
1745
|
+
textOp(left, top, width, height, text, lFontName, wFontName, fontSize, fontRotation, fontStyle, fontColor, type1Font, cutText, alignment, wordWrap, rightToLeft, printStep, backColor, transparent) {
|
|
1746
|
+
const obj = new MetaObjectText();
|
|
1747
|
+
obj.left = left;
|
|
1748
|
+
obj.top = top;
|
|
1749
|
+
obj.height = height;
|
|
1750
|
+
obj.width = width;
|
|
1751
|
+
obj.fontSize = (fontSize << 16) >> 16;
|
|
1752
|
+
obj.fontRotation = (fontRotation << 16) >> 16;
|
|
1753
|
+
obj.fontStyle = (fontStyle << 16) >> 16;
|
|
1754
|
+
obj.fontColor = fontColor;
|
|
1755
|
+
obj.rightToLeft = rightToLeft;
|
|
1756
|
+
obj.cutText = cutText;
|
|
1757
|
+
obj.alignment = alignment;
|
|
1758
|
+
obj.wordWrap = wordWrap;
|
|
1759
|
+
obj.printStep = printStep;
|
|
1760
|
+
obj.backColor = backColor;
|
|
1761
|
+
obj.transparent = transparent;
|
|
1762
|
+
obj.type1Font = type1Font;
|
|
1763
|
+
const page = this.metaFile.pages.get(this.metaFile.currentPage);
|
|
1764
|
+
obj.textP = page.addString(text);
|
|
1765
|
+
obj.textS = text.length;
|
|
1766
|
+
obj.lFontNameP = page.addString(lFontName);
|
|
1767
|
+
obj.lFontNameS = lFontName.length;
|
|
1768
|
+
obj.wFontNameP = page.addString(wFontName);
|
|
1769
|
+
obj.wFontNameS = wFontName.length;
|
|
1770
|
+
page.objects.push(obj);
|
|
1771
|
+
return true;
|
|
1772
|
+
}
|
|
1773
|
+
textHeightOp(text, lFontName, _wFontName, recWidth, fontSize, fontStyle, type1Font, printStep) {
|
|
1774
|
+
const extent = this.requireDriver().textExtent({
|
|
1775
|
+
text,
|
|
1776
|
+
lFontName,
|
|
1777
|
+
// C# parity: the report's default Windows font, not the one given (a misspelt argument)
|
|
1778
|
+
wFontName: this.model.wFontName,
|
|
1779
|
+
fontSize: (fontSize << 16) >> 16,
|
|
1780
|
+
fontRotation: 0,
|
|
1781
|
+
fontStyle: (fontStyle << 16) >> 16,
|
|
1782
|
+
fontColor: 0,
|
|
1783
|
+
type1Font,
|
|
1784
|
+
cutText: false,
|
|
1785
|
+
alignment: 0,
|
|
1786
|
+
wordWrap: true,
|
|
1787
|
+
rightToLeft: false,
|
|
1788
|
+
printStep,
|
|
1789
|
+
isHtml: false,
|
|
1790
|
+
}, pt(recWidth, 0));
|
|
1791
|
+
return extent.y;
|
|
1792
|
+
}
|
|
1793
|
+
paramInfoOp(paramName, index) {
|
|
1794
|
+
const ctx = this.evaluator.context;
|
|
1795
|
+
let aresult = Variant.fromString('');
|
|
1796
|
+
const ind0 = this.paramIndexOf(toUpperNet(paramName));
|
|
1797
|
+
if (ind0 < 0)
|
|
1798
|
+
throw new NamedException('Parameter not found:' + paramName, paramName);
|
|
1799
|
+
const param = this.params[ind0];
|
|
1800
|
+
const textOf = (v) => v.toString(ctx);
|
|
1801
|
+
// aresult + "\n" + s (values of a multiple selection) or aresult + (char)10 + s (the others)
|
|
1802
|
+
const append = (s, sep) => {
|
|
1803
|
+
if (textOf(aresult).length > 0) {
|
|
1804
|
+
const separator = sep === 'char' ? Variant.fromChar(10) : Variant.fromString('\n');
|
|
1805
|
+
aresult = Variant.add(Variant.add(aresult, separator, ctx), Variant.fromString(s), ctx);
|
|
1806
|
+
}
|
|
1807
|
+
else
|
|
1808
|
+
aresult = Variant.fromString(s);
|
|
1809
|
+
};
|
|
1810
|
+
const toIndex = (s) => parseInt32(s, NumberStyles.Integer, ctx.culture.number);
|
|
1811
|
+
const datasetsAndTexts = () => {
|
|
1812
|
+
switch (index) {
|
|
1813
|
+
case 6:
|
|
1814
|
+
for (const d of param.datasets)
|
|
1815
|
+
append(d, 'char');
|
|
1816
|
+
return true;
|
|
1817
|
+
case 7:
|
|
1818
|
+
aresult = Variant.fromString(param.description);
|
|
1819
|
+
return true;
|
|
1820
|
+
case 8:
|
|
1821
|
+
aresult = Variant.fromString(param.hint);
|
|
1822
|
+
return true;
|
|
1823
|
+
case 9:
|
|
1824
|
+
aresult = Variant.fromString(param.errorMessage);
|
|
1825
|
+
return true;
|
|
1826
|
+
case 10:
|
|
1827
|
+
aresult = Variant.fromString(param.validation);
|
|
1828
|
+
return true;
|
|
1829
|
+
}
|
|
1830
|
+
return false;
|
|
1831
|
+
};
|
|
1832
|
+
const pt2 = param.paramType;
|
|
1833
|
+
if (pt2 === ParamType.Multiple || pt2 === ParamType.List || pt2 === ParamType.SubsExpreList) {
|
|
1834
|
+
switch (index) {
|
|
1835
|
+
case 0:
|
|
1836
|
+
aresult = param.lastValue;
|
|
1837
|
+
break;
|
|
1838
|
+
case 1:
|
|
1839
|
+
if (pt2 === ParamType.Multiple) {
|
|
1840
|
+
for (const s of param.selected) {
|
|
1841
|
+
const ind = toIndex(s);
|
|
1842
|
+
if (param.values.length > ind)
|
|
1843
|
+
append(param.values[ind], 'string');
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
else
|
|
1847
|
+
aresult = param.listValue;
|
|
1848
|
+
break;
|
|
1849
|
+
case 2:
|
|
1850
|
+
if (pt2 === ParamType.Multiple) {
|
|
1851
|
+
for (const s of param.selected)
|
|
1852
|
+
append(String(toIndex(s)), 'char');
|
|
1853
|
+
}
|
|
1854
|
+
else
|
|
1855
|
+
aresult = Variant.fromString(param.listValue.toString(ctx));
|
|
1856
|
+
break;
|
|
1857
|
+
case 3:
|
|
1858
|
+
if (pt2 === ParamType.Multiple) {
|
|
1859
|
+
for (const s of param.selected) {
|
|
1860
|
+
const ind = toIndex(s);
|
|
1861
|
+
if (param.items.length > ind)
|
|
1862
|
+
append(param.items[ind], 'char');
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
else
|
|
1866
|
+
aresult = Variant.fromString(param.lastValue.toString(ctx));
|
|
1867
|
+
break;
|
|
1868
|
+
case 4:
|
|
1869
|
+
for (const s of param.items)
|
|
1870
|
+
append(s, 'char');
|
|
1871
|
+
break;
|
|
1872
|
+
case 5:
|
|
1873
|
+
for (const s of param.values)
|
|
1874
|
+
append(s, 'char');
|
|
1875
|
+
break;
|
|
1876
|
+
default:
|
|
1877
|
+
datasetsAndTexts();
|
|
1878
|
+
break;
|
|
1879
|
+
}
|
|
1880
|
+
}
|
|
1881
|
+
else if (!datasetsAndTexts())
|
|
1882
|
+
aresult = Variant.fromString(param.lastValue.toString(ctx));
|
|
1883
|
+
return aresult;
|
|
1884
|
+
}
|
|
1885
|
+
reOpenOp(datasetName, sql) {
|
|
1886
|
+
const index = this.dataInfoIndexOf(datasetName);
|
|
1887
|
+
if (index < 0)
|
|
1888
|
+
throw new NamedException('No data info found:' + datasetName, datasetName);
|
|
1889
|
+
const adata = this.dataInfos[index];
|
|
1890
|
+
adata.disConnect();
|
|
1891
|
+
// Evaluates from evaluator all parameters
|
|
1892
|
+
for (const p of this.params)
|
|
1893
|
+
p.lastValue = this.evaluator.evaluateText('M.' + p.alias);
|
|
1894
|
+
adata.sqlOverride = sql;
|
|
1895
|
+
runSync(adata.connect(), 'REOPEN of the dataset ' + datasetName);
|
|
1896
|
+
return true;
|
|
1897
|
+
}
|
|
1898
|
+
getSQLValueOp(connectionname, sql) {
|
|
1899
|
+
const index = this.databaseIndexOf(toUpperNet(connectionname));
|
|
1900
|
+
if (index < 0)
|
|
1901
|
+
throw new NamedException('Connection name not found:' + connectionname, connectionname);
|
|
1902
|
+
return runSync(this.getValueFromSQL(this.databases[index], sql), 'GETVALUEFROMSQL');
|
|
1903
|
+
}
|
|
1904
|
+
/**
|
|
1905
|
+
* DatabaseInfo.GetDataReaderFromSQL with the first column of the first row. As the commands of
|
|
1906
|
+
* the datasets, the command runs inside the implicit transaction of the connection (an HTTP agent
|
|
1907
|
+
* one through its executor); the result is read whole, as C# closes its reader at once.
|
|
1908
|
+
*/
|
|
1909
|
+
*getValueFromSQL(db, sqlsentence) {
|
|
1910
|
+
yield* db.connect();
|
|
1911
|
+
// C# parity: Connection.CreateCommand; a Mybase connection has no Connection
|
|
1912
|
+
if (db.driver === DriverType.Mybase)
|
|
1913
|
+
throw nullReferenceException();
|
|
1914
|
+
const connection = db.connection;
|
|
1915
|
+
if (connection === null)
|
|
1916
|
+
throw nullReferenceException();
|
|
1917
|
+
const ctx = this.evaluator.context;
|
|
1918
|
+
const dataalias = '';
|
|
1919
|
+
for (const aparam of this.params) {
|
|
1920
|
+
switch (aparam.paramType) {
|
|
1921
|
+
case ParamType.Subst:
|
|
1922
|
+
case ParamType.Multiple:
|
|
1923
|
+
if (aparam.datasets.indexOf(dataalias) >= 0)
|
|
1924
|
+
sqlsentence = replaceNet(sqlsentence, aparam.search, aparam.value.toImplicitString(ctx) ?? '');
|
|
1925
|
+
break;
|
|
1926
|
+
case ParamType.SubstExpre:
|
|
1927
|
+
case ParamType.SubsExpreList:
|
|
1928
|
+
// C# parity: the datasets are searched for the alias of the connection, and the value
|
|
1929
|
+
// is evaluated by a new evaluator without the report's identifiers
|
|
1930
|
+
if (aparam.datasets.indexOf(db.alias) >= 0) {
|
|
1931
|
+
const ev = new Evaluator({ context: this.context, host: this.evalHost });
|
|
1932
|
+
ev.expression = aparam.value.toString(ctx);
|
|
1933
|
+
const nvalue = ev.evaluate().toString(ctx);
|
|
1934
|
+
sqlsentence = replaceNet(sqlsentence, aparam.search, nvalue);
|
|
1935
|
+
}
|
|
1936
|
+
break;
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
const parameters = [];
|
|
1940
|
+
for (const aparam of this.params) {
|
|
1941
|
+
if (aparam.datasets.indexOf(dataalias) >= 0) {
|
|
1942
|
+
const t = aparam.paramType;
|
|
1943
|
+
if (t !== ParamType.Subst && t !== ParamType.Multiple && t !== ParamType.SubstExpre && t !== ParamType.SubsExpreList) {
|
|
1944
|
+
// C# parity: the value assigned is the Variant itself (no provider can bind it)
|
|
1945
|
+
const pv = variantParameterValue(aparam.value);
|
|
1946
|
+
parameters.push({ name: '@' + sqlParameterName(sqlsentence, aparam.alias), value: pv.value, valueType: 'Object', dbType: variantDbType(aparam.value) });
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
const result = yield* wait(connection.query({ sql: sqlsentence, parameters, dataset: dataalias }));
|
|
1951
|
+
const first = result.rows[0];
|
|
1952
|
+
if (first === undefined)
|
|
1953
|
+
return Variant.null;
|
|
1954
|
+
// Variant.AssignFromObject(reader[0]): the value as the reader gives it, by its type
|
|
1955
|
+
const value = first[0];
|
|
1956
|
+
if (value === null || value === undefined)
|
|
1957
|
+
return Variant.null;
|
|
1958
|
+
if (typeof value === 'number') {
|
|
1959
|
+
switch (result.columns[0]?.type) {
|
|
1960
|
+
case 'Int64':
|
|
1961
|
+
return Number.isInteger(value) ? Variant.fromLong(value) : Variant.fromDouble(value);
|
|
1962
|
+
case 'Int32':
|
|
1963
|
+
case 'Int16':
|
|
1964
|
+
return Number.isInteger(value) ? Variant.fromInteger(value) : Variant.fromDouble(value);
|
|
1965
|
+
case 'Byte':
|
|
1966
|
+
return Number.isInteger(value) ? Variant.fromByte(value) : Variant.fromDouble(value);
|
|
1967
|
+
default:
|
|
1968
|
+
return Variant.fromDouble(value);
|
|
1969
|
+
}
|
|
1970
|
+
}
|
|
1971
|
+
return Variant.fromHost(value);
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
//# sourceMappingURL=report.js.map
|