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 #ifndef _DBA_COREAPI_RESULTSET_HXX_ 24 #define _DBA_COREAPI_RESULTSET_HXX_ 25 26 #ifndef _DBA_COREAPI_COLUMN_HXX_ 27 #include "column.hxx" 28 #endif 29 #ifndef DBTOOLS_WARNINGSCONTAINER_HXX 30 #include <connectivity/warningscontainer.hxx> 31 #endif 32 33 #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ 34 #include <com/sun/star/lang/XServiceInfo.hpp> 35 #endif 36 #ifndef _COM_SUN_STAR_SDBC_XSTATEMENT_HPP_ 37 #include <com/sun/star/sdbc/XStatement.hpp> 38 #endif 39 #ifndef _COM_SUN_STAR_SDBC_XCLOSEABLE_HPP_ 40 #include <com/sun/star/sdbc/XCloseable.hpp> 41 #endif 42 #ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_ 43 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> 44 #endif 45 #ifndef _COM_SUN_STAR_SDBC_XWARNINGSSUPPLIER_HPP_ 46 #include <com/sun/star/sdbc/XWarningsSupplier.hpp> 47 #endif 48 #ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ 49 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp> 50 #endif 51 #ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ 52 #include <com/sun/star/sdbc/XResultSet.hpp> 53 #endif 54 #ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ 55 #include <com/sun/star/sdbc/XRow.hpp> 56 #endif 57 #ifndef _COM_SUN_STAR_SDBC_XCOLUMNLOCATE_HPP_ 58 #include <com/sun/star/sdbc/XColumnLocate.hpp> 59 #endif 60 #ifndef _COM_SUN_STAR_SDBCX_XROWLOCATE_HPP_ 61 #include <com/sun/star/sdbcx/XRowLocate.hpp> 62 #endif 63 #ifndef _COM_SUN_STAR_SDBC_XROWUPDATE_HPP_ 64 #include <com/sun/star/sdbc/XRowUpdate.hpp> 65 #endif 66 #ifndef _COM_SUN_STAR_SDBC_XRESULTSETUPDATE_HPP_ 67 #include <com/sun/star/sdbc/XResultSetUpdate.hpp> 68 #endif 69 #ifndef _COM_SUN_STAR_SDBC_RESULTSETCONCURRENCY_HPP_ 70 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp> 71 #endif 72 73 #ifndef _CPPUHELPER_PROPSHLP_HXX 74 #include <cppuhelper/propshlp.hxx> 75 #endif 76 #ifndef _COMPHELPER_PROPERTY_ARRAY_HELPER_HXX_ 77 #include <comphelper/proparrhlp.hxx> 78 #endif 79 #ifndef _OSL_DIAGNOSE_H_ 80 #include <osl/diagnose.h> 81 #endif 82 #ifndef _CPPUHELPER_COMPBASE11_HXX_ 83 #include <cppuhelper/compbase11.hxx> 84 #endif 85 #ifndef _COMPHELPER_BROADCASTHELPER_HXX_ 86 #include <comphelper/broadcasthelper.hxx> 87 #endif 88 89 namespace dbaccess 90 { 91 typedef ::cppu::WeakComponentImplHelper11< ::com::sun::star::sdbc::XWarningsSupplier, 92 ::com::sun::star::sdbc::XResultSet, 93 ::com::sun::star::sdbc::XResultSetMetaDataSupplier, 94 ::com::sun::star::sdbc::XRow, 95 ::com::sun::star::sdbc::XCloseable, 96 ::com::sun::star::sdbc::XColumnLocate, 97 ::com::sun::star::sdbcx::XRowLocate, 98 ::com::sun::star::sdbcx::XColumnsSupplier, 99 ::com::sun::star::sdbc::XResultSetUpdate, 100 ::com::sun::star::sdbc::XRowUpdate, 101 ::com::sun::star::lang::XServiceInfo > OResultSetBase; 102 103 typedef ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> ONoWeakStatement; 104 105 //************************************************************ 106 // OResultSet 107 //************************************************************ 108 class OResultSet : public comphelper::OBaseMutex, 109 public OResultSetBase, 110 public ::cppu::OPropertySetHelper, 111 public ::comphelper::OPropertyArrayUsageHelper < OResultSet > 112 { 113 protected: 114 ONoWeakStatement m_aStatement; 115 116 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > m_xDelegatorResultSet; 117 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetUpdate > m_xDelegatorResultSetUpdate; 118 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow > m_xDelegatorRow; 119 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowUpdate > m_xDelegatorRowUpdate; 120 121 ::dbtools::WarningsContainer m_aWarnings; 122 OColumns* m_pColumns; 123 sal_Int32 m_nResultSetType; 124 sal_Int32 m_nResultSetConcurrency; 125 sal_Bool m_bIsBookmarkable : 1; 126 127 public: 128 OResultSet(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >& _xResultSet, 129 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xStatement, 130 sal_Bool _bCaseSensitive); 131 virtual ~OResultSet(); 132 133 // ::com::sun::star::lang::XTypeProvider 134 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException); 135 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException); 136 137 // ::com::sun::star::uno::XInterface 138 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException); 139 virtual void SAL_CALL acquire() throw(); 140 virtual void SAL_CALL release() throw(); 141 142 // ::com::sun::star::lang::XServiceInfo 143 virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); 144 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); 145 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); 146 147 // ::cppu::OComponentHelper 148 virtual void SAL_CALL disposing(void); 149 150 // ::com::sun::star::sdbc::XCloseable 151 virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 152 153 // com::sun::star::beans::XPropertySet 154 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); 155 156 // comphelper::OPropertyArrayUsageHelper 157 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; 158 159 // cppu::OPropertySetHelper 160 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); 161 162 virtual sal_Bool SAL_CALL convertFastPropertyValue( 163 ::com::sun::star::uno::Any & rConvertedValue, 164 ::com::sun::star::uno::Any & rOldValue, 165 sal_Int32 nHandle, 166 const ::com::sun::star::uno::Any& rValue ) 167 throw (::com::sun::star::lang::IllegalArgumentException); 168 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( 169 sal_Int32 nHandle, 170 const ::com::sun::star::uno::Any& rValue 171 ) 172 throw (::com::sun::star::uno::Exception); 173 virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const; 174 175 // ::com::sun::star::sdbc::XWarningsSupplier 176 virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 177 virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 178 179 // ::com::sun::star::sdbc::XResultSetMetaDataSupplier 180 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 181 182 // ::com::sun::star::sdbc::XColumnLocate 183 virtual sal_Int32 SAL_CALL findColumn( const ::rtl::OUString& columnName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 184 185 // ::com::sun::star::sdbcx::XColumnsSupplier 186 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getColumns( ) throw(::com::sun::star::uno::RuntimeException); 187 188 // ::com::sun::star::sdbc::XRow 189 virtual sal_Bool SAL_CALL wasNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 190 virtual ::rtl::OUString SAL_CALL getString( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 191 virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 192 virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 193 virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 194 virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 195 virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 196 virtual float SAL_CALL getFloat( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 197 virtual double SAL_CALL getDouble( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 198 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 199 virtual ::com::sun::star::util::Date SAL_CALL getDate( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 200 virtual ::com::sun::star::util::Time SAL_CALL getTime( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 201 virtual ::com::sun::star::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 202 virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 203 virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 204 virtual ::com::sun::star::uno::Any SAL_CALL getObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 205 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 206 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 207 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 208 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 209 210 // ::com::sun::star::sdbc::XResultSet 211 virtual sal_Bool SAL_CALL next( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 212 virtual sal_Bool SAL_CALL isBeforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 213 virtual sal_Bool SAL_CALL isAfterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 214 virtual sal_Bool SAL_CALL isFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 215 virtual sal_Bool SAL_CALL isLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 216 virtual void SAL_CALL beforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 217 virtual void SAL_CALL afterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 218 virtual sal_Bool SAL_CALL first( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 219 virtual sal_Bool SAL_CALL last( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 220 virtual sal_Int32 SAL_CALL getRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 221 virtual sal_Bool SAL_CALL absolute( sal_Int32 row ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 222 virtual sal_Bool SAL_CALL relative( sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 223 virtual sal_Bool SAL_CALL previous( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 224 virtual void SAL_CALL refreshRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 225 virtual sal_Bool SAL_CALL rowUpdated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 226 virtual sal_Bool SAL_CALL rowInserted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 227 virtual sal_Bool SAL_CALL rowDeleted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 228 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 229 230 // ::com::sun::star::sdbcx::XRowLocate 231 virtual ::com::sun::star::uno::Any SAL_CALL getBookmark( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 232 virtual sal_Bool SAL_CALL moveToBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 233 virtual sal_Bool SAL_CALL moveRelativeToBookmark( const ::com::sun::star::uno::Any& bookmark, sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 234 virtual sal_Int32 SAL_CALL compareBookmarks( const ::com::sun::star::uno::Any& first, const ::com::sun::star::uno::Any& second ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 235 virtual sal_Bool SAL_CALL hasOrderedBookmarks( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 236 virtual sal_Int32 SAL_CALL hashBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 237 238 // ::com::sun::star::sdbc::XResultSetUpdate 239 virtual void SAL_CALL insertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 240 virtual void SAL_CALL updateRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 241 virtual void SAL_CALL deleteRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 242 virtual void SAL_CALL cancelRowUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 243 virtual void SAL_CALL moveToInsertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 244 virtual void SAL_CALL moveToCurrentRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 245 246 // ::com::sun::star::sdbc::XRowUpdate 247 virtual void SAL_CALL updateNull( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 248 virtual void SAL_CALL updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 249 virtual void SAL_CALL updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 250 virtual void SAL_CALL updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 251 virtual void SAL_CALL updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 252 virtual void SAL_CALL updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 253 virtual void SAL_CALL updateFloat( sal_Int32 columnIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 254 virtual void SAL_CALL updateDouble( sal_Int32 columnIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 255 virtual void SAL_CALL updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 256 virtual void SAL_CALL updateBytes( sal_Int32 columnIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 257 virtual void SAL_CALL updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 258 virtual void SAL_CALL updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 259 virtual void SAL_CALL updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 260 virtual void SAL_CALL updateBinaryStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 261 virtual void SAL_CALL updateCharacterStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 262 virtual void SAL_CALL updateObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 263 virtual void SAL_CALL updateNumericObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 264 265 protected: 266 void checkReadOnly() const; 267 void checkBookmarkable() const; 268 269 private: 270 using ::cppu::OPropertySetHelper::getFastPropertyValue; 271 }; 272 } 273 #endif // _DBA_COREAPI_RESULTSET_HXX_ 274 275