tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / connectivity / source / cpool / ZDriverWrapper.cxx
blob9a1bdf971f97a6af0b013dec42820b18bc3daacd
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 #include "ZDriverWrapper.hxx"
21 #include "ZConnectionPool.hxx"
22 #include <osl/diagnose.h>
25 namespace connectivity
29 using namespace ::com::sun::star::uno;
30 using namespace ::com::sun::star::sdbc;
31 using namespace ::com::sun::star::beans;
33 ODriverWrapper::ODriverWrapper( Reference< XAggregation >& _rxAggregateDriver, OConnectionPool* _pPool )
34 :m_pConnectionPool(_pPool)
36 OSL_ENSURE(_rxAggregateDriver.is(), "ODriverWrapper::ODriverWrapper: invalid aggregate!");
37 OSL_ENSURE(m_pConnectionPool.is(), "ODriverWrapper::ODriverWrapper: invalid connection pool!");
39 osl_atomic_increment( &m_refCount );
40 if (_rxAggregateDriver.is())
42 // transfer the (one and only) real ref to the aggregate to our member
43 m_xDriverAggregate = _rxAggregateDriver;
44 _rxAggregateDriver = nullptr;
46 // a second "real" reference
47 m_xDriver.set(m_xDriverAggregate, UNO_QUERY);
48 OSL_ENSURE(m_xDriver.is(), "ODriverWrapper::ODriverWrapper: invalid aggregate (no XDriver)!");
50 // set ourself as delegator
51 m_xDriverAggregate->setDelegator( getXWeak() );
53 osl_atomic_decrement( &m_refCount );
57 ODriverWrapper::~ODriverWrapper()
59 if (m_xDriverAggregate.is())
60 m_xDriverAggregate->setDelegator(nullptr);
64 Any SAL_CALL ODriverWrapper::queryInterface( const Type& _rType )
66 Any aReturn = ODriverWrapper_BASE::queryInterface(_rType);
67 return aReturn.hasValue() ? aReturn : (m_xDriverAggregate.is() ? m_xDriverAggregate->queryAggregation(_rType) : aReturn);
71 Reference< XConnection > SAL_CALL ODriverWrapper::connect( const OUString& url, const Sequence< PropertyValue >& info )
73 Reference< XConnection > xConnection;
74 if (m_pConnectionPool.is())
75 // route this through the pool
76 xConnection = m_pConnectionPool->getConnectionWithInfo( url, info );
77 else if (m_xDriver.is())
78 xConnection = m_xDriver->connect( url, info );
80 return xConnection;
84 sal_Bool SAL_CALL ODriverWrapper::acceptsURL( const OUString& url )
86 return m_xDriver.is() && m_xDriver->acceptsURL(url);
90 Sequence< DriverPropertyInfo > SAL_CALL ODriverWrapper::getPropertyInfo( const OUString& url, const Sequence< PropertyValue >& info )
92 Sequence< DriverPropertyInfo > aInfo;
93 if (m_xDriver.is())
94 aInfo = m_xDriver->getPropertyInfo(url, info);
95 return aInfo;
99 sal_Int32 SAL_CALL ODriverWrapper::getMajorVersion( )
101 return m_xDriver.is() ? m_xDriver->getMajorVersion() : 0;
105 sal_Int32 SAL_CALL ODriverWrapper::getMinorVersion( )
107 return m_xDriver.is() ? m_xDriver->getMinorVersion() : 0;
111 } // namespace connectivity
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */