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 #ifndef DBACCESS_CORE_API_ROWSETBASE_HXX 23 #define DBACCESS_CORE_API_ROWSETBASE_HXX 24 25 #ifndef _CPPUHELPER_IMPLBASE10_HXX_ 26 #include <cppuhelper/implbase10.hxx> 27 #endif 28 #ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ 29 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp> 30 #endif 31 #ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ 32 #include <com/sun/star/sdbc/XRow.hpp> 33 #endif 34 #ifndef _COM_SUN_STAR_SDBC_XCOLUMNLOCATE_HPP_ 35 #include <com/sun/star/sdbc/XColumnLocate.hpp> 36 #endif 37 #ifndef _COM_SUN_STAR_SDBC_XCLOSEABLE_HPP_ 38 #include <com/sun/star/sdbc/XCloseable.hpp> 39 #endif 40 #ifndef _COM_SUN_STAR_SDBCX_XROWLOCATE_HPP_ 41 #include <com/sun/star/sdbcx/XRowLocate.hpp> 42 #endif 43 #ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_ 44 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> 45 #endif 46 #ifndef _COM_SUN_STAR_SDBC_XWARNINGSSUPPLIER_HPP_ 47 #include <com/sun/star/sdbc/XWarningsSupplier.hpp> 48 #endif 49 #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ 50 #include <com/sun/star/lang/XServiceInfo.hpp> 51 #endif 52 #ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ 53 #include <com/sun/star/lang/XUnoTunnel.hpp> 54 #endif 55 #ifndef _CPPUHELPER_INTERFACECONTAINER_H_ 56 #include <cppuhelper/interfacecontainer.h> 57 #endif 58 #ifndef CONNECTIVITY_SQLERROR_HXX 59 #include <connectivity/sqlerror.hxx> 60 #endif 61 #ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ 62 #include <connectivity/CommonTools.hxx> 63 #endif 64 #ifndef COMPHELPER_PROPERTYSTATECONTAINER_HXX 65 #include <comphelper/propertystatecontainer.hxx> 66 #endif 67 #ifndef _COMPHELPER_PROPERTY_ARRAY_HELPER_HXX_ 68 #include <comphelper/proparrhlp.hxx> 69 #endif 70 #ifndef _COM_SUN_STAR_SDBC_XROWSET_HPP_ 71 #include <com/sun/star/sdbc/XRowSet.hpp> 72 #endif 73 #ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTYPES_HPP_ 74 #include <com/sun/star/util/XNumberFormatTypes.hpp> 75 #endif 76 #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ 77 #include <com/sun/star/container/XNameAccess.hpp> 78 #endif 79 #ifndef DBACCESS_CORE_API_ROWSETROW_HXX 80 #include "RowSetRow.hxx" 81 #endif 82 #ifndef _COMPHELPER_BROADCASTHELPER_HXX_ 83 #include <comphelper/broadcasthelper.hxx> 84 #endif 85 #ifndef DBACCESS_ROWSETCACHEITERATOR_HXX 86 #include "RowSetCacheIterator.hxx" 87 #endif 88 #include "core_resource.hxx" 89 #include <comphelper/componentcontext.hxx> 90 91 #include <functional> 92 93 94 namespace com { namespace sun { namespace star { 95 namespace sdb { struct RowChangeEvent; } 96 namespace lang { struct Locale; } 97 } } } 98 99 namespace dbaccess 100 { 101 class OEmptyCollection; 102 103 typedef ::cppu::ImplHelper10< ::com::sun::star::sdbcx::XRowLocate, 104 ::com::sun::star::sdbc::XRow, 105 ::com::sun::star::sdbc::XResultSetMetaDataSupplier, 106 ::com::sun::star::sdbc::XWarningsSupplier, 107 ::com::sun::star::sdbc::XColumnLocate, 108 ::com::sun::star::sdbcx::XColumnsSupplier, 109 ::com::sun::star::lang::XServiceInfo, 110 ::com::sun::star::sdbc::XRowSet, 111 ::com::sun::star::sdbc::XCloseable, 112 ::com::sun::star::lang::XUnoTunnel> ORowSetBase_BASE; 113 114 class ORowSetCache; 115 class ORowSetDataColumns; 116 class ORowSetCacheIterator; 117 class ORowSetDataColumn; 118 class ORowSetBase : public ORowSetBase_BASE, 119 public ::comphelper::OPropertyStateContainer, 120 public ::comphelper::OPropertyArrayUsageHelper<ORowSetBase> // this class hold the static property info 121 { 122 OModuleClient m_aModuleClient; 123 protected: 124 typedef ::std::vector<ORowSetDataColumn*> TDataColumns; 125 ::osl::Mutex* m_pMutex; // this the mutex form the rowset itself 126 ::osl::Mutex m_aRowCountMutex, // mutex for rowcount changes 127 // we need an extra mutex for columns to prevent deadlock when setting new values 128 // for a row 129 m_aColumnsMutex; 130 131 ::com::sun::star::uno::Any m_aBookmark; 132 ORowSetCacheIterator m_aCurrentRow; // contains the actual fetched row 133 TORowSetOldRowHelperRef m_aOldRow; 134 TDataColumns m_aDataColumns; // holds the columns as m_pColumns but know the implementation class 135 connectivity::ORowSetValue m_aEmptyValue; // only for error case 136 137 ::cppu::OWeakObject* m_pMySelf; // set by derived classes 138 ORowSetCache* m_pCache; // the cache is used by the rowset and his clone (shared) 139 ORowSetDataColumns* m_pColumns; // represent the select columns 140 ::cppu::OBroadcastHelper& m_rBHelper; // must be set from the derived classes 141 // is used when the formatkey for database types is set 142 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatTypes> m_xNumberFormatTypes; 143 OEmptyCollection* m_pEmptyCollection; 144 145 ::comphelper::ComponentContext m_aContext; 146 ::connectivity::SQLError m_aErrors; 147 148 sal_Int32 m_nLastColumnIndex; // the last column ask for, used for wasNull() 149 sal_Int32 m_nDeletedPosition; // is set only when a row was deleted 150 sal_Int32 m_nResultSetType; // fetch property 151 sal_Int32 m_nResultSetConcurrency; 152 sal_Bool m_bClone; // I'm clone or not 153 sal_Bool m_bIgnoreResult ; 154 sal_Bool m_bBeforeFirst : 1; 155 sal_Bool m_bAfterLast : 1; 156 sal_Bool m_bIsInsertRow : 1; 157 158 protected: 159 ORowSetBase( 160 const ::comphelper::ComponentContext& _rContext, 161 ::cppu::OBroadcastHelper& _rBHelper, 162 ::osl::Mutex* _pMutex 163 ); 164 165 // fire a notification for all that are listening on column::VALUE property 166 void firePropertyChange(const ORowSetRow& _rOldRow); 167 // fire a change for one column 168 // _nPos starts at zero 169 void firePropertyChange(sal_Int32 _nPos,const ::connectivity::ORowSetValue& _rNewValue); 170 171 // fire if rowcount changed 172 virtual void fireRowcount(); 173 // notify row changed 174 virtual sal_Bool notifyAllListenersCursorBeforeMove(::osl::ResettableMutexGuard& _rGuard); 175 // notify cursor moved 176 virtual void notifyAllListenersCursorMoved(::osl::ResettableMutexGuard& _rGuard); 177 // notify all that rowset changed 178 virtual void notifyAllListeners(::osl::ResettableMutexGuard& _rGuard); 179 180 // cancel the insertion, if necessary (means if we're on the insert row) 181 virtual void doCancelModification( ) = 0; 182 // return <TRUE/> if and only if we're using the insert row (means: we're updating _or_ inserting) 183 virtual sal_Bool isModification( ) = 0; 184 // return <TRUE/> if and only if the current row is modified 185 // TODO: isn't this the same as isModification? 186 virtual sal_Bool isModified( ) = 0; 187 // return <TRUE/> if and only if the current row is the insert row 188 virtual sal_Bool isNew( ) = 0; 189 // notify the change of a boolean property 190 void fireProperty( sal_Int32 _nProperty, sal_Bool _bNew, sal_Bool _bOld ); 191 192 // OPropertyStateContainer 193 virtual void getPropertyDefaultByHandle( sal_Int32 _nHandle, ::com::sun::star::uno::Any& _rDefault ) const; 194 virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue,sal_Int32 nHandle) const; 195 196 enum CursorMoveDirection 197 { 198 /// denotes a cursor move forward 199 MOVE_FORWARD, 200 /// denotes a cursor move backwards 201 MOVE_BACKWARD, 202 /// denotes no cursor move at all, used when the current row is to be refreshed only 203 MOVE_NONE_REFRESH_ONLY 204 }; 205 /** positions the cache in preparation of a cursor move 206 207 Normally, the cache is simply moved to our bookmark (m_aBookmark). If however the current 208 row is deleted, then the cache is properly positioned for a following cursor movement in the 209 given direction. 210 211 @param _ePrepareForDirection 212 the direction into which the cursor should be moved after the call. If we're currently not on 213 a deleted row, this parameter is ignored, since in this case the cache is simply moved to 214 m_aBookmark.</br> 215 If, however, we're currently on a deleted row, this is used to properly position the cache 216 using <member>m_nDeletedPosition</member>.<br/> 217 In this case, MOVE_NONE_REFRESH_ONLY is not supported. This is because the deleted row 218 (to which the RowSet currently points to) is not present in the cache. So, you cannot move the 219 cache to this row. 220 */ 221 void positionCache( CursorMoveDirection _ePrepareForDirection ); 222 223 // returns a value of a column of the current row 224 const connectivity::ORowSetValue& getValue(sal_Int32 columnIndex); 225 // the cache has to be checked before calling this method 226 const connectivity::ORowSetValue& impl_getValue(sal_Int32 columnIndex); 227 // sets the current and the bookmark 228 void setCurrentRow( sal_Bool _bMoved, sal_Bool _bDoNotify, const ORowSetRow& _rOldValues, ::osl::ResettableMutexGuard& _rGuard); 229 void checkPositioningAllowed() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 230 // checks if the cache is null 231 void checkCache(); 232 // sets the bookmark to Any() 233 // m_aCurrentRow to end of matrix 234 // m_aOldRow to NULL 235 void movementFailed(); 236 237 ORowSetRow getOldRow(sal_Bool _bWasNew); 238 /** move the cache the position defined by the member functor 239 @param _aCheckFunctor 240 Return <TRUE/> when we already stand on the row we want to. 241 @param _aMovementFunctor 242 The method used to move. 243 @return 244 <TRUE/> if movement was successful. 245 */ 246 sal_Bool SAL_CALL move( ::std::mem_fun_t<sal_Bool,ORowSetBase>& _aCheckFunctor, 247 ::std::mem_fun_t<sal_Bool,ORowSetCache>& _aMovementFunctor); 248 249 /** same meaning as isFirst. Only need by mem_fun 250 @return 251 <TRUE/> if so. 252 */ 253 sal_Bool isOnFirst(); 254 /** same meaning as isLast. Only need by mem_fun 255 @return 256 <TRUE/> if so. 257 */ 258 sal_Bool isOnLast(); 259 260 /** returns the current row count 261 262 This function takes into account that we might actually be positioned on a 263 deleted row, so that m_pCache->m_nRowCount does not really reflect the actual 264 count. 265 266 @precond 267 Our mutex is locked. 268 */ 269 sal_Int32 impl_getRowCount() const; 270 271 // the checkCache has to be called before calling this methods 272 sal_Bool impl_wasNull(); 273 sal_Int32 impl_getRow(); 274 sal_Bool impl_rowDeleted(); 275 276 public: 277 virtual ~ORowSetBase(); 278 279 // OComponentHelper 280 virtual void SAL_CALL disposing(void); 281 282 // com::sun::star::beans::XPropertySet getPropertySetInfo()283 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException) 284 { 285 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); 286 } 287 288 // comphelper::OPropertyArrayUsageHelper 289 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; 290 291 // cppu::OPropertySetHelper 292 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); 293 294 // com::sun::star::lang::XTypeProvider 295 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException); 296 297 // com::sun::star::uno::XInterface 298 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException); 299 300 // ::com::sun::star::sdbc::XWarningsSupplier 301 virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 302 virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 303 304 // ::com::sun::star::sdbc::XResultSetMetaDataSupplier 305 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); 306 307 // ::com::sun::star::sdbc::XColumnLocate 308 virtual sal_Int32 SAL_CALL findColumn( const ::rtl::OUString& columnName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 309 310 // ::com::sun::star::sdbcx::XColumnsSupplier 311 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getColumns( ) throw(::com::sun::star::uno::RuntimeException); 312 313 // ::com::sun::star::sdbc::XRow 314 virtual sal_Bool SAL_CALL wasNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 315 virtual ::rtl::OUString SAL_CALL getString( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 316 virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 317 virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 318 virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 319 virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 320 virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 321 virtual float SAL_CALL getFloat( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 322 virtual double SAL_CALL getDouble( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 323 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); 324 virtual ::com::sun::star::util::Date SAL_CALL getDate( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 325 virtual ::com::sun::star::util::Time SAL_CALL getTime( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 326 virtual ::com::sun::star::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 327 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); 328 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); 329 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); 330 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); 331 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); 332 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); 333 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); 334 335 // ::com::sun::star::sdbcx::XRowLocate 336 virtual ::com::sun::star::uno::Any SAL_CALL getBookmark( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 337 virtual sal_Bool SAL_CALL moveToBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 338 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); 339 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); 340 virtual sal_Bool SAL_CALL hasOrderedBookmarks( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 341 virtual sal_Int32 SAL_CALL hashBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 342 343 // ::com::sun::star::sdbc::XResultSet 344 virtual sal_Bool SAL_CALL next( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 345 virtual sal_Bool SAL_CALL isBeforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 346 virtual sal_Bool SAL_CALL isAfterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 347 virtual sal_Bool SAL_CALL isFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 348 virtual sal_Bool SAL_CALL isLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 349 virtual void SAL_CALL beforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 350 virtual void SAL_CALL afterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 351 virtual sal_Bool SAL_CALL first( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 352 virtual sal_Bool SAL_CALL last( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 353 virtual sal_Int32 SAL_CALL getRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 354 virtual sal_Bool SAL_CALL absolute( sal_Int32 row ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 355 virtual sal_Bool SAL_CALL relative( sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 356 virtual sal_Bool SAL_CALL previous( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 357 virtual void SAL_CALL refreshRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 358 virtual sal_Bool SAL_CALL rowUpdated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 359 virtual sal_Bool SAL_CALL rowInserted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 360 virtual sal_Bool SAL_CALL rowDeleted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 361 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); 362 363 // ::com::sun::star::sdbc::XRowSet 364 virtual void SAL_CALL execute( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) = 0; 365 virtual void SAL_CALL addRowSetListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSetListener >& listener ) throw(::com::sun::star::uno::RuntimeException) = 0; 366 virtual void SAL_CALL removeRowSetListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSetListener >& listener ) throw(::com::sun::star::uno::RuntimeException) = 0; 367 368 // is called when the rowset is going to delete this bookmark _rBookmark 369 void onDeleteRow( const ::com::sun::star::uno::Any& _rBookmark ); 370 // is called when the rowset has deleted this bookmark _rBookmark 371 void onDeletedRow( const ::com::sun::star::uno::Any& _rBookmark, sal_Int32 _nPos ); 372 373 // ========================================================== 374 // granular access control GrantNotifierAccessdbaccess::ORowSetBase::GrantNotifierAccess375 struct GrantNotifierAccess { friend class ORowSetNotifier; private: GrantNotifierAccess () { } }; 376 377 // cancel the insertion, if necessary (means if we're on the insert row) doCancelModification(const GrantNotifierAccess &)378 inline void doCancelModification( const GrantNotifierAccess& ) { doCancelModification(); } isModification(const GrantNotifierAccess &)379 inline sal_Bool isModification( const GrantNotifierAccess& ) { return isModification(); } isModified(const GrantNotifierAccess &)380 inline sal_Bool isModified( const GrantNotifierAccess& ) { return isModified(); } isNew(const GrantNotifierAccess &)381 inline sal_Bool isNew( const GrantNotifierAccess& ) { return isNew(); } isInsertRow()382 inline sal_Bool isInsertRow() { return m_bIsInsertRow; } // isNew() || isModified(); } fireProperty(sal_Int32 _nProperty,sal_Bool _bNew,sal_Bool _bOld,const GrantNotifierAccess &)383 inline void fireProperty( sal_Int32 _nProperty, sal_Bool _bNew, sal_Bool _bOld, const GrantNotifierAccess& ) 384 { 385 fireProperty( _nProperty, _bNew, _bOld ); 386 } firePropertyChange(sal_Int32 _nPos,const::connectivity::ORowSetValue & _rNewValue,const GrantNotifierAccess &)387 inline void firePropertyChange(sal_Int32 _nPos,const ::connectivity::ORowSetValue& _rNewValue, const GrantNotifierAccess& ) 388 { 389 firePropertyChange(_nPos,_rNewValue); 390 } 391 using ::comphelper::OPropertyStateContainer::getFastPropertyValue; 392 getMutex() const393 ::osl::Mutex* getMutex() const { return m_pMutex; } 394 }; 395 396 // ======================================================================== 397 /** eases the handling of the doCancelModification and notifyCancelInsert methods 398 399 <p>The class can only be used on the stack, within a method of ORowSetBase (or derivees)</p> 400 */ 401 struct ORowSetNotifierImpl; 402 class ORowSetNotifier 403 { 404 private: 405 ::std::auto_ptr<ORowSetNotifierImpl> m_pImpl; 406 ORowSetBase* m_pRowSet; 407 // not acquired! This is not necessary because this class here is to be used on the stack within 408 // a method of ORowSetBase (or derivees) 409 sal_Bool m_bWasNew; 410 sal_Bool m_bWasModified; 411 412 #ifdef DBG_UTIL 413 sal_Bool m_bNotifyCalled; 414 #endif 415 416 public: 417 /** constructs the object, and cancels the insertion 418 419 @see ORowSetBase::doCancelModification 420 */ 421 ORowSetNotifier( ORowSetBase* m_pRowSet ); 422 423 /** use this one to consturct an vector for change value notification 424 */ 425 ORowSetNotifier( ORowSetBase* m_pRowSet,const ORowSetValueVector::Vector& i_aRow ); 426 427 // destructs the object. <member>fire</member> has to be called before. 428 ~ORowSetNotifier( ); 429 430 /** notifies the insertion 431 432 <p>This has <em>not</em> been put into the destructor by intention!<br/> 433 434 The destructor is called during stack unwinding in case of an exception, so if we would do 435 listener notification there, this would have the potential of another exception during stack 436 unwinding, which would terminate the application.</p> 437 438 @see ORowSetBase::notifyCancelInsert 439 */ 440 void fire(); 441 442 /** notifies value change events and notifies IsModified 443 @param i_aChangedColumns the index of the changed value columns 444 @param i_aRow the old values 445 @see ORowSetBase::notifyCancelInsert 446 */ 447 void firePropertyChange(); 448 449 /** use this one to store the index of the changed column values 450 */ 451 ::std::vector<sal_Int32>& getChangedColumns() const; 452 ::std::vector<com::sun::star::uno::Any>& getChangedBookmarks() const; 453 454 }; 455 456 } // end of namespace 457 458 #endif // DBACCESS_CORE_API_ROWSETBASE_HXX 459 460 /* vim: set noet sw=4 ts=4: */ 461