dBASE: put back an array for trailer

since except language code, the other information aren't used
but keep the details in comment

Change-Id: Ibb5bf22e88bd3a5f9c7603ad018cada8add8b2ce
Reviewed-on: https://gerrit.libreoffice.org/38799
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Julien Nabet <serval2412@yahoo.fr>
This commit is contained in:
Julien Nabet
2017-06-14 19:13:22 +02:00
parent df2f811673
commit 5435e2b2aa
2 changed files with 26 additions and 48 deletions

View File

@@ -222,35 +222,7 @@ void ODbaseTable::readHeader()
if (m_aHeader.recordLength == 0) if (m_aHeader.recordLength == 0)
throwInvalidDbaseFormat(); throwInvalidDbaseFormat();
m_pFileStream->ReadBytes(m_aHeader.reserved1, 2); m_pFileStream->ReadBytes(m_aHeader.trailer, 20);
if(ERRCODE_NONE != m_pFileStream->GetErrorCode())
throwInvalidDbaseFormat();
m_pFileStream->ReadUChar(m_aHeader.incompTransact);
if(ERRCODE_NONE != m_pFileStream->GetErrorCode())
throwInvalidDbaseFormat();
m_pFileStream->ReadUChar(m_aHeader.encryptionFlag);
if(ERRCODE_NONE != m_pFileStream->GetErrorCode())
throwInvalidDbaseFormat();
m_pFileStream->ReadBytes(m_aHeader.freeRecordThread, 4);
if(ERRCODE_NONE != m_pFileStream->GetErrorCode())
throwInvalidDbaseFormat();
m_pFileStream->ReadBytes(m_aHeader.multiUserdBASE, 8);
if(ERRCODE_NONE != m_pFileStream->GetErrorCode())
throwInvalidDbaseFormat();
m_pFileStream->ReadUChar(m_aHeader.MDXFlag);
if(ERRCODE_NONE != m_pFileStream->GetErrorCode())
throwInvalidDbaseFormat();
m_pFileStream->ReadUChar(m_aHeader.languageDriver);
if(ERRCODE_NONE != m_pFileStream->GetErrorCode())
throwInvalidDbaseFormat();
m_pFileStream->ReadBytes(m_aHeader.reserved2, 2);
if(ERRCODE_NONE != m_pFileStream->GetErrorCode()) if(ERRCODE_NONE != m_pFileStream->GetErrorCode())
throwInvalidDbaseFormat(); throwInvalidDbaseFormat();
@@ -277,9 +249,10 @@ void ODbaseTable::readHeader()
case dBaseIIIMemo: case dBaseIIIMemo:
case FoxProMemo: case FoxProMemo:
m_pFileStream->SetEndian(SvStreamEndian::LITTLE); m_pFileStream->SetEndian(SvStreamEndian::LITTLE);
if ( m_aHeader.languageDriver != 0x00 && getConnection()->isTextEncodingDefaulted() ) // trailer[17] corresponds to language code, see DBFHeader def in connectivity/source/inc/dbase/DTable.hxx
if ( m_aHeader.trailer[17] != 0x00 && getConnection()->isTextEncodingDefaulted() )
{ {
switch(m_aHeader.languageDriver) switch(m_aHeader.trailer[17])
{ {
case 0x01: m_eEncoding = RTL_TEXTENCODING_IBM_437; break; // DOS USA code page 437 case 0x01: m_eEncoding = RTL_TEXTENCODING_IBM_437; break; // DOS USA code page 437
case 0x02: m_eEncoding = RTL_TEXTENCODING_IBM_850; break; // DOS Multilingual code page 850 case 0x02: m_eEncoding = RTL_TEXTENCODING_IBM_850; break; // DOS Multilingual code page 850

View File

@@ -57,23 +57,28 @@ namespace connectivity
private: private:
// sources: https://www.clicketyclick.dk/databases/xbase/format/dbf.html (dBASE III and 5) // sources: https://www.clicketyclick.dk/databases/xbase/format/dbf.html (dBASE III and 5)
// http://www.dbase.com/KnowledgeBase/int/db7_file_fmt.htm (dBASE 7) which is similar at least for this part // http://www.dbase.com/KnowledgeBase/int/db7_file_fmt.htm (dBASE 7) which is similar at least for this part
struct DBFHeader { struct DBFHeader { // address/pos in trailer
DBFType type; // dBASE/xBASE type, see DBFType DBFType type; // dBASE/xBASE type, see DBFType 00h
sal_uInt8 dateElems[3]; // Date of last change (YYMMDD) sal_uInt8 dateElems[3]; // Date of last change (YYMMDD) 01h
sal_uInt32 nbRecords; // Number of records sal_uInt32 nbRecords; // Number of records 04h
sal_uInt16 headerLength; sal_uInt16 headerLength; // 08h
sal_uInt16 recordLength; // length of 1 record sal_uInt16 recordLength; // Length of 1 record 10h
sal_uInt8 reserved1[2]; // should be filled with 0 sal_uInt8 trailer[20];
sal_uInt8 incompTransact; // Incomplete transaction (dBASE IV): // this last field contains these data:
// - reserved:2 bytes:should be filled with 0 12h/0
// - incomplete transaction:1 byte:dBASE IV 14h/2
// 00h Transaction ended (or rolled back) // 00h Transaction ended (or rolled back)
// 01h Transaction started // 01h Transaction started
sal_uInt8 encryptionFlag; // dBASE IV: 00h not encrypted, 01h data encrypted // - encryptionFlag:1 byte: dBASE IV 15h/3
sal_uInt8 freeRecordThread[4]; // reserved for LAN only // 00h not encrypted
sal_uInt8 multiUserdBASE[8]; // reserved for multi-user dBASE (dBASE III+) // 01h for encrypted
sal_uInt8 MDXFlag; // dBASE IV 0x01 if a production .MDX file exists for this table // - freeRecordThread:4 bytes:reserved for LAN only 16h/4
// - multiUserdBASE:8 bytes:reserved for multi-user dBASE (dBASE III+) 20h/8
// - MDXFlag:1 byte:dBASE IV 28h/16
// 0x01 if a production .MDX file exists for this table
// 0x00 if no .MDX file exists // 0x00 if no .MDX file exists
sal_uInt8 languageDriver; // codepage (from Foxpro) // - languageDriver:1 byte:codepage (from Foxpro) 29h/17
sal_uInt8 reserved2[2]; // should be filled with 0 // - reserved:2 bytes: should be filled with 0 30h/18
}; };
struct DBFColumn { /* Column descriptors */ struct DBFColumn { /* Column descriptors */
sal_uInt8 db_fnm[11]; /* Field name */ sal_uInt8 db_fnm[11]; /* Field name */