summaryrefslogtreecommitdiff
path: root/unotools
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-06-27 14:07:26 +0200
committerStephan Bergmann <sbergman@redhat.com>2016-06-27 14:07:26 +0200
commitbf9728a85413df8324a428bb2c19c9c8a02ba022 (patch)
tree5e763f9204d4ff22fea1cbe9f56ede7c598b231a /unotools
parent121109610f9af0b294cf042c6ae5abc6fcc4f326 (diff)
Clean up uses of Any::getValue() in unotools
Change-Id: I2e1d98c5947d0d72c369fa6b2df17eb2eec1f64c
Diffstat (limited to 'unotools')
-rw-r--r--unotools/source/config/fltrcfg.cxx11
-rw-r--r--unotools/source/config/fontcfg.cxx14
-rw-r--r--unotools/source/config/misccfg.cxx9
-rw-r--r--unotools/source/config/saveopt.cxx3
4 files changed, 19 insertions, 18 deletions
diff --git a/unotools/source/config/fltrcfg.cxx b/unotools/source/config/fltrcfg.cxx
index 6033578a095a..55785aa9273d 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 b4585c80b6cc..022c90509ced 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 afb59da178a4..a694ae356e90 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 9a340748989c..84f860dcc2ef 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()