diff options
author | Michael Stahl <mstahl@redhat.com> | 2012-06-12 22:25:23 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-06-12 23:25:16 +0200 |
commit | f9c5a36609523317b6634f18d834296c6b3dcb22 (patch) | |
tree | 0d1e1a6c12b839d79ca37cac84ba23e73ede9f57 /basic | |
parent | 6ec1108370d9e27f3e75c1a50f9525b06d5a3c82 (diff) |
SbPropertyValues::setPropertyValue doesn't check that property exists
Change-Id: Ia63eea0c19bfa750b80f4c99f278f8d144c714a8
Diffstat (limited to 'basic')
-rw-r--r-- | basic/source/classes/propacc.cxx | 23 | ||||
-rw-r--r-- | basic/source/inc/propacc.hxx | 2 |
2 files changed, 14 insertions, 11 deletions
diff --git a/basic/source/classes/propacc.cxx b/basic/source/classes/propacc.cxx index 945e719d0d42..b34cdf6ad397 100644 --- a/basic/source/classes/propacc.cxx +++ b/basic/source/classes/propacc.cxx @@ -34,6 +34,7 @@ #include <sbunoobj.hxx> using com::sun::star::uno::Reference; +using namespace com::sun::star; using namespace com::sun::star::uno; using namespace com::sun::star::lang; using namespace com::sun::star::beans; @@ -114,12 +115,18 @@ Reference< XPropertySetInfo > SbPropertyValues::getPropertySetInfo(void) throw( //------------------------------------------------------------------------- -sal_Int32 SbPropertyValues::GetIndex_Impl( const ::rtl::OUString &rPropName ) const +size_t SbPropertyValues::GetIndex_Impl( const ::rtl::OUString &rPropName ) const { SbPropertyValueArr_Impl::const_iterator it = std::lower_bound( _aPropVals.begin(), _aPropVals.end(), rPropName, SbCompare_UString_PropertyValue_Impl() ); - return it != _aPropVals.end() ? it - _aPropVals.begin() : USHRT_MAX; + if (it == _aPropVals.end()) + { + throw beans::UnknownPropertyException( + "Property not found: " + rPropName, + const_cast<SbPropertyValues&>(*this)); + } + return it - _aPropVals.begin(); } //---------------------------------------------------------------------------- @@ -133,9 +140,8 @@ void SbPropertyValues::setPropertyValue( ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) { - sal_Int32 nIndex = GetIndex_Impl( aPropertyName ); - PropertyValue *pPropVal = _aPropVals[ - sal::static_int_cast< sal_uInt16 >(nIndex)]; + size_t const nIndex = GetIndex_Impl( aPropertyName ); + PropertyValue *const pPropVal = _aPropVals[nIndex]; pPropVal->Value = aValue; } @@ -147,11 +153,8 @@ Any SbPropertyValues::getPropertyValue( ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) { - sal_Int32 nIndex = GetIndex_Impl( aPropertyName ); - if ( nIndex != USHRT_MAX ) - return _aPropVals[ - sal::static_int_cast< sal_uInt16 >(nIndex)]->Value; - return Any(); + size_t const nIndex = GetIndex_Impl( aPropertyName ); + return _aPropVals[nIndex]->Value; } //---------------------------------------------------------------------------- diff --git a/basic/source/inc/propacc.hxx b/basic/source/inc/propacc.hxx index b5a2e7142fc3..09cd9bf28580 100644 --- a/basic/source/inc/propacc.hxx +++ b/basic/source/inc/propacc.hxx @@ -51,7 +51,7 @@ class SbPropertyValues: public SbPropertyValuesHelper ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > _xInfo; private: - sal_Int32 GetIndex_Impl( const ::rtl::OUString &rPropName ) const; + size_t GetIndex_Impl( const ::rtl::OUString &rPropName ) const; public: SbPropertyValues(); |