1*caf5cd79SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*caf5cd79SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*caf5cd79SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*caf5cd79SAndrew Rist  * distributed with this work for additional information
6*caf5cd79SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*caf5cd79SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*caf5cd79SAndrew Rist  * "License"); you may not use this file except in compliance
9*caf5cd79SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*caf5cd79SAndrew Rist  *
11*caf5cd79SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*caf5cd79SAndrew Rist  *
13*caf5cd79SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*caf5cd79SAndrew Rist  * software distributed under the License is distributed on an
15*caf5cd79SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*caf5cd79SAndrew Rist  * KIND, either express or implied.  See the License for the
17*caf5cd79SAndrew Rist  * specific language governing permissions and limitations
18*caf5cd79SAndrew Rist  * under the License.
19*caf5cd79SAndrew Rist  *
20*caf5cd79SAndrew Rist  *************************************************************/
21*caf5cd79SAndrew Rist 
22*caf5cd79SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _CONNECTIVITY_ADO_ASTATEMENT_HXX_
25cdf0e10cSrcweir #define _CONNECTIVITY_ADO_ASTATEMENT_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/sdbc/XStatement.hpp>
28cdf0e10cSrcweir #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
29cdf0e10cSrcweir #include <com/sun/star/sdbc/XMultipleResults.hpp>
30cdf0e10cSrcweir #include <com/sun/star/sdbc/XBatchExecution.hpp>
31cdf0e10cSrcweir #include <com/sun/star/sdbc/XCloseable.hpp>
32cdf0e10cSrcweir #include <com/sun/star/sdbc/SQLWarning.hpp>
33cdf0e10cSrcweir #include <com/sun/star/util/XCancellable.hpp>
34cdf0e10cSrcweir #include <cppuhelper/compbase5.hxx>
35cdf0e10cSrcweir #include <comphelper/proparrhlp.hxx>
36cdf0e10cSrcweir #include <comphelper/uno3.hxx>
37cdf0e10cSrcweir #include <comphelper/broadcasthelper.hxx>
38cdf0e10cSrcweir #include "ado/AConnection.hxx"
39cdf0e10cSrcweir #ifndef _LIST_
40cdf0e10cSrcweir #include <list>
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir #include "ado/Awrapado.hxx"
43cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
44cdf0e10cSrcweir 
45cdf0e10cSrcweir namespace connectivity
46cdf0e10cSrcweir {
47cdf0e10cSrcweir 	namespace ado
48cdf0e10cSrcweir 	{
49cdf0e10cSrcweir         typedef ::cppu::WeakComponentImplHelper5<   ::com::sun::star::sdbc::XStatement,
50cdf0e10cSrcweir                                                     ::com::sun::star::sdbc::XWarningsSupplier,
51cdf0e10cSrcweir                                                     ::com::sun::star::util::XCancellable,
52cdf0e10cSrcweir                                                     ::com::sun::star::sdbc::XCloseable,
53cdf0e10cSrcweir                                                     ::com::sun::star::sdbc::XMultipleResults> OStatement_BASE;
54cdf0e10cSrcweir 
55cdf0e10cSrcweir 		//**************************************************************
56cdf0e10cSrcweir 		//************ Class: java.sql.Statement
57cdf0e10cSrcweir 		//**************************************************************
58cdf0e10cSrcweir 		class OStatement_Base		:	public comphelper::OBaseMutex,
59cdf0e10cSrcweir 										public	OStatement_BASE,
60cdf0e10cSrcweir 										public	::cppu::OPropertySetHelper,
61cdf0e10cSrcweir 										public	::comphelper::OPropertyArrayUsageHelper<OStatement_Base>,
62cdf0e10cSrcweir 										public  connectivity::OSubComponent<OStatement_Base, OStatement_BASE>
63cdf0e10cSrcweir 
64cdf0e10cSrcweir 		{
65cdf0e10cSrcweir 			friend class connectivity::OSubComponent<OStatement_Base, OStatement_BASE>;
66cdf0e10cSrcweir 			friend class OResultSet;
67cdf0e10cSrcweir 
68cdf0e10cSrcweir 			::com::sun::star::sdbc::SQLWarning			m_aLastWarning;
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 		protected:
71cdf0e10cSrcweir 			::std::list< ::rtl::OUString>				m_aBatchList;
72cdf0e10cSrcweir 
73cdf0e10cSrcweir             ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet>    m_xResultSet;   // The last ResultSet created
74cdf0e10cSrcweir 																		//  for this Statement
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 			OConnection*								m_pConnection;// The owning Connection object
77cdf0e10cSrcweir 			WpADOCommand								m_Command;
78cdf0e10cSrcweir 			WpADORecordset								m_RecordSet;
79cdf0e10cSrcweir 			OLEVariant									m_RecordsAffected;
80cdf0e10cSrcweir 			OLEVariant									m_Parameters;
81cdf0e10cSrcweir 			::std::vector<connectivity::OTypeInfo>		m_aTypeInfo;	// Hashtable containing an entry
82cdf0e10cSrcweir 																		//  for each row returned by
83cdf0e10cSrcweir 																		//  DatabaseMetaData.getTypeInfo.
84cdf0e10cSrcweir 			sal_Int32									m_nMaxRows;
85cdf0e10cSrcweir 			sal_Int32									m_nFetchSize;
86cdf0e10cSrcweir 			LockTypeEnum								m_eLockType;
87cdf0e10cSrcweir 			CursorTypeEnum								m_eCursorType;
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 			using OStatement_BASE::rBHelper;
90cdf0e10cSrcweir 		private:
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 			sal_Int32 getQueryTimeOut()         const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
93cdf0e10cSrcweir             sal_Int32 getMaxFieldSize()         const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
94cdf0e10cSrcweir             sal_Int32 getMaxRows()              const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
95cdf0e10cSrcweir             sal_Int32 getResultSetConcurrency() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
96cdf0e10cSrcweir             sal_Int32 getResultSetType()        const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
97cdf0e10cSrcweir             sal_Int32 getFetchDirection()       const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
98cdf0e10cSrcweir             sal_Int32 getFetchSize()            const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
99cdf0e10cSrcweir             ::rtl::OUString getCursorName()     const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
100cdf0e10cSrcweir 
101cdf0e10cSrcweir             void setQueryTimeOut(sal_Int32 _par0)           throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
102cdf0e10cSrcweir             void setMaxFieldSize(sal_Int32 _par0)           throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
103cdf0e10cSrcweir             void setMaxRows(sal_Int32 _par0)                throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
104cdf0e10cSrcweir             void setResultSetConcurrency(sal_Int32 _par0)   throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
105cdf0e10cSrcweir             void setResultSetType(sal_Int32 _par0)          throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
106cdf0e10cSrcweir             void setFetchDirection(sal_Int32 _par0)         throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
107cdf0e10cSrcweir             void setFetchSize(sal_Int32 _par0)              throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
108cdf0e10cSrcweir             void setCursorName(const ::rtl::OUString &_par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 		protected:
111cdf0e10cSrcweir 
112cdf0e10cSrcweir 			void assignRecordSet( ADORecordset* _pRS );
113cdf0e10cSrcweir 
114cdf0e10cSrcweir             void reset () throw( ::com::sun::star::sdbc::SQLException);
115cdf0e10cSrcweir             void clearMyResultSet () throw( ::com::sun::star::sdbc::SQLException);
116cdf0e10cSrcweir             void setWarning (const  ::com::sun::star::sdbc::SQLWarning &ex) throw( ::com::sun::star::sdbc::SQLException);
117cdf0e10cSrcweir             sal_Int32 getColumnCount () throw( ::com::sun::star::sdbc::SQLException);
118cdf0e10cSrcweir             sal_Int32 getRowCount () throw( ::com::sun::star::sdbc::SQLException);
119cdf0e10cSrcweir 			sal_Int32 getPrecision ( sal_Int32 sqlType);
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 			void disposeResultSet();
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 			// OPropertyArrayUsageHelper
124cdf0e10cSrcweir 			virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
125cdf0e10cSrcweir 			// OPropertySetHelper
126cdf0e10cSrcweir 			virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
127cdf0e10cSrcweir 			virtual sal_Bool SAL_CALL convertFastPropertyValue(
128cdf0e10cSrcweir                                 ::com::sun::star::uno::Any & rConvertedValue,
129cdf0e10cSrcweir                                 ::com::sun::star::uno::Any & rOldValue,
130cdf0e10cSrcweir 								sal_Int32 nHandle,
131cdf0e10cSrcweir                                 const ::com::sun::star::uno::Any& rValue )
132cdf0e10cSrcweir 									throw (::com::sun::star::lang::IllegalArgumentException);
133cdf0e10cSrcweir 			virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
134cdf0e10cSrcweir 									sal_Int32 nHandle,
135cdf0e10cSrcweir                                     const ::com::sun::star::uno::Any& rValue
136cdf0e10cSrcweir 									)
137cdf0e10cSrcweir                                     throw (::com::sun::star::uno::Exception);
138cdf0e10cSrcweir 			virtual void SAL_CALL getFastPropertyValue(
139cdf0e10cSrcweir                                     ::com::sun::star::uno::Any& rValue,
140cdf0e10cSrcweir 									sal_Int32 nHandle
141cdf0e10cSrcweir 									) const;
142cdf0e10cSrcweir 		public:
143cdf0e10cSrcweir 			OStatement_Base(OConnection* _pConnection );
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 			using OStatement_BASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >;
146cdf0e10cSrcweir 			// OComponentHelper
147cdf0e10cSrcweir 			virtual void SAL_CALL disposing(void);
148cdf0e10cSrcweir 			// XInterface
149cdf0e10cSrcweir             virtual void SAL_CALL acquire() throw();
150cdf0e10cSrcweir 			virtual void SAL_CALL release() throw();
151cdf0e10cSrcweir             virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
152cdf0e10cSrcweir 			//XTypeProvider
153cdf0e10cSrcweir             virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw(::com::sun::star::uno::RuntimeException);
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 			// XPropertySet
156cdf0e10cSrcweir             virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
157cdf0e10cSrcweir 			// XStatement
158cdf0e10cSrcweir             virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
159cdf0e10cSrcweir             virtual sal_Int32 SAL_CALL executeUpdate( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
160cdf0e10cSrcweir             virtual sal_Bool SAL_CALL execute( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
161cdf0e10cSrcweir             virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
162cdf0e10cSrcweir 			// XWarningsSupplier
163cdf0e10cSrcweir             virtual ::com::sun::star::uno::Any SAL_CALL getWarnings(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
164cdf0e10cSrcweir             virtual void SAL_CALL clearWarnings(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
165cdf0e10cSrcweir 			// XCancellable
166cdf0e10cSrcweir             virtual void SAL_CALL cancel(  ) throw(::com::sun::star::uno::RuntimeException);
167cdf0e10cSrcweir 			// XCloseable
168cdf0e10cSrcweir             virtual void SAL_CALL close(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
169cdf0e10cSrcweir 			// XMultipleResults
170cdf0e10cSrcweir             virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getResultSet(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
171cdf0e10cSrcweir             virtual sal_Int32 SAL_CALL getUpdateCount(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
172cdf0e10cSrcweir             virtual sal_Bool SAL_CALL getMoreResults(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
173cdf0e10cSrcweir 		};
174cdf0e10cSrcweir 
175cdf0e10cSrcweir 		class OStatement :	public OStatement_Base,
176cdf0e10cSrcweir                             public ::com::sun::star::sdbc::XBatchExecution,
177cdf0e10cSrcweir                             public ::com::sun::star::lang::XServiceInfo
178cdf0e10cSrcweir 		{
179cdf0e10cSrcweir 		public:
180cdf0e10cSrcweir 			// ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
OStatement(OConnection * _pConnection)181cdf0e10cSrcweir 			OStatement( OConnection* _pConnection) : OStatement_Base( _pConnection){};
182cdf0e10cSrcweir 			~OStatement();
183cdf0e10cSrcweir 
184cdf0e10cSrcweir 			DECLARE_SERVICE_INFO();
185cdf0e10cSrcweir 
186cdf0e10cSrcweir 			virtual void SAL_CALL acquire() throw();
187cdf0e10cSrcweir             virtual void SAL_CALL release() throw();
188cdf0e10cSrcweir             virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
189cdf0e10cSrcweir 			// XBatchExecution
190cdf0e10cSrcweir             virtual void SAL_CALL addBatch( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
191cdf0e10cSrcweir             virtual void SAL_CALL clearBatch(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
192cdf0e10cSrcweir             virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
193cdf0e10cSrcweir 		};
194cdf0e10cSrcweir 	}
195cdf0e10cSrcweir }
196cdf0e10cSrcweir #endif // _CONNECTIVITY_ADO_ASTATEMENT_HXX_
197cdf0e10cSrcweir 
198