User: rt      
Date: 05/10/24 01:28:26

Modified:
 /dba/dbaccess/source/core/dataaccess/
  connection.cxx

Log:
 INTEGRATION: CWS dba201d (1.44.2); FILE MERGED
 2005/10/05 10:17:29 fs 1.44.2.1: #i55493# corect getTypes to also include 
types from the aggregate

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.44&r2=1.45
Delta lines:  +39 -36
---------------------
--- connection.cxx      23 Sep 2005 12:04:20 -0000      1.44
+++ connection.cxx      24 Oct 2005 08:28:24 -0000      1.45
@@ -342,6 +342,9 @@
 
        try
        {
+        Reference< XTypeProvider > xTest( _rxMaster, UNO_QUERY );
+        xTest->getTypes();
+
                Reference< XProxyFactory > xProxyFactory(
                                
_rxORB->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.reflection.ProxyFactory"))),UNO_QUERY);
                Reference<XAggregation> xAgg = 
xProxyFactory->createProxy(_rxMaster.get());
@@ -504,44 +507,44 @@
        m_aAdditionalWarnings.clear();
 }
 
-// com::sun::star::lang::XTypeProvider
 //--------------------------------------------------------------------------
-Sequence< Type > OConnection::getTypes() throw (RuntimeException)
+namespace
 {
-       if ( m_bSupportsViews && m_bSupportsUsers && m_bSupportsGroups )
-               return concatSequences(OSubComponent::getTypes(), 
OConnection_Base::getTypes());
-
-       // here views are supported
-       Sequence<Type> aTypes = OSubComponent::getTypes();
-       Sequence<Type> aConTypes = OConnection_Base::getTypes();
-       sal_Int32 nSize = aTypes.getLength();
-       aTypes.realloc(aTypes.getLength() + aConTypes.getLength() - 1);
-       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 )
+    struct CompareTypeByName : public ::std::binary_function< Type, Type, bool 
>
                {
-                       if ( m_bSupportsGroups )
-                               aTypes.getArray()[nSize++] = *pIter;
-               }
-               else if ( *pIter == aUserToHide )
+        bool operator() ( const Type& _rLHS, const Type& _rRHS ) const
                {
-                       if ( m_bSupportsUsers )
-                               aTypes.getArray()[nSize++] = *pIter;
+            return _rLHS.getTypeName() < _rRHS.getTypeName();
                }
-               else
-                       aTypes.getArray()[nSize++] = *pIter;
+    };
+    typedef ::std::set< Type, CompareTypeByName > TypeBag;
+
+    void lcl_copyTypes( TypeBag& _out_rTypes, const Sequence< Type >& _rTypes )
+    {
+        ::std::copy( _rTypes.getConstArray(), _rTypes.getConstArray() + 
_rTypes.getLength(),
+            ::std::insert_iterator< TypeBag >( _out_rTypes, 
_out_rTypes.begin() ) );
        }
-       return aTypes;
+}
+// com::sun::star::lang::XTypeProvider
+//--------------------------------------------------------------------------
+Sequence< Type > OConnection::getTypes() throw (RuntimeException)
+{
+    TypeBag aNormalizedTypes;
+
+    lcl_copyTypes( aNormalizedTypes, OSubComponent::getTypes() );
+    lcl_copyTypes( aNormalizedTypes, OConnection_Base::getTypes() );
+    lcl_copyTypes( aNormalizedTypes, 
::connectivity::OConnectionWrapper::getTypes() );
+
+    if ( !m_bSupportsViews )
+        aNormalizedTypes.erase( XViewsSupplier::static_type() );
+    if ( !m_bSupportsUsers )
+        aNormalizedTypes.erase( XUsersSupplier::static_type() );
+    if ( !m_bSupportsGroups )
+        aNormalizedTypes.erase( XGroupsSupplier::static_type() );
+
+    Sequence< Type > aSupportedTypes( aNormalizedTypes.size() );
+    ::std::copy( aNormalizedTypes.begin(), aNormalizedTypes.end(), 
aSupportedTypes.getArray() );
+       return aSupportedTypes;
 }
 
 //--------------------------------------------------------------------------
@@ -554,11 +557,11 @@
 //--------------------------------------------------------------------------
 Any OConnection::queryInterface( const Type & rType ) throw (RuntimeException)
 {
-       if(!m_bSupportsViews && rType == getCppuType( 
(Reference<XViewsSupplier>*)0))
+    if ( !m_bSupportsViews && rType.equals( XViewsSupplier::static_type() ) )
                return Any();
-       else if(!m_bSupportsUsers && rType == getCppuType( 
(Reference<XUsersSupplier>*)0))
+       else if ( !m_bSupportsUsers && rType.equals( 
XUsersSupplier::static_type() ) )
                return Any();
-       else if(!m_bSupportsGroups && rType == getCppuType( 
(Reference<XGroupsSupplier>*)0))
+       else if ( !m_bSupportsGroups && rType.equals( 
XGroupsSupplier::static_type() ) )
                return Any();
        Any aReturn = OSubComponent::queryInterface( rType );
        if (!aReturn.hasValue())




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to