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 .
21 #include "TConnection.hxx"
22 #include <cppuhelper/typeprovider.hxx>
23 #include <comphelper/types.hxx>
24 #include <comphelper/officeresourcebundle.hxx>
25 #include <connectivity/dbexception.hxx>
27 using namespace connectivity
;
28 using namespace com::sun::star::uno
;
29 using namespace com::sun::star::lang
;
30 using namespace com::sun::star::sdbc
;
31 using namespace com::sun::star::beans
;
32 using namespace ::osl
;
35 OMetaConnection::OMetaConnection()
36 : OMetaConnection_BASE(m_aMutex
)
37 , m_nTextEncoding(RTL_TEXTENCODING_MS_1252
)
41 void OMetaConnection::disposing()
43 ::osl::MutexGuard
aGuard(m_aMutex
);
44 m_xMetaData
= WeakReference
< XDatabaseMetaData
>();
45 for (OWeakRefArray::iterator i
= m_aStatements
.begin(); m_aStatements
.end() != i
; ++i
)
49 Reference
< XInterface
> xStatement( i
->get() );
50 ::comphelper::disposeComponent( xStatement
);
52 catch (const DisposedException
&)
56 m_aStatements
.clear();
59 sal_Int64 SAL_CALL
OMetaConnection::getSomething( const ::com::sun::star::uno::Sequence
< sal_Int8
>& rId
) throw (::com::sun::star::uno::RuntimeException
, std::exception
)
61 return (rId
.getLength() == 16 && 0 == memcmp(getUnoTunnelImplementationId().getConstArray(), rId
.getConstArray(), 16 ) )
62 ? reinterpret_cast< sal_Int64
>( this )
66 Sequence
< sal_Int8
> OMetaConnection::getUnoTunnelImplementationId()
68 static ::cppu::OImplementationId
* pId
= 0;
71 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
74 static ::cppu::OImplementationId aId
;
78 return pId
->getImplementationId();
81 ::dbtools::OPropertyMap
& OMetaConnection::getPropMap()
83 static ::dbtools::OPropertyMap s_aPropertyNameMap
;
84 return s_aPropertyNameMap
;
87 void OMetaConnection::throwGenericSQLException( sal_uInt16 _nErrorResourceId
,const Reference
< XInterface
>& _xContext
)
89 OUString sErrorMessage
;
90 if ( _nErrorResourceId
)
91 sErrorMessage
= m_aResources
.getResourceString( _nErrorResourceId
);
92 Reference
< XInterface
> xContext
= _xContext
;
95 ::dbtools::throwGenericSQLException( sErrorMessage
, xContext
);
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */