diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2016-05-03 15:26:01 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-05-03 15:26:01 +0200 |
commit | 0b1e4a306705d8c25db6e233244101ba6c4c16b6 (patch) | |
tree | e3ce34a2d884bb5469aa0e15e8d66b6aa08a876e /svl/source/numbers/numfmuno.cxx | |
parent | ab3d2e568fe1595584c66c2ff07843e72f608944 (diff) |
Prevent Any::setValue from reinterpreting bool* as sal_Bool*
...which only happens ot work in environments where sizeof (bool) == 1. The
simpler alternative is to use the operator <<= template without passing explicit
UNO type information, anyway.
The std::nullptr_t overloads are needed to disambiguate calls with a nullptr
argument. (Which can at least be meaningful for VOID, but for other types what
it happens to do is store a default value of the given type.) As std::nullptr_t
is only C++11, this all needs to be LIBO_INTERNAL_ONLY.
Change-Id: Iff06a6ba94250bd4ae4afc937c2a2bfa75f0888f
Diffstat (limited to 'svl/source/numbers/numfmuno.cxx')
-rw-r--r-- | svl/source/numbers/numfmuno.cxx | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/svl/source/numbers/numfmuno.cxx b/svl/source/numbers/numfmuno.cxx index 368dde3e3174..0f87d6809b5e 100644 --- a/svl/source/numbers/numfmuno.cxx +++ b/svl/source/numbers/numfmuno.cxx @@ -737,13 +737,11 @@ uno::Any SAL_CALL SvNumberFormatObj::getPropertyValue( const OUString& aProperty else if (aPropertyName == PROPERTYNAME_STDFORM) { //! Pass through SvNumberformat Member bStandard? - sal_Bool bStandard = ( ( nKey % SV_COUNTRY_LANGUAGE_OFFSET ) == 0 ); - aRet.setValue( &bStandard, cppu::UnoType<bool>::get() ); + aRet <<= ( ( nKey % SV_COUNTRY_LANGUAGE_OFFSET ) == 0 ); } else if (aPropertyName == PROPERTYNAME_USERDEF) { - sal_Bool bUserDef = ( ( pFormat->GetType() & css::util::NumberFormat::DEFINED ) != 0 ); - aRet.setValue( &bUserDef, cppu::UnoType<bool>::get() ); + aRet <<= ( ( pFormat->GetType() & css::util::NumberFormat::DEFINED ) != 0 ); } else if (aPropertyName == PROPERTYNAME_DECIMALS) { @@ -758,12 +756,12 @@ uno::Any SAL_CALL SvNumberFormatObj::getPropertyValue( const OUString& aProperty else if (aPropertyName == PROPERTYNAME_NEGRED) { pFormat->GetFormatSpecialInfo( bThousand, bRed, nDecimals, nLeading ); - aRet.setValue( &bRed, cppu::UnoType<bool>::get() ); + aRet <<= bRed; } else if (aPropertyName == PROPERTYNAME_THOUS) { pFormat->GetFormatSpecialInfo( bThousand, bRed, nDecimals, nLeading ); - aRet.setValue( &bThousand, cppu::UnoType<bool>::get() ); + aRet <<= bThousand; } else if (aPropertyName == PROPERTYNAME_CURRSYM) { @@ -852,9 +850,9 @@ uno::Sequence<beans::PropertyValue> SAL_CALL SvNumberFormatObj::getPropertyValue OUString aFmtStr = pFormat->GetFormatstring(); OUString aComment = pFormat->GetComment(); - sal_Bool bStandard = ( ( nKey % SV_COUNTRY_LANGUAGE_OFFSET ) == 0 ); + bool bStandard = ( ( nKey % SV_COUNTRY_LANGUAGE_OFFSET ) == 0 ); //! Pass through SvNumberformat Member bStandard? - sal_Bool bUserDef = ( ( pFormat->GetType() & css::util::NumberFormat::DEFINED ) != 0 ); + bool bUserDef = ( ( pFormat->GetType() & css::util::NumberFormat::DEFINED ) != 0 ); bool bThousand, bRed; sal_uInt16 nDecimals, nLeading; pFormat->GetFormatSpecialInfo( bThousand, bRed, nDecimals, nLeading ); @@ -872,17 +870,17 @@ uno::Sequence<beans::PropertyValue> SAL_CALL SvNumberFormatObj::getPropertyValue pArray[3].Name = PROPERTYNAME_COMMENT; pArray[3].Value <<= aComment; pArray[4].Name = PROPERTYNAME_STDFORM; - pArray[4].Value.setValue( &bStandard, cppu::UnoType<bool>::get() ); + pArray[4].Value <<= bStandard; pArray[5].Name = PROPERTYNAME_USERDEF; - pArray[5].Value.setValue( &bUserDef, cppu::UnoType<bool>::get() ); + pArray[5].Value <<= bUserDef; pArray[6].Name = PROPERTYNAME_DECIMALS; pArray[6].Value <<= (sal_Int16)( nDecimals ); pArray[7].Name = PROPERTYNAME_LEADING; pArray[7].Value <<= (sal_Int16)( nLeading ); pArray[8].Name = PROPERTYNAME_NEGRED; - pArray[8].Value.setValue( &bRed, cppu::UnoType<bool>::get() ); + pArray[8].Value <<= bRed; pArray[9].Name = PROPERTYNAME_THOUS; - pArray[9].Value.setValue( &bThousand, cppu::UnoType<bool>::get() ); + pArray[9].Value <<= bThousand; pArray[10].Name = PROPERTYNAME_CURRSYM; pArray[10].Value <<= aSymbol; pArray[11].Name = PROPERTYNAME_CURREXT; @@ -1001,8 +999,7 @@ uno::Any SAL_CALL SvNumberFormatSettingsObj::getPropertyValue( const OUString& a { if (aPropertyName == PROPERTYNAME_NOZERO) { - sal_Bool bNoZero = pFormatter->GetNoZero(); - aRet.setValue( &bNoZero, cppu::UnoType<bool>::get() ); + aRet <<= pFormatter->GetNoZero(); } else if (aPropertyName == PROPERTYNAME_NULLDATE) { |