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