bump product version to 6.3.0.0.beta1
[LibreOffice.git] / connectivity / source / commontools / TConnection.cxx
blob779ea853520ff6596c8121ea09d2d8ec499538c5
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 <string.h>
21 #include <TConnection.hxx>
22 #include <cppuhelper/typeprovider.hxx>
23 #include <comphelper/types.hxx>
24 #include <connectivity/dbexception.hxx>
26 using namespace connectivity;
27 using namespace com::sun::star::uno;
28 using namespace com::sun::star::lang;
29 using namespace com::sun::star::sdbc;
30 using namespace com::sun::star::beans;
31 using namespace ::osl;
34 OMetaConnection::OMetaConnection()
35 : OMetaConnection_BASE(m_aMutex)
36 , m_nTextEncoding(RTL_TEXTENCODING_MS_1252)
40 void OMetaConnection::disposing()
42 ::osl::MutexGuard aGuard(m_aMutex);
43 m_xMetaData = WeakReference< XDatabaseMetaData>();
44 for (auto const& statement : m_aStatements)
46 try
48 Reference< XInterface > xStatement( statement.get() );
49 ::comphelper::disposeComponent( xStatement );
51 catch (const DisposedException&)
55 m_aStatements.clear();
57 //XUnoTunnel
58 sal_Int64 SAL_CALL OMetaConnection::getSomething( const css::uno::Sequence< sal_Int8 >& rId )
60 return (rId.getLength() == 16 && 0 == memcmp(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
61 ? reinterpret_cast< sal_Int64 >( this )
62 : sal_Int64(0);
65 Sequence< sal_Int8 > OMetaConnection::getUnoTunnelImplementationId()
67 static ::cppu::OImplementationId implId;
69 return implId.getImplementationId();
72 ::dbtools::OPropertyMap& OMetaConnection::getPropMap()
74 static ::dbtools::OPropertyMap s_aPropertyNameMap;
75 return s_aPropertyNameMap;
78 void OMetaConnection::throwGenericSQLException(const char* pErrorResourceId, const Reference< XInterface>& _xContext )
80 OUString sErrorMessage;
81 if (pErrorResourceId)
82 sErrorMessage = m_aResources.getResourceString(pErrorResourceId);
83 Reference< XInterface> xContext = _xContext;
84 if ( !xContext.is() )
85 xContext = *this;
86 ::dbtools::throwGenericSQLException( sErrorMessage, xContext);
89 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */