diff options
Diffstat (limited to 'connectivity/source/drivers/dbase/DTable.cxx')
-rw-r--r-- | connectivity/source/drivers/dbase/DTable.cxx | 415 |
1 files changed, 202 insertions, 213 deletions
diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx index fa286f3456..f309944c07 100644 --- a/connectivity/source/drivers/dbase/DTable.cxx +++ b/connectivity/source/drivers/dbase/DTable.cxx @@ -205,15 +205,15 @@ void ODbaseTable::readHeader() OSL_ENSURE(m_pFileStream,"No Stream available!"); if(!m_pFileStream) return; - m_pFileStream->RefreshBuffer(); // sicherstellen, dass die Kopfinformationen tatsaechlich neu gelesen werden + m_pFileStream->RefreshBuffer(); // Make sure, that the header information actually is read again m_pFileStream->Seek(STREAM_SEEK_TO_BEGIN); - BYTE nType=0; + sal_uInt8 nType=0; (*m_pFileStream) >> nType; if(ERRCODE_NONE != m_pFileStream->GetErrorCode()) throwInvalidDbaseFormat(); - m_pFileStream->Read((char*)(&m_aHeader.db_aedat), 3*sizeof(BYTE)); + m_pFileStream->Read((char*)(&m_aHeader.db_aedat), 3*sizeof(sal_uInt8)); if(ERRCODE_NONE != m_pFileStream->GetErrorCode()) throwInvalidDbaseFormat(); (*m_pFileStream) >> m_aHeader.db_anz; @@ -225,18 +225,18 @@ void ODbaseTable::readHeader() (*m_pFileStream) >> m_aHeader.db_slng; if(ERRCODE_NONE != m_pFileStream->GetErrorCode()) throwInvalidDbaseFormat(); - m_pFileStream->Read((char*)(&m_aHeader.db_frei), 20*sizeof(BYTE)); + m_pFileStream->Read((char*)(&m_aHeader.db_frei), 20*sizeof(sal_uInt8)); if(ERRCODE_NONE != m_pFileStream->GetErrorCode()) throwInvalidDbaseFormat(); - if ( ( ( m_aHeader.db_kopf - 1 ) / 32 - 1 ) <= 0 ) // anzahl felder + if ( ( ( m_aHeader.db_kopf - 1 ) / 32 - 1 ) <= 0 ) // number of fields { // no dbase file throwInvalidDbaseFormat(); } else { - // Konsistenzpruefung des Header: + // Consistency check of the header: m_aHeader.db_typ = (DBFType)nType; switch (m_aHeader.db_typ) { @@ -306,7 +306,7 @@ void ODbaseTable::fillColumns() m_aPrecisions.clear(); m_aScales.clear(); - // Anzahl Felder: + // Number of fields: const sal_Int32 nFieldCount = (m_aHeader.db_kopf - 1) / 32 - 1; OSL_ENSURE(nFieldCount,"No columns in table!"); @@ -319,7 +319,7 @@ void ODbaseTable::fillColumns() aStrFieldName.AssignAscii("Column"); ::rtl::OUString aTypeName; static const ::rtl::OUString sVARCHAR(RTL_CONSTASCII_USTRINGPARAM("VARCHAR")); - const sal_Bool bCase = getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers(); + const sal_Bool bCase = getConnection()->getMetaData()->supportsMixedCaseQuotedIdentifiers(); const bool bFoxPro = m_aHeader.db_typ == VisualFoxPro || m_aHeader.db_typ == VisualFoxProAuto || m_aHeader.db_typ == FoxProMemo; sal_Int32 i = 0; @@ -357,10 +357,10 @@ OSL_TRACE("column type: %c",aDBFColumn.db_typ); aTypeName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NUMERIC")); eType = DataType::DECIMAL; - // Bei numerischen Feldern werden zwei Zeichen mehr geschrieben, als die Precision der Spaltenbeschreibung eigentlich - // angibt, um Platz fuer das eventuelle Vorzeichen und das Komma zu haben. Das muss ich jetzt aber wieder rausrechnen. + // for numeric fields two characters more are written, than the precision of the column description predescribes, + // to keep room for the possible sign and the comma. This has to be considered... nPrecision = SvDbaseConverter::ConvertPrecisionToOdbc(nPrecision,aDBFColumn.db_dez); - // leider gilt das eben Gesagte nicht fuer aeltere Versionen .... + // This is not true for older versions .... break; case 'L': eType = DataType::BIT; @@ -506,17 +506,17 @@ void ODbaseTable::construct() readHeader(); if (HasMemoFields()) { - // Memo-Dateinamen bilden (.DBT): - // nyi: Unschoen fuer Unix und Mac! + // Create Memo-Filename (.DBT): + // nyi: Ugly for Unix and Mac! if ( m_aHeader.db_typ == FoxProMemo || VisualFoxPro == m_aHeader.db_typ || VisualFoxProAuto == m_aHeader.db_typ ) // foxpro uses another extension aURL.SetExtension(String::CreateFromAscii("fpt")); else aURL.SetExtension(String::CreateFromAscii("dbt")); - // Wenn die Memodatei nicht gefunden wird, werden die Daten trotzdem angezeigt - // allerdings koennen keine Updates durchgefuehrt werden - // jedoch die Operation wird ausgefuehrt + // If the memo file isn't found, the data will be displayed anyhow. + // However, updates can't be done + // but the operation is executed m_pMemoStream = createStream_simpleError( aURL.GetMainURL(INetURLObject::NO_DECODE), STREAM_READWRITE | STREAM_NOCREATE | STREAM_SHARE_DENYWRITE); if ( !m_pMemoStream ) { @@ -528,24 +528,24 @@ void ODbaseTable::construct() } fillColumns(); - UINT32 nFileSize = lcl_getFileSize(*m_pFileStream); + sal_uInt32 nFileSize = lcl_getFileSize(*m_pFileStream); m_pFileStream->Seek(STREAM_SEEK_TO_BEGIN); if ( m_aHeader.db_anz == 0 && ((nFileSize-m_aHeader.db_kopf)/m_aHeader.db_slng) > 0) // seems to be empty or someone wrote bullshit into the dbase file m_aHeader.db_anz = ((nFileSize-m_aHeader.db_kopf)/m_aHeader.db_slng); - // Buffersize abhaengig von der Filegroesse + // Buffersize dependent on the file size m_pFileStream->SetBufferSize(nFileSize > 1000000 ? 32768 : nFileSize > 100000 ? 16384 : nFileSize > 10000 ? 4096 : 1024); if (m_pMemoStream) { - // Puffer genau auf Laenge eines Satzes stellen + // set the buffer extactly to the length of a record m_pMemoStream->Seek(STREAM_SEEK_TO_END); nFileSize = m_pMemoStream->Tell(); m_pMemoStream->Seek(STREAM_SEEK_TO_BEGIN); - // Buffersize abhaengig von der Filegroesse + // Buffersize dependent on the file size m_pMemoStream->SetBufferSize(nFileSize > 1000000 ? 32768 : nFileSize > 100000 ? 16384 : nFileSize > 10000 ? 4096 : @@ -556,32 +556,31 @@ void ODbaseTable::construct() } } //------------------------------------------------------------------ -BOOL ODbaseTable::ReadMemoHeader() +sal_Bool ODbaseTable::ReadMemoHeader() { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::ReadMemoHeader" ); m_pMemoStream->SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN); - m_pMemoStream->RefreshBuffer(); // sicherstellen das die Kopfinformationen tatsaechlich neu gelesen werden + m_pMemoStream->RefreshBuffer(); // make sure that the header information is actually read again m_pMemoStream->Seek(0L); (*m_pMemoStream) >> m_aMemoHeader.db_next; switch (m_aHeader.db_typ) { - case dBaseIIIMemo: // dBase III: feste Blockgroesse + case dBaseIIIMemo: // dBase III: fixed block size case dBaseIVMemo: - // manchmal wird aber auch dBase3 dBase4 Memo zugeordnet + // sometimes dBase3 is attached to dBase4 memo m_pMemoStream->Seek(20L); (*m_pMemoStream) >> m_aMemoHeader.db_size; - if (m_aMemoHeader.db_size > 1 && m_aMemoHeader.db_size != 512) // 1 steht auch fuer dBase 3 + if (m_aMemoHeader.db_size > 1 && m_aMemoHeader.db_size != 512) // 1 is also for dBase 3 m_aMemoHeader.db_typ = MemodBaseIV; else if (m_aMemoHeader.db_size > 1 && m_aMemoHeader.db_size == 512) { - // nun gibt es noch manche Dateien, die verwenden eine Groessenangabe, - // sind aber dennoch dBase Dateien + // There are files using size specification, though they are dBase-files char sHeader[4]; m_pMemoStream->Seek(m_aMemoHeader.db_size); m_pMemoStream->Read(sHeader,4); - if ((m_pMemoStream->GetErrorCode() != ERRCODE_NONE) || ((BYTE)sHeader[0]) != 0xFF || ((BYTE)sHeader[1]) != 0xFF || ((BYTE)sHeader[2]) != 0x08) + if ((m_pMemoStream->GetErrorCode() != ERRCODE_NONE) || ((sal_uInt8)sHeader[0]) != 0xFF || ((sal_uInt8)sHeader[1]) != 0xFF || ((sal_uInt8)sHeader[2]) != 0x08) m_aMemoHeader.db_typ = MemodBaseIII; else m_aMemoHeader.db_typ = MemodBaseIV; @@ -601,10 +600,10 @@ BOOL ODbaseTable::ReadMemoHeader() (*m_pMemoStream) >> m_aMemoHeader.db_size; break; default: - OSL_ENSURE( false, "ODbaseTable::ReadMemoHeader: unsupported memo type!" ); + OSL_FAIL( "ODbaseTable::ReadMemoHeader: unsupported memo type!" ); break; } - return TRUE; + return sal_True; } // ------------------------------------------------------------------------- String ODbaseTable::getEntry(OConnection* _pConnection,const ::rtl::OUString& _sName ) @@ -680,15 +679,15 @@ void ODbaseTable::refreshIndexes() aURL.setExtension(String::CreateFromAscii("inf")); Config aInfFile(aURL.getFSysPath(INetURLObject::FSYS_DETECT)); aInfFile.SetGroup(dBASE_III_GROUP); - USHORT nKeyCnt = aInfFile.GetKeyCount(); + sal_uInt16 nKeyCnt = aInfFile.GetKeyCount(); ByteString aKeyName; ByteString aIndexName; - for (USHORT nKey = 0; nKey < nKeyCnt; nKey++) + for (sal_uInt16 nKey = 0; nKey < nKeyCnt; nKey++) { - // Verweist der Key auf ein Indexfile?... + // Refences the key an index-file? aKeyName = aInfFile.GetKeyName( nKey ); - //...wenn ja, Indexliste der Tabelle hinzufuegen + //...if yes, add the index list of the table if (aKeyName.Copy(0,3) == ByteString("NDX") ) { aIndexName = aInfFile.ReadKey(aKeyName); @@ -786,26 +785,26 @@ sal_Int64 ODbaseTable::getSomething( const Sequence< sal_Int8 > & rId ) throw (R sal_Bool ODbaseTable::fetchRow(OValueRefRow& _rRow,const OSQLColumns & _rCols, sal_Bool _bUseTableDefs,sal_Bool bRetrieveData) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::fetchRow" ); - // Einlesen der Daten - BOOL bIsCurRecordDeleted = ((char)m_pBuffer[0] == '*') ? TRUE : sal_False; + // Read the data + bool bIsCurRecordDeleted = (char)m_pBuffer[0] == '*'; // only read the bookmark - // Satz als geloescht markieren + // Mark record as deleted _rRow->setDeleted(bIsCurRecordDeleted); *(_rRow->get())[0] = m_nFilePos; if (!bRetrieveData) - return TRUE; + return sal_True; sal_Size nByteOffset = 1; - // Felder: + // Fields: OSQLColumns::Vector::const_iterator aIter = _rCols.get().begin(); OSQLColumns::Vector::const_iterator aEnd = _rCols.get().end(); const sal_Size nCount = _rRow->get().size(); for (sal_Size i = 1; aIter != aEnd && nByteOffset <= m_nBufferSize && i < nCount;++aIter, i++) { - // Laengen je nach Datentyp: + // Lengths depending on data type: sal_Int32 nLen = 0; sal_Int32 nType = 0; if(_bUseTableDefs) @@ -834,7 +833,7 @@ sal_Bool ODbaseTable::fetchRow(OValueRefRow& _rRow,const OSQLColumns & _rCols, s nLen = SvDbaseConverter::ConvertPrecisionToDbase(nLen,m_aScales[i-1]); else nLen = SvDbaseConverter::ConvertPrecisionToDbase(nLen,getINT32((*aIter)->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)))); - break; // das Vorzeichen und das Komma + break; // the sign and the comma case DataType::BINARY: case DataType::OTHER: @@ -842,10 +841,10 @@ sal_Bool ODbaseTable::fetchRow(OValueRefRow& _rRow,const OSQLColumns & _rCols, s continue; } - // Ist die Variable ueberhaupt gebunden? + // Is the variable bound? if ( !(_rRow->get())[i]->isBound() ) { - // Nein - naechstes Feld. + // No - next field. nByteOffset += nLen; OSL_ENSURE( nByteOffset <= m_nBufferSize ,"ByteOffset > m_nBufferSize!"); continue; @@ -900,7 +899,7 @@ sal_Bool ODbaseTable::fetchRow(OValueRefRow& _rRow,const OSQLColumns & _rCols, s else if ( DataType::DOUBLE == nType ) { double d = 0.0; - if (getBOOL((*aIter)->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)))) // Currency wird gesondert behandelt + if (getBOOL((*aIter)->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)))) // Currency is treated separately { sal_Int64 nValue = 0; memcpy(&nValue, pData, nLen); @@ -920,7 +919,7 @@ sal_Bool ODbaseTable::fetchRow(OValueRefRow& _rRow,const OSQLColumns & _rCols, s else { sal_Int32 nPos1 = -1, nPos2 = -1; - // Falls Nul-Zeichen im String enthalten sind, in Blanks umwandeln! + // If the string contains Nul-characters, then convert them to blanks! for (sal_Int32 k = 0; k < nLen; k++) { if (pData[k] == '\0') @@ -941,7 +940,7 @@ sal_Bool ODbaseTable::fetchRow(OValueRefRow& _rRow,const OSQLColumns & _rCols, s { // Empty string. Skip it. nByteOffset += nLen; - (_rRow->get())[i]->setNull(); // keine Werte -> fertig + (_rRow->get())[i]->setNull(); // no values -> done continue; } @@ -969,13 +968,13 @@ sal_Bool ODbaseTable::fetchRow(OValueRefRow& _rRow,const OSQLColumns & _rCols, s break; case DataType::BIT: { - BOOL b; + sal_Bool b; switch (* ((const char *)pData)) { case 'T': case 'Y': - case 'J': b = TRUE; break; - default: b = FALSE; break; + case 'J': b = sal_True; break; + default: b = sal_False; break; } *(_rRow->get())[i] = b; } @@ -984,8 +983,8 @@ sal_Bool ODbaseTable::fetchRow(OValueRefRow& _rRow,const OSQLColumns & _rCols, s case DataType::BINARY: case DataType::LONGVARCHAR: { - const long nBlockNo = aStr.toInt32(); // Blocknummer lesen - if (nBlockNo > 0 && m_pMemoStream) // Daten aus Memo-Datei lesen, nur wenn + const long nBlockNo = aStr.toInt32(); // read blocknumber + if (nBlockNo > 0 && m_pMemoStream) // Read data from memo-file, only if { if ( !ReadMemo(nBlockNo, (_rRow->get())[i]->get()) ) break; @@ -994,7 +993,7 @@ sal_Bool ODbaseTable::fetchRow(OValueRefRow& _rRow,const OSQLColumns & _rCols, s (_rRow->get())[i]->setNull(); } break; default: - OSL_ASSERT("Falscher Type"); + OSL_FAIL("Falscher Type"); } (_rRow->get())[i]->setTypeKind(nType); } @@ -1010,7 +1009,7 @@ void ODbaseTable::FileClose() { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::FileClose" ); ::osl::MutexGuard aGuard(m_aMutex); - // falls noch nicht alles geschrieben wurde + // if not everything has been written yet if (m_pMemoStream && m_pMemoStream->IsWritable()) m_pMemoStream->Flush(); @@ -1020,7 +1019,7 @@ void ODbaseTable::FileClose() ODbaseTable_BASE::FileClose(); } // ------------------------------------------------------------------------- -BOOL ODbaseTable::CreateImpl() +sal_Bool ODbaseTable::CreateImpl() { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::CreateImpl" ); OSL_ENSURE(!m_pFileStream, "SequenceError"); @@ -1041,7 +1040,7 @@ BOOL ODbaseTable::CreateImpl() { ::rtl::OUString aIdent = m_pConnection->getContent()->getIdentifier()->getContentIdentifier(); if ( aIdent.lastIndexOf('/') != (aIdent.getLength()-1) ) - aIdent += ::rtl::OUString::createFromAscii("/"); + aIdent += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")); aIdent += m_Name; aName = aIdent.getStr(); } @@ -1055,7 +1054,7 @@ BOOL ODbaseTable::CreateImpl() Content aContent(aURL.GetMainURL(INetURLObject::NO_DECODE),Reference<XCommandEnvironment>()); if (aContent.isDocument()) { - // Hack fuer Bug #30609 , nur wenn das File existiert und die Laenge > 0 gibt es einen Fehler + // Only if the file exists with length > 0 raise an error SvStream* pFileStream = createStream_simpleError( aURL.GetMainURL(INetURLObject::NO_DECODE),STREAM_READ); if (pFileStream && pFileStream->Seek(STREAM_SEEK_TO_END)) @@ -1069,7 +1068,7 @@ BOOL ODbaseTable::CreateImpl() { } - BOOL bMemoFile = sal_False; + sal_Bool bMemoFile = sal_False; sal_Bool bOk = CreateFile(aURL, bMemoFile); @@ -1080,7 +1079,7 @@ BOOL ODbaseTable::CreateImpl() try { Content aContent(aURL.GetMainURL(INetURLObject::NO_DECODE),Reference<XCommandEnvironment>()); - aContent.executeCommand( rtl::OUString::createFromAscii( "delete" ),bool2any( sal_True ) ); + aContent.executeCommand( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("delete")),bool2any( sal_True ) ); } catch(Exception&) // an exception is thrown when no file exists { @@ -1108,7 +1107,7 @@ BOOL ODbaseTable::CreateImpl() try { Content aMemoContent(aURL.GetMainURL(INetURLObject::NO_DECODE),Reference<XCommandEnvironment>()); - aMemoContent.executeCommand( rtl::OUString::createFromAscii( "delete" ),bool2any( sal_True ) ); + aMemoContent.executeCommand( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("delete")),bool2any( sal_True ) ); } catch(const Exception&) { @@ -1124,7 +1123,7 @@ BOOL ODbaseTable::CreateImpl() { aURL.setExtension(aExt); // kill dbf file Content aMemoContent(aURL.GetMainURL(INetURLObject::NO_DECODE),Reference<XCommandEnvironment>()); - aMemoContent.executeCommand( rtl::OUString::createFromAscii( "delete" ),bool2any( sal_True ) ); + aMemoContent.executeCommand( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("delete")),bool2any( sal_True ) ); return sal_False; } m_aHeader.db_typ = dBaseIIIMemo; @@ -1132,7 +1131,7 @@ BOOL ODbaseTable::CreateImpl() else m_aHeader.db_typ = dBaseIII; - return TRUE; + return sal_True; } // ----------------------------------------------------------------------------- void ODbaseTable::throwInvalidColumnType(const sal_uInt16 _nErrorId,const ::rtl::OUString& _sColumnName) @@ -1154,19 +1153,19 @@ void ODbaseTable::throwInvalidColumnType(const sal_uInt16 _nErrorId,const ::rtl: ::dbtools::throwGenericSQLException( sError, *this ); } //------------------------------------------------------------------ -// erzeugt grundsaetzlich dBase IV Datei Format -BOOL ODbaseTable::CreateFile(const INetURLObject& aFile, BOOL& bCreateMemo) +// creates in principle dBase IV file format +sal_Bool ODbaseTable::CreateFile(const INetURLObject& aFile, sal_Bool& bCreateMemo) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::CreateFile" ); bCreateMemo = sal_False; - Date aDate; // aktuelles Datum + Date aDate; // current date m_pFileStream = createStream_simpleError( aFile.GetMainURL(INetURLObject::NO_DECODE),STREAM_READWRITE | STREAM_SHARE_DENYWRITE | STREAM_TRUNC ); if (!m_pFileStream) return sal_False; - BYTE nDbaseType = dBaseIII; + sal_uInt8 nDbaseType = dBaseIII; Reference<XIndexAccess> xColumns(getColumns(),UNO_QUERY); Reference<XPropertySet> xCol; const ::rtl::OUString sPropType = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE); @@ -1208,19 +1207,19 @@ BOOL ODbaseTable::CreateFile(const INetURLObject& aFile, BOOL& bCreateMemo) memset(aBuffer,0,sizeof(aBuffer)); m_pFileStream->Seek(0L); - (*m_pFileStream) << (BYTE) nDbaseType; // dBase format - (*m_pFileStream) << (BYTE) (aDate.GetYear() % 100); // aktuelles Datum + (*m_pFileStream) << (sal_uInt8) nDbaseType; // dBase format + (*m_pFileStream) << (sal_uInt8) (aDate.GetYear() % 100); // current date - (*m_pFileStream) << (BYTE) aDate.GetMonth(); - (*m_pFileStream) << (BYTE) aDate.GetDay(); - (*m_pFileStream) << 0L; // Anzahl der Datensaetze - (*m_pFileStream) << (USHORT)((m_pColumns->getCount()+1) * 32 + 1); // Kopfinformationen, - // pColumns erhaelt immer eine Spalte mehr - (*m_pFileStream) << (USHORT) 0; // Satzlaenge wird spaeter bestimmt + (*m_pFileStream) << (sal_uInt8) aDate.GetMonth(); + (*m_pFileStream) << (sal_uInt8) aDate.GetDay(); + (*m_pFileStream) << 0L; // number of data records + (*m_pFileStream) << (sal_uInt16)((m_pColumns->getCount()+1) * 32 + 1); // header information, + // pColumns contains always an additional column + (*m_pFileStream) << (sal_uInt16) 0; // record length will be determined later m_pFileStream->Write(aBuffer, 20); - USHORT nRecLength = 1; // Laenge 1 fuer deleted flag + sal_uInt16 nRecLength = 1; // Length 1 for deleted flag sal_Int32 nMaxFieldLength = m_pConnection->getMetaData()->getMaxColumnNameLength(); ::rtl::OUString aName; const ::rtl::OUString sPropName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME); @@ -1262,7 +1261,7 @@ BOOL ODbaseTable::CreateFile(const INetURLObject& aFile, BOOL& bCreateMemo) cTyp = 'C'; break; case DataType::DOUBLE: - if (getBOOL(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)))) // Currency wird gesondert behandelt + if (getBOOL(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)))) // Currency will be treated separately cTyp = 'Y'; else cTyp = 'B'; @@ -1276,7 +1275,7 @@ BOOL ODbaseTable::CreateFile(const INetURLObject& aFile, BOOL& bCreateMemo) case DataType::DECIMAL: case DataType::NUMERIC: case DataType::REAL: - cTyp = 'N'; // nur dBase 3 format + cTyp = 'N'; // only dBase 3 format break; case DataType::TIMESTAMP: cTyp = 'T'; @@ -1313,9 +1312,9 @@ BOOL ODbaseTable::CreateFile(const INetURLObject& aFile, BOOL& bCreateMemo) { throwInvalidColumnType(STR_INVALID_COLUMN_PRECISION, aName); } - (*m_pFileStream) << (BYTE) Min((ULONG)nPrecision, 255UL); //Feldlaenge - nRecLength = nRecLength + (USHORT)::std::min((USHORT)nPrecision, (USHORT)255UL); - (*m_pFileStream) << (BYTE)0; //Nachkommastellen + (*m_pFileStream) << (sal_uInt8) Min((unsigned)nPrecision, 255U); // field length + nRecLength = nRecLength + (sal_uInt16)::std::min((sal_uInt16)nPrecision, (sal_uInt16)255UL); + (*m_pFileStream) << (sal_uInt8)0; // decimals break; case 'F': case 'N': @@ -1325,43 +1324,43 @@ BOOL ODbaseTable::CreateFile(const INetURLObject& aFile, BOOL& bCreateMemo) { throwInvalidColumnType(STR_INVALID_PRECISION_SCALE, aName); } - if (getBOOL(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)))) // Currency wird gesondert behandelt + if (getBOOL(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)))) // Currency will be treated separately { - (*m_pFileStream) << (BYTE)10; // Standard Laenge - (*m_pFileStream) << (BYTE)4; + (*m_pFileStream) << (sal_uInt8)10; // standard length + (*m_pFileStream) << (sal_uInt8)4; nRecLength += 10; } else { sal_Int32 nPrec = SvDbaseConverter::ConvertPrecisionToDbase(nPrecision,nScale); - (*m_pFileStream) << (BYTE)( nPrec); - (*m_pFileStream) << (BYTE)nScale; - nRecLength += (USHORT)nPrec; + (*m_pFileStream) << (sal_uInt8)( nPrec); + (*m_pFileStream) << (sal_uInt8)nScale; + nRecLength += (sal_uInt16)nPrec; } break; case 'L': - (*m_pFileStream) << (BYTE)1; - (*m_pFileStream) << (BYTE)0; + (*m_pFileStream) << (sal_uInt8)1; + (*m_pFileStream) << (sal_uInt8)0; ++nRecLength; break; case 'I': - (*m_pFileStream) << (BYTE)4; - (*m_pFileStream) << (BYTE)0; + (*m_pFileStream) << (sal_uInt8)4; + (*m_pFileStream) << (sal_uInt8)0; nRecLength += 4; break; case 'Y': case 'B': case 'T': case 'D': - (*m_pFileStream) << (BYTE)8; - (*m_pFileStream) << (BYTE)0; + (*m_pFileStream) << (sal_uInt8)8; + (*m_pFileStream) << (sal_uInt8)0; nRecLength += 8; break; case 'M': - bCreateMemo = TRUE; - (*m_pFileStream) << (BYTE)10; - (*m_pFileStream) << (BYTE)0; + bCreateMemo = sal_True; + (*m_pFileStream) << (sal_uInt8)10; + (*m_pFileStream) << (sal_uInt8)0; nRecLength += 10; if ( bBinary ) aBuffer[0] = 0x06; @@ -1373,18 +1372,18 @@ BOOL ODbaseTable::CreateFile(const INetURLObject& aFile, BOOL& bCreateMemo) aBuffer[0] = 0x00; } - (*m_pFileStream) << (BYTE)FIELD_DESCRIPTOR_TERMINATOR; // kopf ende + (*m_pFileStream) << (sal_uInt8)FIELD_DESCRIPTOR_TERMINATOR; // end of header (*m_pFileStream) << (char)DBF_EOL; m_pFileStream->Seek(10L); - (*m_pFileStream) << nRecLength; // Satzlaenge nachtraeglich eintragen + (*m_pFileStream) << nRecLength; // set record length afterwards if (bCreateMemo) { m_pFileStream->Seek(0L); if (nDbaseType == VisualFoxPro) - (*m_pFileStream) << (BYTE) FoxProMemo; + (*m_pFileStream) << (sal_uInt8) FoxProMemo; else - (*m_pFileStream) << (BYTE) dBaseIIIMemo; + (*m_pFileStream) << (sal_uInt8) dBaseIIIMemo; } // if (bCreateMemo) } catch ( const Exception& e ) @@ -1399,15 +1398,15 @@ BOOL ODbaseTable::CreateFile(const INetURLObject& aFile, BOOL& bCreateMemo) catch(const Exception&) { } throw; } - return TRUE; + return sal_True; } //------------------------------------------------------------------ -// erzeugt grundsaetzlich dBase III Datei Format -BOOL ODbaseTable::CreateMemoFile(const INetURLObject& aFile) +// creates in principle dBase III file format +sal_Bool ODbaseTable::CreateMemoFile(const INetURLObject& aFile) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::CreateMemoFile" ); - // Makro zum Filehandling fuers Erzeugen von Tabellen + // filehandling macro for table creation m_pMemoStream = createStream_simpleError( aFile.GetMainURL(INetURLObject::NO_DECODE),STREAM_READWRITE | STREAM_SHARE_DENYWRITE); if (!m_pMemoStream) @@ -1416,33 +1415,25 @@ BOOL ODbaseTable::CreateMemoFile(const INetURLObject& aFile) char aBuffer[512]; // write buffer memset(aBuffer,0,sizeof(aBuffer)); -#ifdef WIN - m_pMemoStream->Seek(0L); - for (UINT16 i = 0; i < 512; i++) - { - (*m_pMemoStream) << BYTE(0); - } -#else m_pMemoStream->SetFiller('\0'); m_pMemoStream->SetStreamSize(512); -#endif m_pMemoStream->Seek(0L); - (*m_pMemoStream) << long(1); // Zeiger auf ersten freien Block + (*m_pMemoStream) << long(1); // pointer to the first free block m_pMemoStream->Flush(); delete m_pMemoStream; m_pMemoStream = NULL; - return TRUE; + return sal_True; } //------------------------------------------------------------------ -BOOL ODbaseTable::Drop_Static(const ::rtl::OUString& _sUrl,sal_Bool _bHasMemoFields,OCollection* _pIndexes ) +sal_Bool ODbaseTable::Drop_Static(const ::rtl::OUString& _sUrl,sal_Bool _bHasMemoFields,OCollection* _pIndexes ) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::Drop_Static" ); INetURLObject aURL; aURL.SetURL(_sUrl); - BOOL bDropped = ::utl::UCBContentHelper::Kill(aURL.GetMainURL(INetURLObject::NO_DECODE)); + sal_Bool bDropped = ::utl::UCBContentHelper::Kill(aURL.GetMainURL(INetURLObject::NO_DECODE)); if(bDropped) { @@ -1471,11 +1462,10 @@ BOOL ODbaseTable::Drop_Static(const ::rtl::OUString& _sUrl,sal_Bool _bHasMemoFie aURL.setExtension(String::CreateFromAscii("inf")); // as the inf file does not necessarily exist, we aren't allowed to use UCBContentHelper::Kill - // 89711 - 16.07.2001 - frank.schoenheit@sun.com try { ::ucbhelper::Content aDeleteContent( aURL.GetMainURL( INetURLObject::NO_DECODE ), Reference< XCommandEnvironment > () ); - aDeleteContent.executeCommand( ::rtl::OUString::createFromAscii( "delete" ), makeAny( sal_Bool( sal_True ) ) ); + aDeleteContent.executeCommand( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("delete")), makeAny( sal_Bool( sal_True ) ) ); } catch(Exception&) { @@ -1486,7 +1476,7 @@ BOOL ODbaseTable::Drop_Static(const ::rtl::OUString& _sUrl,sal_Bool _bHasMemoFie return bDropped; } // ----------------------------------------------------------------------------- -BOOL ODbaseTable::DropImpl() +sal_Bool ODbaseTable::DropImpl() { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::DropImpl" ); FileClose(); @@ -1494,7 +1484,7 @@ BOOL ODbaseTable::DropImpl() if(!m_pIndexes) refreshIndexes(); // look for indexes which must be deleted as well - BOOL bDropped = Drop_Static(getEntry(m_pConnection,m_Name),HasMemoFields(),m_pIndexes); + sal_Bool bDropped = Drop_Static(getEntry(m_pConnection,m_Name),HasMemoFields(),m_pIndexes); if(!bDropped) {// we couldn't drop the table so we have to reopen it construct(); @@ -1505,24 +1495,24 @@ BOOL ODbaseTable::DropImpl() } //------------------------------------------------------------------ -BOOL ODbaseTable::InsertRow(OValueRefVector& rRow, BOOL bFlush,const Reference<XIndexAccess>& _xCols) +sal_Bool ODbaseTable::InsertRow(OValueRefVector& rRow, sal_Bool bFlush,const Reference<XIndexAccess>& _xCols) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::InsertRow" ); - // Buffer mit Leerzeichen fuellen + // fill buffer with blanks AllocBuffer(); memset(m_pBuffer, 0, m_aHeader.db_slng); m_pBuffer[0] = ' '; - // Gesamte neue Row uebernehmen: - // ... und am Ende als neuen Record hinzufuegen: - UINT32 nTempPos = m_nFilePos, - nFileSize = 0, - nMemoFileSize = 0; + // Copy new row completely: + // ... and add at the end as new Record: + sal_uInt32 nTempPos = m_nFilePos; - m_nFilePos = (ULONG)m_aHeader.db_anz + 1; - BOOL bInsertRow = UpdateBuffer( rRow, NULL, _xCols ); + m_nFilePos = (sal_uIntPtr)m_aHeader.db_anz + 1; + sal_Bool bInsertRow = UpdateBuffer( rRow, NULL, _xCols ); if ( bInsertRow ) { + sal_uInt32 nFileSize = 0, nMemoFileSize = 0; + nFileSize = lcl_getFileSize(*m_pFileStream); if (HasMemoFields() && m_pMemoStream) @@ -1533,26 +1523,26 @@ BOOL ODbaseTable::InsertRow(OValueRefVector& rRow, BOOL bFlush,const Reference<X if (!WriteBuffer()) { - m_pFileStream->SetStreamSize(nFileSize); // alte Groesse restaurieren + m_pFileStream->SetStreamSize(nFileSize); // restore old size if (HasMemoFields() && m_pMemoStream) - m_pMemoStream->SetStreamSize(nMemoFileSize); // alte Groesse restaurieren - m_nFilePos = nTempPos; // Fileposition restaurieren + m_pMemoStream->SetStreamSize(nMemoFileSize); // restore old size + m_nFilePos = nTempPos; // restore file position } else { (*m_pFileStream) << (char)DBF_EOL; // write EOL - // Anzahl Datensaetze im Header erhoehen: + // raise number of datasets in the header: m_pFileStream->Seek( 4L ); (*m_pFileStream) << (m_aHeader.db_anz + 1); - // beim AppendOnly kein Flush! + // if AppendOnly no flush! if (bFlush) m_pFileStream->Flush(); - // bei Erfolg # erhoehen + // raise number if successfully m_aHeader.db_anz++; - *rRow.get()[0] = m_nFilePos; // BOOKmark setzen + *rRow.get()[0] = m_nFilePos; // set bookmark m_nFilePos = nTempPos; } } @@ -1563,18 +1553,18 @@ BOOL ODbaseTable::InsertRow(OValueRefVector& rRow, BOOL bFlush,const Reference<X } //------------------------------------------------------------------ -BOOL ODbaseTable::UpdateRow(OValueRefVector& rRow, OValueRefRow& pOrgRow,const Reference<XIndexAccess>& _xCols) +sal_Bool ODbaseTable::UpdateRow(OValueRefVector& rRow, OValueRefRow& pOrgRow,const Reference<XIndexAccess>& _xCols) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::UpdateRow" ); - // Buffer mit Leerzeichen fuellen + // fill buffer with blanks AllocBuffer(); - // Auf gewuenschten Record positionieren: + // position on desired record: long nPos = m_aHeader.db_kopf + (long)(m_nFilePos-1) * m_aHeader.db_slng; m_pFileStream->Seek(nPos); m_pFileStream->Read((char*)m_pBuffer, m_aHeader.db_slng); - UINT32 nMemoFileSize( 0 ); + sal_uInt32 nMemoFileSize( 0 ); if (HasMemoFields() && m_pMemoStream) { m_pMemoStream->Seek(STREAM_SEEK_TO_END); @@ -1583,7 +1573,7 @@ BOOL ODbaseTable::UpdateRow(OValueRefVector& rRow, OValueRefRow& pOrgRow,const R if (!UpdateBuffer(rRow, pOrgRow,_xCols) || !WriteBuffer()) { if (HasMemoFields() && m_pMemoStream) - m_pMemoStream->SetStreamSize(nMemoFileSize); // alte Groesse restaurieren + m_pMemoStream->SetStreamSize(nMemoFileSize); // restore old size } else { @@ -1593,24 +1583,23 @@ BOOL ODbaseTable::UpdateRow(OValueRefVector& rRow, OValueRefRow& pOrgRow,const R } //------------------------------------------------------------------ -BOOL ODbaseTable::DeleteRow(const OSQLColumns& _rCols) +sal_Bool ODbaseTable::DeleteRow(const OSQLColumns& _rCols) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::DeleteRow" ); - // Einfach das Loesch-Flag setzen (egal, ob es schon gesetzt war - // oder nicht): - // Auf gewuenschten Record positionieren: + // Set the Delete-Flag (be it set or not): + // Position on desired record: long nFilePos = m_aHeader.db_kopf + (long)(m_nFilePos-1) * m_aHeader.db_slng; m_pFileStream->Seek(nFilePos); OValueRefRow aRow = new OValueRefVector(_rCols.get().size()); - if (!fetchRow(aRow,_rCols,TRUE,TRUE)) + if (!fetchRow(aRow,_rCols,sal_True,sal_True)) return sal_False; Reference<XPropertySet> xCol; ::rtl::OUString aColName; ::comphelper::UStringMixEqual aCase(isCaseSensitive()); - for (USHORT i = 0; i < m_pColumns->getCount(); i++) + for (sal_uInt16 i = 0; i < m_pColumns->getCount(); i++) { Reference<XPropertySet> xIndex = isUniqueByColumnName(i); if (xIndex.is()) @@ -1642,7 +1631,7 @@ BOOL ODbaseTable::DeleteRow(const OSQLColumns& _rCols) } m_pFileStream->Seek(nFilePos); - (*m_pFileStream) << (BYTE)'*'; // mark the row in the table as deleted + (*m_pFileStream) << (sal_uInt8)'*'; // mark the row in the table as deleted m_pFileStream->Flush(); return sal_True; } @@ -1682,18 +1671,18 @@ double toDouble(const ByteString& rString) } //------------------------------------------------------------------ -BOOL ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,const Reference<XIndexAccess>& _xCols) +sal_Bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,const Reference<XIndexAccess>& _xCols) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::UpdateBuffer" ); OSL_ENSURE(m_pBuffer,"Buffer is NULL!"); if ( !m_pBuffer ) - return FALSE; + return sal_False; sal_Int32 nByteOffset = 1; - // Felder aktualisieren: + // Update fields: Reference<XPropertySet> xCol; Reference<XPropertySet> xIndex; - USHORT i; + sal_uInt16 i; ::rtl::OUString aColName; const sal_Int32 nColumnCount = m_pColumns->getCount(); ::std::vector< Reference<XPropertySet> > aIndexedCols(nColumnCount); @@ -1740,7 +1729,7 @@ BOOL ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,const if (pIndex->Find(0,*rRow.get()[nPos])) { - // es existiert kein eindeutiger Wert + // There is no unique value if ( !aColName.getLength() ) { m_pColumns->getByIndex(i) >>= xCol; @@ -1902,7 +1891,7 @@ BOOL ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,const const double d = rRow.get()[nPos]->getValue(); m_pColumns->getByIndex(i) >>= xCol; - if (getBOOL(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)))) // Currency wird gesondert behandelt + if (getBOOL(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)))) // Currency is treated separately { sal_Int64 nValue = 0; if ( m_aScales[i] ) @@ -1910,7 +1899,7 @@ BOOL ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,const else nValue = (sal_Int64)(d); memcpy(pData,&nValue,nLen); - } // if (getBOOL(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)))) // Currency wird gesondert behandelt + } // if (getBOOL(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)))) // Currency is treated separately else memcpy(pData,&d,nLen); } @@ -1959,7 +1948,7 @@ BOOL ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,const char cNext = pData[nLen]; // Mark's scratch and replaced by 0 pData[nLen] = '\0'; // This is because the buffer is always a sign of greater ... - ULONG nBlockNo = strtol((const char *)pData,NULL,10); // Block number read + sal_uIntPtr nBlockNo = strtol((const char *)pData,NULL,10); // Block number read // Next initial character restore again: pData[nLen] = cNext; @@ -2015,14 +2004,14 @@ BOOL ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,const } // ----------------------------------------------------------------------------- -BOOL ODbaseTable::WriteMemo(ORowSetValue& aVariable, ULONG& rBlockNr) +sal_Bool ODbaseTable::WriteMemo(ORowSetValue& aVariable, sal_uIntPtr& rBlockNr) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::WriteMemo" ); - // wird die BlockNr 0 vorgegeben, wird der block ans Ende gehaengt - ULONG nSize = 0; + // if the BlockNo 0 is given, the block will be appended at the end + sal_uIntPtr nSize = 0; ::rtl::OString aStr; ::com::sun::star::uno::Sequence<sal_Int8> aValue; - BYTE nHeader[4]; + sal_uInt8 nHeader[4]; const bool bBinary = aVariable.getTypeKind() == DataType::LONGVARBINARY && m_aMemoHeader.db_typ == MemoFoxPro; if ( bBinary ) { @@ -2034,25 +2023,25 @@ BOOL ODbaseTable::WriteMemo(ORowSetValue& aVariable, ULONG& rBlockNr) nSize = DBTypeConversion::convertUnicodeString( aVariable.getString(), aStr, m_eEncoding ); } - // Anhaengen oder ueberschreiben - BOOL bAppend = rBlockNr == 0; + // append or overwrite + sal_Bool bAppend = rBlockNr == 0; if (!bAppend) { switch (m_aMemoHeader.db_typ) { - case MemodBaseIII: // dBase III-Memofeld, endet mit 2 * Ctrl-Z + case MemodBaseIII: // dBase III-Memofield, ends with 2 * Ctrl-Z bAppend = nSize > (512 - 2); break; case MemoFoxPro: - case MemodBaseIV: // dBase IV-Memofeld mit Laengenangabe + case MemodBaseIV: // dBase IV-Memofield with length { char sHeader[4]; m_pMemoStream->Seek(rBlockNr * m_aMemoHeader.db_size); m_pMemoStream->SeekRel(4L); m_pMemoStream->Read(sHeader,4); - ULONG nOldSize; + sal_uIntPtr nOldSize; if (m_aMemoHeader.db_typ == MemoFoxPro) nOldSize = ((((unsigned char)sHeader[0]) * 256 + (unsigned char)sHeader[1]) * 256 + @@ -2064,8 +2053,8 @@ BOOL ODbaseTable::WriteMemo(ORowSetValue& aVariable, ULONG& rBlockNr) (unsigned char)sHeader[1]) * 256 + (unsigned char)sHeader[0] - 8; - // passt die neue Laenge in die belegten Bloecke - ULONG nUsedBlocks = ((nSize + 8) / m_aMemoHeader.db_size) + (((nSize + 8) % m_aMemoHeader.db_size > 0) ? 1 : 0), + // fits the new length in the used blocks + sal_uIntPtr nUsedBlocks = ((nSize + 8) / m_aMemoHeader.db_size) + (((nSize + 8) % m_aMemoHeader.db_size > 0) ? 1 : 0), nOldUsedBlocks = ((nOldSize + 8) / m_aMemoHeader.db_size) + (((nOldSize + 8) % m_aMemoHeader.db_size > 0) ? 1 : 0); bAppend = nUsedBlocks > nOldUsedBlocks; } @@ -2074,8 +2063,8 @@ BOOL ODbaseTable::WriteMemo(ORowSetValue& aVariable, ULONG& rBlockNr) if (bAppend) { - ULONG nStreamSize = m_pMemoStream->Seek(STREAM_SEEK_TO_END); - // letzten block auffuellen + sal_uIntPtr nStreamSize = m_pMemoStream->Seek(STREAM_SEEK_TO_END); + // fill last block rBlockNr = (nStreamSize / m_aMemoHeader.db_size) + ((nStreamSize % m_aMemoHeader.db_size) > 0 ? 1 : 0); m_pMemoStream->SetStreamSize(rBlockNr * m_aMemoHeader.db_size); @@ -2088,7 +2077,7 @@ BOOL ODbaseTable::WriteMemo(ORowSetValue& aVariable, ULONG& rBlockNr) switch (m_aMemoHeader.db_typ) { - case MemodBaseIII: // dBase III-Memofeld, endet mit Ctrl-Z + case MemodBaseIII: // dBase III-Memofield, ends with Ctrl-Z { const char cEOF = (char) DBF_EOL; nSize++; @@ -2096,33 +2085,33 @@ BOOL ODbaseTable::WriteMemo(ORowSetValue& aVariable, ULONG& rBlockNr) (*m_pMemoStream) << cEOF << cEOF; } break; case MemoFoxPro: - case MemodBaseIV: // dBase IV-Memofeld mit Laengenangabe + case MemodBaseIV: // dBase IV-Memofeld with length { if ( MemodBaseIV == m_aMemoHeader.db_typ ) - (*m_pMemoStream) << (BYTE)0xFF - << (BYTE)0xFF - << (BYTE)0x08; + (*m_pMemoStream) << (sal_uInt8)0xFF + << (sal_uInt8)0xFF + << (sal_uInt8)0x08; else - (*m_pMemoStream) << (BYTE)0x00 - << (BYTE)0x00 - << (BYTE)0x00; + (*m_pMemoStream) << (sal_uInt8)0x00 + << (sal_uInt8)0x00 + << (sal_uInt8)0x00; - UINT32 nWriteSize = nSize; + sal_uInt32 nWriteSize = nSize; if (m_aMemoHeader.db_typ == MemoFoxPro) { if ( bBinary ) - (*m_pMemoStream) << (BYTE) 0x00; // Picture + (*m_pMemoStream) << (sal_uInt8) 0x00; // Picture else - (*m_pMemoStream) << (BYTE) 0x01; // Memo + (*m_pMemoStream) << (sal_uInt8) 0x01; // Memo for (int i = 4; i > 0; nWriteSize >>= 8) - nHeader[--i] = (BYTE) (nWriteSize % 256); + nHeader[--i] = (sal_uInt8) (nWriteSize % 256); } else { - (*m_pMemoStream) << (BYTE) 0x00; + (*m_pMemoStream) << (sal_uInt8) 0x00; nWriteSize += 8; for (int i = 0; i < 4; nWriteSize >>= 8) - nHeader[i++] = (BYTE) (nWriteSize % 256); + nHeader[i++] = (sal_uInt8) (nWriteSize % 256); } m_pMemoStream->Write(nHeader,4); @@ -2135,13 +2124,13 @@ BOOL ODbaseTable::WriteMemo(ORowSetValue& aVariable, ULONG& rBlockNr) } - // Schreiben der neuen Blocknummer + // Write the new block number if (bAppend) { - ULONG nStreamSize = m_pMemoStream->Seek(STREAM_SEEK_TO_END); + sal_uIntPtr nStreamSize = m_pMemoStream->Seek(STREAM_SEEK_TO_END); m_aMemoHeader.db_next = (nStreamSize / m_aMemoHeader.db_size) + ((nStreamSize % m_aMemoHeader.db_size) > 0 ? 1 : 0); - // Schreiben der neuen Blocknummer + // Write the new block number m_pMemoStream->Seek(0L); (*m_pMemoStream) << m_aMemoHeader.db_next; m_pMemoStream->Flush(); @@ -2195,7 +2184,7 @@ void ODbaseTable::alterColumn(sal_Int32 index, if(xOldColumn.is()) xCopyColumn = xOldColumn->createDataDescriptor(); else - xCopyColumn = new OColumn(getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers()); + xCopyColumn = new OColumn(getConnection()->getMetaData()->supportsMixedCaseQuotedIdentifiers()); ::comphelper::copyProperties(descriptor,xCopyColumn); @@ -2220,7 +2209,7 @@ void ODbaseTable::alterColumn(sal_Int32 index, if(xColumn.is()) xCpy = xColumn->createDataDescriptor(); else - xCpy = new OColumn(getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers()); + xCpy = new OColumn(getConnection()->getMetaData()->supportsMixedCaseQuotedIdentifiers()); ::comphelper::copyProperties(xProp,xCpy); xAppend->appendByDescriptor(xCpy); } @@ -2236,7 +2225,7 @@ void ODbaseTable::alterColumn(sal_Int32 index, if(xColumn.is()) xCpy = xColumn->createDataDescriptor(); else - xCpy = new OColumn(getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers()); + xCpy = new OColumn(getConnection()->getMetaData()->supportsMixedCaseQuotedIdentifiers()); ::comphelper::copyProperties(xProp,xCpy); xAppend->appendByDescriptor(xCpy); } @@ -2281,7 +2270,7 @@ void ODbaseTable::alterColumn(sal_Int32 index, } catch(const Exception&) { - OSL_ENSURE(0,"ODbaseTable::alterColumn: Exception occured!"); + OSL_FAIL("ODbaseTable::alterColumn: Exception occurred!"); throw; } } @@ -2319,7 +2308,7 @@ namespace { ::rtl::OUString aIdent = _pConenction->getContent()->getIdentifier()->getContentIdentifier(); if ( aIdent.lastIndexOf('/') != (aIdent.getLength()-1) ) - aIdent += ::rtl::OUString::createFromAscii("/"); + aIdent += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")); aIdent += oldName; aName = aIdent; } @@ -2336,11 +2325,11 @@ namespace Content aContent(aURL.GetMainURL(INetURLObject::NO_DECODE),Reference<XCommandEnvironment>()); Sequence< PropertyValue > aProps( 1 ); - aProps[0].Name = ::rtl::OUString::createFromAscii("Title"); + aProps[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Title")); aProps[0].Handle = -1; // n/a aProps[0].Value = makeAny( ::rtl::OUString(sNewName) ); Sequence< Any > aValues; - aContent.executeCommand( rtl::OUString::createFromAscii( "setPropertyValues" ),makeAny(aProps) ) >>= aValues; + aContent.executeCommand( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("setPropertyValues")),makeAny(aProps) ) >>= aValues; if(aValues.getLength() && aValues[0].hasValue()) throw Exception(); } @@ -2377,7 +2366,7 @@ void ODbaseTable::addColumn(const Reference< XPropertySet >& _xNewColumn) pNewTable->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME),makeAny(::rtl::OUString(sTempName))); { Reference<XAppend> xAppend(pNewTable->getColumns(),UNO_QUERY); - sal_Bool bCase = getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers(); + sal_Bool bCase = getConnection()->getMetaData()->supportsMixedCaseQuotedIdentifiers(); // copy the structure for(sal_Int32 i=0;i < m_pColumns->getCount();++i) { @@ -2410,7 +2399,7 @@ void ODbaseTable::addColumn(const Reference< XPropertySet >& _xNewColumn) ::dbtools::throwGenericSQLException( sError, *this ); } - BOOL bAlreadyDroped = FALSE; + sal_Bool bAlreadyDroped = sal_False; try { pNewTable->construct(); @@ -2419,7 +2408,7 @@ void ODbaseTable::addColumn(const Reference< XPropertySet >& _xNewColumn) // drop the old table if(DropImpl()) { - bAlreadyDroped = TRUE; + bAlreadyDroped = sal_True; pNewTable->renameImpl(m_Name); // release the temp file } @@ -2450,7 +2439,7 @@ void ODbaseTable::dropColumn(sal_Int32 _nPos) pNewTable->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME),makeAny(::rtl::OUString(sTempName))); { Reference<XAppend> xAppend(pNewTable->getColumns(),UNO_QUERY); - sal_Bool bCase = getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers(); + sal_Bool bCase = getConnection()->getMetaData()->supportsMixedCaseQuotedIdentifiers(); // copy the structure for(sal_Int32 i=0;i < m_pColumns->getCount();++i) { @@ -2501,7 +2490,7 @@ String ODbaseTable::createTempFile() RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::createTempFile" ); ::rtl::OUString aIdent = m_pConnection->getContent()->getIdentifier()->getContentIdentifier(); if ( aIdent.lastIndexOf('/') != (aIdent.getLength()-1) ) - aIdent += ::rtl::OUString::createFromAscii("/"); + aIdent += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")); String sTempName(aIdent); String sExt; sExt.AssignAscii("."); @@ -2603,7 +2592,7 @@ sal_Bool ODbaseTable::seekRow(IResultSetHelper::Movement eCursorPosition, sal_In { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::seekRow" ); // ---------------------------------------------------------- - // Positionierung vorbereiten: + // prepare positioning: OSL_ENSURE(m_pFileStream,"ODbaseTable::seekRow: FileStream is NULL!"); sal_uInt32 nNumberOfRecords = (sal_uInt32)m_aHeader.db_anz; @@ -2647,11 +2636,11 @@ sal_Bool ODbaseTable::seekRow(IResultSetHelper::Movement eCursorPosition, sal_In OSL_ENSURE(m_nFilePos >= 1,"SdbDBFCursor::FileFetchRow: ungueltige Record-Position"); sal_Int32 nPos = m_aHeader.db_kopf + (sal_Int32)(m_nFilePos-1) * nEntryLen; - ULONG nLen = m_pFileStream->Seek(nPos); + m_pFileStream->Seek(nPos); if (m_pFileStream->GetError() != ERRCODE_NONE) goto Error; - nLen = m_pFileStream->Read((char*)m_pBuffer, nEntryLen); + m_pFileStream->Read((char*)m_pBuffer, nEntryLen); if (m_pFileStream->GetError() != ERRCODE_NONE) goto Error; } @@ -2674,7 +2663,7 @@ Error: m_nFilePos = 0; break; case IResultSetHelper::BOOKMARK: - m_nFilePos = nTempPos; // vorherige Position + m_nFilePos = nTempPos; // last position } return sal_False; @@ -2683,27 +2672,27 @@ End: return sal_True; } // ----------------------------------------------------------------------------- -BOOL ODbaseTable::ReadMemo(ULONG nBlockNo, ORowSetValue& aVariable) +sal_Bool ODbaseTable::ReadMemo(sal_uIntPtr nBlockNo, ORowSetValue& aVariable) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::ReadMemo" ); - BOOL bIsText = TRUE; + bool bIsText = true; m_pMemoStream->Seek(nBlockNo * m_aMemoHeader.db_size); switch (m_aMemoHeader.db_typ) { - case MemodBaseIII: // dBase III-Memofeld, endet mit Ctrl-Z + case MemodBaseIII: // dBase III-Memofield, ends with Ctrl-Z { const char cEOF = (char) DBF_EOL; ByteString aBStr; static char aBuf[514]; - aBuf[512] = 0; // sonst kann der Zufall uebel mitspielen - BOOL bReady = sal_False; + aBuf[512] = 0; // avoid random value + sal_Bool bReady = sal_False; do { m_pMemoStream->Read(&aBuf,512); - USHORT i = 0; + sal_uInt16 i = 0; while (aBuf[i] != cEOF && ++i < 512) ; bReady = aBuf[i] == cEOF; @@ -2718,7 +2707,7 @@ BOOL ODbaseTable::ReadMemo(ULONG nBlockNo, ORowSetValue& aVariable) } break; case MemoFoxPro: - case MemodBaseIV: // dBase IV-Memofeld mit Laengenangabe + case MemodBaseIV: // dBase IV-Memofield with length { char sHeader[4]; m_pMemoStream->Read(sHeader,4); @@ -2727,7 +2716,7 @@ BOOL ODbaseTable::ReadMemo(ULONG nBlockNo, ORowSetValue& aVariable) { bIsText = sHeader[3] != 0; } - else if (((BYTE)sHeader[0]) != 0xFF || ((BYTE)sHeader[1]) != 0xFF || ((BYTE)sHeader[2]) != 0x08) + else if (((sal_uInt8)sHeader[0]) != 0xFF || ((sal_uInt8)sHeader[1]) != 0xFF || ((sal_uInt8)sHeader[2]) != 0x08) { return sal_False; } @@ -2776,7 +2765,7 @@ BOOL ODbaseTable::ReadMemo(ULONG nBlockNo, ORowSetValue& aVariable) void ODbaseTable::AllocBuffer() { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::AllocBuffer" ); - UINT16 nSize = m_aHeader.db_slng; + sal_uInt16 nSize = m_aHeader.db_slng; OSL_ENSURE(nSize > 0, "Size too small"); if (m_nBufferSize != nSize) @@ -2785,20 +2774,20 @@ void ODbaseTable::AllocBuffer() m_pBuffer = NULL; } - // Falls noch kein Puffer vorhanden: allozieren: + // if there is no buffer available: allocate: if (m_pBuffer == NULL && nSize) { m_nBufferSize = nSize; - m_pBuffer = new BYTE[m_nBufferSize+1]; + m_pBuffer = new sal_uInt8[m_nBufferSize+1]; } } // ----------------------------------------------------------------------------- -BOOL ODbaseTable::WriteBuffer() +sal_Bool ODbaseTable::WriteBuffer() { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::WriteBuffer" ); OSL_ENSURE(m_nFilePos >= 1,"SdbDBFCursor::FileFetchRow: ungueltige Record-Position"); - // Auf gewuenschten Record positionieren: + // postion on desired record: long nPos = m_aHeader.db_kopf + (long)(m_nFilePos-1) * m_aHeader.db_slng; m_pFileStream->Seek(nPos); return m_pFileStream->Write((char*) m_pBuffer, m_aHeader.db_slng) > 0; |