Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include <string.h>
21 : #include "TConnection.hxx"
22 : #include <cppuhelper/typeprovider.hxx>
23 : #include <comphelper/types.hxx>
24 : #include <comphelper/officeresourcebundle.hxx>
25 : #include <connectivity/dbexception.hxx>
26 :
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;
33 :
34 :
35 50 : OMetaConnection::OMetaConnection()
36 : : OMetaConnection_BASE(m_aMutex)
37 50 : , m_nTextEncoding(RTL_TEXTENCODING_MS_1252)
38 : {
39 50 : }
40 :
41 46 : void OMetaConnection::disposing()
42 : {
43 46 : ::osl::MutexGuard aGuard(m_aMutex);
44 46 : m_xMetaData = WeakReference< XDatabaseMetaData>();
45 382 : for (OWeakRefArray::iterator i = m_aStatements.begin(); m_aStatements.end() != i; ++i)
46 : {
47 : try
48 : {
49 336 : Reference< XInterface > xStatement( i->get() );
50 336 : ::comphelper::disposeComponent( xStatement );
51 : }
52 0 : catch (const DisposedException&)
53 : {
54 : }
55 : }
56 46 : m_aStatements.clear();
57 46 : }
58 : //XUnoTunnel
59 10 : sal_Int64 SAL_CALL OMetaConnection::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw (::com::sun::star::uno::RuntimeException, std::exception)
60 : {
61 40 : return (rId.getLength() == 16 && 0 == memcmp(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
62 : ? reinterpret_cast< sal_Int64 >( this )
63 39 : : (sal_Int64)0;
64 : }
65 :
66 19 : Sequence< sal_Int8 > OMetaConnection::getUnoTunnelImplementationId()
67 : {
68 : static ::cppu::OImplementationId * pId = 0;
69 19 : if (! pId)
70 : {
71 4 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
72 4 : if (! pId)
73 : {
74 4 : static ::cppu::OImplementationId aId;
75 4 : pId = &aId;
76 4 : }
77 : }
78 19 : return pId->getImplementationId();
79 : }
80 :
81 102329 : ::dbtools::OPropertyMap& OMetaConnection::getPropMap()
82 : {
83 102329 : static ::dbtools::OPropertyMap s_aPropertyNameMap;
84 102329 : return s_aPropertyNameMap;
85 : }
86 :
87 22 : void OMetaConnection::throwGenericSQLException( sal_uInt16 _nErrorResourceId,const Reference< XInterface>& _xContext )
88 : {
89 22 : OUString sErrorMessage;
90 22 : if ( _nErrorResourceId )
91 22 : sErrorMessage = m_aResources.getResourceString( _nErrorResourceId );
92 44 : Reference< XInterface> xContext = _xContext;
93 22 : if ( !xContext.is() )
94 0 : xContext = *this;
95 44 : ::dbtools::throwGenericSQLException( sErrorMessage, xContext);
96 0 : }
97 :
98 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|