[Libreoffice-commits] core.git: include/comphelper

Stephan Bergmann sbergman at redhat.com
Mon Jun 20 16:21:53 UTC 2016


 include/comphelper/property.hxx |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

New commits:
commit 92712332f32988e7827520f3480aaef9dfd5804a
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Jun 20 18:21:27 2016 +0200

    Restrict tryPropertyValueEnum to enum types
    
    Change-Id: I54a6fdc341185fe4bdb9cc7d1b1a1feb0737bf47

diff --git a/include/comphelper/property.hxx b/include/comphelper/property.hxx
index 74c3183..a4171fd 100644
--- a/include/comphelper/property.hxx
+++ b/include/comphelper/property.hxx
@@ -25,6 +25,7 @@
 #include <com/sun/star/beans/Property.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <functional>
+#include <type_traits>
 #include <comphelper/comphelperdllapi.h>
 #include <cppu/unotype.hxx>
 
@@ -95,12 +96,9 @@ bool tryPropertyValue(css::uno::Any& /*out*/_rConvertedValue, css::uno::Any& /*o
     @exception      InvalidArgumentException thrown if the value could not be converted to the requested type (which is the template argument)
 */
 template <class ENUMTYPE>
-bool tryPropertyValueEnum(css::uno::Any& /*out*/_rConvertedValue, css::uno::Any& /*out*/_rOldValue, const css::uno::Any& _rValueToSet, const ENUMTYPE& _rCurrentValue)
+typename std::enable_if<std::is_enum<ENUMTYPE>::value, bool>::type
+tryPropertyValueEnum(css::uno::Any& /*out*/_rConvertedValue, css::uno::Any& /*out*/_rOldValue, const css::uno::Any& _rValueToSet, const ENUMTYPE& _rCurrentValue)
 {
-    if (cppu::getTypeFavourUnsigned(&_rCurrentValue).getTypeClass()
-        != css::uno::TypeClass_ENUM)
-        return tryPropertyValue(_rConvertedValue, _rOldValue, _rValueToSet, _rCurrentValue);
-
     bool bModified(false);
     ENUMTYPE aNewValue;
     ::cppu::any2enum(aNewValue, _rValueToSet);


More information about the Libreoffice-commits mailing list