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