merge the formfield patch from ooo-build
[ooovba.git] / dbaccess / source / core / api / RowSetBase.cxx
blobbbd2e825a84af90fcabd7c78a01ac120366d175e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: RowSetBase.cxx,v $
10 * $Revision: 1.95 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
33 #ifndef DBACCESS_CORE_API_ROWSETBASE_HXX
34 #include "RowSetBase.hxx"
35 #endif
36 #ifndef DBACCESS_CORE_API_CROWSETDATACOLUMN_HXX
37 #include "CRowSetDataColumn.hxx"
38 #endif
39 #ifndef _CONNECTIVITY_SDBCX_COLLECTION_HXX_
40 #include <connectivity/sdbcx/VCollection.hxx>
41 #endif
42 #ifndef DBACCESS_CORE_API_ROWSETCACHE_HXX
43 #include "RowSetCache.hxx"
44 #endif
45 #ifndef DBACCESS_SHARED_DBASTRINGS_HRC
46 #include "dbastrings.hrc"
47 #endif
48 #ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
49 #include <com/sun/star/lang/DisposedException.hpp>
50 #endif
51 #ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
52 #include <com/sun/star/beans/PropertyAttribute.hpp>
53 #endif
54 #ifndef _COM_SUN_STAR_SDBCX_COMPAREBOOKMARK_HPP_
55 #include <com/sun/star/sdbcx/CompareBookmark.hpp>
56 #endif
57 #ifndef _COM_SUN_STAR_SDBC_RESULTSETCONCURRENCY_HPP_
58 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
59 #endif
60 #ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_
61 #include <com/sun/star/lang/Locale.hpp>
62 #endif
63 #ifndef _COM_SUN_STAR_UTIL_NUMBERFORMAT_HPP_
64 #include <com/sun/star/util/NumberFormat.hpp>
65 #endif
66 #ifndef _COMPHELPER_SEQUENCE_HXX_
67 #include <comphelper/sequence.hxx>
68 #endif
69 #ifndef _COMPHELPER_EXTRACT_HXX_
70 #include <comphelper/extract.hxx>
71 #endif
72 #ifndef _COMPHELPER_SEQSTREAM_HXX
73 #include <comphelper/seqstream.hxx>
74 #endif
75 #ifndef _DBHELPER_DBEXCEPTION_HXX_
76 #include <connectivity/dbexception.hxx>
77 #endif
78 #ifndef _OSL_THREAD_H_
79 #include <osl/thread.h>
80 #endif
81 #ifndef _TOOLS_DEBUG_HXX
82 #include <tools/debug.hxx>
83 #endif
84 #include <rtl/logfile.hxx>
86 using namespace dbaccess;
87 using namespace connectivity;
88 using namespace connectivity::sdbcx;
89 using namespace comphelper;
90 using namespace dbtools;
91 using namespace ::com::sun::star::uno;
92 using namespace ::com::sun::star::beans;
93 using namespace ::com::sun::star::sdbc;
94 using namespace ::com::sun::star::sdb;
95 using namespace ::com::sun::star::sdbcx;
96 using namespace ::com::sun::star::container;
97 using namespace ::com::sun::star::lang;
98 using namespace ::com::sun::star::util;
99 using namespace ::cppu;
100 using namespace ::osl;
102 namespace dbaccess
105 // =========================================================================
106 // = OEmptyCollection
107 // =========================================================================
108 // -------------------------------------------------------------------------
109 class OEmptyCollection : public sdbcx::OCollection
111 protected:
112 virtual void impl_refresh() throw(RuntimeException);
113 virtual connectivity::sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
114 public:
115 OEmptyCollection(::cppu::OWeakObject& _rParent,::osl::Mutex& _rMutex) : OCollection(_rParent,sal_True,_rMutex,::std::vector< ::rtl::OUString>()){}
117 // -----------------------------------------------------------------------------
118 void OEmptyCollection::impl_refresh() throw(RuntimeException)
121 // -----------------------------------------------------------------------------
122 connectivity::sdbcx::ObjectType OEmptyCollection::createObject(const ::rtl::OUString& /*_rName*/)
124 return connectivity::sdbcx::ObjectType();
126 // -----------------------------------------------------------------------------
128 // =========================================================================
129 // = ORowSetBase
130 // =========================================================================
131 DBG_NAME(ORowSetBase)
132 // -------------------------------------------------------------------------
133 ORowSetBase::ORowSetBase( const ::comphelper::ComponentContext& _rContext, ::cppu::OBroadcastHelper& _rBHelper, ::osl::Mutex* _pMutex )
134 :OPropertyStateContainer(_rBHelper)
135 ,m_pMutex(_pMutex)
136 ,m_pCache(NULL)
137 ,m_pColumns(NULL)
138 ,m_rBHelper(_rBHelper)
139 ,m_pEmptyCollection( NULL )
140 ,m_aContext( _rContext )
141 ,m_aErrors( _rContext )
142 ,m_nLastColumnIndex(-1)
143 ,m_nDeletedPosition(-1)
144 ,m_nResultSetType( ResultSetType::FORWARD_ONLY )
145 ,m_nResultSetConcurrency( ResultSetConcurrency::READ_ONLY )
146 ,m_bClone(sal_False)
147 ,m_bIgnoreResult(sal_False)
148 ,m_bBeforeFirst(sal_True) // changed from sal_False
149 ,m_bAfterLast(sal_False)
151 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::ORowSetBase" );
152 DBG_CTOR(ORowSetBase,NULL);
154 sal_Int32 nRBT = PropertyAttribute::READONLY | PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT;
156 sal_Int32 nInitialRowCountValue = 0;
157 sal_Bool bInitialRowCountFinalValue( sal_False );
158 registerPropertyNoMember( PROPERTY_ROWCOUNT, PROPERTY_ID_ROWCOUNT, nRBT, ::getCppuType( &nInitialRowCountValue ), &nInitialRowCountValue );
159 registerPropertyNoMember( PROPERTY_ISROWCOUNTFINAL, PROPERTY_ID_ISROWCOUNTFINAL, nRBT, ::getBooleanCppuType(), &bInitialRowCountFinalValue );
161 // -----------------------------------------------------------------------------
162 ORowSetBase::~ORowSetBase()
164 if(m_pColumns)
166 TDataColumns().swap(m_aDataColumns);
167 m_pColumns->acquire();
168 m_pColumns->disposing();
169 delete m_pColumns;
170 m_pColumns = NULL;
173 if ( m_pEmptyCollection )
174 delete m_pEmptyCollection;
176 DBG_DTOR(ORowSetBase,NULL);
178 // com::sun::star::lang::XTypeProvider
179 //--------------------------------------------------------------------------
180 Sequence< Type > ORowSetBase::getTypes() throw (RuntimeException)
182 //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getTypes" );
183 return ::comphelper::concatSequences(ORowSetBase_BASE::getTypes(),OPropertyStateContainer::getTypes());
185 // com::sun::star::uno::XInterface
186 //--------------------------------------------------------------------------
187 Any ORowSetBase::queryInterface( const Type & rType ) throw (RuntimeException)
189 //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::queryInterface" );
190 Any aRet = ORowSetBase_BASE::queryInterface(rType);
191 if(!aRet.hasValue())
192 aRet = OPropertyStateContainer::queryInterface(rType);
193 return aRet;
195 // -------------------------------------------------------------------------
196 void SAL_CALL ORowSetBase::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const
198 //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getFastPropertyValue" );
199 if(m_pCache)
201 switch(nHandle)
203 case PROPERTY_ID_ROWCOUNT:
204 rValue <<= impl_getRowCount();
205 break;
206 case PROPERTY_ID_ISROWCOUNTFINAL:
207 rValue.setValue(&m_pCache->m_bRowCountFinal,::getCppuBooleanType());
208 break;
209 default:
210 OPropertyStateContainer::getFastPropertyValue(rValue,nHandle);
213 else
214 OPropertyStateContainer::getFastPropertyValue(rValue,nHandle);
216 // -------------------------------------------------------------------------
217 // OComponentHelper
218 void SAL_CALL ORowSetBase::disposing(void)
220 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::disposing" );
221 MutexGuard aGuard(*m_pMutex);
223 if ( m_pColumns )
225 TDataColumns().swap(m_aDataColumns);
226 m_pColumns->disposing();
228 if ( m_pCache )
230 m_pCache->deregisterOldRow(m_aOldRow);
231 m_pCache->deleteIterator(this);
233 m_pCache = NULL;
235 // -------------------------------------------------------------------------
236 // comphelper::OPropertyArrayUsageHelper
237 ::cppu::IPropertyArrayHelper* ORowSetBase::createArrayHelper( ) const
239 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::createArrayHelper" );
240 Sequence< Property > aProps;
241 describeProperties(aProps);
242 return new ::cppu::OPropertyArrayHelper(aProps);
244 // -------------------------------------------------------------------------
245 // cppu::OPropertySetHelper
246 ::cppu::IPropertyArrayHelper& SAL_CALL ORowSetBase::getInfoHelper()
248 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getInfoHelper" );
249 return *const_cast<ORowSetBase*>(this)->getArrayHelper();
251 // -------------------------------------------------------------------------
252 // XRow
253 sal_Bool SAL_CALL ORowSetBase::wasNull( ) throw(SQLException, RuntimeException)
255 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::wasNull" );
256 ::osl::MutexGuard aGuard( *m_pMutex );
257 checkCache();
258 return impl_wasNull();
260 // -----------------------------------------------------------------------------
261 sal_Bool ORowSetBase::impl_wasNull()
263 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::impl_wasNull" );
264 return ((m_nLastColumnIndex != -1) && !m_aCurrentRow.isNull() && m_aCurrentRow != m_pCache->getEnd() && m_aCurrentRow->isValid()) ? ((*m_aCurrentRow)->get())[m_nLastColumnIndex].isNull() : sal_True;
267 // -----------------------------------------------------------------------------
268 const ORowSetValue& ORowSetBase::getValue(sal_Int32 columnIndex)
270 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getValue" );
271 checkCache();
272 return impl_getValue(columnIndex);
274 // -----------------------------------------------------------------------------
275 const ORowSetValue& ORowSetBase::impl_getValue(sal_Int32 columnIndex)
277 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::impl_getValue" );
278 if ( m_bBeforeFirst || m_bAfterLast )
280 OSL_ENSURE(0,"ORowSetBase::getValue: Illegal call here (we're before first or after last)!");
281 throwSQLException( "The cursor points to before the first or after the last row.", SQL_INVALID_CURSOR_POSITION, *m_pMySelf );
282 // TODO: resource
285 if ( impl_rowDeleted() )
287 return m_aEmptyValue;
290 bool bValidCurrentRow = ( !m_aCurrentRow.isNull() && m_aCurrentRow != m_pCache->getEnd() && m_aCurrentRow->isValid() );
291 if ( !bValidCurrentRow )
293 // currentrow is null when the clone moves the window
294 positionCache( MOVE_NONE_REFRESH_ONLY );
295 m_aCurrentRow = m_pCache->m_aMatrixIter;
296 OSL_ENSURE(!m_aCurrentRow.isNull(),"ORowSetBase::getValue: we don't stand on a valid row! Row is null.");
298 bValidCurrentRow = ( !m_aCurrentRow.isNull() && m_aCurrentRow != m_pCache->getEnd() && m_aCurrentRow->isValid() );
301 if ( bValidCurrentRow )
303 #if OSL_DEBUG_LEVEL > 0
304 ORowSetMatrix::iterator aCacheEnd;
305 ORowSetMatrix::iterator aCurrentRow;
306 aCacheEnd = m_pCache->getEnd();
307 aCurrentRow = m_aCurrentRow;
308 ORowSetCacheMap::iterator aCacheIter = m_aCurrentRow.getIter();
309 sal_Int32 n = aCacheIter->first;
310 n = n;
311 ORowSetCacheIterator_Helper aHelper = aCacheIter->second;
312 ORowSetMatrix::iterator k = aHelper.aIterator;
313 for (; k != m_pCache->getEnd(); ++k)
315 ORowSetValueVector* pTemp = k->getBodyPtr();
316 OSL_ENSURE( pTemp != (void*)0xfeeefeee,"HALT!" );
318 #endif
319 OSL_ENSURE(!m_aCurrentRow.isNull() && m_aCurrentRow < m_pCache->getEnd() && aCacheIter != m_pCache->m_aCacheIterators.end(),"Invalid iterator set for currentrow!");
320 #if OSL_DEBUG_LEVEL > 0
321 ORowSetRow rRow = (*m_aCurrentRow);
322 OSL_ENSURE(rRow.isValid() && static_cast<sal_uInt16>(columnIndex) < (rRow->get()).size(),"Invalid size of vector!");
323 #endif
324 return ((*m_aCurrentRow)->get())[m_nLastColumnIndex = columnIndex];
327 // we should normally never reach this
328 return m_aEmptyValue;
330 // -------------------------------------------------------------------------
331 ::rtl::OUString SAL_CALL ORowSetBase::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
333 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getString" );
334 ::osl::MutexGuard aGuard( *m_pMutex );
335 return getValue(columnIndex);
337 // -------------------------------------------------------------------------
338 sal_Bool SAL_CALL ORowSetBase::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
340 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getBoolean" );
341 ::osl::MutexGuard aGuard( *m_pMutex );
342 return getValue(columnIndex);
344 // -------------------------------------------------------------------------
345 sal_Int8 SAL_CALL ORowSetBase::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
347 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getByte" );
348 ::osl::MutexGuard aGuard( *m_pMutex );
349 return getValue(columnIndex);
351 // -------------------------------------------------------------------------
352 sal_Int16 SAL_CALL ORowSetBase::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
354 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getShort" );
355 ::osl::MutexGuard aGuard( *m_pMutex );
356 return getValue(columnIndex);
358 // -------------------------------------------------------------------------
359 sal_Int32 SAL_CALL ORowSetBase::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
361 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getInt" );
362 ::osl::MutexGuard aGuard( *m_pMutex );
363 return getValue(columnIndex);
365 // -------------------------------------------------------------------------
366 sal_Int64 SAL_CALL ORowSetBase::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
368 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getLong" );
369 ::osl::MutexGuard aGuard( *m_pMutex );
370 return getValue(columnIndex);
372 // -------------------------------------------------------------------------
373 float SAL_CALL ORowSetBase::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
375 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getFloat" );
376 ::osl::MutexGuard aGuard( *m_pMutex );
377 return getValue(columnIndex);
379 // -------------------------------------------------------------------------
380 double SAL_CALL ORowSetBase::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
382 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getDouble" );
383 ::osl::MutexGuard aGuard( *m_pMutex );
384 return getValue(columnIndex);
386 // -------------------------------------------------------------------------
387 Sequence< sal_Int8 > SAL_CALL ORowSetBase::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
389 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getBytes" );
390 ::osl::MutexGuard aGuard( *m_pMutex );
391 return getValue(columnIndex);
393 // -------------------------------------------------------------------------
394 ::com::sun::star::util::Date SAL_CALL ORowSetBase::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
396 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getDate" );
397 ::osl::MutexGuard aGuard( *m_pMutex );
398 return getValue(columnIndex);
400 // -------------------------------------------------------------------------
401 ::com::sun::star::util::Time SAL_CALL ORowSetBase::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
403 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getTime" );
404 ::osl::MutexGuard aGuard( *m_pMutex );
405 return getValue(columnIndex);
407 // -------------------------------------------------------------------------
408 ::com::sun::star::util::DateTime SAL_CALL ORowSetBase::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
410 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getTimestamp" );
411 ::osl::MutexGuard aGuard( *m_pMutex );
412 return getValue(columnIndex);
414 // -------------------------------------------------------------------------
415 Reference< ::com::sun::star::io::XInputStream > SAL_CALL ORowSetBase::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
417 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getBinaryStream" );
418 ::osl::MutexGuard aGuard( *m_pMutex );
419 checkCache();
421 if ( m_bBeforeFirst || m_bAfterLast )
423 OSL_ENSURE(0,"ORowSetBase::getBinaryStream: Illegal call here (we're before first or after last)!");
424 throwSQLException( "The cursor points to before the first or after the last row.", SQL_INVALID_CURSOR_POSITION, *m_pMySelf );
425 // TODO: resource
428 if ( impl_rowDeleted() )
430 return NULL;
433 bool bValidCurrentRow = ( !m_aCurrentRow.isNull() && m_aCurrentRow != m_pCache->getEnd() && m_aCurrentRow->isValid() );
434 if ( !bValidCurrentRow )
436 positionCache( MOVE_NONE_REFRESH_ONLY );
437 m_aCurrentRow = m_pCache->m_aMatrixIter;
438 OSL_ENSURE(!m_aCurrentRow.isNull(),"ORowSetBase::getBinaryStream: we don't stand on a valid row! Row is null.");
440 bValidCurrentRow = ( !m_aCurrentRow.isNull() && m_aCurrentRow != m_pCache->getEnd() && m_aCurrentRow->isValid() );
443 if ( bValidCurrentRow )
444 return new ::comphelper::SequenceInputStream(((*m_aCurrentRow)->get())[m_nLastColumnIndex = columnIndex].getSequence());
446 // we should normally never reach this
447 return Reference< ::com::sun::star::io::XInputStream >();
449 // -------------------------------------------------------------------------
450 Reference< ::com::sun::star::io::XInputStream > SAL_CALL ORowSetBase::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
452 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getCharacterStream" );
453 return getBinaryStream(columnIndex);
455 // -------------------------------------------------------------------------
456 Any SAL_CALL ORowSetBase::getObject( sal_Int32 columnIndex, const Reference< XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
458 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getObject" );
459 ::osl::MutexGuard aGuard( *m_pMutex );
460 checkCache();
462 return getValue(columnIndex).makeAny();
464 // -------------------------------------------------------------------------
465 Reference< XRef > SAL_CALL ORowSetBase::getRef( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
467 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getRef" );
468 ::dbtools::throwFeatureNotImplementedException( "XRow::getRef", *m_pMySelf );
469 return NULL;
471 // -------------------------------------------------------------------------
472 Reference< XBlob > SAL_CALL ORowSetBase::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
474 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getBlob" );
475 ::dbtools::throwFeatureNotImplementedException( "XRow::getBlob", *m_pMySelf );
476 return NULL;
478 // -------------------------------------------------------------------------
479 Reference< XClob > SAL_CALL ORowSetBase::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
481 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getClob" );
482 ::dbtools::throwFeatureNotImplementedException( "XRow::getClob", *m_pMySelf );
483 return NULL;
485 // -------------------------------------------------------------------------
486 Reference< XArray > SAL_CALL ORowSetBase::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
488 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getArray" );
489 ::dbtools::throwFeatureNotImplementedException( "XRow::getArray", *m_pMySelf );
490 return NULL;
492 // -------------------------------------------------------------------------
493 // ::com::sun::star::sdbcx::XRowLocate
494 Any SAL_CALL ORowSetBase::getBookmark( ) throw(SQLException, RuntimeException)
496 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getBookmark" );
497 DBG_TRACE2("DBACCESS ORowSetBase::getBookmark() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
498 ::connectivity::checkDisposed(m_rBHelper.bDisposed);
499 ::osl::MutexGuard aGuard( *m_pMutex );
500 checkCache();
502 if ( m_bBeforeFirst || m_bAfterLast )
503 throwSQLException( "The rows before the first and after the last row don't have a bookmark.", SQL_INVALID_CURSOR_POSITION, *m_pMySelf );
504 // TODO: resource
506 if ( impl_rowDeleted() )
507 throwSQLException( "The current row is deleted, and thus doesn't have a bookmark.", SQL_INVALID_CURSOR_POSITION, *m_pMySelf );
508 // TODO: resource
510 OSL_ENSURE( m_aBookmark.hasValue(), "ORowSetBase::getBookmark: bookmark has no value!" );
511 return m_aBookmark;
513 // -------------------------------------------------------------------------
514 sal_Bool SAL_CALL ORowSetBase::moveToBookmark( const Any& bookmark ) throw(SQLException, RuntimeException)
516 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::moveToBookmark" );
517 DBG_TRACE2("DBACCESS ORowSetBase::moveToBookmark(Any) Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
518 OSL_ENSURE(bookmark.hasValue(),"ORowSetBase::moveToBookmark bookmark has no value!");
519 ::osl::ResettableMutexGuard aGuard( *m_pMutex );
521 if(!bookmark.hasValue() || m_nResultSetType == ResultSetType::FORWARD_ONLY)
523 if(bookmark.hasValue())
524 OSL_ENSURE(0,"MoveToBookmark is not possible when we are only forward");
525 else
526 OSL_ENSURE(0,"Bookmark is not valid");
527 throwFunctionSequenceException(*m_pMySelf);
531 checkCache();
533 sal_Bool bRet( notifyAllListenersCursorBeforeMove( aGuard ) );
534 if ( bRet )
536 // check if we are inserting a row
537 sal_Bool bWasNew = m_pCache->m_bNew || impl_rowDeleted();
539 ORowSetNotifier aNotifier( this );
540 // this will call cancelRowModification on the cache if necessary
542 ORowSetRow aOldValues = getOldRow(bWasNew);
544 bRet = m_pCache->moveToBookmark(bookmark);
545 doCancelModification( );
546 if(bRet)
548 // notification order
549 // - column values
550 // - cursorMoved
551 setCurrentRow( sal_True, sal_True, aOldValues, aGuard );
553 else
555 movementFailed();
558 // - IsModified
559 // - IsNew
560 aNotifier.fire( );
562 DBG_TRACE2("DBACCESS ORowSetBase::moveToBookmark(Any) = %i Clone = %i\n",bRet,m_bClone);
563 return bRet;
565 // -------------------------------------------------------------------------
566 sal_Bool SAL_CALL ORowSetBase::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw(SQLException, RuntimeException)
568 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::moveRelativeToBookmark" );
569 DBG_TRACE2("DBACCESS ORowSetBase::moveRelativeToBookmark(Any,%i) Clone = %i\n",rows,m_bClone);
570 ::connectivity::checkDisposed(m_rBHelper.bDisposed);
572 ::osl::ResettableMutexGuard aGuard( *m_pMutex );
574 checkPositioningAllowed();
576 sal_Bool bRet( notifyAllListenersCursorBeforeMove( aGuard ) );
577 if ( bRet )
579 // check if we are inserting a row
580 sal_Bool bWasNew = m_pCache->m_bNew || rowDeleted();
582 ORowSetNotifier aNotifier( this );
583 // this will call cancelRowModification on the cache if necessary
585 ORowSetRow aOldValues = getOldRow(bWasNew);
587 bRet = m_pCache->moveRelativeToBookmark(bookmark,rows);
588 doCancelModification( );
589 if(bRet)
591 // notification order
592 // - column values
593 // - cursorMoved
594 setCurrentRow( sal_True, sal_True, aOldValues, aGuard );
596 else
597 movementFailed();
599 // - IsModified
600 // - IsNew
601 aNotifier.fire( );
603 // RowCount/IsRowCountFinal
604 fireRowcount();
606 DBG_TRACE3("DBACCESS ORowSetBase::moveRelativeToBookmark(Any,%i) = %i Clone = %i\n",rows,bRet,m_bClone);
607 return bRet;
609 // -------------------------------------------------------------------------
610 sal_Int32 SAL_CALL ORowSetBase::compareBookmarks( const Any& _first, const Any& _second ) throw(SQLException, RuntimeException)
612 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::compareBookmarks" );
613 ::osl::MutexGuard aGuard( *m_pMutex );
614 checkCache();
615 return m_pCache->compareBookmarks(_first,_second);
617 // -------------------------------------------------------------------------
618 sal_Bool SAL_CALL ORowSetBase::hasOrderedBookmarks( ) throw(SQLException, RuntimeException)
620 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::hasOrderedBookmarks" );
621 ::osl::MutexGuard aGuard( *m_pMutex );
622 checkCache();
623 return m_pCache->hasOrderedBookmarks();
625 // -------------------------------------------------------------------------
626 sal_Int32 SAL_CALL ORowSetBase::hashBookmark( const Any& bookmark ) throw(SQLException, RuntimeException)
628 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::hashBookmark" );
629 ::osl::MutexGuard aGuard( *m_pMutex );
630 checkCache();
631 return m_pCache->hashBookmark(bookmark);
633 // -------------------------------------------------------------------------
634 // -------------------------------------------------------------------------
635 // XResultSetMetaDataSupplier
636 Reference< XResultSetMetaData > SAL_CALL ORowSetBase::getMetaData( ) throw(SQLException, RuntimeException)
638 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getMetaData" );
639 ::connectivity::checkDisposed(m_rBHelper.bDisposed);
641 Reference< XResultSetMetaData > xMeta;
642 if(m_pCache)
643 xMeta = m_pCache->getMetaData();
645 return xMeta;
647 // -------------------------------------------------------------------------
649 // XColumnLocate
650 sal_Int32 SAL_CALL ORowSetBase::findColumn( const ::rtl::OUString& columnName ) throw(SQLException, RuntimeException)
652 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::findColumn" );
653 ::connectivity::checkDisposed(m_rBHelper.bDisposed);
655 ::osl::MutexGuard aGuard( m_aColumnsMutex );
656 // it is possible to save some time her when we remember the names - position relation in a map
657 return m_pColumns ? m_pColumns->findColumn(columnName) : sal_Int32(0);
659 // -------------------------------------------------------------------------
661 // ::com::sun::star::sdbcx::XColumnsSupplier
662 Reference< XNameAccess > SAL_CALL ORowSetBase::getColumns( ) throw(RuntimeException)
664 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getColumns" );
665 ::connectivity::checkDisposed(m_rBHelper.bDisposed);
667 ::osl::MutexGuard aGuard( m_aColumnsMutex );
668 if(!m_pColumns)
670 if (!m_pEmptyCollection)
671 m_pEmptyCollection = new OEmptyCollection(*m_pMySelf,m_aColumnsMutex);
672 return m_pEmptyCollection;
675 return m_pColumns;
677 // -------------------------------------------------------------------------
678 // XResultSet
679 sal_Bool SAL_CALL ORowSetBase::next( ) throw(SQLException, RuntimeException)
681 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::next" );
682 DBG_TRACE2("DBACCESS ORowSetBase::next() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
683 ::osl::ResettableMutexGuard aGuard( *m_pMutex );
684 checkCache();
686 sal_Bool bRet( notifyAllListenersCursorBeforeMove( aGuard ) );
687 if ( bRet )
689 // check if we are inserting a row
690 sal_Bool bWasNew = m_pCache->m_bNew || impl_rowDeleted();
692 ORowSetNotifier aNotifier( this );
693 // this will call cancelRowModification on the cache if necessary
695 ORowSetRow aOldValues = getOldRow(bWasNew);
697 positionCache( MOVE_FORWARD );
698 sal_Bool bAfterLast = m_pCache->isAfterLast();
699 bRet = m_pCache->next();
700 doCancelModification( );
703 if ( bRet || bAfterLast != m_pCache->isAfterLast() )
705 // notification order
706 // - column values
707 // - cursorMoved
708 setCurrentRow( bRet, sal_True, aOldValues, aGuard );
709 OSL_ENSURE(!m_bBeforeFirst,"BeforeFirst is true. I don't know why?");
711 else
713 // moved after the last row
714 movementFailed();
715 OSL_ENSURE(m_bAfterLast,"AfterLast is false. I don't know why?");
718 // - IsModified
719 // - IsNew
720 aNotifier.fire();
722 // - RowCount/IsRowCountFinal
723 fireRowcount();
725 DBG_TRACE3("DBACCESS ORowSetBase::next() = %i Clone = %i ID = %i\n",bRet,m_bClone,osl_getThreadIdentifier(NULL));
726 return bRet;
728 // -------------------------------------------------------------------------
729 sal_Bool SAL_CALL ORowSetBase::isBeforeFirst( ) throw(SQLException, RuntimeException)
731 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::isBeforeFirst" );
732 ::connectivity::checkDisposed(m_rBHelper.bDisposed);
733 ::osl::MutexGuard aGuard( *m_pMutex );
734 checkCache();
736 DBG_TRACE2("DBACCESS ORowSetBase::isBeforeFirst() = %i Clone = %i\n",m_bBeforeFirst,m_bClone);
738 return m_bBeforeFirst;
740 // -------------------------------------------------------------------------
741 sal_Bool SAL_CALL ORowSetBase::isAfterLast( ) throw(SQLException, RuntimeException)
743 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::isAfterLast" );
744 ::connectivity::checkDisposed(m_rBHelper.bDisposed);
745 ::osl::MutexGuard aGuard( *m_pMutex );
746 checkCache();
747 DBG_TRACE2("DBACCESS ORowSetBase::isAfterLast() = %i Clone = %i\n",m_bAfterLast,m_bClone);
749 return m_bAfterLast;
751 // -------------------------------------------------------------------------
752 sal_Bool ORowSetBase::isOnFirst()
754 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::isOnFirst" );
755 return isFirst();
757 // -------------------------------------------------------------------------
758 sal_Bool SAL_CALL ORowSetBase::isFirst( ) throw(SQLException, RuntimeException)
760 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::isFirst" );
761 DBG_TRACE2("DBACCESS ORowSetBase::isFirst() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
763 ::connectivity::checkDisposed(m_rBHelper.bDisposed);
764 ::osl::MutexGuard aGuard( *m_pMutex );
765 checkCache();
767 if ( m_bBeforeFirst || m_bAfterLast )
768 return sal_False;
770 if ( impl_rowDeleted() )
771 return ( m_nDeletedPosition == 1 );
773 positionCache( MOVE_NONE_REFRESH_ONLY );
774 sal_Bool bIsFirst = m_pCache->isFirst();
776 DBG_TRACE2("DBACCESS ORowSetBase::isFirst() = %i Clone = %i\n",bIsFirst,m_bClone);
777 return bIsFirst;
779 // -------------------------------------------------------------------------
780 sal_Bool ORowSetBase::isOnLast()
782 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::isOnLast" );
783 return isLast();
785 // -----------------------------------------------------------------------------
786 sal_Bool SAL_CALL ORowSetBase::isLast( ) throw(SQLException, RuntimeException)
788 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::isLast" );
789 DBG_TRACE2("DBACCESS ORowSetBase::isLast() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
790 ::connectivity::checkDisposed(m_rBHelper.bDisposed);
791 ::osl::MutexGuard aGuard( *m_pMutex );
792 checkCache();
794 if ( m_bBeforeFirst || m_bAfterLast )
795 return sal_False;
797 if ( impl_rowDeleted() )
799 if ( !m_pCache->m_bRowCountFinal )
800 return sal_False;
801 else
802 return ( m_nDeletedPosition == impl_getRowCount() );
805 positionCache( MOVE_NONE_REFRESH_ONLY );
806 sal_Bool bIsLast = m_pCache->isLast();
808 DBG_TRACE2("DBACCESS ORowSetBase::isLast() = %i Clone = %i\n",bIsLast,m_bClone);
809 return bIsLast;
811 // -------------------------------------------------------------------------
812 void SAL_CALL ORowSetBase::beforeFirst( ) throw(SQLException, RuntimeException)
814 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::beforeFirst" );
815 DBG_TRACE2("DBACCESS ORowSetBase::beforeFirst() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
816 ::connectivity::checkDisposed(m_rBHelper.bDisposed);
817 ::osl::ResettableMutexGuard aGuard( *m_pMutex );
819 checkPositioningAllowed();
821 // check if we are inserting a row
822 sal_Bool bWasNew = m_pCache->m_bNew || impl_rowDeleted();
824 if((bWasNew || !m_bBeforeFirst) && notifyAllListenersCursorBeforeMove(aGuard) )
826 ORowSetNotifier aNotifier( this );
827 // this will call cancelRowModification on the cache if necessary
829 if ( !m_bBeforeFirst )
831 ORowSetRow aOldValues = getOldRow(bWasNew);
832 m_pCache->beforeFirst();
833 doCancelModification( );
835 // notification order
836 // - column values
837 // - cursorMoved
838 setCurrentRow( sal_True, sal_True, aOldValues, aGuard );
840 // - IsModified
841 // - Isnew
842 aNotifier.fire();
844 // - RowCount/IsRowCountFinal
845 fireRowcount();
848 // to be done _after_ the notifications!
849 m_aOldRow->clearRow();
851 DBG_TRACE2("DBACCESS ORowSetBase::beforeFirst() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
853 // -------------------------------------------------------------------------
854 void SAL_CALL ORowSetBase::afterLast( ) throw(SQLException, RuntimeException)
856 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::afterLast" );
857 DBG_TRACE2("DBACCESS ORowSetBase::afterLast() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
858 ::connectivity::checkDisposed(m_rBHelper.bDisposed);
860 ::osl::ResettableMutexGuard aGuard( *m_pMutex );
861 checkPositioningAllowed();
863 sal_Bool bWasNew = m_pCache->m_bNew || impl_rowDeleted();
865 if((bWasNew || !m_bAfterLast) && notifyAllListenersCursorBeforeMove(aGuard) )
867 // check if we are inserting a row
868 ORowSetNotifier aNotifier( this );
869 // this will call cancelRowModification on the cache if necessary
871 if(!m_bAfterLast)
873 ORowSetRow aOldValues = getOldRow(bWasNew);
875 m_pCache->afterLast();
876 doCancelModification( );
878 // notification order
879 // - column values
880 // - cursorMoved
881 setCurrentRow( sal_True, sal_True, aOldValues, aGuard );
883 // - IsModified
884 // - Isnew
885 aNotifier.fire();
887 // - RowCount/IsRowCountFinal
888 fireRowcount();
891 DBG_TRACE2("DBACCESS ORowSetBase::afterLast() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
893 // -----------------------------------------------------------------------------
894 sal_Bool SAL_CALL ORowSetBase::move( ::std::mem_fun_t<sal_Bool,ORowSetBase>& _aCheckFunctor,
895 ::std::mem_fun_t<sal_Bool,ORowSetCache>& _aMovementFunctor)
897 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::move" );
898 DBG_TRACE2("DBACCESS ORowSetBase::move() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
899 ::connectivity::checkDisposed(m_rBHelper.bDisposed);
900 ::osl::ResettableMutexGuard aGuard( *m_pMutex );
901 checkPositioningAllowed();
903 sal_Bool bRet( notifyAllListenersCursorBeforeMove( aGuard ) );
904 if( bRet )
906 // check if we are inserting a row
907 sal_Bool bWasNew = m_pCache->m_bNew || rowDeleted();
909 ORowSetNotifier aNotifier( this );
910 // this will call cancelRowModification on the cache if necessary
912 ORowSetRow aOldValues = getOldRow(bWasNew);
914 sal_Bool bMoved = ( bWasNew || !_aCheckFunctor(this) );
916 bRet = _aMovementFunctor(m_pCache);
917 doCancelModification( );
919 if ( bRet )
921 // notification order
922 // - column values
923 // - cursorMoved
924 setCurrentRow( bMoved, sal_True, aOldValues, aGuard );
926 else
927 { // first goes wrong so there is no row
928 movementFailed();
931 // - IsModified
932 // - IsNew
933 aNotifier.fire();
935 // - RowCount/IsRowCountFinal
936 fireRowcount();
938 DBG_TRACE2("DBACCESS ORowSetBase::move() = %i Clone = %i\n",bRet,m_bClone);
939 return bRet;
941 // -------------------------------------------------------------------------
942 sal_Bool SAL_CALL ORowSetBase::first( ) throw(SQLException, RuntimeException)
944 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::first" );
945 DBG_TRACE2("DBACCESS ORowSetBase::first() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
946 ::std::mem_fun_t<sal_Bool,ORowSetBase> ioF_tmp(&ORowSetBase::isOnFirst);
947 ::std::mem_fun_t<sal_Bool,ORowSetCache> F_tmp(&ORowSetCache::first);
948 return move(ioF_tmp,F_tmp);
950 // -------------------------------------------------------------------------
951 sal_Bool SAL_CALL ORowSetBase::last( ) throw(SQLException, RuntimeException)
953 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::last" );
954 DBG_TRACE2("DBACCESS ORowSetBase::last() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
955 ::std::mem_fun_t<sal_Bool,ORowSetBase> ioL_tmp(&ORowSetBase::isOnLast);
956 ::std::mem_fun_t<sal_Bool,ORowSetCache> L_tmp(&ORowSetCache::last);
957 return move(ioL_tmp,L_tmp);
959 // -------------------------------------------------------------------------
960 sal_Int32 SAL_CALL ORowSetBase::getRow( ) throw(SQLException, RuntimeException)
962 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getRow" );
963 DBG_TRACE2("DBACCESS ORowSetBase::getRow() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
964 ::osl::MutexGuard aGuard( *m_pMutex );
966 checkCache();
967 return impl_getRow();
969 // -------------------------------------------------------------------------
970 sal_Int32 ORowSetBase::impl_getRow()
972 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::impl_getRow" );
973 sal_Int32 nPos = 0;
974 if ( m_bBeforeFirst )
975 nPos = 0;
976 else if ( m_bAfterLast )
977 nPos = impl_getRowCount() + 1;
978 else if ( impl_rowDeleted() )
979 nPos = m_nDeletedPosition;
980 else if ( !m_bClone && m_pCache->m_bNew )
981 nPos = 0;
982 else
984 if ( m_pCache->isAfterLast()
985 || m_pCache->isBeforeFirst()
986 || ( m_pCache->compareBookmarks( m_aBookmark, m_pCache->getBookmark() ) != CompareBookmark::EQUAL )
989 positionCache( MOVE_NONE_REFRESH_ONLY );
991 nPos = m_pCache->getRow();
993 DBG_TRACE3("DBACCESS ORowSetBase::impl_getRow() = %i Clone = %i ID = %i\n",nPos,m_bClone,osl_getThreadIdentifier(NULL));
994 return nPos;
996 // -------------------------------------------------------------------------
997 sal_Bool SAL_CALL ORowSetBase::absolute( sal_Int32 row ) throw(SQLException, RuntimeException)
999 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::absolute" );
1000 DBG_TRACE2("DBACCESS ORowSetBase::absolute(%i) Clone = %i\n",row,m_bClone);
1001 ::connectivity::checkDisposed(m_rBHelper.bDisposed);
1002 ::osl::ResettableMutexGuard aGuard( *m_pMutex );
1003 checkPositioningAllowed();
1005 sal_Bool bRet = ( row > 0 )
1006 && notifyAllListenersCursorBeforeMove( aGuard );
1007 if ( bRet )
1009 // check if we are inserting a row
1010 sal_Bool bWasNew = m_pCache->m_bNew || rowDeleted();
1012 ORowSetNotifier aNotifier( this );
1013 // this will call cancelRowModification on the cache if necessary
1015 ORowSetRow aOldValues = getOldRow(bWasNew);
1017 bRet = m_pCache->absolute(row);
1018 doCancelModification( );
1020 if(bRet)
1022 // notification order
1023 // - column values
1024 // - cursorMoved
1025 setCurrentRow( sal_True, sal_True, aOldValues, aGuard );
1027 else
1028 { // absolute movement goes wrong we stand left or right side of the rows
1029 movementFailed();
1032 // - IsModified
1033 // - IsNew
1034 aNotifier.fire();
1036 // - RowCount/IsRowCountFinal
1037 fireRowcount();
1039 DBG_TRACE3("DBACCESS ORowSetBase::absolute(%i) = %i Clone = %i\n",row,bRet,m_bClone);
1040 return bRet;
1042 // -------------------------------------------------------------------------
1043 sal_Bool SAL_CALL ORowSetBase::relative( sal_Int32 rows ) throw(SQLException, RuntimeException)
1045 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::relative" );
1046 DBG_TRACE2("DBACCESS ORowSetBase::relative(%i) Clone = %i\n",rows,m_bClone);
1047 ::connectivity::checkDisposed(m_rBHelper.bDisposed);
1049 ::osl::ResettableMutexGuard aGuard( *m_pMutex );
1051 if(!rows)
1052 return sal_True; // in this case do nothing
1054 checkPositioningAllowed();
1056 sal_Bool bRet =
1057 ( ( !m_bAfterLast || rows <= 0 )
1058 && ( !m_bBeforeFirst || rows >= 0 )
1059 && notifyAllListenersCursorBeforeMove( aGuard )
1062 if ( bRet )
1064 // check if we are inserting a row
1065 sal_Bool bWasNew = m_pCache->m_bNew || rowDeleted();
1067 ORowSetNotifier aNotifier( this );
1068 // this will call cancelRowModification on the cache if necessary
1070 ORowSetRow aOldValues = getOldRow(bWasNew);
1072 positionCache( rows > 0 ? MOVE_FORWARD : MOVE_BACKWARD );
1073 bRet = m_pCache->relative(rows);
1074 doCancelModification( );
1076 if(bRet)
1078 // notification order
1079 // - column values
1080 // - cursorMoved
1081 setCurrentRow( sal_True, sal_True, aOldValues, aGuard );
1083 else
1085 movementFailed();
1088 // - IsModified
1089 // - IsNew
1090 aNotifier.fire();
1092 // - RowCount/IsRowCountFinal
1093 fireRowcount();
1095 DBG_TRACE3("DBACCESS ORowSetBase::relative(%i) = %i Clone = %i\n",rows,bRet,m_bClone);
1096 return bRet;
1098 // -------------------------------------------------------------------------
1099 sal_Bool SAL_CALL ORowSetBase::previous( ) throw(SQLException, RuntimeException)
1101 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::previous" );
1102 DBG_TRACE2("DBACCESS ORowSetBase::previous() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
1103 ::connectivity::checkDisposed(m_rBHelper.bDisposed);
1104 ::osl::ResettableMutexGuard aGuard( *m_pMutex );
1106 checkPositioningAllowed();
1108 sal_Bool bRet = !m_bBeforeFirst
1109 && notifyAllListenersCursorBeforeMove(aGuard);
1111 if ( bRet )
1113 // check if we are inserting a row
1114 sal_Bool bWasNew = m_pCache->m_bNew || rowDeleted();
1116 ORowSetNotifier aNotifier( this );
1117 // this will call cancelRowModification on the cache if necessary
1119 ORowSetRow aOldValues = getOldRow(bWasNew);
1121 positionCache( MOVE_BACKWARD );
1122 bRet = m_pCache->previous();
1123 doCancelModification( );
1125 // if m_bBeforeFirst is false and bRet is false than we stood on the first row
1126 if(!m_bBeforeFirst || bRet)
1128 // notification order
1129 // - column values
1130 // - cursorMoved
1131 setCurrentRow( sal_True, sal_True, aOldValues, aGuard );
1133 else
1135 DBG_ERROR( "ORowSetBase::previous: inconsistency!" );
1136 // we should never reach this place, as we should not get into this whole branch if m_bBeforeFirst
1137 // was |true| from the beginning
1138 movementFailed();
1141 // - IsModified
1142 // - IsNew
1143 aNotifier.fire();
1145 // - RowCount/IsRowCountFinal
1146 fireRowcount();
1148 DBG_TRACE2("DBACCESS ORowSetBase::previous() = %i Clone = %i\n",bRet,m_bClone);
1149 return bRet;
1151 // -----------------------------------------------------------------------------
1152 void ORowSetBase::setCurrentRow( sal_Bool _bMoved, sal_Bool _bDoNotify, const ORowSetRow& _rOldValues, ::osl::ResettableMutexGuard& _rGuard )
1154 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::setCurrentRow" );
1155 DBG_TRACE2("DBACCESS ORowSetBase::setCurrentRow() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
1156 m_bBeforeFirst = m_pCache->isBeforeFirst();
1157 m_bAfterLast = m_pCache->isAfterLast();
1158 //m_pCache->resetInsertRow(sal_True);
1160 if(!(m_bBeforeFirst || m_bAfterLast))
1162 m_aBookmark = m_pCache->getBookmark();
1163 OSL_ENSURE(m_aBookmark.hasValue(),"Bookmark has no value!");
1164 m_aCurrentRow = m_pCache->m_aMatrixIter;
1165 OSL_ENSURE(!m_aCurrentRow.isNull(),"CurrentRow is null!");
1166 m_aCurrentRow.setBookmark(m_aBookmark);
1167 OSL_ENSURE(!m_aCurrentRow.isNull() && m_aCurrentRow != m_pCache->getEnd(),"Position of matrix iterator isn't valid!");
1168 OSL_ENSURE(m_aCurrentRow->isValid(),"Currentrow isn't valid");
1169 OSL_ENSURE(m_aBookmark.hasValue(),"Bookmark has no value!");
1171 #if OSL_DEBUG_LEVEL > 0
1172 sal_Int32 nOldRow = m_pCache->getRow();
1173 #endif
1174 positionCache( MOVE_NONE_REFRESH_ONLY );
1175 #if OSL_DEBUG_LEVEL > 0
1176 sal_Int32 nNewRow = m_pCache->getRow();
1177 #endif
1178 OSL_ENSURE(nOldRow == nNewRow,"Old position is not equal to new postion");
1179 m_aCurrentRow = m_pCache->m_aMatrixIter;
1180 OSL_ENSURE(!m_aCurrentRow.isNull(),"CurrentRow is nul after positionCache!");
1181 #if OSL_DEBUG_LEVEL > 0
1182 ORowSetRow rRow = (*m_aCurrentRow);
1183 OSL_ENSURE(rRow.isValid() ,"Invalid size of vector!");
1184 #endif
1185 // the cache could repositioned so we need to adjust the cache
1186 // #104144# OJ
1187 if ( _bMoved && m_aCurrentRow.isNull() )
1189 positionCache( MOVE_NONE_REFRESH_ONLY );
1190 m_aCurrentRow = m_pCache->m_aMatrixIter;
1191 OSL_ENSURE(!m_aCurrentRow.isNull(),"CurrentRow is nul after positionCache!");
1194 else
1196 m_aOldRow->clearRow();
1197 m_aCurrentRow = m_pCache->getEnd();
1198 m_aBookmark = Any();
1199 m_aCurrentRow.setBookmark(m_aBookmark);
1202 // notification order
1203 // - column values
1204 if ( _bDoNotify )
1205 firePropertyChange(_rOldValues);
1207 // TODO: can this be done before the notifications?
1208 if(!(m_bBeforeFirst || m_bAfterLast) && !m_aCurrentRow.isNull() && m_aCurrentRow->isValid() && m_aCurrentRow != m_pCache->getEnd())
1209 m_aOldRow->setRow(new ORowSetValueVector(m_aCurrentRow->getBody()));
1211 if ( _bMoved && _bDoNotify )
1212 // - cursorMoved
1213 notifyAllListenersCursorMoved( _rGuard );
1215 DBG_TRACE2("DBACCESS ORowSetBase::setCurrentRow() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
1217 // -----------------------------------------------------------------------------
1218 void ORowSetBase::checkPositioningAllowed() throw( SQLException, RuntimeException )
1220 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::checkPositioningAllowed" );
1221 if(!m_pCache || m_nResultSetType == ResultSetType::FORWARD_ONLY)
1222 throwFunctionSequenceException(*m_pMySelf);
1224 //------------------------------------------------------------------------------
1225 Reference< XInterface > ORowSetBase::getStatement(void) throw( SQLException, RuntimeException )
1227 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getStatement" );
1228 return NULL;
1230 // -------------------------------------------------------------------------
1231 void SAL_CALL ORowSetBase::refreshRow( ) throw(SQLException, RuntimeException)
1233 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::refreshRow" );
1234 ::connectivity::checkDisposed(m_rBHelper.bDisposed);
1235 ::osl::MutexGuard aGuard( *m_pMutex );
1236 checkCache();
1237 if ( impl_rowDeleted() )
1238 throwSQLException( "The current row is deleted", SQL_INVALID_CURSOR_STATE, Reference< XRowSet >( this ) );
1240 if(!(m_bBeforeFirst || m_bAfterLast))
1242 positionCache( MOVE_NONE_REFRESH_ONLY );
1243 m_pCache->refreshRow();
1246 // -------------------------------------------------------------------------
1247 sal_Bool SAL_CALL ORowSetBase::rowUpdated( ) throw(SQLException, RuntimeException)
1249 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::rowUpdated" );
1250 ::osl::MutexGuard aGuard( *m_pMutex );
1251 checkCache();
1253 if ( impl_rowDeleted() )
1254 return sal_False;
1256 return m_pCache->rowUpdated();
1258 // -------------------------------------------------------------------------
1259 sal_Bool SAL_CALL ORowSetBase::rowInserted( ) throw(SQLException, RuntimeException)
1261 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::rowInserted" );
1262 ::osl::MutexGuard aGuard( *m_pMutex );
1264 checkCache();
1266 if ( impl_rowDeleted() )
1267 return sal_False;
1269 return m_pCache->rowInserted();
1271 // -------------------------------------------------------------------------
1272 sal_Bool SAL_CALL ORowSetBase::rowDeleted( ) throw(SQLException, RuntimeException)
1274 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::rowDeleted" );
1275 ::osl::MutexGuard aGuard( *m_pMutex );
1276 checkCache();
1277 return impl_rowDeleted();
1279 // -------------------------------------------------------------------------
1280 sal_Bool ORowSetBase::impl_rowDeleted( )
1282 return !m_aBookmark.hasValue() && !m_bBeforeFirst && !m_bAfterLast;
1284 // -------------------------------------------------------------------------
1285 // XWarningsSupplier
1286 Any SAL_CALL ORowSetBase::getWarnings( ) throw(SQLException, RuntimeException)
1288 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getWarnings" );
1289 ::osl::MutexGuard aGuard( *m_pMutex );
1291 if ( m_pCache )
1293 Reference< XWarningsSupplier > xWarnings( m_pCache->m_xSet.get(), UNO_QUERY );
1294 if ( xWarnings.is() )
1295 return xWarnings->getWarnings();
1298 return Any();
1300 // -------------------------------------------------------------------------
1301 void SAL_CALL ORowSetBase::clearWarnings( ) throw(SQLException, RuntimeException)
1303 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::clearWarnings" );
1304 ::osl::MutexGuard aGuard( *m_pMutex );
1306 if ( m_pCache )
1308 Reference< XWarningsSupplier > xWarnings( m_pCache->m_xSet.get(), UNO_QUERY );
1309 if ( xWarnings.is() )
1310 xWarnings->clearWarnings();
1313 // -------------------------------------------------------------------------
1314 void ORowSetBase::firePropertyChange(const ORowSetRow& _rOldRow)
1316 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::firePropertyChange" );
1317 DBG_TRACE2("DBACCESS ORowSetBase::firePropertyChange() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
1318 OSL_ENSURE(m_pColumns,"Columns can not be NULL here!");
1319 #if OSL_DEBUG_LEVEL > 1
1320 sal_Bool bNull;
1321 ORowSetMatrix::iterator atest;
1322 bNull = m_aCurrentRow.isNull();
1323 atest = m_aCurrentRow;
1324 #endif
1325 sal_Int32 i=0;
1328 TDataColumns::iterator aEnd = m_aDataColumns.end();
1329 for(TDataColumns::iterator aIter = m_aDataColumns.begin();aIter != aEnd;++aIter,++i) // #104278# OJ ++i inserted
1330 (*aIter)->fireValueChange(_rOldRow.isValid() ? (_rOldRow->get())[i+1] : ::connectivity::ORowSetValue());
1332 catch(Exception&)
1334 OSL_ENSURE(0,"firePropertyChange: Exception");
1336 DBG_TRACE2("DBACCESS ORowSetBase::firePropertyChange() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
1339 // -----------------------------------------------------------------------------
1340 void ORowSetBase::fireRowcount()
1342 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::fireRowcount" );
1345 // -----------------------------------------------------------------------------
1346 sal_Bool ORowSetBase::notifyAllListenersCursorBeforeMove(::osl::ResettableMutexGuard& /*_rGuard*/)
1348 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::notifyAllListenersCursorBeforeMove" );
1349 return sal_True;
1352 // -----------------------------------------------------------------------------
1353 void ORowSetBase::notifyAllListenersCursorMoved(::osl::ResettableMutexGuard& /*_rGuard*/)
1355 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::notifyAllListenersCursorMoved" );
1358 // -----------------------------------------------------------------------------
1359 void ORowSetBase::notifyAllListeners(::osl::ResettableMutexGuard& /*_rGuard*/)
1361 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::notifyAllListeners" );
1364 // -----------------------------------------------------------------------------
1365 void ORowSetBase::fireProperty( sal_Int32 _nProperty, sal_Bool _bNew, sal_Bool _bOld )
1367 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::fireProperty" );
1368 Any aNew = bool2any( _bNew );
1369 Any aOld = bool2any( _bOld );
1370 fire( &_nProperty, &aNew, &aOld, 1, sal_False );
1373 // -----------------------------------------------------------------------------
1374 void ORowSetBase::positionCache( CursorMoveDirection _ePrepareForDirection )
1376 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::positionCache" );
1377 DBG_TRACE2("DBACCESS ORowSetBase::positionCache() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
1379 sal_Bool bSuccess = sal_False;
1380 if ( m_aBookmark.hasValue() )
1382 bSuccess = m_pCache->moveToBookmark( m_aBookmark );
1384 else
1386 if ( m_bBeforeFirst )
1388 bSuccess = m_pCache->beforeFirst();
1390 else if ( m_bAfterLast )
1392 bSuccess = m_pCache->afterLast();
1394 else
1396 OSL_ENSURE( m_nDeletedPosition >= 1, "ORowSetBase::positionCache: no bookmark, and no valid 'deleted position'!" );
1397 switch ( _ePrepareForDirection )
1399 case MOVE_FORWARD:
1400 if ( m_nDeletedPosition > 1 )
1401 bSuccess = m_pCache->absolute( m_nDeletedPosition - 1 );
1402 else
1404 m_pCache->beforeFirst();
1405 bSuccess = sal_True;
1407 break;
1409 case MOVE_BACKWARD:
1410 if ( m_pCache->m_bRowCountFinal && ( m_nDeletedPosition == impl_getRowCount() ) )
1412 m_pCache->afterLast();
1413 bSuccess = sal_True;
1415 else
1416 bSuccess = m_pCache->absolute( m_nDeletedPosition );
1417 break;
1419 case MOVE_NONE_REFRESH_ONLY:
1420 bSuccess = sal_False; // will be asserted below
1421 break;
1425 OSL_ENSURE( bSuccess, "ORowSetBase::positionCache: failed!" );
1427 DBG_TRACE2("DBACCESS ORowSetBase::positionCache() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
1429 // -----------------------------------------------------------------------------
1430 void ORowSetBase::checkCache()
1432 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::checkCache" );
1433 ::connectivity::checkDisposed(m_rBHelper.bDisposed);
1434 if(!m_pCache)
1435 throwFunctionSequenceException(*m_pMySelf);
1437 // -----------------------------------------------------------------------------
1438 void ORowSetBase::movementFailed()
1440 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::movementFailed" );
1441 DBG_TRACE2("DBACCESS ORowSetBase::movementFailed() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
1442 m_aOldRow->clearRow();
1443 m_aCurrentRow = m_pCache->getEnd();
1444 m_bBeforeFirst = m_pCache->isBeforeFirst();
1445 m_bAfterLast = m_pCache->isAfterLast();
1446 m_aBookmark = Any();
1447 m_aCurrentRow.setBookmark(m_aBookmark);
1448 OSL_ENSURE(m_bBeforeFirst || m_bAfterLast,"BeforeFirst or AfterLast is wrong!");
1449 DBG_TRACE2("DBACCESS ORowSetBase::movementFailed() Clone = %i ID = %i\n",m_bClone,osl_getThreadIdentifier(NULL));
1451 // -----------------------------------------------------------------------------
1452 ORowSetRow ORowSetBase::getOldRow(sal_Bool _bWasNew)
1454 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getOldRow" );
1455 OSL_ENSURE(m_aOldRow.isValid(),"RowSetRowHElper isn't valid!");
1456 ORowSetRow aOldValues;
1457 if ( !_bWasNew && m_aOldRow->getRow().isValid() )
1458 aOldValues = new ORowSetValueVector( m_aOldRow->getRow().getBody()); // remember the old values
1459 return aOldValues;
1461 // -----------------------------------------------------------------------------
1462 void ORowSetBase::getPropertyDefaultByHandle( sal_Int32 /*_nHandle*/, Any& _rDefault ) const
1464 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::getPropertyDefaultByHandle" );
1465 _rDefault.clear();
1467 // -----------------------------------------------------------------------------
1468 void ORowSetBase::onDeleteRow( const Any& _rBookmark )
1470 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::onDeleteRow" );
1471 if ( rowDeleted() )
1472 // not interested in
1473 return;
1475 ::osl::MutexGuard aGuard( *m_pMutex );
1476 //OSL_ENSURE( m_aBookmark.hasValue(), "ORowSetBase::onDeleteRow: Bookmark isn't valid!" );
1477 if ( compareBookmarks( _rBookmark, m_aBookmark ) == 0 )
1479 positionCache( MOVE_NONE_REFRESH_ONLY );
1480 m_nDeletedPosition = m_pCache->getRow();
1483 // -----------------------------------------------------------------------------
1484 void ORowSetBase::onDeletedRow( const Any& _rBookmark, sal_Int32 _nPos )
1486 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::onDeletedRow" );
1487 if ( rowDeleted() )
1489 // if we're a clone, and on a deleted row, and the main RowSet deleted another
1490 // row (only the main RowSet can, clones can't), which is *before* our
1491 // deleted position, then we have to adjust this position
1492 if ( m_bClone && ( _nPos < m_nDeletedPosition ) )
1493 --m_nDeletedPosition;
1494 return;
1497 ::osl::MutexGuard aGuard( *m_pMutex );
1498 if ( compareBookmarks( _rBookmark, m_aBookmark ) == 0 )
1500 m_aOldRow->clearRow();
1501 m_aCurrentRow = m_pCache->getEnd();
1502 m_aBookmark = Any();
1503 m_aCurrentRow.setBookmark( m_aBookmark );
1506 // -----------------------------------------------------------------------------
1507 sal_Int32 ORowSetBase::impl_getRowCount() const
1509 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::impl_getRowCount" );
1510 sal_Int32 nRowCount( m_pCache->m_nRowCount );
1511 if ( const_cast< ORowSetBase* >( this )->rowDeleted() && !m_pCache->m_bNew )
1512 ++nRowCount;
1513 return nRowCount;
1515 // =============================================================================
1516 DBG_NAME(ORowSetNotifier)
1517 // -----------------------------------------------------------------------------
1518 ORowSetNotifier::ORowSetNotifier( ORowSetBase* _pRowSet )
1519 :m_pRowSet( _pRowSet )
1520 ,m_bWasNew( sal_False )
1521 ,m_bWasModified( sal_False )
1522 #ifdef DBG_UTIL
1523 ,m_bNotifyCalled( sal_False )
1524 #endif
1526 DBG_CTOR(ORowSetNotifier,NULL);
1528 OSL_ENSURE( m_pRowSet, "ORowSetNotifier::ORowSetNotifier: invalid row set. This wil crash." );
1530 // remember the "inserted" and "modified" state for later firing
1531 m_bWasNew = m_pRowSet->isNew( ORowSetBase::GrantNotifierAccess() );
1532 m_bWasModified = m_pRowSet->isModified( ORowSetBase::GrantNotifierAccess() );
1534 // if the row set is on the insert row, then we need to cancel this
1535 if ( m_pRowSet->isModification( ORowSetBase::GrantNotifierAccess() ) )
1536 m_pRowSet->doCancelModification( ORowSetBase::GrantNotifierAccess() );
1539 // -----------------------------------------------------------------------------
1540 ORowSetNotifier::~ORowSetNotifier( )
1542 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetNotifier::~ORowSetNotifier" );
1543 DBG_DTOR(ORowSetNotifier,NULL);
1546 // -----------------------------------------------------------------------------
1547 void ORowSetNotifier::fire()
1549 // we're not interested in firing changes FALSE->TRUE, only TRUE->FALSE.
1550 // (the former would be quite pathological, e.g. after a failed movement)
1552 if ( m_bWasModified
1553 && ( m_bWasModified != m_pRowSet->isModified( ORowSetBase::GrantNotifierAccess() ) )
1555 m_pRowSet->fireProperty( PROPERTY_ID_ISMODIFIED, sal_False, sal_True, ORowSetBase::GrantNotifierAccess() );
1557 if ( m_bWasNew
1558 && ( m_bWasNew != m_pRowSet->isNew( ORowSetBase::GrantNotifierAccess() ) )
1560 m_pRowSet->fireProperty( PROPERTY_ID_ISNEW, sal_False, sal_True, ORowSetBase::GrantNotifierAccess() );
1562 #ifdef DBG_UTIL
1563 m_bNotifyCalled = sal_True;
1564 #endif
1567 } // namespace dbaccess