* Do not clear report data when loading design and rdoManageData is off

git-svn-id: trunk@60565 -
This commit is contained in:
michael 2019-03-03 09:21:03 +00:00
parent ccf69c22af
commit 95c9d73fd4

View File

@ -994,7 +994,6 @@ begin
end end
else else
begin begin
StopDesigning;
LoadDesignFromFile(AFileName); LoadDesignFromFile(AFileName);
SetFileCaption(AFileName); SetFileCaption(AFileName);
end; end;
@ -1856,8 +1855,10 @@ procedure TFPReportDesignerForm.CreateReportDataSets(Errors: TStrings);
begin begin
if (rdoManageData in DesignOptions) then
FReportDesignData.ApplyToReport(FReport,Errors); FReportDesignData.ApplyToReport(FReport,Errors);
FReport.RestoreDataFromNames; FReport.RestoreDataFromNames;
FReportData.Report:=FReport;
FReportData.RefreshData; FReportData.RefreshData;
end; end;
@ -2106,7 +2107,6 @@ end;
Procedure TFPReportDesignerForm.LoadReportFromFile(Const AFileName : String); Procedure TFPReportDesignerForm.LoadReportFromFile(Const AFileName : String);
begin begin
StopDesigning;
LoadDesignFromFile(AFileName); LoadDesignFromFile(AFileName);
SetFileCaption(AFileName); SetFileCaption(AFileName);
if Assigned(MRUMenuManager1) then if Assigned(MRUMenuManager1) then
@ -2122,6 +2122,7 @@ Var
I : integer; I : integer;
begin begin
I:=FReportDesignData.DataDefinitions.Count;
FStopDesigning:=True; FStopDesigning:=True;
try try
if Assigned(FReport) then if Assigned(FReport) then
@ -2135,9 +2136,12 @@ begin
// Give LCL time to clean up. // Give LCL time to clean up.
Application.ProcessMessages; Application.ProcessMessages;
FReportData.Report:=Nil; FReportData.Report:=Nil;
if (rdoManageData in DesignOptions) then
begin
if Assigned(FReport) then if Assigned(FReport) then
FReportDesignData.RemoveFromReport(FReport); FReportDesignData.RemoveFromReport(FReport);
FReportDesignData.DataDefinitions.Clear; FReportDesignData.DataDefinitions.Clear;
end;
FOI.Report:=Nil; FOI.Report:=Nil;
FOI.SelectControls(Nil); FOI.SelectControls(Nil);
Finally Finally
@ -2169,7 +2173,7 @@ begin
FReport := TFPReport.Create(Self); FReport := TFPReport.Create(Self);
end end
else else
FReport.Clear; FReport.Clear(rdoManageData in DesignOptions);
end end
else else
FReport := TFPReport.Create(Self); FReport := TFPReport.Create(Self);
@ -2208,10 +2212,10 @@ begin
DD:=lJSON.Get('DesignData',TJSONObject(Nil)); DD:=lJSON.Get('DesignData',TJSONObject(Nil));
if Assigned(DD) then if Assigned(DD) then
FReportDesignData.DataDefinitions.LoadFromJSON(DD); FReportDesignData.DataDefinitions.LoadFromJSON(DD);
end;
// We must do this before the report is loaded, so the pages/bands can find their data // We must do this before the report is loaded, so the pages/bands can find their data
Errs:=TStringList.Create; Errs:=TStringList.Create;
CreateReportDataSets(Errs); CreateReportDataSets(Errs);
end;
FReport.ReadElement(rs); FReport.ReadElement(rs);
if (FReport.Owner<>Self) and (OldName<>'') then if (FReport.Owner<>Self) and (OldName<>'') then
FReport.Name:=OldName; FReport.Name:=OldName;