sd: keep a non-owning pointer to the OverridingShell
[LibreOffice.git] / connectivity / source / commontools / TConnection.cxx
blobc730946a56b7631d3d7d9eef919d2998dc3c446c
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 <TConnection.hxx>
21 #include <comphelper/servicehelper.hxx>
22 #include <comphelper/types.hxx>
23 #include <connectivity/dbexception.hxx>
25 using namespace connectivity;
26 using namespace com::sun::star::uno;
27 using namespace com::sun::star::lang;
28 using namespace com::sun::star::sdbc;
29 using namespace ::osl;
32 OMetaConnection::OMetaConnection()
33 : OMetaConnection_BASE(m_aMutex)
34 , m_nTextEncoding(RTL_TEXTENCODING_MS_1252)
38 void OMetaConnection::disposing()
40 ::osl::MutexGuard aGuard(m_aMutex);
41 m_xMetaData = WeakReference< XDatabaseMetaData>();
42 for (auto const& statement : m_aStatements)
44 try
46 Reference< XInterface > xStatement( statement.get() );
47 ::comphelper::disposeComponent( xStatement );
49 catch (const DisposedException&)
53 m_aStatements.clear();
55 //XUnoTunnel
56 sal_Int64 SAL_CALL OMetaConnection::getSomething( const css::uno::Sequence< sal_Int8 >& rId )
58 return comphelper::getSomethingImpl(rId, this);
61 const Sequence< sal_Int8 > & OMetaConnection::getUnoTunnelId()
63 static const comphelper::UnoIdInit implId;
64 return implId.getSeq();
67 ::dbtools::OPropertyMap& OMetaConnection::getPropMap()
69 static ::dbtools::OPropertyMap s_aPropertyNameMap;
70 return s_aPropertyNameMap;
73 void OMetaConnection::throwGenericSQLException(TranslateId pErrorResourceId, const Reference< XInterface>& _xContext )
75 OUString sErrorMessage;
76 if (pErrorResourceId)
77 sErrorMessage = m_aResources.getResourceString(pErrorResourceId);
78 Reference< XInterface> xContext = _xContext;
79 if ( !xContext.is() )
80 xContext = *this;
81 ::dbtools::throwGenericSQLException( sErrorMessage, xContext);
84 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */