xref: /trunk/main/connectivity/source/inc/file/FTable.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _CONNECTIVITY_FILE_TABLE_HXX_
29 #define _CONNECTIVITY_FILE_TABLE_HXX_
30 
31 #include "connectivity/sdbcx/VTable.hxx"
32 #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
33 #include <com/sun/star/lang/XUnoTunnel.hpp>
34 #ifndef _CONNECTIVITY_FILE_BCONNECTION_HXX_
35 #include "file/FConnection.hxx"
36 #endif
37 #include "file/filedllapi.hxx"
38 #include <tools/stream.hxx>
39 #include "connectivity/FValue.hxx"
40 #include "TResultSetHelper.hxx"
41 
42 namespace connectivity
43 {
44     namespace file
45     {
46         typedef connectivity::sdbcx::OTable OTable_TYPEDEF;
47 
48         class OOO_DLLPUBLIC_FILE OFileTable :   public OTable_TYPEDEF
49         {
50         protected:
51             OConnection*                                        m_pConnection;
52             SvStream*                                           m_pFileStream;
53             ::vos::ORef<OSQLColumns>                            m_aColumns;
54             sal_Int32                                           m_nFilePos;                 // aktuelle IResultSetHelper::Movement
55             sal_uInt8*                                          m_pBuffer;
56             sal_uInt16                                          m_nBufferSize;  // Groesse des ReadBuffer, wenn pBuffer != NULL
57             sal_Bool                                            m_bWriteable;   // svstream cann't say if we are writeable
58                                                                                 // so we have to
59 
60             virtual void FileClose();
61             virtual ~OFileTable( );
62         public:
63             virtual void refreshColumns();
64             virtual void refreshKeys();
65             virtual void refreshIndexes();
66         public:
67             OFileTable( sdbcx::OCollection* _pTables,OConnection* _pConnection);
68             OFileTable( sdbcx::OCollection* _pTables,OConnection* _pConnection,
69                     const ::rtl::OUString& _Name,
70                     const ::rtl::OUString& _Type,
71                     const ::rtl::OUString& _Description = ::rtl::OUString(),
72                     const ::rtl::OUString& _SchemaName = ::rtl::OUString(),
73                     const ::rtl::OUString& _CatalogName = ::rtl::OUString()
74                 );
75 
76             //XInterface
77             virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
78             virtual void SAL_CALL acquire() throw();
79             virtual void SAL_CALL release() throw();
80             // ::cppu::OComponentHelper
81             virtual void SAL_CALL disposing(void);
82 
83             OConnection* getConnection() const { return m_pConnection;}
84             virtual sal_Int32 getCurrentLastPos() const {return -1;}
85 
86             virtual sal_Bool seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos) = 0;
87             virtual sal_Bool fetchRow(OValueRefRow& _rRow,const OSQLColumns& _rCols, sal_Bool _bUseTableDefs,sal_Bool bRetrieveData) = 0;
88 
89             ::vos::ORef<OSQLColumns> getTableColumns() const {return m_aColumns;}
90             virtual sal_Bool InsertRow(OValueRefVector& rRow, sal_Bool bFlush,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xCols);
91             virtual sal_Bool DeleteRow(const OSQLColumns& _rCols);
92             virtual sal_Bool UpdateRow(OValueRefVector& rRow, OValueRefRow& pOrgRow,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xCols);
93             virtual void addColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& descriptor);
94             virtual void dropColumn(sal_Int32 _nPos);
95             // refresh the header of file based tables to see changes done by someone
96             virtual void refreshHeader();
97 
98             ::rtl::OUString SAL_CALL getName() throw() { return m_Name; }
99 
100             ::rtl::OUString getSchema() { return m_SchemaName; }
101             sal_Bool isReadOnly() const { return !m_bWriteable; }
102                 // m_pFileStream && !m_pFileStream->IsWritable(); }
103             // com::sun::star::lang::XUnoTunnel
104             virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
105             static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
106 
107 
108             sal_Int32 getFilePos() const { return m_nFilePos; }
109 
110         public:
111             // helper
112 
113             // creates a stream using ::utl::UcbStreamHelper::CreateStream, but the error is simplified
114             // (NULL or non-NULL is returned)
115             static SvStream* createStream_simpleError( const String& _rFileName, StreamMode _eOpenMode);
116         };
117     }
118 }
119 #endif // _CONNECTIVITY_FILE_TABLE_HXX_
120 
121