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