1 #ifndef MYSQLC_STATEMENT_HXX 2 #define MYSQLC_STATEMENT_HXX 3 4 #include "mysqlc_connection.hxx" 5 #include "mysqlc_subcomponent.hxx" 6 7 #include <com/sun/star/lang/XServiceInfo.hpp> 8 #include <com/sun/star/sdbc/SQLWarning.hpp> 9 #include <com/sun/star/sdbc/XBatchExecution.hpp> 10 #include <com/sun/star/sdbc/XCloseable.hpp> 11 #include <com/sun/star/sdbc/XMultipleResults.hpp> 12 #include <com/sun/star/sdbc/XStatement.hpp> 13 #include <com/sun/star/sdbc/XWarningsSupplier.hpp> 14 #include <com/sun/star/util/XCancellable.hpp> 15 16 #include <preextstl.h> 17 #include <cppconn/statement.h> 18 #include <postextstl.h> 19 #include <cppuhelper/compbase5.hxx> 20 #include <list> 21 22 namespace connectivity 23 { 24 namespace mysqlc 25 { 26 using ::com::sun::star::sdbc::SQLWarning; 27 using ::com::sun::star::sdbc::SQLException; 28 using ::com::sun::star::uno::Any; 29 using ::com::sun::star::uno::RuntimeException; 30 using ::rtl::OUString; 31 32 typedef ::cppu::WeakComponentImplHelper5< ::com::sun::star::sdbc::XStatement, 33 ::com::sun::star::sdbc::XWarningsSupplier, 34 ::com::sun::star::util::XCancellable, 35 ::com::sun::star::sdbc::XCloseable, 36 ::com::sun::star::sdbc::XMultipleResults> OCommonStatement_IBase; 37 38 class OCommonStatement; 39 typedef OSubComponent< OCommonStatement, OCommonStatement_IBase > OStatement_CBase; 40 41 //************************************************************** 42 //************ Class: OCommonStatement 43 // is a base class for the normal statement and for the prepared statement 44 //************************************************************** 45 class OCommonStatement :public OBase_Mutex 46 ,public OCommonStatement_IBase 47 ,public ::cppu::OPropertySetHelper 48 ,public OPropertyArrayUsageHelper<OCommonStatement> 49 ,public OStatement_CBase 50 51 { 52 friend class OSubComponent< OCommonStatement, OCommonStatement_IBase >; 53 54 private: 55 SQLWarning m_aLastWarning; 56 57 protected: 58 ::std::list< OUString> m_aBatchList; 59 60 OConnection* m_pConnection; // The owning Connection object 61 62 sql::Statement *cppStatement; 63 64 protected: 65 void disposeResultSet(); 66 67 // OPropertyArrayUsageHelper 68 ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; 69 70 // OPropertySetHelper 71 ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); 72 sal_Bool SAL_CALL convertFastPropertyValue(Any & rConvertedValue, Any & rOldValue, 73 sal_Int32 nHandle, const Any& rValue) 74 throw (::com::sun::star::lang::IllegalArgumentException); 75 76 void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const Any& rValue) 77 throw(::com::sun::star::uno::Exception); 78 79 void SAL_CALL getFastPropertyValue(Any& rValue, sal_Int32 nHandle) const; 80 virtual ~OCommonStatement(); 81 82 protected: 83 OCommonStatement(OConnection* _pConnection, sql::Statement *_cppStatement); 84 85 public: 86 ::cppu::OBroadcastHelper& rBHelper; 87 using OCommonStatement_IBase::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >; 88 89 // OComponentHelper 90 void SAL_CALL disposing(void); 91 92 // XInterface 93 void SAL_CALL release() throw(); 94 95 void SAL_CALL acquire() throw(); 96 97 // XInterface 98 Any SAL_CALL queryInterface(const ::com::sun::star::uno::Type & rType) 99 throw(RuntimeException); 100 101 //XTypeProvider 102 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() 103 throw(RuntimeException); 104 105 // XPropertySet 106 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() 107 throw(RuntimeException); 108 109 // XStatement 110 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery(const OUString& sql) 111 throw(SQLException, RuntimeException); 112 113 sal_Int32 SAL_CALL executeUpdate(const OUString& sql) 114 throw(SQLException, RuntimeException); 115 116 sal_Bool SAL_CALL execute( const OUString& sql ) 117 throw(SQLException, RuntimeException); 118 119 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection() 120 throw(SQLException, RuntimeException); 121 122 // XWarningsSupplier 123 Any SAL_CALL getWarnings() throw(SQLException, RuntimeException); 124 125 void SAL_CALL clearWarnings() throw(SQLException, RuntimeException); 126 127 // XCancellable 128 void SAL_CALL cancel() throw(RuntimeException); 129 130 // XCloseable 131 void SAL_CALL close() throw(SQLException, RuntimeException); 132 133 // XMultipleResults 134 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getResultSet() 135 throw(SQLException, RuntimeException); 136 137 sal_Int32 SAL_CALL getUpdateCount() throw(SQLException, RuntimeException); 138 139 sal_Bool SAL_CALL getMoreResults() throw(SQLException, RuntimeException); 140 141 // other methods 142 OConnection* getOwnConnection() const { return m_pConnection;} 143 144 private: 145 using ::cppu::OPropertySetHelper::getFastPropertyValue; 146 }; 147 148 149 class OStatement : public OCommonStatement, 150 public ::com::sun::star::sdbc::XBatchExecution, 151 public ::com::sun::star::lang::XServiceInfo 152 153 { 154 protected: 155 virtual ~OStatement(){} 156 157 public: 158 // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: 159 OStatement(OConnection* _pConnection, sql::Statement *_cppStatement) : OCommonStatement(_pConnection, _cppStatement) {} 160 DECLARE_SERVICE_INFO(); 161 162 Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) 163 throw(RuntimeException); 164 165 void SAL_CALL acquire() throw(); 166 void SAL_CALL release() throw(); 167 168 // XBatchExecution 169 void SAL_CALL addBatch(const OUString& sql) 170 throw(SQLException, RuntimeException); 171 172 void SAL_CALL clearBatch() throw(SQLException, RuntimeException); 173 174 ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch() 175 throw(SQLException, RuntimeException); 176 177 }; 178 } 179 } 180 #endif // MYSQLC_STATEMENT_HXX 181 182 /* 183 * Local variables: 184 * tab-width: 4 185 * c-basic-offset: 4 186 * End: 187 * vim600: noet sw=4 ts=4 fdm=marker 188 * vim<600: noet sw=4 ts=4 189 */ 190