Tag: cws_src680_dba30
User: fs      
Date: 05/04/06 00:20:19

Modified:
 /dba/dbaccess/source/core/dataaccess/
  datasource.cxx, datasource.hxx

Log:
 #i46768# implement a Settings property, wrapping (as PropertyBag) the Info 
property

File Changes:

Directory: /dba/dbaccess/source/core/dataaccess/
================================================

File [changed]: datasource.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/datasource.cxx?r1=1.59&r2=1.59.2.1
Delta lines:  +108 -74
----------------------
--- datasource.cxx      23 Mar 2005 09:46:37 -0000      1.59
+++ datasource.cxx      6 Apr 2005 07:20:16 -0000       1.59.2.1
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: datasource.cxx,v $
  *
- *  $Revision: 1.59 $
+ *  $Revision: 1.59.2.1 $
  *
- *  last change: $Author: vg $ $Date: 2005/03/23 09:46:37 $
+ *  last change: $Author: fs $ $Date: 2005/04/06 07:20:16 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -116,6 +116,18 @@
 #ifndef _COM_SUN_STAR_REFLECTION_XPROXYFACTORY_HPP_
 #include <com/sun/star/reflection/XProxyFactory.hpp>
 #endif
+#ifndef _COM_SUN_STAR_BEANS_NAMEDVALUE_HPP_
+#include <com/sun/star/beans/NamedValue.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYCONTAINER_HPP_
+#include <com/sun/star/beans/XPropertyContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYSTATE_HPP_
+#include <com/sun/star/beans/PropertyState.hpp>
+#endif
 #ifndef _TYPELIB_TYPEDESCRIPTION_HXX_
 #include <typelib/typedescription.hxx>
 #endif
@@ -440,37 +452,16 @@
                osl_incrementInterlockedCount(&_rIter->second.nALiveCount);
        }
 
+    //----------------------------------------------------------------------
        namespace 
        {
-               Sequence< PropertyValue > lcl_filterDriverProperties(const 
Reference< XDriver >& _xDriver,const ::rtl::OUString& _sUrl,const Sequence< 
PropertyValue >& _rDataSourceSettings)
+        //------------------------------------------------------------------
+        Sequence< PropertyValue > lcl_filterDriverProperties( const Reference< 
XDriver >& _xDriver, const ::rtl::OUString& _sUrl,
+            const Sequence< PropertyValue >& _rDataSourceSettings, const 
AsciiPropertyValue* _pKnownSettings )
                {
                        if ( _xDriver.is() )
                        {
                                Sequence< DriverPropertyInfo > 
aDriverInfo(_xDriver->getPropertyInfo(_sUrl,_rDataSourceSettings));
-                               const char* pKnownSettings[] = {
-                                            // known JDBC settings
-                                            "JavaDriverClass",
-                                            // known settings for file-based 
drivers
-                                            "Extension", "CharSet", 
"HeaderLine",
-                                            "FieldDelimiter", 
"StringDelimiter", "DecimalDelimiter",
-                                            "ThousandDelimiter", "ShowDeleted",
-                                            // known ODBC settings
-                                            "SystemDriverSettings", 
"UseCatalog",
-                                            // settings related to auto 
increment handling
-                                            "AutoIncrementCreation", 
"AutoRetrievingStatement", "IsAutoRetrievingEnabled",
-                                            // known Adabas driver setting
-                                            "ShutdownDatabase", 
"DataCacheSizeIncrement", "DataCacheSize",
-                                            "ControlUser", "ControlPassword",
-                                            // known LDAP driver settings
-                                            "HostName", "PortNumber", 
"BaseDN", "MaxRowCount"
-                                            // misc known driver settings
-                                            "ParameterNameSubstitution", 
"AddIndexAppendix",
-                                            // known SDB level settings
-                                            "IgnoreDriverPrivileges", 
"NoNameLengthLimit", "AppendTableAliasName",
-                                            "EnableSQL92Check", 
"BooleanComparisonMode", "TableTypeFilterMode",
-                                            "RespectDriverResultSetType", 
"UseSchemaInSelect", "UseCatalogInSelect"
-                                                                               
};
-                               sal_Int32 nKnownSettings = 
sizeof(pKnownSettings) / sizeof(pKnownSettings[0]);
 
                                const PropertyValue* pDataSourceSetting = 
_rDataSourceSettings.getConstArray();
                                const PropertyValue* pEnd = pDataSourceSetting 
+ _rDataSourceSettings.getLength();
@@ -480,17 +471,17 @@
                                for ( ; pDataSourceSetting != pEnd ; 
++pDataSourceSetting )
                                {
                                        sal_Bool bAllowSetting = sal_False;
-                                       sal_Int32 i;
-                                       for ( i=0; i < nKnownSettings; ++i )
+                    const AsciiPropertyValue* pSetting = _pKnownSettings;
+                                       for ( ; pSetting->AsciiName; ++pSetting 
)
                                        {
-                                               if ( 
!pDataSourceSetting->Name.compareToAscii( pKnownSettings[i] ) )
-                                               {   // the particular setting 
is known
+                                               if ( 
!pDataSourceSetting->Name.compareToAscii( pSetting->AsciiName ) )
+                                               {   // the particular data 
source setting is known
 
                             const DriverPropertyInfo* pAllowedDriverSetting = 
aDriverInfo.getConstArray();
                                                        const 
DriverPropertyInfo* pDriverSettingsEnd = pAllowedDriverSetting + 
aDriverInfo.getLength();                                         
                                                        for ( ; 
pAllowedDriverSetting != pDriverSettingsEnd; ++pAllowedDriverSetting )
                                                        {
-                                                               if ( 
!pAllowedDriverSetting->Name.compareToAscii( pKnownSettings[i] ) )
+                                                               if ( 
!pAllowedDriverSetting->Name.compareToAscii( pSetting->AsciiName ) )
                                                                {   // the 
driver also allows this setting
                                                                        
bAllowSetting = sal_True;
                                                                        break;
@@ -499,7 +490,7 @@
                                                        break;
                                                }
                                        }
-                                       if ( bAllowSetting || ( i == 
nKnownSettings ) )
+                                       if ( bAllowSetting || 
!pSetting->AsciiName )
                                        {   // if the driver allows this 
particular setting, or if the setting is completely unknown,
                         // we pass it to the driver
                                                aRet.push_back( 
*pDataSourceSetting );
@@ -510,6 +501,15 @@
                        }
                        return Sequence< PropertyValue >();
                }
+
+        //------------------------------------------------------------------
+        struct CheckForDefaultPropertyValue : public ::std::unary_function< 
PropertyValue, bool >
+        {
+            bool operator()( const PropertyValue& _rProp )
+            {
+                return _rProp.State == PropertyState_DEFAULT_VALUE;
+            }
+        };
        }
 //============================================================
 //= ODatabaseContext
@@ -728,7 +728,12 @@
                        nExceptionMessageId = RID_STR_COULDNOTCONNECT_NODRIVER;
                else
                {
-                       Sequence< PropertyValue > aDriverInfo = 
lcl_filterDriverProperties(xDriver,m_pImpl->m_sConnectURL,m_pImpl->m_aInfo);
+                       Sequence< PropertyValue > aDriverInfo = 
lcl_filterDriverProperties(
+                xDriver,
+                m_pImpl->m_sConnectURL,
+                m_pImpl->m_xSettings->getPropertyValues(),
+                m_pImpl->getDefaultDataSourceSettings()
+            );
 
                        if ( m_pImpl->isEmbeddedDatabase() )
                        {
@@ -773,14 +778,15 @@
 
//------------------------------------------------------------------------------
 ::cppu::IPropertyArrayHelper* ODatabaseSource::createArrayHelper( ) const
 {
-       BEGIN_PROPERTY_HELPER(12)
-               DECL_PROP1(INFO,                                                
Sequence< PropertyValue >,BOUND);
+       BEGIN_PROPERTY_HELPER(13)
+               DECL_PROP1(INFO,                                                
Sequence< PropertyValue >,  BOUND);
                DECL_PROP1_BOOL(ISPASSWORDREQUIRED,                             
                                        BOUND);
                DECL_PROP1_BOOL(ISREADONLY,                                     
                                                READONLY);
-               DECL_PROP1(LAYOUTINFORMATION,                   Sequence< 
::com::sun::star::beans::PropertyValue >,BOUND);
+               DECL_PROP1(LAYOUTINFORMATION,                   Sequence< 
PropertyValue >,  BOUND);
                DECL_PROP1(NAME,                                                
::rtl::OUString,                        READONLY);
                DECL_PROP2_IFACE(NUMBERFORMATSSUPPLIER, XNumberFormatsSupplier, 
        READONLY, TRANSIENT);
                DECL_PROP1(PASSWORD,                                    
::rtl::OUString,                        TRANSIENT);
+               DECL_PROP2_IFACE(SETTINGS,              XPropertySet,           
    BOUND, READONLY);
                DECL_PROP1_BOOL(SUPPRESSVERSIONCL,                              
                                        BOUND);
                DECL_PROP1(TABLEFILTER,                                 
Sequence< ::rtl::OUString >,BOUND);
                DECL_PROP1(TABLETYPEFILTER,                             
Sequence< ::rtl::OUString >,BOUND);
@@ -846,11 +852,11 @@
                                            throw IllegalArgumentException();
                            }
 
-                                               
-                           bModified = m_pImpl->m_aInfo.getLength() != 
aValues.getLength();
+                Sequence< PropertyValue > aSettings = 
m_pImpl->m_xSettings->getPropertyValues();
+                bModified = aSettings.getLength() != aValues.getLength();
                            if ( !bModified )
                            {
-                                   const PropertyValue* pInfoIter = 
m_pImpl->m_aInfo.getConstArray();
+                    const PropertyValue* pInfoIter = aSettings.getConstArray();
                                    const PropertyValue* pBegin = 
aValues.getConstArray();
                                    const PropertyValue* pEnd   = pBegin + 
aValues.getLength();
                                    for (;!bModified && pBegin != pEnd ; 
++pBegin,++pInfoIter)
@@ -864,10 +870,11 @@
                            }
 
                            rConvertedValue = rValue;
-                           rOldValue <<= m_pImpl->m_aInfo;
-                   }   break;
+                rOldValue <<= aSettings;
+            }
+            break;
                    default:
-                           DBG_ERROR("unknown Property");
+                DBG_ERROR( "ODatabaseSource::convertFastPropertyValue: unknown 
or readonly Property!" );
            }
     }
        return bModified;
@@ -904,7 +911,19 @@
                            rValue >>= m_pImpl->m_sConnectURL;
                            break;
                    case PROPERTY_ID_INFO:
-                           rValue >>= m_pImpl->m_aInfo;
+            {
+                Sequence< PropertyValue > aInfo;
+                OSL_VERIFY( rValue >>= aInfo );
+                try
+                {
+                    m_pImpl->m_xSettings->setPropertyValues( aInfo );
+                }
+                catch( const Exception& )
+                {
+                  OSL_ENSURE( sal_False,
+                        "ODatabaseSource::setFastPropertyValue_NoBroadcast: 
caught an exception while forwarding the Info property value to the property 
bag!" );
+                }
+            }
                            break;
                    case PROPERTY_ID_LAYOUTINFORMATION:
                            rValue >>= m_pImpl->m_aLayoutInformation;
@@ -943,7 +962,21 @@
                            rValue = bool2any(m_pImpl->m_bReadOnly);
                            break;
                    case PROPERTY_ID_INFO:
-                           rValue <<= m_pImpl->m_aInfo;
+            {
+                Sequence< PropertyValue > aValues( 
m_pImpl->m_xSettings->getPropertyValues() );
+                Sequence< PropertyValue > aNonDefaultValues( 
aValues.getLength() );
+                const PropertyValue* pCopyEnd = ::std::remove_copy_if(
+                    aValues.getConstArray(),
+                    aValues.getConstArray() + aValues.getLength(),
+                    aNonDefaultValues.getArray(),
+                    CheckForDefaultPropertyValue()
+                );
+                aNonDefaultValues.realloc( pCopyEnd - 
aNonDefaultValues.getArray() );
+                rValue <<= aNonDefaultValues;
+            }
+            break;
+            case PROPERTY_ID_SETTINGS:
+                rValue <<= m_pImpl->m_xSettings;
                            break;
                    case PROPERTY_ID_URL:
                            rValue <<= m_pImpl->m_sConnectURL;
@@ -1113,7 +1146,8 @@
                        m_pImpl->m_pSharedConnectionManager = new 
OSharedConnectionManager(m_pImpl->m_xServiceFactory);
                        m_pImpl->m_xSharedConnectionManager = 
m_pImpl->m_pSharedConnectionManager;
                }
-               xConn = 
m_pImpl->m_pSharedConnectionManager->getConnection(m_pImpl->m_sConnectURL,user,password,m_pImpl->m_aInfo,this);
+               xConn = m_pImpl->m_pSharedConnectionManager->getConnection(
+            m_pImpl->m_sConnectURL, user, password, 
m_pImpl->m_xSettings->getPropertyValues(), this );
        }
        
        if ( xConn.is() )

File [changed]: datasource.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/datasource.hxx?r1=1.29&r2=1.29.12.1
Delta lines:  +6 -6
-------------------
--- datasource.hxx      10 Mar 2005 16:34:36 -0000      1.29
+++ datasource.hxx      6 Apr 2005 07:20:17 -0000       1.29.12.1
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: datasource.hxx,v $
  *
- *  $Revision: 1.29 $
+ *  $Revision: 1.29.12.1 $
  *
- *  last change: $Author: vg $ $Date: 2005/03/10 16:34:36 $
+ *  last change: $Author: fs $ $Date: 2005/04/06 07:20:17 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses




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

Reply via email to