1*34dd1e25SAndrew Rist /************************************************************** 2*34dd1e25SAndrew Rist * 3*34dd1e25SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*34dd1e25SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*34dd1e25SAndrew Rist * distributed with this work for additional information 6*34dd1e25SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*34dd1e25SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*34dd1e25SAndrew Rist * "License"); you may not use this file except in compliance 9*34dd1e25SAndrew Rist * with the License. You may obtain a copy of the License at 10*34dd1e25SAndrew Rist * 11*34dd1e25SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*34dd1e25SAndrew Rist * 13*34dd1e25SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*34dd1e25SAndrew Rist * software distributed under the License is distributed on an 15*34dd1e25SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*34dd1e25SAndrew Rist * KIND, either express or implied. See the License for the 17*34dd1e25SAndrew Rist * specific language governing permissions and limitations 18*34dd1e25SAndrew Rist * under the License. 19*34dd1e25SAndrew Rist * 20*34dd1e25SAndrew Rist *************************************************************/ 21*34dd1e25SAndrew Rist 22*34dd1e25SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef CONNECTIVITY_SSTATEMENT_HXX 25cdf0e10cSrcweir #define CONNECTIVITY_SSTATEMENT_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 "SConnection.hxx" 36cdf0e10cSrcweir #include <list> 37cdf0e10cSrcweir #include "OSubComponent.hxx" 38cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 39cdf0e10cSrcweir 40cdf0e10cSrcweir namespace connectivity 41cdf0e10cSrcweir { 42cdf0e10cSrcweir namespace skeleton 43cdf0e10cSrcweir { 44cdf0e10cSrcweir 45cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper5< ::com::sun::star::sdbc::XStatement, 46cdf0e10cSrcweir ::com::sun::star::sdbc::XWarningsSupplier, 47cdf0e10cSrcweir ::com::sun::star::util::XCancellable, 48cdf0e10cSrcweir ::com::sun::star::sdbc::XCloseable, 49cdf0e10cSrcweir ::com::sun::star::sdbc::XMultipleResults> OStatement_BASE; 50cdf0e10cSrcweir 51cdf0e10cSrcweir //************************************************************** 52cdf0e10cSrcweir //************ Class: OStatement_Base 53cdf0e10cSrcweir // is a base class for the normal statement and for the prepared statement 54cdf0e10cSrcweir //************************************************************** 55cdf0e10cSrcweir class OStatement_Base : public OBase_Mutex, 56cdf0e10cSrcweir public OStatement_BASE, 57cdf0e10cSrcweir public ::cppu::OPropertySetHelper, 58cdf0e10cSrcweir public OPropertyArrayUsageHelper<OStatement_Base> 59cdf0e10cSrcweir 60cdf0e10cSrcweir { 61cdf0e10cSrcweir ::com::sun::star::sdbc::SQLWarning m_aLastWarning; 62cdf0e10cSrcweir protected: 63cdf0e10cSrcweir ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet> m_xResultSet; // The last ResultSet created 64cdf0e10cSrcweir // for this Statement 65cdf0e10cSrcweir 66cdf0e10cSrcweir ::std::list< ::rtl::OUString> m_aBatchList; 67cdf0e10cSrcweir 68cdf0e10cSrcweir OConnection* m_pConnection; // The owning Connection object 69cdf0e10cSrcweir protected: 70cdf0e10cSrcweir 71cdf0e10cSrcweir void disposeResultSet(); 72cdf0e10cSrcweir 73cdf0e10cSrcweir // OPropertyArrayUsageHelper 74cdf0e10cSrcweir virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; 75cdf0e10cSrcweir // OPropertySetHelper 76cdf0e10cSrcweir virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); 77cdf0e10cSrcweir virtual sal_Bool SAL_CALL convertFastPropertyValue( 78cdf0e10cSrcweir ::com::sun::star::uno::Any & rConvertedValue, 79cdf0e10cSrcweir ::com::sun::star::uno::Any & rOldValue, 80cdf0e10cSrcweir sal_Int32 nHandle, 81cdf0e10cSrcweir const ::com::sun::star::uno::Any& rValue ) 82cdf0e10cSrcweir throw (::com::sun::star::lang::IllegalArgumentException); 83cdf0e10cSrcweir virtual void SAL_CALL setFastPropertyValue_NoBroadcast( 84cdf0e10cSrcweir sal_Int32 nHandle, 85cdf0e10cSrcweir const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::uno::Exception); 86cdf0e10cSrcweir virtual void SAL_CALL getFastPropertyValue( 87cdf0e10cSrcweir ::com::sun::star::uno::Any& rValue, 88cdf0e10cSrcweir sal_Int32 nHandle) const; 89cdf0e10cSrcweir virtual ~OStatement_Base(); 90cdf0e10cSrcweir 91cdf0e10cSrcweir public: 92cdf0e10cSrcweir ::cppu::OBroadcastHelper& rBHelper; 93cdf0e10cSrcweir OStatement_Base(OConnection* _pConnection ); 94cdf0e10cSrcweir using OStatement_BASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >; 95cdf0e10cSrcweir 96cdf0e10cSrcweir // OComponentHelper disposing(void)97cdf0e10cSrcweir virtual void SAL_CALL disposing(void){OStatement_BASE::disposing();} 98cdf0e10cSrcweir // XInterface 99cdf0e10cSrcweir virtual void SAL_CALL release() throw(); 100cdf0e10cSrcweir virtual void SAL_CALL acquire() throw(); 101cdf0e10cSrcweir // XInterface 102cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); 103cdf0e10cSrcweir //XTypeProvider 104cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); 105cdf0e10cSrcweir 106cdf0e10cSrcweir // XPropertySet 107cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); 108cdf0e10cSrcweir // XStatement 109cdf0e10cSrcweir 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) ; 110cdf0e10cSrcweir virtual sal_Int32 SAL_CALL executeUpdate( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; 111cdf0e10cSrcweir virtual sal_Bool SAL_CALL execute( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; 112cdf0e10cSrcweir 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) ; 113cdf0e10cSrcweir // XWarningsSupplier 114cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 115cdf0e10cSrcweir virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 116cdf0e10cSrcweir // XCancellable 117cdf0e10cSrcweir virtual void SAL_CALL cancel( ) throw(::com::sun::star::uno::RuntimeException); 118cdf0e10cSrcweir // XCloseable 119cdf0e10cSrcweir virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 120cdf0e10cSrcweir // XMultipleResults 121cdf0e10cSrcweir 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); 122cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getUpdateCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 123cdf0e10cSrcweir virtual sal_Bool SAL_CALL getMoreResults( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 124cdf0e10cSrcweir 125cdf0e10cSrcweir // other methods getOwnConnection() const126cdf0e10cSrcweir OConnection* getOwnConnection() const { return m_pConnection;} 127cdf0e10cSrcweir }; 128cdf0e10cSrcweir 129cdf0e10cSrcweir class OStatement_BASE2 :public OStatement_Base 130cdf0e10cSrcweir ,public OSubComponent<OStatement_BASE2, OStatement_BASE> 131cdf0e10cSrcweir 132cdf0e10cSrcweir { 133cdf0e10cSrcweir friend class OSubComponent<OStatement_BASE2, OStatement_BASE>; 134cdf0e10cSrcweir public: OStatement_BASE2(OConnection * _pConnection)135cdf0e10cSrcweir OStatement_BASE2(OConnection* _pConnection ) : OStatement_Base(_pConnection ), 136cdf0e10cSrcweir OSubComponent<OStatement_BASE2, OStatement_BASE>((::cppu::OWeakObject*)_pConnection, this){} 137cdf0e10cSrcweir // OComponentHelper 138cdf0e10cSrcweir virtual void SAL_CALL disposing(void); 139cdf0e10cSrcweir // XInterface 140cdf0e10cSrcweir virtual void SAL_CALL release() throw(); 141cdf0e10cSrcweir }; 142cdf0e10cSrcweir 143cdf0e10cSrcweir class OStatement : public OStatement_BASE2, 144cdf0e10cSrcweir public ::com::sun::star::sdbc::XBatchExecution, 145cdf0e10cSrcweir public ::com::sun::star::lang::XServiceInfo 146cdf0e10cSrcweir { 147cdf0e10cSrcweir protected: ~OStatement()148cdf0e10cSrcweir virtual ~OStatement(){} 149cdf0e10cSrcweir public: 150cdf0e10cSrcweir // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: OStatement(OConnection * _pConnection)151cdf0e10cSrcweir OStatement( OConnection* _pConnection) : OStatement_BASE2( _pConnection){} 152cdf0e10cSrcweir DECLARE_SERVICE_INFO(); 153cdf0e10cSrcweir 154cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); 155cdf0e10cSrcweir virtual void SAL_CALL acquire() throw(); 156cdf0e10cSrcweir virtual void SAL_CALL release() throw(); 157cdf0e10cSrcweir // XBatchExecution 158cdf0e10cSrcweir virtual void SAL_CALL addBatch( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 159cdf0e10cSrcweir virtual void SAL_CALL clearBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 160cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 161cdf0e10cSrcweir }; 162cdf0e10cSrcweir } 163cdf0e10cSrcweir } 164cdf0e10cSrcweir #endif // CONNECTIVITY_SSTATEMENT_HXX 165