Branch libreoffice-5-0-4
[LibreOffice.git] / include / connectivity / ConnectionWrapper.hxx
blob21bafca49c924ccc96461e525eb772709fad57d2
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 #ifndef INCLUDED_CONNECTIVITY_CONNECTIONWRAPPER_HXX
21 #define INCLUDED_CONNECTIVITY_CONNECTIONWRAPPER_HXX
23 #include <cppuhelper/implbase2.hxx>
24 #include <com/sun/star/lang/XServiceInfo.hpp>
25 #include <com/sun/star/beans/PropertyValue.hpp>
26 #include <com/sun/star/lang/XUnoTunnel.hpp>
27 #include <com/sun/star/sdbc/XConnection.hpp>
28 #include <com/sun/star/uno/XComponentContext.hpp>
29 #include <comphelper/broadcasthelper.hxx>
30 #include <connectivity/CommonTools.hxx>
31 #include <connectivity/dbtoolsdllapi.hxx>
33 namespace connectivity
37 //= OConnectionWrapper - wraps all methods to the real connection from the driver
38 //= but when disposed it doesn't dispose the real connection
40 typedef ::cppu::ImplHelper2< ::com::sun::star::lang::XServiceInfo,
41 ::com::sun::star::lang::XUnoTunnel
42 > OConnection_BASE;
44 class OOO_DLLPUBLIC_DBTOOLS OConnectionWrapper : public OConnection_BASE
46 protected:
47 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation > m_xProxyConnection;
48 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
49 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XTypeProvider > m_xTypeProvider;
50 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > m_xUnoTunnel;
51 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XServiceInfo > m_xServiceInfo;
53 virtual ~OConnectionWrapper();
54 void setDelegation(::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation >& _rxProxyConnection,oslInterlockedCount& _rRefCount);
55 void setDelegation(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection
56 ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext
57 ,oslInterlockedCount& _rRefCount);
58 // must be called from derived classes
59 void disposing();
60 public:
61 OConnectionWrapper( );
63 // XServiceInfo
64 DECLARE_SERVICE_INFO();
65 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
66 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
68 // com::sun::star::lang::XUnoTunnel
69 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
70 static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
71 /** method to create unique ids
72 @param _rURL
73 The URL.
74 @param _rInfo
75 The info property of the datasource. It will be resorted if needed.
76 @param _pBuffer
77 Here we store the digest. Must not NULL.
78 @param _rUserName
79 The user name.
80 @param _rPassword
81 The password.
83 static void createUniqueId( const OUString& _rURL
84 ,::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rInfo
85 ,sal_uInt8* _pBuffer
86 ,const OUString& _rUserName = OUString()
87 ,const OUString& _rPassword = OUString());
90 #endif // INCLUDED_CONNECTIVITY_CONNECTIONWRAPPER_HXX
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */