1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <connectivity/ConnectionWrapper.hxx>
23 #include <com/sun/star/util/XFlushable.hpp>
24 #include <com/sun/star/sdbc/XDriver.hpp>
25 #include <com/sun/star/sdb/application/XTableUIProvider.hpp>
26 #include <cppuhelper/compbase.hxx>
27 #include <cppuhelper/basemutex.hxx>
28 #include <comphelper/uno3.hxx>
29 #include <comphelper/interfacecontainer2.hxx>
31 namespace connectivity::hsqldb
33 class SAL_NO_VTABLE IMethodGuardAccess
36 virtual ::osl::Mutex
& getMutex() const = 0;
37 virtual void checkDisposed() const = 0;
40 ~IMethodGuardAccess() {}
44 // OHsqlConnection - wraps all methods to the real connection from the driver
45 // but when disposed it doesn't dispose the real connection
47 typedef ::cppu::ImplInheritanceHelper
< OConnectionWrapper
48 , css::util::XFlushable
49 , css::sdb::application::XTableUIProvider
50 > OHsqlConnection_BASE
;
52 class OHsqlConnection
:public OHsqlConnection_BASE
53 ,public IMethodGuardAccess
56 ::comphelper::OInterfaceContainerHelper2 m_aFlushListeners
;
57 css::uno::Reference
< css::sdbc::XDriver
> m_xDriver
;
58 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
63 virtual void SAL_CALL
disposing() override
;
64 virtual ~OHsqlConnection() override
;
68 const css::uno::Reference
< css::sdbc::XDriver
>& _rxDriver
,
69 const css::uno::Reference
< css::sdbc::XConnection
>& _xConnection
,
70 const css::uno::Reference
< css::uno::XComponentContext
>& _rxContext
74 DECLARE_SERVICE_INFO();
77 virtual ::osl::Mutex
& getMutex() const override
;
78 virtual void checkDisposed() const override
;
81 virtual void SAL_CALL
flush( ) override
;
82 virtual void SAL_CALL
addFlushListener( const css::uno::Reference
< css::util::XFlushListener
>& l
) override
;
83 virtual void SAL_CALL
removeFlushListener( const css::uno::Reference
< css::util::XFlushListener
>& l
) override
;
86 virtual css::uno::Reference
< css::graphic::XGraphic
> SAL_CALL
getTableIcon( const OUString
& TableName
, ::sal_Int32 ColorMode
) override
;
87 virtual css::uno::Reference
< css::uno::XInterface
> SAL_CALL
getTableEditor( const css::uno::Reference
< css::sdb::application::XDatabaseDocumentUI
>& DocumentUI
, const OUString
& TableName
) override
;
91 /** retrieves our table container
93 our table container. Guaranteed to not be <NULL/>.
94 @throws css::lang::WrappedTargetException
95 if a non-RuntimeException is caught during obtaining the container.
96 @throws css::uno::RuntimeException
97 if a serious error occurs
101 css::uno::Reference
< css::container::XNameAccess
>
102 impl_getTableContainer_throw();
104 /** checks whether the given table name denotes an existing table
106 the fully name of the table to check for existence
107 @throws css::lang::IllegalArgumentException
108 if the name does not denote an existing table
112 void impl_checkExistingTable_throw( const OUString
& _rTableName
);
114 /** checks whether the given table name refers to a HSQL TEXT TABLE
116 bool impl_isTextTable_nothrow( const OUString
& _rTableName
);
118 /** retrieves the icon for HSQL TEXT TABLEs
120 css::uno::Reference
< css::graphic::XGraphic
>
121 impl_getTextTableIcon_nothrow();
127 class MethodGuard
: public ::osl::MutexGuard
130 MethodGuard( const IMethodGuardAccess
& _rComponent
)
131 : ::osl::MutexGuard( _rComponent
.getMutex() )
133 _rComponent
.checkDisposed();
139 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */