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