1*b1cdbd2cSJim Jagielski /**************************************************************
2*b1cdbd2cSJim Jagielski *
3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one
4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file
5*b1cdbd2cSJim Jagielski * distributed with this work for additional information
6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file
7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the
8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance
9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at
10*b1cdbd2cSJim Jagielski *
11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0
12*b1cdbd2cSJim Jagielski *
13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing,
14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an
15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the
17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations
18*b1cdbd2cSJim Jagielski * under the License.
19*b1cdbd2cSJim Jagielski *
20*b1cdbd2cSJim Jagielski *************************************************************/
21*b1cdbd2cSJim Jagielski
22*b1cdbd2cSJim Jagielski
23*b1cdbd2cSJim Jagielski
24*b1cdbd2cSJim Jagielski // MARKER(update_precomp.py): autogen include statement, do not remove
25*b1cdbd2cSJim Jagielski #include "precompiled_connectivity.hxx"
26*b1cdbd2cSJim Jagielski #include "ado/AConnection.hxx"
27*b1cdbd2cSJim Jagielski #include "ado/ADatabaseMetaData.hxx"
28*b1cdbd2cSJim Jagielski #include "ado/ADriver.hxx"
29*b1cdbd2cSJim Jagielski #include "ado/AStatement.hxx"
30*b1cdbd2cSJim Jagielski #include "ado/ACallableStatement.hxx"
31*b1cdbd2cSJim Jagielski #include "ado/APreparedStatement.hxx"
32*b1cdbd2cSJim Jagielski #include "ado/ACatalog.hxx"
33*b1cdbd2cSJim Jagielski #include <com/sun/star/sdbc/ColumnValue.hpp>
34*b1cdbd2cSJim Jagielski #include <com/sun/star/sdbc/TransactionIsolation.hpp>
35*b1cdbd2cSJim Jagielski #include <com/sun/star/sdbc/XRow.hpp>
36*b1cdbd2cSJim Jagielski #include <com/sun/star/lang/DisposedException.hpp>
37*b1cdbd2cSJim Jagielski #include <cppuhelper/typeprovider.hxx>
38*b1cdbd2cSJim Jagielski #include "connectivity/dbexception.hxx"
39*b1cdbd2cSJim Jagielski #include <osl/file.hxx>
40*b1cdbd2cSJim Jagielski #include "resource/ado_res.hrc"
41*b1cdbd2cSJim Jagielski
42*b1cdbd2cSJim Jagielski using namespace dbtools;
43*b1cdbd2cSJim Jagielski using namespace connectivity::ado;
44*b1cdbd2cSJim Jagielski using namespace com::sun::star::uno;
45*b1cdbd2cSJim Jagielski using namespace com::sun::star::lang;
46*b1cdbd2cSJim Jagielski using namespace com::sun::star::beans;
47*b1cdbd2cSJim Jagielski using namespace com::sun::star::sdbc;
48*b1cdbd2cSJim Jagielski using namespace com::sun::star::sdbcx;
49*b1cdbd2cSJim Jagielski
50*b1cdbd2cSJim Jagielski //------------------------------------------------------------------------------
51*b1cdbd2cSJim Jagielski IMPLEMENT_SERVICE_INFO(OConnection,"com.sun.star.sdbcx.AConnection","com.sun.star.sdbc.Connection");
52*b1cdbd2cSJim Jagielski // --------------------------------------------------------------------------------
OConnection(ODriver * _pDriver)53*b1cdbd2cSJim Jagielski OConnection::OConnection(ODriver* _pDriver) throw(SQLException, RuntimeException)
54*b1cdbd2cSJim Jagielski : OSubComponent<OConnection, OConnection_BASE>((::cppu::OWeakObject*)_pDriver, this),
55*b1cdbd2cSJim Jagielski m_bClosed(sal_False),
56*b1cdbd2cSJim Jagielski m_xCatalog(NULL),
57*b1cdbd2cSJim Jagielski m_pDriver(_pDriver),
58*b1cdbd2cSJim Jagielski m_pAdoConnection(NULL),
59*b1cdbd2cSJim Jagielski m_bAutocommit(sal_True),
60*b1cdbd2cSJim Jagielski m_nEngineType(0),
61*b1cdbd2cSJim Jagielski m_pCatalog(NULL)
62*b1cdbd2cSJim Jagielski {
63*b1cdbd2cSJim Jagielski osl_incrementInterlockedCount( &m_refCount );
64*b1cdbd2cSJim Jagielski
65*b1cdbd2cSJim Jagielski IClassFactory2* pIUnknown = NULL;
66*b1cdbd2cSJim Jagielski IUnknown *pOuter = NULL;
67*b1cdbd2cSJim Jagielski HRESULT hr;
68*b1cdbd2cSJim Jagielski hr = CoGetClassObject( ADOS::CLSID_ADOCONNECTION_21,
69*b1cdbd2cSJim Jagielski CLSCTX_INPROC_SERVER,
70*b1cdbd2cSJim Jagielski NULL,
71*b1cdbd2cSJim Jagielski IID_IClassFactory2,
72*b1cdbd2cSJim Jagielski (void**)&pIUnknown );
73*b1cdbd2cSJim Jagielski
74*b1cdbd2cSJim Jagielski if( !FAILED( hr ) )
75*b1cdbd2cSJim Jagielski {
76*b1cdbd2cSJim Jagielski ADOConnection *pCon = NULL;
77*b1cdbd2cSJim Jagielski hr = pIUnknown->CreateInstanceLic( pOuter,
78*b1cdbd2cSJim Jagielski NULL,
79*b1cdbd2cSJim Jagielski ADOS::IID_ADOCONNECTION_21,
80*b1cdbd2cSJim Jagielski ADOS::GetKeyStr(),
81*b1cdbd2cSJim Jagielski (void**) &pCon);
82*b1cdbd2cSJim Jagielski
83*b1cdbd2cSJim Jagielski if( !FAILED( hr ) )
84*b1cdbd2cSJim Jagielski {
85*b1cdbd2cSJim Jagielski OSL_ENSURE( pCon, "OConnection::OConnection: invalid ADO object!" );
86*b1cdbd2cSJim Jagielski
87*b1cdbd2cSJim Jagielski m_pAdoConnection = new WpADOConnection( pCon );
88*b1cdbd2cSJim Jagielski // CreateInstanceLic returned an object which was already acquired
89*b1cdbd2cSJim Jagielski pCon->Release( );
90*b1cdbd2cSJim Jagielski
91*b1cdbd2cSJim Jagielski }
92*b1cdbd2cSJim Jagielski
93*b1cdbd2cSJim Jagielski // Class Factory is no longer needed
94*b1cdbd2cSJim Jagielski pIUnknown->Release();
95*b1cdbd2cSJim Jagielski }
96*b1cdbd2cSJim Jagielski
97*b1cdbd2cSJim Jagielski osl_decrementInterlockedCount( &m_refCount );
98*b1cdbd2cSJim Jagielski }
99*b1cdbd2cSJim Jagielski //-----------------------------------------------------------------------------
~OConnection()100*b1cdbd2cSJim Jagielski OConnection::~OConnection()
101*b1cdbd2cSJim Jagielski {
102*b1cdbd2cSJim Jagielski }
103*b1cdbd2cSJim Jagielski //-----------------------------------------------------------------------------
construct(const::rtl::OUString & url,const Sequence<PropertyValue> & info)104*b1cdbd2cSJim Jagielski void OConnection::construct(const ::rtl::OUString& url,const Sequence< PropertyValue >& info)
105*b1cdbd2cSJim Jagielski {
106*b1cdbd2cSJim Jagielski osl_incrementInterlockedCount( &m_refCount );
107*b1cdbd2cSJim Jagielski
108*b1cdbd2cSJim Jagielski setConnectionInfo(info);
109*b1cdbd2cSJim Jagielski
110*b1cdbd2cSJim Jagielski sal_Int32 nLen = url.indexOf(':');
111*b1cdbd2cSJim Jagielski nLen = url.indexOf(':',nLen+1);
112*b1cdbd2cSJim Jagielski ::rtl::OUString aDSN(url.copy(nLen+1)),aUID,aPWD;
113*b1cdbd2cSJim Jagielski if ( aDSN.compareToAscii("access:",7) == 0 )
114*b1cdbd2cSJim Jagielski aDSN = aDSN.copy(7);
115*b1cdbd2cSJim Jagielski
116*b1cdbd2cSJim Jagielski sal_Int32 nTimeout = 20;
117*b1cdbd2cSJim Jagielski sal_Bool bSilent = sal_True;
118*b1cdbd2cSJim Jagielski const PropertyValue *pIter = info.getConstArray();
119*b1cdbd2cSJim Jagielski const PropertyValue *pEnd = pIter + info.getLength();
120*b1cdbd2cSJim Jagielski for(;pIter != pEnd;++pIter)
121*b1cdbd2cSJim Jagielski {
122*b1cdbd2cSJim Jagielski if(!pIter->Name.compareToAscii("Timeout"))
123*b1cdbd2cSJim Jagielski pIter->Value >>= nTimeout;
124*b1cdbd2cSJim Jagielski else if(!pIter->Name.compareToAscii("Silent"))
125*b1cdbd2cSJim Jagielski pIter->Value >>= bSilent;
126*b1cdbd2cSJim Jagielski else if(!pIter->Name.compareToAscii("user"))
127*b1cdbd2cSJim Jagielski pIter->Value >>= aUID;
128*b1cdbd2cSJim Jagielski else if(!pIter->Name.compareToAscii("password"))
129*b1cdbd2cSJim Jagielski pIter->Value >>= aPWD;
130*b1cdbd2cSJim Jagielski }
131*b1cdbd2cSJim Jagielski try
132*b1cdbd2cSJim Jagielski {
133*b1cdbd2cSJim Jagielski if(m_pAdoConnection)
134*b1cdbd2cSJim Jagielski {
135*b1cdbd2cSJim Jagielski if(m_pAdoConnection->Open(aDSN,aUID,aPWD,adConnectUnspecified))
136*b1cdbd2cSJim Jagielski m_pAdoConnection->PutCommandTimeout(nTimeout);
137*b1cdbd2cSJim Jagielski else
138*b1cdbd2cSJim Jagielski ADOS::ThrowException(*m_pAdoConnection,*this);
139*b1cdbd2cSJim Jagielski if(m_pAdoConnection->get_State() != adStateOpen)
140*b1cdbd2cSJim Jagielski throwGenericSQLException( STR_NO_CONNECTION,*this );
141*b1cdbd2cSJim Jagielski
142*b1cdbd2cSJim Jagielski WpADOProperties aProps = m_pAdoConnection->get_Properties();
143*b1cdbd2cSJim Jagielski if(aProps.IsValid())
144*b1cdbd2cSJim Jagielski {
145*b1cdbd2cSJim Jagielski OTools::putValue(aProps,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Jet OLEDB:ODBC Parsing")),sal_True);
146*b1cdbd2cSJim Jagielski OLEVariant aVar(OTools::getValue(aProps,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Jet OLEDB:Engine Type"))));
147*b1cdbd2cSJim Jagielski if(!aVar.isNull() && !aVar.isEmpty())
148*b1cdbd2cSJim Jagielski m_nEngineType = aVar;
149*b1cdbd2cSJim Jagielski }
150*b1cdbd2cSJim Jagielski buildTypeInfo();
151*b1cdbd2cSJim Jagielski //bErg = TRUE;
152*b1cdbd2cSJim Jagielski }
153*b1cdbd2cSJim Jagielski else
154*b1cdbd2cSJim Jagielski ::dbtools::throwFunctionSequenceException(*this);
155*b1cdbd2cSJim Jagielski
156*b1cdbd2cSJim Jagielski }
157*b1cdbd2cSJim Jagielski catch(const Exception )
158*b1cdbd2cSJim Jagielski {
159*b1cdbd2cSJim Jagielski osl_decrementInterlockedCount( &m_refCount );
160*b1cdbd2cSJim Jagielski throw;
161*b1cdbd2cSJim Jagielski }
162*b1cdbd2cSJim Jagielski osl_decrementInterlockedCount( &m_refCount );
163*b1cdbd2cSJim Jagielski }
164*b1cdbd2cSJim Jagielski //-----------------------------------------------------------------------------
release()165*b1cdbd2cSJim Jagielski void SAL_CALL OConnection::release() throw()
166*b1cdbd2cSJim Jagielski {
167*b1cdbd2cSJim Jagielski relase_ChildImpl();
168*b1cdbd2cSJim Jagielski }
169*b1cdbd2cSJim Jagielski // --------------------------------------------------------------------------------
createStatement()170*b1cdbd2cSJim Jagielski Reference< XStatement > SAL_CALL OConnection::createStatement( ) throw(SQLException, RuntimeException)
171*b1cdbd2cSJim Jagielski {
172*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
173*b1cdbd2cSJim Jagielski checkDisposed(OConnection_BASE::rBHelper.bDisposed);
174*b1cdbd2cSJim Jagielski
175*b1cdbd2cSJim Jagielski OStatement* pStmt = new OStatement(this);
176*b1cdbd2cSJim Jagielski Reference< XStatement > xStmt = pStmt;
177*b1cdbd2cSJim Jagielski m_aStatements.push_back(WeakReferenceHelper(*pStmt));
178*b1cdbd2cSJim Jagielski return pStmt;
179*b1cdbd2cSJim Jagielski }
180*b1cdbd2cSJim Jagielski // --------------------------------------------------------------------------------
prepareStatement(const::rtl::OUString & sql)181*b1cdbd2cSJim Jagielski Reference< XPreparedStatement > SAL_CALL OConnection::prepareStatement( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
182*b1cdbd2cSJim Jagielski {
183*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
184*b1cdbd2cSJim Jagielski checkDisposed(OConnection_BASE::rBHelper.bDisposed);
185*b1cdbd2cSJim Jagielski
186*b1cdbd2cSJim Jagielski
187*b1cdbd2cSJim Jagielski OPreparedStatement* pStmt = new OPreparedStatement(this,m_aTypeInfo,sql);
188*b1cdbd2cSJim Jagielski Reference< XPreparedStatement > xPStmt = pStmt;
189*b1cdbd2cSJim Jagielski m_aStatements.push_back(WeakReferenceHelper(*pStmt));
190*b1cdbd2cSJim Jagielski return xPStmt;
191*b1cdbd2cSJim Jagielski }
192*b1cdbd2cSJim Jagielski // --------------------------------------------------------------------------------
prepareCall(const::rtl::OUString & sql)193*b1cdbd2cSJim Jagielski Reference< XPreparedStatement > SAL_CALL OConnection::prepareCall( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
194*b1cdbd2cSJim Jagielski {
195*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
196*b1cdbd2cSJim Jagielski checkDisposed(OConnection_BASE::rBHelper.bDisposed);
197*b1cdbd2cSJim Jagielski
198*b1cdbd2cSJim Jagielski
199*b1cdbd2cSJim Jagielski OCallableStatement* pStmt = new OCallableStatement(this,m_aTypeInfo,sql);
200*b1cdbd2cSJim Jagielski Reference< XPreparedStatement > xPStmt = pStmt;
201*b1cdbd2cSJim Jagielski m_aStatements.push_back(WeakReferenceHelper(*pStmt));
202*b1cdbd2cSJim Jagielski return xPStmt;
203*b1cdbd2cSJim Jagielski }
204*b1cdbd2cSJim Jagielski // --------------------------------------------------------------------------------
nativeSQL(const::rtl::OUString & _sql)205*b1cdbd2cSJim Jagielski ::rtl::OUString SAL_CALL OConnection::nativeSQL( const ::rtl::OUString& _sql ) throw(SQLException, RuntimeException)
206*b1cdbd2cSJim Jagielski {
207*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
208*b1cdbd2cSJim Jagielski checkDisposed(OConnection_BASE::rBHelper.bDisposed);
209*b1cdbd2cSJim Jagielski
210*b1cdbd2cSJim Jagielski
211*b1cdbd2cSJim Jagielski ::rtl::OUString sql = _sql;
212*b1cdbd2cSJim Jagielski WpADOProperties aProps = m_pAdoConnection->get_Properties();
213*b1cdbd2cSJim Jagielski if(aProps.IsValid())
214*b1cdbd2cSJim Jagielski {
215*b1cdbd2cSJim Jagielski OTools::putValue(aProps,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Jet OLEDB:ODBC Parsing")),sal_True);
216*b1cdbd2cSJim Jagielski WpADOCommand aCommand;
217*b1cdbd2cSJim Jagielski aCommand.Create();
218*b1cdbd2cSJim Jagielski aCommand.put_ActiveConnection((IDispatch*)*m_pAdoConnection);
219*b1cdbd2cSJim Jagielski aCommand.put_CommandText(sql);
220*b1cdbd2cSJim Jagielski sql = aCommand.get_CommandText();
221*b1cdbd2cSJim Jagielski }
222*b1cdbd2cSJim Jagielski
223*b1cdbd2cSJim Jagielski return sql;
224*b1cdbd2cSJim Jagielski }
225*b1cdbd2cSJim Jagielski // --------------------------------------------------------------------------------
setAutoCommit(sal_Bool autoCommit)226*b1cdbd2cSJim Jagielski void SAL_CALL OConnection::setAutoCommit( sal_Bool autoCommit ) throw(SQLException, RuntimeException)
227*b1cdbd2cSJim Jagielski {
228*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
229*b1cdbd2cSJim Jagielski checkDisposed(OConnection_BASE::rBHelper.bDisposed);
230*b1cdbd2cSJim Jagielski
231*b1cdbd2cSJim Jagielski
232*b1cdbd2cSJim Jagielski m_bAutocommit = autoCommit;
233*b1cdbd2cSJim Jagielski if(!autoCommit)
234*b1cdbd2cSJim Jagielski m_pAdoConnection->BeginTrans();
235*b1cdbd2cSJim Jagielski else
236*b1cdbd2cSJim Jagielski m_pAdoConnection->RollbackTrans();
237*b1cdbd2cSJim Jagielski }
238*b1cdbd2cSJim Jagielski // --------------------------------------------------------------------------------
getAutoCommit()239*b1cdbd2cSJim Jagielski sal_Bool SAL_CALL OConnection::getAutoCommit( ) throw(SQLException, RuntimeException)
240*b1cdbd2cSJim Jagielski {
241*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
242*b1cdbd2cSJim Jagielski checkDisposed(OConnection_BASE::rBHelper.bDisposed);
243*b1cdbd2cSJim Jagielski
244*b1cdbd2cSJim Jagielski
245*b1cdbd2cSJim Jagielski return m_bAutocommit;
246*b1cdbd2cSJim Jagielski }
247*b1cdbd2cSJim Jagielski // --------------------------------------------------------------------------------
commit()248*b1cdbd2cSJim Jagielski void SAL_CALL OConnection::commit( ) throw(SQLException, RuntimeException)
249*b1cdbd2cSJim Jagielski {
250*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
251*b1cdbd2cSJim Jagielski checkDisposed(OConnection_BASE::rBHelper.bDisposed);
252*b1cdbd2cSJim Jagielski
253*b1cdbd2cSJim Jagielski
254*b1cdbd2cSJim Jagielski m_pAdoConnection->CommitTrans();
255*b1cdbd2cSJim Jagielski }
256*b1cdbd2cSJim Jagielski // --------------------------------------------------------------------------------
rollback()257*b1cdbd2cSJim Jagielski void SAL_CALL OConnection::rollback( ) throw(SQLException, RuntimeException)
258*b1cdbd2cSJim Jagielski {
259*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
260*b1cdbd2cSJim Jagielski checkDisposed(OConnection_BASE::rBHelper.bDisposed);
261*b1cdbd2cSJim Jagielski
262*b1cdbd2cSJim Jagielski
263*b1cdbd2cSJim Jagielski m_pAdoConnection->RollbackTrans();
264*b1cdbd2cSJim Jagielski }
265*b1cdbd2cSJim Jagielski // --------------------------------------------------------------------------------
isClosed()266*b1cdbd2cSJim Jagielski sal_Bool SAL_CALL OConnection::isClosed( ) throw(SQLException, RuntimeException)
267*b1cdbd2cSJim Jagielski {
268*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
269*b1cdbd2cSJim Jagielski
270*b1cdbd2cSJim Jagielski return OConnection_BASE::rBHelper.bDisposed && !m_pAdoConnection->get_State();
271*b1cdbd2cSJim Jagielski }
272*b1cdbd2cSJim Jagielski // --------------------------------------------------------------------------------
getMetaData()273*b1cdbd2cSJim Jagielski Reference< XDatabaseMetaData > SAL_CALL OConnection::getMetaData( ) throw(SQLException, RuntimeException)
274*b1cdbd2cSJim Jagielski {
275*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
276*b1cdbd2cSJim Jagielski checkDisposed(OConnection_BASE::rBHelper.bDisposed);
277*b1cdbd2cSJim Jagielski
278*b1cdbd2cSJim Jagielski
279*b1cdbd2cSJim Jagielski Reference< XDatabaseMetaData > xMetaData = m_xMetaData;
280*b1cdbd2cSJim Jagielski if(!xMetaData.is())
281*b1cdbd2cSJim Jagielski {
282*b1cdbd2cSJim Jagielski xMetaData = new ODatabaseMetaData(this);
283*b1cdbd2cSJim Jagielski m_xMetaData = xMetaData;
284*b1cdbd2cSJim Jagielski }
285*b1cdbd2cSJim Jagielski
286*b1cdbd2cSJim Jagielski return xMetaData;
287*b1cdbd2cSJim Jagielski }
288*b1cdbd2cSJim Jagielski // --------------------------------------------------------------------------------
setReadOnly(sal_Bool readOnly)289*b1cdbd2cSJim Jagielski void SAL_CALL OConnection::setReadOnly( sal_Bool readOnly ) throw(SQLException, RuntimeException)
290*b1cdbd2cSJim Jagielski {
291*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
292*b1cdbd2cSJim Jagielski checkDisposed(OConnection_BASE::rBHelper.bDisposed);
293*b1cdbd2cSJim Jagielski
294*b1cdbd2cSJim Jagielski
295*b1cdbd2cSJim Jagielski
296*b1cdbd2cSJim Jagielski m_pAdoConnection->put_Mode(readOnly ? adModeRead : adModeReadWrite);
297*b1cdbd2cSJim Jagielski ADOS::ThrowException(*m_pAdoConnection,*this);
298*b1cdbd2cSJim Jagielski }
299*b1cdbd2cSJim Jagielski // --------------------------------------------------------------------------------
isReadOnly()300*b1cdbd2cSJim Jagielski sal_Bool SAL_CALL OConnection::isReadOnly( ) throw(SQLException, RuntimeException)
301*b1cdbd2cSJim Jagielski {
302*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
303*b1cdbd2cSJim Jagielski checkDisposed(OConnection_BASE::rBHelper.bDisposed);
304*b1cdbd2cSJim Jagielski
305*b1cdbd2cSJim Jagielski
306*b1cdbd2cSJim Jagielski return m_pAdoConnection->get_Mode() == adModeRead;
307*b1cdbd2cSJim Jagielski }
308*b1cdbd2cSJim Jagielski // --------------------------------------------------------------------------------
setCatalog(const::rtl::OUString & catalog)309*b1cdbd2cSJim Jagielski void SAL_CALL OConnection::setCatalog( const ::rtl::OUString& catalog ) throw(SQLException, RuntimeException)
310*b1cdbd2cSJim Jagielski {
311*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
312*b1cdbd2cSJim Jagielski checkDisposed(OConnection_BASE::rBHelper.bDisposed);
313*b1cdbd2cSJim Jagielski
314*b1cdbd2cSJim Jagielski m_pAdoConnection->PutDefaultDatabase(catalog);
315*b1cdbd2cSJim Jagielski ADOS::ThrowException(*m_pAdoConnection,*this);
316*b1cdbd2cSJim Jagielski }
317*b1cdbd2cSJim Jagielski // --------------------------------------------------------------------------------
getCatalog()318*b1cdbd2cSJim Jagielski ::rtl::OUString SAL_CALL OConnection::getCatalog( ) throw(SQLException, RuntimeException)
319*b1cdbd2cSJim Jagielski {
320*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
321*b1cdbd2cSJim Jagielski checkDisposed(OConnection_BASE::rBHelper.bDisposed);
322*b1cdbd2cSJim Jagielski
323*b1cdbd2cSJim Jagielski return m_pAdoConnection->GetDefaultDatabase();
324*b1cdbd2cSJim Jagielski }
325*b1cdbd2cSJim Jagielski // --------------------------------------------------------------------------------
setTransactionIsolation(sal_Int32 level)326*b1cdbd2cSJim Jagielski void SAL_CALL OConnection::setTransactionIsolation( sal_Int32 level ) throw(SQLException, RuntimeException)
327*b1cdbd2cSJim Jagielski {
328*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
329*b1cdbd2cSJim Jagielski checkDisposed(OConnection_BASE::rBHelper.bDisposed);
330*b1cdbd2cSJim Jagielski
331*b1cdbd2cSJim Jagielski
332*b1cdbd2cSJim Jagielski IsolationLevelEnum eIso;
333*b1cdbd2cSJim Jagielski switch(level)
334*b1cdbd2cSJim Jagielski {
335*b1cdbd2cSJim Jagielski case TransactionIsolation::NONE:
336*b1cdbd2cSJim Jagielski eIso = adXactUnspecified;
337*b1cdbd2cSJim Jagielski break;
338*b1cdbd2cSJim Jagielski case TransactionIsolation::READ_UNCOMMITTED:
339*b1cdbd2cSJim Jagielski eIso = adXactReadUncommitted;
340*b1cdbd2cSJim Jagielski break;
341*b1cdbd2cSJim Jagielski case TransactionIsolation::READ_COMMITTED:
342*b1cdbd2cSJim Jagielski eIso = adXactReadCommitted;
343*b1cdbd2cSJim Jagielski break;
344*b1cdbd2cSJim Jagielski case TransactionIsolation::REPEATABLE_READ:
345*b1cdbd2cSJim Jagielski eIso = adXactRepeatableRead;
346*b1cdbd2cSJim Jagielski break;
347*b1cdbd2cSJim Jagielski case TransactionIsolation::SERIALIZABLE:
348*b1cdbd2cSJim Jagielski eIso = adXactSerializable;
349*b1cdbd2cSJim Jagielski break;
350*b1cdbd2cSJim Jagielski default:
351*b1cdbd2cSJim Jagielski OSL_ENSURE(0,"OConnection::setTransactionIsolation invalid level");
352*b1cdbd2cSJim Jagielski return;
353*b1cdbd2cSJim Jagielski }
354*b1cdbd2cSJim Jagielski m_pAdoConnection->put_IsolationLevel(eIso);
355*b1cdbd2cSJim Jagielski ADOS::ThrowException(*m_pAdoConnection,*this);
356*b1cdbd2cSJim Jagielski }
357*b1cdbd2cSJim Jagielski // --------------------------------------------------------------------------------
getTransactionIsolation()358*b1cdbd2cSJim Jagielski sal_Int32 SAL_CALL OConnection::getTransactionIsolation( ) throw(SQLException, RuntimeException)
359*b1cdbd2cSJim Jagielski {
360*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
361*b1cdbd2cSJim Jagielski checkDisposed(OConnection_BASE::rBHelper.bDisposed);
362*b1cdbd2cSJim Jagielski
363*b1cdbd2cSJim Jagielski
364*b1cdbd2cSJim Jagielski sal_Int32 nRet = 0;
365*b1cdbd2cSJim Jagielski switch(m_pAdoConnection->get_IsolationLevel())
366*b1cdbd2cSJim Jagielski {
367*b1cdbd2cSJim Jagielski case adXactUnspecified:
368*b1cdbd2cSJim Jagielski nRet = TransactionIsolation::NONE;
369*b1cdbd2cSJim Jagielski break;
370*b1cdbd2cSJim Jagielski case adXactReadUncommitted:
371*b1cdbd2cSJim Jagielski nRet = TransactionIsolation::READ_UNCOMMITTED;
372*b1cdbd2cSJim Jagielski break;
373*b1cdbd2cSJim Jagielski case adXactReadCommitted:
374*b1cdbd2cSJim Jagielski nRet = TransactionIsolation::READ_COMMITTED;
375*b1cdbd2cSJim Jagielski break;
376*b1cdbd2cSJim Jagielski case adXactRepeatableRead:
377*b1cdbd2cSJim Jagielski nRet = TransactionIsolation::REPEATABLE_READ;
378*b1cdbd2cSJim Jagielski break;
379*b1cdbd2cSJim Jagielski case adXactSerializable:
380*b1cdbd2cSJim Jagielski nRet = TransactionIsolation::SERIALIZABLE;
381*b1cdbd2cSJim Jagielski break;
382*b1cdbd2cSJim Jagielski default:
383*b1cdbd2cSJim Jagielski OSL_ENSURE(0,"OConnection::setTransactionIsolation invalid level");
384*b1cdbd2cSJim Jagielski }
385*b1cdbd2cSJim Jagielski ADOS::ThrowException(*m_pAdoConnection,*this);
386*b1cdbd2cSJim Jagielski return nRet;
387*b1cdbd2cSJim Jagielski }
388*b1cdbd2cSJim Jagielski // --------------------------------------------------------------------------------
getTypeMap()389*b1cdbd2cSJim Jagielski Reference< ::com::sun::star::container::XNameAccess > SAL_CALL OConnection::getTypeMap( ) throw(SQLException, RuntimeException)
390*b1cdbd2cSJim Jagielski {
391*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
392*b1cdbd2cSJim Jagielski checkDisposed(OConnection_BASE::rBHelper.bDisposed);
393*b1cdbd2cSJim Jagielski
394*b1cdbd2cSJim Jagielski
395*b1cdbd2cSJim Jagielski return NULL;
396*b1cdbd2cSJim Jagielski }
397*b1cdbd2cSJim Jagielski // --------------------------------------------------------------------------------
setTypeMap(const Reference<::com::sun::star::container::XNameAccess> &)398*b1cdbd2cSJim Jagielski void SAL_CALL OConnection::setTypeMap( const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
399*b1cdbd2cSJim Jagielski {
400*b1cdbd2cSJim Jagielski ::dbtools::throwFeatureNotImplementedException( "XConnection::setTypeMap", *this );
401*b1cdbd2cSJim Jagielski }
402*b1cdbd2cSJim Jagielski // --------------------------------------------------------------------------------
403*b1cdbd2cSJim Jagielski // XCloseable
close()404*b1cdbd2cSJim Jagielski void SAL_CALL OConnection::close( ) throw(SQLException, RuntimeException)
405*b1cdbd2cSJim Jagielski {
406*b1cdbd2cSJim Jagielski {
407*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
408*b1cdbd2cSJim Jagielski checkDisposed(OConnection_BASE::rBHelper.bDisposed);
409*b1cdbd2cSJim Jagielski
410*b1cdbd2cSJim Jagielski }
411*b1cdbd2cSJim Jagielski dispose();
412*b1cdbd2cSJim Jagielski }
413*b1cdbd2cSJim Jagielski // --------------------------------------------------------------------------------
414*b1cdbd2cSJim Jagielski // XWarningsSupplier
getWarnings()415*b1cdbd2cSJim Jagielski Any SAL_CALL OConnection::getWarnings( ) throw(SQLException, RuntimeException)
416*b1cdbd2cSJim Jagielski {
417*b1cdbd2cSJim Jagielski return Any();
418*b1cdbd2cSJim Jagielski }
419*b1cdbd2cSJim Jagielski // --------------------------------------------------------------------------------
clearWarnings()420*b1cdbd2cSJim Jagielski void SAL_CALL OConnection::clearWarnings( ) throw(SQLException, RuntimeException)
421*b1cdbd2cSJim Jagielski {
422*b1cdbd2cSJim Jagielski }
423*b1cdbd2cSJim Jagielski //--------------------------------------------------------------------
buildTypeInfo()424*b1cdbd2cSJim Jagielski void OConnection::buildTypeInfo() throw( SQLException)
425*b1cdbd2cSJim Jagielski {
426*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
427*b1cdbd2cSJim Jagielski
428*b1cdbd2cSJim Jagielski ADORecordset *pRecordset = m_pAdoConnection->getTypeInfo();
429*b1cdbd2cSJim Jagielski if ( pRecordset )
430*b1cdbd2cSJim Jagielski {
431*b1cdbd2cSJim Jagielski pRecordset->AddRef();
432*b1cdbd2cSJim Jagielski VARIANT_BOOL bIsAtBOF;
433*b1cdbd2cSJim Jagielski pRecordset->get_BOF(&bIsAtBOF);
434*b1cdbd2cSJim Jagielski
435*b1cdbd2cSJim Jagielski sal_Bool bOk = sal_True;
436*b1cdbd2cSJim Jagielski if ( bIsAtBOF == VARIANT_TRUE )
437*b1cdbd2cSJim Jagielski bOk = SUCCEEDED(pRecordset->MoveNext());
438*b1cdbd2cSJim Jagielski
439*b1cdbd2cSJim Jagielski if ( bOk )
440*b1cdbd2cSJim Jagielski {
441*b1cdbd2cSJim Jagielski // HACK for access
442*b1cdbd2cSJim Jagielski static const ::rtl::OUString s_sVarChar(RTL_CONSTASCII_USTRINGPARAM("VarChar"));
443*b1cdbd2cSJim Jagielski do
444*b1cdbd2cSJim Jagielski {
445*b1cdbd2cSJim Jagielski sal_Int32 nPos = 1;
446*b1cdbd2cSJim Jagielski OExtendedTypeInfo* aInfo = new OExtendedTypeInfo();
447*b1cdbd2cSJim Jagielski aInfo->aSimpleType.aTypeName = ADOS::getField(pRecordset,nPos++).get_Value();
448*b1cdbd2cSJim Jagielski aInfo->eType = (DataTypeEnum)(sal_Int32)ADOS::getField(pRecordset,nPos++).get_Value();
449*b1cdbd2cSJim Jagielski if ( aInfo->eType == adWChar && aInfo->aSimpleType.aTypeName == s_sVarChar )
450*b1cdbd2cSJim Jagielski aInfo->eType = adVarWChar;
451*b1cdbd2cSJim Jagielski aInfo->aSimpleType.nType = (sal_Int16)ADOS::MapADOType2Jdbc(static_cast<DataTypeEnum>(aInfo->eType));
452*b1cdbd2cSJim Jagielski aInfo->aSimpleType.nPrecision = ADOS::getField(pRecordset,nPos++).get_Value();
453*b1cdbd2cSJim Jagielski aInfo->aSimpleType.aLiteralPrefix = ADOS::getField(pRecordset,nPos++).get_Value();
454*b1cdbd2cSJim Jagielski aInfo->aSimpleType.aLiteralSuffix = ADOS::getField(pRecordset,nPos++).get_Value();
455*b1cdbd2cSJim Jagielski aInfo->aSimpleType.aCreateParams = ADOS::getField(pRecordset,nPos++).get_Value();
456*b1cdbd2cSJim Jagielski aInfo->aSimpleType.bNullable = ADOS::getField(pRecordset,nPos++).get_Value();
457*b1cdbd2cSJim Jagielski aInfo->aSimpleType.bCaseSensitive = ADOS::getField(pRecordset,nPos++).get_Value();
458*b1cdbd2cSJim Jagielski aInfo->aSimpleType.nSearchType = ADOS::getField(pRecordset,nPos++).get_Value();
459*b1cdbd2cSJim Jagielski aInfo->aSimpleType.bUnsigned = ADOS::getField(pRecordset,nPos++).get_Value();
460*b1cdbd2cSJim Jagielski aInfo->aSimpleType.bCurrency = ADOS::getField(pRecordset,nPos++).get_Value();
461*b1cdbd2cSJim Jagielski aInfo->aSimpleType.bAutoIncrement = ADOS::getField(pRecordset,nPos++).get_Value();
462*b1cdbd2cSJim Jagielski aInfo->aSimpleType.aLocalTypeName = ADOS::getField(pRecordset,nPos++).get_Value();
463*b1cdbd2cSJim Jagielski aInfo->aSimpleType.nMinimumScale = ADOS::getField(pRecordset,nPos++).get_Value();
464*b1cdbd2cSJim Jagielski aInfo->aSimpleType.nMaximumScale = ADOS::getField(pRecordset,nPos++).get_Value();
465*b1cdbd2cSJim Jagielski if ( adCurrency == aInfo->eType && !aInfo->aSimpleType.nMaximumScale)
466*b1cdbd2cSJim Jagielski {
467*b1cdbd2cSJim Jagielski aInfo->aSimpleType.nMinimumScale = 4;
468*b1cdbd2cSJim Jagielski aInfo->aSimpleType.nMaximumScale = 4;
469*b1cdbd2cSJim Jagielski }
470*b1cdbd2cSJim Jagielski aInfo->aSimpleType.nNumPrecRadix = ADOS::getField(pRecordset,nPos++).get_Value();
471*b1cdbd2cSJim Jagielski // Now that we have the type info, save it
472*b1cdbd2cSJim Jagielski // in the Hashtable if we don't already have an
473*b1cdbd2cSJim Jagielski // entry for this SQL type.
474*b1cdbd2cSJim Jagielski
475*b1cdbd2cSJim Jagielski m_aTypeInfo.insert(OTypeInfoMap::value_type(aInfo->eType,aInfo));
476*b1cdbd2cSJim Jagielski }
477*b1cdbd2cSJim Jagielski while ( SUCCEEDED(pRecordset->MoveNext()) );
478*b1cdbd2cSJim Jagielski }
479*b1cdbd2cSJim Jagielski pRecordset->Release();
480*b1cdbd2cSJim Jagielski }
481*b1cdbd2cSJim Jagielski }
482*b1cdbd2cSJim Jagielski //------------------------------------------------------------------------------
disposing()483*b1cdbd2cSJim Jagielski void OConnection::disposing()
484*b1cdbd2cSJim Jagielski {
485*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard(m_aMutex);
486*b1cdbd2cSJim Jagielski
487*b1cdbd2cSJim Jagielski OConnection_BASE::disposing();
488*b1cdbd2cSJim Jagielski
489*b1cdbd2cSJim Jagielski m_bClosed = sal_True;
490*b1cdbd2cSJim Jagielski m_xMetaData = ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XDatabaseMetaData>();
491*b1cdbd2cSJim Jagielski m_xCatalog = ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbcx::XTablesSupplier>();
492*b1cdbd2cSJim Jagielski m_pDriver = NULL;
493*b1cdbd2cSJim Jagielski
494*b1cdbd2cSJim Jagielski m_pAdoConnection->Close();
495*b1cdbd2cSJim Jagielski
496*b1cdbd2cSJim Jagielski OTypeInfoMap::iterator aIter = m_aTypeInfo.begin();
497*b1cdbd2cSJim Jagielski for (; aIter != m_aTypeInfo.end(); ++aIter)
498*b1cdbd2cSJim Jagielski delete aIter->second;
499*b1cdbd2cSJim Jagielski
500*b1cdbd2cSJim Jagielski m_aTypeInfo.clear();
501*b1cdbd2cSJim Jagielski
502*b1cdbd2cSJim Jagielski delete m_pAdoConnection;
503*b1cdbd2cSJim Jagielski m_pAdoConnection = NULL;
504*b1cdbd2cSJim Jagielski
505*b1cdbd2cSJim Jagielski dispose_ChildImpl();
506*b1cdbd2cSJim Jagielski }
507*b1cdbd2cSJim Jagielski // -----------------------------------------------------------------------------
getSomething(const::com::sun::star::uno::Sequence<sal_Int8> & rId)508*b1cdbd2cSJim Jagielski sal_Int64 SAL_CALL OConnection::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw (::com::sun::star::uno::RuntimeException)
509*b1cdbd2cSJim Jagielski {
510*b1cdbd2cSJim Jagielski return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
511*b1cdbd2cSJim Jagielski ?
512*b1cdbd2cSJim Jagielski reinterpret_cast< sal_Int64 >( this )
513*b1cdbd2cSJim Jagielski :
514*b1cdbd2cSJim Jagielski OConnection_BASE::getSomething(rId);
515*b1cdbd2cSJim Jagielski }
516*b1cdbd2cSJim Jagielski // -----------------------------------------------------------------------------
getUnoTunnelImplementationId()517*b1cdbd2cSJim Jagielski Sequence< sal_Int8 > OConnection::getUnoTunnelImplementationId()
518*b1cdbd2cSJim Jagielski {
519*b1cdbd2cSJim Jagielski static ::cppu::OImplementationId * pId = 0;
520*b1cdbd2cSJim Jagielski if (! pId)
521*b1cdbd2cSJim Jagielski {
522*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
523*b1cdbd2cSJim Jagielski if (! pId)
524*b1cdbd2cSJim Jagielski {
525*b1cdbd2cSJim Jagielski static ::cppu::OImplementationId aId;
526*b1cdbd2cSJim Jagielski pId = &aId;
527*b1cdbd2cSJim Jagielski }
528*b1cdbd2cSJim Jagielski }
529*b1cdbd2cSJim Jagielski return pId->getImplementationId();
530*b1cdbd2cSJim Jagielski }
531*b1cdbd2cSJim Jagielski // -----------------------------------------------------------------------------
getTypeInfoFromType(const OTypeInfoMap & _rTypeInfo,DataTypeEnum _nType,const::rtl::OUString & _sTypeName,sal_Int32 _nPrecision,sal_Int32 _nScale,sal_Bool & _brForceToType)532*b1cdbd2cSJim Jagielski const OExtendedTypeInfo* OConnection::getTypeInfoFromType(const OTypeInfoMap& _rTypeInfo,
533*b1cdbd2cSJim Jagielski DataTypeEnum _nType,
534*b1cdbd2cSJim Jagielski const ::rtl::OUString& _sTypeName,
535*b1cdbd2cSJim Jagielski sal_Int32 _nPrecision,
536*b1cdbd2cSJim Jagielski sal_Int32 _nScale,
537*b1cdbd2cSJim Jagielski sal_Bool& _brForceToType)
538*b1cdbd2cSJim Jagielski {
539*b1cdbd2cSJim Jagielski const OExtendedTypeInfo* pTypeInfo = NULL;
540*b1cdbd2cSJim Jagielski _brForceToType = sal_False;
541*b1cdbd2cSJim Jagielski // search for type
542*b1cdbd2cSJim Jagielski ::std::pair<OTypeInfoMap::const_iterator, OTypeInfoMap::const_iterator> aPair = _rTypeInfo.equal_range(_nType);
543*b1cdbd2cSJim Jagielski OTypeInfoMap::const_iterator aIter = aPair.first;
544*b1cdbd2cSJim Jagielski if(aIter != _rTypeInfo.end()) // compare with end is correct here
545*b1cdbd2cSJim Jagielski {
546*b1cdbd2cSJim Jagielski for(;aIter != aPair.second;++aIter)
547*b1cdbd2cSJim Jagielski {
548*b1cdbd2cSJim Jagielski // search the best matching type
549*b1cdbd2cSJim Jagielski OExtendedTypeInfo* pInfo = aIter->second;
550*b1cdbd2cSJim Jagielski #ifdef DBG_UTIL
551*b1cdbd2cSJim Jagielski ::rtl::OUString sDBTypeName = pInfo->aSimpleType.aTypeName;
552*b1cdbd2cSJim Jagielski sal_Int32 nDBTypePrecision = pInfo->aSimpleType.nPrecision; (void)nDBTypePrecision;
553*b1cdbd2cSJim Jagielski sal_Int32 nDBTypeScale = pInfo->aSimpleType.nMaximumScale; (void)nDBTypeScale;
554*b1cdbd2cSJim Jagielski sal_Int32 nAdoType = pInfo->eType; (void)nAdoType;
555*b1cdbd2cSJim Jagielski #endif
556*b1cdbd2cSJim Jagielski if ( ( !_sTypeName.getLength()
557*b1cdbd2cSJim Jagielski || (pInfo->aSimpleType.aTypeName.equalsIgnoreAsciiCase(_sTypeName))
558*b1cdbd2cSJim Jagielski )
559*b1cdbd2cSJim Jagielski && (pInfo->aSimpleType.nPrecision >= _nPrecision)
560*b1cdbd2cSJim Jagielski && (pInfo->aSimpleType.nMaximumScale >= _nScale)
561*b1cdbd2cSJim Jagielski
562*b1cdbd2cSJim Jagielski )
563*b1cdbd2cSJim Jagielski break;
564*b1cdbd2cSJim Jagielski }
565*b1cdbd2cSJim Jagielski
566*b1cdbd2cSJim Jagielski if (aIter == aPair.second)
567*b1cdbd2cSJim Jagielski {
568*b1cdbd2cSJim Jagielski for(aIter = aPair.first; aIter != aPair.second; ++aIter)
569*b1cdbd2cSJim Jagielski {
570*b1cdbd2cSJim Jagielski // search the best matching type (now comparing the local names)
571*b1cdbd2cSJim Jagielski if ( (aIter->second->aSimpleType.aLocalTypeName.equalsIgnoreAsciiCase(_sTypeName))
572*b1cdbd2cSJim Jagielski && (aIter->second->aSimpleType.nPrecision >= _nPrecision)
573*b1cdbd2cSJim Jagielski && (aIter->second->aSimpleType.nMaximumScale >= _nScale)
574*b1cdbd2cSJim Jagielski )
575*b1cdbd2cSJim Jagielski {
576*b1cdbd2cSJim Jagielski // we can not assert here because we could be in d&d
577*b1cdbd2cSJim Jagielski /*
578*b1cdbd2cSJim Jagielski OSL_ENSURE(sal_False,
579*b1cdbd2cSJim Jagielski ( ::rtl::OString("getTypeInfoFromType: assuming column type ")
580*b1cdbd2cSJim Jagielski += ::rtl::OString(aIter->second->aTypeName.getStr(), aIter->second->aTypeName.getLength(), gsl_getSystemTextEncoding())
581*b1cdbd2cSJim Jagielski += ::rtl::OString("\" (expected type name ")
582*b1cdbd2cSJim Jagielski += ::rtl::OString(_sTypeName.getStr(), _sTypeName.getLength(), gsl_getSystemTextEncoding())
583*b1cdbd2cSJim Jagielski += ::rtl::OString(" matches the type's local name).")).getStr());
584*b1cdbd2cSJim Jagielski */
585*b1cdbd2cSJim Jagielski break;
586*b1cdbd2cSJim Jagielski }
587*b1cdbd2cSJim Jagielski }
588*b1cdbd2cSJim Jagielski }
589*b1cdbd2cSJim Jagielski
590*b1cdbd2cSJim Jagielski if (aIter == aPair.second)
591*b1cdbd2cSJim Jagielski { // no match for the names, no match for the local names
592*b1cdbd2cSJim Jagielski // -> drop the precision and the scale restriction, accept any type with the property
593*b1cdbd2cSJim Jagielski // type id (nType)
594*b1cdbd2cSJim Jagielski
595*b1cdbd2cSJim Jagielski // we can not assert here because we could be in d&d
596*b1cdbd2cSJim Jagielski pTypeInfo = aPair.first->second;
597*b1cdbd2cSJim Jagielski _brForceToType = sal_True;
598*b1cdbd2cSJim Jagielski }
599*b1cdbd2cSJim Jagielski else
600*b1cdbd2cSJim Jagielski pTypeInfo = aIter->second;
601*b1cdbd2cSJim Jagielski }
602*b1cdbd2cSJim Jagielski else if ( _sTypeName.getLength() )
603*b1cdbd2cSJim Jagielski {
604*b1cdbd2cSJim Jagielski ::comphelper::TStringMixEqualFunctor aCase(sal_False);
605*b1cdbd2cSJim Jagielski // search for typeinfo where the typename is equal _sTypeName
606*b1cdbd2cSJim Jagielski OTypeInfoMap::const_iterator aFind = ::std::find_if(_rTypeInfo.begin(),
607*b1cdbd2cSJim Jagielski _rTypeInfo.end(),
608*b1cdbd2cSJim Jagielski ::std::compose1(
609*b1cdbd2cSJim Jagielski ::std::bind2nd(aCase, _sTypeName),
610*b1cdbd2cSJim Jagielski ::std::compose1(
611*b1cdbd2cSJim Jagielski ::std::mem_fun(&OExtendedTypeInfo::getDBName),
612*b1cdbd2cSJim Jagielski ::std::select2nd<OTypeInfoMap::value_type>())
613*b1cdbd2cSJim Jagielski )
614*b1cdbd2cSJim Jagielski );
615*b1cdbd2cSJim Jagielski if(aFind != _rTypeInfo.end())
616*b1cdbd2cSJim Jagielski pTypeInfo = aFind->second;
617*b1cdbd2cSJim Jagielski }
618*b1cdbd2cSJim Jagielski
619*b1cdbd2cSJim Jagielski // we can not assert here because we could be in d&d
620*b1cdbd2cSJim Jagielski // OSL_ENSURE(pTypeInfo, "getTypeInfoFromType: no type info found for this type!");
621*b1cdbd2cSJim Jagielski return pTypeInfo;
622*b1cdbd2cSJim Jagielski }
623*b1cdbd2cSJim Jagielski // -----------------------------------------------------------------------------
624*b1cdbd2cSJim Jagielski
625*b1cdbd2cSJim Jagielski
626*b1cdbd2cSJim Jagielski
627