Browse Source

* fcl-db: dbase: backlinks:
- allow auto-upgrade from FoxPro to VisualFoxpro when backlink specified
- check on required tablelevel when assigning backlinks
- translation for error messages (Spanish,Italian,Polish,Portugues,Russian) needed
- layout/comment fixes

git-svn-id: trunk@28020 -

reiniero 11 years ago
parent
commit
115a64d62c

+ 6 - 0
packages/fcl-db/src/dbase/dbf.pas

@@ -397,6 +397,8 @@ type
     // Visual Foxpro: relative path to .dbc database file containing
     // Visual Foxpro: relative path to .dbc database file containing
     // long field names and other metadata
     // long field names and other metadata
     // Empty if this is a "free table", not linked to a .dbc file
     // Empty if this is a "free table", not linked to a .dbc file
+    // Setting this with a FoxPro tablelevel will auto-upgrade to Visual Foxpro
+    // Unsupported for other versions
     property BackLink: String read FBackLink write SetBackLink;
     property BackLink: String read FBackLink write SetBackLink;
     property LanguageID: Byte read FLanguageID write SetLanguageID;
     property LanguageID: Byte read FLanguageID write SetLanguageID;
     property LanguageStr: String read GetLanguageStr;
     property LanguageStr: String read GetLanguageStr;
@@ -2213,6 +2215,10 @@ end;
 
 
 procedure TDbf.SetBackLink(NewBackLink: String);
 procedure TDbf.SetBackLink(NewBackLink: String);
 begin
 begin
+  // Only supported in Visual Foxpro but allow auto-upgrade from Foxpro
+  if not(Tablelevel in [TDBF_TABLELEVEL_FOXPRO,TDBF_TABLELEVEL_VISUALFOXPRO]) then
+    raise EDbfError.CreateFmt(STRING_FEATURE_NOT_SUPPORTED_THIS_TABLELEVEL,
+      [Tablelevel]);
   CheckInactive;
   CheckInactive;
 
 
   FBackLink := NewBackLink;
   FBackLink := NewBackLink;

+ 15 - 5
packages/fcl-db/src/dbase/dbf_dbffile.pas

@@ -667,7 +667,7 @@ var
   I, lFieldOffset, lSize, lPrec: Integer;
   I, lFieldOffset, lSize, lPrec: Integer;
   lHasBlob: Boolean;
   lHasBlob: Boolean;
   lLocaleID: LCID;
   lLocaleID: LCID;
-  lNullVarFlagCount:integer; //(VFP only) Keeps track of number null/varlength flags needed for _NULLFLAGS size calculation
+  lNullVarFlagCount: integer; //(VFP only) Keeps track of number null/varlength flags needed for _NULLFLAGS size calculation
 begin
 begin
   try
   try
     // first reset file
     // first reset file
@@ -759,14 +759,14 @@ begin
       lHasBlob := lHasBlob or lFieldDef.IsBlob;
       lHasBlob := lHasBlob or lFieldDef.IsBlob;
       // Check for Foxpro, too, as it can get auto-upgraded to vfp:
       // Check for Foxpro, too, as it can get auto-upgraded to vfp:
       if (FDbfVersion in [xFoxPro,xVisualFoxPro]) then
       if (FDbfVersion in [xFoxPro,xVisualFoxPro]) then
-        begin
+      begin
         if (lFieldDef.NativeFieldType='Q') or (lFieldDef.NativeFieldType='V') then
         if (lFieldDef.NativeFieldType='Q') or (lFieldDef.NativeFieldType='V') then
         begin
         begin
           lNullVarFlagCount:=lNullVarFlagCount+1;
           lNullVarFlagCount:=lNullVarFlagCount+1;
         end;
         end;
         if (lFieldDef.NullPosition>=0) then
         if (lFieldDef.NullPosition>=0) then
           lNullVarFlagCount:=lNullVarFlagCount+1;
           lNullVarFlagCount:=lNullVarFlagCount+1;
-        end;
+      end;
 
 
       // apply field transformation tricks
       // apply field transformation tricks
       lSize := lFieldDef.Size;
       lSize := lFieldDef.Size;
@@ -809,11 +809,21 @@ begin
         begin
         begin
           // VerDBF=$03 also includes dbase formats, so we perform an extra check
           // VerDBF=$03 also includes dbase formats, so we perform an extra check
           if (PDbfHdr(Header)^.VerDBF in [$02,$03]) and
           if (PDbfHdr(Header)^.VerDBF in [$02,$03]) and
-            ((lFieldDef.NativeFieldType in ['0', 'Y', 'T', 'O', '+', 'Q', 'V']) or (lNullVarFlagCount>0)) then
+            ((lFieldDef.NativeFieldType in ['0', 'Y', 'T', 'O', '+', 'Q', 'V']) or
+            (lNullVarFlagCount>0)) then
+          begin
+            PDbfHdr(Header)^.VerDBF := $30; {Visual FoxPro}
+            FDBFVersion:=xVisualFoxPro;
+          end;
+
+          // Upgrade if a non-empty backlink is specified - for FoxPro only
+          if (FBackLink<>'') and
+            ((FDBFVersion=xFoxPro) or (PDbfHdr(Header)^.VerDBF=$02)) then
           begin
           begin
             PDbfHdr(Header)^.VerDBF := $30; {Visual FoxPro}
             PDbfHdr(Header)^.VerDBF := $30; {Visual FoxPro}
             FDBFVersion:=xVisualFoxPro; //needed to write the backlink info
             FDBFVersion:=xVisualFoxPro; //needed to write the backlink info
           end;
           end;
+
           //AutoInc only support in Visual Foxpro; another upgrade
           //AutoInc only support in Visual Foxpro; another upgrade
           //Note: .AutoIncrementNext is really a cardinal (see the definition)
           //Note: .AutoIncrementNext is really a cardinal (see the definition)
           lFieldDescIII.AutoIncrementNext:=SwapIntLE(lFieldDef.AutoInc);
           lFieldDescIII.AutoIncrementNext:=SwapIntLE(lFieldDef.AutoInc);
@@ -834,7 +844,7 @@ begin
         end;
         end;
       end;
       end;
 
 
-      // update our field list
+      // Update our field list
       with FFieldDefs.AddFieldDef do
       with FFieldDefs.AddFieldDef do
       begin
       begin
         Assign(lFieldDef);
         Assign(lFieldDef);

+ 1 - 0
packages/fcl-db/src/dbase/dbf_str.inc

@@ -1,6 +1,7 @@
 var
 var
   STRING_FILE_NOT_FOUND: string;
   STRING_FILE_NOT_FOUND: string;
   STRING_VERSION: string;
   STRING_VERSION: string;
+  STRING_FEATURE_NOT_SUPPORTED_THIS_TABLELEVEL: string;
 
 
   STRING_RECORD_LOCKED: string;
   STRING_RECORD_LOCKED: string;
   STRING_WRITE_ERROR: string;
   STRING_WRITE_ERROR: string;

+ 1 - 0
packages/fcl-db/src/dbase/dbf_str.pas

@@ -11,6 +11,7 @@ initialization
 
 
   STRING_FILE_NOT_FOUND               := 'Open: file not found: "%s".';
   STRING_FILE_NOT_FOUND               := 'Open: file not found: "%s".';
   STRING_VERSION                      := 'TDbf V%d.%d';
   STRING_VERSION                      := 'TDbf V%d.%d';
+  STRING_FEATURE_NOT_SUPPORTED_THIS_TABLELEVEL:= 'This feature is not supported in tablelevel %d';
 
 
   STRING_RECORD_LOCKED                := 'Record locked.';
   STRING_RECORD_LOCKED                := 'Record locked.';
   STRING_WRITE_ERROR                  := 'Error while writing occurred. (Disk full?)';
   STRING_WRITE_ERROR                  := 'Error while writing occurred. (Disk full?)';

+ 2 - 0
packages/fcl-db/src/dbase/dbf_str_es.pas

@@ -11,6 +11,8 @@ initialization
 
 
   STRING_FILE_NOT_FOUND               := 'Apertura: archivo no encontrado: "%s".';
   STRING_FILE_NOT_FOUND               := 'Apertura: archivo no encontrado: "%s".';
   STRING_VERSION                      := 'TDbf V%d.%d';
   STRING_VERSION                      := 'TDbf V%d.%d';
+  // todo: translate me
+  STRING_FEATURE_NOT_SUPPORTED_THIS_TABLELEVEL: string; := 'This feature is not supported in tablelevel %d';
 
 
   STRING_RECORD_LOCKED                := 'Registro bloqueado.';
   STRING_RECORD_LOCKED                := 'Registro bloqueado.';
   STRING_WRITE_ERROR                  := 'Error de escritura. (Disco lleno?)';
   STRING_WRITE_ERROR                  := 'Error de escritura. (Disco lleno?)';

+ 3 - 23
packages/fcl-db/src/dbase/dbf_str_fr.pas

@@ -3,28 +3,7 @@ unit dbf_str;
 interface
 interface
 
 
 {$I dbf_common.inc}
 {$I dbf_common.inc}
-
-var
-  STRING_FILE_NOT_FOUND: string;
-  STRING_VERSION: string;
-
-  STRING_RECORD_LOCKED: string;
-  STRING_KEY_VIOLATION: string;
-
-  STRING_INVALID_DBF_FILE: string;
-  STRING_INVALID_DBF_FILE_FIELDERROR: string;
-  STRING_FIELD_TOO_LONG: string;
-  STRING_INVALID_FIELD_COUNT: string;
-  STRING_INVALID_FIELD_TYPE: string;
-
-  STRING_INDEX_BASED_ON_UNKNOWN_FIELD: string;
-  STRING_INDEX_BASED_ON_INVALID_FIELD: string;
-  STRING_INDEX_EXPRESSION_TOO_LONG: string;
-  STRING_INVALID_INDEX_TYPE: string;
-  STRING_CANNOT_OPEN_INDEX: string;
-  STRING_TOO_MANY_INDEXES: string;
-  STRING_INDEX_NOT_EXIST: string;
-  STRING_NEED_EXCLUSIVE_ACCESS: string;
+{$I dbf_str.inc}
 
 
 implementation
 implementation
 
 
@@ -32,7 +11,8 @@ initialization
 
 
   STRING_FILE_NOT_FOUND               := 'Ouverture: fichier non trouvé: "%s"';
   STRING_FILE_NOT_FOUND               := 'Ouverture: fichier non trouvé: "%s"';
   STRING_VERSION                      := 'TDbf V%d.%d';
   STRING_VERSION                      := 'TDbf V%d.%d';
-
+  STRING_FEATURE_NOT_SUPPORTED_THIS_TABLELEVEL: string; := 'Cette fonctionnalité n'est pas supporté dans tablelevel %d'; 
+  
   STRING_RECORD_LOCKED                := 'Enregistrement verrouillé.';
   STRING_RECORD_LOCKED                := 'Enregistrement verrouillé.';
   STRING_KEY_VIOLATION                := 'Violation de clé. (doublon dans un index).'+#13+#10+
   STRING_KEY_VIOLATION                := 'Violation de clé. (doublon dans un index).'+#13+#10+
                                          'Index: %s'+#13+#10+'Enregistrement=%d Cle=''%s''';
                                          'Index: %s'+#13+#10+'Enregistrement=%d Cle=''%s''';

+ 2 - 0
packages/fcl-db/src/dbase/dbf_str_ita.pas

@@ -12,6 +12,8 @@ initialization
 
 
   STRING_FILE_NOT_FOUND               := 'Apertura: file non trovato: "%s"';
   STRING_FILE_NOT_FOUND               := 'Apertura: file non trovato: "%s"';
   STRING_VERSION                      := 'TDbf V%d.%d';
   STRING_VERSION                      := 'TDbf V%d.%d';
+  // todo: translate me
+  STRING_FEATURE_NOT_SUPPORTED_THIS_TABLELEVEL: string; := 'This feature is not supported in tablelevel %d'; 
 
 
   STRING_RECORD_LOCKED                := 'Record già in uso.';
   STRING_RECORD_LOCKED                := 'Record già in uso.';
 
 

+ 1 - 0
packages/fcl-db/src/dbase/dbf_str_nl.pas

@@ -11,6 +11,7 @@ initialization
 
 
   STRING_FILE_NOT_FOUND               := 'Openen: bestand niet gevonden: "%s"';
   STRING_FILE_NOT_FOUND               := 'Openen: bestand niet gevonden: "%s"';
   STRING_VERSION                      := 'TDbf V%d.%d';
   STRING_VERSION                      := 'TDbf V%d.%d';
+  STRING_FEATURE_NOT_SUPPORTED_THIS_TABLELEVEL: string; := 'Deze functionaliteit wordt niet ondersteund in tablelevel %d'; 
 
 
   STRING_RECORD_LOCKED                := 'Record in gebruik.';
   STRING_RECORD_LOCKED                := 'Record in gebruik.';
   STRING_WRITE_ERROR                  := 'Error tijdens schrijven. (Disk vol?)';
   STRING_WRITE_ERROR                  := 'Error tijdens schrijven. (Disk vol?)';

+ 2 - 0
packages/fcl-db/src/dbase/dbf_str_pl.pas

@@ -11,6 +11,8 @@ initialization
 
 
   STRING_FILE_NOT_FOUND               := 'Open: brak pliku: "%s"';
   STRING_FILE_NOT_FOUND               := 'Open: brak pliku: "%s"';
   STRING_VERSION                      := 'TDbf V%d.%d';
   STRING_VERSION                      := 'TDbf V%d.%d';
+  // todo: translate me
+  STRING_FEATURE_NOT_SUPPORTED_THIS_TABLELEVEL: string; := 'This feature is not supported in tablelevel %d';
 
 
   STRING_RECORD_LOCKED                := 'Rekord zablokowany.';
   STRING_RECORD_LOCKED                := 'Rekord zablokowany.';
   STRING_WRITE_ERROR                  := 'Niezapisano(Brak miejsca na dysku?)';
   STRING_WRITE_ERROR                  := 'Niezapisano(Brak miejsca na dysku?)';

+ 2 - 0
packages/fcl-db/src/dbase/dbf_str_pt.pas

@@ -13,6 +13,8 @@ initialization
 
 
   STRING_FILE_NOT_FOUND               := 'Abertura: arquivo não encontrado: "%s".';
   STRING_FILE_NOT_FOUND               := 'Abertura: arquivo não encontrado: "%s".';
   STRING_VERSION                      := 'TDbf V%d.%d';
   STRING_VERSION                      := 'TDbf V%d.%d';
+  //todo: translate me
+  STRING_FEATURE_NOT_SUPPORTED_THIS_TABLELEVEL: string; := 'This feature is not supported in tablelevel %d';
 
 
   STRING_RECORD_LOCKED                := 'Registro bloqueado.';
   STRING_RECORD_LOCKED                := 'Registro bloqueado.';
   STRING_WRITE_ERROR                  := 'Erro de escrita. (Disco cheio?)';
   STRING_WRITE_ERROR                  := 'Erro de escrita. (Disco cheio?)';

+ 2 - 0
packages/fcl-db/src/dbase/dbf_str_ru.pas

@@ -16,6 +16,8 @@ initialization
 
 
   STRING_FILE_NOT_FOUND               := 'Ôàéë "%s" íå ñóùåñòâóåò. Îòêðûòü íåâîçìîæíî.';
   STRING_FILE_NOT_FOUND               := 'Ôàéë "%s" íå ñóùåñòâóåò. Îòêðûòü íåâîçìîæíî.';
   STRING_VERSION                      := 'TDbf V%d.%d';
   STRING_VERSION                      := 'TDbf V%d.%d';
+  //todo: translate me
+  STRING_FEATURE_NOT_SUPPORTED_THIS_TABLELEVEL: string; := 'This feature is not supported in tablelevel %d';
 
 
   STRING_RECORD_LOCKED                := 'Çàïèñü (ñòðîêà òàáëèöû) çàáëîêèðîâàíà.';
   STRING_RECORD_LOCKED                := 'Çàïèñü (ñòðîêà òàáëèöû) çàáëîêèðîâàíà.';
   STRING_WRITE_ERROR                  := 'Îøèáêà çàïèñè íà äèñê (Äèñê çàïîëíåí?)';
   STRING_WRITE_ERROR                  := 'Îøèáêà çàïèñè íà äèñê (Äèñê çàïîëíåí?)';

+ 2 - 2
packages/fcl-db/src/dbase/dbf_struct.inc

@@ -18,12 +18,12 @@ type
 
 
   PDbfHdr = ^rDbfHdr;
   PDbfHdr = ^rDbfHdr;
   rDbfHdr = packed record
   rDbfHdr = packed record
-    VerDBF      : Byte;     // 0
+    VerDBF      : Byte;     // 0 DBF file type/version
     Year        : Byte;     // 1 year last updated
     Year        : Byte;     // 1 year last updated
     Month       : Byte;     // 2 month last updated
     Month       : Byte;     // 2 month last updated
     Day         : Byte;     // 3 day last updated
     Day         : Byte;     // 3 day last updated
     RecordCount : Integer;  // 4-7 number of records in file
     RecordCount : Integer;  // 4-7 number of records in file
-    FullHdrSize : Word;     // 8-9
+    FullHdrSize : Word;     // 8-9 size of the header in bytes
     RecordSize  : Word;     // 10-11 sum of all field sizes, including delete flag
     RecordSize  : Word;     // 10-11 sum of all field sizes, including delete flag
     Dummy1      : Word;     // 12-13
     Dummy1      : Word;     // 12-13
     IncTrans    : Byte;     // 14
     IncTrans    : Byte;     // 14