* Register correct property editors for bands (bug ID #33248) and make sure objects can be selected

git-svn-id: trunk@57395 -
This commit is contained in:
michael 2018-02-27 16:19:29 +00:00
parent 960b8ab51b
commit a3eae26195
2 changed files with 197 additions and 7 deletions

View File

@ -427,7 +427,8 @@ begin
FOI.OnSelectElement:=@DoSelectComponent;
FOI.OnModified:=@DoSelectionModifiedByOI;
MRUMenuManager1 := TMRUMenuManager.Create(self);
with MRUMenuManager1 do begin
with MRUMenuManager1 do
begin
maxRecent := 5;
IniFileName := ChangeFileExt(ParamStr(0), '.ini');
MenuItem := MIRecent;
@ -436,7 +437,7 @@ begin
MenuCaptionMask := '(%d) %s';
OnRecentFile := @MRUMenuManager1RecentFile;
LoadRecentFilesFromIni;
end;
end;
end;
procedure TFPReportDesignerForm.FormCloseQuery(Sender: TObject;
@ -477,10 +478,12 @@ Var
I : Integer;
begin
Report.StartDesigning;
For I:=0 to Report.PageCount-1 do
AddPageDesign(I+1,Report.Pages[I]);
ShowReportData;
ResetObjectInspector;
end;
procedure TFPReportDesignerForm.CreateReportData;
@ -934,6 +937,7 @@ begin
p.Margins.Right := 20;
p.Margins.Bottom := 20;
FReport.AddPage(P);
Report.StartDesigning;
FOI.RefreshReportTree;
Result:=True
end;
@ -1236,6 +1240,8 @@ Var
I : integer;
begin
if Assigned(FReport) then
Report.EndDesigning;
For I:=ComponentCount-1 downto 0 do
if Components[I] is TFPReportDesignerControl then
Components[I].Free;
@ -1358,6 +1364,9 @@ end;
procedure TFPReportDesignerForm.DoElementCreated(Sender: TObject;
AElement: TFPReportElement);
begin
AElement.StartDesigning;
if AElement.Name='' then
AElement.Name:=AElement.AllocateName;
If AElement is TFPReportCustomMemo then
begin
TFPReportMemo(AElement).Font.Name := 'LiberationSans';

View File

@ -23,16 +23,72 @@ uses
Type
{ TDataComponentPropertyEditor }
{ TReportComponentPropertyEditor }
TDataComponentPropertyEditor = class(TComponentPropertyEditor)
TReportComponentPropertyEditor = class(TComponentPropertyEditor)
Protected
Function GetReport : TFPCustomReport;
Function GetPage : TFPReportCustomPage;
end;
{ TDataComponentPropertyEditor }
TDataComponentPropertyEditor = class(TReportComponentPropertyEditor)
Public
procedure GetValues(Proc: TGetStrProc); override;
procedure SetValue(const NewValue: ansistring); override;
end;
{ TReportBandPropertyEditor }
TReportBandPropertyEditor = class(TReportComponentPropertyEditor)
Public
Function BandTypes : TFPReportBandTypes; virtual;
procedure GetValues(Proc: TGetStrProc); override;
procedure SetValue(const NewValue: ansistring); override;
end;
{ TChildBandPropertyEditor }
TChildBandPropertyEditor = Class(TReportBandPropertyEditor)
Public
Function BandTypes : TFPReportBandTypes; override;
end;
{ TDataFooterBandPropertyEditor }
TDataFooterBandPropertyEditor = Class(TReportBandPropertyEditor)
Public
Function BandTypes : TFPReportBandTypes; override;
end;
{ TDataHeaderBandPropertyEditor }
TDataHeaderBandPropertyEditor = Class(TReportBandPropertyEditor)
Public
Function BandTypes : TFPReportBandTypes; override;
end;
{ TDataBandPropertyEditor }
TDataBandPropertyEditor = Class(TReportBandPropertyEditor)
Public
Function BandTypes : TFPReportBandTypes; override;
end;
{ TGroupHeaderBandPropertyEditor }
TGroupHeaderBandPropertyEditor = Class(TReportBandPropertyEditor)
Public
Function BandTypes : TFPReportBandTypes; override;
end;
{ TGroupFooterBandPropertyEditor }
TGroupFooterBandPropertyEditor = Class(TReportBandPropertyEditor)
Public
Function BandTypes : TFPReportBandTypes; override;
end;
Procedure RegisterFPReportPropEditors;
@ -43,11 +99,133 @@ Procedure RegisterFPReportPropEditors;
begin
RegisterPropertyEditor(TypeInfo(TFPReportData), TFPreportElement, 'Data', TDataComponentPropertyEditor);
RegisterPropertyEditor(TypeInfo(TFPReportCustomBand), TFPReportCustomBand, 'Child', TChildBandPropertyEditor);
RegisterPropertyEditor(TypeInfo(TFPReportCustomDataFooterBand), TFPReportCustomBand, 'FooterBand', TDataFooterBandPropertyEditor);
RegisterPropertyEditor(TypeInfo(TFPReportCustomDataHeaderBand), TFPReportCustomBand, 'HeaderBand', TDataHeaderBandPropertyEditor);
RegisterPropertyEditor(TypeInfo(TFPReportCustomDataBand), TFPReportCustomBand, 'MasterBand', TDataBandPropertyEditor);
RegisterPropertyEditor(TypeInfo(TFPReportCustomGroupHeaderBand),TFPReportCustomGroupHeaderBand, 'ParentGroupHeader', TGroupHeaderBandPropertyEditor);
RegisterPropertyEditor(TypeInfo(TFPReportCustomGroupFooterBand),TFPReportCustomGroupHeaderBand, 'GroupFooter', TGroupFooterBandPropertyEditor);
end;
{ TDataComponentPropertyEditor }
{ TGroupFooterBandPropertyEditor }
function TDataComponentPropertyEditor.GetReport: TFPCustomReport;
function TGroupFooterBandPropertyEditor.BandTypes: TFPReportBandTypes;
begin
Result:=[btGroupFooter];
end;
{ TGroupHeaderBandPropertyEditor }
function TGroupHeaderBandPropertyEditor.BandTypes: TFPReportBandTypes;
begin
Result:=[btGroupHeader];
end;
{ TDataBandPropertyEditor }
function TDataBandPropertyEditor.BandTypes: TFPReportBandTypes;
begin
Result:=[btDataband];
end;
{ TDataHeaderBandPropertyEditor }
function TDataHeaderBandPropertyEditor.BandTypes: TFPReportBandTypes;
begin
Result:=[btDataHeader];
end;
{ TDataFooterBandPropertyEditor }
function TDataFooterBandPropertyEditor.BandTypes: TFPReportBandTypes;
begin
Result:=[btDataFooter];
end;
{ TChildBandPropertyEditor }
function TChildBandPropertyEditor.BandTypes: TFPReportBandTypes;
begin
Result:=[btChild];
end;
{ TReportBandPropertyEditor }
function TReportBandPropertyEditor.BandTypes: TFPReportBandTypes;
begin
Result:=[]
end;
procedure TReportBandPropertyEditor.GetValues(Proc: TGetStrProc);
Var
P : TFPReportCustomPage;
I : Integer;
BT : TFPReportBandTypes;
Function BandAllowed(B : TFPReportCustomBand) : Boolean;
begin
Result:=(B.Name<>'');
if Result and (BT<>[]) then
Result:=B.ReportBandType in BT;
end;
begin
P:=GetPage;
BT:=BandTypes;
proc(oisNone);
if Assigned(P) then
For I:=0 to P.BandCount-1 do
if BandAllowed(P.Bands[i]) then
Proc(P.Bands[i].Name);
end;
procedure TReportBandPropertyEditor.SetValue(const NewValue: ansistring);
Var
P : TFPReportCustomPage;
B : TFPReportCustomBand;
I : integer;
begin
B:=nil;
if (NewValue<>oisNone) then
begin
P:=GetPage;
I:=0;
if Assigned(P) then
While (B=Nil) and (I<P.BandCount) do
begin
if SameText(NewValue,P.Bands[I].Name) then
B:=P.Bands[I];
Inc(I);
end;
end;
if Assigned(PropertyHook) then
PropertyHook.ObjectReferenceChanged(Self,B);
SetPtrValue(B);
end;
{ TReportComponentPropertyEditor }
Function TReportComponentPropertyEditor.GetPage : TFPReportCustomPage;
Var
C : TPersistent;
begin
Result:=Nil;
C:=GetComponent(0);
// Latest SVN has page
if C is TFPReportCustomPage then
Result:=C as TFPReportCustomPage
else if C is TFPReportCustomBand then
Result:=TFPReportCustomBand(C).Page
else if C is TFPReportElement then
Result:=TFPReportElement(C).Page;
end;
function TReportComponentPropertyEditor.GetReport: TFPCustomReport;
Var
C : TPersistent;
begin
@ -59,6 +237,8 @@ begin
Result:=TFPReportElement(C).Report;
end;
{ TDataComponentPropertyEditor }
procedure TDataComponentPropertyEditor.GetValues(Proc: TGetStrProc);
Var
@ -80,7 +260,6 @@ Var
RD : TFPReportData;
begin
if NewValue=GetValue then exit;
RD:=nil;
if (NewValue<>oisNone) then
begin
@ -88,6 +267,8 @@ begin
if Assigned(Report) then
RD:=Report.ReportData.FindReportData(NewValue);
end;
if Assigned(PropertyHook) then
PropertyHook.ObjectReferenceChanged(Self,RD);
SetPtrValue(RD);
end;