basic/source/classes/propacc.cxx |   21 +++++++++++++--------
 basic/source/inc/propacc.hxx     |    2 +-
 2 files changed, 14 insertions(+), 9 deletions(-)

New commits:
commit dfa7f7cd91f1860ed0e469b121a5ec0604aea125
Author: Michael Stahl <mst...@redhat.com>
Date:   Tue Jun 12 22:25:23 2012 +0200

    SbPropertyValues::setPropertyValue doesn't check that property exists
    
    (cherry picked from commit f9c5a36609523317b6634f18d834296c6b3dcb22)
    
    Conflicts:
        basic/source/classes/propacc.cxx
    
    Change-Id: Ia63eea0c19bfa750b80f4c99f278f8d144c714a8

diff --git a/basic/source/classes/propacc.cxx b/basic/source/classes/propacc.cxx
index ce9c027..66c6976 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 f8e91d1..431f703 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();
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to