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_ADO_ASTATEMENT_HXX_ 25 #define _CONNECTIVITY_ADO_ASTATEMENT_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 <comphelper/proparrhlp.hxx> 36 #include <comphelper/uno3.hxx> 37 #include <comphelper/broadcasthelper.hxx> 38 #include "ado/AConnection.hxx" 39 #ifndef _LIST_ 40 #include <list> 41 #endif 42 #include "ado/Awrapado.hxx" 43 #include <com/sun/star/lang/XServiceInfo.hpp> 44 45 namespace connectivity 46 { 47 namespace ado 48 { 49 typedef ::cppu::WeakComponentImplHelper5< ::com::sun::star::sdbc::XStatement, 50 ::com::sun::star::sdbc::XWarningsSupplier, 51 ::com::sun::star::util::XCancellable, 52 ::com::sun::star::sdbc::XCloseable, 53 ::com::sun::star::sdbc::XMultipleResults> OStatement_BASE; 54 55 //************************************************************** 56 //************ Class: java.sql.Statement 57 //************************************************************** 58 class OStatement_Base : public comphelper::OBaseMutex, 59 public OStatement_BASE, 60 public ::cppu::OPropertySetHelper, 61 public ::comphelper::OPropertyArrayUsageHelper<OStatement_Base>, 62 public connectivity::OSubComponent<OStatement_Base, OStatement_BASE> 63 64 { 65 friend class connectivity::OSubComponent<OStatement_Base, OStatement_BASE>; 66 friend class OResultSet; 67 68 ::com::sun::star::sdbc::SQLWarning m_aLastWarning; 69 70 protected: 71 ::std::list< ::rtl::OUString> m_aBatchList; 72 73 ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet> m_xResultSet; // The last ResultSet created 74 // for this Statement 75 76 OConnection* m_pConnection;// The owning Connection object 77 WpADOCommand m_Command; 78 WpADORecordset m_RecordSet; 79 OLEVariant m_RecordsAffected; 80 OLEVariant m_Parameters; 81 ::std::vector<connectivity::OTypeInfo> m_aTypeInfo; // Hashtable containing an entry 82 // for each row returned by 83 // DatabaseMetaData.getTypeInfo. 84 sal_Int32 m_nMaxRows; 85 sal_Int32 m_nFetchSize; 86 LockTypeEnum m_eLockType; 87 CursorTypeEnum m_eCursorType; 88 89 using OStatement_BASE::rBHelper; 90 private: 91 92 sal_Int32 getQueryTimeOut() const; 93 sal_Int32 getMaxFieldSize() const; 94 sal_Int32 getMaxRows() const; 95 sal_Int32 getResultSetConcurrency() const; 96 sal_Int32 getResultSetType() const; 97 sal_Int32 getFetchDirection() const; 98 sal_Int32 getFetchSize() const; 99 ::rtl::OUString getCursorName() const; 100 101 void setQueryTimeOut(sal_Int32 _par0); 102 void setMaxFieldSize(sal_Int32 _par0); 103 void setMaxRows(sal_Int32 _par0); 104 void setResultSetConcurrency(sal_Int32 _par0); 105 void setResultSetType(sal_Int32 _par0); 106 void setFetchDirection(sal_Int32 _par0); 107 void setFetchSize(sal_Int32 _par0); 108 void setCursorName(const ::rtl::OUString &_par0); 109 110 protected: 111 112 void assignRecordSet( ADORecordset* _pRS ); 113 114 void reset (); 115 void clearMyResultSet (); 116 void setWarning (const ::com::sun::star::sdbc::SQLWarning &ex); 117 sal_Int32 getColumnCount (); 118 sal_Int32 getRowCount (); 119 sal_Int32 getPrecision ( sal_Int32 sqlType); 120 121 void disposeResultSet(); 122 123 // OPropertyArrayUsageHelper 124 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; 125 // OPropertySetHelper 126 virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); 127 virtual sal_Bool SAL_CALL convertFastPropertyValue( 128 ::com::sun::star::uno::Any & rConvertedValue, 129 ::com::sun::star::uno::Any & rOldValue, 130 sal_Int32 nHandle, 131 const ::com::sun::star::uno::Any& rValue ); 132 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( 133 sal_Int32 nHandle, 134 const ::com::sun::star::uno::Any& rValue 135 ); 136 virtual void SAL_CALL getFastPropertyValue( 137 ::com::sun::star::uno::Any& rValue, 138 sal_Int32 nHandle 139 ) const; 140 public: 141 OStatement_Base(OConnection* _pConnection ); 142 143 using OStatement_BASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >; 144 // OComponentHelper 145 virtual void SAL_CALL disposing(void); 146 // XInterface 147 virtual void SAL_CALL acquire() throw(); 148 virtual void SAL_CALL release() throw(); 149 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ); 150 //XTypeProvider 151 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ); 152 153 // XPropertySet 154 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ); 155 // XStatement 156 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( const ::rtl::OUString& sql ) ; 157 virtual sal_Int32 SAL_CALL executeUpdate( const ::rtl::OUString& sql ) ; 158 virtual sal_Bool SAL_CALL execute( const ::rtl::OUString& sql ) ; 159 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) ; 160 // XWarningsSupplier 161 virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ); 162 virtual void SAL_CALL clearWarnings( ); 163 // XCancellable 164 virtual void SAL_CALL cancel( ); 165 // XCloseable 166 virtual void SAL_CALL close( ); 167 // XMultipleResults 168 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getResultSet( ); 169 virtual sal_Int32 SAL_CALL getUpdateCount( ); 170 virtual sal_Bool SAL_CALL getMoreResults( ); 171 }; 172 173 class OStatement : public OStatement_Base, 174 public ::com::sun::star::sdbc::XBatchExecution, 175 public ::com::sun::star::lang::XServiceInfo 176 { 177 public: 178 // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: OStatement(OConnection * _pConnection)179 OStatement( OConnection* _pConnection) : OStatement_Base( _pConnection){}; 180 ~OStatement(); 181 182 DECLARE_SERVICE_INFO(); 183 184 virtual void SAL_CALL acquire() throw(); 185 virtual void SAL_CALL release() throw(); 186 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ); 187 // XBatchExecution 188 virtual void SAL_CALL addBatch( const ::rtl::OUString& sql ); 189 virtual void SAL_CALL clearBatch( ); 190 virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ); 191 }; 192 } 193 } 194 #endif // _CONNECTIVITY_ADO_ASTATEMENT_HXX_ 195