LCOV - code coverage report
Current view: top level - dbaccess/source/core/api - RowSet.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 1570 0.0 %
Date: 2014-04-14 Functions: 0 170 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "sal/config.h"
      21             : 
      22             : #include <map>
      23             : #include <utility>
      24             : 
      25             : #include <string.h>
      26             : #include "RowSet.hxx"
      27             : #include "dbastrings.hrc"
      28             : #include "sdbcoretools.hxx"
      29             : #include "SingleSelectQueryComposer.hxx"
      30             : #include "module_dba.hxx"
      31             : #include "CRowSetColumn.hxx"
      32             : #include "CRowSetDataColumn.hxx"
      33             : #include "RowSetCache.hxx"
      34             : #include "core_resource.hrc"
      35             : #include "core_resource.hxx"
      36             : #include "tablecontainer.hxx"
      37             : 
      38             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      39             : #include <com/sun/star/container/XChild.hpp>
      40             : #include <com/sun/star/lang/DisposedException.hpp>
      41             : #include <com/sun/star/sdb/CommandType.hpp>
      42             : #include <com/sun/star/sdb/DatabaseContext.hpp>
      43             : #include <com/sun/star/sdb/ErrorCondition.hpp>
      44             : #include <com/sun/star/sdb/RowChangeAction.hpp>
      45             : #include <com/sun/star/sdb/RowSetVetoException.hpp>
      46             : #include <com/sun/star/sdb/XCompletedConnection.hpp>
      47             : #include <com/sun/star/sdb/XParametersSupplier.hpp>
      48             : #include <com/sun/star/sdb/XQueriesSupplier.hpp>
      49             : #include <com/sun/star/sdbc/FetchDirection.hpp>
      50             : #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
      51             : #include <com/sun/star/sdbc/XDataSource.hpp>
      52             : #include <com/sun/star/sdbc/XDriverAccess.hpp>
      53             : #include <com/sun/star/sdbcx/CompareBookmark.hpp>
      54             : #include <com/sun/star/sdbcx/Privilege.hpp>
      55             : #include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
      56             : #include <com/sun/star/uno/XNamingService.hpp>
      57             : #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
      58             : 
      59             : #include <comphelper/processfactory.hxx>
      60             : #include <comphelper/interaction.hxx>
      61             : #include <comphelper/property.hxx>
      62             : #include <comphelper/seqstream.hxx>
      63             : #include <comphelper/sequence.hxx>
      64             : #include <comphelper/types.hxx>
      65             : #include <comphelper/uno3.hxx>
      66             : #include <connectivity/BlobHelper.hxx>
      67             : #include <connectivity/dbconversion.hxx>
      68             : #include <connectivity/dbexception.hxx>
      69             : #include <connectivity/dbtools.hxx>
      70             : #include <cppuhelper/exc_hlp.hxx>
      71             : #include <cppuhelper/interfacecontainer.h>
      72             : #include <cppuhelper/supportsservice.hxx>
      73             : #include <cppuhelper/typeprovider.hxx>
      74             : #include <unotools/syslocale.hxx>
      75             : #include <tools/debug.hxx>
      76             : #include <tools/diagnose_ex.h>
      77             : #include <unotools/configmgr.hxx>
      78             : 
      79             : using namespace utl;
      80             : using namespace dbaccess;
      81             : using namespace connectivity;
      82             : using namespace comphelper;
      83             : using namespace dbtools;
      84             : using namespace ::com::sun::star;
      85             : using namespace ::com::sun::star::uno;
      86             : using namespace ::com::sun::star::beans;
      87             : using namespace ::com::sun::star::sdbc;
      88             : using namespace ::com::sun::star::sdb;
      89             : using namespace ::com::sun::star::sdbcx;
      90             : using namespace ::com::sun::star::container;
      91             : using namespace ::com::sun::star::lang;
      92             : using namespace ::com::sun::star::task;
      93             : using namespace ::com::sun::star::util;
      94             : using namespace ::cppu;
      95             : using namespace ::osl;
      96             : 
      97           0 : extern "C" void SAL_CALL createRegistryInfo_ORowSet()
      98             : {
      99           0 :     static ::dba::OAutoRegistration< ORowSet > aAutoRegistration;
     100           0 : }
     101             : 
     102             : #define NOTIFY_LISTERNERS_CHECK(_rListeners,T,method)                             \
     103             :     Sequence< Reference< XInterface > > aListenerSeq = _rListeners.getElements(); \
     104             :                                                                                   \
     105             :     const Reference< XInterface >* pxIntBegin = aListenerSeq.getConstArray();     \
     106             :     const Reference< XInterface >* pxInt = pxIntBegin + aListenerSeq.getLength(); \
     107             :                                                                                   \
     108             :     _rGuard.clear();                                                              \
     109             :     sal_Bool bCheck = sal_True;                                                   \
     110             :     while( pxInt > pxIntBegin && bCheck )                                         \
     111             :     {                                                                             \
     112             :         try                                                                       \
     113             :         {                                                                         \
     114             :             while( pxInt > pxIntBegin && bCheck )                                 \
     115             :             {                                                                     \
     116             :                 --pxInt;                                                          \
     117             :                 bCheck = static_cast< T* >( pxInt->get() )->method(aEvt);         \
     118             :             }                                                                     \
     119             :         }                                                                         \
     120             :         catch( RuntimeException& )                                                \
     121             :         {                                                                         \
     122             :         }                                                                         \
     123             :     }                                                                             \
     124             :     _rGuard.reset();
     125             : 
     126             : 
     127             : namespace dbaccess
     128             : {
     129           0 : ORowSet::ORowSet( const Reference< ::com::sun::star::uno::XComponentContext >& _rxContext )
     130             :     :ORowSet_BASE1(m_aMutex)
     131             :     ,ORowSetBase( _rxContext, ORowSet_BASE1::rBHelper, &m_aMutex )
     132             :     ,m_pParameters( NULL )
     133             :     ,m_aRowsetListeners(*m_pMutex)
     134             :     ,m_aApproveListeners(*m_pMutex)
     135             :     ,m_aRowsChangeListener(*m_pMutex)
     136             :     ,m_pTables(NULL)
     137             :     ,m_nFetchDirection(FetchDirection::FORWARD)
     138             :     ,m_nFetchSize(50)
     139             :     ,m_nMaxFieldSize(0)
     140             :     ,m_nMaxRows(0)
     141             :     ,m_nQueryTimeOut(0)
     142             :     ,m_nCommandType(CommandType::COMMAND)
     143             :     ,m_nTransactionIsolation(0)
     144             :     ,m_nPrivileges(0)
     145             :     ,m_nLastKnownRowCount(0)
     146             :     ,m_nInAppend(0)
     147             :     ,m_bLastKnownRowCountFinal(sal_False)
     148             :     ,m_bUseEscapeProcessing(sal_True)
     149             :     ,m_bApplyFilter(sal_False)
     150             :     ,m_bCommandFacetsDirty( sal_True )
     151             :     ,m_bParametersDirty( true )
     152             :     ,m_bModified(sal_False)
     153             :     ,m_bRebuildConnOnExecute(sal_False)
     154             :     ,m_bIsBookmarkable(sal_True)
     155             :     ,m_bNew(sal_False)
     156             :     ,m_bCanUpdateInsertedRows(sal_True)
     157             :     ,m_bOwnConnection(sal_False)
     158           0 :     ,m_bPropChangeNotifyEnabled(sal_True)
     159             : {
     160           0 :     m_nResultSetType = ResultSetType::SCROLL_SENSITIVE;
     161           0 :     m_nResultSetConcurrency = ResultSetConcurrency::UPDATABLE;
     162           0 :     m_pMySelf = this;
     163           0 :     m_aActiveConnection <<= m_xActiveConnection;
     164             : 
     165           0 :     sal_Int32 nRBT  = PropertyAttribute::READONLY   | PropertyAttribute::BOUND      | PropertyAttribute::TRANSIENT;
     166           0 :     sal_Int32 nRT   = PropertyAttribute::READONLY   | PropertyAttribute::TRANSIENT;
     167           0 :     sal_Int32 nBT   = PropertyAttribute::BOUND      | PropertyAttribute::TRANSIENT;
     168             : 
     169           0 :     m_aPrematureParamValues.get().resize( 0 );
     170             : 
     171             :     // sdb.RowSet Properties
     172           0 :     registerMayBeVoidProperty(PROPERTY_ACTIVE_CONNECTION,PROPERTY_ID_ACTIVE_CONNECTION, PropertyAttribute::MAYBEVOID|PropertyAttribute::TRANSIENT|PropertyAttribute::BOUND, &m_aActiveConnection,   ::getCppuType(static_cast< Reference< XConnection >* >(0)));
     173           0 :     registerProperty(PROPERTY_DATASOURCENAME,       PROPERTY_ID_DATASOURCENAME,         PropertyAttribute::BOUND,       &m_aDataSourceName,     ::getCppuType(static_cast< OUString*>(0)));
     174           0 :     registerProperty(PROPERTY_COMMAND,              PROPERTY_ID_COMMAND,                PropertyAttribute::BOUND,       &m_aCommand,            ::getCppuType(static_cast< OUString*>(0)));
     175           0 :     registerProperty(PROPERTY_COMMAND_TYPE,         PROPERTY_ID_COMMAND_TYPE,           PropertyAttribute::BOUND,       &m_nCommandType,        ::getCppuType(static_cast< sal_Int32*>(0)));
     176           0 :     registerProperty(PROPERTY_ACTIVECOMMAND,        PROPERTY_ID_ACTIVECOMMAND,          nRBT,                           &m_aActiveCommand,      ::getCppuType(static_cast< OUString*>(0)));
     177           0 :     registerProperty(PROPERTY_IGNORERESULT,         PROPERTY_ID_IGNORERESULT,           PropertyAttribute::BOUND,       &m_bIgnoreResult,       ::getBooleanCppuType());
     178           0 :     registerProperty(PROPERTY_FILTER,               PROPERTY_ID_FILTER,                 PropertyAttribute::BOUND,       &m_aFilter,             ::getCppuType(static_cast< OUString*>(0)));
     179           0 :     registerProperty(PROPERTY_HAVING_CLAUSE,        PROPERTY_ID_HAVING_CLAUSE,          PropertyAttribute::BOUND,       &m_aHavingClause,       ::getCppuType(static_cast< OUString*>(0)));
     180           0 :     registerProperty(PROPERTY_GROUP_BY,             PROPERTY_ID_GROUP_BY,               PropertyAttribute::BOUND,       &m_aGroupBy,            ::getCppuType(static_cast< OUString*>(0)));
     181           0 :     registerProperty(PROPERTY_APPLYFILTER,          PROPERTY_ID_APPLYFILTER,            PropertyAttribute::BOUND,       &m_bApplyFilter,        ::getBooleanCppuType());
     182           0 :     registerProperty(PROPERTY_ORDER,                PROPERTY_ID_ORDER,                  PropertyAttribute::BOUND,       &m_aOrder,              ::getCppuType(static_cast< OUString*>(0)));
     183           0 :     registerProperty(PROPERTY_PRIVILEGES,           PROPERTY_ID_PRIVILEGES,             nRT,                            &m_nPrivileges,         ::getCppuType(static_cast< sal_Int32*>(0)));
     184           0 :     registerProperty(PROPERTY_ISMODIFIED,           PROPERTY_ID_ISMODIFIED,             nBT,                            &m_bModified,           ::getBooleanCppuType());
     185           0 :     registerProperty(PROPERTY_ISNEW,                PROPERTY_ID_ISNEW,                  nRBT,                           &m_bNew,                ::getBooleanCppuType());
     186           0 :     registerProperty(PROPERTY_SINGLESELECTQUERYCOMPOSER,PROPERTY_ID_SINGLESELECTQUERYCOMPOSER,  nRT,                    &m_xComposer,   ::getCppuType(static_cast< Reference< XSingleSelectQueryComposer >* >(0)));
     187             : 
     188             :     // sdbcx.ResultSet Properties
     189           0 :     registerProperty(PROPERTY_ISBOOKMARKABLE,       PROPERTY_ID_ISBOOKMARKABLE,         nRT,                            &m_bIsBookmarkable,      ::getBooleanCppuType());
     190           0 :     registerProperty(PROPERTY_CANUPDATEINSERTEDROWS,PROPERTY_ID_CANUPDATEINSERTEDROWS,  nRT,                            &m_bCanUpdateInsertedRows,      ::getBooleanCppuType());
     191             :     // sdbc.ResultSet Properties
     192           0 :     registerProperty(PROPERTY_RESULTSETCONCURRENCY, PROPERTY_ID_RESULTSETCONCURRENCY,   PropertyAttribute::TRANSIENT,   &m_nResultSetConcurrency,::getCppuType(static_cast< sal_Int32*>(0)));
     193           0 :     registerProperty(PROPERTY_RESULTSETTYPE,        PROPERTY_ID_RESULTSETTYPE,          PropertyAttribute::TRANSIENT,   &m_nResultSetType,      ::getCppuType(static_cast< sal_Int32*>(0)));
     194           0 :     registerProperty(PROPERTY_FETCHDIRECTION,       PROPERTY_ID_FETCHDIRECTION,         PropertyAttribute::TRANSIENT,   &m_nFetchDirection,     ::getCppuType(static_cast< sal_Int32*>(0)));
     195           0 :     registerProperty(PROPERTY_FETCHSIZE,            PROPERTY_ID_FETCHSIZE,              PropertyAttribute::TRANSIENT,   &m_nFetchSize,          ::getCppuType(static_cast< sal_Int32*>(0)));
     196             : 
     197             :     // sdbc.RowSet Properties
     198           0 :     registerProperty(PROPERTY_URL,                  PROPERTY_ID_URL,                    0,                              &m_aURL,                ::getCppuType(static_cast< OUString*>(0)));
     199           0 :     registerProperty(PROPERTY_TRANSACTIONISOLATION, PROPERTY_ID_TRANSACTIONISOLATION,   PropertyAttribute::TRANSIENT,   &m_nTransactionIsolation,::getCppuType(static_cast< sal_Int32*>(0)));
     200           0 :     registerMayBeVoidProperty(PROPERTY_TYPEMAP,     PROPERTY_ID_TYPEMAP,                PropertyAttribute::MAYBEVOID|PropertyAttribute::TRANSIENT,  &m_aTypeMap,            ::getCppuType(static_cast< Reference< XNameAccess >* >(0)));
     201           0 :     registerProperty(PROPERTY_ESCAPE_PROCESSING,PROPERTY_ID_ESCAPE_PROCESSING,  PropertyAttribute::BOUND,       &m_bUseEscapeProcessing,::getBooleanCppuType()  );
     202           0 :     registerProperty(PROPERTY_QUERYTIMEOUT,         PROPERTY_ID_QUERYTIMEOUT,           PropertyAttribute::TRANSIENT,   &m_nQueryTimeOut,       ::getCppuType(static_cast< sal_Int32*>(0)));
     203           0 :     registerProperty(PROPERTY_MAXFIELDSIZE,         PROPERTY_ID_MAXFIELDSIZE,           PropertyAttribute::TRANSIENT,   &m_nMaxFieldSize,       ::getCppuType(static_cast< sal_Int32*>(0)));
     204           0 :     registerProperty(PROPERTY_MAXROWS,              PROPERTY_ID_MAXROWS,                0,                              &m_nMaxRows,            ::getCppuType(static_cast< sal_Int32*>(0)) );
     205           0 :     registerProperty(PROPERTY_USER,                 PROPERTY_ID_USER,                   PropertyAttribute::TRANSIENT,   &m_aUser,               ::getCppuType(static_cast< OUString*>(0)));
     206           0 :     registerProperty(PROPERTY_PASSWORD,             PROPERTY_ID_PASSWORD,               PropertyAttribute::TRANSIENT,   &m_aPassword,           ::getCppuType(static_cast< OUString*>(0)));
     207             : 
     208           0 :     registerProperty(PROPERTY_UPDATE_CATALOGNAME,   PROPERTY_ID_UPDATE_CATALOGNAME,     PropertyAttribute::BOUND,       &m_aUpdateCatalogName,  ::getCppuType(static_cast< OUString*>(0)));
     209           0 :     registerProperty(PROPERTY_UPDATE_SCHEMANAME,    PROPERTY_ID_UPDATE_SCHEMANAME,      PropertyAttribute::BOUND,       &m_aUpdateSchemaName,   ::getCppuType(static_cast< OUString*>(0)));
     210           0 :     registerProperty(PROPERTY_UPDATE_TABLENAME,     PROPERTY_ID_UPDATE_TABLENAME,       PropertyAttribute::BOUND,       &m_aUpdateTableName,    ::getCppuType(static_cast< OUString*>(0)));
     211             : 
     212             :     // ???
     213           0 :     registerProperty(PROPERTY_CHANGE_NOTIFICATION_ENABLED, PROPERTY_ID_PROPCHANGE_NOTIFY, PropertyAttribute::BOUND,     &m_bPropChangeNotifyEnabled, ::getBooleanCppuType());
     214           0 : }
     215             : 
     216           0 : ORowSet::~ORowSet()
     217             : {
     218           0 :     if ( !m_rBHelper.bDisposed && !m_rBHelper.bInDispose )
     219             :     {
     220             :         SAL_WARN("dbaccess", "Please check who doesn't dispose this component!");
     221           0 :         osl_atomic_increment( &m_refCount );
     222           0 :         dispose();
     223             :     }
     224           0 : }
     225             : 
     226           0 : void ORowSet::getPropertyDefaultByHandle( sal_Int32 _nHandle, Any& _rDefault ) const
     227             : {
     228           0 :     switch( _nHandle )
     229             :     {
     230             :         case PROPERTY_ID_COMMAND_TYPE:
     231           0 :             _rDefault <<= static_cast<sal_Int32>(CommandType::COMMAND);
     232           0 :             break;
     233             :         case PROPERTY_ID_IGNORERESULT:
     234           0 :             _rDefault <<= sal_False;
     235           0 :             break;
     236             :         case PROPERTY_ID_APPLYFILTER:
     237           0 :             _rDefault <<= sal_False;
     238           0 :             break;
     239             :         case PROPERTY_ID_ISMODIFIED:
     240           0 :             _rDefault <<= sal_False;
     241           0 :             break;
     242             :         case PROPERTY_ID_ISBOOKMARKABLE:
     243           0 :             _rDefault <<= sal_True;
     244           0 :             break;
     245             :         case PROPERTY_ID_CANUPDATEINSERTEDROWS:
     246           0 :             _rDefault <<= sal_True;
     247           0 :             break;
     248             :         case PROPERTY_ID_RESULTSETTYPE:
     249           0 :             _rDefault <<= ResultSetType::SCROLL_INSENSITIVE;
     250           0 :             break;
     251             :         case PROPERTY_ID_RESULTSETCONCURRENCY:
     252           0 :             _rDefault <<= ResultSetConcurrency::UPDATABLE;
     253           0 :             break;
     254             :         case PROPERTY_ID_FETCHDIRECTION:
     255           0 :             _rDefault <<= FetchDirection::FORWARD;
     256           0 :             break;
     257             :         case PROPERTY_ID_FETCHSIZE:
     258           0 :             _rDefault <<= static_cast<sal_Int32>(1);
     259           0 :             break;
     260             :         case PROPERTY_ID_ESCAPE_PROCESSING:
     261           0 :             _rDefault <<= sal_True;
     262           0 :             break;
     263             :         case PROPERTY_ID_MAXROWS:
     264           0 :             _rDefault <<= sal_Int32( 0 );
     265           0 :             break;
     266             :         case PROPERTY_ID_FILTER:
     267             :         case PROPERTY_ID_HAVING_CLAUSE:
     268             :         case PROPERTY_ID_GROUP_BY:
     269             :         case PROPERTY_ID_ORDER:
     270             :         case PROPERTY_ID_UPDATE_CATALOGNAME:
     271             :         case PROPERTY_ID_UPDATE_SCHEMANAME:
     272             :         case PROPERTY_ID_UPDATE_TABLENAME:
     273           0 :             _rDefault <<= OUString();
     274           0 :             break;
     275             :     }
     276           0 : }
     277             : 
     278             : //  typedef ::comphelper::OPropertyArrayUsageHelper<ORowSet> ORowSet_Prop;
     279           0 : void SAL_CALL ORowSet::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) throw (Exception, std::exception)
     280             : {
     281           0 :     switch(nHandle)
     282             :     {
     283             :         case PROPERTY_ID_ISMODIFIED:
     284           0 :             m_bModified = cppu::any2bool(rValue);
     285           0 :             break;
     286             :         case PROPERTY_ID_FETCHDIRECTION:
     287           0 :             if( m_nResultSetType == ResultSetType::FORWARD_ONLY)
     288           0 :                 throw Exception(); // else run through
     289             :         default:
     290           0 :             OPropertyStateContainer::setFastPropertyValue_NoBroadcast(nHandle,rValue);
     291             :     }
     292             : 
     293           0 :     if  (   ( nHandle == PROPERTY_ID_ACTIVE_CONNECTION )
     294           0 :         ||  ( nHandle == PROPERTY_ID_DATASOURCENAME )
     295           0 :         ||  ( nHandle == PROPERTY_ID_COMMAND )
     296           0 :         ||  ( nHandle == PROPERTY_ID_COMMAND_TYPE )
     297           0 :         ||  ( nHandle == PROPERTY_ID_IGNORERESULT )
     298           0 :         ||  ( nHandle == PROPERTY_ID_FILTER )
     299           0 :         ||  ( nHandle == PROPERTY_ID_HAVING_CLAUSE )
     300           0 :         ||  ( nHandle == PROPERTY_ID_GROUP_BY )
     301           0 :         ||  ( nHandle == PROPERTY_ID_APPLYFILTER )
     302           0 :         ||  ( nHandle == PROPERTY_ID_ORDER )
     303           0 :         ||  ( nHandle == PROPERTY_ID_URL )
     304           0 :         ||  ( nHandle == PROPERTY_ID_USER )
     305             :         )
     306             :     {
     307           0 :         m_bCommandFacetsDirty = sal_True;
     308             :     }
     309             : 
     310             : 
     311           0 :     switch(nHandle)
     312             :     {
     313             :         case PROPERTY_ID_ACTIVE_CONNECTION:
     314             :             // the new connection
     315             :             {
     316           0 :                 Reference< XConnection > xNewConnection(m_aActiveConnection,UNO_QUERY);
     317           0 :                 setActiveConnection(xNewConnection, sal_False);
     318             :             }
     319             : 
     320           0 :             m_bOwnConnection        = sal_False;
     321           0 :             m_bRebuildConnOnExecute = sal_False;
     322           0 :             break;
     323             : 
     324             :         case PROPERTY_ID_DATASOURCENAME:
     325           0 :             if(!m_xStatement.is())
     326             :             {
     327           0 :                 Reference< XConnection >  xNewConn;
     328           0 :                 Any aNewConn;
     329           0 :                 aNewConn <<= xNewConn;
     330           0 :                 setFastPropertyValue(PROPERTY_ID_ACTIVE_CONNECTION, aNewConn);
     331             :             }
     332             :             else
     333           0 :                 m_bRebuildConnOnExecute = sal_True;
     334           0 :             break;
     335             :         case PROPERTY_ID_FETCHSIZE:
     336           0 :             if(m_pCache)
     337             :             {
     338           0 :                 m_pCache->setFetchSize(m_nFetchSize);
     339           0 :                 fireRowcount();
     340             :             }
     341           0 :             break;
     342             :         case PROPERTY_ID_URL:
     343             :             // is the connection-to-be-built determined by the url (which is the case if m_aDataSourceName is empty) ?
     344           0 :             if (m_aDataSourceName.isEmpty())
     345             :             {
     346             :                 // are we active at the moment ?
     347           0 :                 if (m_xStatement.is())
     348             :                     // yes -> the next execute needs to rebuild our connection because of this new property
     349           0 :                     m_bRebuildConnOnExecute = sal_True;
     350             :                 else
     351             :                 {   // no -> drop our active connection (if we have one) as it doesn't correspond to this new property value anymore
     352           0 :                     Reference< XConnection >  xNewConn;
     353           0 :                     Any aNewConn;
     354           0 :                     aNewConn <<= xNewConn;
     355           0 :                     setFastPropertyValue(PROPERTY_ID_ACTIVE_CONNECTION, aNewConn);
     356             :                 }
     357             :             }
     358           0 :             m_bOwnConnection = sal_True;
     359           0 :             break;
     360             :         case PROPERTY_ID_TYPEMAP:
     361           0 :             m_xTypeMap.set(m_aTypeMap, css::uno::UNO_QUERY);
     362           0 :             break;
     363             :         case PROPERTY_ID_PROPCHANGE_NOTIFY:
     364           0 :             m_bPropChangeNotifyEnabled = ::cppu::any2bool(rValue);
     365           0 :             break;
     366             :         default:
     367           0 :             break;
     368             :     };
     369           0 : }
     370             : 
     371           0 : void SAL_CALL ORowSet::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const
     372             : {
     373           0 :     if(m_pCache)
     374             :     {
     375           0 :         switch(nHandle)
     376             :         {
     377             :         case PROPERTY_ID_ISMODIFIED:
     378           0 :             rValue.setValue(&m_bModified,::getCppuBooleanType());
     379           0 :             break;
     380             :         case PROPERTY_ID_ISNEW:
     381           0 :             rValue.setValue(&m_bNew,::getCppuBooleanType());
     382           0 :             break;
     383             :         case PROPERTY_ID_PRIVILEGES:
     384           0 :             rValue <<= m_pCache->m_nPrivileges;
     385           0 :             break;
     386             :         case PROPERTY_ID_ACTIVE_CONNECTION:
     387           0 :             rValue <<= m_xActiveConnection;
     388           0 :             break;
     389             :         case PROPERTY_ID_TYPEMAP:
     390           0 :             rValue <<= m_xTypeMap;
     391           0 :             break;
     392             :         default:
     393           0 :             ORowSetBase::getFastPropertyValue(rValue,nHandle);
     394             :         };
     395             :     }
     396             :     else
     397             :     {
     398           0 :         switch(nHandle)
     399             :         {
     400             :             case PROPERTY_ID_ACTIVE_CONNECTION:
     401           0 :                 rValue <<= m_xActiveConnection;
     402           0 :                 break;
     403             :             case PROPERTY_ID_TYPEMAP:
     404           0 :                 rValue <<= m_xTypeMap;
     405           0 :                 break;
     406             :             case PROPERTY_ID_PROPCHANGE_NOTIFY:
     407           0 :                 rValue <<= m_bPropChangeNotifyEnabled;
     408           0 :                 break;
     409             :             default:
     410           0 :                 ORowSetBase::getFastPropertyValue(rValue,nHandle);
     411             :         }
     412             :     }
     413           0 : }
     414             : 
     415             : // com::sun::star::XTypeProvider
     416           0 : Sequence< Type > SAL_CALL ORowSet::getTypes() throw (RuntimeException, std::exception)
     417             : {
     418           0 :     OTypeCollection aTypes(::getCppuType( (const Reference< XPropertySet > *)0 ),
     419           0 :                             ::getCppuType( (const Reference< XFastPropertySet > *)0 ),
     420           0 :                             ::getCppuType( (const Reference< XMultiPropertySet > *)0 ),
     421           0 :                            ::comphelper::concatSequences(ORowSet_BASE1::getTypes(),ORowSetBase::getTypes()));
     422           0 :     return aTypes.getTypes();
     423             : }
     424             : 
     425           0 : Sequence< sal_Int8 > SAL_CALL ORowSet::getImplementationId() throw (RuntimeException, std::exception)
     426             : {
     427           0 :     return css::uno::Sequence<sal_Int8>();
     428             : }
     429             : 
     430             : // com::sun::star::XInterface
     431           0 : Any SAL_CALL ORowSet::queryInterface( const Type & rType ) throw (RuntimeException, std::exception)
     432             : {
     433           0 :     return ORowSet_BASE1::queryInterface( rType);
     434             : }
     435             : 
     436           0 : void SAL_CALL ORowSet::acquire() throw()
     437             : {
     438           0 :     ORowSet_BASE1::acquire();
     439           0 : }
     440             : 
     441           0 : void SAL_CALL ORowSet::release() throw()
     442             : {
     443           0 :     ORowSet_BASE1::release();
     444           0 : }
     445             : 
     446             : // com::sun::star::XUnoTunnel
     447           0 : sal_Int64 SAL_CALL ORowSet::getSomething( const Sequence< sal_Int8 >& rId ) throw(RuntimeException, std::exception)
     448             : {
     449           0 :     if (rId.getLength() == 16 && 0 == memcmp(getUnoTunnelImplementationId().getConstArray(),  rId.getConstArray(), 16 ) )
     450           0 :         return reinterpret_cast<sal_Int64>(this);
     451             : 
     452           0 :     return 0;
     453             : }
     454             : 
     455           0 : Sequence< sal_Int8 > ORowSet::getUnoTunnelImplementationId()
     456             : {
     457             :     static ::cppu::OImplementationId * pId = 0;
     458           0 :     if (! pId)
     459             :     {
     460           0 :         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
     461           0 :         if (! pId)
     462             :         {
     463           0 :             static ::cppu::OImplementationId aId;
     464           0 :             pId = &aId;
     465           0 :         }
     466             :     }
     467           0 :     return pId->getImplementationId();
     468             : }
     469             : 
     470             : // com::sun::star::XAggregation
     471           0 : Any SAL_CALL ORowSet::queryAggregation( const Type& rType ) throw(RuntimeException, std::exception)
     472             : {
     473           0 :     Any aRet(ORowSetBase::queryInterface(rType));
     474           0 :     if (!aRet.hasValue())
     475           0 :         aRet = ORowSet_BASE1::queryAggregation(rType);
     476           0 :     return aRet;
     477             : }
     478             : 
     479           0 : OUString ORowSet::getImplementationName_static(  ) throw(RuntimeException)
     480             : {
     481           0 :     return OUString("com.sun.star.comp.dba.ORowSet");
     482             : }
     483             : 
     484             : // ::com::sun::star::XServiceInfo
     485           0 : OUString SAL_CALL ORowSet::getImplementationName(  ) throw(RuntimeException, std::exception)
     486             : {
     487           0 :     return getImplementationName_static();
     488             : }
     489             : 
     490           0 : sal_Bool SAL_CALL ORowSet::supportsService( const OUString& _rServiceName ) throw(RuntimeException, std::exception)
     491             : {
     492           0 :     return cppu::supportsService(this, _rServiceName);
     493             : }
     494             : 
     495           0 : Sequence< OUString > ORowSet::getSupportedServiceNames_static(  ) throw (RuntimeException)
     496             : {
     497           0 :     Sequence< OUString > aSNS( 5 );
     498           0 :     aSNS[0] = SERVICE_SDBC_RESULTSET;
     499           0 :     aSNS[1] = SERVICE_SDBC_ROWSET;
     500           0 :     aSNS[2] = SERVICE_SDBCX_RESULTSET;
     501           0 :     aSNS[3] = SERVICE_SDB_RESULTSET;
     502           0 :     aSNS[4] = SERVICE_SDB_ROWSET;
     503           0 :     return aSNS;
     504             : }
     505             : 
     506           0 : Sequence< OUString > SAL_CALL ORowSet::getSupportedServiceNames(  ) throw(RuntimeException, std::exception)
     507             : {
     508           0 :     return getSupportedServiceNames_static();
     509             : }
     510             : 
     511           0 : Reference< XInterface > ORowSet::Create(const Reference< XComponentContext >& _rxContext)
     512             : {
     513           0 :     return *(new ORowSet( _rxContext ));
     514             : }
     515             : 
     516             : // OComponentHelper
     517           0 : void SAL_CALL ORowSet::disposing()
     518             : {
     519           0 :     OPropertyStateContainer::disposing();
     520             : 
     521           0 :     MutexGuard aGuard(m_aMutex);
     522           0 :     EventObject aDisposeEvent;
     523           0 :     aDisposeEvent.Source = static_cast< XComponent* >(this);
     524           0 :     m_aRowsetListeners.disposeAndClear( aDisposeEvent );
     525           0 :     m_aApproveListeners.disposeAndClear( aDisposeEvent );
     526           0 :     m_aRowsChangeListener.disposeAndClear( aDisposeEvent );
     527             : 
     528           0 :     freeResources( true );
     529             : 
     530             :     // remove myself as dispose listener
     531           0 :     Reference< XComponent >  xComponent(m_xActiveConnection, UNO_QUERY);
     532           0 :     if (xComponent.is())
     533             :     {
     534           0 :         Reference<XEventListener> xEvt;
     535           0 :         query_aggregation(this,xEvt);
     536           0 :         xComponent->removeEventListener(xEvt);
     537             :     }
     538             : 
     539           0 :     m_aActiveConnection = Any(); // the any conatains a reference too
     540           0 :     if(m_bOwnConnection)
     541           0 :         ::comphelper::disposeComponent(m_xActiveConnection);
     542           0 :     m_xActiveConnection = NULL;
     543             : 
     544             : 
     545           0 :     ORowSetBase::disposing();
     546           0 : }
     547             : 
     548           0 : void ORowSet::freeResources( bool _bComplete )
     549             : {
     550           0 :     MutexGuard aGuard(m_aMutex);
     551             : 
     552             :     // free all clones
     553           0 :     connectivity::OWeakRefArray::iterator aEnd = m_aClones.end();
     554           0 :     for (connectivity::OWeakRefArray::iterator i = m_aClones.begin(); aEnd != i; ++i)
     555             :     {
     556           0 :         Reference< XComponent > xComp(i->get(), UNO_QUERY);
     557           0 :         if (xComp.is())
     558           0 :             xComp->dispose();
     559           0 :     }
     560           0 :     m_aClones.clear();
     561             : 
     562           0 :     if ( _bComplete )
     563             :     {
     564             :         // the columns must be disposed before the querycomposer is disposed because
     565             :         // their owner can be the composer
     566           0 :         TDataColumns().swap(m_aDataColumns);// clear and resize capacity
     567           0 :         ::std::vector<bool>().swap(m_aReadOnlyDataColumns);
     568             : 
     569           0 :         m_xColumns      = NULL;
     570           0 :         if ( m_pColumns )
     571           0 :             m_pColumns->disposing();
     572             :         // dispose the composer to avoid that everbody knows that the querycomposer is eol
     573           0 :         try { ::comphelper::disposeComponent( m_xComposer ); }
     574           0 :         catch(Exception&)
     575             :         {
     576             :             DBG_UNHANDLED_EXCEPTION();
     577           0 :             m_xComposer = NULL;
     578             :         }
     579             : 
     580             :         // let our warnings container forget the reference to the (possibly disposed) old result set
     581           0 :         m_aWarnings.setExternalWarnings( NULL );
     582             : 
     583           0 :         DELETEZ(m_pCache);
     584             : 
     585           0 :         impl_resetTables_nothrow();
     586             : 
     587           0 :         m_xStatement    = NULL;
     588           0 :         m_xTypeMap      = NULL;
     589             : 
     590           0 :         m_aBookmark     = Any();
     591           0 :         m_bBeforeFirst  = sal_True;
     592           0 :         m_bAfterLast    = sal_False;
     593           0 :         m_bNew          = sal_False;
     594           0 :         m_bModified     = sal_False;
     595           0 :         m_bIsInsertRow  = sal_False;
     596           0 :         m_bLastKnownRowCountFinal = sal_False;
     597           0 :         m_nLastKnownRowCount      = 0;
     598           0 :         if ( m_aOldRow.is() )
     599           0 :             m_aOldRow->clearRow();
     600             : 
     601           0 :         impl_disposeParametersContainer_nothrow();
     602             : 
     603           0 :         m_bCommandFacetsDirty = sal_True;
     604           0 :     }
     605           0 : }
     606             : 
     607           0 : void ORowSet::setActiveConnection( Reference< XConnection >& _rxNewConn, sal_Bool _bFireEvent )
     608             : {
     609           0 :     if (_rxNewConn.get() == m_xActiveConnection.get())
     610             :         // nothing to do
     611           0 :         return;
     612             : 
     613             :     // remove the event listener for the old connection
     614           0 :     Reference< XComponent >  xComponent(m_xActiveConnection, UNO_QUERY);
     615           0 :     if (xComponent.is())
     616             :     {
     617           0 :         Reference<XEventListener> xListener;
     618           0 :         query_aggregation(this, xListener);
     619           0 :         xComponent->removeEventListener(xListener);
     620             :     }
     621             : 
     622             :     // if we owned the connection, remember it for later disposing
     623           0 :     if(m_bOwnConnection)
     624           0 :         m_xOldConnection = m_xActiveConnection;
     625             : 
     626             :     // for firing the PropertyChangeEvent
     627           0 :     sal_Int32 nHandle = PROPERTY_ID_ACTIVE_CONNECTION;
     628           0 :     Any aOldConnection; aOldConnection <<= m_xActiveConnection;
     629           0 :     Any aNewConnection; aNewConnection <<= _rxNewConn;
     630             : 
     631             :     // set the new connection
     632           0 :     m_xActiveConnection = _rxNewConn;
     633           0 :     if (m_xActiveConnection.is())
     634           0 :         m_aActiveConnection <<= m_xActiveConnection;
     635             :     else
     636           0 :         m_aActiveConnection.clear();
     637             : 
     638             :     // fire the event
     639           0 :     if (_bFireEvent)
     640           0 :         fire(&nHandle, &aNewConnection, &aOldConnection, 1, sal_False);
     641             : 
     642             :     // register as event listener for the new connection
     643           0 :     xComponent.set(m_xActiveConnection,UNO_QUERY);
     644           0 :     if (xComponent.is())
     645             :     {
     646           0 :         Reference<XEventListener> xListener;
     647           0 :         query_aggregation(this, xListener);
     648           0 :         xComponent->addEventListener(xListener);
     649           0 :     }
     650             : }
     651             : 
     652             : // ::com::sun::star::XEventListener
     653           0 : void SAL_CALL ORowSet::disposing( const ::com::sun::star::lang::EventObject& Source ) throw(RuntimeException, std::exception)
     654             : {
     655             :     // close rowset because the connection is going to be deleted (someone told me :-)
     656           0 :     Reference<XConnection> xCon(Source.Source,UNO_QUERY);
     657           0 :     if(m_xActiveConnection == xCon)
     658             :     {
     659           0 :         close();
     660             :         {
     661           0 :             MutexGuard aGuard( m_aMutex );
     662           0 :             Reference< XConnection > xXConnection;
     663           0 :             setActiveConnection( xXConnection );
     664             :         }
     665           0 :     }
     666           0 : }
     667             : 
     668             : // XCloseable
     669           0 : void SAL_CALL ORowSet::close(  ) throw(SQLException, RuntimeException, std::exception)
     670             : {
     671             :     {
     672           0 :         MutexGuard aGuard( m_aMutex );
     673           0 :         ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
     674             :     }
     675             :     // additionals things to set
     676           0 :     freeResources( true );
     677           0 : }
     678             : 
     679             : // comphelper::OPropertyArrayUsageHelper
     680           0 : ::cppu::IPropertyArrayHelper* ORowSet::createArrayHelper( ) const
     681             : {
     682           0 :     Sequence< Property > aProps;
     683           0 :     describeProperties(aProps);
     684           0 :     return new ::cppu::OPropertyArrayHelper(aProps);
     685             : }
     686             : 
     687             : // cppu::OPropertySetHelper
     688           0 : ::cppu::IPropertyArrayHelper& SAL_CALL ORowSet::getInfoHelper()
     689             : {
     690             :     typedef ::comphelper::OPropertyArrayUsageHelper<ORowSet> ORowSet_PROP;
     691           0 :     return *ORowSet_PROP::getArrayHelper();
     692             : }
     693             : 
     694           0 : void ORowSet::updateValue(sal_Int32 columnIndex,const ORowSetValue& x)
     695             : {
     696           0 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
     697             : 
     698           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
     699           0 :     checkUpdateConditions(columnIndex);
     700           0 :     checkUpdateIterator();
     701             : 
     702           0 :     ORowSetValueVector::Vector& rRow = ((*m_aCurrentRow)->get());
     703           0 :     ORowSetNotifier aNotify(this,rRow);
     704           0 :     m_pCache->updateValue(columnIndex,x,rRow,aNotify.getChangedColumns());
     705           0 :     m_bModified = m_bModified || !aNotify.getChangedColumns().empty();
     706           0 :     aNotify.firePropertyChange();
     707           0 : }
     708             : 
     709             : // XRowUpdate
     710           0 : void SAL_CALL ORowSet::updateNull( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     711             : {
     712           0 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
     713             : 
     714           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
     715           0 :     checkUpdateConditions(columnIndex);
     716           0 :     checkUpdateIterator();
     717             : 
     718           0 :     ORowSetValueVector::Vector& rRow = ((*m_aCurrentRow)->get());
     719           0 :     ORowSetNotifier aNotify(this,rRow);
     720           0 :     m_pCache->updateNull(columnIndex,rRow,aNotify.getChangedColumns());
     721           0 :     m_bModified = m_bModified || !aNotify.getChangedColumns().empty();
     722           0 :     aNotify.firePropertyChange();
     723           0 : }
     724             : 
     725           0 : void SAL_CALL ORowSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(SQLException, RuntimeException, std::exception)
     726             : {
     727           0 :     updateValue(columnIndex, static_cast<bool>(x));
     728           0 : }
     729             : 
     730           0 : void SAL_CALL ORowSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(SQLException, RuntimeException, std::exception)
     731             : {
     732           0 :     updateValue(columnIndex,x);
     733           0 : }
     734             : 
     735           0 : void SAL_CALL ORowSet::updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(SQLException, RuntimeException, std::exception)
     736             : {
     737           0 :     updateValue(columnIndex,x);
     738           0 : }
     739             : 
     740           0 : void SAL_CALL ORowSet::updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(SQLException, RuntimeException, std::exception)
     741             : {
     742           0 :     updateValue(columnIndex,x);
     743           0 : }
     744             : 
     745           0 : void SAL_CALL ORowSet::updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw(SQLException, RuntimeException, std::exception)
     746             : {
     747           0 :     updateValue(columnIndex,x);
     748           0 : }
     749             : 
     750           0 : void SAL_CALL ORowSet::updateFloat( sal_Int32 columnIndex, float x ) throw(SQLException, RuntimeException, std::exception)
     751             : {
     752           0 :     updateValue(columnIndex,x);
     753           0 : }
     754             : 
     755           0 : void SAL_CALL ORowSet::updateDouble( sal_Int32 columnIndex, double x ) throw(SQLException, RuntimeException, std::exception)
     756             : {
     757           0 :     updateValue(columnIndex,x);
     758           0 : }
     759             : 
     760           0 : void SAL_CALL ORowSet::updateString( sal_Int32 columnIndex, const OUString& x ) throw(SQLException, RuntimeException, std::exception)
     761             : {
     762           0 :     updateValue(columnIndex,x);
     763           0 : }
     764             : 
     765           0 : void SAL_CALL ORowSet::updateBytes( sal_Int32 columnIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException, std::exception)
     766             : {
     767           0 :     updateValue(columnIndex,x);
     768           0 : }
     769             : 
     770           0 : void SAL_CALL ORowSet::updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw(SQLException, RuntimeException, std::exception)
     771             : {
     772           0 :     updateValue(columnIndex,x);
     773           0 : }
     774             : 
     775           0 : void SAL_CALL ORowSet::updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw(SQLException, RuntimeException, std::exception)
     776             : {
     777           0 :     updateValue(columnIndex,x);
     778           0 : }
     779             : 
     780           0 : void SAL_CALL ORowSet::updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw(SQLException, RuntimeException, std::exception)
     781             : {
     782           0 :     updateValue(columnIndex,x);
     783           0 : }
     784             : 
     785           0 : void SAL_CALL ORowSet::updateBinaryStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException, std::exception)
     786             : {
     787           0 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
     788           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
     789           0 :     checkUpdateConditions(columnIndex);
     790           0 :     checkUpdateIterator();
     791             : 
     792             :      {
     793           0 :         Sequence<sal_Int8> aSeq;
     794           0 :         if(x.is())
     795           0 :             x->readBytes(aSeq,length);
     796           0 :         updateValue(columnIndex,aSeq);
     797           0 :     }
     798           0 : }
     799             : 
     800           0 : void SAL_CALL ORowSet::updateCharacterStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException, std::exception)
     801             : {
     802           0 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
     803           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
     804           0 :     checkUpdateConditions(columnIndex);
     805           0 :     checkUpdateIterator();
     806           0 :     ORowSetValueVector::Vector& rRow = ((*m_aCurrentRow)->get());
     807           0 :     ORowSetNotifier aNotify(this,rRow);
     808           0 :     m_pCache->updateCharacterStream(columnIndex,x,length,rRow,aNotify.getChangedColumns());
     809           0 :     m_bModified = m_bModified || !aNotify.getChangedColumns().empty();
     810           0 :     aNotify.firePropertyChange();
     811           0 : }
     812             : 
     813           0 : void SAL_CALL ORowSet::updateObject( sal_Int32 columnIndex, const Any& x ) throw(SQLException, RuntimeException, std::exception)
     814             : {
     815           0 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
     816           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
     817           0 :     checkUpdateConditions(columnIndex);
     818           0 :     checkUpdateIterator();
     819             : 
     820           0 :     Any aNewValue = x;
     821             : 
     822           0 :     if ( m_pColumns )
     823             :     {
     824           0 :         Reference<XPropertySet> xColumn(m_pColumns->getByIndex(columnIndex-1),UNO_QUERY);
     825           0 :         sal_Int32 nColType = 0;
     826           0 :         xColumn->getPropertyValue(PROPERTY_TYPE) >>= nColType;
     827           0 :         switch( nColType )
     828             :         {
     829             :             case DataType::DATE:
     830             :             case DataType::TIME:
     831             :             case DataType::TIMESTAMP:
     832             :             {
     833           0 :                 double nValue = 0;
     834           0 :                 if ( x >>= nValue )
     835             :                 {
     836           0 :                     if ( DataType::TIMESTAMP == nColType )
     837           0 :                         aNewValue <<= dbtools::DBTypeConversion::toDateTime( nValue );
     838           0 :                     else if ( DataType::DATE == nColType )
     839           0 :                         aNewValue <<= dbtools::DBTypeConversion::toDate( nValue );
     840             :                     else
     841           0 :                         aNewValue <<= dbtools::DBTypeConversion::toTime( nValue );
     842             :                 }
     843           0 :                 break;
     844             :             }
     845           0 :         }
     846             :     }
     847             : 
     848           0 :     if (!::dbtools::implUpdateObject(this, columnIndex, aNewValue))
     849             :     {   // there is no other updateXXX call which can handle the value in x
     850           0 :         ORowSetValueVector::Vector& rRow = ((*m_aCurrentRow)->get());
     851           0 :         ORowSetNotifier aNotify(this,rRow);
     852           0 :         m_pCache->updateObject(columnIndex,aNewValue,rRow,aNotify.getChangedColumns());
     853           0 :         m_bModified = m_bModified || !aNotify.getChangedColumns().empty();
     854           0 :         aNotify.firePropertyChange();
     855           0 :     }
     856           0 : }
     857             : 
     858           0 : void SAL_CALL ORowSet::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal_Int32 scale ) throw(SQLException, RuntimeException, std::exception)
     859             : {
     860           0 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
     861           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
     862           0 :     checkUpdateConditions(columnIndex);
     863           0 :     checkUpdateIterator();
     864           0 :     ORowSetValueVector::Vector& rRow = ((*m_aCurrentRow)->get());
     865           0 :     ORowSetNotifier aNotify(this,rRow);
     866           0 :     m_pCache->updateNumericObject(columnIndex,x,scale,rRow,aNotify.getChangedColumns());
     867           0 :     m_bModified = m_bModified || !aNotify.getChangedColumns().empty();
     868           0 :     aNotify.firePropertyChange();
     869           0 : }
     870             : 
     871             : // XResultSetUpdate
     872           0 : void SAL_CALL ORowSet::insertRow(  ) throw(SQLException, RuntimeException, std::exception)
     873             : {
     874           0 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
     875             :     // insertRow is not allowd when
     876             :     // standing not on the insert row nor
     877             :     // when the row isn't modified
     878             :     // or the concurency is read only
     879           0 :     ::osl::ResettableMutexGuard aGuard( *m_pMutex );
     880             : 
     881           0 :     if(!m_pCache || !m_bNew || !m_bModified || m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY)
     882           0 :         throwFunctionSequenceException(*this);
     883             : 
     884             :     // remember old value for fire
     885           0 :     sal_Bool bOld = m_bNew;
     886             : 
     887           0 :     ORowSetRow aOldValues;
     888           0 :     if ( !m_aCurrentRow.isNull() )
     889           0 :         aOldValues = new ORowSetValueVector( *(*m_aCurrentRow));
     890           0 :     Sequence<Any> aChangedBookmarks;
     891           0 :     RowsChangeEvent aEvt(*this,RowChangeAction::INSERT,1,aChangedBookmarks);
     892           0 :     notifyAllListenersRowBeforeChange(aGuard,aEvt);
     893             : 
     894           0 :     ::std::vector< Any > aBookmarks;
     895           0 :     sal_Bool bInserted = m_pCache->insertRow(aBookmarks);
     896             : 
     897             :     // make sure that our row is set to the new inserted row before clearing the insert flags in the cache
     898           0 :     m_pCache->resetInsertRow(bInserted);
     899             : 
     900             :     // notification order
     901             :     // - column values
     902           0 :     setCurrentRow( sal_False, sal_True, aOldValues, aGuard ); // we don't move here
     903             : 
     904             :     // read-only flag restored
     905           0 :     impl_restoreDataColumnsWriteable_throw();
     906             : 
     907             :     // - rowChanged
     908           0 :     notifyAllListenersRowChanged(aGuard,aEvt);
     909             : 
     910           0 :     if ( !aBookmarks.empty() )
     911             :     {
     912           0 :         RowsChangeEvent aUpEvt(*this,RowChangeAction::UPDATE,aBookmarks.size(),Sequence<Any>(&(*aBookmarks.begin()),aBookmarks.size()));
     913           0 :         notifyAllListenersRowChanged(aGuard,aUpEvt);
     914             :     }
     915             : 
     916             :     // - IsModified
     917           0 :     if(!m_bModified)
     918           0 :         fireProperty(PROPERTY_ID_ISMODIFIED,sal_False,sal_True);
     919             :     OSL_ENSURE( !m_bModified, "ORowSet::insertRow: just updated, but _still_ modified?" );
     920             : 
     921             :     // - IsNew
     922           0 :     if(m_bNew != bOld)
     923           0 :         fireProperty(PROPERTY_ID_ISNEW,m_bNew,bOld);
     924             : 
     925             :     // - RowCount/IsRowCountFinal
     926           0 :     fireRowcount();
     927           0 : }
     928             : 
     929           0 : sal_Int32 SAL_CALL ORowSet::getRow(  ) throw(SQLException, RuntimeException, std::exception)
     930             : {
     931           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
     932           0 :     checkCache();
     933             : 
     934             :     // check if we are inserting a row
     935           0 :     return (m_pCache && isInsertRow()) ? 0 : ORowSetBase::getRow();
     936             : }
     937             : 
     938           0 : void SAL_CALL ORowSet::updateRow(  ) throw(SQLException, RuntimeException, std::exception)
     939             : {
     940           0 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
     941             :     // not allowed when standing on insert row
     942           0 :     ::osl::ResettableMutexGuard aGuard( *m_pMutex );
     943           0 :     if ( !m_pCache || m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY || m_bNew || ((m_pCache->m_nPrivileges & Privilege::UPDATE ) != Privilege::UPDATE) )
     944           0 :         throwFunctionSequenceException(*this);
     945             : 
     946             : 
     947           0 :     if(m_bModified)
     948             :     {
     949           0 :         ORowSetRow aOldValues;
     950           0 :         if ( !m_aCurrentRow.isNull() )
     951           0 :             aOldValues = new ORowSetValueVector( *(*m_aCurrentRow) );
     952             : 
     953           0 :         Sequence<Any> aChangedBookmarks;
     954           0 :         RowsChangeEvent aEvt(*this,RowChangeAction::UPDATE,1,aChangedBookmarks);
     955           0 :         notifyAllListenersRowBeforeChange(aGuard,aEvt);
     956             : 
     957           0 :         ::std::vector< Any > aBookmarks;
     958           0 :         m_pCache->updateRow(m_aCurrentRow.operator ->(),aBookmarks);
     959           0 :         if ( !aBookmarks.empty() )
     960           0 :             aEvt.Bookmarks = Sequence<Any>(&(*aBookmarks.begin()),aBookmarks.size());
     961           0 :         aEvt.Rows += aBookmarks.size();
     962           0 :         m_aBookmark     = m_pCache->getBookmark();
     963           0 :         m_aCurrentRow   = m_pCache->m_aMatrixIter;
     964           0 :         m_bIsInsertRow  = sal_False;
     965           0 :         if ( m_pCache->m_aMatrixIter != m_pCache->getEnd() && (*m_pCache->m_aMatrixIter).is() )
     966             :         {
     967           0 :             if ( m_pCache->isResultSetChanged() )
     968             :             {
     969           0 :                 impl_rebuild_throw(aGuard);
     970             :             }
     971             :             else
     972             :             {
     973           0 :                 m_aOldRow->setRow(new ORowSetValueVector(*(*m_aCurrentRow)));
     974             : 
     975             :                 // notification order
     976             :                 // - column values
     977           0 :                 ORowSetBase::firePropertyChange(aOldValues);
     978             :             }
     979             :             // - rowChanged
     980           0 :             notifyAllListenersRowChanged(aGuard,aEvt);
     981             : 
     982             :             // - IsModified
     983           0 :             if(!m_bModified)
     984           0 :                 fireProperty(PROPERTY_ID_ISMODIFIED,sal_False,sal_True);
     985             :             OSL_ENSURE( !m_bModified, "ORowSet::updateRow: just updated, but _still_ modified?" );
     986             : 
     987             :             // - RowCount/IsRowCountFinal
     988           0 :             fireRowcount();
     989             :         }
     990           0 :         else if ( !m_bAfterLast ) // the update went rong
     991             :         {
     992           0 :             ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_UPDATE_FAILED ), SQL_INVALID_CURSOR_POSITION, *this );
     993           0 :         }
     994           0 :     }
     995           0 : }
     996             : 
     997           0 : void SAL_CALL ORowSet::deleteRow(  ) throw(SQLException, RuntimeException, std::exception)
     998             : {
     999           0 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
    1000             : 
    1001           0 :     ::osl::ResettableMutexGuard aGuard( *m_pMutex );
    1002           0 :     checkCache();
    1003             : 
    1004           0 :     if ( m_bBeforeFirst || m_bAfterLast )
    1005           0 :         ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_DELETE_BEFORE_AFTER ), SQL_INVALID_CURSOR_POSITION, *this );
    1006           0 :     if ( m_bNew )
    1007           0 :         ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_DELETE_INSERT_ROW ), SQL_INVALID_CURSOR_POSITION, *this );
    1008           0 :     if  ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY )
    1009           0 :         ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_RESULT_IS_READONLY ), SQL_FUNCTION_SEQUENCE_ERROR, *this );
    1010           0 :     if ( ( m_pCache->m_nPrivileges & Privilege::DELETE ) != Privilege::DELETE )
    1011           0 :         ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_DELETE_PRIVILEGE ), SQL_FUNCTION_SEQUENCE_ERROR, *this );
    1012           0 :     if ( rowDeleted() )
    1013           0 :         ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_ROW_ALREADY_DELETED ), SQL_FUNCTION_SEQUENCE_ERROR, *this );
    1014             : 
    1015             :     // this call position the cache indirect
    1016           0 :     Any aBookmarkToDelete( m_aBookmark );
    1017           0 :     positionCache( MOVE_NONE_REFRESH_ONLY );
    1018           0 :     sal_Int32 nDeletePosition = m_pCache->getRow();
    1019             : 
    1020           0 :     notifyRowSetAndClonesRowDelete( aBookmarkToDelete );
    1021             : 
    1022           0 :     ORowSetRow aOldValues;
    1023           0 :     if ( m_pCache->m_aMatrixIter != m_pCache->getEnd() && m_pCache->m_aMatrixIter->is() )
    1024           0 :         aOldValues = new ORowSetValueVector( *(*(m_pCache->m_aMatrixIter)) );
    1025             : 
    1026           0 :     Sequence<Any> aChangedBookmarks;
    1027           0 :     RowsChangeEvent aEvt(*this,RowChangeAction::DELETE,1,aChangedBookmarks);
    1028           0 :     notifyAllListenersRowBeforeChange(aGuard,aEvt);
    1029             : 
    1030           0 :     m_pCache->deleteRow();
    1031           0 :     notifyRowSetAndClonesRowDeleted( aBookmarkToDelete, nDeletePosition );
    1032             : 
    1033           0 :     ORowSetNotifier aNotifier( this );
    1034             :         // this will call cancelRowModification on the cache if necessary
    1035             : 
    1036             :     // notification order
    1037             :     // - rowChanged
    1038           0 :     notifyAllListenersRowChanged(aGuard,aEvt);
    1039             : 
    1040             :     // - IsModified
    1041             :     // - IsNew
    1042           0 :     aNotifier.fire( );
    1043             : 
    1044             :     // - RowCount/IsRowCountFinal
    1045           0 :     fireRowcount();
    1046           0 : }
    1047             : 
    1048           0 : void ORowSet::implCancelRowUpdates( sal_Bool _bNotifyModified ) SAL_THROW( ( SQLException, RuntimeException ) )
    1049             : {
    1050           0 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
    1051             : 
    1052           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
    1053           0 :     if ( m_bBeforeFirst || m_bAfterLast || rowDeleted() )
    1054           0 :         return; // nothing to do so return
    1055             : 
    1056           0 :     checkCache();
    1057             :     // cancelRowUpdates is not allowed when:
    1058             :     // - standing on the insert row
    1059             :     // - the concurrency is read only
    1060             :     // - the current row is deleted
    1061           0 :     if ( m_bNew || m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY )
    1062           0 :         throwFunctionSequenceException(*this);
    1063             : 
    1064           0 :     positionCache( MOVE_NONE_REFRESH_ONLY );
    1065             : 
    1066           0 :     ORowSetRow aOldValues;
    1067           0 :     if ( !m_bModified && _bNotifyModified && !m_aCurrentRow.isNull() )
    1068           0 :         aOldValues = new ORowSetValueVector( *(*m_aCurrentRow) );
    1069             : 
    1070           0 :     m_pCache->cancelRowUpdates();
    1071             : 
    1072           0 :     m_aBookmark     = m_pCache->getBookmark();
    1073           0 :     m_aCurrentRow   = m_pCache->m_aMatrixIter;
    1074           0 :     m_bIsInsertRow  = sal_False;
    1075           0 :     m_aCurrentRow.setBookmark(m_aBookmark);
    1076             : 
    1077             :     // notification order
    1078             :     // IsModified
    1079           0 :     if( !m_bModified && _bNotifyModified )
    1080             :     {
    1081             :         // - column values
    1082           0 :         ORowSetBase::firePropertyChange(aOldValues);
    1083           0 :         fireProperty(PROPERTY_ID_ISMODIFIED,sal_False,sal_True);
    1084           0 :     }
    1085             : }
    1086             : 
    1087           0 : void SAL_CALL ORowSet::cancelRowUpdates(  ) throw(SQLException, RuntimeException, std::exception)
    1088             : {
    1089           0 :     implCancelRowUpdates( sal_True );
    1090           0 : }
    1091             : 
    1092           0 : void SAL_CALL ORowSet::addRowSetListener( const Reference< XRowSetListener >& listener ) throw(RuntimeException, std::exception)
    1093             : {
    1094           0 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
    1095             : 
    1096           0 :     ::osl::MutexGuard aGuard( m_aColumnsMutex );
    1097           0 :     if(listener.is())
    1098           0 :         m_aRowsetListeners.addInterface(listener);
    1099           0 : }
    1100             : 
    1101           0 : void SAL_CALL ORowSet::removeRowSetListener( const Reference< XRowSetListener >& listener ) throw(RuntimeException, std::exception)
    1102             : {
    1103           0 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
    1104             : 
    1105           0 :     ::osl::MutexGuard aGuard( m_aColumnsMutex );
    1106           0 :     if(listener.is())
    1107           0 :         m_aRowsetListeners.removeInterface(listener);
    1108           0 : }
    1109             : 
    1110           0 : void ORowSet::notifyAllListeners(::osl::ResettableMutexGuard& _rGuard)
    1111             : {
    1112           0 :     EventObject aEvt(*m_pMySelf);
    1113           0 :     _rGuard.clear();
    1114           0 :     m_aRowsetListeners.notifyEach( &XRowSetListener::rowSetChanged, aEvt );
    1115           0 :     _rGuard.reset();
    1116           0 : }
    1117             : 
    1118           0 : void ORowSet::notifyAllListenersCursorMoved(::osl::ResettableMutexGuard& _rGuard)
    1119             : {
    1120           0 :     EventObject aEvt(*m_pMySelf);
    1121           0 :     _rGuard.clear();
    1122           0 :     m_aRowsetListeners.notifyEach( &XRowSetListener::cursorMoved, aEvt );
    1123           0 :     _rGuard.reset();
    1124           0 : }
    1125             : 
    1126           0 : void ORowSet::notifyAllListenersRowChanged(::osl::ResettableMutexGuard& _rGuard, const RowsChangeEvent& aEvt)
    1127             : {
    1128           0 :     _rGuard.clear();
    1129           0 :     m_aRowsetListeners.notifyEach( &XRowSetListener::rowChanged, (EventObject)aEvt );
    1130           0 :     m_aRowsChangeListener.notifyEach( &XRowsChangeListener::rowsChanged, aEvt );
    1131           0 :     _rGuard.reset();
    1132           0 : }
    1133             : 
    1134           0 : sal_Bool ORowSet::notifyAllListenersCursorBeforeMove(::osl::ResettableMutexGuard& _rGuard)
    1135             : {
    1136           0 :     EventObject aEvt(*m_pMySelf);
    1137           0 :     NOTIFY_LISTERNERS_CHECK(m_aApproveListeners,XRowSetApproveListener,approveCursorMove);
    1138           0 :     return bCheck;
    1139             : }
    1140             : 
    1141           0 : void ORowSet::notifyAllListenersRowBeforeChange(::osl::ResettableMutexGuard& _rGuard,const RowChangeEvent &aEvt)
    1142             : {
    1143           0 :     NOTIFY_LISTERNERS_CHECK(m_aApproveListeners,XRowSetApproveListener,approveRowChange);
    1144           0 :     if ( !bCheck )
    1145           0 :         m_aErrors.raiseTypedException( sdb::ErrorCondition::ROW_SET_OPERATION_VETOED, *this, ::cppu::UnoType< RowSetVetoException >::get() );
    1146           0 : }
    1147             : 
    1148           0 : void ORowSet::fireRowcount()
    1149             : {
    1150           0 :     sal_Int32 nCurrentRowCount( impl_getRowCount() );
    1151           0 :     sal_Bool bCurrentRowCountFinal( m_pCache->m_bRowCountFinal );
    1152             : 
    1153           0 :     if ( m_nLastKnownRowCount != nCurrentRowCount )
    1154             :     {
    1155           0 :         sal_Int32 nHandle = PROPERTY_ID_ROWCOUNT;
    1156           0 :         Any aNew,aOld;
    1157           0 :         aNew <<= nCurrentRowCount; aOld <<= m_nLastKnownRowCount;
    1158           0 :         fire(&nHandle,&aNew,&aOld,1,sal_False);
    1159           0 :         m_nLastKnownRowCount = nCurrentRowCount;
    1160             :     }
    1161           0 :     if ( !m_bLastKnownRowCountFinal && ( m_bLastKnownRowCountFinal != bCurrentRowCountFinal ) )
    1162             :     {
    1163           0 :         sal_Int32 nHandle = PROPERTY_ID_ISROWCOUNTFINAL;
    1164           0 :         Any aNew,aOld;
    1165           0 :         aNew <<= bCurrentRowCountFinal;
    1166           0 :         aOld <<= m_bLastKnownRowCountFinal;
    1167           0 :         fire(&nHandle,&aNew,&aOld,1,sal_False);
    1168           0 :         m_bLastKnownRowCountFinal = bCurrentRowCountFinal;
    1169             :     }
    1170           0 : }
    1171             : 
    1172           0 : void SAL_CALL ORowSet::moveToInsertRow(  ) throw(SQLException, RuntimeException, std::exception)
    1173             : {
    1174           0 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
    1175             : 
    1176           0 :     ::osl::ResettableMutexGuard aGuard( *m_pMutex );
    1177           0 :     checkPositioningAllowed();
    1178           0 :     if ( ( m_pCache->m_nPrivileges & Privilege::INSERT ) != Privilege::INSERT )
    1179           0 :         ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_INSERT_PRIVILEGE ), SQL_GENERAL_ERROR, *this );
    1180             : 
    1181           0 :     if ( notifyAllListenersCursorBeforeMove( aGuard ) )
    1182             :     {
    1183             :         // remember old value for fire
    1184           0 :         ORowSetRow aOldValues;
    1185           0 :         if ( rowDeleted() )
    1186             :         {
    1187           0 :             positionCache( MOVE_FORWARD );
    1188           0 :             m_pCache->next();
    1189           0 :             setCurrentRow( sal_True, sal_False, aOldValues, aGuard);
    1190             :         }
    1191             :         else
    1192           0 :             positionCache( MOVE_NONE_REFRESH_ONLY );
    1193             : 
    1194             :         // check before because the resultset could be empty
    1195           0 :         if  (   !m_bBeforeFirst
    1196           0 :             &&  !m_bAfterLast
    1197           0 :             &&  m_pCache->m_aMatrixIter != m_pCache->getEnd()
    1198           0 :             &&  m_pCache->m_aMatrixIter->is()
    1199             :             )
    1200           0 :             aOldValues = new ORowSetValueVector( *(*(m_pCache->m_aMatrixIter)) );
    1201             : 
    1202           0 :         const sal_Bool bNewState = m_bNew;
    1203           0 :         const sal_Bool bModState = m_bModified;
    1204             : 
    1205           0 :         m_pCache->moveToInsertRow();
    1206           0 :         m_aCurrentRow = m_pCache->m_aInsertRow;
    1207           0 :         m_bIsInsertRow  = sal_True;
    1208             : 
    1209             :         // set read-only flag to false
    1210           0 :         impl_setDataColumnsWriteable_throw();
    1211             : 
    1212             :         // notification order
    1213             :         // - column values
    1214           0 :         ORowSetBase::firePropertyChange(aOldValues);
    1215             : 
    1216             :         // - cursorMoved
    1217           0 :         notifyAllListenersCursorMoved(aGuard);
    1218             : 
    1219             :         // - IsModified
    1220           0 :         if ( bModState != m_bModified )
    1221           0 :             fireProperty( PROPERTY_ID_ISMODIFIED, m_bModified, bModState );
    1222             : 
    1223             :         // - IsNew
    1224           0 :         if ( bNewState != m_bNew )
    1225           0 :             fireProperty( PROPERTY_ID_ISNEW, m_bNew, bNewState );
    1226             : 
    1227             :         // - RowCount/IsRowCountFinal
    1228           0 :         fireRowcount();
    1229           0 :     }
    1230           0 : }
    1231             : 
    1232           0 : void ORowSet::impl_setDataColumnsWriteable_throw()
    1233             : {
    1234           0 :     impl_restoreDataColumnsWriteable_throw();
    1235           0 :     TDataColumns::iterator aIter = m_aDataColumns.begin();
    1236           0 :     m_aReadOnlyDataColumns.resize(m_aDataColumns.size(),false);
    1237           0 :     ::std::vector<bool, std::allocator<bool> >::iterator aReadIter = m_aReadOnlyDataColumns.begin();
    1238           0 :     for(;aIter != m_aDataColumns.end();++aIter,++aReadIter)
    1239             :     {
    1240           0 :         sal_Bool bReadOnly = sal_False;
    1241           0 :         (*aIter)->getPropertyValue(PROPERTY_ISREADONLY) >>= bReadOnly;
    1242           0 :         *aReadIter = bReadOnly;
    1243             : 
    1244           0 :         (*aIter)->setPropertyValue(PROPERTY_ISREADONLY,makeAny(sal_False));
    1245             :     }
    1246           0 : }
    1247             : 
    1248           0 : void ORowSet::impl_restoreDataColumnsWriteable_throw()
    1249             : {
    1250             :     assert(m_aDataColumns.size() == m_aReadOnlyDataColumns.size() || m_aReadOnlyDataColumns.size() == 0 );
    1251           0 :     TDataColumns::iterator aIter = m_aDataColumns.begin();
    1252           0 :     ::std::vector<bool, std::allocator<bool> >::iterator aReadIter = m_aReadOnlyDataColumns.begin();
    1253           0 :     for(;aReadIter != m_aReadOnlyDataColumns.end();++aIter,++aReadIter)
    1254             :     {
    1255           0 :         (*aIter)->setPropertyValue(PROPERTY_ISREADONLY,makeAny((sal_Bool)*aReadIter ));
    1256             :     }
    1257           0 :     m_aReadOnlyDataColumns.clear();
    1258           0 : }
    1259             : 
    1260           0 : void SAL_CALL ORowSet::moveToCurrentRow(  ) throw(SQLException, RuntimeException, std::exception)
    1261             : {
    1262           0 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
    1263             : 
    1264           0 :     ::osl::ResettableMutexGuard aGuard( *m_pMutex );
    1265           0 :     checkPositioningAllowed();
    1266             : 
    1267           0 :     if ( !m_pCache->m_bNew && !m_bModified )
    1268             :         // nothing to do if we're not on the insertion row, and not modified otherwise
    1269           0 :         return;
    1270             : 
    1271           0 :     if ( rowDeleted() )
    1272             :         // this would perhaps even justify a RuntimeException ....
    1273             :         // if the current row is deleted, then no write access to this row should be possible. So,
    1274             :         // m_bModified should be true. Also, as soon as somebody calls moveToInsertRow,
    1275             :         // our current row should not be deleted anymore. So, we should not have survived the above
    1276             :         // check "if ( !m_pCache->m_bNew && !m_bModified )"
    1277           0 :         ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_ROW_ALREADY_DELETED ), SQL_FUNCTION_SEQUENCE_ERROR, *this );
    1278             : 
    1279           0 :     if ( notifyAllListenersCursorBeforeMove( aGuard ) )
    1280             :     {
    1281           0 :         positionCache( MOVE_NONE_REFRESH_ONLY );
    1282             : 
    1283           0 :         ORowSetNotifier aNotifier( this );
    1284             : 
    1285             :         // notification order
    1286             :         // - cursorMoved
    1287           0 :         notifyAllListenersCursorMoved(aGuard);
    1288             : 
    1289             :         // - IsModified
    1290             :         // - IsNew
    1291           0 :         aNotifier.fire();
    1292           0 :     }
    1293             : }
    1294             : 
    1295             : // XRow
    1296           0 : sal_Bool SAL_CALL ORowSet::wasNull(  ) throw(SQLException, RuntimeException, std::exception)
    1297             : {
    1298           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
    1299           0 :     checkCache();
    1300             : 
    1301           0 :     return ( m_pCache && isInsertRow() ) ? ((*m_pCache->m_aInsertRow)->get())[m_nLastColumnIndex].isNull() : ORowSetBase::wasNull();
    1302             : }
    1303             : 
    1304           0 : const ORowSetValue& ORowSet::getInsertValue(sal_Int32 columnIndex)
    1305             : {
    1306           0 :     checkCache();
    1307             : 
    1308           0 :     if ( m_pCache && isInsertRow() )
    1309           0 :         return  ((*m_pCache->m_aInsertRow)->get())[m_nLastColumnIndex = columnIndex];
    1310             : 
    1311           0 :     return getValue(columnIndex);
    1312             : }
    1313             : 
    1314           0 : OUString SAL_CALL ORowSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
    1315             : {
    1316           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
    1317           0 :     return getInsertValue(columnIndex);
    1318             : }
    1319             : 
    1320           0 : sal_Bool SAL_CALL ORowSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
    1321             : {
    1322           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
    1323             :     // the extra cast is to recognise the "true" or "false" strings
    1324           0 :     return static_cast<bool>(getInsertValue(columnIndex));
    1325             : }
    1326             : 
    1327           0 : sal_Int8 SAL_CALL ORowSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
    1328             : {
    1329           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
    1330           0 :     return getInsertValue(columnIndex);
    1331             : }
    1332             : 
    1333           0 : sal_Int16 SAL_CALL ORowSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
    1334             : {
    1335           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
    1336           0 :     return getInsertValue(columnIndex);
    1337             : }
    1338             : 
    1339           0 : sal_Int32 SAL_CALL ORowSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
    1340             : {
    1341           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
    1342           0 :     return getInsertValue(columnIndex);
    1343             : }
    1344             : 
    1345           0 : sal_Int64 SAL_CALL ORowSet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
    1346             : {
    1347           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
    1348           0 :     return getInsertValue(columnIndex);
    1349             : }
    1350             : 
    1351           0 : float SAL_CALL ORowSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
    1352             : {
    1353           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
    1354           0 :     return getInsertValue(columnIndex);
    1355             : }
    1356             : 
    1357           0 : double SAL_CALL ORowSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
    1358             : {
    1359           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
    1360           0 :     return getInsertValue(columnIndex);
    1361             : }
    1362             : 
    1363           0 : Sequence< sal_Int8 > SAL_CALL ORowSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
    1364             : {
    1365           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
    1366           0 :     return getInsertValue(columnIndex);
    1367             : }
    1368             : 
    1369           0 : ::com::sun::star::util::Date SAL_CALL ORowSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
    1370             : {
    1371           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
    1372           0 :     return getInsertValue(columnIndex);
    1373             : }
    1374             : 
    1375           0 : ::com::sun::star::util::Time SAL_CALL ORowSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
    1376             : {
    1377           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
    1378           0 :     return getInsertValue(columnIndex);
    1379             : }
    1380             : 
    1381           0 : ::com::sun::star::util::DateTime SAL_CALL ORowSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
    1382             : {
    1383           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
    1384           0 :     return getInsertValue(columnIndex);
    1385             : }
    1386             : 
    1387           0 : Reference< ::com::sun::star::io::XInputStream > SAL_CALL ORowSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
    1388             : {
    1389           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
    1390           0 :     if ( m_pCache && isInsertRow() )
    1391             :     {
    1392           0 :         checkCache();
    1393           0 :         return new ::comphelper::SequenceInputStream(((*m_pCache->m_aInsertRow)->get())[m_nLastColumnIndex = columnIndex].getSequence());
    1394             :     }
    1395             : 
    1396           0 :     return ORowSetBase::getBinaryStream(columnIndex);
    1397             : }
    1398             : 
    1399           0 : Reference< ::com::sun::star::io::XInputStream > SAL_CALL ORowSet::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
    1400             : {
    1401           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
    1402           0 :     if(m_pCache && isInsertRow() )
    1403             :     {
    1404           0 :         checkCache();
    1405           0 :         return new ::comphelper::SequenceInputStream(((*m_pCache->m_aInsertRow)->get())[m_nLastColumnIndex = columnIndex].getSequence());
    1406             :     }
    1407             : 
    1408           0 :     return ORowSetBase::getCharacterStream(columnIndex);
    1409             : }
    1410             : 
    1411           0 : Any SAL_CALL ORowSet::getObject( sal_Int32 columnIndex, const Reference< XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException, std::exception)
    1412             : {
    1413           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
    1414           0 :     return getInsertValue(columnIndex).makeAny();
    1415             : }
    1416             : 
    1417           0 : Reference< XRef > SAL_CALL ORowSet::getRef( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
    1418             : {
    1419           0 :     return Reference< XRef >();
    1420             : }
    1421             : 
    1422           0 : Reference< XBlob > SAL_CALL ORowSet::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
    1423             : {
    1424           0 :     if ( m_pCache && isInsertRow() )
    1425             :     {
    1426           0 :         checkCache();
    1427           0 :         return new ::connectivity::BlobHelper(((*m_pCache->m_aInsertRow)->get())[m_nLastColumnIndex = columnIndex].getSequence());
    1428             :     }
    1429           0 :     return ORowSetBase::getBlob(columnIndex);
    1430             : }
    1431             : 
    1432           0 : Reference< XClob > SAL_CALL ORowSet::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
    1433             : {
    1434           0 :     return Reference< XClob >(getInsertValue(columnIndex).makeAny(),UNO_QUERY);
    1435             : }
    1436             : 
    1437           0 : Reference< XArray > SAL_CALL ORowSet::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
    1438             : {
    1439           0 :     return Reference< XArray >();
    1440             : }
    1441             : 
    1442           0 : void SAL_CALL ORowSet::executeWithCompletion( const Reference< XInteractionHandler >& _rxHandler ) throw(SQLException, RuntimeException, std::exception)
    1443             : {
    1444           0 :     if (!_rxHandler.is())
    1445           0 :         execute();
    1446             : 
    1447           0 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
    1448             : 
    1449             :     // tell everybody that we will change the result set
    1450           0 :     approveExecution();
    1451             : 
    1452           0 :     ResettableMutexGuard aGuard( m_aMutex );
    1453             : 
    1454             :     try
    1455             :     {
    1456           0 :         freeResources( m_bCommandFacetsDirty );
    1457             : 
    1458             :         // calc the connection to be used
    1459           0 :         if (m_xActiveConnection.is() && m_bRebuildConnOnExecute)
    1460             :         {
    1461             :             // there was a setProperty(ActiveConnection), but a setProperty(DataSource) _after_ that, too
    1462           0 :             Reference< XConnection > xXConnection;
    1463           0 :             setActiveConnection( xXConnection );
    1464             :         }
    1465           0 :         calcConnection( _rxHandler );
    1466           0 :         m_bRebuildConnOnExecute = sal_False;
    1467             : 
    1468           0 :         Reference< XSingleSelectQueryComposer > xComposer = getCurrentSettingsComposer( this, m_aContext );
    1469           0 :         Reference<XParametersSupplier>  xParameters(xComposer, UNO_QUERY);
    1470             : 
    1471           0 :         Reference<XIndexAccess>  xParamsAsIndicies = xParameters.is() ? xParameters->getParameters() : Reference<XIndexAccess>();
    1472           0 :         const sal_Int32 nParamCount = xParamsAsIndicies.is() ? xParamsAsIndicies->getCount() : 0;
    1473           0 :         if ( m_aParametersSet.size() < (size_t)nParamCount )
    1474           0 :             m_aParametersSet.resize( nParamCount ,false);
    1475             : 
    1476           0 :         ::dbtools::askForParameters( xComposer, this, m_xActiveConnection, _rxHandler,m_aParametersSet );
    1477             :     }
    1478             :     // ensure that only the allowed exceptions leave this block
    1479           0 :     catch(SQLException&)
    1480             :     {
    1481           0 :         throw;
    1482             :     }
    1483           0 :     catch(RuntimeException&)
    1484             :     {
    1485           0 :         throw;
    1486             :     }
    1487           0 :     catch(Exception&)
    1488             :     {
    1489             :         SAL_WARN("dbaccess", "ORowSet::executeWithCompletion: caught an unexpected exception type while filling in the parameters!");
    1490             :     }
    1491             : 
    1492             :     // we're done with the parameters, now for the real execution
    1493             : 
    1494             :     //  do the real execute
    1495           0 :     execute_NoApprove_NoNewConn(aGuard);
    1496           0 : }
    1497             : 
    1498           0 : Reference< XIndexAccess > SAL_CALL ORowSet::getParameters(  ) throw (RuntimeException, std::exception)
    1499             : {
    1500           0 :     ::osl::MutexGuard aGuard( *m_pMutex );
    1501           0 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
    1502             : 
    1503           0 :     if ( m_bCommandFacetsDirty )
    1504             :         // need to rebuild the parameters, since some property which contributes to the
    1505             :         // complete command, and thus the parameters, changed
    1506           0 :         impl_disposeParametersContainer_nothrow();
    1507             : 
    1508           0 :     if ( !m_pParameters.get() && !m_aCommand.isEmpty() )
    1509             :     {
    1510             :         try
    1511             :         {
    1512           0 :             OUString sNotInterestedIn;
    1513           0 :             impl_initComposer_throw( sNotInterestedIn );
    1514             :         }
    1515           0 :         catch( const Exception& )
    1516             :         {
    1517             :             // silence it
    1518             :         }
    1519             :     }
    1520             : 
    1521             :     // our caller could change our parameters at any time
    1522           0 :     m_bParametersDirty = true;
    1523             : 
    1524           0 :     return m_pParameters.get();
    1525             : }
    1526             : 
    1527           0 : void ORowSet::approveExecution() throw (RowSetVetoException, RuntimeException)
    1528             : {
    1529           0 :     ::osl::MutexGuard aGuard( m_aColumnsMutex );
    1530           0 :     EventObject aEvt(*this);
    1531             : 
    1532           0 :     OInterfaceIteratorHelper aApproveIter( m_aApproveListeners );
    1533           0 :     while ( aApproveIter.hasMoreElements() )
    1534             :     {
    1535           0 :         Reference< XRowSetApproveListener > xListener( static_cast< XRowSetApproveListener* >( aApproveIter.next() ) );
    1536             :         try
    1537             :         {
    1538           0 :             if ( xListener.is() && !xListener->approveRowSetChange( aEvt ) )
    1539           0 :                 throw RowSetVetoException();
    1540             :         }
    1541           0 :         catch ( const DisposedException& e )
    1542             :         {
    1543           0 :             if ( e.Context == xListener )
    1544           0 :                 aApproveIter.remove();
    1545             :         }
    1546           0 :         catch ( const RuntimeException& ) { throw; }
    1547           0 :         catch ( const RowSetVetoException& ) { throw; }
    1548           0 :         catch ( const Exception& )
    1549             :         {
    1550             :             DBG_UNHANDLED_EXCEPTION();
    1551             :         }
    1552           0 :     }
    1553           0 : }
    1554             : 
    1555             : // XRowSet
    1556           0 : void SAL_CALL ORowSet::execute(  ) throw(SQLException, RuntimeException, std::exception)
    1557             : {
    1558           0 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
    1559             : 
    1560             :     // tell everybody that we will change the result set
    1561           0 :     approveExecution();
    1562             : 
    1563           0 :     ResettableMutexGuard aGuard( m_aMutex );
    1564           0 :     freeResources( m_bCommandFacetsDirty );
    1565             : 
    1566             :     // calc the connection to be used
    1567           0 :     if (m_xActiveConnection.is() && m_bRebuildConnOnExecute) {
    1568             :         // there was a setProperty(ActiveConnection), but a setProperty(DataSource) _after_ that, too
    1569           0 :         Reference< XConnection> xXConnection;
    1570           0 :         setActiveConnection( xXConnection );
    1571             :     }
    1572             : 
    1573           0 :     calcConnection(NULL);
    1574           0 :     m_bRebuildConnOnExecute = sal_False;
    1575             : 
    1576             :     // do the real execute
    1577           0 :     execute_NoApprove_NoNewConn(aGuard);
    1578           0 : }
    1579             : 
    1580           0 : void ORowSet::setStatementResultSetType( const Reference< XPropertySet >& _rxStatement, sal_Int32 _nDesiredResultSetType, sal_Int32 _nDesiredResultSetConcurrency )
    1581             : {
    1582             :     OSL_ENSURE( _rxStatement.is(), "ORowSet::setStatementResultSetType: invalid statement - this will crash!" );
    1583             : 
    1584           0 :     sal_Int32 nResultSetType( _nDesiredResultSetType );
    1585           0 :     sal_Int32 nResultSetConcurrency( _nDesiredResultSetConcurrency );
    1586             : 
    1587             :     // there *might* be a data source setting which tells use to be more defensive with those settings
    1588             :     // #i15113#
    1589           0 :     sal_Bool bRespectDriverRST = sal_False;
    1590           0 :     Any aSetting;
    1591           0 :     if ( getDataSourceSetting( ::dbaccess::getDataSource( m_xActiveConnection ), "RespectDriverResultSetType", aSetting ) )
    1592             :     {
    1593           0 :         OSL_VERIFY( aSetting >>= bRespectDriverRST );
    1594             :     }
    1595             : 
    1596           0 :     if ( bRespectDriverRST )
    1597             :     {
    1598             :         // try type/concurrency settings with decreasing usefulness, and rely on what the connection claims
    1599             :         // to support
    1600           0 :         Reference< XDatabaseMetaData > xMeta( m_xActiveConnection->getMetaData() );
    1601             : 
    1602             :         sal_Int32 nCharacteristics[5][2] =
    1603             :         {   { ResultSetType::SCROLL_SENSITIVE, ResultSetConcurrency::UPDATABLE },
    1604             :             { ResultSetType::SCROLL_INSENSITIVE, ResultSetConcurrency::UPDATABLE },
    1605             :             { ResultSetType::SCROLL_SENSITIVE, ResultSetConcurrency::READ_ONLY },
    1606             :             { ResultSetType::SCROLL_INSENSITIVE, ResultSetConcurrency::READ_ONLY },
    1607             :             { ResultSetType::FORWARD_ONLY, ResultSetConcurrency::READ_ONLY }
    1608           0 :         };
    1609           0 :         sal_Int32 i=0;
    1610           0 :         if ( m_xActiveConnection->getMetaData()->isReadOnly() )
    1611           0 :             i = 2; // if the database is read-only we only should use read-only concurrency
    1612             : 
    1613           0 :         for ( ; i<5; ++i )
    1614             :         {
    1615           0 :             nResultSetType = nCharacteristics[i][0];
    1616           0 :             nResultSetConcurrency = nCharacteristics[i][1];
    1617             : 
    1618             :             // don't try type/concurrency pairs which are more featured than what our caller requested
    1619           0 :             if ( nResultSetType > _nDesiredResultSetType )
    1620           0 :                 continue;
    1621           0 :             if ( nResultSetConcurrency > _nDesiredResultSetConcurrency )
    1622           0 :                 continue;
    1623             : 
    1624           0 :             if ( xMeta.is() && xMeta->supportsResultSetConcurrency( nResultSetType, nResultSetConcurrency ) )
    1625           0 :                 break;
    1626           0 :         }
    1627             :     }
    1628             : 
    1629           0 :     _rxStatement->setPropertyValue( PROPERTY_RESULTSETTYPE, makeAny( nResultSetType ) );
    1630           0 :     _rxStatement->setPropertyValue( PROPERTY_RESULTSETCONCURRENCY, makeAny( nResultSetConcurrency ) );
    1631           0 : }
    1632             : 
    1633           0 : void ORowSet::impl_makeNewStatement_throw()
    1634             : {
    1635           0 :     OUString sCommandToExecute;
    1636           0 :     impl_initComposer_throw( sCommandToExecute );
    1637             : 
    1638             :     try
    1639             :     {
    1640           0 :         m_xStatement = m_xActiveConnection->prepareStatement( sCommandToExecute );
    1641           0 :         if ( !m_xStatement.is() )
    1642             :         {
    1643           0 :             ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_INTERNAL_ERROR ), SQL_GENERAL_ERROR, *this );
    1644             :         }
    1645             : 
    1646           0 :         Reference< XPropertySet > xStatementProps( m_xStatement, UNO_QUERY_THROW );
    1647             :         // set the result set type and concurrency
    1648             :         try
    1649             :         {
    1650           0 :             xStatementProps->setPropertyValue( PROPERTY_USEBOOKMARKS, makeAny( sal_True ) );
    1651           0 :             xStatementProps->setPropertyValue( PROPERTY_MAXROWS, makeAny( m_nMaxRows ) );
    1652             : 
    1653           0 :             setStatementResultSetType( xStatementProps, m_nResultSetType, m_nResultSetConcurrency );
    1654             :         }
    1655           0 :         catch ( const Exception& )
    1656             :         {
    1657             :             // this exception doesn't matter here because when we catch an exception
    1658             :             // then the driver doesn't support this feature
    1659           0 :         }
    1660             :     }
    1661           0 :     catch( const SQLException& )
    1662             :     {
    1663           0 :         SQLExceptionInfo aError( ::cppu::getCaughtException() );
    1664             :         OSL_ENSURE( aError.isValid(), "ORowSet::impl_makeNewStatement_throw: caught an SQLException which we cannot analyze!" );
    1665             : 
    1666             :         // append information about what we were actually going to execute
    1667             :         try
    1668             :         {
    1669           0 :             OUString sInfo(DBA_RES_PARAM( RID_STR_COMMAND_LEADING_TO_ERROR, "$command$", sCommandToExecute )  );
    1670           0 :             aError.append( SQLExceptionInfo::SQL_CONTEXT, sInfo );
    1671             :         }
    1672           0 :         catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); }
    1673             : 
    1674             :         // propagate
    1675           0 :         aError.doThrow();
    1676           0 :     }
    1677           0 : }
    1678             : 
    1679           0 : Reference< XResultSet > ORowSet::impl_prepareAndExecute_throw()
    1680             : {
    1681           0 :     if(m_bCommandFacetsDirty)
    1682           0 :         impl_makeNewStatement_throw();
    1683             : 
    1684           0 :     m_aParameterValueForCache.get().resize(1);
    1685           0 :     Reference< XParameters > xParam( m_xStatement, UNO_QUERY_THROW );
    1686           0 :     size_t nParamCount( m_pParameters.is() ? m_pParameters->size() : m_aPrematureParamValues.get().size() );
    1687           0 :     for ( size_t i=1; i<=nParamCount; ++i )
    1688             :     {
    1689           0 :         ORowSetValue& rParamValue( getParameterStorage( (sal_Int32)i ) );
    1690           0 :         ::dbtools::setObjectWithInfo( xParam, i, rParamValue.makeAny(), rParamValue.getTypeKind() );
    1691           0 :         m_aParameterValueForCache.get().push_back(rParamValue);
    1692             :     }
    1693           0 :     m_bParametersDirty = false;
    1694             : 
    1695           0 :     Reference< XResultSet > xResultSet(m_xStatement->executeQuery());
    1696             : 
    1697           0 :     OUString aComposedUpdateTableName;
    1698           0 :     if ( !m_aUpdateTableName.isEmpty() )
    1699           0 :         aComposedUpdateTableName = composeTableName( m_xActiveConnection->getMetaData(), m_aUpdateCatalogName, m_aUpdateSchemaName, m_aUpdateTableName, false, ::dbtools::eInDataManipulation );
    1700             : 
    1701             :     SAL_INFO("dbaccess", "ORowSet::execute_NoApprove_NoNewConn: creating cache" );
    1702           0 :     m_pCache = new ORowSetCache( xResultSet, m_xComposer.get(), m_aContext, aComposedUpdateTableName, m_bModified, m_bNew,m_aParameterValueForCache,m_aFilter,m_nMaxRows );
    1703           0 :     if ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY )
    1704             :     {
    1705           0 :         m_nPrivileges = Privilege::SELECT;
    1706           0 :         m_pCache->m_nPrivileges = Privilege::SELECT;
    1707             :     }
    1708           0 :     m_pCache->setFetchSize(m_nFetchSize);
    1709           0 :     m_aCurrentRow   = m_pCache->createIterator(this);
    1710           0 :     m_bIsInsertRow  = sal_False;
    1711           0 :     m_aOldRow       = m_pCache->registerOldRow();
    1712             : 
    1713           0 :     return xResultSet;
    1714             : }
    1715             : 
    1716           0 : void ORowSet::impl_initializeColumnSettings_nothrow( const Reference< XPropertySet >& _rxTemplateColumn, const Reference< XPropertySet >& _rxRowSetColumn )
    1717             : {
    1718             :     OSL_ENSURE( _rxTemplateColumn.is() && _rxRowSetColumn.is(),
    1719             :         "ORowSet::impl_initializeColumnSettings_nothrow: this will crash!" );
    1720             : 
    1721           0 :     bool bHaveAnyColumnSetting = false;
    1722             :     try
    1723             :     {
    1724           0 :         Reference< XPropertySetInfo > xInfo( _rxTemplateColumn->getPropertySetInfo(), UNO_QUERY_THROW );
    1725             : 
    1726             :         // a number of properties is plain copied
    1727             :         const OUString aPropertyNames[] = {
    1728             :             OUString(PROPERTY_ALIGN), OUString(PROPERTY_RELATIVEPOSITION), OUString(PROPERTY_WIDTH), OUString(PROPERTY_HIDDEN), OUString(PROPERTY_CONTROLMODEL),
    1729             :             OUString(PROPERTY_HELPTEXT), OUString(PROPERTY_CONTROLDEFAULT)
    1730           0 :         };
    1731           0 :         for ( size_t i=0; i<sizeof( aPropertyNames ) / sizeof( aPropertyNames[0] ); ++i )
    1732             :         {
    1733           0 :             if ( xInfo->hasPropertyByName( aPropertyNames[i] ) )
    1734             :             {
    1735           0 :                 _rxRowSetColumn->setPropertyValue( aPropertyNames[i], _rxTemplateColumn->getPropertyValue( aPropertyNames[i] ) );
    1736           0 :                 bHaveAnyColumnSetting = true;
    1737             :             }
    1738             :         }
    1739             : 
    1740             :         // the format key is slightly more complex
    1741           0 :         sal_Int32 nFormatKey = 0;
    1742           0 :         if( xInfo->hasPropertyByName( PROPERTY_NUMBERFORMAT ) )
    1743             :         {
    1744           0 :             _rxTemplateColumn->getPropertyValue( PROPERTY_NUMBERFORMAT ) >>= nFormatKey;
    1745           0 :             bHaveAnyColumnSetting = true;
    1746             :         }
    1747           0 :         if ( !nFormatKey && m_xNumberFormatTypes.is() )
    1748           0 :             nFormatKey = ::dbtools::getDefaultNumberFormat( _rxTemplateColumn, m_xNumberFormatTypes, SvtSysLocale().GetLanguageTag().getLocale() );
    1749           0 :         _rxRowSetColumn->setPropertyValue( PROPERTY_NUMBERFORMAT, makeAny( nFormatKey ) );
    1750             :     }
    1751           0 :     catch(Exception&)
    1752             :     {
    1753             :         DBG_UNHANDLED_EXCEPTION();
    1754           0 :         return;
    1755             :     }
    1756             : 
    1757           0 :     if ( bHaveAnyColumnSetting )
    1758           0 :         return;
    1759             : 
    1760             :     // the template column could not provide *any* setting. Okay, probably it's a parser column, which
    1761             :     // does not offer those. However, perhaps the template column referes to a table column, which we
    1762             :     // can use as new template column
    1763             :     try
    1764             :     {
    1765           0 :         Reference< XPropertySetInfo > xInfo( _rxTemplateColumn->getPropertySetInfo(), UNO_QUERY_THROW );
    1766           0 :         if ( !xInfo->hasPropertyByName( PROPERTY_TABLENAME ) )
    1767             :             // no chance
    1768           0 :             return;
    1769             : 
    1770           0 :         OUString sTableName;
    1771           0 :         OSL_VERIFY( _rxTemplateColumn->getPropertyValue( PROPERTY_TABLENAME ) >>= sTableName );
    1772             : 
    1773           0 :         Reference< XNameAccess > xTables( impl_getTables_throw(), UNO_QUERY_THROW );
    1774           0 :         if ( !xTables->hasByName( sTableName ) )
    1775             :             // no chance
    1776           0 :             return;
    1777             : 
    1778           0 :         Reference< XColumnsSupplier > xTableColSup( xTables->getByName( sTableName ), UNO_QUERY_THROW );
    1779           0 :         Reference< XNameAccess > xTableCols( xTableColSup->getColumns(), UNO_QUERY_THROW );
    1780             : 
    1781           0 :         OUString sTableColumnName;
    1782             : 
    1783             :         // get the "Name" or (preferred) "RealName" property of the column
    1784           0 :         OUString sNamePropertyName( PROPERTY_NAME );
    1785           0 :         if ( xInfo->hasPropertyByName( PROPERTY_REALNAME ) )
    1786           0 :             sNamePropertyName = PROPERTY_REALNAME;
    1787           0 :         OSL_VERIFY( _rxTemplateColumn->getPropertyValue( sNamePropertyName ) >>= sTableColumnName );
    1788             : 
    1789           0 :         if ( !xTableCols->hasByName( sTableColumnName ) )
    1790           0 :             return;
    1791             : 
    1792           0 :         Reference< XPropertySet > xTableColumn( xTableCols->getByName( sTableColumnName ), UNO_QUERY_THROW );
    1793           0 :         impl_initializeColumnSettings_nothrow( xTableColumn, _rxRowSetColumn );
    1794             :     }
    1795           0 :     catch( const Exception& )
    1796             :     {
    1797             :         DBG_UNHANDLED_EXCEPTION();
    1798             :     }
    1799             : }
    1800             : 
    1801           0 : void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotification)
    1802             : {
    1803             :     SAL_INFO("dbaccess", "ORowSet::execute_NoApprove_NoNewConn" );
    1804             : 
    1805             :     // now we can dispose our old connection
    1806           0 :     ::comphelper::disposeComponent(m_xOldConnection);
    1807           0 :     m_xOldConnection = NULL;
    1808             : 
    1809             :     // do we need a new statement
    1810           0 :     if ( m_bCommandFacetsDirty )
    1811             :     {
    1812           0 :         m_xStatement    = NULL;
    1813           0 :         m_xComposer     = NULL;
    1814             : 
    1815           0 :         Reference< XResultSet > xResultSet( impl_prepareAndExecute_throw() );
    1816             : 
    1817             :         // let our warnings container forget the reference to the (possibly disposed) old result set
    1818           0 :         m_aWarnings.setExternalWarnings( NULL );
    1819             :         // clear all current warnings
    1820           0 :         m_aWarnings.clearWarnings();
    1821             :         // let the warnings container know about the new "external warnings"
    1822           0 :         m_aWarnings.setExternalWarnings( Reference< XWarningsSupplier >( xResultSet, UNO_QUERY ) );
    1823             : 
    1824             :         // get the locale
    1825           0 :         Locale aLocale = SvtSysLocale().GetLanguageTag().getLocale();
    1826             : 
    1827             :         // get the numberformatTypes
    1828             :         OSL_ENSURE(m_xActiveConnection.is(),"No ActiveConnection");
    1829           0 :         Reference< XNumberFormatTypes> xNumberFormatTypes;
    1830           0 :         Reference< XNumberFormatsSupplier> xNumberFormat = ::dbtools::getNumberFormats(m_xActiveConnection);
    1831           0 :         if ( xNumberFormat.is() )
    1832           0 :             m_xNumberFormatTypes.set(xNumberFormat->getNumberFormats(),UNO_QUERY);
    1833             : 
    1834           0 :         ::rtl::Reference< ::connectivity::OSQLColumns> aColumns = new ::connectivity::OSQLColumns();
    1835           0 :         ::std::vector< OUString> aNames;
    1836           0 :         OUString aDescription;
    1837             : 
    1838           0 :         const ::std::map<sal_Int32,sal_Int32>& rKeyColumns = m_pCache->getKeyColumns();
    1839           0 :         if(!m_xColumns.is())
    1840             :         {
    1841             :             SAL_INFO("dbaccess", "ORowSet::execute_NoApprove_NoNewConn::creating columns" );
    1842             :             // use the meta data
    1843           0 :             Reference<XResultSetMetaDataSupplier> xMetaSup(m_xStatement,UNO_QUERY);
    1844             :             try
    1845             :             {
    1846           0 :                 Reference<XResultSetMetaData> xMetaData = xMetaSup->getMetaData();
    1847           0 :                 if ( xMetaData.is() )
    1848             :                 {
    1849           0 :                     sal_Int32 nCount = xMetaData->getColumnCount();
    1850           0 :                     m_aDataColumns.reserve(nCount+1);
    1851           0 :                     aColumns->get().reserve(nCount+1);
    1852           0 :                     std::map< OUString, int > aColumnMap;
    1853           0 :                     for (sal_Int32 i = 0 ; i < nCount; ++i)
    1854             :                     {
    1855             :                         // retrieve the name of the column
    1856           0 :                         OUString sName = xMetaData->getColumnName(i + 1);
    1857             :                         // check for duplicate entries
    1858           0 :                         if(aColumnMap.find(sName) != aColumnMap.end())
    1859             :                         {
    1860           0 :                             OUString sAlias(sName);
    1861           0 :                             sal_Int32 searchIndex=1;
    1862           0 :                             while(aColumnMap.find(sAlias) != aColumnMap.end())
    1863             :                             {
    1864           0 :                                 (sAlias = sName) += OUString::number(searchIndex++);
    1865             :                             }
    1866           0 :                             sName = sAlias;
    1867             :                         }
    1868           0 :                         ORowSetDataColumn* pColumn = new ORowSetDataColumn( getMetaData(),
    1869             :                                                                             this,
    1870             :                                                                             this,
    1871             :                                                                             i+1,
    1872           0 :                                                                             m_xActiveConnection->getMetaData(),
    1873             :                                                                             aDescription,
    1874             :                                                                             OUString(),
    1875           0 :                                                                             m_aCurrentRow);
    1876           0 :                         aColumnMap.insert(std::make_pair(sName,0));
    1877           0 :                         aColumns->get().push_back(pColumn);
    1878           0 :                         pColumn->setName(sName);
    1879           0 :                         aNames.push_back(sName);
    1880           0 :                         m_aDataColumns.push_back(pColumn);
    1881             : 
    1882           0 :                         pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ISREADONLY,makeAny(rKeyColumns.find(i+1) != rKeyColumns.end()));
    1883             : 
    1884             :                         try
    1885             :                         {
    1886           0 :                             sal_Int32 nFormatKey = 0;
    1887           0 :                             if(m_xNumberFormatTypes.is())
    1888           0 :                                 nFormatKey = ::dbtools::getDefaultNumberFormat(pColumn,m_xNumberFormatTypes,aLocale);
    1889             : 
    1890             : 
    1891           0 :                             pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_NUMBERFORMAT,makeAny(nFormatKey));
    1892           0 :                             pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_RELATIVEPOSITION,makeAny(sal_Int32(i+1)));
    1893           0 :                             pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_WIDTH,makeAny(sal_Int32(227)));
    1894           0 :                             pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ALIGN,makeAny((sal_Int32)0));
    1895           0 :                             pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_HIDDEN, css::uno::Any(false));
    1896             :                         }
    1897           0 :                         catch(Exception&)
    1898             :                         {
    1899             :                         }
    1900           0 :                     }
    1901           0 :                 }
    1902             :             }
    1903           0 :             catch (SQLException&)
    1904             :             {
    1905           0 :             }
    1906             :         }
    1907             :         else
    1908             :         {
    1909             :             // create the rowset columns
    1910           0 :             Reference< XResultSetMetaData > xMeta( getMetaData(), UNO_QUERY_THROW );
    1911           0 :             sal_Int32 nCount = xMeta->getColumnCount();
    1912           0 :             m_aDataColumns.reserve(nCount+1);
    1913           0 :             aColumns->get().reserve(nCount+1);
    1914           0 :             ::std::set< Reference< XPropertySet > > aAllColumns;
    1915             : 
    1916           0 :             for(sal_Int32 i=1; i <= nCount ;++i)
    1917             :             {
    1918           0 :                 OUString sName = xMeta->getColumnName(i);
    1919           0 :                 OUString sColumnLabel = xMeta->getColumnLabel(i);
    1920             : 
    1921             :                 // retrieve the column number |i|
    1922           0 :                 Reference<XPropertySet> xColumn;
    1923             :                 {
    1924           0 :                     sal_Bool bReFetchName = sal_False;
    1925           0 :                     if (m_xColumns->hasByName(sColumnLabel))
    1926           0 :                         m_xColumns->getByName(sColumnLabel) >>= xColumn;
    1927           0 :                     if (!xColumn.is() && m_xColumns->hasByName(sName))
    1928           0 :                         m_xColumns->getByName(sName) >>= xColumn;
    1929             : 
    1930             :                     // check if column already in the list we need another
    1931           0 :                     if ( aAllColumns.find( xColumn ) != aAllColumns.end() )
    1932             :                     {
    1933           0 :                         xColumn = NULL;
    1934           0 :                         bReFetchName = sal_True;
    1935           0 :                         sColumnLabel = "";
    1936             :                     }
    1937           0 :                     if(!xColumn.is())
    1938             :                     {
    1939             :                         // no column found so we could look at the position i
    1940           0 :                         Reference<XIndexAccess> xIndexAccess(m_xColumns,UNO_QUERY);
    1941           0 :                         if(xIndexAccess.is() && i <= xIndexAccess->getCount())
    1942             :                         {
    1943           0 :                             xIndexAccess->getByIndex(i-1) >>= xColumn;
    1944             :                         }
    1945             :                         else
    1946             :                         {
    1947           0 :                             Sequence< OUString> aSeq = m_xColumns->getElementNames();
    1948           0 :                             if( i <= aSeq.getLength())
    1949             :                             {
    1950           0 :                                 m_xColumns->getByName(aSeq.getConstArray()[i-1]) >>= xColumn;
    1951           0 :                             }
    1952           0 :                         }
    1953             :                     }
    1954           0 :                     if(bReFetchName && xColumn.is())
    1955           0 :                         xColumn->getPropertyValue(PROPERTY_NAME) >>= sName;
    1956           0 :                     aAllColumns.insert( xColumn );
    1957             :                 }
    1958             : 
    1959             :                 // create a RowSetDataColumn
    1960             :                 {
    1961           0 :                     Reference<XPropertySetInfo> xInfo = xColumn.is() ? xColumn->getPropertySetInfo() : Reference<XPropertySetInfo>();
    1962           0 :                     if(xInfo.is() && xInfo->hasPropertyByName(PROPERTY_DESCRIPTION))
    1963           0 :                         aDescription = comphelper::getString(xColumn->getPropertyValue(PROPERTY_DESCRIPTION));
    1964             : 
    1965           0 :                     OUString sParseLabel;
    1966           0 :                     if ( xColumn.is() )
    1967             :                     {
    1968           0 :                         xColumn->getPropertyValue(PROPERTY_LABEL) >>= sParseLabel;
    1969             :                     }
    1970           0 :                     ORowSetDataColumn* pColumn = new ORowSetDataColumn( getMetaData(),
    1971             :                                                                         this,
    1972             :                                                                         this,
    1973             :                                                                         i,
    1974           0 :                                                                         m_xActiveConnection->getMetaData(),
    1975             :                                                                         aDescription,
    1976             :                                                                         sParseLabel,
    1977           0 :                                                                         m_aCurrentRow);
    1978           0 :                     aColumns->get().push_back(pColumn);
    1979             : 
    1980           0 :                     pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ISREADONLY,makeAny(rKeyColumns.find(i) != rKeyColumns.end()));
    1981             : 
    1982           0 :                     if(sColumnLabel.isEmpty())
    1983             :                     {
    1984           0 :                         if(xColumn.is())
    1985           0 :                             xColumn->getPropertyValue(PROPERTY_NAME) >>= sColumnLabel;
    1986             :                         else
    1987           0 :                             sColumnLabel = DBACORE_RESSTRING( RID_STR_EXPRESSION1 );
    1988             :                     }
    1989           0 :                     pColumn->setName(sColumnLabel);
    1990           0 :                     aNames.push_back(sColumnLabel);
    1991           0 :                     m_aDataColumns.push_back(pColumn);
    1992             : 
    1993           0 :                     if ( xColumn.is() )
    1994           0 :                         impl_initializeColumnSettings_nothrow( xColumn, pColumn );
    1995             :                 }
    1996           0 :             }
    1997             :         }
    1998             :         // now create the columns we need
    1999           0 :         if(m_pColumns)
    2000           0 :             m_pColumns->assign(aColumns,aNames);
    2001             :         else
    2002             :         {
    2003           0 :             Reference<XDatabaseMetaData> xMeta = m_xActiveConnection->getMetaData();
    2004           0 :             m_pColumns = new ORowSetDataColumns(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers(),
    2005           0 :                                                 aColumns,*this,m_aColumnsMutex,aNames);
    2006           0 :         }
    2007             :     }
    2008             :     else // !m_bCommandFacetsDirty
    2009             :     {
    2010           0 :         impl_rebuild_throw(_rClearForNotification);
    2011             :     }
    2012           0 :     checkCache();
    2013             :     // notify the rowset listeners
    2014           0 :     notifyAllListeners(_rClearForNotification);
    2015           0 : }
    2016             : 
    2017             : // XRowSetApproveBroadcaster
    2018           0 : void SAL_CALL ORowSet::addRowSetApproveListener( const Reference< XRowSetApproveListener >& listener ) throw(RuntimeException, std::exception)
    2019             : {
    2020           0 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
    2021             : 
    2022           0 :     ::osl::MutexGuard aGuard( m_aColumnsMutex );
    2023             : 
    2024           0 :     m_aApproveListeners.addInterface(listener);
    2025           0 : }
    2026             : 
    2027           0 : void SAL_CALL ORowSet::removeRowSetApproveListener( const Reference< XRowSetApproveListener >& listener ) throw(RuntimeException, std::exception)
    2028             : {
    2029           0 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
    2030             : 
    2031           0 :     ::osl::MutexGuard aGuard( m_aColumnsMutex );
    2032             : 
    2033           0 :     m_aApproveListeners.removeInterface(listener);
    2034           0 : }
    2035             : 
    2036             : // XRowsChangeBroadcaster
    2037           0 : void SAL_CALL ORowSet::addRowsChangeListener( const Reference< XRowsChangeListener >& listener ) throw(RuntimeException, std::exception)
    2038             : {
    2039           0 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
    2040             : 
    2041           0 :     ::osl::MutexGuard aGuard( m_aColumnsMutex );
    2042             : 
    2043           0 :     m_aRowsChangeListener.addInterface(listener);
    2044           0 : }
    2045             : 
    2046           0 : void SAL_CALL ORowSet::removeRowsChangeListener( const Reference< XRowsChangeListener >& listener ) throw(RuntimeException, std::exception)
    2047             : {
    2048           0 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
    2049             : 
    2050           0 :     ::osl::MutexGuard aGuard( m_aColumnsMutex );
    2051             : 
    2052           0 :     m_aRowsChangeListener.removeInterface(listener);
    2053           0 : }
    2054             : 
    2055             : // XResultSetAccess
    2056           0 : Reference< XResultSet > SAL_CALL ORowSet::createResultSet(  ) throw(SQLException, RuntimeException, std::exception)
    2057             : {
    2058           0 :     ::osl::MutexGuard aGuard( m_aColumnsMutex );
    2059             : 
    2060           0 :     if(m_xStatement.is())
    2061             :     {
    2062           0 :         ORowSetClone* pClone = new ORowSetClone( m_aContext, *this, m_pMutex );
    2063           0 :         Reference< XResultSet > xRet(pClone);
    2064           0 :         m_aClones.push_back(WeakReferenceHelper(xRet));
    2065           0 :         return xRet;
    2066             :     }
    2067           0 :     return Reference< XResultSet >();
    2068             : }
    2069             : 
    2070             : // ::com::sun::star::util::XCancellable
    2071           0 : void SAL_CALL ORowSet::cancel(  ) throw(RuntimeException, std::exception)
    2072             : {
    2073           0 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
    2074           0 : }
    2075             : 
    2076             : // ::com::sun::star::sdbcx::XDeleteRows
    2077           0 : Sequence< sal_Int32 > SAL_CALL ORowSet::deleteRows( const Sequence< Any >& rows ) throw(SQLException, RuntimeException, std::exception)
    2078             : {
    2079           0 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
    2080             : 
    2081           0 :     if(!m_pCache || m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY)
    2082           0 :         throwFunctionSequenceException(*this);
    2083             : 
    2084           0 :     ::osl::ResettableMutexGuard aGuard( *m_pMutex );
    2085             : 
    2086           0 :     Sequence<Any> aChangedBookmarks;
    2087           0 :     RowsChangeEvent aEvt(*this,RowChangeAction::DELETE,rows.getLength(),aChangedBookmarks);
    2088             :     // notify the rowset listeners
    2089           0 :     notifyAllListenersRowBeforeChange(aGuard,aEvt);
    2090             : 
    2091           0 :     Sequence< sal_Int32 > aResults( rows.getLength() );
    2092           0 :     const Any* row = rows.getConstArray();
    2093           0 :     const Any* rowEnd = rows.getConstArray() + rows.getLength();
    2094           0 :     sal_Int32* result = aResults.getArray();
    2095           0 :     for ( ; row != rowEnd; ++row, ++result )
    2096             :     {
    2097           0 :         *result = 0;
    2098           0 :         if ( !m_pCache->moveToBookmark( *row ) )
    2099           0 :             continue;
    2100           0 :         sal_Int32 nDeletePosition = m_pCache->getRow();
    2101             : 
    2102             :         // first notify the clones so that they can save their position
    2103           0 :         notifyRowSetAndClonesRowDelete( *row );
    2104             : 
    2105             :         // now delete the row
    2106           0 :         if ( !m_pCache->deleteRow() )
    2107           0 :             continue;
    2108           0 :         *result = 1;
    2109             :         // now notify that we have deleted
    2110           0 :         notifyRowSetAndClonesRowDeleted( *row, nDeletePosition );
    2111             :     }
    2112           0 :     aEvt.Rows = aResults.getLength();
    2113             : 
    2114             :     // we have to check if we stand on the insert row and if so we have to reset it
    2115           0 :     ORowSetNotifier aNotifier( this );
    2116             :         // this will call cancelRowModification on the cache if necessary
    2117             :     // notification order
    2118             :     // - rowChanged
    2119           0 :     notifyAllListenersRowChanged(aGuard,aEvt);
    2120             : 
    2121             :     // - IsModified
    2122             :     // - IsNew
    2123           0 :     aNotifier.fire();
    2124             : 
    2125             :     // - RowCount/IsRowCountFinal
    2126           0 :     fireRowcount();
    2127             : 
    2128           0 :     return aResults;
    2129             : }
    2130             : 
    2131           0 : void ORowSet::notifyRowSetAndClonesRowDelete( const Any& _rBookmark )
    2132             : {
    2133             :     // notify ourself
    2134           0 :     onDeleteRow( _rBookmark );
    2135             :     // notify the clones
    2136           0 :     connectivity::OWeakRefArray::iterator aEnd = m_aClones.end();
    2137           0 :     for (connectivity::OWeakRefArray::iterator i = m_aClones.begin(); aEnd != i; ++i)
    2138             :     {
    2139           0 :         Reference< XUnoTunnel > xTunnel(i->get(),UNO_QUERY);
    2140           0 :         if(xTunnel.is())
    2141             :         {
    2142           0 :             ORowSetClone* pClone = reinterpret_cast<ORowSetClone*>(xTunnel->getSomething(ORowSetClone::getUnoTunnelImplementationId()));
    2143           0 :             if(pClone)
    2144           0 :                 pClone->onDeleteRow( _rBookmark );
    2145             :         }
    2146           0 :     }
    2147           0 : }
    2148             : 
    2149           0 : void ORowSet::notifyRowSetAndClonesRowDeleted( const Any& _rBookmark, sal_Int32 _nPos )
    2150             : {
    2151             :     // notify ourself
    2152           0 :     onDeletedRow( _rBookmark, _nPos );
    2153             :     // notify the clones
    2154           0 :     connectivity::OWeakRefArray::iterator aEnd = m_aClones.end();
    2155           0 :     for (connectivity::OWeakRefArray::iterator i = m_aClones.begin(); aEnd != i; ++i)
    2156             :     {
    2157           0 :         Reference< XUnoTunnel > xTunnel(i->get(),UNO_QUERY);
    2158           0 :         if(xTunnel.is())
    2159             :         {
    2160           0 :             ORowSetClone* pClone = reinterpret_cast<ORowSetClone*>(xTunnel->getSomething(ORowSetClone::getUnoTunnelImplementationId()));
    2161           0 :             if(pClone)
    2162           0 :                 pClone->onDeletedRow( _rBookmark, _nPos );
    2163             :         }
    2164           0 :     }
    2165           0 : }
    2166             : 
    2167           0 : Reference< XConnection >  ORowSet::calcConnection(const Reference< XInteractionHandler >& _rxHandler) throw( SQLException, RuntimeException )
    2168             : {
    2169           0 :     MutexGuard aGuard(m_aMutex);
    2170           0 :     if (!m_xActiveConnection.is())
    2171             :     {
    2172           0 :         Reference< XConnection > xNewConn;
    2173           0 :         if ( !m_aDataSourceName.isEmpty() )
    2174             :         {
    2175           0 :             Reference< XDatabaseContext > xDatabaseContext( DatabaseContext::create(m_aContext) );
    2176             :             try
    2177             :             {
    2178           0 :                 Reference< XDataSource > xDataSource( xDatabaseContext->getByName( m_aDataSourceName ), UNO_QUERY_THROW );
    2179             : 
    2180             :                 // try connecting with the interaction handler
    2181           0 :                 Reference< XCompletedConnection > xComplConn( xDataSource, UNO_QUERY );
    2182           0 :                 if ( _rxHandler.is() && xComplConn.is() )
    2183             :                 {
    2184           0 :                     xNewConn = xComplConn->connectWithCompletion( _rxHandler );
    2185             :                 }
    2186             :                 else
    2187             :                 {
    2188           0 :                     xNewConn = xDataSource->getConnection( m_aUser, m_aPassword );
    2189           0 :                 }
    2190             :             }
    2191           0 :             catch ( const SQLException& )
    2192             :             {
    2193           0 :                 throw;
    2194             :             }
    2195           0 :             catch ( const Exception& )
    2196             :             {
    2197           0 :                 Any aError = ::cppu::getCaughtException();
    2198             :                 OUString sMessage = ResourceManager::loadString( RID_NO_SUCH_DATA_SOURCE,
    2199           0 :                     "$name$", m_aDataSourceName, "$error$", extractExceptionMessage( m_aContext, aError ) );
    2200           0 :                 ::dbtools::throwGenericSQLException( sMessage, *this );
    2201           0 :             }
    2202             :         }
    2203           0 :         setActiveConnection(xNewConn);
    2204           0 :         m_bOwnConnection = sal_True;
    2205             :     }
    2206           0 :     return m_xActiveConnection;
    2207             : }
    2208             : 
    2209           0 : Reference< XNameAccess > ORowSet::impl_getTables_throw()
    2210             : {
    2211           0 :     Reference< XNameAccess > xTables;
    2212             : 
    2213           0 :     Reference< XTablesSupplier >  xTablesAccess( m_xActiveConnection, UNO_QUERY );
    2214           0 :     if ( xTablesAccess.is() )
    2215             :     {
    2216           0 :         xTables.set( xTablesAccess->getTables(), UNO_QUERY_THROW );
    2217             :     }
    2218           0 :     else if ( m_pTables )
    2219             :     {
    2220           0 :         xTables = m_pTables;
    2221             :     }
    2222             :     else
    2223             :     {
    2224           0 :         if ( !m_xActiveConnection.is() )
    2225           0 :             throw SQLException(DBA_RES(RID_STR_CONNECTION_INVALID),*this,SQLSTATE_GENERAL,1000,Any() );
    2226             : 
    2227           0 :         sal_Bool bCase = sal_True;
    2228             :         try
    2229             :         {
    2230           0 :             Reference<XDatabaseMetaData> xMeta = m_xActiveConnection->getMetaData();
    2231           0 :             bCase = xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers();
    2232             :         }
    2233           0 :         catch(SQLException&)
    2234             :         {
    2235             :             DBG_UNHANDLED_EXCEPTION();
    2236             :         }
    2237             : 
    2238           0 :         m_pTables = new OTableContainer(*this,m_aMutex,m_xActiveConnection,bCase,NULL,NULL,NULL,m_nInAppend);
    2239           0 :         xTables = m_pTables;
    2240           0 :         Sequence< OUString> aTableFilter(1);
    2241           0 :         aTableFilter[0] = "%";
    2242           0 :         m_pTables->construct(aTableFilter,Sequence< OUString>());
    2243             :     }
    2244             : 
    2245           0 :     return xTables;
    2246             : }
    2247             : 
    2248           0 : void ORowSet::impl_resetTables_nothrow()
    2249             : {
    2250           0 :     if ( !m_pTables )
    2251           0 :         return;
    2252             : 
    2253             :     try
    2254             :     {
    2255           0 :         m_pTables->dispose();
    2256             :     }
    2257           0 :     catch( const Exception& )
    2258             :     {
    2259             :         DBG_UNHANDLED_EXCEPTION();
    2260             :     }
    2261             : 
    2262           0 :     DELETEZ( m_pTables );
    2263             : }
    2264             : 
    2265           0 : sal_Bool ORowSet::impl_initComposer_throw( OUString& _out_rCommandToExecute )
    2266             : {
    2267           0 :     sal_Bool bUseEscapeProcessing = impl_buildActiveCommand_throw( );
    2268           0 :     _out_rCommandToExecute = m_aActiveCommand;
    2269           0 :     if ( !bUseEscapeProcessing )
    2270           0 :         return bUseEscapeProcessing;
    2271             : 
    2272           0 :     if (m_bCommandFacetsDirty)
    2273           0 :         m_xComposer = NULL;
    2274             : 
    2275           0 :     Reference< XMultiServiceFactory > xFactory( m_xActiveConnection, UNO_QUERY );
    2276           0 :     if ( !m_xComposer.is() && xFactory.is() )
    2277             :     {
    2278             :         try
    2279             :         {
    2280           0 :             m_xComposer.set( xFactory->createInstance( SERVICE_NAME_SINGLESELECTQUERYCOMPOSER ), UNO_QUERY_THROW );
    2281             :         }
    2282           0 :         catch (const Exception& ) { m_xComposer = NULL; }
    2283             :     }
    2284           0 :     if ( !m_xComposer.is() )
    2285           0 :         m_xComposer = new OSingleSelectQueryComposer( impl_getTables_throw(), m_xActiveConnection, m_aContext );
    2286             : 
    2287           0 :     m_xComposer->setCommand( m_aCommand,m_nCommandType );
    2288           0 :     m_aActiveCommand = m_xComposer->getQuery();
    2289             : 
    2290           0 :     m_xComposer->setFilter( m_bApplyFilter ? m_aFilter : OUString() );
    2291           0 :     m_xComposer->setHavingClause( m_bApplyFilter ? m_aHavingClause : OUString() );
    2292             : 
    2293           0 :     if ( m_bIgnoreResult )
    2294             :     {   // append a "0=1" filter
    2295             :         // don't simply overwrite an existent filter, this would lead to problems if this existent
    2296             :         // filter contains parameters (since a keyset may add parameters itself)
    2297           0 :         m_xComposer->setElementaryQuery( m_xComposer->getQuery( ) );
    2298           0 :         m_xComposer->setFilter( OUString("0 = 1"  ) );
    2299             :     }
    2300             : 
    2301           0 :     m_xComposer->setOrder( m_aOrder );
    2302           0 :     m_xComposer->setGroup( m_aGroupBy );
    2303             : 
    2304           0 :     if ( !m_xColumns.is() )
    2305             :     {
    2306           0 :         Reference< XColumnsSupplier > xCols( m_xComposer, UNO_QUERY_THROW );
    2307           0 :         m_xColumns = xCols->getColumns();
    2308             :     }
    2309             : 
    2310           0 :     impl_initParametersContainer_nothrow();
    2311             : 
    2312           0 :     _out_rCommandToExecute = m_xComposer->getQueryWithSubstitution();
    2313             : 
    2314           0 :     m_bCommandFacetsDirty = sal_False;
    2315             : 
    2316           0 :     return bUseEscapeProcessing;
    2317             : }
    2318             : 
    2319           0 : sal_Bool ORowSet::impl_buildActiveCommand_throw()
    2320             : {
    2321             :     // create the sql command
    2322             :     // from a table name or get the command out of a query (not a view)
    2323             :     // the last use the command as it is
    2324           0 :     sal_Bool bDoEscapeProcessing = m_bUseEscapeProcessing;
    2325             : 
    2326           0 :     m_aActiveCommand = "";
    2327           0 :     OUString sCommand;
    2328             : 
    2329           0 :     if ( m_aCommand.isEmpty() )
    2330           0 :         return bDoEscapeProcessing;
    2331             : 
    2332           0 :     switch (m_nCommandType)
    2333             :     {
    2334             :         case CommandType::TABLE:
    2335             :         {
    2336           0 :             impl_resetTables_nothrow();
    2337           0 :             if ( bDoEscapeProcessing )
    2338             :             {
    2339           0 :                 Reference< XNameAccess > xTables( impl_getTables_throw() );
    2340           0 :                 if ( xTables->hasByName(m_aCommand) )
    2341             :                 {
    2342             :                 }
    2343             :                 else
    2344             :                 {
    2345           0 :                     OUString sMessage( DBACORE_RESSTRING( RID_STR_TABLE_DOES_NOT_EXIST ) );
    2346           0 :                     throwGenericSQLException(sMessage.replaceAll( "$table$", m_aCommand ),*this);
    2347           0 :                 }
    2348             :             }
    2349             :             else
    2350             :             {
    2351           0 :                 sCommand = "SELECT * FROM ";
    2352           0 :                 OUString sCatalog, sSchema, sTable;
    2353           0 :                 ::dbtools::qualifiedNameComponents( m_xActiveConnection->getMetaData(), m_aCommand, sCatalog, sSchema, sTable, ::dbtools::eInDataManipulation );
    2354           0 :                 sCommand += ::dbtools::composeTableNameForSelect( m_xActiveConnection, sCatalog, sSchema, sTable );
    2355             :             }
    2356             :         }
    2357           0 :         break;
    2358             : 
    2359             :         case CommandType::QUERY:
    2360             :         {
    2361           0 :             Reference< XQueriesSupplier >  xQueriesAccess(m_xActiveConnection, UNO_QUERY);
    2362           0 :             if (xQueriesAccess.is())
    2363             :             {
    2364           0 :                 Reference< ::com::sun::star::container::XNameAccess >  xQueries(xQueriesAccess->getQueries());
    2365           0 :                 if (xQueries->hasByName(m_aCommand))
    2366             :                 {
    2367           0 :                     Reference< XPropertySet > xQuery(xQueries->getByName(m_aCommand),UNO_QUERY);
    2368             :                     OSL_ENSURE(xQuery.is(),"ORowSet::impl_buildActiveCommand_throw: Query is NULL!");
    2369           0 :                     if ( xQuery.is() )
    2370             :                     {
    2371           0 :                         xQuery->getPropertyValue(PROPERTY_COMMAND) >>= sCommand;
    2372           0 :                         xQuery->getPropertyValue(PROPERTY_ESCAPE_PROCESSING) >>= bDoEscapeProcessing;
    2373           0 :                         if ( bDoEscapeProcessing != m_bUseEscapeProcessing )
    2374             :                         {
    2375           0 :                             sal_Bool bOldValue = m_bUseEscapeProcessing;
    2376           0 :                             m_bUseEscapeProcessing = bDoEscapeProcessing;
    2377           0 :                             fireProperty(PROPERTY_ID_ESCAPE_PROCESSING,bOldValue,bDoEscapeProcessing);
    2378             :                         }
    2379             : 
    2380           0 :                         OUString aCatalog,aSchema,aTable;
    2381           0 :                         xQuery->getPropertyValue(PROPERTY_UPDATE_CATALOGNAME)   >>= aCatalog;
    2382           0 :                         xQuery->getPropertyValue(PROPERTY_UPDATE_SCHEMANAME)    >>= aSchema;
    2383           0 :                         xQuery->getPropertyValue(PROPERTY_UPDATE_TABLENAME)     >>= aTable;
    2384           0 :                         if(!aTable.isEmpty())
    2385           0 :                             m_aUpdateTableName = composeTableName( m_xActiveConnection->getMetaData(), aCatalog, aSchema, aTable, false, ::dbtools::eInDataManipulation );
    2386           0 :                     }
    2387             :                 }
    2388             :                 else
    2389             :                 {
    2390           0 :                     OUString sMessage( DBACORE_RESSTRING( RID_STR_QUERY_DOES_NOT_EXIST ) );
    2391           0 :                     throwGenericSQLException(sMessage.replaceAll( "$table$", m_aCommand ),*this);
    2392           0 :                 }
    2393             :             }
    2394             :             else
    2395           0 :                 throw SQLException(DBA_RES(RID_STR_NO_XQUERIESSUPPLIER),*this,OUString(),0,Any());
    2396             :         }
    2397           0 :         break;
    2398             : 
    2399             :         default:
    2400           0 :             sCommand = m_aCommand;
    2401           0 :             break;
    2402             :     }
    2403             : 
    2404           0 :     m_aActiveCommand = sCommand;
    2405             : 
    2406           0 :     if ( m_aActiveCommand.isEmpty() && !bDoEscapeProcessing )
    2407           0 :         ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_SQL_COMMAND ), SQL_FUNCTION_SEQUENCE_ERROR, *this );
    2408             : 
    2409           0 :     return bDoEscapeProcessing;
    2410             : }
    2411             : 
    2412           0 : void ORowSet::impl_initParametersContainer_nothrow()
    2413             : {
    2414             :     OSL_PRECOND( !m_pParameters.is(), "ORowSet::impl_initParametersContainer_nothrow: already initialized the parameters!" );
    2415             : 
    2416           0 :     m_pParameters = new param::ParameterWrapperContainer( m_xComposer.get() );
    2417             :     // copy the premature parameters into the final ones
    2418           0 :     size_t nParamCount( ::std::min( m_pParameters->size(), m_aPrematureParamValues.get().size() ) );
    2419           0 :     for ( size_t i=0; i<nParamCount; ++i )
    2420             :     {
    2421           0 :         (*m_pParameters)[i] = m_aPrematureParamValues.get()[i];
    2422             :     }
    2423           0 : }
    2424             : 
    2425           0 : void ORowSet::impl_disposeParametersContainer_nothrow()
    2426             : {
    2427           0 :     if ( !m_pParameters.is() )
    2428           0 :         return;
    2429             : 
    2430             :     // copy the actual values to our "premature" ones, to preserve them for later use
    2431           0 :     size_t nParamCount( m_pParameters->size() );
    2432           0 :     m_aPrematureParamValues.get().resize( nParamCount );
    2433           0 :     for ( size_t i=0; i<nParamCount; ++i )
    2434             :     {
    2435           0 :         m_aPrematureParamValues.get()[i] = (*m_pParameters)[i];
    2436             :     }
    2437             : 
    2438           0 :     m_pParameters->dispose();
    2439           0 :     m_pParameters = NULL;
    2440             : }
    2441             : 
    2442           0 : ORowSetValue& ORowSet::getParameterStorage(sal_Int32 parameterIndex)
    2443             : {
    2444           0 :     ::connectivity::checkDisposed( ORowSet_BASE1::rBHelper.bDisposed );
    2445           0 :     if ( parameterIndex < 1 )
    2446           0 :         throwInvalidIndexException( *this );
    2447             : 
    2448           0 :     if ( m_aParametersSet.size() < (size_t)parameterIndex )
    2449           0 :         m_aParametersSet.resize( parameterIndex ,false);
    2450           0 :     m_aParametersSet[parameterIndex - 1] = true;
    2451             : 
    2452           0 :     if ( m_pParameters.is() )
    2453             :     {
    2454           0 :         if ( m_bCommandFacetsDirty )
    2455             :         // need to rebuild the parameters, since some property which contributes to the
    2456             :         // complete command, and thus the parameters, changed
    2457           0 :             impl_disposeParametersContainer_nothrow();
    2458           0 :         if ( m_pParameters.is() )
    2459             :         {
    2460           0 :             if ( (size_t)parameterIndex > m_pParameters->size() )
    2461           0 :                 throwInvalidIndexException( *this );
    2462           0 :             return (*m_pParameters)[ parameterIndex - 1 ];
    2463             :         }
    2464             :     }
    2465             : 
    2466           0 :     if ( m_aPrematureParamValues.get().size() < (size_t)parameterIndex )
    2467           0 :         m_aPrematureParamValues.get().resize( parameterIndex );
    2468           0 :     return m_aPrematureParamValues.get()[ parameterIndex - 1 ];
    2469             : }
    2470             : 
    2471             : // XParameters
    2472           0 : void SAL_CALL ORowSet::setNull( sal_Int32 parameterIndex, sal_Int32 /*sqlType*/ ) throw(SQLException, RuntimeException, std::exception)
    2473             : {
    2474           0 :     ::osl::MutexGuard aGuard( m_aColumnsMutex );
    2475             : 
    2476           0 :     getParameterStorage( parameterIndex ).setNull();
    2477           0 :     m_bParametersDirty = true;
    2478           0 : }
    2479             : 
    2480           0 : void SAL_CALL ORowSet::setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const OUString& /*typeName*/ ) throw(SQLException, RuntimeException, std::exception)
    2481             : {
    2482           0 :     setNull( parameterIndex, sqlType );
    2483           0 : }
    2484             : 
    2485           0 : void ORowSet::setParameter(sal_Int32 parameterIndex, const ORowSetValue& x)
    2486             : {
    2487           0 :     ::osl::MutexGuard aGuard( m_aColumnsMutex );
    2488             : 
    2489           0 :     getParameterStorage( parameterIndex ) = x;
    2490           0 :     m_bParametersDirty = true;
    2491           0 : }
    2492             : 
    2493           0 : void SAL_CALL ORowSet::setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(SQLException, RuntimeException, std::exception)
    2494             : {
    2495           0 :     setParameter(parameterIndex, static_cast<bool>(x));
    2496           0 : }
    2497             : 
    2498           0 : void SAL_CALL ORowSet::setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(SQLException, RuntimeException, std::exception)
    2499             : {
    2500           0 :     setParameter(parameterIndex,x);
    2501           0 : }
    2502             : 
    2503           0 : void SAL_CALL ORowSet::setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(SQLException, RuntimeException, std::exception)
    2504             : {
    2505           0 :     setParameter(parameterIndex,x);
    2506           0 : }
    2507             : 
    2508           0 : void SAL_CALL ORowSet::setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(SQLException, RuntimeException, std::exception)
    2509             : {
    2510           0 :     setParameter(parameterIndex,x);
    2511           0 : }
    2512             : 
    2513           0 : void SAL_CALL ORowSet::setLong( sal_Int32 parameterIndex, sal_Int64 x ) throw(SQLException, RuntimeException, std::exception)
    2514             : {
    2515           0 :     setParameter(parameterIndex,x);
    2516           0 : }
    2517             : 
    2518           0 : void SAL_CALL ORowSet::setFloat( sal_Int32 parameterIndex, float x ) throw(SQLException, RuntimeException, std::exception)
    2519             : {
    2520           0 :     setParameter(parameterIndex,x);
    2521           0 : }
    2522             : 
    2523           0 : void SAL_CALL ORowSet::setDouble( sal_Int32 parameterIndex, double x ) throw(SQLException, RuntimeException, std::exception)
    2524             : {
    2525           0 :     setParameter(parameterIndex,x);
    2526           0 : }
    2527             : 
    2528           0 : void SAL_CALL ORowSet::setString( sal_Int32 parameterIndex, const OUString& x ) throw(SQLException, RuntimeException, std::exception)
    2529             : {
    2530           0 :     setParameter(parameterIndex,x);
    2531           0 : }
    2532             : 
    2533           0 : void SAL_CALL ORowSet::setBytes( sal_Int32 parameterIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException, std::exception)
    2534             : {
    2535           0 :     setParameter(parameterIndex,x);
    2536           0 : }
    2537             : 
    2538           0 : void SAL_CALL ORowSet::setDate( sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x ) throw(SQLException, RuntimeException, std::exception)
    2539             : {
    2540           0 :     setParameter(parameterIndex,x);
    2541           0 : }
    2542             : 
    2543           0 : void SAL_CALL ORowSet::setTime( sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x ) throw(SQLException, RuntimeException, std::exception)
    2544             : {
    2545           0 :     setParameter(parameterIndex,x);
    2546           0 : }
    2547             : 
    2548           0 : void SAL_CALL ORowSet::setTimestamp( sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x ) throw(SQLException, RuntimeException, std::exception)
    2549             : {
    2550           0 :     setParameter(parameterIndex,x);
    2551           0 : }
    2552             : 
    2553           0 : void SAL_CALL ORowSet::setBinaryStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException, std::exception)
    2554             : {
    2555           0 :     ::osl::MutexGuard aGuard( m_aColumnsMutex );
    2556           0 :     ORowSetValue& rParamValue( getParameterStorage( parameterIndex ) );
    2557             : 
    2558             :     try
    2559             :     {
    2560           0 :         Sequence <sal_Int8> aData;
    2561           0 :         x->readBytes(aData, length);
    2562           0 :         rParamValue = aData;
    2563           0 :         m_bParametersDirty = true;
    2564           0 :         x->closeInput();
    2565             :     }
    2566           0 :     catch( Exception& )
    2567             :     {
    2568           0 :         throw SQLException();
    2569           0 :     }
    2570           0 : }
    2571             : 
    2572           0 : void SAL_CALL ORowSet::setCharacterStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException, std::exception)
    2573             : {
    2574           0 :     ::osl::MutexGuard aGuard( m_aColumnsMutex );
    2575           0 :     ORowSetValue& rParamValue( getParameterStorage( parameterIndex ) );
    2576             :     try
    2577             :     {
    2578           0 :         Sequence <sal_Int8> aData;
    2579           0 :         OUString aDataStr;
    2580             :         // the data is given as character data and the length defines the character length
    2581           0 :         sal_Int32 nSize = x->readBytes(aData, length * sizeof(sal_Unicode));
    2582           0 :         if (nSize / sizeof(sal_Unicode))
    2583           0 :             aDataStr = OUString((sal_Unicode*)aData.getConstArray(), nSize / sizeof(sal_Unicode));
    2584           0 :         m_bParametersDirty = true;
    2585           0 :         rParamValue = aDataStr;
    2586           0 :         rParamValue.setTypeKind( DataType::LONGVARCHAR );
    2587           0 :         x->closeInput();
    2588             :     }
    2589           0 :     catch( Exception& )
    2590             :     {
    2591           0 :         throw SQLException();
    2592           0 :     }
    2593           0 : }
    2594             : 
    2595           0 : void SAL_CALL ORowSet::setObject( sal_Int32 parameterIndex, const Any& x ) throw(SQLException, RuntimeException, std::exception)
    2596             : {
    2597           0 :     if ( ::dbtools::implSetObject( this, parameterIndex, x ) )
    2598             :     {
    2599           0 :         m_bParametersDirty = true;
    2600             :     }
    2601             :     else
    2602             :     {   // there is no other setXXX call which can handle the value in x
    2603           0 :         throw SQLException();
    2604             :     }
    2605           0 : }
    2606             : 
    2607           0 : void SAL_CALL ORowSet::setObjectWithInfo( sal_Int32 parameterIndex, const Any& x, sal_Int32 targetSqlType, sal_Int32 /*scale*/ ) throw(SQLException, RuntimeException, std::exception)
    2608             : {
    2609           0 :     ::osl::MutexGuard aGuard( m_aColumnsMutex );
    2610           0 :     ORowSetValue& rParamValue( getParameterStorage( parameterIndex ) );
    2611           0 :     setObject( parameterIndex, x );
    2612           0 :     rParamValue.setTypeKind( targetSqlType );
    2613           0 : }
    2614             : 
    2615           0 : void SAL_CALL ORowSet::setRef( sal_Int32 /*parameterIndex*/, const Reference< XRef >& /*x*/ ) throw(SQLException, RuntimeException, std::exception)
    2616             : {
    2617           0 :     ::dbtools::throwFeatureNotImplementedException( "XParameters::setRef", *this );
    2618           0 : }
    2619             : 
    2620           0 : void SAL_CALL ORowSet::setBlob( sal_Int32 /*parameterIndex*/, const Reference< XBlob >& /*x*/ ) throw(SQLException, RuntimeException, std::exception)
    2621             : {
    2622           0 :     ::dbtools::throwFeatureNotImplementedException( "XParameters::setBlob", *this );
    2623           0 : }
    2624             : 
    2625           0 : void SAL_CALL ORowSet::setClob( sal_Int32 /*parameterIndex*/, const Reference< XClob >& /*x*/ ) throw(SQLException, RuntimeException, std::exception)
    2626             : {
    2627           0 :     ::dbtools::throwFeatureNotImplementedException( "XParameters::setClob", *this );
    2628           0 : }
    2629             : 
    2630           0 : void SAL_CALL ORowSet::setArray( sal_Int32 /*parameterIndex*/, const Reference< XArray >& /*x*/ ) throw(SQLException, RuntimeException, std::exception)
    2631             : {
    2632           0 :     ::dbtools::throwFeatureNotImplementedException( "XParameters::setArray", *this );
    2633           0 : }
    2634             : 
    2635           0 : void SAL_CALL ORowSet::clearParameters(  ) throw(SQLException, RuntimeException, std::exception)
    2636             : {
    2637           0 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
    2638             : 
    2639           0 :     ::osl::MutexGuard aGuard( m_aColumnsMutex );
    2640             : 
    2641           0 :     size_t nParamCount( m_pParameters.is() ? m_pParameters->size() : m_aPrematureParamValues.get().size() );
    2642           0 :     for ( size_t i=1; i<=nParamCount; ++i )
    2643           0 :         getParameterStorage( (sal_Int32)i ).setNull();
    2644           0 :     m_aParametersSet.clear();
    2645           0 : }
    2646             : 
    2647           0 : Any SAL_CALL ORowSet::getWarnings(  ) throw (SQLException, RuntimeException, std::exception)
    2648             : {
    2649           0 :     return m_aWarnings.getWarnings();
    2650             : }
    2651             : 
    2652           0 : void SAL_CALL ORowSet::clearWarnings(  ) throw (SQLException, RuntimeException, std::exception)
    2653             : {
    2654           0 :     m_aWarnings.clearWarnings();
    2655           0 : }
    2656             : 
    2657           0 : void ORowSet::doCancelModification( )
    2658             : {
    2659           0 :     if ( isModification() )
    2660             :     {
    2661             :         // read-only flag restored
    2662           0 :         impl_restoreDataColumnsWriteable_throw();
    2663           0 :         m_pCache->cancelRowModification();
    2664             :     }
    2665           0 :     m_bModified = sal_False;
    2666           0 :     m_bIsInsertRow = sal_False;
    2667           0 : }
    2668             : 
    2669           0 : sal_Bool ORowSet::isModification( )
    2670             : {
    2671           0 :     return isNew();
    2672             : }
    2673             : 
    2674           0 : sal_Bool ORowSet::isModified( )
    2675             : {
    2676           0 :     return m_bModified;
    2677             : }
    2678             : 
    2679           0 : sal_Bool ORowSet::isNew( )
    2680             : {
    2681           0 :     return m_bNew;
    2682             : }
    2683             : 
    2684           0 : sal_Bool ORowSet::isPropertyChangeNotificationEnabled() const
    2685             : {
    2686           0 :     return m_bPropChangeNotifyEnabled;
    2687             : }
    2688             : 
    2689           0 : void ORowSet::checkUpdateIterator()
    2690             : {
    2691           0 :     if(!m_bIsInsertRow)
    2692             :     {
    2693           0 :         m_pCache->setUpdateIterator(m_aCurrentRow);
    2694           0 :         m_aCurrentRow = m_pCache->m_aInsertRow;
    2695           0 :         m_bIsInsertRow = sal_True;
    2696             :     }
    2697           0 : }
    2698             : 
    2699           0 : void ORowSet::checkUpdateConditions(sal_Int32 columnIndex)
    2700             : {
    2701           0 :     checkCache();
    2702           0 :     if ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY)
    2703           0 :         ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_RESULT_IS_READONLY ), SQL_GENERAL_ERROR, *this );
    2704             : 
    2705           0 :     if ( rowDeleted() )
    2706           0 :         ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_ROW_ALREADY_DELETED ), SQL_INVALID_CURSOR_POSITION, *this );
    2707             : 
    2708           0 :     if ( m_aCurrentRow.isNull() )
    2709           0 :         ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_INVALID_CURSOR_STATE ), SQL_INVALID_CURSOR_STATE, *this );
    2710             : 
    2711           0 :     if ( columnIndex <= 0 || sal_Int32((*m_aCurrentRow)->get().size()) <= columnIndex )
    2712           0 :         ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_INVALID_INDEX ), SQL_INVALID_DESCRIPTOR_INDEX, *this );
    2713           0 : }
    2714             : 
    2715           0 : void SAL_CALL ORowSet::refreshRow(  ) throw(SQLException, RuntimeException, std::exception)
    2716             : {
    2717             : 
    2718           0 :     ORowSetNotifier aNotifier( this );
    2719             :         // this will call cancelRowModification on the cache if necessary
    2720             : 
    2721             :     // notification order:
    2722           0 :     if ( m_bModified && m_pCache )
    2723           0 :         implCancelRowUpdates( sal_False ); // do _not_ notify the IsModify - will do this ourself below
    2724             : 
    2725             :     // - column values
    2726           0 :     ORowSetBase::refreshRow();
    2727             : 
    2728             :     // - IsModified
    2729             :     // - IsNew
    2730           0 :     aNotifier.fire( );
    2731           0 : }
    2732             : 
    2733           0 : void ORowSet::impl_rebuild_throw(::osl::ResettableMutexGuard& _rGuard)
    2734             : {
    2735           0 :     Reference< XResultSet > xResultSet;
    2736           0 :     if(m_bParametersDirty)
    2737             :     {
    2738           0 :         xResultSet = impl_prepareAndExecute_throw();
    2739             :     }
    2740             :     else
    2741             :     {
    2742           0 :         xResultSet = m_xStatement->executeQuery();
    2743           0 :         m_pCache->reset(xResultSet);
    2744             :     }
    2745           0 :     m_aWarnings.setExternalWarnings( Reference< XWarningsSupplier >( xResultSet, UNO_QUERY ) );
    2746           0 :     notifyAllListeners(_rGuard);
    2747           0 : }
    2748             : 
    2749             : // ***********************************************************
    2750             : //  ORowSetClone
    2751             : // ***********************************************************
    2752             : 
    2753           0 : ORowSetClone::ORowSetClone( const Reference<XComponentContext>& _rContext, ORowSet& rParent, ::osl::Mutex* _pMutex )
    2754             :              :OSubComponent(m_aMutex, rParent)
    2755             :              ,ORowSetBase( _rContext, OComponentHelper::rBHelper, _pMutex )
    2756             :              ,m_pParent(&rParent)
    2757             :              ,m_nFetchDirection(rParent.m_nFetchDirection)
    2758             :              ,m_nFetchSize(rParent.m_nFetchSize)
    2759           0 :              ,m_bIsBookmarkable(sal_True)
    2760             : {
    2761             : 
    2762           0 :     m_nResultSetType        = rParent.m_nResultSetType;
    2763           0 :     m_nResultSetConcurrency = ResultSetConcurrency::READ_ONLY;
    2764           0 :     m_pMySelf               = this;
    2765           0 :     m_bClone                = sal_True;
    2766           0 :     m_bBeforeFirst          = rParent.m_bBeforeFirst;
    2767           0 :     m_bAfterLast            = rParent.m_bAfterLast;
    2768           0 :     m_pCache                = rParent.m_pCache;
    2769           0 :     m_aBookmark             = rParent.m_aBookmark;
    2770           0 :     m_aCurrentRow           = m_pCache->createIterator(this);
    2771           0 :     m_xNumberFormatTypes    = rParent.m_xNumberFormatTypes;
    2772             : 
    2773           0 :     m_aOldRow = m_pCache->registerOldRow();
    2774             : 
    2775           0 :     ::rtl::Reference< ::connectivity::OSQLColumns> aColumns = new ::connectivity::OSQLColumns();
    2776           0 :     ::std::vector< OUString> aNames;
    2777             : 
    2778           0 :     OUString aDescription;
    2779           0 :     Locale aLocale = SvtSysLocale().GetLanguageTag().getLocale();
    2780             : 
    2781           0 :     if ( rParent.m_pColumns )
    2782             :     {
    2783           0 :         Sequence< OUString> aSeq = rParent.m_pColumns->getElementNames();
    2784           0 :         const OUString* pIter    = aSeq.getConstArray();
    2785           0 :         const OUString* pEnd     = pIter + aSeq.getLength();
    2786           0 :         aColumns->get().reserve(aSeq.getLength()+1);
    2787           0 :         for(sal_Int32 i=1;pIter != pEnd ;++pIter,++i)
    2788             :         {
    2789           0 :             Reference<XPropertySet> xColumn;
    2790           0 :             rParent.m_pColumns->getByName(*pIter) >>= xColumn;
    2791           0 :             if(xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_DESCRIPTION))
    2792           0 :                 aDescription = comphelper::getString(xColumn->getPropertyValue(PROPERTY_DESCRIPTION));
    2793             : 
    2794           0 :             OUString sParseLabel;
    2795           0 :             xColumn->getPropertyValue(PROPERTY_LABEL) >>= sParseLabel;
    2796           0 :             ORowSetColumn* pColumn = new ORowSetColumn( rParent.getMetaData(),
    2797             :                                                                 this,
    2798             :                                                                 i,
    2799           0 :                                                                 rParent.m_xActiveConnection->getMetaData(),
    2800             :                                                                 aDescription,
    2801             :                                                                 sParseLabel,
    2802           0 :                                                                 m_aCurrentRow);
    2803           0 :             aColumns->get().push_back(pColumn);
    2804           0 :             pColumn->setName(*pIter);
    2805           0 :             aNames.push_back(*pIter);
    2806           0 :             m_aDataColumns.push_back(pColumn);
    2807             : 
    2808           0 :             pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ALIGN,xColumn->getPropertyValue(PROPERTY_ALIGN));
    2809           0 :             sal_Int32 nFormatKey = 0;
    2810           0 :             xColumn->getPropertyValue(PROPERTY_NUMBERFORMAT) >>= nFormatKey;
    2811           0 :             if(!nFormatKey && xColumn.is() && m_xNumberFormatTypes.is())
    2812           0 :                 nFormatKey = ::dbtools::getDefaultNumberFormat(xColumn,m_xNumberFormatTypes,aLocale);
    2813           0 :             pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_NUMBERFORMAT,makeAny(nFormatKey));
    2814           0 :             pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_RELATIVEPOSITION,xColumn->getPropertyValue(PROPERTY_RELATIVEPOSITION));
    2815           0 :             pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_WIDTH,xColumn->getPropertyValue(PROPERTY_WIDTH));
    2816           0 :             pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_HIDDEN,xColumn->getPropertyValue(PROPERTY_HIDDEN));
    2817           0 :             pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_CONTROLMODEL,xColumn->getPropertyValue(PROPERTY_CONTROLMODEL));
    2818           0 :             pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_HELPTEXT,xColumn->getPropertyValue(PROPERTY_HELPTEXT));
    2819           0 :             pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_CONTROLDEFAULT,xColumn->getPropertyValue(PROPERTY_CONTROLDEFAULT));
    2820             : 
    2821           0 :         }
    2822             :     }
    2823           0 :     Reference<XDatabaseMetaData> xMeta = rParent.m_xActiveConnection->getMetaData();
    2824           0 :     m_pColumns = new ORowSetDataColumns(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers(),
    2825           0 :                                         aColumns,*this,m_aMutex,aNames);
    2826             : 
    2827           0 :     sal_Int32 nRT   = PropertyAttribute::READONLY   | PropertyAttribute::TRANSIENT;
    2828             : 
    2829             :     // sdb.RowSet Properties
    2830           0 :     registerMayBeVoidProperty(PROPERTY_ACTIVE_CONNECTION,PROPERTY_ID_ACTIVE_CONNECTION, PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY,   &rParent.m_aActiveConnection,   ::getCppuType(static_cast< Reference< XConnection >* >(0)));
    2831           0 :     registerProperty(PROPERTY_RESULTSETCONCURRENCY, PROPERTY_ID_RESULTSETCONCURRENCY,   PropertyAttribute::READONLY,    &m_nResultSetConcurrency,::getCppuType(static_cast< sal_Int32*>(0)));
    2832           0 :     registerProperty(PROPERTY_RESULTSETTYPE,        PROPERTY_ID_RESULTSETTYPE,          PropertyAttribute::READONLY,    &m_nResultSetType,      ::getCppuType(static_cast< sal_Int32*>(0)));
    2833           0 :     registerProperty(PROPERTY_FETCHDIRECTION,       PROPERTY_ID_FETCHDIRECTION,         PropertyAttribute::TRANSIENT,   &m_nFetchDirection,     ::getCppuType(static_cast< sal_Int32*>(0)));
    2834           0 :     registerProperty(PROPERTY_FETCHSIZE,            PROPERTY_ID_FETCHSIZE,              PropertyAttribute::TRANSIENT,   &m_nFetchSize,          ::getCppuType(static_cast< sal_Int32*>(0)));
    2835           0 :     registerProperty(PROPERTY_ISBOOKMARKABLE,       PROPERTY_ID_ISBOOKMARKABLE,         nRT,                            &m_bIsBookmarkable,      ::getBooleanCppuType());
    2836           0 : }
    2837             : 
    2838           0 : ORowSetClone::~ORowSetClone()
    2839             : {
    2840           0 : }
    2841             : 
    2842             : // com::sun::star::XTypeProvider
    2843           0 : Sequence< Type > ORowSetClone::getTypes() throw (RuntimeException, std::exception)
    2844             : {
    2845           0 :     return ::comphelper::concatSequences(OSubComponent::getTypes(),ORowSetBase::getTypes());
    2846             : }
    2847             : 
    2848             : // com::sun::star::XInterface
    2849           0 : Any ORowSetClone::queryInterface( const Type & rType ) throw (RuntimeException, std::exception)
    2850             : {
    2851           0 :     Any aRet = ORowSetBase::queryInterface(rType);
    2852           0 :     if(!aRet.hasValue())
    2853           0 :         aRet = OSubComponent::queryInterface(rType);
    2854           0 :     return aRet;
    2855             : }
    2856             : 
    2857           0 : void ORowSetClone::acquire() throw()
    2858             : {
    2859           0 :     OSubComponent::acquire();
    2860           0 : }
    2861             : 
    2862           0 : void ORowSetClone::release() throw()
    2863             : {
    2864           0 :     OSubComponent::release();
    2865           0 : }
    2866             : 
    2867             : // XServiceInfo
    2868           0 : OUString ORowSetClone::getImplementationName(  ) throw(RuntimeException, std::exception)
    2869             : {
    2870           0 :     return OUString("com.sun.star.sdb.ORowSetClone");
    2871             : }
    2872             : 
    2873           0 : sal_Bool ORowSetClone::supportsService( const OUString& _rServiceName ) throw (RuntimeException, std::exception)
    2874             : {
    2875           0 :     return cppu::supportsService(this, _rServiceName);
    2876             : }
    2877             : 
    2878           0 : Sequence< OUString > ORowSetClone::getSupportedServiceNames(  ) throw (RuntimeException, std::exception)
    2879             : {
    2880           0 :     Sequence< OUString > aSNS( 2 );
    2881           0 :     aSNS[0] = SERVICE_SDBC_RESULTSET;
    2882           0 :     aSNS[1] = SERVICE_SDB_RESULTSET;
    2883           0 :     return aSNS;
    2884             : }
    2885             : 
    2886             : // OComponentHelper
    2887           0 : void ORowSetClone::disposing()
    2888             : {
    2889           0 :     MutexGuard aGuard( m_aMutex );
    2890           0 :     ORowSetBase::disposing();
    2891             : 
    2892           0 :     m_pParent   = NULL;
    2893           0 :     m_pMutex    = &m_aMutex; // this must be done here because someone could hold a ref to us and try to do something
    2894           0 :     OSubComponent::disposing();
    2895           0 : }
    2896             : 
    2897             : // XCloseable
    2898           0 : void ORowSetClone::close(void) throw( SQLException, RuntimeException, std::exception )
    2899             : {
    2900             :     {
    2901           0 :         MutexGuard aGuard( m_aMutex );
    2902           0 :         if (OComponentHelper::rBHelper.bDisposed)
    2903           0 :             throw DisposedException();
    2904             :     }
    2905           0 :     dispose();
    2906           0 : }
    2907             : 
    2908             : // comphelper::OPropertyArrayUsageHelper
    2909           0 : ::cppu::IPropertyArrayHelper* ORowSetClone::createArrayHelper( ) const
    2910             : {
    2911           0 :     Sequence< Property > aProps;
    2912           0 :     describeProperties(aProps);
    2913           0 :     return new ::cppu::OPropertyArrayHelper(aProps);
    2914             : }
    2915             : 
    2916             : // cppu::OPropertySetHelper
    2917           0 : ::cppu::IPropertyArrayHelper& SAL_CALL ORowSetClone::getInfoHelper()
    2918             : {
    2919             :     typedef ::comphelper::OPropertyArrayUsageHelper<ORowSetClone> ORowSetClone_PROP;
    2920           0 :     return *ORowSetClone_PROP::getArrayHelper();
    2921             : }
    2922             : 
    2923           0 : Sequence< sal_Int8 > ORowSetClone::getUnoTunnelImplementationId()
    2924             : {
    2925             :     static ::cppu::OImplementationId * pId = 0;
    2926           0 :     if (! pId)
    2927             :     {
    2928           0 :         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
    2929           0 :         if (! pId)
    2930             :         {
    2931           0 :             static ::cppu::OImplementationId aId;
    2932           0 :             pId = &aId;
    2933           0 :         }
    2934             :     }
    2935           0 :     return pId->getImplementationId();
    2936             : }
    2937             : 
    2938             : // com::sun::star::XUnoTunnel
    2939           0 : sal_Int64 SAL_CALL ORowSetClone::getSomething( const Sequence< sal_Int8 >& rId ) throw(RuntimeException, std::exception)
    2940             : {
    2941           0 :     if (rId.getLength() == 16 && 0 == memcmp(getUnoTunnelImplementationId().getConstArray(),  rId.getConstArray(), 16 ) )
    2942           0 :         return reinterpret_cast<sal_Int64>(this);
    2943             : 
    2944           0 :     return 0;
    2945             : }
    2946             : 
    2947           0 : void SAL_CALL ORowSetClone::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) throw (Exception, std::exception)
    2948             : {
    2949           0 :     if ( nHandle == PROPERTY_ID_FETCHSIZE )
    2950             :     {
    2951           0 :         if ( m_pParent )
    2952           0 :             m_pParent->setFastPropertyValue_NoBroadcast( nHandle, rValue );
    2953             :     }
    2954             : 
    2955           0 :     OPropertyStateContainer::setFastPropertyValue_NoBroadcast(nHandle,rValue);
    2956           0 : }
    2957             : 
    2958           0 : void ORowSetClone::doCancelModification( )
    2959             : {
    2960           0 : }
    2961             : 
    2962           0 : sal_Bool ORowSetClone::isModification( )
    2963             : {
    2964           0 :     return sal_False;
    2965             : }
    2966             : 
    2967           0 : sal_Bool ORowSetClone::isModified( )
    2968             : {
    2969           0 :     return sal_False;
    2970             : }
    2971             : 
    2972           0 : sal_Bool ORowSetClone::isNew( )
    2973             : {
    2974           0 :     return sal_False;
    2975             : }
    2976             : 
    2977           0 : void SAL_CALL ORowSetClone::execute(  ) throw(SQLException, RuntimeException, std::exception)
    2978             : {
    2979           0 :     throwFunctionNotSupportedException( "RowSetClone::XRowSet::execute", *this );
    2980           0 : }
    2981             : 
    2982           0 : void SAL_CALL ORowSetClone::addRowSetListener( const Reference< XRowSetListener >& ) throw(RuntimeException, std::exception)
    2983             : {
    2984           0 :     throwFunctionNotSupportedException( "RowSetClone::XRowSet", *this );
    2985           0 : }
    2986             : 
    2987           0 : void SAL_CALL ORowSetClone::removeRowSetListener( const Reference< XRowSetListener >& ) throw(RuntimeException, std::exception)
    2988             : {
    2989           0 :     throwFunctionNotSupportedException( "RowSetClone::XRowSet", *this );
    2990           0 : }
    2991             : 
    2992             : } // dbaccess
    2993             : 
    2994             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10