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 : sal_Bool m_bClone; // I'm clone or not
106 : sal_Bool m_bIgnoreResult ;
107 : sal_Bool m_bBeforeFirst : 1;
108 : sal_Bool m_bAfterLast : 1;
109 : sal_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 sal_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 sal_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 sal_Bool isModified( ) = 0;
140 : // return <TRUE/> if and only if the current row is the insert row
141 : virtual sal_Bool isNew( ) = 0;
142 : // return <TRUE/> if the property change notification should be fired
143 : // upon property change.
144 : virtual sal_Bool isPropertyChangeNotificationEnabled() const;
145 : // notify the change of a boolean property
146 : void fireProperty( sal_Int32 _nProperty, sal_Bool _bNew, sal_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, used when the current row is to be refreshed only
159 : MOVE_NONE_REFRESH_ONLY
160 : };
161 : /** positions the cache in preparation of a cursor move
162 :
163 : Normally, the cache is simply moved to our bookmark (m_aBookmark). If however the current
164 : row is deleted, then the cache is properly positioned for a following cursor movement in the
165 : given direction.
166 :
167 : @param _ePrepareForDirection
168 : the direction into which the cursor should be moved after the call. If we're currently not on
169 : a deleted row, this parameter is ignored, since in this case the cache is simply moved to
170 : m_aBookmark.</br>
171 : If, however, we're currently on a deleted row, this is used to properly position the cache
172 : using <member>m_nDeletedPosition</member>.<br/>
173 : In this case, MOVE_NONE_REFRESH_ONLY is not supported. This is because the deleted row
174 : (to which the RowSet currently points to) is not present in the cache. So, you cannot move the
175 : cache to this row.
176 : */
177 : void positionCache( CursorMoveDirection _ePrepareForDirection );
178 :
179 : // returns a value of a column of the current row
180 : const connectivity::ORowSetValue& getValue(sal_Int32 columnIndex);
181 : // the cache has to be checked before calling this method
182 : const connectivity::ORowSetValue& impl_getValue(sal_Int32 columnIndex);
183 : // sets the current and the bookmark
184 : void setCurrentRow( sal_Bool _bMoved, sal_Bool _bDoNotify, const ORowSetRow& _rOldValues, ::osl::ResettableMutexGuard& _rGuard);
185 : void checkPositioningAllowed() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
186 : // checks if the cache is null
187 : void checkCache();
188 : // sets the bookmark to Any()
189 : // m_aCurrentRow to end of matrix
190 : // m_aOldRow to NULL
191 : void movementFailed();
192 :
193 : ORowSetRow getOldRow(sal_Bool _bWasNew);
194 : /** move the cache the postion defined by the member functor
195 : @param _aCheckFunctor
196 : Return <TRUE/> when we already stand on the row we want to.
197 : @param _aMovementFunctor
198 : The mehtod used to move.
199 : @return
200 : <TRUE/> if movement was successful.
201 : */
202 : sal_Bool SAL_CALL move( ::std::mem_fun_t<sal_Bool,ORowSetBase>& _aCheckFunctor,
203 : ::std::mem_fun_t<sal_Bool,ORowSetCache>& _aMovementFunctor);
204 :
205 : /** same meaning as isFirst. Only need by mem_fun
206 : @return
207 : <TRUE/> if so.
208 : */
209 : sal_Bool isOnFirst();
210 : /** same meaning as isLast. Only need by mem_fun
211 : @return
212 : <TRUE/> if so.
213 : */
214 : sal_Bool isOnLast();
215 :
216 : /** returns the current row count
217 :
218 : This function takes into account that we might actually be positioned on a
219 : deleted row, so that m_pCache->m_nRowCount does not really reflect the actual
220 : count.
221 :
222 : @precond
223 : Our mutext is locked.
224 : */
225 : sal_Int32 impl_getRowCount() const;
226 :
227 : // the checkCache has to be called before calling this methods
228 : sal_Bool impl_wasNull();
229 : sal_Int32 impl_getRow();
230 : sal_Bool impl_rowDeleted();
231 :
232 : public:
233 : virtual ~ORowSetBase();
234 :
235 : // OComponentHelper
236 : virtual void SAL_CALL disposing(void);
237 :
238 : // com::sun::star::beans::XPropertySet
239 0 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
240 : {
241 0 : return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
242 : }
243 :
244 : // comphelper::OPropertyArrayUsageHelper
245 : virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const SAL_OVERRIDE;
246 :
247 : // cppu::OPropertySetHelper
248 : virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() SAL_OVERRIDE;
249 :
250 : // com::sun::star::lang::XTypeProvider
251 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
252 :
253 : // com::sun::star::uno::XInterface
254 : 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;
255 :
256 : // ::com::sun::star::sdbc::XWarningsSupplier
257 : virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
258 : virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
259 :
260 : // ::com::sun::star::sdbc::XResultSetMetaDataSupplier
261 : 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;
262 :
263 : // ::com::sun::star::sdbc::XColumnLocate
264 : virtual sal_Int32 SAL_CALL findColumn( const OUString& columnName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
265 :
266 : // ::com::sun::star::sdbcx::XColumnsSupplier
267 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getColumns( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
268 :
269 : // ::com::sun::star::sdbc::XRow
270 : virtual sal_Bool SAL_CALL wasNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
271 : virtual OUString SAL_CALL getString( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
272 : virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
273 : virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
274 : virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
275 : virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
276 : virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
277 : virtual float SAL_CALL getFloat( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
278 : virtual double SAL_CALL getDouble( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
279 : 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;
280 : 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;
281 : 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;
282 : 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;
283 : 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;
284 : 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;
285 : 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;
286 : 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;
287 : 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;
288 : 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;
289 : 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;
290 :
291 : // ::com::sun::star::sdbcx::XRowLocate
292 : virtual ::com::sun::star::uno::Any SAL_CALL getBookmark( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
293 : 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;
294 : 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;
295 : 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;
296 : virtual sal_Bool SAL_CALL hasOrderedBookmarks( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
297 : 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;
298 :
299 : // ::com::sun::star::sdbc::XResultSet
300 : virtual sal_Bool SAL_CALL next( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
301 : virtual sal_Bool SAL_CALL isBeforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
302 : virtual sal_Bool SAL_CALL isAfterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
303 : virtual sal_Bool SAL_CALL isFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
304 : virtual sal_Bool SAL_CALL isLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
305 : virtual void SAL_CALL beforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
306 : virtual void SAL_CALL afterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
307 : virtual sal_Bool SAL_CALL first( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
308 : virtual sal_Bool SAL_CALL last( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
309 : virtual sal_Int32 SAL_CALL getRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
310 : virtual sal_Bool SAL_CALL absolute( sal_Int32 row ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
311 : virtual sal_Bool SAL_CALL relative( sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
312 : virtual sal_Bool SAL_CALL previous( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
313 : virtual void SAL_CALL refreshRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
314 : virtual sal_Bool SAL_CALL rowUpdated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
315 : virtual sal_Bool SAL_CALL rowInserted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
316 : virtual sal_Bool SAL_CALL rowDeleted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
317 : 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;
318 :
319 : // ::com::sun::star::sdbc::XRowSet
320 : virtual void SAL_CALL execute( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE = 0;
321 : 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;
322 : 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;
323 :
324 : // is called when the rowset is going to delete this bookmark _rBookmark
325 : void onDeleteRow( const ::com::sun::star::uno::Any& _rBookmark );
326 : // is called when the rowset has deleted this bookmark _rBookmark
327 : void onDeletedRow( const ::com::sun::star::uno::Any& _rBookmark, sal_Int32 _nPos );
328 :
329 : // granular access control
330 0 : struct GrantNotifierAccess { friend class ORowSetNotifier; private: GrantNotifierAccess () { } };
331 :
332 : // cancel the insertion, if necessary (means if we're on the insert row)
333 0 : inline void doCancelModification( const GrantNotifierAccess& ) { doCancelModification(); }
334 0 : inline sal_Bool isModification( const GrantNotifierAccess& ) { return isModification(); }
335 0 : inline sal_Bool isModified( const GrantNotifierAccess& ) { return isModified(); }
336 0 : inline sal_Bool isNew( const GrantNotifierAccess& ) { return isNew(); }
337 0 : inline sal_Bool isInsertRow() { return m_bIsInsertRow; } // isNew() || isModified(); }
338 0 : inline void fireProperty( sal_Int32 _nProperty, sal_Bool _bNew, sal_Bool _bOld, const GrantNotifierAccess& )
339 : {
340 0 : fireProperty( _nProperty, _bNew, _bOld );
341 0 : }
342 0 : inline void firePropertyChange(sal_Int32 _nPos,const ::connectivity::ORowSetValue& _rNewValue, const GrantNotifierAccess& )
343 : {
344 0 : firePropertyChange(_nPos,_rNewValue);
345 0 : }
346 : using ::comphelper::OPropertyStateContainer::getFastPropertyValue;
347 :
348 0 : ::osl::Mutex* getMutex() const { return m_pMutex; }
349 : };
350 :
351 : /** eases the handling of the doCancelModification and notifyCancelInsert methods
352 :
353 : <p>The class can only be used on the stack, within a method of ORowSetBase (or derivees)</p>
354 : */
355 : struct ORowSetNotifierImpl;
356 : class ORowSetNotifier
357 : {
358 : private:
359 : ::std::auto_ptr<ORowSetNotifierImpl> m_pImpl;
360 : ORowSetBase* m_pRowSet;
361 : // not aquired! This is not necessary because this class here is to be used on the stack within
362 : // a method of ORowSetBase (or derivees)
363 : sal_Bool m_bWasNew;
364 : sal_Bool m_bWasModified;
365 :
366 : #ifdef DBG_UTIL
367 : sal_Bool m_bNotifyCalled;
368 : #endif
369 :
370 : public:
371 : /** constructs the object, and cancels the insertion
372 :
373 : @see ORowSetBase::doCancelModification
374 : */
375 : ORowSetNotifier( ORowSetBase* m_pRowSet );
376 :
377 : /** use this one to consturct an vector for change value notification
378 : */
379 : ORowSetNotifier( ORowSetBase* m_pRowSet,const ORowSetValueVector::Vector& i_aRow );
380 :
381 : // destructs the object. <member>fire</member> has to be called before.
382 : ~ORowSetNotifier( );
383 :
384 : /** notifies the insertion
385 :
386 : <p>This has <em>not</em> been put into the destructor by intention!<br/>
387 :
388 : The destructor is called during stack unwinding in case of an exception, so if we would do
389 : listener notification there, this would have the potential of another exception during stack
390 : unwinding, which would terminate the application.</p>
391 :
392 : @see ORowSetBase::notifyCancelInsert
393 : */
394 : void fire();
395 :
396 : /** notifies value change events and notifies IsModified
397 : @param i_aChangedColumns the index of the changed value columns
398 : @param i_aRow the old values
399 : @see ORowSetBase::notifyCancelInsert
400 : */
401 : void firePropertyChange();
402 :
403 : /** use this one to store the inde of the changed column values
404 : */
405 : ::std::vector<sal_Int32>& getChangedColumns() const;
406 :
407 : };
408 :
409 : } // end of namespace
410 :
411 : #endif // INCLUDED_DBACCESS_SOURCE_CORE_API_ROWSETBASE_HXX
412 :
413 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|