xref: /AOO41X/main/connectivity/source/drivers/macab/MacabConnection.hxx (revision 67e470dafe1997e73f56ff7ff4878983707e3e07)
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 
24 #ifndef _CONNECTIVITY_MACAB_CONNECTION_HXX_
25 #define _CONNECTIVITY_MACAB_CONNECTION_HXX_
26 
27 #include <map>
28 #include "OSubComponent.hxx"
29 #include "connectivity/CommonTools.hxx"
30 #include <com/sun/star/lang/XServiceInfo.hpp>
31 #include <com/sun/star/sdbc/SQLWarning.hpp>
32 #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
33 #include <com/sun/star/sdbc/XConnection.hpp>
34 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
35 #include <comphelper/broadcasthelper.hxx>
36 #include <cppuhelper/compbase3.hxx>
37 #include "TConnection.hxx"
38 
39 namespace connectivity
40 {
41     namespace macab
42     {
43 
44         typedef ::cppu::WeakComponentImplHelper3<   ::com::sun::star::sdbc::XConnection,
45                                                 ::com::sun::star::sdbc::XWarningsSupplier,
46                                                 ::com::sun::star::lang::XServiceInfo
47                                             > OMetaConnection_BASE;
48 
49         class MacabStatement_Base;
50         class MacabDriver;
51         class MacabDatabaseMetaData;
52         class MacabAddressBook;
53 
54         //typedef OMetaConnection_BASE              MacabConnection_BASE; // implements basics and text encoding
55         typedef std::vector< ::com::sun::star::uno::WeakReferenceHelper > OWeakRefArray;
56 
57         typedef connectivity::OMetaConnection MacabConnection_BASE;
58 
59         class MacabConnection : public MacabConnection_BASE,
60                             public OSubComponent<MacabConnection, MacabConnection_BASE>
61         {
62             friend class OSubComponent<MacabConnection, MacabConnection_BASE>;
63 
64         protected:
65             //====================================================================
66             // Data attributes
67             //====================================================================
68             MacabAddressBook*                   m_pAddressBook; // the address book
69             MacabDriver*                                m_pDriver;      // pointer to the owning driver object
70             ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier>
71                                                     m_xCatalog;     // needed for the SQL interpreter
72 
73         public:
74             virtual void construct( const ::rtl::OUString& url,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info) throw(::com::sun::star::sdbc::SQLException);
75 
76             MacabConnection(MacabDriver* _pDriver);
77             virtual ~MacabConnection();
78 
79             void closeAllStatements () throw( ::com::sun::star::sdbc::SQLException);
80 
81             // OComponentHelper
82             virtual void SAL_CALL disposing(void);
83 
84             // XInterface
85             virtual void SAL_CALL release() throw();
86 
87             // XServiceInfo
88             DECLARE_SERVICE_INFO();
89 
90             // XConnection
91             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);
92             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);
93             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);
94             virtual ::rtl::OUString SAL_CALL nativeSQL( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
95             virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
96             virtual sal_Bool SAL_CALL getAutoCommit(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
97             virtual void SAL_CALL commit(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
98             virtual void SAL_CALL rollback(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
99             virtual sal_Bool SAL_CALL isClosed(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
100             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);
101             virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
102             virtual sal_Bool SAL_CALL isReadOnly(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
103             virtual void SAL_CALL setCatalog( const ::rtl::OUString& catalog ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
104             virtual ::rtl::OUString SAL_CALL getCatalog(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
105             virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
106             virtual sal_Int32 SAL_CALL getTransactionIsolation(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
107             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);
108             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);
109 
110             // XCloseable
111             virtual void SAL_CALL close(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
112 
113             // XWarningsSupplier
114             virtual ::com::sun::star::uno::Any SAL_CALL getWarnings(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
115             virtual void SAL_CALL clearWarnings(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
116 
117             // needed for the SQL interpreter
118             ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL createCatalog();
119 
120             // accessors
getDriver() const121             inline MacabDriver*         getDriver()         const { return m_pDriver;}
122                    MacabAddressBook* getAddressBook()   const;
123         };
124     }
125 }
126 
127 #endif // _CONNECTIVITY_MACAB_CONNECTION_HXX_
128