Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / connectivity / source / inc / hsqldb / HConnection.hxx
blob19739437bf82c0a4d451ebcc44154ff5ef21cac0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_HSQLDB_HCONNECTION_HXX
21 #define INCLUDED_CONNECTIVITY_SOURCE_INC_HSQLDB_HCONNECTION_HXX
23 #include <connectivity/ConnectionWrapper.hxx>
24 #include <com/sun/star/util/XFlushable.hpp>
25 #include <com/sun/star/sdbc/XDriver.hpp>
26 #include <com/sun/star/sdb/application/XTableUIProvider.hpp>
27 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
28 #include <cppuhelper/compbase.hxx>
29 #include <cppuhelper/basemutex.hxx>
30 #include <comphelper/uno3.hxx>
31 #include <comphelper/interfacecontainer2.hxx>
33 namespace connectivity
35 namespace hsqldb
37 class SAL_NO_VTABLE IMethodGuardAccess
39 public:
40 virtual ::osl::Mutex& getMutex() const = 0;
41 virtual void checkDisposed() const = 0;
43 protected:
44 ~IMethodGuardAccess() {}
48 // OHsqlConnection - wraps all methods to the real connection from the driver
49 // but when disposed it doesn't dispose the real connection
51 typedef ::cppu::WeakComponentImplHelper< css::util::XFlushable
52 , css::sdb::application::XTableUIProvider
53 > OHsqlConnection_BASE;
55 class OHsqlConnection :public cppu::BaseMutex
56 ,public OHsqlConnection_BASE
57 ,public OConnectionWrapper
58 ,public IMethodGuardAccess
60 private:
61 ::comphelper::OInterfaceContainerHelper2 m_aFlushListeners;
62 css::uno::Reference< css::sdbc::XDriver > m_xDriver;
63 css::uno::Reference< css::uno::XComponentContext > m_xContext;
64 bool m_bIni;
65 bool m_bReadOnly;
67 protected:
68 virtual void SAL_CALL disposing() override;
69 virtual ~OHsqlConnection() override;
71 public:
72 OHsqlConnection(
73 const css::uno::Reference< css::sdbc::XDriver >& _rxDriver,
74 const css::uno::Reference< css::sdbc::XConnection >& _xConnection,
75 const css::uno::Reference< css::uno::XComponentContext>& _rxContext
78 // XServiceInfo
79 DECLARE_SERVICE_INFO();
80 DECLARE_XTYPEPROVIDER()
81 DECLARE_XINTERFACE( )
83 // IMethodGuardAccess
84 virtual ::osl::Mutex& getMutex() const override;
85 virtual void checkDisposed() const override;
87 // XFlushable
88 virtual void SAL_CALL flush( ) override;
89 virtual void SAL_CALL addFlushListener( const css::uno::Reference< css::util::XFlushListener >& l ) override;
90 virtual void SAL_CALL removeFlushListener( const css::uno::Reference< css::util::XFlushListener >& l ) override;
92 // XTableUIProvider
93 virtual css::uno::Reference< css::graphic::XGraphic > SAL_CALL getTableIcon( const OUString& TableName, ::sal_Int32 ColorMode ) override;
94 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getTableEditor( const css::uno::Reference< css::sdb::application::XDatabaseDocumentUI >& DocumentUI, const OUString& TableName ) override;
96 private:
98 /** retrieves our table container
99 @return
100 our table container. Guaranteed to not be <NULL/>.
101 @throws css::lang::WrappedTargetException
102 if a non-RuntimeException is caught during obtaining the container.
103 @throws css::uno::RuntimeException
104 if a serious error occurs
105 @precond
106 We're not disposed.
108 css::uno::Reference< css::container::XNameAccess >
109 impl_getTableContainer_throw();
111 /** checks whether the given table name denotes an existing table
112 @param _rTableName
113 the fully name of the table to check for existence
114 @throws css::lang::IllegalArgumentException
115 if the name does not denote an existing table
116 @precond
117 We're not disposed.
119 void impl_checkExistingTable_throw( const OUString& _rTableName );
121 /** checks whether the given table name refers to a HSQL TEXT TABLE
123 bool impl_isTextTable_nothrow( const OUString& _rTableName );
125 /** retrieves the icon for HSQL TEXT TABLEs
127 css::uno::Reference< css::graphic::XGraphic >
128 impl_getTextTableIcon_nothrow();
132 // OHsqlConnection
134 class MethodGuard : public ::osl::MutexGuard
136 private:
137 typedef ::osl::MutexGuard BaseGuard;
139 public:
140 MethodGuard( const IMethodGuardAccess& _rComponent )
141 :BaseGuard( _rComponent.getMutex() )
143 _rComponent.checkDisposed();
148 #endif // INCLUDED_CONNECTIVITY_SOURCE_INC_HSQLDB_HCONNECTION_HXX
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */