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 .
20 #include "ZConnectionWrapper.hxx"
22 using namespace connectivity
;
24 using namespace com::sun::star::uno
;
25 using namespace com::sun::star::lang
;
26 using namespace com::sun::star::beans
;
27 using namespace com::sun::star::sdbc
;
29 OConnectionWeakWrapper::OConnectionWeakWrapper(Reference
< XAggregation
>& _xConnection
)
30 : OConnectionWeakWrapper_BASE(m_aMutex
)
32 setDelegation(_xConnection
,m_refCount
);
33 OSL_ENSURE(m_xConnection
.is(),"OConnectionWeakWrapper: Connection must be valid!");
36 OConnectionWeakWrapper::~OConnectionWeakWrapper()
38 if ( !OConnectionWeakWrapper_BASE::rBHelper
.bDisposed
)
40 osl_atomic_increment( &m_refCount
);
46 IMPLEMENT_SERVICE_INFO(OConnectionWeakWrapper
, "com.sun.star.sdbc.drivers.OConnectionWeakWrapper", "com.sun.star.sdbc.Connection")
49 Reference
< XStatement
> SAL_CALL
OConnectionWeakWrapper::createStatement( )
51 ::osl::MutexGuard
aGuard( m_aMutex
);
52 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper
.bDisposed
);
55 return m_xConnection
->createStatement();
58 Reference
< XPreparedStatement
> SAL_CALL
OConnectionWeakWrapper::prepareStatement( const OUString
& sql
)
60 ::osl::MutexGuard
aGuard( m_aMutex
);
61 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper
.bDisposed
);
64 return m_xConnection
->prepareStatement(sql
);
67 Reference
< XPreparedStatement
> SAL_CALL
OConnectionWeakWrapper::prepareCall( const OUString
& sql
)
69 ::osl::MutexGuard
aGuard( m_aMutex
);
70 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper
.bDisposed
);
73 return m_xConnection
->prepareCall(sql
);
76 OUString SAL_CALL
OConnectionWeakWrapper::nativeSQL( const OUString
& sql
)
78 ::osl::MutexGuard
aGuard( m_aMutex
);
79 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper
.bDisposed
);
82 return m_xConnection
->nativeSQL(sql
);
85 void SAL_CALL
OConnectionWeakWrapper::setAutoCommit( sal_Bool autoCommit
)
87 ::osl::MutexGuard
aGuard( m_aMutex
);
88 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper
.bDisposed
);
90 m_xConnection
->setAutoCommit(autoCommit
);
93 sal_Bool SAL_CALL
OConnectionWeakWrapper::getAutoCommit( )
95 ::osl::MutexGuard
aGuard( m_aMutex
);
96 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper
.bDisposed
);
99 return m_xConnection
->getAutoCommit();
102 void SAL_CALL
OConnectionWeakWrapper::commit( )
104 ::osl::MutexGuard
aGuard( m_aMutex
);
105 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper
.bDisposed
);
108 m_xConnection
->commit();
111 void SAL_CALL
OConnectionWeakWrapper::rollback( )
113 ::osl::MutexGuard
aGuard( m_aMutex
);
114 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper
.bDisposed
);
117 m_xConnection
->rollback();
120 sal_Bool SAL_CALL
OConnectionWeakWrapper::isClosed( )
122 ::osl::MutexGuard
aGuard( m_aMutex
);
124 return m_xConnection
->isClosed();
127 Reference
< XDatabaseMetaData
> SAL_CALL
OConnectionWeakWrapper::getMetaData( )
129 ::osl::MutexGuard
aGuard( m_aMutex
);
130 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper
.bDisposed
);
133 return m_xConnection
->getMetaData();
136 void SAL_CALL
OConnectionWeakWrapper::setReadOnly( sal_Bool readOnly
)
138 ::osl::MutexGuard
aGuard( m_aMutex
);
139 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper
.bDisposed
);
142 m_xConnection
->setReadOnly(readOnly
);
145 sal_Bool SAL_CALL
OConnectionWeakWrapper::isReadOnly( )
147 ::osl::MutexGuard
aGuard( m_aMutex
);
148 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper
.bDisposed
);
151 return m_xConnection
->isReadOnly();
154 void SAL_CALL
OConnectionWeakWrapper::setCatalog( const OUString
& catalog
)
156 ::osl::MutexGuard
aGuard( m_aMutex
);
157 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper
.bDisposed
);
160 m_xConnection
->setCatalog(catalog
);
163 OUString SAL_CALL
OConnectionWeakWrapper::getCatalog( )
165 ::osl::MutexGuard
aGuard( m_aMutex
);
166 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper
.bDisposed
);
169 return m_xConnection
->getCatalog();
172 void SAL_CALL
OConnectionWeakWrapper::setTransactionIsolation( sal_Int32 level
)
174 ::osl::MutexGuard
aGuard( m_aMutex
);
175 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper
.bDisposed
);
178 m_xConnection
->setTransactionIsolation(level
);
181 sal_Int32 SAL_CALL
OConnectionWeakWrapper::getTransactionIsolation( )
183 ::osl::MutexGuard
aGuard( m_aMutex
);
184 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper
.bDisposed
);
187 return m_xConnection
->getTransactionIsolation();
190 Reference
< css::container::XNameAccess
> SAL_CALL
OConnectionWeakWrapper::getTypeMap( )
192 ::osl::MutexGuard
aGuard( m_aMutex
);
193 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper
.bDisposed
);
196 return m_xConnection
->getTypeMap();
199 void SAL_CALL
OConnectionWeakWrapper::setTypeMap( const Reference
< css::container::XNameAccess
>& typeMap
)
201 ::osl::MutexGuard
aGuard( m_aMutex
);
202 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper
.bDisposed
);
205 m_xConnection
->setTypeMap(typeMap
);
209 void SAL_CALL
OConnectionWeakWrapper::close( )
212 ::osl::MutexGuard
aGuard( m_aMutex
);
213 checkDisposed(OConnectionWeakWrapper_BASE::rBHelper
.bDisposed
);
219 void OConnectionWeakWrapper::disposing()
221 ::osl::MutexGuard
aGuard(m_aMutex
);
223 OConnectionWeakWrapper_BASE::disposing();
224 OConnectionWrapper::disposing();
227 // css::lang::XUnoTunnel
228 IMPLEMENT_FORWARD_REFCOUNT( OConnectionWeakWrapper
, OConnectionWeakWrapper_BASE
)
230 css::uno::Any SAL_CALL
OConnectionWeakWrapper::queryInterface( const css::uno::Type
& _rType
)
232 css::uno::Any aReturn
= OConnectionWeakWrapper_BASE::queryInterface( _rType
);
233 if ( !aReturn
.hasValue() )
234 aReturn
= OConnectionWrapper::queryInterface( _rType
);
238 IMPLEMENT_FORWARD_XTYPEPROVIDER2(OConnectionWeakWrapper
,OConnectionWeakWrapper_BASE
,OConnectionWrapper
)
241 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */