diff options
author | Release Engineers <releng@openoffice.org> | 2008-12-01 15:44:36 +0000 |
---|---|---|
committer | Release Engineers <releng@openoffice.org> | 2008-12-01 15:44:36 +0000 |
commit | 57654e6fc4be854da72ab48f2d65cdcefbb36cb3 (patch) | |
tree | 6294b5a218b422f4bf82c9f5b2a5d342165b61b7 /comphelper | |
parent | c5f44514bf09ac2030f3beb8b0e4a2b9e22e2e37 (diff) |
CWS-TOOLING: integrate CWS sw301bf03_DEV300
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/inc/comphelper/propertybag.hxx | 12 | ||||
-rw-r--r-- | comphelper/source/property/opropertybag.cxx | 7 | ||||
-rw-r--r-- | comphelper/source/property/propertybag.cxx | 14 |
3 files changed, 28 insertions, 5 deletions
diff --git a/comphelper/inc/comphelper/propertybag.hxx b/comphelper/inc/comphelper/propertybag.hxx index 50789ce045c3..3a47bd5bb4c7 100644 --- a/comphelper/inc/comphelper/propertybag.hxx +++ b/comphelper/inc/comphelper/propertybag.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: propertybag.hxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.60.1 $ * * This file is part of OpenOffice.org. * @@ -62,12 +62,20 @@ namespace comphelper PropertyBag(); virtual ~PropertyBag(); + /** allow adding property with empty string as name + (by default, such names are rejected with IllegalActionException). + @param i_isAllowed + iff true, empty property name will be allowed + */ + void setAllowEmptyPropertyName(bool i_isAllowed = true); + /** adds a property to the bag The type of the property is determined from its initial value (<code>_rInitialValue</code>). @param _rName - the name of the new property. Must not be empty. + the name of the new property. Must not be empty unless + explicitly allowed with setAllowEmptyPropertyName. @param _nHandle the handle of the new property @param _nAttributes diff --git a/comphelper/source/property/opropertybag.cxx b/comphelper/source/property/opropertybag.cxx index 2cd347b29e10..e7b14795186e 100644 --- a/comphelper/source/property/opropertybag.cxx +++ b/comphelper/source/property/opropertybag.cxx @@ -126,6 +126,13 @@ namespace comphelper ); aArguments.get_ensureType( "AutomaticAddition", m_bAutoAddProperties ); + bool AllowEmptyPropertyName(false); + aArguments.get_ensureType( "AllowEmptyPropertyName", + AllowEmptyPropertyName ); + if (AllowEmptyPropertyName) { + m_aDynamicProperties.setAllowEmptyPropertyName( + AllowEmptyPropertyName); + } } //-------------------------------------------------------------------- diff --git a/comphelper/source/property/propertybag.cxx b/comphelper/source/property/propertybag.cxx index b447e9635fb1..91c104b119f2 100644 --- a/comphelper/source/property/propertybag.cxx +++ b/comphelper/source/property/propertybag.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: propertybag.cxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.60.1 $ * * This file is part of OpenOffice.org. * @@ -66,7 +66,9 @@ namespace comphelper typedef ::std::map< sal_Int32, Any > MapInt2Any; struct PropertyBag_Impl { + PropertyBag_Impl() : m_bAllowEmptyPropertyName(false) { } MapInt2Any aDefaults; + bool m_bAllowEmptyPropertyName; }; //==================================================================== @@ -83,18 +85,24 @@ namespace comphelper } //-------------------------------------------------------------------- + void PropertyBag::setAllowEmptyPropertyName( bool i_isAllowed ) + { + m_pImpl->m_bAllowEmptyPropertyName = i_isAllowed; + } + + //-------------------------------------------------------------------- void PropertyBag::addProperty( const ::rtl::OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, const Any& _rInitialValue ) { // check type sanity Type aPropertyType = _rInitialValue.getValueType(); if ( aPropertyType.getTypeClass() == TypeClass_VOID ) throw IllegalTypeException( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "The initial vallue must be non-NULL, to determine the property type." ) ), + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "The initial value must be non-NULL to determine the property type." ) ), // TODO: resource NULL ); // check name/handle sanity - if ( !_rName.getLength() ) + if ( !m_pImpl->m_bAllowEmptyPropertyName && !_rName.getLength() ) throw IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "The property name must not be empty." ) ), // TODO: resource |