update dev300-m58
[ooovba.git] / connectivity / source / inc / ado / Awrapado.hxx
blob453f1ae4b3d389ad299161a98fb7fa5cff200a40
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: Awrapado.hxx,v $
10 * $Revision: 1.16 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _CONNECTIVITY_ADO_AWRAPADO_HXX_
31 #define _CONNECTIVITY_ADO_AWRAPADO_HXX_
33 #include <com/sun/star/beans/PropertyAttribute.hpp>
35 // Includes fuer ADO
36 #include "ado_pre_sys_include.h"
37 #include <oledb.h>
38 #include <ocidl.h>
39 #include <adoint.h>
40 #include "ado_post_sys_include.h"
43 #include "ado/adoimp.hxx"
44 #include "ado/Aolewrap.hxx"
45 #include "ado/Aolevariant.hxx"
47 namespace connectivity
49 namespace ado
51 class WpADOConnection;
52 class WpADOCommand;
53 class WpADORecordset;
54 class WpADOField;
55 class WpADOParameter;
56 class WpADOError;
57 class WpADOProperty;
59 typedef WpOLEAppendCollection< ADOFields, ADOField, WpADOField> WpADOFields;
60 typedef WpOLECollection< ADOProperties, ADOProperty, WpADOProperty> WpADOProperties;
62 //------------------------------------------------------------------------
63 class WpADOConnection : public WpOLEBase<ADOConnection>
65 friend class WpADOCommand;
66 public:
68 WpADOConnection(ADOConnection* pInt) : WpOLEBase<ADOConnection>(pInt){}
70 WpADOConnection(const WpADOConnection& rhs){operator=(rhs);}
72 WpADOConnection& operator=(const WpADOConnection& rhs)
73 {WpOLEBase<ADOConnection>::operator=(rhs); return *this;}
75 //////////////////////////////////////////////////////////////////////
77 WpADOProperties get_Properties() const;
79 rtl::OUString GetConnectionString() const;
81 sal_Bool PutConnectionString(const ::rtl::OUString &aCon) const;
83 sal_Int32 GetCommandTimeout() const;
85 void PutCommandTimeout(sal_Int32 nRet);
87 sal_Int32 GetConnectionTimeout() const ;
89 void PutConnectionTimeout(sal_Int32 nRet);
91 sal_Bool Close( ) ;
93 sal_Bool Execute(const ::rtl::OUString& _CommandText,OLEVariant& RecordsAffected,long Options, WpADORecordset** ppiRset);
95 sal_Bool BeginTrans();
97 sal_Bool CommitTrans( ) ;
99 sal_Bool RollbackTrans( );
101 sal_Bool Open(const ::rtl::OUString& ConnectionString, const ::rtl::OUString& UserID,const ::rtl::OUString& Password,long Options);
103 sal_Bool GetErrors(ADOErrors** pErrors);
105 ::rtl::OUString GetDefaultDatabase() const;
107 sal_Bool PutDefaultDatabase(const ::rtl::OUString& _bstr);
109 IsolationLevelEnum get_IsolationLevel() const ;
111 sal_Bool put_IsolationLevel(const IsolationLevelEnum& eNum) ;
113 sal_Int32 get_Attributes() const;
115 sal_Bool put_Attributes(sal_Int32 nRet);
117 CursorLocationEnum get_CursorLocation() const;
119 sal_Bool put_CursorLocation(const CursorLocationEnum &eNum) ;
121 ConnectModeEnum get_Mode() const;
123 sal_Bool put_Mode(const ConnectModeEnum &eNum) ;
125 ::rtl::OUString get_Provider() const;
127 sal_Bool put_Provider(const ::rtl::OUString& _bstr);
129 sal_Int32 get_State() const;
131 sal_Bool OpenSchema(SchemaEnum eNum,OLEVariant& Restrictions,OLEVariant& SchemaID,ADORecordset**pprset);
133 ::rtl::OUString get_Version() const;
135 // special methods
136 ADORecordset* getExportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table );
137 ADORecordset* getImportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table );
138 ADORecordset* getPrimaryKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table );
139 ADORecordset* getIndexInfo( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Bool unique, sal_Bool approximate );
140 ADORecordset* getTablePrivileges( const ::com::sun::star::uno::Any& catalog,
141 const ::rtl::OUString& schemaPattern,
142 const ::rtl::OUString& tableNamePattern );
143 ADORecordset* getCrossReference( const ::com::sun::star::uno::Any& primaryCatalog,
144 const ::rtl::OUString& primarySchema,
145 const ::rtl::OUString& primaryTable,
146 const ::com::sun::star::uno::Any& foreignCatalog,
147 const ::rtl::OUString& foreignSchema,
148 const ::rtl::OUString& foreignTable);
149 ADORecordset* getProcedures( const ::com::sun::star::uno::Any& catalog,
150 const ::rtl::OUString& schemaPattern,
151 const ::rtl::OUString& procedureNamePattern );
152 ADORecordset* getProcedureColumns( const ::com::sun::star::uno::Any& catalog,
153 const ::rtl::OUString& schemaPattern,
154 const ::rtl::OUString& procedureNamePattern,
155 const ::rtl::OUString& columnNamePattern );
156 ADORecordset* getTables( const ::com::sun::star::uno::Any& catalog,
157 const ::rtl::OUString& schemaPattern,
158 const ::rtl::OUString& tableNamePattern,
159 const ::com::sun::star::uno::Sequence< ::rtl::OUString >& types );
160 ADORecordset* getColumns( const ::com::sun::star::uno::Any& catalog,
161 const ::rtl::OUString& schemaPattern,
162 const ::rtl::OUString& tableNamePattern,
163 const ::rtl::OUString& columnNamePattern );
164 ADORecordset* getColumnPrivileges( const ::com::sun::star::uno::Any& catalog,
165 const ::rtl::OUString& schemaPattern,
166 const ::rtl::OUString& table,
167 const ::rtl::OUString& columnNamePattern );
168 ADORecordset* getTypeInfo(DataTypeEnum _eType = adEmpty );
171 //------------------------------------------------------------------------
172 class WpADOCommand : public WpOLEBase<ADOCommand>
174 public:
175 WpADOCommand(){}
176 // Konstruktoren, operator=
177 // diese rufen nur die Oberklasse
178 WpADOCommand(ADOCommand* pInt) : WpOLEBase<ADOCommand>(pInt){}
180 WpADOCommand(const WpADOCommand& rhs){operator=(rhs);}
182 WpADOCommand& operator=(const WpADOCommand& rhs)
184 WpOLEBase<ADOCommand>::operator=(rhs); return *this;}
186 //////////////////////////////////////////////////////////////////////
188 sal_Bool putref_ActiveConnection( WpADOConnection *pCon);
190 void put_ActiveConnection(/* [in] */ const OLEVariant& vConn);
191 void Create();
192 sal_Int32 get_State() const;
193 ::rtl::OUString get_CommandText() const;
194 sal_Bool put_CommandText(const ::rtl::OUString &aCon) ;
195 sal_Int32 get_CommandTimeout() const;
196 void put_CommandTimeout(sal_Int32 nRet);
197 sal_Bool get_Prepared() const;
198 sal_Bool put_Prepared(VARIANT_BOOL bPrepared) const;
199 sal_Bool Execute(OLEVariant& RecordsAffected,OLEVariant& Parameters,long Options, ADORecordset** ppiRset);
200 ADOParameter* CreateParameter(const ::rtl::OUString &_bstr,DataTypeEnum Type,ParameterDirectionEnum Direction,long nSize,const OLEVariant &Value);
202 ADOParameters* get_Parameters() const;
203 sal_Bool put_CommandType( /* [in] */ CommandTypeEnum lCmdType);
204 CommandTypeEnum get_CommandType( ) const ;
205 // gibt den Namen des Feldes zur"ueck
206 ::rtl::OUString GetName() const ;
207 sal_Bool put_Name(const ::rtl::OUString& _Name);
208 sal_Bool Cancel();
210 //------------------------------------------------------------------------
211 class WpADOError : public WpOLEBase<ADOError>
213 public:
215 // Konstruktoren, operator=
216 // diese rufen nur die Oberklasse
218 WpADOError(ADOError* pInt):WpOLEBase<ADOError>(pInt){}
220 WpADOError(const WpADOError& rhs){operator=(rhs);}
222 WpADOError& operator=(const WpADOError& rhs)
223 {WpOLEBase<ADOError>::operator=(rhs); return *this;}
225 //////////////////////////////////////////////////////////////////////
227 ::rtl::OUString GetDescription() const;
229 ::rtl::OUString GetSource() const ;
231 sal_Int32 GetNumber() const ;
232 ::rtl::OUString GetSQLState() const ;
233 sal_Int32 GetNativeError() const ;
238 //------------------------------------------------------------------------
239 class WpADOField : public WpOLEBase<ADOField>
241 // friend class WpADOFields;
242 public:
244 // Konstruktoren, operator=
245 // diese rufen nur die Oberklasse
246 WpADOField(ADOField* pInt=NULL):WpOLEBase<ADOField>(pInt){}
247 WpADOField(const WpADOField& rhs){operator=(rhs);}
249 WpADOField& operator=(const WpADOField& rhs)
250 {WpOLEBase<ADOField>::operator=(rhs); return *this;}
251 //////////////////////////////////////////////////////////////////////
253 WpADOProperties get_Properties();
254 sal_Int32 GetActualSize() const ;
255 sal_Int32 GetAttributes() const ;
256 sal_Int32 GetStatus() const ;
257 sal_Int32 GetDefinedSize() const ;
258 // gibt den Namen des Feldes zur"ueck
259 ::rtl::OUString GetName() const ;
260 DataTypeEnum GetADOType() const ;
261 void get_Value(OLEVariant& aValVar) const ;
262 OLEVariant get_Value() const;
263 sal_Bool PutValue(const OLEVariant& aVariant);
264 sal_Int32 GetPrecision() const ;
265 sal_Int32 GetNumericScale() const ;
266 sal_Bool AppendChunk(const OLEVariant& _Variant);
267 OLEVariant GetChunk(long Length) const;
268 void GetChunk(long Length,OLEVariant &aValVar) const;
269 OLEVariant GetOriginalValue() const;
270 void GetOriginalValue(OLEVariant &aValVar) const;
271 OLEVariant GetUnderlyingValue() const;
273 void GetUnderlyingValue(OLEVariant &aValVar) const;
275 sal_Bool PutPrecision(sal_Int8 _prec);
277 sal_Bool PutNumericScale(sal_Int8 _prec);
279 void PutADOType(DataTypeEnum eType) ;
281 sal_Bool PutDefinedSize(sal_Int32 _nDefSize);
283 sal_Bool PutAttributes(sal_Int32 _nDefSize);
288 //------------------------------------------------------------------------
289 class WpADOProperty: public WpOLEBase<ADOProperty>
291 public:
292 // Konstruktoren, operator=
293 // diese rufen nur die Oberklasse
294 WpADOProperty(ADOProperty* pInt=NULL):WpOLEBase<ADOProperty>(pInt){}
295 WpADOProperty(const WpADOProperty& rhs){operator=(rhs);}
296 WpADOProperty& operator=(const WpADOProperty& rhs)
297 {WpOLEBase<ADOProperty>::operator=(rhs); return *this;}
298 //////////////////////////////////////////////////////////////////////
300 OLEVariant GetValue() const;
301 void GetValue(OLEVariant &aValVar) const;
302 sal_Bool PutValue(const OLEVariant &aValVar) ;
303 ::rtl::OUString GetName() const ;
304 DataTypeEnum GetADOType() const ;
305 sal_Int32 GetAttributes() const ;
306 sal_Bool PutAttributes(sal_Int32 _nDefSize);
310 class WpADORecordset : public WpOLEBase<ADORecordset>
313 public:
314 // Konstruktoren, operator=
315 // diese rufen nur die Oberklasse
316 WpADORecordset(ADORecordset* pInt=NULL):WpOLEBase<ADORecordset>(pInt){}
317 WpADORecordset(const WpADORecordset& rhs){operator=(rhs);}
318 WpADORecordset& operator=(const WpADORecordset& rhs)
320 WpOLEBase<ADORecordset>::operator=(rhs);
321 return *this;
323 ~WpADORecordset()
325 // if(pInterface && get_State() == adStateOpen)
326 // Close();
328 //////////////////////////////////////////////////////////////////////
329 void Create();
330 sal_Bool Open(
331 /* [optional][in] */ VARIANT Source,
332 /* [optional][in] */ VARIANT ActiveConnection,
333 /* [defaultvalue][in] */ CursorTypeEnum CursorType,
334 /* [defaultvalue][in] */ LockTypeEnum LockType,
335 /* [defaultvalue][in] */ sal_Int32 Options);
336 LockTypeEnum GetLockType();
337 void Close();
338 sal_Bool Cancel() const;
339 sal_Int32 get_State( );
340 sal_Bool Supports( /* [in] */ CursorOptionEnum CursorOptions);
341 PositionEnum get_AbsolutePosition();
342 void GetDataSource(IUnknown** pIUnknown) const ;
343 void PutRefDataSource(IUnknown* pIUnknown);
344 void GetBookmark(VARIANT& var);
345 OLEVariant GetBookmark();
346 CompareEnum CompareBookmarks(const OLEVariant& left,const OLEVariant& right);
347 sal_Bool SetBookmark(const OLEVariant &pSafeAr);
348 WpADOFields GetFields() const;
349 sal_Bool Move(sal_Int32 nRows, VARIANT aBmk);
350 sal_Bool MoveNext();
351 sal_Bool MovePrevious();
352 sal_Bool MoveFirst();
353 sal_Bool MoveLast();
355 sal_Bool IsAtBOF() const;
356 sal_Bool IsAtEOF() const;
357 sal_Bool Delete(AffectEnum eNum);
358 sal_Bool AddNew(const OLEVariant &FieldList,const OLEVariant &Values);
359 sal_Bool Update(const OLEVariant &FieldList,const OLEVariant &Values);
360 sal_Bool CancelUpdate();
361 WpADOProperties get_Properties() const;
362 sal_Bool NextRecordset(OLEVariant& RecordsAffected,ADORecordset** ppiRset);
363 sal_Bool get_RecordCount(sal_Int32 &_nRet) const;
364 sal_Bool get_MaxRecords(sal_Int32 &_nRet) const;
365 sal_Bool put_MaxRecords(sal_Int32 _nRet);
366 sal_Bool get_CursorType(CursorTypeEnum &_nRet) const;
367 sal_Bool put_CursorType(CursorTypeEnum _nRet);
368 sal_Bool get_LockType(LockTypeEnum &_nRet) const;
369 sal_Bool put_LockType(LockTypeEnum _nRet);
370 sal_Bool get_CacheSize(sal_Int32 &_nRet) const;
371 sal_Bool put_CacheSize(sal_Int32 _nRet);
372 sal_Bool UpdateBatch(AffectEnum AffectRecords);
375 //------------------------------------------------------------------------
376 class WpADOParameter:public WpOLEBase<ADOParameter>
378 public:
379 // Konstruktoren, operator=
380 // diese rufen nur die Oberklasse
381 WpADOParameter(ADOParameter* pInt):WpOLEBase<ADOParameter>(pInt){}
382 WpADOParameter(const WpADOParameter& rhs):WpOLEBase<ADOParameter>(rhs){}
383 WpADOParameter& operator=(const WpADOParameter& rhs)
384 {WpOLEBase<ADOParameter>::operator=(rhs); return *this;}
385 //////////////////////////////////////////////////////////////////////
387 ::rtl::OUString GetName() const ;
388 DataTypeEnum GetADOType() const ;
389 void put_Type(const DataTypeEnum& _eType);
390 sal_Bool put_Size(const sal_Int32& _nSize);
391 sal_Int32 GetAttributes() const ;
392 sal_Int32 GetPrecision() const ;
393 sal_Int32 GetNumericScale() const ;
394 ParameterDirectionEnum get_Direction() const;
395 void GetValue(OLEVariant& aValVar) const ;
396 OLEVariant GetValue() const;
397 sal_Bool PutValue(const OLEVariant& aVariant);
398 sal_Bool AppendChunk(const OLEVariant& aVariant);
401 class OTools
403 public:
404 /** putValue set the property value at the ado column
405 @param _rProps the properties where to set
406 @param _aPosition which property to set
407 @param _aValVar the value to set
409 static void putValue(const WpADOProperties& _rProps,const OLEVariant &_aPosition,const OLEVariant &_aValVar);
411 /** getValue returns a specific property value
412 @param _rProps the properties where to set
413 @param _aPosition the property
415 @return the property value
417 static OLEVariant getValue(const WpADOProperties& _rProps,const OLEVariant &_aPosition);
421 #endif //_CONNECTIVITY_ADO_AWRAPADO_HXX_