-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathrpactivexreport.pas
325 lines (279 loc) · 9.39 KB
/
rpactivexreport.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
{*******************************************************}
{ }
{ Report Manager }
{ }
{ rpactivexreport }
{ Base for ActiveX Report }
{ }
{ }
{ Copyright (c) 1994-2019 Toni Martir }
{ }
{ This file is under the MPL license }
{ If you enhace this file you must provide }
{ source code }
{ }
{ }
{*******************************************************}
unit rpactivexreport;
interface
{$I rpconf.inc}
uses
Windows, Messages, SysUtils, Classes, Controls,Forms,
{$IFDEF USEVARIANTS}
Variants,
{$ENDIF}
rpvclreport,Graphics,rpreport,rpmdconsts;
const
AX_CONSWIDTH=75;
AX_CONSHEIGHT=20;
type
TRpActiveXReport = class(TCustomControl)
private
{ Private declarations }
FVCLReport:TVCLReport;
FFilename:String;
FPreview:boolean;
FTitle:string;
FLanguage:integer;
FSHowProgress:boolean;
FShowPrintDIalog:boolean;
FAsyncExecution:boolean;
procedure SetFilename(Value:string);
procedure SetPreview(Value:boolean);
procedure SetAsyncExecution(Value:boolean);
procedure SetShowProgress(Value:boolean);
procedure SetShowPrintDialog(Value:boolean);
procedure SetTitle(Value:string);
procedure SetLanguage(Value:integer);
protected
{ Protected declarations }
procedure Paint;override;
public
procedure SetDatasetSQL(datasetname:string;sqlsentence:string);
procedure SetDatabaseConnectionString(databasename:string;connectionstring:string);
function GetDatasetSQL(datasetname:string):string;
function GetDatabaseConnectionString(databasename:string):string;
procedure SetParamValue(paramname:string;paramvalue:Variant);
function GetParamValue(paramname:string):Variant;
function Execute:Boolean;
procedure PrinterSetup;
function ShowParams:boolean;
procedure SaveToPDF(filename:string;compressed:boolean=false);
procedure SaveToText(filename:string;textdriver:String);
procedure SaveToMetafile(filename:string);
procedure SaveToHTML(filename:string);
procedure SaveToHTMLSingle(filename:string);
procedure SaveToCustomText(filename:string);
procedure SaveToSVG(filename:string);
procedure SaveToCSV(filename:string);
procedure SaveToCSV2(filename:string;separator:string);
function PrintRange(frompage:integer;topage:integer;
copies:integer;collate:boolean):boolean;
procedure ExecuteRemote(hostname:String;port:integer;user,password,aliasname,reportname:String);
procedure GetRemoteParams(hostname:String;port:integer;user,password,aliasname,reportname:String);
procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer);override;
constructor Create(AOwner:TComponent);override;
function GetReport:TRpReport;
{$IFNDEF DOTNETD}
procedure SetRecordset(datasetname:string; recordset: Pointer);
{$ENDIF}
procedure SaveToFile(filename:String);
{ Public declarations }
published
{ Published declarations }
property Filename:string read FFilename write SetFilename;
property Preview:boolean read FPreview write SetPreview default true;
property AsyncExecution:boolean read FAsyncExecution write SetAsyncExecution default false;
property ShowProgress:boolean read FShowProgress write SetShowProgress;
property ShowPrintDialog:boolean read FShowPrintDialog write SetShowPrintDialog;
property Title:string read FTitle write SetTitle;
property Language:integer read FLanguage write SetLanguage;
end;
implementation
procedure TRpActiveXReport.Paint;
begin
Canvas.Brush.Color:=clWhite;
Canvas.Pen.Color:=clBlack;
Canvas.Rectangle(ClientRect);
Canvas.TextOut(2,2,'ReportManX');
end;
procedure TRpActiveXReport.SetBounds(ALeft, ATop, AWidth, AHeight: Integer);
begin
AWidth:=AX_CONSWIDTH;
AHeight:=AX_CONSHEIGHT;
inherited SetBounds(ALeft,ATop,AWidth,AHeight);
end;
procedure TRpActiveXReport.SaveToFile(filename:String);
begin
FVCLReport.Report.SaveToFile(filename);
end;
constructor TRpActiveXReport.Create(AOwner:TComponent);
begin
inherited Create(AOwner);
Width:=AX_CONSWIDTH;
Height:=AX_CONSHEIGHT;
FVCLReport:=TVCLReport.Create(Self);
end;
procedure TRpActiveXReport.SetFilename(Value:string);
begin
FVCLReport.Filename:=Value;
FFilename:=Value;
end;
procedure TRpActiveXReport.SetPreview(Value:boolean);
begin
FVCLReport.Preview:=Value;
FPreview:=Value;
end;
procedure TRpActiveXReport.SetAsyncExecution(Value:boolean);
begin
FVCLReport.AsyncExecution:=Value;
FAsyncExecution:=Value;
end;
function TRpActiveXReport.Execute:boolean;
begin
Result:=FVCLReport.Execute;
end;
procedure TRpActiveXReport.ExecuteRemote(hostname:String;port:integer;user,password,aliasname,reportname:String);
begin
FVCLReport.ExecuteRemote(hostname,port,user,password,aliasname,reportname);
end;
procedure TRpActiveXReport.GetRemoteParams(hostname:String;port:integer;user,password,aliasname,reportname:String);
begin
FVCLReport.GetRemoteParams(hostname,port,user,password,aliasname,reportname);
end;
function TRpActiveXReport.GetReport:TRpReport;
begin
Result:=FVCLReport.Report;
end;
procedure TRpActiveXReport.SetShowProgress(Value:Boolean);
begin
FVCLReport.ShowProgress:=Value;
FShowProgress:=Value;
end;
procedure TRpActiveXReport.SetShowPrintDialog(Value:boolean);
begin
FVCLReport.ShowPrintDialog:=Value;
FShowProgress:=Value;
end;
procedure TRpActiveXReport.SetTitle(Value:string);
begin
FVCLReport.Title:=Value;
FTitle:=Value;
end;
procedure TRpActiveXReport.SetLanguage(Value:integer);
begin
FVCLReport.Language:=Value;
FLanguage:=Value;
end;
procedure TRpActiveXReport.PrinterSetup;
begin
FVCLReport.PrinterSetup;
end;
function TRpActiveXReport.ShowParams:boolean;
begin
Result:=FVCLReport.ShowParams;
end;
procedure TRpActiveXReport.SaveToPDF(filename:string;compressed:boolean=false);
begin
FVCLReport.SaveToPDF(filename,compressed);
end;
procedure TRpActiveXReport.SaveToText(filename:string;textdriver:String);
begin
FVCLReport.SaveToText(filename,textdriver);
end;
procedure TRpActiveXReport.SaveToMetafile(filename:string);
begin
FVCLReport.SaveToMetafile(filename);
end;
procedure TRpActiveXReport.SaveToHTML(filename:string);
begin
FVCLReport.SaveToHtml(filename);
end;
procedure TRpActiveXReport.SaveToHTMLSingle(filename:string);
begin
FVCLReport.SaveToHtmlSingle(filename);
end;
procedure TRpActiveXReport.SaveToCustomText(filename:string);
begin
FVCLReport.SaveToCustomText(filename);
end;
procedure TRpActiveXReport.SaveToSVG(filename:string);
begin
FVCLReport.SaveToSVG(filename);
end;
procedure TRpActiveXReport.SaveToCSV(filename:string);
begin
FVCLReport.SaveToCSV(filename);
end;
procedure TRpActiveXReport.SaveToCSV2(filename:string;separator:string);
begin
FVCLReport.SaveToCSV(filename,separator);
end;
function TRpActiveXReport.PrintRange(frompage:integer;topage:integer;
copies:integer;collate:boolean):boolean;
begin
Result:=FVCLReport.PrintRange(frompage,topage,copies,collate);
end;
procedure TRpActiveXReport.SetDatabaseConnectionString(databasename:string;connectionstring:string);
var
index:integer;
begin
index:=FVCLReport.Report.DatabaseInfo.IndexOf(databasename);
if index<0 then
Raise Exception.Create(SRpDatabaseNotExists+':'+databasename);
FVCLReport.Report.DatabaseInfo.Items[index].ADOConnectionString:=connectionstring;
end;
procedure TRpActiveXReport.SetDatasetSQL(datasetname:string;sqlsentence:string);
var
index:integer;
begin
index:=FVCLReport.Report.DataInfo.IndexOf(datasetname);
if index<0 then
Raise Exception.Create(SRpDatasetNotExists+':'+datasetname);
FVCLReport.Report.DataInfo.Items[index].SQL:=sqlsentence;
end;
procedure TRpActiveXReport.SetParamValue(paramname:string;paramvalue:Variant);
begin
FVCLReport.Report.Params.ParamByName(paramname).Value:=paramvalue;
end;
function TRpActiveXReport.GetDatasetSQL(datasetname:string):string;
var
index:integer;
begin
index:=FVCLReport.Report.DataInfo.IndexOf(datasetname);
if index<0 then
Raise Exception.Create(SRpDatasetNotExists+':'+datasetname);
Result:=FVCLReport.Report.DataInfo.Items[index].SQL;
end;
function TRpActiveXReport.GetDatabaseConnectionString(databasename:string):string;
var
index:integer;
begin
index:=FVCLReport.Report.DatabaseInfo.IndexOf(databasename);
if index<0 then
Raise Exception.Create(SRpDatabaseNotExists+':'+databasename);
Result:=FVCLReport.Report.DatabaseInfo.Items[index].ADOConnectionString;
end;
function TRpActiveXReport.GetParamValue(paramname:string):Variant;
begin
Result:=FVCLReport.Report.Params.ParamByName(paramname).Value;
end;
{$IFNDEF DOTNETD}
procedure TRpActiveXReport.SetRecordset(datasetname:string; recordset: Pointer);
var
index:integer;
begin
index:=FVCLReport.Report.DataInfo.IndexOf(datasetname);
if index<0 then
Raise Exception.Create(SRpDatasetNotExists+':'+datasetname);
{$IFDEF USEADO}
FVCLReport.Report.DataInfo.Items[index].externalDataset:=recordset;
// maybe reste params...
//FVCLReport.Report.DataInfo.Items[index].SQL := '';
{$ENDIF}
end;
{$ENDIF}
initialization
Application.UpdateFormatSettings:=false;
end.