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 INCLUDED_DBACCESS_SOURCE_CORE_API_ROWSETBASE_HXX
20 : #define INCLUDED_DBACCESS_SOURCE_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 :
45 : #include <functional>
46 :
47 : namespace com { namespace sun { namespace star {
48 : namespace sdb { struct RowChangeEvent; }
49 : namespace lang { struct Locale; }
50 : } } }
51 :
52 : namespace dbaccess
53 : {
54 : class OEmptyCollection;
55 :
56 : typedef ::cppu::ImplHelper10< ::com::sun::star::sdbcx::XRowLocate,
57 : ::com::sun::star::sdbc::XRow,
58 : ::com::sun::star::sdbc::XResultSetMetaDataSupplier,
59 : ::com::sun::star::sdbc::XWarningsSupplier,
60 : ::com::sun::star::sdbc::XColumnLocate,
61 : ::com::sun::star::sdbcx::XColumnsSupplier,
62 : ::com::sun::star::lang::XServiceInfo,
63 : ::com::sun::star::sdbc::XRowSet,
64 : ::com::sun::star::sdbc::XCloseable,
65 : ::com::sun::star::lang::XUnoTunnel> ORowSetBase_BASE;
66 :
67 : class ORowSetCache;
68 : class ORowSetDataColumns;
69 : class ORowSetCacheIterator;
70 : class ORowSetDataColumn;
71 : class ORowSetBase : public ORowSetBase_BASE,
72 : public ::comphelper::OPropertyStateContainer,
73 : public ::comphelper::OPropertyArrayUsageHelper<ORowSetBase> // this class hold the static property info
74 : {
75 : OModuleClient m_aModuleClient;
76 : protected:
77 : typedef ::std::vector<ORowSetDataColumn*> TDataColumns;
78 : ::osl::Mutex* m_pMutex; // this the mutex form the rowset itself
79 : ::osl::Mutex m_aRowCountMutex, // mutex for rowcount changes
80 : // we need a extra mutex for columns to prevend deadlock when setting new values
81 : // for a row
82 : m_aColumnsMutex;
83 :
84 : ::com::sun::star::uno::Any m_aBookmark;
85 : ORowSetCacheIterator m_aCurrentRow; // contains the actual fetched row
86 : TORowSetOldRowHelperRef m_aOldRow;
87 : TDataColumns m_aDataColumns; // holds the columns as m_pColumns but know the implementation class
88 : connectivity::ORowSetValue m_aEmptyValue; // only for error case
89 :
90 : ::cppu::OWeakObject* m_pMySelf; // set by derived classes
91 : ORowSetCache* m_pCache; // the cache is used by the rowset and his clone (shared)
92 : ORowSetDataColumns* m_pColumns; // represent the select columns
93 : ::cppu::OBroadcastHelper& m_rBHelper; // must be set from the derived classes
94 : // is used when the formatkey for database types is set
95 : ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatTypes> m_xNumberFormatTypes;
96 : OEmptyCollection* m_pEmptyCollection;
97 :
98 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> m_aContext;
99 : ::connectivity::SQLError m_aErrors;
100 :
101 : sal_Int32 m_nLastColumnIndex; // the last column ask for, used for wasNull()
102 : sal_Int32 m_nDeletedPosition; // is set only when a row was deleted
103 : sal_Int32 m_nResultSetType; // fetch property
104 : sal_Int32 m_nResultSetConcurrency;
105 : bool m_bClone; // I'm clone or not
106 : bool m_bIgnoreResult ;
107 : bool m_bBeforeFirst : 1;
108 : bool m_bAfterLast : 1;
109 : bool m_bIsInsertRow : 1;
110 :
111 : protected:
112 : ORowSetBase(
113 : const css::uno::Reference<css::uno::XComponentContext>& _rContext,
114 : ::cppu::OBroadcastHelper& _rBHelper,
115 : ::osl::Mutex* _pMutex
116 : );
117 :
118 : // fire a notification for all that are listening on column::VALUE property
119 : void firePropertyChange(const ORowSetRow& _rOldRow);
120 : // fire a change for one column
121 : // _nPos starts at zero
122 : void firePropertyChange(sal_Int32 _nPos,const ::connectivity::ORowSetValue& _rNewValue);
123 :
124 : // fire if rowcount changed
125 : virtual void fireRowcount();
126 : // notify row changed
127 : virtual bool notifyAllListenersCursorBeforeMove(::osl::ResettableMutexGuard& _rGuard);
128 : // notify cursor moved
129 : virtual void notifyAllListenersCursorMoved(::osl::ResettableMutexGuard& _rGuard);
130 : // notify all that rowset changed
131 : virtual void notifyAllListeners(::osl::ResettableMutexGuard& _rGuard);
132 :
133 : // cancel the insertion, if necessary (means if we're on the insert row)
134 : virtual void doCancelModification( ) = 0;
135 : // return <TRUE/> if and only if we're using the insert row (means: we're updating _or_ inserting)
136 : virtual bool isModification( ) = 0;
137 : // return <TRUE/> if and only if the current row is modified
138 : // TODO: isn't this the same as isModification?
139 : virtual bool isModified( ) = 0;
140 : // return <TRUE/> if and only if the current row is the insert row
141 : virtual bool isNew( ) = 0;
142 : // return <TRUE/> if the property change notification should be fired
143 : // upon property change.
144 : virtual bool isPropertyChangeNotificationEnabled() const;
145 : // notify the change of a boolean property
146 : void fireProperty( sal_Int32 _nProperty, bool _bNew, bool _bOld );
147 :
148 : // OPropertyStateContainer
149 : virtual void getPropertyDefaultByHandle( sal_Int32 _nHandle, ::com::sun::star::uno::Any& _rDefault ) const SAL_OVERRIDE;
150 : virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue,sal_Int32 nHandle) const SAL_OVERRIDE;
151 :
152 : enum CursorMoveDirection
153 : {
154 : /// denotes a cursor move forward
155 : MOVE_FORWARD,
156 : /// denotes a cursor move backwards
157 : MOVE_BACKWARD,
158 : /// denotes no cursor move at all, but move cache to current row (if it is not there already)
159 : MOVE_NONE,
160 : /// denotes no cursor move at all, but force the cache to move to current row (and refresh the row)
161 : MOVE_NONE_REFRESH
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) 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( bool _bMoved, 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(bool _bWasNew);
196 : /** move the cache the position 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 method used to move.
201 : @return
202 : <TRUE/> if movement was successful.
203 : */
204 : bool SAL_CALL move( ::std::mem_fun_t<bool,ORowSetBase>& _aCheckFunctor,
205 : ::std::mem_fun_t<bool,ORowSetCache>& _aMovementFunctor);
206 :
207 : /** same meaning as isFirst. Only need by mem_fun
208 : @return
209 : <TRUE/> if so.
210 : */
211 : bool isOnFirst();
212 : /** same meaning as isLast. Only need by mem_fun
213 : @return
214 : <TRUE/> if so.
215 : */
216 : 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 : bool impl_wasNull();
231 : sal_Int32 impl_getRow();
232 : bool impl_rowDeleted();
233 :
234 : public:
235 : virtual ~ORowSetBase();
236 :
237 : // OComponentHelper
238 : virtual void SAL_CALL disposing();
239 :
240 : // com::sun::star::beans::XPropertySet
241 257 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
242 : {
243 257 : return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
244 : }
245 :
246 : // comphelper::OPropertyArrayUsageHelper
247 : virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const SAL_OVERRIDE;
248 :
249 : // cppu::OPropertySetHelper
250 : virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
260 : virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
264 :
265 : // ::com::sun::star::sdbc::XColumnLocate
266 : virtual sal_Int32 SAL_CALL findColumn( const OUString& columnName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
273 : virtual OUString SAL_CALL getString( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
274 : virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
275 : virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
276 : virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
277 : virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
278 : virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
279 : virtual float SAL_CALL getFloat( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
280 : virtual double SAL_CALL getDouble( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
282 : virtual ::com::sun::star::util::Date SAL_CALL getDate( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
283 : virtual ::com::sun::star::util::Time SAL_CALL getTime( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
284 : virtual ::com::sun::star::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
298 : virtual sal_Bool SAL_CALL hasOrderedBookmarks( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
303 : virtual sal_Bool SAL_CALL isBeforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
304 : virtual sal_Bool SAL_CALL isAfterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
305 : virtual sal_Bool SAL_CALL isFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
306 : virtual sal_Bool SAL_CALL isLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
307 : virtual void SAL_CALL beforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
308 : virtual void SAL_CALL afterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
309 : virtual sal_Bool SAL_CALL first( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
310 : virtual sal_Bool SAL_CALL last( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
311 : virtual sal_Int32 SAL_CALL getRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
312 : virtual sal_Bool SAL_CALL absolute( sal_Int32 row ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
313 : virtual sal_Bool SAL_CALL relative( sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
314 : virtual sal_Bool SAL_CALL previous( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
315 : virtual void SAL_CALL refreshRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
316 : virtual sal_Bool SAL_CALL rowUpdated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
317 : virtual sal_Bool SAL_CALL rowInserted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
318 : virtual sal_Bool SAL_CALL rowDeleted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
320 :
321 : // ::com::sun::star::sdbc::XRowSet
322 : virtual void SAL_CALL execute( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE = 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, std::exception) SAL_OVERRIDE = 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, std::exception) SAL_OVERRIDE = 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 : // granular access control
332 5872 : struct GrantNotifierAccess { friend class ORowSetNotifier; private: GrantNotifierAccess () { } };
333 :
334 : // cancel the insertion, if necessary (means if we're on the insert row)
335 3 : inline void doCancelModification( const GrantNotifierAccess& ) { doCancelModification(); }
336 1943 : inline bool isModification( const GrantNotifierAccess& ) { return isModification(); }
337 1946 : inline bool isModified( const GrantNotifierAccess& ) { return isModified(); }
338 1946 : inline bool isNew( const GrantNotifierAccess& ) { return isNew(); }
339 191917 : inline bool isInsertRow() { return m_bIsInsertRow; } // isNew() || isModified(); }
340 20 : inline void fireProperty( sal_Int32 _nProperty, bool _bNew, bool _bOld, const GrantNotifierAccess& )
341 : {
342 20 : fireProperty( _nProperty, _bNew, _bOld );
343 20 : }
344 14 : inline void firePropertyChange(sal_Int32 _nPos,const ::connectivity::ORowSetValue& _rNewValue, const GrantNotifierAccess& )
345 : {
346 14 : firePropertyChange(_nPos,_rNewValue);
347 14 : }
348 : using ::comphelper::OPropertyStateContainer::getFastPropertyValue;
349 :
350 : ::osl::Mutex* getMutex() const { return m_pMutex; }
351 : };
352 :
353 : /** eases the handling of the doCancelModification and notifyCancelInsert methods
354 :
355 : <p>The class can only be used on the stack, within a method of ORowSetBase (or derivees)</p>
356 : */
357 : struct ORowSetNotifierImpl;
358 : class ORowSetNotifier
359 : {
360 : private:
361 : ::std::unique_ptr<ORowSetNotifierImpl> m_pImpl;
362 : ORowSetBase* m_pRowSet;
363 : // not acquired! This is not necessary because this class here is to be used on the stack within
364 : // a method of ORowSetBase (or derivees)
365 : bool m_bWasNew;
366 : bool m_bWasModified;
367 :
368 : #ifdef DBG_UTIL
369 : bool m_bNotifyCalled;
370 : #endif
371 :
372 : public:
373 : /** constructs the object, and cancels the insertion
374 :
375 : @see ORowSetBase::doCancelModification
376 : */
377 : ORowSetNotifier( ORowSetBase* m_pRowSet );
378 :
379 : /** use this one to consturct an vector for change value notification
380 : */
381 : ORowSetNotifier( ORowSetBase* m_pRowSet,const ORowSetValueVector::Vector& i_aRow );
382 :
383 : // destructs the object. <member>fire</member> has to be called before.
384 : ~ORowSetNotifier( );
385 :
386 : /** notifies the insertion
387 :
388 : <p>This has <em>not</em> been put into the destructor by intention!<br/>
389 :
390 : The destructor is called during stack unwinding in case of an exception, so if we would do
391 : listener notification there, this would have the potential of another exception during stack
392 : unwinding, which would terminate the application.</p>
393 :
394 : @see ORowSetBase::notifyCancelInsert
395 : */
396 : void fire();
397 :
398 : /** notifies value change events and notifies IsModified
399 : @param i_aChangedColumns the index of the changed value columns
400 : @param i_aRow the old values
401 : @see ORowSetBase::notifyCancelInsert
402 : */
403 : void firePropertyChange();
404 :
405 : /** use this one to store the inde of the changed column values
406 : */
407 : ::std::vector<sal_Int32>& getChangedColumns() const;
408 :
409 : };
410 :
411 : } // end of namespace
412 :
413 : #endif // INCLUDED_DBACCESS_SOURCE_CORE_API_ROWSETBASE_HXX
414 :
415 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|