LCOV - code coverage report
Current view: top level - dbaccess/source/core/api - RowSet.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 957 1578 60.6 %
Date: 2014-11-03 Functions: 98 172 57.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10