summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-06-17 19:40:58 +0200
committerStephan Bergmann <sbergman@redhat.com>2016-06-17 19:40:58 +0200
commitbb1e59d596ffa29d40b4538e18a08e5e91d469a9 (patch)
treeebc795d45b683f7268788f57db7baa3ddfb9285e /comphelper
parent45c2410041c48c22bd860efb42d4daadad7869b0 (diff)
Simplify OPropertyContainerHelper::registerPropertyNoMember's _pInitialValue
Change-Id: Ibfb27b3eded45e2646dada37ce3663f427985ae9
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/source/property/propertybag.cxx4
-rw-r--r--comphelper/source/property/propertycontainerhelper.cxx14
2 files changed, 9 insertions, 9 deletions
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<Any>::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);
}