xref: /AOO41X/main/connectivity/source/inc/ado/Awrapado.hxx (revision caf5cd79edad04a48dcaf209068b3b89eae4622e)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _CONNECTIVITY_ADO_AWRAPADO_HXX_
24 #define _CONNECTIVITY_ADO_AWRAPADO_HXX_
25 
26 #include <com/sun/star/beans/PropertyAttribute.hpp>
27 
28 // Includes fuer ADO
29 #include "ado_pre_sys_include.h"
30 #include <oledb.h>
31 #include <ocidl.h>
32 #include <adoint.h>
33 #include "ado_post_sys_include.h"
34 
35 
36 #include "ado/adoimp.hxx"
37 #include "ado/Aolewrap.hxx"
38 #include "ado/Aolevariant.hxx"
39 
40 namespace connectivity
41 {
42     namespace ado
43     {
44         class WpADOConnection;
45         class WpADOCommand;
46         class WpADORecordset;
47         class WpADOField;
48         class WpADOParameter;
49         class WpADOError;
50         class WpADOProperty;
51 
52         typedef WpOLEAppendCollection<  ADOFields,      ADOField,       WpADOField>         WpADOFields;
53         typedef WpOLECollection<        ADOProperties,  ADOProperty,    WpADOProperty>      WpADOProperties;
54 
55         //------------------------------------------------------------------------
56         class WpADOConnection : public WpOLEBase<ADOConnection>
57         {
58             friend class WpADOCommand;
59         public:
60 
WpADOConnection(ADOConnection * pInt)61             WpADOConnection(ADOConnection* pInt)    :   WpOLEBase<ADOConnection>(pInt){}
62 
WpADOConnection(const WpADOConnection & rhs)63             WpADOConnection(const WpADOConnection& rhs){operator=(rhs);}
64 
operator =(const WpADOConnection & rhs)65              WpADOConnection& operator=(const WpADOConnection& rhs)
66                 {WpOLEBase<ADOConnection>::operator=(rhs); return *this;}
67 
68             //////////////////////////////////////////////////////////////////////
69 
70             WpADOProperties get_Properties() const;
71 
72              rtl::OUString GetConnectionString() const;
73 
74              sal_Bool PutConnectionString(const ::rtl::OUString &aCon) const;
75 
76              sal_Int32 GetCommandTimeout() const;
77 
78              void PutCommandTimeout(sal_Int32 nRet);
79 
80              sal_Int32 GetConnectionTimeout() const ;
81 
82              void PutConnectionTimeout(sal_Int32 nRet);
83 
84              sal_Bool Close( ) ;
85 
86              sal_Bool Execute(const ::rtl::OUString& _CommandText,OLEVariant& RecordsAffected,long Options, WpADORecordset** ppiRset);
87 
88              sal_Bool BeginTrans();
89 
90              sal_Bool CommitTrans( ) ;
91 
92              sal_Bool RollbackTrans( );
93 
94              sal_Bool Open(const ::rtl::OUString& ConnectionString, const ::rtl::OUString& UserID,const ::rtl::OUString& Password,long Options);
95 
96              sal_Bool GetErrors(ADOErrors** pErrors);
97 
98              ::rtl::OUString GetDefaultDatabase() const;
99 
100              sal_Bool PutDefaultDatabase(const ::rtl::OUString& _bstr);
101 
102              IsolationLevelEnum get_IsolationLevel() const ;
103 
104              sal_Bool put_IsolationLevel(const IsolationLevelEnum& eNum) ;
105 
106              sal_Int32 get_Attributes() const;
107 
108              sal_Bool put_Attributes(sal_Int32 nRet);
109 
110              CursorLocationEnum get_CursorLocation() const;
111 
112              sal_Bool put_CursorLocation(const CursorLocationEnum &eNum) ;
113 
114              ConnectModeEnum get_Mode() const;
115 
116              sal_Bool put_Mode(const ConnectModeEnum &eNum) ;
117 
118              ::rtl::OUString get_Provider() const;
119 
120              sal_Bool put_Provider(const ::rtl::OUString& _bstr);
121 
122              sal_Int32 get_State() const;
123 
124              sal_Bool OpenSchema(SchemaEnum eNum,OLEVariant& Restrictions,OLEVariant& SchemaID,ADORecordset**pprset);
125 
126              ::rtl::OUString get_Version() const;
127 
128              // special methods
129              ADORecordset* getExportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table );
130              ADORecordset* getImportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table );
131              ADORecordset* getPrimaryKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table );
132              ADORecordset* getIndexInfo( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Bool unique, sal_Bool approximate );
133              ADORecordset* getTablePrivileges( const ::com::sun::star::uno::Any& catalog,
134                                                   const ::rtl::OUString& schemaPattern,
135                                                   const ::rtl::OUString& tableNamePattern );
136              ADORecordset* getCrossReference( const ::com::sun::star::uno::Any& primaryCatalog,
137                                                   const ::rtl::OUString& primarySchema,
138                                                   const ::rtl::OUString& primaryTable,
139                                                   const ::com::sun::star::uno::Any& foreignCatalog,
140                                                   const ::rtl::OUString& foreignSchema,
141                                                   const ::rtl::OUString& foreignTable);
142              ADORecordset* getProcedures( const ::com::sun::star::uno::Any& catalog,
143                                                   const ::rtl::OUString& schemaPattern,
144                                                   const ::rtl::OUString& procedureNamePattern );
145              ADORecordset* getProcedureColumns( const ::com::sun::star::uno::Any& catalog,
146                                                   const ::rtl::OUString& schemaPattern,
147                                                   const ::rtl::OUString& procedureNamePattern,
148                                                   const ::rtl::OUString& columnNamePattern );
149              ADORecordset* getTables( const ::com::sun::star::uno::Any& catalog,
150                                                   const ::rtl::OUString& schemaPattern,
151                                                   const ::rtl::OUString& tableNamePattern,
152                                                   const ::com::sun::star::uno::Sequence< ::rtl::OUString >& types );
153              ADORecordset* getColumns( const ::com::sun::star::uno::Any& catalog,
154                                                   const ::rtl::OUString& schemaPattern,
155                                                   const ::rtl::OUString& tableNamePattern,
156                                                   const ::rtl::OUString& columnNamePattern );
157              ADORecordset* getColumnPrivileges( const ::com::sun::star::uno::Any& catalog,
158                                                   const ::rtl::OUString& schemaPattern,
159                                                   const ::rtl::OUString& table,
160                                                   const ::rtl::OUString& columnNamePattern );
161              ADORecordset* getTypeInfo(DataTypeEnum _eType = adEmpty );
162         };
163 
164         //------------------------------------------------------------------------
165         class WpADOCommand : public WpOLEBase<ADOCommand>
166         {
167         public:
WpADOCommand()168             WpADOCommand(){}
169             // Konstruktoren, operator=
170             // diese rufen nur die Oberklasse
WpADOCommand(ADOCommand * pInt)171             WpADOCommand(ADOCommand* pInt)  :   WpOLEBase<ADOCommand>(pInt){}
172 
WpADOCommand(const WpADOCommand & rhs)173             WpADOCommand(const WpADOCommand& rhs){operator=(rhs);}
174 
operator =(const WpADOCommand & rhs)175              WpADOCommand& operator=(const WpADOCommand& rhs)
176             {
177                 WpOLEBase<ADOCommand>::operator=(rhs); return *this;}
178 
179             //////////////////////////////////////////////////////////////////////
180 
181             sal_Bool putref_ActiveConnection( WpADOConnection *pCon);
182 
183             void put_ActiveConnection(/* [in] */ const OLEVariant& vConn);
184              void Create();
185              sal_Int32 get_State() const;
186              ::rtl::OUString get_CommandText() const;
187              sal_Bool put_CommandText(const ::rtl::OUString &aCon) ;
188              sal_Int32 get_CommandTimeout() const;
189              void put_CommandTimeout(sal_Int32 nRet);
190              sal_Bool get_Prepared() const;
191              sal_Bool put_Prepared(VARIANT_BOOL bPrepared) const;
192              sal_Bool Execute(OLEVariant& RecordsAffected,OLEVariant& Parameters,long Options, ADORecordset** ppiRset);
193              ADOParameter* CreateParameter(const ::rtl::OUString &_bstr,DataTypeEnum Type,ParameterDirectionEnum Direction,long nSize,const OLEVariant &Value);
194 
195              ADOParameters* get_Parameters() const;
196              sal_Bool put_CommandType( /* [in] */ CommandTypeEnum lCmdType);
197              CommandTypeEnum get_CommandType( ) const ;
198             // gibt den Namen des Feldes zur"ueck
199              ::rtl::OUString GetName() const ;
200              sal_Bool put_Name(const ::rtl::OUString& _Name);
201              sal_Bool Cancel();
202         };
203         //------------------------------------------------------------------------
204         class WpADOError : public WpOLEBase<ADOError>
205         {
206         public:
207 
208             // Konstruktoren, operator=
209             // diese rufen nur die Oberklasse
210 
WpADOError(ADOError * pInt)211             WpADOError(ADOError* pInt):WpOLEBase<ADOError>(pInt){}
212 
WpADOError(const WpADOError & rhs)213             WpADOError(const WpADOError& rhs){operator=(rhs);}
214 
operator =(const WpADOError & rhs)215              WpADOError& operator=(const WpADOError& rhs)
216                 {WpOLEBase<ADOError>::operator=(rhs); return *this;}
217 
218             //////////////////////////////////////////////////////////////////////
219 
220              ::rtl::OUString GetDescription() const;
221 
222              ::rtl::OUString GetSource() const ;
223 
224              sal_Int32 GetNumber() const ;
225              ::rtl::OUString GetSQLState() const ;
226              sal_Int32 GetNativeError() const ;
227         };
228 
229 
230 
231         //------------------------------------------------------------------------
232         class WpADOField : public WpOLEBase<ADOField>
233         {
234             //  friend class WpADOFields;
235         public:
236 
237             // Konstruktoren, operator=
238             // diese rufen nur die Oberklasse
WpADOField(ADOField * pInt=NULL)239             WpADOField(ADOField* pInt=NULL):WpOLEBase<ADOField>(pInt){}
WpADOField(const WpADOField & rhs)240             WpADOField(const WpADOField& rhs){operator=(rhs);}
241 
operator =(const WpADOField & rhs)242              WpADOField& operator=(const WpADOField& rhs)
243                 {WpOLEBase<ADOField>::operator=(rhs); return *this;}
244             //////////////////////////////////////////////////////////////////////
245 
246              WpADOProperties get_Properties();
247              sal_Int32 GetActualSize() const ;
248              sal_Int32 GetAttributes() const ;
249              sal_Int32 GetStatus() const      ;
250              sal_Int32 GetDefinedSize() const ;
251             // gibt den Namen des Feldes zur"ueck
252              ::rtl::OUString GetName() const ;
253              DataTypeEnum GetADOType() const  ;
254              void get_Value(OLEVariant& aValVar) const ;
255              OLEVariant get_Value() const;
256              sal_Bool PutValue(const OLEVariant& aVariant);
257              sal_Int32 GetPrecision() const ;
258              sal_Int32 GetNumericScale() const ;
259              sal_Bool AppendChunk(const OLEVariant& _Variant);
260              OLEVariant GetChunk(long Length) const;
261              void GetChunk(long Length,OLEVariant &aValVar) const;
262              OLEVariant GetOriginalValue() const;
263              void GetOriginalValue(OLEVariant &aValVar) const;
264              OLEVariant GetUnderlyingValue() const;
265 
266              void GetUnderlyingValue(OLEVariant &aValVar) const;
267 
268              sal_Bool PutPrecision(sal_Int8 _prec);
269 
270              sal_Bool PutNumericScale(sal_Int8 _prec);
271 
272              void PutADOType(DataTypeEnum eType) ;
273 
274              sal_Bool PutDefinedSize(sal_Int32 _nDefSize);
275 
276              sal_Bool PutAttributes(sal_Int32 _nDefSize);
277         };
278 
279 
280 
281         //------------------------------------------------------------------------
282         class WpADOProperty: public WpOLEBase<ADOProperty>
283         {
284         public:
285             // Konstruktoren, operator=
286             // diese rufen nur die Oberklasse
WpADOProperty(ADOProperty * pInt=NULL)287             WpADOProperty(ADOProperty* pInt=NULL):WpOLEBase<ADOProperty>(pInt){}
WpADOProperty(const WpADOProperty & rhs)288             WpADOProperty(const WpADOProperty& rhs){operator=(rhs);}
operator =(const WpADOProperty & rhs)289              WpADOProperty& operator=(const WpADOProperty& rhs)
290                 {WpOLEBase<ADOProperty>::operator=(rhs); return *this;}
291             //////////////////////////////////////////////////////////////////////
292 
293              OLEVariant GetValue() const;
294              void GetValue(OLEVariant &aValVar) const;
295              sal_Bool PutValue(const OLEVariant &aValVar) ;
296              ::rtl::OUString GetName() const ;
297              DataTypeEnum GetADOType() const ;
298              sal_Int32 GetAttributes() const ;
299              sal_Bool PutAttributes(sal_Int32 _nDefSize);
300         };
301 
302 
303         class WpADORecordset : public WpOLEBase<ADORecordset>
304         {
305 
306         public:
307             // Konstruktoren, operator=
308             // diese rufen nur die Oberklasse
WpADORecordset(ADORecordset * pInt=NULL)309             WpADORecordset(ADORecordset* pInt=NULL):WpOLEBase<ADORecordset>(pInt){}
WpADORecordset(const WpADORecordset & rhs)310             WpADORecordset(const WpADORecordset& rhs){operator=(rhs);}
operator =(const WpADORecordset & rhs)311              WpADORecordset& operator=(const WpADORecordset& rhs)
312             {
313                 WpOLEBase<ADORecordset>::operator=(rhs);
314                 return *this;
315             }
~WpADORecordset()316             ~WpADORecordset()
317             {
318                 //  if(pInterface && get_State() == adStateOpen)
319                     //  Close();
320             }
321             //////////////////////////////////////////////////////////////////////
322              void Create();
323              sal_Bool Open(
324                     /* [optional][in] */ VARIANT Source,
325                     /* [optional][in] */ VARIANT ActiveConnection,
326                     /* [defaultvalue][in] */ CursorTypeEnum CursorType,
327                     /* [defaultvalue][in] */ LockTypeEnum LockType,
328                     /* [defaultvalue][in] */ sal_Int32 Options);
329              LockTypeEnum GetLockType();
330              void Close();
331              sal_Bool Cancel() const;
332              sal_Int32 get_State( );
333              sal_Bool Supports( /* [in] */ CursorOptionEnum CursorOptions);
334             PositionEnum get_AbsolutePosition();
335              void GetDataSource(IUnknown** pIUnknown) const ;
336              void PutRefDataSource(IUnknown* pIUnknown);
337              void GetBookmark(VARIANT& var);
338              OLEVariant GetBookmark();
339             CompareEnum CompareBookmarks(const OLEVariant& left,const OLEVariant& right);
340              sal_Bool SetBookmark(const OLEVariant &pSafeAr);
341              WpADOFields GetFields() const;
342              sal_Bool Move(sal_Int32 nRows, VARIANT aBmk);
343              sal_Bool MoveNext();
344              sal_Bool MovePrevious();
345              sal_Bool MoveFirst();
346              sal_Bool MoveLast();
347 
348              sal_Bool IsAtBOF() const;
349              sal_Bool IsAtEOF() const;
350              sal_Bool Delete(AffectEnum eNum);
351              sal_Bool AddNew(const OLEVariant &FieldList,const OLEVariant &Values);
352              sal_Bool Update(const OLEVariant &FieldList,const OLEVariant &Values);
353              sal_Bool CancelUpdate();
354              WpADOProperties get_Properties() const;
355              sal_Bool NextRecordset(OLEVariant& RecordsAffected,ADORecordset** ppiRset);
356              sal_Bool get_RecordCount(sal_Int32 &_nRet) const;
357              sal_Bool get_MaxRecords(sal_Int32 &_nRet) const;
358              sal_Bool put_MaxRecords(sal_Int32 _nRet);
359              sal_Bool get_CursorType(CursorTypeEnum &_nRet) const;
360              sal_Bool put_CursorType(CursorTypeEnum _nRet);
361              sal_Bool get_LockType(LockTypeEnum &_nRet) const;
362              sal_Bool put_LockType(LockTypeEnum _nRet);
363              sal_Bool get_CacheSize(sal_Int32 &_nRet) const;
364              sal_Bool put_CacheSize(sal_Int32 _nRet);
365              sal_Bool UpdateBatch(AffectEnum AffectRecords);
366         };
367 
368         //------------------------------------------------------------------------
369         class WpADOParameter:public WpOLEBase<ADOParameter>
370         {
371         public:
372             // Konstruktoren, operator=
373             // diese rufen nur die Oberklasse
WpADOParameter(ADOParameter * pInt)374             WpADOParameter(ADOParameter* pInt):WpOLEBase<ADOParameter>(pInt){}
WpADOParameter(const WpADOParameter & rhs)375             WpADOParameter(const WpADOParameter& rhs):WpOLEBase<ADOParameter>(rhs){}
operator =(const WpADOParameter & rhs)376              WpADOParameter& operator=(const WpADOParameter& rhs)
377                 {WpOLEBase<ADOParameter>::operator=(rhs); return *this;}
378             //////////////////////////////////////////////////////////////////////
379 
380              ::rtl::OUString GetName() const ;
381              DataTypeEnum GetADOType() const ;
382              void put_Type(const DataTypeEnum& _eType);
383              sal_Bool put_Size(const sal_Int32& _nSize);
384              sal_Int32 GetAttributes() const ;
385              sal_Int32 GetPrecision() const ;
386              sal_Int32 GetNumericScale() const ;
387              ParameterDirectionEnum get_Direction() const;
388              void GetValue(OLEVariant& aValVar) const ;
389              OLEVariant GetValue() const;
390              sal_Bool PutValue(const OLEVariant& aVariant);
391              sal_Bool AppendChunk(const OLEVariant& aVariant);
392         };
393 
394         class OTools
395         {
396         public:
397             /** putValue set the property value at the ado column
398                 @param  _rProps     the properties where to set
399                 @param  _aPosition  which property to set
400                 @param  _aValVar    the value to set
401             */
402             static void             putValue(const WpADOProperties& _rProps,const OLEVariant &_aPosition,const OLEVariant &_aValVar);
403 
404             /** getValue returns a specific property value
405                 @param  _rProps     the properties where to set
406                 @param  _aPosition  the property
407 
408                 @return the property value
409             */
410             static OLEVariant       getValue(const WpADOProperties& _rProps,const OLEVariant &_aPosition);
411         };
412     }
413 }
414 #endif //_CONNECTIVITY_ADO_AWRAPADO_HXX_
415 
416