summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2012-06-12 22:25:23 +0200
committerMichael Stahl <mstahl@redhat.com>2012-06-12 23:56:56 +0200
commitdfa7f7cd91f1860ed0e469b121a5ec0604aea125 (patch)
treeca4c4243d0dde2e016b174781bc713188589a3df /basic
parent9649bd88f43982c7232ad576997c78317f670d7e (diff)
SbPropertyValues::setPropertyValue doesn't check that property exists
(cherry picked from commit f9c5a36609523317b6634f18d834296c6b3dcb22) Conflicts: basic/source/classes/propacc.cxx Change-Id: Ia63eea0c19bfa750b80f4c99f278f8d144c714a8
Diffstat (limited to 'basic')
-rw-r--r--basic/source/classes/propacc.cxx21
-rw-r--r--basic/source/inc/propacc.hxx2
2 files changed, 14 insertions, 9 deletions
diff --git a/basic/source/classes/propacc.cxx b/basic/source/classes/propacc.cxx
index ce9c027a9623..66c6976c25d4 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;
@@ -109,14 +110,20 @@ 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
{
PropertyValue **ppPV;
ppPV = (PropertyValue **)
bsearch( &rPropName, _aPropVals.GetData(), _aPropVals.Count(),
sizeof( PropertyValue* ),
SbCompare_UString_PropertyValue_Impl );
- return ppPV ? ppPV - _aPropVals.GetData() : USHRT_MAX;
+ if (!ppPV)
+ {
+ throw beans::UnknownPropertyException(
+ "Property not found: " + rPropName,
+ const_cast<SbPropertyValues&>(*this));
+ }
+ return ppPV - _aPropVals.GetData();
}
//----------------------------------------------------------------------------
@@ -130,7 +137,7 @@ void SbPropertyValues::setPropertyValue(
::com::sun::star::lang::WrappedTargetException,
::com::sun::star::uno::RuntimeException)
{
- sal_Int32 nIndex = GetIndex_Impl( aPropertyName );
+ size_t const nIndex = GetIndex_Impl( aPropertyName );
PropertyValue *pPropVal = _aPropVals.GetObject(
sal::static_int_cast< sal_uInt16 >(nIndex));
pPropVal->Value = aValue;
@@ -144,11 +151,9 @@ 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.GetObject(
- sal::static_int_cast< sal_uInt16 >(nIndex))->Value;
- return Any();
+ size_t const nIndex = GetIndex_Impl( aPropertyName );
+ return _aPropVals.GetObject(
+ sal::static_int_cast< sal_uInt16 >(nIndex))->Value;
}
//----------------------------------------------------------------------------
diff --git a/basic/source/inc/propacc.hxx b/basic/source/inc/propacc.hxx
index f8e91d1f565b..431f703950c5 100644
--- a/basic/source/inc/propacc.hxx
+++ b/basic/source/inc/propacc.hxx
@@ -52,7 +52,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();