1*caf5cd79SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*caf5cd79SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*caf5cd79SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*caf5cd79SAndrew Rist  * distributed with this work for additional information
6*caf5cd79SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*caf5cd79SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*caf5cd79SAndrew Rist  * "License"); you may not use this file except in compliance
9*caf5cd79SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*caf5cd79SAndrew Rist  *
11*caf5cd79SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*caf5cd79SAndrew Rist  *
13*caf5cd79SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*caf5cd79SAndrew Rist  * software distributed under the License is distributed on an
15*caf5cd79SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*caf5cd79SAndrew Rist  * KIND, either express or implied.  See the License for the
17*caf5cd79SAndrew Rist  * specific language governing permissions and limitations
18*caf5cd79SAndrew Rist  * under the License.
19*caf5cd79SAndrew Rist  *
20*caf5cd79SAndrew Rist  *************************************************************/
21*caf5cd79SAndrew Rist 
22*caf5cd79SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _CONNECTIVITY_FILE_TABLE_HXX_
25cdf0e10cSrcweir #define _CONNECTIVITY_FILE_TABLE_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "connectivity/sdbcx/VTable.hxx"
28cdf0e10cSrcweir #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
29cdf0e10cSrcweir #include <com/sun/star/lang/XUnoTunnel.hpp>
30cdf0e10cSrcweir #ifndef _CONNECTIVITY_FILE_BCONNECTION_HXX_
31cdf0e10cSrcweir #include "file/FConnection.hxx"
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir #include "file/filedllapi.hxx"
34cdf0e10cSrcweir #include <tools/stream.hxx>
35cdf0e10cSrcweir #include "connectivity/FValue.hxx"
36cdf0e10cSrcweir #include "TResultSetHelper.hxx"
37cdf0e10cSrcweir 
38cdf0e10cSrcweir namespace connectivity
39cdf0e10cSrcweir {
40cdf0e10cSrcweir 	namespace file
41cdf0e10cSrcweir 	{
42cdf0e10cSrcweir 		typedef connectivity::sdbcx::OTable OTable_TYPEDEF;
43cdf0e10cSrcweir 
44cdf0e10cSrcweir 		class OOO_DLLPUBLIC_FILE OFileTable :	public OTable_TYPEDEF
45cdf0e10cSrcweir 		{
46cdf0e10cSrcweir 		protected:
47cdf0e10cSrcweir 			OConnection*										m_pConnection;
48cdf0e10cSrcweir 			SvStream*											m_pFileStream;
49cdf0e10cSrcweir 			::vos::ORef<OSQLColumns>							m_aColumns;
50cdf0e10cSrcweir 			sal_Int32											m_nFilePos;					// aktuelle IResultSetHelper::Movement
51cdf0e10cSrcweir 			sal_uInt8*											m_pBuffer;
52cdf0e10cSrcweir 			sal_uInt16											m_nBufferSize;	// Groesse des ReadBuffer, wenn pBuffer != NULL
53cdf0e10cSrcweir 			sal_Bool											m_bWriteable;	// svstream cann't say if we are writeable
54cdf0e10cSrcweir 																				// so we have to
55cdf0e10cSrcweir 
56cdf0e10cSrcweir 			virtual void FileClose();
57cdf0e10cSrcweir 			virtual ~OFileTable( );
58cdf0e10cSrcweir 		public:
59cdf0e10cSrcweir 			virtual void refreshColumns();
60cdf0e10cSrcweir 			virtual void refreshKeys();
61cdf0e10cSrcweir 			virtual void refreshIndexes();
62cdf0e10cSrcweir 		public:
63cdf0e10cSrcweir 			OFileTable( sdbcx::OCollection* _pTables,OConnection* _pConnection);
64cdf0e10cSrcweir 			OFileTable(	sdbcx::OCollection* _pTables,OConnection* _pConnection,
65cdf0e10cSrcweir 					const ::rtl::OUString& _Name,
66cdf0e10cSrcweir 					const ::rtl::OUString& _Type,
67cdf0e10cSrcweir 					const ::rtl::OUString& _Description = ::rtl::OUString(),
68cdf0e10cSrcweir 					const ::rtl::OUString& _SchemaName = ::rtl::OUString(),
69cdf0e10cSrcweir 					const ::rtl::OUString& _CatalogName = ::rtl::OUString()
70cdf0e10cSrcweir 				);
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 			//XInterface
73cdf0e10cSrcweir 			virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
74cdf0e10cSrcweir 			virtual void SAL_CALL acquire() throw();
75cdf0e10cSrcweir             virtual void SAL_CALL release() throw();
76cdf0e10cSrcweir 			// ::cppu::OComponentHelper
77cdf0e10cSrcweir 			virtual void SAL_CALL disposing(void);
78cdf0e10cSrcweir 
getConnection() const79cdf0e10cSrcweir 			OConnection* getConnection() const { return m_pConnection;}
getCurrentLastPos() const80cdf0e10cSrcweir 			virtual sal_Int32 getCurrentLastPos() const {return -1;}
81cdf0e10cSrcweir 
82cdf0e10cSrcweir 			virtual sal_Bool seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos) = 0;
83cdf0e10cSrcweir 			virtual sal_Bool fetchRow(OValueRefRow& _rRow,const OSQLColumns& _rCols, sal_Bool _bUseTableDefs,sal_Bool bRetrieveData) = 0;
84cdf0e10cSrcweir 
getTableColumns() const85cdf0e10cSrcweir 			::vos::ORef<OSQLColumns> getTableColumns() const {return m_aColumns;}
86cdf0e10cSrcweir 			virtual sal_Bool InsertRow(OValueRefVector& rRow, sal_Bool bFlush,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xCols);
87cdf0e10cSrcweir 			virtual sal_Bool DeleteRow(const OSQLColumns& _rCols);
88cdf0e10cSrcweir 			virtual sal_Bool UpdateRow(OValueRefVector& rRow, OValueRefRow& pOrgRow,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xCols);
89cdf0e10cSrcweir 			virtual void addColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& descriptor);
90cdf0e10cSrcweir 			virtual void dropColumn(sal_Int32 _nPos);
91cdf0e10cSrcweir 			// refresh the header of file based tables to see changes done by someone
92cdf0e10cSrcweir 			virtual void refreshHeader();
93cdf0e10cSrcweir 
getName()94cdf0e10cSrcweir 			::rtl::OUString SAL_CALL getName() throw() { return m_Name; }
95cdf0e10cSrcweir 
getSchema()96cdf0e10cSrcweir 			::rtl::OUString getSchema() { return m_SchemaName; }
isReadOnly() const97cdf0e10cSrcweir 			sal_Bool isReadOnly() const { return !m_bWriteable; }
98cdf0e10cSrcweir 				// m_pFileStream && !m_pFileStream->IsWritable(); }
99cdf0e10cSrcweir 			// com::sun::star::lang::XUnoTunnel
100cdf0e10cSrcweir 			virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
101cdf0e10cSrcweir 			static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 
getFilePos() const104cdf0e10cSrcweir 			sal_Int32 getFilePos() const { return m_nFilePos; }
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 		public:
107cdf0e10cSrcweir 			// helper
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 			// creates a stream using ::utl::UcbStreamHelper::CreateStream, but the error is simplified
110cdf0e10cSrcweir 			// (NULL or non-NULL is returned)
111cdf0e10cSrcweir 			static SvStream* createStream_simpleError( const String& _rFileName, StreamMode _eOpenMode);
112cdf0e10cSrcweir 		};
113cdf0e10cSrcweir 	}
114cdf0e10cSrcweir }
115cdf0e10cSrcweir #endif // _CONNECTIVITY_FILE_TABLE_HXX_
116cdf0e10cSrcweir 
117