[Libreoffice-commits] core.git: connectivity/source
Julien Nabet
serval2412 at yahoo.fr
Wed Jun 14 19:22:31 UTC 2017
connectivity/source/drivers/dbase/DTable.cxx | 35 ++----------------------
connectivity/source/inc/dbase/DTable.hxx | 39 +++++++++++++++------------
2 files changed, 26 insertions(+), 48 deletions(-)
New commits:
commit 5435e2b2aa6cbd2b72df09c28d8d16bb71f5018f
Author: Julien Nabet <serval2412 at yahoo.fr>
Date: Wed Jun 14 19:13:22 2017 +0200
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 at yahoo.fr>
Tested-by: Julien Nabet <serval2412 at yahoo.fr>
diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx
index 14c75d283b34..a684616771c6 100644
--- a/connectivity/source/drivers/dbase/DTable.cxx
+++ b/connectivity/source/drivers/dbase/DTable.cxx
@@ -222,35 +222,7 @@ void ODbaseTable::readHeader()
if (m_aHeader.recordLength == 0)
throwInvalidDbaseFormat();
- m_pFileStream->ReadBytes(m_aHeader.reserved1, 2);
- 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);
+ m_pFileStream->ReadBytes(m_aHeader.trailer, 20);
if(ERRCODE_NONE != m_pFileStream->GetErrorCode())
throwInvalidDbaseFormat();
@@ -277,9 +249,10 @@ void ODbaseTable::readHeader()
case dBaseIIIMemo:
case FoxProMemo:
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 0x02: m_eEncoding = RTL_TEXTENCODING_IBM_850; break; // DOS Multilingual code page 850
diff --git a/connectivity/source/inc/dbase/DTable.hxx b/connectivity/source/inc/dbase/DTable.hxx
index 867cde2e8e00..3402c563b6b0 100644
--- a/connectivity/source/inc/dbase/DTable.hxx
+++ b/connectivity/source/inc/dbase/DTable.hxx
@@ -57,23 +57,28 @@ namespace connectivity
private:
// 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
- struct DBFHeader {
- DBFType type; // dBASE/xBASE type, see DBFType
- sal_uInt8 dateElems[3]; // Date of last change (YYMMDD)
- sal_uInt32 nbRecords; // Number of records
- sal_uInt16 headerLength;
- sal_uInt16 recordLength; // length of 1 record
- sal_uInt8 reserved1[2]; // should be filled with 0
- sal_uInt8 incompTransact; // Incomplete transaction (dBASE IV):
- // 00h Transaction ended (or rolled back)
- // 01h Transaction started
- sal_uInt8 encryptionFlag; // dBASE IV: 00h not encrypted, 01h data encrypted
- sal_uInt8 freeRecordThread[4]; // reserved for LAN only
- sal_uInt8 multiUserdBASE[8]; // reserved for multi-user dBASE (dBASE III+)
- sal_uInt8 MDXFlag; // dBASE IV 0x01 if a production .MDX file exists for this table
- // 0x00 if no .MDX file exists
- sal_uInt8 languageDriver; // codepage (from Foxpro)
- sal_uInt8 reserved2[2]; // should be filled with 0
+ struct DBFHeader { // address/pos in trailer
+ DBFType type; // dBASE/xBASE type, see DBFType 00h
+ sal_uInt8 dateElems[3]; // Date of last change (YYMMDD) 01h
+ sal_uInt32 nbRecords; // Number of records 04h
+ sal_uInt16 headerLength; // 08h
+ sal_uInt16 recordLength; // Length of 1 record 10h
+ sal_uInt8 trailer[20];
+ // 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)
+ // 01h Transaction started
+ // - encryptionFlag:1 byte: dBASE IV 15h/3
+ // 00h not encrypted
+ // 01h for encrypted
+ // - 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
+ // - languageDriver:1 byte:codepage (from Foxpro) 29h/17
+ // - reserved:2 bytes: should be filled with 0 30h/18
};
struct DBFColumn { /* Column descriptors */
sal_uInt8 db_fnm[11]; /* Field name */
More information about the Libreoffice-commits
mailing list