1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_connectivity.hxx"
26 #include "ado/ADatabaseMetaData.hxx"
27 #include "ado/ADatabaseMetaDataResultSetMetaData.hxx"
28 #include "ado/Awrapado.hxx"
29 #include "ado/AGroup.hxx"
30 #include "ado/adoimp.hxx"
31 #include "ado/AIndex.hxx"
32 #include "ado/AKey.hxx"
33 #include "ado/ATable.hxx"
34 #include <com/sun/star/sdbc/DataType.hpp>
35 #include <com/sun/star/sdbc/ProcedureResult.hpp>
36 #include <com/sun/star/sdbc/ColumnValue.hpp>
37 #ifdef DELETE
38 #undef DELETE
39 #endif
40 #include <com/sun/star/sdbcx/Privilege.hpp>
41 #include <com/sun/star/sdbcx/PrivilegeObject.hpp>
42 #include <com/sun/star/sdbc/KeyRule.hpp>
43 #include <com/sun/star/sdbcx/KeyType.hpp>
44
45 using namespace connectivity::ado;
46 using namespace ::com::sun::star::sdbc;
47 using namespace ::com::sun::star::sdbcx;
48 using namespace ::com::sun::star::uno;
49
50 // -------------------------------------------------------------------------
fillLiterals()51 void ODatabaseMetaData::fillLiterals()
52 {
53 ADORecordset *pRecordset = NULL;
54 OLEVariant vtEmpty;
55 vtEmpty.setNoArg();
56 m_pADOConnection->OpenSchema(adSchemaDBInfoLiterals,vtEmpty,vtEmpty,&pRecordset);
57
58 ADOS::ThrowException(*m_pADOConnection,*this);
59
60 OSL_ENSURE(pRecordset,"fillLiterals: no resultset!");
61 if ( pRecordset )
62 {
63 WpADORecordset aRecordset(pRecordset);
64
65 aRecordset.MoveFirst();
66 OLEVariant aValue;
67 LiteralInfo aInfo;
68 while(!aRecordset.IsAtEOF())
69 {
70 WpOLEAppendCollection<ADOFields, ADOField, WpADOField> aFields(aRecordset.GetFields());
71 WpADOField aField(aFields.GetItem(1));
72 aInfo.pwszLiteralValue = aField.get_Value();
73 aField = aFields.GetItem(5);
74 aInfo.fSupported = aField.get_Value();
75 aField = aFields.GetItem(6);
76 aInfo.cchMaxLen = aField.get_Value().getUInt32();
77
78 aField = aFields.GetItem(4);
79 sal_uInt32 nId = aField.get_Value().getUInt32();
80 m_aLiteralInfo[nId] = aInfo;
81
82 aRecordset.MoveNext();
83 }
84 aRecordset.Close();
85 }
86 }
87 // -------------------------------------------------------------------------
getMaxSize(sal_uInt32 _nId)88 sal_Int32 ODatabaseMetaData::getMaxSize(sal_uInt32 _nId)
89 {
90 if(!m_aLiteralInfo.size())
91 fillLiterals();
92
93 sal_Int32 nSize = 0;
94 ::std::map<sal_uInt32,LiteralInfo>::const_iterator aIter = m_aLiteralInfo.find(_nId);
95 if(aIter != m_aLiteralInfo.end() && (*aIter).second.fSupported)
96 nSize = ((*aIter).second.cchMaxLen == (-1)) ? 0 : (*aIter).second.cchMaxLen;
97 return nSize;
98 }
99 // -------------------------------------------------------------------------
isCapable(sal_uInt32 _nId)100 sal_Bool ODatabaseMetaData::isCapable(sal_uInt32 _nId)
101 {
102 if(!m_aLiteralInfo.size())
103 fillLiterals();
104 sal_Bool bSupported = sal_False;
105 ::std::map<sal_uInt32,LiteralInfo>::const_iterator aIter = m_aLiteralInfo.find(_nId);
106 if(aIter != m_aLiteralInfo.end())
107 bSupported = (*aIter).second.fSupported;
108 return bSupported;
109 }
110
111 // -------------------------------------------------------------------------
getLiteral(sal_uInt32 _nId)112 ::rtl::OUString ODatabaseMetaData::getLiteral(sal_uInt32 _nId)
113 {
114 if(!m_aLiteralInfo.size())
115 fillLiterals();
116 ::rtl::OUString sStr;
117 ::std::map<sal_uInt32,LiteralInfo>::const_iterator aIter = m_aLiteralInfo.find(_nId);
118 if(aIter != m_aLiteralInfo.end() && (*aIter).second.fSupported)
119 sStr = (*aIter).second.pwszLiteralValue;
120 return sStr;
121 }
122 // -----------------------------------------------------------------------------
123 // -------------------------------------------------------------------------
setColumnPrivilegesMap()124 void ODatabaseMetaDataResultSetMetaData::setColumnPrivilegesMap()
125 {
126 m_mColumns[8] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("IS_GRANTABLE"),
127 ColumnValue::NULLABLE,
128 3,3,0,
129 DataType::VARCHAR);
130 }
131 // -------------------------------------------------------------------------
setColumnsMap()132 void ODatabaseMetaDataResultSetMetaData::setColumnsMap()
133 {
134 m_mColumns[6] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("TYPE_NAME"),
135 ColumnValue::NO_NULLS,
136 0,0,0,
137 DataType::VARCHAR);
138 m_mColumns[11] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("NULLABLE"),
139 ColumnValue::NO_NULLS,
140 1,1,0,
141 DataType::INTEGER);
142 m_mColumns[12] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("REMARKS"),
143 ColumnValue::NULLABLE,
144 0,0,0,
145 DataType::VARCHAR);
146 m_mColumns[13] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("COLUMN_DEF"),
147 ColumnValue::NULLABLE,
148 0,0,0,
149 DataType::VARCHAR);
150 m_mColumns[14] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("SQL_DATA_TYPE"),
151 ColumnValue::NO_NULLS,
152 1,1,0,
153 DataType::INTEGER);
154 m_mColumns[15] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("SQL_DATETIME_SUB"),
155 ColumnValue::NO_NULLS,
156 1,1,0,
157 DataType::INTEGER);
158 m_mColumns[16] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("CHAR_OCTET_LENGTH"),
159 ColumnValue::NO_NULLS,
160 1,1,0,
161 DataType::INTEGER);
162 }
163 // -------------------------------------------------------------------------
setTablesMap()164 void ODatabaseMetaDataResultSetMetaData::setTablesMap()
165 {
166 m_mColumns[5] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("REMARKS"),
167 ColumnValue::NULLABLE,
168 0,0,0,
169 DataType::VARCHAR);
170 }
171 // -------------------------------------------------------------------------
setProcedureColumnsMap()172 void ODatabaseMetaDataResultSetMetaData::setProcedureColumnsMap()
173 {
174 m_mColumns[12] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("NULLABLE"),
175 ColumnValue::NO_NULLS,
176 1,1,0,
177 DataType::INTEGER);
178 }
179 // -------------------------------------------------------------------------
setPrimaryKeysMap()180 void ODatabaseMetaDataResultSetMetaData::setPrimaryKeysMap()
181 {
182 m_mColumns[5] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("KEY_SEQ"),
183 ColumnValue::NO_NULLS,
184 1,1,0,
185 DataType::INTEGER);
186 m_mColumns[6] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("PK_NAME"),
187 ColumnValue::NULLABLE,
188 0,0,0,
189 DataType::VARCHAR);
190 }
191 // -------------------------------------------------------------------------
setIndexInfoMap()192 void ODatabaseMetaDataResultSetMetaData::setIndexInfoMap()
193 {
194 m_mColumns[4] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("NON_UNIQUE"),
195 ColumnValue::NO_NULLS,
196 1,1,0,
197 DataType::BIT);
198 m_mColumns[5] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("INDEX_QUALIFIER"),
199 ColumnValue::NULLABLE,
200 0,0,0,
201 DataType::VARCHAR);
202 m_mColumns[10] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("ASC_OR_DESC"),
203 ColumnValue::NULLABLE,
204 0,0,0,
205 DataType::VARCHAR);
206 }
207 // -------------------------------------------------------------------------
setTablePrivilegesMap()208 void ODatabaseMetaDataResultSetMetaData::setTablePrivilegesMap()
209 {
210 m_mColumns[6] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("PRIVILEGE"),
211 ColumnValue::NULLABLE,
212 0,0,0,
213 DataType::VARCHAR);
214 m_mColumns[7] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("IS_GRANTABLE"),
215 ColumnValue::NULLABLE,
216 0,0,0,
217 DataType::VARCHAR);
218 }
219 // -------------------------------------------------------------------------
setCrossReferenceMap()220 void ODatabaseMetaDataResultSetMetaData::setCrossReferenceMap()
221 {
222 m_mColumns[9] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("KEY_SEQ"),
223 ColumnValue::NO_NULLS,
224 1,1,0,
225 DataType::INTEGER);
226 }
227 // -------------------------------------------------------------------------
setTypeInfoMap()228 void ODatabaseMetaDataResultSetMetaData::setTypeInfoMap()
229 {
230 m_mColumns[3] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("PRECISION"),
231 ColumnValue::NO_NULLS,
232 1,1,0,
233 DataType::INTEGER);
234 m_mColumns[7] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("NULLABLE"),
235 ColumnValue::NO_NULLS,
236 1,1,0,
237 DataType::INTEGER);
238 m_mColumns[12] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("AUTO_INCREMENT"),
239 ColumnValue::NO_NULLS,
240 1,1,0,
241 DataType::BIT);
242 m_mColumns[16] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("SQL_DATA_TYPE"),
243 ColumnValue::NO_NULLS,
244 1,1,0,
245 DataType::INTEGER);
246 m_mColumns[17] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("SQL_DATETIME_SUB"),
247 ColumnValue::NO_NULLS,
248 1,1,0,
249 DataType::INTEGER);
250 m_mColumns[18] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("NUM_PREC_RADIX"),
251 ColumnValue::NO_NULLS,
252 1,1,0,
253 DataType::INTEGER);
254 }
255 // -------------------------------------------------------------------------
setProceduresMap()256 void ODatabaseMetaDataResultSetMetaData::setProceduresMap()
257 {
258 m_mColumns[7] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("REMARKS"),
259 ColumnValue::NULLABLE,
260 0,0,0,
261 DataType::VARCHAR);
262 }
263 // -------------------------------------------------------------------------
isSearchable(sal_Int32 column)264 sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isSearchable( sal_Int32 column ) throw(SQLException, RuntimeException)
265 {
266 if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
267 return (*m_mColumnsIter).second.isSearchable();
268 return sal_True;
269 }
270 // -------------------------------------------------------------------------
isAutoIncrement(sal_Int32 column)271 sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isAutoIncrement( sal_Int32 column ) throw(SQLException, RuntimeException)
272 {
273 if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
274 return (*m_mColumnsIter).second.isAutoIncrement();
275 return sal_False;
276 }
277 // -------------------------------------------------------------------------
getColumnServiceName(sal_Int32 column)278 ::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnServiceName( sal_Int32 column ) throw(SQLException, RuntimeException)
279 {
280 if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
281 return (*m_mColumnsIter).second.getColumnServiceName();
282 return ::rtl::OUString();
283 }
284 // -------------------------------------------------------------------------
getTableName(sal_Int32 column)285 ::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getTableName( sal_Int32 column ) throw(SQLException, RuntimeException)
286 {
287 if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
288 return (*m_mColumnsIter).second.getTableName();
289 return ::rtl::OUString();
290 }
291 // -------------------------------------------------------------------------
getCatalogName(sal_Int32 column)292 ::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getCatalogName( sal_Int32 column ) throw(SQLException, RuntimeException)
293 {
294 if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
295 return (*m_mColumnsIter).second.getCatalogName();
296 return ::rtl::OUString();
297 }
298 // -------------------------------------------------------------------------
getColumnTypeName(sal_Int32 column)299 ::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnTypeName( sal_Int32 column ) throw(SQLException, RuntimeException)
300 {
301 if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
302 return (*m_mColumnsIter).second.getColumnTypeName();
303 return ::rtl::OUString();
304 }
305 // -------------------------------------------------------------------------
306
isCaseSensitive(sal_Int32 column)307 sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isCaseSensitive( sal_Int32 column ) throw(SQLException, RuntimeException)
308 {
309 if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
310 return (*m_mColumnsIter).second.isCaseSensitive();
311 return sal_True;
312 }
313 // -------------------------------------------------------------------------
314
getSchemaName(sal_Int32 column)315 ::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getSchemaName( sal_Int32 column ) throw(SQLException, RuntimeException)
316 {
317 if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
318 return (*m_mColumnsIter).second.getSchemaName();
319 return ::rtl::OUString();
320 }
321 // -----------------------------------------------------------------------------
322 // -------------------------------------------------------------------------
MapObjectType(sal_Int32 _ObjType)323 ObjectTypeEnum OAdoGroup::MapObjectType(sal_Int32 _ObjType)
324 {
325 ObjectTypeEnum eNumType= adPermObjTable;
326 switch(_ObjType)
327 {
328 case PrivilegeObject::TABLE:
329 break;
330 case PrivilegeObject::VIEW:
331 eNumType = adPermObjView;
332 break;
333 case PrivilegeObject::COLUMN:
334 eNumType = adPermObjColumn;
335 break;
336 }
337 return eNumType;
338 }
339 // -------------------------------------------------------------------------
MapRight(RightsEnum _eNum)340 sal_Int32 OAdoGroup::MapRight(RightsEnum _eNum)
341 {
342 sal_Int32 nRight = 0;
343 if(_eNum & adRightRead)
344 nRight |= Privilege::SELECT;
345 if(_eNum & adRightInsert)
346 nRight |= Privilege::INSERT;
347 if(_eNum & adRightUpdate)
348 nRight |= Privilege::UPDATE;
349 if(_eNum & adRightDelete)
350 nRight |= Privilege::DELETE;
351 if(_eNum & adRightReadDesign)
352 nRight |= Privilege::READ;
353 if(_eNum & adRightCreate)
354 nRight |= Privilege::CREATE;
355 if(_eNum & adRightWriteDesign)
356 nRight |= Privilege::ALTER;
357 if(_eNum & adRightReference)
358 nRight |= Privilege::REFERENCE;
359 if(_eNum & adRightDrop)
360 nRight |= Privilege::DROP;
361
362 return nRight;
363 }
364 // -------------------------------------------------------------------------
Map2Right(sal_Int32 _eNum)365 RightsEnum OAdoGroup::Map2Right(sal_Int32 _eNum)
366 {
367 sal_Int32 nRight = adRightNone;
368 if(_eNum & Privilege::SELECT)
369 nRight |= adRightRead;
370
371 if(_eNum & Privilege::INSERT)
372 nRight |= adRightInsert;
373
374 if(_eNum & Privilege::UPDATE)
375 nRight |= adRightUpdate;
376
377 if(_eNum & Privilege::DELETE)
378 nRight |= adRightDelete;
379
380 if(_eNum & Privilege::READ)
381 nRight |= adRightReadDesign;
382
383 if(_eNum & Privilege::CREATE)
384 nRight |= adRightCreate;
385
386 if(_eNum & Privilege::ALTER)
387 nRight |= adRightWriteDesign;
388
389 if(_eNum & Privilege::REFERENCE)
390 nRight |= adRightReference;
391
392 if(_eNum & Privilege::DROP)
393 nRight |= adRightDrop;
394
395 return (RightsEnum)nRight;
396 }
397 // -------------------------------------------------------------------------
Create()398 void WpADOIndex::Create()
399 {
400 HRESULT hr = -1;
401
402 _ADOIndex* pIndex = NULL;
403 hr = CoCreateInstance(ADOS::CLSID_ADOINDEX_25,
404 NULL,
405 CLSCTX_INPROC_SERVER,
406 ADOS::IID_ADOINDEX_25,
407 (void**)&pIndex );
408
409
410 if( !FAILED( hr ) )
411 {
412 operator=( pIndex );
413 pIndex->Release();
414 }
415 }
416 // -------------------------------------------------------------------------
fillPropertyValues()417 void OAdoIndex::fillPropertyValues()
418 {
419 if(m_aIndex.IsValid())
420 {
421 m_Name = m_aIndex.get_Name();
422 m_IsUnique = m_aIndex.get_Unique();
423 m_IsPrimaryKeyIndex = m_aIndex.get_PrimaryKey();
424 m_IsClustered = m_aIndex.get_Clustered();
425 }
426 }
427 // -----------------------------------------------------------------------------
Create()428 void WpADOKey::Create()
429 {
430 HRESULT hr = -1;
431 _ADOKey* pKey = NULL;
432 hr = CoCreateInstance(ADOS::CLSID_ADOKEY_25,
433 NULL,
434 CLSCTX_INPROC_SERVER,
435 ADOS::IID_ADOKEY_25,
436 (void**)&pKey );
437
438
439 if( !FAILED( hr ) )
440 {
441 operator=( pKey );
442 pKey->Release();
443 }
444 }
445 // -------------------------------------------------------------------------
fillPropertyValues()446 void OAdoKey::fillPropertyValues()
447 {
448 if(m_aKey.IsValid())
449 {
450 m_aProps->m_Type = MapKeyRule(m_aKey.get_Type());
451 m_Name = m_aKey.get_Name();
452 m_aProps->m_ReferencedTable = m_aKey.get_RelatedTable();
453 m_aProps->m_UpdateRule = MapRule(m_aKey.get_UpdateRule());
454 m_aProps->m_DeleteRule = MapRule(m_aKey.get_DeleteRule());
455 }
456 }
457 // -------------------------------------------------------------------------
MapRule(const RuleEnum & _eNum)458 sal_Int32 OAdoKey::MapRule(const RuleEnum& _eNum)
459 {
460 sal_Int32 eNum = KeyRule::NO_ACTION;
461 switch(_eNum)
462 {
463 case adRICascade:
464 eNum = KeyRule::CASCADE;
465 break;
466 case adRISetNull:
467 eNum = KeyRule::SET_NULL;
468 break;
469 case adRINone:
470 eNum = KeyRule::NO_ACTION;
471 break;
472 case adRISetDefault:
473 eNum = KeyRule::SET_DEFAULT;
474 break;
475 }
476 return eNum;
477 }
478 // -------------------------------------------------------------------------
Map2Rule(const sal_Int32 & _eNum)479 RuleEnum OAdoKey::Map2Rule(const sal_Int32& _eNum)
480 {
481 RuleEnum eNum = adRINone;
482 switch(_eNum)
483 {
484 case KeyRule::CASCADE:
485 eNum = adRICascade;
486 break;
487 case KeyRule::SET_NULL:
488 eNum = adRISetNull;
489 break;
490 case KeyRule::NO_ACTION:
491 eNum = adRINone;
492 break;
493 case KeyRule::SET_DEFAULT:
494 eNum = adRISetDefault;
495 break;
496 }
497 return eNum;
498 }
499 // -------------------------------------------------------------------------
MapKeyRule(const KeyTypeEnum & _eNum)500 sal_Int32 OAdoKey::MapKeyRule(const KeyTypeEnum& _eNum)
501 {
502 sal_Int32 nKeyType = KeyType::PRIMARY;
503 switch(_eNum)
504 {
505 case adKeyPrimary:
506 nKeyType = KeyType::PRIMARY;
507 break;
508 case adKeyForeign:
509 nKeyType = KeyType::FOREIGN;
510 break;
511 case adKeyUnique:
512 nKeyType = KeyType::UNIQUE;
513 break;
514 }
515 return nKeyType;
516 }
517 // -------------------------------------------------------------------------
Map2KeyRule(const sal_Int32 & _eNum)518 KeyTypeEnum OAdoKey::Map2KeyRule(const sal_Int32& _eNum)
519 {
520 KeyTypeEnum eNum( adKeyPrimary );
521 switch(_eNum)
522 {
523 case KeyType::PRIMARY:
524 eNum = adKeyPrimary;
525 break;
526 case KeyType::FOREIGN:
527 eNum = adKeyForeign;
528 break;
529 case KeyType::UNIQUE:
530 eNum = adKeyUnique;
531 break;
532 default:
533 OSL_ENSURE( false, "OAdoKey::Map2KeyRule: invalid key type!" );
534 }
535 return eNum;
536 }
537 // -----------------------------------------------------------------------------
Create()538 void WpADOTable::Create()
539 {
540 HRESULT hr = -1;
541 _ADOTable* pTable = NULL;
542 hr = CoCreateInstance(ADOS::CLSID_ADOTABLE_25,
543 NULL,
544 CLSCTX_INPROC_SERVER,
545 ADOS::IID_ADOTABLE_25,
546 (void**)&pTable );
547
548
549 if( !FAILED( hr ) )
550 {
551 operator=( pTable );
552 pTable->Release();
553 }
554 }
555 // -------------------------------------------------------------------------
GetObjectOwner(const::rtl::OUString & _rName,ObjectTypeEnum _eNum)556 ::rtl::OUString WpADOCatalog::GetObjectOwner(const ::rtl::OUString& _rName, ObjectTypeEnum _eNum)
557 {
558 OLEVariant _rVar;
559 _rVar.setNoArg();
560 OLEString aBSTR;
561 OLEString sStr1(_rName);
562 pInterface->GetObjectOwner(sStr1,_eNum,_rVar,&aBSTR);
563 return aBSTR;
564 }
565 // -----------------------------------------------------------------------------
fillPropertyValues()566 void OAdoTable::fillPropertyValues()
567 {
568 if(m_aTable.IsValid())
569 {
570 m_Name = m_aTable.get_Name();
571 m_Type = m_aTable.get_Type();
572 {
573 WpADOCatalog aCat(m_aTable.get_ParentCatalog());
574 if(aCat.IsValid())
575 m_CatalogName = aCat.GetObjectOwner(m_aTable.get_Name(),adPermObjTable);
576 }
577 {
578 WpADOProperties aProps = m_aTable.get_Properties();
579 if(aProps.IsValid())
580 m_Description = OTools::getValue(aProps,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Description")));
581 }
582 }
583 }
584 // -----------------------------------------------------------------------------
Create()585 void WpADOUser::Create()
586 {
587 HRESULT hr = -1;
588 _ADOUser* pUser = NULL;
589 hr = CoCreateInstance(ADOS::CLSID_ADOUSER_25,
590 NULL,
591 CLSCTX_INPROC_SERVER,
592 ADOS::IID_ADOUSER_25,
593 (void**)&pUser );
594
595
596 if( !FAILED( hr ) )
597 {
598 operator=( pUser );
599 pUser->Release();
600 }
601 }
602 // -------------------------------------------------------------------------
603
604
605