[Libreoffice-commits] core.git: include/svl svl/source
Stephan Bergmann
sbergman at redhat.com
Thu Jun 23 14:48:39 UTC 2016
include/svl/poolitem.hxx | 15 ++++-----------
svl/source/config/cjkoptions.cxx | 3 ++-
svl/source/items/itemprop.cxx | 4 +++-
svl/source/misc/fstathelper.cxx | 3 ++-
svl/source/numbers/numfmuno.cxx | 5 +++--
5 files changed, 14 insertions(+), 16 deletions(-)
New commits:
commit 4809fedd7cd3443100fba1c776267e2d87eb3f95
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Tue Jun 21 15:48:59 2016 +0200
Clean up uses of Any::getValue() in svl
Change-Id: I2005ce59d6211181ed039eaff60ffd31084e1d40
diff --git a/include/svl/poolitem.hxx b/include/svl/poolitem.hxx
index f2f9f29..986c6e0 100644
--- a/include/svl/poolitem.hxx
+++ b/include/svl/poolitem.hxx
@@ -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;
diff --git a/svl/source/config/cjkoptions.cxx b/svl/source/config/cjkoptions.cxx
index e0b1b9e..c16cccf 100644
--- a/svl/source/config/cjkoptions.cxx
+++ b/svl/source/config/cjkoptions.cxx
@@ -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;
diff --git a/svl/source/items/itemprop.cxx b/svl/source/items/itemprop.cxx
index 639c1f3..69f78e5 100644
--- a/svl/source/items/itemprop.cxx
+++ b/svl/source/items/itemprop.cxx
@@ -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 );
}
}
diff --git a/svl/source/misc/fstathelper.cxx b/svl/source/misc/fstathelper.cxx
index 6f8a184..6530ff7 100644
--- a/svl/source/misc/fstathelper.cxx
+++ b/svl/source/misc/fstathelper.cxx
@@ -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 )
diff --git a/svl/source/numbers/numfmuno.cxx b/svl/source/numbers/numfmuno.cxx
index 0047c34..3e9436f 100644
--- a/svl/source/numbers/numfmuno.cxx
+++ b/svl/source/numbers/numfmuno.cxx
@@ -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)
{
More information about the Libreoffice-commits
mailing list