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