Kaydet (Commit) 4809fedd authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Clean up uses of Any::getValue() in svl

Change-Id: I2005ce59d6211181ed039eaff60ffd31084e1d40
üst c7c27b9b
......@@ -50,18 +50,11 @@ enum SfxItemKind {
inline bool Any2Bool( const css::uno::Any&rValue )
{
bool bValue = false;
if( rValue.hasValue() )
if( !(rValue >>= bValue) )
{
if( rValue.getValueType() == cppu::UnoType<bool>::get() )
{
bValue = *static_cast<sal_Bool const *>(rValue.getValue());
}
else
{
sal_Int32 nNum = 0;
if( rValue >>= nNum )
bValue = nNum != 0;
}
sal_Int32 nNum = 0;
if( rValue >>= nNum )
bValue = nNum != 0;
}
return bValue;
......
......@@ -19,6 +19,7 @@
#include <svl/cjkoptions.hxx>
#include <o3tl/any.hxx>
#include <svl/languageoptions.hxx>
#include <i18nlangtag/lang.h>
#include <unotools/configitem.hxx>
......@@ -179,7 +180,7 @@ void SvtCJKOptions_Impl::Load()
{
if( pValues[nProp].hasValue() )
{
bool bValue = *static_cast<sal_Bool const *>(pValues[nProp].getValue());
bool bValue = *o3tl::doAccess<bool>(pValues[nProp]);
switch ( nProp )
{
case 0: { bCJKFont = bValue; bROCJKFont = pROStates[nProp]; } break;
......
......@@ -17,7 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sal/config.h>
#include <o3tl/any.hxx>
#include <svl/itemprop.hxx>
#include <svl/itempool.hxx>
#include <svl/itemset.hxx>
......@@ -198,7 +200,7 @@ void SfxItemPropertySet::getPropertyValue( const SfxItemPropertySimpleEntry& rEn
if( rEntry.aType.getTypeClass() == TypeClass_ENUM &&
rAny.getValueTypeClass() == TypeClass_LONG )
{
sal_Int32 nTmp = *static_cast<sal_Int32 const *>(rAny.getValue());
sal_Int32 nTmp = *o3tl::forceAccess<sal_Int32>(rAny);
rAny.setValue( &nTmp, rEntry.aType );
}
}
......
......@@ -19,6 +19,7 @@
#include <com/sun/star/util/DateTime.hpp>
#include <comphelper/processfactory.hxx>
#include <o3tl/any.hxx>
#include <rtl/ustring.hxx>
#include <svl/fstathelper.hxx>
#include <tools/date.hxx>
......@@ -43,7 +44,7 @@ bool FStatHelper::GetModifiedDateTimeOfFile( const OUString& rURL,
if( aAny.hasValue() )
{
bRet = true;
const util::DateTime* pDT = static_cast<util::DateTime const *>(aAny.getValue());
auto pDT = o3tl::doAccess<util::DateTime>(aAny);
if( pDate )
*pDate = Date( pDT->Day, pDT->Month, pDT->Year );
if( pTime )
......
......@@ -19,6 +19,7 @@
#include <tools/color.hxx>
#include <i18nlangtag/mslangid.hxx>
#include <o3tl/any.hxx>
#include <osl/mutex.hxx>
#include <osl/diagnose.h>
#include <rtl/ustring.hxx>
......@@ -952,8 +953,8 @@ void SAL_CALL SvNumberFormatSettingsObj::setPropertyValue( const OUString& aProp
if (aPropertyName == PROPERTYNAME_NOZERO)
{
// operator >>= shouldn't be used for bool (?)
if ( aValue.getValueTypeClass() == uno::TypeClass_BOOLEAN )
pFormatter->SetNoZero( *static_cast<sal_Bool const *>(aValue.getValue()) );
if ( auto b = o3tl::tryAccess<bool>(aValue) )
pFormatter->SetNoZero( *b );
}
else if (aPropertyName == PROPERTYNAME_NULLDATE)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment