1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
28 #ifndef _CONNECTIVITY_ADO_AWRAPADO_HXX_
29 #define _CONNECTIVITY_ADO_AWRAPADO_HXX_
31 #include <com/sun/star/beans/PropertyAttribute.hpp>
34 #include "ado_pre_sys_include.h"
38 #include "ado_post_sys_include.h"
39 #include "ado/adoimp.hxx"
40 #include "ado/Aolewrap.hxx"
41 #include "ado/Aolevariant.hxx"
43 namespace connectivity
47 class WpADOConnection
;
55 typedef WpOLEAppendCollection
< ADOFields
, ADOField
, WpADOField
> WpADOFields
;
56 typedef WpOLECollection
< ADOProperties
, ADOProperty
, WpADOProperty
> WpADOProperties
;
58 //------------------------------------------------------------------------
59 class WpADOConnection
: public WpOLEBase
<ADOConnection
>
61 friend class WpADOCommand
;
64 WpADOConnection(ADOConnection
* pInt
) : WpOLEBase
<ADOConnection
>(pInt
){}
66 WpADOConnection(const WpADOConnection
& rhs
) : WpOLEBase
<ADOConnection
>(rhs
) {}
68 WpADOConnection
& operator=(const WpADOConnection
& rhs
)
69 {WpOLEBase
<ADOConnection
>::operator=(rhs
); return *this;}
71 //////////////////////////////////////////////////////////////////////
73 WpADOProperties
get_Properties() const;
75 rtl::OUString
GetConnectionString() const;
76 sal_Bool
PutConnectionString(const ::rtl::OUString
&aCon
) const;
77 sal_Int32
GetCommandTimeout() const;
78 void PutCommandTimeout(sal_Int32 nRet
);
79 sal_Int32
GetConnectionTimeout() const ;
80 void PutConnectionTimeout(sal_Int32 nRet
);
83 sal_Bool
Execute(const ::rtl::OUString
& _CommandText
,OLEVariant
& RecordsAffected
,long Options
, WpADORecordset
** ppiRset
);
84 sal_Bool
BeginTrans();
85 sal_Bool
CommitTrans( ) ;
86 sal_Bool
RollbackTrans( );
87 sal_Bool
Open(const ::rtl::OUString
& ConnectionString
, const ::rtl::OUString
& UserID
,const ::rtl::OUString
& Password
,long Options
);
88 sal_Bool
GetErrors(ADOErrors
** pErrors
);
90 ::rtl::OUString
GetDefaultDatabase() const;
91 sal_Bool
PutDefaultDatabase(const ::rtl::OUString
& _bstr
);
93 IsolationLevelEnum
get_IsolationLevel() const ;
94 sal_Bool
put_IsolationLevel(const IsolationLevelEnum
& eNum
) ;
96 sal_Int32
get_Attributes() const;
97 sal_Bool
put_Attributes(sal_Int32 nRet
);
99 CursorLocationEnum
get_CursorLocation() const;
100 sal_Bool
put_CursorLocation(const CursorLocationEnum
&eNum
) ;
102 ConnectModeEnum
get_Mode() const;
103 sal_Bool
put_Mode(const ConnectModeEnum
&eNum
) ;
105 ::rtl::OUString
get_Provider() const;
106 sal_Bool
put_Provider(const ::rtl::OUString
& _bstr
);
108 sal_Int32
get_State() const;
110 sal_Bool
OpenSchema(SchemaEnum eNum
,OLEVariant
& Restrictions
,OLEVariant
& SchemaID
,ADORecordset
**pprset
);
112 ::rtl::OUString
get_Version() const;
115 ADORecordset
* getExportedKeys( const ::com::sun::star::uno::Any
& catalog
, const ::rtl::OUString
& schema
, const ::rtl::OUString
& table
);
116 ADORecordset
* getImportedKeys( const ::com::sun::star::uno::Any
& catalog
, const ::rtl::OUString
& schema
, const ::rtl::OUString
& table
);
117 ADORecordset
* getPrimaryKeys( const ::com::sun::star::uno::Any
& catalog
, const ::rtl::OUString
& schema
, const ::rtl::OUString
& table
);
118 ADORecordset
* getIndexInfo( const ::com::sun::star::uno::Any
& catalog
, const ::rtl::OUString
& schema
, const ::rtl::OUString
& table
, sal_Bool unique
, sal_Bool approximate
);
119 ADORecordset
* getTablePrivileges( const ::com::sun::star::uno::Any
& catalog
,
120 const ::rtl::OUString
& schemaPattern
,
121 const ::rtl::OUString
& tableNamePattern
);
122 ADORecordset
* getCrossReference( const ::com::sun::star::uno::Any
& primaryCatalog
,
123 const ::rtl::OUString
& primarySchema
,
124 const ::rtl::OUString
& primaryTable
,
125 const ::com::sun::star::uno::Any
& foreignCatalog
,
126 const ::rtl::OUString
& foreignSchema
,
127 const ::rtl::OUString
& foreignTable
);
128 ADORecordset
* getProcedures( const ::com::sun::star::uno::Any
& catalog
,
129 const ::rtl::OUString
& schemaPattern
,
130 const ::rtl::OUString
& procedureNamePattern
);
131 ADORecordset
* getProcedureColumns( const ::com::sun::star::uno::Any
& catalog
,
132 const ::rtl::OUString
& schemaPattern
,
133 const ::rtl::OUString
& procedureNamePattern
,
134 const ::rtl::OUString
& columnNamePattern
);
135 ADORecordset
* getTables( const ::com::sun::star::uno::Any
& catalog
,
136 const ::rtl::OUString
& schemaPattern
,
137 const ::rtl::OUString
& tableNamePattern
,
138 const ::com::sun::star::uno::Sequence
< ::rtl::OUString
>& types
);
139 ADORecordset
* getColumns( const ::com::sun::star::uno::Any
& catalog
,
140 const ::rtl::OUString
& schemaPattern
,
141 const ::rtl::OUString
& tableNamePattern
,
142 const ::rtl::OUString
& columnNamePattern
);
143 ADORecordset
* getColumnPrivileges( const ::com::sun::star::uno::Any
& catalog
,
144 const ::rtl::OUString
& schemaPattern
,
145 const ::rtl::OUString
& table
,
146 const ::rtl::OUString
& columnNamePattern
);
147 ADORecordset
* getTypeInfo(DataTypeEnum _eType
= adEmpty
);
150 //------------------------------------------------------------------------
151 class WpADOCommand
: public WpOLEBase
<ADOCommand
>
156 // They only call the superclass
157 WpADOCommand(ADOCommand
* pInt
) : WpOLEBase
<ADOCommand
>(pInt
){}
159 WpADOCommand(const WpADOCommand
& rhs
) : WpOLEBase
<ADOCommand
>(rhs
) {}
161 WpADOCommand
& operator=(const WpADOCommand
& rhs
)
163 WpOLEBase
<ADOCommand
>::operator=(rhs
); return *this;}
165 //////////////////////////////////////////////////////////////////////
167 sal_Bool
putref_ActiveConnection( WpADOConnection
*pCon
);
169 void put_ActiveConnection(/* [in] */ const OLEVariant
& vConn
);
171 sal_Int32
get_State() const;
172 ::rtl::OUString
get_CommandText() const;
173 sal_Bool
put_CommandText(const ::rtl::OUString
&aCon
) ;
174 sal_Int32
get_CommandTimeout() const;
175 void put_CommandTimeout(sal_Int32 nRet
);
176 sal_Bool
get_Prepared() const;
177 sal_Bool
put_Prepared(VARIANT_BOOL bPrepared
) const;
178 sal_Bool
Execute(OLEVariant
& RecordsAffected
,OLEVariant
& Parameters
,long Options
, ADORecordset
** ppiRset
);
179 ADOParameter
* CreateParameter(const ::rtl::OUString
&_bstr
,DataTypeEnum Type
,ParameterDirectionEnum Direction
,long nSize
,const OLEVariant
&Value
);
181 ADOParameters
* get_Parameters() const;
182 sal_Bool
put_CommandType( /* [in] */ CommandTypeEnum lCmdType
);
183 CommandTypeEnum
get_CommandType( ) const ;
184 // Returns the field's name
185 ::rtl::OUString
GetName() const ;
186 sal_Bool
put_Name(const ::rtl::OUString
& _Name
);
189 //------------------------------------------------------------------------
190 class WpADOError
: public WpOLEBase
<ADOError
>
195 // They only call the superclass
196 WpADOError(ADOError
* pInt
):WpOLEBase
<ADOError
>(pInt
){}
198 WpADOError(const WpADOError
& rhs
) : WpOLEBase
<ADOError
>(rhs
) {}
200 WpADOError
& operator=(const WpADOError
& rhs
)
201 {WpOLEBase
<ADOError
>::operator=(rhs
); return *this;}
203 //////////////////////////////////////////////////////////////////////
205 ::rtl::OUString
GetDescription() const;
206 ::rtl::OUString
GetSource() const ;
207 sal_Int32
GetNumber() const ;
208 ::rtl::OUString
GetSQLState() const ;
209 sal_Int32
GetNativeError() const ;
214 //------------------------------------------------------------------------
215 class WpADOField
: public WpOLEBase
<ADOField
>
217 // friend class WpADOFields;
221 // They only call the superclass
222 WpADOField(ADOField
* pInt
=NULL
):WpOLEBase
<ADOField
>(pInt
){}
223 WpADOField(const WpADOField
& rhs
) : WpOLEBase
<ADOField
>(rhs
) {}
225 WpADOField
& operator=(const WpADOField
& rhs
)
226 {WpOLEBase
<ADOField
>::operator=(rhs
); return *this;}
227 //////////////////////////////////////////////////////////////////////
229 WpADOProperties
get_Properties();
230 sal_Int32
GetActualSize() const ;
231 sal_Int32
GetAttributes() const ;
232 sal_Int32
GetStatus() const ;
233 sal_Int32
GetDefinedSize() const ;
234 // Returns the field's name
235 ::rtl::OUString
GetName() const ;
236 DataTypeEnum
GetADOType() const ;
237 void get_Value(OLEVariant
& aValVar
) const ;
238 OLEVariant
get_Value() const;
239 sal_Bool
PutValue(const OLEVariant
& aVariant
);
240 sal_Int32
GetPrecision() const ;
241 sal_Int32
GetNumericScale() const ;
242 sal_Bool
AppendChunk(const OLEVariant
& _Variant
);
243 OLEVariant
GetChunk(long Length
) const;
244 void GetChunk(long Length
,OLEVariant
&aValVar
) const;
245 OLEVariant
GetOriginalValue() const;
246 void GetOriginalValue(OLEVariant
&aValVar
) const;
247 OLEVariant
GetUnderlyingValue() const;
249 void GetUnderlyingValue(OLEVariant
&aValVar
) const;
251 sal_Bool
PutPrecision(sal_Int8 _prec
);
253 sal_Bool
PutNumericScale(sal_Int8 _prec
);
255 void PutADOType(DataTypeEnum eType
) ;
257 sal_Bool
PutDefinedSize(sal_Int32 _nDefSize
);
259 sal_Bool
PutAttributes(sal_Int32 _nDefSize
);
264 //------------------------------------------------------------------------
265 class WpADOProperty
: public WpOLEBase
<ADOProperty
>
269 // They only call the superclass
270 WpADOProperty(ADOProperty
* pInt
=NULL
):WpOLEBase
<ADOProperty
>(pInt
){}
271 WpADOProperty(const WpADOProperty
& rhs
) : WpOLEBase
<ADOProperty
>(rhs
) {}
272 WpADOProperty
& operator=(const WpADOProperty
& rhs
)
273 {WpOLEBase
<ADOProperty
>::operator=(rhs
); return *this;}
274 //////////////////////////////////////////////////////////////////////
276 OLEVariant
GetValue() const;
277 void GetValue(OLEVariant
&aValVar
) const;
278 sal_Bool
PutValue(const OLEVariant
&aValVar
) ;
279 ::rtl::OUString
GetName() const ;
280 DataTypeEnum
GetADOType() const ;
281 sal_Int32
GetAttributes() const ;
282 sal_Bool
PutAttributes(sal_Int32 _nDefSize
);
286 class WpADORecordset
: public WpOLEBase
<ADORecordset
>
291 // They only call the superclass
292 WpADORecordset(ADORecordset
* pInt
=NULL
):WpOLEBase
<ADORecordset
>(pInt
){}
293 WpADORecordset(const WpADORecordset
& rhs
) : WpOLEBase
<ADORecordset
>() {operator=(rhs
);}
294 WpADORecordset
& operator=(const WpADORecordset
& rhs
)
296 WpOLEBase
<ADORecordset
>::operator=(rhs
);
301 // if(pInterface && get_State() == adStateOpen)
304 //////////////////////////////////////////////////////////////////////
307 /* [optional][in] */ VARIANT Source
,
308 /* [optional][in] */ VARIANT ActiveConnection
,
309 /* [defaultvalue][in] */ CursorTypeEnum CursorType
,
310 /* [defaultvalue][in] */ LockTypeEnum LockType
,
311 /* [defaultvalue][in] */ sal_Int32 Options
);
312 LockTypeEnum
GetLockType();
314 sal_Bool
Cancel() const;
315 sal_Int32
get_State( );
316 sal_Bool
Supports( /* [in] */ CursorOptionEnum CursorOptions
);
317 PositionEnum_Param
get_AbsolutePosition();
318 void GetDataSource(IUnknown
** pIUnknown
) const ;
319 void PutRefDataSource(IUnknown
* pIUnknown
);
320 void GetBookmark(VARIANT
& var
);
321 OLEVariant
GetBookmark();
322 CompareEnum
CompareBookmarks(const OLEVariant
& left
,const OLEVariant
& right
);
323 sal_Bool
SetBookmark(const OLEVariant
&pSafeAr
);
324 WpADOFields
GetFields() const;
325 sal_Bool
Move(sal_Int32 nRows
, VARIANT aBmk
);
327 sal_Bool
MovePrevious();
328 sal_Bool
MoveFirst();
331 sal_Bool
IsAtBOF() const;
332 sal_Bool
IsAtEOF() const;
333 sal_Bool
Delete(AffectEnum eNum
);
334 sal_Bool
AddNew(const OLEVariant
&FieldList
,const OLEVariant
&Values
);
335 sal_Bool
Update(const OLEVariant
&FieldList
,const OLEVariant
&Values
);
336 sal_Bool
CancelUpdate();
337 WpADOProperties
get_Properties() const;
338 sal_Bool
NextRecordset(OLEVariant
& RecordsAffected
,ADORecordset
** ppiRset
);
339 sal_Bool
get_RecordCount(ADO_LONGPTR
&_nRet
) const;
340 sal_Bool
get_MaxRecords(ADO_LONGPTR
&_nRet
) const;
341 sal_Bool
put_MaxRecords(ADO_LONGPTR _nRet
);
342 sal_Bool
get_CursorType(CursorTypeEnum
&_nRet
) const;
343 sal_Bool
put_CursorType(CursorTypeEnum _nRet
);
344 sal_Bool
get_LockType(LockTypeEnum
&_nRet
) const;
345 sal_Bool
put_LockType(LockTypeEnum _nRet
);
346 sal_Bool
get_CacheSize(sal_Int32
&_nRet
) const;
347 sal_Bool
put_CacheSize(sal_Int32 _nRet
);
348 sal_Bool
UpdateBatch(AffectEnum AffectRecords
);
351 //------------------------------------------------------------------------
352 class WpADOParameter
:public WpOLEBase
<ADOParameter
>
356 // They only call the superclass
357 WpADOParameter(ADOParameter
* pInt
):WpOLEBase
<ADOParameter
>(pInt
){}
358 WpADOParameter(const WpADOParameter
& rhs
):WpOLEBase
<ADOParameter
>(rhs
){}
359 WpADOParameter
& operator=(const WpADOParameter
& rhs
)
360 {WpOLEBase
<ADOParameter
>::operator=(rhs
); return *this;}
361 //////////////////////////////////////////////////////////////////////
363 ::rtl::OUString
GetName() const ;
364 DataTypeEnum
GetADOType() const ;
365 void put_Type(const DataTypeEnum
& _eType
);
366 sal_Bool
put_Size(const sal_Int32
& _nSize
);
367 sal_Int32
GetAttributes() const ;
368 sal_Int32
GetPrecision() const ;
369 sal_Int32
GetNumericScale() const ;
370 ParameterDirectionEnum
get_Direction() const;
371 void GetValue(OLEVariant
& aValVar
) const ;
372 OLEVariant
GetValue() const;
373 sal_Bool
PutValue(const OLEVariant
& aVariant
);
374 sal_Bool
AppendChunk(const OLEVariant
& aVariant
);
380 /** putValue set the property value at the ado column
381 @param _rProps the properties where to set
382 @param _aPosition which property to set
383 @param _aValVar the value to set
385 static void putValue(const WpADOProperties
& _rProps
,const OLEVariant
&_aPosition
,const OLEVariant
&_aValVar
);
387 /** getValue returns a specific property value
388 @param _rProps the properties where to set
389 @param _aPosition the property
391 @return the property value
393 static OLEVariant
getValue(const WpADOProperties
& _rProps
,const OLEVariant
&_aPosition
);
397 #endif //_CONNECTIVITY_ADO_AWRAPADO_HXX_
399 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */