1*cdf0e10cSrcweir #ifndef MYSQLC_STATEMENT_HXX
2*cdf0e10cSrcweir #define MYSQLC_STATEMENT_HXX
3*cdf0e10cSrcweir 
4*cdf0e10cSrcweir #include "mysqlc_connection.hxx"
5*cdf0e10cSrcweir #include "mysqlc_subcomponent.hxx"
6*cdf0e10cSrcweir 
7*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
8*cdf0e10cSrcweir #include <com/sun/star/sdbc/SQLWarning.hpp>
9*cdf0e10cSrcweir #include <com/sun/star/sdbc/XBatchExecution.hpp>
10*cdf0e10cSrcweir #include <com/sun/star/sdbc/XCloseable.hpp>
11*cdf0e10cSrcweir #include <com/sun/star/sdbc/XMultipleResults.hpp>
12*cdf0e10cSrcweir #include <com/sun/star/sdbc/XStatement.hpp>
13*cdf0e10cSrcweir #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
14*cdf0e10cSrcweir #include <com/sun/star/util/XCancellable.hpp>
15*cdf0e10cSrcweir 
16*cdf0e10cSrcweir #include <preextstl.h>
17*cdf0e10cSrcweir #include <cppconn/statement.h>
18*cdf0e10cSrcweir #include <postextstl.h>
19*cdf0e10cSrcweir #include <cppuhelper/compbase5.hxx>
20*cdf0e10cSrcweir #include <list>
21*cdf0e10cSrcweir 
22*cdf0e10cSrcweir namespace connectivity
23*cdf0e10cSrcweir {
24*cdf0e10cSrcweir 	namespace mysqlc
25*cdf0e10cSrcweir 	{
26*cdf0e10cSrcweir 		using ::com::sun::star::sdbc::SQLWarning;
27*cdf0e10cSrcweir 		using ::com::sun::star::sdbc::SQLException;
28*cdf0e10cSrcweir 		using ::com::sun::star::uno::Any;
29*cdf0e10cSrcweir 		using ::com::sun::star::uno::RuntimeException;
30*cdf0e10cSrcweir 		using ::rtl::OUString;
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir         typedef ::cppu::WeakComponentImplHelper5<	::com::sun::star::sdbc::XStatement,
33*cdf0e10cSrcweir                                                     ::com::sun::star::sdbc::XWarningsSupplier,
34*cdf0e10cSrcweir                                                     ::com::sun::star::util::XCancellable,
35*cdf0e10cSrcweir                                                     ::com::sun::star::sdbc::XCloseable,
36*cdf0e10cSrcweir                                                     ::com::sun::star::sdbc::XMultipleResults> OCommonStatement_IBase;
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir         class OCommonStatement;
39*cdf0e10cSrcweir         typedef OSubComponent< OCommonStatement, OCommonStatement_IBase >   OStatement_CBase;
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir 		//**************************************************************
42*cdf0e10cSrcweir 		//************ Class: OCommonStatement
43*cdf0e10cSrcweir 		// is a base class for the normal statement and for the prepared statement
44*cdf0e10cSrcweir 		//**************************************************************
45*cdf0e10cSrcweir         class OCommonStatement  :public OBase_Mutex
46*cdf0e10cSrcweir                                 ,public OCommonStatement_IBase
47*cdf0e10cSrcweir                                 ,public ::cppu::OPropertySetHelper
48*cdf0e10cSrcweir                                 ,public OPropertyArrayUsageHelper<OCommonStatement>
49*cdf0e10cSrcweir                                 ,public OStatement_CBase
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir 		{
52*cdf0e10cSrcweir             friend class OSubComponent< OCommonStatement, OCommonStatement_IBase >;
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir         private:
55*cdf0e10cSrcweir 			SQLWarning m_aLastWarning;
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir 		protected:
58*cdf0e10cSrcweir 			::std::list< OUString>	m_aBatchList;
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir 			OConnection*			m_pConnection;	// The owning Connection object
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir 			sql::Statement			*cppStatement;
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir 		protected:
65*cdf0e10cSrcweir 			void disposeResultSet();
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir 			// OPropertyArrayUsageHelper
68*cdf0e10cSrcweir 			::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir 			// OPropertySetHelper
71*cdf0e10cSrcweir 			::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
72*cdf0e10cSrcweir 			sal_Bool SAL_CALL convertFastPropertyValue(Any & rConvertedValue, Any & rOldValue,
73*cdf0e10cSrcweir 															   sal_Int32 nHandle, const Any& rValue)
74*cdf0e10cSrcweir 												throw (::com::sun::star::lang::IllegalArgumentException);
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir 			void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const Any& rValue)
77*cdf0e10cSrcweir 												throw(::com::sun::star::uno::Exception);
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir 			void SAL_CALL getFastPropertyValue(Any& rValue, sal_Int32 nHandle) const;
80*cdf0e10cSrcweir 			virtual ~OCommonStatement();
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir         protected:
83*cdf0e10cSrcweir 			OCommonStatement(OConnection* _pConnection, sql::Statement *_cppStatement);
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir 		public:
86*cdf0e10cSrcweir 			::cppu::OBroadcastHelper& rBHelper;
87*cdf0e10cSrcweir 			using OCommonStatement_IBase::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >;
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir 			// OComponentHelper
90*cdf0e10cSrcweir 			void SAL_CALL disposing(void);
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir 			// XInterface
93*cdf0e10cSrcweir 			void SAL_CALL release() 			throw();
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir 			void SAL_CALL acquire() 			throw();
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir 			// XInterface
98*cdf0e10cSrcweir 			Any SAL_CALL queryInterface(const ::com::sun::star::uno::Type & rType)
99*cdf0e10cSrcweir 												throw(RuntimeException);
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir 			//XTypeProvider
102*cdf0e10cSrcweir 			::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes()
103*cdf0e10cSrcweir 												throw(RuntimeException);
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir 			// XPropertySet
106*cdf0e10cSrcweir 			::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo()
107*cdf0e10cSrcweir 												throw(RuntimeException);
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir 			// XStatement
110*cdf0e10cSrcweir 			::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery(const OUString& sql)
111*cdf0e10cSrcweir 												throw(SQLException, RuntimeException);
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir 			sal_Int32 SAL_CALL executeUpdate(const OUString& sql)
114*cdf0e10cSrcweir 												throw(SQLException, RuntimeException);
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir 			sal_Bool SAL_CALL execute( const OUString& sql )
117*cdf0e10cSrcweir 												throw(SQLException, RuntimeException);
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir 			::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection()
120*cdf0e10cSrcweir 												throw(SQLException, RuntimeException);
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir 			// XWarningsSupplier
123*cdf0e10cSrcweir 			Any SAL_CALL getWarnings() 		throw(SQLException, RuntimeException);
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir 			void SAL_CALL clearWarnings() 		throw(SQLException, RuntimeException);
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir 			// XCancellable
128*cdf0e10cSrcweir 			void SAL_CALL cancel() 				throw(RuntimeException);
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir 			// XCloseable
131*cdf0e10cSrcweir 			void SAL_CALL close() 				throw(SQLException, RuntimeException);
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir 			// XMultipleResults
134*cdf0e10cSrcweir 			::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getResultSet()
135*cdf0e10cSrcweir 												throw(SQLException, RuntimeException);
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir 			sal_Int32 SAL_CALL getUpdateCount() throw(SQLException, RuntimeException);
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir 			sal_Bool SAL_CALL getMoreResults()	throw(SQLException, RuntimeException);
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir 			// other methods
142*cdf0e10cSrcweir 			OConnection* getOwnConnection() const { return m_pConnection;}
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir 		private:
145*cdf0e10cSrcweir 			using ::cppu::OPropertySetHelper::getFastPropertyValue;
146*cdf0e10cSrcweir 		};
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir 		class OStatement :	public OCommonStatement,
150*cdf0e10cSrcweir 							public ::com::sun::star::sdbc::XBatchExecution,
151*cdf0e10cSrcweir 							public ::com::sun::star::lang::XServiceInfo
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir 		{
154*cdf0e10cSrcweir 		protected:
155*cdf0e10cSrcweir 			virtual ~OStatement(){}
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir 		public:
158*cdf0e10cSrcweir 			// ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
159*cdf0e10cSrcweir 			OStatement(OConnection* _pConnection, sql::Statement *_cppStatement) : OCommonStatement(_pConnection, _cppStatement) {}
160*cdf0e10cSrcweir 			DECLARE_SERVICE_INFO();
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir 			Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType )
163*cdf0e10cSrcweir 												throw(RuntimeException);
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir 			void SAL_CALL acquire() 			throw();
166*cdf0e10cSrcweir 			void SAL_CALL release() 			throw();
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir 			// XBatchExecution
169*cdf0e10cSrcweir 			void SAL_CALL addBatch(const OUString& sql)
170*cdf0e10cSrcweir 												throw(SQLException, RuntimeException);
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir 			void SAL_CALL clearBatch()			throw(SQLException, RuntimeException);
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir 			::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch()
175*cdf0e10cSrcweir 												throw(SQLException, RuntimeException);
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir 		};
178*cdf0e10cSrcweir 	}
179*cdf0e10cSrcweir }
180*cdf0e10cSrcweir #endif // MYSQLC_STATEMENT_HXX
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir /*
183*cdf0e10cSrcweir  * Local variables:
184*cdf0e10cSrcweir  * tab-width: 4
185*cdf0e10cSrcweir  * c-basic-offset: 4
186*cdf0e10cSrcweir  * End:
187*cdf0e10cSrcweir  * vim600: noet sw=4 ts=4 fdm=marker
188*cdf0e10cSrcweir  * vim<600: noet sw=4 ts=4
189*cdf0e10cSrcweir  */
190