xref: /trunk/main/connectivity/source/inc/file/FConnection.hxx (revision 914d351e5f5b84e4342a86d6ab8d4aca7308b9bd)
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
10cdf0e10cSrcweir  *
11*caf5cd79SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
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.
19cdf0e10cSrcweir  *
20*caf5cd79SAndrew Rist  *************************************************************/
21*caf5cd79SAndrew Rist 
22*caf5cd79SAndrew Rist 
23cdf0e10cSrcweir #ifndef _CONNECTIVITY_FILE_OCONNECTION_HXX_
24cdf0e10cSrcweir #define _CONNECTIVITY_FILE_OCONNECTION_HXX_
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <com/sun/star/ucb/XContent.hpp>
27cdf0e10cSrcweir #include <com/sun/star/sdbc/SQLWarning.hpp>
28cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
29cdf0e10cSrcweir #include "OSubComponent.hxx"
30cdf0e10cSrcweir #ifndef _MAP_
31cdf0e10cSrcweir #include <map>
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir #include "connectivity/CommonTools.hxx"
34cdf0e10cSrcweir #include "OTypeInfo.hxx"
35cdf0e10cSrcweir #include <tools/string.hxx>
36cdf0e10cSrcweir #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
37cdf0e10cSrcweir #include <com/sun/star/ucb/XDynamicResultSet.hpp>
38cdf0e10cSrcweir #include "connectivity/sqlparse.hxx"
39cdf0e10cSrcweir #include "connectivity/sqliterator.hxx"
40cdf0e10cSrcweir #include "TConnection.hxx"
41cdf0e10cSrcweir #include "file/filedllapi.hxx"
42cdf0e10cSrcweir 
43cdf0e10cSrcweir namespace connectivity
44cdf0e10cSrcweir {
45cdf0e10cSrcweir     namespace file
46cdf0e10cSrcweir     {
47cdf0e10cSrcweir 
48cdf0e10cSrcweir         class OStatement_Base;
49cdf0e10cSrcweir         class ODatabaseMetaData;
50cdf0e10cSrcweir         class OFileDriver;
51cdf0e10cSrcweir 
52cdf0e10cSrcweir         class OOO_DLLPUBLIC_FILE OConnection :
53cdf0e10cSrcweir                             public connectivity::OMetaConnection,
54cdf0e10cSrcweir                             public connectivity::OSubComponent<OConnection, connectivity::OMetaConnection>
55cdf0e10cSrcweir         {
56cdf0e10cSrcweir             friend class connectivity::OSubComponent<OConnection, connectivity::OMetaConnection>;
57cdf0e10cSrcweir 
58cdf0e10cSrcweir         protected:
59cdf0e10cSrcweir             //====================================================================
60cdf0e10cSrcweir             // Data attributes
61cdf0e10cSrcweir             //====================================================================
62cdf0e10cSrcweir             ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbcx::XTablesSupplier>         m_xCatalog;
63cdf0e10cSrcweir 
64cdf0e10cSrcweir             ::com::sun::star::sdbc::SQLWarning            m_aLastWarning; //      Last SQLWarning generated by
65cdf0e10cSrcweir 
66cdf0e10cSrcweir             String                      m_aFilenameExtension;
67cdf0e10cSrcweir             OFileDriver*                m_pDriver;      //  Pointer to the owning
68cdf0e10cSrcweir                                                         //  driver object
69cdf0e10cSrcweir             ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XDynamicResultSet >    m_xDir; // directory
70cdf0e10cSrcweir             ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent>              m_xContent;
71cdf0e10cSrcweir 
72cdf0e10cSrcweir             sal_Bool                    m_bClosed;
73cdf0e10cSrcweir             sal_Bool                    m_bAutoCommit;
74cdf0e10cSrcweir             sal_Bool                    m_bReadOnly;
75cdf0e10cSrcweir             sal_Bool                    m_bShowDeleted;
76cdf0e10cSrcweir             sal_Bool                    m_bCaseSensitiveExtension;
77cdf0e10cSrcweir             sal_Bool                    m_bCheckSQL92;
78cdf0e10cSrcweir             bool                        m_bDefaultTextEncoding;
79cdf0e10cSrcweir 
80cdf0e10cSrcweir 
81cdf0e10cSrcweir             void throwUrlNotValid(const ::rtl::OUString & _rsUrl,const ::rtl::OUString & _rsMessage);
82cdf0e10cSrcweir 
83cdf0e10cSrcweir             virtual ~OConnection();
84cdf0e10cSrcweir         public:
85cdf0e10cSrcweir 
86cdf0e10cSrcweir             OConnection(OFileDriver*    _pDriver);
87cdf0e10cSrcweir 
88cdf0e10cSrcweir             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);
89cdf0e10cSrcweir 
90cdf0e10cSrcweir             void closeAllStatements () throw( ::com::sun::star::sdbc::SQLException);
91cdf0e10cSrcweir 
92cdf0e10cSrcweir             // OComponentHelper
93cdf0e10cSrcweir             virtual void SAL_CALL disposing(void);
94cdf0e10cSrcweir             // XInterface
95cdf0e10cSrcweir             virtual void SAL_CALL release() throw();
96cdf0e10cSrcweir 
97cdf0e10cSrcweir             // XServiceInfo
98cdf0e10cSrcweir             DECLARE_SERVICE_INFO();
99cdf0e10cSrcweir 
100cdf0e10cSrcweir             // XConnection
101cdf0e10cSrcweir             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);
102cdf0e10cSrcweir             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);
103cdf0e10cSrcweir             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);
104cdf0e10cSrcweir             virtual ::rtl::OUString SAL_CALL nativeSQL( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
105cdf0e10cSrcweir             virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
106cdf0e10cSrcweir             virtual sal_Bool SAL_CALL getAutoCommit(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
107cdf0e10cSrcweir             virtual void SAL_CALL commit(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
108cdf0e10cSrcweir             virtual void SAL_CALL rollback(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
109cdf0e10cSrcweir             virtual sal_Bool SAL_CALL isClosed(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
110cdf0e10cSrcweir             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);
111cdf0e10cSrcweir             virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
112cdf0e10cSrcweir             virtual sal_Bool SAL_CALL isReadOnly(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
113cdf0e10cSrcweir             virtual void SAL_CALL setCatalog( const ::rtl::OUString& catalog ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
114cdf0e10cSrcweir             virtual ::rtl::OUString SAL_CALL getCatalog(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
115cdf0e10cSrcweir             virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
116cdf0e10cSrcweir             virtual sal_Int32 SAL_CALL getTransactionIsolation(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
117cdf0e10cSrcweir             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);
118cdf0e10cSrcweir             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);
119cdf0e10cSrcweir             // XCloseable
120cdf0e10cSrcweir             virtual void SAL_CALL close(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
121cdf0e10cSrcweir             // XWarningsSupplier
122cdf0e10cSrcweir             virtual ::com::sun::star::uno::Any SAL_CALL getWarnings(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
123cdf0e10cSrcweir             virtual void SAL_CALL clearWarnings(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
124cdf0e10cSrcweir             //XUnoTunnel
125cdf0e10cSrcweir             virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw (::com::sun::star::uno::RuntimeException);
126cdf0e10cSrcweir             static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
127cdf0e10cSrcweir 
128cdf0e10cSrcweir             // no interface methods
129cdf0e10cSrcweir             ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XDynamicResultSet > getDir() const;
getContent() const130cdf0e10cSrcweir             ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent>  getContent() const { return m_xContent; }
131cdf0e10cSrcweir             // create a catalog or return the catalog already created
132cdf0e10cSrcweir             virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > createCatalog();
133cdf0e10cSrcweir 
134cdf0e10cSrcweir             sal_Bool                matchesExtension( const String& _rExt ) const;
135cdf0e10cSrcweir 
getExtension() const136cdf0e10cSrcweir             inline const String&    getExtension()              const { return m_aFilenameExtension; }
isCaseSensitveExtension() const137cdf0e10cSrcweir             inline sal_Bool         isCaseSensitveExtension()   const { return m_bCaseSensitiveExtension; }
getDriver() const138cdf0e10cSrcweir             inline OFileDriver*     getDriver()                 const { return m_pDriver; }
showDeleted() const139cdf0e10cSrcweir             inline sal_Bool         showDeleted()               const { return m_bShowDeleted; }
isCheckEnabled() const140cdf0e10cSrcweir             inline sal_Bool         isCheckEnabled()            const { return m_bCheckSQL92; }
isTextEncodingDefaulted() const141cdf0e10cSrcweir             inline bool             isTextEncodingDefaulted()   const { return m_bDefaultTextEncoding; }
142cdf0e10cSrcweir 
143cdf0e10cSrcweir         public:
144cdf0e10cSrcweir             struct GrantAccess
145cdf0e10cSrcweir             {
146cdf0e10cSrcweir                 friend class ODatabaseMetaData;
147cdf0e10cSrcweir             private:
GrantAccessconnectivity::file::OConnection::GrantAccess148cdf0e10cSrcweir                 GrantAccess() { }
149cdf0e10cSrcweir             };
150cdf0e10cSrcweir 
setCaseSensitiveExtension(sal_Bool _bIsCS,GrantAccess)151cdf0e10cSrcweir             void    setCaseSensitiveExtension( sal_Bool _bIsCS, GrantAccess ) { m_bCaseSensitiveExtension = _bIsCS; }
152cdf0e10cSrcweir         };
153cdf0e10cSrcweir     }
154cdf0e10cSrcweir }
155cdf0e10cSrcweir #endif // _CONNECTIVITY_FILE_OCONNECTION_HXX_
156