Update ooo320-m1
[ooovba.git] / connectivity / source / drivers / ado / Awrapado.cxx
blob155e4a0fed79ac2eecab4258f7cce5f661aeec47
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: Awrapado.cxx,v $
10 * $Revision: 1.20 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_connectivity.hxx"
33 #include "ado/Awrapado.hxx"
34 #include "ado/Awrapadox.hxx"
35 #include <comphelper/types.hxx>
36 #include <rtl/ustrbuf.hxx>
37 #include "diagnose_ex.h"
39 namespace connectivity
41 namespace ado
43 sal_Int32 nAdoObjectCounter = 0;
47 using namespace connectivity::ado;
49 void WpADOCatalog::Create()
51 HRESULT hr = -1;
52 _ADOCatalog* pCommand;
53 hr = CoCreateInstance(ADOS::CLSID_ADOCATALOG_25,
54 NULL,
55 CLSCTX_INPROC_SERVER,
56 ADOS::IID_ADOCATALOG_25,
57 (void**)&pCommand );
60 if( !FAILED( hr ) )
61 setWithOutAddRef(pCommand);
65 WpADOProperties WpADOConnection::get_Properties() const
67 ADOProperties* pProps=NULL;
68 pInterface->get_Properties(&pProps);
69 WpADOProperties aProps;
70 aProps.setWithOutAddRef(pProps);
71 return aProps;
74 rtl::OUString WpADOConnection::GetConnectionString() const
76 OSL_ENSURE(pInterface,"Interface is null!");
77 OLEString aBSTR;
78 pInterface->get_ConnectionString(&aBSTR);
79 return aBSTR;
82 sal_Bool WpADOConnection::PutConnectionString(const ::rtl::OUString &aCon) const
84 OSL_ENSURE(pInterface,"Interface is null!");
85 OLEString bstr(aCon);
86 sal_Bool bErg = SUCCEEDED(pInterface->put_ConnectionString(bstr));
88 return bErg;
91 sal_Int32 WpADOConnection::GetCommandTimeout() const
93 OSL_ENSURE(pInterface,"Interface is null!");
94 sal_Int32 nRet=0;
95 pInterface->get_CommandTimeout(&nRet);
96 return nRet;
99 void WpADOConnection::PutCommandTimeout(sal_Int32 nRet)
101 OSL_ENSURE(pInterface,"Interface is null!");
102 pInterface->put_CommandTimeout(nRet);
105 sal_Int32 WpADOConnection::GetConnectionTimeout() const
107 OSL_ENSURE(pInterface,"Interface is null!");
108 sal_Int32 nRet=0;
109 pInterface->get_ConnectionTimeout(&nRet);
110 return nRet;
113 void WpADOConnection::PutConnectionTimeout(sal_Int32 nRet)
115 OSL_ENSURE(pInterface,"Interface is null!");
116 pInterface->put_ConnectionTimeout(nRet);
119 sal_Bool WpADOConnection::Close( )
121 OSL_ENSURE(pInterface,"Interface is null!");
122 return (SUCCEEDED(pInterface->Close()));
125 sal_Bool WpADOConnection::Execute(const ::rtl::OUString& _CommandText,OLEVariant& RecordsAffected,long Options, WpADORecordset** ppiRset)
127 OSL_ENSURE(pInterface,"Interface is null!");
128 OLEString sStr1(_CommandText);
129 sal_Bool bErg = SUCCEEDED(pInterface->Execute(sStr1,&RecordsAffected,Options,(_ADORecordset**)ppiRset));
130 return bErg;
133 sal_Bool WpADOConnection::BeginTrans()
135 OSL_ENSURE(pInterface,"Interface is null!");
136 sal_Int32 nIso=0;
137 return SUCCEEDED(pInterface->BeginTrans(&nIso));
140 sal_Bool WpADOConnection::CommitTrans( )
142 OSL_ENSURE(pInterface,"Interface is null!");
143 return SUCCEEDED(pInterface->CommitTrans());
146 sal_Bool WpADOConnection::RollbackTrans( )
148 OSL_ENSURE(pInterface,"Interface is null!");
149 return SUCCEEDED(pInterface->RollbackTrans());
152 sal_Bool WpADOConnection::Open(const ::rtl::OUString& ConnectionString, const ::rtl::OUString& UserID,const ::rtl::OUString& Password,long Options)
154 OSL_ENSURE(pInterface,"Interface is null!");
155 OLEString sStr1(ConnectionString);
156 OLEString sStr2(UserID);
157 OLEString sStr3(Password);
158 sal_Bool bErg = SUCCEEDED(pInterface->Open(sStr1,sStr2,sStr3,Options));
159 return bErg;
162 sal_Bool WpADOConnection::GetErrors(ADOErrors** pErrors)
164 OSL_ENSURE(pInterface,"Interface is null!");
165 return SUCCEEDED(pInterface->get_Errors(pErrors));
168 ::rtl::OUString WpADOConnection::GetDefaultDatabase() const
170 OSL_ENSURE(pInterface,"Interface is null!");
171 OLEString aBSTR; pInterface->get_DefaultDatabase(&aBSTR);
172 return aBSTR;
175 sal_Bool WpADOConnection::PutDefaultDatabase(const ::rtl::OUString& _bstr)
177 OSL_ENSURE(pInterface,"Interface is null!");
178 OLEString bstr(_bstr);
179 sal_Bool bErg = SUCCEEDED(pInterface->put_DefaultDatabase(bstr));
181 return bErg;
184 IsolationLevelEnum WpADOConnection::get_IsolationLevel() const
186 OSL_ENSURE(pInterface,"Interface is null!");
187 IsolationLevelEnum eNum=adXactUnspecified;
188 pInterface->get_IsolationLevel(&eNum);
189 return eNum;
192 sal_Bool WpADOConnection::put_IsolationLevel(const IsolationLevelEnum& eNum)
194 OSL_ENSURE(pInterface,"Interface is null!");
195 return SUCCEEDED(pInterface->put_IsolationLevel(eNum));
198 sal_Int32 WpADOConnection::get_Attributes() const
200 OSL_ENSURE(pInterface,"Interface is null!");
201 sal_Int32 nRet=0;
202 pInterface->get_Attributes(&nRet);
203 return nRet;
206 sal_Bool WpADOConnection::put_Attributes(sal_Int32 nRet)
208 OSL_ENSURE(pInterface,"Interface is null!");
209 return SUCCEEDED(pInterface->put_Attributes(nRet));
212 CursorLocationEnum WpADOConnection::get_CursorLocation() const
214 OSL_ENSURE(pInterface,"Interface is null!");
215 CursorLocationEnum eNum=adUseNone;
216 pInterface->get_CursorLocation(&eNum);
217 return eNum;
220 sal_Bool WpADOConnection::put_CursorLocation(const CursorLocationEnum &eNum)
222 OSL_ENSURE(pInterface,"Interface is null!");
223 return SUCCEEDED(pInterface->put_CursorLocation(eNum));
226 ConnectModeEnum WpADOConnection::get_Mode() const
228 OSL_ENSURE(pInterface,"Interface is null!");
229 ConnectModeEnum eNum=adModeUnknown;
230 pInterface->get_Mode(&eNum);
231 return eNum;
234 sal_Bool WpADOConnection::put_Mode(const ConnectModeEnum &eNum)
236 OSL_ENSURE(pInterface,"Interface is null!");
237 return SUCCEEDED(pInterface->put_Mode(eNum));
240 ::rtl::OUString WpADOConnection::get_Provider() const
242 OSL_ENSURE(pInterface,"Interface is null!");
243 OLEString aBSTR; pInterface->get_Provider(&aBSTR);
244 return aBSTR;
247 sal_Bool WpADOConnection::put_Provider(const ::rtl::OUString& _bstr)
249 OSL_ENSURE(pInterface,"Interface is null!");
250 OLEString bstr(_bstr);
251 return SUCCEEDED(pInterface->put_Provider(bstr));
254 sal_Int32 WpADOConnection::get_State() const
256 OSL_ENSURE(pInterface,"Interface is null!");
257 sal_Int32 nRet=0;
258 pInterface->get_State(&nRet);
259 return nRet;
262 sal_Bool WpADOConnection::OpenSchema(SchemaEnum eNum,OLEVariant& Restrictions,OLEVariant& SchemaID,ADORecordset**pprset)
264 OSL_ENSURE(pInterface,"Interface is null!");
265 return SUCCEEDED(pInterface->OpenSchema(eNum,Restrictions,SchemaID,pprset));
268 ::rtl::OUString WpADOConnection::get_Version() const
270 OSL_ENSURE(pInterface,"Interface is null!");
271 OLEString aBSTR;
272 pInterface->get_Version(&aBSTR);
273 return aBSTR;
276 sal_Bool WpADOCommand::putref_ActiveConnection( WpADOConnection *pCon)
278 OSL_ENSURE(pInterface,"Interface is null!");
279 if(pCon)
280 return SUCCEEDED(pInterface->putref_ActiveConnection(pCon->pInterface));
281 else
282 return SUCCEEDED(pInterface->putref_ActiveConnection(NULL));
285 void WpADOCommand::put_ActiveConnection(/* [in] */ const OLEVariant& vConn)
287 OSL_ENSURE(pInterface,"Interface is null!");
288 pInterface->put_ActiveConnection(vConn);
291 void WpADOCommand::Create()
293 IClassFactory2* pInterface2 = NULL;
294 IUnknown *pOuter = NULL;
295 HRESULT hr;
296 hr = CoGetClassObject( ADOS::CLSID_ADOCOMMAND_21,
297 CLSCTX_INPROC_SERVER,
298 NULL,
299 IID_IClassFactory2,
300 (void**)&pInterface2 );
302 if( !FAILED( hr ) )
304 ADOCommand* pCommand=NULL;
306 hr = pInterface2->CreateInstanceLic( pOuter,
307 NULL,
308 ADOS::IID_ADOCOMMAND_21,
309 ADOS::GetKeyStr(),
310 (void**) &pCommand);
312 if( !FAILED( hr ) )
314 operator=(pCommand);
315 pCommand->Release();
318 pInterface2->Release();
322 sal_Int32 WpADOCommand::get_State() const
324 OSL_ENSURE(pInterface,"Interface is null!");
325 sal_Int32 nRet=0;
326 pInterface->get_State(&nRet);
327 return nRet;
330 ::rtl::OUString WpADOCommand::get_CommandText() const
332 OSL_ENSURE(pInterface,"Interface is null!");
333 OLEString aBSTR;
334 pInterface->get_CommandText(&aBSTR);
335 return aBSTR;
338 sal_Bool WpADOCommand::put_CommandText(const ::rtl::OUString &aCon)
340 OSL_ENSURE(pInterface,"Interface is null!");
341 OLEString bstr(aCon);
342 sal_Bool bErg = SUCCEEDED(pInterface->put_CommandText(bstr));
344 return bErg;
347 sal_Int32 WpADOCommand::get_CommandTimeout() const
349 OSL_ENSURE(pInterface,"Interface is null!");
350 sal_Int32 nRet=0;
351 pInterface->get_CommandTimeout(&nRet);
352 return nRet;
355 void WpADOCommand::put_CommandTimeout(sal_Int32 nRet)
357 OSL_ENSURE(pInterface,"Interface is null!");
358 pInterface->put_CommandTimeout(nRet);
361 sal_Bool WpADOCommand::get_Prepared() const
363 OSL_ENSURE(pInterface,"Interface is null!");
364 VARIANT_BOOL bPrepared = VARIANT_FALSE;
365 pInterface->get_Prepared(&bPrepared);
366 return bPrepared == VARIANT_TRUE;
369 sal_Bool WpADOCommand::put_Prepared(VARIANT_BOOL bPrepared) const
371 OSL_ENSURE(pInterface,"Interface is null!");
372 return SUCCEEDED(pInterface->put_Prepared(bPrepared));
375 sal_Bool WpADOCommand::Execute(OLEVariant& RecordsAffected,OLEVariant& Parameters,long Options, ADORecordset** ppiRset)
377 OSL_ENSURE(pInterface,"Interface is null!");
378 return SUCCEEDED(pInterface->Execute(&RecordsAffected,&Parameters,Options,ppiRset));
381 ADOParameter* WpADOCommand::CreateParameter(const ::rtl::OUString &_bstr,DataTypeEnum Type,ParameterDirectionEnum Direction,long nSize,const OLEVariant &Value)
383 OSL_ENSURE(pInterface,"Interface is null!");
384 ADOParameter* pPara = NULL;
385 OLEString bstr(_bstr);
386 sal_Bool bErg = SUCCEEDED(pInterface->CreateParameter(bstr,Type,Direction,nSize,Value,&pPara));
388 return bErg ? pPara : NULL;
391 ADOParameters* WpADOCommand::get_Parameters() const
393 OSL_ENSURE(pInterface,"Interface is null!");
394 ADOParameters* pPara=NULL;
395 pInterface->get_Parameters(&pPara);
396 return pPara;
399 sal_Bool WpADOCommand::put_CommandType( /* [in] */ CommandTypeEnum lCmdType)
401 OSL_ENSURE(pInterface,"Interface is null!");
402 return SUCCEEDED(pInterface->put_CommandType(lCmdType));
405 CommandTypeEnum WpADOCommand::get_CommandType( ) const
407 OSL_ENSURE(pInterface,"Interface is null!");
408 CommandTypeEnum eNum=adCmdUnspecified;
409 pInterface->get_CommandType(&eNum);
410 return eNum;
413 // gibt den Namen des Feldes zur"ueck
414 ::rtl::OUString WpADOCommand::GetName() const
416 OSL_ENSURE(pInterface,"Interface is null!");
417 OLEString aBSTR;
418 pInterface->get_Name(&aBSTR);
419 return aBSTR;
422 sal_Bool WpADOCommand::put_Name(const ::rtl::OUString& _Name)
424 OSL_ENSURE(pInterface,"Interface is null!");
425 OLEString bstr(_Name);
426 sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr));
428 return bErg;
430 sal_Bool WpADOCommand::Cancel()
432 OSL_ENSURE(pInterface,"Interface is null!");
433 return SUCCEEDED(pInterface->Cancel());
436 ::rtl::OUString WpADOError::GetDescription() const
438 OSL_ENSURE(pInterface,"Interface is null!");
439 OLEString aBSTR;
440 pInterface->get_Description(&aBSTR);
441 return aBSTR;
444 ::rtl::OUString WpADOError::GetSource() const
446 OSL_ENSURE(pInterface,"Interface is null!");
447 OLEString aBSTR;
448 pInterface->get_Source(&aBSTR);
449 return aBSTR;
452 sal_Int32 WpADOError::GetNumber() const
454 OSL_ENSURE(pInterface,"Interface is null!");
455 sal_Int32 nErrNr=0;
456 pInterface->get_Number(&nErrNr);
457 return nErrNr;
460 ::rtl::OUString WpADOError::GetSQLState() const
462 OSL_ENSURE(pInterface,"Interface is null!");
463 OLEString aBSTR;
464 pInterface->get_SQLState(&aBSTR);
465 return aBSTR;
468 sal_Int32 WpADOError::GetNativeError() const
470 OSL_ENSURE(pInterface,"Interface is null!");
471 sal_Int32 nErrNr=0;
472 pInterface->get_NativeError(&nErrNr);
473 return nErrNr;
475 WpADOProperties WpADOField::get_Properties()
477 OSL_ENSURE(pInterface,"Interface is null!");
478 ADOProperties* pProps = NULL;
479 pInterface->get_Properties(&pProps);
480 WpADOProperties aProps;
482 aProps.setWithOutAddRef(pProps);
483 return aProps;
486 sal_Int32 WpADOField::GetActualSize() const
488 OSL_ENSURE(pInterface,"Interface is null!");
489 sal_Int32 nActualSize=0;
490 pInterface->get_ActualSize(&nActualSize);
491 return nActualSize;
494 sal_Int32 WpADOField::GetAttributes() const
496 OSL_ENSURE(pInterface,"Interface is null!");
497 sal_Int32 eADOSFieldAttributes=0;
498 pInterface->get_Attributes(&eADOSFieldAttributes);
499 return eADOSFieldAttributes;
502 sal_Int32 WpADOField::GetStatus() const
504 OSL_ENSURE(pInterface,"Interface is null!");
505 sal_Int32 eADOSFieldAttributes=0;
506 // pInterface->get_Status(&eADOSFieldAttributes);
507 return eADOSFieldAttributes;
510 sal_Int32 WpADOField::GetDefinedSize() const
512 OSL_ENSURE(pInterface,"Interface is null!");
513 sal_Int32 nDefinedSize=0;
514 pInterface->get_DefinedSize(&nDefinedSize);
515 return nDefinedSize;
518 // gibt den Namen des Feldes zur"ueck
519 ::rtl::OUString WpADOField::GetName() const
521 OSL_ENSURE(pInterface,"Interface is null!");
522 OLEString aBSTR;
523 pInterface->get_Name(&aBSTR);
524 return aBSTR;
527 DataTypeEnum WpADOField::GetADOType() const
529 OSL_ENSURE(pInterface,"Interface is null!");
530 DataTypeEnum eType=adEmpty;
531 pInterface->get_Type(&eType);
532 return eType;
535 void WpADOField::get_Value(OLEVariant& aValVar) const
537 OSL_ENSURE(pInterface,"Interface is null!");
538 aValVar.setEmpty();
539 sal_Bool bOk = SUCCEEDED(pInterface->get_Value(&aValVar));
540 (void)bOk;
543 OLEVariant WpADOField::get_Value() const
545 OSL_ENSURE(pInterface,"Interface is null!");
546 OLEVariant aValVar;
547 pInterface->get_Value(&aValVar);
548 return aValVar;
551 sal_Bool WpADOField::PutValue(const OLEVariant& aVariant)
553 OSL_ENSURE(pInterface,"Interface is null!");
554 return (SUCCEEDED(pInterface->put_Value(aVariant)));
557 sal_Int32 WpADOField::GetPrecision() const
559 OSL_ENSURE(pInterface,"Interface is null!");
560 sal_uInt8 eType=0;
561 pInterface->get_Precision(&eType);
562 return eType;
565 sal_Int32 WpADOField::GetNumericScale() const
567 OSL_ENSURE(pInterface,"Interface is null!");
568 sal_uInt8 eType=0;
569 pInterface->get_NumericScale(&eType);
570 return eType;
573 sal_Bool WpADOField::AppendChunk(const OLEVariant& _Variant)
575 OSL_ENSURE(pInterface,"Interface is null!");
576 return (SUCCEEDED(pInterface->AppendChunk(_Variant)));
579 OLEVariant WpADOField::GetChunk(long Length) const
581 OSL_ENSURE(pInterface,"Interface is null!");
582 OLEVariant aValVar;
583 pInterface->GetChunk(Length,&aValVar);
584 return aValVar;
587 void WpADOField::GetChunk(long Length,OLEVariant &aValVar) const
589 OSL_ENSURE(pInterface,"Interface is null!");
590 pInterface->GetChunk(Length,&aValVar);
593 OLEVariant WpADOField::GetOriginalValue() const
595 OSL_ENSURE(pInterface,"Interface is null!");
596 OLEVariant aValVar;
597 pInterface->get_OriginalValue(&aValVar);
598 return aValVar;
601 void WpADOField::GetOriginalValue(OLEVariant &aValVar) const
603 OSL_ENSURE(pInterface,"Interface is null!");
604 pInterface->get_OriginalValue(&aValVar);
607 OLEVariant WpADOField::GetUnderlyingValue() const
609 OSL_ENSURE(pInterface,"Interface is null!");
610 OLEVariant aValVar;
611 pInterface->get_UnderlyingValue(&aValVar);
612 return aValVar;
615 void WpADOField::GetUnderlyingValue(OLEVariant &aValVar) const
617 OSL_ENSURE(pInterface,"Interface is null!");
618 pInterface->get_UnderlyingValue(&aValVar);
621 sal_Bool WpADOField::PutPrecision(sal_Int8 _prec)
623 OSL_ENSURE(pInterface,"Interface is null!");
624 return (SUCCEEDED(pInterface->put_Precision(_prec)));
627 sal_Bool WpADOField::PutNumericScale(sal_Int8 _prec)
629 OSL_ENSURE(pInterface,"Interface is null!");
630 return (SUCCEEDED(pInterface->put_NumericScale(_prec)));
633 void WpADOField::PutADOType(DataTypeEnum eType)
635 OSL_ENSURE(pInterface,"Interface is null!");
636 pInterface->put_Type(eType);
639 sal_Bool WpADOField::PutDefinedSize(sal_Int32 _nDefSize)
641 OSL_ENSURE(pInterface,"Interface is null!");
642 return (SUCCEEDED(pInterface->put_DefinedSize(_nDefSize)));
645 sal_Bool WpADOField::PutAttributes(sal_Int32 _nDefSize)
647 OSL_ENSURE(pInterface,"Interface is null!");
648 return (SUCCEEDED(pInterface->put_Attributes(_nDefSize)));
651 OLEVariant WpADOProperty::GetValue() const
653 OLEVariant aValVar;
654 if(pInterface)
655 pInterface->get_Value(&aValVar);
656 return aValVar;
659 void WpADOProperty::GetValue(OLEVariant &aValVar) const
661 OSL_ENSURE(pInterface,"Interface is null!");
662 if(pInterface)
663 pInterface->get_Value(&aValVar);
666 sal_Bool WpADOProperty::PutValue(const OLEVariant &aValVar)
668 OSL_ENSURE(pInterface,"Interface is null!");
669 return (SUCCEEDED(pInterface->put_Value(aValVar)));
672 ::rtl::OUString WpADOProperty::GetName() const
674 OSL_ENSURE(pInterface,"Interface is null!");
675 OLEString aBSTR;
676 pInterface->get_Name(&aBSTR);
677 return aBSTR;
680 DataTypeEnum WpADOProperty::GetADOType() const
682 OSL_ENSURE(pInterface,"Interface is null!");
683 DataTypeEnum eType=adEmpty;
684 pInterface->get_Type(&eType);
685 return eType;
688 sal_Int32 WpADOProperty::GetAttributes() const
690 OSL_ENSURE(pInterface,"Interface is null!");
691 sal_Int32 eADOSFieldAttributes=0;
692 pInterface->get_Attributes(&eADOSFieldAttributes);
693 return eADOSFieldAttributes;
696 sal_Bool WpADOProperty::PutAttributes(sal_Int32 _nDefSize)
698 OSL_ENSURE(pInterface,"Interface is null!");
699 return (SUCCEEDED(pInterface->put_Attributes(_nDefSize)));
701 void WpADORecordset::Create()
703 IClassFactory2* pInterface2 = NULL;
704 IUnknown *pOuter = NULL;
705 HRESULT hr;
706 hr = CoGetClassObject( ADOS::CLSID_ADORECORDSET_21,
707 CLSCTX_INPROC_SERVER,
708 NULL,
709 IID_IClassFactory2,
710 (void**)&pInterface2 );
712 if( !FAILED( hr ) )
714 ADORecordset *pRec = NULL;
715 hr = pInterface2->CreateInstanceLic( pOuter,
716 NULL,
717 ADOS::IID_ADORECORDSET_21,
718 ADOS::GetKeyStr(),
719 (void**) &pRec);
721 if( !FAILED( hr ) )
723 operator=(pRec);
724 pRec->Release();
727 pInterface2->Release();
731 sal_Bool WpADORecordset::Open(
732 /* [optional][in] */ VARIANT Source,
733 /* [optional][in] */ VARIANT ActiveConnection,
734 /* [defaultvalue][in] */ CursorTypeEnum CursorType,
735 /* [defaultvalue][in] */ LockTypeEnum LockType,
736 /* [defaultvalue][in] */ sal_Int32 Options)
738 OSL_ENSURE(pInterface,"Interface is null!");
739 return (SUCCEEDED(pInterface->Open(Source,ActiveConnection,CursorType,LockType,Options)));
743 LockTypeEnum WpADORecordset::GetLockType()
745 OSL_ENSURE(pInterface,"Interface is null!");
746 LockTypeEnum eType=adLockUnspecified;
747 pInterface->get_LockType(&eType);
748 return eType;
751 void WpADORecordset::Close()
753 OSL_ENSURE(pInterface,"Interface is null!");
754 OSL_ENSURE(pInterface,"Interface is null!");
755 pInterface->Close();
758 sal_Bool WpADORecordset::Cancel() const
760 OSL_ENSURE(pInterface,"Interface is null!");
761 return (SUCCEEDED(pInterface->Cancel()));
764 sal_Int32 WpADORecordset::get_State( )
766 OSL_ENSURE(pInterface,"Interface is null!");
767 sal_Int32 nState = 0;
768 pInterface->get_State(&nState);
769 return nState;
772 sal_Bool WpADORecordset::Supports( /* [in] */ CursorOptionEnum CursorOptions)
774 OSL_ENSURE(pInterface,"Interface is null!");
775 VARIANT_BOOL bSupports=VARIANT_FALSE;
776 pInterface->Supports(CursorOptions,&bSupports);
777 return bSupports == VARIANT_TRUE;
780 PositionEnum WpADORecordset::get_AbsolutePosition()
782 OSL_ENSURE(pInterface,"Interface is null!");
783 PositionEnum aTemp=adPosUnknown;
784 pInterface->get_AbsolutePosition(&aTemp);
785 return aTemp;
788 void WpADORecordset::GetDataSource(IUnknown** _pInterface) const
790 OSL_ENSURE(pInterface,"Interface is null!");
791 pInterface->get_DataSource(_pInterface);
794 void WpADORecordset::PutRefDataSource(IUnknown* _pInterface)
796 OSL_ENSURE(pInterface,"Interface is null!");
797 pInterface->putref_DataSource(_pInterface);
800 void WpADORecordset::GetBookmark(VARIANT& var)
802 OSL_ENSURE(pInterface,"Interface is null!");
803 pInterface->get_Bookmark(&var);
806 OLEVariant WpADORecordset::GetBookmark()
808 OSL_ENSURE(pInterface,"Interface is null!");
809 OLEVariant var;
810 pInterface->get_Bookmark(&var);
811 return var;
814 CompareEnum WpADORecordset::CompareBookmarks(const OLEVariant& left,const OLEVariant& right)
816 OSL_ENSURE(pInterface,"Interface is null!");
817 CompareEnum eNum=adCompareNotComparable;
818 pInterface->CompareBookmarks(left,right,&eNum);
819 return eNum;
822 sal_Bool WpADORecordset::SetBookmark(const OLEVariant &pSafeAr)
824 OSL_ENSURE(pInterface,"Interface is null!");
825 return SUCCEEDED(pInterface->put_Bookmark(pSafeAr));
829 WpADOFields WpADORecordset::GetFields() const
831 OSL_ENSURE(pInterface,"Interface is null!");
832 ADOFields* pFields=NULL;
833 pInterface->get_Fields(&pFields);
834 WpADOFields aFields;
835 aFields.setWithOutAddRef(pFields);
836 return aFields;
840 sal_Bool WpADORecordset::Move(sal_Int32 nRows, VARIANT aBmk) {return pInterface && SUCCEEDED(pInterface->Move(nRows, aBmk));}
841 sal_Bool WpADORecordset::MoveNext() {return pInterface && SUCCEEDED(pInterface->MoveNext());}
842 sal_Bool WpADORecordset::MovePrevious() {return pInterface && SUCCEEDED(pInterface->MovePrevious());}
843 sal_Bool WpADORecordset::MoveFirst() {return pInterface && SUCCEEDED(pInterface->MoveFirst());}
844 sal_Bool WpADORecordset::MoveLast() {return pInterface && SUCCEEDED(pInterface->MoveLast());}
846 sal_Bool WpADORecordset::IsAtBOF() const
848 OSL_ENSURE(pInterface,"Interface is null!");
849 VARIANT_BOOL bIsAtBOF=VARIANT_FALSE;
850 pInterface->get_BOF(&bIsAtBOF);
851 return bIsAtBOF == VARIANT_TRUE;
854 sal_Bool WpADORecordset::IsAtEOF() const
856 OSL_ENSURE(pInterface,"Interface is null!");
857 VARIANT_BOOL bIsAtEOF=VARIANT_FALSE;
858 pInterface->get_EOF(&bIsAtEOF);
859 return bIsAtEOF == VARIANT_TRUE;
862 sal_Bool WpADORecordset::Delete(AffectEnum eNum)
864 OSL_ENSURE(pInterface,"Interface is null!");
865 return SUCCEEDED(pInterface->Delete(eNum));
868 sal_Bool WpADORecordset::AddNew(const OLEVariant &FieldList,const OLEVariant &Values)
870 OSL_ENSURE(pInterface,"Interface is null!");
871 return SUCCEEDED(pInterface->AddNew(FieldList,Values));
874 sal_Bool WpADORecordset::Update(const OLEVariant &FieldList,const OLEVariant &Values)
876 OSL_ENSURE(pInterface,"Interface is null!");
877 return SUCCEEDED(pInterface->Update(FieldList,Values));
880 sal_Bool WpADORecordset::CancelUpdate()
882 OSL_ENSURE(pInterface,"Interface is null!");
883 return SUCCEEDED(pInterface->CancelUpdate());
886 WpADOProperties WpADORecordset::get_Properties() const
888 OSL_ENSURE(pInterface,"Interface is null!");
889 ADOProperties* pProps=NULL;
890 pInterface->get_Properties(&pProps);
891 WpADOProperties aProps;
892 aProps.setWithOutAddRef(pProps);
893 return aProps;
896 sal_Bool WpADORecordset::NextRecordset(OLEVariant& RecordsAffected,ADORecordset** ppiRset)
898 OSL_ENSURE(pInterface,"Interface is null!");
899 return SUCCEEDED(pInterface->NextRecordset(&RecordsAffected,ppiRset));
902 sal_Bool WpADORecordset::get_RecordCount(sal_Int32 &_nRet) const
904 OSL_ENSURE(pInterface,"Interface is null!");
905 return SUCCEEDED(pInterface->get_RecordCount(&_nRet));
908 sal_Bool WpADORecordset::get_MaxRecords(sal_Int32 &_nRet) const
910 OSL_ENSURE(pInterface,"Interface is null!");
911 return SUCCEEDED(pInterface->get_MaxRecords(&_nRet));
914 sal_Bool WpADORecordset::put_MaxRecords(sal_Int32 _nRet)
916 OSL_ENSURE(pInterface,"Interface is null!");
917 return SUCCEEDED(pInterface->put_MaxRecords(_nRet));
920 sal_Bool WpADORecordset::get_CursorType(CursorTypeEnum &_nRet) const
922 OSL_ENSURE(pInterface,"Interface is null!");
923 return SUCCEEDED(pInterface->get_CursorType(&_nRet));
926 sal_Bool WpADORecordset::put_CursorType(CursorTypeEnum _nRet)
928 OSL_ENSURE(pInterface,"Interface is null!");
929 return SUCCEEDED(pInterface->put_CursorType(_nRet));
932 sal_Bool WpADORecordset::get_LockType(LockTypeEnum &_nRet) const
934 OSL_ENSURE(pInterface,"Interface is null!");
935 return SUCCEEDED(pInterface->get_LockType(&_nRet));
938 sal_Bool WpADORecordset::put_LockType(LockTypeEnum _nRet)
940 OSL_ENSURE(pInterface,"Interface is null!");
941 return SUCCEEDED(pInterface->put_LockType(_nRet));
944 sal_Bool WpADORecordset::get_CacheSize(sal_Int32 &_nRet) const
946 OSL_ENSURE(pInterface,"Interface is null!");
947 return SUCCEEDED(pInterface->get_CacheSize(&_nRet));
950 sal_Bool WpADORecordset::put_CacheSize(sal_Int32 _nRet)
952 OSL_ENSURE(pInterface,"Interface is null!");
953 return SUCCEEDED(pInterface->put_CacheSize(_nRet));
956 sal_Bool WpADORecordset::UpdateBatch(AffectEnum AffectRecords)
958 OSL_ENSURE(pInterface,"Interface is null!");
959 return SUCCEEDED(pInterface->UpdateBatch(AffectRecords));
962 ::rtl::OUString WpADOParameter::GetName() const
964 OSL_ENSURE(pInterface,"Interface is null!");
965 OLEString aBSTR;
966 pInterface->get_Name(&aBSTR);
967 return aBSTR;
970 DataTypeEnum WpADOParameter::GetADOType() const
972 OSL_ENSURE(pInterface,"Interface is null!");
973 DataTypeEnum eType=adEmpty;
974 pInterface->get_Type(&eType);
975 return eType;
978 void WpADOParameter::put_Type(const DataTypeEnum& _eType)
980 OSL_ENSURE(pInterface,"Interface is null!");
981 pInterface->put_Type(_eType);
984 sal_Int32 WpADOParameter::GetAttributes() const
986 OSL_ENSURE(pInterface,"Interface is null!");
987 sal_Int32 eADOSFieldAttributes=0;
988 pInterface->get_Attributes(&eADOSFieldAttributes);
989 return eADOSFieldAttributes;
992 sal_Int32 WpADOParameter::GetPrecision() const
994 OSL_ENSURE(pInterface,"Interface is null!");
995 sal_uInt8 eType=0;
996 pInterface->get_Precision(&eType);
997 return eType;
1000 sal_Int32 WpADOParameter::GetNumericScale() const
1002 OSL_ENSURE(pInterface,"Interface is null!");
1003 sal_uInt8 eType=0;
1004 pInterface->get_NumericScale(&eType);
1005 return eType;
1008 ParameterDirectionEnum WpADOParameter::get_Direction() const
1010 OSL_ENSURE(pInterface,"Interface is null!");
1011 ParameterDirectionEnum alParmDirection=adParamUnknown;
1012 pInterface->get_Direction(&alParmDirection);
1013 return alParmDirection;
1016 void WpADOParameter::GetValue(OLEVariant& aValVar) const
1018 OSL_ENSURE(pInterface,"Interface is null!");
1019 pInterface->get_Value(&aValVar);
1022 OLEVariant WpADOParameter::GetValue() const
1024 OSL_ENSURE(pInterface,"Interface is null!");
1025 OLEVariant aValVar;
1026 pInterface->get_Value(&aValVar);
1027 return aValVar;
1030 sal_Bool WpADOParameter::PutValue(const OLEVariant& aVariant)
1032 OSL_ENSURE(pInterface,"Interface is null!");
1033 return (SUCCEEDED(pInterface->put_Value(aVariant)));
1035 sal_Bool WpADOParameter::AppendChunk(const OLEVariant& aVariant)
1037 OSL_ENSURE(pInterface,"Interface is null!");
1038 return (SUCCEEDED(pInterface->AppendChunk(aVariant)));
1040 sal_Bool WpADOParameter::put_Size(const sal_Int32& _nSize)
1042 OSL_ENSURE(pInterface,"Interface is null!");
1043 return (SUCCEEDED(pInterface->put_Size(_nSize)));
1046 ::rtl::OUString WpADOColumn::get_Name() const
1048 OSL_ENSURE(pInterface,"Interface is null!");
1049 OLEString aBSTR;
1050 pInterface->get_Name(&aBSTR);
1051 return aBSTR;
1054 ::rtl::OUString WpADOColumn::get_RelatedColumn() const
1056 OSL_ENSURE(pInterface,"Interface is null!");
1057 OLEString aBSTR;
1058 pInterface->get_RelatedColumn(&aBSTR);
1059 return aBSTR;
1062 void WpADOColumn::put_Name(const ::rtl::OUString& _rName)
1064 OSL_ENSURE(pInterface,"Interface is null!");
1065 OLEString bstr(_rName);
1066 sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr));
1067 (void)bErg;
1069 void WpADOColumn::put_RelatedColumn(const ::rtl::OUString& _rName)
1071 OSL_ENSURE(pInterface,"Interface is null!");
1072 OLEString bstr(_rName);
1073 sal_Bool bErg = SUCCEEDED(pInterface->put_RelatedColumn(bstr));
1074 (void)bErg;
1077 DataTypeEnum WpADOColumn::get_Type() const
1079 OSL_ENSURE(pInterface,"Interface is null!");
1080 DataTypeEnum eNum = adVarChar;
1081 pInterface->get_Type(&eNum);
1082 return eNum;
1085 void WpADOColumn::put_Type(const DataTypeEnum& _eNum)
1087 OSL_ENSURE(pInterface,"Interface is null!");
1088 pInterface->put_Type(_eNum);
1091 sal_Int32 WpADOColumn::get_Precision() const
1093 OSL_ENSURE(pInterface,"Interface is null!");
1094 sal_Int32 nPrec=0;
1095 pInterface->get_Precision(&nPrec);
1096 return nPrec;
1099 void WpADOColumn::put_Precision(sal_Int32 _nPre)
1101 OSL_ENSURE(pInterface,"Interface is null!");
1102 pInterface->put_Precision(_nPre);
1105 sal_Int32 WpADOColumn::get_DefinedSize() const
1107 OSL_ENSURE(pInterface,"Interface is null!");
1108 sal_Int32 nPrec=0;
1109 pInterface->get_DefinedSize(&nPrec);
1110 return nPrec;
1112 sal_uInt8 WpADOColumn::get_NumericScale() const
1114 OSL_ENSURE(pInterface,"Interface is null!");
1115 sal_uInt8 nPrec=0;
1116 pInterface->get_NumericScale(&nPrec);
1117 return nPrec;
1120 void WpADOColumn::put_NumericScale(sal_Int8 _nScale)
1122 OSL_ENSURE(pInterface,"Interface is null!");
1123 pInterface->put_NumericScale(_nScale);
1126 SortOrderEnum WpADOColumn::get_SortOrder() const
1128 OSL_ENSURE(pInterface,"Interface is null!");
1129 SortOrderEnum nPrec=adSortAscending;
1130 pInterface->get_SortOrder(&nPrec);
1131 return nPrec;
1134 void WpADOColumn::put_SortOrder(SortOrderEnum _nScale)
1136 OSL_ENSURE(pInterface,"Interface is null!");
1137 pInterface->put_SortOrder(_nScale);
1140 ColumnAttributesEnum WpADOColumn::get_Attributes() const
1142 OSL_ENSURE(pInterface,"Interface is null!");
1143 ColumnAttributesEnum eNum=adColNullable;
1144 pInterface->get_Attributes(&eNum);
1145 return eNum;
1148 sal_Bool WpADOColumn::put_Attributes(const ColumnAttributesEnum& _eNum)
1150 OSL_ENSURE(pInterface,"Interface is null!");
1151 return SUCCEEDED(pInterface->put_Attributes(_eNum));
1154 WpADOProperties WpADOColumn::get_Properties() const
1156 OSL_ENSURE(pInterface,"Interface is null!");
1157 ADOProperties* pProps = NULL;
1158 pInterface->get_Properties(&pProps);
1159 WpADOProperties aProps;
1161 aProps.setWithOutAddRef(pProps);
1162 return aProps;
1165 ::rtl::OUString WpADOKey::get_Name() const
1167 OSL_ENSURE(pInterface,"Interface is null!");
1168 OLEString aBSTR;
1169 pInterface->get_Name(&aBSTR);
1170 return aBSTR;
1173 void WpADOKey::put_Name(const ::rtl::OUString& _rName)
1175 OSL_ENSURE(pInterface,"Interface is null!");
1176 OLEString bstr(_rName);
1177 sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr));
1178 (void)bErg;
1181 KeyTypeEnum WpADOKey::get_Type() const
1183 OSL_ENSURE(pInterface,"Interface is null!");
1184 KeyTypeEnum eNum=adKeyPrimary;
1185 pInterface->get_Type(&eNum);
1186 return eNum;
1189 void WpADOKey::put_Type(const KeyTypeEnum& _eNum)
1191 OSL_ENSURE(pInterface,"Interface is null!");
1192 pInterface->put_Type(_eNum);
1195 ::rtl::OUString WpADOKey::get_RelatedTable() const
1197 OSL_ENSURE(pInterface,"Interface is null!");
1198 OLEString aBSTR;
1199 pInterface->get_RelatedTable(&aBSTR);
1200 return aBSTR;
1203 void WpADOKey::put_RelatedTable(const ::rtl::OUString& _rName)
1205 OSL_ENSURE(pInterface,"Interface is null!");
1206 OLEString bstr(_rName);
1207 sal_Bool bErg = SUCCEEDED(pInterface->put_RelatedTable(bstr));
1208 (void)bErg;
1211 RuleEnum WpADOKey::get_DeleteRule() const
1213 OSL_ENSURE(pInterface,"Interface is null!");
1214 RuleEnum eNum = adRINone;
1215 pInterface->get_DeleteRule(&eNum);
1216 return eNum;
1219 void WpADOKey::put_DeleteRule(const RuleEnum& _eNum)
1221 OSL_ENSURE(pInterface,"Interface is null!");
1222 pInterface->put_DeleteRule(_eNum);
1225 RuleEnum WpADOKey::get_UpdateRule() const
1227 OSL_ENSURE(pInterface,"Interface is null!");
1228 RuleEnum eNum = adRINone;
1229 pInterface->get_UpdateRule(&eNum);
1230 return eNum;
1233 void WpADOKey::put_UpdateRule(const RuleEnum& _eNum)
1235 OSL_ENSURE(pInterface,"Interface is null!");
1236 pInterface->put_UpdateRule(_eNum);
1239 WpADOColumns WpADOKey::get_Columns() const
1241 OSL_ENSURE(pInterface,"Interface is null!");
1242 ADOColumns* pCols = NULL;
1243 pInterface->get_Columns(&pCols);
1244 WpADOColumns aCols;
1245 aCols.setWithOutAddRef(pCols);
1246 return aCols;
1249 ::rtl::OUString WpADOIndex::get_Name() const
1251 OSL_ENSURE(pInterface,"Interface is null!");
1252 OLEString aBSTR;
1253 pInterface->get_Name(&aBSTR);
1254 return aBSTR;
1257 void WpADOIndex::put_Name(const ::rtl::OUString& _rName)
1259 OSL_ENSURE(pInterface,"Interface is null!");
1260 OLEString bstr(_rName);
1261 sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr));
1262 (void)bErg;
1265 sal_Bool WpADOIndex::get_Clustered() const
1267 OSL_ENSURE(pInterface,"Interface is null!");
1268 VARIANT_BOOL eNum = VARIANT_FALSE;
1269 pInterface->get_Clustered(&eNum);
1270 return eNum == VARIANT_TRUE;
1273 void WpADOIndex::put_Clustered(sal_Bool _b)
1275 OSL_ENSURE(pInterface,"Interface is null!");
1276 pInterface->put_Clustered(_b ? VARIANT_TRUE : VARIANT_FALSE);
1279 sal_Bool WpADOIndex::get_Unique() const
1281 OSL_ENSURE(pInterface,"Interface is null!");
1282 VARIANT_BOOL eNum = VARIANT_FALSE;
1283 pInterface->get_Unique(&eNum);
1284 return eNum == VARIANT_TRUE;
1287 void WpADOIndex::put_Unique(sal_Bool _b)
1289 OSL_ENSURE(pInterface,"Interface is null!");
1290 pInterface->put_Unique(_b ? VARIANT_TRUE : VARIANT_FALSE);
1293 sal_Bool WpADOIndex::get_PrimaryKey() const
1295 OSL_ENSURE(pInterface,"Interface is null!");
1296 VARIANT_BOOL eNum = VARIANT_FALSE;
1297 pInterface->get_PrimaryKey(&eNum);
1298 return eNum == VARIANT_TRUE;
1301 void WpADOIndex::put_PrimaryKey(sal_Bool _b)
1303 OSL_ENSURE(pInterface,"Interface is null!");
1304 pInterface->put_PrimaryKey(_b ? VARIANT_TRUE : VARIANT_FALSE);
1307 WpADOColumns WpADOIndex::get_Columns() const
1309 OSL_ENSURE(pInterface,"Interface is null!");
1310 ADOColumns* pCols = NULL;
1311 pInterface->get_Columns(&pCols);
1312 WpADOColumns aCols;
1313 aCols.setWithOutAddRef(pCols);
1314 return aCols;
1317 void WpADOCatalog::putref_ActiveConnection(IDispatch* pCon)
1319 OSL_ENSURE(pInterface,"Interface is null!");
1320 pInterface->putref_ActiveConnection(pCon);
1323 WpADOTables WpADOCatalog::get_Tables()
1325 OSL_ENSURE(pInterface,"Interface is null!");
1326 ADOTables* pRet = NULL;
1327 pInterface->get_Tables(&pRet);
1328 WpADOTables aRet;
1329 aRet.setWithOutAddRef(pRet);
1330 return aRet;
1333 WpADOViews WpADOCatalog::get_Views()
1335 OSL_ENSURE(pInterface,"Interface is null!");
1336 ADOViews* pRet = NULL;
1337 pInterface->get_Views(&pRet);
1338 WpADOViews aRet;
1339 aRet.setWithOutAddRef(pRet);
1340 return aRet;
1343 WpADOGroups WpADOCatalog::get_Groups()
1345 OSL_ENSURE(pInterface,"Interface is null!");
1346 ADOGroups* pRet = NULL;
1347 pInterface->get_Groups(&pRet);
1348 WpADOGroups aRet;
1349 aRet.setWithOutAddRef(pRet);
1350 return aRet;
1353 WpADOUsers WpADOCatalog::get_Users()
1355 OSL_ENSURE(pInterface,"Interface is null!");
1356 ADOUsers* pRet = NULL;
1357 pInterface->get_Users(&pRet);
1358 WpADOUsers aRet;
1359 aRet.setWithOutAddRef(pRet);
1360 return aRet;
1363 ADOProcedures* WpADOCatalog::get_Procedures()
1365 OSL_ENSURE(pInterface,"Interface is null!");
1366 ADOProcedures* pRet = NULL;
1367 pInterface->get_Procedures(&pRet);
1368 return pRet;
1371 ::rtl::OUString WpADOTable::get_Name() const
1373 OSL_ENSURE(pInterface,"Interface is null!");
1374 OLEString aBSTR;
1375 pInterface->get_Name(&aBSTR);
1376 return aBSTR;
1379 void WpADOTable::put_Name(const ::rtl::OUString& _rName)
1381 OSL_ENSURE(pInterface,"Interface is null!");
1382 OLEString bstr(_rName);
1383 sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr));
1384 (void)bErg;
1387 ::rtl::OUString WpADOTable::get_Type() const
1389 OSL_ENSURE(pInterface,"Interface is null!");
1390 OLEString aBSTR;
1391 pInterface->get_Type(&aBSTR);
1392 return aBSTR;
1395 WpADOColumns WpADOTable::get_Columns() const
1397 OSL_ENSURE(pInterface,"Interface is null!");
1398 ADOColumns* pCols = NULL;
1399 pInterface->get_Columns(&pCols);
1400 WpADOColumns aCols;
1401 aCols.setWithOutAddRef(pCols);
1402 return aCols;
1405 WpADOIndexes WpADOTable::get_Indexes() const
1407 OSL_ENSURE(pInterface,"Interface is null!");
1408 ADOIndexes* pCols = NULL;
1409 pInterface->get_Indexes(&pCols);
1410 WpADOIndexes aRet;
1411 aRet.setWithOutAddRef(pCols);
1412 return aRet;
1415 WpADOKeys WpADOTable::get_Keys() const
1417 OSL_ENSURE(pInterface,"Interface is null!");
1418 ADOKeys* pCols = NULL;
1419 pInterface->get_Keys(&pCols);
1420 WpADOKeys aRet;
1421 aRet.setWithOutAddRef(pCols);
1422 return aRet;
1425 WpADOCatalog WpADOTable::get_ParentCatalog() const
1427 OSL_ENSURE(pInterface,"Interface is null!");
1428 ADOCatalog* pCat = NULL;
1429 pInterface->get_ParentCatalog(&pCat);
1430 WpADOCatalog aRet;
1431 aRet.setWithOutAddRef(pCat);
1432 return aRet;
1435 WpADOProperties WpADOTable::get_Properties() const
1437 OSL_ENSURE(pInterface,"Interface is null!");
1438 ADOProperties* pProps = NULL;
1439 pInterface->get_Properties(&pProps);
1440 WpADOProperties aProps;
1441 aProps.setWithOutAddRef(pProps);
1442 return aProps;
1445 ::rtl::OUString WpADOView::get_Name() const
1447 OSL_ENSURE(pInterface,"Interface is null!");
1448 OLEString aBSTR;
1449 pInterface->get_Name(&aBSTR);
1450 return aBSTR;
1453 void WpADOView::get_Command(OLEVariant& _rVar) const
1455 OSL_ENSURE(pInterface,"Interface is null!");
1456 pInterface->get_Command(&_rVar);
1459 void WpADOView::put_Command(OLEVariant& _rVar)
1461 pInterface->put_Command(_rVar);
1464 ::rtl::OUString WpADOGroup::get_Name() const
1466 OLEString aBSTR;
1467 pInterface->get_Name(&aBSTR);
1468 return aBSTR;
1471 void WpADOGroup::put_Name(const ::rtl::OUString& _rName)
1473 OLEString bstr(_rName);
1474 sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr));
1475 (void)bErg;
1478 RightsEnum WpADOGroup::GetPermissions(
1479 /* [in] */ const OLEVariant& Name,
1480 /* [in] */ ObjectTypeEnum ObjectType)
1482 RightsEnum Rights=adRightNone;
1483 OLEVariant ObjectTypeId;
1484 ObjectTypeId.setNoArg();
1485 pInterface->GetPermissions(Name,ObjectType,ObjectTypeId,&Rights);
1486 return Rights;
1489 sal_Bool WpADOGroup::SetPermissions(
1490 /* [in] */ const OLEVariant& Name,
1491 /* [in] */ ObjectTypeEnum ObjectType,
1492 /* [in] */ ActionEnum Action,
1493 /* [in] */ RightsEnum Rights)
1495 OLEVariant ObjectTypeId;
1496 ObjectTypeId.setNoArg();
1497 return SUCCEEDED(pInterface->SetPermissions(Name,ObjectType,Action,Rights,adInheritNone,ObjectTypeId));
1500 WpADOUsers WpADOGroup::get_Users( )
1502 ADOUsers* pRet = NULL;
1503 pInterface->get_Users( &pRet);
1504 WpADOUsers aRet;
1505 aRet.setWithOutAddRef(pRet);
1506 return aRet;
1509 ::rtl::OUString WpADOUser::get_Name() const
1511 OLEString aBSTR;
1512 pInterface->get_Name(&aBSTR);
1513 return aBSTR;
1516 void WpADOUser::put_Name(const ::rtl::OUString& _rName)
1518 OLEString bstr(_rName);
1519 sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr));
1520 (void)bErg;
1523 sal_Bool WpADOUser::ChangePassword(const ::rtl::OUString& _rPwd,const ::rtl::OUString& _rNewPwd)
1525 OLEString sStr1(_rPwd);
1526 OLEString sStr2(_rNewPwd);
1527 sal_Bool bErg = SUCCEEDED(pInterface->ChangePassword(sStr1,sStr2));
1528 return bErg;
1531 WpADOGroups WpADOUser::get_Groups()
1533 ADOGroups* pRet = NULL;
1534 pInterface->get_Groups(&pRet);
1535 WpADOGroups aRet;
1536 aRet.setWithOutAddRef(pRet);
1537 return aRet;
1540 RightsEnum WpADOUser::GetPermissions(
1541 /* [in] */ const OLEVariant& Name,
1542 /* [in] */ ObjectTypeEnum ObjectType)
1544 RightsEnum Rights=adRightNone;
1545 OLEVariant ObjectTypeId;
1546 ObjectTypeId.setNoArg();
1547 pInterface->GetPermissions(Name,ObjectType,ObjectTypeId,&Rights);
1548 return Rights;
1551 sal_Bool WpADOUser::SetPermissions(
1552 /* [in] */ const OLEVariant& Name,
1553 /* [in] */ ObjectTypeEnum ObjectType,
1554 /* [in] */ ActionEnum Action,
1555 /* [in] */ RightsEnum Rights)
1557 OLEVariant ObjectTypeId;
1558 ObjectTypeId.setNoArg();
1559 return SUCCEEDED(pInterface->SetPermissions(Name,ObjectType,Action,Rights,adInheritNone,ObjectTypeId));
1562 WpBase::WpBase() : pIUnknown(NULL)
1565 WpBase::WpBase(IDispatch* pInt)
1566 :pIUnknown(pInt)
1568 if (pIUnknown)
1570 ULONG nCount = pIUnknown->AddRef();
1571 (void)nCount;
1572 // OSL_ENSURE(nCount == 1,"Count is greater than 1");
1576 //inline
1577 WpBase& WpBase::operator=(const WpBase& rhs)
1579 if (rhs.pIUnknown != pIUnknown)
1581 if (pIUnknown)
1582 pIUnknown->Release();
1583 pIUnknown = rhs.pIUnknown;
1584 if (pIUnknown)
1585 pIUnknown->AddRef();
1587 return *this;
1590 WpBase& WpBase::operator=(IDispatch* rhs)
1592 if (pIUnknown != rhs)
1594 if (pIUnknown)
1595 pIUnknown->Release();
1596 pIUnknown = rhs;
1597 if (pIUnknown)
1598 pIUnknown->AddRef();
1600 return *this;
1603 WpBase::WpBase(const WpBase& aWrapper)
1605 operator=(aWrapper);
1608 WpBase::~WpBase()
1610 if (pIUnknown)
1612 pIUnknown->Release();
1613 pIUnknown = NULL;
1617 void WpBase::clear()
1619 if (pIUnknown)
1621 pIUnknown->Release();
1622 pIUnknown = NULL;
1627 sal_Bool WpBase::IsValid() const
1629 return pIUnknown != NULL;
1631 WpBase::operator IDispatch*()
1633 return pIUnknown;
1636 ADORecordset* WpADOConnection::getExportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table )
1638 // Create elements used in the array
1639 HRESULT hr = S_OK;
1640 SAFEARRAYBOUND rgsabound[1];
1641 SAFEARRAY *psa = NULL;
1642 OLEVariant varCriteria[6];
1644 // Create SafeArray Bounds and initialize the array
1645 rgsabound[0].lLbound = 0;
1646 rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0];
1647 psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
1649 sal_Int32 nPos=0;
1650 if(catalog.hasValue())
1651 varCriteria[nPos].setString(::comphelper::getString(catalog));
1653 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
1654 if(schema.getLength() && schema.toChar() != '%')
1655 varCriteria[nPos].setString(schema);
1656 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
1658 varCriteria[nPos].setString(table);
1659 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
1661 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
1662 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
1663 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
1665 OLEVariant vtEmpty;
1666 vtEmpty.setNoArg();
1668 // Initialize and fill the SafeArray
1669 OLEVariant vsa;
1670 vsa.setArray(psa,VT_VARIANT);
1672 ADORecordset *pRecordset = NULL;
1673 OpenSchema(adSchemaForeignKeys,vsa,vtEmpty,&pRecordset);
1674 return pRecordset;
1676 // -----------------------------------------------------------------------------
1677 ADORecordset* WpADOConnection::getImportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table )
1679 // Create elements used in the array
1680 HRESULT hr = S_OK;
1681 SAFEARRAYBOUND rgsabound[1];
1682 SAFEARRAY *psa = NULL;
1683 OLEVariant varCriteria[6];
1685 // Create SafeArray Bounds and initialize the array
1686 rgsabound[0].lLbound = 0;
1687 rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0];
1688 psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
1690 sal_Int32 nPos=0;
1691 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
1692 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
1693 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
1695 if(catalog.hasValue())
1696 varCriteria[nPos].setString(::comphelper::getString(catalog));
1698 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
1699 if(schema.getLength() && schema.toChar() != '%')
1700 varCriteria[nPos].setString(schema);
1701 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
1703 varCriteria[nPos].setString(table);
1704 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
1706 OLEVariant vtEmpty;
1707 vtEmpty.setNoArg();
1709 // Initialize and fill the SafeArray
1710 OLEVariant vsa;
1711 vsa.setArray(psa,VT_VARIANT);
1713 ADORecordset *pRecordset = NULL;
1714 OpenSchema(adSchemaForeignKeys,vsa,vtEmpty,&pRecordset);
1716 return pRecordset;
1719 // -----------------------------------------------------------------------------
1720 ADORecordset* WpADOConnection::getPrimaryKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table )
1722 // Create elements used in the array
1723 HRESULT hr = S_OK;
1724 SAFEARRAYBOUND rgsabound[1];
1725 SAFEARRAY *psa = NULL;
1726 OLEVariant varCriteria[3];
1728 // Create SafeArray Bounds and initialize the array
1729 rgsabound[0].lLbound = 0;
1730 rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0];
1731 psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
1733 sal_Int32 nPos=0;
1734 if(catalog.hasValue())
1735 varCriteria[nPos].setString(::comphelper::getString(catalog));
1737 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
1738 if(schema.getLength() && schema.toChar() != '%')
1739 varCriteria[nPos].setString(schema);
1740 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
1742 varCriteria[nPos].setString(table);
1743 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
1746 OLEVariant vtEmpty;
1747 vtEmpty.setNoArg();
1749 // Initialize and fill the SafeArray
1750 OLEVariant vsa;
1751 vsa.setArray(psa,VT_VARIANT);
1753 ADORecordset *pRecordset = NULL;
1754 OpenSchema(adSchemaPrimaryKeys,vsa,vtEmpty,&pRecordset);
1756 return pRecordset;
1758 // -----------------------------------------------------------------------------
1759 ADORecordset* WpADOConnection::getIndexInfo(
1760 const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table,
1761 sal_Bool /*unique*/, sal_Bool /*approximate*/ )
1763 // Create elements used in the array
1764 HRESULT hr = S_OK;
1765 SAFEARRAYBOUND rgsabound[1];
1766 SAFEARRAY *psa = NULL;
1767 OLEVariant varCriteria[5];
1769 // Create SafeArray Bounds and initialize the array
1770 rgsabound[0].lLbound = 0;
1771 rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0];
1772 psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
1774 sal_Int32 nPos=0;
1775 if(catalog.hasValue())
1776 varCriteria[nPos].setString(::comphelper::getString(catalog));
1778 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
1779 if(schema.getLength() && schema.toChar() != '%')
1780 varCriteria[nPos].setString(schema);
1781 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
1783 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// INDEX_NAME
1785 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TYPE
1787 varCriteria[nPos].setString(table);
1788 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
1790 OLEVariant vtEmpty;
1791 vtEmpty.setNoArg();
1793 // Initialize and fill the SafeArray
1794 OLEVariant vsa;
1795 vsa.setArray(psa,VT_VARIANT);
1797 ADORecordset *pRecordset = NULL;
1798 OpenSchema(adSchemaIndexes,vsa,vtEmpty,&pRecordset);
1800 return pRecordset;
1802 // -----------------------------------------------------------------------------
1803 ADORecordset* WpADOConnection::getTablePrivileges( const ::com::sun::star::uno::Any& catalog,
1804 const ::rtl::OUString& schemaPattern,
1805 const ::rtl::OUString& tableNamePattern )
1807 HRESULT hr = S_OK;
1808 SAFEARRAYBOUND rgsabound[1];
1809 SAFEARRAY *psa = NULL;
1810 OLEVariant varCriteria[5];
1812 // Create SafeArray Bounds and initialize the array
1813 rgsabound[0].lLbound = 0;
1814 rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0];
1815 psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
1817 sal_Int32 nPos=0;
1818 if(catalog.hasValue())
1819 varCriteria[nPos].setString(::comphelper::getString(catalog));
1821 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
1822 if(schemaPattern.getLength() && schemaPattern.toChar() != '%')
1823 varCriteria[nPos].setString(schemaPattern);
1824 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
1826 if(tableNamePattern.toChar() != '%')
1827 varCriteria[nPos].setString(tableNamePattern);
1828 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
1830 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// GRANTOR
1831 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// GRANTEE
1833 OLEVariant vtEmpty;
1834 vtEmpty.setNoArg();
1836 // Initialize and fill the SafeArray
1837 OLEVariant vsa;
1838 vsa.setArray(psa,VT_VARIANT);
1840 ADORecordset *pRecordset = NULL;
1841 OpenSchema(adSchemaTablePrivileges,vsa,vtEmpty,&pRecordset);
1843 return pRecordset;
1845 // -----------------------------------------------------------------------------
1846 ADORecordset* WpADOConnection::getCrossReference( const ::com::sun::star::uno::Any& primaryCatalog,
1847 const ::rtl::OUString& primarySchema,
1848 const ::rtl::OUString& primaryTable,
1849 const ::com::sun::star::uno::Any& foreignCatalog,
1850 const ::rtl::OUString& foreignSchema,
1851 const ::rtl::OUString& foreignTable)
1853 // Create elements used in the array
1854 HRESULT hr = S_OK;
1855 SAFEARRAYBOUND rgsabound[1];
1856 SAFEARRAY *psa = NULL;
1857 OLEVariant varCriteria[6];
1859 // Create SafeArray Bounds and initialize the array
1860 rgsabound[0].lLbound = 0;
1861 rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0];
1862 psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
1864 sal_Int32 nPos=0;
1865 if(primaryCatalog.hasValue())
1866 varCriteria[nPos].setString(::comphelper::getString(primaryCatalog));
1868 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
1869 if(primarySchema.getLength() && primarySchema.toChar() != '%')
1870 varCriteria[nPos].setString(primarySchema);
1871 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
1873 varCriteria[nPos].setString(primaryTable);
1874 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
1876 if(foreignCatalog.hasValue())
1877 varCriteria[nPos].setString(::comphelper::getString(foreignCatalog));
1879 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
1880 if(foreignSchema.getLength() && foreignSchema.toChar() != '%')
1881 varCriteria[nPos].setString(foreignSchema);
1882 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
1884 varCriteria[nPos].setString(foreignTable);
1885 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
1887 OLEVariant vtEmpty;
1888 vtEmpty.setNoArg();
1890 // Initialize and fill the SafeArray
1891 OLEVariant vsa;
1892 vsa.setArray(psa,VT_VARIANT);
1894 ADORecordset *pRecordset = NULL;
1895 OpenSchema(adSchemaForeignKeys,vsa,vtEmpty,&pRecordset);
1897 return pRecordset;
1899 // -----------------------------------------------------------------------------
1900 ADORecordset* WpADOConnection::getProcedures( const ::com::sun::star::uno::Any& catalog,
1901 const ::rtl::OUString& schemaPattern,
1902 const ::rtl::OUString& procedureNamePattern )
1904 HRESULT hr = S_OK;
1905 SAFEARRAYBOUND rgsabound[1];
1906 SAFEARRAY *psa = NULL;
1907 OLEVariant varCriteria[3];
1909 // Create SafeArray Bounds and initialize the array
1910 rgsabound[0].lLbound = 0;
1911 rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0];
1912 psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
1914 sal_Int32 nPos=0;
1915 if(catalog.hasValue())
1916 varCriteria[nPos].setString(::comphelper::getString(catalog));
1918 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
1919 if(schemaPattern.getLength() && schemaPattern.toChar() != '%')
1920 varCriteria[nPos].setString(schemaPattern);
1921 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
1923 if(procedureNamePattern.toChar() != '%')
1924 varCriteria[nPos].setString(procedureNamePattern);
1925 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
1927 OLEVariant vtEmpty;
1928 vtEmpty.setNoArg();
1930 // Initialize and fill the SafeArray
1931 OLEVariant vsa;
1932 vsa.setArray(psa,VT_VARIANT);
1934 ADORecordset *pRecordset = NULL;
1935 OpenSchema(adSchemaProcedures,vsa,vtEmpty,&pRecordset);
1937 return pRecordset;
1939 // -----------------------------------------------------------------------------
1940 ADORecordset* WpADOConnection::getProcedureColumns( const ::com::sun::star::uno::Any& catalog,
1941 const ::rtl::OUString& schemaPattern,
1942 const ::rtl::OUString& procedureNamePattern,
1943 const ::rtl::OUString& columnNamePattern )
1945 // Create elements used in the array
1946 HRESULT hr = S_OK;
1947 SAFEARRAYBOUND rgsabound[1];
1948 SAFEARRAY *psa = NULL;
1949 OLEVariant varCriteria[4];
1951 // Create SafeArray Bounds and initialize the array
1952 rgsabound[0].lLbound = 0;
1953 rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0];
1954 psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
1956 sal_Int32 nPos=0;
1957 if(catalog.hasValue())
1958 varCriteria[nPos].setString(::comphelper::getString(catalog));
1960 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
1961 if(schemaPattern.getLength() && schemaPattern.toChar() != '%')
1962 varCriteria[nPos].setString(schemaPattern);
1963 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
1965 if(procedureNamePattern.toChar() != '%')
1966 varCriteria[nPos].setString(procedureNamePattern);
1967 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
1969 if(columnNamePattern.toChar() != '%')
1970 varCriteria[nPos].setString(columnNamePattern);
1971 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// COLUMN_NAME
1973 OLEVariant vtEmpty;
1974 vtEmpty.setNoArg();
1976 // Initialize and fill the SafeArray
1977 OLEVariant vsa;
1978 vsa.setArray(psa,VT_VARIANT);
1980 ADORecordset *pRecordset = NULL;
1981 OpenSchema(adSchemaProcedureParameters,vsa,vtEmpty,&pRecordset);
1983 return pRecordset;
1985 // -----------------------------------------------------------------------------
1986 ADORecordset* WpADOConnection::getTables( const ::com::sun::star::uno::Any& catalog,
1987 const ::rtl::OUString& schemaPattern,
1988 const ::rtl::OUString& tableNamePattern,
1989 const ::com::sun::star::uno::Sequence< ::rtl::OUString >& types )
1991 // Create elements used in the array
1992 HRESULT hr = S_OK;
1993 OLEVariant varCriteria[4];
1995 sal_Int32 nPos=0;
1996 ::rtl::OUString sCatalog;
1997 if ( catalog.hasValue() && (catalog >>= sCatalog) )
1998 varCriteria[nPos].setString(sCatalog);
2000 ++nPos;
2001 if(schemaPattern.getLength() && schemaPattern.toChar() != '%')
2002 varCriteria[nPos].setString(schemaPattern);
2004 ++nPos;
2005 if(tableNamePattern.toChar() != '%')
2006 varCriteria[nPos].setString(tableNamePattern);
2008 ++nPos;
2009 ::rtl::OUStringBuffer aTypes;
2010 ::rtl::OUString aComma = ::rtl::OUString::createFromAscii(",");
2011 const ::rtl::OUString* pIter = types.getConstArray();
2012 const ::rtl::OUString* pEnd = pIter + types.getLength();
2013 for( ; pIter != pEnd ; ++pIter)
2015 if ( aTypes.getLength() )
2016 aTypes.append(aComma);
2017 aTypes.append(*pIter);
2020 ::rtl::OUString sTypeNames = aTypes.makeStringAndClear();
2021 if ( sTypeNames.getLength() )
2022 varCriteria[nPos].setString(sTypeNames);
2024 // Create SafeArray Bounds and initialize the array
2025 const sal_Int32 nCrit = sizeof varCriteria / sizeof varCriteria[0];
2026 SAFEARRAYBOUND rgsabound[1];
2027 rgsabound[0].lLbound = 0;
2028 rgsabound[0].cElements = nCrit;
2029 SAFEARRAY *psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
2031 // Set the values for each element of the array
2032 for( long i = 0 ; i < nCrit && SUCCEEDED( hr );i++)
2034 hr = SafeArrayPutElement(psa, &i,&varCriteria[i]);
2037 OLEVariant vtEmpty;
2038 vtEmpty.setNoArg();
2040 // Initialize and fill the SafeArray
2041 OLEVariant vsa;
2042 vsa.setArray(psa,VT_VARIANT);
2044 ADORecordset *pRecordset = NULL;
2045 OpenSchema(adSchemaTables,vsa,vtEmpty,&pRecordset);
2047 return pRecordset;
2049 // -----------------------------------------------------------------------------
2050 ADORecordset* WpADOConnection::getColumns( const ::com::sun::star::uno::Any& catalog,
2051 const ::rtl::OUString& schemaPattern,
2052 const ::rtl::OUString& tableNamePattern,
2053 const ::rtl::OUString& columnNamePattern )
2055 // Create elements used in the array
2056 HRESULT hr = S_OK;
2057 SAFEARRAYBOUND rgsabound[1];
2058 SAFEARRAY *psa = NULL;
2059 OLEVariant varCriteria[4];
2061 // Create SafeArray Bounds and initialize the array
2062 rgsabound[0].lLbound = 0;
2063 rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0];
2064 psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
2066 sal_Int32 nPos=0;
2067 if(catalog.hasValue())
2068 varCriteria[nPos].setString(::comphelper::getString(catalog));
2070 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
2071 if(schemaPattern.getLength() && schemaPattern.toChar() != '%')
2072 varCriteria[nPos].setString(schemaPattern);
2073 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
2075 if(tableNamePattern.toChar() != '%')
2076 varCriteria[nPos].setString(tableNamePattern);
2077 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
2079 varCriteria[nPos].setString(columnNamePattern);
2080 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// COLUMN_NAME
2082 OLEVariant vtEmpty;
2083 vtEmpty.setNoArg();
2085 // Initialize and fill the SafeArray
2086 OLEVariant vsa;
2087 vsa.setArray(psa,VT_VARIANT);
2089 ADORecordset *pRecordset = NULL;
2090 OpenSchema(adSchemaColumns,vsa,vtEmpty,&pRecordset);
2092 return pRecordset;
2094 // -----------------------------------------------------------------------------
2095 ADORecordset* WpADOConnection::getColumnPrivileges( const ::com::sun::star::uno::Any& catalog,
2096 const ::rtl::OUString& schema,
2097 const ::rtl::OUString& table,
2098 const ::rtl::OUString& columnNamePattern )
2100 // Create elements used in the array
2101 HRESULT hr = S_OK;
2102 SAFEARRAYBOUND rgsabound[1];
2103 SAFEARRAY *psa = NULL;
2104 OLEVariant varCriteria[4];
2106 // Create SafeArray Bounds and initialize the array
2107 rgsabound[0].lLbound = 0;
2108 rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0];
2109 psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
2111 sal_Int32 nPos=0;
2112 if(catalog.hasValue())
2113 varCriteria[nPos].setString(::comphelper::getString(catalog));
2115 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
2116 if(schema.getLength() && schema.toChar() != '%')
2117 varCriteria[nPos].setString(schema);
2118 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
2120 varCriteria[nPos].setString(table);
2121 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
2123 varCriteria[nPos].setString(columnNamePattern);
2124 hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// COLUMN_NAME
2126 OLEVariant vtEmpty;
2127 vtEmpty.setNoArg();
2129 // Initialize and fill the SafeArray
2130 OLEVariant vsa;
2131 vsa.setArray(psa,VT_VARIANT);
2133 ADORecordset *pRecordset = NULL;
2134 OpenSchema(adSchemaColumnPrivileges,vsa,vtEmpty,&pRecordset);
2136 return pRecordset;
2138 // -----------------------------------------------------------------------------
2139 ADORecordset* WpADOConnection::getTypeInfo(DataTypeEnum /*_eType*/)
2141 // Create elements used in the array
2142 OLEVariant varCriteria[2];
2143 const int nCrit = sizeof varCriteria / sizeof varCriteria[0];
2144 // Create SafeArray Bounds and initialize the array
2145 SAFEARRAYBOUND rgsabound[1];
2146 rgsabound[0].lLbound = 0;
2147 rgsabound[0].cElements = nCrit;
2148 SAFEARRAY *psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
2150 sal_Int32 nPos = 0;
2151 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;
2152 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;
2154 // Initialize and fill the SafeArray
2155 OLEVariant vsa;
2156 vsa.setArray(psa,VT_VARIANT);
2158 OLEVariant aEmpty;
2159 aEmpty.setNoArg();
2161 ADORecordset *pRec=NULL;
2162 OpenSchema(adSchemaProviderTypes,vsa,aEmpty,&pRec);
2164 return pRec;
2166 // -----------------------------------------------------------------------------
2167 void WpADOColumn::put_ParentCatalog(/* [in] */ _ADOCatalog __RPC_FAR *ppvObject)
2169 OSL_ENSURE(pInterface,"Interface is null!");
2170 sal_Bool bRet = SUCCEEDED(pInterface->put_ParentCatalog(ppvObject));
2171 OSL_ENSURE(bRet,"Could not set ParentCatalog!");
2172 OSL_UNUSED(bRet);
2174 // -----------------------------------------------------------------------------
2175 void WpADOTable::putref_ParentCatalog(/* [in] */ _ADOCatalog __RPC_FAR *ppvObject)
2177 OSL_ENSURE(pInterface,"Interface is null!");
2178 sal_Bool bRet = SUCCEEDED(pInterface->putref_ParentCatalog(ppvObject));
2179 OSL_ENSURE(bRet,"Could not set ParentCatalog!");
2180 OSL_UNUSED(bRet);
2182 // -----------------------------------------------------------------------------
2183 void WpBase::setIDispatch(IDispatch* _pIUnknown)
2185 pIUnknown = _pIUnknown;
2187 // -----------------------------------------------------------------------------
2188 void OTools::putValue(const WpADOProperties& _rProps,const OLEVariant &_aPosition,const OLEVariant &_aValVar)
2190 OSL_ENSURE(_rProps.IsValid(),"Properties are not valid!");
2191 WpADOProperty aProp(_rProps.GetItem(_aPosition));
2192 if ( aProp.IsValid() )
2194 sal_Bool bRet = aProp.PutValue(_aValVar);
2195 OSL_ENSURE(bRet,"Could not put value!");
2196 OSL_UNUSED(bRet);
2199 // -----------------------------------------------------------------------------
2200 OLEVariant OTools::getValue(const WpADOProperties& _rProps,const OLEVariant &_aPosition)
2202 WpADOProperty aProp(_rProps.GetItem(_aPosition));
2203 return aProp.GetValue();