1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_connectivity.hxx" 30 #include "ado/Awrapado.hxx" 31 #include "ado/Awrapadox.hxx" 32 #include <comphelper/types.hxx> 33 #include <rtl/ustrbuf.hxx> 34 #include "diagnose_ex.h" 35 36 namespace connectivity 37 { 38 namespace ado 39 { 40 sal_Int32 nAdoObjectCounter = 0; 41 } 42 } 43 44 using namespace connectivity::ado; 45 46 void WpADOCatalog::Create() 47 { 48 HRESULT hr = -1; 49 _ADOCatalog* pCommand; 50 hr = CoCreateInstance(ADOS::CLSID_ADOCATALOG_25, 51 NULL, 52 CLSCTX_INPROC_SERVER, 53 ADOS::IID_ADOCATALOG_25, 54 (void**)&pCommand ); 55 56 57 if( !FAILED( hr ) ) 58 setWithOutAddRef(pCommand); 59 } 60 61 62 WpADOProperties WpADOConnection::get_Properties() const 63 { 64 ADOProperties* pProps=NULL; 65 pInterface->get_Properties(&pProps); 66 WpADOProperties aProps; 67 aProps.setWithOutAddRef(pProps); 68 return aProps; 69 } 70 71 rtl::OUString WpADOConnection::GetConnectionString() const 72 { 73 OSL_ENSURE(pInterface,"Interface is null!"); 74 OLEString aBSTR; 75 pInterface->get_ConnectionString(&aBSTR); 76 return aBSTR; 77 } 78 79 sal_Bool WpADOConnection::PutConnectionString(const ::rtl::OUString &aCon) const 80 { 81 OSL_ENSURE(pInterface,"Interface is null!"); 82 OLEString bstr(aCon); 83 sal_Bool bErg = SUCCEEDED(pInterface->put_ConnectionString(bstr)); 84 85 return bErg; 86 } 87 88 sal_Int32 WpADOConnection::GetCommandTimeout() const 89 { 90 OSL_ENSURE(pInterface,"Interface is null!"); 91 sal_Int32 nRet=0; 92 pInterface->get_CommandTimeout(&nRet); 93 return nRet; 94 } 95 96 void WpADOConnection::PutCommandTimeout(sal_Int32 nRet) 97 { 98 OSL_ENSURE(pInterface,"Interface is null!"); 99 pInterface->put_CommandTimeout(nRet); 100 } 101 102 sal_Int32 WpADOConnection::GetConnectionTimeout() const 103 { 104 OSL_ENSURE(pInterface,"Interface is null!"); 105 sal_Int32 nRet=0; 106 pInterface->get_ConnectionTimeout(&nRet); 107 return nRet; 108 } 109 110 void WpADOConnection::PutConnectionTimeout(sal_Int32 nRet) 111 { 112 OSL_ENSURE(pInterface,"Interface is null!"); 113 pInterface->put_ConnectionTimeout(nRet); 114 } 115 116 sal_Bool WpADOConnection::Close( ) 117 { 118 OSL_ENSURE(pInterface,"Interface is null!"); 119 return (SUCCEEDED(pInterface->Close())); 120 } 121 122 sal_Bool WpADOConnection::Execute(const ::rtl::OUString& _CommandText,OLEVariant& RecordsAffected,long Options, WpADORecordset** ppiRset) 123 { 124 OSL_ENSURE(pInterface,"Interface is null!"); 125 OLEString sStr1(_CommandText); 126 sal_Bool bErg = SUCCEEDED(pInterface->Execute(sStr1,&RecordsAffected,Options,(_ADORecordset**)ppiRset)); 127 return bErg; 128 } 129 130 sal_Bool WpADOConnection::BeginTrans() 131 { 132 OSL_ENSURE(pInterface,"Interface is null!"); 133 sal_Int32 nIso=0; 134 return SUCCEEDED(pInterface->BeginTrans(&nIso)); 135 } 136 137 sal_Bool WpADOConnection::CommitTrans( ) 138 { 139 OSL_ENSURE(pInterface,"Interface is null!"); 140 return SUCCEEDED(pInterface->CommitTrans()); 141 } 142 143 sal_Bool WpADOConnection::RollbackTrans( ) 144 { 145 OSL_ENSURE(pInterface,"Interface is null!"); 146 return SUCCEEDED(pInterface->RollbackTrans()); 147 } 148 149 sal_Bool WpADOConnection::Open(const ::rtl::OUString& ConnectionString, const ::rtl::OUString& UserID,const ::rtl::OUString& Password,long Options) 150 { 151 OSL_ENSURE(pInterface,"Interface is null!"); 152 OLEString sStr1(ConnectionString); 153 OLEString sStr2(UserID); 154 OLEString sStr3(Password); 155 sal_Bool bErg = SUCCEEDED(pInterface->Open(sStr1,sStr2,sStr3,Options)); 156 return bErg; 157 } 158 159 sal_Bool WpADOConnection::GetErrors(ADOErrors** pErrors) 160 { 161 OSL_ENSURE(pInterface,"Interface is null!"); 162 return SUCCEEDED(pInterface->get_Errors(pErrors)); 163 } 164 165 ::rtl::OUString WpADOConnection::GetDefaultDatabase() const 166 { 167 OSL_ENSURE(pInterface,"Interface is null!"); 168 OLEString aBSTR; pInterface->get_DefaultDatabase(&aBSTR); 169 return aBSTR; 170 } 171 172 sal_Bool WpADOConnection::PutDefaultDatabase(const ::rtl::OUString& _bstr) 173 { 174 OSL_ENSURE(pInterface,"Interface is null!"); 175 OLEString bstr(_bstr); 176 sal_Bool bErg = SUCCEEDED(pInterface->put_DefaultDatabase(bstr)); 177 178 return bErg; 179 } 180 181 IsolationLevelEnum WpADOConnection::get_IsolationLevel() const 182 { 183 OSL_ENSURE(pInterface,"Interface is null!"); 184 IsolationLevelEnum eNum=adXactUnspecified; 185 pInterface->get_IsolationLevel(&eNum); 186 return eNum; 187 } 188 189 sal_Bool WpADOConnection::put_IsolationLevel(const IsolationLevelEnum& eNum) 190 { 191 OSL_ENSURE(pInterface,"Interface is null!"); 192 return SUCCEEDED(pInterface->put_IsolationLevel(eNum)); 193 } 194 195 sal_Int32 WpADOConnection::get_Attributes() const 196 { 197 OSL_ENSURE(pInterface,"Interface is null!"); 198 sal_Int32 nRet=0; 199 pInterface->get_Attributes(&nRet); 200 return nRet; 201 } 202 203 sal_Bool WpADOConnection::put_Attributes(sal_Int32 nRet) 204 { 205 OSL_ENSURE(pInterface,"Interface is null!"); 206 return SUCCEEDED(pInterface->put_Attributes(nRet)); 207 } 208 209 CursorLocationEnum WpADOConnection::get_CursorLocation() const 210 { 211 OSL_ENSURE(pInterface,"Interface is null!"); 212 CursorLocationEnum eNum=adUseNone; 213 pInterface->get_CursorLocation(&eNum); 214 return eNum; 215 } 216 217 sal_Bool WpADOConnection::put_CursorLocation(const CursorLocationEnum &eNum) 218 { 219 OSL_ENSURE(pInterface,"Interface is null!"); 220 return SUCCEEDED(pInterface->put_CursorLocation(eNum)); 221 } 222 223 ConnectModeEnum WpADOConnection::get_Mode() const 224 { 225 OSL_ENSURE(pInterface,"Interface is null!"); 226 ConnectModeEnum eNum=adModeUnknown; 227 pInterface->get_Mode(&eNum); 228 return eNum; 229 } 230 231 sal_Bool WpADOConnection::put_Mode(const ConnectModeEnum &eNum) 232 { 233 OSL_ENSURE(pInterface,"Interface is null!"); 234 return SUCCEEDED(pInterface->put_Mode(eNum)); 235 } 236 237 ::rtl::OUString WpADOConnection::get_Provider() const 238 { 239 OSL_ENSURE(pInterface,"Interface is null!"); 240 OLEString aBSTR; pInterface->get_Provider(&aBSTR); 241 return aBSTR; 242 } 243 244 sal_Bool WpADOConnection::put_Provider(const ::rtl::OUString& _bstr) 245 { 246 OSL_ENSURE(pInterface,"Interface is null!"); 247 OLEString bstr(_bstr); 248 return SUCCEEDED(pInterface->put_Provider(bstr)); 249 } 250 251 sal_Int32 WpADOConnection::get_State() const 252 { 253 OSL_ENSURE(pInterface,"Interface is null!"); 254 sal_Int32 nRet=0; 255 pInterface->get_State(&nRet); 256 return nRet; 257 } 258 259 sal_Bool WpADOConnection::OpenSchema(SchemaEnum eNum,OLEVariant& Restrictions,OLEVariant& SchemaID,ADORecordset**pprset) 260 { 261 OSL_ENSURE(pInterface,"Interface is null!"); 262 return SUCCEEDED(pInterface->OpenSchema(eNum,Restrictions,SchemaID,pprset)); 263 } 264 265 ::rtl::OUString WpADOConnection::get_Version() const 266 { 267 OSL_ENSURE(pInterface,"Interface is null!"); 268 OLEString aBSTR; 269 pInterface->get_Version(&aBSTR); 270 return aBSTR; 271 } 272 273 sal_Bool WpADOCommand::putref_ActiveConnection( WpADOConnection *pCon) 274 { 275 OSL_ENSURE(pInterface,"Interface is null!"); 276 if(pCon) 277 return SUCCEEDED(pInterface->putref_ActiveConnection(pCon->pInterface)); 278 else 279 return SUCCEEDED(pInterface->putref_ActiveConnection(NULL)); 280 } 281 282 void WpADOCommand::put_ActiveConnection(/* [in] */ const OLEVariant& vConn) 283 { 284 OSL_ENSURE(pInterface,"Interface is null!"); 285 pInterface->put_ActiveConnection(vConn); 286 } 287 288 void WpADOCommand::Create() 289 { 290 IClassFactory2* pInterface2 = NULL; 291 IUnknown *pOuter = NULL; 292 HRESULT hr; 293 hr = CoGetClassObject( ADOS::CLSID_ADOCOMMAND_21, 294 CLSCTX_INPROC_SERVER, 295 NULL, 296 IID_IClassFactory2, 297 (void**)&pInterface2 ); 298 299 if( !FAILED( hr ) ) 300 { 301 ADOCommand* pCommand=NULL; 302 303 hr = pInterface2->CreateInstanceLic( pOuter, 304 NULL, 305 ADOS::IID_ADOCOMMAND_21, 306 ADOS::GetKeyStr(), 307 (void**) &pCommand); 308 309 if( !FAILED( hr ) ) 310 { 311 operator=(pCommand); 312 pCommand->Release(); 313 } 314 315 pInterface2->Release(); 316 } 317 } 318 319 sal_Int32 WpADOCommand::get_State() const 320 { 321 OSL_ENSURE(pInterface,"Interface is null!"); 322 sal_Int32 nRet=0; 323 pInterface->get_State(&nRet); 324 return nRet; 325 } 326 327 ::rtl::OUString WpADOCommand::get_CommandText() const 328 { 329 OSL_ENSURE(pInterface,"Interface is null!"); 330 OLEString aBSTR; 331 pInterface->get_CommandText(&aBSTR); 332 return aBSTR; 333 } 334 335 sal_Bool WpADOCommand::put_CommandText(const ::rtl::OUString &aCon) 336 { 337 OSL_ENSURE(pInterface,"Interface is null!"); 338 OLEString bstr(aCon); 339 sal_Bool bErg = SUCCEEDED(pInterface->put_CommandText(bstr)); 340 341 return bErg; 342 } 343 344 sal_Int32 WpADOCommand::get_CommandTimeout() const 345 { 346 OSL_ENSURE(pInterface,"Interface is null!"); 347 sal_Int32 nRet=0; 348 pInterface->get_CommandTimeout(&nRet); 349 return nRet; 350 } 351 352 void WpADOCommand::put_CommandTimeout(sal_Int32 nRet) 353 { 354 OSL_ENSURE(pInterface,"Interface is null!"); 355 pInterface->put_CommandTimeout(nRet); 356 } 357 358 sal_Bool WpADOCommand::get_Prepared() const 359 { 360 OSL_ENSURE(pInterface,"Interface is null!"); 361 VARIANT_BOOL bPrepared = VARIANT_FALSE; 362 pInterface->get_Prepared(&bPrepared); 363 return bPrepared == VARIANT_TRUE; 364 } 365 366 sal_Bool WpADOCommand::put_Prepared(VARIANT_BOOL bPrepared) const 367 { 368 OSL_ENSURE(pInterface,"Interface is null!"); 369 return SUCCEEDED(pInterface->put_Prepared(bPrepared)); 370 } 371 372 sal_Bool WpADOCommand::Execute(OLEVariant& RecordsAffected,OLEVariant& Parameters,long Options, ADORecordset** ppiRset) 373 { 374 OSL_ENSURE(pInterface,"Interface is null!"); 375 return SUCCEEDED(pInterface->Execute(&RecordsAffected,&Parameters,Options,ppiRset)); 376 } 377 378 ADOParameter* WpADOCommand::CreateParameter(const ::rtl::OUString &_bstr,DataTypeEnum Type,ParameterDirectionEnum Direction,long nSize,const OLEVariant &Value) 379 { 380 OSL_ENSURE(pInterface,"Interface is null!"); 381 ADOParameter* pPara = NULL; 382 OLEString bstr(_bstr); 383 sal_Bool bErg = SUCCEEDED(pInterface->CreateParameter(bstr,Type,Direction,nSize,Value,&pPara)); 384 385 return bErg ? pPara : NULL; 386 } 387 388 ADOParameters* WpADOCommand::get_Parameters() const 389 { 390 OSL_ENSURE(pInterface,"Interface is null!"); 391 ADOParameters* pPara=NULL; 392 pInterface->get_Parameters(&pPara); 393 return pPara; 394 } 395 396 sal_Bool WpADOCommand::put_CommandType( /* [in] */ CommandTypeEnum lCmdType) 397 { 398 OSL_ENSURE(pInterface,"Interface is null!"); 399 return SUCCEEDED(pInterface->put_CommandType(lCmdType)); 400 } 401 402 CommandTypeEnum WpADOCommand::get_CommandType( ) const 403 { 404 OSL_ENSURE(pInterface,"Interface is null!"); 405 CommandTypeEnum eNum=adCmdUnspecified; 406 pInterface->get_CommandType(&eNum); 407 return eNum; 408 } 409 410 // gibt den Namen des Feldes zur"ueck 411 ::rtl::OUString WpADOCommand::GetName() const 412 { 413 OSL_ENSURE(pInterface,"Interface is null!"); 414 OLEString aBSTR; 415 pInterface->get_Name(&aBSTR); 416 return aBSTR; 417 } 418 419 sal_Bool WpADOCommand::put_Name(const ::rtl::OUString& _Name) 420 { 421 OSL_ENSURE(pInterface,"Interface is null!"); 422 OLEString bstr(_Name); 423 sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr)); 424 425 return bErg; 426 } 427 sal_Bool WpADOCommand::Cancel() 428 { 429 OSL_ENSURE(pInterface,"Interface is null!"); 430 return SUCCEEDED(pInterface->Cancel()); 431 } 432 433 ::rtl::OUString WpADOError::GetDescription() const 434 { 435 OSL_ENSURE(pInterface,"Interface is null!"); 436 OLEString aBSTR; 437 pInterface->get_Description(&aBSTR); 438 return aBSTR; 439 } 440 441 ::rtl::OUString WpADOError::GetSource() const 442 { 443 OSL_ENSURE(pInterface,"Interface is null!"); 444 OLEString aBSTR; 445 pInterface->get_Source(&aBSTR); 446 return aBSTR; 447 } 448 449 sal_Int32 WpADOError::GetNumber() const 450 { 451 OSL_ENSURE(pInterface,"Interface is null!"); 452 sal_Int32 nErrNr=0; 453 pInterface->get_Number(&nErrNr); 454 return nErrNr; 455 } 456 457 ::rtl::OUString WpADOError::GetSQLState() const 458 { 459 OSL_ENSURE(pInterface,"Interface is null!"); 460 OLEString aBSTR; 461 pInterface->get_SQLState(&aBSTR); 462 return aBSTR; 463 } 464 465 sal_Int32 WpADOError::GetNativeError() const 466 { 467 OSL_ENSURE(pInterface,"Interface is null!"); 468 sal_Int32 nErrNr=0; 469 pInterface->get_NativeError(&nErrNr); 470 return nErrNr; 471 } 472 WpADOProperties WpADOField::get_Properties() 473 { 474 OSL_ENSURE(pInterface,"Interface is null!"); 475 ADOProperties* pProps = NULL; 476 pInterface->get_Properties(&pProps); 477 WpADOProperties aProps; 478 479 aProps.setWithOutAddRef(pProps); 480 return aProps; 481 } 482 483 sal_Int32 WpADOField::GetActualSize() const 484 { 485 OSL_ENSURE(pInterface,"Interface is null!"); 486 sal_Int32 nActualSize=0; 487 pInterface->get_ActualSize(&nActualSize); 488 return nActualSize; 489 } 490 491 sal_Int32 WpADOField::GetAttributes() const 492 { 493 OSL_ENSURE(pInterface,"Interface is null!"); 494 sal_Int32 eADOSFieldAttributes=0; 495 pInterface->get_Attributes(&eADOSFieldAttributes); 496 return eADOSFieldAttributes; 497 } 498 499 sal_Int32 WpADOField::GetStatus() const 500 { 501 OSL_ENSURE(pInterface,"Interface is null!"); 502 sal_Int32 eADOSFieldAttributes=0; 503 // pInterface->get_Status(&eADOSFieldAttributes); 504 return eADOSFieldAttributes; 505 } 506 507 sal_Int32 WpADOField::GetDefinedSize() const 508 { 509 OSL_ENSURE(pInterface,"Interface is null!"); 510 sal_Int32 nDefinedSize=0; 511 pInterface->get_DefinedSize(&nDefinedSize); 512 return nDefinedSize; 513 } 514 515 // gibt den Namen des Feldes zur"ueck 516 ::rtl::OUString WpADOField::GetName() const 517 { 518 OSL_ENSURE(pInterface,"Interface is null!"); 519 OLEString aBSTR; 520 pInterface->get_Name(&aBSTR); 521 return aBSTR; 522 } 523 524 DataTypeEnum WpADOField::GetADOType() const 525 { 526 OSL_ENSURE(pInterface,"Interface is null!"); 527 DataTypeEnum eType=adEmpty; 528 pInterface->get_Type(&eType); 529 return eType; 530 } 531 532 void WpADOField::get_Value(OLEVariant& aValVar) const 533 { 534 OSL_ENSURE(pInterface,"Interface is null!"); 535 aValVar.setEmpty(); 536 sal_Bool bOk = SUCCEEDED(pInterface->get_Value(&aValVar)); 537 (void)bOk; 538 } 539 540 OLEVariant WpADOField::get_Value() const 541 { 542 OSL_ENSURE(pInterface,"Interface is null!"); 543 OLEVariant aValVar; 544 pInterface->get_Value(&aValVar); 545 return aValVar; 546 } 547 548 sal_Bool WpADOField::PutValue(const OLEVariant& aVariant) 549 { 550 OSL_ENSURE(pInterface,"Interface is null!"); 551 return (SUCCEEDED(pInterface->put_Value(aVariant))); 552 } 553 554 sal_Int32 WpADOField::GetPrecision() const 555 { 556 OSL_ENSURE(pInterface,"Interface is null!"); 557 sal_uInt8 eType=0; 558 pInterface->get_Precision(&eType); 559 return eType; 560 } 561 562 sal_Int32 WpADOField::GetNumericScale() const 563 { 564 OSL_ENSURE(pInterface,"Interface is null!"); 565 sal_uInt8 eType=0; 566 pInterface->get_NumericScale(&eType); 567 return eType; 568 } 569 570 sal_Bool WpADOField::AppendChunk(const OLEVariant& _Variant) 571 { 572 OSL_ENSURE(pInterface,"Interface is null!"); 573 return (SUCCEEDED(pInterface->AppendChunk(_Variant))); 574 } 575 576 OLEVariant WpADOField::GetChunk(long Length) const 577 { 578 OSL_ENSURE(pInterface,"Interface is null!"); 579 OLEVariant aValVar; 580 pInterface->GetChunk(Length,&aValVar); 581 return aValVar; 582 } 583 584 void WpADOField::GetChunk(long Length,OLEVariant &aValVar) const 585 { 586 OSL_ENSURE(pInterface,"Interface is null!"); 587 pInterface->GetChunk(Length,&aValVar); 588 } 589 590 OLEVariant WpADOField::GetOriginalValue() const 591 { 592 OSL_ENSURE(pInterface,"Interface is null!"); 593 OLEVariant aValVar; 594 pInterface->get_OriginalValue(&aValVar); 595 return aValVar; 596 } 597 598 void WpADOField::GetOriginalValue(OLEVariant &aValVar) const 599 { 600 OSL_ENSURE(pInterface,"Interface is null!"); 601 pInterface->get_OriginalValue(&aValVar); 602 } 603 604 OLEVariant WpADOField::GetUnderlyingValue() const 605 { 606 OSL_ENSURE(pInterface,"Interface is null!"); 607 OLEVariant aValVar; 608 pInterface->get_UnderlyingValue(&aValVar); 609 return aValVar; 610 } 611 612 void WpADOField::GetUnderlyingValue(OLEVariant &aValVar) const 613 { 614 OSL_ENSURE(pInterface,"Interface is null!"); 615 pInterface->get_UnderlyingValue(&aValVar); 616 } 617 618 sal_Bool WpADOField::PutPrecision(sal_Int8 _prec) 619 { 620 OSL_ENSURE(pInterface,"Interface is null!"); 621 return (SUCCEEDED(pInterface->put_Precision(_prec))); 622 } 623 624 sal_Bool WpADOField::PutNumericScale(sal_Int8 _prec) 625 { 626 OSL_ENSURE(pInterface,"Interface is null!"); 627 return (SUCCEEDED(pInterface->put_NumericScale(_prec))); 628 } 629 630 void WpADOField::PutADOType(DataTypeEnum eType) 631 { 632 OSL_ENSURE(pInterface,"Interface is null!"); 633 pInterface->put_Type(eType); 634 } 635 636 sal_Bool WpADOField::PutDefinedSize(sal_Int32 _nDefSize) 637 { 638 OSL_ENSURE(pInterface,"Interface is null!"); 639 return (SUCCEEDED(pInterface->put_DefinedSize(_nDefSize))); 640 } 641 642 sal_Bool WpADOField::PutAttributes(sal_Int32 _nDefSize) 643 { 644 OSL_ENSURE(pInterface,"Interface is null!"); 645 return (SUCCEEDED(pInterface->put_Attributes(_nDefSize))); 646 } 647 648 OLEVariant WpADOProperty::GetValue() const 649 { 650 OLEVariant aValVar; 651 if(pInterface) 652 pInterface->get_Value(&aValVar); 653 return aValVar; 654 } 655 656 void WpADOProperty::GetValue(OLEVariant &aValVar) const 657 { 658 OSL_ENSURE(pInterface,"Interface is null!"); 659 if(pInterface) 660 pInterface->get_Value(&aValVar); 661 } 662 663 sal_Bool WpADOProperty::PutValue(const OLEVariant &aValVar) 664 { 665 OSL_ENSURE(pInterface,"Interface is null!"); 666 return (SUCCEEDED(pInterface->put_Value(aValVar))); 667 } 668 669 ::rtl::OUString WpADOProperty::GetName() const 670 { 671 OSL_ENSURE(pInterface,"Interface is null!"); 672 OLEString aBSTR; 673 pInterface->get_Name(&aBSTR); 674 return aBSTR; 675 } 676 677 DataTypeEnum WpADOProperty::GetADOType() const 678 { 679 OSL_ENSURE(pInterface,"Interface is null!"); 680 DataTypeEnum eType=adEmpty; 681 pInterface->get_Type(&eType); 682 return eType; 683 } 684 685 sal_Int32 WpADOProperty::GetAttributes() const 686 { 687 OSL_ENSURE(pInterface,"Interface is null!"); 688 sal_Int32 eADOSFieldAttributes=0; 689 pInterface->get_Attributes(&eADOSFieldAttributes); 690 return eADOSFieldAttributes; 691 } 692 693 sal_Bool WpADOProperty::PutAttributes(sal_Int32 _nDefSize) 694 { 695 OSL_ENSURE(pInterface,"Interface is null!"); 696 return (SUCCEEDED(pInterface->put_Attributes(_nDefSize))); 697 } 698 void WpADORecordset::Create() 699 { 700 IClassFactory2* pInterface2 = NULL; 701 IUnknown *pOuter = NULL; 702 HRESULT hr; 703 hr = CoGetClassObject( ADOS::CLSID_ADORECORDSET_21, 704 CLSCTX_INPROC_SERVER, 705 NULL, 706 IID_IClassFactory2, 707 (void**)&pInterface2 ); 708 709 if( !FAILED( hr ) ) 710 { 711 ADORecordset *pRec = NULL; 712 hr = pInterface2->CreateInstanceLic( pOuter, 713 NULL, 714 ADOS::IID_ADORECORDSET_21, 715 ADOS::GetKeyStr(), 716 (void**) &pRec); 717 718 if( !FAILED( hr ) ) 719 { 720 operator=(pRec); 721 pRec->Release(); 722 } 723 724 pInterface2->Release(); 725 } 726 } 727 728 sal_Bool WpADORecordset::Open( 729 /* [optional][in] */ VARIANT Source, 730 /* [optional][in] */ VARIANT ActiveConnection, 731 /* [defaultvalue][in] */ CursorTypeEnum CursorType, 732 /* [defaultvalue][in] */ LockTypeEnum LockType, 733 /* [defaultvalue][in] */ sal_Int32 Options) 734 { 735 OSL_ENSURE(pInterface,"Interface is null!"); 736 return (SUCCEEDED(pInterface->Open(Source,ActiveConnection,CursorType,LockType,Options))); 737 } 738 739 740 LockTypeEnum WpADORecordset::GetLockType() 741 { 742 OSL_ENSURE(pInterface,"Interface is null!"); 743 LockTypeEnum eType=adLockUnspecified; 744 pInterface->get_LockType(&eType); 745 return eType; 746 } 747 748 void WpADORecordset::Close() 749 { 750 OSL_ENSURE(pInterface,"Interface is null!"); 751 OSL_ENSURE(pInterface,"Interface is null!"); 752 pInterface->Close(); 753 } 754 755 sal_Bool WpADORecordset::Cancel() const 756 { 757 OSL_ENSURE(pInterface,"Interface is null!"); 758 return (SUCCEEDED(pInterface->Cancel())); 759 } 760 761 sal_Int32 WpADORecordset::get_State( ) 762 { 763 OSL_ENSURE(pInterface,"Interface is null!"); 764 sal_Int32 nState = 0; 765 pInterface->get_State(&nState); 766 return nState; 767 } 768 769 sal_Bool WpADORecordset::Supports( /* [in] */ CursorOptionEnum CursorOptions) 770 { 771 OSL_ENSURE(pInterface,"Interface is null!"); 772 VARIANT_BOOL bSupports=VARIANT_FALSE; 773 pInterface->Supports(CursorOptions,&bSupports); 774 return bSupports == VARIANT_TRUE; 775 } 776 777 PositionEnum WpADORecordset::get_AbsolutePosition() 778 { 779 OSL_ENSURE(pInterface,"Interface is null!"); 780 PositionEnum aTemp=adPosUnknown; 781 pInterface->get_AbsolutePosition(&aTemp); 782 return aTemp; 783 } 784 785 void WpADORecordset::GetDataSource(IUnknown** _pInterface) const 786 { 787 OSL_ENSURE(pInterface,"Interface is null!"); 788 pInterface->get_DataSource(_pInterface); 789 } 790 791 void WpADORecordset::PutRefDataSource(IUnknown* _pInterface) 792 { 793 OSL_ENSURE(pInterface,"Interface is null!"); 794 pInterface->putref_DataSource(_pInterface); 795 } 796 797 void WpADORecordset::GetBookmark(VARIANT& var) 798 { 799 OSL_ENSURE(pInterface,"Interface is null!"); 800 pInterface->get_Bookmark(&var); 801 } 802 803 OLEVariant WpADORecordset::GetBookmark() 804 { 805 OSL_ENSURE(pInterface,"Interface is null!"); 806 OLEVariant var; 807 pInterface->get_Bookmark(&var); 808 return var; 809 } 810 811 CompareEnum WpADORecordset::CompareBookmarks(const OLEVariant& left,const OLEVariant& right) 812 { 813 OSL_ENSURE(pInterface,"Interface is null!"); 814 CompareEnum eNum=adCompareNotComparable; 815 pInterface->CompareBookmarks(left,right,&eNum); 816 return eNum; 817 } 818 819 sal_Bool WpADORecordset::SetBookmark(const OLEVariant &pSafeAr) 820 { 821 OSL_ENSURE(pInterface,"Interface is null!"); 822 return SUCCEEDED(pInterface->put_Bookmark(pSafeAr)); 823 } 824 825 826 WpADOFields WpADORecordset::GetFields() const 827 { 828 OSL_ENSURE(pInterface,"Interface is null!"); 829 ADOFields* pFields=NULL; 830 pInterface->get_Fields(&pFields); 831 WpADOFields aFields; 832 aFields.setWithOutAddRef(pFields); 833 return aFields; 834 } 835 836 837 sal_Bool WpADORecordset::Move(sal_Int32 nRows, VARIANT aBmk) {return pInterface && SUCCEEDED(pInterface->Move(nRows, aBmk));} 838 sal_Bool WpADORecordset::MoveNext() {return pInterface && SUCCEEDED(pInterface->MoveNext());} 839 sal_Bool WpADORecordset::MovePrevious() {return pInterface && SUCCEEDED(pInterface->MovePrevious());} 840 sal_Bool WpADORecordset::MoveFirst() {return pInterface && SUCCEEDED(pInterface->MoveFirst());} 841 sal_Bool WpADORecordset::MoveLast() {return pInterface && SUCCEEDED(pInterface->MoveLast());} 842 843 sal_Bool WpADORecordset::IsAtBOF() const 844 { 845 OSL_ENSURE(pInterface,"Interface is null!"); 846 VARIANT_BOOL bIsAtBOF=VARIANT_FALSE; 847 pInterface->get_BOF(&bIsAtBOF); 848 return bIsAtBOF == VARIANT_TRUE; 849 } 850 851 sal_Bool WpADORecordset::IsAtEOF() const 852 { 853 OSL_ENSURE(pInterface,"Interface is null!"); 854 VARIANT_BOOL bIsAtEOF=VARIANT_FALSE; 855 pInterface->get_EOF(&bIsAtEOF); 856 return bIsAtEOF == VARIANT_TRUE; 857 } 858 859 sal_Bool WpADORecordset::Delete(AffectEnum eNum) 860 { 861 OSL_ENSURE(pInterface,"Interface is null!"); 862 return SUCCEEDED(pInterface->Delete(eNum)); 863 } 864 865 sal_Bool WpADORecordset::AddNew(const OLEVariant &FieldList,const OLEVariant &Values) 866 { 867 OSL_ENSURE(pInterface,"Interface is null!"); 868 return SUCCEEDED(pInterface->AddNew(FieldList,Values)); 869 } 870 871 sal_Bool WpADORecordset::Update(const OLEVariant &FieldList,const OLEVariant &Values) 872 { 873 OSL_ENSURE(pInterface,"Interface is null!"); 874 return SUCCEEDED(pInterface->Update(FieldList,Values)); 875 } 876 877 sal_Bool WpADORecordset::CancelUpdate() 878 { 879 OSL_ENSURE(pInterface,"Interface is null!"); 880 return SUCCEEDED(pInterface->CancelUpdate()); 881 } 882 883 WpADOProperties WpADORecordset::get_Properties() const 884 { 885 OSL_ENSURE(pInterface,"Interface is null!"); 886 ADOProperties* pProps=NULL; 887 pInterface->get_Properties(&pProps); 888 WpADOProperties aProps; 889 aProps.setWithOutAddRef(pProps); 890 return aProps; 891 } 892 893 sal_Bool WpADORecordset::NextRecordset(OLEVariant& RecordsAffected,ADORecordset** ppiRset) 894 { 895 OSL_ENSURE(pInterface,"Interface is null!"); 896 return SUCCEEDED(pInterface->NextRecordset(&RecordsAffected,ppiRset)); 897 } 898 899 sal_Bool WpADORecordset::get_RecordCount(sal_Int32 &_nRet) const 900 { 901 OSL_ENSURE(pInterface,"Interface is null!"); 902 return SUCCEEDED(pInterface->get_RecordCount(&_nRet)); 903 } 904 905 sal_Bool WpADORecordset::get_MaxRecords(sal_Int32 &_nRet) const 906 { 907 OSL_ENSURE(pInterface,"Interface is null!"); 908 return SUCCEEDED(pInterface->get_MaxRecords(&_nRet)); 909 } 910 911 sal_Bool WpADORecordset::put_MaxRecords(sal_Int32 _nRet) 912 { 913 OSL_ENSURE(pInterface,"Interface is null!"); 914 return SUCCEEDED(pInterface->put_MaxRecords(_nRet)); 915 } 916 917 sal_Bool WpADORecordset::get_CursorType(CursorTypeEnum &_nRet) const 918 { 919 OSL_ENSURE(pInterface,"Interface is null!"); 920 return SUCCEEDED(pInterface->get_CursorType(&_nRet)); 921 } 922 923 sal_Bool WpADORecordset::put_CursorType(CursorTypeEnum _nRet) 924 { 925 OSL_ENSURE(pInterface,"Interface is null!"); 926 return SUCCEEDED(pInterface->put_CursorType(_nRet)); 927 } 928 929 sal_Bool WpADORecordset::get_LockType(LockTypeEnum &_nRet) const 930 { 931 OSL_ENSURE(pInterface,"Interface is null!"); 932 return SUCCEEDED(pInterface->get_LockType(&_nRet)); 933 } 934 935 sal_Bool WpADORecordset::put_LockType(LockTypeEnum _nRet) 936 { 937 OSL_ENSURE(pInterface,"Interface is null!"); 938 return SUCCEEDED(pInterface->put_LockType(_nRet)); 939 } 940 941 sal_Bool WpADORecordset::get_CacheSize(sal_Int32 &_nRet) const 942 { 943 OSL_ENSURE(pInterface,"Interface is null!"); 944 return SUCCEEDED(pInterface->get_CacheSize(&_nRet)); 945 } 946 947 sal_Bool WpADORecordset::put_CacheSize(sal_Int32 _nRet) 948 { 949 OSL_ENSURE(pInterface,"Interface is null!"); 950 return SUCCEEDED(pInterface->put_CacheSize(_nRet)); 951 } 952 953 sal_Bool WpADORecordset::UpdateBatch(AffectEnum AffectRecords) 954 { 955 OSL_ENSURE(pInterface,"Interface is null!"); 956 return SUCCEEDED(pInterface->UpdateBatch(AffectRecords)); 957 } 958 959 ::rtl::OUString WpADOParameter::GetName() const 960 { 961 OSL_ENSURE(pInterface,"Interface is null!"); 962 OLEString aBSTR; 963 pInterface->get_Name(&aBSTR); 964 return aBSTR; 965 } 966 967 DataTypeEnum WpADOParameter::GetADOType() const 968 { 969 OSL_ENSURE(pInterface,"Interface is null!"); 970 DataTypeEnum eType=adEmpty; 971 pInterface->get_Type(&eType); 972 return eType; 973 } 974 975 void WpADOParameter::put_Type(const DataTypeEnum& _eType) 976 { 977 OSL_ENSURE(pInterface,"Interface is null!"); 978 pInterface->put_Type(_eType); 979 } 980 981 sal_Int32 WpADOParameter::GetAttributes() const 982 { 983 OSL_ENSURE(pInterface,"Interface is null!"); 984 sal_Int32 eADOSFieldAttributes=0; 985 pInterface->get_Attributes(&eADOSFieldAttributes); 986 return eADOSFieldAttributes; 987 } 988 989 sal_Int32 WpADOParameter::GetPrecision() const 990 { 991 OSL_ENSURE(pInterface,"Interface is null!"); 992 sal_uInt8 eType=0; 993 pInterface->get_Precision(&eType); 994 return eType; 995 } 996 997 sal_Int32 WpADOParameter::GetNumericScale() const 998 { 999 OSL_ENSURE(pInterface,"Interface is null!"); 1000 sal_uInt8 eType=0; 1001 pInterface->get_NumericScale(&eType); 1002 return eType; 1003 } 1004 1005 ParameterDirectionEnum WpADOParameter::get_Direction() const 1006 { 1007 OSL_ENSURE(pInterface,"Interface is null!"); 1008 ParameterDirectionEnum alParmDirection=adParamUnknown; 1009 pInterface->get_Direction(&alParmDirection); 1010 return alParmDirection; 1011 } 1012 1013 void WpADOParameter::GetValue(OLEVariant& aValVar) const 1014 { 1015 OSL_ENSURE(pInterface,"Interface is null!"); 1016 pInterface->get_Value(&aValVar); 1017 } 1018 1019 OLEVariant WpADOParameter::GetValue() const 1020 { 1021 OSL_ENSURE(pInterface,"Interface is null!"); 1022 OLEVariant aValVar; 1023 pInterface->get_Value(&aValVar); 1024 return aValVar; 1025 } 1026 1027 sal_Bool WpADOParameter::PutValue(const OLEVariant& aVariant) 1028 { 1029 OSL_ENSURE(pInterface,"Interface is null!"); 1030 return (SUCCEEDED(pInterface->put_Value(aVariant))); 1031 } 1032 sal_Bool WpADOParameter::AppendChunk(const OLEVariant& aVariant) 1033 { 1034 OSL_ENSURE(pInterface,"Interface is null!"); 1035 return (SUCCEEDED(pInterface->AppendChunk(aVariant))); 1036 } 1037 sal_Bool WpADOParameter::put_Size(const sal_Int32& _nSize) 1038 { 1039 OSL_ENSURE(pInterface,"Interface is null!"); 1040 return (SUCCEEDED(pInterface->put_Size(_nSize))); 1041 } 1042 1043 ::rtl::OUString WpADOColumn::get_Name() const 1044 { 1045 OSL_ENSURE(pInterface,"Interface is null!"); 1046 OLEString aBSTR; 1047 pInterface->get_Name(&aBSTR); 1048 return aBSTR; 1049 } 1050 1051 ::rtl::OUString WpADOColumn::get_RelatedColumn() const 1052 { 1053 OSL_ENSURE(pInterface,"Interface is null!"); 1054 OLEString aBSTR; 1055 pInterface->get_RelatedColumn(&aBSTR); 1056 return aBSTR; 1057 } 1058 1059 void WpADOColumn::put_Name(const ::rtl::OUString& _rName) 1060 { 1061 OSL_ENSURE(pInterface,"Interface is null!"); 1062 OLEString bstr(_rName); 1063 sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr)); 1064 (void)bErg; 1065 } 1066 void WpADOColumn::put_RelatedColumn(const ::rtl::OUString& _rName) 1067 { 1068 OSL_ENSURE(pInterface,"Interface is null!"); 1069 OLEString bstr(_rName); 1070 sal_Bool bErg = SUCCEEDED(pInterface->put_RelatedColumn(bstr)); 1071 (void)bErg; 1072 } 1073 1074 DataTypeEnum WpADOColumn::get_Type() const 1075 { 1076 OSL_ENSURE(pInterface,"Interface is null!"); 1077 DataTypeEnum eNum = adVarChar; 1078 pInterface->get_Type(&eNum); 1079 return eNum; 1080 } 1081 1082 void WpADOColumn::put_Type(const DataTypeEnum& _eNum) 1083 { 1084 OSL_ENSURE(pInterface,"Interface is null!"); 1085 pInterface->put_Type(_eNum); 1086 } 1087 1088 sal_Int32 WpADOColumn::get_Precision() const 1089 { 1090 OSL_ENSURE(pInterface,"Interface is null!"); 1091 sal_Int32 nPrec=0; 1092 pInterface->get_Precision(&nPrec); 1093 return nPrec; 1094 } 1095 1096 void WpADOColumn::put_Precision(sal_Int32 _nPre) 1097 { 1098 OSL_ENSURE(pInterface,"Interface is null!"); 1099 pInterface->put_Precision(_nPre); 1100 } 1101 1102 sal_Int32 WpADOColumn::get_DefinedSize() const 1103 { 1104 OSL_ENSURE(pInterface,"Interface is null!"); 1105 sal_Int32 nPrec=0; 1106 pInterface->get_DefinedSize(&nPrec); 1107 return nPrec; 1108 } 1109 sal_uInt8 WpADOColumn::get_NumericScale() const 1110 { 1111 OSL_ENSURE(pInterface,"Interface is null!"); 1112 sal_uInt8 nPrec=0; 1113 pInterface->get_NumericScale(&nPrec); 1114 return nPrec; 1115 } 1116 1117 void WpADOColumn::put_NumericScale(sal_Int8 _nScale) 1118 { 1119 OSL_ENSURE(pInterface,"Interface is null!"); 1120 pInterface->put_NumericScale(_nScale); 1121 } 1122 1123 SortOrderEnum WpADOColumn::get_SortOrder() const 1124 { 1125 OSL_ENSURE(pInterface,"Interface is null!"); 1126 SortOrderEnum nPrec=adSortAscending; 1127 pInterface->get_SortOrder(&nPrec); 1128 return nPrec; 1129 } 1130 1131 void WpADOColumn::put_SortOrder(SortOrderEnum _nScale) 1132 { 1133 OSL_ENSURE(pInterface,"Interface is null!"); 1134 pInterface->put_SortOrder(_nScale); 1135 } 1136 1137 ColumnAttributesEnum WpADOColumn::get_Attributes() const 1138 { 1139 OSL_ENSURE(pInterface,"Interface is null!"); 1140 ColumnAttributesEnum eNum=adColNullable; 1141 pInterface->get_Attributes(&eNum); 1142 return eNum; 1143 } 1144 1145 sal_Bool WpADOColumn::put_Attributes(const ColumnAttributesEnum& _eNum) 1146 { 1147 OSL_ENSURE(pInterface,"Interface is null!"); 1148 return SUCCEEDED(pInterface->put_Attributes(_eNum)); 1149 } 1150 1151 WpADOProperties WpADOColumn::get_Properties() const 1152 { 1153 OSL_ENSURE(pInterface,"Interface is null!"); 1154 ADOProperties* pProps = NULL; 1155 pInterface->get_Properties(&pProps); 1156 WpADOProperties aProps; 1157 1158 aProps.setWithOutAddRef(pProps); 1159 return aProps; 1160 } 1161 1162 ::rtl::OUString WpADOKey::get_Name() const 1163 { 1164 OSL_ENSURE(pInterface,"Interface is null!"); 1165 OLEString aBSTR; 1166 pInterface->get_Name(&aBSTR); 1167 return aBSTR; 1168 } 1169 1170 void WpADOKey::put_Name(const ::rtl::OUString& _rName) 1171 { 1172 OSL_ENSURE(pInterface,"Interface is null!"); 1173 OLEString bstr(_rName); 1174 sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr)); 1175 (void)bErg; 1176 } 1177 1178 KeyTypeEnum WpADOKey::get_Type() const 1179 { 1180 OSL_ENSURE(pInterface,"Interface is null!"); 1181 KeyTypeEnum eNum=adKeyPrimary; 1182 pInterface->get_Type(&eNum); 1183 return eNum; 1184 } 1185 1186 void WpADOKey::put_Type(const KeyTypeEnum& _eNum) 1187 { 1188 OSL_ENSURE(pInterface,"Interface is null!"); 1189 pInterface->put_Type(_eNum); 1190 } 1191 1192 ::rtl::OUString WpADOKey::get_RelatedTable() const 1193 { 1194 OSL_ENSURE(pInterface,"Interface is null!"); 1195 OLEString aBSTR; 1196 pInterface->get_RelatedTable(&aBSTR); 1197 return aBSTR; 1198 } 1199 1200 void WpADOKey::put_RelatedTable(const ::rtl::OUString& _rName) 1201 { 1202 OSL_ENSURE(pInterface,"Interface is null!"); 1203 OLEString bstr(_rName); 1204 sal_Bool bErg = SUCCEEDED(pInterface->put_RelatedTable(bstr)); 1205 (void)bErg; 1206 } 1207 1208 RuleEnum WpADOKey::get_DeleteRule() const 1209 { 1210 OSL_ENSURE(pInterface,"Interface is null!"); 1211 RuleEnum eNum = adRINone; 1212 pInterface->get_DeleteRule(&eNum); 1213 return eNum; 1214 } 1215 1216 void WpADOKey::put_DeleteRule(const RuleEnum& _eNum) 1217 { 1218 OSL_ENSURE(pInterface,"Interface is null!"); 1219 pInterface->put_DeleteRule(_eNum); 1220 } 1221 1222 RuleEnum WpADOKey::get_UpdateRule() const 1223 { 1224 OSL_ENSURE(pInterface,"Interface is null!"); 1225 RuleEnum eNum = adRINone; 1226 pInterface->get_UpdateRule(&eNum); 1227 return eNum; 1228 } 1229 1230 void WpADOKey::put_UpdateRule(const RuleEnum& _eNum) 1231 { 1232 OSL_ENSURE(pInterface,"Interface is null!"); 1233 pInterface->put_UpdateRule(_eNum); 1234 } 1235 1236 WpADOColumns WpADOKey::get_Columns() const 1237 { 1238 OSL_ENSURE(pInterface,"Interface is null!"); 1239 ADOColumns* pCols = NULL; 1240 pInterface->get_Columns(&pCols); 1241 WpADOColumns aCols; 1242 aCols.setWithOutAddRef(pCols); 1243 return aCols; 1244 } 1245 1246 ::rtl::OUString WpADOIndex::get_Name() const 1247 { 1248 OSL_ENSURE(pInterface,"Interface is null!"); 1249 OLEString aBSTR; 1250 pInterface->get_Name(&aBSTR); 1251 return aBSTR; 1252 } 1253 1254 void WpADOIndex::put_Name(const ::rtl::OUString& _rName) 1255 { 1256 OSL_ENSURE(pInterface,"Interface is null!"); 1257 OLEString bstr(_rName); 1258 sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr)); 1259 (void)bErg; 1260 } 1261 1262 sal_Bool WpADOIndex::get_Clustered() const 1263 { 1264 OSL_ENSURE(pInterface,"Interface is null!"); 1265 VARIANT_BOOL eNum = VARIANT_FALSE; 1266 pInterface->get_Clustered(&eNum); 1267 return eNum == VARIANT_TRUE; 1268 } 1269 1270 void WpADOIndex::put_Clustered(sal_Bool _b) 1271 { 1272 OSL_ENSURE(pInterface,"Interface is null!"); 1273 pInterface->put_Clustered(_b ? VARIANT_TRUE : VARIANT_FALSE); 1274 } 1275 1276 sal_Bool WpADOIndex::get_Unique() const 1277 { 1278 OSL_ENSURE(pInterface,"Interface is null!"); 1279 VARIANT_BOOL eNum = VARIANT_FALSE; 1280 pInterface->get_Unique(&eNum); 1281 return eNum == VARIANT_TRUE; 1282 } 1283 1284 void WpADOIndex::put_Unique(sal_Bool _b) 1285 { 1286 OSL_ENSURE(pInterface,"Interface is null!"); 1287 pInterface->put_Unique(_b ? VARIANT_TRUE : VARIANT_FALSE); 1288 } 1289 1290 sal_Bool WpADOIndex::get_PrimaryKey() const 1291 { 1292 OSL_ENSURE(pInterface,"Interface is null!"); 1293 VARIANT_BOOL eNum = VARIANT_FALSE; 1294 pInterface->get_PrimaryKey(&eNum); 1295 return eNum == VARIANT_TRUE; 1296 } 1297 1298 void WpADOIndex::put_PrimaryKey(sal_Bool _b) 1299 { 1300 OSL_ENSURE(pInterface,"Interface is null!"); 1301 pInterface->put_PrimaryKey(_b ? VARIANT_TRUE : VARIANT_FALSE); 1302 } 1303 1304 WpADOColumns WpADOIndex::get_Columns() const 1305 { 1306 OSL_ENSURE(pInterface,"Interface is null!"); 1307 ADOColumns* pCols = NULL; 1308 pInterface->get_Columns(&pCols); 1309 WpADOColumns aCols; 1310 aCols.setWithOutAddRef(pCols); 1311 return aCols; 1312 } 1313 1314 void WpADOCatalog::putref_ActiveConnection(IDispatch* pCon) 1315 { 1316 OSL_ENSURE(pInterface,"Interface is null!"); 1317 pInterface->putref_ActiveConnection(pCon); 1318 } 1319 1320 WpADOTables WpADOCatalog::get_Tables() 1321 { 1322 OSL_ENSURE(pInterface,"Interface is null!"); 1323 ADOTables* pRet = NULL; 1324 pInterface->get_Tables(&pRet); 1325 WpADOTables aRet; 1326 aRet.setWithOutAddRef(pRet); 1327 return aRet; 1328 } 1329 1330 WpADOViews WpADOCatalog::get_Views() 1331 { 1332 OSL_ENSURE(pInterface,"Interface is null!"); 1333 ADOViews* pRet = NULL; 1334 pInterface->get_Views(&pRet); 1335 WpADOViews aRet; 1336 aRet.setWithOutAddRef(pRet); 1337 return aRet; 1338 } 1339 1340 WpADOGroups WpADOCatalog::get_Groups() 1341 { 1342 OSL_ENSURE(pInterface,"Interface is null!"); 1343 ADOGroups* pRet = NULL; 1344 pInterface->get_Groups(&pRet); 1345 WpADOGroups aRet; 1346 aRet.setWithOutAddRef(pRet); 1347 return aRet; 1348 } 1349 1350 WpADOUsers WpADOCatalog::get_Users() 1351 { 1352 OSL_ENSURE(pInterface,"Interface is null!"); 1353 ADOUsers* pRet = NULL; 1354 pInterface->get_Users(&pRet); 1355 WpADOUsers aRet; 1356 aRet.setWithOutAddRef(pRet); 1357 return aRet; 1358 } 1359 1360 ADOProcedures* WpADOCatalog::get_Procedures() 1361 { 1362 OSL_ENSURE(pInterface,"Interface is null!"); 1363 ADOProcedures* pRet = NULL; 1364 pInterface->get_Procedures(&pRet); 1365 return pRet; 1366 } 1367 1368 ::rtl::OUString WpADOTable::get_Name() const 1369 { 1370 OSL_ENSURE(pInterface,"Interface is null!"); 1371 OLEString aBSTR; 1372 pInterface->get_Name(&aBSTR); 1373 return aBSTR; 1374 } 1375 1376 void WpADOTable::put_Name(const ::rtl::OUString& _rName) 1377 { 1378 OSL_ENSURE(pInterface,"Interface is null!"); 1379 OLEString bstr(_rName); 1380 sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr)); 1381 (void)bErg; 1382 } 1383 1384 ::rtl::OUString WpADOTable::get_Type() const 1385 { 1386 OSL_ENSURE(pInterface,"Interface is null!"); 1387 OLEString aBSTR; 1388 pInterface->get_Type(&aBSTR); 1389 return aBSTR; 1390 } 1391 1392 WpADOColumns WpADOTable::get_Columns() const 1393 { 1394 OSL_ENSURE(pInterface,"Interface is null!"); 1395 ADOColumns* pCols = NULL; 1396 pInterface->get_Columns(&pCols); 1397 WpADOColumns aCols; 1398 aCols.setWithOutAddRef(pCols); 1399 return aCols; 1400 } 1401 1402 WpADOIndexes WpADOTable::get_Indexes() const 1403 { 1404 OSL_ENSURE(pInterface,"Interface is null!"); 1405 ADOIndexes* pCols = NULL; 1406 pInterface->get_Indexes(&pCols); 1407 WpADOIndexes aRet; 1408 aRet.setWithOutAddRef(pCols); 1409 return aRet; 1410 } 1411 1412 WpADOKeys WpADOTable::get_Keys() const 1413 { 1414 OSL_ENSURE(pInterface,"Interface is null!"); 1415 ADOKeys* pCols = NULL; 1416 pInterface->get_Keys(&pCols); 1417 WpADOKeys aRet; 1418 aRet.setWithOutAddRef(pCols); 1419 return aRet; 1420 } 1421 1422 WpADOCatalog WpADOTable::get_ParentCatalog() const 1423 { 1424 OSL_ENSURE(pInterface,"Interface is null!"); 1425 ADOCatalog* pCat = NULL; 1426 pInterface->get_ParentCatalog(&pCat); 1427 WpADOCatalog aRet; 1428 aRet.setWithOutAddRef(pCat); 1429 return aRet; 1430 } 1431 1432 WpADOProperties WpADOTable::get_Properties() const 1433 { 1434 OSL_ENSURE(pInterface,"Interface is null!"); 1435 ADOProperties* pProps = NULL; 1436 pInterface->get_Properties(&pProps); 1437 WpADOProperties aProps; 1438 aProps.setWithOutAddRef(pProps); 1439 return aProps; 1440 } 1441 1442 ::rtl::OUString WpADOView::get_Name() const 1443 { 1444 OSL_ENSURE(pInterface,"Interface is null!"); 1445 OLEString aBSTR; 1446 pInterface->get_Name(&aBSTR); 1447 return aBSTR; 1448 } 1449 1450 void WpADOView::get_Command(OLEVariant& _rVar) const 1451 { 1452 OSL_ENSURE(pInterface,"Interface is null!"); 1453 pInterface->get_Command(&_rVar); 1454 } 1455 1456 void WpADOView::put_Command(OLEVariant& _rVar) 1457 { 1458 pInterface->put_Command(_rVar); 1459 } 1460 1461 ::rtl::OUString WpADOGroup::get_Name() const 1462 { 1463 OLEString aBSTR; 1464 pInterface->get_Name(&aBSTR); 1465 return aBSTR; 1466 } 1467 1468 void WpADOGroup::put_Name(const ::rtl::OUString& _rName) 1469 { 1470 OLEString bstr(_rName); 1471 sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr)); 1472 (void)bErg; 1473 } 1474 1475 RightsEnum WpADOGroup::GetPermissions( 1476 /* [in] */ const OLEVariant& Name, 1477 /* [in] */ ObjectTypeEnum ObjectType) 1478 { 1479 RightsEnum Rights=adRightNone; 1480 OLEVariant ObjectTypeId; 1481 ObjectTypeId.setNoArg(); 1482 pInterface->GetPermissions(Name,ObjectType,ObjectTypeId,&Rights); 1483 return Rights; 1484 } 1485 1486 sal_Bool WpADOGroup::SetPermissions( 1487 /* [in] */ const OLEVariant& Name, 1488 /* [in] */ ObjectTypeEnum ObjectType, 1489 /* [in] */ ActionEnum Action, 1490 /* [in] */ RightsEnum Rights) 1491 { 1492 OLEVariant ObjectTypeId; 1493 ObjectTypeId.setNoArg(); 1494 return SUCCEEDED(pInterface->SetPermissions(Name,ObjectType,Action,Rights,adInheritNone,ObjectTypeId)); 1495 } 1496 1497 WpADOUsers WpADOGroup::get_Users( ) 1498 { 1499 ADOUsers* pRet = NULL; 1500 pInterface->get_Users( &pRet); 1501 WpADOUsers aRet; 1502 aRet.setWithOutAddRef(pRet); 1503 return aRet; 1504 } 1505 1506 ::rtl::OUString WpADOUser::get_Name() const 1507 { 1508 OLEString aBSTR; 1509 pInterface->get_Name(&aBSTR); 1510 return aBSTR; 1511 } 1512 1513 void WpADOUser::put_Name(const ::rtl::OUString& _rName) 1514 { 1515 OLEString bstr(_rName); 1516 sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr)); 1517 (void)bErg; 1518 } 1519 1520 sal_Bool WpADOUser::ChangePassword(const ::rtl::OUString& _rPwd,const ::rtl::OUString& _rNewPwd) 1521 { 1522 OLEString sStr1(_rPwd); 1523 OLEString sStr2(_rNewPwd); 1524 sal_Bool bErg = SUCCEEDED(pInterface->ChangePassword(sStr1,sStr2)); 1525 return bErg; 1526 } 1527 1528 WpADOGroups WpADOUser::get_Groups() 1529 { 1530 ADOGroups* pRet = NULL; 1531 pInterface->get_Groups(&pRet); 1532 WpADOGroups aRet; 1533 aRet.setWithOutAddRef(pRet); 1534 return aRet; 1535 } 1536 1537 RightsEnum WpADOUser::GetPermissions( 1538 /* [in] */ const OLEVariant& Name, 1539 /* [in] */ ObjectTypeEnum ObjectType) 1540 { 1541 RightsEnum Rights=adRightNone; 1542 OLEVariant ObjectTypeId; 1543 ObjectTypeId.setNoArg(); 1544 pInterface->GetPermissions(Name,ObjectType,ObjectTypeId,&Rights); 1545 return Rights; 1546 } 1547 1548 sal_Bool WpADOUser::SetPermissions( 1549 /* [in] */ const OLEVariant& Name, 1550 /* [in] */ ObjectTypeEnum ObjectType, 1551 /* [in] */ ActionEnum Action, 1552 /* [in] */ RightsEnum Rights) 1553 { 1554 OLEVariant ObjectTypeId; 1555 ObjectTypeId.setNoArg(); 1556 return SUCCEEDED(pInterface->SetPermissions(Name,ObjectType,Action,Rights,adInheritNone,ObjectTypeId)); 1557 } 1558 1559 WpBase::WpBase() : pIUnknown(NULL) 1560 { 1561 } 1562 WpBase::WpBase(IDispatch* pInt) 1563 :pIUnknown(pInt) 1564 { 1565 if (pIUnknown) 1566 { 1567 ULONG nCount = pIUnknown->AddRef(); 1568 (void)nCount; 1569 // OSL_ENSURE(nCount == 1,"Count is greater than 1"); 1570 } 1571 } 1572 1573 //inline 1574 WpBase& WpBase::operator=(const WpBase& rhs) 1575 { 1576 if (rhs.pIUnknown != pIUnknown) 1577 { 1578 if (pIUnknown) 1579 pIUnknown->Release(); 1580 pIUnknown = rhs.pIUnknown; 1581 if (pIUnknown) 1582 pIUnknown->AddRef(); 1583 } 1584 return *this; 1585 }; 1586 1587 WpBase& WpBase::operator=(IDispatch* rhs) 1588 { 1589 if (pIUnknown != rhs) 1590 { 1591 if (pIUnknown) 1592 pIUnknown->Release(); 1593 pIUnknown = rhs; 1594 if (pIUnknown) 1595 pIUnknown->AddRef(); 1596 } 1597 return *this; 1598 } 1599 1600 WpBase::WpBase(const WpBase& aWrapper) 1601 { 1602 operator=(aWrapper); 1603 } 1604 1605 WpBase::~WpBase() 1606 { 1607 if (pIUnknown) 1608 { 1609 pIUnknown->Release(); 1610 pIUnknown = NULL; 1611 } 1612 } 1613 1614 void WpBase::clear() 1615 { 1616 if (pIUnknown) 1617 { 1618 pIUnknown->Release(); 1619 pIUnknown = NULL; 1620 } 1621 } 1622 1623 1624 sal_Bool WpBase::IsValid() const 1625 { 1626 return pIUnknown != NULL; 1627 } 1628 WpBase::operator IDispatch*() 1629 { 1630 return pIUnknown; 1631 } 1632 1633 ADORecordset* WpADOConnection::getExportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) 1634 { 1635 // Create elements used in the array 1636 HRESULT hr = S_OK; 1637 SAFEARRAYBOUND rgsabound[1]; 1638 SAFEARRAY *psa = NULL; 1639 OLEVariant varCriteria[6]; 1640 1641 // Create SafeArray Bounds and initialize the array 1642 rgsabound[0].lLbound = 0; 1643 rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; 1644 psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); 1645 1646 sal_Int32 nPos=0; 1647 if(catalog.hasValue()) 1648 varCriteria[nPos].setString(::comphelper::getString(catalog)); 1649 1650 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG 1651 if(schema.getLength() && schema.toChar() != '%') 1652 varCriteria[nPos].setString(schema); 1653 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA 1654 1655 varCriteria[nPos].setString(table); 1656 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME 1657 1658 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG 1659 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA 1660 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME 1661 1662 OLEVariant vtEmpty; 1663 vtEmpty.setNoArg(); 1664 1665 // Initialize and fill the SafeArray 1666 OLEVariant vsa; 1667 vsa.setArray(psa,VT_VARIANT); 1668 1669 ADORecordset *pRecordset = NULL; 1670 OpenSchema(adSchemaForeignKeys,vsa,vtEmpty,&pRecordset); 1671 return pRecordset; 1672 } 1673 // ----------------------------------------------------------------------------- 1674 ADORecordset* WpADOConnection::getImportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) 1675 { 1676 // Create elements used in the array 1677 HRESULT hr = S_OK; 1678 SAFEARRAYBOUND rgsabound[1]; 1679 SAFEARRAY *psa = NULL; 1680 OLEVariant varCriteria[6]; 1681 1682 // Create SafeArray Bounds and initialize the array 1683 rgsabound[0].lLbound = 0; 1684 rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; 1685 psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); 1686 1687 sal_Int32 nPos=0; 1688 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG 1689 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA 1690 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME 1691 1692 if(catalog.hasValue()) 1693 varCriteria[nPos].setString(::comphelper::getString(catalog)); 1694 1695 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG 1696 if(schema.getLength() && schema.toChar() != '%') 1697 varCriteria[nPos].setString(schema); 1698 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA 1699 1700 varCriteria[nPos].setString(table); 1701 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME 1702 1703 OLEVariant vtEmpty; 1704 vtEmpty.setNoArg(); 1705 1706 // Initialize and fill the SafeArray 1707 OLEVariant vsa; 1708 vsa.setArray(psa,VT_VARIANT); 1709 1710 ADORecordset *pRecordset = NULL; 1711 OpenSchema(adSchemaForeignKeys,vsa,vtEmpty,&pRecordset); 1712 1713 return pRecordset; 1714 1715 } 1716 // ----------------------------------------------------------------------------- 1717 ADORecordset* WpADOConnection::getPrimaryKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) 1718 { 1719 // Create elements used in the array 1720 HRESULT hr = S_OK; 1721 SAFEARRAYBOUND rgsabound[1]; 1722 SAFEARRAY *psa = NULL; 1723 OLEVariant varCriteria[3]; 1724 1725 // Create SafeArray Bounds and initialize the array 1726 rgsabound[0].lLbound = 0; 1727 rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; 1728 psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); 1729 1730 sal_Int32 nPos=0; 1731 if(catalog.hasValue()) 1732 varCriteria[nPos].setString(::comphelper::getString(catalog)); 1733 1734 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG 1735 if(schema.getLength() && schema.toChar() != '%') 1736 varCriteria[nPos].setString(schema); 1737 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA 1738 1739 varCriteria[nPos].setString(table); 1740 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME 1741 1742 1743 OLEVariant vtEmpty; 1744 vtEmpty.setNoArg(); 1745 1746 // Initialize and fill the SafeArray 1747 OLEVariant vsa; 1748 vsa.setArray(psa,VT_VARIANT); 1749 1750 ADORecordset *pRecordset = NULL; 1751 OpenSchema(adSchemaPrimaryKeys,vsa,vtEmpty,&pRecordset); 1752 1753 return pRecordset; 1754 } 1755 // ----------------------------------------------------------------------------- 1756 ADORecordset* WpADOConnection::getIndexInfo( 1757 const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, 1758 sal_Bool /*unique*/, sal_Bool /*approximate*/ ) 1759 { 1760 // Create elements used in the array 1761 HRESULT hr = S_OK; 1762 SAFEARRAYBOUND rgsabound[1]; 1763 SAFEARRAY *psa = NULL; 1764 OLEVariant varCriteria[5]; 1765 1766 // Create SafeArray Bounds and initialize the array 1767 rgsabound[0].lLbound = 0; 1768 rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; 1769 psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); 1770 1771 sal_Int32 nPos=0; 1772 if(catalog.hasValue()) 1773 varCriteria[nPos].setString(::comphelper::getString(catalog)); 1774 1775 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG 1776 if(schema.getLength() && schema.toChar() != '%') 1777 varCriteria[nPos].setString(schema); 1778 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA 1779 1780 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// INDEX_NAME 1781 1782 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TYPE 1783 1784 varCriteria[nPos].setString(table); 1785 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME 1786 1787 OLEVariant vtEmpty; 1788 vtEmpty.setNoArg(); 1789 1790 // Initialize and fill the SafeArray 1791 OLEVariant vsa; 1792 vsa.setArray(psa,VT_VARIANT); 1793 1794 ADORecordset *pRecordset = NULL; 1795 OpenSchema(adSchemaIndexes,vsa,vtEmpty,&pRecordset); 1796 1797 return pRecordset; 1798 } 1799 // ----------------------------------------------------------------------------- 1800 ADORecordset* WpADOConnection::getTablePrivileges( const ::com::sun::star::uno::Any& catalog, 1801 const ::rtl::OUString& schemaPattern, 1802 const ::rtl::OUString& tableNamePattern ) 1803 { 1804 HRESULT hr = S_OK; 1805 SAFEARRAYBOUND rgsabound[1]; 1806 SAFEARRAY *psa = NULL; 1807 OLEVariant varCriteria[5]; 1808 1809 // Create SafeArray Bounds and initialize the array 1810 rgsabound[0].lLbound = 0; 1811 rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; 1812 psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); 1813 1814 sal_Int32 nPos=0; 1815 if(catalog.hasValue()) 1816 varCriteria[nPos].setString(::comphelper::getString(catalog)); 1817 1818 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG 1819 if(schemaPattern.getLength() && schemaPattern.toChar() != '%') 1820 varCriteria[nPos].setString(schemaPattern); 1821 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA 1822 1823 if(tableNamePattern.toChar() != '%') 1824 varCriteria[nPos].setString(tableNamePattern); 1825 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME 1826 1827 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// GRANTOR 1828 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// GRANTEE 1829 1830 OLEVariant vtEmpty; 1831 vtEmpty.setNoArg(); 1832 1833 // Initialize and fill the SafeArray 1834 OLEVariant vsa; 1835 vsa.setArray(psa,VT_VARIANT); 1836 1837 ADORecordset *pRecordset = NULL; 1838 OpenSchema(adSchemaTablePrivileges,vsa,vtEmpty,&pRecordset); 1839 1840 return pRecordset; 1841 } 1842 // ----------------------------------------------------------------------------- 1843 ADORecordset* WpADOConnection::getCrossReference( const ::com::sun::star::uno::Any& primaryCatalog, 1844 const ::rtl::OUString& primarySchema, 1845 const ::rtl::OUString& primaryTable, 1846 const ::com::sun::star::uno::Any& foreignCatalog, 1847 const ::rtl::OUString& foreignSchema, 1848 const ::rtl::OUString& foreignTable) 1849 { 1850 // Create elements used in the array 1851 HRESULT hr = S_OK; 1852 SAFEARRAYBOUND rgsabound[1]; 1853 SAFEARRAY *psa = NULL; 1854 OLEVariant varCriteria[6]; 1855 1856 // Create SafeArray Bounds and initialize the array 1857 rgsabound[0].lLbound = 0; 1858 rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; 1859 psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); 1860 1861 sal_Int32 nPos=0; 1862 if(primaryCatalog.hasValue()) 1863 varCriteria[nPos].setString(::comphelper::getString(primaryCatalog)); 1864 1865 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG 1866 if(primarySchema.getLength() && primarySchema.toChar() != '%') 1867 varCriteria[nPos].setString(primarySchema); 1868 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA 1869 1870 varCriteria[nPos].setString(primaryTable); 1871 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME 1872 1873 if(foreignCatalog.hasValue()) 1874 varCriteria[nPos].setString(::comphelper::getString(foreignCatalog)); 1875 1876 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG 1877 if(foreignSchema.getLength() && foreignSchema.toChar() != '%') 1878 varCriteria[nPos].setString(foreignSchema); 1879 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA 1880 1881 varCriteria[nPos].setString(foreignTable); 1882 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME 1883 1884 OLEVariant vtEmpty; 1885 vtEmpty.setNoArg(); 1886 1887 // Initialize and fill the SafeArray 1888 OLEVariant vsa; 1889 vsa.setArray(psa,VT_VARIANT); 1890 1891 ADORecordset *pRecordset = NULL; 1892 OpenSchema(adSchemaForeignKeys,vsa,vtEmpty,&pRecordset); 1893 1894 return pRecordset; 1895 } 1896 // ----------------------------------------------------------------------------- 1897 ADORecordset* WpADOConnection::getProcedures( const ::com::sun::star::uno::Any& catalog, 1898 const ::rtl::OUString& schemaPattern, 1899 const ::rtl::OUString& procedureNamePattern ) 1900 { 1901 HRESULT hr = S_OK; 1902 SAFEARRAYBOUND rgsabound[1]; 1903 SAFEARRAY *psa = NULL; 1904 OLEVariant varCriteria[3]; 1905 1906 // Create SafeArray Bounds and initialize the array 1907 rgsabound[0].lLbound = 0; 1908 rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; 1909 psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); 1910 1911 sal_Int32 nPos=0; 1912 if(catalog.hasValue()) 1913 varCriteria[nPos].setString(::comphelper::getString(catalog)); 1914 1915 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG 1916 if(schemaPattern.getLength() && schemaPattern.toChar() != '%') 1917 varCriteria[nPos].setString(schemaPattern); 1918 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA 1919 1920 if(procedureNamePattern.toChar() != '%') 1921 varCriteria[nPos].setString(procedureNamePattern); 1922 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME 1923 1924 OLEVariant vtEmpty; 1925 vtEmpty.setNoArg(); 1926 1927 // Initialize and fill the SafeArray 1928 OLEVariant vsa; 1929 vsa.setArray(psa,VT_VARIANT); 1930 1931 ADORecordset *pRecordset = NULL; 1932 OpenSchema(adSchemaProcedures,vsa,vtEmpty,&pRecordset); 1933 1934 return pRecordset; 1935 } 1936 // ----------------------------------------------------------------------------- 1937 ADORecordset* WpADOConnection::getProcedureColumns( const ::com::sun::star::uno::Any& catalog, 1938 const ::rtl::OUString& schemaPattern, 1939 const ::rtl::OUString& procedureNamePattern, 1940 const ::rtl::OUString& columnNamePattern ) 1941 { 1942 // Create elements used in the array 1943 HRESULT hr = S_OK; 1944 SAFEARRAYBOUND rgsabound[1]; 1945 SAFEARRAY *psa = NULL; 1946 OLEVariant varCriteria[4]; 1947 1948 // Create SafeArray Bounds and initialize the array 1949 rgsabound[0].lLbound = 0; 1950 rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; 1951 psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); 1952 1953 sal_Int32 nPos=0; 1954 if(catalog.hasValue()) 1955 varCriteria[nPos].setString(::comphelper::getString(catalog)); 1956 1957 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG 1958 if(schemaPattern.getLength() && schemaPattern.toChar() != '%') 1959 varCriteria[nPos].setString(schemaPattern); 1960 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA 1961 1962 if(procedureNamePattern.toChar() != '%') 1963 varCriteria[nPos].setString(procedureNamePattern); 1964 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME 1965 1966 if(columnNamePattern.toChar() != '%') 1967 varCriteria[nPos].setString(columnNamePattern); 1968 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// COLUMN_NAME 1969 1970 OLEVariant vtEmpty; 1971 vtEmpty.setNoArg(); 1972 1973 // Initialize and fill the SafeArray 1974 OLEVariant vsa; 1975 vsa.setArray(psa,VT_VARIANT); 1976 1977 ADORecordset *pRecordset = NULL; 1978 OpenSchema(adSchemaProcedureParameters,vsa,vtEmpty,&pRecordset); 1979 1980 return pRecordset; 1981 } 1982 // ----------------------------------------------------------------------------- 1983 ADORecordset* WpADOConnection::getTables( const ::com::sun::star::uno::Any& catalog, 1984 const ::rtl::OUString& schemaPattern, 1985 const ::rtl::OUString& tableNamePattern, 1986 const ::com::sun::star::uno::Sequence< ::rtl::OUString >& types ) 1987 { 1988 // Create elements used in the array 1989 HRESULT hr = S_OK; 1990 OLEVariant varCriteria[4]; 1991 1992 sal_Int32 nPos=0; 1993 ::rtl::OUString sCatalog; 1994 if ( catalog.hasValue() && (catalog >>= sCatalog) ) 1995 varCriteria[nPos].setString(sCatalog); 1996 1997 ++nPos; 1998 if(schemaPattern.getLength() && schemaPattern.toChar() != '%') 1999 varCriteria[nPos].setString(schemaPattern); 2000 2001 ++nPos; 2002 if(tableNamePattern.toChar() != '%') 2003 varCriteria[nPos].setString(tableNamePattern); 2004 2005 ++nPos; 2006 ::rtl::OUStringBuffer aTypes; 2007 ::rtl::OUString aComma = ::rtl::OUString::createFromAscii(","); 2008 const ::rtl::OUString* pIter = types.getConstArray(); 2009 const ::rtl::OUString* pEnd = pIter + types.getLength(); 2010 for( ; pIter != pEnd ; ++pIter) 2011 { 2012 if ( aTypes.getLength() ) 2013 aTypes.append(aComma); 2014 aTypes.append(*pIter); 2015 } 2016 2017 ::rtl::OUString sTypeNames = aTypes.makeStringAndClear(); 2018 if ( sTypeNames.getLength() ) 2019 varCriteria[nPos].setString(sTypeNames); 2020 2021 // Create SafeArray Bounds and initialize the array 2022 const sal_Int32 nCrit = sizeof varCriteria / sizeof varCriteria[0]; 2023 SAFEARRAYBOUND rgsabound[1]; 2024 rgsabound[0].lLbound = 0; 2025 rgsabound[0].cElements = nCrit; 2026 SAFEARRAY *psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); 2027 2028 // Set the values for each element of the array 2029 for( long i = 0 ; i < nCrit && SUCCEEDED( hr );i++) 2030 { 2031 hr = SafeArrayPutElement(psa, &i,&varCriteria[i]); 2032 } 2033 2034 OLEVariant vtEmpty; 2035 vtEmpty.setNoArg(); 2036 2037 // Initialize and fill the SafeArray 2038 OLEVariant vsa; 2039 vsa.setArray(psa,VT_VARIANT); 2040 2041 ADORecordset *pRecordset = NULL; 2042 OpenSchema(adSchemaTables,vsa,vtEmpty,&pRecordset); 2043 2044 return pRecordset; 2045 } 2046 // ----------------------------------------------------------------------------- 2047 ADORecordset* WpADOConnection::getColumns( const ::com::sun::star::uno::Any& catalog, 2048 const ::rtl::OUString& schemaPattern, 2049 const ::rtl::OUString& tableNamePattern, 2050 const ::rtl::OUString& columnNamePattern ) 2051 { 2052 // Create elements used in the array 2053 HRESULT hr = S_OK; 2054 SAFEARRAYBOUND rgsabound[1]; 2055 SAFEARRAY *psa = NULL; 2056 OLEVariant varCriteria[4]; 2057 2058 // Create SafeArray Bounds and initialize the array 2059 rgsabound[0].lLbound = 0; 2060 rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; 2061 psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); 2062 2063 sal_Int32 nPos=0; 2064 if(catalog.hasValue()) 2065 varCriteria[nPos].setString(::comphelper::getString(catalog)); 2066 2067 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG 2068 if(schemaPattern.getLength() && schemaPattern.toChar() != '%') 2069 varCriteria[nPos].setString(schemaPattern); 2070 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA 2071 2072 if(tableNamePattern.toChar() != '%') 2073 varCriteria[nPos].setString(tableNamePattern); 2074 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME 2075 2076 varCriteria[nPos].setString(columnNamePattern); 2077 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// COLUMN_NAME 2078 2079 OLEVariant vtEmpty; 2080 vtEmpty.setNoArg(); 2081 2082 // Initialize and fill the SafeArray 2083 OLEVariant vsa; 2084 vsa.setArray(psa,VT_VARIANT); 2085 2086 ADORecordset *pRecordset = NULL; 2087 OpenSchema(adSchemaColumns,vsa,vtEmpty,&pRecordset); 2088 2089 return pRecordset; 2090 } 2091 // ----------------------------------------------------------------------------- 2092 ADORecordset* WpADOConnection::getColumnPrivileges( const ::com::sun::star::uno::Any& catalog, 2093 const ::rtl::OUString& schema, 2094 const ::rtl::OUString& table, 2095 const ::rtl::OUString& columnNamePattern ) 2096 { 2097 // Create elements used in the array 2098 HRESULT hr = S_OK; 2099 SAFEARRAYBOUND rgsabound[1]; 2100 SAFEARRAY *psa = NULL; 2101 OLEVariant varCriteria[4]; 2102 2103 // Create SafeArray Bounds and initialize the array 2104 rgsabound[0].lLbound = 0; 2105 rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; 2106 psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); 2107 2108 sal_Int32 nPos=0; 2109 if(catalog.hasValue()) 2110 varCriteria[nPos].setString(::comphelper::getString(catalog)); 2111 2112 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG 2113 if(schema.getLength() && schema.toChar() != '%') 2114 varCriteria[nPos].setString(schema); 2115 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA 2116 2117 varCriteria[nPos].setString(table); 2118 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME 2119 2120 varCriteria[nPos].setString(columnNamePattern); 2121 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// COLUMN_NAME 2122 2123 OLEVariant vtEmpty; 2124 vtEmpty.setNoArg(); 2125 2126 // Initialize and fill the SafeArray 2127 OLEVariant vsa; 2128 vsa.setArray(psa,VT_VARIANT); 2129 2130 ADORecordset *pRecordset = NULL; 2131 OpenSchema(adSchemaColumnPrivileges,vsa,vtEmpty,&pRecordset); 2132 2133 return pRecordset; 2134 } 2135 // ----------------------------------------------------------------------------- 2136 ADORecordset* WpADOConnection::getTypeInfo(DataTypeEnum /*_eType*/) 2137 { 2138 // Create elements used in the array 2139 OLEVariant varCriteria[2]; 2140 const int nCrit = sizeof varCriteria / sizeof varCriteria[0]; 2141 // Create SafeArray Bounds and initialize the array 2142 SAFEARRAYBOUND rgsabound[1]; 2143 rgsabound[0].lLbound = 0; 2144 rgsabound[0].cElements = nCrit; 2145 SAFEARRAY *psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); 2146 2147 sal_Int32 nPos = 0; 2148 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++; 2149 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++; 2150 2151 // Initialize and fill the SafeArray 2152 OLEVariant vsa; 2153 vsa.setArray(psa,VT_VARIANT); 2154 2155 OLEVariant aEmpty; 2156 aEmpty.setNoArg(); 2157 2158 ADORecordset *pRec=NULL; 2159 OpenSchema(adSchemaProviderTypes,vsa,aEmpty,&pRec); 2160 2161 return pRec; 2162 } 2163 // ----------------------------------------------------------------------------- 2164 void WpADOColumn::put_ParentCatalog(/* [in] */ _ADOCatalog __RPC_FAR *ppvObject) 2165 { 2166 OSL_ENSURE(pInterface,"Interface is null!"); 2167 sal_Bool bRet = SUCCEEDED(pInterface->put_ParentCatalog(ppvObject)); 2168 OSL_ENSURE(bRet,"Could not set ParentCatalog!"); 2169 OSL_UNUSED(bRet); 2170 } 2171 // ----------------------------------------------------------------------------- 2172 void WpADOTable::putref_ParentCatalog(/* [in] */ _ADOCatalog __RPC_FAR *ppvObject) 2173 { 2174 OSL_ENSURE(pInterface,"Interface is null!"); 2175 sal_Bool bRet = SUCCEEDED(pInterface->putref_ParentCatalog(ppvObject)); 2176 OSL_ENSURE(bRet,"Could not set ParentCatalog!"); 2177 OSL_UNUSED(bRet); 2178 } 2179 // ----------------------------------------------------------------------------- 2180 void WpBase::setIDispatch(IDispatch* _pIUnknown) 2181 { 2182 pIUnknown = _pIUnknown; 2183 } 2184 // ----------------------------------------------------------------------------- 2185 void OTools::putValue(const WpADOProperties& _rProps,const OLEVariant &_aPosition,const OLEVariant &_aValVar) 2186 { 2187 OSL_ENSURE(_rProps.IsValid(),"Properties are not valid!"); 2188 WpADOProperty aProp(_rProps.GetItem(_aPosition)); 2189 if ( aProp.IsValid() ) 2190 { 2191 sal_Bool bRet = aProp.PutValue(_aValVar); 2192 OSL_ENSURE(bRet,"Could not put value!"); 2193 OSL_UNUSED(bRet); 2194 } 2195 } 2196 // ----------------------------------------------------------------------------- 2197 OLEVariant OTools::getValue(const WpADOProperties& _rProps,const OLEVariant &_aPosition) 2198 { 2199 WpADOProperty aProp(_rProps.GetItem(_aPosition)); 2200 return aProp.GetValue(); 2201 } 2202