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 :
20 : #include "RowSetBase.hxx"
21 : #include "CRowSetDataColumn.hxx"
22 : #include <connectivity/sdbcx/VCollection.hxx>
23 : #include "RowSetCache.hxx"
24 : #include "dbastrings.hrc"
25 : #include "core_resource.hrc"
26 : #include <com/sun/star/lang/DisposedException.hpp>
27 : #include <com/sun/star/beans/PropertyAttribute.hpp>
28 : #include <com/sun/star/sdbcx/CompareBookmark.hpp>
29 : #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
30 : #include <com/sun/star/lang/Locale.hpp>
31 : #include <com/sun/star/util/NumberFormat.hpp>
32 : #include <comphelper/sequence.hxx>
33 : #include <comphelper/seqstream.hxx>
34 : #include <connectivity/dbexception.hxx>
35 : #include <tools/debug.hxx>
36 :
37 : using namespace dbaccess;
38 : using namespace connectivity;
39 : using namespace connectivity::sdbcx;
40 : using namespace comphelper;
41 : using namespace dbtools;
42 : using namespace ::com::sun::star::uno;
43 : using namespace ::com::sun::star::beans;
44 : using namespace ::com::sun::star::sdbc;
45 : using namespace ::com::sun::star::sdb;
46 : using namespace ::com::sun::star::sdbcx;
47 : using namespace ::com::sun::star::container;
48 : using namespace ::com::sun::star::lang;
49 : using namespace ::com::sun::star::util;
50 : using namespace ::cppu;
51 : using namespace ::osl;
52 :
53 : namespace dbaccess
54 : {
55 :
56 : // OEmptyCollection
57 0 : class OEmptyCollection : public sdbcx::OCollection
58 : {
59 : protected:
60 : virtual void impl_refresh() throw(RuntimeException) SAL_OVERRIDE;
61 : virtual connectivity::sdbcx::ObjectType createObject(const OUString& _rName) SAL_OVERRIDE;
62 : public:
63 0 : OEmptyCollection(::cppu::OWeakObject& _rParent,::osl::Mutex& _rMutex) : OCollection(_rParent, true, _rMutex, ::std::vector< OUString>()){}
64 : };
65 :
66 0 : void OEmptyCollection::impl_refresh() throw(RuntimeException)
67 : {
68 0 : }
69 :
70 0 : connectivity::sdbcx::ObjectType OEmptyCollection::createObject(const OUString& /*_rName*/)
71 : {
72 0 : return connectivity::sdbcx::ObjectType();
73 : }
74 :
75 : // ORowSetBase
76 :
77 0 : ORowSetBase::ORowSetBase( const Reference<XComponentContext>& _rContext, ::cppu::OBroadcastHelper& _rBHelper, ::osl::Mutex* _pMutex )
78 : :OPropertyStateContainer(_rBHelper)
79 : ,m_pMutex(_pMutex)
80 : ,m_pMySelf(NULL)
81 : ,m_pCache(NULL)
82 : ,m_pColumns(NULL)
83 : ,m_rBHelper(_rBHelper)
84 : ,m_pEmptyCollection( NULL )
85 : ,m_aContext( _rContext )
86 : ,m_aErrors( _rContext )
87 : ,m_nLastColumnIndex(-1)
88 : ,m_nDeletedPosition(-1)
89 : ,m_nResultSetType( ResultSetType::FORWARD_ONLY )
90 : ,m_nResultSetConcurrency( ResultSetConcurrency::READ_ONLY )
91 : ,m_bClone(sal_False)
92 : ,m_bIgnoreResult(sal_False)
93 : ,m_bBeforeFirst(sal_True) // changed from sal_False
94 : ,m_bAfterLast(sal_False)
95 0 : ,m_bIsInsertRow(sal_False)
96 : {
97 : SAL_INFO("dbaccess", "ORowSetBase::ORowSetBase" );
98 :
99 0 : sal_Int32 nRBT = PropertyAttribute::READONLY | PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT;
100 :
101 0 : sal_Int32 nInitialRowCountValue = 0;
102 0 : sal_Bool bInitialRowCountFinalValue( sal_False );
103 0 : registerPropertyNoMember( PROPERTY_ROWCOUNT, PROPERTY_ID_ROWCOUNT, nRBT, ::getCppuType( &nInitialRowCountValue ), &nInitialRowCountValue );
104 0 : registerPropertyNoMember( PROPERTY_ISROWCOUNTFINAL, PROPERTY_ID_ISROWCOUNTFINAL, nRBT, ::getBooleanCppuType(), &bInitialRowCountFinalValue );
105 0 : }
106 :
107 0 : ORowSetBase::~ORowSetBase()
108 : {
109 0 : if(m_pColumns)
110 : {
111 0 : TDataColumns().swap(m_aDataColumns);
112 0 : m_pColumns->acquire();
113 0 : m_pColumns->disposing();
114 0 : delete m_pColumns;
115 0 : m_pColumns = NULL;
116 : }
117 :
118 0 : if ( m_pEmptyCollection )
119 0 : delete m_pEmptyCollection;
120 :
121 0 : }
122 :
123 : // com::sun::star::lang::XTypeProvider
124 0 : Sequence< Type > ORowSetBase::getTypes() throw (RuntimeException, std::exception)
125 : {
126 0 : return ::comphelper::concatSequences(ORowSetBase_BASE::getTypes(),OPropertyStateContainer::getTypes());
127 : }
128 :
129 : // com::sun::star::uno::XInterface
130 0 : Any ORowSetBase::queryInterface( const Type & rType ) throw (RuntimeException, std::exception)
131 : {
132 0 : Any aRet = ORowSetBase_BASE::queryInterface(rType);
133 0 : if(!aRet.hasValue())
134 0 : aRet = OPropertyStateContainer::queryInterface(rType);
135 0 : return aRet;
136 : }
137 :
138 0 : void SAL_CALL ORowSetBase::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const
139 : {
140 : //SAL_INFO("dbaccess", "ORowSetBase::getFastPropertyValue" );
141 0 : if(m_pCache)
142 : {
143 0 : switch(nHandle)
144 : {
145 : case PROPERTY_ID_ROWCOUNT:
146 0 : rValue <<= impl_getRowCount();
147 0 : break;
148 : case PROPERTY_ID_ISROWCOUNTFINAL:
149 0 : rValue.setValue(&m_pCache->m_bRowCountFinal,::getCppuBooleanType());
150 0 : break;
151 : default:
152 0 : OPropertyStateContainer::getFastPropertyValue(rValue,nHandle);
153 : };
154 : }
155 : else
156 0 : OPropertyStateContainer::getFastPropertyValue(rValue,nHandle);
157 0 : }
158 :
159 : // OComponentHelper
160 0 : void SAL_CALL ORowSetBase::disposing(void)
161 : {
162 : SAL_INFO("dbaccess", "ORowSetBase::disposing" );
163 0 : MutexGuard aGuard(*m_pMutex);
164 :
165 0 : if ( m_pColumns )
166 : {
167 0 : TDataColumns().swap(m_aDataColumns);
168 0 : m_pColumns->disposing();
169 : }
170 0 : if ( m_pCache )
171 : {
172 0 : m_pCache->deregisterOldRow(m_aOldRow);
173 0 : m_pCache->deleteIterator(this);
174 : }
175 0 : m_pCache = NULL;
176 0 : }
177 :
178 : // comphelper::OPropertyArrayUsageHelper
179 0 : ::cppu::IPropertyArrayHelper* ORowSetBase::createArrayHelper( ) const
180 : {
181 : SAL_INFO("dbaccess", "ORowSetBase::createArrayHelper" );
182 0 : Sequence< Property > aProps;
183 0 : describeProperties(aProps);
184 0 : return new ::cppu::OPropertyArrayHelper(aProps);
185 : }
186 :
187 : // cppu::OPropertySetHelper
188 0 : ::cppu::IPropertyArrayHelper& SAL_CALL ORowSetBase::getInfoHelper()
189 : {
190 : SAL_INFO("dbaccess", "ORowSetBase::getInfoHelper" );
191 0 : return *const_cast<ORowSetBase*>(this)->getArrayHelper();
192 : }
193 :
194 : // XRow
195 0 : sal_Bool SAL_CALL ORowSetBase::wasNull( ) throw(SQLException, RuntimeException, std::exception)
196 : {
197 : SAL_INFO("dbaccess", "ORowSetBase::wasNull" );
198 0 : ::osl::MutexGuard aGuard( *m_pMutex );
199 0 : checkCache();
200 0 : return impl_wasNull();
201 : }
202 :
203 0 : sal_Bool ORowSetBase::impl_wasNull()
204 : {
205 : SAL_INFO("dbaccess", "ORowSetBase::impl_wasNull" );
206 0 : return ((m_nLastColumnIndex != -1) && !m_aCurrentRow.isNull() && m_aCurrentRow != m_pCache->getEnd() && m_aCurrentRow->is()) ? ((*m_aCurrentRow)->get())[m_nLastColumnIndex].isNull() : sal_True;
207 : }
208 :
209 0 : const ORowSetValue& ORowSetBase::getValue(sal_Int32 columnIndex)
210 : {
211 : SAL_INFO("dbaccess", "ORowSetBase::getValue" );
212 0 : checkCache();
213 0 : return impl_getValue(columnIndex);
214 : }
215 :
216 0 : const ORowSetValue& ORowSetBase::impl_getValue(sal_Int32 columnIndex)
217 : {
218 : SAL_INFO("dbaccess", "ORowSetBase::impl_getValue" );
219 0 : if ( m_bBeforeFirst || m_bAfterLast )
220 : {
221 : SAL_WARN("dbaccess", "ORowSetBase::getValue: Illegal call here (we're before first or after last)!");
222 0 : ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_CURSOR_BEFORE_OR_AFTER ), SQL_INVALID_CURSOR_POSITION, *m_pMySelf );
223 : }
224 :
225 0 : if ( impl_rowDeleted() )
226 : {
227 0 : return m_aEmptyValue;
228 : }
229 :
230 0 : bool bValidCurrentRow = ( !m_aCurrentRow.isNull() && m_aCurrentRow != m_pCache->getEnd() && m_aCurrentRow->is() );
231 0 : if ( !bValidCurrentRow )
232 : {
233 : // currentrow is null when the clone moves the window
234 0 : positionCache( MOVE_NONE_REFRESH_ONLY );
235 0 : m_aCurrentRow = m_pCache->m_aMatrixIter;
236 0 : m_bIsInsertRow = sal_False;
237 : OSL_ENSURE(!m_aCurrentRow.isNull(),"ORowSetBase::getValue: we don't stand on a valid row! Row is null.");
238 :
239 0 : bValidCurrentRow = ( !m_aCurrentRow.isNull() && m_aCurrentRow != m_pCache->getEnd() && m_aCurrentRow->is() );
240 : }
241 :
242 0 : if ( bValidCurrentRow )
243 : {
244 : #if OSL_DEBUG_LEVEL > 0
245 : ORowSetMatrix::iterator aCacheEnd;
246 : ORowSetMatrix::iterator aCurrentRow;
247 : aCacheEnd = m_pCache->getEnd();
248 : aCurrentRow = m_aCurrentRow;
249 : ORowSetCacheMap::iterator aCacheIter = m_aCurrentRow.getIter();
250 : ORowSetCacheIterator_Helper aHelper = aCacheIter->second;
251 : ORowSetMatrix::iterator k = aHelper.aIterator;
252 : for (; k != m_pCache->getEnd(); ++k)
253 : {
254 : ORowSetValueVector* pTemp = k->get();
255 : OSL_ENSURE( pTemp != (void*)0xfeeefeee,"HALT!" );
256 : }
257 : #endif
258 : OSL_ENSURE(!m_aCurrentRow.isNull() && m_aCurrentRow < m_pCache->getEnd() && aCacheIter != m_pCache->m_aCacheIterators.end(),"Invalid iterator set for currentrow!");
259 : #if OSL_DEBUG_LEVEL > 0
260 : ORowSetRow rRow = (*m_aCurrentRow);
261 : OSL_ENSURE(rRow.is() && static_cast<sal_uInt16>(columnIndex) < (rRow->get()).size(),"Invalid size of vector!");
262 : #endif
263 0 : return ((*m_aCurrentRow)->get())[m_nLastColumnIndex = columnIndex];
264 : }
265 :
266 : // we should normally never reach this
267 0 : return m_aEmptyValue;
268 : }
269 :
270 0 : OUString SAL_CALL ORowSetBase::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
271 : {
272 : SAL_INFO("dbaccess", "ORowSetBase::getString" );
273 0 : ::osl::MutexGuard aGuard( *m_pMutex );
274 0 : return getValue(columnIndex);
275 : }
276 :
277 0 : sal_Bool SAL_CALL ORowSetBase::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
278 : {
279 : SAL_INFO("dbaccess", "ORowSetBase::getBoolean" );
280 0 : ::osl::MutexGuard aGuard( *m_pMutex );
281 0 : return getValue(columnIndex);
282 : }
283 :
284 0 : sal_Int8 SAL_CALL ORowSetBase::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
285 : {
286 : SAL_INFO("dbaccess", "ORowSetBase::getByte" );
287 0 : ::osl::MutexGuard aGuard( *m_pMutex );
288 0 : return getValue(columnIndex);
289 : }
290 :
291 0 : sal_Int16 SAL_CALL ORowSetBase::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
292 : {
293 : SAL_INFO("dbaccess", "ORowSetBase::getShort" );
294 0 : ::osl::MutexGuard aGuard( *m_pMutex );
295 0 : return getValue(columnIndex);
296 : }
297 :
298 0 : sal_Int32 SAL_CALL ORowSetBase::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
299 : {
300 : SAL_INFO("dbaccess", "ORowSetBase::getInt" );
301 0 : ::osl::MutexGuard aGuard( *m_pMutex );
302 0 : return getValue(columnIndex);
303 : }
304 :
305 0 : sal_Int64 SAL_CALL ORowSetBase::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
306 : {
307 : SAL_INFO("dbaccess", "ORowSetBase::getLong" );
308 0 : ::osl::MutexGuard aGuard( *m_pMutex );
309 0 : return getValue(columnIndex);
310 : }
311 :
312 0 : float SAL_CALL ORowSetBase::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
313 : {
314 : SAL_INFO("dbaccess", "ORowSetBase::getFloat" );
315 0 : ::osl::MutexGuard aGuard( *m_pMutex );
316 0 : return getValue(columnIndex);
317 : }
318 :
319 0 : double SAL_CALL ORowSetBase::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
320 : {
321 : SAL_INFO("dbaccess", "ORowSetBase::getDouble" );
322 0 : ::osl::MutexGuard aGuard( *m_pMutex );
323 0 : return getValue(columnIndex);
324 : }
325 :
326 0 : Sequence< sal_Int8 > SAL_CALL ORowSetBase::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
327 : {
328 : SAL_INFO("dbaccess", "ORowSetBase::getBytes" );
329 0 : ::osl::MutexGuard aGuard( *m_pMutex );
330 0 : return getValue(columnIndex);
331 : }
332 :
333 0 : ::com::sun::star::util::Date SAL_CALL ORowSetBase::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
334 : {
335 : SAL_INFO("dbaccess", "ORowSetBase::getDate" );
336 0 : ::osl::MutexGuard aGuard( *m_pMutex );
337 0 : return getValue(columnIndex);
338 : }
339 :
340 0 : ::com::sun::star::util::Time SAL_CALL ORowSetBase::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
341 : {
342 : SAL_INFO("dbaccess", "ORowSetBase::getTime" );
343 0 : ::osl::MutexGuard aGuard( *m_pMutex );
344 0 : return getValue(columnIndex);
345 : }
346 :
347 0 : ::com::sun::star::util::DateTime SAL_CALL ORowSetBase::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
348 : {
349 : SAL_INFO("dbaccess", "ORowSetBase::getTimestamp" );
350 0 : ::osl::MutexGuard aGuard( *m_pMutex );
351 0 : return getValue(columnIndex);
352 : }
353 :
354 0 : Reference< ::com::sun::star::io::XInputStream > SAL_CALL ORowSetBase::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
355 : {
356 : SAL_INFO("dbaccess", "ORowSetBase::getBinaryStream" );
357 0 : ::osl::MutexGuard aGuard( *m_pMutex );
358 0 : checkCache();
359 :
360 0 : if ( m_bBeforeFirst || m_bAfterLast )
361 : {
362 : SAL_WARN("dbaccess", "ORowSetBase::getBinaryStream: Illegal call here (we're before first or after last)!");
363 0 : ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_CURSOR_BEFORE_OR_AFTER ), SQL_INVALID_CURSOR_POSITION, *m_pMySelf );
364 : }
365 :
366 0 : if ( impl_rowDeleted() )
367 : {
368 0 : return NULL;
369 : }
370 :
371 0 : bool bValidCurrentRow = ( !m_aCurrentRow.isNull() && m_aCurrentRow != m_pCache->getEnd() && m_aCurrentRow->is() );
372 0 : if ( !bValidCurrentRow )
373 : {
374 0 : positionCache( MOVE_NONE_REFRESH_ONLY );
375 0 : m_aCurrentRow = m_pCache->m_aMatrixIter;
376 0 : m_bIsInsertRow = sal_False;
377 : OSL_ENSURE(!m_aCurrentRow.isNull(),"ORowSetBase::getBinaryStream: we don't stand on a valid row! Row is null.");
378 :
379 0 : bValidCurrentRow = ( !m_aCurrentRow.isNull() && m_aCurrentRow != m_pCache->getEnd() && m_aCurrentRow->is() );
380 : }
381 :
382 0 : if ( bValidCurrentRow )
383 0 : return new ::comphelper::SequenceInputStream(((*m_aCurrentRow)->get())[m_nLastColumnIndex = columnIndex].getSequence());
384 :
385 : // we should normally never reach this
386 0 : return Reference< ::com::sun::star::io::XInputStream >();
387 : }
388 :
389 0 : Reference< ::com::sun::star::io::XInputStream > SAL_CALL ORowSetBase::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
390 : {
391 : SAL_INFO("dbaccess", "ORowSetBase::getCharacterStream" );
392 0 : return getBinaryStream(columnIndex);
393 : }
394 :
395 0 : Any SAL_CALL ORowSetBase::getObject( sal_Int32 columnIndex, const Reference< XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException, std::exception)
396 : {
397 : SAL_INFO("dbaccess", "ORowSetBase::getObject" );
398 0 : ::osl::MutexGuard aGuard( *m_pMutex );
399 0 : checkCache();
400 :
401 0 : return getValue(columnIndex).makeAny();
402 : }
403 :
404 0 : Reference< XRef > SAL_CALL ORowSetBase::getRef( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
405 : {
406 : SAL_INFO("dbaccess", "ORowSetBase::getRef" );
407 0 : ::dbtools::throwFeatureNotImplementedException( "XRow::getRef", *m_pMySelf );
408 0 : return NULL;
409 : }
410 :
411 0 : Reference< XBlob > SAL_CALL ORowSetBase::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
412 : {
413 : SAL_INFO("dbaccess", "ORowSetBase::getBlob" );
414 0 : return Reference< XBlob >(getValue(columnIndex).makeAny(),UNO_QUERY);
415 : }
416 :
417 0 : Reference< XClob > SAL_CALL ORowSetBase::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
418 : {
419 : SAL_INFO("dbaccess", "ORowSetBase::getClob" );
420 0 : return Reference< XClob >(getValue(columnIndex).makeAny(),UNO_QUERY);
421 : }
422 :
423 0 : Reference< XArray > SAL_CALL ORowSetBase::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
424 : {
425 : SAL_INFO("dbaccess", "ORowSetBase::getArray" );
426 0 : ::dbtools::throwFeatureNotImplementedException( "XRow::getArray", *m_pMySelf );
427 0 : return NULL;
428 : }
429 :
430 : // ::com::sun::star::sdbcx::XRowLocate
431 0 : Any SAL_CALL ORowSetBase::getBookmark( ) throw(SQLException, RuntimeException, std::exception)
432 : {
433 : SAL_INFO("dbaccess", "ORowSetBase::getBookmark" );
434 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::getBookmark() Clone = " << m_bClone);
435 0 : ::connectivity::checkDisposed(m_rBHelper.bDisposed);
436 0 : ::osl::MutexGuard aGuard( *m_pMutex );
437 0 : checkCache();
438 :
439 0 : if ( m_bBeforeFirst || m_bAfterLast )
440 0 : ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_BOOKMARK_BEFORE_OR_AFTER ), SQL_INVALID_CURSOR_POSITION, *m_pMySelf );
441 :
442 0 : if ( impl_rowDeleted() )
443 0 : ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_BOOKMARK_DELETED ), SQL_INVALID_CURSOR_POSITION, *m_pMySelf );
444 :
445 : OSL_ENSURE( m_aBookmark.hasValue(), "ORowSetBase::getBookmark: bookmark has no value!" );
446 0 : return m_aBookmark;
447 : }
448 :
449 0 : sal_Bool SAL_CALL ORowSetBase::moveToBookmark( const Any& bookmark ) throw(SQLException, RuntimeException, std::exception)
450 : {
451 : SAL_INFO("dbaccess", "ORowSetBase::moveToBookmark" );
452 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::moveToBookmark(Any) Clone = " << m_bClone);
453 : OSL_ENSURE(bookmark.hasValue(),"ORowSetBase::moveToBookmark bookmark has no value!");
454 0 : ::osl::ResettableMutexGuard aGuard( *m_pMutex );
455 :
456 0 : if(!bookmark.hasValue() || m_nResultSetType == ResultSetType::FORWARD_ONLY)
457 : {
458 0 : if(bookmark.hasValue())
459 : SAL_WARN("dbaccess", "MoveToBookmark is not possible when we are only forward");
460 : else
461 : SAL_WARN("dbaccess", "Bookmark is not valid");
462 0 : throwFunctionSequenceException(*m_pMySelf);
463 : }
464 :
465 0 : checkCache();
466 :
467 0 : sal_Bool bRet( notifyAllListenersCursorBeforeMove( aGuard ) );
468 0 : if ( bRet )
469 : {
470 : // check if we are inserting a row
471 0 : sal_Bool bWasNew = m_pCache->m_bNew || impl_rowDeleted();
472 :
473 0 : ORowSetNotifier aNotifier( this );
474 : // this will call cancelRowModification on the cache if necessary
475 :
476 0 : ORowSetRow aOldValues = getOldRow(bWasNew);
477 :
478 0 : bRet = m_pCache->moveToBookmark(bookmark);
479 0 : doCancelModification( );
480 0 : if(bRet)
481 : {
482 : // notification order
483 : // - column values
484 : // - cursorMoved
485 0 : setCurrentRow( sal_True, sal_True, aOldValues, aGuard );
486 : }
487 : else
488 : {
489 0 : movementFailed();
490 : }
491 :
492 : // - IsModified
493 : // - IsNew
494 0 : aNotifier.fire( );
495 : }
496 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::moveToBookmark(Any) = " << bRet << " Clone = " << m_bClone);
497 0 : return bRet;
498 : }
499 :
500 0 : sal_Bool SAL_CALL ORowSetBase::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw(SQLException, RuntimeException, std::exception)
501 : {
502 : SAL_INFO("dbaccess", "ORowSetBase::moveRelativeToBookmark" );
503 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::moveRelativeToBookmark(Any," << rows << ") Clone = " << m_bClone);
504 0 : ::connectivity::checkDisposed(m_rBHelper.bDisposed);
505 :
506 0 : ::osl::ResettableMutexGuard aGuard( *m_pMutex );
507 :
508 0 : checkPositioningAllowed();
509 :
510 0 : sal_Bool bRet( notifyAllListenersCursorBeforeMove( aGuard ) );
511 0 : if ( bRet )
512 : {
513 : // check if we are inserting a row
514 0 : sal_Bool bWasNew = m_pCache->m_bNew || rowDeleted();
515 :
516 0 : ORowSetNotifier aNotifier( this );
517 : // this will call cancelRowModification on the cache if necessary
518 :
519 0 : ORowSetRow aOldValues = getOldRow(bWasNew);
520 :
521 0 : bRet = m_pCache->moveRelativeToBookmark(bookmark,rows);
522 0 : doCancelModification( );
523 0 : if(bRet)
524 : {
525 : // notification order
526 : // - column values
527 : // - cursorMoved
528 0 : setCurrentRow( sal_True, sal_True, aOldValues, aGuard );
529 : }
530 : else
531 0 : movementFailed();
532 :
533 : // - IsModified
534 : // - IsNew
535 0 : aNotifier.fire( );
536 :
537 : // RowCount/IsRowCountFinal
538 0 : fireRowcount();
539 : }
540 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::moveRelativeToBookmark(Any," << rows << ") = " << bRet << " Clone = " << m_bClone);
541 0 : return bRet;
542 : }
543 :
544 0 : sal_Int32 SAL_CALL ORowSetBase::compareBookmarks( const Any& _first, const Any& _second ) throw(SQLException, RuntimeException, std::exception)
545 : {
546 : SAL_INFO("dbaccess", "ORowSetBase::compareBookmarks" );
547 0 : ::osl::MutexGuard aGuard( *m_pMutex );
548 0 : checkCache();
549 0 : return m_pCache->compareBookmarks(_first,_second);
550 : }
551 :
552 0 : sal_Bool SAL_CALL ORowSetBase::hasOrderedBookmarks( ) throw(SQLException, RuntimeException, std::exception)
553 : {
554 : SAL_INFO("dbaccess", "ORowSetBase::hasOrderedBookmarks" );
555 0 : ::osl::MutexGuard aGuard( *m_pMutex );
556 0 : checkCache();
557 0 : return m_pCache->hasOrderedBookmarks();
558 : }
559 :
560 0 : sal_Int32 SAL_CALL ORowSetBase::hashBookmark( const Any& bookmark ) throw(SQLException, RuntimeException, std::exception)
561 : {
562 : SAL_INFO("dbaccess", "ORowSetBase::hashBookmark" );
563 0 : ::osl::MutexGuard aGuard( *m_pMutex );
564 0 : checkCache();
565 0 : return m_pCache->hashBookmark(bookmark);
566 : }
567 :
568 : // XResultSetMetaDataSupplier
569 0 : Reference< XResultSetMetaData > SAL_CALL ORowSetBase::getMetaData( ) throw(SQLException, RuntimeException, std::exception)
570 : {
571 : SAL_INFO("dbaccess", "ORowSetBase::getMetaData" );
572 0 : ::connectivity::checkDisposed(m_rBHelper.bDisposed);
573 :
574 0 : Reference< XResultSetMetaData > xMeta;
575 0 : if(m_pCache)
576 0 : xMeta = m_pCache->getMetaData();
577 :
578 0 : return xMeta;
579 : }
580 :
581 : // XColumnLocate
582 0 : sal_Int32 SAL_CALL ORowSetBase::findColumn( const OUString& columnName ) throw(SQLException, RuntimeException, std::exception)
583 : {
584 : SAL_INFO("dbaccess", "ORowSetBase::findColumn" );
585 0 : ::connectivity::checkDisposed(m_rBHelper.bDisposed);
586 :
587 0 : ::osl::MutexGuard aGuard( m_aColumnsMutex );
588 : // it is possible to save some time here when we remember the names - position relation in a map
589 0 : return m_pColumns ? m_pColumns->findColumn(columnName) : sal_Int32(0);
590 : }
591 :
592 : // ::com::sun::star::sdbcx::XColumnsSupplier
593 0 : Reference< XNameAccess > SAL_CALL ORowSetBase::getColumns( ) throw(RuntimeException, std::exception)
594 : {
595 : SAL_INFO("dbaccess", "ORowSetBase::getColumns" );
596 0 : ::connectivity::checkDisposed(m_rBHelper.bDisposed);
597 :
598 0 : ::osl::MutexGuard aGuard( m_aColumnsMutex );
599 0 : if(!m_pColumns)
600 : {
601 0 : if (!m_pEmptyCollection)
602 0 : m_pEmptyCollection = new OEmptyCollection(*m_pMySelf,m_aColumnsMutex);
603 0 : return m_pEmptyCollection;
604 : }
605 :
606 0 : return m_pColumns;
607 : }
608 :
609 : // XResultSet
610 0 : sal_Bool SAL_CALL ORowSetBase::next( ) throw(SQLException, RuntimeException, std::exception)
611 : {
612 : SAL_INFO("dbaccess", "ORowSetBase::next" );
613 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::next() Clone = " << m_bClone);
614 0 : ::osl::ResettableMutexGuard aGuard( *m_pMutex );
615 0 : checkCache();
616 :
617 0 : sal_Bool bRet( notifyAllListenersCursorBeforeMove( aGuard ) );
618 0 : if ( bRet )
619 : {
620 : // check if we are inserting a row
621 0 : sal_Bool bWasNew = m_pCache->m_bNew || impl_rowDeleted();
622 :
623 0 : ORowSetNotifier aNotifier( this );
624 : // this will call cancelRowModification on the cache if necessary
625 :
626 0 : ORowSetRow aOldValues = getOldRow(bWasNew);
627 :
628 0 : positionCache( MOVE_FORWARD );
629 0 : sal_Bool bAfterLast = m_pCache->isAfterLast();
630 0 : bRet = m_pCache->next();
631 0 : doCancelModification( );
632 :
633 0 : if ( bRet || bAfterLast != m_pCache->isAfterLast() )
634 : {
635 : // notification order
636 : // - column values
637 : // - cursorMoved
638 0 : setCurrentRow( bRet, sal_True, aOldValues, aGuard );
639 : OSL_ENSURE(!m_bBeforeFirst,"BeforeFirst is true. I don't know why?");
640 : }
641 : else
642 : {
643 : // moved after the last row
644 0 : movementFailed();
645 : OSL_ENSURE(m_bAfterLast,"AfterLast is false. I don't know why?");
646 : }
647 :
648 : // - IsModified
649 : // - IsNew
650 0 : aNotifier.fire();
651 :
652 : // - RowCount/IsRowCountFinal
653 0 : fireRowcount();
654 : }
655 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::next() = " << bRet << " Clone = " << m_bClone);
656 0 : return bRet;
657 : }
658 :
659 0 : sal_Bool SAL_CALL ORowSetBase::isBeforeFirst( ) throw(SQLException, RuntimeException, std::exception)
660 : {
661 : SAL_INFO("dbaccess", "ORowSetBase::isBeforeFirst" );
662 0 : ::connectivity::checkDisposed(m_rBHelper.bDisposed);
663 0 : ::osl::MutexGuard aGuard( *m_pMutex );
664 0 : checkCache();
665 :
666 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::isBeforeFirst() = " << m_bBeforeFirst << " Clone = " << m_bClone);
667 :
668 0 : return m_bBeforeFirst;
669 : }
670 :
671 0 : sal_Bool SAL_CALL ORowSetBase::isAfterLast( ) throw(SQLException, RuntimeException, std::exception)
672 : {
673 : SAL_INFO("dbaccess", "ORowSetBase::isAfterLast" );
674 0 : ::connectivity::checkDisposed(m_rBHelper.bDisposed);
675 0 : ::osl::MutexGuard aGuard( *m_pMutex );
676 0 : checkCache();
677 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::isAfterLast() = " << m_bAfterLast << " Clone = " << m_bClone);
678 :
679 0 : return m_bAfterLast;
680 : }
681 :
682 0 : sal_Bool ORowSetBase::isOnFirst()
683 : {
684 : SAL_INFO("dbaccess", "ORowSetBase::isOnFirst" );
685 0 : return isFirst();
686 : }
687 :
688 0 : sal_Bool SAL_CALL ORowSetBase::isFirst( ) throw(SQLException, RuntimeException, std::exception)
689 : {
690 : SAL_INFO("dbaccess", "ORowSetBase::isFirst" );
691 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::isFirst() Clone = " << m_bClone);
692 :
693 0 : ::connectivity::checkDisposed(m_rBHelper.bDisposed);
694 0 : ::osl::MutexGuard aGuard( *m_pMutex );
695 0 : checkCache();
696 :
697 0 : if ( m_bBeforeFirst || m_bAfterLast )
698 0 : return sal_False;
699 :
700 0 : if ( impl_rowDeleted() )
701 0 : return ( m_nDeletedPosition == 1 );
702 :
703 0 : sal_Bool bIsFirst = m_pCache->isFirst();
704 :
705 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::isFirst() = " << bIsFirst << " Clone = " << m_bClone);
706 0 : return bIsFirst;
707 : }
708 :
709 0 : sal_Bool ORowSetBase::isOnLast()
710 : {
711 : SAL_INFO("dbaccess", "ORowSetBase::isOnLast" );
712 0 : return isLast();
713 : }
714 :
715 0 : sal_Bool SAL_CALL ORowSetBase::isLast( ) throw(SQLException, RuntimeException, std::exception)
716 : {
717 : SAL_INFO("dbaccess", "ORowSetBase::isLast" );
718 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::isLast() Clone = " << m_bClone);
719 0 : ::connectivity::checkDisposed(m_rBHelper.bDisposed);
720 0 : ::osl::MutexGuard aGuard( *m_pMutex );
721 0 : checkCache();
722 :
723 0 : if ( m_bBeforeFirst || m_bAfterLast )
724 0 : return sal_False;
725 :
726 0 : if ( impl_rowDeleted() )
727 : {
728 0 : if ( !m_pCache->m_bRowCountFinal )
729 0 : return sal_False;
730 : else
731 0 : return ( m_nDeletedPosition == impl_getRowCount() );
732 : }
733 :
734 0 : sal_Bool bIsLast = m_pCache->isLast();
735 :
736 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::isLast() = " << bIsLast << " Clone = " << m_bClone);
737 0 : return bIsLast;
738 : }
739 :
740 0 : void SAL_CALL ORowSetBase::beforeFirst( ) throw(SQLException, RuntimeException, std::exception)
741 : {
742 : SAL_INFO("dbaccess", "ORowSetBase::beforeFirst" );
743 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::beforeFirst() Clone = " << m_bClone);
744 0 : ::connectivity::checkDisposed(m_rBHelper.bDisposed);
745 0 : ::osl::ResettableMutexGuard aGuard( *m_pMutex );
746 :
747 0 : checkPositioningAllowed();
748 :
749 : // check if we are inserting a row
750 0 : sal_Bool bWasNew = m_pCache->m_bNew || impl_rowDeleted();
751 :
752 0 : if((bWasNew || !m_bBeforeFirst) && notifyAllListenersCursorBeforeMove(aGuard) )
753 : {
754 0 : ORowSetNotifier aNotifier( this );
755 : // this will call cancelRowModification on the cache if necessary
756 :
757 0 : if ( !m_bBeforeFirst )
758 : {
759 0 : ORowSetRow aOldValues = getOldRow(bWasNew);
760 0 : m_pCache->beforeFirst();
761 0 : doCancelModification( );
762 :
763 : // notification order
764 : // - column values
765 : // - cursorMoved
766 0 : setCurrentRow( sal_True, sal_True, aOldValues, aGuard );
767 :
768 : // - IsModified
769 : // - Isnew
770 0 : aNotifier.fire();
771 :
772 : // - RowCount/IsRowCountFinal
773 0 : fireRowcount();
774 : }
775 :
776 : // to be done _after_ the notifications!
777 0 : m_aOldRow->clearRow();
778 : }
779 0 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::beforeFirst() Clone = " << m_bClone);
780 0 : }
781 :
782 0 : void SAL_CALL ORowSetBase::afterLast( ) throw(SQLException, RuntimeException, std::exception)
783 : {
784 : SAL_INFO("dbaccess", "ORowSetBase::afterLast" );
785 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::afterLast() Clone = " << m_bClone);
786 0 : ::connectivity::checkDisposed(m_rBHelper.bDisposed);
787 :
788 0 : ::osl::ResettableMutexGuard aGuard( *m_pMutex );
789 0 : checkPositioningAllowed();
790 :
791 0 : sal_Bool bWasNew = m_pCache->m_bNew || impl_rowDeleted();
792 :
793 0 : if((bWasNew || !m_bAfterLast) && notifyAllListenersCursorBeforeMove(aGuard) )
794 : {
795 : // check if we are inserting a row
796 0 : ORowSetNotifier aNotifier( this );
797 : // this will call cancelRowModification on the cache if necessary
798 :
799 0 : if(!m_bAfterLast)
800 : {
801 0 : ORowSetRow aOldValues = getOldRow(bWasNew);
802 :
803 0 : m_pCache->afterLast();
804 0 : doCancelModification( );
805 :
806 : // notification order
807 : // - column values
808 : // - cursorMoved
809 0 : setCurrentRow( sal_True, sal_True, aOldValues, aGuard );
810 :
811 : // - IsModified
812 : // - Isnew
813 0 : aNotifier.fire();
814 :
815 : // - RowCount/IsRowCountFinal
816 0 : fireRowcount();
817 0 : }
818 : }
819 0 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::afterLast() Clone = " << m_bClone);
820 0 : }
821 :
822 0 : sal_Bool SAL_CALL ORowSetBase::move( ::std::mem_fun_t<sal_Bool,ORowSetBase>& _aCheckFunctor,
823 : ::std::mem_fun_t<sal_Bool,ORowSetCache>& _aMovementFunctor)
824 : {
825 : SAL_INFO("dbaccess", "ORowSetBase::move" );
826 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::move() Clone = " << m_bClone);
827 0 : ::connectivity::checkDisposed(m_rBHelper.bDisposed);
828 0 : ::osl::ResettableMutexGuard aGuard( *m_pMutex );
829 0 : checkPositioningAllowed();
830 :
831 0 : sal_Bool bRet( notifyAllListenersCursorBeforeMove( aGuard ) );
832 0 : if( bRet )
833 : {
834 : // check if we are inserting a row
835 0 : sal_Bool bWasNew = m_pCache->m_bNew || rowDeleted();
836 :
837 0 : ORowSetNotifier aNotifier( this );
838 : // this will call cancelRowModification on the cache if necessary
839 :
840 0 : ORowSetRow aOldValues = getOldRow(bWasNew);
841 :
842 0 : sal_Bool bMoved = ( bWasNew || !_aCheckFunctor(this) );
843 :
844 0 : bRet = _aMovementFunctor(m_pCache);
845 0 : doCancelModification( );
846 :
847 0 : if ( bRet )
848 : {
849 : // notification order
850 : // - column values
851 : // - cursorMoved
852 0 : setCurrentRow( bMoved, sal_True, aOldValues, aGuard );
853 : }
854 : else
855 : { // first goes wrong so there is no row
856 0 : movementFailed();
857 : }
858 :
859 : // - IsModified
860 : // - IsNew
861 0 : aNotifier.fire();
862 :
863 : // - RowCount/IsRowCountFinal
864 0 : fireRowcount();
865 : }
866 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::move() = " << bRet << " Clone = " << m_bClone);
867 0 : return bRet;
868 : }
869 :
870 0 : sal_Bool SAL_CALL ORowSetBase::first( ) throw(SQLException, RuntimeException, std::exception)
871 : {
872 : SAL_INFO("dbaccess", "ORowSetBase::first" );
873 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::first() Clone = " << m_bClone);
874 0 : ::std::mem_fun_t<sal_Bool,ORowSetBase> ioF_tmp(&ORowSetBase::isOnFirst);
875 0 : ::std::mem_fun_t<sal_Bool,ORowSetCache> F_tmp(&ORowSetCache::first);
876 0 : return move(ioF_tmp,F_tmp);
877 : }
878 :
879 0 : sal_Bool SAL_CALL ORowSetBase::last( ) throw(SQLException, RuntimeException, std::exception)
880 : {
881 : SAL_INFO("dbaccess", "ORowSetBase::last" );
882 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::last() Clone = " << m_bClone);
883 0 : ::std::mem_fun_t<sal_Bool,ORowSetBase> ioL_tmp(&ORowSetBase::isOnLast);
884 0 : ::std::mem_fun_t<sal_Bool,ORowSetCache> L_tmp(&ORowSetCache::last);
885 0 : return move(ioL_tmp,L_tmp);
886 : }
887 :
888 0 : sal_Int32 SAL_CALL ORowSetBase::getRow( ) throw(SQLException, RuntimeException, std::exception)
889 : {
890 : SAL_INFO("dbaccess", "ORowSetBase::getRow" );
891 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::getRow() Clone = " << m_bClone);
892 0 : ::osl::MutexGuard aGuard( *m_pMutex );
893 :
894 0 : checkCache();
895 0 : return impl_getRow();
896 : }
897 :
898 0 : sal_Int32 ORowSetBase::impl_getRow()
899 : {
900 : SAL_INFO("dbaccess", "ORowSetBase::impl_getRow" );
901 0 : sal_Int32 nPos = 0;
902 0 : if ( m_bBeforeFirst )
903 0 : nPos = 0;
904 0 : else if ( m_bAfterLast )
905 0 : nPos = impl_getRowCount() + 1;
906 0 : else if ( impl_rowDeleted() )
907 0 : nPos = m_nDeletedPosition;
908 0 : else if ( !m_bClone && m_pCache->m_bNew )
909 0 : nPos = 0;
910 : else
911 : {
912 0 : if ( m_pCache->isAfterLast()
913 0 : || m_pCache->isBeforeFirst()
914 0 : || ( m_pCache->compareBookmarks( m_aBookmark, m_pCache->getBookmark() ) != CompareBookmark::EQUAL )
915 : )
916 : {
917 0 : positionCache( MOVE_NONE_REFRESH_ONLY );
918 : }
919 0 : nPos = m_pCache->getRow();
920 : }
921 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::impl_getRow() = " << nPos << " Clone = " << m_bClone);
922 0 : return nPos;
923 : }
924 :
925 0 : sal_Bool SAL_CALL ORowSetBase::absolute( sal_Int32 row ) throw(SQLException, RuntimeException, std::exception)
926 : {
927 : SAL_INFO("dbaccess", "ORowSetBase::absolute" );
928 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::absolute(" << row << ") Clone = " << m_bClone);
929 0 : ::connectivity::checkDisposed(m_rBHelper.bDisposed);
930 0 : ::osl::ResettableMutexGuard aGuard( *m_pMutex );
931 0 : checkPositioningAllowed();
932 :
933 0 : sal_Bool bRet = ( row > 0 )
934 0 : && notifyAllListenersCursorBeforeMove( aGuard );
935 0 : if ( bRet )
936 : {
937 : // check if we are inserting a row
938 0 : sal_Bool bWasNew = m_pCache->m_bNew || rowDeleted();
939 :
940 0 : ORowSetNotifier aNotifier( this );
941 : // this will call cancelRowModification on the cache if necessary
942 :
943 0 : ORowSetRow aOldValues = getOldRow(bWasNew);
944 :
945 0 : bRet = m_pCache->absolute(row);
946 0 : doCancelModification( );
947 :
948 0 : if(bRet)
949 : {
950 : // notification order
951 : // - column values
952 : // - cursorMoved
953 0 : setCurrentRow( sal_True, sal_True, aOldValues, aGuard );
954 : }
955 : else
956 : { // absolute movement goes wrong we stand left or right side of the rows
957 0 : movementFailed();
958 : }
959 :
960 : // - IsModified
961 : // - IsNew
962 0 : aNotifier.fire();
963 :
964 : // - RowCount/IsRowCountFinal
965 0 : fireRowcount();
966 : }
967 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::absolute(" << row << ") = " << bRet << " Clone = " << m_bClone);
968 0 : return bRet;
969 : }
970 :
971 0 : sal_Bool SAL_CALL ORowSetBase::relative( sal_Int32 rows ) throw(SQLException, RuntimeException, std::exception)
972 : {
973 : SAL_INFO("dbaccess", "ORowSetBase::relative" );
974 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::relative(" << rows << ") Clone = " << m_bClone);
975 0 : ::connectivity::checkDisposed(m_rBHelper.bDisposed);
976 :
977 0 : ::osl::ResettableMutexGuard aGuard( *m_pMutex );
978 :
979 0 : if(!rows)
980 0 : return sal_True; // in this case do nothing
981 :
982 0 : checkPositioningAllowed();
983 :
984 : sal_Bool bRet =
985 0 : ( ( !m_bAfterLast || rows <= 0 )
986 0 : && ( !m_bBeforeFirst || rows >= 0 )
987 0 : && notifyAllListenersCursorBeforeMove( aGuard )
988 0 : );
989 :
990 0 : if ( bRet )
991 : {
992 : // check if we are inserting a row
993 0 : sal_Bool bWasNew = m_pCache->m_bNew || rowDeleted();
994 :
995 0 : ORowSetNotifier aNotifier( this );
996 : // this will call cancelRowModification on the cache if necessary
997 :
998 0 : ORowSetRow aOldValues = getOldRow(bWasNew);
999 :
1000 0 : positionCache( rows > 0 ? MOVE_FORWARD : MOVE_BACKWARD );
1001 0 : bRet = m_pCache->relative(rows);
1002 0 : doCancelModification( );
1003 :
1004 0 : if(bRet)
1005 : {
1006 : // notification order
1007 : // - column values
1008 : // - cursorMoved
1009 0 : setCurrentRow( sal_True, sal_True, aOldValues, aGuard );
1010 : }
1011 : else
1012 : {
1013 0 : movementFailed();
1014 : }
1015 :
1016 : // - IsModified
1017 : // - IsNew
1018 0 : aNotifier.fire();
1019 :
1020 : // - RowCount/IsRowCountFinal
1021 0 : fireRowcount();
1022 : }
1023 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::relative(" << rows << ") = " << bRet << " Clone = " << m_bClone);
1024 0 : return bRet;
1025 : }
1026 :
1027 0 : sal_Bool SAL_CALL ORowSetBase::previous( ) throw(SQLException, RuntimeException, std::exception)
1028 : {
1029 : SAL_INFO("dbaccess", "ORowSetBase::previous" );
1030 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::previous() Clone = " << m_bClone);
1031 0 : ::connectivity::checkDisposed(m_rBHelper.bDisposed);
1032 0 : ::osl::ResettableMutexGuard aGuard( *m_pMutex );
1033 :
1034 0 : checkPositioningAllowed();
1035 :
1036 0 : sal_Bool bRet = !m_bBeforeFirst
1037 0 : && notifyAllListenersCursorBeforeMove(aGuard);
1038 :
1039 0 : if ( bRet )
1040 : {
1041 : // check if we are inserting a row
1042 0 : sal_Bool bWasNew = m_pCache->m_bNew || rowDeleted();
1043 :
1044 0 : ORowSetNotifier aNotifier( this );
1045 : // this will call cancelRowModification on the cache if necessary
1046 :
1047 0 : ORowSetRow aOldValues = getOldRow(bWasNew);
1048 :
1049 0 : positionCache( MOVE_BACKWARD );
1050 0 : bRet = m_pCache->previous();
1051 0 : doCancelModification( );
1052 :
1053 : // if m_bBeforeFirst is false and bRet is false than we stood on the first row
1054 0 : if(!m_bBeforeFirst || bRet)
1055 : {
1056 : // notification order
1057 : // - column values
1058 : // - cursorMoved
1059 0 : setCurrentRow( sal_True, sal_True, aOldValues, aGuard );
1060 : }
1061 : else
1062 : {
1063 : SAL_WARN("dbaccess", "ORowSetBase::previous: inconsistency!" );
1064 : // we should never reach this place, as we should not get into this whole branch if m_bBeforeFirst
1065 : // was |true| from the beginning
1066 0 : movementFailed();
1067 : }
1068 :
1069 : // - IsModified
1070 : // - IsNew
1071 0 : aNotifier.fire();
1072 :
1073 : // - RowCount/IsRowCountFinal
1074 0 : fireRowcount();
1075 : }
1076 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::previous() = " << bRet << " Clone = " << m_bClone);
1077 0 : return bRet;
1078 : }
1079 :
1080 0 : void ORowSetBase::setCurrentRow( sal_Bool _bMoved, sal_Bool _bDoNotify, const ORowSetRow& _rOldValues, ::osl::ResettableMutexGuard& _rGuard )
1081 : {
1082 : SAL_INFO("dbaccess", "ORowSetBase::setCurrentRow" );
1083 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::setCurrentRow() Clone = " << m_bClone);
1084 0 : m_bBeforeFirst = m_pCache->isBeforeFirst();
1085 0 : m_bAfterLast = m_pCache->isAfterLast();
1086 :
1087 0 : if(!(m_bBeforeFirst || m_bAfterLast))
1088 : {
1089 0 : m_aBookmark = m_pCache->getBookmark();
1090 : OSL_ENSURE(m_aBookmark.hasValue(),"Bookmark has no value!");
1091 0 : m_aCurrentRow = m_pCache->m_aMatrixIter;
1092 0 : m_bIsInsertRow = sal_False;
1093 : OSL_ENSURE(!m_aCurrentRow.isNull(),"CurrentRow is null!");
1094 0 : m_aCurrentRow.setBookmark(m_aBookmark);
1095 : OSL_ENSURE(!m_aCurrentRow.isNull() && m_aCurrentRow != m_pCache->getEnd(),"Position of matrix iterator isn't valid!");
1096 : OSL_ENSURE(m_aCurrentRow->is(),"Currentrow isn't valid");
1097 : OSL_ENSURE(m_aBookmark.hasValue(),"Bookmark has no value!");
1098 :
1099 0 : m_aCurrentRow = m_pCache->m_aMatrixIter;
1100 0 : m_bIsInsertRow = sal_False;
1101 : OSL_ENSURE(!m_aCurrentRow.isNull(),"CurrentRow is nul after positionCache!");
1102 : #if OSL_DEBUG_LEVEL > 0
1103 : ORowSetRow rRow = (*m_aCurrentRow);
1104 : OSL_ENSURE(rRow.is() ,"Invalid size of vector!");
1105 : #endif
1106 : // the cache could repositioned so we need to adjust the cache
1107 0 : if ( _bMoved && m_aCurrentRow.isNull() )
1108 : {
1109 0 : positionCache( MOVE_NONE_REFRESH_ONLY );
1110 0 : m_aCurrentRow = m_pCache->m_aMatrixIter;
1111 0 : m_bIsInsertRow = sal_False;
1112 : OSL_ENSURE(!m_aCurrentRow.isNull(),"CurrentRow is nul after positionCache!");
1113 : }
1114 : }
1115 : else
1116 : {
1117 0 : m_aOldRow->clearRow();
1118 0 : m_aCurrentRow = m_pCache->getEnd();
1119 0 : m_aBookmark = Any();
1120 0 : m_aCurrentRow.setBookmark(m_aBookmark);
1121 : }
1122 :
1123 : // notification order
1124 : // - column values
1125 0 : if ( _bDoNotify )
1126 0 : firePropertyChange(_rOldValues);
1127 :
1128 : // TODO: can this be done before the notifications?
1129 0 : if(!(m_bBeforeFirst || m_bAfterLast) && !m_aCurrentRow.isNull() && m_aCurrentRow->is() && m_aCurrentRow != m_pCache->getEnd())
1130 0 : m_aOldRow->setRow(new ORowSetValueVector( *(*m_aCurrentRow) ));
1131 :
1132 0 : if ( _bMoved && _bDoNotify )
1133 : // - cursorMoved
1134 0 : notifyAllListenersCursorMoved( _rGuard );
1135 :
1136 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::setCurrentRow() Clone = " << m_bClone);
1137 0 : }
1138 :
1139 0 : void ORowSetBase::checkPositioningAllowed() throw( SQLException, RuntimeException )
1140 : {
1141 : SAL_INFO("dbaccess", "ORowSetBase::checkPositioningAllowed" );
1142 0 : if(!m_pCache || m_nResultSetType == ResultSetType::FORWARD_ONLY)
1143 0 : throwFunctionSequenceException(*m_pMySelf);
1144 0 : }
1145 :
1146 0 : Reference< XInterface > ORowSetBase::getStatement(void) throw( SQLException, RuntimeException, std::exception )
1147 : {
1148 : SAL_INFO("dbaccess", "ORowSetBase::getStatement" );
1149 0 : return NULL;
1150 : }
1151 :
1152 0 : void SAL_CALL ORowSetBase::refreshRow( ) throw(SQLException, RuntimeException, std::exception)
1153 : {
1154 : SAL_INFO("dbaccess", "ORowSetBase::refreshRow" );
1155 0 : ::connectivity::checkDisposed(m_rBHelper.bDisposed);
1156 0 : ::osl::MutexGuard aGuard( *m_pMutex );
1157 0 : checkCache();
1158 0 : if ( impl_rowDeleted() )
1159 0 : throwSQLException( "The current row is deleted", SQL_INVALID_CURSOR_STATE, Reference< XRowSet >( this ) );
1160 :
1161 0 : if(!(m_bBeforeFirst || m_bAfterLast))
1162 : {
1163 0 : sal_Bool bWasNew = m_pCache->m_bNew || impl_rowDeleted();
1164 0 : ORowSetRow aOldValues = getOldRow(bWasNew);
1165 0 : positionCache( MOVE_NONE_REFRESH_ONLY );
1166 0 : m_pCache->refreshRow();
1167 0 : firePropertyChange(aOldValues);
1168 0 : }
1169 0 : }
1170 :
1171 0 : sal_Bool SAL_CALL ORowSetBase::rowUpdated( ) throw(SQLException, RuntimeException, std::exception)
1172 : {
1173 : SAL_INFO("dbaccess", "ORowSetBase::rowUpdated" );
1174 0 : ::osl::MutexGuard aGuard( *m_pMutex );
1175 0 : checkCache();
1176 :
1177 0 : if ( impl_rowDeleted() )
1178 0 : return sal_False;
1179 :
1180 0 : return m_pCache->rowUpdated();
1181 : }
1182 :
1183 0 : sal_Bool SAL_CALL ORowSetBase::rowInserted( ) throw(SQLException, RuntimeException, std::exception)
1184 : {
1185 : SAL_INFO("dbaccess", "ORowSetBase::rowInserted" );
1186 0 : ::osl::MutexGuard aGuard( *m_pMutex );
1187 :
1188 0 : checkCache();
1189 :
1190 0 : if ( impl_rowDeleted() )
1191 0 : return sal_False;
1192 :
1193 0 : return m_pCache->rowInserted();
1194 : }
1195 :
1196 0 : sal_Bool SAL_CALL ORowSetBase::rowDeleted( ) throw(SQLException, RuntimeException, std::exception)
1197 : {
1198 : SAL_INFO("dbaccess", "ORowSetBase::rowDeleted" );
1199 0 : ::osl::MutexGuard aGuard( *m_pMutex );
1200 0 : checkCache();
1201 0 : return impl_rowDeleted();
1202 : }
1203 :
1204 0 : sal_Bool ORowSetBase::impl_rowDeleted( )
1205 : {
1206 0 : return !m_aBookmark.hasValue() && !m_bBeforeFirst && !m_bAfterLast;
1207 : }
1208 :
1209 : // XWarningsSupplier
1210 0 : Any SAL_CALL ORowSetBase::getWarnings( ) throw(SQLException, RuntimeException, std::exception)
1211 : {
1212 : SAL_INFO("dbaccess", "ORowSetBase::getWarnings" );
1213 0 : ::osl::MutexGuard aGuard( *m_pMutex );
1214 :
1215 0 : if ( m_pCache )
1216 : {
1217 0 : Reference< XWarningsSupplier > xWarnings( m_pCache->m_xSet.get(), UNO_QUERY );
1218 0 : if ( xWarnings.is() )
1219 0 : return xWarnings->getWarnings();
1220 : }
1221 :
1222 0 : return Any();
1223 : }
1224 :
1225 0 : void SAL_CALL ORowSetBase::clearWarnings( ) throw(SQLException, RuntimeException, std::exception)
1226 : {
1227 : SAL_INFO("dbaccess", "ORowSetBase::clearWarnings" );
1228 0 : ::osl::MutexGuard aGuard( *m_pMutex );
1229 :
1230 0 : if ( m_pCache )
1231 : {
1232 0 : Reference< XWarningsSupplier > xWarnings( m_pCache->m_xSet.get(), UNO_QUERY );
1233 0 : if ( xWarnings.is() )
1234 0 : xWarnings->clearWarnings();
1235 0 : }
1236 0 : }
1237 :
1238 0 : void ORowSetBase::firePropertyChange(const ORowSetRow& _rOldRow)
1239 : {
1240 0 : if (!isPropertyChangeNotificationEnabled())
1241 0 : return;
1242 :
1243 : SAL_INFO("dbaccess", "ORowSetBase::firePropertyChange" );
1244 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::firePropertyChange() Clone = " << m_bClone);
1245 : OSL_ENSURE(m_pColumns,"Columns can not be NULL here!");
1246 0 : sal_Int32 i=0;
1247 : try
1248 : {
1249 0 : TDataColumns::iterator aEnd = m_aDataColumns.end();
1250 0 : for(TDataColumns::iterator aIter = m_aDataColumns.begin();aIter != aEnd;++aIter,++i)
1251 0 : (*aIter)->fireValueChange(_rOldRow.is() ? (_rOldRow->get())[i+1] : ::connectivity::ORowSetValue());
1252 : }
1253 0 : catch (const Exception&)
1254 : {
1255 : SAL_WARN("dbaccess", "firePropertyChange: Exception");
1256 : }
1257 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::firePropertyChange() Clone = " << m_bClone);
1258 : }
1259 :
1260 0 : void ORowSetBase::firePropertyChange(sal_Int32 _nPos,const ::connectivity::ORowSetValue& _rOldValue)
1261 : {
1262 : OSL_ENSURE(_nPos < (sal_Int32)m_aDataColumns.size(),"nPos is invalid!");
1263 0 : m_aDataColumns[_nPos]->fireValueChange(_rOldValue);
1264 0 : }
1265 :
1266 0 : void ORowSetBase::fireRowcount()
1267 : {
1268 : SAL_INFO("dbaccess", "ORowSetBase::fireRowcount" );
1269 0 : }
1270 :
1271 0 : sal_Bool ORowSetBase::notifyAllListenersCursorBeforeMove(::osl::ResettableMutexGuard& /*_rGuard*/)
1272 : {
1273 : SAL_INFO("dbaccess", "ORowSetBase::notifyAllListenersCursorBeforeMove" );
1274 0 : return sal_True;
1275 : }
1276 :
1277 0 : void ORowSetBase::notifyAllListenersCursorMoved(::osl::ResettableMutexGuard& /*_rGuard*/)
1278 : {
1279 : SAL_INFO("dbaccess", "ORowSetBase::notifyAllListenersCursorMoved" );
1280 0 : }
1281 :
1282 0 : void ORowSetBase::notifyAllListeners(::osl::ResettableMutexGuard& /*_rGuard*/)
1283 : {
1284 : SAL_INFO("dbaccess", "ORowSetBase::notifyAllListeners" );
1285 0 : }
1286 :
1287 0 : sal_Bool ORowSetBase::isPropertyChangeNotificationEnabled() const
1288 : {
1289 0 : return sal_True;
1290 : }
1291 :
1292 0 : void ORowSetBase::fireProperty( sal_Int32 _nProperty, sal_Bool _bNew, sal_Bool _bOld )
1293 : {
1294 : SAL_INFO("dbaccess", "ORowSetBase::fireProperty" );
1295 0 : Any aNew = css::uno::makeAny( _bNew );
1296 0 : Any aOld = css::uno::makeAny( _bOld );
1297 0 : fire( &_nProperty, &aNew, &aOld, 1, sal_False );
1298 0 : }
1299 :
1300 0 : void ORowSetBase::positionCache( CursorMoveDirection _ePrepareForDirection )
1301 : {
1302 : SAL_INFO("dbaccess", "ORowSetBase::positionCache" );
1303 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::positionCache() Clone = " << m_bClone);
1304 :
1305 0 : sal_Bool bSuccess = sal_False;
1306 0 : if ( m_aBookmark.hasValue() )
1307 : {
1308 0 : if ( _ePrepareForDirection == MOVE_NONE_REFRESH_ONLY ||
1309 0 : m_pCache->compareBookmarks( m_aBookmark, m_pCache->getBookmark() ) != CompareBookmark::EQUAL )
1310 0 : bSuccess = m_pCache->moveToBookmark( m_aBookmark );
1311 : else
1312 0 : bSuccess = sal_True;
1313 : }
1314 : else
1315 : {
1316 0 : if ( m_bBeforeFirst )
1317 : {
1318 0 : bSuccess = m_pCache->beforeFirst();
1319 : }
1320 0 : else if ( m_bAfterLast )
1321 : {
1322 0 : bSuccess = m_pCache->afterLast();
1323 : }
1324 : else
1325 : {
1326 : OSL_ENSURE( m_nDeletedPosition >= 1, "ORowSetBase::positionCache: no bookmark, and no valid 'deleted position'!" );
1327 0 : switch ( _ePrepareForDirection )
1328 : {
1329 : case MOVE_FORWARD:
1330 0 : if ( m_nDeletedPosition > 1 )
1331 0 : bSuccess = m_pCache->absolute( m_nDeletedPosition - 1 );
1332 : else
1333 : {
1334 0 : m_pCache->beforeFirst();
1335 0 : bSuccess = sal_True;
1336 : }
1337 0 : break;
1338 :
1339 : case MOVE_BACKWARD:
1340 0 : if ( m_pCache->m_bRowCountFinal && ( m_nDeletedPosition == impl_getRowCount() ) )
1341 : {
1342 0 : m_pCache->afterLast();
1343 0 : bSuccess = sal_True;
1344 : }
1345 : else
1346 0 : bSuccess = m_pCache->absolute( m_nDeletedPosition );
1347 0 : break;
1348 :
1349 : case MOVE_NONE_REFRESH_ONLY:
1350 0 : bSuccess = sal_False; // will be asserted below
1351 0 : break;
1352 : }
1353 : }
1354 : }
1355 : OSL_ENSURE( bSuccess, "ORowSetBase::positionCache: failed!" );
1356 : (void)bSuccess;
1357 :
1358 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::positionCache() Clone = " << m_bClone);
1359 0 : }
1360 :
1361 0 : void ORowSetBase::checkCache()
1362 : {
1363 : SAL_INFO("dbaccess", "ORowSetBase::checkCache" );
1364 0 : ::connectivity::checkDisposed(m_rBHelper.bDisposed);
1365 0 : if(!m_pCache)
1366 0 : throwFunctionSequenceException(*m_pMySelf);
1367 0 : }
1368 :
1369 0 : void ORowSetBase::movementFailed()
1370 : {
1371 : SAL_INFO("dbaccess", "ORowSetBase::movementFailed" );
1372 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::movementFailed() Clone = " << m_bClone);
1373 0 : m_aOldRow->clearRow();
1374 0 : m_aCurrentRow = m_pCache->getEnd();
1375 0 : m_bBeforeFirst = m_pCache->isBeforeFirst();
1376 0 : m_bAfterLast = m_pCache->isAfterLast();
1377 0 : m_aBookmark = Any();
1378 0 : m_aCurrentRow.setBookmark(m_aBookmark);
1379 : OSL_ENSURE(m_bBeforeFirst || m_bAfterLast,"BeforeFirst or AfterLast is wrong!");
1380 : SAL_INFO("dbaccess", "DBACCESS ORowSetBase::movementFailed() Clone = " << m_bClone);
1381 0 : }
1382 :
1383 0 : ORowSetRow ORowSetBase::getOldRow(sal_Bool _bWasNew)
1384 : {
1385 : SAL_INFO("dbaccess", "ORowSetBase::getOldRow" );
1386 : OSL_ENSURE(m_aOldRow.is(),"RowSetRowHElper isn't valid!");
1387 0 : ORowSetRow aOldValues;
1388 0 : if ( !_bWasNew && m_aOldRow->getRow().is() )
1389 0 : aOldValues = new ORowSetValueVector( *(m_aOldRow->getRow())); // remember the old values
1390 0 : return aOldValues;
1391 : }
1392 :
1393 0 : void ORowSetBase::getPropertyDefaultByHandle( sal_Int32 /*_nHandle*/, Any& _rDefault ) const
1394 : {
1395 : SAL_INFO("dbaccess", "ORowSetBase::getPropertyDefaultByHandle" );
1396 0 : _rDefault.clear();
1397 0 : }
1398 :
1399 0 : void ORowSetBase::onDeleteRow( const Any& _rBookmark )
1400 : {
1401 : SAL_INFO("dbaccess", "ORowSetBase::onDeleteRow" );
1402 0 : if ( rowDeleted() )
1403 : // not interested in
1404 0 : return;
1405 :
1406 0 : ::osl::MutexGuard aGuard( *m_pMutex );
1407 : //OSL_ENSURE( m_aBookmark.hasValue(), "ORowSetBase::onDeleteRow: Bookmark isn't valid!" );
1408 0 : if ( compareBookmarks( _rBookmark, m_aBookmark ) == 0 )
1409 : {
1410 0 : positionCache( MOVE_NONE_REFRESH_ONLY );
1411 0 : m_nDeletedPosition = m_pCache->getRow();
1412 0 : }
1413 : }
1414 :
1415 0 : void ORowSetBase::onDeletedRow( const Any& _rBookmark, sal_Int32 _nPos )
1416 : {
1417 : SAL_INFO("dbaccess", "ORowSetBase::onDeletedRow" );
1418 0 : if ( rowDeleted() )
1419 : {
1420 : // if we're a clone, and on a deleted row, and the main RowSet deleted another
1421 : // row (only the main RowSet can, clones can't), which is *before* our
1422 : // deleted position, then we have to adjust this position
1423 0 : if ( m_bClone && ( _nPos < m_nDeletedPosition ) )
1424 0 : --m_nDeletedPosition;
1425 0 : return;
1426 : }
1427 :
1428 0 : ::osl::MutexGuard aGuard( *m_pMutex );
1429 0 : if ( compareBookmarks( _rBookmark, m_aBookmark ) == 0 )
1430 : {
1431 0 : m_aOldRow->clearRow();
1432 0 : m_aCurrentRow = m_pCache->getEnd();
1433 0 : m_aBookmark = Any();
1434 0 : m_aCurrentRow.setBookmark( m_aBookmark );
1435 0 : }
1436 : }
1437 :
1438 0 : sal_Int32 ORowSetBase::impl_getRowCount() const
1439 : {
1440 : SAL_INFO("dbaccess", "ORowSetBase::impl_getRowCount" );
1441 0 : sal_Int32 nRowCount( m_pCache->m_nRowCount );
1442 0 : if ( const_cast< ORowSetBase* >( this )->rowDeleted() && !m_pCache->m_bNew )
1443 0 : ++nRowCount;
1444 0 : return nRowCount;
1445 : }
1446 :
1447 0 : struct ORowSetNotifierImpl
1448 : {
1449 : ::std::vector<sal_Int32> aChangedColumns;
1450 : ::std::vector<Any> aChangedBookmarks;
1451 : ORowSetValueVector::Vector aRow;
1452 :
1453 : };
1454 :
1455 :
1456 0 : ORowSetNotifier::ORowSetNotifier( ORowSetBase* _pRowSet )
1457 : :m_pRowSet( _pRowSet )
1458 : ,m_bWasNew( sal_False )
1459 0 : ,m_bWasModified( sal_False )
1460 : #ifdef DBG_UTIL
1461 : ,m_bNotifyCalled( sal_False )
1462 : #endif
1463 : {
1464 :
1465 : OSL_ENSURE( m_pRowSet, "ORowSetNotifier::ORowSetNotifier: invalid row set. This wil crash." );
1466 :
1467 : // remember the "inserted" and "modified" state for later firing
1468 0 : m_bWasNew = m_pRowSet->isNew( ORowSetBase::GrantNotifierAccess() );
1469 0 : m_bWasModified = m_pRowSet->isModified( ORowSetBase::GrantNotifierAccess() );
1470 :
1471 : // if the row set is on the insert row, then we need to cancel this
1472 0 : if ( m_pRowSet->isModification( ORowSetBase::GrantNotifierAccess() ) )
1473 0 : m_pRowSet->doCancelModification( ORowSetBase::GrantNotifierAccess() );
1474 0 : }
1475 :
1476 0 : ORowSetNotifier::ORowSetNotifier( ORowSetBase* _pRowSet,const ORowSetValueVector::Vector& i_aRow )
1477 0 : :m_pImpl(new ORowSetNotifierImpl)
1478 : ,m_pRowSet( _pRowSet )
1479 : ,m_bWasNew( sal_False )
1480 0 : ,m_bWasModified( sal_False )
1481 : #ifdef DBG_UTIL
1482 : ,m_bNotifyCalled( sal_False )
1483 : #endif
1484 : {
1485 :
1486 : OSL_ENSURE( m_pRowSet, "ORowSetNotifier::ORowSetNotifier: invalid row set. This wil crash." );
1487 0 : m_pImpl->aRow = i_aRow; // yes, create a copy to store the old values
1488 0 : }
1489 :
1490 0 : ORowSetNotifier::~ORowSetNotifier( )
1491 : {
1492 : SAL_INFO("dbaccess", "ORowSetNotifier::~ORowSetNotifier" );
1493 0 : }
1494 :
1495 0 : void ORowSetNotifier::fire()
1496 : {
1497 : // we're not interested in firing changes FALSE->TRUE, only TRUE->FALSE.
1498 : // (the former would be quite pathological, e.g. after a failed movement)
1499 :
1500 0 : if ( m_bWasModified
1501 0 : && ( m_bWasModified != m_pRowSet->isModified( ORowSetBase::GrantNotifierAccess() ) )
1502 : )
1503 0 : m_pRowSet->fireProperty( PROPERTY_ID_ISMODIFIED, sal_False, sal_True, ORowSetBase::GrantNotifierAccess() );
1504 :
1505 0 : if ( m_bWasNew
1506 0 : && ( m_bWasNew != m_pRowSet->isNew( ORowSetBase::GrantNotifierAccess() ) )
1507 : )
1508 0 : m_pRowSet->fireProperty( PROPERTY_ID_ISNEW, sal_False, sal_True, ORowSetBase::GrantNotifierAccess() );
1509 :
1510 : #ifdef DBG_UTIL
1511 : m_bNotifyCalled = sal_True;
1512 : #endif
1513 0 : }
1514 :
1515 0 : ::std::vector<sal_Int32>& ORowSetNotifier::getChangedColumns() const
1516 : {
1517 : OSL_ENSURE(m_pImpl.get(),"Illegal CTor call, use the other one!");
1518 0 : return m_pImpl->aChangedColumns;
1519 : }
1520 :
1521 0 : void ORowSetNotifier::firePropertyChange()
1522 : {
1523 : OSL_ENSURE(m_pImpl.get(),"Illegal CTor call, use the other one!");
1524 0 : if( m_pImpl.get() )
1525 : {
1526 0 : ::std::vector<sal_Int32>::iterator aIter = m_pImpl->aChangedColumns.begin();
1527 0 : for(;aIter != m_pImpl->aChangedColumns.end();++aIter)
1528 : {
1529 0 : m_pRowSet->firePropertyChange((*aIter)-1 ,m_pImpl->aRow[(*aIter)-1], ORowSetBase::GrantNotifierAccess());
1530 : }
1531 0 : if ( !m_pImpl->aChangedColumns.empty() )
1532 0 : m_pRowSet->fireProperty(PROPERTY_ID_ISMODIFIED,sal_True,sal_False, ORowSetBase::GrantNotifierAccess());
1533 : }
1534 0 : }
1535 :
1536 : } // namespace dbaccess
1537 :
1538 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|