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