mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-07-29 05:36:10 +02:00
LazReport, fix selecting the right export filter when there are multiple options for the same file format (ej PowerPDF and CairoExport), probably broken in r49728 #400b4c4719
git-svn-id: trunk@52466 -
This commit is contained in:
parent
d4b66e8921
commit
1c61bf995e
@ -1347,68 +1347,53 @@ end;
|
|||||||
|
|
||||||
procedure TfrPreviewForm.SaveBtnClick(Sender: TObject);
|
procedure TfrPreviewForm.SaveBtnClick(Sender: TObject);
|
||||||
var
|
var
|
||||||
i, Index, IndexOffset: Integer;
|
i, Index: Integer;
|
||||||
FilterStr, FilterExtension, FileExtension: String;
|
FilterStr: string;
|
||||||
FilterInfo: TExportFilterItem;
|
FilterInfo: TExportFilterItem;
|
||||||
FExtList:TStringList;
|
FExtList:TStringList;
|
||||||
begin
|
begin
|
||||||
if EMFPages = nil then Exit;
|
if EMFPages = nil then Exit;
|
||||||
FExtList:=TStringList.Create;
|
FExtList:=TStringList.Create;
|
||||||
Index := 1;
|
try
|
||||||
if not (roHideDefaultFilter in TfrReport(Doc).Options) then
|
Index := 1;
|
||||||
begin
|
if not (roHideDefaultFilter in TfrReport(Doc).Options) then
|
||||||
FExtList.Add('*.frp');
|
|
||||||
FilterStr := sRepFile + ' (*.frp)|*.frp';
|
|
||||||
IndexOffset := 2;
|
|
||||||
end
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
FilterStr := '';
|
|
||||||
IndexOffset := 1;
|
|
||||||
end;
|
|
||||||
FileExtension := ExtractFileExt(SaveDialog.FileName);
|
|
||||||
|
|
||||||
for i := 0 to ExportFilters.Count - 1 do
|
|
||||||
begin
|
|
||||||
FilterInfo := ExportFilters[i];
|
|
||||||
if FilterInfo.Enabled then
|
|
||||||
begin
|
begin
|
||||||
FExtList.Add(FilterInfo.FilterExt);
|
FExtList.Add('*.frp');
|
||||||
if FilterStr <> '' then
|
FilterStr := sRepFile + ' (*.frp)|*.frp';
|
||||||
FilterStr := FilterStr + '|';
|
end else
|
||||||
FilterStr := FilterStr + FilterInfo.FilterDesc + '|' + FilterInfo.FilterExt;
|
FilterStr := '';
|
||||||
FilterExtension := ExtractFileExt(FilterInfo.FilterExt);
|
|
||||||
if (Index = 1) and (Comparetext(FilterExtension, FileExtension)=0) then
|
|
||||||
Index := i + IndexOffset;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
SaveDialog.Filter := FilterStr;
|
for i := 0 to ExportFilters.Count - 1 do
|
||||||
SaveDialog.FilterIndex := Index;
|
|
||||||
if SaveDialog.Execute then
|
|
||||||
begin
|
|
||||||
FileExtension:=ExtractFileExt(SaveDialog.FileName);
|
|
||||||
if FileExtension = '' then
|
|
||||||
FileExtension:=UTF8Copy(FExtList[SaveDialog.FilterIndex - 1], 2, UTF8Length(FExtList[SaveDialog.FilterIndex - 1]) - 1);
|
|
||||||
|
|
||||||
if FileExtension = '.frp' then
|
|
||||||
SaveToFile(SaveDialog.FileName)
|
|
||||||
else
|
|
||||||
begin
|
begin
|
||||||
for i := 0 to ExportFilters.Count - 1 do
|
FilterInfo := ExportFilters[i];
|
||||||
|
if FilterInfo.Enabled then
|
||||||
begin
|
begin
|
||||||
FilterInfo := ExportFilters[i];
|
FExtList.AddObject(FilterInfo.FilterExt, TObject(PtrInt(i)));
|
||||||
if FilterInfo.Enabled and (FileExtension = UTF8Copy(FilterInfo.FilterExt, 2, UTF8Length(FilterInfo.FilterExt) - 1)) then
|
if FilterStr <> '' then
|
||||||
begin
|
FilterStr := FilterStr + '|';
|
||||||
ExportToWithFilterIndex(i, ChangeFileExt(SaveDialog.FileName, FileExtension));
|
FilterStr := FilterStr + FilterInfo.FilterDesc + '|' + FilterInfo.FilterExt;
|
||||||
break;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
|
||||||
FExtList.Free;
|
|
||||||
|
|
||||||
ScrollBox1.Invalidate;
|
SaveDialog.Filter := FilterStr;
|
||||||
|
SaveDialog.FilterIndex := Index;
|
||||||
|
if SaveDialog.Execute then
|
||||||
|
begin
|
||||||
|
Index := SaveDialog.FilterIndex - 1;
|
||||||
|
if fExtList.Objects[Index]=nil then
|
||||||
|
SaveToFile(SaveDialog.Filename) // using .frp
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
Index := PtrInt(fExtList.Objects[Index]);
|
||||||
|
WriteLn('Exporting ',SaveDialog.FileName,' with ', ExportFilters[Index].FilterDesc);
|
||||||
|
ExportToWithFilterIndex(Index, SaveDialog.FileName);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
finally
|
||||||
|
FExtList.Free;
|
||||||
|
ScrollBox1.Invalidate;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrPreviewForm.PrintBtnClick(Sender: TObject);
|
procedure TfrPreviewForm.PrintBtnClick(Sender: TObject);
|
||||||
|
Loading…
Reference in New Issue
Block a user