-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathacRAP.pas
More file actions
245 lines (194 loc) · 7.13 KB
/
Copy pathacRAP.pas
File metadata and controls
245 lines (194 loc) · 7.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
unit acRAP;
interface
uses
Classes, Forms, raFunc, ppRTTI, db, dbTables, ppUtils, ppReport, ppBands,
ppEngine, osUtils, osExtenso;
type
//grupo para as funções personalizadas Acras
TAcrasRAPFunctions = class (TraSystemFunction)
public
class function Category: String; override;
end;
TGetSummaryTop = class (TAcrasRAPFunctions)
public
procedure ExecuteFunction(aParams: TraParamList); override;
class function GetSignature: String; override;
end;
TValorPorExtenso = class (TAcrasRAPFunctions)
public
procedure ExecuteFunction(aParams: TraParamList); override;
class function GetSignature: String; override;
end;
TGetRestricaousuario = class (TAcrasRAPFunctions)
public
procedure ExecuteFunction(aParams: TraParamList); override;
class function GetSignature: String; override;
end;
//RTTI da classe ppEngine
TacTppEngineRTTI = class(TraTObjectRTTI)
public
class procedure GetPropList(aClass: TClass; aPropList: TraPropList); override;
class function RefClass: TClass; override;
class function GetPropRec(aClass: TClass; const aPropName: String; var aPropRec: TraPropRec): Boolean; override;
class function CallMethod(aObject: TObject; const aMethodName: String; aParams: TraParamList; aGet: Boolean): Boolean; override;
class function GetParams(const aMethodName: String): TraParamList; override;
class function GetPropValue(aObject: TObject; const aPropName: String; var aValue): Boolean; override;
class function SetPropValue(aObject: TObject; const aPropName: String; var aValue): Boolean; override;
end;
TacraTppReportRTTI = class(TraTppReportRTTI)
public
class procedure GetPropList(aClass: TClass; aPropList: TraPropList); override;
class function GetPropRec(aClass: TClass; const aPropName: String; var aPropRec: TraPropRec): Boolean; override;
class function GetParams(const aMethodName: String): TraParamList; override;
class function CallMethod(aObject: TObject; const aMethodName: String; aParams: TraParamList; aGet: Boolean): Boolean; override;
class function GetPropValue(aObject: TObject; const aPropName: String; var aValue): Boolean; override;
class function RefClass: TClass; override;
class function SetPropValue(aObject: TObject; const aPropName: String; var aValue): Boolean; override;
end; {class, TraTppReportRTTI}
implementation
uses ppClass;
{ TmyTDataBaseRTTI }
{ TmyDevelopersFunction }
class function TAcrasRAPFunctions.Category: String;
begin
Result := 'Acras RAP Functions';
end;
{ TGetSummaryTop }
procedure TGetSummaryTop.ExecuteFunction(aParams: TraParamList);
var
asSummary: TppSummaryBand;
lResult: integer;
begin
GetParamValue(0, asSummary);
lResult := asSummary.PrintPosRect.Top;
SetParamValue(1, lResult);
end;
class function TGetSummaryTop.GetSignature: String;
begin
Result := 'function GetSummaryTop(aSummary: TppSummaryBand): integer;';
end;
{ TGetRestricaousuario }
procedure TGetRestricaousuario.ExecuteFunction(aParams: TraParamList);
var
id: integer;
lResult: String;
begin
GetParamValue(0, id);
if getRestricaoUsuario(id)<> nil then
lResult := getRestricaoUsuario(id).Texto
else
lResult := '';
SetParamValue(1, lResult);
end;
class function TGetRestricaousuario.GetSignature: String;
begin
Result := 'function GetRestricaoUsuario(aIdRestricao: integer): String;';
end;
{ TacraTppReportRTTI }
class function TacraTppReportRTTI.CallMethod(aObject: TObject;
const aMethodName: String; aParams: TraParamList;
aGet: Boolean): Boolean;
begin
result := inherited CallMethod(aObject, aMethodName, aParams, aGet);
end;
class function TacraTppReportRTTI.GetParams(
const aMethodName: String): TraParamList;
begin
result := inherited GetParams(aMethodName);
end;
class procedure TacraTppReportRTTI.GetPropList(aClass: TClass;
aPropList: TraPropList);
begin
inherited GetPropList(aClass, aPropList);
{add public props}
aPropList.AddProp('Engine');
end;
class function TacraTppReportRTTI.GetPropRec(aClass: TClass;
const aPropName: String; var aPropRec: TraPropRec): Boolean;
begin
result := inherited getPropRec(aClass, aPropName, aPropRec);
end;
class function TacraTppReportRTTI.GetPropValue(aObject: TObject;
const aPropName: String; var aValue): Boolean;
begin
result := inherited getPropValue(aObject, aPropName, aValue);
end;
class function TacraTppReportRTTI.RefClass: TClass;
begin
result := TppReport;
end;
class function TacraTppReportRTTI.SetPropValue(aObject: TObject;
const aPropName: String; var aValue): Boolean;
begin
result := inherited SetPropValue(aObject, aPropName, aValue);
end;
{ TacTppEngineRTTI }
class function TacTppEngineRTTI.CallMethod(aObject: TObject;
const aMethodName: String; aParams: TraParamList;
aGet: Boolean): Boolean;
begin
Result := inherited CallMethod(aObject, aMethodName, aParams, aGet);
end;
class function TacTppEngineRTTI.GetParams(
const aMethodName: String): TraParamList;
begin
result := inherited GetParams(aMethodName);
end;
class procedure TacTppEngineRTTI.GetPropList(aClass: TClass;
aPropList: TraPropList);
begin
inherited GetPropList(aClass, aPropList);
aPropList.AddProp('PageBottom');
end;
class function TacTppEngineRTTI.GetPropRec(aClass: TClass;
const aPropName: String; var aPropRec: TraPropRec): Boolean;
begin
Result := True;
if ppEqual(aPropName, 'PageBottom') then
PropToRec(aPropName, daInteger, True, aPropRec)
else
Result := inherited GetPropRec(aClass, aPropName, aPropRec);
end;
class function TacTppEngineRTTI.GetPropValue(aObject: TObject;
const aPropName: String; var aValue): Boolean;
begin
Result := True;
if ppEqual(aPropName, 'PageBottom') then
integer(aValue) := TppEngine(aObject).PageBottom
else
Result := inherited GetPropValue(aObject, aPropName, aValue);
end;
class function TacTppEngineRTTI.RefClass: TClass;
begin
result := TppEngine;
end;
class function TacTppEngineRTTI.SetPropValue(aObject: TObject;
const aPropName: String; var aValue): Boolean;
begin
Result := inherited SetPropValue(aObject, aPropName, aValue);
end;
{ TValorPorExtenso }
procedure TValorPorExtenso.ExecuteFunction(aParams: TraParamList);
var
valor: double;
lResult: string;
begin
GetParamValue(0, valor);
lResult := ValorPorExtenso(valor);
SetParamValue(1, lResult);
end;
class function TValorPorExtenso.GetSignature: String;
begin
Result := 'function ValorPorExtenso(aVlor: double): String;';
end;
initialization
raRegisterFunction('GetSummaryTop', TGetSummaryTop);
raRegisterFunction('GetRestricaousuario', TGetRestricaousuario);
raRegisterFunction('ValorPorExtenso', TValorPorExtenso);
raUnRegisterRTTI(TraTppReportRTTI); // unregister the existing RTTI class
raRegisterRTTI(TacraTppReportRTTI); // register your custom RTTI class
raRegisterRTTI(TacTppEngineRTTI);
finalization
raUnRegisterRTTI(TacraTppReportRTTI); // unregister the existing RTTI class
raUnRegisterRTTI(TacTppEngineRTTI);
end.