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

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

Change-Id: I2e1d98c5947d0d72c369fa6b2df17eb2eec1f64c
üst 12110961
......@@ -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);
}
......
......@@ -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;
......
......@@ -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",
}
}
......
......@@ -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()
......
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