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 0 : OMetaConnection::OMetaConnection()
36 : : OMetaConnection_BASE(m_aMutex)
37 0 : , m_nTextEncoding(RTL_TEXTENCODING_MS_1252)
38 : {
39 0 : }
40 :
41 0 : void OMetaConnection::disposing()
42 : {
43 0 : ::osl::MutexGuard aGuard(m_aMutex);
44 0 : m_xMetaData = WeakReference< XDatabaseMetaData>();
45 0 : for (OWeakRefArray::iterator i = m_aStatements.begin(); m_aStatements.end() != i; ++i)
46 : {
47 : try
48 : {
49 0 : Reference< XInterface > xStatement( i->get() );
50 0 : ::comphelper::disposeComponent( xStatement );
51 : }
52 0 : catch (const DisposedException&)
53 : {
54 : }
55 : }
56 0 : m_aStatements.clear();
57 0 : }
58 : //XUnoTunnel
59 0 : 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 0 : return (rId.getLength() == 16 && 0 == memcmp(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
62 : ? reinterpret_cast< sal_Int64 >( this )
63 0 : : (sal_Int64)0;
64 : }
65 :
66 0 : Sequence< sal_Int8 > OMetaConnection::getUnoTunnelImplementationId()
67 : {
68 : static ::cppu::OImplementationId * pId = 0;
69 0 : if (! pId)
70 : {
71 0 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
72 0 : if (! pId)
73 : {
74 0 : static ::cppu::OImplementationId aId;
75 0 : pId = &aId;
76 0 : }
77 : }
78 0 : return pId->getImplementationId();
79 : }
80 :
81 0 : ::dbtools::OPropertyMap& OMetaConnection::getPropMap()
82 : {
83 0 : static ::dbtools::OPropertyMap s_aPropertyNameMap;
84 0 : return s_aPropertyNameMap;
85 : }
86 :
87 0 : void OMetaConnection::throwGenericSQLException( sal_uInt16 _nErrorResourceId,const Reference< XInterface>& _xContext )
88 : {
89 0 : OUString sErrorMessage;
90 0 : if ( _nErrorResourceId )
91 0 : sErrorMessage = m_aResources.getResourceString( _nErrorResourceId );
92 0 : Reference< XInterface> xContext = _xContext;
93 0 : if ( !xContext.is() )
94 0 : xContext = *this;
95 0 : ::dbtools::throwGenericSQLException( sErrorMessage, xContext);
96 0 : }
97 :
98 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|