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