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 .
21 #include <sal/config.h>
23 #include <string_view>
25 #include <com/sun/star/beans/PropertyAttribute.hpp>
31 #include <ado/adoimp.hxx>
32 #include <ado/Aolewrap.hxx>
33 #include <ado/Aolevariant.hxx>
35 namespace connectivity::ado
37 class WpADOConnection
;
45 typedef WpOLEAppendCollection
< ADOFields
, WpADOField
> WpADOFields
;
46 typedef WpOLECollection
< ADOProperties
, WpADOProperty
> WpADOProperties
;
49 class WpADOConnection
: public WpOLEBase
<ADOConnection
>
53 WpADOConnection() = default;
55 WpADOConnection(const WpADOConnection
& rhs
) : WpOLEBase
<ADOConnection
>(rhs
) {}
57 WpADOConnection
& operator=(const WpADOConnection
& rhs
)
58 {WpOLEBase
<ADOConnection
>::operator=(rhs
); return *this;}
61 WpADOProperties
get_Properties() const;
63 OUString
GetConnectionString() const;
64 bool PutConnectionString(std::u16string_view aCon
) const;
65 sal_Int32
GetCommandTimeout() const;
66 void PutCommandTimeout(sal_Int32 nRet
);
67 sal_Int32
GetConnectionTimeout() const ;
68 void PutConnectionTimeout(sal_Int32 nRet
);
71 bool Execute(std::u16string_view CommandText
,OLEVariant
& RecordsAffected
,long Options
, WpADORecordset
** ppiRset
);
74 bool RollbackTrans( );
75 bool Open(std::u16string_view ConnectionString
, std::u16string_view UserID
,std::u16string_view Password
,long Options
);
76 bool GetErrors(ADOErrors
** pErrors
);
78 OUString
GetDefaultDatabase() const;
79 bool PutDefaultDatabase(std::u16string_view _bstr
);
81 IsolationLevelEnum
get_IsolationLevel() const ;
82 bool put_IsolationLevel(const IsolationLevelEnum
& eNum
) ;
84 sal_Int32
get_Attributes() const;
85 bool put_Attributes(sal_Int32 nRet
);
87 CursorLocationEnum
get_CursorLocation() const;
88 bool put_CursorLocation(const CursorLocationEnum
&eNum
) ;
90 ConnectModeEnum
get_Mode() const;
91 bool put_Mode(const ConnectModeEnum
&eNum
) ;
93 OUString
get_Provider() const;
94 bool put_Provider(std::u16string_view _bstr
);
96 sal_Int32
get_State() const;
98 bool OpenSchema(SchemaEnum eNum
,OLEVariant
const & Restrictions
,OLEVariant
const & SchemaID
,ADORecordset
**pprset
);
100 OUString
get_Version() const;
103 ADORecordset
* getExportedKeys( const css::uno::Any
& catalog
, const OUString
& schema
, std::u16string_view table
);
104 ADORecordset
* getImportedKeys( const css::uno::Any
& catalog
, const OUString
& schema
, std::u16string_view table
);
105 ADORecordset
* getPrimaryKeys( const css::uno::Any
& catalog
, const OUString
& schema
, std::u16string_view table
);
106 ADORecordset
* getIndexInfo( const css::uno::Any
& catalog
, const OUString
& schema
, std::u16string_view table
, bool unique
, bool approximate
);
107 ADORecordset
* getTablePrivileges( const css::uno::Any
& catalog
,
108 const OUString
& schemaPattern
,
109 std::u16string_view tableNamePattern
);
110 ADORecordset
* getCrossReference( const css::uno::Any
& primaryCatalog
,
111 const OUString
& primarySchema
,
112 std::u16string_view primaryTable
,
113 const css::uno::Any
& foreignCatalog
,
114 const OUString
& foreignSchema
,
115 std::u16string_view foreignTable
);
116 ADORecordset
* getProcedures( const css::uno::Any
& catalog
,
117 const OUString
& schemaPattern
,
118 std::u16string_view procedureNamePattern
);
119 ADORecordset
* getProcedureColumns( const css::uno::Any
& catalog
,
120 const OUString
& schemaPattern
,
121 std::u16string_view procedureNamePattern
,
122 std::u16string_view columnNamePattern
);
123 ADORecordset
* getTables( const css::uno::Any
& catalog
,
124 const OUString
& schemaPattern
,
125 std::u16string_view tableNamePattern
,
126 const css::uno::Sequence
< OUString
>& types
);
127 ADORecordset
* getColumns( const css::uno::Any
& catalog
,
128 const OUString
& schemaPattern
,
129 std::u16string_view tableNamePattern
,
130 std::u16string_view columnNamePattern
);
131 ADORecordset
* getColumnPrivileges( const css::uno::Any
& catalog
,
132 const OUString
& schemaPattern
,
133 std::u16string_view table
,
134 std::u16string_view columnNamePattern
);
135 ADORecordset
* getTypeInfo(DataTypeEnum _eType
= adEmpty
);
139 class WpADOCommand
: public WpOLEBase
<ADOCommand
>
142 WpADOCommand() = default;
144 // They only call the superclass
145 WpADOCommand(const WpADOCommand
& rhs
) : WpOLEBase
<ADOCommand
>(rhs
) {}
147 WpADOCommand
& operator=(const WpADOCommand
& rhs
)
149 WpOLEBase
<ADOCommand
>::operator=(rhs
); return *this;}
152 bool putref_ActiveConnection(const WpADOConnection
& rCon
);
154 void put_ActiveConnection(/* [in] */ const OLEVariant
& vConn
);
156 sal_Int32
get_State() const;
157 OUString
get_CommandText() const;
158 bool put_CommandText(std::u16string_view aCon
) ;
159 sal_Int32
get_CommandTimeout() const;
160 void put_CommandTimeout(sal_Int32 nRet
);
161 bool get_Prepared() const;
162 bool put_Prepared(VARIANT_BOOL bPrepared
) const;
163 bool Execute(OLEVariant
& RecordsAffected
,OLEVariant
& Parameters
,long Options
, ADORecordset
** ppiRset
);
164 ADOParameter
* CreateParameter(std::u16string_view _bstr
,DataTypeEnum Type
,ParameterDirectionEnum Direction
,long nSize
,const OLEVariant
&Value
);
166 ADOParameters
* get_Parameters() const;
167 bool put_CommandType( /* [in] */ CommandTypeEnum lCmdType
);
168 CommandTypeEnum
get_CommandType( ) const ;
169 // Returns the field's name
170 OUString
GetName() const ;
171 bool put_Name(std::u16string_view Name
);
175 class WpADOError
: public WpOLEBase
<ADOError
>
180 // They only call the superclass
181 WpADOError() = default;
183 WpADOError(const WpADOError
& rhs
) : WpOLEBase
<ADOError
>(rhs
) {}
185 WpADOError
& operator=(const WpADOError
& rhs
)
186 {WpOLEBase
<ADOError
>::operator=(rhs
); return *this;}
189 OUString
GetDescription() const;
190 OUString
GetSource() const ;
191 sal_Int32
GetNumber() const ;
192 OUString
GetSQLState() const ;
193 sal_Int32
GetNativeError() const ;
197 class WpADOField
: public WpOLEBase
<ADOField
>
199 // friend class WpADOFields;
203 // They only call the superclass
204 WpADOField() = default;
205 WpADOField(const WpADOField
& rhs
) : WpOLEBase
<ADOField
>(rhs
) {}
207 WpADOField
& operator=(const WpADOField
& rhs
)
208 {WpOLEBase
<ADOField
>::operator=(rhs
); return *this;}
211 WpADOProperties
get_Properties();
212 sal_Int32
GetActualSize() const ;
213 sal_Int32
GetAttributes() const ;
214 sal_Int32
GetStatus() const ;
215 sal_Int32
GetDefinedSize() const ;
216 // Returns the field's name
217 OUString
GetName() const ;
218 DataTypeEnum
GetADOType() const ;
219 void get_Value(OLEVariant
& aValVar
) const ;
220 OLEVariant
get_Value() const;
221 bool PutValue(const OLEVariant
& aVariant
);
222 sal_Int32
GetPrecision() const ;
223 sal_Int32
GetNumericScale() const ;
224 bool AppendChunk(const OLEVariant
& Variant
);
225 OLEVariant
GetChunk(long Length
) const;
226 void GetChunk(long Length
,OLEVariant
&aValVar
) const;
227 OLEVariant
GetOriginalValue() const;
228 void GetOriginalValue(OLEVariant
&aValVar
) const;
229 OLEVariant
GetUnderlyingValue() const;
231 void GetUnderlyingValue(OLEVariant
&aValVar
) const;
233 bool PutPrecision(sal_Int8 _prec
);
235 bool PutNumericScale(sal_Int8 _prec
);
237 void PutADOType(DataTypeEnum eType
) ;
239 bool PutDefinedSize(sal_Int32 _nDefSize
);
241 bool PutAttributes(sal_Int32 _nDefSize
);
245 class WpADOProperty
: public WpOLEBase
<ADOProperty
>
249 // They only call the superclass
250 WpADOProperty() = default;
251 WpADOProperty(const WpADOProperty
& rhs
) : WpOLEBase
<ADOProperty
>(rhs
) {}
252 WpADOProperty
& operator=(const WpADOProperty
& rhs
)
253 {WpOLEBase
<ADOProperty
>::operator=(rhs
); return *this;}
256 OLEVariant
GetValue() const;
257 void GetValue(OLEVariant
&aValVar
) const;
258 bool PutValue(const OLEVariant
&aValVar
) ;
259 OUString
GetName() const ;
260 DataTypeEnum
GetADOType() const ;
261 sal_Int32
GetAttributes() const ;
262 bool PutAttributes(sal_Int32 _nDefSize
);
266 class WpADORecordset
: public WpOLEBase
<ADORecordset
>
271 // They only call the superclass
272 WpADORecordset() = default;
273 WpADORecordset(const WpADORecordset
& rhs
) : WpOLEBase
<ADORecordset
>() {operator=(rhs
);}
274 WpADORecordset
& operator=(const WpADORecordset
& rhs
)
276 WpOLEBase
<ADORecordset
>::operator=(rhs
);
282 /* [optional][in] */ VARIANT Source
,
283 /* [optional][in] */ VARIANT ActiveConnection
,
284 /* [defaultvalue][in] */ CursorTypeEnum CursorType
,
285 /* [defaultvalue][in] */ LockTypeEnum LockType
,
286 /* [defaultvalue][in] */ sal_Int32 Options
);
287 LockTypeEnum
GetLockType();
290 sal_Int32
get_State( );
291 bool Supports( /* [in] */ CursorOptionEnum CursorOptions
);
292 PositionEnum
get_AbsolutePosition();
293 void GetDataSource(IUnknown
** pIUnknown
) const ;
294 void PutRefDataSource(IUnknown
* pIUnknown
);
295 void GetBookmark(VARIANT
& var
);
296 OLEVariant
GetBookmark();
297 CompareEnum
CompareBookmarks(const OLEVariant
& left
,const OLEVariant
& right
);
298 bool SetBookmark(const OLEVariant
&pSafeAr
);
299 WpADOFields
GetFields() const;
300 bool Move(sal_Int32 nRows
, VARIANT aBmk
);
306 bool IsAtBOF() const;
307 bool IsAtEOF() const;
308 bool Delete(AffectEnum eNum
);
309 bool AddNew(const OLEVariant
&FieldList
,const OLEVariant
&Values
);
310 bool Update(const OLEVariant
&FieldList
,const OLEVariant
&Values
);
312 WpADOProperties
get_Properties() const;
313 bool NextRecordset(OLEVariant
& RecordsAffected
,ADORecordset
** ppiRset
);
314 bool get_RecordCount(long& _nRet
) const;
315 bool get_MaxRecords(long& _nRet
) const;
316 bool put_MaxRecords(ADO_LONGPTR _nRet
);
317 bool get_CursorType(CursorTypeEnum
&_nRet
) const;
318 bool put_CursorType(CursorTypeEnum _nRet
);
319 bool get_LockType(LockTypeEnum
&_nRet
) const;
320 bool put_LockType(LockTypeEnum _nRet
);
321 bool get_CacheSize(sal_Int32
&_nRet
) const;
322 bool put_CacheSize(sal_Int32 _nRet
);
323 bool UpdateBatch(AffectEnum AffectRecords
);
327 class WpADOParameter
:public WpOLEBase
<ADOParameter
>
331 // They only call the superclass
332 WpADOParameter() = default;
333 WpADOParameter(const WpADOParameter
& rhs
):WpOLEBase
<ADOParameter
>(rhs
){}
334 WpADOParameter
& operator=(const WpADOParameter
& rhs
)
335 {WpOLEBase
<ADOParameter
>::operator=(rhs
); return *this;}
338 OUString
GetName() const ;
339 DataTypeEnum
GetADOType() const ;
340 void put_Type(const DataTypeEnum
& _eType
);
341 bool put_Size(sal_Int32 _nSize
);
342 sal_Int32
GetAttributes() const ;
343 sal_Int32
GetPrecision() const ;
344 sal_Int32
GetNumericScale() const ;
345 ParameterDirectionEnum
get_Direction() const;
346 void GetValue(OLEVariant
& aValVar
) const ;
347 OLEVariant
GetValue() const;
348 bool PutValue(const OLEVariant
& aVariant
);
349 bool AppendChunk(const OLEVariant
& aVariant
);
355 /** putValue set the property value at the ado column
356 @param _rProps the properties where to set
357 @param _aPosition which property to set
358 @param _aValVar the value to set
360 static void putValue(const WpADOProperties
& _rProps
,const OLEVariant
&_aPosition
,const OLEVariant
&_aValVar
);
362 /** getValue returns a specific property value
363 @param _rProps the properties where to set
364 @param _aPosition the property
366 @return the property value
368 static OLEVariant
getValue(const WpADOProperties
& _rProps
,const OLEVariant
&_aPosition
);
372 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */