2000-09-18 23:16:46 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* $RCSfile: RowSet.cxx,v $
|
|
|
|
*
|
2002-12-05 13:50:03 +00:00
|
|
|
* $Revision: 1.115 $
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2002-12-05 13:50:03 +00:00
|
|
|
* last change: $Author: oj $ $Date: 2002-12-05 14:50:03 $
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
|
|
|
* The Contents of this file are made available subject to the terms of
|
|
|
|
* either of the following licenses
|
|
|
|
*
|
|
|
|
* - GNU Lesser General Public License Version 2.1
|
|
|
|
* - Sun Industry Standards Source License Version 1.1
|
|
|
|
*
|
|
|
|
* Sun Microsystems Inc., October, 2000
|
|
|
|
*
|
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2000 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Sun Industry Standards Source License Version 1.1
|
|
|
|
* =================================================
|
|
|
|
* The contents of this file are subject to the Sun Industry Standards
|
|
|
|
* Source License Version 1.1 (the "License"); You may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of the
|
|
|
|
* License at http://www.openoffice.org/license.html.
|
|
|
|
*
|
|
|
|
* Software provided under this License is provided on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
|
|
|
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
|
|
|
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
|
|
|
* See the License for the specific provisions governing your rights and
|
|
|
|
* obligations concerning the Software.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* Copyright: 2000 by Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s): _______________________________________
|
|
|
|
*
|
|
|
|
*
|
|
|
|
************************************************************************/
|
2000-10-17 11:21:45 +00:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
#ifndef DBACCESS_CORE_API_ROWSET_HXX
|
|
|
|
#include "RowSet.hxx"
|
|
|
|
#endif
|
2000-10-25 06:32:52 +00:00
|
|
|
#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
|
|
|
|
#include "dbastrings.hrc"
|
2000-09-18 23:16:46 +00:00
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
|
|
|
|
#include <com/sun/star/beans/PropertyAttribute.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
|
|
|
|
#include <com/sun/star/lang/DisposedException.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _CPPUHELPER_INTERFACECONTAINER_H_
|
|
|
|
#include <cppuhelper/interfacecontainer.h>
|
|
|
|
#endif
|
|
|
|
#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
|
|
|
|
#include <cppuhelper/typeprovider.hxx>
|
|
|
|
#endif
|
2000-10-11 10:21:40 +00:00
|
|
|
#ifndef _COMPHELPER_SEQUENCE_HXX_
|
|
|
|
#include <comphelper/sequence.hxx>
|
2000-09-18 23:16:46 +00:00
|
|
|
#endif
|
2000-12-01 13:16:46 +00:00
|
|
|
#ifndef _COM_SUN_STAR_SDB_XCOMPLETEDCONNECTION_HPP_
|
|
|
|
#include <com/sun/star/sdb/XCompletedConnection.hpp>
|
|
|
|
#endif
|
2000-09-18 23:16:46 +00:00
|
|
|
#ifndef _COM_SUN_STAR_SDB_ROWSETVETOEXCEPTION_HPP_
|
|
|
|
#include <com/sun/star/sdb/RowSetVetoException.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_SDBC_FETCHDIRECTION_HPP_
|
|
|
|
#include <com/sun/star/sdbc/FetchDirection.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_SDBC_RESULTSETCONCURRENCY_HPP_
|
|
|
|
#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_
|
|
|
|
#include <com/sun/star/sdb/CommandType.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_
|
|
|
|
#include <com/sun/star/sdbc/XDataSource.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSERFACTORY_HPP_
|
|
|
|
#include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_SDB_XQUERIESSUPPLIER_HPP_
|
|
|
|
#include <com/sun/star/sdb/XQueriesSupplier.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_SDB_ROWCHANGEACTION_HPP_
|
|
|
|
#include <com/sun/star/sdb/RowChangeAction.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_SDBC_XDRIVERACCESS_HPP_
|
|
|
|
#include <com/sun/star/sdbc/XDriverAccess.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_SDBCX_XDATADEFINITIONSUPPLIER_HPP_
|
|
|
|
#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
|
|
|
|
#endif
|
2000-12-06 08:55:44 +00:00
|
|
|
#ifndef _COM_SUN_STAR_SDBCX_COMPAREBOOKMARK_HPP_
|
|
|
|
#include <com/sun/star/sdbcx/CompareBookmark.hpp>
|
|
|
|
#endif
|
2000-09-18 23:16:46 +00:00
|
|
|
#ifndef _COM_SUN_STAR_UNO_XNAMINGSERVICE_HPP_
|
|
|
|
#include <com/sun/star/uno/XNamingService.hpp>
|
|
|
|
#endif
|
2000-10-11 10:21:40 +00:00
|
|
|
#ifndef _CONNECTIVITY_DBTOOLS_HXX_
|
|
|
|
#include <connectivity/dbtools.hxx>
|
2000-09-18 23:16:46 +00:00
|
|
|
#endif
|
2001-03-15 07:29:16 +00:00
|
|
|
#ifndef _COMPHELPER_EXTRACT_HXX_
|
|
|
|
#include <comphelper/extract.hxx>
|
2000-09-18 23:16:46 +00:00
|
|
|
#endif
|
|
|
|
#ifndef DBACCESS_CORE_API_ROWSETCACHE_HXX
|
|
|
|
#include "RowSetCache.hxx"
|
|
|
|
#endif
|
2000-12-19 15:44:43 +00:00
|
|
|
#ifndef _DBA_REGHELPER_HXX_
|
|
|
|
#include "dba_reghelper.hxx"
|
2000-09-18 23:16:46 +00:00
|
|
|
#endif
|
2000-11-03 13:42:50 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
#ifndef _COM_SUN_STAR_SDBC_XDRIVERMANAGER_HPP_
|
|
|
|
#include <com/sun/star/sdbc/XDriverManager.hpp>
|
2000-09-18 23:16:46 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#ifndef _DBACORE_DATACOLUMN_HXX_
|
|
|
|
#include "CRowSetDataColumn.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef DBACCESS_CORE_API_CROWSETCOLUMN_HXX
|
|
|
|
#include "CRowSetColumn.hxx"
|
|
|
|
#endif
|
2000-10-17 09:19:03 +00:00
|
|
|
#ifndef _COMPHELPER_TYPES_HXX_
|
|
|
|
#include <comphelper/types.hxx>
|
2000-10-17 11:21:45 +00:00
|
|
|
#endif
|
2000-10-11 10:21:40 +00:00
|
|
|
#ifndef _COMPHELPER_SEQSTREAM_HXX
|
|
|
|
#include <comphelper/seqstream.hxx>
|
2000-09-29 14:23:36 +00:00
|
|
|
#endif
|
2000-10-17 11:21:45 +00:00
|
|
|
#ifndef _TOOLS_DEBUG_HXX
|
|
|
|
#include <tools/debug.hxx>
|
|
|
|
#endif
|
2000-10-25 06:32:52 +00:00
|
|
|
#ifndef _DBHELPER_DBEXCEPTION_HXX_
|
|
|
|
#include <connectivity/dbexception.hxx>
|
|
|
|
#endif
|
2001-06-22 09:48:40 +00:00
|
|
|
#ifndef _CONNECTIVITY_DBTOOLS_HXX_
|
|
|
|
#include <connectivity/dbtools.hxx>
|
|
|
|
#endif
|
2000-10-30 08:24:02 +00:00
|
|
|
#ifndef DBACCESS_CORE_API_QUERYCOMPOSER_HXX
|
|
|
|
#include "querycomposer.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _DBA_CORE_TABLECONTAINER_HXX_
|
|
|
|
#include "tablecontainer.hxx"
|
2000-10-25 06:32:52 +00:00
|
|
|
#endif
|
2000-11-06 11:14:23 +00:00
|
|
|
#ifndef _COM_SUN_STAR_SDB_XINTERACTIONSUPPLYPARAMETERS_HPP_
|
|
|
|
#include <com/sun/star/sdb/XInteractionSupplyParameters.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_SDB_PARAMETERSREQUEST_HPP_
|
|
|
|
#include <com/sun/star/sdb/ParametersRequest.hpp>
|
|
|
|
#endif
|
2000-12-01 13:16:46 +00:00
|
|
|
#include <com/sun/star/sdb/ParametersRequest.hpp>
|
2000-11-06 11:14:23 +00:00
|
|
|
#ifndef _COM_SUN_STAR_SDB_XPARAMETERSSUPPLIER_HPP_
|
|
|
|
#include <com/sun/star/sdb/XParametersSupplier.hpp>
|
|
|
|
#endif
|
2000-11-22 13:58:32 +00:00
|
|
|
#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_
|
|
|
|
#include <com/sun/star/container/XChild.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATSSUPPLIER_HPP_
|
|
|
|
#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
|
|
|
|
#endif
|
2000-11-06 11:14:23 +00:00
|
|
|
#ifndef _COMPHELPER_INTERACTION_HXX_
|
|
|
|
#include <comphelper/interaction.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _COMPHELPER_PROPERTY_HXX_
|
|
|
|
#include <comphelper/property.hxx>
|
|
|
|
#endif
|
2000-11-22 13:58:32 +00:00
|
|
|
#ifndef _UTL_CONFIGMGR_HXX_
|
|
|
|
#include <unotools/configmgr.hxx>
|
|
|
|
#endif
|
2000-12-12 11:20:31 +00:00
|
|
|
#ifndef _COMPHELPER_UNO3_HXX_
|
|
|
|
#include <comphelper/uno3.hxx>
|
|
|
|
#endif
|
2001-01-22 06:38:24 +00:00
|
|
|
#ifndef _COM_SUN_STAR_SDBCX_COMPAREBOOKMARK_HPP_
|
|
|
|
#include <com/sun/star/sdbcx/CompareBookmark.hpp>
|
|
|
|
#endif
|
2001-04-10 07:05:08 +00:00
|
|
|
#ifndef _DBA_CORE_RESOURCE_HXX_
|
|
|
|
#include "core_resource.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _DBA_CORE_RESOURCE_HRC_
|
|
|
|
#include "core_resource.hrc"
|
|
|
|
#endif
|
2002-09-27 12:02:06 +00:00
|
|
|
#ifndef _DBHELPER_DBCONVERSION_HXX_
|
|
|
|
#include <connectivity/dbconversion.hxx>
|
|
|
|
#endif
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2000-11-22 13:58:32 +00:00
|
|
|
using namespace utl;
|
2000-11-03 13:42:50 +00:00
|
|
|
using namespace dbaccess;
|
|
|
|
using namespace connectivity;
|
|
|
|
using namespace comphelper;
|
|
|
|
using namespace dbtools;
|
2000-09-18 23:16:46 +00:00
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::com::sun::star::sdbc;
|
|
|
|
using namespace ::com::sun::star::sdb;
|
|
|
|
using namespace ::com::sun::star::sdbcx;
|
|
|
|
using namespace ::com::sun::star::container;
|
|
|
|
using namespace ::com::sun::star::lang;
|
2000-11-06 11:14:23 +00:00
|
|
|
using namespace ::com::sun::star::task;
|
2000-11-22 13:58:32 +00:00
|
|
|
using namespace ::com::sun::star::util;
|
2000-09-18 23:16:46 +00:00
|
|
|
using namespace ::cppu;
|
|
|
|
using namespace ::osl;
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
extern "C" void SAL_CALL createRegistryInfo_ORowSet()
|
|
|
|
{
|
|
|
|
static OMultiInstanceAutoRegistration< ORowSet > aAutoRegistration;
|
|
|
|
}
|
2002-08-13 10:13:00 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
#define NOTIFY_LISTERNERS(_rListeners,T,method) \
|
|
|
|
Sequence< Reference< XInterface > > aListenerSeq = _rListeners.getElements(); \
|
|
|
|
\
|
|
|
|
const Reference< XInterface >* pxIntBegin = aListenerSeq.getConstArray(); \
|
|
|
|
const Reference< XInterface >* pxInt = pxIntBegin + aListenerSeq.getLength(); \
|
|
|
|
\
|
|
|
|
_rGuard.clear(); \
|
|
|
|
while( pxInt > pxIntBegin ) \
|
|
|
|
{ \
|
|
|
|
try \
|
|
|
|
{ \
|
|
|
|
while( pxInt > pxIntBegin ) \
|
|
|
|
{ \
|
|
|
|
--pxInt; \
|
|
|
|
static_cast< T* >( pxInt->get() )->method(aEvt); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
catch( RuntimeException& ) \
|
|
|
|
{ \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
_rGuard.reset();
|
|
|
|
|
|
|
|
#define NOTIFY_LISTERNERS_CHECK(_rListeners,T,method) \
|
|
|
|
Sequence< Reference< XInterface > > aListenerSeq = _rListeners.getElements(); \
|
|
|
|
\
|
|
|
|
const Reference< XInterface >* pxIntBegin = aListenerSeq.getConstArray(); \
|
|
|
|
const Reference< XInterface >* pxInt = pxIntBegin + aListenerSeq.getLength(); \
|
|
|
|
\
|
|
|
|
_rGuard.clear(); \
|
|
|
|
sal_Bool bCheck = sal_True; \
|
|
|
|
while( pxInt > pxIntBegin && bCheck ) \
|
|
|
|
{ \
|
|
|
|
try \
|
|
|
|
{ \
|
|
|
|
while( pxInt > pxIntBegin && bCheck ) \
|
|
|
|
{ \
|
|
|
|
--pxInt; \
|
|
|
|
bCheck = static_cast< T* >( pxInt->get() )->method(aEvt); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
catch( RuntimeException& ) \
|
|
|
|
{ \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
_rGuard.reset();
|
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2000-11-06 11:14:23 +00:00
|
|
|
//..................................................................
|
|
|
|
namespace dbaccess
|
|
|
|
{
|
|
|
|
//..................................................................
|
|
|
|
|
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
Reference< XInterface > ORowSet_CreateInstance(const Reference< XMultiServiceFactory >& _rxFactory)
|
|
|
|
{
|
|
|
|
return *(new ORowSet(_rxFactory));
|
|
|
|
}
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
ORowSet::ORowSet(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xFac)
|
|
|
|
: ORowSet_BASE1(m_aMutex)
|
2001-11-15 09:42:42 +00:00
|
|
|
, ORowSetBase(ORowSet_BASE1::rBHelper,&m_aMutex)
|
2000-09-18 23:16:46 +00:00
|
|
|
, m_xServiceManager(_xFac)
|
2001-11-15 09:42:42 +00:00
|
|
|
,m_aRowsetListeners(*m_pMutex)
|
|
|
|
,m_aApproveListeners(*m_pMutex)
|
2000-09-18 23:16:46 +00:00
|
|
|
,m_nFetchDirection(FetchDirection::FORWARD)
|
|
|
|
,m_nFetchSize(1)
|
|
|
|
,m_nCommandType(CommandType::COMMAND)
|
|
|
|
,m_nMaxFieldSize(0)
|
|
|
|
,m_nTransactionIsolation(0)
|
|
|
|
,m_nPrivileges(0)
|
|
|
|
,m_nAsyncUpdateRowCount(0)
|
|
|
|
,m_nMaxRows(0)
|
|
|
|
,m_nQueryTimeOut(0)
|
|
|
|
,m_bUseEscapeProcessing(sal_True)
|
|
|
|
,m_bApplyFilter(sal_False)
|
|
|
|
,m_bInserted(sal_False)
|
|
|
|
,m_bDeleted(sal_False)
|
|
|
|
,m_bUpdated(sal_False)
|
|
|
|
,m_bCreateStatement(sal_True)
|
|
|
|
,m_bCanceled(sal_False)
|
|
|
|
,m_bRowObsolete(sal_False)
|
|
|
|
,m_bModified(sal_False)
|
|
|
|
,m_bOwnsResultRow(sal_False)
|
|
|
|
,m_bRebuildConnOnExecute(sal_False)
|
|
|
|
,m_bNew(sal_False)
|
|
|
|
,m_bIsBookmarable(sal_True)
|
2000-11-15 14:57:40 +00:00
|
|
|
,m_bCanUpdateInsertedRows(sal_True)
|
2000-11-03 13:42:50 +00:00
|
|
|
,m_pTables(NULL)
|
2001-01-26 14:00:05 +00:00
|
|
|
,m_bOwnConnection(sal_False)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-04-05 06:51:27 +00:00
|
|
|
m_nResultSetType = ResultSetType::SCROLL_INSENSITIVE;
|
|
|
|
m_nResultSetConcurrency = ResultSetConcurrency::UPDATABLE;
|
2000-09-18 23:16:46 +00:00
|
|
|
m_pMySelf = this;
|
|
|
|
m_aActiveConnection <<= m_xActiveConnection;
|
|
|
|
|
|
|
|
sal_Int32 nRBT = PropertyAttribute::READONLY | PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT;
|
|
|
|
sal_Int32 nRT = PropertyAttribute::READONLY | PropertyAttribute::TRANSIENT;
|
|
|
|
sal_Int32 nBT = PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT;
|
|
|
|
|
|
|
|
// sdb.RowSet Properties
|
2001-04-12 08:32:26 +00:00
|
|
|
registerMayBeVoidProperty(PROPERTY_ACTIVECONNECTION,PROPERTY_ID_ACTIVECONNECTION, PropertyAttribute::MAYBEVOID|PropertyAttribute::TRANSIENT|PropertyAttribute::BOUND, &m_aActiveConnection, ::getCppuType(reinterpret_cast< Reference< XConnection >* >(NULL)));
|
2000-09-18 23:16:46 +00:00
|
|
|
registerProperty(PROPERTY_DATASOURCENAME, PROPERTY_ID_DATASOURCENAME, PropertyAttribute::BOUND, &m_aDataSourceName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
|
|
|
|
registerProperty(PROPERTY_COMMAND, PROPERTY_ID_COMMAND, PropertyAttribute::BOUND, &m_aCommand, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
|
|
|
|
registerProperty(PROPERTY_COMMANDTYPE, PROPERTY_ID_COMMANDTYPE, PropertyAttribute::BOUND, &m_nCommandType, ::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
|
2000-10-17 09:19:03 +00:00
|
|
|
registerProperty(PROPERTY_ACTIVECOMMAND, PROPERTY_ID_ACTIVECOMMAND, nRBT, &m_aActiveCommand, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
|
2000-09-18 23:16:46 +00:00
|
|
|
registerProperty(PROPERTY_IGNORERESULT, PROPERTY_ID_IGNORERESULT, PropertyAttribute::BOUND, &m_bIgnoreResult, ::getBooleanCppuType());
|
|
|
|
registerProperty(PROPERTY_FILTER, PROPERTY_ID_FILTER, PropertyAttribute::BOUND, &m_aFilter, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
|
|
|
|
registerProperty(PROPERTY_APPLYFILTER, PROPERTY_ID_APPLYFILTER, PropertyAttribute::BOUND, &m_bApplyFilter, ::getBooleanCppuType());
|
|
|
|
registerProperty(PROPERTY_ORDER, PROPERTY_ID_ORDER, PropertyAttribute::BOUND, &m_aOrder, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
|
|
|
|
registerProperty(PROPERTY_PRIVILEGES, PROPERTY_ID_PRIVILEGES, nRT, &m_nPrivileges, ::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
|
2000-09-29 14:23:36 +00:00
|
|
|
registerProperty(PROPERTY_ISMODIFIED, PROPERTY_ID_ISMODIFIED, nBT, &m_bModified, ::getBooleanCppuType());
|
2000-09-18 23:16:46 +00:00
|
|
|
registerProperty(PROPERTY_ISNEW, PROPERTY_ID_ISNEW, nRBT, &m_bNew, ::getBooleanCppuType());
|
|
|
|
|
|
|
|
|
|
|
|
// sdbcx.ResultSet Properties
|
|
|
|
registerProperty(PROPERTY_ISBOOKMARKABLE, PROPERTY_ID_ISBOOKMARKABLE, nRT, &m_bIsBookmarable, ::getBooleanCppuType());
|
2000-11-15 14:57:40 +00:00
|
|
|
registerProperty(PROPERTY_CANUPDATEINSERTEDROWS,PROPERTY_ID_CANUPDATEINSERTEDROWS, nRT, &m_bCanUpdateInsertedRows, ::getBooleanCppuType());
|
2000-09-18 23:16:46 +00:00
|
|
|
// sdbc.ResultSet Properties
|
|
|
|
registerProperty(PROPERTY_RESULTSETCONCURRENCY, PROPERTY_ID_RESULTSETCONCURRENCY, PropertyAttribute::TRANSIENT, &m_nResultSetConcurrency,::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
|
|
|
|
registerProperty(PROPERTY_RESULTSETTYPE, PROPERTY_ID_RESULTSETTYPE, PropertyAttribute::TRANSIENT, &m_nResultSetType, ::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
|
|
|
|
registerProperty(PROPERTY_FETCHDIRECTION, PROPERTY_ID_FETCHDIRECTION, PropertyAttribute::TRANSIENT, &m_nFetchDirection, ::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
|
|
|
|
registerProperty(PROPERTY_FETCHSIZE, PROPERTY_ID_FETCHSIZE, PropertyAttribute::TRANSIENT, &m_nFetchSize, ::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
|
|
|
|
|
|
|
|
// sdbc.RowSet Properties
|
|
|
|
registerProperty(PROPERTY_URL, PROPERTY_ID_URL, 0, &m_aURL, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
|
|
|
|
registerProperty(PROPERTY_TRANSACTIONISOLATION, PROPERTY_ID_TRANSACTIONISOLATION, PropertyAttribute::TRANSIENT, &m_nTransactionIsolation,::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
|
|
|
|
registerMayBeVoidProperty(PROPERTY_TYPEMAP, PROPERTY_ID_TYPEMAP, PropertyAttribute::MAYBEVOID|PropertyAttribute::TRANSIENT, &m_aTypeMap, ::getCppuType(reinterpret_cast< Reference< XNameAccess >* >(NULL)));
|
|
|
|
registerProperty(PROPERTY_USE_ESCAPE_PROCESSING,PROPERTY_ID_USE_ESCAPE_PROCESSING, 0, &m_bUseEscapeProcessing,::getBooleanCppuType() );
|
|
|
|
registerProperty(PROPERTY_QUERYTIMEOUT, PROPERTY_ID_QUERYTIMEOUT, PropertyAttribute::TRANSIENT, &m_nQueryTimeOut, ::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
|
|
|
|
registerProperty(PROPERTY_MAXFIELDSIZE, PROPERTY_ID_MAXFIELDSIZE, PropertyAttribute::TRANSIENT, &m_nMaxFieldSize, ::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
|
|
|
|
registerProperty(PROPERTY_MAXROWS, PROPERTY_ID_MAXROWS, 0, &m_nMaxRows, ::getCppuType(reinterpret_cast< sal_Int32*>(NULL)) );
|
|
|
|
registerProperty(PROPERTY_USER, PROPERTY_ID_USER, PropertyAttribute::TRANSIENT, &m_aUser, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
|
2000-11-19 09:57:19 +00:00
|
|
|
registerProperty(PROPERTY_PASSWORD, PROPERTY_ID_PASSWORD, PropertyAttribute::TRANSIENT, &m_aPassword, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
|
2001-01-09 11:31:57 +00:00
|
|
|
|
|
|
|
registerProperty(PROPERTY_UPDATE_CATALOGNAME, PROPERTY_ID_UPDATE_CATALOGNAME, PropertyAttribute::BOUND, &m_aUpdateCatalogName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
|
|
|
|
registerProperty(PROPERTY_UPDATE_SCHEMANAME, PROPERTY_ID_UPDATE_SCHEMANAME, PropertyAttribute::BOUND, &m_aUpdateSchemaName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
|
|
|
|
registerProperty(PROPERTY_UPDATE_TABLENAME, PROPERTY_ID_UPDATE_TABLENAME, PropertyAttribute::BOUND, &m_aUpdateTableName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
|
|
|
|
|
2001-03-27 05:47:15 +00:00
|
|
|
m_aParameterRow.clear(); // because it was constructed with one element as default
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
2000-10-11 10:21:40 +00:00
|
|
|
// typedef ::comphelper::OPropertyArrayUsageHelper<ORowSet> ORowSet_Prop;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
void SAL_CALL ORowSet::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) throw (Exception)
|
|
|
|
{
|
2000-09-29 14:23:36 +00:00
|
|
|
switch(nHandle)
|
|
|
|
{
|
|
|
|
case PROPERTY_ID_ISMODIFIED:
|
2000-10-17 09:19:03 +00:00
|
|
|
m_bModified = cppu::any2bool(rValue);
|
2000-09-29 14:23:36 +00:00
|
|
|
break;
|
2001-04-05 06:51:27 +00:00
|
|
|
case PROPERTY_ID_FETCHDIRECTION:
|
|
|
|
if( m_nResultSetType == ResultSetType::FORWARD_ONLY)
|
|
|
|
throw Exception(); // else run through
|
2000-09-29 14:23:36 +00:00
|
|
|
default:
|
2000-10-05 08:37:27 +00:00
|
|
|
OPropertyContainer::setFastPropertyValue_NoBroadcast(nHandle,rValue);
|
2000-09-29 14:23:36 +00:00
|
|
|
}
|
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
switch(nHandle)
|
|
|
|
{
|
|
|
|
case PROPERTY_ID_ACTIVECONNECTION:
|
2001-04-12 08:32:26 +00:00
|
|
|
// the new connection
|
2001-04-18 11:46:58 +00:00
|
|
|
{
|
|
|
|
Reference< XConnection > xNewConnection;
|
|
|
|
m_aActiveConnection >>= xNewConnection;
|
|
|
|
setActiveConnection(xNewConnection, sal_False);
|
|
|
|
}
|
2001-04-03 13:16:03 +00:00
|
|
|
|
|
|
|
m_bOwnConnection = sal_False;
|
|
|
|
m_bCreateStatement = sal_True;
|
|
|
|
m_bRebuildConnOnExecute = sal_False;
|
2000-09-18 23:16:46 +00:00
|
|
|
break;
|
2001-04-12 08:32:26 +00:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
case PROPERTY_ID_APPLYFILTER:
|
|
|
|
m_bCreateStatement = sal_True;
|
|
|
|
break;
|
|
|
|
case PROPERTY_ID_COMMAND:
|
|
|
|
m_bCreateStatement = sal_True;
|
|
|
|
break;
|
|
|
|
case PROPERTY_ID_COMMANDTYPE:
|
|
|
|
m_bCreateStatement = sal_True;
|
|
|
|
break;
|
|
|
|
case PROPERTY_ID_DATASOURCENAME:
|
2000-11-06 13:46:11 +00:00
|
|
|
if(!m_xStatement.is())
|
|
|
|
{
|
|
|
|
Reference< XConnection > xNewConn;
|
|
|
|
Any aNewConn;
|
|
|
|
aNewConn <<= xNewConn;
|
|
|
|
setFastPropertyValue(PROPERTY_ID_ACTIVECONNECTION, aNewConn);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
m_bRebuildConnOnExecute = sal_True;
|
2000-09-18 23:16:46 +00:00
|
|
|
m_bCreateStatement = sal_True;
|
2001-05-07 10:11:15 +00:00
|
|
|
// m_bOwnConnection = sal_True;
|
2000-09-18 23:16:46 +00:00
|
|
|
break;
|
|
|
|
case PROPERTY_ID_FETCHSIZE:
|
2001-01-24 08:52:19 +00:00
|
|
|
if(m_pCache)
|
|
|
|
{
|
|
|
|
m_pCache->setMaxRowSize(m_nFetchSize);
|
|
|
|
fireRowcount();
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
break;
|
|
|
|
case PROPERTY_ID_FILTER:
|
|
|
|
m_bCreateStatement = sal_True;
|
|
|
|
break;
|
|
|
|
case PROPERTY_ID_ORDER:
|
|
|
|
m_bCreateStatement = sal_True;
|
|
|
|
break;
|
|
|
|
case PROPERTY_ID_URL:
|
2000-11-06 13:46:11 +00:00
|
|
|
// is the connection-to-be-built determined by the url (which is the case if m_aDataSourceName is empty) ?
|
|
|
|
if (!m_aDataSourceName.getLength())
|
|
|
|
{
|
|
|
|
// are we active at the moment ?
|
|
|
|
if (m_xStatement.is())
|
|
|
|
// yes -> the next execute needs to rebuild our connection because of this new property
|
|
|
|
m_bRebuildConnOnExecute = sal_True;
|
|
|
|
else
|
|
|
|
{ // no -> drop our active connection (if we have one) as it doesn't correspond to this new property value anymore
|
|
|
|
Reference< XConnection > xNewConn;
|
|
|
|
Any aNewConn;
|
|
|
|
aNewConn <<= xNewConn;
|
|
|
|
setFastPropertyValue(PROPERTY_ID_ACTIVECONNECTION, aNewConn);
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
m_bCreateStatement = sal_True;
|
2001-01-26 14:00:05 +00:00
|
|
|
m_bOwnConnection = sal_True;
|
2000-09-18 23:16:46 +00:00
|
|
|
break;
|
|
|
|
case PROPERTY_ID_USER:
|
|
|
|
m_bCreateStatement = sal_True;
|
|
|
|
break;
|
2000-10-17 09:19:03 +00:00
|
|
|
case PROPERTY_ID_TYPEMAP:
|
2001-02-14 12:18:24 +00:00
|
|
|
::cppu::extractInterface(m_xTypeMap,m_aTypeMap);
|
2000-10-17 09:19:03 +00:00
|
|
|
break;
|
2000-09-29 14:23:36 +00:00
|
|
|
default:
|
|
|
|
;
|
2000-09-18 23:16:46 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const
|
|
|
|
{
|
|
|
|
if(m_pCache)
|
|
|
|
{
|
|
|
|
switch(nHandle)
|
|
|
|
{
|
|
|
|
case PROPERTY_ID_ISMODIFIED:
|
2000-10-17 09:19:03 +00:00
|
|
|
rValue.setValue(&m_bModified,::getCppuBooleanType());
|
2000-09-18 23:16:46 +00:00
|
|
|
break;
|
|
|
|
case PROPERTY_ID_ISNEW:
|
2000-10-17 09:19:03 +00:00
|
|
|
rValue.setValue(&m_bNew,::getCppuBooleanType());
|
2000-09-18 23:16:46 +00:00
|
|
|
break;
|
|
|
|
case PROPERTY_ID_PRIVILEGES:
|
|
|
|
rValue <<= m_pCache->m_nPrivileges;
|
|
|
|
break;
|
2000-10-17 09:19:03 +00:00
|
|
|
case PROPERTY_ID_ACTIVECONNECTION:
|
|
|
|
rValue <<= m_xActiveConnection;
|
|
|
|
break;
|
|
|
|
case PROPERTY_ID_TYPEMAP:
|
|
|
|
rValue <<= m_xTypeMap;
|
|
|
|
break;
|
2000-09-18 23:16:46 +00:00
|
|
|
default:
|
|
|
|
ORowSetBase::getFastPropertyValue(rValue,nHandle);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
else
|
2000-10-17 09:19:03 +00:00
|
|
|
{
|
|
|
|
switch(nHandle)
|
|
|
|
{
|
|
|
|
case PROPERTY_ID_ACTIVECONNECTION:
|
|
|
|
rValue <<= m_xActiveConnection;
|
|
|
|
break;
|
|
|
|
case PROPERTY_ID_TYPEMAP:
|
|
|
|
rValue <<= m_xTypeMap;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ORowSetBase::getFastPropertyValue(rValue,nHandle);
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
2000-11-03 13:42:50 +00:00
|
|
|
// com::sun::star::XTypeProvider
|
2000-09-18 23:16:46 +00:00
|
|
|
Sequence< Type > SAL_CALL ORowSet::getTypes() throw (RuntimeException)
|
|
|
|
{
|
|
|
|
OTypeCollection aTypes(::getCppuType( (const Reference< XPropertySet > *)0 ),
|
|
|
|
::getCppuType( (const Reference< XFastPropertySet > *)0 ),
|
|
|
|
::getCppuType( (const Reference< XMultiPropertySet > *)0 ),
|
2000-10-11 10:21:40 +00:00
|
|
|
::comphelper::concatSequences(ORowSet_BASE1::getTypes(),ORowSetBase::getTypes()));
|
2000-09-18 23:16:46 +00:00
|
|
|
return aTypes.getTypes();
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
Sequence< sal_Int8 > SAL_CALL ORowSet::getImplementationId() throw (RuntimeException)
|
|
|
|
{
|
|
|
|
static OImplementationId * pId = 0;
|
|
|
|
if (! pId)
|
|
|
|
{
|
|
|
|
MutexGuard aGuard( Mutex::getGlobalMutex() );
|
|
|
|
if (! pId)
|
|
|
|
{
|
|
|
|
static OImplementationId aId;
|
|
|
|
pId = &aId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pId->getImplementationId();
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
2000-11-03 13:42:50 +00:00
|
|
|
// com::sun::star::XInterface
|
2000-09-18 23:16:46 +00:00
|
|
|
Any SAL_CALL ORowSet::queryInterface( const Type & rType ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
return ORowSet_BASE1::queryInterface( rType);
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
2001-11-01 14:27:20 +00:00
|
|
|
void SAL_CALL ORowSet::acquire() throw()
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
ORowSet_BASE1::acquire();
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
2001-11-01 14:27:20 +00:00
|
|
|
void SAL_CALL ORowSet::release() throw()
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
ORowSet_BASE1::release();
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
2000-11-03 13:42:50 +00:00
|
|
|
// com::sun::star::XUnoTunnel
|
2000-09-18 23:16:46 +00:00
|
|
|
sal_Int64 SAL_CALL ORowSet::getSomething( const Sequence< sal_Int8 >& rId ) throw(RuntimeException)
|
|
|
|
{
|
|
|
|
if (rId.getLength() == 16 && 0 == rtl_compareMemory(getImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
|
|
|
|
return (sal_Int64)this;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
2000-11-03 13:42:50 +00:00
|
|
|
// com::sun::star::XAggregation
|
2000-09-18 23:16:46 +00:00
|
|
|
Any SAL_CALL ORowSet::queryAggregation( const Type& rType ) throw(RuntimeException)
|
|
|
|
{
|
|
|
|
Any aRet(ORowSetBase::queryInterface(rType));
|
|
|
|
if (!aRet.hasValue())
|
|
|
|
aRet = ORowSet_BASE1::queryAggregation(rType);
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
rtl::OUString ORowSet::getImplementationName_Static( ) throw(RuntimeException)
|
|
|
|
{
|
2001-01-05 09:49:38 +00:00
|
|
|
return rtl::OUString::createFromAscii("com.sun.star.comp.dba.ORowSet");
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
2000-11-03 13:42:50 +00:00
|
|
|
// ::com::sun::star::XServiceInfo
|
2000-09-18 23:16:46 +00:00
|
|
|
::rtl::OUString SAL_CALL ORowSet::getImplementationName( ) throw(RuntimeException)
|
|
|
|
{
|
|
|
|
return getImplementationName_Static();
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
sal_Bool SAL_CALL ORowSet::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException)
|
|
|
|
{
|
2000-10-11 10:21:40 +00:00
|
|
|
return ::comphelper::findValue(getSupportedServiceNames(), _rServiceName, sal_True).getLength() != 0;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
Sequence< ::rtl::OUString > ORowSet::getSupportedServiceNames_Static( ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
Sequence< rtl::OUString > aSNS( 5 );
|
|
|
|
aSNS[0] = SERVICE_SDBC_RESULTSET;
|
|
|
|
aSNS[1] = SERVICE_SDBC_ROWSET;
|
|
|
|
aSNS[2] = SERVICE_SDBCX_RESULTSET;
|
|
|
|
aSNS[3] = SERVICE_SDB_RESULTSET;
|
|
|
|
aSNS[4] = SERVICE_SDB_ROWSET;
|
|
|
|
return aSNS;
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
Sequence< ::rtl::OUString > SAL_CALL ORowSet::getSupportedServiceNames( ) throw(RuntimeException)
|
|
|
|
{
|
|
|
|
return getSupportedServiceNames_Static();
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
Reference< XInterface > ORowSet::Create(const Reference< XMultiServiceFactory >& _rxFactory)
|
|
|
|
{
|
|
|
|
return ORowSet_CreateInstance(_rxFactory);
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
// OComponentHelper
|
|
|
|
void SAL_CALL ORowSet::disposing(void)
|
|
|
|
{
|
2000-10-05 08:37:27 +00:00
|
|
|
OPropertyContainer::disposing();
|
2000-09-29 14:23:36 +00:00
|
|
|
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
2001-08-06 10:01:19 +00:00
|
|
|
EventObject aDisposeEvent;
|
|
|
|
aDisposeEvent.Source = static_cast< XComponent* >(this);
|
|
|
|
m_aRowsetListeners.disposeAndClear( aDisposeEvent );
|
|
|
|
m_aApproveListeners.disposeAndClear( aDisposeEvent );
|
2000-09-29 14:23:36 +00:00
|
|
|
|
|
|
|
// just because we want to clear all see freeResources()
|
|
|
|
m_bCreateStatement = sal_True;
|
|
|
|
freeResources();
|
2000-11-03 13:42:50 +00:00
|
|
|
m_xServiceManager = NULL;
|
|
|
|
// remove myself as dispose listener
|
|
|
|
Reference< XComponent > xComponent(m_xActiveConnection, UNO_QUERY);
|
|
|
|
if (xComponent.is())
|
2000-12-12 11:20:31 +00:00
|
|
|
{
|
|
|
|
Reference<XEventListener> xEvt;
|
|
|
|
query_aggregation(this,xEvt);
|
|
|
|
xComponent->removeEventListener(xEvt);
|
|
|
|
}
|
2000-11-03 13:42:50 +00:00
|
|
|
|
|
|
|
m_aActiveConnection = Any(); // the any conatains a reference too
|
2001-01-26 14:00:05 +00:00
|
|
|
if(m_bOwnConnection)
|
|
|
|
::comphelper::disposeComponent(m_xActiveConnection);
|
|
|
|
m_xActiveConnection = NULL;
|
|
|
|
|
2000-09-29 14:23:36 +00:00
|
|
|
|
|
|
|
ORowSetBase::disposing();
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void ORowSet::freeResources()
|
|
|
|
{
|
2000-09-18 23:16:46 +00:00
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
|
|
|
|
// free all clones
|
|
|
|
for (connectivity::OWeakRefArray::iterator i = m_aClones.begin(); m_aClones.end() != i; i++)
|
|
|
|
{
|
|
|
|
Reference< XComponent > xComp(i->get(), UNO_QUERY);
|
|
|
|
if (xComp.is())
|
|
|
|
xComp->dispose();
|
|
|
|
}
|
|
|
|
m_aClones.clear();
|
2000-09-29 14:23:36 +00:00
|
|
|
if (m_bCreateStatement)
|
|
|
|
{
|
2001-01-04 13:25:58 +00:00
|
|
|
// the columns must be disposed before the querycomposer is disposed because
|
|
|
|
// their owner can be the composer
|
2001-08-13 07:45:02 +00:00
|
|
|
TDataColumns().swap(m_aDataColumns);// clear and resize capacity
|
2001-01-04 13:25:58 +00:00
|
|
|
m_xColumns = NULL;
|
|
|
|
if(m_pColumns)
|
|
|
|
m_pColumns->disposing();
|
2000-11-03 13:42:50 +00:00
|
|
|
// dispose the composer to avoid that everbody knows that the querycomposer is eol
|
|
|
|
Reference< XComponent > xComp(m_xComposer, UNO_QUERY);
|
|
|
|
if (xComp.is())
|
|
|
|
xComp->dispose();
|
|
|
|
m_xComposer = NULL;
|
|
|
|
|
2001-01-04 13:25:58 +00:00
|
|
|
DELETEZ(m_pCache);
|
2000-11-03 13:42:50 +00:00
|
|
|
|
|
|
|
if(m_pTables)
|
|
|
|
{
|
2002-08-23 04:56:21 +00:00
|
|
|
m_pTables->dispose(); // clear all references
|
2001-01-04 13:25:58 +00:00
|
|
|
DELETEZ(m_pTables);
|
2000-11-03 13:42:50 +00:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2000-11-03 13:42:50 +00:00
|
|
|
m_xStatement = NULL;
|
|
|
|
m_xTypeMap = NULL;
|
2001-01-04 13:25:58 +00:00
|
|
|
|
2000-09-29 14:23:36 +00:00
|
|
|
m_aBookmark = Any();
|
|
|
|
m_bBeforeFirst = sal_True;
|
|
|
|
m_bAfterLast = sal_False;
|
|
|
|
m_bRowCountFinal= sal_False;
|
2000-10-17 09:19:03 +00:00
|
|
|
m_bNew = sal_False;
|
|
|
|
m_bModified = sal_False;
|
2000-09-29 14:23:36 +00:00
|
|
|
m_nRowCount = 0;
|
2001-02-23 14:22:32 +00:00
|
|
|
m_aOldRow = NULL;
|
2000-09-29 14:23:36 +00:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2001-04-12 08:32:26 +00:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
// -------------------------------------------------------------------------
|
2001-04-12 08:32:26 +00:00
|
|
|
void ORowSet::setActiveConnection( Reference< XConnection >& _rxNewConn, sal_Bool _bFireEvent )
|
|
|
|
{
|
|
|
|
if (_rxNewConn.get() == m_xActiveConnection.get())
|
|
|
|
// nothing to do
|
|
|
|
return;
|
|
|
|
|
|
|
|
// remove the event listener for the old connection
|
|
|
|
Reference< XComponent > xComponent(m_xActiveConnection, UNO_QUERY);
|
|
|
|
if (xComponent.is())
|
|
|
|
{
|
|
|
|
Reference<XEventListener> xListener;
|
|
|
|
query_aggregation(this, xListener);
|
|
|
|
xComponent->removeEventListener(xListener);
|
|
|
|
}
|
|
|
|
|
2001-05-07 10:11:15 +00:00
|
|
|
// if we owned the connection, remember it for later disposing
|
2001-04-12 08:32:26 +00:00
|
|
|
if(m_bOwnConnection)
|
2001-05-07 10:11:15 +00:00
|
|
|
m_xOldConnection = m_xActiveConnection;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2001-04-12 08:32:26 +00:00
|
|
|
// for firing the PropertyChangeEvent
|
|
|
|
sal_Int32 nHandle = PROPERTY_ID_ACTIVECONNECTION;
|
|
|
|
Any aOldConnection; aOldConnection <<= m_xActiveConnection;
|
|
|
|
Any aNewConnection; aNewConnection <<= _rxNewConn;
|
|
|
|
|
|
|
|
// set the new connection
|
|
|
|
m_xActiveConnection = _rxNewConn;
|
|
|
|
if (m_xActiveConnection.is())
|
|
|
|
m_aActiveConnection <<= m_xActiveConnection;
|
|
|
|
else
|
|
|
|
m_aActiveConnection.clear();
|
|
|
|
|
|
|
|
// fire the event
|
|
|
|
if (_bFireEvent)
|
2001-11-08 07:46:06 +00:00
|
|
|
fire(&nHandle, &aNewConnection, &aOldConnection, 1, sal_False);
|
2001-04-12 08:32:26 +00:00
|
|
|
|
|
|
|
// register as event listener for the new connection
|
|
|
|
xComponent = Reference< XComponent >(m_xActiveConnection, UNO_QUERY);
|
|
|
|
if (xComponent.is())
|
|
|
|
{
|
|
|
|
Reference<XEventListener> xListener;
|
|
|
|
query_aggregation(this, xListener);
|
|
|
|
xComponent->addEventListener(xListener);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
2000-11-03 13:42:50 +00:00
|
|
|
// ::com::sun::star::XEventListener
|
2000-09-18 23:16:46 +00:00
|
|
|
void SAL_CALL ORowSet::disposing( const ::com::sun::star::lang::EventObject& Source ) throw(RuntimeException)
|
|
|
|
{
|
|
|
|
// close rowset because the connection is going to be deleted (someone told me :-)
|
2000-12-14 12:51:21 +00:00
|
|
|
Reference<XConnection> xCon(Source.Source,UNO_QUERY);
|
|
|
|
if(m_xActiveConnection == xCon)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2000-12-14 12:51:21 +00:00
|
|
|
close();
|
|
|
|
{
|
|
|
|
MutexGuard aGuard( m_aMutex );
|
2001-11-01 14:27:20 +00:00
|
|
|
Reference< XConnection > xXConnection;
|
|
|
|
setActiveConnection( xXConnection );
|
2000-12-14 12:51:21 +00:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// XCloseable
|
|
|
|
void SAL_CALL ORowSet::close( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
if(m_pCache)
|
|
|
|
m_pCache->close();
|
|
|
|
{
|
|
|
|
MutexGuard aGuard( m_aMutex );
|
2001-06-26 09:12:41 +00:00
|
|
|
::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// additionals things to set
|
|
|
|
m_bCreateStatement = sal_True;
|
2000-11-03 13:42:50 +00:00
|
|
|
freeResources();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
2000-10-11 10:21:40 +00:00
|
|
|
// comphelper::OPropertyArrayUsageHelper
|
2000-09-18 23:16:46 +00:00
|
|
|
::cppu::IPropertyArrayHelper* ORowSet::createArrayHelper( ) const
|
|
|
|
{
|
|
|
|
Sequence< Property > aProps;
|
|
|
|
describeProperties(aProps);
|
|
|
|
return new ::cppu::OPropertyArrayHelper(aProps);
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
// cppu::OPropertySetHelper
|
|
|
|
::cppu::IPropertyArrayHelper& SAL_CALL ORowSet::getInfoHelper()
|
|
|
|
{
|
2000-10-11 10:21:40 +00:00
|
|
|
typedef ::comphelper::OPropertyArrayUsageHelper<ORowSet> ORowSet_PROP;
|
2000-09-18 23:16:46 +00:00
|
|
|
return *ORowSet_PROP::getArrayHelper();
|
|
|
|
}
|
2001-06-26 09:12:41 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void ORowSet::updateValue(sal_Int32 columnIndex,const ORowSetValue& x)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
|
2000-09-29 14:23:36 +00:00
|
|
|
|
2001-11-15 09:42:42 +00:00
|
|
|
::osl::MutexGuard aGuard( *m_pMutex );
|
2001-06-26 09:12:41 +00:00
|
|
|
checkUpdateConditions(columnIndex);
|
2001-01-22 06:38:24 +00:00
|
|
|
checkUpdateIterator();
|
2001-02-19 13:35:05 +00:00
|
|
|
|
2001-08-24 05:40:35 +00:00
|
|
|
::connectivity::ORowSetValue aOldValue((*(*m_aCurrentRow))[columnIndex]);
|
2001-06-26 09:12:41 +00:00
|
|
|
m_pCache->updateValue(columnIndex,x);
|
|
|
|
// we have to notify all listeners
|
|
|
|
(*(*m_aCurrentRow))[columnIndex] = x;
|
|
|
|
firePropertyChange(columnIndex-1 ,aOldValue);
|
2000-09-29 14:23:36 +00:00
|
|
|
fireProperty(PROPERTY_ID_ISMODIFIED,sal_True,sal_False);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
2001-06-26 09:12:41 +00:00
|
|
|
// XRowUpdate
|
|
|
|
void SAL_CALL ORowSet::updateNull( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
updateValue(columnIndex,ORowSetValue());
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
2000-09-18 23:16:46 +00:00
|
|
|
void SAL_CALL ORowSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
updateValue(columnIndex,x);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
updateValue(columnIndex,x);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
updateValue(columnIndex,x);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
updateValue(columnIndex,x);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-09-20 11:59:25 +00:00
|
|
|
updateValue(columnIndex,x);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::updateFloat( sal_Int32 columnIndex, float x ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
updateValue(columnIndex,x);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::updateDouble( sal_Int32 columnIndex, double x ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
updateValue(columnIndex,x);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
updateValue(columnIndex,x);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::updateBytes( sal_Int32 columnIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
updateValue(columnIndex,x);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
updateValue(columnIndex,x);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
updateValue(columnIndex,x);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
updateValue(columnIndex,x);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::updateBinaryStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
|
2000-09-29 14:23:36 +00:00
|
|
|
|
2001-11-15 09:42:42 +00:00
|
|
|
::osl::MutexGuard aGuard( *m_pMutex );
|
2001-06-26 09:12:41 +00:00
|
|
|
|
|
|
|
checkUpdateConditions(columnIndex);
|
|
|
|
|
2001-01-22 06:38:24 +00:00
|
|
|
checkUpdateIterator();
|
2001-08-24 05:40:35 +00:00
|
|
|
::connectivity::ORowSetValue aOldValue;
|
2001-05-28 08:09:29 +00:00
|
|
|
if((*(*m_aCurrentRow))[columnIndex].getTypeKind() == DataType::BLOB)
|
|
|
|
{
|
|
|
|
m_pCache->updateBinaryStream(columnIndex,x,length);
|
2001-08-24 05:40:35 +00:00
|
|
|
aOldValue = (*(*m_aCurrentRow))[columnIndex];
|
2001-05-28 08:09:29 +00:00
|
|
|
(*(*m_aCurrentRow))[columnIndex] = makeAny(x);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Sequence<sal_Int8> aSeq;
|
|
|
|
if(x.is())
|
|
|
|
x->readSomeBytes(aSeq,length);
|
2001-06-26 09:12:41 +00:00
|
|
|
updateValue(columnIndex,aSeq);
|
2001-08-24 05:40:35 +00:00
|
|
|
aOldValue = (*(*m_aCurrentRow))[columnIndex];
|
2001-05-28 08:09:29 +00:00
|
|
|
(*(*m_aCurrentRow))[columnIndex] = aSeq;
|
|
|
|
}
|
2000-09-29 14:23:36 +00:00
|
|
|
|
|
|
|
firePropertyChange(columnIndex-1 ,aOldValue);
|
|
|
|
fireProperty(PROPERTY_ID_ISMODIFIED,sal_True,sal_False);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::updateCharacterStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
|
2000-09-29 14:23:36 +00:00
|
|
|
|
2001-11-15 09:42:42 +00:00
|
|
|
::osl::MutexGuard aGuard( *m_pMutex );
|
2001-06-26 09:12:41 +00:00
|
|
|
checkUpdateConditions(columnIndex);
|
|
|
|
|
2001-01-22 06:38:24 +00:00
|
|
|
checkUpdateIterator();
|
2000-09-18 23:16:46 +00:00
|
|
|
m_pCache->updateCharacterStream(columnIndex,x,length);
|
2000-09-29 14:23:36 +00:00
|
|
|
|
2001-08-24 05:40:35 +00:00
|
|
|
::connectivity::ORowSetValue aOldValue((*(*m_aCurrentRow))[columnIndex]);
|
2000-09-29 14:23:36 +00:00
|
|
|
(*(*m_aCurrentRow))[columnIndex] = makeAny(x);
|
|
|
|
firePropertyChange(columnIndex-1 ,aOldValue);
|
|
|
|
fireProperty(PROPERTY_ID_ISMODIFIED,sal_True,sal_False);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::updateObject( sal_Int32 columnIndex, const Any& x ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
|
2000-09-29 14:23:36 +00:00
|
|
|
|
2001-11-15 09:42:42 +00:00
|
|
|
::osl::MutexGuard aGuard( *m_pMutex );
|
2001-06-26 09:12:41 +00:00
|
|
|
checkUpdateConditions(columnIndex);
|
|
|
|
|
2001-01-22 06:38:24 +00:00
|
|
|
checkUpdateIterator();
|
2001-06-26 08:29:13 +00:00
|
|
|
|
2002-09-27 12:02:06 +00:00
|
|
|
Any aNewValue = x;
|
|
|
|
|
|
|
|
if ( m_pColumns )
|
|
|
|
{
|
|
|
|
Reference<XPropertySet> xColumn;
|
|
|
|
m_pColumns->getByIndex(columnIndex-1) >>= xColumn;
|
|
|
|
sal_Int32 nColType;
|
|
|
|
xColumn->getPropertyValue(PROPERTY_TYPE) >>= nColType;
|
|
|
|
switch( nColType )
|
|
|
|
{
|
|
|
|
case DataType::DATE:
|
|
|
|
case DataType::TIME:
|
|
|
|
case DataType::TIMESTAMP:
|
|
|
|
{
|
|
|
|
double nValue;
|
|
|
|
if ( x >>= nValue )
|
|
|
|
{
|
|
|
|
if ( DataType::TIMESTAMP == nColType )
|
|
|
|
aNewValue <<= dbtools::DBTypeConversion::toDateTime( nValue );
|
|
|
|
else if ( DataType::DATE == nColType )
|
|
|
|
aNewValue <<= dbtools::DBTypeConversion::toDate( nValue );
|
|
|
|
else
|
|
|
|
aNewValue <<= dbtools::DBTypeConversion::toTime( nValue );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!::dbtools::implUpdateObject(this, columnIndex, aNewValue))
|
2001-06-26 08:29:13 +00:00
|
|
|
{ // there is no other updateXXX call which can handle the value in x
|
2001-08-24 05:40:35 +00:00
|
|
|
::connectivity::ORowSetValue aOldValue((*(*m_aCurrentRow))[columnIndex]);
|
2002-09-27 12:02:06 +00:00
|
|
|
m_pCache->updateObject(columnIndex,aNewValue);
|
2001-06-26 08:29:13 +00:00
|
|
|
// we have to notify all listeners
|
2002-09-27 12:02:06 +00:00
|
|
|
(*(*m_aCurrentRow))[columnIndex] = aNewValue;
|
2001-06-26 08:29:13 +00:00
|
|
|
firePropertyChange(columnIndex-1 ,aOldValue);
|
|
|
|
fireProperty(PROPERTY_ID_ISMODIFIED,sal_True,sal_False);
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal_Int32 scale ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
|
2000-09-29 14:23:36 +00:00
|
|
|
|
2001-11-15 09:42:42 +00:00
|
|
|
::osl::MutexGuard aGuard( *m_pMutex );
|
2001-06-26 09:12:41 +00:00
|
|
|
checkUpdateConditions(columnIndex);
|
|
|
|
|
2001-01-22 06:38:24 +00:00
|
|
|
checkUpdateIterator();
|
2001-08-24 05:40:35 +00:00
|
|
|
::connectivity::ORowSetValue aOldValue((*(*m_aCurrentRow))[columnIndex]);
|
2000-09-18 23:16:46 +00:00
|
|
|
m_pCache->updateNumericObject(columnIndex,x,scale);
|
2000-10-04 12:34:40 +00:00
|
|
|
// we have to notify all listeners
|
|
|
|
(*(*m_aCurrentRow))[columnIndex] = x;
|
|
|
|
firePropertyChange(columnIndex-1 ,aOldValue);
|
2000-09-29 14:23:36 +00:00
|
|
|
fireProperty(PROPERTY_ID_ISMODIFIED,sal_True,sal_False);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// XResultSetUpdate
|
|
|
|
void SAL_CALL ORowSet::insertRow( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
|
2001-04-05 06:51:27 +00:00
|
|
|
// insertRow is not allowd when
|
|
|
|
// standing not on the insert row nor
|
|
|
|
// when the row isn't modified
|
|
|
|
// or the concurency is read only
|
2002-08-13 10:13:00 +00:00
|
|
|
::osl::ResettableMutexGuard aGuard( *m_pMutex );
|
2001-04-05 06:51:27 +00:00
|
|
|
if(!m_pCache || !m_bNew || !m_bModified || m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY)
|
2001-04-19 06:14:49 +00:00
|
|
|
throwFunctionSequenceException(*this);
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2000-10-17 09:19:03 +00:00
|
|
|
if(m_bModified)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2000-09-29 14:23:36 +00:00
|
|
|
// remember old value for fire
|
2000-10-17 09:19:03 +00:00
|
|
|
sal_Bool bOld = m_bNew;
|
2000-09-29 14:23:36 +00:00
|
|
|
|
2002-12-05 13:50:03 +00:00
|
|
|
ORowSetRow aOldValues;
|
|
|
|
if ( !m_aCurrentRow.isNull() )
|
|
|
|
aOldValues = new ORowSetValueVector( m_aCurrentRow->getBody() );
|
2000-09-29 14:23:36 +00:00
|
|
|
RowChangeEvent aEvt(*this,RowChangeAction::INSERT,1);
|
2002-08-13 10:13:00 +00:00
|
|
|
if(notifyAllListenersRowBeforeChange(aGuard,aEvt))
|
2001-01-22 06:38:24 +00:00
|
|
|
{
|
2001-11-15 09:42:42 +00:00
|
|
|
::osl::MutexGuard aCacheGuard( *m_pMutex);
|
2001-01-22 06:38:24 +00:00
|
|
|
m_pCache->insertRow();
|
2002-12-05 08:53:00 +00:00
|
|
|
|
|
|
|
// notification order
|
|
|
|
// - column values
|
2002-08-13 10:13:00 +00:00
|
|
|
setCurrentRow(sal_False,aOldValues,aGuard); // we don't move here
|
2000-09-29 14:23:36 +00:00
|
|
|
|
2002-12-05 08:53:00 +00:00
|
|
|
// - rowChanged
|
2002-08-13 10:13:00 +00:00
|
|
|
notifyAllListenersRowChanged(aGuard,aEvt);
|
2000-12-06 08:55:44 +00:00
|
|
|
|
2002-12-05 08:53:00 +00:00
|
|
|
// - IsModified
|
2001-04-06 09:19:13 +00:00
|
|
|
if(!m_bModified)
|
|
|
|
fireProperty(PROPERTY_ID_ISMODIFIED,sal_False,sal_True);
|
2002-12-05 08:53:00 +00:00
|
|
|
OSL_ENSURE( !m_bModified, "ORowSet::insertRow: just updated, but _still_ modified?" );
|
|
|
|
|
|
|
|
// - IsNew
|
|
|
|
if(m_bNew != bOld)
|
|
|
|
fireProperty(PROPERTY_ID_ISNEW,m_bNew,bOld);
|
2000-09-29 14:23:36 +00:00
|
|
|
|
2002-12-05 08:53:00 +00:00
|
|
|
// - RowCount/IsRowCountFinal
|
2001-04-06 09:19:13 +00:00
|
|
|
fireRowcount();
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
2000-09-29 14:23:36 +00:00
|
|
|
sal_Int32 SAL_CALL ORowSet::getRow( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aRowCountMutex );
|
2001-06-26 09:12:41 +00:00
|
|
|
checkCache();
|
|
|
|
|
2000-09-29 14:23:36 +00:00
|
|
|
// check if we are inserting a row
|
2002-12-05 08:53:00 +00:00
|
|
|
return (m_pCache && ( m_pCache->m_bInserted || m_bModified )) ? 0 : ORowSetBase::getRow();
|
2000-09-29 14:23:36 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
2000-09-18 23:16:46 +00:00
|
|
|
void SAL_CALL ORowSet::updateRow( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
|
2001-04-05 06:51:27 +00:00
|
|
|
// not allowed when standing on insert row
|
2002-08-13 10:13:00 +00:00
|
|
|
::osl::ResettableMutexGuard aGuard( *m_pMutex );
|
2001-04-05 06:51:27 +00:00
|
|
|
if(!m_pCache || m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY || m_bNew)
|
2001-04-19 06:14:49 +00:00
|
|
|
throwFunctionSequenceException(*this);
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2000-10-17 09:19:03 +00:00
|
|
|
if(m_bModified)
|
2000-09-29 14:23:36 +00:00
|
|
|
{
|
2002-12-05 13:10:11 +00:00
|
|
|
ORowSetRow aOldValues = new ORowSetValueVector( m_aCurrentRow->getBody() );
|
2000-12-06 08:55:44 +00:00
|
|
|
|
2000-09-29 14:23:36 +00:00
|
|
|
RowChangeEvent aEvt(*this,RowChangeAction::UPDATE,1);
|
2002-08-13 10:13:00 +00:00
|
|
|
if(notifyAllListenersRowBeforeChange(aGuard,aEvt))
|
2001-04-06 09:19:13 +00:00
|
|
|
{
|
|
|
|
m_pCache->updateRow(m_aCurrentRow.operator ->());
|
|
|
|
m_aBookmark = m_pCache->getBookmark();
|
|
|
|
m_aCurrentRow = m_pCache->m_aMatrixIter;
|
2001-08-08 09:05:57 +00:00
|
|
|
m_aOldRow = (*m_aCurrentRow);
|
2000-09-29 14:23:36 +00:00
|
|
|
|
2002-12-05 08:53:00 +00:00
|
|
|
// notification order
|
|
|
|
// - column values
|
2001-04-06 09:19:13 +00:00
|
|
|
ORowSetBase::firePropertyChange(aOldValues);
|
2002-12-05 08:53:00 +00:00
|
|
|
|
|
|
|
// - rowChanged
|
|
|
|
notifyAllListenersRowChanged(aGuard,aEvt);
|
|
|
|
|
|
|
|
// - IsModified
|
2001-04-06 09:19:13 +00:00
|
|
|
if(!m_bModified)
|
|
|
|
fireProperty(PROPERTY_ID_ISMODIFIED,sal_False,sal_True);
|
2002-12-05 08:53:00 +00:00
|
|
|
OSL_ENSURE( !m_bModified, "ORowSet::updateRow: just updated, but _still_ modified?" );
|
2001-04-06 09:19:13 +00:00
|
|
|
}
|
2000-09-29 14:23:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
2000-09-18 23:16:46 +00:00
|
|
|
void SAL_CALL ORowSet::deleteRow( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2002-08-13 10:13:00 +00:00
|
|
|
::osl::ResettableMutexGuard aGuard( *m_pMutex );
|
2001-04-05 06:51:27 +00:00
|
|
|
// deleteRow is not allowed when:
|
|
|
|
// stands before the first row
|
|
|
|
// after the last row
|
|
|
|
// stands on the insert row
|
|
|
|
// the concurrency is read only
|
|
|
|
if(!m_pCache || m_bBeforeFirst || m_bAfterLast || m_bNew || m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY)
|
2001-04-19 06:14:49 +00:00
|
|
|
throwFunctionSequenceException(*this);
|
2001-04-05 06:51:27 +00:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2000-12-06 08:55:44 +00:00
|
|
|
// this call position the cache indirect
|
|
|
|
notifyClonesRowDelete(m_aBookmark);
|
|
|
|
|
2001-06-22 12:08:06 +00:00
|
|
|
positionCache();
|
2000-09-29 14:23:36 +00:00
|
|
|
|
2002-12-05 13:10:11 +00:00
|
|
|
ORowSetRow aOldValues = new ORowSetValueVector( m_pCache->m_aMatrixIter->getBody() );
|
2000-12-06 08:55:44 +00:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
RowChangeEvent aEvt(*this,RowChangeAction::DELETE,1);
|
2002-08-13 10:13:00 +00:00
|
|
|
if(notifyAllListenersRowBeforeChange(aGuard,aEvt))
|
2001-04-06 09:19:13 +00:00
|
|
|
{
|
|
|
|
m_nPosition = m_pCache->getRow();
|
|
|
|
m_pCache->deleteRow();
|
|
|
|
notifyClonesRowDeleted(m_aBookmark);
|
2000-12-06 08:55:44 +00:00
|
|
|
|
2001-04-06 09:19:13 +00:00
|
|
|
m_aBookmark = Any();
|
|
|
|
m_aCurrentRow = NULL;
|
|
|
|
m_aCurrentRow.setBookmark(Any());
|
2000-12-06 08:55:44 +00:00
|
|
|
|
2002-12-05 08:53:00 +00:00
|
|
|
ORowSetNotifier aNotifier( this );
|
|
|
|
// this will call cancelRowModification on the cache if necessary
|
|
|
|
|
|
|
|
// notification order
|
|
|
|
// - rowChanged
|
2002-08-13 10:13:00 +00:00
|
|
|
notifyAllListenersRowChanged(aGuard,aEvt);
|
2002-12-05 08:53:00 +00:00
|
|
|
|
|
|
|
// - IsModified
|
|
|
|
// - IsNew
|
|
|
|
aNotifier.fire( );
|
|
|
|
|
|
|
|
// - RowCount/IsRowCountFinal
|
2001-04-06 09:19:13 +00:00
|
|
|
fireRowcount();
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
2002-12-05 08:53:00 +00:00
|
|
|
void ORowSet::implCancelRowUpdates( sal_Bool _bNotifyModified ) SAL_THROW( ( SQLException, RuntimeException ) )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2001-11-15 09:42:42 +00:00
|
|
|
::osl::MutexGuard aGuard( *m_pMutex );
|
2001-04-05 06:51:27 +00:00
|
|
|
if(m_bBeforeFirst || m_bAfterLast)
|
|
|
|
return; // nothing to do so return
|
|
|
|
|
|
|
|
// cancelRowUpdates is not allowed when:
|
|
|
|
// standing on the insert row
|
|
|
|
// the concurrency is read only
|
|
|
|
if(!m_pCache || m_bNew || m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY)
|
2001-04-19 06:14:49 +00:00
|
|
|
throwFunctionSequenceException(*this);
|
2001-01-22 06:38:24 +00:00
|
|
|
|
2001-06-22 12:08:06 +00:00
|
|
|
positionCache();
|
2001-04-03 07:28:23 +00:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
m_pCache->cancelRowUpdates();
|
2002-12-05 13:10:11 +00:00
|
|
|
ORowSetRow aOldValues = new ORowSetValueVector( m_aCurrentRow->getBody() );
|
2001-01-22 06:38:24 +00:00
|
|
|
|
|
|
|
m_aBookmark = m_pCache->getBookmark();
|
|
|
|
m_aCurrentRow = m_pCache->m_aMatrixIter;
|
|
|
|
m_aCurrentRow.setBookmark(m_aBookmark);
|
|
|
|
|
2002-12-05 08:53:00 +00:00
|
|
|
// notification order
|
|
|
|
// - column values
|
2001-01-22 06:38:24 +00:00
|
|
|
ORowSetBase::firePropertyChange(aOldValues);
|
2002-12-05 08:53:00 +00:00
|
|
|
// IsModified
|
|
|
|
if( !m_bModified && _bNotifyModified )
|
2001-01-22 06:38:24 +00:00
|
|
|
fireProperty(PROPERTY_ID_ISMODIFIED,sal_False,sal_True);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2002-12-05 08:53:00 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::cancelRowUpdates( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
implCancelRowUpdates( sal_True );
|
|
|
|
}
|
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
// -------------------------------------------------------------------------
|
2000-09-29 14:23:36 +00:00
|
|
|
void SAL_CALL ORowSet::addRowSetListener( const Reference< XRowSetListener >& listener ) throw(RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
|
2000-09-29 14:23:36 +00:00
|
|
|
|
|
|
|
::osl::MutexGuard aGuard( m_aColumnsMutex );
|
2001-04-11 05:21:02 +00:00
|
|
|
if(listener.is())
|
2001-08-06 10:01:19 +00:00
|
|
|
m_aRowsetListeners.addInterface(listener);
|
2000-09-29 14:23:36 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::removeRowSetListener( const Reference< XRowSetListener >& listener ) throw(RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
|
2000-09-29 14:23:36 +00:00
|
|
|
|
|
|
|
::osl::MutexGuard aGuard( m_aColumnsMutex );
|
2001-04-11 05:21:02 +00:00
|
|
|
if(listener.is())
|
2001-08-06 10:01:19 +00:00
|
|
|
m_aRowsetListeners.removeInterface(listener);
|
2000-09-29 14:23:36 +00:00
|
|
|
}
|
2002-08-13 10:13:00 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void ORowSet::notifyAllListeners(::osl::ResettableMutexGuard& _rGuard)
|
2000-09-29 14:23:36 +00:00
|
|
|
{
|
|
|
|
EventObject aEvt(*m_pMySelf);
|
2002-08-13 10:13:00 +00:00
|
|
|
NOTIFY_LISTERNERS(m_aRowsetListeners,XRowSetListener,rowSetChanged);
|
2000-09-29 14:23:36 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
2002-08-13 10:13:00 +00:00
|
|
|
void ORowSet::notifyAllListenersCursorMoved(::osl::ResettableMutexGuard& _rGuard)
|
2000-09-29 14:23:36 +00:00
|
|
|
{
|
|
|
|
EventObject aEvt(*m_pMySelf);
|
2002-08-13 10:13:00 +00:00
|
|
|
NOTIFY_LISTERNERS(m_aRowsetListeners,XRowSetListener,cursorMoved);
|
2000-09-29 14:23:36 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
2002-08-13 10:13:00 +00:00
|
|
|
void ORowSet::notifyAllListenersRowChanged(::osl::ResettableMutexGuard& _rGuard,const RowChangeEvent &aEvt)
|
2000-09-29 14:23:36 +00:00
|
|
|
{
|
2002-08-13 10:13:00 +00:00
|
|
|
NOTIFY_LISTERNERS(m_aRowsetListeners,XRowSetListener,rowChanged);
|
2000-09-29 14:23:36 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
2002-08-13 10:13:00 +00:00
|
|
|
sal_Bool ORowSet::notifyAllListenersCursorBeforeMove(::osl::ResettableMutexGuard& _rGuard)
|
2000-09-29 14:23:36 +00:00
|
|
|
{
|
|
|
|
EventObject aEvt(*m_pMySelf);
|
2002-08-13 10:13:00 +00:00
|
|
|
NOTIFY_LISTERNERS_CHECK(m_aApproveListeners,XRowSetApproveListener,approveCursorMove);
|
|
|
|
return bCheck;
|
2000-09-29 14:23:36 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
2002-08-13 10:13:00 +00:00
|
|
|
sal_Bool ORowSet::notifyAllListenersRowBeforeChange(::osl::ResettableMutexGuard& _rGuard,const RowChangeEvent &aEvt)
|
2000-09-29 14:23:36 +00:00
|
|
|
{
|
2002-08-13 10:13:00 +00:00
|
|
|
NOTIFY_LISTERNERS_CHECK(m_aApproveListeners,XRowSetApproveListener,approveRowChange);
|
|
|
|
return bCheck;
|
2000-09-29 14:23:36 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void ORowSet::fireRowcount()
|
|
|
|
{
|
|
|
|
if(m_nRowCount != m_pCache->m_nRowCount)
|
|
|
|
{
|
|
|
|
sal_Int32 nHandle = PROPERTY_ID_ROWCOUNT;
|
|
|
|
Any aNew,aOld;
|
|
|
|
aNew <<= m_pCache->m_nRowCount;aOld <<= m_nRowCount;
|
|
|
|
fire(&nHandle,&aNew,&aOld,1,sal_False);
|
|
|
|
m_nRowCount = m_pCache->m_nRowCount;
|
|
|
|
}
|
|
|
|
if(!m_bRowCountFinal && m_bRowCountFinal != m_pCache->m_bRowCountFinal)
|
|
|
|
{
|
|
|
|
sal_Int32 nHandle = PROPERTY_ID_ISROWCOUNTFINAL;
|
|
|
|
Any aNew,aOld;
|
|
|
|
aNew <<= bool2any(m_pCache->m_bRowCountFinal);
|
|
|
|
aOld <<= bool2any(m_bRowCountFinal);
|
|
|
|
fire(&nHandle,&aNew,&aOld,1,sal_False);
|
|
|
|
m_bRowCountFinal = m_pCache->m_bRowCountFinal;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
2000-09-18 23:16:46 +00:00
|
|
|
void SAL_CALL ORowSet::moveToInsertRow( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2002-08-13 10:13:00 +00:00
|
|
|
::osl::ResettableMutexGuard aGuard( *m_pMutex );
|
2001-08-27 08:16:48 +00:00
|
|
|
checkPositioningAllowed();
|
2000-09-29 14:23:36 +00:00
|
|
|
|
2002-08-13 10:13:00 +00:00
|
|
|
if(notifyAllListenersCursorBeforeMove(aGuard))
|
2001-04-06 09:19:13 +00:00
|
|
|
{
|
|
|
|
// remember old value for fire
|
2001-06-29 07:30:40 +00:00
|
|
|
// check before because the resultset could be empty
|
|
|
|
if(m_aBookmark.hasValue())
|
|
|
|
positionCache();
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2002-12-05 13:50:03 +00:00
|
|
|
ORowSetRow aOldValues;
|
|
|
|
if ( !m_bBeforeFirst && !m_bAfterLast && m_pCache->m_aMatrixIter != m_pCache->getEnd() )
|
|
|
|
aOldValues = new ORowSetValueVector( m_pCache->m_aMatrixIter->getBody() );
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2002-12-05 08:53:00 +00:00
|
|
|
const sal_Bool bNewState = m_bNew;
|
|
|
|
const sal_Bool bModState = m_bModified;
|
2001-04-06 09:19:13 +00:00
|
|
|
|
|
|
|
m_pCache->moveToInsertRow();
|
|
|
|
m_aCurrentRow = m_pCache->m_aInsertRow;
|
2002-08-13 10:13:00 +00:00
|
|
|
|
2002-12-05 08:53:00 +00:00
|
|
|
// notification order
|
|
|
|
// - column values
|
2001-04-06 09:19:13 +00:00
|
|
|
ORowSetBase::firePropertyChange(aOldValues);
|
|
|
|
|
2002-12-05 08:53:00 +00:00
|
|
|
// - cursorMoved
|
|
|
|
notifyAllListenersCursorMoved(aGuard);
|
|
|
|
|
|
|
|
// - IsModified
|
|
|
|
if ( bModState != m_bModified )
|
|
|
|
fireProperty( PROPERTY_ID_ISMODIFIED, m_bModified, bModState );
|
|
|
|
|
|
|
|
// - IsNew
|
|
|
|
if ( bNewState != m_bNew )
|
|
|
|
fireProperty( PROPERTY_ID_ISNEW, m_bNew, bNewState );
|
2001-04-06 09:19:13 +00:00
|
|
|
}
|
2000-09-29 14:23:36 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::moveToCurrentRow( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
|
|
|
|
|
2002-08-13 10:13:00 +00:00
|
|
|
::osl::ResettableMutexGuard aGuard( *m_pMutex );
|
2000-09-29 14:23:36 +00:00
|
|
|
|
2001-08-27 08:16:48 +00:00
|
|
|
checkPositioningAllowed();
|
2000-09-29 14:23:36 +00:00
|
|
|
|
2002-12-05 08:53:00 +00:00
|
|
|
if(m_pCache && ( m_pCache->m_bInserted || m_bModified ))
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2002-08-13 10:13:00 +00:00
|
|
|
if(notifyAllListenersCursorBeforeMove(aGuard))
|
2001-04-06 09:19:13 +00:00
|
|
|
{
|
2001-06-22 12:08:06 +00:00
|
|
|
positionCache();
|
2001-04-06 09:19:13 +00:00
|
|
|
m_pCache->moveToCurrentRow();
|
2002-12-05 08:53:00 +00:00
|
|
|
|
|
|
|
ORowSetNotifier aNotifier( this );
|
|
|
|
// this will call cancelRowModification on the cache if necessary
|
|
|
|
|
|
|
|
// notification order
|
|
|
|
// - cursorMoved
|
2002-08-13 10:13:00 +00:00
|
|
|
notifyAllListenersCursorMoved(aGuard);
|
2000-09-29 14:23:36 +00:00
|
|
|
|
2002-12-05 08:53:00 +00:00
|
|
|
// - IsModified
|
|
|
|
// - IsNew
|
|
|
|
aNotifier.fire();
|
2001-04-06 09:19:13 +00:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
2000-09-29 14:23:36 +00:00
|
|
|
// XRow
|
|
|
|
sal_Bool SAL_CALL ORowSet::wasNull( ) throw(SQLException, RuntimeException)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-11-15 09:42:42 +00:00
|
|
|
::osl::MutexGuard aGuard( *m_pMutex );
|
2001-06-26 09:12:41 +00:00
|
|
|
checkCache();
|
2000-09-29 14:23:36 +00:00
|
|
|
|
2002-12-05 08:53:00 +00:00
|
|
|
return ( m_pCache && ( m_pCache->m_bInserted || m_bModified ) ) ? (*(*m_pCache->m_aInsertRow))[m_nLastColumnIndex].isNull() : ORowSetBase::wasNull();
|
2000-09-29 14:23:36 +00:00
|
|
|
}
|
2001-06-26 09:12:41 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2001-07-30 07:53:02 +00:00
|
|
|
const ORowSetValue& ORowSet::getInsertValue(sal_Int32 columnIndex)
|
2001-06-26 09:12:41 +00:00
|
|
|
{
|
2001-11-15 09:42:42 +00:00
|
|
|
::osl::MutexGuard aGuard( *m_pMutex );
|
2001-06-26 09:12:41 +00:00
|
|
|
checkCache();
|
|
|
|
|
2002-12-05 08:53:00 +00:00
|
|
|
if ( m_pCache && ( m_pCache->m_bInserted || m_bModified ) )
|
2001-10-11 14:30:38 +00:00
|
|
|
return (*(*m_pCache->m_aInsertRow))[m_nLastColumnIndex = columnIndex];
|
|
|
|
else
|
|
|
|
return getValue(columnIndex);
|
2001-06-26 09:12:41 +00:00
|
|
|
}
|
2000-09-29 14:23:36 +00:00
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
::rtl::OUString SAL_CALL ORowSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
return getInsertValue(columnIndex);
|
2000-09-29 14:23:36 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
sal_Bool SAL_CALL ORowSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
return getInsertValue(columnIndex);
|
2000-09-29 14:23:36 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
sal_Int8 SAL_CALL ORowSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
return getInsertValue(columnIndex);
|
2000-09-29 14:23:36 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
sal_Int16 SAL_CALL ORowSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
return getInsertValue(columnIndex);
|
2000-09-29 14:23:36 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
sal_Int32 SAL_CALL ORowSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
return getInsertValue(columnIndex);
|
2000-09-29 14:23:36 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
sal_Int64 SAL_CALL ORowSet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
return getInsertValue(columnIndex);
|
2000-09-29 14:23:36 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
float SAL_CALL ORowSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
return getInsertValue(columnIndex);
|
2000-09-29 14:23:36 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
double SAL_CALL ORowSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
return getInsertValue(columnIndex);
|
2000-09-29 14:23:36 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
Sequence< sal_Int8 > SAL_CALL ORowSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
return getInsertValue(columnIndex);
|
2000-09-29 14:23:36 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
::com::sun::star::util::Date SAL_CALL ORowSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
return getInsertValue(columnIndex);
|
2000-09-29 14:23:36 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
::com::sun::star::util::Time SAL_CALL ORowSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
return getInsertValue(columnIndex);
|
2000-09-29 14:23:36 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
::com::sun::star::util::DateTime SAL_CALL ORowSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
return getInsertValue(columnIndex);
|
2000-09-29 14:23:36 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
Reference< ::com::sun::star::io::XInputStream > SAL_CALL ORowSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-11-15 09:42:42 +00:00
|
|
|
::osl::MutexGuard aGuard( *m_pMutex );
|
2002-12-05 08:53:00 +00:00
|
|
|
if(m_pCache && ( m_pCache->m_bInserted || m_bModified ))
|
2000-09-29 14:23:36 +00:00
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
checkCache();
|
2000-10-11 10:21:40 +00:00
|
|
|
return new ::comphelper::SequenceInputStream((*(*m_pCache->m_aInsertRow))[m_nLastColumnIndex = columnIndex].getSequence());
|
2000-09-29 14:23:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ORowSetBase::getBinaryStream(columnIndex);
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
Reference< ::com::sun::star::io::XInputStream > SAL_CALL ORowSet::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-11-15 09:42:42 +00:00
|
|
|
::osl::MutexGuard aGuard( *m_pMutex );
|
2002-12-05 08:53:00 +00:00
|
|
|
if(m_pCache && ( m_pCache->m_bInserted || m_bModified ))
|
2000-09-29 14:23:36 +00:00
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
checkCache();
|
2000-10-11 10:21:40 +00:00
|
|
|
return new ::comphelper::SequenceInputStream((*(*m_pCache->m_aInsertRow))[m_nLastColumnIndex = columnIndex].getSequence());
|
2000-09-29 14:23:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ORowSetBase::getCharacterStream(columnIndex);
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
Any SAL_CALL ORowSet::getObject( sal_Int32 columnIndex, const Reference< XNameAccess >& typeMap ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-11-15 09:42:42 +00:00
|
|
|
::osl::MutexGuard aGuard( *m_pMutex );
|
2001-06-26 09:12:41 +00:00
|
|
|
checkCache();
|
2000-09-29 14:23:36 +00:00
|
|
|
|
|
|
|
return Any();
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
Reference< XRef > SAL_CALL ORowSet::getRef( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-11-15 09:42:42 +00:00
|
|
|
::osl::MutexGuard aGuard( *m_pMutex );
|
2001-06-26 09:12:41 +00:00
|
|
|
checkCache();
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2000-09-29 14:23:36 +00:00
|
|
|
return Reference< XRef >();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2000-09-29 14:23:36 +00:00
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
Reference< XBlob > SAL_CALL ORowSet::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-11-15 09:42:42 +00:00
|
|
|
::osl::MutexGuard aGuard( *m_pMutex );
|
2001-06-26 09:12:41 +00:00
|
|
|
checkCache();
|
2000-09-29 14:23:36 +00:00
|
|
|
|
|
|
|
return Reference< XBlob >();
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
Reference< XClob > SAL_CALL ORowSet::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-11-15 09:42:42 +00:00
|
|
|
::osl::MutexGuard aGuard( *m_pMutex );
|
2001-06-26 09:12:41 +00:00
|
|
|
checkCache();
|
2000-09-29 14:23:36 +00:00
|
|
|
|
|
|
|
return Reference< XClob >();
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
Reference< XArray > SAL_CALL ORowSet::getArray( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-11-15 09:42:42 +00:00
|
|
|
::osl::MutexGuard aGuard( *m_pMutex );
|
2001-06-26 09:12:41 +00:00
|
|
|
checkCache();
|
2000-09-29 14:23:36 +00:00
|
|
|
|
|
|
|
return Reference< XArray >();
|
|
|
|
}
|
2000-10-31 14:21:51 +00:00
|
|
|
// -------------------------------------------------------------------------
|
2000-11-06 11:14:23 +00:00
|
|
|
void SAL_CALL ORowSet::executeWithCompletion( const Reference< XInteractionHandler >& _rxHandler ) throw(SQLException, RuntimeException)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2000-11-06 11:14:23 +00:00
|
|
|
if (!_rxHandler.is())
|
|
|
|
execute();
|
|
|
|
|
2001-06-26 09:12:41 +00:00
|
|
|
::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
|
2000-11-03 13:42:50 +00:00
|
|
|
|
|
|
|
// tell everybody that we will change the result set
|
2000-11-06 11:14:23 +00:00
|
|
|
approveExecution();
|
|
|
|
|
2002-08-13 10:13:00 +00:00
|
|
|
ResettableMutexGuard aGuard( m_aMutex );
|
2000-11-06 11:14:23 +00:00
|
|
|
|
|
|
|
// create and fill a composer
|
|
|
|
Reference<XSQLQueryComposer> xComposer = getCurrentSettingsComposer(this, m_xServiceManager);
|
2001-01-26 14:00:05 +00:00
|
|
|
|
|
|
|
// we have to set this here again because getCurrentSettingsComposer can force a setpropertyvalue
|
2002-08-22 09:08:10 +00:00
|
|
|
|
|
|
|
// OJ: why? When the ActiveConnection is set again, m_bOwnConnection should be true
|
|
|
|
// m_bOwnConnection = sal_True;
|
2000-12-01 13:16:46 +00:00
|
|
|
try
|
2000-11-06 11:14:23 +00:00
|
|
|
{
|
2000-12-01 13:16:46 +00:00
|
|
|
freeResources();
|
2000-11-06 11:14:23 +00:00
|
|
|
|
2000-12-01 13:16:46 +00:00
|
|
|
// calc the connection to be used
|
2001-11-01 14:27:20 +00:00
|
|
|
if (m_xActiveConnection.is() && m_bRebuildConnOnExecute) {
|
2000-12-01 13:16:46 +00:00
|
|
|
// there was a setProperty(ActiveConnection), but a setProperty(DataSource) _after_ that, too
|
2001-11-01 14:27:20 +00:00
|
|
|
Reference< XConnection > xXConnection;
|
|
|
|
setActiveConnection( xXConnection );
|
|
|
|
}
|
2000-12-01 13:16:46 +00:00
|
|
|
calcConnection(_rxHandler);
|
|
|
|
m_bRebuildConnOnExecute = sal_False;
|
2001-06-22 09:48:40 +00:00
|
|
|
::dbtools::askForParameters(xComposer,this,m_xActiveConnection,_rxHandler);
|
2000-12-01 13:16:46 +00:00
|
|
|
}
|
|
|
|
// ensure that only the allowed exceptions leave this block
|
|
|
|
catch(SQLException&)
|
|
|
|
{
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
catch(RuntimeException&)
|
|
|
|
{
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
DBG_ERROR("ORowSet::executeWithCompletion: caught an unexpected exception type while filling in the parameters!");
|
2000-11-06 11:14:23 +00:00
|
|
|
}
|
|
|
|
|
2000-12-01 13:16:46 +00:00
|
|
|
// we're done with the parameters, now for the real execution
|
|
|
|
|
2000-11-06 11:14:23 +00:00
|
|
|
// do the real execute
|
|
|
|
execute_NoApprove_NoNewConn(aGuard);
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void ORowSet::approveExecution() throw (RowSetVetoException, RuntimeException)
|
|
|
|
{
|
2000-11-17 06:50:17 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aColumnsMutex );
|
2000-11-03 13:42:50 +00:00
|
|
|
EventObject aEvt(*this);
|
|
|
|
OInterfaceIteratorHelper aApproveIter(m_aApproveListeners);
|
|
|
|
while (aApproveIter.hasMoreElements())
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2000-11-03 13:42:50 +00:00
|
|
|
if (!((XRowSetApproveListener*)aApproveIter.next())->approveRowSetChange(aEvt))
|
|
|
|
throw RowSetVetoException();
|
|
|
|
}
|
2000-11-06 11:14:23 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
// XRowSet
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::execute( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
|
2000-11-03 13:42:50 +00:00
|
|
|
|
2000-11-06 11:14:23 +00:00
|
|
|
// tell everybody that we will change the result set
|
|
|
|
approveExecution();
|
2000-11-03 13:42:50 +00:00
|
|
|
|
2002-08-13 10:13:00 +00:00
|
|
|
ResettableMutexGuard aGuard( m_aMutex );
|
2000-11-06 11:14:23 +00:00
|
|
|
freeResources();
|
2000-11-03 13:42:50 +00:00
|
|
|
|
2000-11-06 11:14:23 +00:00
|
|
|
// calc the connection to be used
|
2001-11-01 14:27:20 +00:00
|
|
|
if (m_xActiveConnection.is() && m_bRebuildConnOnExecute) {
|
2000-11-06 11:14:23 +00:00
|
|
|
// there was a setProperty(ActiveConnection), but a setProperty(DataSource) _after_ that, too
|
2001-11-01 14:27:20 +00:00
|
|
|
Reference< XConnection> xXConnection;
|
|
|
|
setActiveConnection( xXConnection );
|
|
|
|
}
|
2000-11-03 13:42:50 +00:00
|
|
|
|
2000-12-01 13:16:46 +00:00
|
|
|
calcConnection(NULL);
|
2000-11-06 11:14:23 +00:00
|
|
|
m_bRebuildConnOnExecute = sal_False;
|
2000-09-29 14:23:36 +00:00
|
|
|
|
2000-11-06 11:14:23 +00:00
|
|
|
// do the real execute
|
|
|
|
execute_NoApprove_NoNewConn(aGuard);
|
2000-11-03 13:42:50 +00:00
|
|
|
|
2000-11-06 11:14:23 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// XRowSet
|
2002-08-13 10:13:00 +00:00
|
|
|
void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotification)
|
2000-11-06 11:14:23 +00:00
|
|
|
{
|
2001-05-07 10:11:15 +00:00
|
|
|
// now we can dispose our old connection
|
|
|
|
::comphelper::disposeComponent(m_xOldConnection);
|
|
|
|
m_xOldConnection = NULL;
|
|
|
|
|
2000-11-06 11:14:23 +00:00
|
|
|
::rtl::OUString aSql;
|
|
|
|
// do we need a new statement
|
|
|
|
if (m_bCreateStatement)
|
|
|
|
{
|
2001-05-07 10:11:15 +00:00
|
|
|
m_xStatement = NULL;
|
|
|
|
m_xComposer = NULL;
|
2000-11-06 11:14:23 +00:00
|
|
|
|
|
|
|
// Build the statement
|
|
|
|
sal_Bool bUseEscapeProcessing;
|
|
|
|
Reference< ::com::sun::star::container::XNameAccess > xTables;
|
|
|
|
// xTables will be filled in getCommand
|
|
|
|
m_aActiveCommand = getCommand(bUseEscapeProcessing,xTables);
|
2001-05-14 08:47:28 +00:00
|
|
|
if (!m_aActiveCommand.getLength())
|
2002-07-25 05:35:23 +00:00
|
|
|
throwGenericSQLException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Empty command submitted!")),*this);
|
2000-12-06 08:55:44 +00:00
|
|
|
|
|
|
|
{
|
2000-11-06 11:14:23 +00:00
|
|
|
m_xStatement = m_xActiveConnection->prepareStatement(
|
|
|
|
aSql = getComposedQuery(m_aActiveCommand, bUseEscapeProcessing,xTables));
|
|
|
|
|
2001-01-09 11:31:57 +00:00
|
|
|
if(m_xStatement.is())
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-01-09 11:31:57 +00:00
|
|
|
Reference<XPropertySet> xProp(m_xStatement,UNO_QUERY);
|
2001-08-29 11:21:08 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
xProp->setPropertyValue(PROPERTY_USEBOOKMARKS,makeAny(sal_True));
|
|
|
|
xProp->setPropertyValue(PROPERTY_RESULTSETTYPE,makeAny(ResultSetType::SCROLL_SENSITIVE));
|
2001-11-29 15:35:26 +00:00
|
|
|
xProp->setPropertyValue(PROPERTY_RESULTSETCONCURRENCY,makeAny(ResultSetConcurrency::UPDATABLE));
|
2001-08-29 11:21:08 +00:00
|
|
|
|
|
|
|
}
|
2001-09-18 10:24:33 +00:00
|
|
|
catch(Exception&)
|
2001-08-29 11:21:08 +00:00
|
|
|
{
|
|
|
|
// this exception doesn't matter here because when we catch an exception
|
|
|
|
// than the driver doesn't support this feature
|
|
|
|
}
|
2001-01-31 11:35:35 +00:00
|
|
|
// xProp->setPropertyValue(PROPERTY_RESULTSETTYPE,makeAny(m_nResultSetType));
|
|
|
|
// xProp->setPropertyValue(PROPERTY_RESULTSETCONCURRENCY,makeAny(m_nResultSetConcurrency));
|
|
|
|
// if(m_nFetchDirection != FetchDirection::FORWARD)
|
|
|
|
// xProp->setPropertyValue(PROPERTY_FETCHDIRECTION,makeAny((sal_Int32)m_nFetchDirection));
|
2001-01-09 11:31:57 +00:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2000-12-06 08:55:44 +00:00
|
|
|
Reference<XParameters> xParam(m_xStatement,UNO_QUERY);
|
|
|
|
sal_Int32 i = 1;
|
|
|
|
for(ORowVector< ORowSetValue >::const_iterator aIter = m_aParameterRow.begin(); aIter != m_aParameterRow.end();++aIter,++i)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-06-22 09:48:40 +00:00
|
|
|
::dbtools::setObjectWithInfo(xParam,i,aIter->makeAny(),aIter->getTypeKind());
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2001-07-09 06:00:18 +00:00
|
|
|
|
2000-12-06 08:55:44 +00:00
|
|
|
Reference< XResultSet> xRs = m_xStatement->executeQuery();
|
2001-01-09 11:31:57 +00:00
|
|
|
// create the composed table name
|
|
|
|
::rtl::OUString aComposedTableName;
|
|
|
|
if(m_aUpdateTableName.getLength())
|
2002-10-07 12:09:48 +00:00
|
|
|
composeTableName(m_xActiveConnection->getMetaData(),m_aUpdateCatalogName,m_aUpdateSchemaName,m_aUpdateTableName,aComposedTableName,sal_False,::dbtools::eInDataManipulation);
|
2001-01-09 11:31:57 +00:00
|
|
|
|
2001-07-19 08:29:22 +00:00
|
|
|
m_pCache = new ORowSetCache(xRs,m_xComposer,m_xServiceManager,m_aParameterRow,aComposedTableName,m_bModified,m_bNew);
|
2001-01-24 08:52:19 +00:00
|
|
|
m_pCache->setMaxRowSize(m_nFetchSize);
|
2001-02-23 14:22:32 +00:00
|
|
|
m_aCurrentRow = m_pCache->createIterator();
|
2001-07-09 06:00:18 +00:00
|
|
|
// now we can clear the parameter row
|
|
|
|
m_aParameterRow.clear();
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2001-01-09 11:31:57 +00:00
|
|
|
// get the locale
|
|
|
|
ConfigManager* pConfigMgr = ConfigManager::GetConfigManager();
|
|
|
|
Locale aLocale;
|
|
|
|
pConfigMgr->GetDirectConfigProperty(ConfigManager::LOCALE) >>= aLocale;
|
|
|
|
|
|
|
|
// get the numberformatTypes
|
2001-01-22 06:38:24 +00:00
|
|
|
OSL_ENSURE(m_xActiveConnection.is(),"No ActiveConnection");
|
2001-01-09 11:31:57 +00:00
|
|
|
Reference< XNumberFormatTypes> xNumberFormatTypes;
|
|
|
|
Reference< XChild> xChild(m_xActiveConnection,UNO_QUERY);
|
|
|
|
if(xChild.is())
|
2000-12-06 08:55:44 +00:00
|
|
|
{
|
2001-01-09 11:31:57 +00:00
|
|
|
Reference< XPropertySet> xProp(xChild->getParent(),UNO_QUERY);
|
|
|
|
if(xProp.is())
|
|
|
|
{
|
|
|
|
Reference< XNumberFormatsSupplier> xNumberFormat;
|
2001-02-14 12:18:24 +00:00
|
|
|
::cppu::extractInterface(xNumberFormat,xProp->getPropertyValue(PROPERTY_NUMBERFORMATSSUPPLIER));
|
2001-01-09 11:31:57 +00:00
|
|
|
if(xNumberFormat.is())
|
|
|
|
m_xNumberFormatTypes = Reference< XNumberFormatTypes>(xNumberFormat->getNumberFormats(),UNO_QUERY);
|
|
|
|
}
|
2000-12-06 08:55:44 +00:00
|
|
|
}
|
2000-11-06 11:14:23 +00:00
|
|
|
|
2001-05-02 11:47:51 +00:00
|
|
|
::vos::ORef< ::connectivity::OSQLColumns> aColumns = new ::connectivity::OSQLColumns();
|
2001-01-09 11:31:57 +00:00
|
|
|
::std::vector< ::rtl::OUString> aNames;
|
|
|
|
::rtl::OUString aDescription;
|
|
|
|
sal_Int32 nFormatKey = 0;
|
2000-11-22 13:58:32 +00:00
|
|
|
|
2001-01-09 11:31:57 +00:00
|
|
|
if(!m_xColumns.is())
|
|
|
|
{
|
|
|
|
// use the meta data
|
|
|
|
Reference<XResultSetMetaDataSupplier> xMetaSup(m_xStatement,UNO_QUERY);
|
|
|
|
Reference<XResultSetMetaData> xMetaData = xMetaSup->getMetaData();
|
2000-11-22 13:58:32 +00:00
|
|
|
|
2001-08-13 07:45:02 +00:00
|
|
|
|
2001-01-09 11:31:57 +00:00
|
|
|
try
|
2000-11-22 13:58:32 +00:00
|
|
|
{
|
2001-08-13 07:45:02 +00:00
|
|
|
sal_Int32 nCount = xMetaData->getColumnCount();
|
|
|
|
m_aDataColumns.reserve(nCount+1);
|
|
|
|
aColumns->reserve(nCount+1);
|
2001-11-23 10:28:26 +00:00
|
|
|
DECLARE_STL_USTRINGACCESS_MAP(int,StringMap);
|
|
|
|
StringMap aColumnMap;
|
2001-08-13 07:45:02 +00:00
|
|
|
for (sal_Int32 i = 0 ; i < nCount; ++i)
|
2000-12-06 08:55:44 +00:00
|
|
|
{
|
2001-01-09 11:31:57 +00:00
|
|
|
// retrieve the name of the column
|
2001-11-23 10:28:26 +00:00
|
|
|
::rtl::OUString sName = xMetaData->getColumnName(i + 1);
|
|
|
|
// check for duplicate entries
|
|
|
|
if(aColumnMap.find(sName) != aColumnMap.end())
|
|
|
|
{
|
|
|
|
::rtl::OUString sAlias(sName);
|
|
|
|
sal_Int32 i=1;
|
|
|
|
while(aColumnMap.find(sAlias) != aColumnMap.end())
|
|
|
|
{
|
|
|
|
(sAlias = sName) += ::rtl::OUString::valueOf(i++);
|
|
|
|
}
|
|
|
|
sName = sAlias;
|
|
|
|
}
|
2001-01-09 11:31:57 +00:00
|
|
|
ORowSetDataColumn* pColumn = new ORowSetDataColumn( getMetaData(),
|
|
|
|
this,
|
|
|
|
this,
|
|
|
|
i+1,
|
|
|
|
aDescription,
|
|
|
|
m_aCurrentRow,
|
|
|
|
m_pCache->getEnd());
|
2001-11-23 10:28:26 +00:00
|
|
|
aColumnMap.insert(StringMap::value_type(sName,0));
|
2001-05-02 11:47:51 +00:00
|
|
|
aColumns->push_back(pColumn);
|
2001-11-23 10:28:26 +00:00
|
|
|
pColumn->setName(sName);
|
|
|
|
aNames.push_back(sName);
|
2001-08-13 07:45:02 +00:00
|
|
|
m_aDataColumns.push_back(pColumn);
|
2001-01-09 11:31:57 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2001-09-27 08:48:57 +00:00
|
|
|
nFormatKey = 0;
|
2001-05-25 09:39:18 +00:00
|
|
|
if(m_xNumberFormatTypes.is())
|
|
|
|
nFormatKey = ::dbtools::getDefaultNumberFormat(pColumn,m_xNumberFormatTypes,aLocale);
|
2001-09-27 08:48:57 +00:00
|
|
|
|
2001-01-09 11:31:57 +00:00
|
|
|
|
|
|
|
pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_NUMBERFORMAT,makeAny(nFormatKey));
|
|
|
|
pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_RELATIVEPOSITION,makeAny(sal_Int32(i+1)));
|
|
|
|
pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_WIDTH,makeAny(sal_Int32(227)));
|
2001-03-02 08:39:07 +00:00
|
|
|
pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ALIGN,makeAny((sal_Int32)0));
|
2001-01-09 11:31:57 +00:00
|
|
|
pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_HIDDEN,::cppu::bool2any(sal_False));
|
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
}
|
2000-12-06 08:55:44 +00:00
|
|
|
}
|
2000-11-22 13:58:32 +00:00
|
|
|
}
|
2001-01-09 11:31:57 +00:00
|
|
|
catch (SQLException&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// create the rowset columns
|
2001-04-11 05:21:02 +00:00
|
|
|
Reference<XResultSetMetaData> xMeta = getMetaData();
|
|
|
|
sal_Int32 nCount = xMeta->getColumnCount();
|
2001-08-13 07:45:02 +00:00
|
|
|
m_aDataColumns.reserve(nCount+1);
|
|
|
|
aColumns->reserve(nCount+1);
|
2001-11-23 10:28:26 +00:00
|
|
|
::std::map<Reference<XPropertySet>,int> aColumnMap; // need to find duplicates
|
2001-08-13 07:45:02 +00:00
|
|
|
|
2001-11-23 10:28:26 +00:00
|
|
|
for(sal_Int32 i=1; i <= nCount ;++i)
|
2000-11-30 15:38:57 +00:00
|
|
|
{
|
2001-11-23 10:28:26 +00:00
|
|
|
sal_Bool bReFetchName = sal_False;
|
2001-04-11 05:21:02 +00:00
|
|
|
::rtl::OUString sName = xMeta->getColumnName(i);
|
2000-12-06 08:55:44 +00:00
|
|
|
Reference<XPropertySet> xColumn;
|
2001-05-08 08:53:25 +00:00
|
|
|
if (m_xColumns->hasByName(sName))
|
2001-04-11 05:21:02 +00:00
|
|
|
m_xColumns->getByName(sName) >>= xColumn;
|
2001-05-08 08:53:25 +00:00
|
|
|
if (!xColumn.is() && m_xColumns->hasByName(xMeta->getColumnLabel(i)))
|
2001-04-11 05:21:02 +00:00
|
|
|
m_xColumns->getByName(xMeta->getColumnLabel(i)) >>= xColumn;
|
2001-11-23 10:28:26 +00:00
|
|
|
// check if column already in the list we need another
|
|
|
|
if(aColumnMap.find(xColumn) != aColumnMap.end())
|
|
|
|
{
|
|
|
|
xColumn = NULL;
|
|
|
|
bReFetchName = sal_True;
|
|
|
|
}
|
2001-05-22 12:08:22 +00:00
|
|
|
if(!xColumn.is())
|
|
|
|
{
|
|
|
|
// no column found so we could look at the position i
|
|
|
|
Reference<XIndexAccess> xIndexAccess(m_xColumns,UNO_QUERY);
|
|
|
|
if(xIndexAccess.is() && i <= xIndexAccess->getCount())
|
|
|
|
{
|
|
|
|
xIndexAccess->getByIndex(i-1) >>= xColumn;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Sequence< ::rtl::OUString> aSeq = m_xColumns->getElementNames();
|
|
|
|
if( i <= aSeq.getLength())
|
|
|
|
m_xColumns->getByName(aSeq.getConstArray()[i-1]) >>= xColumn;
|
|
|
|
}
|
|
|
|
}
|
2001-05-08 08:53:25 +00:00
|
|
|
DBG_ASSERT(xColumn.is(), "ORowSet::execute_NoApprove_NoNewConn: invalid column (NULL)!");
|
2001-11-23 10:28:26 +00:00
|
|
|
if(bReFetchName && xColumn.is())
|
|
|
|
xColumn->getPropertyValue(PROPERTY_NAME) >>= sName;
|
|
|
|
aColumnMap.insert(::std::map< Reference<XPropertySet>,int>::value_type(xColumn,0));
|
2001-04-11 05:21:02 +00:00
|
|
|
|
|
|
|
Reference<XPropertySetInfo> xInfo = xColumn.is() ? xColumn->getPropertySetInfo() : Reference<XPropertySetInfo>();
|
|
|
|
if(xInfo.is() && xInfo->hasPropertyByName(PROPERTY_DESCRIPTION))
|
2000-12-06 08:55:44 +00:00
|
|
|
aDescription = comphelper::getString(xColumn->getPropertyValue(PROPERTY_DESCRIPTION));
|
|
|
|
|
|
|
|
ORowSetDataColumn* pColumn = new ORowSetDataColumn( getMetaData(),
|
|
|
|
this,
|
|
|
|
this,
|
|
|
|
i,
|
|
|
|
aDescription,
|
|
|
|
m_aCurrentRow,
|
|
|
|
m_pCache->getEnd());
|
2001-05-02 11:47:51 +00:00
|
|
|
aColumns->push_back(pColumn);
|
2001-10-26 06:50:50 +00:00
|
|
|
if(!sName.getLength())
|
|
|
|
{
|
|
|
|
if(xColumn.is())
|
|
|
|
xColumn->getPropertyValue(PROPERTY_NAME) >>= sName;
|
|
|
|
else
|
|
|
|
sName = ::rtl::OUString::createFromAscii("Expression1");
|
|
|
|
}
|
2001-04-11 05:21:02 +00:00
|
|
|
pColumn->setName(sName);
|
|
|
|
aNames.push_back(sName);
|
2001-08-13 07:45:02 +00:00
|
|
|
m_aDataColumns.push_back(pColumn);
|
2000-12-06 08:55:44 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2001-04-11 05:21:02 +00:00
|
|
|
if(xInfo.is() && xInfo->hasPropertyByName(PROPERTY_ALIGN))
|
2001-04-05 12:39:30 +00:00
|
|
|
pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ALIGN,xColumn->getPropertyValue(PROPERTY_ALIGN));
|
|
|
|
|
|
|
|
nFormatKey = 0;
|
2001-04-11 05:21:02 +00:00
|
|
|
if(xInfo.is() && xInfo->hasPropertyByName(PROPERTY_NUMBERFORMAT))
|
2001-04-05 12:39:30 +00:00
|
|
|
nFormatKey = comphelper::getINT32(xColumn->getPropertyValue(PROPERTY_NUMBERFORMAT));
|
2001-05-25 09:39:18 +00:00
|
|
|
if (!nFormatKey && xColumn.is() && m_xNumberFormatTypes.is())
|
2001-02-14 12:18:24 +00:00
|
|
|
nFormatKey = ::dbtools::getDefaultNumberFormat(xColumn,m_xNumberFormatTypes,aLocale);
|
2000-12-06 08:55:44 +00:00
|
|
|
|
|
|
|
pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_NUMBERFORMAT,makeAny(nFormatKey));
|
2001-04-11 05:21:02 +00:00
|
|
|
if(xInfo.is() && xInfo->hasPropertyByName(PROPERTY_RELATIVEPOSITION))
|
2001-04-05 12:39:30 +00:00
|
|
|
pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_RELATIVEPOSITION,xColumn->getPropertyValue(PROPERTY_RELATIVEPOSITION));
|
2001-04-11 05:21:02 +00:00
|
|
|
if(xInfo.is() && xInfo->hasPropertyByName(PROPERTY_WIDTH))
|
2001-04-05 12:39:30 +00:00
|
|
|
pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_WIDTH,xColumn->getPropertyValue(PROPERTY_WIDTH));
|
2001-04-11 05:21:02 +00:00
|
|
|
if(xInfo.is() && xInfo->hasPropertyByName(PROPERTY_HIDDEN))
|
2001-04-05 12:39:30 +00:00
|
|
|
pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_HIDDEN,xColumn->getPropertyValue(PROPERTY_HIDDEN));
|
2001-04-11 05:21:02 +00:00
|
|
|
if(xInfo.is() && xInfo->hasPropertyByName(PROPERTY_CONTROLMODEL))
|
2001-04-05 12:39:30 +00:00
|
|
|
pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_CONTROLMODEL,xColumn->getPropertyValue(PROPERTY_CONTROLMODEL));
|
2001-09-20 11:59:25 +00:00
|
|
|
if(xInfo.is() && xInfo->hasPropertyByName(PROPERTY_HELPTEXT))
|
|
|
|
pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_HELPTEXT,xColumn->getPropertyValue(PROPERTY_HELPTEXT));
|
2001-10-19 11:52:27 +00:00
|
|
|
if(xInfo.is() && xInfo->hasPropertyByName(PROPERTY_CONTROLDEFAULT))
|
|
|
|
pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_CONTROLDEFAULT,xColumn->getPropertyValue(PROPERTY_CONTROLDEFAULT));
|
2000-12-06 08:55:44 +00:00
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2001-01-09 11:31:57 +00:00
|
|
|
// now create the columns we need
|
2001-04-20 10:44:05 +00:00
|
|
|
if(m_pColumns)
|
|
|
|
m_pColumns->assign(aColumns,aNames);
|
|
|
|
else
|
|
|
|
m_pColumns = new ORowSetDataColumns(m_xActiveConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers(),
|
|
|
|
aColumns,*this,m_aColumnsMutex,aNames);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
2002-10-10 12:22:42 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
::rtl::OUString sErrorMsg(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("The command '")));
|
|
|
|
sErrorMsg += aSql;
|
|
|
|
sErrorMsg += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("' does not succeed."));
|
|
|
|
throwGenericSQLException(sErrorMsg,*this);
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
2001-06-26 09:12:41 +00:00
|
|
|
checkCache();
|
2000-11-06 11:14:23 +00:00
|
|
|
_rClearForNotification.clear();
|
2000-09-18 23:16:46 +00:00
|
|
|
// notify the rowset listeners
|
2002-08-13 10:13:00 +00:00
|
|
|
notifyAllListeners(_rClearForNotification);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
// XRowSetApproveBroadcaster
|
|
|
|
void SAL_CALL ORowSet::addRowSetApproveListener( const Reference< XRowSetApproveListener >& listener ) throw(RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
::osl::MutexGuard aGuard( m_aColumnsMutex );
|
|
|
|
|
|
|
|
m_aApproveListeners.addInterface(listener);
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::removeRowSetApproveListener( const Reference< XRowSetApproveListener >& listener ) throw(RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
::osl::MutexGuard aGuard( m_aColumnsMutex );
|
|
|
|
|
|
|
|
m_aApproveListeners.removeInterface(listener);
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// XResultSetAccess
|
|
|
|
Reference< XResultSet > SAL_CALL ORowSet::createResultSet( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aColumnsMutex );
|
|
|
|
|
|
|
|
if(m_xStatement.is())
|
|
|
|
{
|
2001-11-15 09:42:42 +00:00
|
|
|
ORowSetClone* pClone = new ORowSetClone(*this,m_pMutex);
|
2000-09-18 23:16:46 +00:00
|
|
|
Reference< XResultSet > xRet(pClone);
|
|
|
|
m_aClones.push_back(WeakReferenceHelper(xRet));
|
|
|
|
return xRet;
|
|
|
|
}
|
|
|
|
return Reference< XResultSet >();
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// ::com::sun::star::util::XCancellable
|
|
|
|
void SAL_CALL ORowSet::cancel( ) throw(RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
if(m_pCache)
|
|
|
|
m_pCache->cancel();
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// ::com::sun::star::sdbcx::XDeleteRows
|
|
|
|
Sequence< sal_Int32 > SAL_CALL ORowSet::deleteRows( const Sequence< Any >& rows ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2001-04-05 06:51:27 +00:00
|
|
|
if(!m_pCache || m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY)
|
2001-04-19 06:14:49 +00:00
|
|
|
throwFunctionSequenceException(*this);
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2002-08-13 10:13:00 +00:00
|
|
|
::osl::ResettableMutexGuard aGuard( *m_pMutex );
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2001-04-06 09:19:13 +00:00
|
|
|
Sequence< sal_Int32 > aRet;
|
2000-09-18 23:16:46 +00:00
|
|
|
RowChangeEvent aEvt(*this,RowChangeAction::DELETE,rows.getLength());
|
|
|
|
// notify the rowset listeners
|
2002-08-13 10:13:00 +00:00
|
|
|
if(notifyAllListenersRowBeforeChange(aGuard,aEvt))
|
2000-09-29 14:23:36 +00:00
|
|
|
{
|
2001-04-06 09:19:13 +00:00
|
|
|
|
|
|
|
// first notify the clones so that they can save their position
|
|
|
|
const Any* pBegin = rows.getConstArray();
|
|
|
|
const Any* pEnd = pBegin + rows.getLength();
|
|
|
|
for(;pBegin != pEnd;++pBegin)
|
2000-12-06 08:55:44 +00:00
|
|
|
{
|
2001-04-06 09:19:13 +00:00
|
|
|
notifyClonesRowDelete(*pBegin);
|
|
|
|
if(compareBookmarks( m_aBookmark,*pBegin) == 0)
|
|
|
|
{
|
2001-06-22 12:08:06 +00:00
|
|
|
positionCache();
|
2001-04-06 09:19:13 +00:00
|
|
|
m_nPosition = m_pCache->getRow();
|
|
|
|
}
|
2000-12-06 08:55:44 +00:00
|
|
|
}
|
2001-04-06 09:19:13 +00:00
|
|
|
// now delete the rows
|
|
|
|
aRet = m_pCache->deleteRows(rows);
|
2000-12-06 08:55:44 +00:00
|
|
|
|
2001-04-06 09:19:13 +00:00
|
|
|
// now notify that we have deleted
|
|
|
|
pBegin = rows.getConstArray();
|
2000-12-06 08:55:44 +00:00
|
|
|
|
2001-04-06 09:19:13 +00:00
|
|
|
const sal_Int32* pRetBegin = aRet.getConstArray();
|
|
|
|
const sal_Int32* pRetEnd = pRetBegin + aRet.getLength();
|
|
|
|
OSL_ENSURE(aRet.getLength() == rows.getLength(),"ORowSet::deleteRows: The length of the rows and returnstatus is not equal!");
|
|
|
|
for(;pBegin != pEnd;++pBegin)
|
2000-12-06 08:55:44 +00:00
|
|
|
{
|
2001-04-06 09:19:13 +00:00
|
|
|
if(*pRetBegin)
|
2000-12-06 08:55:44 +00:00
|
|
|
{
|
2001-04-06 09:19:13 +00:00
|
|
|
notifyClonesRowDeleted(*pBegin);
|
|
|
|
if(compareBookmarks( m_aBookmark,*pBegin) == 0)
|
|
|
|
{
|
|
|
|
m_aBookmark = Any();
|
|
|
|
m_aCurrentRow = NULL;
|
|
|
|
m_aCurrentRow.setBookmark(Any());
|
|
|
|
}
|
2000-12-06 08:55:44 +00:00
|
|
|
}
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2001-04-06 09:19:13 +00:00
|
|
|
aEvt.Rows = aRet.getLength();
|
2002-12-05 08:53:00 +00:00
|
|
|
|
|
|
|
// we have to check if we stand on the insert row and if so we have to reset it
|
|
|
|
ORowSetNotifier aNotifier( this );
|
|
|
|
// this will call cancelRowModification on the cache if necessary
|
|
|
|
|
|
|
|
// notification order
|
|
|
|
// - rowChanged
|
2002-08-13 10:13:00 +00:00
|
|
|
notifyAllListenersRowChanged(aGuard,aEvt);
|
2002-12-05 08:53:00 +00:00
|
|
|
|
|
|
|
// - IsModified
|
|
|
|
// - IsNew
|
|
|
|
aNotifier.fire();
|
|
|
|
|
|
|
|
// - RowCount/IsRowCountFinal
|
2001-04-06 09:19:13 +00:00
|
|
|
fireRowcount();
|
|
|
|
}
|
2000-09-29 14:23:36 +00:00
|
|
|
return aRet;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2000-12-06 08:55:44 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void ORowSet::notifyClonesRowDelete(const Any& _rBookmark)
|
|
|
|
{
|
|
|
|
for (connectivity::OWeakRefArray::iterator i = m_aClones.begin(); m_aClones.end() != i; i++)
|
|
|
|
{
|
|
|
|
Reference< XUnoTunnel > xTunnel(i->get(),UNO_QUERY);
|
|
|
|
if(xTunnel.is())
|
|
|
|
{
|
|
|
|
ORowSetClone* pClone = (ORowSetClone*)xTunnel->getSomething(ORowSetClone::getUnoTunnelImplementationId());
|
|
|
|
if(pClone)
|
|
|
|
pClone->rowDelete(_rBookmark);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void ORowSet::notifyClonesRowDeleted(const Any& _rBookmark)
|
|
|
|
{
|
|
|
|
for (connectivity::OWeakRefArray::iterator i = m_aClones.begin(); m_aClones.end() != i; i++)
|
|
|
|
{
|
|
|
|
Reference< XUnoTunnel > xTunnel(i->get(),UNO_QUERY);
|
|
|
|
if(xTunnel.is())
|
|
|
|
{
|
|
|
|
ORowSetClone* pClone = (ORowSetClone*)xTunnel->getSomething(ORowSetClone::getUnoTunnelImplementationId());
|
|
|
|
if(pClone)
|
|
|
|
pClone->rowDeleted(_rBookmark);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
//------------------------------------------------------------------------------
|
2000-12-01 13:16:46 +00:00
|
|
|
Reference< XConnection > ORowSet::calcConnection(const Reference< XInteractionHandler >& _rxHandler) throw( SQLException, RuntimeException )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
if (!m_xActiveConnection.is())
|
|
|
|
{
|
2001-04-12 08:32:26 +00:00
|
|
|
Reference< XConnection > xNewConn;
|
2001-05-14 08:47:28 +00:00
|
|
|
if (m_aDataSourceName.getLength())
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
// is it a file url?
|
|
|
|
Reference< ::com::sun::star::container::XNameAccess > xNamingContext(m_xServiceManager->createInstance(SERVICE_SDB_DATABASECONTEXT), UNO_QUERY);
|
|
|
|
if (xNamingContext.is() && xNamingContext->hasByName(m_aDataSourceName))
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2000-12-01 13:16:46 +00:00
|
|
|
if(_rxHandler.is())
|
|
|
|
{
|
|
|
|
Reference< XCompletedConnection> xComplConn(Reference< XNamingService > (xNamingContext, UNO_QUERY)->getRegisteredObject(m_aDataSourceName), UNO_QUERY);
|
|
|
|
if(xComplConn.is())
|
2001-04-12 08:32:26 +00:00
|
|
|
xNewConn = xComplConn->connectWithCompletion(_rxHandler);
|
2000-12-01 13:16:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Reference< XDataSource > xDataSource(Reference< XNamingService > (xNamingContext, UNO_QUERY)->getRegisteredObject(m_aDataSourceName), UNO_QUERY);
|
|
|
|
if (xDataSource.is())
|
2001-04-12 08:32:26 +00:00
|
|
|
xNewConn = xDataSource->getConnection(m_aUser, m_aPassword);
|
2000-12-01 13:16:46 +00:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
catch (SQLException &e)
|
|
|
|
{
|
|
|
|
throw e;
|
|
|
|
}
|
2001-03-02 08:39:07 +00:00
|
|
|
catch (Exception&)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
throw SQLException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-04-12 08:32:26 +00:00
|
|
|
setActiveConnection(xNewConn);
|
|
|
|
m_bOwnConnection = sal_True;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
return m_xActiveConnection;
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-03 13:42:50 +00:00
|
|
|
rtl::OUString ORowSet::getCommand(sal_Bool& bEscapeProcessing,::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxRetTables) throw( SQLException)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
// create the sql command
|
|
|
|
// from a table name or get the command out of a query (not a view)
|
|
|
|
// the last use the command as it is
|
|
|
|
bEscapeProcessing = m_bUseEscapeProcessing;
|
|
|
|
rtl::OUString aQuery;
|
2001-05-14 08:47:28 +00:00
|
|
|
if (m_aCommand.getLength())
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2000-10-30 08:24:02 +00:00
|
|
|
// i always need a tables for the querycomposer
|
|
|
|
Reference< XTablesSupplier > xTablesAccess(m_xActiveConnection, UNO_QUERY);
|
|
|
|
if (xTablesAccess.is())
|
|
|
|
{
|
2000-11-03 13:42:50 +00:00
|
|
|
_rxRetTables = xTablesAccess->getTables();
|
2000-10-30 08:24:02 +00:00
|
|
|
}
|
|
|
|
else // the connection is no table supplier so I make it myself
|
|
|
|
{
|
2000-12-01 13:16:46 +00:00
|
|
|
if(!m_xActiveConnection.is())
|
2001-04-26 10:20:06 +00:00
|
|
|
throw SQLException(DBACORE_RESSTRING(RID_STR_CONNECTION_INVALID),*this,SQLSTATE_GENERAL,1000,Any() );
|
2001-10-08 06:26:32 +00:00
|
|
|
sal_Bool bCase = sal_True;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
bCase = m_xActiveConnection->getMetaData()->storesMixedCaseQuotedIdentifiers();
|
|
|
|
}
|
|
|
|
catch(SQLException&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
m_pTables = new OTableContainer(OConfigurationNode(),OConfigurationTreeRoot(),*this,m_aMutex,m_xActiveConnection,bCase);
|
2000-11-03 13:42:50 +00:00
|
|
|
_rxRetTables = m_pTables;
|
2000-12-01 10:37:10 +00:00
|
|
|
Sequence< ::rtl::OUString> aTableFilter(1);
|
|
|
|
aTableFilter[0] = ::rtl::OUString::createFromAscii("%");
|
|
|
|
m_pTables->construct(aTableFilter,Sequence< ::rtl::OUString>());
|
2000-10-30 08:24:02 +00:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
switch (m_nCommandType)
|
|
|
|
{
|
|
|
|
case CommandType::TABLE:
|
|
|
|
{
|
2000-10-30 08:24:02 +00:00
|
|
|
|
2001-01-22 06:38:24 +00:00
|
|
|
OSL_ENSURE(_rxRetTables.is(),"ORowSet::getCommand: We got no tables from the connection!");
|
2000-11-03 13:42:50 +00:00
|
|
|
if (_rxRetTables.is() && _rxRetTables->hasByName(m_aCommand))
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2000-10-30 08:24:02 +00:00
|
|
|
Reference< XPropertySet > xTable;
|
2001-02-14 12:18:24 +00:00
|
|
|
::cppu::extractInterface(xTable,_rxRetTables->getByName(m_aCommand));
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2000-10-30 08:24:02 +00:00
|
|
|
Reference<XColumnsSupplier> xSup(xTable,UNO_QUERY);
|
|
|
|
if(xSup.is())
|
|
|
|
m_xColumns = xSup->getColumns();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
aQuery = rtl::OUString::createFromAscii("SELECT * FROM ");
|
2002-10-07 12:09:48 +00:00
|
|
|
aQuery += ::dbtools::quoteTableName(m_xActiveConnection->getMetaData(), m_aCommand,::dbtools::eInDataManipulation);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CommandType::QUERY:
|
|
|
|
{
|
|
|
|
Reference< XQueriesSupplier > xQueriesAccess(m_xActiveConnection, UNO_QUERY);
|
|
|
|
if (xQueriesAccess.is())
|
|
|
|
{
|
|
|
|
Reference< ::com::sun::star::container::XNameAccess > xQueries(xQueriesAccess->getQueries());
|
|
|
|
if (xQueries->hasByName(m_aCommand))
|
|
|
|
{
|
|
|
|
Reference< XPropertySet > xQuery;
|
2001-02-14 12:18:24 +00:00
|
|
|
::cppu::extractInterface(xQuery,xQueries->getByName(m_aCommand));
|
2000-09-18 23:16:46 +00:00
|
|
|
xQuery->getPropertyValue(PROPERTY_COMMAND) >>= aQuery;
|
|
|
|
bEscapeProcessing = any2bool(xQuery->getPropertyValue(PROPERTY_USE_ESCAPE_PROCESSING));
|
|
|
|
|
|
|
|
::rtl::OUString aCatalog,aSchema,aTable;
|
2001-02-14 12:18:24 +00:00
|
|
|
xQuery->getPropertyValue(PROPERTY_UPDATE_CATALOGNAME) >>= aCatalog;
|
2001-02-05 06:59:01 +00:00
|
|
|
xQuery->getPropertyValue(PROPERTY_UPDATE_SCHEMANAME) >>= aSchema;
|
2001-02-14 12:18:24 +00:00
|
|
|
xQuery->getPropertyValue(PROPERTY_UPDATE_TABLENAME) >>= aTable;
|
2001-01-04 13:25:58 +00:00
|
|
|
if(aTable.getLength())
|
2002-10-07 12:09:48 +00:00
|
|
|
composeTableName(m_xActiveConnection->getMetaData(),aCatalog,aSchema,aTable,m_aUpdateTableName,sal_False,::dbtools::eInDataManipulation);
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
Reference<XColumnsSupplier> xSup(xQuery,UNO_QUERY);
|
|
|
|
if(xSup.is())
|
|
|
|
m_xColumns = xSup->getColumns();
|
|
|
|
}
|
2002-07-25 05:35:23 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
::rtl::OUString sError(RTL_CONSTASCII_USTRINGPARAM("There exists no query with given name: \""));
|
|
|
|
sError += m_aCommand;
|
|
|
|
sError += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\"!"));
|
|
|
|
throwGenericSQLException(sError,*this);
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2000-10-30 08:24:02 +00:00
|
|
|
else
|
|
|
|
throw SQLException(::rtl::OUString::createFromAscii("The interface XQueriesSupplier is not available!"),*this,::rtl::OUString(),0,Any());
|
2000-09-18 23:16:46 +00:00
|
|
|
} break;
|
|
|
|
default:
|
|
|
|
aQuery = m_aCommand;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return aQuery;
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-03 13:42:50 +00:00
|
|
|
rtl::OUString ORowSet::getComposedQuery(const rtl::OUString& rQuery, sal_Bool bEscapeProcessing,::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxRetTables) throw( SQLException, RuntimeException )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
// use query composer to make a useful query with filter and/or order by part
|
|
|
|
rtl::OUString aFilterStatement = rQuery;
|
|
|
|
if (bEscapeProcessing)
|
|
|
|
{
|
|
|
|
Reference< XSQLQueryComposerFactory > xFactory(m_xActiveConnection, UNO_QUERY);
|
|
|
|
if (xFactory.is())
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
m_xComposer = xFactory->createQueryComposer();
|
|
|
|
}
|
2000-11-22 13:58:32 +00:00
|
|
|
catch (Exception&)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
m_xComposer = NULL;
|
|
|
|
}
|
|
|
|
}
|
2000-10-30 08:24:02 +00:00
|
|
|
if(!m_xComposer.is()) // no composer so we create one
|
|
|
|
{
|
2000-11-03 13:42:50 +00:00
|
|
|
OQueryComposer* pComposer = new OQueryComposer(_rxRetTables,m_xActiveConnection,m_xServiceManager);
|
2000-10-30 08:24:02 +00:00
|
|
|
m_xComposer = pComposer;
|
|
|
|
}
|
|
|
|
if(m_xComposer.is())
|
|
|
|
{
|
|
|
|
m_xComposer->setQuery(rQuery);
|
|
|
|
|
2001-02-23 14:22:32 +00:00
|
|
|
if(m_bIgnoreResult)
|
|
|
|
m_xComposer->setFilter(::rtl::OUString::createFromAscii("0=1"));
|
2001-05-14 08:47:28 +00:00
|
|
|
else if (m_aFilter.getLength() && m_bApplyFilter)
|
2000-10-30 08:24:02 +00:00
|
|
|
m_xComposer->setFilter(m_aFilter);
|
2001-02-23 14:22:32 +00:00
|
|
|
|
2001-05-14 08:47:28 +00:00
|
|
|
if (m_aOrder.getLength())
|
2000-10-30 08:24:02 +00:00
|
|
|
m_xComposer->setOrder(m_aOrder);
|
|
|
|
|
|
|
|
aFilterStatement = m_xComposer->getComposedQuery();
|
2000-11-30 15:38:57 +00:00
|
|
|
if(!m_xColumns.is())
|
|
|
|
{
|
|
|
|
Reference<XColumnsSupplier> xCols(m_xComposer,UNO_QUERY);
|
|
|
|
m_xColumns = xCols->getColumns();
|
|
|
|
}
|
2000-10-30 08:24:02 +00:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
return aFilterStatement;
|
|
|
|
}
|
2001-06-26 09:12:41 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void ORowSet::checkAndResizeParameters(sal_Int32 parameterIndex)
|
|
|
|
{
|
|
|
|
::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
|
|
|
|
if (parameterIndex < 1)
|
|
|
|
throwInvalidIndexException(*this);
|
|
|
|
else if ((sal_Int32)m_aParameterRow.size() < parameterIndex)
|
|
|
|
m_aParameterRow.resize(parameterIndex);
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
// XParameters
|
|
|
|
void SAL_CALL ORowSet::setNull( sal_Int32 parameterIndex, sal_Int32 sqlType ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aColumnsMutex );
|
2001-06-26 09:12:41 +00:00
|
|
|
checkAndResizeParameters(parameterIndex);
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
m_aParameterRow[parameterIndex-1].setNull();
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
|
|
|
|
::osl::MutexGuard aGuard( m_aColumnsMutex );
|
2001-06-26 09:12:41 +00:00
|
|
|
checkAndResizeParameters(parameterIndex);
|
2000-09-18 23:16:46 +00:00
|
|
|
m_aParameterRow[parameterIndex-1].setNull();
|
|
|
|
}
|
2001-06-26 09:12:41 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void ORowSet::setParameter(sal_Int32 parameterIndex, const ORowSetValue& x)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aColumnsMutex );
|
2001-06-26 09:12:41 +00:00
|
|
|
checkAndResizeParameters(parameterIndex);
|
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
m_aParameterRow[parameterIndex-1] = x;
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
2001-06-26 09:12:41 +00:00
|
|
|
void SAL_CALL ORowSet::setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
setParameter(parameterIndex,x);
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
2000-09-18 23:16:46 +00:00
|
|
|
void SAL_CALL ORowSet::setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
setParameter(parameterIndex,x);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
setParameter(parameterIndex,x);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
setParameter(parameterIndex,x);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::setLong( sal_Int32 parameterIndex, sal_Int64 x ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-09-20 11:59:25 +00:00
|
|
|
setParameter(parameterIndex,x);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::setFloat( sal_Int32 parameterIndex, float x ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
setParameter(parameterIndex,x);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::setDouble( sal_Int32 parameterIndex, double x ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
setParameter(parameterIndex,x);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
setParameter(parameterIndex,x);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::setBytes( sal_Int32 parameterIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
setParameter(parameterIndex,x);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::setDate( sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
setParameter(parameterIndex,x);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::setTime( sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
setParameter(parameterIndex,x);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::setTimestamp( sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
setParameter(parameterIndex,x);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::setBinaryStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aColumnsMutex );
|
2001-06-26 09:12:41 +00:00
|
|
|
checkAndResizeParameters(parameterIndex);
|
2000-09-18 23:16:46 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
Sequence <sal_Int8> aData;
|
|
|
|
x->readBytes(aData, length);
|
|
|
|
m_aParameterRow[parameterIndex-1] = aData;
|
|
|
|
x->closeInput();
|
|
|
|
}
|
2001-03-02 08:39:07 +00:00
|
|
|
catch( Exception& )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
throw SQLException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::setCharacterStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aColumnsMutex );
|
2001-06-26 09:12:41 +00:00
|
|
|
checkAndResizeParameters(parameterIndex);
|
2000-09-18 23:16:46 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
Sequence <sal_Int8> aData;
|
|
|
|
rtl::OUString aDataStr;
|
|
|
|
// the data is given as character data and the length defines the character length
|
|
|
|
sal_Int32 nSize = x->readBytes(aData, length * sizeof(sal_Unicode));
|
|
|
|
if (nSize / sizeof(sal_Unicode))
|
|
|
|
aDataStr = rtl::OUString((sal_Unicode*)aData.getConstArray(), nSize / sizeof(sal_Unicode));
|
|
|
|
m_aParameterRow[parameterIndex-1] = aDataStr;
|
|
|
|
m_aParameterRow[parameterIndex-1].setTypeKind(DataType::LONGVARCHAR);
|
|
|
|
x->closeInput();
|
|
|
|
}
|
2001-03-02 08:39:07 +00:00
|
|
|
catch( Exception& )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
throw SQLException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::setObject( sal_Int32 parameterIndex, const Any& x ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aColumnsMutex );
|
2001-06-26 09:12:41 +00:00
|
|
|
checkAndResizeParameters(parameterIndex);
|
|
|
|
if (!::dbtools::implSetObject(this, parameterIndex, x))
|
|
|
|
{ // there is no other setXXX call which can handle the value in x
|
|
|
|
throw SQLException();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::setObjectWithInfo( sal_Int32 parameterIndex, const Any& x, sal_Int32 targetSqlType, sal_Int32 scale ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aColumnsMutex );
|
2001-06-26 09:12:41 +00:00
|
|
|
checkAndResizeParameters(parameterIndex);
|
2000-09-18 23:16:46 +00:00
|
|
|
setObject(parameterIndex, x);
|
|
|
|
m_aParameterRow[parameterIndex-1].setTypeKind(targetSqlType);
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::setRef( sal_Int32 parameterIndex, const Reference< XRef >& x ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
throw SQLException();
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::setBlob( sal_Int32 parameterIndex, const Reference< XBlob >& x ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
throw SQLException();
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::setClob( sal_Int32 parameterIndex, const Reference< XClob >& x ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
throw SQLException();
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::setArray( sal_Int32 parameterIndex, const Reference< XArray >& x ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
throw SQLException();
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::clearParameters( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2001-06-26 09:12:41 +00:00
|
|
|
::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
::osl::MutexGuard aGuard( m_aColumnsMutex );
|
2001-06-26 09:12:41 +00:00
|
|
|
// this is the real clear
|
|
|
|
m_aParameterRow = connectivity::ORowVector< ORowSetValue >();
|
2001-06-26 10:03:28 +00:00
|
|
|
m_aParameterRow.clear();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
2001-08-24 05:40:35 +00:00
|
|
|
void ORowSet::firePropertyChange(sal_Int32 _nPos,const ::connectivity::ORowSetValue& _rOldValue)
|
2000-09-29 14:23:36 +00:00
|
|
|
{
|
2001-08-30 07:07:36 +00:00
|
|
|
OSL_ENSURE(_nPos < (sal_Int32)m_aDataColumns.size(),"nPos is invalid!");
|
2001-08-14 06:50:38 +00:00
|
|
|
m_aDataColumns[_nPos]->fireValueChange(_rOldValue);
|
2000-09-29 14:23:36 +00:00
|
|
|
}
|
2002-12-05 08:53:00 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void ORowSet::doCancelModification( )
|
2000-09-29 14:23:36 +00:00
|
|
|
{
|
2002-12-05 08:53:00 +00:00
|
|
|
OSL_ENSURE( isModification(), "ORowSet::doCancelModification: invalid call (no cache!)!" );
|
|
|
|
if ( isModification() )
|
|
|
|
m_pCache->cancelRowModification();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
sal_Bool ORowSet::isModification( )
|
|
|
|
{
|
|
|
|
return m_pCache && m_pCache->m_bInserted;
|
2000-09-29 14:23:36 +00:00
|
|
|
}
|
2002-12-05 08:53:00 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
sal_Bool ORowSet::isModified( )
|
|
|
|
{
|
|
|
|
return m_bModified;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
sal_Bool ORowSet::isNew( )
|
|
|
|
{
|
|
|
|
return m_bNew;
|
|
|
|
}
|
|
|
|
|
2001-01-22 06:38:24 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void ORowSet::checkUpdateIterator()
|
|
|
|
{
|
|
|
|
if(!m_bModified && !m_bNew)
|
|
|
|
{
|
|
|
|
m_pCache->setUpdateIterator(m_aCurrentRow);
|
|
|
|
m_aCurrentRow = m_pCache->m_aInsertRow;
|
|
|
|
}
|
|
|
|
}
|
2001-06-26 09:12:41 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void ORowSet::checkUpdateConditions(sal_Int32 columnIndex)
|
|
|
|
{
|
|
|
|
if(!m_pCache || columnIndex <= 0 || m_aCurrentRow == NULL || m_aCurrentRow == m_pCache->getEnd() || m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY)
|
|
|
|
throwFunctionSequenceException(*this);
|
|
|
|
}
|
2002-07-11 06:02:27 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ORowSet::refreshRow( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2002-12-05 08:53:00 +00:00
|
|
|
ORowSetNotifier aNotifier( this );
|
|
|
|
// this will call cancelRowModification on the cache if necessary
|
2002-07-11 06:02:27 +00:00
|
|
|
|
2002-12-05 08:53:00 +00:00
|
|
|
// notification order:
|
|
|
|
if ( m_bModified && m_pCache )
|
|
|
|
// - column values
|
|
|
|
implCancelRowUpdates( sal_False ); // do _not_ notify the IsModify - will do this ourself below
|
2002-07-11 06:02:27 +00:00
|
|
|
|
|
|
|
ORowSetBase::refreshRow();
|
2002-12-05 08:53:00 +00:00
|
|
|
|
|
|
|
// - IsModified
|
|
|
|
// - IsNew
|
|
|
|
aNotifier.fire( );
|
2002-07-11 06:02:27 +00:00
|
|
|
}
|
2000-10-17 11:21:45 +00:00
|
|
|
// ***********************************************************
|
2000-09-18 23:16:46 +00:00
|
|
|
// ORowSetClone
|
2000-10-17 11:21:45 +00:00
|
|
|
// ***********************************************************
|
2000-09-18 23:16:46 +00:00
|
|
|
DBG_NAME(ORowSetClone);
|
|
|
|
//--------------------------------------------------------------------------
|
2001-11-15 09:42:42 +00:00
|
|
|
ORowSetClone::ORowSetClone(ORowSet& rParent,::osl::Mutex* _pMutex)
|
2000-09-18 23:16:46 +00:00
|
|
|
:OSubComponent(m_aMutex, rParent)
|
2001-11-15 09:42:42 +00:00
|
|
|
,ORowSetBase(OComponentHelper::rBHelper,_pMutex)
|
2000-09-18 23:16:46 +00:00
|
|
|
,m_nFetchDirection(rParent.m_nFetchDirection)
|
|
|
|
,m_nFetchSize(rParent.m_nFetchSize)
|
|
|
|
,m_bDeleted(rParent.m_bDeleted)
|
|
|
|
,m_bRowObsolete(rParent.m_bRowObsolete)
|
|
|
|
,m_bIsBookmarable(sal_True)
|
2001-01-24 08:52:19 +00:00
|
|
|
,m_pParent(&rParent)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
DBG_CTOR(ORowSetClone, NULL);
|
|
|
|
|
2001-04-05 06:51:27 +00:00
|
|
|
m_nResultSetType = rParent.m_nResultSetType;
|
|
|
|
m_nResultSetConcurrency = ResultSetConcurrency::READ_ONLY;
|
2000-11-22 13:58:32 +00:00
|
|
|
m_pMySelf = this;
|
|
|
|
m_bClone = sal_True;
|
|
|
|
m_bBeforeFirst = rParent.m_bBeforeFirst;
|
|
|
|
m_bAfterLast = rParent.m_bAfterLast;
|
|
|
|
m_pCache = rParent.m_pCache;
|
|
|
|
m_aBookmark = rParent.m_aBookmark;
|
2001-01-22 06:38:24 +00:00
|
|
|
m_aCurrentRow = m_pCache->createIterator();
|
2000-11-22 13:58:32 +00:00
|
|
|
m_xNumberFormatTypes = rParent.m_xNumberFormatTypes;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2001-05-02 11:47:51 +00:00
|
|
|
::vos::ORef< ::connectivity::OSQLColumns> aColumns = new ::connectivity::OSQLColumns();
|
2000-09-18 23:16:46 +00:00
|
|
|
::std::vector< ::rtl::OUString> aNames;
|
|
|
|
|
2000-10-17 09:19:03 +00:00
|
|
|
::rtl::OUString aDescription;
|
2000-11-22 13:58:32 +00:00
|
|
|
ConfigManager* pConfigMgr = ConfigManager::GetConfigManager();
|
|
|
|
Locale aLocale;
|
|
|
|
pConfigMgr->GetDirectConfigProperty(ConfigManager::LOCALE) >>= aLocale;
|
2000-10-17 09:19:03 +00:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
Sequence< ::rtl::OUString> aSeq = rParent.m_pColumns->getElementNames();
|
|
|
|
const ::rtl::OUString* pBegin = aSeq.getConstArray();
|
|
|
|
const ::rtl::OUString* pEnd = pBegin + aSeq.getLength();
|
2001-08-13 07:45:02 +00:00
|
|
|
aColumns->reserve(aSeq.getLength()+1);
|
2000-09-18 23:16:46 +00:00
|
|
|
for(sal_Int32 i=1;pBegin != pEnd ;++pBegin,++i)
|
|
|
|
{
|
2000-10-17 09:19:03 +00:00
|
|
|
Reference<XPropertySet> xColumn;
|
2001-05-02 11:47:51 +00:00
|
|
|
rParent.m_pColumns->getByName(*pBegin) >>= xColumn;
|
2000-10-17 09:19:03 +00:00
|
|
|
if(xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_DESCRIPTION))
|
|
|
|
aDescription = comphelper::getString(xColumn->getPropertyValue(PROPERTY_DESCRIPTION));
|
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
ORowSetColumn* pColumn = new ORowSetColumn( rParent.getMetaData(),
|
|
|
|
this,
|
|
|
|
i,
|
2000-10-17 09:19:03 +00:00
|
|
|
aDescription,
|
2000-11-10 13:16:30 +00:00
|
|
|
m_aCurrentRow,
|
2000-09-18 23:16:46 +00:00
|
|
|
m_pCache->getEnd());
|
2001-05-02 11:47:51 +00:00
|
|
|
aColumns->push_back(pColumn);
|
2000-09-18 23:16:46 +00:00
|
|
|
pColumn->setName(*pBegin);
|
|
|
|
aNames.push_back(*pBegin);
|
2001-08-13 07:45:02 +00:00
|
|
|
m_aDataColumns.push_back(pColumn);
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ALIGN,xColumn->getPropertyValue(PROPERTY_ALIGN));
|
2000-11-22 13:58:32 +00:00
|
|
|
sal_Int32 nFormatKey = comphelper::getINT32(xColumn->getPropertyValue(PROPERTY_NUMBERFORMAT));
|
2001-05-25 09:39:18 +00:00
|
|
|
if(!nFormatKey && xColumn.is() && m_xNumberFormatTypes.is())
|
2001-02-14 12:18:24 +00:00
|
|
|
nFormatKey = ::dbtools::getDefaultNumberFormat(xColumn,m_xNumberFormatTypes,aLocale);
|
2000-11-22 13:58:32 +00:00
|
|
|
pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_NUMBERFORMAT,makeAny(nFormatKey));
|
2000-09-18 23:16:46 +00:00
|
|
|
pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_RELATIVEPOSITION,xColumn->getPropertyValue(PROPERTY_RELATIVEPOSITION));
|
|
|
|
pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_WIDTH,xColumn->getPropertyValue(PROPERTY_WIDTH));
|
|
|
|
pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_HIDDEN,xColumn->getPropertyValue(PROPERTY_HIDDEN));
|
|
|
|
pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_CONTROLMODEL,xColumn->getPropertyValue(PROPERTY_CONTROLMODEL));
|
2001-09-20 11:59:25 +00:00
|
|
|
pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_HELPTEXT,xColumn->getPropertyValue(PROPERTY_HELPTEXT));
|
2001-10-19 11:52:27 +00:00
|
|
|
pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_CONTROLDEFAULT,xColumn->getPropertyValue(PROPERTY_CONTROLDEFAULT));
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
m_pColumns = new ORowSetDataColumns(rParent.m_xActiveConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers(),
|
|
|
|
aColumns,*this,m_aMutex,aNames);
|
|
|
|
|
|
|
|
sal_Int32 nRT = PropertyAttribute::READONLY | PropertyAttribute::TRANSIENT;
|
|
|
|
|
|
|
|
// sdb.RowSet Properties
|
|
|
|
// registerProperty(PROPERTY_CURSORNAME, PROPERTY_ID_CURSORNAME, PropertyAttribute::READONLY, &m_aDataSourceName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
|
|
|
|
|
|
|
|
registerProperty(PROPERTY_RESULTSETCONCURRENCY, PROPERTY_ID_RESULTSETCONCURRENCY, PropertyAttribute::READONLY, &m_nResultSetConcurrency,::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
|
|
|
|
registerProperty(PROPERTY_RESULTSETTYPE, PROPERTY_ID_RESULTSETTYPE, PropertyAttribute::READONLY, &m_nResultSetType, ::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
|
|
|
|
registerProperty(PROPERTY_FETCHDIRECTION, PROPERTY_ID_FETCHDIRECTION, PropertyAttribute::TRANSIENT, &m_nFetchDirection, ::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
|
|
|
|
registerProperty(PROPERTY_FETCHSIZE, PROPERTY_ID_FETCHSIZE, PropertyAttribute::TRANSIENT, &m_nFetchSize, ::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
|
|
|
|
registerProperty(PROPERTY_ISBOOKMARKABLE, PROPERTY_ID_ISBOOKMARKABLE, nRT, &m_bIsBookmarable, ::getBooleanCppuType());
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
ORowSetClone::~ORowSetClone()
|
|
|
|
{
|
|
|
|
DBG_DTOR(ORowSetClone, NULL);
|
|
|
|
}
|
2000-11-03 13:42:50 +00:00
|
|
|
// com::sun::star::XTypeProvider
|
2000-09-18 23:16:46 +00:00
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
Sequence< Type > ORowSetClone::getTypes() throw (RuntimeException)
|
|
|
|
{
|
2000-10-11 10:21:40 +00:00
|
|
|
return ::comphelper::concatSequences(OSubComponent::getTypes(),ORowSetBase::getTypes());
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2000-11-03 13:42:50 +00:00
|
|
|
// com::sun::star::XInterface
|
2000-09-18 23:16:46 +00:00
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
Any ORowSetClone::queryInterface( const Type & rType ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
Any aRet = ORowSetBase::queryInterface(rType);
|
|
|
|
if(!aRet.hasValue())
|
|
|
|
aRet = OSubComponent::queryInterface(rType);
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
2001-11-01 14:27:20 +00:00
|
|
|
void ORowSetClone::acquire() throw()
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
OSubComponent::acquire();
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2001-11-01 14:27:20 +00:00
|
|
|
void ORowSetClone::release() throw()
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
OSubComponent::release();
|
|
|
|
}
|
|
|
|
|
|
|
|
// XServiceInfo
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
rtl::OUString ORowSetClone::getImplementationName( ) throw(RuntimeException)
|
|
|
|
{
|
|
|
|
return rtl::OUString::createFromAscii("com.sun.star.sdb.ORowSetClone");
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
sal_Bool ORowSetClone::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException)
|
|
|
|
{
|
2000-10-11 10:21:40 +00:00
|
|
|
return ::comphelper::findValue(getSupportedServiceNames(), _rServiceName, sal_True).getLength() != 0;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
Sequence< ::rtl::OUString > ORowSetClone::getSupportedServiceNames( ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
Sequence< ::rtl::OUString > aSNS( 2 );
|
|
|
|
aSNS[0] = SERVICE_SDBC_RESULTSET;
|
|
|
|
aSNS[1] = SERVICE_SDB_RESULTSET;
|
|
|
|
return aSNS;
|
|
|
|
}
|
|
|
|
|
|
|
|
// OComponentHelper
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void ORowSetClone::disposing()
|
|
|
|
{
|
2000-11-03 13:42:50 +00:00
|
|
|
MutexGuard aGuard( m_aMutex );
|
2001-04-05 13:14:41 +00:00
|
|
|
ORowSetBase::disposing();
|
|
|
|
|
2001-11-15 09:42:42 +00:00
|
|
|
m_pParent = NULL;
|
|
|
|
m_pMutex = &m_aMutex; // this must be done here because someone could hold a ref to us and try to do something
|
2000-09-18 23:16:46 +00:00
|
|
|
OSubComponent::disposing();
|
|
|
|
}
|
|
|
|
|
|
|
|
// XCloseable
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void ORowSetClone::close(void) throw( SQLException, RuntimeException )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MutexGuard aGuard( m_aMutex );
|
|
|
|
if (OComponentHelper::rBHelper.bDisposed)
|
|
|
|
throw DisposedException();
|
|
|
|
}
|
|
|
|
dispose();
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
2000-10-11 10:21:40 +00:00
|
|
|
// comphelper::OPropertyArrayUsageHelper
|
2000-09-18 23:16:46 +00:00
|
|
|
::cppu::IPropertyArrayHelper* ORowSetClone::createArrayHelper( ) const
|
|
|
|
{
|
|
|
|
Sequence< Property > aProps;
|
|
|
|
describeProperties(aProps);
|
|
|
|
return new ::cppu::OPropertyArrayHelper(aProps);
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// cppu::OPropertySetHelper
|
|
|
|
::cppu::IPropertyArrayHelper& SAL_CALL ORowSetClone::getInfoHelper()
|
|
|
|
{
|
2000-10-11 10:21:40 +00:00
|
|
|
typedef ::comphelper::OPropertyArrayUsageHelper<ORowSetClone> ORowSetClone_PROP;
|
2000-09-18 23:16:46 +00:00
|
|
|
return *ORowSetClone_PROP::getArrayHelper();
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
2000-12-06 08:55:44 +00:00
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
Sequence< sal_Int8 > ORowSetClone::getUnoTunnelImplementationId()
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2000-12-06 08:55:44 +00:00
|
|
|
static ::cppu::OImplementationId * pId = 0;
|
2000-09-18 23:16:46 +00:00
|
|
|
if (! pId)
|
|
|
|
{
|
2000-12-06 08:55:44 +00:00
|
|
|
::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
|
2000-09-18 23:16:46 +00:00
|
|
|
if (! pId)
|
|
|
|
{
|
2000-12-06 08:55:44 +00:00
|
|
|
static ::cppu::OImplementationId aId;
|
2000-09-18 23:16:46 +00:00
|
|
|
pId = &aId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pId->getImplementationId();
|
|
|
|
}
|
2000-12-06 08:55:44 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2000-11-03 13:42:50 +00:00
|
|
|
// com::sun::star::XUnoTunnel
|
2000-09-18 23:16:46 +00:00
|
|
|
sal_Int64 SAL_CALL ORowSetClone::getSomething( const Sequence< sal_Int8 >& rId ) throw(RuntimeException)
|
|
|
|
{
|
2000-12-06 08:55:44 +00:00
|
|
|
if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
|
2000-09-18 23:16:46 +00:00
|
|
|
return (sal_Int64)this;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2000-12-06 08:55:44 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void ORowSetClone::rowDelete(const ::com::sun::star::uno::Any& _rBookmark)
|
|
|
|
{
|
|
|
|
if(compareBookmarks(_rBookmark,m_aBookmark) == 0)
|
|
|
|
{
|
2001-06-22 09:48:40 +00:00
|
|
|
OSL_ENSURE(m_aBookmark.hasValue(),"ORowSetClone::rowDelete: Bookmark isn't valid!");
|
2001-11-15 09:42:42 +00:00
|
|
|
::osl::MutexGuard aGuard( *m_pMutex );
|
2000-12-06 08:55:44 +00:00
|
|
|
m_pCache->moveToBookmark(m_aBookmark);
|
|
|
|
m_nPosition = m_pCache->getRow();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void ORowSetClone::rowDeleted(const ::com::sun::star::uno::Any& _rBookmark)
|
|
|
|
{
|
|
|
|
if(compareBookmarks(_rBookmark,m_aBookmark) == 0)
|
|
|
|
{
|
|
|
|
m_aBookmark = Any();
|
|
|
|
m_aCurrentRow = NULL;
|
2001-01-22 06:38:24 +00:00
|
|
|
m_aCurrentRow.setBookmark(Any());
|
2000-12-06 08:55:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2001-01-24 08:52:19 +00:00
|
|
|
void SAL_CALL ORowSetClone::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) throw (Exception)
|
|
|
|
{
|
|
|
|
switch(nHandle)
|
|
|
|
{
|
|
|
|
case PROPERTY_ID_FETCHSIZE:
|
|
|
|
if(m_pParent)
|
|
|
|
m_pParent->setFastPropertyValue_NoBroadcast(nHandle,rValue);
|
|
|
|
// run through
|
|
|
|
default:
|
|
|
|
OPropertyContainer::setFastPropertyValue_NoBroadcast(nHandle,rValue);
|
|
|
|
}
|
2000-12-06 08:55:44 +00:00
|
|
|
|
2001-01-24 08:52:19 +00:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2002-12-05 08:53:00 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void ORowSetClone::doCancelModification( )
|
|
|
|
{
|
|
|
|
OSL_ENSURE( sal_False, "ORowSetClone::doCancelModification: invalid call!" );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
sal_Bool ORowSetClone::isModification( )
|
|
|
|
{
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
sal_Bool ORowSetClone::isModified( )
|
|
|
|
{
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
sal_Bool ORowSetClone::isNew( )
|
|
|
|
{
|
|
|
|
return sal_False;
|
|
|
|
}
|
2000-11-03 13:42:50 +00:00
|
|
|
|
2001-09-18 10:24:33 +00:00
|
|
|
}
|