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_HSQLDB_CONNECTION_HXX
21 : #define CONNECTIVITY_HSQLDB_CONNECTION_HXX
22 :
23 : #include "connectivity/ConnectionWrapper.hxx"
24 : #include <com/sun/star/util/XFlushable.hpp>
25 : #include <com/sun/star/sdbc/XDriver.hpp>
26 : #ifndef __com_sun_star_sdb_application_XTableUIProvider_hpp__
27 : #include <com/sun/star/sdb/application/XTableUIProvider.hpp>
28 : #endif
29 : #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
30 : #include <cppuhelper/compbase2.hxx>
31 : #include <comphelper/uno3.hxx>
32 : #include <cppuhelper/interfacecontainer.hxx>
33 : #include <memory>
34 :
35 : namespace connectivity
36 : {
37 : namespace hsqldb
38 : {
39 0 : class SAL_NO_VTABLE IMethodGuardAccess
40 : {
41 : public:
42 : virtual ::osl::Mutex& getMutex() const = 0;
43 : virtual void checkDisposed() const = 0;
44 :
45 : protected:
46 0 : ~IMethodGuardAccess() {}
47 : };
48 :
49 : //==========================================================================
50 : //= OHsqlConnection - wraps all methods to the real connection from the driver
51 : //= but when disposed it doesn't dispose the real connection
52 : //==========================================================================
53 : typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::util::XFlushable
54 : , ::com::sun::star::sdb::application::XTableUIProvider
55 : > OHsqlConnection_BASE;
56 :
57 : class OHsqlConnection :public ::comphelper::OBaseMutex
58 : ,public OHsqlConnection_BASE
59 : ,public OConnectionWrapper
60 : ,public IMethodGuardAccess
61 : {
62 : private:
63 : ::cppu::OInterfaceContainerHelper m_aFlushListeners;
64 : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > m_xDriver;
65 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
66 : bool m_bIni;
67 : bool m_bReadOnly;
68 :
69 : protected:
70 : virtual void SAL_CALL disposing(void);
71 : virtual ~OHsqlConnection();
72 :
73 : public:
74 : OHsqlConnection(
75 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > _rxDriver,
76 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,
77 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext
78 : );
79 :
80 : // XServiceInfo
81 : DECLARE_SERVICE_INFO();
82 : DECLARE_XTYPEPROVIDER()
83 : DECLARE_XINTERFACE( )
84 :
85 : // IMethodGuardAccess
86 : virtual ::osl::Mutex& getMutex() const;
87 : virtual void checkDisposed() const;
88 :
89 : // XFlushable
90 : virtual void SAL_CALL flush( ) throw (::com::sun::star::uno::RuntimeException);
91 : virtual void SAL_CALL addFlushListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XFlushListener >& l ) throw (::com::sun::star::uno::RuntimeException);
92 : virtual void SAL_CALL removeFlushListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XFlushListener >& l ) throw (::com::sun::star::uno::RuntimeException);
93 :
94 : // XTableUIProvider
95 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > SAL_CALL getTableIcon( const ::rtl::OUString& TableName, ::sal_Int32 ColorMode ) throw (::com::sun::star::uno::RuntimeException);
96 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getTableEditor( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >& DocumentUI, const ::rtl::OUString& TableName ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
97 :
98 : private:
99 :
100 : /** retrieves our table container
101 : @return
102 : our table container. Guaranteed to not be <NULL/>.
103 : @throws ::com::sun::star::lang::WrappedTargetException
104 : if a non-RuntimeException is caught during obtaining the container.
105 : @throws ::com::sun::star::uno::RuntimeException
106 : if a serious error occurs
107 : @precond
108 : We're not disposed.
109 : */
110 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
111 : impl_getTableContainer_throw();
112 :
113 : /** checks whether the given table name denotes an existing table
114 : @param _rTableName
115 : the fully name of the table to check for existence
116 : @throws ::com::sun::star::lang::IllegalArgumentException
117 : if the name does not denote an existing table
118 : @precond
119 : We're not disposed.
120 : */
121 : void impl_checkExistingTable_throw( const ::rtl::OUString& _rTableName );
122 :
123 : /** checks whether the given table name refers to a HSQL TEXT TABLE
124 : */
125 : bool impl_isTextTable_nothrow( const ::rtl::OUString& _rTableName );
126 :
127 : /** retrieves the icon for HSQL TEXT TABLEs
128 : */
129 : ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >
130 : impl_getTextTableIcon_nothrow();
131 : };
132 :
133 : //==========================================================================
134 : //= OHsqlConnection
135 : //==========================================================================
136 0 : class MethodGuard : public ::osl::MutexGuard
137 : {
138 : private:
139 : typedef ::osl::MutexGuard BaseGuard;
140 :
141 : public:
142 0 : MethodGuard( const IMethodGuardAccess& _rComponent )
143 0 : :BaseGuard( _rComponent.getMutex() )
144 : {
145 0 : _rComponent.checkDisposed();
146 0 : }
147 : };
148 : }
149 : }
150 : #endif // CONNECTIVITY_HSQLDB_CONNECTION_HXX
151 :
152 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|