User: hr Date: 06/06/19 18:28:54 Modified: /dba/connectivity/source/drivers/flat/ ETable.cxx
Log: INTEGRATION: CWS warnings01 (1.49.16); FILE MERGED 2006/05/26 14:03:28 sb 1.49.16.7: #i53898# Made code warning-free and/or compile at all after resync to SRC680m170. 2006/05/23 23:33:20 sb 1.49.16.6: RESYNC: (1.51-1.53); FILE MERGED 2006/01/25 20:50:14 sb 1.49.16.5: RESYNC: (1.50-1.51); FILE MERGED 2005/11/21 10:07:44 fs 1.49.16.4: #i57457# warning-free code on unx* 2005/11/16 12:59:04 fs 1.49.16.3: #i57457# warning free code 2005/11/07 19:08:49 pl 1.49.16.2: RESYNC: (1.49-1.50); FILE MERGED 2005/11/07 14:43:36 fs 1.49.16.1: #i57457# warning-free code File Changes: Directory: /dba/connectivity/source/drivers/flat/ ================================================= File [changed]: ETable.cxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/flat/ETable.cxx?r1=1.53&r2=1.54 Delta lines: +175 -9 --------------------- --- ETable.cxx 19 Apr 2006 13:16:36 -0000 1.53 +++ ETable.cxx 20 Jun 2006 01:28:52 -0000 1.54 @@ -102,6 +102,9 @@ #ifndef _COMPHELPER_TYPES_HXX_ #include <comphelper/types.hxx> #endif +#ifndef CONNECTIVITY_QUOTED_STRING_HXX +#include "file/quotedstring.hxx" +#endif using namespace ::comphelper; using namespace connectivity; @@ -123,7 +126,7 @@ { BOOL bRead = TRUE; - OFlatString aHeaderLine; + QuotedTokenizedString aHeaderLine; OFlatConnection* pConnection = (OFlatConnection*)m_pConnection; if (pConnection->isHeaderLine()) { @@ -134,7 +137,7 @@ } // read first row - OFlatString aFirstLine; + QuotedTokenizedString aFirstLine; bRead = m_pFileStream->ReadByteStringLine(aFirstLine,pConnection->getTextEncoding()); @@ -197,7 +200,6 @@ UINT16 nScale = 0; BOOL bNumeric = FALSE; - double nRes=0.0; ULONG nIndex = 0; // first without fielddelimiter @@ -542,10 +544,8 @@ sal_Int64 OFlatTable::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException) { return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) - ? - (sal_Int64)this - : - OFlatTable_BASE::getSomething(rId); + ? reinterpret_cast< sal_Int64 >( this ) + : OFlatTable_BASE::getSomething(rId); } //------------------------------------------------------------------ sal_Bool OFlatTable::fetchRow(OValueRefRow& _rRow,const OSQLColumns & _rCols,sal_Bool bIsTable,sal_Bool bRetrieveData) @@ -556,13 +556,13 @@ return TRUE; OFlatConnection* pConnection = (OFlatConnection*)m_pConnection; - sal_Int32 nByteOffset = 1; // Felder: xub_StrLen nStartPos = 0; String aStr; OSQLColumns::const_iterator aIter = _rCols.begin(); OSQLColumns::const_iterator aEnd = _rCols.end(); - for (sal_Int32 i = 1; aIter != aEnd && i < _rRow->size();++aIter, i++) + for (OValueRefVector::size_type i = 1; aIter != aEnd && i < _rRow->size(); + ++aIter, i++) { m_aCurrentLine.GetTokenSpecial(aStr,nStartPos,pConnection->getFieldDelimiter(),pConnection->getStringDelimiter()); @@ -664,6 +664,172 @@ } // ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +sal_Bool OFlatTable::checkHeaderLine() +{ + if (m_nFilePos == 0 && ((OFlatConnection*)m_pConnection)->isHeaderLine()) + { + BOOL bRead2; + do + { + bRead2 = m_pFileStream->ReadByteStringLine(m_aCurrentLine,m_pConnection->getTextEncoding()); + } + while(bRead2 && !m_aCurrentLine.Len()); + m_nFilePos = m_pFileStream->Tell(); + if (m_pFileStream->IsEof()) + return sal_False; + } + return sal_True; +} +//------------------------------------------------------------------ +sal_Bool OFlatTable::seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos) +{ + if ( !m_pFileStream ) + return sal_False; + OFlatConnection* pConnection = (OFlatConnection*)m_pConnection; + // ---------------------------------------------------------- + // Positionierung vorbereiten: + + m_nFilePos = nCurPos; + switch(eCursorPosition) + { + case IResultSetHelper::FIRST: + m_nFilePos = 0; + m_nRowPos = 1; + // run through + case IResultSetHelper::NEXT: + if(eCursorPosition != IResultSetHelper::FIRST) + ++m_nRowPos; + m_pFileStream->Seek(m_nFilePos); + if (m_pFileStream->IsEof() || !checkHeaderLine()) + { + m_nMaxRowCount = m_nRowPos; + return sal_False; + } + m_aRowToFilePos.insert(::std::map<sal_Int32,sal_Int32>::value_type(m_nRowPos,m_nFilePos)); + + m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding()); + if (m_pFileStream->IsEof()) + { + m_nMaxRowCount = m_nRowPos; + return sal_False; + } + nCurPos = m_pFileStream->Tell(); + break; + case IResultSetHelper::PRIOR: + --m_nRowPos; + if(m_nRowPos > 0) + { + m_nFilePos = m_aRowToFilePos.find(m_nRowPos)->second; + m_pFileStream->Seek(m_nFilePos); + if (m_pFileStream->IsEof() || !checkHeaderLine()) + return sal_False; + m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding()); + if (m_pFileStream->IsEof()) + return sal_False; + nCurPos = m_pFileStream->Tell(); + } + else + m_nRowPos = 0; + + break; + case IResultSetHelper::LAST: + if(m_nMaxRowCount) + { + m_nFilePos = m_aRowToFilePos.rbegin()->second; + m_nRowPos = m_aRowToFilePos.rbegin()->first; + m_pFileStream->Seek(m_nFilePos); + if (m_pFileStream->IsEof() || !checkHeaderLine()) + return sal_False; + m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding()); + if (m_pFileStream->IsEof()) + return sal_False; + nCurPos = m_pFileStream->Tell(); + } + else + { + while(seekRow(IResultSetHelper::NEXT,1,nCurPos)) ; // run through after last row + // now I know all + seekRow(IResultSetHelper::PRIOR,1,nCurPos); + } + break; + case IResultSetHelper::RELATIVE: + if(nOffset > 0) + { + for(sal_Int32 i = 0;i<nOffset;++i) + seekRow(IResultSetHelper::NEXT,1,nCurPos); + } + else if(nOffset < 0) + { + for(sal_Int32 i = nOffset;i;++i) + seekRow(IResultSetHelper::PRIOR,1,nCurPos); + } + break; + case IResultSetHelper::ABSOLUTE: + { + if(nOffset < 0) + nOffset = m_nRowPos + nOffset; + ::std::map<sal_Int32,sal_Int32>::const_iterator aIter = m_aRowToFilePos.find(nOffset); + if(aIter != m_aRowToFilePos.end()) + { + m_nFilePos = aIter->second; + m_pFileStream->Seek(m_nFilePos); + if (m_pFileStream->IsEof() || !checkHeaderLine()) + return sal_False; + m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding()); + if (m_pFileStream->IsEof()) + return sal_False; + nCurPos = m_pFileStream->Tell(); + } + else if(m_nMaxRowCount && nOffset > m_nMaxRowCount) // offset is outside the table + { + m_nRowPos = m_nMaxRowCount; + return sal_False; + } + else + { + aIter = m_aRowToFilePos.upper_bound(nOffset); + if(aIter == m_aRowToFilePos.end()) + { + m_nRowPos = m_aRowToFilePos.rbegin()->first; + nCurPos = m_nFilePos = m_aRowToFilePos.rbegin()->second; + while(m_nRowPos != nOffset) + seekRow(IResultSetHelper::NEXT,1,nCurPos); + } + else + { + --aIter; + m_nRowPos = aIter->first; + m_nFilePos = aIter->second; + m_pFileStream->Seek(m_nFilePos); + if (m_pFileStream->IsEof() || !checkHeaderLine()) + return sal_False; + m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding()); + if (m_pFileStream->IsEof()) + return sal_False; + nCurPos = m_pFileStream->Tell(); + } + } + } + + break; + case IResultSetHelper::BOOKMARK: + m_pFileStream->Seek(nOffset); + if (m_pFileStream->IsEof()) + return sal_False; + + m_nFilePos = m_pFileStream->Tell(); // Byte-Position in der Datei merken (am ZeilenANFANG) + m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding()); + if (m_pFileStream->IsEof()) + return sal_False; + nCurPos = m_pFileStream->Tell(); + break; + } + + + return sal_True; +} +// ----------------------------------------------------------------------------- --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
