Update ooo320-m1
[ooovba.git] / connectivity / source / drivers / ado / AConnection.cxx
blob4193a6985f8923a48a2900f225e57d7ec605105c
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: AConnection.cxx,v $
10 * $Revision: 1.30 $
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 "ado/AConnection.hxx"
34 #include "ado/ADatabaseMetaData.hxx"
35 #include "ado/ADriver.hxx"
36 #include "ado/AStatement.hxx"
37 #include "ado/ACallableStatement.hxx"
38 #include "ado/APreparedStatement.hxx"
39 #include "ado/ACatalog.hxx"
40 #include <com/sun/star/sdbc/ColumnValue.hpp>
41 #include <com/sun/star/sdbc/TransactionIsolation.hpp>
42 #include <com/sun/star/sdbc/XRow.hpp>
43 #include <com/sun/star/lang/DisposedException.hpp>
44 #include <cppuhelper/typeprovider.hxx>
45 #include "connectivity/dbexception.hxx"
46 #include <osl/file.hxx>
47 #include "resource/ado_res.hrc"
49 using namespace dbtools;
50 using namespace connectivity::ado;
51 using namespace com::sun::star::uno;
52 using namespace com::sun::star::lang;
53 using namespace com::sun::star::beans;
54 using namespace com::sun::star::sdbc;
55 using namespace com::sun::star::sdbcx;
57 //------------------------------------------------------------------------------
58 IMPLEMENT_SERVICE_INFO(OConnection,"com.sun.star.sdbcx.AConnection","com.sun.star.sdbc.Connection");
59 // --------------------------------------------------------------------------------
60 OConnection::OConnection(ODriver* _pDriver) throw(SQLException, RuntimeException)
61 : OSubComponent<OConnection, OConnection_BASE>((::cppu::OWeakObject*)_pDriver, this),
62 m_bClosed(sal_False),
63 m_xCatalog(NULL),
64 m_pDriver(_pDriver),
65 m_pAdoConnection(NULL),
66 m_bAutocommit(sal_True),
67 m_nEngineType(0),
68 m_pCatalog(NULL)
70 osl_incrementInterlockedCount( &m_refCount );
72 IClassFactory2* pIUnknown = NULL;
73 IUnknown *pOuter = NULL;
74 HRESULT hr;
75 hr = CoGetClassObject( ADOS::CLSID_ADOCONNECTION_21,
76 CLSCTX_INPROC_SERVER,
77 NULL,
78 IID_IClassFactory2,
79 (void**)&pIUnknown );
81 if( !FAILED( hr ) )
83 ADOConnection *pCon = NULL;
84 hr = pIUnknown->CreateInstanceLic( pOuter,
85 NULL,
86 ADOS::IID_ADOCONNECTION_21,
87 ADOS::GetKeyStr(),
88 (void**) &pCon);
90 if( !FAILED( hr ) )
92 OSL_ENSURE( pCon, "OConnection::OConnection: invalid ADO object!" );
94 m_pAdoConnection = new WpADOConnection( pCon );
95 // CreateInstanceLic returned an object which was already acquired
96 pCon->Release( );
100 // Class Factory is no longer needed
101 pIUnknown->Release();
104 osl_decrementInterlockedCount( &m_refCount );
106 //-----------------------------------------------------------------------------
107 OConnection::~OConnection()
110 //-----------------------------------------------------------------------------
111 void OConnection::construct(const ::rtl::OUString& url,const Sequence< PropertyValue >& info)
113 osl_incrementInterlockedCount( &m_refCount );
115 setConnectionInfo(info);
117 sal_Int32 nLen = url.indexOf(':');
118 nLen = url.indexOf(':',nLen+1);
119 ::rtl::OUString aDSN(url.copy(nLen+1)),aUID,aPWD;
120 if ( aDSN.compareToAscii("access:",7) == 0 )
121 aDSN = aDSN.copy(7);
123 sal_Int32 nTimeout = 20;
124 sal_Bool bSilent = sal_True;
125 const PropertyValue *pIter = info.getConstArray();
126 const PropertyValue *pEnd = pIter + info.getLength();
127 for(;pIter != pEnd;++pIter)
129 if(!pIter->Name.compareToAscii("Timeout"))
130 pIter->Value >>= nTimeout;
131 else if(!pIter->Name.compareToAscii("Silent"))
132 pIter->Value >>= bSilent;
133 else if(!pIter->Name.compareToAscii("user"))
134 pIter->Value >>= aUID;
135 else if(!pIter->Name.compareToAscii("password"))
136 pIter->Value >>= aPWD;
140 if(m_pAdoConnection)
142 if(m_pAdoConnection->Open(aDSN,aUID,aPWD,adConnectUnspecified))
143 m_pAdoConnection->PutCommandTimeout(nTimeout);
144 else
145 ADOS::ThrowException(*m_pAdoConnection,*this);
146 if(m_pAdoConnection->get_State() != adStateOpen)
147 throwGenericSQLException( STR_NO_CONNECTION,*this );
149 WpADOProperties aProps = m_pAdoConnection->get_Properties();
150 if(aProps.IsValid())
152 OTools::putValue(aProps,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Jet OLEDB:ODBC Parsing")),sal_True);
153 OLEVariant aVar(OTools::getValue(aProps,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Jet OLEDB:Engine Type"))));
154 if(!aVar.isNull() && !aVar.isEmpty())
155 m_nEngineType = aVar;
157 buildTypeInfo();
158 //bErg = TRUE;
160 else
161 ::dbtools::throwFunctionSequenceException(*this);
164 catch(const Exception )
166 osl_decrementInterlockedCount( &m_refCount );
167 throw;
169 osl_decrementInterlockedCount( &m_refCount );
171 //-----------------------------------------------------------------------------
172 void SAL_CALL OConnection::release() throw()
174 relase_ChildImpl();
176 // --------------------------------------------------------------------------------
177 Reference< XStatement > SAL_CALL OConnection::createStatement( ) throw(SQLException, RuntimeException)
179 ::osl::MutexGuard aGuard( m_aMutex );
180 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
182 OStatement* pStmt = new OStatement(this);
183 Reference< XStatement > xStmt = pStmt;
184 m_aStatements.push_back(WeakReferenceHelper(*pStmt));
185 return pStmt;
187 // --------------------------------------------------------------------------------
188 Reference< XPreparedStatement > SAL_CALL OConnection::prepareStatement( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
190 ::osl::MutexGuard aGuard( m_aMutex );
191 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
194 OPreparedStatement* pStmt = new OPreparedStatement(this,m_aTypeInfo,sql);
195 Reference< XPreparedStatement > xPStmt = pStmt;
196 m_aStatements.push_back(WeakReferenceHelper(*pStmt));
197 return xPStmt;
199 // --------------------------------------------------------------------------------
200 Reference< XPreparedStatement > SAL_CALL OConnection::prepareCall( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
202 ::osl::MutexGuard aGuard( m_aMutex );
203 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
206 OCallableStatement* pStmt = new OCallableStatement(this,m_aTypeInfo,sql);
207 Reference< XPreparedStatement > xPStmt = pStmt;
208 m_aStatements.push_back(WeakReferenceHelper(*pStmt));
209 return xPStmt;
211 // --------------------------------------------------------------------------------
212 ::rtl::OUString SAL_CALL OConnection::nativeSQL( const ::rtl::OUString& _sql ) throw(SQLException, RuntimeException)
214 ::osl::MutexGuard aGuard( m_aMutex );
215 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
218 ::rtl::OUString sql = _sql;
219 WpADOProperties aProps = m_pAdoConnection->get_Properties();
220 if(aProps.IsValid())
222 OTools::putValue(aProps,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Jet OLEDB:ODBC Parsing")),sal_True);
223 WpADOCommand aCommand;
224 aCommand.Create();
225 aCommand.put_ActiveConnection((IDispatch*)*m_pAdoConnection);
226 aCommand.put_CommandText(sql);
227 sql = aCommand.get_CommandText();
230 return sql;
232 // --------------------------------------------------------------------------------
233 void SAL_CALL OConnection::setAutoCommit( sal_Bool autoCommit ) throw(SQLException, RuntimeException)
235 ::osl::MutexGuard aGuard( m_aMutex );
236 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
239 m_bAutocommit = autoCommit;
240 if(!autoCommit)
241 m_pAdoConnection->BeginTrans();
242 else
243 m_pAdoConnection->RollbackTrans();
245 // --------------------------------------------------------------------------------
246 sal_Bool SAL_CALL OConnection::getAutoCommit( ) throw(SQLException, RuntimeException)
248 ::osl::MutexGuard aGuard( m_aMutex );
249 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
252 return m_bAutocommit;
254 // --------------------------------------------------------------------------------
255 void SAL_CALL OConnection::commit( ) throw(SQLException, RuntimeException)
257 ::osl::MutexGuard aGuard( m_aMutex );
258 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
261 m_pAdoConnection->CommitTrans();
263 // --------------------------------------------------------------------------------
264 void SAL_CALL OConnection::rollback( ) throw(SQLException, RuntimeException)
266 ::osl::MutexGuard aGuard( m_aMutex );
267 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
270 m_pAdoConnection->RollbackTrans();
272 // --------------------------------------------------------------------------------
273 sal_Bool SAL_CALL OConnection::isClosed( ) throw(SQLException, RuntimeException)
275 ::osl::MutexGuard aGuard( m_aMutex );
277 return OConnection_BASE::rBHelper.bDisposed && !m_pAdoConnection->get_State();
279 // --------------------------------------------------------------------------------
280 Reference< XDatabaseMetaData > SAL_CALL OConnection::getMetaData( ) throw(SQLException, RuntimeException)
282 ::osl::MutexGuard aGuard( m_aMutex );
283 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
286 Reference< XDatabaseMetaData > xMetaData = m_xMetaData;
287 if(!xMetaData.is())
289 xMetaData = new ODatabaseMetaData(this);
290 m_xMetaData = xMetaData;
293 return xMetaData;
295 // --------------------------------------------------------------------------------
296 void SAL_CALL OConnection::setReadOnly( sal_Bool readOnly ) throw(SQLException, RuntimeException)
298 ::osl::MutexGuard aGuard( m_aMutex );
299 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
303 m_pAdoConnection->put_Mode(readOnly ? adModeRead : adModeReadWrite);
304 ADOS::ThrowException(*m_pAdoConnection,*this);
306 // --------------------------------------------------------------------------------
307 sal_Bool SAL_CALL OConnection::isReadOnly( ) throw(SQLException, RuntimeException)
309 ::osl::MutexGuard aGuard( m_aMutex );
310 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
313 return m_pAdoConnection->get_Mode() == adModeRead;
315 // --------------------------------------------------------------------------------
316 void SAL_CALL OConnection::setCatalog( const ::rtl::OUString& catalog ) throw(SQLException, RuntimeException)
318 ::osl::MutexGuard aGuard( m_aMutex );
319 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
321 m_pAdoConnection->PutDefaultDatabase(catalog);
322 ADOS::ThrowException(*m_pAdoConnection,*this);
324 // --------------------------------------------------------------------------------
325 ::rtl::OUString SAL_CALL OConnection::getCatalog( ) throw(SQLException, RuntimeException)
327 ::osl::MutexGuard aGuard( m_aMutex );
328 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
330 return m_pAdoConnection->GetDefaultDatabase();
332 // --------------------------------------------------------------------------------
333 void SAL_CALL OConnection::setTransactionIsolation( sal_Int32 level ) throw(SQLException, RuntimeException)
335 ::osl::MutexGuard aGuard( m_aMutex );
336 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
339 IsolationLevelEnum eIso;
340 switch(level)
342 case TransactionIsolation::NONE:
343 eIso = adXactUnspecified;
344 break;
345 case TransactionIsolation::READ_UNCOMMITTED:
346 eIso = adXactReadUncommitted;
347 break;
348 case TransactionIsolation::READ_COMMITTED:
349 eIso = adXactReadCommitted;
350 break;
351 case TransactionIsolation::REPEATABLE_READ:
352 eIso = adXactRepeatableRead;
353 break;
354 case TransactionIsolation::SERIALIZABLE:
355 eIso = adXactSerializable;
356 break;
357 default:
358 OSL_ENSURE(0,"OConnection::setTransactionIsolation invalid level");
359 return;
361 m_pAdoConnection->put_IsolationLevel(eIso);
362 ADOS::ThrowException(*m_pAdoConnection,*this);
364 // --------------------------------------------------------------------------------
365 sal_Int32 SAL_CALL OConnection::getTransactionIsolation( ) throw(SQLException, RuntimeException)
367 ::osl::MutexGuard aGuard( m_aMutex );
368 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
371 sal_Int32 nRet = 0;
372 switch(m_pAdoConnection->get_IsolationLevel())
374 case adXactUnspecified:
375 nRet = TransactionIsolation::NONE;
376 break;
377 case adXactReadUncommitted:
378 nRet = TransactionIsolation::READ_UNCOMMITTED;
379 break;
380 case adXactReadCommitted:
381 nRet = TransactionIsolation::READ_COMMITTED;
382 break;
383 case adXactRepeatableRead:
384 nRet = TransactionIsolation::REPEATABLE_READ;
385 break;
386 case adXactSerializable:
387 nRet = TransactionIsolation::SERIALIZABLE;
388 break;
389 default:
390 OSL_ENSURE(0,"OConnection::setTransactionIsolation invalid level");
392 ADOS::ThrowException(*m_pAdoConnection,*this);
393 return nRet;
395 // --------------------------------------------------------------------------------
396 Reference< ::com::sun::star::container::XNameAccess > SAL_CALL OConnection::getTypeMap( ) throw(SQLException, RuntimeException)
398 ::osl::MutexGuard aGuard( m_aMutex );
399 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
402 return NULL;
404 // --------------------------------------------------------------------------------
405 void SAL_CALL OConnection::setTypeMap( const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
407 ::dbtools::throwFeatureNotImplementedException( "XConnection::setTypeMap", *this );
409 // --------------------------------------------------------------------------------
410 // XCloseable
411 void SAL_CALL OConnection::close( ) throw(SQLException, RuntimeException)
414 ::osl::MutexGuard aGuard( m_aMutex );
415 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
418 dispose();
420 // --------------------------------------------------------------------------------
421 // XWarningsSupplier
422 Any SAL_CALL OConnection::getWarnings( ) throw(SQLException, RuntimeException)
424 return Any();
426 // --------------------------------------------------------------------------------
427 void SAL_CALL OConnection::clearWarnings( ) throw(SQLException, RuntimeException)
430 //--------------------------------------------------------------------
431 void OConnection::buildTypeInfo() throw( SQLException)
433 ::osl::MutexGuard aGuard( m_aMutex );
435 ADORecordset *pRecordset = m_pAdoConnection->getTypeInfo();
436 if ( pRecordset )
438 pRecordset->AddRef();
439 VARIANT_BOOL bIsAtBOF;
440 pRecordset->get_BOF(&bIsAtBOF);
442 sal_Bool bOk = sal_True;
443 if ( bIsAtBOF == VARIANT_TRUE )
444 bOk = SUCCEEDED(pRecordset->MoveNext());
446 if ( bOk )
448 // HACK for access
449 static const ::rtl::OUString s_sVarChar(RTL_CONSTASCII_USTRINGPARAM("VarChar"));
452 sal_Int32 nPos = 1;
453 OExtendedTypeInfo* aInfo = new OExtendedTypeInfo();
454 aInfo->aSimpleType.aTypeName = ADOS::getField(pRecordset,nPos++).get_Value();
455 aInfo->eType = (DataTypeEnum)(sal_Int32)ADOS::getField(pRecordset,nPos++).get_Value();
456 if ( aInfo->eType == adWChar && aInfo->aSimpleType.aTypeName == s_sVarChar )
457 aInfo->eType = adVarWChar;
458 aInfo->aSimpleType.nType = (sal_Int16)ADOS::MapADOType2Jdbc(static_cast<DataTypeEnum>(aInfo->eType));
459 aInfo->aSimpleType.nPrecision = ADOS::getField(pRecordset,nPos++).get_Value();
460 aInfo->aSimpleType.aLiteralPrefix = ADOS::getField(pRecordset,nPos++).get_Value();
461 aInfo->aSimpleType.aLiteralSuffix = ADOS::getField(pRecordset,nPos++).get_Value();
462 aInfo->aSimpleType.aCreateParams = ADOS::getField(pRecordset,nPos++).get_Value();
463 aInfo->aSimpleType.bNullable = ADOS::getField(pRecordset,nPos++).get_Value();
464 aInfo->aSimpleType.bCaseSensitive = ADOS::getField(pRecordset,nPos++).get_Value();
465 aInfo->aSimpleType.nSearchType = ADOS::getField(pRecordset,nPos++).get_Value();
466 aInfo->aSimpleType.bUnsigned = ADOS::getField(pRecordset,nPos++).get_Value();
467 aInfo->aSimpleType.bCurrency = ADOS::getField(pRecordset,nPos++).get_Value();
468 aInfo->aSimpleType.bAutoIncrement = ADOS::getField(pRecordset,nPos++).get_Value();
469 aInfo->aSimpleType.aLocalTypeName = ADOS::getField(pRecordset,nPos++).get_Value();
470 aInfo->aSimpleType.nMinimumScale = ADOS::getField(pRecordset,nPos++).get_Value();
471 aInfo->aSimpleType.nMaximumScale = ADOS::getField(pRecordset,nPos++).get_Value();
472 aInfo->aSimpleType.nNumPrecRadix = ADOS::getField(pRecordset,nPos++).get_Value();
473 // Now that we have the type info, save it
474 // in the Hashtable if we don't already have an
475 // entry for this SQL type.
477 m_aTypeInfo.insert(OTypeInfoMap::value_type(aInfo->eType,aInfo));
479 while ( SUCCEEDED(pRecordset->MoveNext()) );
481 pRecordset->Release();
484 //------------------------------------------------------------------------------
485 void OConnection::disposing()
487 ::osl::MutexGuard aGuard(m_aMutex);
489 OConnection_BASE::disposing();
491 m_bClosed = sal_True;
492 m_xMetaData = ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XDatabaseMetaData>();
493 m_xCatalog = ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbcx::XTablesSupplier>();
494 m_pDriver = NULL;
496 m_pAdoConnection->Close();
498 OTypeInfoMap::iterator aIter = m_aTypeInfo.begin();
499 for (; aIter != m_aTypeInfo.end(); ++aIter)
500 delete aIter->second;
502 m_aTypeInfo.clear();
504 delete m_pAdoConnection;
505 m_pAdoConnection = NULL;
507 dispose_ChildImpl();
509 // -----------------------------------------------------------------------------
510 sal_Int64 SAL_CALL OConnection::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw (::com::sun::star::uno::RuntimeException)
512 return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
514 reinterpret_cast< sal_Int64 >( this )
516 OConnection_BASE::getSomething(rId);
518 // -----------------------------------------------------------------------------
519 Sequence< sal_Int8 > OConnection::getUnoTunnelImplementationId()
521 static ::cppu::OImplementationId * pId = 0;
522 if (! pId)
524 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
525 if (! pId)
527 static ::cppu::OImplementationId aId;
528 pId = &aId;
531 return pId->getImplementationId();
533 // -----------------------------------------------------------------------------
534 const OExtendedTypeInfo* OConnection::getTypeInfoFromType(const OTypeInfoMap& _rTypeInfo,
535 DataTypeEnum _nType,
536 const ::rtl::OUString& _sTypeName,
537 sal_Int32 _nPrecision,
538 sal_Int32 _nScale,
539 sal_Bool& _brForceToType)
541 const OExtendedTypeInfo* pTypeInfo = NULL;
542 _brForceToType = sal_False;
543 // search for type
544 ::std::pair<OTypeInfoMap::const_iterator, OTypeInfoMap::const_iterator> aPair = _rTypeInfo.equal_range(_nType);
545 OTypeInfoMap::const_iterator aIter = aPair.first;
546 if(aIter != _rTypeInfo.end()) // compare with end is correct here
548 for(;aIter != aPair.second;++aIter)
550 // search the best matching type
551 OExtendedTypeInfo* pInfo = aIter->second;
552 #ifdef DBG_UTIL
553 ::rtl::OUString sDBTypeName = pInfo->aSimpleType.aTypeName;
554 sal_Int32 nDBTypePrecision = pInfo->aSimpleType.nPrecision; (void)nDBTypePrecision;
555 sal_Int32 nDBTypeScale = pInfo->aSimpleType.nMaximumScale; (void)nDBTypeScale;
556 sal_Int32 nAdoType = pInfo->eType; (void)nAdoType;
557 #endif
558 if ( ( !_sTypeName.getLength()
559 || (pInfo->aSimpleType.aTypeName.equalsIgnoreAsciiCase(_sTypeName))
561 && (pInfo->aSimpleType.nPrecision >= _nPrecision)
562 && (pInfo->aSimpleType.nMaximumScale >= _nScale)
565 break;
568 if (aIter == aPair.second)
570 for(aIter = aPair.first; aIter != aPair.second; ++aIter)
572 // search the best matching type (now comparing the local names)
573 if ( (aIter->second->aSimpleType.aLocalTypeName.equalsIgnoreAsciiCase(_sTypeName))
574 && (aIter->second->aSimpleType.nPrecision >= _nPrecision)
575 && (aIter->second->aSimpleType.nMaximumScale >= _nScale)
578 // we can not assert here because we could be in d&d
580 OSL_ENSURE(sal_False,
581 ( ::rtl::OString("getTypeInfoFromType: assuming column type ")
582 += ::rtl::OString(aIter->second->aTypeName.getStr(), aIter->second->aTypeName.getLength(), gsl_getSystemTextEncoding())
583 += ::rtl::OString("\" (expected type name ")
584 += ::rtl::OString(_sTypeName.getStr(), _sTypeName.getLength(), gsl_getSystemTextEncoding())
585 += ::rtl::OString(" matches the type's local name).")).getStr());
587 break;
592 if (aIter == aPair.second)
593 { // no match for the names, no match for the local names
594 // -> drop the precision and the scale restriction, accept any type with the property
595 // type id (nType)
597 // we can not assert here because we could be in d&d
598 pTypeInfo = aPair.first->second;
599 _brForceToType = sal_True;
601 else
602 pTypeInfo = aIter->second;
604 else if ( _sTypeName.getLength() )
606 ::comphelper::TStringMixEqualFunctor aCase(sal_False);
607 // search for typeinfo where the typename is equal _sTypeName
608 OTypeInfoMap::const_iterator aFind = ::std::find_if(_rTypeInfo.begin(),
609 _rTypeInfo.end(),
610 ::std::compose1(
611 ::std::bind2nd(aCase, _sTypeName),
612 ::std::compose1(
613 ::std::mem_fun(&OExtendedTypeInfo::getDBName),
614 ::std::select2nd<OTypeInfoMap::value_type>())
617 if(aFind != _rTypeInfo.end())
618 pTypeInfo = aFind->second;
621 // we can not assert here because we could be in d&d
622 // OSL_ENSURE(pTypeInfo, "getTypeInfoFromType: no type info found for this type!");
623 return pTypeInfo;
625 // -----------------------------------------------------------------------------