update dev300-m58
[ooovba.git] / dbaccess / source / core / inc / statement.hxx
blob7bfc929dad157a258ff1c89bc526a7c4909faebc
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: statement.hxx,v $
10 * $Revision: 1.11 $
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 _DBA_COREAPI_STATEMENT_HXX_
31 #define _DBA_COREAPI_STATEMENT_HXX_
33 #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
34 #include <com/sun/star/lang/XServiceInfo.hpp>
35 #endif
36 #ifndef _COM_SUN_STAR_SDBC_XSTATEMENT_HPP_
37 #include <com/sun/star/sdbc/XStatement.hpp>
38 #endif
39 #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
40 #include <com/sun/star/sdbc/XConnection.hpp>
41 #endif
42 #ifndef _COM_SUN_STAR_UTIL_XCANCELLABLE_HPP_
43 #include <com/sun/star/util/XCancellable.hpp>
44 #endif
45 #ifndef _COM_SUN_STAR_SDBC_XWARNINGSSUPPLIER_HPP_
46 #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
47 #endif
48 #ifndef _COM_SUN_STAR_SDBC_XCLOSEABLE_HPP_
49 #include <com/sun/star/sdbc/XCloseable.hpp>
50 #endif
51 #ifndef _COM_SUN_STAR_SDBC_XMULTIPLERESULTS_HDL_
52 #include <com/sun/star/sdbc/XMultipleResults.hpp>
53 #endif
54 #ifndef _COM_SUN_STAR_SDBC_XPREPAREDBATCHEXECUTION_HDL_
55 #include <com/sun/star/sdbc/XPreparedBatchExecution.hpp>
56 #endif
57 #include <com/sun/star/sdbc/XBatchExecution.hpp>
58 #ifndef _COM_SUN_STAR_SDBC_XGENERATEDRESULTSET_HPP_
59 #include <com/sun/star/sdbc/XGeneratedResultSet.hpp>
60 #endif
61 #ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYCOMPOSER_HPP_
62 #include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
63 #endif
64 #ifndef _CPPUHELPER_PROPSHLP_HXX
65 #include <cppuhelper/propshlp.hxx>
66 #endif
67 #ifndef _COMPHELPER_PROPERTY_ARRAY_HELPER_HXX_
68 #include <comphelper/proparrhlp.hxx>
69 #endif
70 #ifndef _DBASHARED_APITOOLS_HXX_
71 #include "apitools.hxx"
72 #endif
73 #ifndef _COMPHELPER_BROADCASTHELPER_HXX_
74 #include <comphelper/broadcasthelper.hxx>
75 #endif
77 #include <cppuhelper/implbase3.hxx>
79 //************************************************************
80 // OStatementBase
81 //************************************************************
82 class OStatementBase : public comphelper::OBaseMutex,
83 public OSubComponent,
84 public ::cppu::OPropertySetHelper,
85 public ::comphelper::OPropertyArrayUsageHelper < OStatementBase >,
86 public ::com::sun::star::util::XCancellable,
87 public ::com::sun::star::sdbc::XWarningsSupplier,
88 public ::com::sun::star::sdbc::XPreparedBatchExecution,
89 public ::com::sun::star::sdbc::XMultipleResults,
90 public ::com::sun::star::sdbc::XCloseable,
91 public ::com::sun::star::sdbc::XGeneratedResultSet
93 protected:
94 ::osl::Mutex m_aCancelMutex;
96 ::com::sun::star::uno::WeakReferenceHelper m_aResultSet;
97 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xAggregateAsSet;
98 ::com::sun::star::uno::Reference< ::com::sun::star::util::XCancellable > m_xAggregateAsCancellable;
99 sal_Bool m_bUseBookmarks;
100 sal_Bool m_bEscapeProcessing;
102 virtual ~OStatementBase();
104 public:
105 OStatementBase(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > & _xConn,
106 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & _xStatement);
109 // ::com::sun::star::lang::XTypeProvider
110 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException);
112 // ::com::sun::star::uno::XInterface
113 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException);
114 virtual void SAL_CALL acquire() throw();
115 virtual void SAL_CALL release() throw();
117 // OComponentHelper
118 virtual void SAL_CALL disposing(void);
120 // com::sun::star::beans::XPropertySet
121 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
123 // comphelper::OPropertyArrayUsageHelper
124 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
126 // cppu::OPropertySetHelper
127 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
129 virtual sal_Bool SAL_CALL convertFastPropertyValue(
130 ::com::sun::star::uno::Any & rConvertedValue,
131 ::com::sun::star::uno::Any & rOldValue,
132 sal_Int32 nHandle,
133 const ::com::sun::star::uno::Any& rValue )
134 throw (::com::sun::star::lang::IllegalArgumentException);
135 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
136 sal_Int32 nHandle,
137 const ::com::sun::star::uno::Any& rValue
139 throw (::com::sun::star::uno::Exception);
140 virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const;
142 // ::com::sun::star::sdbc::XWarningsSupplier
143 virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
144 virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
146 // ::com::sun::star::util::XCancellable
147 virtual void SAL_CALL cancel( ) throw(::com::sun::star::uno::RuntimeException);
149 // ::com::sun::star::sdbc::XCloseable
150 virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
152 // ::com::sun::star::sdbc::XMultipleResults
153 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);
154 virtual sal_Int32 SAL_CALL getUpdateCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
155 virtual sal_Bool SAL_CALL getMoreResults( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
157 // ::com::sun::star::sdbc::XPreparedBatchExecution
158 virtual void SAL_CALL addBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
159 virtual void SAL_CALL clearBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
160 virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
161 // ::com::sun::star::sdbc::XGeneratedResultSet
162 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);
164 // Helper
165 void disposeResultSet();
167 protected:
168 using ::cppu::OPropertySetHelper::getFastPropertyValue;
171 //************************************************************
172 // OStatement
173 //************************************************************
174 typedef ::cppu::ImplHelper3 < ::com::sun::star::sdbc::XStatement
175 , ::com::sun::star::lang::XServiceInfo
176 , ::com::sun::star::sdbc::XBatchExecution
177 > OStatement_IFACE;
178 class OStatement :public OStatementBase
179 ,public OStatement_IFACE
181 private:
182 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement > m_xAggregateStatement;
183 ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer > m_xComposer;
184 bool m_bAttemptedComposerCreation;
186 public:
187 OStatement(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > & _xConn,
188 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & _xStatement);
190 DECLARE_XINTERFACE()
191 DECLARE_XTYPEPROVIDER()
193 // ::com::sun::star::lang::XServiceInfo
194 virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
195 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
196 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
198 // ::com::sun::star::sdbc::XStatement
199 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);
200 virtual sal_Int32 SAL_CALL executeUpdate( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
201 virtual sal_Bool SAL_CALL execute( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
202 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);
204 // OComponentHelper
205 virtual void SAL_CALL disposing();
207 // XBatchExecution
208 virtual void SAL_CALL addBatch( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
209 virtual void SAL_CALL clearBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
210 virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
212 using OStatementBase::addBatch;
214 private:
215 /** does escape processing for the given SQL command, if the our EscapeProcessing
216 property allows so.
218 ::rtl::OUString impl_doEscapeProcessing_nothrow( const ::rtl::OUString& _rSQL ) const;
219 bool impl_ensureComposer_nothrow() const;
222 #endif // _DBA_COREAPI_STATEMENT_HXX_