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 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _CONNECTIVITY_FLAT_TABLE_HXX_ 25 #define _CONNECTIVITY_FLAT_TABLE_HXX_ 26 27 #include "file/FTable.hxx" 28 #include "connectivity/sdbcx/VColumn.hxx" 29 #include "connectivity/CommonTools.hxx" 30 #include <tools/urlobj.hxx> 31 #include "file/quotedstring.hxx" 32 #include <unotools/syslocale.hxx> 33 34 namespace connectivity 35 { 36 namespace flat 37 { 38 typedef file::OFileTable OFlatTable_BASE; 39 class OFlatConnection; 40 41 typedef ::std::map< ::rtl::OUString, 42 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed>, comphelper::UStringMixLess > OContainer; 43 typedef ::std::map<sal_Int32, sal_Int32> TRowPositionsInFile; 44 45 class OFlatTable : public OFlatTable_BASE 46 { 47 // maps a row position to a file position 48 TRowPositionsInFile m_aFilePosToEndLinePos; 49 ::std::map<sal_Int32, TRowPositionsInFile::iterator> 50 m_aRowPosToFilePos; 51 ::std::vector<sal_Int32> m_aTypes; // holds all type for columns just to avoid to ask the propertyset 52 ::std::vector<sal_Int32> m_aPrecisions; // same as aboth 53 ::std::vector<sal_Int32> m_aScales; 54 QuotedTokenizedString m_aCurrentLine; 55 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > m_xNumberFormatter; 56 ::com::sun::star::util::Date m_aNullDate; 57 sal_Int32 m_nStartRowFilePos; 58 sal_Int32 m_nRowPos; 59 sal_Int32 m_nMaxRowCount; // will be set if stream is once eof 60 sal_Unicode m_cStringDelimiter; // delimiter for strings m_cStringDelimiter blabla m_cStringDelimiter 61 sal_Unicode m_cFieldDelimiter; // look at the name 62 bool m_bNeedToReadLine; 63 private: 64 void fillColumns(const ::com::sun::star::lang::Locale& _aLocale); 65 sal_Bool CreateFile(const INetURLObject& aFile, sal_Bool& bCreateMemo); 66 sal_Bool readLine(sal_Int32& _rnCurrentPos); 67 void impl_fillColumnInfo_nothrow(QuotedTokenizedString& aFirstLine,xub_StrLen& nStartPosFirstLine,xub_StrLen& nStartPosFirstLine2 68 ,sal_Int32& io_nType,sal_Int32& io_nPrecisions,sal_Int32& io_nScales,String& o_sTypeName 69 ,const sal_Unicode cDecimalDelimiter,const sal_Unicode cThousandDelimiter,const CharClass& aCharClass); 70 public: 71 virtual void refreshColumns(); 72 73 public: 74 // DECLARE_CTY_DEFAULTS( OFlatTable_BASE); 75 OFlatTable( sdbcx::OCollection* _pTables,OFlatConnection* _pConnection, 76 const ::rtl::OUString& _Name, 77 const ::rtl::OUString& _Type, 78 const ::rtl::OUString& _Description = ::rtl::OUString(), 79 const ::rtl::OUString& _SchemaName = ::rtl::OUString(), 80 const ::rtl::OUString& _CatalogName = ::rtl::OUString() 81 ); 82 83 void construct(); // can throw any exception 84 85 virtual sal_Bool seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos); 86 virtual sal_Bool fetchRow(OValueRefRow& _rRow,const OSQLColumns& _rCols, sal_Bool bIsTable,sal_Bool bRetrieveData); 87 virtual void refreshHeader(); 88 89 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); 90 //XTypeProvider 91 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); 92 virtual void SAL_CALL disposing(void); 93 94 // com::sun::star::lang::XUnoTunnel 95 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); 96 static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); 97 98 String getEntry(); 99 }; 100 } 101 } 102 #endif // _CONNECTIVITY_FLAT_TABLE_HXX_ 103 104