xref: /AOO41X/main/connectivity/source/inc/file/FConnection.hxx (revision caf5cd79edad04a48dcaf209068b3b89eae4622e)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _CONNECTIVITY_FILE_OCONNECTION_HXX_
24 #define _CONNECTIVITY_FILE_OCONNECTION_HXX_
25 
26 #include <com/sun/star/ucb/XContent.hpp>
27 #include <com/sun/star/sdbc/SQLWarning.hpp>
28 #include <com/sun/star/beans/PropertyValue.hpp>
29 #include "OSubComponent.hxx"
30 #ifndef _MAP_
31 #include <map>
32 #endif
33 #include "connectivity/CommonTools.hxx"
34 #include "OTypeInfo.hxx"
35 #include <tools/string.hxx>
36 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
37 #include <com/sun/star/ucb/XDynamicResultSet.hpp>
38 #include "connectivity/sqlparse.hxx"
39 #include "connectivity/sqliterator.hxx"
40 #include "TConnection.hxx"
41 #include "file/filedllapi.hxx"
42 
43 namespace connectivity
44 {
45     namespace file
46     {
47 
48         class OStatement_Base;
49         class ODatabaseMetaData;
50         class OFileDriver;
51 
52         class OOO_DLLPUBLIC_FILE OConnection :
53                             public connectivity::OMetaConnection,
54                             public connectivity::OSubComponent<OConnection, connectivity::OMetaConnection>
55         {
56             friend class connectivity::OSubComponent<OConnection, connectivity::OMetaConnection>;
57 
58         protected:
59             //====================================================================
60             // Data attributes
61             //====================================================================
62             ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbcx::XTablesSupplier>         m_xCatalog;
63 
64             ::com::sun::star::sdbc::SQLWarning            m_aLastWarning; //      Last SQLWarning generated by
65 
66             String                      m_aFilenameExtension;
67             OFileDriver*                m_pDriver;      //  Pointer to the owning
68                                                         //  driver object
69             ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XDynamicResultSet >    m_xDir; // directory
70             ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent>              m_xContent;
71 
72             sal_Bool                    m_bClosed;
73             sal_Bool                    m_bAutoCommit;
74             sal_Bool                    m_bReadOnly;
75             sal_Bool                    m_bShowDeleted;
76             sal_Bool                    m_bCaseSensitiveExtension;
77             sal_Bool                    m_bCheckSQL92;
78             bool                        m_bDefaultTextEncoding;
79 
80 
81             void throwUrlNotValid(const ::rtl::OUString & _rsUrl,const ::rtl::OUString & _rsMessage);
82 
83             virtual ~OConnection();
84         public:
85 
86             OConnection(OFileDriver*    _pDriver);
87 
88             virtual void construct(const ::rtl::OUString& _rUrl,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rInfo ) throw( ::com::sun::star::sdbc::SQLException);
89 
90             void closeAllStatements () throw( ::com::sun::star::sdbc::SQLException);
91 
92             // OComponentHelper
93             virtual void SAL_CALL disposing(void);
94             // XInterface
95             virtual void SAL_CALL release() throw();
96 
97             // XServiceInfo
98             DECLARE_SERVICE_INFO();
99 
100             // XConnection
101             virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement > SAL_CALL createStatement(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
102             virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
103             virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareCall( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
104             virtual ::rtl::OUString SAL_CALL nativeSQL( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
105             virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
106             virtual sal_Bool SAL_CALL getAutoCommit(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
107             virtual void SAL_CALL commit(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
108             virtual void SAL_CALL rollback(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
109             virtual sal_Bool SAL_CALL isClosed(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
110             virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > SAL_CALL getMetaData(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
111             virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
112             virtual sal_Bool SAL_CALL isReadOnly(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
113             virtual void SAL_CALL setCatalog( const ::rtl::OUString& catalog ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
114             virtual ::rtl::OUString SAL_CALL getCatalog(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
115             virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
116             virtual sal_Int32 SAL_CALL getTransactionIsolation(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
117             virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTypeMap(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
118             virtual void SAL_CALL setTypeMap( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
119             // XCloseable
120             virtual void SAL_CALL close(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
121             // XWarningsSupplier
122             virtual ::com::sun::star::uno::Any SAL_CALL getWarnings(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
123             virtual void SAL_CALL clearWarnings(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
124             //XUnoTunnel
125             virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw (::com::sun::star::uno::RuntimeException);
126             static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
127 
128             // no interface methods
129             ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XDynamicResultSet > getDir() const;
getContent() const130             ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent>  getContent() const { return m_xContent; }
131             // create a catalog or return the catalog already created
132             virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > createCatalog();
133 
134             sal_Bool                matchesExtension( const String& _rExt ) const;
135 
getExtension() const136             inline const String&    getExtension()              const { return m_aFilenameExtension; }
isCaseSensitveExtension() const137             inline sal_Bool         isCaseSensitveExtension()   const { return m_bCaseSensitiveExtension; }
getDriver() const138             inline OFileDriver*     getDriver()                 const { return m_pDriver; }
showDeleted() const139             inline sal_Bool         showDeleted()               const { return m_bShowDeleted; }
isCheckEnabled() const140             inline sal_Bool         isCheckEnabled()            const { return m_bCheckSQL92; }
isTextEncodingDefaulted() const141             inline bool             isTextEncodingDefaulted()   const { return m_bDefaultTextEncoding; }
142 
143         public:
144             struct GrantAccess
145             {
146                 friend class ODatabaseMetaData;
147             private:
GrantAccessconnectivity::file::OConnection::GrantAccess148                 GrantAccess() { }
149             };
150 
setCaseSensitiveExtension(sal_Bool _bIsCS,GrantAccess)151             void    setCaseSensitiveExtension( sal_Bool _bIsCS, GrantAccess ) { m_bCaseSensitiveExtension = _bIsCS; }
152         };
153     }
154 }
155 #endif // _CONNECTIVITY_FILE_OCONNECTION_HXX_
156 
157