summaryrefslogtreecommitdiff
path: root/xmlscript
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-06-27 15:41:42 +0200
committerStephan Bergmann <sbergman@redhat.com>2016-06-27 15:41:42 +0200
commit7e781aa15ab8c6bb727ccf290db7768bc9ba6245 (patch)
tree39e0e0bbe1c5d49a47979da852387d966e4ed388 /xmlscript
parent232dcd258dc03c318e197fe4bfb0080353423760 (diff)
Clean up uses of Any::getValue() in xmlscript
Change-Id: I863ce5cdf53aee40c12cfe1b8ae4399b7cf006ce
Diffstat (limited to 'xmlscript')
-rw-r--r--xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx5
-rw-r--r--xmlscript/source/xmldlg_imexp/xmldlg_export.cxx55
2 files changed, 31 insertions, 29 deletions
diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx
index 6610f76d4ad4..fe4723cee238 100644
--- a/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx
+++ b/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx
@@ -28,6 +28,7 @@
#include <com/sun/star/document/XStorageBasedDocument.hpp>
#include <com/sun/star/document/XGraphicObjectResolver.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <o3tl/any.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -876,10 +877,10 @@ void ElementDescriptor::readFormattedFieldModel( StyleBag * all_styles )
switch (a.getValueTypeClass())
{
case TypeClass_DOUBLE:
- addAttribute( XMLNS_DIALOGS_PREFIX ":value-default", OUString::number( *static_cast<double const *>(a.getValue()) ) );
+ addAttribute( XMLNS_DIALOGS_PREFIX ":value-default", OUString::number( *o3tl::forceAccess<double>(a) ) );
break;
case TypeClass_STRING:
- addAttribute( XMLNS_DIALOGS_PREFIX ":value-default", *static_cast<OUString const *>(a.getValue()) );
+ addAttribute( XMLNS_DIALOGS_PREFIX ":value-default", *o3tl::forceAccess<OUString>(a) );
break;
default:
break;
diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx
index d8a7446d51b3..1732d64523de 100644
--- a/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx
+++ b/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx
@@ -19,6 +19,7 @@
#include "exp_share.hxx"
+#include <o3tl/any.hxx>
#include <rtl/ustrbuf.hxx>
#include <sal/log.hxx>
#include <tools/diagnose_ex.h>
@@ -517,9 +518,9 @@ void ElementDescriptor::readHexLongAttr( OUString const & rPropName, OUString co
if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
{
Any a( _xProps->getPropertyValue( rPropName ) );
- if (a.getValueTypeClass() == TypeClass_LONG)
+ if (auto n = o3tl::tryAccess<sal_uInt32>(a))
{
- addAttribute( rAttrName, "0x" + OUString::number((sal_Int64)(sal_uInt64)*static_cast<sal_uInt32 const *>(a.getValue()),16) );
+ addAttribute( rAttrName, "0x" + OUString::number(*n, 16) );
}
}
}
@@ -529,9 +530,9 @@ void ElementDescriptor::readDateFormatAttr( OUString const & rPropName, OUString
if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
{
Any a( _xProps->getPropertyValue( rPropName ) );
- if (a.getValueTypeClass() == TypeClass_SHORT)
+ if (auto n = o3tl::tryAccess<sal_Int16>(a))
{
- switch (*static_cast<sal_Int16 const *>(a.getValue()))
+ switch (*n)
{
case 0:
addAttribute( rAttrName, "system_short" );
@@ -626,9 +627,9 @@ void ElementDescriptor::readTimeFormatAttr( OUString const & rPropName, OUString
if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
{
Any a( _xProps->getPropertyValue( rPropName ) );
- if (a.getValueTypeClass() == TypeClass_SHORT)
+ if (auto n = o3tl::tryAccess<sal_Int16>(a))
{
- switch (*static_cast<sal_Int16 const *>(a.getValue()))
+ switch (*n)
{
case 0:
addAttribute( rAttrName, "24h_short" );
@@ -663,9 +664,9 @@ void ElementDescriptor::readAlignAttr( OUString const & rPropName, OUString cons
if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
{
Any a( _xProps->getPropertyValue( rPropName ) );
- if (a.getValueTypeClass() == TypeClass_SHORT)
+ if (auto n = o3tl::tryAccess<sal_Int16>(a))
{
- switch (*static_cast<sal_Int16 const *>(a.getValue()))
+ switch (*n)
{
case 0:
addAttribute( rAttrName, "left" );
@@ -744,9 +745,9 @@ void ElementDescriptor::readImageAlignAttr( OUString const & rPropName, OUString
if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
{
Any a( _xProps->getPropertyValue( rPropName ) );
- if (a.getValueTypeClass() == TypeClass_SHORT)
+ if (auto n = o3tl::tryAccess<sal_Int16>(a))
{
- switch (*static_cast<sal_Int16 const *>(a.getValue()))
+ switch (*n)
{
case 0:
addAttribute( rAttrName, "left" );
@@ -775,9 +776,9 @@ void ElementDescriptor::readImagePositionAttr( OUString const & rPropName, OUStr
if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
{
Any a( _xProps->getPropertyValue( rPropName ) );
- if (a.getValueTypeClass() == TypeClass_SHORT)
+ if (auto n = o3tl::tryAccess<sal_Int16>(a))
{
- switch (*static_cast<sal_Int16 const *>(a.getValue()))
+ switch (*n)
{
case awt::ImagePosition::LeftTop:
addAttribute( rAttrName, "left-top" );
@@ -831,9 +832,9 @@ void ElementDescriptor::readButtonTypeAttr( OUString const & rPropName, OUString
if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
{
Any a( _xProps->getPropertyValue( rPropName ) );
- if (a.getValueTypeClass() == TypeClass_SHORT)
+ if (auto n = o3tl::tryAccess<sal_Int16>(a))
{
- switch (*static_cast<sal_Int16 const *>(a.getValue()))
+ switch (*n)
{
case awt::PushButtonType_STANDARD:
addAttribute( rAttrName, "standard" );
@@ -860,9 +861,9 @@ void ElementDescriptor::readOrientationAttr( OUString const & rPropName, OUStrin
if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
{
Any a( _xProps->getPropertyValue( rPropName ) );
- if (a.getValueTypeClass() == TypeClass_LONG)
+ if (auto n = o3tl::tryAccess<sal_Int16>(a))
{
- switch (*static_cast<sal_Int32 const *>(a.getValue()))
+ switch (*n)
{
case 0:
addAttribute( rAttrName, "horizontal" );
@@ -883,9 +884,9 @@ void ElementDescriptor::readLineEndFormatAttr( OUString const & rPropName, OUStr
if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
{
Any a( _xProps->getPropertyValue( rPropName ) );
- if (a.getValueTypeClass() == TypeClass_SHORT)
+ if (auto n = o3tl::tryAccess<sal_Int16>(a))
{
- switch (*static_cast<sal_Int16 const *>(a.getValue()))
+ switch (*n)
{
case awt::LineEndFormat::CARRIAGE_RETURN:
addAttribute( rAttrName, "carriage-return" );
@@ -1067,7 +1068,7 @@ void ElementDescriptor::readDefaults( bool supportPrintable, bool supportVisible
addAttribute( XMLNS_DIALOGS_PREFIX ":control-implementation", sCtrlName );
}
}
- addAttribute( XMLNS_DIALOGS_PREFIX ":id", * static_cast< const OUString * >( a.getValue() ) );
+ addAttribute( XMLNS_DIALOGS_PREFIX ":id", *o3tl::doAccess<OUString>(a) );
readShortAttr( "TabIndex", XMLNS_DIALOGS_PREFIX ":tab-index" );
bool bEnabled = false;
@@ -1102,24 +1103,24 @@ void ElementDescriptor::readDefaults( bool supportPrintable, bool supportVisible
}
// force writing of pos/size
a = _xProps->getPropertyValue( "PositionX" );
- if (a.getValueTypeClass() == TypeClass_LONG)
+ if (auto n = o3tl::tryAccess<sal_Int32>(a))
{
- addAttribute( XMLNS_DIALOGS_PREFIX ":left", OUString::number( *static_cast<sal_Int32 const *>(a.getValue()) ) );
+ addAttribute( XMLNS_DIALOGS_PREFIX ":left", OUString::number(*n) );
}
a = _xProps->getPropertyValue( "PositionY" );
- if (a.getValueTypeClass() == TypeClass_LONG)
+ if (auto n = o3tl::tryAccess<sal_Int32>(a))
{
- addAttribute( XMLNS_DIALOGS_PREFIX ":top", OUString::number( *static_cast<sal_Int32 const *>(a.getValue()) ) );
+ addAttribute( XMLNS_DIALOGS_PREFIX ":top", OUString::number(*n) );
}
a = _xProps->getPropertyValue( "Width" );
- if (a.getValueTypeClass() == TypeClass_LONG)
+ if (auto n = o3tl::tryAccess<sal_Int32>(a))
{
- addAttribute( XMLNS_DIALOGS_PREFIX ":width", OUString::number( *static_cast<sal_Int32 const *>(a.getValue()) ) );
+ addAttribute( XMLNS_DIALOGS_PREFIX ":width", OUString::number(*n) );
}
a = _xProps->getPropertyValue( "Height" );
- if (a.getValueTypeClass() == TypeClass_LONG)
+ if (auto n = o3tl::tryAccess<sal_Int32>(a))
{
- addAttribute( XMLNS_DIALOGS_PREFIX ":height", OUString::number( *static_cast<sal_Int32 const *>(a.getValue()) ) );
+ addAttribute( XMLNS_DIALOGS_PREFIX ":height", OUString::number(*n) );
}
if (supportPrintable)