unotools/source/config/fltrcfg.cxx | 11 ++++++----- unotools/source/config/fontcfg.cxx | 14 ++++++-------- unotools/source/config/misccfg.cxx | 9 ++++++--- unotools/source/config/saveopt.cxx | 3 +-- 4 files changed, 19 insertions(+), 18 deletions(-)
New commits: commit bf9728a85413df8324a428bb2c19c9c8a02ba022 Author: Stephan Bergmann <[email protected]> Date: Mon Jun 27 14:07:26 2016 +0200 Clean up uses of Any::getValue() in unotools Change-Id: I2e1d98c5947d0d72c369fa6b2df17eb2eec1f64c diff --git a/unotools/source/config/fltrcfg.cxx b/unotools/source/config/fltrcfg.cxx index 6033578..55785aa 100644 --- a/unotools/source/config/fltrcfg.cxx +++ b/unotools/source/config/fltrcfg.cxx @@ -19,6 +19,7 @@ #include <config_features.h> +#include <o3tl/any.hxx> #include <unotools/fltrcfg.hxx> #include <tools/debug.hxx> #include <tools/solar.h> @@ -113,9 +114,9 @@ void SvtAppFilterOptions_Impl::Load() const Any* pValues = aValues.getConstArray(); if(pValues[0].hasValue()) - bLoadVBA = *static_cast<sal_Bool const *>(pValues[0].getValue()); + bLoadVBA = *o3tl::doAccess<bool>(pValues[0]); if(pValues[1].hasValue()) - bSaveVBA = *static_cast<sal_Bool const *>(pValues[1].getValue()); + bSaveVBA = *o3tl::doAccess<bool>(pValues[1]); } class SvtWriterFilterOptions_Impl : public SvtAppFilterOptions_Impl @@ -161,7 +162,7 @@ void SvtWriterFilterOptions_Impl::Load() Sequence<Any> aValues = GetProperties(aNames); const Any* pValues = aValues.getConstArray(); if(pValues[0].hasValue()) - bLoadExecutable = *static_cast<sal_Bool const *>(pValues[0].getValue()); + bLoadExecutable = *o3tl::doAccess<bool>(pValues[0]); } class SvtCalcFilterOptions_Impl : public SvtAppFilterOptions_Impl @@ -207,7 +208,7 @@ void SvtCalcFilterOptions_Impl::Load() Sequence<Any> aValues = GetProperties(aNames); const Any* pValues = aValues.getConstArray(); if(pValues[0].hasValue()) - bLoadExecutable = *static_cast<sal_Bool const *>(pValues[0].getValue()); + bLoadExecutable = *o3tl::doAccess<bool>(pValues[0]); } struct SvtFilterOptions_Impl @@ -392,7 +393,7 @@ void SvtFilterOptions::Load() { if(pValues[nProp].hasValue()) { - bool bVal = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); + bool bVal = *o3tl::doAccess<bool>(pValues[nProp]); sal_uLong nFlag = lcl_GetFlag(nProp); pImpl->SetFlag( nFlag, bVal); } diff --git a/unotools/source/config/fontcfg.cxx b/unotools/source/config/fontcfg.cxx index b4585c8..022c905 100644 --- a/unotools/source/config/fontcfg.cxx +++ b/unotools/source/config/fontcfg.cxx @@ -18,6 +18,7 @@ */ #include <i18nlangtag/mslangid.hxx> +#include <o3tl/any.hxx> #include <unotools/fontcfg.hxx> #include <unotools/fontdefs.hxx> #include <comphelper/processfactory.hxx> @@ -867,9 +868,8 @@ void FontSubstConfiguration::fillSubstVector( const css::uno::Reference< XNameAc try { Any aAny = rFont->getByName( rType ); - if( aAny.getValueTypeClass() == TypeClass_STRING ) + if( auto pLine = o3tl::tryAccess<OUString>(aAny) ) { - const OUString* pLine = static_cast<const OUString*>(aAny.getValue()); sal_Int32 nLength = pLine->getLength(); if( nLength ) { @@ -916,9 +916,8 @@ FontWeight FontSubstConfiguration::getSubstWeight( const css::uno::Reference< XN try { Any aAny = rFont->getByName( rType ); - if( aAny.getValueTypeClass() == TypeClass_STRING ) + if( auto pLine = o3tl::tryAccess<OUString>(aAny) ) { - const OUString* pLine = static_cast<const OUString*>(aAny.getValue()); if( !pLine->isEmpty() ) { for( weight=SAL_N_ELEMENTS(pWeightNames)-1; weight >= 0; weight-- ) @@ -944,9 +943,8 @@ FontWidth FontSubstConfiguration::getSubstWidth( const css::uno::Reference< XNam try { Any aAny = rFont->getByName( rType ); - if( aAny.getValueTypeClass() == TypeClass_STRING ) + if( auto pLine = o3tl::tryAccess<OUString>(aAny) ) { - const OUString* pLine = static_cast<const OUString*>(aAny.getValue()); if( !pLine->isEmpty() ) { for( width=SAL_N_ELEMENTS(pWidthNames)-1; width >= 0; width-- ) @@ -972,9 +970,9 @@ ImplFontAttrs FontSubstConfiguration::getSubstType( const css::uno::Reference< X try { Any aAny = rFont->getByName( rType ); - if( aAny.getValueTypeClass() != TypeClass_STRING ) + auto pLine = o3tl::tryAccess<OUString>(aAny); + if( !pLine ) return ImplFontAttrs::None; - const OUString* pLine = static_cast<const OUString*>(aAny.getValue()); if( pLine->isEmpty() ) return ImplFontAttrs::None; sal_Int32 nIndex = 0; diff --git a/unotools/source/config/misccfg.cxx b/unotools/source/config/misccfg.cxx index afb59da..a694ae3 100644 --- a/unotools/source/config/misccfg.cxx +++ b/unotools/source/config/misccfg.cxx @@ -17,6 +17,9 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <o3tl/any.hxx> #include <unotools/misccfg.hxx> #include <rtl/instance.hxx> #include <unotools/configmgr.hxx> @@ -141,9 +144,9 @@ void SfxMiscCfg::Load() { switch(nProp) { - case 0: bPaperSize = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; //"Print/Warning/PaperSize", - case 1: bPaperOrientation = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; //"Print/Warning/PaperOrientation", - case 2: bNotFound = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; //"Print/Warning/NotFound", + case 0: bPaperSize = *o3tl::doAccess<bool>(pValues[nProp]); break; //"Print/Warning/PaperSize", + case 1: bPaperOrientation = *o3tl::doAccess<bool>(pValues[nProp]); break; //"Print/Warning/PaperOrientation", + case 2: bNotFound = *o3tl::doAccess<bool>(pValues[nProp]); break; //"Print/Warning/NotFound", case 3: pValues[nProp] >>= nYear2000;break; //"DateFormat/TwoDigitYear", } } diff --git a/unotools/source/config/saveopt.cxx b/unotools/source/config/saveopt.cxx index 9a34074..84f860d 100644 --- a/unotools/source/config/saveopt.cxx +++ b/unotools/source/config/saveopt.cxx @@ -789,8 +789,7 @@ SvtLoadOptions_Impl::SvtLoadOptions_Impl() EnableNotification( aNames ); const Any* pValues = aValues.getConstArray(); DBG_ASSERT( aValues.getLength() == aNames.getLength(), "GetProperties failed" ); - if (pValues[0].getValueTypeClass() == css::uno::TypeClass_BOOLEAN) - bLoadUserDefinedSettings = *static_cast<sal_Bool const *>(pValues[0].getValue()); + pValues[0] >>= bLoadUserDefinedSettings; } SvtLoadOptions_Impl::~SvtLoadOptions_Impl() _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
