ETable.cxx (9b5730f6) | ETable.cxx (6c882b5c) |
---|---|
1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 58 unchanged lines hidden (view full) --- 67// ------------------------------------------------------------------------- 68void OFlatTable::fillColumns(const ::com::sun::star::lang::Locale& _aLocale) 69{ 70 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "flat", "Ocke.Janssen@sun.com", "OFlatTable::fillColumns" ); 71 sal_Bool bRead = sal_True; 72 73 QuotedTokenizedString aHeaderLine; 74 OFlatConnection* pConnection = (OFlatConnection*)m_pConnection; | 1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 58 unchanged lines hidden (view full) --- 67// ------------------------------------------------------------------------- 68void OFlatTable::fillColumns(const ::com::sun::star::lang::Locale& _aLocale) 69{ 70 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "flat", "Ocke.Janssen@sun.com", "OFlatTable::fillColumns" ); 71 sal_Bool bRead = sal_True; 72 73 QuotedTokenizedString aHeaderLine; 74 OFlatConnection* pConnection = (OFlatConnection*)m_pConnection; |
75 const rtl_TextEncoding nEncoding = m_pConnection->getTextEncoding(); | |
76 const sal_Bool bHasHeaderLine = pConnection->isHeaderLine(); | 75 const sal_Bool bHasHeaderLine = pConnection->isHeaderLine(); |
76 sal_Int32 nCurPos; |
|
77 if ( bHasHeaderLine ) 78 { 79 while(bRead && !aHeaderLine.Len()) 80 { | 77 if ( bHasHeaderLine ) 78 { 79 while(bRead && !aHeaderLine.Len()) 80 { |
81 bRead = m_pFileStream->ReadByteStringLine(aHeaderLine,nEncoding); | 81 bRead = readLine(aHeaderLine, nCurPos); |
82 } 83 m_nStartRowFilePos = m_pFileStream->Tell(); 84 } 85 86 // read first row 87 QuotedTokenizedString aFirstLine; | 82 } 83 m_nStartRowFilePos = m_pFileStream->Tell(); 84 } 85 86 // read first row 87 QuotedTokenizedString aFirstLine; |
88 bRead = m_pFileStream->ReadByteStringLine(aFirstLine,nEncoding); | 88 bRead = readLine(aFirstLine, nCurPos); |
89 90 if ( !bHasHeaderLine || !aHeaderLine.Len()) 91 { 92 while(bRead && !aFirstLine.Len()) 93 { | 89 90 if ( !bHasHeaderLine || !aHeaderLine.Len()) 91 { 92 while(bRead && !aFirstLine.Len()) 93 { |
94 bRead = m_pFileStream->ReadByteStringLine(aFirstLine,nEncoding); | 94 bRead = readLine(aFirstLine, nCurPos); |
95 } 96 // use first row as headerline because we need the number of columns 97 aHeaderLine = aFirstLine; 98 } 99 // column count 100 const xub_StrLen nFieldCount = aHeaderLine.GetTokenCount(m_cFieldDelimiter,m_cStringDelimiter); 101 102 if(!m_aColumns.isValid()) --- 47 unchanged lines hidden (view full) --- 150 aColumnName += String::CreateFromInt32(i+1); 151 } 152 aColumnNames.push_back(aColumnName); 153 } 154 impl_fillColumnInfo_nothrow(aFirstLine,nStartPosFirstLine,nStartPosFirstLine2,m_aTypes[i],m_aPrecisions[i],m_aScales[i],m_aTypeNames[i],cDecimalDelimiter,cThousandDelimiter,aCharClass); 155 } 156 ++nRowCount; 157 } | 95 } 96 // use first row as headerline because we need the number of columns 97 aHeaderLine = aFirstLine; 98 } 99 // column count 100 const xub_StrLen nFieldCount = aHeaderLine.GetTokenCount(m_cFieldDelimiter,m_cStringDelimiter); 101 102 if(!m_aColumns.isValid()) --- 47 unchanged lines hidden (view full) --- 150 aColumnName += String::CreateFromInt32(i+1); 151 } 152 aColumnNames.push_back(aColumnName); 153 } 154 impl_fillColumnInfo_nothrow(aFirstLine,nStartPosFirstLine,nStartPosFirstLine2,m_aTypes[i],m_aPrecisions[i],m_aScales[i],m_aTypeNames[i],cDecimalDelimiter,cThousandDelimiter,aCharClass); 155 } 156 ++nRowCount; 157 } |
158 while(nRowCount < nMaxRowsToScan && m_pFileStream->ReadByteStringLine(aFirstLine,nEncoding) && !m_pFileStream->IsEof()); | 158 while(nRowCount < nMaxRowsToScan && readLine(aFirstLine,nCurPos) && !m_pFileStream->IsEof()); |
159 160 for (xub_StrLen i = 0; i < nFieldCount; i++) 161 { 162 // check if the columname already exists 163 String aAlias(aColumnNames[i]); 164 OSQLColumns::Vector::const_iterator aFind = connectivity::find(m_aColumns->get().begin(),m_aColumns->get().end(),aAlias,aCase); 165 sal_Int32 nExprCnt = 0; 166 while(aFind != m_aColumns->get().end()) --- 723 unchanged lines hidden (view full) --- 890 891 //nCurPos = m_nFilePos; 892 893 return sal_True; 894} 895// ----------------------------------------------------------------------------- 896sal_Bool OFlatTable::readLine(sal_Int32& _rnCurrentPos) 897{ | 159 160 for (xub_StrLen i = 0; i < nFieldCount; i++) 161 { 162 // check if the columname already exists 163 String aAlias(aColumnNames[i]); 164 OSQLColumns::Vector::const_iterator aFind = connectivity::find(m_aColumns->get().begin(),m_aColumns->get().end(),aAlias,aCase); 165 sal_Int32 nExprCnt = 0; 166 while(aFind != m_aColumns->get().end()) --- 723 unchanged lines hidden (view full) --- 890 891 //nCurPos = m_nFilePos; 892 893 return sal_True; 894} 895// ----------------------------------------------------------------------------- 896sal_Bool OFlatTable::readLine(sal_Int32& _rnCurrentPos) 897{ |
898 return readLine(m_aCurrentLine, _rnCurrentPos); 899} 900// ----------------------------------------------------------------------------- 901sal_Bool OFlatTable::readLine(QuotedTokenizedString& line, sal_Int32& _rnCurrentPos) 902{ |
|
898 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "flat", "Ocke.Janssen@sun.com", "OFlatTable::readLine" ); 899 const rtl_TextEncoding nEncoding = m_pConnection->getTextEncoding(); | 903 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "flat", "Ocke.Janssen@sun.com", "OFlatTable::readLine" ); 904 const rtl_TextEncoding nEncoding = m_pConnection->getTextEncoding(); |
900 m_pFileStream->ReadByteStringLine(m_aCurrentLine,nEncoding); 901 if (m_pFileStream->IsEof()) 902 return sal_False; | 905 m_pFileStream->ReadByteStringLine(line,nEncoding); 906 if (m_pFileStream->IsEof()) 907 return sal_False; |
903 | 908 |
904 QuotedTokenizedString sLine = m_aCurrentLine; // check if the string continues on next line | 909 QuotedTokenizedString sLine = line; // check if the string continues on next line |
905 while( (sLine.GetString().GetTokenCount(m_cStringDelimiter) % 2) != 1 ) 906 { 907 m_pFileStream->ReadByteStringLine(sLine,nEncoding); 908 if ( !m_pFileStream->IsEof() ) 909 { | 910 while( (sLine.GetString().GetTokenCount(m_cStringDelimiter) % 2) != 1 ) 911 { 912 m_pFileStream->ReadByteStringLine(sLine,nEncoding); 913 if ( !m_pFileStream->IsEof() ) 914 { |
910 m_aCurrentLine.GetString().Append('\n'); 911 m_aCurrentLine.GetString() += sLine.GetString(); 912 sLine = m_aCurrentLine; | 915 line.GetString().Append('\n'); 916 line.GetString() += sLine.GetString(); 917 sLine = line; |
913 } 914 else 915 break; 916 } 917 _rnCurrentPos = m_pFileStream->Tell(); 918 return sal_True; 919} | 918 } 919 else 920 break; 921 } 922 _rnCurrentPos = m_pFileStream->Tell(); 923 return sal_True; 924} |
920 | |