1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
,
35 ADOS::IID_ADOCATALOG_25
,
36 reinterpret_cast<void**>(&pCommand
) );
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
);
53 OUString
WpADOConnection::GetConnectionString() const
57 pInterface
->get_ConnectionString(aBSTR
.getAddress());
58 return aBSTR
.asOUString();
61 bool WpADOConnection::PutConnectionString(const OUString
&aCon
) const
65 bool bErg
= SUCCEEDED(pInterface
->put_ConnectionString(bstr
.asBSTR()));
70 sal_Int32
WpADOConnection::GetCommandTimeout() const
74 pInterface
->get_CommandTimeout(&nRet
);
78 void WpADOConnection::PutCommandTimeout(sal_Int32 nRet
)
81 pInterface
->put_CommandTimeout(nRet
);
84 sal_Int32
WpADOConnection::GetConnectionTimeout() const
88 pInterface
->get_ConnectionTimeout(&nRet
);
92 void WpADOConnection::PutConnectionTimeout(sal_Int32 nRet
)
95 pInterface
->put_ConnectionTimeout(nRet
);
98 bool WpADOConnection::Close()
101 return (SUCCEEDED(pInterface
->Close()));
104 bool WpADOConnection::Execute(const OUString
& CommandText
,OLEVariant
& RecordsAffected
,long Options
, WpADORecordset
** ppiRset
)
107 OLEString
sStr1(CommandText
);
108 bool bErg
= SUCCEEDED(pInterface
->Execute(sStr1
.asBSTR(),&RecordsAffected
,Options
,reinterpret_cast<ADORecordset
**>(ppiRset
)));
112 bool WpADOConnection::BeginTrans()
116 return SUCCEEDED(pInterface
->BeginTrans(&nIso
));
119 bool WpADOConnection::CommitTrans( )
122 return SUCCEEDED(pInterface
->CommitTrans());
125 bool WpADOConnection::RollbackTrans( )
128 return SUCCEEDED(pInterface
->RollbackTrans());
131 bool WpADOConnection::Open(const OUString
& ConnectionString
, const OUString
& UserID
,const OUString
& Password
,long Options
)
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
));
141 bool WpADOConnection::GetErrors(ADOErrors
** pErrors
)
144 return SUCCEEDED(pInterface
->get_Errors(pErrors
));
147 OUString
WpADOConnection::GetDefaultDatabase() const
150 OLEString aBSTR
; pInterface
->get_DefaultDatabase(aBSTR
.getAddress());
151 return aBSTR
.asOUString();
154 bool WpADOConnection::PutDefaultDatabase(const OUString
& _bstr
)
157 OLEString
bstr(_bstr
);
158 bool bErg
= SUCCEEDED(pInterface
->put_DefaultDatabase(bstr
.asBSTR()));
163 IsolationLevelEnum
WpADOConnection::get_IsolationLevel() const
166 IsolationLevelEnum eNum
=adXactUnspecified
;
167 pInterface
->get_IsolationLevel(&eNum
);
171 bool WpADOConnection::put_IsolationLevel(const IsolationLevelEnum
& eNum
)
174 return SUCCEEDED(pInterface
->put_IsolationLevel(eNum
));
177 sal_Int32
WpADOConnection::get_Attributes() const
181 pInterface
->get_Attributes(&nRet
);
185 bool WpADOConnection::put_Attributes(sal_Int32 nRet
)
188 return SUCCEEDED(pInterface
->put_Attributes(nRet
));
191 CursorLocationEnum
WpADOConnection::get_CursorLocation() const
194 CursorLocationEnum eNum
=adUseNone
;
195 pInterface
->get_CursorLocation(&eNum
);
199 bool WpADOConnection::put_CursorLocation(const CursorLocationEnum
&eNum
)
202 return SUCCEEDED(pInterface
->put_CursorLocation(eNum
));
205 ConnectModeEnum
WpADOConnection::get_Mode() const
208 ConnectModeEnum eNum
=adModeUnknown
;
209 pInterface
->get_Mode(&eNum
);
213 bool WpADOConnection::put_Mode(const ConnectModeEnum
&eNum
)
216 return SUCCEEDED(pInterface
->put_Mode(eNum
));
219 OUString
WpADOConnection::get_Provider() const
222 OLEString aBSTR
; pInterface
->get_Provider(aBSTR
.getAddress());
223 return aBSTR
.asOUString();
226 bool WpADOConnection::put_Provider(const OUString
& _bstr
)
229 OLEString
bstr(_bstr
);
230 return SUCCEEDED(pInterface
->put_Provider(bstr
.asBSTR()));
233 sal_Int32
WpADOConnection::get_State() const
237 pInterface
->get_State(&nRet
);
241 bool WpADOConnection::OpenSchema(SchemaEnum eNum
,OLEVariant
const & Restrictions
,OLEVariant
const & SchemaID
,ADORecordset
**pprset
)
244 return SUCCEEDED(pInterface
->OpenSchema(eNum
,Restrictions
,SchemaID
,pprset
));
247 OUString
WpADOConnection::get_Version() const
251 pInterface
->get_Version(aBSTR
.getAddress());
252 return aBSTR
.asOUString();
255 bool WpADOCommand::putref_ActiveConnection( WpADOConnection
*pCon
)
259 return SUCCEEDED(pInterface
->putref_ActiveConnection(pCon
->pInterface
));
261 return SUCCEEDED(pInterface
->putref_ActiveConnection(nullptr));
264 void WpADOCommand::put_ActiveConnection(/* [in] */ const OLEVariant
& vConn
)
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
,
277 reinterpret_cast<void**>(&pInterface2
) );
281 ADOCommand
* pCommand
=nullptr;
282 IUnknown
* pOuter
=nullptr;
284 hr
= pInterface2
->CreateInstanceLic( pOuter
,
286 ADOS::IID_ADOCOMMAND_21
,
287 ADOS::GetKeyStr().asBSTR(),
288 reinterpret_cast<void**>(&pCommand
));
296 pInterface2
->Release();
300 sal_Int32
WpADOCommand::get_State() const
304 pInterface
->get_State(&nRet
);
308 OUString
WpADOCommand::get_CommandText() const
312 pInterface
->get_CommandText(aBSTR
.getAddress());
313 return aBSTR
.asOUString();
316 bool WpADOCommand::put_CommandText(const OUString
&aCon
)
319 OLEString
bstr(aCon
);
320 bool bErg
= SUCCEEDED(pInterface
->put_CommandText(bstr
.asBSTR()));
325 sal_Int32
WpADOCommand::get_CommandTimeout() const
329 pInterface
->get_CommandTimeout(&nRet
);
333 void WpADOCommand::put_CommandTimeout(sal_Int32 nRet
)
336 pInterface
->put_CommandTimeout(nRet
);
339 bool WpADOCommand::get_Prepared() const
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
350 return SUCCEEDED(pInterface
->put_Prepared(bPrepared
));
353 bool WpADOCommand::Execute(OLEVariant
& RecordsAffected
,OLEVariant
& Params
,long Options
, ADORecordset
** ppiRset
)
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
)
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
372 ADOParameters
* pPara
=nullptr;
373 pInterface
->get_Parameters(&pPara
);
377 bool WpADOCommand::put_CommandType( /* [in] */ CommandTypeEnum lCmdType
)
380 return SUCCEEDED(pInterface
->put_CommandType(lCmdType
));
383 CommandTypeEnum
WpADOCommand::get_CommandType() const
386 CommandTypeEnum eNum
=adCmdUnspecified
;
387 pInterface
->get_CommandType(&eNum
);
391 // returns the name of the field
392 OUString
WpADOCommand::GetName() const
396 pInterface
->get_Name(aBSTR
.getAddress());
397 return aBSTR
.asOUString();
400 bool WpADOCommand::put_Name(const OUString
& Name
)
403 OLEString
bstr(Name
);
404 bool bErg
= SUCCEEDED(pInterface
->put_Name(bstr
.asBSTR()));
408 bool WpADOCommand::Cancel()
411 return SUCCEEDED(pInterface
->Cancel());
414 OUString
WpADOError::GetDescription() const
418 pInterface
->get_Description(aBSTR
.getAddress());
419 return aBSTR
.asOUString();
422 OUString
WpADOError::GetSource() const
426 pInterface
->get_Source(aBSTR
.getAddress());
427 return aBSTR
.asOUString();
430 sal_Int32
WpADOError::GetNumber() const
434 pInterface
->get_Number(&nErrNr
);
438 OUString
WpADOError::GetSQLState() const
442 pInterface
->get_SQLState(aBSTR
.getAddress());
443 return aBSTR
.asOUString();
446 sal_Int32
WpADOError::GetNativeError() const
450 pInterface
->get_NativeError(&nErrNr
);
454 WpADOProperties
WpADOField::get_Properties()
457 ADOProperties
* pProps
= nullptr;
458 pInterface
->get_Properties(&pProps
);
459 WpADOProperties aProps
;
461 aProps
.setWithOutAddRef(pProps
);
465 sal_Int32
WpADOField::GetActualSize() const
468 ADO_LONGPTR nActualSize
=0;
469 pInterface
->get_ActualSize(&nActualSize
);
473 sal_Int32
WpADOField::GetAttributes() const
476 sal_Int32 eADOSFieldAttributes
=0;
477 pInterface
->get_Attributes(&eADOSFieldAttributes
);
478 return eADOSFieldAttributes
;
481 sal_Int32
WpADOField::GetStatus() const
484 // pInterface->get_Status(&eADOSFieldAttributes);
488 sal_Int32
WpADOField::GetDefinedSize() const
491 ADO_LONGPTR nDefinedSize
=0;
492 pInterface
->get_DefinedSize(&nDefinedSize
);
496 // returns the name of the field
497 OUString
WpADOField::GetName() const
501 pInterface
->get_Name(aBSTR
.getAddress());
502 return aBSTR
.asOUString();
505 DataTypeEnum
WpADOField::GetADOType() const
508 DataTypeEnum eType
=adEmpty
;
509 pInterface
->get_Type(&eType
);
513 void WpADOField::get_Value(OLEVariant
& aValVar
) const
517 pInterface
->get_Value(&aValVar
);
520 OLEVariant
WpADOField::get_Value() const
524 pInterface
->get_Value(&aValVar
);
528 bool WpADOField::PutValue(const OLEVariant
& aVariant
)
531 return (SUCCEEDED(pInterface
->put_Value(aVariant
)));
534 sal_Int32
WpADOField::GetPrecision() const
538 pInterface
->get_Precision(&eType
);
542 sal_Int32
WpADOField::GetNumericScale() const
546 pInterface
->get_NumericScale(&eType
);
550 bool WpADOField::AppendChunk(const OLEVariant
& Variant
)
553 return (SUCCEEDED(pInterface
->AppendChunk(Variant
)));
556 OLEVariant
WpADOField::GetChunk(long Length
) const
560 pInterface
->GetChunk(Length
,&aValVar
);
564 void WpADOField::GetChunk(long Length
,OLEVariant
&aValVar
) const
567 pInterface
->GetChunk(Length
,&aValVar
);
570 OLEVariant
WpADOField::GetOriginalValue() const
574 pInterface
->get_OriginalValue(&aValVar
);
578 void WpADOField::GetOriginalValue(OLEVariant
&aValVar
) const
581 pInterface
->get_OriginalValue(&aValVar
);
584 OLEVariant
WpADOField::GetUnderlyingValue() const
588 pInterface
->get_UnderlyingValue(&aValVar
);
592 void WpADOField::GetUnderlyingValue(OLEVariant
&aValVar
) const
595 pInterface
->get_UnderlyingValue(&aValVar
);
598 bool WpADOField::PutPrecision(sal_Int8 _prec
)
601 return (SUCCEEDED(pInterface
->put_Precision(_prec
)));
604 bool WpADOField::PutNumericScale(sal_Int8 _prec
)
607 return (SUCCEEDED(pInterface
->put_NumericScale(_prec
)));
610 void WpADOField::PutADOType(DataTypeEnum eType
)
613 pInterface
->put_Type(eType
);
616 bool WpADOField::PutDefinedSize(sal_Int32 _nDefSize
)
619 return (SUCCEEDED(pInterface
->put_DefinedSize(_nDefSize
)));
622 bool WpADOField::PutAttributes(sal_Int32 _nDefSize
)
625 return (SUCCEEDED(pInterface
->put_Attributes(_nDefSize
)));
628 OLEVariant
WpADOProperty::GetValue() const
632 pInterface
->get_Value(&aValVar
);
636 void WpADOProperty::GetValue(OLEVariant
&aValVar
) const
640 pInterface
->get_Value(&aValVar
);
643 bool WpADOProperty::PutValue(const OLEVariant
&aValVar
)
646 return (SUCCEEDED(pInterface
->put_Value(aValVar
)));
649 OUString
WpADOProperty::GetName() const
653 pInterface
->get_Name(aBSTR
.getAddress());
654 return aBSTR
.asOUString();
657 DataTypeEnum
WpADOProperty::GetADOType() const
660 DataTypeEnum eType
=adEmpty
;
661 pInterface
->get_Type(&eType
);
665 sal_Int32
WpADOProperty::GetAttributes() const
668 sal_Int32 eADOSFieldAttributes
=0;
669 pInterface
->get_Attributes(&eADOSFieldAttributes
);
670 return eADOSFieldAttributes
;
673 bool WpADOProperty::PutAttributes(sal_Int32 _nDefSize
)
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
,
685 reinterpret_cast<void**>(&pInterface2
) );
689 ADORecordset
*pRec
= nullptr;
690 IUnknown
*pOuter
= nullptr;
691 hr
= pInterface2
->CreateInstanceLic( pOuter
,
693 ADOS::IID_ADORECORDSET_21
,
694 ADOS::GetKeyStr().asBSTR(),
695 reinterpret_cast<void**>(&pRec
));
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
)
715 return (SUCCEEDED(pInterface
->Open(Source
,ActiveConnection
,CursorType
,LockType
,Options
)));
719 LockTypeEnum
WpADORecordset::GetLockType()
722 LockTypeEnum eType
=adLockUnspecified
;
723 pInterface
->get_LockType(&eType
);
727 void WpADORecordset::Close()
733 bool WpADORecordset::Cancel() const
736 return (SUCCEEDED(pInterface
->Cancel()));
739 sal_Int32
WpADORecordset::get_State()
742 sal_Int32 nState
= 0;
743 pInterface
->get_State(&nState
);
747 bool WpADORecordset::Supports( /* [in] */ CursorOptionEnum CursorOptions
)
750 VARIANT_BOOL bSupports
=VARIANT_FALSE
;
751 pInterface
->Supports(CursorOptions
,&bSupports
);
752 return bSupports
== VARIANT_TRUE
;
755 PositionEnum_Param
WpADORecordset::get_AbsolutePosition()
758 PositionEnum_Param aTemp
=adPosUnknown
;
759 pInterface
->get_AbsolutePosition(&aTemp
);
763 void WpADORecordset::GetDataSource(IUnknown
** _pInterface
) const
766 pInterface
->get_DataSource(_pInterface
);
769 void WpADORecordset::PutRefDataSource(IUnknown
* _pInterface
)
772 pInterface
->putref_DataSource(_pInterface
);
775 void WpADORecordset::GetBookmark(VARIANT
& var
)
778 pInterface
->get_Bookmark(&var
);
781 OLEVariant
WpADORecordset::GetBookmark()
785 pInterface
->get_Bookmark(&var
);
789 CompareEnum
WpADORecordset::CompareBookmarks(const OLEVariant
& left
,const OLEVariant
& right
)
792 CompareEnum eNum
=adCompareNotComparable
;
793 pInterface
->CompareBookmarks(left
,right
,&eNum
);
797 bool WpADORecordset::SetBookmark(const OLEVariant
&pSafeAr
)
800 return SUCCEEDED(pInterface
->put_Bookmark(pSafeAr
));
804 WpADOFields
WpADORecordset::GetFields() const
807 ADOFields
* pFields
=nullptr;
808 pInterface
->get_Fields(&pFields
);
810 aFields
.setWithOutAddRef(pFields
);
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
824 VARIANT_BOOL bIsAtBOF
=VARIANT_FALSE
;
825 pInterface
->get_BOF(&bIsAtBOF
);
826 return bIsAtBOF
== VARIANT_TRUE
;
829 bool WpADORecordset::IsAtEOF() const
832 VARIANT_BOOL bIsAtEOF
=VARIANT_FALSE
;
833 pInterface
->get_EOF(&bIsAtEOF
);
834 return bIsAtEOF
== VARIANT_TRUE
;
837 bool WpADORecordset::Delete(AffectEnum eNum
)
840 return SUCCEEDED(pInterface
->Delete(eNum
));
843 bool WpADORecordset::AddNew(const OLEVariant
&FieldList
,const OLEVariant
&Values
)
846 return SUCCEEDED(pInterface
->AddNew(FieldList
,Values
));
849 bool WpADORecordset::Update(const OLEVariant
&FieldList
,const OLEVariant
&Values
)
852 return SUCCEEDED(pInterface
->Update(FieldList
,Values
));
855 bool WpADORecordset::CancelUpdate()
858 return SUCCEEDED(pInterface
->CancelUpdate());
861 WpADOProperties
WpADORecordset::get_Properties() const
864 ADOProperties
* pProps
=nullptr;
865 pInterface
->get_Properties(&pProps
);
866 WpADOProperties aProps
;
867 aProps
.setWithOutAddRef(pProps
);
871 bool WpADORecordset::NextRecordset(OLEVariant
& RecordsAffected
,ADORecordset
** ppiRset
)
874 return SUCCEEDED(pInterface
->NextRecordset(&RecordsAffected
,ppiRset
));
877 bool WpADORecordset::get_RecordCount(ADO_LONGPTR
&_nRet
) const
880 return SUCCEEDED(pInterface
->get_RecordCount(&_nRet
));
883 bool WpADORecordset::get_MaxRecords(ADO_LONGPTR
&_nRet
) const
886 return SUCCEEDED(pInterface
->get_MaxRecords(&_nRet
));
889 bool WpADORecordset::put_MaxRecords(ADO_LONGPTR _nRet
)
892 return SUCCEEDED(pInterface
->put_MaxRecords(_nRet
));
895 bool WpADORecordset::get_CursorType(CursorTypeEnum
&_nRet
) const
898 return SUCCEEDED(pInterface
->get_CursorType(&_nRet
));
901 bool WpADORecordset::put_CursorType(CursorTypeEnum _nRet
)
904 return SUCCEEDED(pInterface
->put_CursorType(_nRet
));
907 bool WpADORecordset::get_LockType(LockTypeEnum
&_nRet
) const
910 return SUCCEEDED(pInterface
->get_LockType(&_nRet
));
913 bool WpADORecordset::put_LockType(LockTypeEnum _nRet
)
916 return SUCCEEDED(pInterface
->put_LockType(_nRet
));
919 bool WpADORecordset::get_CacheSize(sal_Int32
&_nRet
) const
922 return SUCCEEDED(pInterface
->get_CacheSize(&_nRet
));
925 bool WpADORecordset::put_CacheSize(sal_Int32 _nRet
)
928 return SUCCEEDED(pInterface
->put_CacheSize(_nRet
));
931 bool WpADORecordset::UpdateBatch(AffectEnum AffectRecords
)
934 return SUCCEEDED(pInterface
->UpdateBatch(AffectRecords
));
937 OUString
WpADOParameter::GetName() const
941 pInterface
->get_Name(aBSTR
.getAddress());
942 return aBSTR
.asOUString();
945 DataTypeEnum
WpADOParameter::GetADOType() const
948 DataTypeEnum eType
=adEmpty
;
949 pInterface
->get_Type(&eType
);
953 void WpADOParameter::put_Type(const DataTypeEnum
& _eType
)
956 pInterface
->put_Type(_eType
);
959 sal_Int32
WpADOParameter::GetAttributes() const
962 sal_Int32 eADOSFieldAttributes
=0;
963 pInterface
->get_Attributes(&eADOSFieldAttributes
);
964 return eADOSFieldAttributes
;
967 sal_Int32
WpADOParameter::GetPrecision() const
971 pInterface
->get_Precision(&eType
);
975 sal_Int32
WpADOParameter::GetNumericScale() const
979 pInterface
->get_NumericScale(&eType
);
983 ParameterDirectionEnum
WpADOParameter::get_Direction() const
986 ParameterDirectionEnum alParmDirection
=adParamUnknown
;
987 pInterface
->get_Direction(&alParmDirection
);
988 return alParmDirection
;
991 void WpADOParameter::GetValue(OLEVariant
& aValVar
) const
994 pInterface
->get_Value(&aValVar
);
997 OLEVariant
WpADOParameter::GetValue() const
1001 pInterface
->get_Value(&aValVar
);
1005 bool WpADOParameter::PutValue(const OLEVariant
& aVariant
)
1008 return (SUCCEEDED(pInterface
->put_Value(aVariant
)));
1010 bool WpADOParameter::AppendChunk(const OLEVariant
& aVariant
)
1013 return (SUCCEEDED(pInterface
->AppendChunk(aVariant
)));
1015 bool WpADOParameter::put_Size(sal_Int32 _nSize
)
1018 return (SUCCEEDED(pInterface
->put_Size(_nSize
)));
1021 OUString
WpADOColumn::get_Name() const
1025 pInterface
->get_Name(aBSTR
.getAddress());
1026 return aBSTR
.asOUString();
1029 OUString
WpADOColumn::get_RelatedColumn() const
1033 pInterface
->get_RelatedColumn(aBSTR
.getAddress());
1034 return aBSTR
.asOUString();
1037 void WpADOColumn::put_Name(const OUString
& _rName
)
1040 OLEString
bstr(_rName
);
1041 pInterface
->put_Name(bstr
.asBSTR());
1043 void WpADOColumn::put_RelatedColumn(const OUString
& _rName
)
1046 OLEString
bstr(_rName
);
1047 pInterface
->put_RelatedColumn(bstr
.asBSTR());
1050 DataTypeEnum
WpADOColumn::get_Type() const
1053 DataTypeEnum eNum
= adVarChar
;
1054 pInterface
->get_Type(&eNum
);
1058 void WpADOColumn::put_Type(const DataTypeEnum
& _eNum
)
1061 pInterface
->put_Type(_eNum
);
1064 sal_Int32
WpADOColumn::get_Precision() const
1068 pInterface
->get_Precision(&nPrec
);
1072 void WpADOColumn::put_Precision(sal_Int32 _nPre
)
1075 pInterface
->put_Precision(_nPre
);
1078 sal_Int32
WpADOColumn::get_DefinedSize() const
1082 pInterface
->get_DefinedSize(&nPrec
);
1085 sal_uInt8
WpADOColumn::get_NumericScale() const
1089 pInterface
->get_NumericScale(&nPrec
);
1093 void WpADOColumn::put_NumericScale(sal_Int8 _nScale
)
1096 pInterface
->put_NumericScale(_nScale
);
1099 SortOrderEnum
WpADOColumn::get_SortOrder() const
1102 SortOrderEnum nPrec
=adSortAscending
;
1103 pInterface
->get_SortOrder(&nPrec
);
1107 void WpADOColumn::put_SortOrder(SortOrderEnum _nScale
)
1110 pInterface
->put_SortOrder(_nScale
);
1113 ColumnAttributesEnum
WpADOColumn::get_Attributes() const
1116 ColumnAttributesEnum eNum
=adColNullable
;
1117 pInterface
->get_Attributes(&eNum
);
1121 bool WpADOColumn::put_Attributes(const ColumnAttributesEnum
& _eNum
)
1124 return SUCCEEDED(pInterface
->put_Attributes(_eNum
));
1127 WpADOProperties
WpADOColumn::get_Properties() const
1130 ADOProperties
* pProps
= nullptr;
1131 pInterface
->get_Properties(&pProps
);
1132 WpADOProperties aProps
;
1134 aProps
.setWithOutAddRef(pProps
);
1138 OUString
WpADOKey::get_Name() const
1142 pInterface
->get_Name(aBSTR
.getAddress());
1143 return aBSTR
.asOUString();
1146 void WpADOKey::put_Name(const OUString
& _rName
)
1149 OLEString
bstr(_rName
);
1150 pInterface
->put_Name(bstr
.asBSTR());
1153 KeyTypeEnum
WpADOKey::get_Type() const
1156 KeyTypeEnum eNum
=adKeyPrimary
;
1157 pInterface
->get_Type(&eNum
);
1161 void WpADOKey::put_Type(const KeyTypeEnum
& _eNum
)
1164 pInterface
->put_Type(_eNum
);
1167 OUString
WpADOKey::get_RelatedTable() const
1171 pInterface
->get_RelatedTable(aBSTR
.getAddress());
1172 return aBSTR
.asOUString();
1175 void WpADOKey::put_RelatedTable(const OUString
& _rName
)
1178 OLEString
bstr(_rName
);
1179 pInterface
->put_RelatedTable(bstr
.asBSTR());
1182 RuleEnum
WpADOKey::get_DeleteRule() const
1185 RuleEnum eNum
= adRINone
;
1186 pInterface
->get_DeleteRule(&eNum
);
1190 void WpADOKey::put_DeleteRule(const RuleEnum
& _eNum
)
1193 pInterface
->put_DeleteRule(_eNum
);
1196 RuleEnum
WpADOKey::get_UpdateRule() const
1199 RuleEnum eNum
= adRINone
;
1200 pInterface
->get_UpdateRule(&eNum
);
1204 void WpADOKey::put_UpdateRule(const RuleEnum
& _eNum
)
1207 pInterface
->put_UpdateRule(_eNum
);
1210 WpADOColumns
WpADOKey::get_Columns() const
1213 ADOColumns
* pCols
= nullptr;
1214 pInterface
->get_Columns(&pCols
);
1216 aCols
.setWithOutAddRef(pCols
);
1220 OUString
WpADOIndex::get_Name() const
1224 pInterface
->get_Name(aBSTR
.getAddress());
1225 return aBSTR
.asOUString();
1228 void WpADOIndex::put_Name(const OUString
& _rName
)
1231 OLEString
bstr(_rName
);
1232 pInterface
->put_Name(bstr
.asBSTR());
1235 bool WpADOIndex::get_Clustered() const
1238 VARIANT_BOOL eNum
= VARIANT_FALSE
;
1239 pInterface
->get_Clustered(&eNum
);
1240 return eNum
== VARIANT_TRUE
;
1243 void WpADOIndex::put_Clustered(bool _b
)
1246 pInterface
->put_Clustered(_b
? VARIANT_TRUE
: VARIANT_FALSE
);
1249 bool WpADOIndex::get_Unique() const
1252 VARIANT_BOOL eNum
= VARIANT_FALSE
;
1253 pInterface
->get_Unique(&eNum
);
1254 return eNum
== VARIANT_TRUE
;
1257 void WpADOIndex::put_Unique(bool _b
)
1260 pInterface
->put_Unique(_b
? VARIANT_TRUE
: VARIANT_FALSE
);
1263 bool WpADOIndex::get_PrimaryKey() const
1266 VARIANT_BOOL eNum
= VARIANT_FALSE
;
1267 pInterface
->get_PrimaryKey(&eNum
);
1268 return eNum
== VARIANT_TRUE
;
1271 void WpADOIndex::put_PrimaryKey(bool _b
)
1274 pInterface
->put_PrimaryKey(_b
? VARIANT_TRUE
: VARIANT_FALSE
);
1277 WpADOColumns
WpADOIndex::get_Columns() const
1280 ADOColumns
* pCols
= nullptr;
1281 pInterface
->get_Columns(&pCols
);
1283 aCols
.setWithOutAddRef(pCols
);
1287 void WpADOCatalog::putref_ActiveConnection(IDispatch
* pCon
)
1290 pInterface
->putref_ActiveConnection(pCon
);
1293 WpADOTables
WpADOCatalog::get_Tables()
1296 ADOTables
* pRet
= nullptr;
1297 pInterface
->get_Tables(&pRet
);
1299 aRet
.setWithOutAddRef(pRet
);
1303 WpADOViews
WpADOCatalog::get_Views()
1306 ADOViews
* pRet
= nullptr;
1307 pInterface
->get_Views(&pRet
);
1309 aRet
.setWithOutAddRef(pRet
);
1313 WpADOGroups
WpADOCatalog::get_Groups()
1316 ADOGroups
* pRet
= nullptr;
1317 pInterface
->get_Groups(&pRet
);
1319 aRet
.setWithOutAddRef(pRet
);
1323 WpADOUsers
WpADOCatalog::get_Users()
1326 ADOUsers
* pRet
= nullptr;
1327 pInterface
->get_Users(&pRet
);
1329 aRet
.setWithOutAddRef(pRet
);
1333 ADOProcedures
* WpADOCatalog::get_Procedures()
1336 ADOProcedures
* pRet
= nullptr;
1337 pInterface
->get_Procedures(&pRet
);
1341 OUString
WpADOTable::get_Name() const
1345 pInterface
->get_Name(aBSTR
.getAddress());
1346 return aBSTR
.asOUString();
1349 void WpADOTable::put_Name(const OUString
& _rName
)
1352 OLEString
bstr(_rName
);
1353 pInterface
->put_Name(bstr
.asBSTR());
1356 OUString
WpADOTable::get_Type() const
1360 pInterface
->get_Type(aBSTR
.getAddress());
1361 return aBSTR
.asOUString();
1364 WpADOColumns
WpADOTable::get_Columns() const
1367 ADOColumns
* pCols
= nullptr;
1368 pInterface
->get_Columns(&pCols
);
1370 aCols
.setWithOutAddRef(pCols
);
1374 WpADOIndexes
WpADOTable::get_Indexes() const
1377 ADOIndexes
* pCols
= nullptr;
1378 pInterface
->get_Indexes(&pCols
);
1380 aRet
.setWithOutAddRef(pCols
);
1384 WpADOKeys
WpADOTable::get_Keys() const
1387 ADOKeys
* pCols
= nullptr;
1388 pInterface
->get_Keys(&pCols
);
1390 aRet
.setWithOutAddRef(pCols
);
1394 WpADOCatalog
WpADOTable::get_ParentCatalog() const
1397 ADOCatalog
* pCat
= nullptr;
1398 pInterface
->get_ParentCatalog(&pCat
);
1400 aRet
.setWithOutAddRef(pCat
);
1404 WpADOProperties
WpADOTable::get_Properties() const
1407 ADOProperties
* pProps
= nullptr;
1408 pInterface
->get_Properties(&pProps
);
1409 WpADOProperties aProps
;
1410 aProps
.setWithOutAddRef(pProps
);
1414 OUString
WpADOView::get_Name() const
1418 pInterface
->get_Name(aBSTR
.getAddress());
1419 return aBSTR
.asOUString();
1422 void WpADOView::get_Command(OLEVariant
& _rVar
) const
1425 pInterface
->get_Command(&_rVar
);
1428 void WpADOView::put_Command(OLEVariant
const & _rVar
)
1431 pInterface
->put_Command(_rVar
);
1434 OUString
WpADOGroup::get_Name() const
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
);
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
);
1474 aRet
.setWithOutAddRef(pRet
);
1478 OUString
WpADOUser::get_Name() const
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()));
1499 WpADOGroups
WpADOUser::get_Groups()
1501 ADOGroups
* pRet
= nullptr;
1502 pInterface
->get_Groups(&pRet
);
1504 aRet
.setWithOutAddRef(pRet
);
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
);
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
)
1538 pIUnknown
->AddRef();
1542 WpBase::WpBase(const WpBase
& aWrapper
)
1543 :pIUnknown(aWrapper
.pIUnknown
)
1546 pIUnknown
->AddRef();
1550 WpBase
& WpBase::operator=(const WpBase
& rhs
)
1552 operator=(rhs
.pIUnknown
);
1556 WpBase
& WpBase::operator=(IDispatch
* rhs
)
1558 if (pIUnknown
!= rhs
)
1561 pIUnknown
->Release();
1564 pIUnknown
->AddRef();
1573 pIUnknown
->Release();
1574 pIUnknown
= nullptr;
1578 void WpBase::clear()
1582 pIUnknown
->Release();
1583 pIUnknown
= nullptr;
1588 bool WpBase::IsValid() const
1590 return pIUnknown
!= nullptr;
1592 WpBase::operator IDispatch
*()
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
);
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
1628 // Initialize and fill the SafeArray
1630 vsa
.setArray(psa
,VT_VARIANT
);
1632 ADORecordset
*pRecordset
= nullptr;
1633 OpenSchema(adSchemaForeignKeys
,vsa
,vtEmpty
,&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
);
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
1668 // Initialize and fill the SafeArray
1670 vsa
.setArray(psa
,VT_VARIANT
);
1672 ADORecordset
*pRecordset
= nullptr;
1673 OpenSchema(adSchemaForeignKeys
,vsa
,vtEmpty
,&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
);
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
1707 // Initialize and fill the SafeArray
1709 vsa
.setArray(psa
,VT_VARIANT
);
1711 ADORecordset
*pRecordset
= nullptr;
1712 OpenSchema(adSchemaPrimaryKeys
,vsa
,vtEmpty
,&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
);
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
1750 // Initialize and fill the SafeArray
1752 vsa
.setArray(psa
,VT_VARIANT
);
1754 ADORecordset
*pRecordset
= nullptr;
1755 OpenSchema(adSchemaIndexes
,vsa
,vtEmpty
,&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
);
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
1792 // Initialize and fill the SafeArray
1794 vsa
.setArray(psa
,VT_VARIANT
);
1796 ADORecordset
*pRecordset
= nullptr;
1797 OpenSchema(adSchemaTablePrivileges
,vsa
,vtEmpty
,&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
);
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
1845 // Initialize and fill the SafeArray
1847 vsa
.setArray(psa
,VT_VARIANT
);
1849 ADORecordset
*pRecordset
= nullptr;
1850 OpenSchema(adSchemaForeignKeys
,vsa
,vtEmpty
,&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
);
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
1884 // Initialize and fill the SafeArray
1886 vsa
.setArray(psa
,VT_VARIANT
);
1888 ADORecordset
*pRecordset
= nullptr;
1889 OpenSchema(adSchemaProcedures
,vsa
,vtEmpty
,&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
);
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
1929 // Initialize and fill the SafeArray
1931 vsa
.setArray(psa
,VT_VARIANT
);
1933 ADORecordset
*pRecordset
= nullptr;
1934 OpenSchema(adSchemaProcedureParameters
,vsa
,vtEmpty
,&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
1946 OLEVariant varCriteria
[4];
1950 if ( catalog
.hasValue() && (catalog
>>= sCatalog
) )
1951 varCriteria
[nPos
].setString(sCatalog
);
1954 if(schemaPattern
.getLength() && schemaPattern
.toChar() != '%')
1955 varCriteria
[nPos
].setString(schemaPattern
);
1958 if(tableNamePattern
.toChar() != '%')
1959 varCriteria
[nPos
].setString(tableNamePattern
);
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() )
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
]);
1992 // Initialize and fill the SafeArray
1994 vsa
.setArray(psa
,VT_VARIANT
);
1996 ADORecordset
*pRecordset
= nullptr;
1997 OpenSchema(adSchemaTables
,vsa
,vtEmpty
,&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
);
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
2036 // Initialize and fill the SafeArray
2038 vsa
.setArray(psa
,VT_VARIANT
);
2040 ADORecordset
*pRecordset
= nullptr;
2041 OpenSchema(adSchemaColumns
,vsa
,vtEmpty
,&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
);
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
2079 // Initialize and fill the SafeArray
2081 vsa
.setArray(psa
,VT_VARIANT
);
2083 ADORecordset
*pRecordset
= nullptr;
2084 OpenSchema(adSchemaColumnPrivileges
,vsa
,vtEmpty
,&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
);
2101 SafeArrayPutElement(psa
,&nPos
,&varCriteria
[nPos
]);nPos
++;
2102 SafeArrayPutElement(psa
,&nPos
,&varCriteria
[nPos
]);nPos
++;
2104 // Initialize and fill the SafeArray
2106 vsa
.setArray(psa
,VT_VARIANT
);
2111 ADORecordset
*pRec
=nullptr;
2112 OpenSchema(adSchemaProviderTypes
,vsa
,aEmpty
,&pRec
);
2117 void WpADOColumn::put_ParentCatalog(/* [in] */ _ADOCatalog __RPC_FAR
*ppvObject
)
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
)
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: */