Bump for 3.6-28
[LibreOffice.git] / connectivity / source / drivers / ado / AConnection.cxx
blob40c93b3d66b79ee3d4f1e5098c505bf81045ae12
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include "ado/AConnection.hxx"
30 #include "ado/ADatabaseMetaData.hxx"
31 #include "ado/ADriver.hxx"
32 #include "ado/AStatement.hxx"
33 #include "ado/ACallableStatement.hxx"
34 #include "ado/APreparedStatement.hxx"
35 #include "ado/ACatalog.hxx"
36 #include <com/sun/star/sdbc/ColumnValue.hpp>
37 #include <com/sun/star/sdbc/TransactionIsolation.hpp>
38 #include <com/sun/star/sdbc/XRow.hpp>
39 #include <com/sun/star/lang/DisposedException.hpp>
40 #include <cppuhelper/typeprovider.hxx>
41 #include "connectivity/dbexception.hxx"
42 #include <osl/file.hxx>
43 #include "resource/ado_res.hrc"
45 #include <o3tl/compat_functional.hxx>
47 using namespace dbtools;
48 using namespace connectivity::ado;
49 using namespace com::sun::star::uno;
50 using namespace com::sun::star::lang;
51 using namespace com::sun::star::beans;
52 using namespace com::sun::star::sdbc;
53 using namespace com::sun::star::sdbcx;
55 //------------------------------------------------------------------------------
56 IMPLEMENT_SERVICE_INFO(OConnection,"com.sun.star.sdbcx.AConnection","com.sun.star.sdbc.Connection");
57 // --------------------------------------------------------------------------------
58 OConnection::OConnection(ODriver* _pDriver) throw(SQLException, RuntimeException)
59 : OSubComponent<OConnection, OConnection_BASE>((::cppu::OWeakObject*)_pDriver, this),
60 m_xCatalog(NULL),
61 m_pDriver(_pDriver),
62 m_pAdoConnection(NULL),
63 m_pCatalog(NULL),
64 m_nEngineType(0),
65 m_bClosed(sal_False),
66 m_bAutocommit(sal_True)
68 osl_incrementInterlockedCount( &m_refCount );
70 IClassFactory2* pIUnknown = NULL;
71 IUnknown *pOuter = NULL;
72 HRESULT hr;
73 hr = CoGetClassObject( ADOS::CLSID_ADOCONNECTION_21,
74 CLSCTX_INPROC_SERVER,
75 NULL,
76 IID_IClassFactory2,
77 (void**)&pIUnknown );
79 if( !FAILED( hr ) )
81 ADOConnection *pCon = NULL;
82 hr = pIUnknown->CreateInstanceLic( pOuter,
83 NULL,
84 ADOS::IID_ADOCONNECTION_21,
85 ADOS::GetKeyStr(),
86 (void**) &pCon);
88 if( !FAILED( hr ) )
90 OSL_ENSURE( pCon, "OConnection::OConnection: invalid ADO object!" );
92 m_pAdoConnection = new WpADOConnection( pCon );
93 // CreateInstanceLic returned an object which was already acquired
94 pCon->Release( );
98 // Class Factory is no longer needed
99 pIUnknown->Release();
102 osl_decrementInterlockedCount( &m_refCount );
104 //-----------------------------------------------------------------------------
105 OConnection::~OConnection()
108 //-----------------------------------------------------------------------------
109 void OConnection::construct(const ::rtl::OUString& url,const Sequence< PropertyValue >& info)
111 osl_incrementInterlockedCount( &m_refCount );
113 setConnectionInfo(info);
115 sal_Int32 nLen = url.indexOf(':');
116 nLen = url.indexOf(':',nLen+1);
117 ::rtl::OUString aDSN(url.copy(nLen+1)),aUID,aPWD;
118 if ( aDSN.compareToAscii("access:",7) == 0 )
119 aDSN = aDSN.copy(7);
121 sal_Int32 nTimeout = 20;
122 sal_Bool bSilent = sal_True;
123 const PropertyValue *pIter = info.getConstArray();
124 const PropertyValue *pEnd = pIter + info.getLength();
125 for(;pIter != pEnd;++pIter)
127 if(!pIter->Name.compareToAscii("Timeout"))
128 pIter->Value >>= nTimeout;
129 else if(!pIter->Name.compareToAscii("Silent"))
130 pIter->Value >>= bSilent;
131 else if(!pIter->Name.compareToAscii("user"))
132 pIter->Value >>= aUID;
133 else if(!pIter->Name.compareToAscii("password"))
134 pIter->Value >>= aPWD;
138 if(m_pAdoConnection)
140 if(m_pAdoConnection->Open(aDSN,aUID,aPWD,adConnectUnspecified))
141 m_pAdoConnection->PutCommandTimeout(nTimeout);
142 else
143 ADOS::ThrowException(*m_pAdoConnection,*this);
144 if(m_pAdoConnection->get_State() != adStateOpen)
145 throwGenericSQLException( STR_NO_CONNECTION,*this );
147 WpADOProperties aProps = m_pAdoConnection->get_Properties();
148 if(aProps.IsValid())
150 OTools::putValue(aProps,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Jet OLEDB:ODBC Parsing")),sal_True);
151 OLEVariant aVar(OTools::getValue(aProps,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Jet OLEDB:Engine Type"))));
152 if(!aVar.isNull() && !aVar.isEmpty())
153 m_nEngineType = aVar;
155 buildTypeInfo();
156 //bErg = TRUE;
158 else
159 ::dbtools::throwFunctionSequenceException(*this);
162 catch(const Exception& )
164 osl_decrementInterlockedCount( &m_refCount );
165 throw;
167 osl_decrementInterlockedCount( &m_refCount );
169 //-----------------------------------------------------------------------------
170 void SAL_CALL OConnection::release() throw()
172 relase_ChildImpl();
174 // --------------------------------------------------------------------------------
175 Reference< XStatement > SAL_CALL OConnection::createStatement( ) throw(SQLException, RuntimeException)
177 ::osl::MutexGuard aGuard( m_aMutex );
178 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
180 OStatement* pStmt = new OStatement(this);
181 Reference< XStatement > xStmt = pStmt;
182 m_aStatements.push_back(WeakReferenceHelper(*pStmt));
183 return pStmt;
185 // --------------------------------------------------------------------------------
186 Reference< XPreparedStatement > SAL_CALL OConnection::prepareStatement( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
188 ::osl::MutexGuard aGuard( m_aMutex );
189 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
192 OPreparedStatement* pStmt = new OPreparedStatement(this,m_aTypeInfo,sql);
193 Reference< XPreparedStatement > xPStmt = pStmt;
194 m_aStatements.push_back(WeakReferenceHelper(*pStmt));
195 return xPStmt;
197 // --------------------------------------------------------------------------------
198 Reference< XPreparedStatement > SAL_CALL OConnection::prepareCall( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
200 ::osl::MutexGuard aGuard( m_aMutex );
201 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
204 OCallableStatement* pStmt = new OCallableStatement(this,m_aTypeInfo,sql);
205 Reference< XPreparedStatement > xPStmt = pStmt;
206 m_aStatements.push_back(WeakReferenceHelper(*pStmt));
207 return xPStmt;
209 // --------------------------------------------------------------------------------
210 ::rtl::OUString SAL_CALL OConnection::nativeSQL( const ::rtl::OUString& _sql ) throw(SQLException, RuntimeException)
212 ::osl::MutexGuard aGuard( m_aMutex );
213 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
216 ::rtl::OUString sql = _sql;
217 WpADOProperties aProps = m_pAdoConnection->get_Properties();
218 if(aProps.IsValid())
220 OTools::putValue(aProps,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Jet OLEDB:ODBC Parsing")),sal_True);
221 WpADOCommand aCommand;
222 aCommand.Create();
223 aCommand.put_ActiveConnection((IDispatch*)*m_pAdoConnection);
224 aCommand.put_CommandText(sql);
225 sql = aCommand.get_CommandText();
228 return sql;
230 // --------------------------------------------------------------------------------
231 void SAL_CALL OConnection::setAutoCommit( sal_Bool autoCommit ) throw(SQLException, RuntimeException)
233 ::osl::MutexGuard aGuard( m_aMutex );
234 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
237 m_bAutocommit = autoCommit;
238 if(!autoCommit)
239 m_pAdoConnection->BeginTrans();
240 else
241 m_pAdoConnection->RollbackTrans();
243 // --------------------------------------------------------------------------------
244 sal_Bool SAL_CALL OConnection::getAutoCommit( ) throw(SQLException, RuntimeException)
246 ::osl::MutexGuard aGuard( m_aMutex );
247 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
250 return m_bAutocommit;
252 // --------------------------------------------------------------------------------
253 void SAL_CALL OConnection::commit( ) throw(SQLException, RuntimeException)
255 ::osl::MutexGuard aGuard( m_aMutex );
256 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
259 m_pAdoConnection->CommitTrans();
261 // --------------------------------------------------------------------------------
262 void SAL_CALL OConnection::rollback( ) throw(SQLException, RuntimeException)
264 ::osl::MutexGuard aGuard( m_aMutex );
265 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
268 m_pAdoConnection->RollbackTrans();
270 // --------------------------------------------------------------------------------
271 sal_Bool SAL_CALL OConnection::isClosed( ) throw(SQLException, RuntimeException)
273 ::osl::MutexGuard aGuard( m_aMutex );
275 return OConnection_BASE::rBHelper.bDisposed && !m_pAdoConnection->get_State();
277 // --------------------------------------------------------------------------------
278 Reference< XDatabaseMetaData > SAL_CALL OConnection::getMetaData( ) throw(SQLException, RuntimeException)
280 ::osl::MutexGuard aGuard( m_aMutex );
281 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
284 Reference< XDatabaseMetaData > xMetaData = m_xMetaData;
285 if(!xMetaData.is())
287 xMetaData = new ODatabaseMetaData(this);
288 m_xMetaData = xMetaData;
291 return xMetaData;
293 // --------------------------------------------------------------------------------
294 void SAL_CALL OConnection::setReadOnly( sal_Bool readOnly ) throw(SQLException, RuntimeException)
296 ::osl::MutexGuard aGuard( m_aMutex );
297 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
301 m_pAdoConnection->put_Mode(readOnly ? adModeRead : adModeReadWrite);
302 ADOS::ThrowException(*m_pAdoConnection,*this);
304 // --------------------------------------------------------------------------------
305 sal_Bool SAL_CALL OConnection::isReadOnly( ) throw(SQLException, RuntimeException)
307 ::osl::MutexGuard aGuard( m_aMutex );
308 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
311 return m_pAdoConnection->get_Mode() == adModeRead;
313 // --------------------------------------------------------------------------------
314 void SAL_CALL OConnection::setCatalog( const ::rtl::OUString& catalog ) throw(SQLException, RuntimeException)
316 ::osl::MutexGuard aGuard( m_aMutex );
317 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
319 m_pAdoConnection->PutDefaultDatabase(catalog);
320 ADOS::ThrowException(*m_pAdoConnection,*this);
322 // --------------------------------------------------------------------------------
323 ::rtl::OUString SAL_CALL OConnection::getCatalog( ) throw(SQLException, RuntimeException)
325 ::osl::MutexGuard aGuard( m_aMutex );
326 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
328 return m_pAdoConnection->GetDefaultDatabase();
330 // --------------------------------------------------------------------------------
331 void SAL_CALL OConnection::setTransactionIsolation( sal_Int32 level ) throw(SQLException, RuntimeException)
333 ::osl::MutexGuard aGuard( m_aMutex );
334 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
337 IsolationLevelEnum eIso;
338 switch(level)
340 case TransactionIsolation::NONE:
341 eIso = adXactUnspecified;
342 break;
343 case TransactionIsolation::READ_UNCOMMITTED:
344 eIso = adXactReadUncommitted;
345 break;
346 case TransactionIsolation::READ_COMMITTED:
347 eIso = adXactReadCommitted;
348 break;
349 case TransactionIsolation::REPEATABLE_READ:
350 eIso = adXactRepeatableRead;
351 break;
352 case TransactionIsolation::SERIALIZABLE:
353 eIso = adXactSerializable;
354 break;
355 default:
356 OSL_FAIL("OConnection::setTransactionIsolation invalid level");
357 return;
359 m_pAdoConnection->put_IsolationLevel(eIso);
360 ADOS::ThrowException(*m_pAdoConnection,*this);
362 // --------------------------------------------------------------------------------
363 sal_Int32 SAL_CALL OConnection::getTransactionIsolation( ) throw(SQLException, RuntimeException)
365 ::osl::MutexGuard aGuard( m_aMutex );
366 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
369 sal_Int32 nRet = 0;
370 switch(m_pAdoConnection->get_IsolationLevel())
372 case adXactUnspecified:
373 nRet = TransactionIsolation::NONE;
374 break;
375 case adXactReadUncommitted:
376 nRet = TransactionIsolation::READ_UNCOMMITTED;
377 break;
378 case adXactReadCommitted:
379 nRet = TransactionIsolation::READ_COMMITTED;
380 break;
381 case adXactRepeatableRead:
382 nRet = TransactionIsolation::REPEATABLE_READ;
383 break;
384 case adXactSerializable:
385 nRet = TransactionIsolation::SERIALIZABLE;
386 break;
387 default:
388 OSL_FAIL("OConnection::setTransactionIsolation invalid level");
390 ADOS::ThrowException(*m_pAdoConnection,*this);
391 return nRet;
393 // --------------------------------------------------------------------------------
394 Reference< ::com::sun::star::container::XNameAccess > SAL_CALL OConnection::getTypeMap( ) throw(SQLException, RuntimeException)
396 ::osl::MutexGuard aGuard( m_aMutex );
397 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
400 return NULL;
402 // --------------------------------------------------------------------------------
403 void SAL_CALL OConnection::setTypeMap( const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
405 ::dbtools::throwFeatureNotImplementedException( "XConnection::setTypeMap", *this );
407 // --------------------------------------------------------------------------------
408 // XCloseable
409 void SAL_CALL OConnection::close( ) throw(SQLException, RuntimeException)
412 ::osl::MutexGuard aGuard( m_aMutex );
413 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
416 dispose();
418 // --------------------------------------------------------------------------------
419 // XWarningsSupplier
420 Any SAL_CALL OConnection::getWarnings( ) throw(SQLException, RuntimeException)
422 return Any();
424 // --------------------------------------------------------------------------------
425 void SAL_CALL OConnection::clearWarnings( ) throw(SQLException, RuntimeException)
428 //--------------------------------------------------------------------
429 void OConnection::buildTypeInfo() throw( SQLException)
431 ::osl::MutexGuard aGuard( m_aMutex );
433 ADORecordset *pRecordset = m_pAdoConnection->getTypeInfo();
434 if ( pRecordset )
436 pRecordset->AddRef();
437 VARIANT_BOOL bIsAtBOF;
438 pRecordset->get_BOF(&bIsAtBOF);
440 sal_Bool bOk = sal_True;
441 if ( bIsAtBOF == VARIANT_TRUE )
442 bOk = SUCCEEDED(pRecordset->MoveNext());
444 if ( bOk )
446 // HACK for access
447 static const ::rtl::OUString s_sVarChar(RTL_CONSTASCII_USTRINGPARAM("VarChar"));
450 sal_Int32 nPos = 1;
451 OExtendedTypeInfo* aInfo = new OExtendedTypeInfo();
452 aInfo->aSimpleType.aTypeName = ADOS::getField(pRecordset,nPos++).get_Value();
453 aInfo->eType = (DataTypeEnum)(sal_Int32)ADOS::getField(pRecordset,nPos++).get_Value();
454 if ( aInfo->eType == adWChar && aInfo->aSimpleType.aTypeName == s_sVarChar )
455 aInfo->eType = adVarWChar;
456 aInfo->aSimpleType.nType = (sal_Int16)ADOS::MapADOType2Jdbc(static_cast<DataTypeEnum>(aInfo->eType));
457 aInfo->aSimpleType.nPrecision = ADOS::getField(pRecordset,nPos++).get_Value();
458 aInfo->aSimpleType.aLiteralPrefix = ADOS::getField(pRecordset,nPos++).get_Value();
459 aInfo->aSimpleType.aLiteralSuffix = ADOS::getField(pRecordset,nPos++).get_Value();
460 aInfo->aSimpleType.aCreateParams = ADOS::getField(pRecordset,nPos++).get_Value();
461 aInfo->aSimpleType.bNullable = ADOS::getField(pRecordset,nPos++).get_Value();
462 aInfo->aSimpleType.bCaseSensitive = ADOS::getField(pRecordset,nPos++).get_Value();
463 aInfo->aSimpleType.nSearchType = ADOS::getField(pRecordset,nPos++).get_Value();
464 aInfo->aSimpleType.bUnsigned = ADOS::getField(pRecordset,nPos++).get_Value();
465 aInfo->aSimpleType.bCurrency = ADOS::getField(pRecordset,nPos++).get_Value();
466 aInfo->aSimpleType.bAutoIncrement = ADOS::getField(pRecordset,nPos++).get_Value();
467 aInfo->aSimpleType.aLocalTypeName = ADOS::getField(pRecordset,nPos++).get_Value();
468 aInfo->aSimpleType.nMinimumScale = ADOS::getField(pRecordset,nPos++).get_Value();
469 aInfo->aSimpleType.nMaximumScale = ADOS::getField(pRecordset,nPos++).get_Value();
470 if ( adCurrency == aInfo->eType && !aInfo->aSimpleType.nMaximumScale)
472 aInfo->aSimpleType.nMinimumScale = 4;
473 aInfo->aSimpleType.nMaximumScale = 4;
475 aInfo->aSimpleType.nNumPrecRadix = ADOS::getField(pRecordset,nPos++).get_Value();
476 // Now that we have the type info, save it
477 // in the Hashtable if we don't already have an
478 // entry for this SQL type.
480 m_aTypeInfo.insert(OTypeInfoMap::value_type(aInfo->eType,aInfo));
482 while ( SUCCEEDED(pRecordset->MoveNext()) );
484 pRecordset->Release();
487 //------------------------------------------------------------------------------
488 void OConnection::disposing()
490 ::osl::MutexGuard aGuard(m_aMutex);
492 OConnection_BASE::disposing();
494 m_bClosed = sal_True;
495 m_xMetaData = ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XDatabaseMetaData>();
496 m_xCatalog = ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbcx::XTablesSupplier>();
497 m_pDriver = NULL;
499 m_pAdoConnection->Close();
501 OTypeInfoMap::iterator aIter = m_aTypeInfo.begin();
502 for (; aIter != m_aTypeInfo.end(); ++aIter)
503 delete aIter->second;
505 m_aTypeInfo.clear();
507 delete m_pAdoConnection;
508 m_pAdoConnection = NULL;
510 dispose_ChildImpl();
512 // -----------------------------------------------------------------------------
513 sal_Int64 SAL_CALL OConnection::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw (::com::sun::star::uno::RuntimeException)
515 return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
517 reinterpret_cast< sal_Int64 >( this )
519 OConnection_BASE::getSomething(rId);
521 // -----------------------------------------------------------------------------
522 Sequence< sal_Int8 > OConnection::getUnoTunnelImplementationId()
524 static ::cppu::OImplementationId * pId = 0;
525 if (! pId)
527 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
528 if (! pId)
530 static ::cppu::OImplementationId aId;
531 pId = &aId;
534 return pId->getImplementationId();
536 // -----------------------------------------------------------------------------
537 const OExtendedTypeInfo* OConnection::getTypeInfoFromType(const OTypeInfoMap& _rTypeInfo,
538 DataTypeEnum _nType,
539 const ::rtl::OUString& _sTypeName,
540 sal_Int32 _nPrecision,
541 sal_Int32 _nScale,
542 sal_Bool& _brForceToType)
544 const OExtendedTypeInfo* pTypeInfo = NULL;
545 _brForceToType = sal_False;
546 // search for type
547 ::std::pair<OTypeInfoMap::const_iterator, OTypeInfoMap::const_iterator> aPair = _rTypeInfo.equal_range(_nType);
548 OTypeInfoMap::const_iterator aIter = aPair.first;
549 if(aIter != _rTypeInfo.end()) // compare with end is correct here
551 for(;aIter != aPair.second;++aIter)
553 // search the best matching type
554 OExtendedTypeInfo* pInfo = aIter->second;
555 #ifdef DBG_UTIL
556 ::rtl::OUString sDBTypeName = pInfo->aSimpleType.aTypeName;
557 sal_Int32 nDBTypePrecision = pInfo->aSimpleType.nPrecision; (void)nDBTypePrecision;
558 sal_Int32 nDBTypeScale = pInfo->aSimpleType.nMaximumScale; (void)nDBTypeScale;
559 sal_Int32 nAdoType = pInfo->eType; (void)nAdoType;
560 #endif
561 if ( ( !_sTypeName.getLength()
562 || (pInfo->aSimpleType.aTypeName.equalsIgnoreAsciiCase(_sTypeName))
564 && (pInfo->aSimpleType.nPrecision >= _nPrecision)
565 && (pInfo->aSimpleType.nMaximumScale >= _nScale)
568 break;
571 if (aIter == aPair.second)
573 for(aIter = aPair.first; aIter != aPair.second; ++aIter)
575 // search the best matching type (now comparing the local names)
576 if ( (aIter->second->aSimpleType.aLocalTypeName.equalsIgnoreAsciiCase(_sTypeName))
577 && (aIter->second->aSimpleType.nPrecision >= _nPrecision)
578 && (aIter->second->aSimpleType.nMaximumScale >= _nScale)
581 // we can not assert here because we could be in d&d
583 OSL_FAIL(( ::rtl::OString("getTypeInfoFromType: assuming column type ")
584 += ::rtl::OString(aIter->second->aTypeName.getStr(), aIter->second->aTypeName.getLength(), osl_getThreadTextEncoding())
585 += ::rtl::OString("\" (expected type name ")
586 += ::rtl::OString(_sTypeName.getStr(), _sTypeName.getLength(), osl_getThreadTextEncoding())
587 += ::rtl::OString(" matches the type's local name).")).getStr());
589 break;
594 if (aIter == aPair.second)
595 { // no match for the names, no match for the local names
596 // -> drop the precision and the scale restriction, accept any type with the property
597 // type id (nType)
599 // we can not assert here because we could be in d&d
600 pTypeInfo = aPair.first->second;
601 _brForceToType = sal_True;
603 else
604 pTypeInfo = aIter->second;
606 else if ( _sTypeName.getLength() )
608 ::comphelper::TStringMixEqualFunctor aCase(sal_False);
609 // search for typeinfo where the typename is equal _sTypeName
610 OTypeInfoMap::const_iterator aFind = ::std::find_if(_rTypeInfo.begin(),
611 _rTypeInfo.end(),
612 ::o3tl::compose1(
613 ::std::bind2nd(aCase, _sTypeName),
614 ::o3tl::compose1(
615 ::std::mem_fun(&OExtendedTypeInfo::getDBName),
616 ::o3tl::select2nd<OTypeInfoMap::value_type>())
619 if(aFind != _rTypeInfo.end())
620 pTypeInfo = aFind->second;
623 // we can not assert here because we could be in d&d
624 // OSL_ENSURE(pTypeInfo, "getTypeInfoFromType: no type info found for this type!");
625 return pTypeInfo;
627 // -----------------------------------------------------------------------------
631 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */