You've already forked lazarus-ccr
fpspreadsheet: Fix fpsctrls demo picking the correct file extension for saving.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5237 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -975,6 +975,7 @@ object MainForm: TMainForm
|
||||
Caption = 'Save &as ...'
|
||||
Dialog.Title = 'AcSaveFileAs'
|
||||
Dialog.Filter = 'Excel XML spreadsheet (*.xlsx)|*.xlsx|Excel XP/2003 XML spreadsheets (*.xml)|*.xml|Excel 97-2003 spreadsheets (*.xls)|*.xls|Excel 5 spreadsheet (*.xls)|*.xls|Excel 2.1 spreadsheets (*.xls)|*.xls|LibreOffice/OpenOffice spreadsheet (*.ods)|*.ods|Comma-delimited files (*.csv)|*.csv|HTML files (*.html; *.htm)|*.html;*.htm|WikiTable (WikiMedia-Format, *.wikitable_wikimedia)|*.wikitable_wikimedia'
|
||||
Dialog.OnTypeChange = TSaveDialogTypeChange
|
||||
Hint = 'Save spreadsheet'
|
||||
ImageIndex = 45
|
||||
BeforeExecute = AcFileSaveAsBeforeExecute
|
||||
|
@ -381,6 +381,7 @@ type
|
||||
procedure HyperlinkHandler(Sender: TObject; ACaption: String;
|
||||
var AHyperlink: TsHyperlink);
|
||||
procedure InspectorTabControlChange(Sender: TObject);
|
||||
procedure TSaveDialogTypeChange(Sender: TObject);
|
||||
procedure WorksheetGridClickHyperlink(Sender: TObject;
|
||||
const AHyperlink: TsHyperlink);
|
||||
procedure WorksheetGridMouseWheel(Sender: TObject; Shift: TShiftState;
|
||||
@ -468,10 +469,13 @@ end;
|
||||
procedure TMainForm.AcFileSaveAsAccept(Sender: TObject);
|
||||
var
|
||||
fmt: TsSpreadFormatID;
|
||||
fmts: TsSpreadFormatIDArray;
|
||||
ext: String;
|
||||
begin
|
||||
Screen.Cursor := crHourglass;
|
||||
try
|
||||
fmt := FSaveFormats[AcFileSaveAs.Dialog.FilterIndex-1];
|
||||
fmt := FSaveFormats[AcFileSaveAs.Dialog.FilterIndex - 1];
|
||||
ext := ExtractFileExt(ACFileSaveAs.Dialog.Filename);
|
||||
WorkbookSource.SaveToSpreadsheetFile(UTF8ToAnsi(AcFileSaveAs.Dialog.FileName), fmt);
|
||||
UpdateCaption;
|
||||
finally
|
||||
@ -480,11 +484,23 @@ begin
|
||||
end;
|
||||
|
||||
procedure TMainForm.AcFileSaveAsBeforeExecute(Sender: TObject);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
if WorkbookSource.FileName = '' then
|
||||
exit;
|
||||
|
||||
AcFileSaveAs.Dialog.InitialDir := ExtractFileDir(WorkbookSource.FileName);
|
||||
AcFileSaveAs.Dialog.FileName := ExtractFileName(WorkbookSource.FileName);
|
||||
|
||||
// Pre-select the file format according to the input file
|
||||
if WorkbookSource.Workbook.FileFormatID = sfidUnknown then
|
||||
exit;
|
||||
for i:=0 to High(FSaveformats) do
|
||||
if FSaveFormats[i] = WorkbookSource.Workbook.FileFormatID then begin
|
||||
AcFileSaveAs.Dialog.FilterIndex := i + 1;
|
||||
break;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMainForm.AcFrozenColsExecute(Sender: TObject);
|
||||
@ -808,6 +824,14 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMainForm.TSaveDialogTypeChange(Sender: TObject);
|
||||
var
|
||||
ext: String;
|
||||
begin
|
||||
ext := GetSpreadFormatExt(FSaveFormats[AcFileSaveAs.Dialog.FilterIndex - 1]);
|
||||
AcFileSaveAs.Dialog.FileName := ChangeFileExt(AcFileSaveAs.Dialog.FileName, ext);
|
||||
end;
|
||||
|
||||
procedure TMainForm.UpdateCaption;
|
||||
begin
|
||||
if WorkbookSource = nil then
|
||||
|
@ -38,6 +38,7 @@ function GetSpreadFormats(AFileAccess: TsSpreadFileAccess;
|
||||
function GetSpreadFormatsFromFileName(AFileAccess: TsSpreadFileAccess; AFileName: TFileName;
|
||||
APriorityFormat: TsSpreadFormatID = sfidUnknown): TsSpreadFormatIDArray;
|
||||
|
||||
function GetSpreadFormatExt(AFormatID: TsSpreadFormatID): String;
|
||||
function GetSpreadFormatName(AFormatID: TsSpreadFormatID): String;
|
||||
function GetSpreadTechnicalName(AFormatID: TsSpreadFormatID): String;
|
||||
|
||||
@ -535,6 +536,11 @@ begin
|
||||
AFileAccess, AFileName, APriorityFormat);
|
||||
end;
|
||||
|
||||
function GetSpreadFormatExt(AFormatID: TsSpreadFormatID): String;
|
||||
begin
|
||||
Result := SpreadFormatRegistry.DefaultExt[AFormatID];
|
||||
end;
|
||||
|
||||
function GetSpreadFormatName(AFormatID: TsSpreadFormatID): String;
|
||||
begin
|
||||
Result := SpreadFormatRegistry.FormatName[AFormatID];
|
||||
|
Reference in New Issue
Block a user