📄 repoedit.pas
字号:
while not (thControl is TQuickRep) and (thControl <> nil) do
begin
thRect.left := thRect.left - thControl.Left;
thRect.top := thRect.top - thControl.Top;
thControl := thControl.Parent;
end;
thRect.right:=thREct.Left+thW;
thRect.bottom:=thRect.Top+thH;
AControl.BoundsRect:=ThRect;
AControl.Update;
end;
function SetBool(Value:Boolean):string;
const BoolVal: array[Boolean] of string = ('0', '1');
begin
Result:=BoolVal[Value];
end;
function GetBool(Value:string):boolean;
begin
Result := (Value<>'0') and (UpperCase(Value)<>'FALSE') and (UpperCase(Value)<>'F');
end;
function SetInt(Value:Integer):string;
begin
Result:=inttostr(Value);
end;
function GetInt(Value:string):integer;
begin
Result:=strtoint(Value);
end;
procedure Register;
begin
RegisterComponents('QReport', [TRepoEdit]);
end;
//procedure IniCheck;
procedure TRepoEdit.thFormClose(Sender: TObject; var Action: TCloseAction);
begin
IsEditing:=false;
end;
function TRepoEdit.GetVariantCount;
begin
Result:=1;
end;
constructor TRepoEdit.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FEnabled:=True;
fThReport:=nil;
FThPanel:=nil;
FCurrentVariant:=0;
FOnNeedCount:=nil;
FOnNeedData:=nil;
// ThConfirmForm:=nil;
FAppendOBJ:=nil;
ThPopupmenu:=nil;
thEnabledLab:=nil;
thFrame:=nil;
thStatusBar:=nil;
// PreviewStyle:=fsMDIForm;
if not (csDesigning in ComponentState) then begin
TQRCSVFilter.Create(Owner);
TQRTextFilter.Create(Owner);
TQRHTMLFilter.Create(Owner);
// TQREXCELFilter.Create(Owner); // if you have professional qr then uncomment this line (or qr304bv)
// TQRRTFFilter.create(Owner); // if you have professional qr then uncomment this line (or qr304bv)
// TQRWMFFilter.create(Owner); // if you have professional qr then uncomment this line (or qr304bv)
end;
// TQRExcelFilter.Create(AOwner);
end;
procedure TRepoEdit.SetAppendOBJ(Value:TQRPrintable);
begin
if Assigned(FAppendOBJ) then FAppendOBJ:=nil;
FAppendObj:=Value;
end;
destructor TRepoEdit.Destroy;
begin
inherited Destroy;
end;
procedure TRepoEdit.Loaded;
var i:integer;
NewForm:TForm;
thScroll:TScrollBox;
begin
CannotMouseDown:=false;
if not (csDesigning in ComponentState) then begin
if Owner is tQuickRep then FThReport:=Owner as TQuickRep
else if Owner is TForm then begin
with (Owner as TForm) do
For i:=0 to ComponentCount-1 do
if Components[i] is TQuickRep then
FThReport:= (Components[i] as TQuickRep);
end
else begin
bvMessError('Cannot use RepoEdit!');
exit;
end;
if assigned(owner) then begin
if (Owner is TForm) then FThForm:=(Owner as TForm)
else if Owner is TQuickRep then begin
NewForm:=TForm.Create(Self);
NewForm.Name:='OpenWithRepoEdit_'+FThReport.Name;
FThForm:=NewForm;
FThReport.parent:=FThForm;
end;
thForm.onClose:=thFormClose;
thScroll:=TScrollBox.Create(Self);
thScroll.align:=alclient;
thScroll.Parent:=fthForm;
thReport.Parent:=thScroll;
thScroll.Visible:=true;
end
else begin
bvMessError('Cannot use RepoEdit!');
exit;
end;
end;
end;
function TRepoEdit.RestoreNotFrontBack(ThCompName:string):integer;
begin
IniCheck;
with TaReport do begin
SetKey;
TaRepNameForm.AsString:=CorrectName;
TaRepNameComp.AsString:=ThCompName+VariantStr;
if Gotokey then Result:=FieldByname('NotFrontback').AsInteger
else Result:=0;
end;
end;
procedure TRepoEdit.SaveNotFrontBack(ThCompName:string;Value:integer);
begin
IniCheck;
with TaReport do begin
SetKey;
TaRepNameForm.AsString:=CorrectName;
TaRepNameComp.AsString:=ThCompName+VariantStr;
if Not Gotokey then begin
Insert;
TaRepNameForm.AsString:=CorrectName;
TaRepNameComp.AsString:=ThCompName+VariantStr;
end
else Edit;
FieldByname('NotFrontback').AsInteger:=Value;
Post;
end;
end;
function TrepoEdit.DeleteSaved(ThComp:string):boolean;
begin
IniCheck;
try
with TaReport do begin
SetKey;
taRepNameForm.AsString:=CorrectName;
TaRepNameComp.AsString:=ThComp+VariantStr;
if GotoKey then begin
Delete;
Result:=true;
end
else Result:=false;
end;
except
Result:=false;
end;
end;
function TrepoEdit.DeleteSavedReport(DeleteReport:boolean):boolean;
var i:integer; ThName:string;
begin
Result:=true;
IniCheck;
try
with TaReport do begin
First;
Locate('NameForm',CorrectName,[]);
while not eof and (TaRepNameForm.AsString=CorrectName) do begin
if (pos(':',TaRepNameComp.AsString)=0)
and (CurrentVariant=0)
or
(pos(VariantStr,TaRepNameComp.AsString)>0)
then begin
if (CurrentVariant=0)
and (TaRepNameComp.AsString=ThReport.Name)
or
(pos(VariantStr,TaRepNameComp.AsString)>0)
and (TaRepNameComp.AsString=ThReport.Name+VariantStr)
then begin
if DeleteReport then Delete
else with TStringList.Create do begin
SetText(pchar(TaRepValue.asString));
ThName:=Values['VariantName'];
Clear;
Values['VariantName']:=ThName;
Edit;
for i:=taRepNameComp.FieldNo+1 to FieldCount-1 do begin
fields[i].Clear;
end;
TaRepValue.AsString:=Text;
Post;
Next;
Free;
end
end
else
Delete;
end
else Next;
end;
end;
except
Result:=false;
end;
end;
procedure TRepoEdit.RestoreReport;
var
ThComp:TComponent;
ThFSt:TFontStyles;
ThFileName:string;
ThName:string;
ThVal:integer;
Str,Str2:string;
ParentComp:TComponent;
i:integer;
begin
if csDesigning in ComponentState then exit;
IniCheck;
ThReport.Left:=0;
thReport.Top:=0;
if Enabled then begin
TaReport.SetKey;
TarepNameForm.AsString:=CorrectName;
TaRepNameComp.AsString:=ThReport.Name+VariantStr;
if not Tareport.Gotokey then begin
if Enabled then begin
TaReport.insert;
TaRepNameForm.AsString:=CorrectName;
TaRepNamecomp.AsString:=ThReport.Name+VariantStr;
TaReport.fieldByname('Enabled').AsBoolean:=Enabled;
TaReport.post;
end
end
else begin
Enabled:=TaReport.FieldByname('Enabled').AsBoolean;
end
end;
if Enabled then with tStringList.create do
try
SetText(pchar(TaRepValue.Value));
for i:=0 to count-1 do begin
if uppercase(Names[i])='ZOOM'
then ThReport.Zoom:=GetInt(Values[Names[i]])
else If upperCase(Names[i])='PAGE.BOTTOMMARGIN'
then ThReport.page.BottomMargin:=strtofloat(Values[Names[i]])
else If upperCase(Names[i])='PAGE.LEFTMARGIN'
then ThReport.page.LEFTMargin:=strtofloat(Values[Names[i]])
else If upperCase(Names[i])='PAGE.RIGHTMARGIN'
then ThReport.page.RIGHTMargin:=strtofloat(Values[Names[i]])
else If upperCase(Names[i])='PAGE.TOPMARGIN'
then ThReport.page.TOPMargin:=strtofloat(Values[Names[i]])
else If upperCase(Names[i])='PAGE.COLUMNSPACE'
then ThReport.page.columnspace:=strtofloat(Values[Names[i]])
else If upperCase(Names[i])='PAGE.LENGTH'
then ThReport.page.LENGTH:=strtofloat(Values[Names[i]])
else If upperCase(Names[i])='PAGE.WIDTH'
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -