bump product version to 6.3.0.0.beta1
[LibreOffice.git] / connectivity / source / drivers / ado / Awrapado.cxx
blob1fc664f89a5a6a551687be82f9862f083a3b0988
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/macros.h>
21 #include <ado/Awrapado.hxx>
22 #include <ado/Awrapadox.hxx>
23 #include <comphelper/types.hxx>
24 #include <rtl/ustrbuf.hxx>
25 #include <sal/log.hxx>
27 using namespace connectivity::ado;
29 void WpADOCatalog::Create()
31 _ADOCatalog* pCommand;
32 HRESULT hr = CoCreateInstance(ADOS::CLSID_ADOCATALOG_25,
33 nullptr,
34 CLSCTX_INPROC_SERVER,
35 ADOS::IID_ADOCATALOG_25,
36 reinterpret_cast<void**>(&pCommand) );
39 if( !FAILED( hr ) )
40 setWithOutAddRef(pCommand);
44 WpADOProperties WpADOConnection::get_Properties() const
46 ADOProperties* pProps=nullptr;
47 pInterface->get_Properties(&pProps);
48 WpADOProperties aProps;
49 aProps.setWithOutAddRef(pProps);
50 return aProps;
53 OUString WpADOConnection::GetConnectionString() const
55 assert(pInterface);
56 OLEString aBSTR;
57 pInterface->get_ConnectionString(aBSTR.getAddress());
58 return aBSTR.asOUString();
61 bool WpADOConnection::PutConnectionString(const OUString &aCon) const
63 assert(pInterface);
64 OLEString bstr(aCon);
65 bool bErg = SUCCEEDED(pInterface->put_ConnectionString(bstr.asBSTR()));
67 return bErg;
70 sal_Int32 WpADOConnection::GetCommandTimeout() const
72 assert(pInterface);
73 sal_Int32 nRet=0;
74 pInterface->get_CommandTimeout(&nRet);
75 return nRet;
78 void WpADOConnection::PutCommandTimeout(sal_Int32 nRet)
80 assert(pInterface);
81 pInterface->put_CommandTimeout(nRet);
84 sal_Int32 WpADOConnection::GetConnectionTimeout() const
86 assert(pInterface);
87 sal_Int32 nRet=0;
88 pInterface->get_ConnectionTimeout(&nRet);
89 return nRet;
92 void WpADOConnection::PutConnectionTimeout(sal_Int32 nRet)
94 assert(pInterface);
95 pInterface->put_ConnectionTimeout(nRet);
98 bool WpADOConnection::Close()
100 assert(pInterface);
101 return (SUCCEEDED(pInterface->Close()));
104 bool WpADOConnection::Execute(const OUString& CommandText,OLEVariant& RecordsAffected,long Options, WpADORecordset** ppiRset)
106 assert(pInterface);
107 OLEString sStr1(CommandText);
108 bool bErg = SUCCEEDED(pInterface->Execute(sStr1.asBSTR(),&RecordsAffected,Options,reinterpret_cast<ADORecordset**>(ppiRset)));
109 return bErg;
112 bool WpADOConnection::BeginTrans()
114 assert(pInterface);
115 sal_Int32 nIso=0;
116 return SUCCEEDED(pInterface->BeginTrans(&nIso));
119 bool WpADOConnection::CommitTrans( )
121 assert(pInterface);
122 return SUCCEEDED(pInterface->CommitTrans());
125 bool WpADOConnection::RollbackTrans( )
127 assert(pInterface);
128 return SUCCEEDED(pInterface->RollbackTrans());
131 bool WpADOConnection::Open(const OUString& ConnectionString, const OUString& UserID,const OUString& Password,long Options)
133 assert(pInterface);
134 OLEString sStr1(ConnectionString);
135 OLEString sStr2(UserID);
136 OLEString sStr3(Password);
137 bool bErg = SUCCEEDED(pInterface->Open(sStr1.asBSTR(),sStr2.asBSTR(),sStr3.asBSTR(),Options));
138 return bErg;
141 bool WpADOConnection::GetErrors(ADOErrors** pErrors)
143 assert(pInterface);
144 return SUCCEEDED(pInterface->get_Errors(pErrors));
147 OUString WpADOConnection::GetDefaultDatabase() const
149 assert(pInterface);
150 OLEString aBSTR; pInterface->get_DefaultDatabase(aBSTR.getAddress());
151 return aBSTR.asOUString();
154 bool WpADOConnection::PutDefaultDatabase(const OUString& _bstr)
156 assert(pInterface);
157 OLEString bstr(_bstr);
158 bool bErg = SUCCEEDED(pInterface->put_DefaultDatabase(bstr.asBSTR()));
160 return bErg;
163 IsolationLevelEnum WpADOConnection::get_IsolationLevel() const
165 assert(pInterface);
166 IsolationLevelEnum eNum=adXactUnspecified;
167 pInterface->get_IsolationLevel(&eNum);
168 return eNum;
171 bool WpADOConnection::put_IsolationLevel(const IsolationLevelEnum& eNum)
173 assert(pInterface);
174 return SUCCEEDED(pInterface->put_IsolationLevel(eNum));
177 sal_Int32 WpADOConnection::get_Attributes() const
179 assert(pInterface);
180 sal_Int32 nRet=0;
181 pInterface->get_Attributes(&nRet);
182 return nRet;
185 bool WpADOConnection::put_Attributes(sal_Int32 nRet)
187 assert(pInterface);
188 return SUCCEEDED(pInterface->put_Attributes(nRet));
191 CursorLocationEnum WpADOConnection::get_CursorLocation() const
193 assert(pInterface);
194 CursorLocationEnum eNum=adUseNone;
195 pInterface->get_CursorLocation(&eNum);
196 return eNum;
199 bool WpADOConnection::put_CursorLocation(const CursorLocationEnum &eNum)
201 assert(pInterface);
202 return SUCCEEDED(pInterface->put_CursorLocation(eNum));
205 ConnectModeEnum WpADOConnection::get_Mode() const
207 assert(pInterface);
208 ConnectModeEnum eNum=adModeUnknown;
209 pInterface->get_Mode(&eNum);
210 return eNum;
213 bool WpADOConnection::put_Mode(const ConnectModeEnum &eNum)
215 assert(pInterface);
216 return SUCCEEDED(pInterface->put_Mode(eNum));
219 OUString WpADOConnection::get_Provider() const
221 assert(pInterface);
222 OLEString aBSTR; pInterface->get_Provider(aBSTR.getAddress());
223 return aBSTR.asOUString();
226 bool WpADOConnection::put_Provider(const OUString& _bstr)
228 assert(pInterface);
229 OLEString bstr(_bstr);
230 return SUCCEEDED(pInterface->put_Provider(bstr.asBSTR()));
233 sal_Int32 WpADOConnection::get_State() const
235 assert(pInterface);
236 sal_Int32 nRet=0;
237 pInterface->get_State(&nRet);
238 return nRet;
241 bool WpADOConnection::OpenSchema(SchemaEnum eNum,OLEVariant const & Restrictions,OLEVariant const & SchemaID,ADORecordset**pprset)
243 assert(pInterface);
244 return SUCCEEDED(pInterface->OpenSchema(eNum,Restrictions,SchemaID,pprset));
247 OUString WpADOConnection::get_Version() const
249 assert(pInterface);
250 OLEString aBSTR;
251 pInterface->get_Version(aBSTR.getAddress());
252 return aBSTR.asOUString();
255 bool WpADOCommand::putref_ActiveConnection( WpADOConnection *pCon)
257 assert(pInterface);
258 if(pCon)
259 return SUCCEEDED(pInterface->putref_ActiveConnection(pCon->pInterface));
260 else
261 return SUCCEEDED(pInterface->putref_ActiveConnection(nullptr));
264 void WpADOCommand::put_ActiveConnection(/* [in] */ const OLEVariant& vConn)
266 assert(pInterface);
267 pInterface->put_ActiveConnection(vConn);
270 void WpADOCommand::Create()
272 IClassFactory2* pInterface2 = nullptr;
273 HRESULT hr = CoGetClassObject( ADOS::CLSID_ADOCOMMAND_21,
274 CLSCTX_INPROC_SERVER,
275 nullptr,
276 IID_IClassFactory2,
277 reinterpret_cast<void**>(&pInterface2) );
279 if( !FAILED( hr ) )
281 ADOCommand* pCommand=nullptr;
282 IUnknown* pOuter=nullptr;
284 hr = pInterface2->CreateInstanceLic( pOuter,
285 nullptr,
286 ADOS::IID_ADOCOMMAND_21,
287 ADOS::GetKeyStr().asBSTR(),
288 reinterpret_cast<void**>(&pCommand));
290 if( !FAILED( hr ) )
292 operator=(pCommand);
293 pCommand->Release();
296 pInterface2->Release();
300 sal_Int32 WpADOCommand::get_State() const
302 assert(pInterface);
303 sal_Int32 nRet=0;
304 pInterface->get_State(&nRet);
305 return nRet;
308 OUString WpADOCommand::get_CommandText() const
310 assert(pInterface);
311 OLEString aBSTR;
312 pInterface->get_CommandText(aBSTR.getAddress());
313 return aBSTR.asOUString();
316 bool WpADOCommand::put_CommandText(const OUString &aCon)
318 assert(pInterface);
319 OLEString bstr(aCon);
320 bool bErg = SUCCEEDED(pInterface->put_CommandText(bstr.asBSTR()));
322 return bErg;
325 sal_Int32 WpADOCommand::get_CommandTimeout() const
327 assert(pInterface);
328 sal_Int32 nRet=0;
329 pInterface->get_CommandTimeout(&nRet);
330 return nRet;
333 void WpADOCommand::put_CommandTimeout(sal_Int32 nRet)
335 assert(pInterface);
336 pInterface->put_CommandTimeout(nRet);
339 bool WpADOCommand::get_Prepared() const
341 assert(pInterface);
342 VARIANT_BOOL bPrepared = VARIANT_FALSE;
343 pInterface->get_Prepared(&bPrepared);
344 return bPrepared == VARIANT_TRUE;
347 bool WpADOCommand::put_Prepared(VARIANT_BOOL bPrepared) const
349 assert(pInterface);
350 return SUCCEEDED(pInterface->put_Prepared(bPrepared));
353 bool WpADOCommand::Execute(OLEVariant& RecordsAffected,OLEVariant& Params,long Options, ADORecordset** ppiRset)
355 assert(pInterface);
356 return SUCCEEDED(pInterface->Execute(&RecordsAffected,&Params,Options,ppiRset));
359 ADOParameter* WpADOCommand::CreateParameter(const OUString &_bstr,DataTypeEnum Type,ParameterDirectionEnum Direction,long nSize,const OLEVariant &Value)
361 assert(pInterface);
362 ADOParameter* pPara = nullptr;
363 OLEString bstr(_bstr);
364 bool bErg = SUCCEEDED(pInterface->CreateParameter(bstr.asBSTR(),Type,Direction,nSize,Value,&pPara));
366 return bErg ? pPara : nullptr;
369 ADOParameters* WpADOCommand::get_Parameters() const
371 assert(pInterface);
372 ADOParameters* pPara=nullptr;
373 pInterface->get_Parameters(&pPara);
374 return pPara;
377 bool WpADOCommand::put_CommandType( /* [in] */ CommandTypeEnum lCmdType)
379 assert(pInterface);
380 return SUCCEEDED(pInterface->put_CommandType(lCmdType));
383 CommandTypeEnum WpADOCommand::get_CommandType() const
385 assert(pInterface);
386 CommandTypeEnum eNum=adCmdUnspecified;
387 pInterface->get_CommandType(&eNum);
388 return eNum;
391 // returns the name of the field
392 OUString WpADOCommand::GetName() const
394 assert(pInterface);
395 OLEString aBSTR;
396 pInterface->get_Name(aBSTR.getAddress());
397 return aBSTR.asOUString();
400 bool WpADOCommand::put_Name(const OUString& Name)
402 assert(pInterface);
403 OLEString bstr(Name);
404 bool bErg = SUCCEEDED(pInterface->put_Name(bstr.asBSTR()));
406 return bErg;
408 bool WpADOCommand::Cancel()
410 assert(pInterface);
411 return SUCCEEDED(pInterface->Cancel());
414 OUString WpADOError::GetDescription() const
416 assert(pInterface);
417 OLEString aBSTR;
418 pInterface->get_Description(aBSTR.getAddress());
419 return aBSTR.asOUString();
422 OUString WpADOError::GetSource() const
424 assert(pInterface);
425 OLEString aBSTR;
426 pInterface->get_Source(aBSTR.getAddress());
427 return aBSTR.asOUString();
430 sal_Int32 WpADOError::GetNumber() const
432 assert(pInterface);
433 sal_Int32 nErrNr=0;
434 pInterface->get_Number(&nErrNr);
435 return nErrNr;
438 OUString WpADOError::GetSQLState() const
440 assert(pInterface);
441 OLEString aBSTR;
442 pInterface->get_SQLState(aBSTR.getAddress());
443 return aBSTR.asOUString();
446 sal_Int32 WpADOError::GetNativeError() const
448 assert(pInterface);
449 sal_Int32 nErrNr=0;
450 pInterface->get_NativeError(&nErrNr);
451 return nErrNr;
454 WpADOProperties WpADOField::get_Properties()
456 assert(pInterface);
457 ADOProperties* pProps = nullptr;
458 pInterface->get_Properties(&pProps);
459 WpADOProperties aProps;
461 aProps.setWithOutAddRef(pProps);
462 return aProps;
465 sal_Int32 WpADOField::GetActualSize() const
467 assert(pInterface);
468 ADO_LONGPTR nActualSize=0;
469 pInterface->get_ActualSize(&nActualSize);
470 return nActualSize;
473 sal_Int32 WpADOField::GetAttributes() const
475 assert(pInterface);
476 sal_Int32 eADOSFieldAttributes=0;
477 pInterface->get_Attributes(&eADOSFieldAttributes);
478 return eADOSFieldAttributes;
481 sal_Int32 WpADOField::GetStatus() const
483 assert(pInterface);
484 // pInterface->get_Status(&eADOSFieldAttributes);
485 return 0;
488 sal_Int32 WpADOField::GetDefinedSize() const
490 assert(pInterface);
491 ADO_LONGPTR nDefinedSize=0;
492 pInterface->get_DefinedSize(&nDefinedSize);
493 return nDefinedSize;
496 // returns the name of the field
497 OUString WpADOField::GetName() const
499 assert(pInterface);
500 OLEString aBSTR;
501 pInterface->get_Name(aBSTR.getAddress());
502 return aBSTR.asOUString();
505 DataTypeEnum WpADOField::GetADOType() const
507 assert(pInterface);
508 DataTypeEnum eType=adEmpty;
509 pInterface->get_Type(&eType);
510 return eType;
513 void WpADOField::get_Value(OLEVariant& aValVar) const
515 assert(pInterface);
516 aValVar.setEmpty();
517 pInterface->get_Value(&aValVar);
520 OLEVariant WpADOField::get_Value() const
522 assert(pInterface);
523 OLEVariant aValVar;
524 pInterface->get_Value(&aValVar);
525 return aValVar;
528 bool WpADOField::PutValue(const OLEVariant& aVariant)
530 assert(pInterface);
531 return (SUCCEEDED(pInterface->put_Value(aVariant)));
534 sal_Int32 WpADOField::GetPrecision() const
536 assert(pInterface);
537 sal_uInt8 eType=0;
538 pInterface->get_Precision(&eType);
539 return eType;
542 sal_Int32 WpADOField::GetNumericScale() const
544 assert(pInterface);
545 sal_uInt8 eType=0;
546 pInterface->get_NumericScale(&eType);
547 return eType;
550 bool WpADOField::AppendChunk(const OLEVariant& Variant)
552 assert(pInterface);
553 return (SUCCEEDED(pInterface->AppendChunk(Variant)));
556 OLEVariant WpADOField::GetChunk(long Length) const
558 assert(pInterface);
559 OLEVariant aValVar;
560 pInterface->GetChunk(Length,&aValVar);
561 return aValVar;
564 void WpADOField::GetChunk(long Length,OLEVariant &aValVar) const
566 assert(pInterface);
567 pInterface->GetChunk(Length,&aValVar);
570 OLEVariant WpADOField::GetOriginalValue() const
572 assert(pInterface);
573 OLEVariant aValVar;
574 pInterface->get_OriginalValue(&aValVar);
575 return aValVar;
578 void WpADOField::GetOriginalValue(OLEVariant &aValVar) const
580 assert(pInterface);
581 pInterface->get_OriginalValue(&aValVar);
584 OLEVariant WpADOField::GetUnderlyingValue() const
586 assert(pInterface);
587 OLEVariant aValVar;
588 pInterface->get_UnderlyingValue(&aValVar);
589 return aValVar;
592 void WpADOField::GetUnderlyingValue(OLEVariant &aValVar) const
594 assert(pInterface);
595 pInterface->get_UnderlyingValue(&aValVar);
598 bool WpADOField::PutPrecision(sal_Int8 _prec)
600 assert(pInterface);
601 return (SUCCEEDED(pInterface->put_Precision(_prec)));
604 bool WpADOField::PutNumericScale(sal_Int8 _prec)
606 assert(pInterface);
607 return (SUCCEEDED(pInterface->put_NumericScale(_prec)));
610 void WpADOField::PutADOType(DataTypeEnum eType)
612 assert(pInterface);
613 pInterface->put_Type(eType);
616 bool WpADOField::PutDefinedSize(sal_Int32 _nDefSize)
618 assert(pInterface);
619 return (SUCCEEDED(pInterface->put_DefinedSize(_nDefSize)));
622 bool WpADOField::PutAttributes(sal_Int32 _nDefSize)
624 assert(pInterface);
625 return (SUCCEEDED(pInterface->put_Attributes(_nDefSize)));
628 OLEVariant WpADOProperty::GetValue() const
630 OLEVariant aValVar;
631 if(pInterface)
632 pInterface->get_Value(&aValVar);
633 return aValVar;
636 void WpADOProperty::GetValue(OLEVariant &aValVar) const
638 assert(pInterface);
639 if(pInterface)
640 pInterface->get_Value(&aValVar);
643 bool WpADOProperty::PutValue(const OLEVariant &aValVar)
645 assert(pInterface);
646 return (SUCCEEDED(pInterface->put_Value(aValVar)));
649 OUString WpADOProperty::GetName() const
651 assert(pInterface);
652 OLEString aBSTR;
653 pInterface->get_Name(aBSTR.getAddress());
654 return aBSTR.asOUString();
657 DataTypeEnum WpADOProperty::GetADOType() const
659 assert(pInterface);
660 DataTypeEnum eType=adEmpty;
661 pInterface->get_Type(&eType);
662 return eType;
665 sal_Int32 WpADOProperty::GetAttributes() const
667 assert(pInterface);
668 sal_Int32 eADOSFieldAttributes=0;
669 pInterface->get_Attributes(&eADOSFieldAttributes);
670 return eADOSFieldAttributes;
673 bool WpADOProperty::PutAttributes(sal_Int32 _nDefSize)
675 assert(pInterface);
676 return (SUCCEEDED(pInterface->put_Attributes(_nDefSize)));
678 void WpADORecordset::Create()
680 IClassFactory2* pInterface2 = nullptr;
681 HRESULT hr = CoGetClassObject( ADOS::CLSID_ADORECORDSET_21,
682 CLSCTX_INPROC_SERVER,
683 nullptr,
684 IID_IClassFactory2,
685 reinterpret_cast<void**>(&pInterface2) );
687 if( !FAILED( hr ) )
689 ADORecordset *pRec = nullptr;
690 IUnknown *pOuter = nullptr;
691 hr = pInterface2->CreateInstanceLic( pOuter,
692 nullptr,
693 ADOS::IID_ADORECORDSET_21,
694 ADOS::GetKeyStr().asBSTR(),
695 reinterpret_cast<void**>(&pRec));
697 if( !FAILED( hr ) )
699 operator=(pRec);
700 pRec->Release();
703 pInterface2->Release();
707 bool WpADORecordset::Open(
708 /* [optional][in] */ VARIANT Source,
709 /* [optional][in] */ VARIANT ActiveConnection,
710 /* [defaultvalue][in] */ CursorTypeEnum CursorType,
711 /* [defaultvalue][in] */ LockTypeEnum LockType,
712 /* [defaultvalue][in] */ sal_Int32 Options)
714 assert(pInterface);
715 return (SUCCEEDED(pInterface->Open(Source,ActiveConnection,CursorType,LockType,Options)));
719 LockTypeEnum WpADORecordset::GetLockType()
721 assert(pInterface);
722 LockTypeEnum eType=adLockUnspecified;
723 pInterface->get_LockType(&eType);
724 return eType;
727 void WpADORecordset::Close()
729 assert(pInterface);
730 pInterface->Close();
733 bool WpADORecordset::Cancel() const
735 assert(pInterface);
736 return (SUCCEEDED(pInterface->Cancel()));
739 sal_Int32 WpADORecordset::get_State()
741 assert(pInterface);
742 sal_Int32 nState = 0;
743 pInterface->get_State(&nState);
744 return nState;
747 bool WpADORecordset::Supports( /* [in] */ CursorOptionEnum CursorOptions)
749 assert(pInterface);
750 VARIANT_BOOL bSupports=VARIANT_FALSE;
751 pInterface->Supports(CursorOptions,&bSupports);
752 return bSupports == VARIANT_TRUE;
755 PositionEnum_Param WpADORecordset::get_AbsolutePosition()
757 assert(pInterface);
758 PositionEnum_Param aTemp=adPosUnknown;
759 pInterface->get_AbsolutePosition(&aTemp);
760 return aTemp;
763 void WpADORecordset::GetDataSource(IUnknown** _pInterface) const
765 assert(pInterface);
766 pInterface->get_DataSource(_pInterface);
769 void WpADORecordset::PutRefDataSource(IUnknown* _pInterface)
771 assert(pInterface);
772 pInterface->putref_DataSource(_pInterface);
775 void WpADORecordset::GetBookmark(VARIANT& var)
777 assert(pInterface);
778 pInterface->get_Bookmark(&var);
781 OLEVariant WpADORecordset::GetBookmark()
783 assert(pInterface);
784 OLEVariant var;
785 pInterface->get_Bookmark(&var);
786 return var;
789 CompareEnum WpADORecordset::CompareBookmarks(const OLEVariant& left,const OLEVariant& right)
791 assert(pInterface);
792 CompareEnum eNum=adCompareNotComparable;
793 pInterface->CompareBookmarks(left,right,&eNum);
794 return eNum;
797 bool WpADORecordset::SetBookmark(const OLEVariant &pSafeAr)
799 assert(pInterface);
800 return SUCCEEDED(pInterface->put_Bookmark(pSafeAr));
804 WpADOFields WpADORecordset::GetFields() const
806 assert(pInterface);
807 ADOFields* pFields=nullptr;
808 pInterface->get_Fields(&pFields);
809 WpADOFields aFields;
810 aFields.setWithOutAddRef(pFields);
811 return aFields;
815 bool WpADORecordset::Move(sal_Int32 nRows, VARIANT aBmk) {return pInterface && SUCCEEDED(pInterface->Move(nRows, aBmk));}
816 bool WpADORecordset::MoveNext() {return pInterface && SUCCEEDED(pInterface->MoveNext());}
817 bool WpADORecordset::MovePrevious() {return pInterface && SUCCEEDED(pInterface->MovePrevious());}
818 bool WpADORecordset::MoveFirst() {return pInterface && SUCCEEDED(pInterface->MoveFirst());}
819 bool WpADORecordset::MoveLast() {return pInterface && SUCCEEDED(pInterface->MoveLast());}
821 bool WpADORecordset::IsAtBOF() const
823 assert(pInterface);
824 VARIANT_BOOL bIsAtBOF=VARIANT_FALSE;
825 pInterface->get_BOF(&bIsAtBOF);
826 return bIsAtBOF == VARIANT_TRUE;
829 bool WpADORecordset::IsAtEOF() const
831 assert(pInterface);
832 VARIANT_BOOL bIsAtEOF=VARIANT_FALSE;
833 pInterface->get_EOF(&bIsAtEOF);
834 return bIsAtEOF == VARIANT_TRUE;
837 bool WpADORecordset::Delete(AffectEnum eNum)
839 assert(pInterface);
840 return SUCCEEDED(pInterface->Delete(eNum));
843 bool WpADORecordset::AddNew(const OLEVariant &FieldList,const OLEVariant &Values)
845 assert(pInterface);
846 return SUCCEEDED(pInterface->AddNew(FieldList,Values));
849 bool WpADORecordset::Update(const OLEVariant &FieldList,const OLEVariant &Values)
851 assert(pInterface);
852 return SUCCEEDED(pInterface->Update(FieldList,Values));
855 bool WpADORecordset::CancelUpdate()
857 assert(pInterface);
858 return SUCCEEDED(pInterface->CancelUpdate());
861 WpADOProperties WpADORecordset::get_Properties() const
863 assert(pInterface);
864 ADOProperties* pProps=nullptr;
865 pInterface->get_Properties(&pProps);
866 WpADOProperties aProps;
867 aProps.setWithOutAddRef(pProps);
868 return aProps;
871 bool WpADORecordset::NextRecordset(OLEVariant& RecordsAffected,ADORecordset** ppiRset)
873 assert(pInterface);
874 return SUCCEEDED(pInterface->NextRecordset(&RecordsAffected,ppiRset));
877 bool WpADORecordset::get_RecordCount(ADO_LONGPTR &_nRet) const
879 assert(pInterface);
880 return SUCCEEDED(pInterface->get_RecordCount(&_nRet));
883 bool WpADORecordset::get_MaxRecords(ADO_LONGPTR &_nRet) const
885 assert(pInterface);
886 return SUCCEEDED(pInterface->get_MaxRecords(&_nRet));
889 bool WpADORecordset::put_MaxRecords(ADO_LONGPTR _nRet)
891 assert(pInterface);
892 return SUCCEEDED(pInterface->put_MaxRecords(_nRet));
895 bool WpADORecordset::get_CursorType(CursorTypeEnum &_nRet) const
897 assert(pInterface);
898 return SUCCEEDED(pInterface->get_CursorType(&_nRet));
901 bool WpADORecordset::put_CursorType(CursorTypeEnum _nRet)
903 assert(pInterface);
904 return SUCCEEDED(pInterface->put_CursorType(_nRet));
907 bool WpADORecordset::get_LockType(LockTypeEnum &_nRet) const
909 assert(pInterface);
910 return SUCCEEDED(pInterface->get_LockType(&_nRet));
913 bool WpADORecordset::put_LockType(LockTypeEnum _nRet)
915 assert(pInterface);
916 return SUCCEEDED(pInterface->put_LockType(_nRet));
919 bool WpADORecordset::get_CacheSize(sal_Int32 &_nRet) const
921 assert(pInterface);
922 return SUCCEEDED(pInterface->get_CacheSize(&_nRet));
925 bool WpADORecordset::put_CacheSize(sal_Int32 _nRet)
927 assert(pInterface);
928 return SUCCEEDED(pInterface->put_CacheSize(_nRet));
931 bool WpADORecordset::UpdateBatch(AffectEnum AffectRecords)
933 assert(pInterface);
934 return SUCCEEDED(pInterface->UpdateBatch(AffectRecords));
937 OUString WpADOParameter::GetName() const
939 assert(pInterface);
940 OLEString aBSTR;
941 pInterface->get_Name(aBSTR.getAddress());
942 return aBSTR.asOUString();
945 DataTypeEnum WpADOParameter::GetADOType() const
947 assert(pInterface);
948 DataTypeEnum eType=adEmpty;
949 pInterface->get_Type(&eType);
950 return eType;
953 void WpADOParameter::put_Type(const DataTypeEnum& _eType)
955 assert(pInterface);
956 pInterface->put_Type(_eType);
959 sal_Int32 WpADOParameter::GetAttributes() const
961 assert(pInterface);
962 sal_Int32 eADOSFieldAttributes=0;
963 pInterface->get_Attributes(&eADOSFieldAttributes);
964 return eADOSFieldAttributes;
967 sal_Int32 WpADOParameter::GetPrecision() const
969 assert(pInterface);
970 sal_uInt8 eType=0;
971 pInterface->get_Precision(&eType);
972 return eType;
975 sal_Int32 WpADOParameter::GetNumericScale() const
977 assert(pInterface);
978 sal_uInt8 eType=0;
979 pInterface->get_NumericScale(&eType);
980 return eType;
983 ParameterDirectionEnum WpADOParameter::get_Direction() const
985 assert(pInterface);
986 ParameterDirectionEnum alParmDirection=adParamUnknown;
987 pInterface->get_Direction(&alParmDirection);
988 return alParmDirection;
991 void WpADOParameter::GetValue(OLEVariant& aValVar) const
993 assert(pInterface);
994 pInterface->get_Value(&aValVar);
997 OLEVariant WpADOParameter::GetValue() const
999 assert(pInterface);
1000 OLEVariant aValVar;
1001 pInterface->get_Value(&aValVar);
1002 return aValVar;
1005 bool WpADOParameter::PutValue(const OLEVariant& aVariant)
1007 assert(pInterface);
1008 return (SUCCEEDED(pInterface->put_Value(aVariant)));
1010 bool WpADOParameter::AppendChunk(const OLEVariant& aVariant)
1012 assert(pInterface);
1013 return (SUCCEEDED(pInterface->AppendChunk(aVariant)));
1015 bool WpADOParameter::put_Size(sal_Int32 _nSize)
1017 assert(pInterface);
1018 return (SUCCEEDED(pInterface->put_Size(_nSize)));
1021 OUString WpADOColumn::get_Name() const
1023 assert(pInterface);
1024 OLEString aBSTR;
1025 pInterface->get_Name(aBSTR.getAddress());
1026 return aBSTR.asOUString();
1029 OUString WpADOColumn::get_RelatedColumn() const
1031 assert(pInterface);
1032 OLEString aBSTR;
1033 pInterface->get_RelatedColumn(aBSTR.getAddress());
1034 return aBSTR.asOUString();
1037 void WpADOColumn::put_Name(const OUString& _rName)
1039 assert(pInterface);
1040 OLEString bstr(_rName);
1041 pInterface->put_Name(bstr.asBSTR());
1043 void WpADOColumn::put_RelatedColumn(const OUString& _rName)
1045 assert(pInterface);
1046 OLEString bstr(_rName);
1047 pInterface->put_RelatedColumn(bstr.asBSTR());
1050 DataTypeEnum WpADOColumn::get_Type() const
1052 assert(pInterface);
1053 DataTypeEnum eNum = adVarChar;
1054 pInterface->get_Type(&eNum);
1055 return eNum;
1058 void WpADOColumn::put_Type(const DataTypeEnum& _eNum)
1060 assert(pInterface);
1061 pInterface->put_Type(_eNum);
1064 sal_Int32 WpADOColumn::get_Precision() const
1066 assert(pInterface);
1067 sal_Int32 nPrec=0;
1068 pInterface->get_Precision(&nPrec);
1069 return nPrec;
1072 void WpADOColumn::put_Precision(sal_Int32 _nPre)
1074 assert(pInterface);
1075 pInterface->put_Precision(_nPre);
1078 sal_Int32 WpADOColumn::get_DefinedSize() const
1080 assert(pInterface);
1081 sal_Int32 nPrec=0;
1082 pInterface->get_DefinedSize(&nPrec);
1083 return nPrec;
1085 sal_uInt8 WpADOColumn::get_NumericScale() const
1087 assert(pInterface);
1088 sal_uInt8 nPrec=0;
1089 pInterface->get_NumericScale(&nPrec);
1090 return nPrec;
1093 void WpADOColumn::put_NumericScale(sal_Int8 _nScale)
1095 assert(pInterface);
1096 pInterface->put_NumericScale(_nScale);
1099 SortOrderEnum WpADOColumn::get_SortOrder() const
1101 assert(pInterface);
1102 SortOrderEnum nPrec=adSortAscending;
1103 pInterface->get_SortOrder(&nPrec);
1104 return nPrec;
1107 void WpADOColumn::put_SortOrder(SortOrderEnum _nScale)
1109 assert(pInterface);
1110 pInterface->put_SortOrder(_nScale);
1113 ColumnAttributesEnum WpADOColumn::get_Attributes() const
1115 assert(pInterface);
1116 ColumnAttributesEnum eNum=adColNullable;
1117 pInterface->get_Attributes(&eNum);
1118 return eNum;
1121 bool WpADOColumn::put_Attributes(const ColumnAttributesEnum& _eNum)
1123 assert(pInterface);
1124 return SUCCEEDED(pInterface->put_Attributes(_eNum));
1127 WpADOProperties WpADOColumn::get_Properties() const
1129 assert(pInterface);
1130 ADOProperties* pProps = nullptr;
1131 pInterface->get_Properties(&pProps);
1132 WpADOProperties aProps;
1134 aProps.setWithOutAddRef(pProps);
1135 return aProps;
1138 OUString WpADOKey::get_Name() const
1140 assert(pInterface);
1141 OLEString aBSTR;
1142 pInterface->get_Name(aBSTR.getAddress());
1143 return aBSTR.asOUString();
1146 void WpADOKey::put_Name(const OUString& _rName)
1148 assert(pInterface);
1149 OLEString bstr(_rName);
1150 pInterface->put_Name(bstr.asBSTR());
1153 KeyTypeEnum WpADOKey::get_Type() const
1155 assert(pInterface);
1156 KeyTypeEnum eNum=adKeyPrimary;
1157 pInterface->get_Type(&eNum);
1158 return eNum;
1161 void WpADOKey::put_Type(const KeyTypeEnum& _eNum)
1163 assert(pInterface);
1164 pInterface->put_Type(_eNum);
1167 OUString WpADOKey::get_RelatedTable() const
1169 assert(pInterface);
1170 OLEString aBSTR;
1171 pInterface->get_RelatedTable(aBSTR.getAddress());
1172 return aBSTR.asOUString();
1175 void WpADOKey::put_RelatedTable(const OUString& _rName)
1177 assert(pInterface);
1178 OLEString bstr(_rName);
1179 pInterface->put_RelatedTable(bstr.asBSTR());
1182 RuleEnum WpADOKey::get_DeleteRule() const
1184 assert(pInterface);
1185 RuleEnum eNum = adRINone;
1186 pInterface->get_DeleteRule(&eNum);
1187 return eNum;
1190 void WpADOKey::put_DeleteRule(const RuleEnum& _eNum)
1192 assert(pInterface);
1193 pInterface->put_DeleteRule(_eNum);
1196 RuleEnum WpADOKey::get_UpdateRule() const
1198 assert(pInterface);
1199 RuleEnum eNum = adRINone;
1200 pInterface->get_UpdateRule(&eNum);
1201 return eNum;
1204 void WpADOKey::put_UpdateRule(const RuleEnum& _eNum)
1206 assert(pInterface);
1207 pInterface->put_UpdateRule(_eNum);
1210 WpADOColumns WpADOKey::get_Columns() const
1212 assert(pInterface);
1213 ADOColumns* pCols = nullptr;
1214 pInterface->get_Columns(&pCols);
1215 WpADOColumns aCols;
1216 aCols.setWithOutAddRef(pCols);
1217 return aCols;
1220 OUString WpADOIndex::get_Name() const
1222 assert(pInterface);
1223 OLEString aBSTR;
1224 pInterface->get_Name(aBSTR.getAddress());
1225 return aBSTR.asOUString();
1228 void WpADOIndex::put_Name(const OUString& _rName)
1230 assert(pInterface);
1231 OLEString bstr(_rName);
1232 pInterface->put_Name(bstr.asBSTR());
1235 bool WpADOIndex::get_Clustered() const
1237 assert(pInterface);
1238 VARIANT_BOOL eNum = VARIANT_FALSE;
1239 pInterface->get_Clustered(&eNum);
1240 return eNum == VARIANT_TRUE;
1243 void WpADOIndex::put_Clustered(bool _b)
1245 assert(pInterface);
1246 pInterface->put_Clustered(_b ? VARIANT_TRUE : VARIANT_FALSE);
1249 bool WpADOIndex::get_Unique() const
1251 assert(pInterface);
1252 VARIANT_BOOL eNum = VARIANT_FALSE;
1253 pInterface->get_Unique(&eNum);
1254 return eNum == VARIANT_TRUE;
1257 void WpADOIndex::put_Unique(bool _b)
1259 assert(pInterface);
1260 pInterface->put_Unique(_b ? VARIANT_TRUE : VARIANT_FALSE);
1263 bool WpADOIndex::get_PrimaryKey() const
1265 assert(pInterface);
1266 VARIANT_BOOL eNum = VARIANT_FALSE;
1267 pInterface->get_PrimaryKey(&eNum);
1268 return eNum == VARIANT_TRUE;
1271 void WpADOIndex::put_PrimaryKey(bool _b)
1273 assert(pInterface);
1274 pInterface->put_PrimaryKey(_b ? VARIANT_TRUE : VARIANT_FALSE);
1277 WpADOColumns WpADOIndex::get_Columns() const
1279 assert(pInterface);
1280 ADOColumns* pCols = nullptr;
1281 pInterface->get_Columns(&pCols);
1282 WpADOColumns aCols;
1283 aCols.setWithOutAddRef(pCols);
1284 return aCols;
1287 void WpADOCatalog::putref_ActiveConnection(IDispatch* pCon)
1289 assert(pInterface);
1290 pInterface->putref_ActiveConnection(pCon);
1293 WpADOTables WpADOCatalog::get_Tables()
1295 assert(pInterface);
1296 ADOTables* pRet = nullptr;
1297 pInterface->get_Tables(&pRet);
1298 WpADOTables aRet;
1299 aRet.setWithOutAddRef(pRet);
1300 return aRet;
1303 WpADOViews WpADOCatalog::get_Views()
1305 assert(pInterface);
1306 ADOViews* pRet = nullptr;
1307 pInterface->get_Views(&pRet);
1308 WpADOViews aRet;
1309 aRet.setWithOutAddRef(pRet);
1310 return aRet;
1313 WpADOGroups WpADOCatalog::get_Groups()
1315 assert(pInterface);
1316 ADOGroups* pRet = nullptr;
1317 pInterface->get_Groups(&pRet);
1318 WpADOGroups aRet;
1319 aRet.setWithOutAddRef(pRet);
1320 return aRet;
1323 WpADOUsers WpADOCatalog::get_Users()
1325 assert(pInterface);
1326 ADOUsers* pRet = nullptr;
1327 pInterface->get_Users(&pRet);
1328 WpADOUsers aRet;
1329 aRet.setWithOutAddRef(pRet);
1330 return aRet;
1333 ADOProcedures* WpADOCatalog::get_Procedures()
1335 assert(pInterface);
1336 ADOProcedures* pRet = nullptr;
1337 pInterface->get_Procedures(&pRet);
1338 return pRet;
1341 OUString WpADOTable::get_Name() const
1343 assert(pInterface);
1344 OLEString aBSTR;
1345 pInterface->get_Name(aBSTR.getAddress());
1346 return aBSTR.asOUString();
1349 void WpADOTable::put_Name(const OUString& _rName)
1351 assert(pInterface);
1352 OLEString bstr(_rName);
1353 pInterface->put_Name(bstr.asBSTR());
1356 OUString WpADOTable::get_Type() const
1358 assert(pInterface);
1359 OLEString aBSTR;
1360 pInterface->get_Type(aBSTR.getAddress());
1361 return aBSTR.asOUString();
1364 WpADOColumns WpADOTable::get_Columns() const
1366 assert(pInterface);
1367 ADOColumns* pCols = nullptr;
1368 pInterface->get_Columns(&pCols);
1369 WpADOColumns aCols;
1370 aCols.setWithOutAddRef(pCols);
1371 return aCols;
1374 WpADOIndexes WpADOTable::get_Indexes() const
1376 assert(pInterface);
1377 ADOIndexes* pCols = nullptr;
1378 pInterface->get_Indexes(&pCols);
1379 WpADOIndexes aRet;
1380 aRet.setWithOutAddRef(pCols);
1381 return aRet;
1384 WpADOKeys WpADOTable::get_Keys() const
1386 assert(pInterface);
1387 ADOKeys* pCols = nullptr;
1388 pInterface->get_Keys(&pCols);
1389 WpADOKeys aRet;
1390 aRet.setWithOutAddRef(pCols);
1391 return aRet;
1394 WpADOCatalog WpADOTable::get_ParentCatalog() const
1396 assert(pInterface);
1397 ADOCatalog* pCat = nullptr;
1398 pInterface->get_ParentCatalog(&pCat);
1399 WpADOCatalog aRet;
1400 aRet.setWithOutAddRef(pCat);
1401 return aRet;
1404 WpADOProperties WpADOTable::get_Properties() const
1406 assert(pInterface);
1407 ADOProperties* pProps = nullptr;
1408 pInterface->get_Properties(&pProps);
1409 WpADOProperties aProps;
1410 aProps.setWithOutAddRef(pProps);
1411 return aProps;
1414 OUString WpADOView::get_Name() const
1416 assert(pInterface);
1417 OLEString aBSTR;
1418 pInterface->get_Name(aBSTR.getAddress());
1419 return aBSTR.asOUString();
1422 void WpADOView::get_Command(OLEVariant& _rVar) const
1424 assert(pInterface);
1425 pInterface->get_Command(&_rVar);
1428 void WpADOView::put_Command(OLEVariant const & _rVar)
1430 assert(pInterface);
1431 pInterface->put_Command(_rVar);
1434 OUString WpADOGroup::get_Name() const
1436 OLEString aBSTR;
1437 pInterface->get_Name(aBSTR.getAddress());
1438 return aBSTR.asOUString();
1441 void WpADOGroup::put_Name(const OUString& _rName)
1443 OLEString bstr(_rName);
1444 pInterface->put_Name(bstr.asBSTR());
1447 RightsEnum WpADOGroup::GetPermissions(
1448 /* [in] */ const OLEVariant& Name,
1449 /* [in] */ ObjectTypeEnum ObjectType)
1451 RightsEnum Rights=adRightNone;
1452 OLEVariant ObjectTypeId;
1453 ObjectTypeId.setNoArg();
1454 pInterface->GetPermissions(Name,ObjectType,ObjectTypeId,&Rights);
1455 return Rights;
1458 bool WpADOGroup::SetPermissions(
1459 /* [in] */ const OLEVariant& Name,
1460 /* [in] */ ObjectTypeEnum ObjectType,
1461 /* [in] */ ActionEnum Action,
1462 /* [in] */ RightsEnum Rights)
1464 OLEVariant ObjectTypeId;
1465 ObjectTypeId.setNoArg();
1466 return SUCCEEDED(pInterface->SetPermissions(Name,ObjectType,Action,Rights,adInheritNone,ObjectTypeId));
1469 WpADOUsers WpADOGroup::get_Users( )
1471 ADOUsers* pRet = nullptr;
1472 pInterface->get_Users( &pRet);
1473 WpADOUsers aRet;
1474 aRet.setWithOutAddRef(pRet);
1475 return aRet;
1478 OUString WpADOUser::get_Name() const
1480 OLEString aBSTR;
1481 pInterface->get_Name(aBSTR.getAddress());
1482 return aBSTR.asOUString();
1485 void WpADOUser::put_Name(const OUString& _rName)
1487 OLEString bstr(_rName);
1488 pInterface->put_Name(bstr.asBSTR());
1491 bool WpADOUser::ChangePassword(const OUString& _rPwd,const OUString& _rNewPwd)
1493 OLEString sStr1(_rPwd);
1494 OLEString sStr2(_rNewPwd);
1495 bool bErg = SUCCEEDED(pInterface->ChangePassword(sStr1.asBSTR(),sStr2.asBSTR()));
1496 return bErg;
1499 WpADOGroups WpADOUser::get_Groups()
1501 ADOGroups* pRet = nullptr;
1502 pInterface->get_Groups(&pRet);
1503 WpADOGroups aRet;
1504 aRet.setWithOutAddRef(pRet);
1505 return aRet;
1508 RightsEnum WpADOUser::GetPermissions(
1509 /* [in] */ const OLEVariant& Name,
1510 /* [in] */ ObjectTypeEnum ObjectType)
1512 RightsEnum Rights=adRightNone;
1513 OLEVariant ObjectTypeId;
1514 ObjectTypeId.setNoArg();
1515 pInterface->GetPermissions(Name,ObjectType,ObjectTypeId,&Rights);
1516 return Rights;
1519 bool WpADOUser::SetPermissions(
1520 /* [in] */ const OLEVariant& Name,
1521 /* [in] */ ObjectTypeEnum ObjectType,
1522 /* [in] */ ActionEnum Action,
1523 /* [in] */ RightsEnum Rights)
1525 OLEVariant ObjectTypeId;
1526 ObjectTypeId.setNoArg();
1527 return SUCCEEDED(pInterface->SetPermissions(Name,ObjectType,Action,Rights,adInheritNone,ObjectTypeId));
1530 WpBase::WpBase() : pIUnknown(nullptr)
1533 WpBase::WpBase(IDispatch* pInt)
1534 :pIUnknown(pInt)
1536 if (pIUnknown)
1538 pIUnknown->AddRef();
1542 WpBase::WpBase(const WpBase& aWrapper)
1543 :pIUnknown(aWrapper.pIUnknown)
1545 if (pIUnknown)
1546 pIUnknown->AddRef();
1549 //inline
1550 WpBase& WpBase::operator=(const WpBase& rhs)
1552 operator=(rhs.pIUnknown);
1553 return *this;
1556 WpBase& WpBase::operator=(IDispatch* rhs)
1558 if (pIUnknown != rhs)
1560 if (pIUnknown)
1561 pIUnknown->Release();
1562 pIUnknown = rhs;
1563 if (pIUnknown)
1564 pIUnknown->AddRef();
1566 return *this;
1569 WpBase::~WpBase()
1571 if (pIUnknown)
1573 pIUnknown->Release();
1574 pIUnknown = nullptr;
1578 void WpBase::clear()
1580 if (pIUnknown)
1582 pIUnknown->Release();
1583 pIUnknown = nullptr;
1588 bool WpBase::IsValid() const
1590 return pIUnknown != nullptr;
1592 WpBase::operator IDispatch*()
1594 return pIUnknown;
1597 ADORecordset* WpADOConnection::getExportedKeys( const css::uno::Any& catalog, const OUString& schema, const OUString& table )
1599 // Create elements used in the array
1600 SAFEARRAYBOUND rgsabound[1];
1601 SAFEARRAY *psa = nullptr;
1602 OLEVariant varCriteria[6];
1604 // Create SafeArray Bounds and initialize the array
1605 rgsabound[0].lLbound = 0;
1606 rgsabound[0].cElements = SAL_N_ELEMENTS(varCriteria);
1607 psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
1609 sal_Int32 nPos=0;
1610 if(catalog.hasValue())
1611 varCriteria[nPos].setString(::comphelper::getString(catalog));
1613 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
1614 if(schema.getLength() && schema.toChar() != '%')
1615 varCriteria[nPos].setString(schema);
1616 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
1618 varCriteria[nPos].setString(table);
1619 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
1621 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
1622 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
1623 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
1625 OLEVariant vtEmpty;
1626 vtEmpty.setNoArg();
1628 // Initialize and fill the SafeArray
1629 OLEVariant vsa;
1630 vsa.setArray(psa,VT_VARIANT);
1632 ADORecordset *pRecordset = nullptr;
1633 OpenSchema(adSchemaForeignKeys,vsa,vtEmpty,&pRecordset);
1634 return pRecordset;
1637 ADORecordset* WpADOConnection::getImportedKeys( const css::uno::Any& catalog, const OUString& schema, const OUString& table )
1639 // Create elements used in the array
1640 SAFEARRAYBOUND rgsabound[1];
1641 SAFEARRAY *psa = nullptr;
1642 OLEVariant varCriteria[6];
1644 // Create SafeArray Bounds and initialize the array
1645 rgsabound[0].lLbound = 0;
1646 rgsabound[0].cElements = SAL_N_ELEMENTS(varCriteria);
1647 psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
1649 sal_Int32 nPos=0;
1650 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
1651 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
1652 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
1654 if(catalog.hasValue())
1655 varCriteria[nPos].setString(::comphelper::getString(catalog));
1657 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
1658 if(schema.getLength() && schema.toChar() != '%')
1659 varCriteria[nPos].setString(schema);
1660 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
1662 varCriteria[nPos].setString(table);
1663 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 = nullptr;
1673 OpenSchema(adSchemaForeignKeys,vsa,vtEmpty,&pRecordset);
1675 return pRecordset;
1679 ADORecordset* WpADOConnection::getPrimaryKeys( const css::uno::Any& catalog, const OUString& schema, const OUString& table )
1681 // Create elements used in the array
1682 SAFEARRAYBOUND rgsabound[1];
1683 SAFEARRAY *psa = nullptr;
1684 OLEVariant varCriteria[3];
1686 // Create SafeArray Bounds and initialize the array
1687 rgsabound[0].lLbound = 0;
1688 rgsabound[0].cElements = SAL_N_ELEMENTS(varCriteria);
1689 psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
1691 sal_Int32 nPos=0;
1692 if(catalog.hasValue())
1693 varCriteria[nPos].setString(::comphelper::getString(catalog));
1695 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
1696 if(schema.getLength() && schema.toChar() != '%')
1697 varCriteria[nPos].setString(schema);
1698 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
1700 varCriteria[nPos].setString(table);
1701 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
1704 OLEVariant vtEmpty;
1705 vtEmpty.setNoArg();
1707 // Initialize and fill the SafeArray
1708 OLEVariant vsa;
1709 vsa.setArray(psa,VT_VARIANT);
1711 ADORecordset *pRecordset = nullptr;
1712 OpenSchema(adSchemaPrimaryKeys,vsa,vtEmpty,&pRecordset);
1714 return pRecordset;
1717 ADORecordset* WpADOConnection::getIndexInfo(
1718 const css::uno::Any& catalog, const OUString& schema, const OUString& table,
1719 bool /*unique*/, bool /*approximate*/ )
1721 // Create elements used in the array
1722 SAFEARRAYBOUND rgsabound[1];
1723 SAFEARRAY *psa = nullptr;
1724 OLEVariant varCriteria[5];
1726 // Create SafeArray Bounds and initialize the array
1727 rgsabound[0].lLbound = 0;
1728 rgsabound[0].cElements = SAL_N_ELEMENTS(varCriteria);
1729 psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
1731 sal_Int32 nPos=0;
1732 if(catalog.hasValue())
1733 varCriteria[nPos].setString(::comphelper::getString(catalog));
1735 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
1736 if(schema.getLength() && schema.toChar() != '%')
1737 varCriteria[nPos].setString(schema);
1738 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
1740 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// INDEX_NAME
1742 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TYPE
1744 varCriteria[nPos].setString(table);
1745 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
1747 OLEVariant vtEmpty;
1748 vtEmpty.setNoArg();
1750 // Initialize and fill the SafeArray
1751 OLEVariant vsa;
1752 vsa.setArray(psa,VT_VARIANT);
1754 ADORecordset *pRecordset = nullptr;
1755 OpenSchema(adSchemaIndexes,vsa,vtEmpty,&pRecordset);
1757 return pRecordset;
1760 ADORecordset* WpADOConnection::getTablePrivileges( const css::uno::Any& catalog,
1761 const OUString& schemaPattern,
1762 const OUString& tableNamePattern )
1764 SAFEARRAYBOUND rgsabound[1];
1765 SAFEARRAY *psa = nullptr;
1766 OLEVariant varCriteria[5];
1768 // Create SafeArray Bounds and initialize the array
1769 rgsabound[0].lLbound = 0;
1770 rgsabound[0].cElements = SAL_N_ELEMENTS(varCriteria);
1771 psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
1773 sal_Int32 nPos=0;
1774 if(catalog.hasValue())
1775 varCriteria[nPos].setString(::comphelper::getString(catalog));
1777 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
1778 if(schemaPattern.getLength() && schemaPattern.toChar() != '%')
1779 varCriteria[nPos].setString(schemaPattern);
1780 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
1782 if(tableNamePattern.toChar() != '%')
1783 varCriteria[nPos].setString(tableNamePattern);
1784 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
1786 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// GRANTOR
1787 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// GRANTEE
1789 OLEVariant vtEmpty;
1790 vtEmpty.setNoArg();
1792 // Initialize and fill the SafeArray
1793 OLEVariant vsa;
1794 vsa.setArray(psa,VT_VARIANT);
1796 ADORecordset *pRecordset = nullptr;
1797 OpenSchema(adSchemaTablePrivileges,vsa,vtEmpty,&pRecordset);
1799 return pRecordset;
1802 ADORecordset* WpADOConnection::getCrossReference( const css::uno::Any& primaryCatalog,
1803 const OUString& primarySchema,
1804 const OUString& primaryTable,
1805 const css::uno::Any& foreignCatalog,
1806 const OUString& foreignSchema,
1807 const OUString& foreignTable)
1809 // Create elements used in the array
1810 SAFEARRAYBOUND rgsabound[1];
1811 SAFEARRAY *psa = nullptr;
1812 OLEVariant varCriteria[6];
1814 // Create SafeArray Bounds and initialize the array
1815 rgsabound[0].lLbound = 0;
1816 rgsabound[0].cElements = SAL_N_ELEMENTS(varCriteria);
1817 psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
1819 sal_Int32 nPos=0;
1820 if(primaryCatalog.hasValue())
1821 varCriteria[nPos].setString(::comphelper::getString(primaryCatalog));
1823 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
1824 if(primarySchema.getLength() && primarySchema.toChar() != '%')
1825 varCriteria[nPos].setString(primarySchema);
1826 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
1828 varCriteria[nPos].setString(primaryTable);
1829 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
1831 if(foreignCatalog.hasValue())
1832 varCriteria[nPos].setString(::comphelper::getString(foreignCatalog));
1834 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
1835 if(foreignSchema.getLength() && foreignSchema.toChar() != '%')
1836 varCriteria[nPos].setString(foreignSchema);
1837 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
1839 varCriteria[nPos].setString(foreignTable);
1840 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
1842 OLEVariant vtEmpty;
1843 vtEmpty.setNoArg();
1845 // Initialize and fill the SafeArray
1846 OLEVariant vsa;
1847 vsa.setArray(psa,VT_VARIANT);
1849 ADORecordset *pRecordset = nullptr;
1850 OpenSchema(adSchemaForeignKeys,vsa,vtEmpty,&pRecordset);
1852 return pRecordset;
1855 ADORecordset* WpADOConnection::getProcedures( const css::uno::Any& catalog,
1856 const OUString& schemaPattern,
1857 const OUString& procedureNamePattern )
1859 SAFEARRAYBOUND rgsabound[1];
1860 SAFEARRAY *psa = nullptr;
1861 OLEVariant varCriteria[3];
1863 // Create SafeArray Bounds and initialize the array
1864 rgsabound[0].lLbound = 0;
1865 rgsabound[0].cElements = SAL_N_ELEMENTS(varCriteria);
1866 psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
1868 sal_Int32 nPos=0;
1869 if(catalog.hasValue())
1870 varCriteria[nPos].setString(::comphelper::getString(catalog));
1872 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
1873 if(schemaPattern.getLength() && schemaPattern.toChar() != '%')
1874 varCriteria[nPos].setString(schemaPattern);
1875 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
1877 if(procedureNamePattern.toChar() != '%')
1878 varCriteria[nPos].setString(procedureNamePattern);
1879 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
1881 OLEVariant vtEmpty;
1882 vtEmpty.setNoArg();
1884 // Initialize and fill the SafeArray
1885 OLEVariant vsa;
1886 vsa.setArray(psa,VT_VARIANT);
1888 ADORecordset *pRecordset = nullptr;
1889 OpenSchema(adSchemaProcedures,vsa,vtEmpty,&pRecordset);
1891 return pRecordset;
1894 ADORecordset* WpADOConnection::getProcedureColumns( const css::uno::Any& catalog,
1895 const OUString& schemaPattern,
1896 const OUString& procedureNamePattern,
1897 const OUString& columnNamePattern )
1899 // Create elements used in the array
1900 SAFEARRAYBOUND rgsabound[1];
1901 SAFEARRAY *psa = nullptr;
1902 OLEVariant varCriteria[4];
1904 // Create SafeArray Bounds and initialize the array
1905 rgsabound[0].lLbound = 0;
1906 rgsabound[0].cElements = SAL_N_ELEMENTS(varCriteria);
1907 psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
1909 sal_Int32 nPos=0;
1910 if(catalog.hasValue())
1911 varCriteria[nPos].setString(::comphelper::getString(catalog));
1913 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
1914 if(schemaPattern.getLength() && schemaPattern.toChar() != '%')
1915 varCriteria[nPos].setString(schemaPattern);
1916 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
1918 if(procedureNamePattern.toChar() != '%')
1919 varCriteria[nPos].setString(procedureNamePattern);
1920 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
1922 if(columnNamePattern.toChar() != '%')
1923 varCriteria[nPos].setString(columnNamePattern);
1924 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// COLUMN_NAME
1926 OLEVariant vtEmpty;
1927 vtEmpty.setNoArg();
1929 // Initialize and fill the SafeArray
1930 OLEVariant vsa;
1931 vsa.setArray(psa,VT_VARIANT);
1933 ADORecordset *pRecordset = nullptr;
1934 OpenSchema(adSchemaProcedureParameters,vsa,vtEmpty,&pRecordset);
1936 return pRecordset;
1939 ADORecordset* WpADOConnection::getTables( const css::uno::Any& catalog,
1940 const OUString& schemaPattern,
1941 const OUString& tableNamePattern,
1942 const css::uno::Sequence< OUString >& types )
1944 // Create elements used in the array
1945 HRESULT hr = S_OK;
1946 OLEVariant varCriteria[4];
1948 sal_Int32 nPos=0;
1949 OUString sCatalog;
1950 if ( catalog.hasValue() && (catalog >>= sCatalog) )
1951 varCriteria[nPos].setString(sCatalog);
1953 ++nPos;
1954 if(schemaPattern.getLength() && schemaPattern.toChar() != '%')
1955 varCriteria[nPos].setString(schemaPattern);
1957 ++nPos;
1958 if(tableNamePattern.toChar() != '%')
1959 varCriteria[nPos].setString(tableNamePattern);
1961 ++nPos;
1962 OUStringBuffer aTypes;
1963 const OUString* pIter = types.getConstArray();
1964 const OUString* pEnd = pIter + types.getLength();
1965 for( ; pIter != pEnd ; ++pIter)
1967 if ( aTypes.getLength() )
1968 aTypes.append(",");
1969 aTypes.append(*pIter);
1972 OUString sTypeNames = aTypes.makeStringAndClear();
1973 if ( sTypeNames.getLength() )
1974 varCriteria[nPos].setString(sTypeNames);
1976 // Create SafeArray Bounds and initialize the array
1977 const sal_Int32 nCrit = SAL_N_ELEMENTS(varCriteria);
1978 SAFEARRAYBOUND rgsabound[1];
1979 rgsabound[0].lLbound = 0;
1980 rgsabound[0].cElements = nCrit;
1981 SAFEARRAY *psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
1983 // Set the values for each element of the array
1984 for( long i = 0 ; i < nCrit && SUCCEEDED( hr );i++)
1986 hr = SafeArrayPutElement(psa, &i,&varCriteria[i]);
1989 OLEVariant vtEmpty;
1990 vtEmpty.setNoArg();
1992 // Initialize and fill the SafeArray
1993 OLEVariant vsa;
1994 vsa.setArray(psa,VT_VARIANT);
1996 ADORecordset *pRecordset = nullptr;
1997 OpenSchema(adSchemaTables,vsa,vtEmpty,&pRecordset);
1999 return pRecordset;
2002 ADORecordset* WpADOConnection::getColumns( const css::uno::Any& catalog,
2003 const OUString& schemaPattern,
2004 const OUString& tableNamePattern,
2005 const OUString& columnNamePattern )
2007 // Create elements used in the array
2008 SAFEARRAYBOUND rgsabound[1];
2009 SAFEARRAY *psa = nullptr;
2010 OLEVariant varCriteria[4];
2012 // Create SafeArray Bounds and initialize the array
2013 rgsabound[0].lLbound = 0;
2014 rgsabound[0].cElements = SAL_N_ELEMENTS(varCriteria);
2015 psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
2017 sal_Int32 nPos=0;
2018 if(catalog.hasValue())
2019 varCriteria[nPos].setString(::comphelper::getString(catalog));
2021 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
2022 if(schemaPattern.getLength() && schemaPattern.toChar() != '%')
2023 varCriteria[nPos].setString(schemaPattern);
2024 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
2026 if(tableNamePattern.toChar() != '%')
2027 varCriteria[nPos].setString(tableNamePattern);
2028 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
2030 varCriteria[nPos].setString(columnNamePattern);
2031 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// COLUMN_NAME
2033 OLEVariant vtEmpty;
2034 vtEmpty.setNoArg();
2036 // Initialize and fill the SafeArray
2037 OLEVariant vsa;
2038 vsa.setArray(psa,VT_VARIANT);
2040 ADORecordset *pRecordset = nullptr;
2041 OpenSchema(adSchemaColumns,vsa,vtEmpty,&pRecordset);
2043 return pRecordset;
2046 ADORecordset* WpADOConnection::getColumnPrivileges( const css::uno::Any& catalog,
2047 const OUString& schema,
2048 const OUString& table,
2049 const OUString& columnNamePattern )
2051 // Create elements used in the array
2052 SAFEARRAYBOUND rgsabound[1];
2053 SAFEARRAY *psa = nullptr;
2054 OLEVariant varCriteria[4];
2056 // Create SafeArray Bounds and initialize the array
2057 rgsabound[0].lLbound = 0;
2058 rgsabound[0].cElements = SAL_N_ELEMENTS(varCriteria);
2059 psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
2061 sal_Int32 nPos=0;
2062 if(catalog.hasValue())
2063 varCriteria[nPos].setString(::comphelper::getString(catalog));
2065 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
2066 if(schema.getLength() && schema.toChar() != '%')
2067 varCriteria[nPos].setString(schema);
2068 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
2070 varCriteria[nPos].setString(table);
2071 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
2073 varCriteria[nPos].setString(columnNamePattern);
2074 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// COLUMN_NAME
2076 OLEVariant vtEmpty;
2077 vtEmpty.setNoArg();
2079 // Initialize and fill the SafeArray
2080 OLEVariant vsa;
2081 vsa.setArray(psa,VT_VARIANT);
2083 ADORecordset *pRecordset = nullptr;
2084 OpenSchema(adSchemaColumnPrivileges,vsa,vtEmpty,&pRecordset);
2086 return pRecordset;
2089 ADORecordset* WpADOConnection::getTypeInfo(DataTypeEnum /*_eType*/)
2091 // Create elements used in the array
2092 OLEVariant varCriteria[2];
2093 const int nCrit = SAL_N_ELEMENTS(varCriteria);
2094 // Create SafeArray Bounds and initialize the array
2095 SAFEARRAYBOUND rgsabound[1];
2096 rgsabound[0].lLbound = 0;
2097 rgsabound[0].cElements = nCrit;
2098 SAFEARRAY *psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
2100 sal_Int32 nPos = 0;
2101 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;
2102 SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;
2104 // Initialize and fill the SafeArray
2105 OLEVariant vsa;
2106 vsa.setArray(psa,VT_VARIANT);
2108 OLEVariant aEmpty;
2109 aEmpty.setNoArg();
2111 ADORecordset *pRec=nullptr;
2112 OpenSchema(adSchemaProviderTypes,vsa,aEmpty,&pRec);
2114 return pRec;
2117 void WpADOColumn::put_ParentCatalog(/* [in] */ _ADOCatalog __RPC_FAR *ppvObject)
2119 assert(pInterface);
2120 bool bRet = SUCCEEDED(pInterface->put_ParentCatalog(ppvObject));
2121 SAL_WARN_IF(!bRet, "connectivity.ado", "Could not set ParentCatalog!");
2124 void WpADOTable::putref_ParentCatalog(/* [in] */ _ADOCatalog __RPC_FAR *ppvObject)
2126 assert(pInterface);
2127 bool bRet = SUCCEEDED(pInterface->putref_ParentCatalog(ppvObject));
2128 SAL_WARN_IF(!bRet, "connectivity.ado", "Could not set ParentCatalog!");
2131 void WpBase::setIDispatch(IDispatch* _pIUnknown)
2133 pIUnknown = _pIUnknown;
2136 void OTools::putValue(const WpADOProperties& _rProps,const OLEVariant &_aPosition,const OLEVariant &_aValVar)
2138 SAL_WARN_IF(!_rProps.IsValid(), "connectivity.ado", "Properties are not valid!");
2139 WpADOProperty aProp(_rProps.GetItem(_aPosition));
2140 if ( aProp.IsValid() )
2142 bool bRet = aProp.PutValue(_aValVar);
2143 SAL_WARN_IF(!bRet, "connectivity.ado", "Could not put value!");
2147 OLEVariant OTools::getValue(const WpADOProperties& _rProps,const OLEVariant &_aPosition)
2149 WpADOProperty aProp(_rProps.GetItem(_aPosition));
2150 return aProp.GetValue();
2153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */