mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-07 18:30:32 +02:00
* Patch from Reinier Olislagers to fix bug #20160
git-svn-id: trunk@18985 -
This commit is contained in:
parent
852ae48cb7
commit
aa4ab64ea5
@ -100,25 +100,27 @@ end;
|
|||||||
procedure TFPCustomDBFExport.CheckExportFieldNames(const MaxFieldNameLength: integer);
|
procedure TFPCustomDBFExport.CheckExportFieldNames(const MaxFieldNameLength: integer);
|
||||||
|
|
||||||
Var
|
Var
|
||||||
I,J : Integer;
|
i,NameCounter : Integer;
|
||||||
EF : TExportFieldItem;
|
EF : TExportFieldItem;
|
||||||
FN : String;
|
NewFieldName : String;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
For I:=0 to ExportFields.Count-1 do
|
For i:=0 to ExportFields.Count-1 do
|
||||||
begin
|
begin
|
||||||
EF:=ExportFields[i];
|
EF:=ExportFields[i];
|
||||||
|
{ Cut off field name at max length, and
|
||||||
|
rename if it already exists:}
|
||||||
If (Length(EF.ExportedName)>MaxFieldNameLength) then
|
If (Length(EF.ExportedName)>MaxFieldNameLength) then
|
||||||
begin
|
begin
|
||||||
FN:=Copy(EF.ExportedName,1,MaxFieldNameLength);
|
NewFieldName:=Copy(EF.ExportedName,1,MaxFieldNameLength);
|
||||||
If ExportFields.IndexOfExportedName(FN)<>-1 then
|
If ExportFields.IndexOfExportedName(NewFieldName)<>-1 then
|
||||||
begin
|
begin
|
||||||
J:=1;
|
NameCounter:=1;
|
||||||
Repeat
|
Repeat
|
||||||
FN:=Copy(EF.ExportedName,1,8)+Format('%.2d',[J]);
|
NewFieldName:=Copy(EF.ExportedName,1,8)+Format('%.2d',[NameCounter]);
|
||||||
Until (ExportFIelds.IndexOfExportedName(FN)=-1);
|
Until (ExportFIelds.IndexOfExportedName(NewFieldName)=-1);
|
||||||
end;
|
end;
|
||||||
EF.ExportedName:=FN;
|
EF.ExportedName:=NewFieldName;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -130,7 +132,7 @@ Const
|
|||||||
|
|
||||||
Var
|
Var
|
||||||
EF : TDBFExportFieldItem;
|
EF : TDBFExportFieldItem;
|
||||||
I : Integer;
|
i : Integer;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
// DBase III,IV, and FoxPro have a 10 character field length limit.
|
// DBase III,IV, and FoxPro have a 10 character field length limit.
|
||||||
@ -144,18 +146,18 @@ begin
|
|||||||
with FDBF.FieldDefs do
|
with FDBF.FieldDefs do
|
||||||
begin
|
begin
|
||||||
Clear;
|
Clear;
|
||||||
For I:=0 to ExportFields.Count-1 do
|
For i:=0 to ExportFields.Count-1 do
|
||||||
begin
|
begin
|
||||||
EF:=ExportFIelds[i] as TDBFExportFieldItem;
|
EF:=ExportFields[i] as TDBFExportFieldItem;
|
||||||
If EF.ENabled and Assigned(EF.Field) then
|
If EF.Enabled and Assigned(EF.Field) then
|
||||||
Add(EF.ExportedName,EF.FIeld.DataType,EF.Field.Size);
|
Add(EF.ExportedName,EF.Field.DataType,EF.Field.Size);
|
||||||
end;
|
end;
|
||||||
FDBF.TableLevel:=Levels[FormatSettings.TableFormat];
|
FDBF.TableLevel:=Levels[FormatSettings.TableFormat];
|
||||||
FDBF.CreateTable;
|
FDBF.CreateTable;
|
||||||
FDBF.Exclusive := true;
|
FDBF.Exclusive := true;
|
||||||
FDBF.Open;
|
FDBF.Open;
|
||||||
end;
|
end;
|
||||||
For I:=0 to ExportFields.Count-1 do
|
For i:=0 to ExportFields.Count-1 do
|
||||||
begin
|
begin
|
||||||
EF:=ExportFIelds[i] as TDBFExportFieldItem;
|
EF:=ExportFIelds[i] as TDBFExportFieldItem;
|
||||||
If EF.Enabled then
|
If EF.Enabled then
|
||||||
@ -226,20 +228,29 @@ Var
|
|||||||
begin
|
begin
|
||||||
F:=EF as TDBFExportFieldItem;
|
F:=EF as TDBFExportFieldItem;
|
||||||
With F do
|
With F do
|
||||||
|
// Export depending on field datatype;
|
||||||
|
// convert to dbf data types where necessary.
|
||||||
|
// Fall back to string if unknown datatype
|
||||||
If FIeld.IsNull then
|
If FIeld.IsNull then
|
||||||
DestField.Clear
|
DestField.Clear
|
||||||
else If Field.Datatype in IntFieldTypes then
|
else if Field.Datatype in (IntFieldTypes+[ftAutoInc,ftLargeInt]) then
|
||||||
DestField.AsInteger:=Field.AsInteger
|
DestField.AsInteger:=Field.AsInteger
|
||||||
else if Field.dataType in [ftString,ftFixedChar] then
|
else if Field.Datatype in [ftBCD,ftCurrency,ftFloat,ftFMTBcd] then
|
||||||
|
DestField.AsFloat:=Field.AsFloat
|
||||||
|
else if Field.DataType in [ftString,ftFixedChar] then
|
||||||
|
DestField.AsString:=Field.AsString
|
||||||
|
else if (Field.DataType in ([ftWideMemo,ftWideString,ftFixedWideChar]+BlobFieldTypes)) then
|
||||||
|
DestField.AsWideString:=Field.AsWideString
|
||||||
|
{ Note: we test for the wide text fields before the MemoFieldTypes, in order to
|
||||||
|
let ftWideMemo end up at the right place }
|
||||||
|
else if Field.DataType in MemoFieldTypes then
|
||||||
DestField.AsString:=Field.AsString
|
DestField.AsString:=Field.AsString
|
||||||
else if Field.DataType=ftBoolean then
|
else if Field.DataType=ftBoolean then
|
||||||
DestField.AsBoolean:=Field.AsBoolean
|
DestField.AsBoolean:=Field.AsBoolean
|
||||||
else if (Field.DataType in ([ftWidestring,ftFixedWideChar]+BlobFieldTypes)) then
|
|
||||||
DestField.AsWideString:=Field.AsWideString
|
|
||||||
else if field.DataType in DateFieldTypes then
|
else if field.DataType in DateFieldTypes then
|
||||||
DestField.AsDatetime:=Field.AsDateTime
|
DestField.AsDatetime:=Field.AsDateTime
|
||||||
else
|
else
|
||||||
DestField.AsDatetime:=Field.AsDateTime
|
DestField.AsString:=Field.AsString
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure RegisterDBFExportFormat;
|
Procedure RegisterDBFExportFormat;
|
||||||
|
Loading…
Reference in New Issue
Block a user