diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-10-10 15:47:34 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-10-10 18:14:35 +0100 |
commit | 9b92b4239e8d8d9657a0ba22959c7b0a99306870 (patch) | |
tree | e2f9abe140505b6cc6fac401baaa486b3eee57b1 /comphelper | |
parent | 0e06dbd3a0ab36dac81227c0cc16ec8c303f0585 (diff) |
coverity#706285 Uncaught exception
Change-Id: I6d7227a0614042f7a65520fc79b31afa3d7ca744
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/source/property/propertybag.cxx | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/comphelper/source/property/propertybag.cxx b/comphelper/source/property/propertybag.cxx index 78e6a65bf3fc..a822fdd4e078 100644 --- a/comphelper/source/property/propertybag.cxx +++ b/comphelper/source/property/propertybag.cxx @@ -21,6 +21,7 @@ #include <com/sun/star/beans/IllegalTypeException.hpp> #include <com/sun/star/beans/PropertyExistException.hpp> +#include <com/sun/star/container/ElementExistException.hpp> #include <com/sun/star/lang/IllegalArgumentException.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/beans/NotRemoveableException.hpp> @@ -37,6 +38,7 @@ namespace comphelper using ::com::sun::star::uno::TypeClass_VOID; using ::com::sun::star::beans::IllegalTypeException; using ::com::sun::star::beans::PropertyExistException; + using ::com::sun::star::container::ElementExistException; using ::com::sun::star::lang::IllegalArgumentException; using ::com::sun::star::beans::Property; using ::com::sun::star::beans::NotRemoveableException; @@ -88,15 +90,24 @@ namespace comphelper ); } - void lcl_checkNameAndHandle( const OUString& _name, const sal_Int32 _handle, const PropertyBag& _container ) + void lcl_checkNameAndHandle_PropertyExistException( const OUString& _name, const sal_Int32 _handle, const PropertyBag& _container ) { if ( _container.hasPropertyByName( _name ) || _container.hasPropertyByHandle( _handle ) ) throw PropertyExistException( "Property name or handle already used.", - // TODO: resource NULL ); } + + void lcl_checkNameAndHandle_ElementExistException( const OUString& _name, const sal_Int32 _handle, const PropertyBag& _container ) + { + if ( _container.hasPropertyByName( _name ) || _container.hasPropertyByHandle( _handle ) ) + throw ElementExistException( + "Property name or handle already used.", + NULL ); + + } + } @@ -112,7 +123,7 @@ namespace comphelper // check name/handle sanity lcl_checkForEmptyName( m_pImpl->m_bAllowEmptyPropertyName, _rName ); - lcl_checkNameAndHandle( _rName, _nHandle, *this ); + lcl_checkNameAndHandle_ElementExistException( _rName, _nHandle, *this ); // register the property OSL_ENSURE( _nAttributes & PropertyAttribute::MAYBEVOID, "PropertyBag::addVoidProperty: this is for default-void properties only!" ); @@ -135,7 +146,7 @@ namespace comphelper // check name/handle sanity lcl_checkForEmptyName( m_pImpl->m_bAllowEmptyPropertyName, _rName ); - lcl_checkNameAndHandle( _rName, _nHandle, *this ); + lcl_checkNameAndHandle_PropertyExistException( _rName, _nHandle, *this ); // register the property registerPropertyNoMember( _rName, _nHandle, _nAttributes, aPropertyType, |