LCOV - code coverage report
Current view: top level - dbaccess/source/core/api - RowSet.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 955 1570 60.8 %
Date: 2014-04-11 Functions: 97 170 57.1 %
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          21 : extern "C" void SAL_CALL createRegistryInfo_ORowSet()
      98             : {
      99          21 :     static ::dba::OAutoRegistration< ORowSet > aAutoRegistration;
     100          21 : }
     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         176 : 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         176 :     ,m_bPropChangeNotifyEnabled(sal_True)
     159             : {
     160         176 :     m_nResultSetType = ResultSetType::SCROLL_SENSITIVE;
     161         176 :     m_nResultSetConcurrency = ResultSetConcurrency::UPDATABLE;
     162         176 :     m_pMySelf = this;
     163         176 :     m_aActiveConnection <<= m_xActiveConnection;
     164             : 
     165         176 :     sal_Int32 nRBT  = PropertyAttribute::READONLY   | PropertyAttribute::BOUND      | PropertyAttribute::TRANSIENT;
     166         176 :     sal_Int32 nRT   = PropertyAttribute::READONLY   | PropertyAttribute::TRANSIENT;
     167         176 :     sal_Int32 nBT   = PropertyAttribute::BOUND      | PropertyAttribute::TRANSIENT;
     168             : 
     169         176 :     m_aPrematureParamValues.get().resize( 0 );
     170             : 
     171             :     // sdb.RowSet Properties
     172         176 :     registerMayBeVoidProperty(PROPERTY_ACTIVE_CONNECTION,PROPERTY_ID_ACTIVE_CONNECTION, PropertyAttribute::MAYBEVOID|PropertyAttribute::TRANSIENT|PropertyAttribute::BOUND, &m_aActiveConnection,   ::getCppuType(static_cast< Reference< XConnection >* >(0)));
     173         176 :     registerProperty(PROPERTY_DATASOURCENAME,       PROPERTY_ID_DATASOURCENAME,         PropertyAttribute::BOUND,       &m_aDataSourceName,     ::getCppuType(static_cast< OUString*>(0)));
     174         176 :     registerProperty(PROPERTY_COMMAND,              PROPERTY_ID_COMMAND,                PropertyAttribute::BOUND,       &m_aCommand,            ::getCppuType(static_cast< OUString*>(0)));
     175         176 :     registerProperty(PROPERTY_COMMAND_TYPE,         PROPERTY_ID_COMMAND_TYPE,           PropertyAttribute::BOUND,       &m_nCommandType,        ::getCppuType(static_cast< sal_Int32*>(0)));
     176         176 :     registerProperty(PROPERTY_ACTIVECOMMAND,        PROPERTY_ID_ACTIVECOMMAND,          nRBT,                           &m_aActiveCommand,      ::getCppuType(static_cast< OUString*>(0)));
     177         176 :     registerProperty(PROPERTY_IGNORERESULT,         PROPERTY_ID_IGNORERESULT,           PropertyAttribute::BOUND,       &m_bIgnoreResult,       ::getBooleanCppuType());
     178         176 :     registerProperty(PROPERTY_FILTER,               PROPERTY_ID_FILTER,                 PropertyAttribute::BOUND,       &m_aFilter,             ::getCppuType(static_cast< OUString*>(0)));
     179         176 :     registerProperty(PROPERTY_HAVING_CLAUSE,        PROPERTY_ID_HAVING_CLAUSE,          PropertyAttribute::BOUND,       &m_aHavingClause,       ::getCppuType(static_cast< OUString*>(0)));
     180         176 :     registerProperty(PROPERTY_GROUP_BY,             PROPERTY_ID_GROUP_BY,               PropertyAttribute::BOUND,       &m_aGroupBy,            ::getCppuType(static_cast< OUString*>(0)));
     181         176 :     registerProperty(PROPERTY_APPLYFILTER,          PROPERTY_ID_APPLYFILTER,            PropertyAttribute::BOUND,       &m_bApplyFilter,        ::getBooleanCppuType());
     182         176 :     registerProperty(PROPERTY_ORDER,                PROPERTY_ID_ORDER,                  PropertyAttribute::BOUND,       &m_aOrder,              ::getCppuType(static_cast< OUString*>(0)));
     183         176 :     registerProperty(PROPERTY_PRIVILEGES,           PROPERTY_ID_PRIVILEGES,             nRT,                            &m_nPrivileges,         ::getCppuType(static_cast< sal_Int32*>(0)));
     184         176 :     registerProperty(PROPERTY_ISMODIFIED,           PROPERTY_ID_ISMODIFIED,             nBT,                            &m_bModified,           ::getBooleanCppuType());
     185         176 :     registerProperty(PROPERTY_ISNEW,                PROPERTY_ID_ISNEW,                  nRBT,                           &m_bNew,                ::getBooleanCppuType());
     186         176 :     registerProperty(PROPERTY_SINGLESELECTQUERYCOMPOSER,PROPERTY_ID_SINGLESELECTQUERYCOMPOSER,  nRT,                    &m_xComposer,   ::getCppuType(static_cast< Reference< XSingleSelectQueryComposer >* >(0)));
     187             : 
     188             :     // sdbcx.ResultSet Properties
     189         176 :     registerProperty(PROPERTY_ISBOOKMARKABLE,       PROPERTY_ID_ISBOOKMARKABLE,         nRT,                            &m_bIsBookmarkable,      ::getBooleanCppuType());
     190         176 :     registerProperty(PROPERTY_CANUPDATEINSERTEDROWS,PROPERTY_ID_CANUPDATEINSERTEDROWS,  nRT,                            &m_bCanUpdateInsertedRows,      ::getBooleanCppuType());
     191             :     // sdbc.ResultSet Properties
     192         176 :     registerProperty(PROPERTY_RESULTSETCONCURRENCY, PROPERTY_ID_RESULTSETCONCURRENCY,   PropertyAttribute::TRANSIENT,   &m_nResultSetConcurrency,::getCppuType(static_cast< sal_Int32*>(0)));
     193         176 :     registerProperty(PROPERTY_RESULTSETTYPE,        PROPERTY_ID_RESULTSETTYPE,          PropertyAttribute::TRANSIENT,   &m_nResultSetType,      ::getCppuType(static_cast< sal_Int32*>(0)));
     194         176 :     registerProperty(PROPERTY_FETCHDIRECTION,       PROPERTY_ID_FETCHDIRECTION,         PropertyAttribute::TRANSIENT,   &m_nFetchDirection,     ::getCppuType(static_cast< sal_Int32*>(0)));
     195         176 :     registerProperty(PROPERTY_FETCHSIZE,            PROPERTY_ID_FETCHSIZE,              PropertyAttribute::TRANSIENT,   &m_nFetchSize,          ::getCppuType(static_cast< sal_Int32*>(0)));
     196             : 
     197             :     // sdbc.RowSet Properties
     198         176 :     registerProperty(PROPERTY_URL,                  PROPERTY_ID_URL,                    0,                              &m_aURL,                ::getCppuType(static_cast< OUString*>(0)));
     199         176 :     registerProperty(PROPERTY_TRANSACTIONISOLATION, PROPERTY_ID_TRANSACTIONISOLATION,   PropertyAttribute::TRANSIENT,   &m_nTransactionIsolation,::getCppuType(static_cast< sal_Int32*>(0)));
     200         176 :     registerMayBeVoidProperty(PROPERTY_TYPEMAP,     PROPERTY_ID_TYPEMAP,                PropertyAttribute::MAYBEVOID|PropertyAttribute::TRANSIENT,  &m_aTypeMap,            ::getCppuType(static_cast< Reference< XNameAccess >* >(0)));
     201         176 :     registerProperty(PROPERTY_ESCAPE_PROCESSING,PROPERTY_ID_ESCAPE_PROCESSING,  PropertyAttribute::BOUND,       &m_bUseEscapeProcessing,::getBooleanCppuType()  );
     202         176 :     registerProperty(PROPERTY_QUERYTIMEOUT,         PROPERTY_ID_QUERYTIMEOUT,           PropertyAttribute::TRANSIENT,   &m_nQueryTimeOut,       ::getCppuType(static_cast< sal_Int32*>(0)));
     203         176 :     registerProperty(PROPERTY_MAXFIELDSIZE,         PROPERTY_ID_MAXFIELDSIZE,           PropertyAttribute::TRANSIENT,   &m_nMaxFieldSize,       ::getCppuType(static_cast< sal_Int32*>(0)));
     204         176 :     registerProperty(PROPERTY_MAXROWS,              PROPERTY_ID_MAXROWS,                0,                              &m_nMaxRows,            ::getCppuType(static_cast< sal_Int32*>(0)) );
     205         176 :     registerProperty(PROPERTY_USER,                 PROPERTY_ID_USER,                   PropertyAttribute::TRANSIENT,   &m_aUser,               ::getCppuType(static_cast< OUString*>(0)));
     206         176 :     registerProperty(PROPERTY_PASSWORD,             PROPERTY_ID_PASSWORD,               PropertyAttribute::TRANSIENT,   &m_aPassword,           ::getCppuType(static_cast< OUString*>(0)));
     207             : 
     208         176 :     registerProperty(PROPERTY_UPDATE_CATALOGNAME,   PROPERTY_ID_UPDATE_CATALOGNAME,     PropertyAttribute::BOUND,       &m_aUpdateCatalogName,  ::getCppuType(static_cast< OUString*>(0)));
     209         176 :     registerProperty(PROPERTY_UPDATE_SCHEMANAME,    PROPERTY_ID_UPDATE_SCHEMANAME,      PropertyAttribute::BOUND,       &m_aUpdateSchemaName,   ::getCppuType(static_cast< OUString*>(0)));
     210         176 :     registerProperty(PROPERTY_UPDATE_TABLENAME,     PROPERTY_ID_UPDATE_TABLENAME,       PropertyAttribute::BOUND,       &m_aUpdateTableName,    ::getCppuType(static_cast< OUString*>(0)));
     211             : 
     212             :     // ???
     213         176 :     registerProperty(PROPERTY_CHANGE_NOTIFICATION_ENABLED, PROPERTY_ID_PROPCHANGE_NOTIFY, PropertyAttribute::BOUND,     &m_bPropChangeNotifyEnabled, ::getBooleanCppuType());
     214         176 : }
     215             : 
     216         519 : ORowSet::~ORowSet()
     217             : {
     218         173 :     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         346 : }
     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         789 : void SAL_CALL ORowSet::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) throw (Exception, std::exception)
     280             : {
     281         789 :     switch(nHandle)
     282             :     {
     283             :         case PROPERTY_ID_ISMODIFIED:
     284           6 :             m_bModified = cppu::any2bool(rValue);
     285           6 :             break;
     286             :         case PROPERTY_ID_FETCHDIRECTION:
     287           3 :             if( m_nResultSetType == ResultSetType::FORWARD_ONLY)
     288           0 :                 throw Exception(); // else run through
     289             :         default:
     290         783 :             OPropertyStateContainer::setFastPropertyValue_NoBroadcast(nHandle,rValue);
     291             :     }
     292             : 
     293         789 :     if  (   ( nHandle == PROPERTY_ID_ACTIVE_CONNECTION )
     294         637 :         ||  ( nHandle == PROPERTY_ID_DATASOURCENAME )
     295         540 :         ||  ( nHandle == PROPERTY_ID_COMMAND )
     296         434 :         ||  ( nHandle == PROPERTY_ID_COMMAND_TYPE )
     297         278 :         ||  ( nHandle == PROPERTY_ID_IGNORERESULT )
     298         272 :         ||  ( nHandle == PROPERTY_ID_FILTER )
     299         266 :         ||  ( nHandle == PROPERTY_ID_HAVING_CLAUSE )
     300         260 :         ||  ( nHandle == PROPERTY_ID_GROUP_BY )
     301         254 :         ||  ( nHandle == PROPERTY_ID_APPLYFILTER )
     302          86 :         ||  ( nHandle == PROPERTY_ID_ORDER )
     303          79 :         ||  ( nHandle == PROPERTY_ID_URL )
     304          78 :         ||  ( nHandle == PROPERTY_ID_USER )
     305             :         )
     306             :     {
     307         714 :         m_bCommandFacetsDirty = sal_True;
     308             :     }
     309             : 
     310             : 
     311         789 :     switch(nHandle)
     312             :     {
     313             :         case PROPERTY_ID_ACTIVE_CONNECTION:
     314             :             // the new connection
     315             :             {
     316         152 :                 Reference< XConnection > xNewConnection(m_aActiveConnection,UNO_QUERY);
     317         152 :                 setActiveConnection(xNewConnection, sal_False);
     318             :             }
     319             : 
     320         152 :             m_bOwnConnection        = sal_False;
     321         152 :             m_bRebuildConnOnExecute = sal_False;
     322         152 :             break;
     323             : 
     324             :         case PROPERTY_ID_DATASOURCENAME:
     325          97 :             if(!m_xStatement.is())
     326             :             {
     327          90 :                 Reference< XConnection >  xNewConn;
     328         180 :                 Any aNewConn;
     329          90 :                 aNewConn <<= xNewConn;
     330         180 :                 setFastPropertyValue(PROPERTY_ID_ACTIVE_CONNECTION, aNewConn);
     331             :             }
     332             :             else
     333           7 :                 m_bRebuildConnOnExecute = sal_True;
     334          97 :             break;
     335             :         case PROPERTY_ID_FETCHSIZE:
     336          15 :             if(m_pCache)
     337             :             {
     338           3 :                 m_pCache->setFetchSize(m_nFetchSize);
     339           3 :                 fireRowcount();
     340             :             }
     341          15 :             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           1 :             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           1 :             m_bOwnConnection = sal_True;
     359           1 :             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           4 :             m_bPropChangeNotifyEnabled = ::cppu::any2bool(rValue);
     365           4 :             break;
     366             :         default:
     367         520 :             break;
     368             :     };
     369         789 : }
     370             : 
     371        1095 : void SAL_CALL ORowSet::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const
     372             : {
     373        1095 :     if(m_pCache)
     374             :     {
     375         472 :         switch(nHandle)
     376             :         {
     377             :         case PROPERTY_ID_ISMODIFIED:
     378          40 :             rValue.setValue(&m_bModified,::getCppuBooleanType());
     379          40 :             break;
     380             :         case PROPERTY_ID_ISNEW:
     381          10 :             rValue.setValue(&m_bNew,::getCppuBooleanType());
     382          10 :             break;
     383             :         case PROPERTY_ID_PRIVILEGES:
     384           3 :             rValue <<= m_pCache->m_nPrivileges;
     385           3 :             break;
     386             :         case PROPERTY_ID_ACTIVE_CONNECTION:
     387          60 :             rValue <<= m_xActiveConnection;
     388          60 :             break;
     389             :         case PROPERTY_ID_TYPEMAP:
     390           2 :             rValue <<= m_xTypeMap;
     391           2 :             break;
     392             :         default:
     393         357 :             ORowSetBase::getFastPropertyValue(rValue,nHandle);
     394             :         };
     395             :     }
     396             :     else
     397             :     {
     398         623 :         switch(nHandle)
     399             :         {
     400             :             case PROPERTY_ID_ACTIVE_CONNECTION:
     401         379 :                 rValue <<= m_xActiveConnection;
     402         379 :                 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         244 :                 ORowSetBase::getFastPropertyValue(rValue,nHandle);
     411             :         }
     412             :     }
     413        1095 : }
     414             : 
     415             : // com::sun::star::XTypeProvider
     416           2 : Sequence< Type > SAL_CALL ORowSet::getTypes() throw (RuntimeException, std::exception)
     417             : {
     418           2 :     OTypeCollection aTypes(::getCppuType( (const Reference< XPropertySet > *)0 ),
     419           2 :                             ::getCppuType( (const Reference< XFastPropertySet > *)0 ),
     420           2 :                             ::getCppuType( (const Reference< XMultiPropertySet > *)0 ),
     421           4 :                            ::comphelper::concatSequences(ORowSet_BASE1::getTypes(),ORowSetBase::getTypes()));
     422           2 :     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        2474 : Any SAL_CALL ORowSet::queryInterface( const Type & rType ) throw (RuntimeException, std::exception)
     432             : {
     433        2474 :     return ORowSet_BASE1::queryInterface( rType);
     434             : }
     435             : 
     436        9104 : void SAL_CALL ORowSet::acquire() throw()
     437             : {
     438        9104 :     ORowSet_BASE1::acquire();
     439        9104 : }
     440             : 
     441        9062 : void SAL_CALL ORowSet::release() throw()
     442             : {
     443        9062 :     ORowSet_BASE1::release();
     444        9062 : }
     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        3212 : Any SAL_CALL ORowSet::queryAggregation( const Type& rType ) throw(RuntimeException, std::exception)
     472             : {
     473        3212 :     Any aRet(ORowSetBase::queryInterface(rType));
     474        3212 :     if (!aRet.hasValue())
     475        1774 :         aRet = ORowSet_BASE1::queryAggregation(rType);
     476        3212 :     return aRet;
     477             : }
     478             : 
     479          21 : OUString ORowSet::getImplementationName_static(  ) throw(RuntimeException)
     480             : {
     481          21 :     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           4 : sal_Bool SAL_CALL ORowSet::supportsService( const OUString& _rServiceName ) throw(RuntimeException, std::exception)
     491             : {
     492           4 :     return cppu::supportsService(this, _rServiceName);
     493             : }
     494             : 
     495          25 : Sequence< OUString > ORowSet::getSupportedServiceNames_static(  ) throw (RuntimeException)
     496             : {
     497          25 :     Sequence< OUString > aSNS( 5 );
     498          25 :     aSNS[0] = SERVICE_SDBC_RESULTSET;
     499          25 :     aSNS[1] = SERVICE_SDBC_ROWSET;
     500          25 :     aSNS[2] = SERVICE_SDBCX_RESULTSET;
     501          25 :     aSNS[3] = SERVICE_SDB_RESULTSET;
     502          25 :     aSNS[4] = SERVICE_SDB_ROWSET;
     503          25 :     return aSNS;
     504             : }
     505             : 
     506           4 : Sequence< OUString > SAL_CALL ORowSet::getSupportedServiceNames(  ) throw(RuntimeException, std::exception)
     507             : {
     508           4 :     return getSupportedServiceNames_static();
     509             : }
     510             : 
     511         176 : Reference< XInterface > ORowSet::Create(const Reference< XComponentContext >& _rxContext)
     512             : {
     513         176 :     return *(new ORowSet( _rxContext ));
     514             : }
     515             : 
     516             : // OComponentHelper
     517         175 : void SAL_CALL ORowSet::disposing()
     518             : {
     519         175 :     OPropertyStateContainer::disposing();
     520             : 
     521         175 :     MutexGuard aGuard(m_aMutex);
     522         350 :     EventObject aDisposeEvent;
     523         175 :     aDisposeEvent.Source = static_cast< XComponent* >(this);
     524         175 :     m_aRowsetListeners.disposeAndClear( aDisposeEvent );
     525         175 :     m_aApproveListeners.disposeAndClear( aDisposeEvent );
     526         175 :     m_aRowsChangeListener.disposeAndClear( aDisposeEvent );
     527             : 
     528         175 :     freeResources( true );
     529             : 
     530             :     // remove myself as dispose listener
     531         350 :     Reference< XComponent >  xComponent(m_xActiveConnection, UNO_QUERY);
     532         175 :     if (xComponent.is())
     533             :     {
     534          12 :         Reference<XEventListener> xEvt;
     535          12 :         query_aggregation(this,xEvt);
     536          12 :         xComponent->removeEventListener(xEvt);
     537             :     }
     538             : 
     539         175 :     m_aActiveConnection = Any(); // the any conatains a reference too
     540         175 :     if(m_bOwnConnection)
     541          13 :         ::comphelper::disposeComponent(m_xActiveConnection);
     542         175 :     m_xActiveConnection = NULL;
     543             : 
     544             : 
     545         350 :     ORowSetBase::disposing();
     546         175 : }
     547             : 
     548         247 : void ORowSet::freeResources( bool _bComplete )
     549             : {
     550         247 :     MutexGuard aGuard(m_aMutex);
     551             : 
     552             :     // free all clones
     553         247 :     connectivity::OWeakRefArray::iterator aEnd = m_aClones.end();
     554         249 :     for (connectivity::OWeakRefArray::iterator i = m_aClones.begin(); aEnd != i; ++i)
     555             :     {
     556           2 :         Reference< XComponent > xComp(i->get(), UNO_QUERY);
     557           2 :         if (xComp.is())
     558           2 :             xComp->dispose();
     559           2 :     }
     560         247 :     m_aClones.clear();
     561             : 
     562         247 :     if ( _bComplete )
     563             :     {
     564             :         // the columns must be disposed before the querycomposer is disposed because
     565             :         // their owner can be the composer
     566         244 :         TDataColumns().swap(m_aDataColumns);// clear and resize capacity
     567         244 :         ::std::vector<bool>().swap(m_aReadOnlyDataColumns);
     568             : 
     569         244 :         m_xColumns      = NULL;
     570         244 :         if ( m_pColumns )
     571          24 :             m_pColumns->disposing();
     572             :         // dispose the composer to avoid that everbody knows that the querycomposer is eol
     573         244 :         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         244 :         m_aWarnings.setExternalWarnings( NULL );
     582             : 
     583         244 :         DELETEZ(m_pCache);
     584             : 
     585         244 :         impl_resetTables_nothrow();
     586             : 
     587         244 :         m_xStatement    = NULL;
     588         244 :         m_xTypeMap      = NULL;
     589             : 
     590         244 :         m_aBookmark     = Any();
     591         244 :         m_bBeforeFirst  = sal_True;
     592         244 :         m_bAfterLast    = sal_False;
     593         244 :         m_bNew          = sal_False;
     594         244 :         m_bModified     = sal_False;
     595         244 :         m_bIsInsertRow  = sal_False;
     596         244 :         m_bLastKnownRowCountFinal = sal_False;
     597         244 :         m_nLastKnownRowCount      = 0;
     598         244 :         if ( m_aOldRow.is() )
     599          24 :             m_aOldRow->clearRow();
     600             : 
     601         244 :         impl_disposeParametersContainer_nothrow();
     602             : 
     603         244 :         m_bCommandFacetsDirty = sal_True;
     604         247 :     }
     605         247 : }
     606             : 
     607         203 : void ORowSet::setActiveConnection( Reference< XConnection >& _rxNewConn, sal_Bool _bFireEvent )
     608             : {
     609         203 :     if (_rxNewConn.get() == m_xActiveConnection.get())
     610             :         // nothing to do
     611         366 :         return;
     612             : 
     613             :     // remove the event listener for the old connection
     614          40 :     Reference< XComponent >  xComponent(m_xActiveConnection, UNO_QUERY);
     615          40 :     if (xComponent.is())
     616             :     {
     617          14 :         Reference<XEventListener> xListener;
     618          14 :         query_aggregation(this, xListener);
     619          14 :         xComponent->removeEventListener(xListener);
     620             :     }
     621             : 
     622             :     // if we owned the connection, remember it for later disposing
     623          40 :     if(m_bOwnConnection)
     624           1 :         m_xOldConnection = m_xActiveConnection;
     625             : 
     626             :     // for firing the PropertyChangeEvent
     627          40 :     sal_Int32 nHandle = PROPERTY_ID_ACTIVE_CONNECTION;
     628          80 :     Any aOldConnection; aOldConnection <<= m_xActiveConnection;
     629          80 :     Any aNewConnection; aNewConnection <<= _rxNewConn;
     630             : 
     631             :     // set the new connection
     632          40 :     m_xActiveConnection = _rxNewConn;
     633          40 :     if (m_xActiveConnection.is())
     634          26 :         m_aActiveConnection <<= m_xActiveConnection;
     635             :     else
     636          14 :         m_aActiveConnection.clear();
     637             : 
     638             :     // fire the event
     639          40 :     if (_bFireEvent)
     640          27 :         fire(&nHandle, &aNewConnection, &aOldConnection, 1, sal_False);
     641             : 
     642             :     // register as event listener for the new connection
     643          40 :     xComponent.set(m_xActiveConnection,UNO_QUERY);
     644          40 :     if (xComponent.is())
     645             :     {
     646          26 :         Reference<XEventListener> xListener;
     647          26 :         query_aggregation(this, xListener);
     648          26 :         xComponent->addEventListener(xListener);
     649          40 :     }
     650             : }
     651             : 
     652             : // ::com::sun::star::XEventListener
     653          38 : 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          38 :     Reference<XConnection> xCon(Source.Source,UNO_QUERY);
     657          38 :     if(m_xActiveConnection == xCon)
     658             :     {
     659          38 :         close();
     660             :         {
     661          38 :             MutexGuard aGuard( m_aMutex );
     662          76 :             Reference< XConnection > xXConnection;
     663          76 :             setActiveConnection( xXConnection );
     664             :         }
     665          38 :     }
     666          38 : }
     667             : 
     668             : // XCloseable
     669          40 : void SAL_CALL ORowSet::close(  ) throw(SQLException, RuntimeException, std::exception)
     670             : {
     671             :     {
     672          40 :         MutexGuard aGuard( m_aMutex );
     673          40 :         ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
     674             :     }
     675             :     // additionals things to set
     676          40 :     freeResources( true );
     677          40 : }
     678             : 
     679             : // comphelper::OPropertyArrayUsageHelper
     680          49 : ::cppu::IPropertyArrayHelper* ORowSet::createArrayHelper( ) const
     681             : {
     682          49 :     Sequence< Property > aProps;
     683          49 :     describeProperties(aProps);
     684          49 :     return new ::cppu::OPropertyArrayHelper(aProps);
     685             : }
     686             : 
     687             : // cppu::OPropertySetHelper
     688        5440 : ::cppu::IPropertyArrayHelper& SAL_CALL ORowSet::getInfoHelper()
     689             : {
     690             :     typedef ::comphelper::OPropertyArrayUsageHelper<ORowSet> ORowSet_PROP;
     691        5440 :     return *ORowSet_PROP::getArrayHelper();
     692             : }
     693             : 
     694           6 : void ORowSet::updateValue(sal_Int32 columnIndex,const ORowSetValue& x)
     695             : {
     696           6 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
     697             : 
     698           6 :     ::osl::MutexGuard aGuard( *m_pMutex );
     699           6 :     checkUpdateConditions(columnIndex);
     700           6 :     checkUpdateIterator();
     701             : 
     702           6 :     ORowSetValueVector::Vector& rRow = ((*m_aCurrentRow)->get());
     703          12 :     ORowSetNotifier aNotify(this,rRow);
     704           6 :     m_pCache->updateValue(columnIndex,x,rRow,aNotify.getChangedColumns());
     705           6 :     m_bModified = m_bModified || !aNotify.getChangedColumns().empty();
     706          12 :     aNotify.firePropertyChange();
     707           6 : }
     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           6 : void SAL_CALL ORowSet::updateString( sal_Int32 columnIndex, const OUString& x ) throw(SQLException, RuntimeException, std::exception)
     761             : {
     762           6 :     updateValue(columnIndex,x);
     763           6 : }
     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           1 : void SAL_CALL ORowSet::insertRow(  ) throw(SQLException, RuntimeException, std::exception)
     873             : {
     874           1 :     ::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           1 :     ::osl::ResettableMutexGuard aGuard( *m_pMutex );
     880             : 
     881           1 :     if(!m_pCache || !m_bNew || !m_bModified || m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY)
     882           0 :         throwFunctionSequenceException(*this);
     883             : 
     884             :     // remember old value for fire
     885           1 :     sal_Bool bOld = m_bNew;
     886             : 
     887           2 :     ORowSetRow aOldValues;
     888           1 :     if ( !m_aCurrentRow.isNull() )
     889           1 :         aOldValues = new ORowSetValueVector( *(*m_aCurrentRow));
     890           2 :     Sequence<Any> aChangedBookmarks;
     891           2 :     RowsChangeEvent aEvt(*this,RowChangeAction::INSERT,1,aChangedBookmarks);
     892           1 :     notifyAllListenersRowBeforeChange(aGuard,aEvt);
     893             : 
     894           2 :     ::std::vector< Any > aBookmarks;
     895           1 :     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           1 :     m_pCache->resetInsertRow(bInserted);
     899             : 
     900             :     // notification order
     901             :     // - column values
     902           1 :     setCurrentRow( sal_False, sal_True, aOldValues, aGuard ); // we don't move here
     903             : 
     904             :     // read-only flag restored
     905           1 :     impl_restoreDataColumnsWriteable_throw();
     906             : 
     907             :     // - rowChanged
     908           1 :     notifyAllListenersRowChanged(aGuard,aEvt);
     909             : 
     910           1 :     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           1 :     if(!m_bModified)
     918           1 :         fireProperty(PROPERTY_ID_ISMODIFIED,sal_False,sal_True);
     919             :     OSL_ENSURE( !m_bModified, "ORowSet::insertRow: just updated, but _still_ modified?" );
     920             : 
     921             :     // - IsNew
     922           1 :     if(m_bNew != bOld)
     923           1 :         fireProperty(PROPERTY_ID_ISNEW,m_bNew,bOld);
     924             : 
     925             :     // - RowCount/IsRowCountFinal
     926           2 :     fireRowcount();
     927           1 : }
     928             : 
     929          11 : sal_Int32 SAL_CALL ORowSet::getRow(  ) throw(SQLException, RuntimeException, std::exception)
     930             : {
     931          11 :     ::osl::MutexGuard aGuard( *m_pMutex );
     932          11 :     checkCache();
     933             : 
     934             :     // check if we are inserting a row
     935          11 :     return (m_pCache && isInsertRow()) ? 0 : ORowSetBase::getRow();
     936             : }
     937             : 
     938           4 : void SAL_CALL ORowSet::updateRow(  ) throw(SQLException, RuntimeException, std::exception)
     939             : {
     940           4 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
     941             :     // not allowed when standing on insert row
     942           4 :     ::osl::ResettableMutexGuard aGuard( *m_pMutex );
     943           4 :     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           4 :     if(m_bModified)
     948             :     {
     949           4 :         ORowSetRow aOldValues;
     950           4 :         if ( !m_aCurrentRow.isNull() )
     951           4 :             aOldValues = new ORowSetValueVector( *(*m_aCurrentRow) );
     952             : 
     953           8 :         Sequence<Any> aChangedBookmarks;
     954           8 :         RowsChangeEvent aEvt(*this,RowChangeAction::UPDATE,1,aChangedBookmarks);
     955           4 :         notifyAllListenersRowBeforeChange(aGuard,aEvt);
     956             : 
     957           8 :         ::std::vector< Any > aBookmarks;
     958           4 :         m_pCache->updateRow(m_aCurrentRow.operator ->(),aBookmarks);
     959           4 :         if ( !aBookmarks.empty() )
     960           0 :             aEvt.Bookmarks = Sequence<Any>(&(*aBookmarks.begin()),aBookmarks.size());
     961           4 :         aEvt.Rows += aBookmarks.size();
     962           4 :         m_aBookmark     = m_pCache->getBookmark();
     963           4 :         m_aCurrentRow   = m_pCache->m_aMatrixIter;
     964           4 :         m_bIsInsertRow  = sal_False;
     965           4 :         if ( m_pCache->m_aMatrixIter != m_pCache->getEnd() && (*m_pCache->m_aMatrixIter).is() )
     966             :         {
     967           4 :             if ( m_pCache->isResultSetChanged() )
     968             :             {
     969           0 :                 impl_rebuild_throw(aGuard);
     970             :             }
     971             :             else
     972             :             {
     973           4 :                 m_aOldRow->setRow(new ORowSetValueVector(*(*m_aCurrentRow)));
     974             : 
     975             :                 // notification order
     976             :                 // - column values
     977           4 :                 ORowSetBase::firePropertyChange(aOldValues);
     978             :             }
     979             :             // - rowChanged
     980           4 :             notifyAllListenersRowChanged(aGuard,aEvt);
     981             : 
     982             :             // - IsModified
     983           4 :             if(!m_bModified)
     984           4 :                 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           4 :             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           4 :         }
     994           4 :     }
     995           4 : }
     996             : 
     997           1 : void SAL_CALL ORowSet::deleteRow(  ) throw(SQLException, RuntimeException, std::exception)
     998             : {
     999           1 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
    1000             : 
    1001           1 :     ::osl::ResettableMutexGuard aGuard( *m_pMutex );
    1002           1 :     checkCache();
    1003             : 
    1004           1 :     if ( m_bBeforeFirst || m_bAfterLast )
    1005           0 :         ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_DELETE_BEFORE_AFTER ), SQL_INVALID_CURSOR_POSITION, *this );
    1006           1 :     if ( m_bNew )
    1007           0 :         ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_DELETE_INSERT_ROW ), SQL_INVALID_CURSOR_POSITION, *this );
    1008           1 :     if  ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY )
    1009           0 :         ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_RESULT_IS_READONLY ), SQL_FUNCTION_SEQUENCE_ERROR, *this );
    1010           1 :     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           1 :     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           2 :     Any aBookmarkToDelete( m_aBookmark );
    1017           1 :     positionCache( MOVE_NONE_REFRESH_ONLY );
    1018           1 :     sal_Int32 nDeletePosition = m_pCache->getRow();
    1019             : 
    1020           1 :     notifyRowSetAndClonesRowDelete( aBookmarkToDelete );
    1021             : 
    1022           2 :     ORowSetRow aOldValues;
    1023           1 :     if ( m_pCache->m_aMatrixIter != m_pCache->getEnd() && m_pCache->m_aMatrixIter->is() )
    1024           1 :         aOldValues = new ORowSetValueVector( *(*(m_pCache->m_aMatrixIter)) );
    1025             : 
    1026           2 :     Sequence<Any> aChangedBookmarks;
    1027           2 :     RowsChangeEvent aEvt(*this,RowChangeAction::DELETE,1,aChangedBookmarks);
    1028           1 :     notifyAllListenersRowBeforeChange(aGuard,aEvt);
    1029             : 
    1030           1 :     m_pCache->deleteRow();
    1031           1 :     notifyRowSetAndClonesRowDeleted( aBookmarkToDelete, nDeletePosition );
    1032             : 
    1033           2 :     ORowSetNotifier aNotifier( this );
    1034             :         // this will call cancelRowModification on the cache if necessary
    1035             : 
    1036             :     // notification order
    1037             :     // - rowChanged
    1038           1 :     notifyAllListenersRowChanged(aGuard,aEvt);
    1039             : 
    1040             :     // - IsModified
    1041             :     // - IsNew
    1042           1 :     aNotifier.fire( );
    1043             : 
    1044             :     // - RowCount/IsRowCountFinal
    1045           2 :     fireRowcount();
    1046           1 : }
    1047             : 
    1048           1 : void ORowSet::implCancelRowUpdates( sal_Bool _bNotifyModified ) SAL_THROW( ( SQLException, RuntimeException ) )
    1049             : {
    1050           1 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
    1051             : 
    1052           1 :     ::osl::MutexGuard aGuard( *m_pMutex );
    1053           1 :     if ( m_bBeforeFirst || m_bAfterLast || rowDeleted() )
    1054           1 :         return; // nothing to do so return
    1055             : 
    1056           1 :     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           1 :     if ( m_bNew || m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY )
    1062           0 :         throwFunctionSequenceException(*this);
    1063             : 
    1064           1 :     positionCache( MOVE_NONE_REFRESH_ONLY );
    1065             : 
    1066           2 :     ORowSetRow aOldValues;
    1067           1 :     if ( !m_bModified && _bNotifyModified && !m_aCurrentRow.isNull() )
    1068           0 :         aOldValues = new ORowSetValueVector( *(*m_aCurrentRow) );
    1069             : 
    1070           1 :     m_pCache->cancelRowUpdates();
    1071             : 
    1072           1 :     m_aBookmark     = m_pCache->getBookmark();
    1073           1 :     m_aCurrentRow   = m_pCache->m_aMatrixIter;
    1074           1 :     m_bIsInsertRow  = sal_False;
    1075           1 :     m_aCurrentRow.setBookmark(m_aBookmark);
    1076             : 
    1077             :     // notification order
    1078             :     // IsModified
    1079           1 :     if( !m_bModified && _bNotifyModified )
    1080             :     {
    1081             :         // - column values
    1082           0 :         ORowSetBase::firePropertyChange(aOldValues);
    1083           0 :         fireProperty(PROPERTY_ID_ISMODIFIED,sal_False,sal_True);
    1084           1 :     }
    1085             : }
    1086             : 
    1087           0 : void SAL_CALL ORowSet::cancelRowUpdates(  ) throw(SQLException, RuntimeException, std::exception)
    1088             : {
    1089           0 :     implCancelRowUpdates( sal_True );
    1090           0 : }
    1091             : 
    1092          87 : void SAL_CALL ORowSet::addRowSetListener( const Reference< XRowSetListener >& listener ) throw(RuntimeException, std::exception)
    1093             : {
    1094          87 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
    1095             : 
    1096          87 :     ::osl::MutexGuard aGuard( m_aColumnsMutex );
    1097          87 :     if(listener.is())
    1098          87 :         m_aRowsetListeners.addInterface(listener);
    1099          87 : }
    1100             : 
    1101         247 : void SAL_CALL ORowSet::removeRowSetListener( const Reference< XRowSetListener >& listener ) throw(RuntimeException, std::exception)
    1102             : {
    1103         247 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
    1104             : 
    1105         247 :     ::osl::MutexGuard aGuard( m_aColumnsMutex );
    1106         247 :     if(listener.is())
    1107         247 :         m_aRowsetListeners.removeInterface(listener);
    1108         247 : }
    1109             : 
    1110          24 : void ORowSet::notifyAllListeners(::osl::ResettableMutexGuard& _rGuard)
    1111             : {
    1112          24 :     EventObject aEvt(*m_pMySelf);
    1113          24 :     _rGuard.clear();
    1114          24 :     m_aRowsetListeners.notifyEach( &XRowSetListener::rowSetChanged, aEvt );
    1115          24 :     _rGuard.reset();
    1116          24 : }
    1117             : 
    1118         119 : void ORowSet::notifyAllListenersCursorMoved(::osl::ResettableMutexGuard& _rGuard)
    1119             : {
    1120         119 :     EventObject aEvt(*m_pMySelf);
    1121         119 :     _rGuard.clear();
    1122         119 :     m_aRowsetListeners.notifyEach( &XRowSetListener::cursorMoved, aEvt );
    1123         119 :     _rGuard.reset();
    1124         119 : }
    1125             : 
    1126           6 : void ORowSet::notifyAllListenersRowChanged(::osl::ResettableMutexGuard& _rGuard, const RowsChangeEvent& aEvt)
    1127             : {
    1128           6 :     _rGuard.clear();
    1129           6 :     m_aRowsetListeners.notifyEach( &XRowSetListener::rowChanged, (EventObject)aEvt );
    1130           6 :     m_aRowsChangeListener.notifyEach( &XRowsChangeListener::rowsChanged, aEvt );
    1131           6 :     _rGuard.reset();
    1132           6 : }
    1133             : 
    1134         131 : sal_Bool ORowSet::notifyAllListenersCursorBeforeMove(::osl::ResettableMutexGuard& _rGuard)
    1135             : {
    1136         131 :     EventObject aEvt(*m_pMySelf);
    1137         262 :     NOTIFY_LISTERNERS_CHECK(m_aApproveListeners,XRowSetApproveListener,approveCursorMove);
    1138         262 :     return bCheck;
    1139             : }
    1140             : 
    1141           6 : void ORowSet::notifyAllListenersRowBeforeChange(::osl::ResettableMutexGuard& _rGuard,const RowChangeEvent &aEvt)
    1142             : {
    1143           6 :     NOTIFY_LISTERNERS_CHECK(m_aApproveListeners,XRowSetApproveListener,approveRowChange);
    1144           6 :     if ( !bCheck )
    1145           0 :         m_aErrors.raiseTypedException( sdb::ErrorCondition::ROW_SET_OPERATION_VETOED, *this, ::cppu::UnoType< RowSetVetoException >::get() );
    1146           6 : }
    1147             : 
    1148         138 : void ORowSet::fireRowcount()
    1149             : {
    1150         138 :     sal_Int32 nCurrentRowCount( impl_getRowCount() );
    1151         138 :     sal_Bool bCurrentRowCountFinal( m_pCache->m_bRowCountFinal );
    1152             : 
    1153         138 :     if ( m_nLastKnownRowCount != nCurrentRowCount )
    1154             :     {
    1155          20 :         sal_Int32 nHandle = PROPERTY_ID_ROWCOUNT;
    1156          40 :         Any aNew,aOld;
    1157          20 :         aNew <<= nCurrentRowCount; aOld <<= m_nLastKnownRowCount;
    1158          20 :         fire(&nHandle,&aNew,&aOld,1,sal_False);
    1159          40 :         m_nLastKnownRowCount = nCurrentRowCount;
    1160             :     }
    1161         138 :     if ( !m_bLastKnownRowCountFinal && ( m_bLastKnownRowCountFinal != bCurrentRowCountFinal ) )
    1162             :     {
    1163          16 :         sal_Int32 nHandle = PROPERTY_ID_ISROWCOUNTFINAL;
    1164          32 :         Any aNew,aOld;
    1165          16 :         aNew <<= bCurrentRowCountFinal;
    1166          16 :         aOld <<= m_bLastKnownRowCountFinal;
    1167          16 :         fire(&nHandle,&aNew,&aOld,1,sal_False);
    1168          32 :         m_bLastKnownRowCountFinal = bCurrentRowCountFinal;
    1169             :     }
    1170         138 : }
    1171             : 
    1172           1 : void SAL_CALL ORowSet::moveToInsertRow(  ) throw(SQLException, RuntimeException, std::exception)
    1173             : {
    1174           1 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
    1175             : 
    1176           1 :     ::osl::ResettableMutexGuard aGuard( *m_pMutex );
    1177           1 :     checkPositioningAllowed();
    1178           1 :     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           1 :     if ( notifyAllListenersCursorBeforeMove( aGuard ) )
    1182             :     {
    1183             :         // remember old value for fire
    1184           1 :         ORowSetRow aOldValues;
    1185           1 :         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           1 :             positionCache( MOVE_NONE_REFRESH_ONLY );
    1193             : 
    1194             :         // check before because the resultset could be empty
    1195           2 :         if  (   !m_bBeforeFirst
    1196           0 :             &&  !m_bAfterLast
    1197           0 :             &&  m_pCache->m_aMatrixIter != m_pCache->getEnd()
    1198           1 :             &&  m_pCache->m_aMatrixIter->is()
    1199             :             )
    1200           0 :             aOldValues = new ORowSetValueVector( *(*(m_pCache->m_aMatrixIter)) );
    1201             : 
    1202           1 :         const sal_Bool bNewState = m_bNew;
    1203           1 :         const sal_Bool bModState = m_bModified;
    1204             : 
    1205           1 :         m_pCache->moveToInsertRow();
    1206           1 :         m_aCurrentRow = m_pCache->m_aInsertRow;
    1207           1 :         m_bIsInsertRow  = sal_True;
    1208             : 
    1209             :         // set read-only flag to false
    1210           1 :         impl_setDataColumnsWriteable_throw();
    1211             : 
    1212             :         // notification order
    1213             :         // - column values
    1214           1 :         ORowSetBase::firePropertyChange(aOldValues);
    1215             : 
    1216             :         // - cursorMoved
    1217           1 :         notifyAllListenersCursorMoved(aGuard);
    1218             : 
    1219             :         // - IsModified
    1220           1 :         if ( bModState != m_bModified )
    1221           0 :             fireProperty( PROPERTY_ID_ISMODIFIED, m_bModified, bModState );
    1222             : 
    1223             :         // - IsNew
    1224           1 :         if ( bNewState != m_bNew )
    1225           1 :             fireProperty( PROPERTY_ID_ISNEW, m_bNew, bNewState );
    1226             : 
    1227             :         // - RowCount/IsRowCountFinal
    1228           1 :         fireRowcount();
    1229           1 :     }
    1230           1 : }
    1231             : 
    1232           1 : void ORowSet::impl_setDataColumnsWriteable_throw()
    1233             : {
    1234           1 :     impl_restoreDataColumnsWriteable_throw();
    1235           1 :     TDataColumns::iterator aIter = m_aDataColumns.begin();
    1236           1 :     m_aReadOnlyDataColumns.resize(m_aDataColumns.size(),false);
    1237           1 :     ::std::vector<bool, std::allocator<bool> >::iterator aReadIter = m_aReadOnlyDataColumns.begin();
    1238          32 :     for(;aIter != m_aDataColumns.end();++aIter,++aReadIter)
    1239             :     {
    1240          31 :         sal_Bool bReadOnly = sal_False;
    1241          31 :         (*aIter)->getPropertyValue(PROPERTY_ISREADONLY) >>= bReadOnly;
    1242          31 :         *aReadIter = bReadOnly;
    1243             : 
    1244          31 :         (*aIter)->setPropertyValue(PROPERTY_ISREADONLY,makeAny(sal_False));
    1245             :     }
    1246           1 : }
    1247             : 
    1248           2 : void ORowSet::impl_restoreDataColumnsWriteable_throw()
    1249             : {
    1250             :     assert(m_aDataColumns.size() == m_aReadOnlyDataColumns.size() || m_aReadOnlyDataColumns.size() == 0 );
    1251           2 :     TDataColumns::iterator aIter = m_aDataColumns.begin();
    1252           2 :     ::std::vector<bool, std::allocator<bool> >::iterator aReadIter = m_aReadOnlyDataColumns.begin();
    1253          33 :     for(;aReadIter != m_aReadOnlyDataColumns.end();++aIter,++aReadIter)
    1254             :     {
    1255          31 :         (*aIter)->setPropertyValue(PROPERTY_ISREADONLY,makeAny((sal_Bool)*aReadIter ));
    1256             :     }
    1257           2 :     m_aReadOnlyDataColumns.clear();
    1258           2 : }
    1259             : 
    1260           1 : void SAL_CALL ORowSet::moveToCurrentRow(  ) throw(SQLException, RuntimeException, std::exception)
    1261             : {
    1262           1 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
    1263             : 
    1264           1 :     ::osl::ResettableMutexGuard aGuard( *m_pMutex );
    1265           1 :     checkPositioningAllowed();
    1266             : 
    1267           1 :     if ( !m_pCache->m_bNew && !m_bModified )
    1268             :         // nothing to do if we're not on the insertion row, and not modified otherwise
    1269           2 :         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         501 : sal_Bool SAL_CALL ORowSet::wasNull(  ) throw(SQLException, RuntimeException, std::exception)
    1297             : {
    1298         501 :     ::osl::MutexGuard aGuard( *m_pMutex );
    1299         501 :     checkCache();
    1300             : 
    1301         501 :     return ( m_pCache && isInsertRow() ) ? ((*m_pCache->m_aInsertRow)->get())[m_nLastColumnIndex].isNull() : ORowSetBase::wasNull();
    1302             : }
    1303             : 
    1304         757 : const ORowSetValue& ORowSet::getInsertValue(sal_Int32 columnIndex)
    1305             : {
    1306         757 :     checkCache();
    1307             : 
    1308         757 :     if ( m_pCache && isInsertRow() )
    1309           1 :         return  ((*m_pCache->m_aInsertRow)->get())[m_nLastColumnIndex = columnIndex];
    1310             : 
    1311         756 :     return getValue(columnIndex);
    1312             : }
    1313             : 
    1314         757 : OUString SAL_CALL ORowSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
    1315             : {
    1316         757 :     ::osl::MutexGuard aGuard( *m_pMutex );
    1317         757 :     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           5 : void SAL_CALL ORowSet::executeWithCompletion( const Reference< XInteractionHandler >& _rxHandler ) throw(SQLException, RuntimeException, std::exception)
    1443             : {
    1444           5 :     if (!_rxHandler.is())
    1445           0 :         execute();
    1446             : 
    1447           5 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
    1448             : 
    1449             :     // tell everybody that we will change the result set
    1450           5 :     approveExecution();
    1451             : 
    1452           5 :     ResettableMutexGuard aGuard( m_aMutex );
    1453             : 
    1454             :     try
    1455             :     {
    1456           5 :         freeResources( m_bCommandFacetsDirty );
    1457             : 
    1458             :         // calc the connection to be used
    1459           5 :         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           5 :         calcConnection( _rxHandler );
    1466           5 :         m_bRebuildConnOnExecute = sal_False;
    1467             : 
    1468           5 :         Reference< XSingleSelectQueryComposer > xComposer = getCurrentSettingsComposer( this, m_aContext );
    1469          10 :         Reference<XParametersSupplier>  xParameters(xComposer, UNO_QUERY);
    1470             : 
    1471          10 :         Reference<XIndexAccess>  xParamsAsIndicies = xParameters.is() ? xParameters->getParameters() : Reference<XIndexAccess>();
    1472           5 :         const sal_Int32 nParamCount = xParamsAsIndicies.is() ? xParamsAsIndicies->getCount() : 0;
    1473           5 :         if ( m_aParametersSet.size() < (size_t)nParamCount )
    1474           1 :             m_aParametersSet.resize( nParamCount ,false);
    1475             : 
    1476          10 :         ::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           5 :     execute_NoApprove_NoNewConn(aGuard);
    1496           5 : }
    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          32 : void ORowSet::approveExecution() throw (RowSetVetoException, RuntimeException)
    1528             : {
    1529          32 :     ::osl::MutexGuard aGuard( m_aColumnsMutex );
    1530          64 :     EventObject aEvt(*this);
    1531             : 
    1532          64 :     OInterfaceIteratorHelper aApproveIter( m_aApproveListeners );
    1533          65 :     while ( aApproveIter.hasMoreElements() )
    1534             :     {
    1535           1 :         Reference< XRowSetApproveListener > xListener( static_cast< XRowSetApproveListener* >( aApproveIter.next() ) );
    1536             :         try
    1537             :         {
    1538           1 :             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          33 :     }
    1553          32 : }
    1554             : 
    1555             : // XRowSet
    1556          27 : void SAL_CALL ORowSet::execute(  ) throw(SQLException, RuntimeException, std::exception)
    1557             : {
    1558          27 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
    1559             : 
    1560             :     // tell everybody that we will change the result set
    1561          27 :     approveExecution();
    1562             : 
    1563          27 :     ResettableMutexGuard aGuard( m_aMutex );
    1564          27 :     freeResources( m_bCommandFacetsDirty );
    1565             : 
    1566             :     // calc the connection to be used
    1567          27 :     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          27 :     calcConnection(NULL);
    1574          27 :     m_bRebuildConnOnExecute = sal_False;
    1575             : 
    1576             :     // do the real execute
    1577          38 :     execute_NoApprove_NoNewConn(aGuard);
    1578          16 : }
    1579             : 
    1580          18 : 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          18 :     sal_Int32 nResultSetType( _nDesiredResultSetType );
    1585          18 :     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          18 :     sal_Bool bRespectDriverRST = sal_False;
    1590          18 :     Any aSetting;
    1591          18 :     if ( getDataSourceSetting( ::dbaccess::getDataSource( m_xActiveConnection ), "RespectDriverResultSetType", aSetting ) )
    1592             :     {
    1593          18 :         OSL_VERIFY( aSetting >>= bRespectDriverRST );
    1594             :     }
    1595             : 
    1596          18 :     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          18 :     _rxStatement->setPropertyValue( PROPERTY_RESULTSETTYPE, makeAny( nResultSetType ) );
    1630          18 :     _rxStatement->setPropertyValue( PROPERTY_RESULTSETCONCURRENCY, makeAny( nResultSetConcurrency ) );
    1631          18 : }
    1632             : 
    1633          29 : void ORowSet::impl_makeNewStatement_throw()
    1634             : {
    1635          29 :     OUString sCommandToExecute;
    1636          29 :     impl_initComposer_throw( sCommandToExecute );
    1637             : 
    1638             :     try
    1639             :     {
    1640          18 :         m_xStatement = m_xActiveConnection->prepareStatement( sCommandToExecute );
    1641          18 :         if ( !m_xStatement.is() )
    1642             :         {
    1643           0 :             ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_INTERNAL_ERROR ), SQL_GENERAL_ERROR, *this );
    1644             :         }
    1645             : 
    1646          18 :         Reference< XPropertySet > xStatementProps( m_xStatement, UNO_QUERY_THROW );
    1647             :         // set the result set type and concurrency
    1648             :         try
    1649             :         {
    1650          18 :             xStatementProps->setPropertyValue( PROPERTY_USEBOOKMARKS, makeAny( sal_True ) );
    1651          18 :             xStatementProps->setPropertyValue( PROPERTY_MAXROWS, makeAny( m_nMaxRows ) );
    1652             : 
    1653          18 :             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          18 :         }
    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          29 :     }
    1677          18 : }
    1678             : 
    1679          31 : Reference< XResultSet > ORowSet::impl_prepareAndExecute_throw()
    1680             : {
    1681          31 :     if(m_bCommandFacetsDirty)
    1682          29 :         impl_makeNewStatement_throw();
    1683             : 
    1684          20 :     m_aParameterValueForCache.get().resize(1);
    1685          20 :     Reference< XParameters > xParam( m_xStatement, UNO_QUERY_THROW );
    1686          20 :     size_t nParamCount( m_pParameters.is() ? m_pParameters->size() : m_aPrematureParamValues.get().size() );
    1687          25 :     for ( size_t i=1; i<=nParamCount; ++i )
    1688             :     {
    1689           5 :         ORowSetValue& rParamValue( getParameterStorage( (sal_Int32)i ) );
    1690           5 :         ::dbtools::setObjectWithInfo( xParam, i, rParamValue.makeAny(), rParamValue.getTypeKind() );
    1691           5 :         m_aParameterValueForCache.get().push_back(rParamValue);
    1692             :     }
    1693          20 :     m_bParametersDirty = false;
    1694             : 
    1695          20 :     Reference< XResultSet > xResultSet(m_xStatement->executeQuery());
    1696             : 
    1697          40 :     OUString aComposedUpdateTableName;
    1698          20 :     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          20 :     m_pCache = new ORowSetCache( xResultSet, m_xComposer.get(), m_aContext, aComposedUpdateTableName, m_bModified, m_bNew,m_aParameterValueForCache,m_aFilter,m_nMaxRows );
    1703          20 :     if ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY )
    1704             :     {
    1705           0 :         m_nPrivileges = Privilege::SELECT;
    1706           0 :         m_pCache->m_nPrivileges = Privilege::SELECT;
    1707             :     }
    1708          20 :     m_pCache->setFetchSize(m_nFetchSize);
    1709          20 :     m_aCurrentRow   = m_pCache->createIterator(this);
    1710          20 :     m_bIsInsertRow  = sal_False;
    1711          20 :     m_aOldRow       = m_pCache->registerOldRow();
    1712             : 
    1713          40 :     return xResultSet;
    1714             : }
    1715             : 
    1716         436 : 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         436 :     bool bHaveAnyColumnSetting = false;
    1722             :     try
    1723             :     {
    1724         436 :         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         872 :         };
    1731        3488 :         for ( size_t i=0; i<sizeof( aPropertyNames ) / sizeof( aPropertyNames[0] ); ++i )
    1732             :         {
    1733        3052 :             if ( xInfo->hasPropertyByName( aPropertyNames[i] ) )
    1734             :             {
    1735        1526 :                 _rxRowSetColumn->setPropertyValue( aPropertyNames[i], _rxTemplateColumn->getPropertyValue( aPropertyNames[i] ) );
    1736        1526 :                 bHaveAnyColumnSetting = true;
    1737             :             }
    1738             :         }
    1739             : 
    1740             :         // the format key is slightly more complex
    1741         436 :         sal_Int32 nFormatKey = 0;
    1742         436 :         if( xInfo->hasPropertyByName( PROPERTY_NUMBERFORMAT ) )
    1743             :         {
    1744         218 :             _rxTemplateColumn->getPropertyValue( PROPERTY_NUMBERFORMAT ) >>= nFormatKey;
    1745         218 :             bHaveAnyColumnSetting = true;
    1746             :         }
    1747         436 :         if ( !nFormatKey && m_xNumberFormatTypes.is() )
    1748         436 :             nFormatKey = ::dbtools::getDefaultNumberFormat( _rxTemplateColumn, m_xNumberFormatTypes, SvtSysLocale().GetLanguageTag().getLocale() );
    1749         872 :         _rxRowSetColumn->setPropertyValue( PROPERTY_NUMBERFORMAT, makeAny( nFormatKey ) );
    1750             :     }
    1751           0 :     catch(Exception&)
    1752             :     {
    1753             :         DBG_UNHANDLED_EXCEPTION();
    1754           0 :         return;
    1755             :     }
    1756             : 
    1757         436 :     if ( bHaveAnyColumnSetting )
    1758         218 :         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         218 :         Reference< XPropertySetInfo > xInfo( _rxTemplateColumn->getPropertySetInfo(), UNO_QUERY_THROW );
    1766         218 :         if ( !xInfo->hasPropertyByName( PROPERTY_TABLENAME ) )
    1767             :             // no chance
    1768           0 :             return;
    1769             : 
    1770         436 :         OUString sTableName;
    1771         218 :         OSL_VERIFY( _rxTemplateColumn->getPropertyValue( PROPERTY_TABLENAME ) >>= sTableName );
    1772             : 
    1773         436 :         Reference< XNameAccess > xTables( impl_getTables_throw(), UNO_QUERY_THROW );
    1774         218 :         if ( !xTables->hasByName( sTableName ) )
    1775             :             // no chance
    1776           0 :             return;
    1777             : 
    1778         436 :         Reference< XColumnsSupplier > xTableColSup( xTables->getByName( sTableName ), UNO_QUERY_THROW );
    1779         436 :         Reference< XNameAccess > xTableCols( xTableColSup->getColumns(), UNO_QUERY_THROW );
    1780             : 
    1781         436 :         OUString sTableColumnName;
    1782             : 
    1783             :         // get the "Name" or (preferred) "RealName" property of the column
    1784         436 :         OUString sNamePropertyName( PROPERTY_NAME );
    1785         218 :         if ( xInfo->hasPropertyByName( PROPERTY_REALNAME ) )
    1786         218 :             sNamePropertyName = PROPERTY_REALNAME;
    1787         218 :         OSL_VERIFY( _rxTemplateColumn->getPropertyValue( sNamePropertyName ) >>= sTableColumnName );
    1788             : 
    1789         218 :         if ( !xTableCols->hasByName( sTableColumnName ) )
    1790           0 :             return;
    1791             : 
    1792         436 :         Reference< XPropertySet > xTableColumn( xTableCols->getByName( sTableColumnName ), UNO_QUERY_THROW );
    1793         436 :         impl_initializeColumnSettings_nothrow( xTableColumn, _rxRowSetColumn );
    1794             :     }
    1795           0 :     catch( const Exception& )
    1796             :     {
    1797             :         DBG_UNHANDLED_EXCEPTION();
    1798             :     }
    1799             : }
    1800             : 
    1801          32 : 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          32 :     ::comphelper::disposeComponent(m_xOldConnection);
    1807          32 :     m_xOldConnection = NULL;
    1808             : 
    1809             :     // do we need a new statement
    1810          32 :     if ( m_bCommandFacetsDirty )
    1811             :     {
    1812          29 :         m_xStatement    = NULL;
    1813          29 :         m_xComposer     = NULL;
    1814             : 
    1815          29 :         Reference< XResultSet > xResultSet( impl_prepareAndExecute_throw() );
    1816             : 
    1817             :         // let our warnings container forget the reference to the (possibly disposed) old result set
    1818          18 :         m_aWarnings.setExternalWarnings( NULL );
    1819             :         // clear all current warnings
    1820          18 :         m_aWarnings.clearWarnings();
    1821             :         // let the warnings container know about the new "external warnings"
    1822          18 :         m_aWarnings.setExternalWarnings( Reference< XWarningsSupplier >( xResultSet, UNO_QUERY ) );
    1823             : 
    1824             :         // get the locale
    1825          36 :         Locale aLocale = SvtSysLocale().GetLanguageTag().getLocale();
    1826             : 
    1827             :         // get the numberformatTypes
    1828             :         OSL_ENSURE(m_xActiveConnection.is(),"No ActiveConnection");
    1829          36 :         Reference< XNumberFormatTypes> xNumberFormatTypes;
    1830          36 :         Reference< XNumberFormatsSupplier> xNumberFormat = ::dbtools::getNumberFormats(m_xActiveConnection);
    1831          18 :         if ( xNumberFormat.is() )
    1832          18 :             m_xNumberFormatTypes.set(xNumberFormat->getNumberFormats(),UNO_QUERY);
    1833             : 
    1834          36 :         ::rtl::Reference< ::connectivity::OSQLColumns> aColumns = new ::connectivity::OSQLColumns();
    1835          36 :         ::std::vector< OUString> aNames;
    1836          36 :         OUString aDescription;
    1837             : 
    1838          18 :         const ::std::map<sal_Int32,sal_Int32>& rKeyColumns = m_pCache->getKeyColumns();
    1839          18 :         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          18 :             Reference< XResultSetMetaData > xMeta( getMetaData(), UNO_QUERY_THROW );
    1911          18 :             sal_Int32 nCount = xMeta->getColumnCount();
    1912          18 :             m_aDataColumns.reserve(nCount+1);
    1913          18 :             aColumns->get().reserve(nCount+1);
    1914          36 :             ::std::set< Reference< XPropertySet > > aAllColumns;
    1915             : 
    1916         236 :             for(sal_Int32 i=1; i <= nCount ;++i)
    1917             :             {
    1918         218 :                 OUString sName = xMeta->getColumnName(i);
    1919         436 :                 OUString sColumnLabel = xMeta->getColumnLabel(i);
    1920             : 
    1921             :                 // retrieve the column number |i|
    1922         436 :                 Reference<XPropertySet> xColumn;
    1923             :                 {
    1924         218 :                     sal_Bool bReFetchName = sal_False;
    1925         218 :                     if (m_xColumns->hasByName(sColumnLabel))
    1926         218 :                         m_xColumns->getByName(sColumnLabel) >>= xColumn;
    1927         218 :                     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         218 :                     if ( aAllColumns.find( xColumn ) != aAllColumns.end() )
    1932             :                     {
    1933           0 :                         xColumn = NULL;
    1934           0 :                         bReFetchName = sal_True;
    1935           0 :                         sColumnLabel = "";
    1936             :                     }
    1937         218 :                     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         218 :                     if(bReFetchName && xColumn.is())
    1955           0 :                         xColumn->getPropertyValue(PROPERTY_NAME) >>= sName;
    1956         218 :                     aAllColumns.insert( xColumn );
    1957             :                 }
    1958             : 
    1959             :                 // create a RowSetDataColumn
    1960             :                 {
    1961         218 :                     Reference<XPropertySetInfo> xInfo = xColumn.is() ? xColumn->getPropertySetInfo() : Reference<XPropertySetInfo>();
    1962         218 :                     if(xInfo.is() && xInfo->hasPropertyByName(PROPERTY_DESCRIPTION))
    1963         218 :                         aDescription = comphelper::getString(xColumn->getPropertyValue(PROPERTY_DESCRIPTION));
    1964             : 
    1965         436 :                     OUString sParseLabel;
    1966         218 :                     if ( xColumn.is() )
    1967             :                     {
    1968         218 :                         xColumn->getPropertyValue(PROPERTY_LABEL) >>= sParseLabel;
    1969             :                     }
    1970         218 :                     ORowSetDataColumn* pColumn = new ORowSetDataColumn( getMetaData(),
    1971             :                                                                         this,
    1972             :                                                                         this,
    1973             :                                                                         i,
    1974         218 :                                                                         m_xActiveConnection->getMetaData(),
    1975             :                                                                         aDescription,
    1976             :                                                                         sParseLabel,
    1977         654 :                                                                         m_aCurrentRow);
    1978         218 :                     aColumns->get().push_back(pColumn);
    1979             : 
    1980         218 :                     pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ISREADONLY,makeAny(rKeyColumns.find(i) != rKeyColumns.end()));
    1981             : 
    1982         218 :                     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         218 :                     pColumn->setName(sColumnLabel);
    1990         218 :                     aNames.push_back(sColumnLabel);
    1991         218 :                     m_aDataColumns.push_back(pColumn);
    1992             : 
    1993         218 :                     if ( xColumn.is() )
    1994         436 :                         impl_initializeColumnSettings_nothrow( xColumn, pColumn );
    1995             :                 }
    1996         236 :             }
    1997             :         }
    1998             :         // now create the columns we need
    1999          18 :         if(m_pColumns)
    2000           3 :             m_pColumns->assign(aColumns,aNames);
    2001             :         else
    2002             :         {
    2003          15 :             Reference<XDatabaseMetaData> xMeta = m_xActiveConnection->getMetaData();
    2004          15 :             m_pColumns = new ORowSetDataColumns(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers(),
    2005          15 :                                                 aColumns,*this,m_aColumnsMutex,aNames);
    2006          18 :         }
    2007             :     }
    2008             :     else // !m_bCommandFacetsDirty
    2009             :     {
    2010           3 :         impl_rebuild_throw(_rClearForNotification);
    2011             :     }
    2012          21 :     checkCache();
    2013             :     // notify the rowset listeners
    2014          21 :     notifyAllListeners(_rClearForNotification);
    2015          21 : }
    2016             : 
    2017             : // XRowSetApproveBroadcaster
    2018           1 : void SAL_CALL ORowSet::addRowSetApproveListener( const Reference< XRowSetApproveListener >& listener ) throw(RuntimeException, std::exception)
    2019             : {
    2020           1 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
    2021             : 
    2022           1 :     ::osl::MutexGuard aGuard( m_aColumnsMutex );
    2023             : 
    2024           1 :     m_aApproveListeners.addInterface(listener);
    2025           1 : }
    2026             : 
    2027           1 : void SAL_CALL ORowSet::removeRowSetApproveListener( const Reference< XRowSetApproveListener >& listener ) throw(RuntimeException, std::exception)
    2028             : {
    2029           1 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
    2030             : 
    2031           1 :     ::osl::MutexGuard aGuard( m_aColumnsMutex );
    2032             : 
    2033           1 :     m_aApproveListeners.removeInterface(listener);
    2034           1 : }
    2035             : 
    2036             : // XRowsChangeBroadcaster
    2037           1 : void SAL_CALL ORowSet::addRowsChangeListener( const Reference< XRowsChangeListener >& listener ) throw(RuntimeException, std::exception)
    2038             : {
    2039           1 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
    2040             : 
    2041           1 :     ::osl::MutexGuard aGuard( m_aColumnsMutex );
    2042             : 
    2043           1 :     m_aRowsChangeListener.addInterface(listener);
    2044           1 : }
    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           2 : Reference< XResultSet > SAL_CALL ORowSet::createResultSet(  ) throw(SQLException, RuntimeException, std::exception)
    2057             : {
    2058           2 :     ::osl::MutexGuard aGuard( m_aColumnsMutex );
    2059             : 
    2060           2 :     if(m_xStatement.is())
    2061             :     {
    2062           2 :         ORowSetClone* pClone = new ORowSetClone( m_aContext, *this, m_pMutex );
    2063           2 :         Reference< XResultSet > xRet(pClone);
    2064           2 :         m_aClones.push_back(WeakReferenceHelper(xRet));
    2065           2 :         return xRet;
    2066             :     }
    2067           0 :     return Reference< XResultSet >();
    2068             : }
    2069             : 
    2070             : // ::com::sun::star::util::XCancellable
    2071           1 : void SAL_CALL ORowSet::cancel(  ) throw(RuntimeException, std::exception)
    2072             : {
    2073           1 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
    2074           1 : }
    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           1 : void ORowSet::notifyRowSetAndClonesRowDelete( const Any& _rBookmark )
    2132             : {
    2133             :     // notify ourself
    2134           1 :     onDeleteRow( _rBookmark );
    2135             :     // notify the clones
    2136           1 :     connectivity::OWeakRefArray::iterator aEnd = m_aClones.end();
    2137           1 :     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           1 : }
    2148             : 
    2149           1 : void ORowSet::notifyRowSetAndClonesRowDeleted( const Any& _rBookmark, sal_Int32 _nPos )
    2150             : {
    2151             :     // notify ourself
    2152           1 :     onDeletedRow( _rBookmark, _nPos );
    2153             :     // notify the clones
    2154           1 :     connectivity::OWeakRefArray::iterator aEnd = m_aClones.end();
    2155           1 :     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           1 : }
    2166             : 
    2167          32 : Reference< XConnection >  ORowSet::calcConnection(const Reference< XInteractionHandler >& _rxHandler) throw( SQLException, RuntimeException )
    2168             : {
    2169          32 :     MutexGuard aGuard(m_aMutex);
    2170          32 :     if (!m_xActiveConnection.is())
    2171             :     {
    2172          13 :         Reference< XConnection > xNewConn;
    2173          13 :         if ( !m_aDataSourceName.isEmpty() )
    2174             :         {
    2175          13 :             Reference< XDatabaseContext > xDatabaseContext( DatabaseContext::create(m_aContext) );
    2176             :             try
    2177             :             {
    2178          13 :                 Reference< XDataSource > xDataSource( xDatabaseContext->getByName( m_aDataSourceName ), UNO_QUERY_THROW );
    2179             : 
    2180             :                 // try connecting with the interaction handler
    2181          26 :                 Reference< XCompletedConnection > xComplConn( xDataSource, UNO_QUERY );
    2182          13 :                 if ( _rxHandler.is() && xComplConn.is() )
    2183             :                 {
    2184           4 :                     xNewConn = xComplConn->connectWithCompletion( _rxHandler );
    2185             :                 }
    2186             :                 else
    2187             :                 {
    2188           9 :                     xNewConn = xDataSource->getConnection( m_aUser, m_aPassword );
    2189          13 :                 }
    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          13 :             }
    2202             :         }
    2203          13 :         setActiveConnection(xNewConn);
    2204          13 :         m_bOwnConnection = sal_True;
    2205             :     }
    2206          32 :     return m_xActiveConnection;
    2207             : }
    2208             : 
    2209         240 : Reference< XNameAccess > ORowSet::impl_getTables_throw()
    2210             : {
    2211         240 :     Reference< XNameAccess > xTables;
    2212             : 
    2213         480 :     Reference< XTablesSupplier >  xTablesAccess( m_xActiveConnection, UNO_QUERY );
    2214         240 :     if ( xTablesAccess.is() )
    2215             :     {
    2216         240 :         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         480 :     return xTables;
    2246             : }
    2247             : 
    2248         266 : void ORowSet::impl_resetTables_nothrow()
    2249             : {
    2250         266 :     if ( !m_pTables )
    2251         532 :         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          29 : sal_Bool ORowSet::impl_initComposer_throw( OUString& _out_rCommandToExecute )
    2266             : {
    2267          29 :     sal_Bool bUseEscapeProcessing = impl_buildActiveCommand_throw( );
    2268          18 :     _out_rCommandToExecute = m_aActiveCommand;
    2269          18 :     if ( !bUseEscapeProcessing )
    2270           0 :         return bUseEscapeProcessing;
    2271             : 
    2272          18 :     if (m_bCommandFacetsDirty)
    2273          18 :         m_xComposer = NULL;
    2274             : 
    2275          18 :     Reference< XMultiServiceFactory > xFactory( m_xActiveConnection, UNO_QUERY );
    2276          18 :     if ( !m_xComposer.is() && xFactory.is() )
    2277             :     {
    2278             :         try
    2279             :         {
    2280          18 :             m_xComposer.set( xFactory->createInstance( SERVICE_NAME_SINGLESELECTQUERYCOMPOSER ), UNO_QUERY_THROW );
    2281             :         }
    2282           0 :         catch (const Exception& ) { m_xComposer = NULL; }
    2283             :     }
    2284          18 :     if ( !m_xComposer.is() )
    2285           0 :         m_xComposer = new OSingleSelectQueryComposer( impl_getTables_throw(), m_xActiveConnection, m_aContext );
    2286             : 
    2287          18 :     m_xComposer->setCommand( m_aCommand,m_nCommandType );
    2288          18 :     m_aActiveCommand = m_xComposer->getQuery();
    2289             : 
    2290          18 :     m_xComposer->setFilter( m_bApplyFilter ? m_aFilter : OUString() );
    2291          18 :     m_xComposer->setHavingClause( m_bApplyFilter ? m_aHavingClause : OUString() );
    2292             : 
    2293          18 :     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          18 :     m_xComposer->setOrder( m_aOrder );
    2302          18 :     m_xComposer->setGroup( m_aGroupBy );
    2303             : 
    2304          18 :     if ( !m_xColumns.is() )
    2305             :     {
    2306          18 :         Reference< XColumnsSupplier > xCols( m_xComposer, UNO_QUERY_THROW );
    2307          18 :         m_xColumns = xCols->getColumns();
    2308             :     }
    2309             : 
    2310          18 :     impl_initParametersContainer_nothrow();
    2311             : 
    2312          18 :     _out_rCommandToExecute = m_xComposer->getQueryWithSubstitution();
    2313             : 
    2314          18 :     m_bCommandFacetsDirty = sal_False;
    2315             : 
    2316          18 :     return bUseEscapeProcessing;
    2317             : }
    2318             : 
    2319          29 : 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          29 :     sal_Bool bDoEscapeProcessing = m_bUseEscapeProcessing;
    2325             : 
    2326          29 :     m_aActiveCommand = "";
    2327          29 :     OUString sCommand;
    2328             : 
    2329          29 :     if ( m_aCommand.isEmpty() )
    2330           0 :         return bDoEscapeProcessing;
    2331             : 
    2332          29 :     switch (m_nCommandType)
    2333             :     {
    2334             :         case CommandType::TABLE:
    2335             :         {
    2336          22 :             impl_resetTables_nothrow();
    2337          22 :             if ( bDoEscapeProcessing )
    2338             :             {
    2339          22 :                 Reference< XNameAccess > xTables( impl_getTables_throw() );
    2340          22 :                 if ( xTables->hasByName(m_aCommand) )
    2341             :                 {
    2342             :                 }
    2343             :                 else
    2344             :                 {
    2345          11 :                     OUString sMessage( DBACORE_RESSTRING( RID_STR_TABLE_DOES_NOT_EXIST ) );
    2346          22 :                     throwGenericSQLException(sMessage.replaceAll( "$table$", m_aCommand ),*this);
    2347          22 :                 }
    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          11 :         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           7 :             sCommand = m_aCommand;
    2401           7 :             break;
    2402             :     }
    2403             : 
    2404          18 :     m_aActiveCommand = sCommand;
    2405             : 
    2406          18 :     if ( m_aActiveCommand.isEmpty() && !bDoEscapeProcessing )
    2407           0 :         ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_SQL_COMMAND ), SQL_FUNCTION_SEQUENCE_ERROR, *this );
    2408             : 
    2409          29 :     return bDoEscapeProcessing;
    2410             : }
    2411             : 
    2412          18 : void ORowSet::impl_initParametersContainer_nothrow()
    2413             : {
    2414             :     OSL_PRECOND( !m_pParameters.is(), "ORowSet::impl_initParametersContainer_nothrow: already initialized the parameters!" );
    2415             : 
    2416          18 :     m_pParameters = new param::ParameterWrapperContainer( m_xComposer.get() );
    2417             :     // copy the premature parameters into the final ones
    2418          18 :     size_t nParamCount( ::std::min( m_pParameters->size(), m_aPrematureParamValues.get().size() ) );
    2419          21 :     for ( size_t i=0; i<nParamCount; ++i )
    2420             :     {
    2421           3 :         (*m_pParameters)[i] = m_aPrematureParamValues.get()[i];
    2422             :     }
    2423          18 : }
    2424             : 
    2425         246 : void ORowSet::impl_disposeParametersContainer_nothrow()
    2426             : {
    2427         246 :     if ( !m_pParameters.is() )
    2428         474 :         return;
    2429             : 
    2430             :     // copy the actual values to our "premature" ones, to preserve them for later use
    2431          18 :     size_t nParamCount( m_pParameters->size() );
    2432          18 :     m_aPrematureParamValues.get().resize( nParamCount );
    2433          21 :     for ( size_t i=0; i<nParamCount; ++i )
    2434             :     {
    2435           3 :         m_aPrematureParamValues.get()[i] = (*m_pParameters)[i];
    2436             :     }
    2437             : 
    2438          18 :     m_pParameters->dispose();
    2439          18 :     m_pParameters = NULL;
    2440             : }
    2441             : 
    2442          11 : ORowSetValue& ORowSet::getParameterStorage(sal_Int32 parameterIndex)
    2443             : {
    2444          11 :     ::connectivity::checkDisposed( ORowSet_BASE1::rBHelper.bDisposed );
    2445          11 :     if ( parameterIndex < 1 )
    2446           0 :         throwInvalidIndexException( *this );
    2447             : 
    2448          11 :     if ( m_aParametersSet.size() < (size_t)parameterIndex )
    2449           2 :         m_aParametersSet.resize( parameterIndex ,false);
    2450          11 :     m_aParametersSet[parameterIndex - 1] = true;
    2451             : 
    2452          11 :     if ( m_pParameters.is() )
    2453             :     {
    2454           9 :         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           2 :             impl_disposeParametersContainer_nothrow();
    2458           9 :         if ( m_pParameters.is() )
    2459             :         {
    2460           7 :             if ( (size_t)parameterIndex > m_pParameters->size() )
    2461           0 :                 throwInvalidIndexException( *this );
    2462           7 :             return (*m_pParameters)[ parameterIndex - 1 ];
    2463             :         }
    2464             :     }
    2465             : 
    2466           4 :     if ( m_aPrematureParamValues.get().size() < (size_t)parameterIndex )
    2467           3 :         m_aPrematureParamValues.get().resize( parameterIndex );
    2468           4 :     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           5 : void ORowSet::setParameter(sal_Int32 parameterIndex, const ORowSetValue& x)
    2486             : {
    2487           5 :     ::osl::MutexGuard aGuard( m_aColumnsMutex );
    2488             : 
    2489           5 :     getParameterStorage( parameterIndex ) = x;
    2490           5 :     m_bParametersDirty = true;
    2491           5 : }
    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           5 : void SAL_CALL ORowSet::setString( sal_Int32 parameterIndex, const OUString& x ) throw(SQLException, RuntimeException, std::exception)
    2529             : {
    2530           5 :     setParameter(parameterIndex,x);
    2531           5 : }
    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           1 : void SAL_CALL ORowSet::setObject( sal_Int32 parameterIndex, const Any& x ) throw(SQLException, RuntimeException, std::exception)
    2596             : {
    2597           1 :     if ( ::dbtools::implSetObject( this, parameterIndex, x ) )
    2598             :     {
    2599           1 :         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           1 : }
    2606             : 
    2607           1 : void SAL_CALL ORowSet::setObjectWithInfo( sal_Int32 parameterIndex, const Any& x, sal_Int32 targetSqlType, sal_Int32 /*scale*/ ) throw(SQLException, RuntimeException, std::exception)
    2608             : {
    2609           1 :     ::osl::MutexGuard aGuard( m_aColumnsMutex );
    2610           1 :     ORowSetValue& rParamValue( getParameterStorage( parameterIndex ) );
    2611           1 :     setObject( parameterIndex, x );
    2612           1 :     rParamValue.setTypeKind( targetSqlType );
    2613           1 : }
    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           1 : void SAL_CALL ORowSet::clearParameters(  ) throw(SQLException, RuntimeException, std::exception)
    2636             : {
    2637           1 :     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
    2638             : 
    2639           1 :     ::osl::MutexGuard aGuard( m_aColumnsMutex );
    2640             : 
    2641           1 :     size_t nParamCount( m_pParameters.is() ? m_pParameters->size() : m_aPrematureParamValues.get().size() );
    2642           1 :     for ( size_t i=1; i<=nParamCount; ++i )
    2643           0 :         getParameterStorage( (sal_Int32)i ).setNull();
    2644           1 :     m_aParametersSet.clear();
    2645           1 : }
    2646             : 
    2647           2 : Any SAL_CALL ORowSet::getWarnings(  ) throw (SQLException, RuntimeException, std::exception)
    2648             : {
    2649           2 :     return m_aWarnings.getWarnings();
    2650             : }
    2651             : 
    2652           2 : void SAL_CALL ORowSet::clearWarnings(  ) throw (SQLException, RuntimeException, std::exception)
    2653             : {
    2654           2 :     m_aWarnings.clearWarnings();
    2655           2 : }
    2656             : 
    2657         130 : void ORowSet::doCancelModification( )
    2658             : {
    2659         130 :     if ( isModification() )
    2660             :     {
    2661             :         // read-only flag restored
    2662           0 :         impl_restoreDataColumnsWriteable_throw();
    2663           0 :         m_pCache->cancelRowModification();
    2664             :     }
    2665         130 :     m_bModified = sal_False;
    2666         130 :     m_bIsInsertRow = sal_False;
    2667         130 : }
    2668             : 
    2669         262 : sal_Bool ORowSet::isModification( )
    2670             : {
    2671         262 :     return isNew();
    2672             : }
    2673             : 
    2674         133 : sal_Bool ORowSet::isModified( )
    2675             : {
    2676         133 :     return m_bModified;
    2677             : }
    2678             : 
    2679         394 : sal_Bool ORowSet::isNew( )
    2680             : {
    2681         394 :     return m_bNew;
    2682             : }
    2683             : 
    2684         135 : sal_Bool ORowSet::isPropertyChangeNotificationEnabled() const
    2685             : {
    2686         135 :     return m_bPropChangeNotifyEnabled;
    2687             : }
    2688             : 
    2689           6 : void ORowSet::checkUpdateIterator()
    2690             : {
    2691           6 :     if(!m_bIsInsertRow)
    2692             :     {
    2693           5 :         m_pCache->setUpdateIterator(m_aCurrentRow);
    2694           5 :         m_aCurrentRow = m_pCache->m_aInsertRow;
    2695           5 :         m_bIsInsertRow = sal_True;
    2696             :     }
    2697           6 : }
    2698             : 
    2699           6 : void ORowSet::checkUpdateConditions(sal_Int32 columnIndex)
    2700             : {
    2701           6 :     checkCache();
    2702           6 :     if ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY)
    2703           0 :         ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_RESULT_IS_READONLY ), SQL_GENERAL_ERROR, *this );
    2704             : 
    2705           6 :     if ( rowDeleted() )
    2706           0 :         ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_ROW_ALREADY_DELETED ), SQL_INVALID_CURSOR_POSITION, *this );
    2707             : 
    2708           6 :     if ( m_aCurrentRow.isNull() )
    2709           0 :         ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_INVALID_CURSOR_STATE ), SQL_INVALID_CURSOR_STATE, *this );
    2710             : 
    2711           6 :     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           6 : }
    2714             : 
    2715           1 : void SAL_CALL ORowSet::refreshRow(  ) throw(SQLException, RuntimeException, std::exception)
    2716             : {
    2717             : 
    2718           1 :     ORowSetNotifier aNotifier( this );
    2719             :         // this will call cancelRowModification on the cache if necessary
    2720             : 
    2721             :     // notification order:
    2722           1 :     if ( m_bModified && m_pCache )
    2723           1 :         implCancelRowUpdates( sal_False ); // do _not_ notify the IsModify - will do this ourself below
    2724             : 
    2725             :     // - column values
    2726           1 :     ORowSetBase::refreshRow();
    2727             : 
    2728             :     // - IsModified
    2729             :     // - IsNew
    2730           1 :     aNotifier.fire( );
    2731           1 : }
    2732             : 
    2733           3 : void ORowSet::impl_rebuild_throw(::osl::ResettableMutexGuard& _rGuard)
    2734             : {
    2735           3 :     Reference< XResultSet > xResultSet;
    2736           3 :     if(m_bParametersDirty)
    2737             :     {
    2738           2 :         xResultSet = impl_prepareAndExecute_throw();
    2739             :     }
    2740             :     else
    2741             :     {
    2742           1 :         xResultSet = m_xStatement->executeQuery();
    2743           1 :         m_pCache->reset(xResultSet);
    2744             :     }
    2745           3 :     m_aWarnings.setExternalWarnings( Reference< XWarningsSupplier >( xResultSet, UNO_QUERY ) );
    2746           3 :     notifyAllListeners(_rGuard);
    2747           3 : }
    2748             : 
    2749             : // ***********************************************************
    2750             : //  ORowSetClone
    2751             : // ***********************************************************
    2752             : 
    2753           2 : 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           2 :              ,m_bIsBookmarkable(sal_True)
    2760             : {
    2761             : 
    2762           2 :     m_nResultSetType        = rParent.m_nResultSetType;
    2763           2 :     m_nResultSetConcurrency = ResultSetConcurrency::READ_ONLY;
    2764           2 :     m_pMySelf               = this;
    2765           2 :     m_bClone                = sal_True;
    2766           2 :     m_bBeforeFirst          = rParent.m_bBeforeFirst;
    2767           2 :     m_bAfterLast            = rParent.m_bAfterLast;
    2768           2 :     m_pCache                = rParent.m_pCache;
    2769           2 :     m_aBookmark             = rParent.m_aBookmark;
    2770           2 :     m_aCurrentRow           = m_pCache->createIterator(this);
    2771           2 :     m_xNumberFormatTypes    = rParent.m_xNumberFormatTypes;
    2772             : 
    2773           2 :     m_aOldRow = m_pCache->registerOldRow();
    2774             : 
    2775           2 :     ::rtl::Reference< ::connectivity::OSQLColumns> aColumns = new ::connectivity::OSQLColumns();
    2776           4 :     ::std::vector< OUString> aNames;
    2777             : 
    2778           4 :     OUString aDescription;
    2779           4 :     Locale aLocale = SvtSysLocale().GetLanguageTag().getLocale();
    2780             : 
    2781           2 :     if ( rParent.m_pColumns )
    2782             :     {
    2783           2 :         Sequence< OUString> aSeq = rParent.m_pColumns->getElementNames();
    2784           2 :         const OUString* pIter    = aSeq.getConstArray();
    2785           2 :         const OUString* pEnd     = pIter + aSeq.getLength();
    2786           2 :         aColumns->get().reserve(aSeq.getLength()+1);
    2787          44 :         for(sal_Int32 i=1;pIter != pEnd ;++pIter,++i)
    2788             :         {
    2789          42 :             Reference<XPropertySet> xColumn;
    2790          42 :             rParent.m_pColumns->getByName(*pIter) >>= xColumn;
    2791          42 :             if(xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_DESCRIPTION))
    2792          42 :                 aDescription = comphelper::getString(xColumn->getPropertyValue(PROPERTY_DESCRIPTION));
    2793             : 
    2794          84 :             OUString sParseLabel;
    2795          42 :             xColumn->getPropertyValue(PROPERTY_LABEL) >>= sParseLabel;
    2796          42 :             ORowSetColumn* pColumn = new ORowSetColumn( rParent.getMetaData(),
    2797             :                                                                 this,
    2798             :                                                                 i,
    2799          42 :                                                                 rParent.m_xActiveConnection->getMetaData(),
    2800             :                                                                 aDescription,
    2801             :                                                                 sParseLabel,
    2802         126 :                                                                 m_aCurrentRow);
    2803          42 :             aColumns->get().push_back(pColumn);
    2804          42 :             pColumn->setName(*pIter);
    2805          42 :             aNames.push_back(*pIter);
    2806          42 :             m_aDataColumns.push_back(pColumn);
    2807             : 
    2808          42 :             pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ALIGN,xColumn->getPropertyValue(PROPERTY_ALIGN));
    2809          42 :             sal_Int32 nFormatKey = 0;
    2810          42 :             xColumn->getPropertyValue(PROPERTY_NUMBERFORMAT) >>= nFormatKey;
    2811          42 :             if(!nFormatKey && xColumn.is() && m_xNumberFormatTypes.is())
    2812           0 :                 nFormatKey = ::dbtools::getDefaultNumberFormat(xColumn,m_xNumberFormatTypes,aLocale);
    2813          42 :             pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_NUMBERFORMAT,makeAny(nFormatKey));
    2814          42 :             pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_RELATIVEPOSITION,xColumn->getPropertyValue(PROPERTY_RELATIVEPOSITION));
    2815          42 :             pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_WIDTH,xColumn->getPropertyValue(PROPERTY_WIDTH));
    2816          42 :             pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_HIDDEN,xColumn->getPropertyValue(PROPERTY_HIDDEN));
    2817          42 :             pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_CONTROLMODEL,xColumn->getPropertyValue(PROPERTY_CONTROLMODEL));
    2818          42 :             pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_HELPTEXT,xColumn->getPropertyValue(PROPERTY_HELPTEXT));
    2819          42 :             pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_CONTROLDEFAULT,xColumn->getPropertyValue(PROPERTY_CONTROLDEFAULT));
    2820             : 
    2821          44 :         }
    2822             :     }
    2823           4 :     Reference<XDatabaseMetaData> xMeta = rParent.m_xActiveConnection->getMetaData();
    2824           2 :     m_pColumns = new ORowSetDataColumns(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers(),
    2825           2 :                                         aColumns,*this,m_aMutex,aNames);
    2826             : 
    2827           2 :     sal_Int32 nRT   = PropertyAttribute::READONLY   | PropertyAttribute::TRANSIENT;
    2828             : 
    2829             :     // sdb.RowSet Properties
    2830           2 :     registerMayBeVoidProperty(PROPERTY_ACTIVE_CONNECTION,PROPERTY_ID_ACTIVE_CONNECTION, PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY,   &rParent.m_aActiveConnection,   ::getCppuType(static_cast< Reference< XConnection >* >(0)));
    2831           2 :     registerProperty(PROPERTY_RESULTSETCONCURRENCY, PROPERTY_ID_RESULTSETCONCURRENCY,   PropertyAttribute::READONLY,    &m_nResultSetConcurrency,::getCppuType(static_cast< sal_Int32*>(0)));
    2832           2 :     registerProperty(PROPERTY_RESULTSETTYPE,        PROPERTY_ID_RESULTSETTYPE,          PropertyAttribute::READONLY,    &m_nResultSetType,      ::getCppuType(static_cast< sal_Int32*>(0)));
    2833           2 :     registerProperty(PROPERTY_FETCHDIRECTION,       PROPERTY_ID_FETCHDIRECTION,         PropertyAttribute::TRANSIENT,   &m_nFetchDirection,     ::getCppuType(static_cast< sal_Int32*>(0)));
    2834           2 :     registerProperty(PROPERTY_FETCHSIZE,            PROPERTY_ID_FETCHSIZE,              PropertyAttribute::TRANSIENT,   &m_nFetchSize,          ::getCppuType(static_cast< sal_Int32*>(0)));
    2835           4 :     registerProperty(PROPERTY_ISBOOKMARKABLE,       PROPERTY_ID_ISBOOKMARKABLE,         nRT,                            &m_bIsBookmarkable,      ::getBooleanCppuType());
    2836           2 : }
    2837             : 
    2838           4 : ORowSetClone::~ORowSetClone()
    2839             : {
    2840           4 : }
    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          13 : Any ORowSetClone::queryInterface( const Type & rType ) throw (RuntimeException, std::exception)
    2850             : {
    2851          13 :     Any aRet = ORowSetBase::queryInterface(rType);
    2852          13 :     if(!aRet.hasValue())
    2853           7 :         aRet = OSubComponent::queryInterface(rType);
    2854          13 :     return aRet;
    2855             : }
    2856             : 
    2857         159 : void ORowSetClone::acquire() throw()
    2858             : {
    2859         159 :     OSubComponent::acquire();
    2860         159 : }
    2861             : 
    2862         157 : void ORowSetClone::release() throw()
    2863             : {
    2864         157 :     OSubComponent::release();
    2865         157 : }
    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           2 : void ORowSetClone::disposing()
    2888             : {
    2889           2 :     MutexGuard aGuard( m_aMutex );
    2890           2 :     ORowSetBase::disposing();
    2891             : 
    2892           2 :     m_pParent   = NULL;
    2893           2 :     m_pMutex    = &m_aMutex; // this must be done here because someone could hold a ref to us and try to do something
    2894           2 :     OSubComponent::disposing();
    2895           2 : }
    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           1 : ::cppu::IPropertyArrayHelper* ORowSetClone::createArrayHelper( ) const
    2910             : {
    2911           1 :     Sequence< Property > aProps;
    2912           1 :     describeProperties(aProps);
    2913           1 :     return new ::cppu::OPropertyArrayHelper(aProps);
    2914             : }
    2915             : 
    2916             : // cppu::OPropertySetHelper
    2917           2 : ::cppu::IPropertyArrayHelper& SAL_CALL ORowSetClone::getInfoHelper()
    2918             : {
    2919             :     typedef ::comphelper::OPropertyArrayUsageHelper<ORowSetClone> ORowSetClone_PROP;
    2920           2 :     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          16 : void ORowSetClone::doCancelModification( )
    2959             : {
    2960          16 : }
    2961             : 
    2962          16 : sal_Bool ORowSetClone::isModification( )
    2963             : {
    2964          16 :     return sal_False;
    2965             : }
    2966             : 
    2967          16 : sal_Bool ORowSetClone::isModified( )
    2968             : {
    2969          16 :     return sal_False;
    2970             : }
    2971             : 
    2972          16 : sal_Bool ORowSetClone::isNew( )
    2973             : {
    2974          16 :     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