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(); 135 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId(); 136 137 // ::com::sun::star::uno::XInterface 138 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ); 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( ); 144 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ); 145 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ); 146 147 // ::cppu::OComponentHelper 148 virtual void SAL_CALL disposing(void); 149 150 // ::com::sun::star::sdbc::XCloseable 151 virtual void SAL_CALL close( ); 152 153 // com::sun::star::beans::XPropertySet 154 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ); 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 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( 168 sal_Int32 nHandle, 169 const ::com::sun::star::uno::Any& rValue 170 ); 171 virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const; 172 173 // ::com::sun::star::sdbc::XWarningsSupplier 174 virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ); 175 virtual void SAL_CALL clearWarnings( ); 176 177 // ::com::sun::star::sdbc::XResultSetMetaDataSupplier 178 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ); 179 180 // ::com::sun::star::sdbc::XColumnLocate 181 virtual sal_Int32 SAL_CALL findColumn( const ::rtl::OUString& columnName ); 182 183 // ::com::sun::star::sdbcx::XColumnsSupplier 184 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getColumns( ); 185 186 // ::com::sun::star::sdbc::XRow 187 virtual sal_Bool SAL_CALL wasNull( ); 188 virtual ::rtl::OUString SAL_CALL getString( sal_Int32 columnIndex ); 189 virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex ); 190 virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex ); 191 virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex ); 192 virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex ); 193 virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex ); 194 virtual float SAL_CALL getFloat( sal_Int32 columnIndex ); 195 virtual double SAL_CALL getDouble( sal_Int32 columnIndex ); 196 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex ); 197 virtual ::com::sun::star::util::Date SAL_CALL getDate( sal_Int32 columnIndex ); 198 virtual ::com::sun::star::util::Time SAL_CALL getTime( sal_Int32 columnIndex ); 199 virtual ::com::sun::star::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex ); 200 virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex ); 201 virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex ); 202 virtual ::com::sun::star::uno::Any SAL_CALL getObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ); 203 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex ); 204 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex ); 205 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex ); 206 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex ); 207 208 // ::com::sun::star::sdbc::XResultSet 209 virtual sal_Bool SAL_CALL next( ); 210 virtual sal_Bool SAL_CALL isBeforeFirst( ); 211 virtual sal_Bool SAL_CALL isAfterLast( ); 212 virtual sal_Bool SAL_CALL isFirst( ); 213 virtual sal_Bool SAL_CALL isLast( ); 214 virtual void SAL_CALL beforeFirst( ); 215 virtual void SAL_CALL afterLast( ); 216 virtual sal_Bool SAL_CALL first( ); 217 virtual sal_Bool SAL_CALL last( ); 218 virtual sal_Int32 SAL_CALL getRow( ); 219 virtual sal_Bool SAL_CALL absolute( sal_Int32 row ); 220 virtual sal_Bool SAL_CALL relative( sal_Int32 rows ); 221 virtual sal_Bool SAL_CALL previous( ); 222 virtual void SAL_CALL refreshRow( ); 223 virtual sal_Bool SAL_CALL rowUpdated( ); 224 virtual sal_Bool SAL_CALL rowInserted( ); 225 virtual sal_Bool SAL_CALL rowDeleted( ); 226 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getStatement( ); 227 228 // ::com::sun::star::sdbcx::XRowLocate 229 virtual ::com::sun::star::uno::Any SAL_CALL getBookmark( ); 230 virtual sal_Bool SAL_CALL moveToBookmark( const ::com::sun::star::uno::Any& bookmark ); 231 virtual sal_Bool SAL_CALL moveRelativeToBookmark( const ::com::sun::star::uno::Any& bookmark, sal_Int32 rows ); 232 virtual sal_Int32 SAL_CALL compareBookmarks( const ::com::sun::star::uno::Any& first, const ::com::sun::star::uno::Any& second ); 233 virtual sal_Bool SAL_CALL hasOrderedBookmarks( ); 234 virtual sal_Int32 SAL_CALL hashBookmark( const ::com::sun::star::uno::Any& bookmark ); 235 236 // ::com::sun::star::sdbc::XResultSetUpdate 237 virtual void SAL_CALL insertRow( ); 238 virtual void SAL_CALL updateRow( ); 239 virtual void SAL_CALL deleteRow( ); 240 virtual void SAL_CALL cancelRowUpdates( ); 241 virtual void SAL_CALL moveToInsertRow( ); 242 virtual void SAL_CALL moveToCurrentRow( ); 243 244 // ::com::sun::star::sdbc::XRowUpdate 245 virtual void SAL_CALL updateNull( sal_Int32 columnIndex ); 246 virtual void SAL_CALL updateBoolean( sal_Int32 columnIndex, sal_Bool x ); 247 virtual void SAL_CALL updateByte( sal_Int32 columnIndex, sal_Int8 x ); 248 virtual void SAL_CALL updateShort( sal_Int32 columnIndex, sal_Int16 x ); 249 virtual void SAL_CALL updateInt( sal_Int32 columnIndex, sal_Int32 x ); 250 virtual void SAL_CALL updateLong( sal_Int32 columnIndex, sal_Int64 x ); 251 virtual void SAL_CALL updateFloat( sal_Int32 columnIndex, float x ); 252 virtual void SAL_CALL updateDouble( sal_Int32 columnIndex, double x ); 253 virtual void SAL_CALL updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ); 254 virtual void SAL_CALL updateBytes( sal_Int32 columnIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ); 255 virtual void SAL_CALL updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ); 256 virtual void SAL_CALL updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ); 257 virtual void SAL_CALL updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ); 258 virtual void SAL_CALL updateBinaryStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ); 259 virtual void SAL_CALL updateCharacterStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ); 260 virtual void SAL_CALL updateObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x ); 261 virtual void SAL_CALL updateNumericObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x, sal_Int32 scale ); 262 263 protected: 264 void checkReadOnly() const; 265 void checkBookmarkable() const; 266 267 private: 268 using ::cppu::OPropertySetHelper::getFastPropertyValue; 269 }; 270 } 271 #endif // _DBA_COREAPI_RESULTSET_HXX_ 272