Tag: cws_src680_dba25 User: oj Date: 05/03/03 23:25:36 Modified: /dba/dbaccess/source/core/dataaccess/ connection.cxx, connection.hxx
Log: #i43912# connection now supports also XGroupsSupplier and XUsersSupplier if the master tables supports it File Changes: Directory: /dba/dbaccess/source/core/dataaccess/ ================================================ File [changed]: connection.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/connection.cxx?r1=1.40&r2=1.40.36.1 Delta lines: +76 -43 --------------------- --- connection.cxx 21 Jan 2005 17:02:45 -0000 1.40 +++ connection.cxx 4 Mar 2005 07:25:33 -0000 1.40.36.1 @@ -2,9 +2,9 @@ * * $RCSfile: connection.cxx,v $ * - * $Revision: 1.40 $ + * $Revision: 1.40.36.1 $ * - * last change: $Author: kz $ $Date: 2005/01/21 17:02:45 $ + * last change: $Author: oj $ $Date: 2005/03/04 07:25:33 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -360,6 +360,8 @@ ,m_pTables(NULL) ,m_pViews(NULL) ,m_bSupportsViews(sal_False) + ,m_bSupportsUsers(sal_False) + ,m_bSupportsGroups(sal_False) { DBG_CTOR(OConnection,NULL); osl_incrementInterlockedCount(&m_refCount); @@ -425,9 +427,7 @@ // some dbs doesn't support this type so we should ask if a XViewsSupplier is supported if(!m_bSupportsViews) { - Reference< XViewsSupplier > xMaster; - m_xMasterTables = ::dbtools::getDataDefinitionByURLAndConnection(xMeta->getURL(),m_xMasterConnection,m_xORB); - xMaster.set(m_xMasterTables,UNO_QUERY); + Reference< XViewsSupplier > xMaster(getMasterTables(),UNO_QUERY); if (xMaster.is() && xMaster->getViews().is()) m_bSupportsViews = sal_True; @@ -438,6 +438,9 @@ m_pViews->addContainerListener(m_pTables); m_pTables->addContainerListener(m_pViews); } + m_bSupportsUsers = Reference< XUsersSupplier> (getMasterTables(),UNO_QUERY).is(); + m_bSupportsGroups = Reference< XGroupsSupplier> (getMasterTables(),UNO_QUERY).is(); + } } catch(Exception&) @@ -531,7 +534,7 @@ //-------------------------------------------------------------------------- Sequence< Type > OConnection::getTypes() throw (RuntimeException) { - if ( m_bSupportsViews ) + if ( m_bSupportsViews && m_bSupportsUsers && m_bSupportsGroups ) return concatSequences(OSubComponent::getTypes(), OConnection_Base::getTypes()); // here views are supported @@ -539,13 +542,30 @@ Sequence<Type> aConTypes = OConnection_Base::getTypes(); sal_Int32 nSize = aTypes.getLength(); aTypes.realloc(aTypes.getLength() + aConTypes.getLength() - 1); - Type* pBegin = aConTypes.getArray(); - Type* pEnd = pBegin + aConTypes.getLength(); - Type aTypeToHide = getCppuType( (Reference<XViewsSupplier>*)0); - for (; pBegin != pEnd; ++pBegin) + Type* pIter = aConTypes.getArray(); + Type* pEnd = pIter + aConTypes.getLength(); + Type aViewToHide = getCppuType( (Reference<XViewsSupplier>*)0); + Type aGroupToHide = getCppuType( (Reference<XGroupsSupplier>*)0); + Type aUserToHide = getCppuType( (Reference<XUsersSupplier>*)0); + for (; pIter != pEnd; ++pIter ) + { + if ( *pIter == aViewToHide ) + { + if ( m_bSupportsViews ) + aTypes.getArray()[nSize++] = *pIter; + } + else if ( *pIter == aGroupToHide ) + { + if ( m_bSupportsGroups ) + aTypes.getArray()[nSize++] = *pIter; + } + else if ( *pIter == aUserToHide ) { - if(*pBegin != aTypeToHide) - aTypes.getArray()[nSize++] = *pBegin; + if ( m_bSupportsUsers ) + aTypes.getArray()[nSize++] = *pIter; + } + else + aTypes.getArray()[nSize++] = *pIter; } return aTypes; } @@ -562,6 +582,10 @@ { if(!m_bSupportsViews && rType == getCppuType( (Reference<XViewsSupplier>*)0)) return Any(); + else if(!m_bSupportsUsers && rType == getCppuType( (Reference<XUsersSupplier>*)0)) + return Any(); + else if(!m_bSupportsGroups && rType == getCppuType( (Reference<XGroupsSupplier>*)0)) + return Any(); Any aReturn = OSubComponent::queryInterface( rType ); if (!aReturn.hasValue()) { @@ -661,21 +685,7 @@ { if (!m_pTables->isInitialized()) { - - // check if out "master connection" can supply tables - if(!m_xMasterTables.is()) - { - try - { - Reference<XDatabaseMetaData> xMeta = getMetaData(); - if ( xMeta.is() ) - m_xMasterTables = ::dbtools::getDataDefinitionByURLAndConnection(xMeta->getURL(),m_xMasterConnection,m_xORB); - } - catch(SQLException&) - { - } - } - + getMasterTables(); if (m_xMasterTables.is() && m_xMasterTables->getTables().is()) { // yes -> wrap them @@ -692,20 +702,7 @@ if (!m_pViews->isInitialized()) { // check if out "master connection" can supply tables - Reference< XViewsSupplier > xMaster(m_xMasterTables,UNO_QUERY); - if(!m_xMasterTables.is()) - { - try - { - Reference<XDatabaseMetaData> xMeta = getMetaData(); - if ( xMeta.is() ) - m_xMasterTables = ::dbtools::getDataDefinitionByURLAndConnection(xMeta->getURL(),m_xMasterConnection,m_xORB); - xMaster.set(m_xMasterTables,UNO_QUERY); - } - catch(SQLException&) - { - } - } + Reference< XViewsSupplier > xMaster(getMasterTables(),UNO_QUERY); if (xMaster.is() && xMaster->getViews().is()) m_pViews->construct(xMaster->getViews(),m_aTableFilter, m_aTableTypeFilter); @@ -804,6 +801,42 @@ return aRet; } // ----------------------------------------------------------------------------- +Reference< XTablesSupplier > OConnection::getMasterTables() +{ +// check if out "master connection" can supply tables + if(!m_xMasterTables.is()) + { + try + { + Reference<XDatabaseMetaData> xMeta = getMetaData(); + if ( xMeta.is() ) + m_xMasterTables = ::dbtools::getDataDefinitionByURLAndConnection(xMeta->getURL(),m_xMasterConnection,m_xORB); + } + catch(SQLException&) + { + } + } + return m_xMasterTables; +} +// ----------------------------------------------------------------------------- +// XUsersSupplier +Reference< XNameAccess > SAL_CALL OConnection::getUsers( ) throw(RuntimeException) +{ + MutexGuard aGuard(m_aMutex); + checkDisposed(); + + Reference<XUsersSupplier> xUsr(getMasterTables(),UNO_QUERY); + return xUsr.is() ? xUsr->getUsers() : Reference< XNameAccess >(); +} +// ----------------------------------------------------------------------------- +// XGroupsSupplier +Reference< XNameAccess > SAL_CALL OConnection::getGroups( ) throw(RuntimeException) +{ + MutexGuard aGuard(m_aMutex); + checkDisposed(); + Reference<XGroupsSupplier> xGrp(getMasterTables(),UNO_QUERY); + return xGrp.is() ? xGrp->getGroups() : Reference< XNameAccess >(); +} //........................................................................ } // namespace dbaccess //........................................................................ File [changed]: connection.hxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/connection.hxx?r1=1.20&r2=1.20.102.1 Delta lines: +23 -6 -------------------- --- connection.hxx 2 Aug 2004 15:08:25 -0000 1.20 +++ connection.hxx 4 Mar 2005 07:25:33 -0000 1.20.102.1 @@ -2,9 +2,9 @@ * * $RCSfile: connection.hxx,v $ * - * $Revision: 1.20 $ + * $Revision: 1.20.102.1 $ * - * last change: $Author: hr $ $Date: 2004/08/02 15:08:25 $ + * last change: $Author: oj $ $Date: 2005/03/04 07:25:33 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -79,11 +79,17 @@ #ifndef _COM_SUN_STAR_SDBCX_XVIEWSSUPPLIER_HPP_ #include <com/sun/star/sdbcx/XViewsSupplier.hpp> #endif +#ifndef _COM_SUN_STAR_SDBCX_XUSERSSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XUsersSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XGROUPSSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XGroupsSupplier.hpp> +#endif #ifndef _COM_SUN_STAR_SDB_XQUERIESSUPPLIER_HPP_ #include <com/sun/star/sdb/XQueriesSupplier.hpp> #endif -#ifndef _CPPUHELPER_IMPLBASE9_HXX_ -#include <cppuhelper/implbase9.hxx> +#ifndef _CPPUHELPER_IMPLBASE11_HXX_ +#include <cppuhelper/implbase11.hxx> #endif #ifndef _DBASHARED_APITOOLS_HXX_ #include "apitools.hxx" @@ -114,7 +120,7 @@ //========================================================================== //========================================================================== -typedef ::cppu::ImplHelper9 < ::com::sun::star::container::XChild +typedef ::cppu::ImplHelper11< ::com::sun::star::container::XChild , ::com::sun::star::sdbcx::XTablesSupplier , ::com::sun::star::sdbcx::XViewsSupplier , ::com::sun::star::sdbc::XConnection @@ -123,6 +129,8 @@ , ::com::sun::star::sdb::XCommandPreparation , ::com::sun::star::lang::XServiceInfo , ::com::sun::star::lang::XMultiServiceFactory + , ::com::sun::star::sdbcx::XUsersSupplier + , ::com::sun::star::sdbcx::XGroupsSupplier > OConnection_Base; class ODatabaseSource; @@ -154,6 +162,8 @@ OViewContainer* m_pViews; ::com::sun::star::uno::Any m_aAdditionalWarnings; // own warnings (appended to the ones got by the master connection) sal_Bool m_bSupportsViews; // true when the getTableTypes return "VIEW" as type + sal_Bool m_bSupportsUsers; + sal_Bool m_bSupportsGroups; protected: virtual ~OConnection(); @@ -229,6 +239,11 @@ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Arguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableServiceNames( ) throw (::com::sun::star::uno::RuntimeException); + // XUsersSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getUsers( ) throw(::com::sun::star::uno::RuntimeException); + // XGroupsSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getGroups( ) throw(::com::sun::star::uno::RuntimeException); + // IRefreshListener virtual void refresh(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rToBeRefreshed); protected: @@ -245,6 +260,8 @@ if ( rBHelper.bDisposed || !m_xConnection.is() ) throw ::com::sun::star::lang::DisposedException(); } + + ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > getMasterTables(); }; //........................................................................ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
