mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-06 11:50:19 +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);
|
||||
|
||||
Var
|
||||
I,J : Integer;
|
||||
i,NameCounter : Integer;
|
||||
EF : TExportFieldItem;
|
||||
FN : String;
|
||||
NewFieldName : String;
|
||||
|
||||
begin
|
||||
For I:=0 to ExportFields.Count-1 do
|
||||
For i:=0 to ExportFields.Count-1 do
|
||||
begin
|
||||
EF:=ExportFields[i];
|
||||
{ Cut off field name at max length, and
|
||||
rename if it already exists:}
|
||||
If (Length(EF.ExportedName)>MaxFieldNameLength) then
|
||||
begin
|
||||
FN:=Copy(EF.ExportedName,1,MaxFieldNameLength);
|
||||
If ExportFields.IndexOfExportedName(FN)<>-1 then
|
||||
NewFieldName:=Copy(EF.ExportedName,1,MaxFieldNameLength);
|
||||
If ExportFields.IndexOfExportedName(NewFieldName)<>-1 then
|
||||
begin
|
||||
J:=1;
|
||||
NameCounter:=1;
|
||||
Repeat
|
||||
FN:=Copy(EF.ExportedName,1,8)+Format('%.2d',[J]);
|
||||
Until (ExportFIelds.IndexOfExportedName(FN)=-1);
|
||||
NewFieldName:=Copy(EF.ExportedName,1,8)+Format('%.2d',[NameCounter]);
|
||||
Until (ExportFIelds.IndexOfExportedName(NewFieldName)=-1);
|
||||
end;
|
||||
EF.ExportedName:=FN;
|
||||
EF.ExportedName:=NewFieldName;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@ -130,7 +132,7 @@ Const
|
||||
|
||||
Var
|
||||
EF : TDBFExportFieldItem;
|
||||
I : Integer;
|
||||
i : Integer;
|
||||
|
||||
begin
|
||||
// DBase III,IV, and FoxPro have a 10 character field length limit.
|
||||
@ -144,18 +146,18 @@ begin
|
||||
with FDBF.FieldDefs do
|
||||
begin
|
||||
Clear;
|
||||
For I:=0 to ExportFields.Count-1 do
|
||||
For i:=0 to ExportFields.Count-1 do
|
||||
begin
|
||||
EF:=ExportFIelds[i] as TDBFExportFieldItem;
|
||||
If EF.ENabled and Assigned(EF.Field) then
|
||||
Add(EF.ExportedName,EF.FIeld.DataType,EF.Field.Size);
|
||||
EF:=ExportFields[i] as TDBFExportFieldItem;
|
||||
If EF.Enabled and Assigned(EF.Field) then
|
||||
Add(EF.ExportedName,EF.Field.DataType,EF.Field.Size);
|
||||
end;
|
||||
FDBF.TableLevel:=Levels[FormatSettings.TableFormat];
|
||||
FDBF.CreateTable;
|
||||
FDBF.Exclusive := true;
|
||||
FDBF.Open;
|
||||
end;
|
||||
For I:=0 to ExportFields.Count-1 do
|
||||
For i:=0 to ExportFields.Count-1 do
|
||||
begin
|
||||
EF:=ExportFIelds[i] as TDBFExportFieldItem;
|
||||
If EF.Enabled then
|
||||
@ -226,20 +228,29 @@ Var
|
||||
begin
|
||||
F:=EF as TDBFExportFieldItem;
|
||||
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
|
||||
DestField.Clear
|
||||
else If Field.Datatype in IntFieldTypes then
|
||||
else if Field.Datatype in (IntFieldTypes+[ftAutoInc,ftLargeInt]) then
|
||||
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
|
||||
else if Field.DataType=ftBoolean then
|
||||
DestField.AsBoolean:=Field.AsBoolean
|
||||
else if (Field.DataType in ([ftWidestring,ftFixedWideChar]+BlobFieldTypes)) then
|
||||
DestField.AsWideString:=Field.AsWideString
|
||||
else if field.DataType in DateFieldTypes then
|
||||
DestField.AsDatetime:=Field.AsDateTime
|
||||
else
|
||||
DestField.AsDatetime:=Field.AsDateTime
|
||||
DestField.AsString:=Field.AsString
|
||||
end;
|
||||
|
||||
Procedure RegisterDBFExportFormat;
|
||||
|
Loading…
Reference in New Issue
Block a user