From bb1e59d596ffa29d40b4538e18a08e5e91d469a9 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Fri, 17 Jun 2016 19:40:58 +0200 Subject: Simplify OPropertyContainerHelper::registerPropertyNoMember's _pInitialValue Change-Id: Ibfb27b3eded45e2646dada37ce3663f427985ae9 --- comphelper/source/property/propertybag.cxx | 4 ++-- comphelper/source/property/propertycontainerhelper.cxx | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'comphelper/source/property') diff --git a/comphelper/source/property/propertybag.cxx b/comphelper/source/property/propertybag.cxx index 7f32dd970fb0..019c2b9d5723 100644 --- a/comphelper/source/property/propertybag.cxx +++ b/comphelper/source/property/propertybag.cxx @@ -120,7 +120,7 @@ namespace comphelper // register the property OSL_ENSURE( _nAttributes & PropertyAttribute::MAYBEVOID, "PropertyBag::addVoidProperty: this is for default-void properties only!" ); - registerPropertyNoMember( _rName, _nHandle, _nAttributes | PropertyAttribute::MAYBEVOID, _rType, nullptr ); + registerPropertyNoMember( _rName, _nHandle, _nAttributes | PropertyAttribute::MAYBEVOID, _rType, css::uno::Any() ); // remember the default m_pImpl->aDefaults.insert( MapInt2Any::value_type( _nHandle, Any() ) ); @@ -143,7 +143,7 @@ namespace comphelper // register the property registerPropertyNoMember( _rName, _nHandle, _nAttributes, aPropertyType, - _rInitialValue.hasValue() ? _rInitialValue.getValue() : nullptr ); + _rInitialValue ); // remember the default m_pImpl->aDefaults.insert( MapInt2Any::value_type( _nHandle, _rInitialValue ) ); diff --git a/comphelper/source/property/propertycontainerhelper.cxx b/comphelper/source/property/propertycontainerhelper.cxx index 9122ba0a7a74..5e7fa4f00e16 100644 --- a/comphelper/source/property/propertycontainerhelper.cxx +++ b/comphelper/source/property/propertycontainerhelper.cxx @@ -121,21 +121,21 @@ void OPropertyContainerHelper::registerMayBeVoidProperty(const OUString& _rName, void OPropertyContainerHelper::registerPropertyNoMember(const OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, - const Type& _rType, const void* _pInitialValue) + const Type& _rType, css::uno::Any const & _pInitialValue) { OSL_ENSURE(!_rType.equals(cppu::UnoType::get()), "OPropertyContainerHelper::registerPropertyNoMember : don't give my the type of an uno::Any ! Really can't handle this !"); - OSL_ENSURE(_pInitialValue || ((_nAttributes & PropertyAttribute::MAYBEVOID) != 0), - "OPropertyContainerHelper::registerPropertyNoMember : you should not omit the initial value if the property can't be void! This will definitively crash later!"); + OSL_ENSURE( + (_pInitialValue.isExtractableTo(_rType) + || (!_pInitialValue.hasValue() + && (_nAttributes & PropertyAttribute::MAYBEVOID) != 0)), + "bad initial value"); PropertyDescription aNewProp; aNewProp.aProperty = Property( _rName, _nHandle, _rType, (sal_Int16)_nAttributes ); aNewProp.eLocated = PropertyDescription::LocationType::HoldMyself; aNewProp.aLocation.nOwnClassVectorIndex = m_aHoldProperties.size(); - if (_pInitialValue) - m_aHoldProperties.push_back(Any(_pInitialValue, _rType)); - else - m_aHoldProperties.push_back(Any()); + m_aHoldProperties.push_back(_pInitialValue); implPushBackProperty(aNewProp); } -- cgit