Tag: cws_src680_dba205b User: fs Date: 2006/08/03 23:46:47 Modified: dba/dbaccess/source/core/api/RowSet.cxx dba/dbaccess/source/core/api/RowSet.hxx
Log: copying the changes from CWS dba204c herein, to prevent later conflicts File Changes: Directory: /dba/dbaccess/source/core/api/ ========================================= File [changed]: RowSet.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/api/RowSet.cxx?r1=1.145&r2=1.145.18.1 Delta lines: +88 -55 --------------------- --- RowSet.cxx 10 Jul 2006 15:03:11 -0000 1.145 +++ RowSet.cxx 4 Aug 2006 06:46:43 -0000 1.145.18.1 @@ -4,9 +4,9 @@ * * $RCSfile: RowSet.cxx,v $ * - * $Revision: 1.145 $ + * $Revision: 1.145.18.1 $ * - * last change: $Author: obo $ $Date: 2006/07/10 15:03:11 $ + * last change: $Author: fs $ $Date: 2006/08/04 06:46:43 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -42,6 +42,9 @@ #ifndef DBACORE_SDBCORETOOLS_HXX #include "sdbcoretools.hxx" #endif +#ifndef DBACCESS_CORE_API_SINGLESELECTQUERYCOMPOSER_HXX +#include "SingleSelectQueryComposer.hxx" +#endif #ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ #include <com/sun/star/beans/PropertyAttribute.hpp> #endif @@ -693,11 +696,7 @@ DELETEZ(m_pCache); - if(m_pTables) - { - m_pTables->dispose(); // clear all references - DELETEZ(m_pTables); - } + impl_resetTables_nothrow(); m_xStatement = NULL; m_xTypeMap = NULL; @@ -1694,9 +1693,16 @@ SQLExceptionInfo aError( ::cppu::getCaughtException() ); OSL_ENSURE( aError.isValid(), "ORowSet::execute_NoApprove_NoNewConn: caught an SQLException which we cannot analyze!" ); - String sInfo( DBA_RES_PARAM( RID_STR_COMMAND_LEADING_TO_ERROR, "$command$", impl_getComposedQuery_throw( false ) ) ); + // append information about what we were actually going to execute + try + { + String sQuery = bUseEscapeProcessing ? impl_getComposedQuery_throw( false ) : m_aActiveCommand; + String sInfo( DBA_RES_PARAM( RID_STR_COMMAND_LEADING_TO_ERROR, "$command$", sQuery ) ); aError.append( SQLExceptionInfo::SQL_CONTEXT, sInfo ); + } + catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); } + // propagate aError.doThrow(); } @@ -2104,34 +2110,26 @@ } return m_xActiveConnection; } + //------------------------------------------------------------------------------ -sal_Bool ORowSet::impl_buildActiveCommand_throw() +Reference< XNameAccess > ORowSet::impl_getTables_throw() { - // create the sql command - // from a table name or get the command out of a query (not a view) - // the last use the command as it is - sal_Bool bDoEscapeProcessing = m_bUseEscapeProcessing; - - m_aActiveCommand = ::rtl::OUString(); - ::rtl::OUString sCommand; - - if ( !m_aCommand.getLength() ) - return bDoEscapeProcessing; - - switch (m_nCommandType) - { - case CommandType::TABLE: - { Reference< XNameAccess > xTables; + Reference< XTablesSupplier > xTablesAccess( m_xActiveConnection, UNO_QUERY ); if ( xTablesAccess.is() ) { xTables.set( xTablesAccess->getTables(), UNO_QUERY_THROW ); } + else if ( m_pTables ) + { + xTables = m_pTables; + } else { - if(!m_xActiveConnection.is()) + if ( !m_xActiveConnection.is() ) throw SQLException(DBA_RES(RID_STR_CONNECTION_INVALID),*this,SQLSTATE_GENERAL,1000,Any() ); + sal_Bool bCase = sal_True; try { @@ -2143,12 +2141,6 @@ DBG_UNHANDLED_EXCEPTION(); } - if ( m_pTables ) - { - m_pTables->dispose(); // clear all references - DELETEZ(m_pTables); - } - m_pTables = new OTableContainer(*this,m_aMutex,m_xActiveConnection,bCase,NULL,NULL); xTables = m_pTables; Sequence< ::rtl::OUString> aTableFilter(1); @@ -2156,6 +2148,48 @@ m_pTables->construct(aTableFilter,Sequence< ::rtl::OUString>()); } + return xTables; +} + +//------------------------------------------------------------------------------ +void ORowSet::impl_resetTables_nothrow() +{ + if ( !m_pTables ) + return; + + try + { + m_pTables->dispose(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + DELETEZ( m_pTables ); +} + +//------------------------------------------------------------------------------ +sal_Bool ORowSet::impl_buildActiveCommand_throw() +{ + // create the sql command + // from a table name or get the command out of a query (not a view) + // the last use the command as it is + sal_Bool bDoEscapeProcessing = m_bUseEscapeProcessing; + + m_aActiveCommand = ::rtl::OUString(); + ::rtl::OUString sCommand; + + if ( !m_aCommand.getLength() ) + return bDoEscapeProcessing; + + switch (m_nCommandType) + { + case CommandType::TABLE: + { + impl_resetTables_nothrow(); + Reference< XNameAccess > xTables( impl_getTables_throw() ); + if ( xTables->hasByName(m_aCommand) ) { Reference< XPropertySet > xTable; @@ -2250,19 +2284,18 @@ //------------------------------------------------------------------------------ ::rtl::OUString ORowSet::impl_getComposedQuery_throw( bool _bForExecution ) { - Reference< XMultiServiceFactory > xFactory( m_xActiveConnection, UNO_QUERY_THROW ); + Reference< XMultiServiceFactory > xFactory( m_xActiveConnection, UNO_QUERY ); + if ( xFactory.is() ) + { try { ::comphelper::disposeComponent( m_xComposer ); m_xComposer.set( xFactory->createInstance( SERVICE_NAME_SINGLESELECTQUERYCOMPOSER ), UNO_QUERY_THROW ); } - catch (const Exception& ) - { - m_xComposer = NULL; + catch (const Exception& ) { m_xComposer = NULL; } } if ( !m_xComposer.is() ) - throwSQLException( "No query composer could be provided by the connection.", SQL_GENERAL_ERROR, *this ); - // TODO: resource + m_xComposer = new OSingleSelectQueryComposer( impl_getTables_throw(), m_xActiveConnection, m_xServiceManager ); m_xComposer->setElementaryQuery( m_aActiveCommand ); File [changed]: RowSet.hxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/api/RowSet.hxx?r1=1.44&r2=1.44.18.1 Delta lines: +22 -3 -------------------- --- RowSet.hxx 10 Jul 2006 15:03:25 -0000 1.44 +++ RowSet.hxx 4 Aug 2006 06:46:44 -0000 1.44.18.1 @@ -4,9 +4,9 @@ * * $RCSfile: RowSet.hxx,v $ * - * $Revision: 1.44 $ + * $Revision: 1.44.18.1 $ * - * last change: $Author: obo $ $Date: 2006/07/10 15:03:25 $ + * last change: $Author: fs $ $Date: 2006/08/04 06:46:44 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -198,6 +198,25 @@ of a query we're based on. */ sal_Bool impl_buildActiveCommand_throw(); + + /** returns the table container of our active connection + + If our connection is able to provide a tables container, this one is returned. + Else, if m_pTables is not <NULL/>, this one will returned. + Else, m_pTables will be constructed and returned. + + @precond m_xActiveConnection is not <NULL/> + @throws ::com::sun::star::sdbc::SQLException + if retrieving or constructing the tables container goes wrong + + @see impl_resetTables_nothrow + */ + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > + impl_getTables_throw(); + + /** cleans up m_pTables, and resets it to <NULL/> + */ + void impl_resetTables_nothrow(); /** prepares and executes our command */ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
