Update ooo320-m1
[ooovba.git] / connectivity / source / commontools / TConnection.cxx
blob36b5c8a31562b03109a2f726184760c674c1b2d5
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: TConnection.cxx,v $
10 * $Revision: 1.9.56.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_connectivity.hxx"
33 #include "TConnection.hxx"
34 #include <cppuhelper/typeprovider.hxx>
35 #include <comphelper/types.hxx>
36 #include <comphelper/officeresourcebundle.hxx>
37 #include <connectivity/dbexception.hxx>
39 using namespace connectivity;
40 using namespace com::sun::star::uno;
41 using namespace com::sun::star::lang;
42 using namespace com::sun::star::sdbc;
43 using namespace com::sun::star::beans;
44 using namespace ::osl;
46 //------------------------------------------------------------------------------
47 OMetaConnection::OMetaConnection()
48 : OMetaConnection_BASE(m_aMutex)
49 , m_nTextEncoding(RTL_TEXTENCODING_MS_1252)
52 //------------------------------------------------------------------------------
53 void OMetaConnection::disposing()
55 ::osl::MutexGuard aGuard(m_aMutex);
56 m_xMetaData = WeakReference< XDatabaseMetaData>();
57 for (OWeakRefArray::iterator i = m_aStatements.begin(); m_aStatements.end() != i; ++i)
59 try
61 Reference< XInterface > xStatement( i->get() );
62 ::comphelper::disposeComponent( xStatement );
64 catch (DisposedException)
68 m_aStatements.clear();
70 //XUnoTunnel
71 sal_Int64 SAL_CALL OMetaConnection::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw (::com::sun::star::uno::RuntimeException)
73 return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
74 ? reinterpret_cast< sal_Int64 >( this )
75 : (sal_Int64)0;
77 // -----------------------------------------------------------------------------
78 Sequence< sal_Int8 > OMetaConnection::getUnoTunnelImplementationId()
80 static ::cppu::OImplementationId * pId = 0;
81 if (! pId)
83 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
84 if (! pId)
86 static ::cppu::OImplementationId aId;
87 pId = &aId;
90 return pId->getImplementationId();
92 // -----------------------------------------------------------------------------
93 ::dbtools::OPropertyMap& OMetaConnection::getPropMap()
95 static ::dbtools::OPropertyMap s_aPropertyNameMap;
96 return s_aPropertyNameMap;
98 // -----------------------------------------------------------------------------
99 void OMetaConnection::throwGenericSQLException( sal_uInt16 _nErrorResourceId,const Reference< XInterface>& _xContext )
101 ::rtl::OUString sErrorMessage;
102 if ( _nErrorResourceId )
103 sErrorMessage = m_aResources.getResourceString( _nErrorResourceId );
104 Reference< XInterface> xContext = _xContext;
105 if ( !xContext.is() )
106 xContext = *this;
107 ::dbtools::throwGenericSQLException( sErrorMessage, xContext);