1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: statement.hxx,v $
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>
36 #ifndef _COM_SUN_STAR_SDBC_XSTATEMENT_HPP_
37 #include <com/sun/star/sdbc/XStatement.hpp>
39 #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
40 #include <com/sun/star/sdbc/XConnection.hpp>
42 #ifndef _COM_SUN_STAR_UTIL_XCANCELLABLE_HPP_
43 #include <com/sun/star/util/XCancellable.hpp>
45 #ifndef _COM_SUN_STAR_SDBC_XWARNINGSSUPPLIER_HPP_
46 #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
48 #ifndef _COM_SUN_STAR_SDBC_XCLOSEABLE_HPP_
49 #include <com/sun/star/sdbc/XCloseable.hpp>
51 #ifndef _COM_SUN_STAR_SDBC_XMULTIPLERESULTS_HDL_
52 #include <com/sun/star/sdbc/XMultipleResults.hpp>
54 #ifndef _COM_SUN_STAR_SDBC_XPREPAREDBATCHEXECUTION_HDL_
55 #include <com/sun/star/sdbc/XPreparedBatchExecution.hpp>
57 #include <com/sun/star/sdbc/XBatchExecution.hpp>
58 #ifndef _COM_SUN_STAR_SDBC_XGENERATEDRESULTSET_HPP_
59 #include <com/sun/star/sdbc/XGeneratedResultSet.hpp>
61 #ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYCOMPOSER_HPP_
62 #include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
64 #ifndef _CPPUHELPER_PROPSHLP_HXX
65 #include <cppuhelper/propshlp.hxx>
67 #ifndef _COMPHELPER_PROPERTY_ARRAY_HELPER_HXX_
68 #include <comphelper/proparrhlp.hxx>
70 #ifndef _DBASHARED_APITOOLS_HXX_
71 #include "apitools.hxx"
73 #ifndef _COMPHELPER_BROADCASTHELPER_HXX_
74 #include <comphelper/broadcasthelper.hxx>
77 #include <cppuhelper/implbase3.hxx>
79 //************************************************************
81 //************************************************************
82 class OStatementBase
: public comphelper::OBaseMutex
,
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
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();
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();
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
,
133 const ::com::sun::star::uno::Any
& rValue
)
134 throw (::com::sun::star::lang::IllegalArgumentException
);
135 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast(
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
);
165 void disposeResultSet();
168 using ::cppu::OPropertySetHelper::getFastPropertyValue
;
171 //************************************************************
173 //************************************************************
174 typedef ::cppu::ImplHelper3
< ::com::sun::star::sdbc::XStatement
175 , ::com::sun::star::lang::XServiceInfo
176 , ::com::sun::star::sdbc::XBatchExecution
178 class OStatement
:public OStatementBase
179 ,public OStatement_IFACE
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
;
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
);
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
);
205 virtual void SAL_CALL
disposing();
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
;
215 /** does escape processing for the given SQL command, if the our EscapeProcessing
218 ::rtl::OUString
impl_doEscapeProcessing_nothrow( const ::rtl::OUString
& _rSQL
) const;
219 bool impl_ensureComposer_nothrow() const;
222 #endif // _DBA_COREAPI_STATEMENT_HXX_