diff options
Diffstat (limited to 'connectivity/source/drivers/flat/ETable.cxx')
-rw-r--r-- | connectivity/source/drivers/flat/ETable.cxx | 43 |
1 files changed, 13 insertions, 30 deletions
diff --git a/connectivity/source/drivers/flat/ETable.cxx b/connectivity/source/drivers/flat/ETable.cxx index 0dceba05b641..9cab6b13da5a 100644 --- a/connectivity/source/drivers/flat/ETable.cxx +++ b/connectivity/source/drivers/flat/ETable.cxx @@ -27,10 +27,8 @@ #include <o3tl/safeint.hxx> #include <rtl/math.hxx> #include <sal/log.hxx> -#include <tools/solar.h> #include <tools/urlobj.hxx> #include <cppuhelper/queryinterface.hxx> -#include <cppuhelper/typeprovider.hxx> #include <comphelper/numbers.hxx> #include <comphelper/servicehelper.hxx> #include <com/sun/star/util/NumberFormat.hpp> @@ -65,6 +63,8 @@ void OFlatTable::fillColumns(const css::lang::Locale& _aLocale) { m_bNeedToReadLine = true; // we overwrite m_aCurrentLine, seek the stream, ... m_pFileStream->Seek(0); + // tdf#123055 - start to read unicode text in order to avoid the BOM + m_pFileStream->StartReadingUnicodeText(RTL_TEXTENCODING_DONTKNOW); m_aCurrentLine = QuotedTokenizedString(); bool bRead = true; @@ -72,7 +72,8 @@ void OFlatTable::fillColumns(const css::lang::Locale& _aLocale) const bool bHasHeaderLine = pConnection->isHeaderLine(); QuotedTokenizedString aHeaderLine; - TRowPositionInFile rowPos(0, 0); + const sal_Int32 nPos = static_cast<sal_Int32>(m_pFileStream->Tell()); + TRowPositionInFile rowPos(nPos, nPos); sal_Int32 rowNum(0); if ( bHasHeaderLine ) { @@ -176,7 +177,7 @@ void OFlatTable::fillColumns(const css::lang::Locale& _aLocale) aFind = connectivity::find(m_aColumns->begin(),m_aColumns->end(),aAlias,aCase); } - sdbcx::OColumn* pColumn = new sdbcx::OColumn(aAlias,aTypeNames[i],OUString(),OUString(), + rtl::Reference<sdbcx::OColumn> pColumn = new sdbcx::OColumn(aAlias,aTypeNames[i],OUString(),OUString(), ColumnValue::NULLABLE, m_aPrecisions[i], m_aScales[i], @@ -186,8 +187,7 @@ void OFlatTable::fillColumns(const css::lang::Locale& _aLocale) false, bCase, m_CatalogName, getSchema(), getName()); - Reference< XPropertySet> xCol = pColumn; - m_aColumns->push_back(xCol); + m_aColumns->push_back(pColumn); } m_pFileStream->Seek(m_aRowPosToFilePos[0].second); @@ -200,7 +200,7 @@ void OFlatTable::impl_fillColumnInfo_nothrow(QuotedTokenizedString const & aFirs if ( io_nType != DataType::VARCHAR ) { bool bNumeric = io_nType == DataType::SQLNULL || io_nType == DataType::DOUBLE || io_nType == DataType::DECIMAL || io_nType == DataType::INTEGER; - sal_uLong nIndex = 0; + sal_Int32 nIndex = 0; if ( bNumeric ) { @@ -265,8 +265,8 @@ void OFlatTable::impl_fillColumnInfo_nothrow(QuotedTokenizedString const & aFirs if (bNumeric && cThousandDelimiter) { // Is the delimiter correct? - const OUString aValue = aField2.getToken(0,cDecimalDelimiter); - for( sal_Int32 j = aValue.getLength() - 4; j >= 0; j -= 4) + const std::u16string_view aValue = o3tl::getToken(aField2, 0, cDecimalDelimiter); + for( sal_Int32 j = static_cast<sal_Int32>(aValue.size()) - 4; j >= 0; j -= 4) { const sal_Unicode c = aValue[j]; // just digits, decimal- and thousands-delimiter? @@ -471,7 +471,7 @@ OUString OFlatTable::getEntry() const if ( m_pConnection->matchesExtension( sExt ) ) { if ( !sExt.isEmpty() ) - sName = sName.replaceAt(sName.getLength() - (sExt.getLength() + 1), sExt.getLength()+1, OUString()); + sName = sName.replaceAt(sName.getLength() - (sExt.getLength() + 1), sExt.getLength()+1, u""); if ( sName == m_Name ) { Reference< XContentAccess > xContentAccess( xDir, UNO_QUERY ); @@ -502,7 +502,7 @@ void OFlatTable::refreshColumns() if(m_xColumns) m_xColumns->reFill(aVector); else - m_xColumns = new OFlatColumns(this,m_aMutex,aVector); + m_xColumns.reset(new OFlatColumns(this,m_aMutex,aVector)); } @@ -545,26 +545,10 @@ Any SAL_CALL OFlatTable::queryInterface( const Type & rType ) return Any(); Any aRet = OTable_TYPEDEF::queryInterface(rType); - return aRet.hasValue() ? aRet : ::cppu::queryInterface(rType,static_cast< css::lang::XUnoTunnel*> (this)); + return aRet; } -Sequence< sal_Int8 > OFlatTable::getUnoTunnelId() -{ - static ::cppu::OImplementationId implId; - - return implId.getImplementationId(); -} - -// css::lang::XUnoTunnel - -sal_Int64 OFlatTable::getSomething( const Sequence< sal_Int8 > & rId ) -{ - return (isUnoTunnelId<OFlatTable>(rId)) - ? reinterpret_cast< sal_Int64 >( this ) - : OFlatTable_BASE::getSomething(rId); -} - bool OFlatTable::fetchRow(OValueRefRow& _rRow, const OSQLColumns & _rCols, bool bRetrieveData) { *(*_rRow)[0] = m_nFilePos; @@ -676,7 +660,7 @@ bool OFlatTable::fetchRow(OValueRefRow& _rRow, const OSQLColumns & _rCols, bool // #99178# OJ if ( DataType::DECIMAL == nType || DataType::NUMERIC == nType ) - *(*_rRow)[i] = OUString(OUString::number(nVal)); + *(*_rRow)[i] = OUString::number(nVal); else *(*_rRow)[i] = nVal; } break; @@ -784,7 +768,6 @@ bool OFlatTable::seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 n } // m_nMaxRowCount can still be zero, but now it means there a genuinely zero rows in the table return seekRow(IResultSetHelper::ABSOLUTE1, m_nMaxRowCount, nCurPos); - break; case IResultSetHelper::RELATIVE1: { const sal_Int32 nNewRowPos = m_nRowPos + nOffset; |