merge the formfield patch from ooo-build
[ooovba.git] / connectivity / source / inc / hsqldb / HConnection.hxx
blobc97a0dac6be253926a4ade3464e679387365fd6b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: HConnection.hxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef CONNECTIVITY_HSQLDB_CONNECTION_HXX
32 #define CONNECTIVITY_HSQLDB_CONNECTION_HXX
34 #include "connectivity/ConnectionWrapper.hxx"
35 /** === begin UNO includes === **/
36 #include <com/sun/star/util/XFlushable.hpp>
37 #include <com/sun/star/sdbc/XDriver.hpp>
38 #ifndef __com_sun_star_sdb_application_XTableUIProvider_hpp__
39 #include <com/sun/star/sdb/application/XTableUIProvider.hpp>
40 #endif
41 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
42 /** === end UNO includes === **/
43 #include <cppuhelper/compbase2.hxx>
44 #include <comphelper/uno3.hxx>
45 #include <cppuhelper/interfacecontainer.hxx>
46 #include <memory>
48 namespace connectivity
50 namespace hsqldb
52 class SAL_NO_VTABLE IMethodGuardAccess
54 public:
55 virtual ::osl::Mutex& getMutex() const = 0;
56 virtual void checkDisposed() const = 0;
59 //==========================================================================
60 //= OHsqlConnection - wraps all methods to the real connection from the driver
61 //= but when disposed it doesn't dispose the real connection
62 //==========================================================================
63 typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::util::XFlushable
64 , ::com::sun::star::sdb::application::XTableUIProvider
65 > OHsqlConnection_BASE;
67 class OHsqlConnection :public ::comphelper::OBaseMutex
68 ,public OHsqlConnection_BASE
69 ,public OConnectionWrapper
70 ,public IMethodGuardAccess
72 private:
73 ::cppu::OInterfaceContainerHelper m_aFlushListeners;
74 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > m_xDriver;
75 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB;
76 bool m_bIni;
77 bool m_bReadOnly;
79 protected:
80 virtual void SAL_CALL disposing(void);
81 virtual ~OHsqlConnection();
83 public:
84 OHsqlConnection(
85 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > _rxDriver,
86 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,
87 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _xORB
90 // XServiceInfo
91 DECLARE_SERVICE_INFO();
92 DECLARE_XTYPEPROVIDER()
93 DECLARE_XINTERFACE( )
95 // IMethodGuardAccess
96 virtual ::osl::Mutex& getMutex() const;
97 virtual void checkDisposed() const;
99 // XFlushable
100 virtual void SAL_CALL flush( ) throw (::com::sun::star::uno::RuntimeException);
101 virtual void SAL_CALL addFlushListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XFlushListener >& l ) throw (::com::sun::star::uno::RuntimeException);
102 virtual void SAL_CALL removeFlushListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XFlushListener >& l ) throw (::com::sun::star::uno::RuntimeException);
104 // XTableUIProvider
105 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);
106 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);
108 private:
109 #if 0
110 // TODO: resource
111 /** creates the dialog used for editing a linked table
113 @param _rTableName
114 the name of the table to create the editor for.
116 @param _rxDocumentUI
117 the UI of the database document, for which the editor is to be created.
118 Must not be <NULL/>.
120 @return
121 the table editor dialog instance.
123 @throws ::com::sun::star::lang::WrappedTargetException
124 if creating the dialog instance fails
126 @throws ::com::sun::star::uno::RuntimeException
127 if a serious error occures
129 @precond
130 Our mutex is locked.
132 ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XExecutableDialog >
133 impl_createLinkedTableEditor_throw(
134 const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >& _rxDocumentUI,
135 const ::rtl::OUString& _rTableName
137 #endif
139 /** retrieves our table container
140 @return
141 our table container. Guaranteed to not be <NULL/>.
142 @throws ::com::sun::star::lang::WrappedTargetException
143 if a non-RuntimeException is caught during obtaining the container.
144 @throws ::com::sun::star::uno::RuntimeException
145 if a serious error occurs
146 @precond
147 We're not disposed.
149 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
150 impl_getTableContainer_throw();
152 /** checks whether the given table name denotes an existing table
153 @param _rTableName
154 the fully name of the table to check for existence
155 @throws ::com::sun::star::lang::IllegalArgumentException
156 if the name does not denote an existing table
157 @precond
158 We're not disposed.
160 void impl_checkExistingTable_throw( const ::rtl::OUString& _rTableName );
162 /** checks whether the given table name refers to a HSQL TEXT TABLE
164 bool impl_isTextTable_nothrow( const ::rtl::OUString& _rTableName );
166 /** retrieves the icon for HSQL TEXT TABLEs
168 ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >
169 impl_getTextTableIcon_nothrow( ::sal_Int32 _ColorMode );
172 //==========================================================================
173 //= OHsqlConnection
174 //==========================================================================
175 class MethodGuard : public ::osl::MutexGuard
177 private:
178 typedef ::osl::MutexGuard BaseGuard;
180 public:
181 MethodGuard( const IMethodGuardAccess& _rComponent )
182 :BaseGuard( _rComponent.getMutex() )
184 _rComponent.checkDisposed();
189 #endif // CONNECTIVITY_HSQLDB_CONNECTION_HXX