LibreOffice Module connectivity (master) 1
adoimp.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <com/sun/star/sdbcx/Privilege.hpp>
21#include <com/sun/star/sdbcx/PrivilegeObject.hpp>
23#include <ado/Awrapado.hxx>
24#include <ado/adoimp.hxx>
25#include <osl/diagnose.h>
26#include <systools/win32/oleauto.hxx>
27#include <com/sun/star/sdbc/DataType.hpp>
28
29
30using namespace connectivity::ado;
31using namespace com::sun::star::uno;
32using namespace com::sun::star::sdbc;
33using namespace com::sun::star::sdbcx;
34
35
36#define MYADOID(l) {l, 0,0x10,{0x80,0,0,0xAA,0,0x6D,0x2E,0xA4}};
37
38const CLSID ADOS::CLSID_ADOCONNECTION_21 = MYADOID(0x00000514);
39const IID ADOS::IID_ADOCONNECTION_21 = MYADOID(0x00000550);
40
41const CLSID ADOS::CLSID_ADOCOMMAND_21 = MYADOID(0x00000507);
42const IID ADOS::IID_ADOCOMMAND_21 = MYADOID(0x0000054E);
43
44const CLSID ADOS::CLSID_ADORECORDSET_21 = MYADOID(0x00000535);
45const IID ADOS::IID_ADORECORDSET_21 = MYADOID(0x0000054F);
46
47const CLSID ADOS::CLSID_ADOCATALOG_25 = MYADOID(0x00000602);
48const IID ADOS::IID_ADOCATALOG_25 = MYADOID(0x00000603);
49
50const CLSID ADOS::CLSID_ADOINDEX_25 = MYADOID(0x0000061E);
51const IID ADOS::IID_ADOINDEX_25 = MYADOID(0x0000061F);
52
53const CLSID ADOS::CLSID_ADOTABLE_25 = MYADOID(0x00000609);
54const IID ADOS::IID_ADOTABLE_25 = MYADOID(0x00000610);
55
56const CLSID ADOS::CLSID_ADOKEY_25 = MYADOID(0x00000621);
57const IID ADOS::IID_ADOKEY_25 = MYADOID(0x00000622);
58
59const CLSID ADOS::CLSID_ADOCOLUMN_25 = MYADOID(0x0000061B);
60const IID ADOS::IID_ADOCOLUMN_25 = MYADOID(0x0000061C);
61
62const CLSID ADOS::CLSID_ADOGROUP_25 = MYADOID(0x00000615);
63const IID ADOS::IID_ADOGROUP_25 = MYADOID(0x00000616);
64
65const CLSID ADOS::CLSID_ADOUSER_25 = MYADOID(0x00000618);
66const IID ADOS::IID_ADOUSER_25 = MYADOID(0x00000619);
67
68const CLSID ADOS::CLSID_ADOVIEW_25 = MYADOID(0x00000612);
69const IID ADOS::IID_ADOVIEW_25 = MYADOID(0x00000613);
70
71sal::systools::BStr& ADOS::GetKeyStr()
72{
73 static sal::systools::BStr sKeyStr(u"gxwaezucfyqpwjgqbcmtsncuhwsnyhiohwxz");
74 return sKeyStr;
75}
76
77
78sal_Int32 ADOS::MapADOType2Jdbc(DataTypeEnum eType)
79{
80 sal_Int32 nType = DataType::VARCHAR;
81 switch (eType)
82 {
83 case adUnsignedSmallInt:
84 case adSmallInt: nType = DataType::SMALLINT; break;
85 case adUnsignedInt:
86 case adInteger: nType = DataType::INTEGER; break;
87 case adUnsignedBigInt:
88 case adBigInt: nType = DataType::BIGINT; break;
89 case adSingle: nType = DataType::FLOAT; break;
90 case adDouble: nType = DataType::DOUBLE; break;
91 case adCurrency: nType = DataType::DOUBLE; break;
92 case adVarNumeric:
93 case adNumeric: nType = DataType::NUMERIC; break;
94 case adDecimal: nType = DataType::DECIMAL; break;
95 case adDBDate: nType = DataType::DATE; break;
96 case adDBTime: nType = DataType::TIME; break;
97 case adDate:
98 case adDBTimeStamp: nType = DataType::TIMESTAMP; break;
99 case adBoolean: nType = DataType::BOOLEAN; break;
100// case adArray: nType = DataType::ARRAY; break;
101 case adBinary: nType = DataType::BINARY; break;
102 case adGUID: nType = DataType::OBJECT; break;
103 case adBSTR:
104 case adVarWChar:
105 case adWChar:
106 case adVarChar: nType = DataType::VARCHAR; break;
107 case adLongVarWChar:
108 case adLongVarChar: nType = DataType::LONGVARCHAR; break;
109 case adVarBinary: nType = DataType::VARBINARY; break;
110 case adLongVarBinary: nType = DataType::LONGVARBINARY;break;
111 case adChar: nType = DataType::CHAR; break;
112 case adUnsignedTinyInt:
113 case adTinyInt: nType = DataType::TINYINT; break;
114 case adEmpty: nType = DataType::SQLNULL; break;
115 case adUserDefined:
116 case adPropVariant:
117 case adFileTime:
118 case adChapter:
119 case adIDispatch:
120 case adIUnknown:
121 case adError:
122 case adVariant:
123 nType = DataType::OTHER; break;
124 default:
125 OSL_FAIL("MapADOType2Jdbc: Unknown Type!");
126 ;
127 }
128 return nType;
129}
130
131DataTypeEnum ADOS::MapJdbc2ADOType(sal_Int32 _nType,sal_Int32 _nJetEngine)
132{
133 switch (_nType)
134 {
135 case DataType::SMALLINT: return adSmallInt; break;
136 case DataType::INTEGER: return adInteger; break;
137 case DataType::BIGINT: return adBigInt; break;
138 case DataType::FLOAT: return adSingle; break;
139 case DataType::DOUBLE: return adDouble; break;
140 case DataType::NUMERIC: return adNumeric; break;
141 case DataType::DECIMAL: return adDecimal; break;
142 case DataType::DATE: return isJetEngine(_nJetEngine) ? adDate : adDBDate; break;
143 case DataType::TIME: return adDBTime; break;
144 case DataType::TIMESTAMP: return isJetEngine(_nJetEngine) ? adDate : adDBTimeStamp; break;
145 case DataType::BOOLEAN:
146 case DataType::BIT: return adBoolean; break;
147 case DataType::BINARY: return adBinary; break;
148 case DataType::VARCHAR: return adVarWChar; break;
149 case DataType::CLOB:
150 case DataType::LONGVARCHAR: return adLongVarWChar; break;
151 case DataType::VARBINARY: return adVarBinary; break;
152 case DataType::BLOB:
153 case DataType::LONGVARBINARY: return adLongVarBinary; break;
154 case DataType::CHAR: return adWChar; break;
155 case DataType::TINYINT: return isJetEngine(_nJetEngine) ? adUnsignedTinyInt : adTinyInt;break;
156 case DataType::OBJECT: return adGUID; break;
157 default:
158 OSL_FAIL("MapJdbc2ADOType: Unknown Type!");
159 ;
160 }
161 return adEmpty;
162}
163
188
189bool ADOS::isJetEngine(sal_Int32 _nEngineType)
190{
191 bool bRet = false;
192 switch(_nEngineType)
193 {
218 bRet = true;
219 break;
220 }
221 return bRet;
222}
223
224ObjectTypeEnum ADOS::mapObjectType2Ado(sal_Int32 objType)
225{
226 ObjectTypeEnum eType = adPermObjTable;
227 switch(objType)
228 {
229 case PrivilegeObject::TABLE:
230 eType = adPermObjTable;
231 break;
232 case PrivilegeObject::VIEW:
233 eType = adPermObjView;
234 break;
235 case PrivilegeObject::COLUMN:
236 eType = adPermObjColumn;
237 break;
238 }
239 return eType;
240}
241
242sal_Int32 ADOS::mapAdoType2Object(ObjectTypeEnum objType)
243{
244 sal_Int32 nType = PrivilegeObject::TABLE;
245 switch(objType)
246 {
247 case adPermObjTable:
248 nType = PrivilegeObject::TABLE;
249 break;
250 case adPermObjView:
251 nType = PrivilegeObject::VIEW;
252 break;
253 case adPermObjColumn:
254 nType = PrivilegeObject::COLUMN;
255 break;
256 default:
257 OSL_FAIL( "ADOS::mapAdoType2Object: privilege type cannot be translated!" );
258 break;
259 }
260 return nType;
261}
262#ifdef DELETE
263#undef DELETE
264#endif
265
266sal_Int32 ADOS::mapAdoRights2Sdbc(RightsEnum eRights)
267{
268 sal_Int32 nRights = 0;
269 if((eRights & adRightInsert) == adRightInsert)
270 nRights |= Privilege::INSERT;
271 if((eRights & adRightDelete) == adRightDelete)
272 nRights |= css::sdbcx::Privilege::DELETE;
273 if((eRights & adRightUpdate) == adRightUpdate)
274 nRights |= Privilege::UPDATE;
275 if((eRights & adRightWriteDesign) == adRightWriteDesign)
276 nRights |= Privilege::ALTER;
277 if((eRights & adRightRead) == adRightRead)
278 nRights |= Privilege::SELECT;
279 if((eRights & adRightReference) == adRightReference)
280 nRights |= Privilege::REFERENCE;
281 if((eRights & adRightDrop) == adRightDrop)
282 nRights |= Privilege::DROP;
283
284 return nRights;
285}
286
287sal_Int32 ADOS::mapRights2Ado(sal_Int32 nRights)
288{
289 sal_Int32 eRights = adRightNone;
290
291 if((nRights & Privilege::INSERT) == Privilege::INSERT)
292 eRights |= adRightInsert;
293 if((nRights & Privilege::DELETE) == Privilege::DELETE)
294 eRights |= adRightDelete;
295 if((nRights & Privilege::UPDATE) == Privilege::UPDATE)
296 eRights |= adRightUpdate;
297 if((nRights & Privilege::ALTER) == Privilege::ALTER)
298 eRights |= adRightWriteDesign;
299 if((nRights & Privilege::SELECT) == Privilege::SELECT)
300 eRights |= adRightRead;
301 if((nRights & Privilege::REFERENCE) == Privilege::REFERENCE)
302 eRights |= adRightReference;
303 if((nRights & Privilege::DROP) == Privilege::DROP)
304 eRights |= adRightDrop;
305
306 return eRights;
307}
308
309WpADOField ADOS::getField(ADORecordset* _pRecordSet,sal_Int32 _nColumnIndex)
310{
311 if ( !_pRecordSet )
312 return WpADOField();
313
315 _pRecordSet->get_Fields(&aFields);
316 if(_nColumnIndex <= 0 || _nColumnIndex > aFields.GetItemCount())
318 WpADOField aField(aFields.GetItem(_nColumnIndex-1));
319 if(!aField.IsValid())
321 return aField;
322}
323
324
325/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const int JET_ENGINETYPE_EXCEL30
Definition: adoimp.cxx:173
const int JET_ENGINETYPE_JET4X
Definition: adoimp.cxx:169
const int JET_ENGINETYPE_LOTUSWK4
Definition: adoimp.cxx:181
const int JET_ENGINETYPE_DBASE4
Definition: adoimp.cxx:171
const int JET_ENGINETYPE_LOTUSWK1
Definition: adoimp.cxx:179
const int JET_ENGINETYPE_LOTUSWK3
Definition: adoimp.cxx:180
const int JET_ENGINETYPE_HTML1X
Definition: adoimp.cxx:187
const int JET_ENGINETYPE_JET10
Definition: adoimp.cxx:165
const int JET_ENGINETYPE_EXCEL40
Definition: adoimp.cxx:174
const int JET_ENGINETYPE_PARADOX5X
Definition: adoimp.cxx:184
const int JET_ENGINETYPE_DBASE3
Definition: adoimp.cxx:170
const int JET_ENGINETYPE_JET3X
Definition: adoimp.cxx:168
const int JET_ENGINETYPE_DBASE5
Definition: adoimp.cxx:172
const int JET_ENGINETYPE_PARADOX7X
Definition: adoimp.cxx:185
const int JET_ENGINETYPE_JET11
Definition: adoimp.cxx:166
const int JET_ENGINETYPE_JET20
Definition: adoimp.cxx:167
const int JET_ENGINETYPE_EXCHANGE4
Definition: adoimp.cxx:178
const int JET_ENGINETYPE_EXCEL80
Definition: adoimp.cxx:176
#define MYADOID(l)
Definition: adoimp.cxx:36
const int JET_ENGINETYPE_PARADOX4X
Definition: adoimp.cxx:183
const int JET_ENGINETYPE_PARADOX3X
Definition: adoimp.cxx:182
const int JET_ENGINETYPE_EXCEL90
Definition: adoimp.cxx:177
const int JET_ENGINETYPE_EXCEL50
Definition: adoimp.cxx:175
const int JET_ENGINETYPE_UNKNOWN
Definition: adoimp.cxx:164
const int JET_ENGINETYPE_TEXT1X
Definition: adoimp.cxx:186
static bool isJetEngine(sal_Int32 _nEngineType)
Definition: adoimp.cxx:189
static ObjectTypeEnum mapObjectType2Ado(sal_Int32 objType)
Definition: adoimp.cxx:224
static DataTypeEnum MapJdbc2ADOType(sal_Int32 _nType, sal_Int32 _nJetEngine)
Definition: adoimp.cxx:131
static sal_Int32 MapADOType2Jdbc(DataTypeEnum eType)
Definition: adoimp.cxx:78
static sal_Int32 mapRights2Ado(sal_Int32 nRights)
Definition: adoimp.cxx:287
static WpADOField getField(ADORecordset *_pRecordSet, sal_Int32 _nColumnIndex)
Definition: adoimp.cxx:309
static sal_Int32 mapAdoRights2Sdbc(RightsEnum eRights)
Definition: adoimp.cxx:266
static sal_Int32 mapAdoType2Object(ObjectTypeEnum objType)
Definition: adoimp.cxx:242
sal_Int32 GetItemCount() const
Definition: Aolewrap.hxx:96
WrapT GetItem(sal_Int32 index) const
Definition: Aolewrap.hxx:102
float u
DocumentType eType
void throwInvalidIndexException(const css::uno::Reference< css::uno::XInterface > &Context, const css::uno::Any &Next)
throw an invalid index sqlexception
QPRO_FUNC_TYPE nType