Tag: cws_src680_dba30 User: fs Date: 05/04/06 00:17:39 Modified: /dba/dbaccess/source/core/dataaccess/ ModelImpl.cxx, ModelImpl.hxx
Log: #i46768# introduce Settings propetry for the data source, wrapping the Info property sequence in a convinient way File Changes: Directory: /dba/dbaccess/source/core/dataaccess/ ================================================ File [changed]: ModelImpl.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/ModelImpl.cxx?r1=1.3&r2=1.3.2.1 Delta lines: +113 -14 ---------------------- --- ModelImpl.cxx 23 Mar 2005 09:45:22 -0000 1.3 +++ ModelImpl.cxx 6 Apr 2005 07:17:36 -0000 1.3.2.1 @@ -2,9 +2,9 @@ * * $RCSfile: ModelImpl.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.3.2.1 $ * - * last change: $Author: vg $ $Date: 2005/03/23 09:45:22 $ + * last change: $Author: fs $ $Date: 2005/04/06 07:17:36 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -278,6 +278,51 @@ { m_bReadOnly = sal_False; m_aContainer.resize(4); + + // create the property bag to hold the settings (also know as "Info" property) + try + { + // the set of property value types in the bag is limited: + Sequence< Type > aAllowedTypes(5); + Type* pAllowedType = aAllowedTypes.getArray(); + *pAllowedType++ = ::getCppuType( static_cast< sal_Bool* >( NULL ) ); + *pAllowedType++ = ::getCppuType( static_cast< double* >( NULL ) ); + *pAllowedType++ = ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) ); + *pAllowedType++ = ::getCppuType( static_cast< sal_Int32* >( NULL ) ); + *pAllowedType++ = ::getCppuType( static_cast< sal_Int16* >( NULL ) ); + + Sequence< Any > aInitArgs( 2 ); + aInitArgs[0] <<= NamedValue( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AutomaticAddition" ) ), + makeAny( (sal_Bool)sal_True ) + ); + aInitArgs[1] <<= NamedValue( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AllowedTypes" ) ), + makeAny( aAllowedTypes ) + ); + + m_xSettings = m_xSettings.query( m_xServiceFactory->createInstanceWithArguments( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.beans.PropertyBag" ) ), + aInitArgs + ) ); + + // insert the default settings + Reference< XPropertyContainer > xContainer( m_xSettings, UNO_QUERY ); + OSL_ENSURE( xContainer.is(), "ODatabaseModelImpl::lateInit: invalid property bag - this will crash, sooner or later!" ); + const AsciiPropertyValue* pSettings = getDefaultDataSourceSettings(); + for ( ; pSettings->AsciiName; ++pSettings ) + { + xContainer->addProperty( + ::rtl::OUString::createFromAscii( pSettings->AsciiName ), + PropertyAttribute::BOUND, + pSettings->DefaultValue + ); + } + } + catch( const Exception& ) + { + OSL_ENSURE( sal_False, "ODatabaseModelImpl::lateInit: could not create the PropertyBag for the Info/Settings properties!" ); + } } // ----------------------------------------------------------------------------- ::rtl::OUString ODatabaseModelImpl::getURL( ) @@ -654,6 +699,60 @@ throw IOException(); } } +// ----------------------------------------------------------------------------- +const AsciiPropertyValue* ODatabaseModelImpl::getDefaultDataSourceSettings() +{ + static const AsciiPropertyValue aKnownSettings[] = + { + // known JDBC settings + { "JavaDriverClass", makeAny( ::rtl::OUString() ) }, + // known settings for file-based drivers + { "Extension", makeAny( ::rtl::OUString() ) }, + { "CharSet", makeAny( ::rtl::OUString() ) }, + { "HeaderLine", makeAny( (sal_Bool)sal_True ) }, + { "FieldDelimiter", makeAny( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "," ) ) ) }, + { "StringDelimiter", makeAny( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "\"" ) ) ) }, + { "DecimalDelimiter", makeAny( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "." ) ) ) }, + { "ThousandDelimiter", makeAny( ::rtl::OUString() ) }, + { "ShowDeleted", makeAny( (sal_Bool)sal_False ) }, + // known ODBC settings + { "SystemDriverSettings", makeAny( ::rtl::OUString() ) }, + { "UseCatalog", makeAny( (sal_Bool)sal_False ) }, + // settings related to auto increment handling + { "AutoIncrementCreation", makeAny( ::rtl::OUString() ) }, + { "AutoRetrievingStatement", makeAny( ::rtl::OUString() ) }, + { "IsAutoRetrievingEnabled", makeAny( (sal_Bool)sal_False ) }, + // known Adabas D driver setting + { "ShutdownDatabase", makeAny( (sal_Bool)sal_False ) }, + { "DataCacheSizeIncrement", makeAny( (sal_Int32)20 ) }, + { "DataCacheSize", makeAny( (sal_Int32)20 ) }, + { "ControlUser", makeAny( ::rtl::OUString() ) }, + { "ControlPassword", makeAny( ::rtl::OUString() ) }, + // known LDAP driver settings + { "HostName", makeAny( ::rtl::OUString() ) }, + { "PortNumber", makeAny( (sal_Int32)389 ) }, + { "BaseDN", makeAny( ::rtl::OUString() ) }, + { "MaxRowCount", makeAny( (sal_Int32)100 ) }, + // misc known driver settings + { "ParameterNameSubstitution", makeAny( (sal_Bool)sal_False ) }, + { "AddIndexAppendix", makeAny( (sal_Bool)sal_True ) }, + // known SDB level settings + { "IgnoreDriverPrivileges", makeAny( (sal_Bool)sal_True ) }, + { "NoNameLengthLimit", makeAny( (sal_Bool)sal_False ) }, + { "AppendTableAliasName", makeAny( (sal_Bool)sal_True ) }, + { "EnableSQL92Check", makeAny( (sal_Bool)sal_False ) }, + { "BooleanComparisonMode", makeAny( (sal_Int32)0 ) }, + { "TableTypeFilterMode", makeAny( (sal_Int32)3 ) }, + { "RespectDriverResultSetType", makeAny( (sal_Bool)sal_False ) }, + { "UseSchemaInSelect", makeAny( (sal_Bool)sal_True ) }, + { "UseCatalogInSelect", makeAny( (sal_Bool)sal_True ) }, + { "EnableOuterJoinEscape", makeAny( (sal_Bool)sal_True ) }, + { "PreferDosLikeLineEnds", makeAny( (sal_Bool)sal_False ) }, + { NULL, Any() } + }; + return aKnownSettings; +} + //........................................................................ } // namespace dbaccess //........................................................................ File [changed]: ModelImpl.hxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/ModelImpl.hxx?r1=1.3&r2=1.3.2.1 Delta lines: +28 -18 --------------------- --- ModelImpl.hxx 23 Mar 2005 09:45:36 -0000 1.3 +++ ModelImpl.hxx 6 Apr 2005 07:17:36 -0000 1.3.2.1 @@ -2,9 +2,9 @@ * * $RCSfile: ModelImpl.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.3.2.1 $ * - * last change: $Author: vg $ $Date: 2005/03/23 09:45:36 $ + * last change: $Author: fs $ $Date: 2005/04/06 07:17:36 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -179,6 +179,9 @@ #ifndef _COM_SUN_STAR_UTIL_XREFRESHABLE_HPP_ #include <com/sun/star/util/XRefreshable.hpp> #endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYACCESS_HPP_ +#include <com/sun/star/beans/XPropertyAccess.hpp> +#endif //........................................................................ namespace dbaccess @@ -188,12 +191,17 @@ typedef ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XConnection > OWeakConnection; typedef std::vector< OWeakConnection > OWeakConnectionArray; +struct AsciiPropertyValue +{ + const sal_Char* AsciiName; + ::com::sun::star::uno::Any DefaultValue; +}; + //============================================================ //= ODatabaseModelImpl //============================================================ DECLARE_STL_USTRINGACCESS_MAP(::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >,TStorages); - class ODatabaseModelImpl : public ::rtl::IReference { friend class ODatabaseContext; @@ -239,8 +247,8 @@ sal_Bool m_bModified : 1; sal_Bool m_bDocumentReadOnly : 1; sal_Bool m_bDisposingSubStorages; - ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > - m_aInfo; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyAccess > + m_xSettings; ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aTableFilter; ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aTableTypeFilter; ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > @@ -380,6 +388,8 @@ virtual oslInterlockedCount SAL_CALL release(); + /// returns a all known data source settings, including their default values + static const AsciiPropertyValue* getDefaultDataSourceSettings(); }; //........................................................................ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
