1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_connectivity.hxx"
30*cdf0e10cSrcweir #include <com/sun/star/sdbcx/Privilege.hpp>
31*cdf0e10cSrcweir #include <com/sun/star/sdbcx/PrivilegeObject.hpp>
32*cdf0e10cSrcweir #include "connectivity/dbexception.hxx"
33*cdf0e10cSrcweir #include "ado/Awrapado.hxx"
34*cdf0e10cSrcweir #include "ado/adoimp.hxx"
35*cdf0e10cSrcweir #include <osl/diagnose.h>
36*cdf0e10cSrcweir #include <com/sun/star/sdbc/DataType.hpp>
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir using namespace connectivity::ado;
40*cdf0e10cSrcweir using namespace com::sun::star::uno;
41*cdf0e10cSrcweir using namespace com::sun::star::sdbc;
42*cdf0e10cSrcweir using namespace com::sun::star::sdbcx;
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir #define MYADOID(l) {l, 0,0x10,0x80,0,0,0xAA,0,0x6D,0x2E,0xA4};
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir const CLSID ADOS::CLSID_ADOCONNECTION_21	=	MYADOID(0x00000514);
48*cdf0e10cSrcweir const IID	ADOS::IID_ADOCONNECTION_21		=	MYADOID(0x00000550);
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir const CLSID ADOS::CLSID_ADOCOMMAND_21		=	MYADOID(0x00000507);
51*cdf0e10cSrcweir const IID	ADOS::IID_ADOCOMMAND_21			=	MYADOID(0x0000054E);
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir const CLSID ADOS::CLSID_ADORECORDSET_21		=	MYADOID(0x00000535);
54*cdf0e10cSrcweir const IID	ADOS::IID_ADORECORDSET_21		=	MYADOID(0x0000054F);
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir const CLSID ADOS::CLSID_ADOCATALOG_25		=	MYADOID(0x00000602);
57*cdf0e10cSrcweir const IID ADOS::IID_ADOCATALOG_25			=	MYADOID(0x00000603);
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir const CLSID ADOS::CLSID_ADOINDEX_25			=	MYADOID(0x0000061E);
60*cdf0e10cSrcweir const IID ADOS::IID_ADOINDEX_25				=	MYADOID(0x0000061F);
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir const CLSID ADOS::CLSID_ADOTABLE_25			=	MYADOID(0x00000609);
63*cdf0e10cSrcweir const IID ADOS::IID_ADOTABLE_25				=	MYADOID(0x00000610);
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir const CLSID ADOS::CLSID_ADOKEY_25			=	MYADOID(0x00000621);
66*cdf0e10cSrcweir const IID ADOS::IID_ADOKEY_25				=	MYADOID(0x00000622);
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir const CLSID ADOS::CLSID_ADOCOLUMN_25		=	MYADOID(0x0000061B);
69*cdf0e10cSrcweir const IID ADOS::IID_ADOCOLUMN_25			=	MYADOID(0x0000061C);
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir const CLSID ADOS::CLSID_ADOGROUP_25			=	MYADOID(0x00000615);
72*cdf0e10cSrcweir const IID ADOS::IID_ADOGROUP_25				=	MYADOID(0x00000616);
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir const CLSID ADOS::CLSID_ADOUSER_25			=	MYADOID(0x00000618);
75*cdf0e10cSrcweir const IID ADOS::IID_ADOUSER_25				=	MYADOID(0x00000619);
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir const CLSID ADOS::CLSID_ADOVIEW_25			=	MYADOID(0x00000612);
78*cdf0e10cSrcweir const IID ADOS::IID_ADOVIEW_25				=	MYADOID(0x00000613);
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir OLEString& ADOS::GetKeyStr()
81*cdf0e10cSrcweir {
82*cdf0e10cSrcweir 	static OLEString sKeyStr(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("gxwaezucfyqpwjgqbcmtsncuhwsnyhiohwxz")));
83*cdf0e10cSrcweir 	return sKeyStr;
84*cdf0e10cSrcweir }
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir // -------------------------------------------------------------------------
87*cdf0e10cSrcweir sal_Int32 ADOS::MapADOType2Jdbc(DataTypeEnum eType)
88*cdf0e10cSrcweir {
89*cdf0e10cSrcweir 	sal_Int32 nType = DataType::VARCHAR;;
90*cdf0e10cSrcweir 	switch (eType)
91*cdf0e10cSrcweir 	{
92*cdf0e10cSrcweir 		case adUnsignedSmallInt:
93*cdf0e10cSrcweir 		case adSmallInt:			nType = DataType::SMALLINT;		break;
94*cdf0e10cSrcweir 		case adUnsignedInt:
95*cdf0e10cSrcweir 		case adInteger:				nType = DataType::INTEGER;		break;
96*cdf0e10cSrcweir 		case adUnsignedBigInt:
97*cdf0e10cSrcweir 		case adBigInt:				nType = DataType::BIGINT;		break;
98*cdf0e10cSrcweir 		case adSingle:				nType = DataType::FLOAT;		break;
99*cdf0e10cSrcweir 		case adDouble:				nType = DataType::DOUBLE;		break;
100*cdf0e10cSrcweir 		case adCurrency:			nType = DataType::DOUBLE;		break;
101*cdf0e10cSrcweir 		case adVarNumeric:
102*cdf0e10cSrcweir 		case adNumeric:				nType = DataType::NUMERIC;		break;
103*cdf0e10cSrcweir 		case adDecimal:				nType = DataType::DECIMAL;		break;
104*cdf0e10cSrcweir 		case adDBDate:				nType = DataType::DATE;			break;
105*cdf0e10cSrcweir 		case adDBTime:				nType = DataType::TIME;			break;
106*cdf0e10cSrcweir 		case adDate:
107*cdf0e10cSrcweir 		case adDBTimeStamp:			nType = DataType::TIMESTAMP;	break;
108*cdf0e10cSrcweir 		case adBoolean:				nType = DataType::BOOLEAN;		break;
109*cdf0e10cSrcweir //		case adArray:				nType = DataType::ARRAY;		break;
110*cdf0e10cSrcweir 		case adBinary:				nType = DataType::BINARY;		break;
111*cdf0e10cSrcweir 		case adGUID:				nType = DataType::OBJECT;		break;
112*cdf0e10cSrcweir 		case adBSTR:
113*cdf0e10cSrcweir 		case adVarWChar:
114*cdf0e10cSrcweir 		case adWChar:
115*cdf0e10cSrcweir 		case adVarChar:				nType = DataType::VARCHAR;		break;
116*cdf0e10cSrcweir 		case adLongVarWChar:
117*cdf0e10cSrcweir 		case adLongVarChar:			nType = DataType::LONGVARCHAR;	break;
118*cdf0e10cSrcweir 		case adVarBinary:			nType = DataType::VARBINARY;	break;
119*cdf0e10cSrcweir 		case adLongVarBinary:		nType = DataType::LONGVARBINARY;break;
120*cdf0e10cSrcweir 		case adChar:				nType = DataType::CHAR;			break;
121*cdf0e10cSrcweir 		case adUnsignedTinyInt:
122*cdf0e10cSrcweir 		case adTinyInt:				nType = DataType::TINYINT;		break;
123*cdf0e10cSrcweir 		case adEmpty:				nType = DataType::SQLNULL;		break;
124*cdf0e10cSrcweir 		case adUserDefined:
125*cdf0e10cSrcweir 		case adPropVariant:
126*cdf0e10cSrcweir 		case adFileTime:
127*cdf0e10cSrcweir 		case adChapter:
128*cdf0e10cSrcweir 		case adIDispatch:
129*cdf0e10cSrcweir 		case adIUnknown:
130*cdf0e10cSrcweir 		case adError:
131*cdf0e10cSrcweir 		case adVariant:
132*cdf0e10cSrcweir 									nType = DataType::OTHER;		break;
133*cdf0e10cSrcweir 		default:
134*cdf0e10cSrcweir 			OSL_ENSURE(0,"MapADOType2Jdbc: Unknown Type!");
135*cdf0e10cSrcweir 			;
136*cdf0e10cSrcweir 	}
137*cdf0e10cSrcweir 	return nType;
138*cdf0e10cSrcweir }
139*cdf0e10cSrcweir // -------------------------------------------------------------------------
140*cdf0e10cSrcweir DataTypeEnum ADOS::MapJdbc2ADOType(sal_Int32 _nType,sal_Int32 _nJetEngine)
141*cdf0e10cSrcweir {
142*cdf0e10cSrcweir 	switch (_nType)
143*cdf0e10cSrcweir 	{
144*cdf0e10cSrcweir 		case DataType::SMALLINT:		return adSmallInt;			break;
145*cdf0e10cSrcweir 		case DataType::INTEGER:			return adInteger;			break;
146*cdf0e10cSrcweir 		case DataType::BIGINT:			return adBigInt;			break;
147*cdf0e10cSrcweir 		case DataType::FLOAT:			return adSingle;			break;
148*cdf0e10cSrcweir 		case DataType::DOUBLE:			return adDouble;			break;
149*cdf0e10cSrcweir 		case DataType::NUMERIC:			return adNumeric;			break;
150*cdf0e10cSrcweir 		case DataType::DECIMAL:			return adDecimal;			break;
151*cdf0e10cSrcweir 		case DataType::DATE:			return isJetEngine(_nJetEngine) ? adDate : adDBDate;			break;
152*cdf0e10cSrcweir 		case DataType::TIME:			return adDBTime;			break;
153*cdf0e10cSrcweir 		case DataType::TIMESTAMP:		return isJetEngine(_nJetEngine) ? adDate : adDBTimeStamp;		break;
154*cdf0e10cSrcweir         case DataType::BOOLEAN:
155*cdf0e10cSrcweir 		case DataType::BIT:				return adBoolean;			break;
156*cdf0e10cSrcweir 		case DataType::BINARY:			return adBinary;			break;
157*cdf0e10cSrcweir 		case DataType::VARCHAR:			return adVarWChar;			break;
158*cdf0e10cSrcweir 		case DataType::CLOB:
159*cdf0e10cSrcweir 		case DataType::LONGVARCHAR:		return adLongVarWChar;		break;
160*cdf0e10cSrcweir 		case DataType::VARBINARY:		return adVarBinary;			break;
161*cdf0e10cSrcweir 		case DataType::BLOB:
162*cdf0e10cSrcweir 		case DataType::LONGVARBINARY:	return adLongVarBinary;		break;
163*cdf0e10cSrcweir 		case DataType::CHAR:			return adWChar;				break;
164*cdf0e10cSrcweir 		case DataType::TINYINT:			return isJetEngine(_nJetEngine) ? adUnsignedTinyInt : adTinyInt;break;
165*cdf0e10cSrcweir 		case DataType::OBJECT:			return adGUID;		break;
166*cdf0e10cSrcweir 	default:
167*cdf0e10cSrcweir 		OSL_ENSURE(0,"MapJdbc2ADOType: Unknown Type!");
168*cdf0e10cSrcweir 			;
169*cdf0e10cSrcweir 	}
170*cdf0e10cSrcweir 	return adEmpty;
171*cdf0e10cSrcweir }
172*cdf0e10cSrcweir // -----------------------------------------------------------------------------
173*cdf0e10cSrcweir const int JET_ENGINETYPE_UNKNOWN	= 0;
174*cdf0e10cSrcweir const int JET_ENGINETYPE_JET10		= 1;
175*cdf0e10cSrcweir const int JET_ENGINETYPE_JET11		= 2;
176*cdf0e10cSrcweir const int JET_ENGINETYPE_JET20		= 3;
177*cdf0e10cSrcweir const int JET_ENGINETYPE_JET3X		= 4;
178*cdf0e10cSrcweir const int JET_ENGINETYPE_JET4X		= 5;
179*cdf0e10cSrcweir const int JET_ENGINETYPE_DBASE3		= 10;
180*cdf0e10cSrcweir const int JET_ENGINETYPE_DBASE4		= 11;
181*cdf0e10cSrcweir const int JET_ENGINETYPE_DBASE5		= 12;
182*cdf0e10cSrcweir const int JET_ENGINETYPE_EXCEL30	= 20;
183*cdf0e10cSrcweir const int JET_ENGINETYPE_EXCEL40	= 21;
184*cdf0e10cSrcweir const int JET_ENGINETYPE_EXCEL50	= 22;
185*cdf0e10cSrcweir const int JET_ENGINETYPE_EXCEL80	= 23;
186*cdf0e10cSrcweir const int JET_ENGINETYPE_EXCEL90	= 24;
187*cdf0e10cSrcweir const int JET_ENGINETYPE_EXCHANGE4	= 30;
188*cdf0e10cSrcweir const int JET_ENGINETYPE_LOTUSWK1	= 40;
189*cdf0e10cSrcweir const int JET_ENGINETYPE_LOTUSWK3	= 41;
190*cdf0e10cSrcweir const int JET_ENGINETYPE_LOTUSWK4	= 42;
191*cdf0e10cSrcweir const int JET_ENGINETYPE_PARADOX3X	= 50;
192*cdf0e10cSrcweir const int JET_ENGINETYPE_PARADOX4X	= 51;
193*cdf0e10cSrcweir const int JET_ENGINETYPE_PARADOX5X	= 52;
194*cdf0e10cSrcweir const int JET_ENGINETYPE_PARADOX7X	= 53;
195*cdf0e10cSrcweir const int JET_ENGINETYPE_TEXT1X		= 60;
196*cdf0e10cSrcweir const int JET_ENGINETYPE_HTML1X		= 70;
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir sal_Bool ADOS::isJetEngine(sal_Int32 _nEngineType)
199*cdf0e10cSrcweir {
200*cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
201*cdf0e10cSrcweir 	switch(_nEngineType)
202*cdf0e10cSrcweir 	{
203*cdf0e10cSrcweir 		case JET_ENGINETYPE_UNKNOWN:
204*cdf0e10cSrcweir 		case JET_ENGINETYPE_JET10:
205*cdf0e10cSrcweir 		case JET_ENGINETYPE_JET11:
206*cdf0e10cSrcweir 		case JET_ENGINETYPE_JET20:
207*cdf0e10cSrcweir 		case JET_ENGINETYPE_JET3X:
208*cdf0e10cSrcweir 		case JET_ENGINETYPE_JET4X:
209*cdf0e10cSrcweir 		case JET_ENGINETYPE_DBASE3:
210*cdf0e10cSrcweir 		case JET_ENGINETYPE_DBASE4:
211*cdf0e10cSrcweir 		case JET_ENGINETYPE_DBASE5:
212*cdf0e10cSrcweir 		case JET_ENGINETYPE_EXCEL30:
213*cdf0e10cSrcweir 		case JET_ENGINETYPE_EXCEL40:
214*cdf0e10cSrcweir 		case JET_ENGINETYPE_EXCEL50:
215*cdf0e10cSrcweir 		case JET_ENGINETYPE_EXCEL80:
216*cdf0e10cSrcweir 		case JET_ENGINETYPE_EXCEL90:
217*cdf0e10cSrcweir 		case JET_ENGINETYPE_EXCHANGE4:
218*cdf0e10cSrcweir 		case JET_ENGINETYPE_LOTUSWK1:
219*cdf0e10cSrcweir 		case JET_ENGINETYPE_LOTUSWK3:
220*cdf0e10cSrcweir 		case JET_ENGINETYPE_LOTUSWK4:
221*cdf0e10cSrcweir 		case JET_ENGINETYPE_PARADOX3X:
222*cdf0e10cSrcweir 		case JET_ENGINETYPE_PARADOX4X:
223*cdf0e10cSrcweir 		case JET_ENGINETYPE_PARADOX5X:
224*cdf0e10cSrcweir 		case JET_ENGINETYPE_PARADOX7X:
225*cdf0e10cSrcweir 		case JET_ENGINETYPE_TEXT1X:
226*cdf0e10cSrcweir 		case JET_ENGINETYPE_HTML1X:
227*cdf0e10cSrcweir 			bRet = sal_True;
228*cdf0e10cSrcweir 			break;
229*cdf0e10cSrcweir 	}
230*cdf0e10cSrcweir 	return bRet;
231*cdf0e10cSrcweir }
232*cdf0e10cSrcweir // -----------------------------------------------------------------------------
233*cdf0e10cSrcweir ObjectTypeEnum ADOS::mapObjectType2Ado(sal_Int32 objType)
234*cdf0e10cSrcweir {
235*cdf0e10cSrcweir 	ObjectTypeEnum eType = adPermObjTable;
236*cdf0e10cSrcweir 	switch(objType)
237*cdf0e10cSrcweir 	{
238*cdf0e10cSrcweir 		case PrivilegeObject::TABLE:
239*cdf0e10cSrcweir 			eType = adPermObjTable;
240*cdf0e10cSrcweir 			break;
241*cdf0e10cSrcweir 		case PrivilegeObject::VIEW:
242*cdf0e10cSrcweir 			eType = adPermObjView;
243*cdf0e10cSrcweir 			break;
244*cdf0e10cSrcweir 		case PrivilegeObject::COLUMN:
245*cdf0e10cSrcweir 			eType = adPermObjColumn;
246*cdf0e10cSrcweir 			break;
247*cdf0e10cSrcweir 	}
248*cdf0e10cSrcweir 	return eType;
249*cdf0e10cSrcweir }
250*cdf0e10cSrcweir // -----------------------------------------------------------------------------
251*cdf0e10cSrcweir sal_Int32 ADOS::mapAdoType2Object(ObjectTypeEnum objType)
252*cdf0e10cSrcweir {
253*cdf0e10cSrcweir 	sal_Int32 nType = PrivilegeObject::TABLE;
254*cdf0e10cSrcweir 	switch(objType)
255*cdf0e10cSrcweir 	{
256*cdf0e10cSrcweir 		case adPermObjTable:
257*cdf0e10cSrcweir 			nType = PrivilegeObject::TABLE;
258*cdf0e10cSrcweir 			break;
259*cdf0e10cSrcweir 		case adPermObjView:
260*cdf0e10cSrcweir 			nType = PrivilegeObject::VIEW;
261*cdf0e10cSrcweir 			break;
262*cdf0e10cSrcweir 		case adPermObjColumn:
263*cdf0e10cSrcweir 			nType = PrivilegeObject::COLUMN;
264*cdf0e10cSrcweir 			break;
265*cdf0e10cSrcweir         default:
266*cdf0e10cSrcweir             OSL_ENSURE( false, "ADOS::mapAdoType2Object: privilege type cannot be translated!" );
267*cdf0e10cSrcweir             break;
268*cdf0e10cSrcweir 	}
269*cdf0e10cSrcweir 	return nType;
270*cdf0e10cSrcweir }
271*cdf0e10cSrcweir #ifdef DELETE
272*cdf0e10cSrcweir #undef DELETE
273*cdf0e10cSrcweir #endif
274*cdf0e10cSrcweir // -----------------------------------------------------------------------------
275*cdf0e10cSrcweir sal_Int32 ADOS::mapAdoRights2Sdbc(RightsEnum eRights)
276*cdf0e10cSrcweir {
277*cdf0e10cSrcweir 	sal_Int32 nRights = 0;
278*cdf0e10cSrcweir 	if((eRights & adRightInsert) == adRightInsert)
279*cdf0e10cSrcweir 		nRights |= Privilege::INSERT;
280*cdf0e10cSrcweir 	if((eRights & adRightDelete) == adRightDelete)
281*cdf0e10cSrcweir 		nRights |= ::com::sun::star::sdbcx::Privilege::DELETE;
282*cdf0e10cSrcweir 	if((eRights & adRightUpdate) == adRightUpdate)
283*cdf0e10cSrcweir 		nRights |= Privilege::UPDATE;
284*cdf0e10cSrcweir 	if((eRights & adRightWriteDesign) == adRightWriteDesign)
285*cdf0e10cSrcweir 		nRights |= Privilege::ALTER;
286*cdf0e10cSrcweir 	if((eRights & adRightRead) == adRightRead)
287*cdf0e10cSrcweir 		nRights |= Privilege::SELECT;
288*cdf0e10cSrcweir 	if((eRights & adRightReference) == adRightReference)
289*cdf0e10cSrcweir 		nRights |= Privilege::REFERENCE;
290*cdf0e10cSrcweir 	if((eRights & adRightDrop) == adRightDrop)
291*cdf0e10cSrcweir 		nRights |= Privilege::DROP;
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir 	return nRights;
294*cdf0e10cSrcweir }
295*cdf0e10cSrcweir // -----------------------------------------------------------------------------
296*cdf0e10cSrcweir sal_Int32 ADOS::mapRights2Ado(sal_Int32 nRights)
297*cdf0e10cSrcweir {
298*cdf0e10cSrcweir 	sal_Int32 eRights = adRightNone;
299*cdf0e10cSrcweir 
300*cdf0e10cSrcweir 	if((nRights & Privilege::INSERT) == Privilege::INSERT)
301*cdf0e10cSrcweir 		eRights |= adRightInsert;
302*cdf0e10cSrcweir 	if((nRights & Privilege::DELETE) == Privilege::DELETE)
303*cdf0e10cSrcweir 		eRights |= adRightDelete;
304*cdf0e10cSrcweir 	if((nRights & Privilege::UPDATE) == Privilege::UPDATE)
305*cdf0e10cSrcweir 		eRights |= adRightUpdate;
306*cdf0e10cSrcweir 	if((nRights & Privilege::ALTER) == Privilege::ALTER)
307*cdf0e10cSrcweir 		eRights |= adRightWriteDesign;
308*cdf0e10cSrcweir 	if((nRights & Privilege::SELECT) == Privilege::SELECT)
309*cdf0e10cSrcweir 		eRights |= adRightRead;
310*cdf0e10cSrcweir 	if((nRights & Privilege::REFERENCE) == Privilege::REFERENCE)
311*cdf0e10cSrcweir 		eRights |= adRightReference;
312*cdf0e10cSrcweir 	if((nRights & Privilege::DROP) == Privilege::DROP)
313*cdf0e10cSrcweir 		eRights |= adRightDrop;
314*cdf0e10cSrcweir 
315*cdf0e10cSrcweir 	return eRights;
316*cdf0e10cSrcweir }
317*cdf0e10cSrcweir // -----------------------------------------------------------------------------
318*cdf0e10cSrcweir WpADOField ADOS::getField(ADORecordset* _pRecordSet,sal_Int32 _nColumnIndex) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
319*cdf0e10cSrcweir {
320*cdf0e10cSrcweir 	if ( !_pRecordSet )
321*cdf0e10cSrcweir 		return WpADOField();
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir 	ADOFields* pFields	= NULL;
324*cdf0e10cSrcweir 	_pRecordSet->get_Fields(&pFields);
325*cdf0e10cSrcweir 	WpOLEAppendCollection<ADOFields, ADOField, WpADOField>	aFields(pFields);
326*cdf0e10cSrcweir 	if(_nColumnIndex <= 0 || _nColumnIndex > aFields.GetItemCount())
327*cdf0e10cSrcweir 		::dbtools::throwInvalidIndexException(NULL);
328*cdf0e10cSrcweir 	WpADOField aField(aFields.GetItem(_nColumnIndex-1));
329*cdf0e10cSrcweir 	if(!aField.IsValid())
330*cdf0e10cSrcweir 		::dbtools::throwInvalidIndexException(NULL);
331*cdf0e10cSrcweir 	return aField;
332*cdf0e10cSrcweir }
333*cdf0e10cSrcweir // -----------------------------------------------------------------------------
334*cdf0e10cSrcweir 
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir 
338