1*2e2212a7SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2e2212a7SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2e2212a7SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2e2212a7SAndrew Rist  * distributed with this work for additional information
6*2e2212a7SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2e2212a7SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2e2212a7SAndrew Rist  * "License"); you may not use this file except in compliance
9*2e2212a7SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2e2212a7SAndrew Rist  *
11*2e2212a7SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2e2212a7SAndrew Rist  *
13*2e2212a7SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2e2212a7SAndrew Rist  * software distributed under the License is distributed on an
15*2e2212a7SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2e2212a7SAndrew Rist  * KIND, either express or implied.  See the License for the
17*2e2212a7SAndrew Rist  * specific language governing permissions and limitations
18*2e2212a7SAndrew Rist  * under the License.
19*2e2212a7SAndrew Rist  *
20*2e2212a7SAndrew Rist  *************************************************************/
21*2e2212a7SAndrew Rist 
22*2e2212a7SAndrew Rist 
23cdf0e10cSrcweir #ifndef _DBA_COREAPI_STATEMENT_HXX_
24cdf0e10cSrcweir #define _DBA_COREAPI_STATEMENT_HXX_
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
27cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XSTATEMENT_HPP_
30cdf0e10cSrcweir #include <com/sun/star/sdbc/XStatement.hpp>
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
33cdf0e10cSrcweir #include <com/sun/star/sdbc/XConnection.hpp>
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UTIL_XCANCELLABLE_HPP_
36cdf0e10cSrcweir #include <com/sun/star/util/XCancellable.hpp>
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XWARNINGSSUPPLIER_HPP_
39cdf0e10cSrcweir #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
40cdf0e10cSrcweir #endif
41cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XCLOSEABLE_HPP_
42cdf0e10cSrcweir #include <com/sun/star/sdbc/XCloseable.hpp>
43cdf0e10cSrcweir #endif
44cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XMULTIPLERESULTS_HDL_
45cdf0e10cSrcweir #include <com/sun/star/sdbc/XMultipleResults.hpp>
46cdf0e10cSrcweir #endif
47cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XPREPAREDBATCHEXECUTION_HDL_
48cdf0e10cSrcweir #include <com/sun/star/sdbc/XPreparedBatchExecution.hpp>
49cdf0e10cSrcweir #endif
50cdf0e10cSrcweir #include <com/sun/star/sdbc/XBatchExecution.hpp>
51cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XGENERATEDRESULTSET_HPP_
52cdf0e10cSrcweir #include <com/sun/star/sdbc/XGeneratedResultSet.hpp>
53cdf0e10cSrcweir #endif
54cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYCOMPOSER_HPP_
55cdf0e10cSrcweir #include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
56cdf0e10cSrcweir #endif
57cdf0e10cSrcweir #ifndef _CPPUHELPER_PROPSHLP_HXX
58cdf0e10cSrcweir #include <cppuhelper/propshlp.hxx>
59cdf0e10cSrcweir #endif
60cdf0e10cSrcweir #ifndef _COMPHELPER_PROPERTY_ARRAY_HELPER_HXX_
61cdf0e10cSrcweir #include <comphelper/proparrhlp.hxx>
62cdf0e10cSrcweir #endif
63cdf0e10cSrcweir #ifndef _DBASHARED_APITOOLS_HXX_
64cdf0e10cSrcweir #include "apitools.hxx"
65cdf0e10cSrcweir #endif
66cdf0e10cSrcweir #ifndef _COMPHELPER_BROADCASTHELPER_HXX_
67cdf0e10cSrcweir #include <comphelper/broadcasthelper.hxx>
68cdf0e10cSrcweir #endif
69cdf0e10cSrcweir 
70cdf0e10cSrcweir #include <cppuhelper/implbase3.hxx>
71cdf0e10cSrcweir 
72cdf0e10cSrcweir //************************************************************
73cdf0e10cSrcweir //  OStatementBase
74cdf0e10cSrcweir //************************************************************
75cdf0e10cSrcweir class OStatementBase :	public comphelper::OBaseMutex,
76cdf0e10cSrcweir 						public OSubComponent,
77cdf0e10cSrcweir 						public ::cppu::OPropertySetHelper,
78cdf0e10cSrcweir 						public ::comphelper::OPropertyArrayUsageHelper < OStatementBase >,
79cdf0e10cSrcweir 						public ::com::sun::star::util::XCancellable,
80cdf0e10cSrcweir 						public ::com::sun::star::sdbc::XWarningsSupplier,
81cdf0e10cSrcweir 						public ::com::sun::star::sdbc::XPreparedBatchExecution,
82cdf0e10cSrcweir 						public ::com::sun::star::sdbc::XMultipleResults,
83cdf0e10cSrcweir 						public ::com::sun::star::sdbc::XCloseable,
84cdf0e10cSrcweir 						public ::com::sun::star::sdbc::XGeneratedResultSet
85cdf0e10cSrcweir {
86cdf0e10cSrcweir protected:
87cdf0e10cSrcweir 	::osl::Mutex			m_aCancelMutex;
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 	::com::sun::star::uno::WeakReferenceHelper	m_aResultSet;
90cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xAggregateAsSet;
91cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::util::XCancellable > m_xAggregateAsCancellable;
92cdf0e10cSrcweir 	sal_Bool				m_bUseBookmarks;
93cdf0e10cSrcweir     sal_Bool                m_bEscapeProcessing;
94cdf0e10cSrcweir 
95cdf0e10cSrcweir 	virtual ~OStatementBase();
96cdf0e10cSrcweir 
97cdf0e10cSrcweir public:
98cdf0e10cSrcweir 	OStatementBase(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > & _xConn,
99cdf0e10cSrcweir 				   const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & _xStatement);
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 
102cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider
103cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException);
104cdf0e10cSrcweir 
105cdf0e10cSrcweir // ::com::sun::star::uno::XInterface
106cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException);
107cdf0e10cSrcweir 	virtual void SAL_CALL acquire() throw();
108cdf0e10cSrcweir     virtual void SAL_CALL release() throw();
109cdf0e10cSrcweir 
110cdf0e10cSrcweir // OComponentHelper
111cdf0e10cSrcweir 	virtual void SAL_CALL disposing(void);
112cdf0e10cSrcweir 
113cdf0e10cSrcweir // com::sun::star::beans::XPropertySet
114cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
115cdf0e10cSrcweir 
116cdf0e10cSrcweir // comphelper::OPropertyArrayUsageHelper
117cdf0e10cSrcweir 	virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
118cdf0e10cSrcweir 
119cdf0e10cSrcweir // cppu::OPropertySetHelper
120cdf0e10cSrcweir 	virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 	virtual sal_Bool SAL_CALL convertFastPropertyValue(
123cdf0e10cSrcweir 							::com::sun::star::uno::Any & rConvertedValue,
124cdf0e10cSrcweir 							::com::sun::star::uno::Any & rOldValue,
125cdf0e10cSrcweir 							sal_Int32 nHandle,
126cdf0e10cSrcweir 							const ::com::sun::star::uno::Any& rValue )
127cdf0e10cSrcweir 								throw (::com::sun::star::lang::IllegalArgumentException);
128cdf0e10cSrcweir 	virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
129cdf0e10cSrcweir 								sal_Int32 nHandle,
130cdf0e10cSrcweir 								const ::com::sun::star::uno::Any& rValue
131cdf0e10cSrcweir 												 )
132cdf0e10cSrcweir 												 throw (::com::sun::star::uno::Exception);
133cdf0e10cSrcweir 	virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const;
134cdf0e10cSrcweir 
135cdf0e10cSrcweir // ::com::sun::star::sdbc::XWarningsSupplier
136cdf0e10cSrcweir     virtual ::com::sun::star::uno::Any SAL_CALL getWarnings(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
137cdf0e10cSrcweir     virtual void SAL_CALL clearWarnings(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
138cdf0e10cSrcweir 
139cdf0e10cSrcweir // ::com::sun::star::util::XCancellable
140cdf0e10cSrcweir 	virtual void SAL_CALL cancel(  ) throw(::com::sun::star::uno::RuntimeException);
141cdf0e10cSrcweir 
142cdf0e10cSrcweir // ::com::sun::star::sdbc::XCloseable
143cdf0e10cSrcweir 	virtual void SAL_CALL close(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
144cdf0e10cSrcweir 
145cdf0e10cSrcweir // ::com::sun::star::sdbc::XMultipleResults
146cdf0e10cSrcweir     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);
147cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getUpdateCount(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
148cdf0e10cSrcweir     virtual sal_Bool SAL_CALL getMoreResults(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
149cdf0e10cSrcweir 
150cdf0e10cSrcweir // ::com::sun::star::sdbc::XPreparedBatchExecution
151cdf0e10cSrcweir     virtual void SAL_CALL addBatch(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
152cdf0e10cSrcweir     virtual void SAL_CALL clearBatch(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
153cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
154cdf0e10cSrcweir // ::com::sun::star::sdbc::XGeneratedResultSet
155cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getGeneratedValues(  ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
156cdf0e10cSrcweir 
157cdf0e10cSrcweir // Helper
158cdf0e10cSrcweir 	void disposeResultSet();
159cdf0e10cSrcweir 
160cdf0e10cSrcweir protected:
161cdf0e10cSrcweir     using ::cppu::OPropertySetHelper::getFastPropertyValue;
162cdf0e10cSrcweir };
163cdf0e10cSrcweir 
164cdf0e10cSrcweir //************************************************************
165cdf0e10cSrcweir //  OStatement
166cdf0e10cSrcweir //************************************************************
167cdf0e10cSrcweir typedef ::cppu::ImplHelper3 <   ::com::sun::star::sdbc::XStatement
168cdf0e10cSrcweir                             ,   ::com::sun::star::lang::XServiceInfo
169cdf0e10cSrcweir                             ,   ::com::sun::star::sdbc::XBatchExecution
170cdf0e10cSrcweir                             >   OStatement_IFACE;
171cdf0e10cSrcweir class OStatement    :public OStatementBase
172cdf0e10cSrcweir                     ,public OStatement_IFACE
173cdf0e10cSrcweir {
174cdf0e10cSrcweir private:
175cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement >                  m_xAggregateStatement;
176cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer >   m_xComposer;
177cdf0e10cSrcweir     bool                                                                                    m_bAttemptedComposerCreation;
178cdf0e10cSrcweir 
179cdf0e10cSrcweir public:
180cdf0e10cSrcweir 	OStatement(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > & _xConn,
181cdf0e10cSrcweir 			   const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & _xStatement);
182cdf0e10cSrcweir 
183cdf0e10cSrcweir     DECLARE_XINTERFACE()
184cdf0e10cSrcweir     DECLARE_XTYPEPROVIDER()
185cdf0e10cSrcweir 
186cdf0e10cSrcweir // ::com::sun::star::lang::XServiceInfo
187cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw(::com::sun::star::uno::RuntimeException);
188cdf0e10cSrcweir     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
189cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException);
190cdf0e10cSrcweir 
191cdf0e10cSrcweir // ::com::sun::star::sdbc::XStatement
192cdf0e10cSrcweir     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);
193cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL executeUpdate( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
194cdf0e10cSrcweir     virtual sal_Bool SAL_CALL execute( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
195cdf0e10cSrcweir     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);
196cdf0e10cSrcweir 
197cdf0e10cSrcweir     // OComponentHelper
198cdf0e10cSrcweir 	virtual void SAL_CALL disposing();
199cdf0e10cSrcweir 
200cdf0e10cSrcweir     // XBatchExecution
201cdf0e10cSrcweir 	virtual void SAL_CALL addBatch( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
202cdf0e10cSrcweir 	virtual void SAL_CALL clearBatch(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
203cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
204cdf0e10cSrcweir 
205cdf0e10cSrcweir     using OStatementBase::addBatch;
206cdf0e10cSrcweir 
207cdf0e10cSrcweir private:
208cdf0e10cSrcweir     /** does escape processing for the given SQL command, if the our EscapeProcessing
209cdf0e10cSrcweir         property allows so.
210cdf0e10cSrcweir     */
211cdf0e10cSrcweir     ::rtl::OUString impl_doEscapeProcessing_nothrow( const ::rtl::OUString& _rSQL ) const;
212cdf0e10cSrcweir     bool            impl_ensureComposer_nothrow() const;
213cdf0e10cSrcweir };
214cdf0e10cSrcweir 
215cdf0e10cSrcweir #endif // _DBA_COREAPI_STATEMENT_HXX_
216cdf0e10cSrcweir 
217