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 
10 #ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MCONNECTION_HXX
11 #define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MCONNECTION_HXX
12 
13 #include <TConnection.hxx>
14 #include "MColumnAlias.hxx"
15 
16 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
17 
18 // do we want here namespace too?
19 class MorkParser;
20 
21 namespace connectivity
22 {
23     namespace mork
24     {
25         class MorkDriver;
26         class ErrorDescriptor;
27 
28         typedef connectivity::OMetaConnection OConnection_BASE; // implements basics and text encoding
29 
30         class OConnection final : public OConnection_BASE
31         {
32             // Data attributes
33 
34             rtl::Reference<MorkDriver> m_xDriver;              //  Pointer to the owning
35                                                                //  driver object
36             OColumnAlias    m_aColumnAlias;
37             // Mork Parser (abook)
38             std::unique_ptr<MorkParser> m_pBook;
39             // Mork Parser (history)
40             std::unique_ptr<MorkParser> m_pHistory;
41             // Store Catalog
42             css::uno::Reference< css::sdbcx::XTablesSupplier> m_xCatalog;
43 
44         public:
45             /// @throws css::sdbc::SQLException
46             void construct( const OUString& url);
47             explicit OConnection(MorkDriver* const driver);
48             virtual ~OConnection() override;
49 
getDriver() const50             const rtl::Reference<MorkDriver>& getDriver() const {return m_xDriver;};
getMorkParser(const OString & t)51             MorkParser* getMorkParser(const OString& t) {return t == "CollectedAddressBook" ? m_pHistory.get() : m_pBook.get();};
52 
53             // OComponentHelper
54             virtual void SAL_CALL disposing() override;
55 
56             // XServiceInfo
57             DECLARE_SERVICE_INFO();
58             // XConnection
59             virtual css::uno::Reference< css::sdbc::XStatement > SAL_CALL createStatement(  ) override;
60             virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const OUString& sql ) override;
61             virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareCall( const OUString& sql ) override;
62             virtual OUString SAL_CALL nativeSQL( const OUString& sql ) override;
63             virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) override;
64             virtual sal_Bool SAL_CALL getAutoCommit(  ) override;
65             virtual void SAL_CALL commit(  ) override;
66             virtual void SAL_CALL rollback(  ) override;
67             virtual sal_Bool SAL_CALL isClosed(  ) override;
68             virtual css::uno::Reference< css::sdbc::XDatabaseMetaData > SAL_CALL getMetaData(  ) override;
69             virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) override;
70             virtual sal_Bool SAL_CALL isReadOnly(  ) override;
71             virtual void SAL_CALL setCatalog( const OUString& catalog ) override;
72             virtual OUString SAL_CALL getCatalog(  ) override;
73             virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) override;
74             virtual sal_Int32 SAL_CALL getTransactionIsolation(  ) override;
75             virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTypeMap(  ) override;
76             virtual void SAL_CALL setTypeMap( const css::uno::Reference< css::container::XNameAccess >& typeMap ) override;
77             // XCloseable
78             virtual void SAL_CALL close(  ) override;
79             // XWarningsSupplier
80             virtual css::uno::Any SAL_CALL getWarnings(  ) override;
81             virtual void SAL_CALL clearWarnings() override;
82 
getColumnAlias() const83             const OColumnAlias & getColumnAlias() const   { return m_aColumnAlias; }
84 
getForceLoadTables()85             static bool getForceLoadTables() {return true;}
86 
87             // Added to enable me to use SQLInterpreter which requires an
88             // XNameAccess i/f to access tables.
89             css::uno::Reference< css::sdbcx::XTablesSupplier > createCatalog();
90 
91             void throwSQLException( const ErrorDescriptor& _rError, const css::uno::Reference< css::uno::XInterface >& _rxContext );
92             void throwSQLException( const char* pErrorResourceId, const css::uno::Reference< css::uno::XInterface >& _rxContext );
93         };
94     }
95 }
96 #endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MCONNECTION_HXX
97 
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
99