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