Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef _CONNECTIVITY_FILE_TABLE_HXX_
21 : #define _CONNECTIVITY_FILE_TABLE_HXX_
22 :
23 : #include "connectivity/sdbcx/VTable.hxx"
24 : #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
25 : #include <com/sun/star/lang/XUnoTunnel.hpp>
26 : #include "file/FConnection.hxx"
27 : #include "file/filedllapi.hxx"
28 : #include <tools/stream.hxx>
29 : #include "connectivity/FValue.hxx"
30 : #include "TResultSetHelper.hxx"
31 :
32 : namespace connectivity
33 : {
34 : namespace file
35 : {
36 : typedef connectivity::sdbcx::OTable OTable_TYPEDEF;
37 :
38 : class OOO_DLLPUBLIC_FILE OFileTable : public OTable_TYPEDEF
39 : {
40 : protected:
41 : OConnection* m_pConnection;
42 : SvStream* m_pFileStream;
43 : ::rtl::Reference<OSQLColumns> m_aColumns;
44 : sal_Int32 m_nFilePos; // current IResultSetHelper::Movement
45 : sal_uInt8* m_pBuffer;
46 : sal_uInt16 m_nBufferSize; // size of the ReadBuffer, if pBuffer != NULL
47 : sal_Bool m_bWriteable; // svstream cann't say if we are writeable
48 : // so we have to
49 :
50 : virtual void FileClose();
51 : virtual ~OFileTable( );
52 : public:
53 : virtual void refreshColumns();
54 : virtual void refreshKeys();
55 : virtual void refreshIndexes();
56 : public:
57 : OFileTable( sdbcx::OCollection* _pTables,OConnection* _pConnection);
58 : OFileTable( sdbcx::OCollection* _pTables,OConnection* _pConnection,
59 : const ::rtl::OUString& _Name,
60 : const ::rtl::OUString& _Type,
61 : const ::rtl::OUString& _Description = ::rtl::OUString(),
62 : const ::rtl::OUString& _SchemaName = ::rtl::OUString(),
63 : const ::rtl::OUString& _CatalogName = ::rtl::OUString()
64 : );
65 :
66 : //XInterface
67 : virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
68 : virtual void SAL_CALL acquire() throw();
69 : virtual void SAL_CALL release() throw();
70 : // ::cppu::OComponentHelper
71 : virtual void SAL_CALL disposing(void);
72 :
73 0 : OConnection* getConnection() const { return m_pConnection;}
74 0 : virtual sal_Int32 getCurrentLastPos() const {return -1;}
75 :
76 : virtual sal_Bool seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos) = 0;
77 : virtual sal_Bool fetchRow(OValueRefRow& _rRow,const OSQLColumns& _rCols, sal_Bool _bUseTableDefs,sal_Bool bRetrieveData) = 0;
78 :
79 0 : ::rtl::Reference<OSQLColumns> getTableColumns() const {return m_aColumns;}
80 : virtual sal_Bool InsertRow(OValueRefVector& rRow, sal_Bool bFlush,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xCols);
81 : virtual sal_Bool DeleteRow(const OSQLColumns& _rCols);
82 : virtual sal_Bool UpdateRow(OValueRefVector& rRow, OValueRefRow& pOrgRow,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xCols);
83 : virtual void addColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& descriptor);
84 : virtual void dropColumn(sal_Int32 _nPos);
85 : // refresh the header of file based tables to see changes done by someone
86 : virtual void refreshHeader();
87 :
88 0 : ::rtl::OUString SAL_CALL getName() throw() { return m_Name; }
89 :
90 0 : ::rtl::OUString getSchema() { return m_SchemaName; }
91 0 : sal_Bool isReadOnly() const { return !m_bWriteable; }
92 : // m_pFileStream && !m_pFileStream->IsWritable(); }
93 : // com::sun::star::lang::XUnoTunnel
94 : virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
95 : static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
96 :
97 :
98 0 : sal_Int32 getFilePos() const { return m_nFilePos; }
99 :
100 : public:
101 : // helper
102 :
103 : // creates a stream using ::utl::UcbStreamHelper::CreateStream, but the error is simplified
104 : // (NULL or non-NULL is returned)
105 : static SvStream* createStream_simpleError( const String& _rFileName, StreamMode _eOpenMode);
106 : };
107 : }
108 : }
109 : #endif // _CONNECTIVITY_FILE_TABLE_HXX_
110 :
111 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|