include/o3tl/any.hxx                              |  264 ++++++++++++++++++++++
 xmloff/source/core/unoatrcn.cxx                   |   10 
 xmloff/source/draw/XMLImageMapExport.cxx          |    3 
 xmloff/source/draw/animationexport.cxx            |   66 ++---
 xmloff/source/draw/shapeexport.cxx                |   13 -
 xmloff/source/draw/ximpcustomshape.cxx            |   21 -
 xmloff/source/style/XMLPageExport.cxx             |    3 
 xmloff/source/style/prstylei.cxx                  |    5 
 xmloff/source/style/styleexp.cxx                  |    9 
 xmloff/source/style/xmlbahdl.cxx                  |    3 
 xmloff/source/style/xmlnume.cxx                   |    6 
 xmloff/source/style/xmlnumi.cxx                   |    3 
 xmloff/source/style/xmlstyle.cxx                  |    2 
 xmloff/source/text/XMLIndexMarkExport.cxx         |    5 
 xmloff/source/text/XMLLineNumberingExport.cxx     |    9 
 xmloff/source/text/XMLRedlineExport.cxx           |   23 +
 xmloff/source/text/XMLSectionExport.cxx           |   31 +-
 xmloff/source/text/XMLTextColumnsExport.cxx       |    7 
 xmloff/source/text/XMLTextHeaderFooterContext.cxx |    7 
 xmloff/source/text/XMLTextMasterPageContext.cxx   |    3 
 xmloff/source/text/txtexppr.cxx                   |    9 
 xmloff/source/text/txtflde.cxx                    |    5 
 xmloff/source/text/txtftne.cxx                    |    6 
 xmloff/source/text/txtimppr.cxx                   |    5 
 xmloff/source/text/txtparae.cxx                   |   45 ++-
 xmloff/source/text/txtprhdl.cxx                   |   15 -
 xmloff/source/text/txtstyli.cxx                   |    4 
 27 files changed, 437 insertions(+), 145 deletions(-)

New commits:
commit 0d7c5823124696f80583ac2a5f0e28f329f6f786
Author: Stephan Bergmann <sberg...@redhat.com>
Date:   Thu Jun 2 15:06:06 2016 +0200

    New o3tl::try/doGet to obtain value from Any
    
    ...in an attempt to reduce usage of type-unsafe
    
      void const * css::uno::Any::getValue()
    
    These new functions are often more convenient to use than the existing 
">>=" and
    Any::get<T>.  Note how they are careful to provide a pointer directly into 
the
    given Any, instead of creating temporaries.
    
    As an example, replaced most calls of getValue across xmloff:
    
    * Cases that first check for a specific type (via getValueType etc.) and 
then
      call getValue can instead call tryGet.  (But beware that tryGet supports 
some
      conversions, which a check for a specific type may have missed---either
      intentionally or by accident.  Also beware the somewhat common idiom of
      checking for TypeClass_ENUM and then using getValue to obtain a sal_Int32;
      this cannot be replaced with a call to tryGet.)
    
    * Cases that seem confident that the Any is of the correct type when calling
      getValue (but apparently are confident due to some higher-layer protocol, 
as
      the surrounding code does not do any checking via getValueType or 
similar) can
      instead call doGet.  It throws an exception if it turns out the confidence
      wasn't warranted.  (Many of the existing calls that directly dereferenced 
the
      return value of getValue as sal_Bool look suspicious, in that the author 
might
      have thought the given code would also cover a VOID Any---which 
technically it
      even would have happened to do.  If any RuntimeExceptions thrown from 
these
      doGet calls start to crop up, these changes need to be revisited.  Some 
may
      even be rewritten as uses of ">>=".  But at least "make check" did not 
show
      any such problems.  Also note that casting the value obtained from 
getValue to
      any css::uno::Reference<X> with X being anything but the base
      css::uno::XInterface was always prone to producing a bad pointer, in case 
the
      interface actually stored in the Any derived from X via multiple 
inheritance.)
    
    * Should there ever be cases where an Any is known to be of the requested 
type,
      some additional forceGet could be introduced (which would assert instead 
of
      throwing an exception).
    
    Change-Id: I2d8739e86314eff73abfcafe01d806f5bc5c34db

diff --git a/include/o3tl/any.hxx b/include/o3tl/any.hxx
new file mode 100644
index 0000000..268ae20
--- /dev/null
+++ b/include/o3tl/any.hxx
@@ -0,0 +1,264 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_O3TL_ANY_HXX
+#define INCLUDED_O3TL_ANY_HXX
+
+#include <sal/config.h>
+
+#include <type_traits>
+#include <utility>
+
+#include <boost/optional.hpp>
+
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/RuntimeException.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <cppu/unotype.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+// Some functionality related to css::uno::Any that would ideally be part of
+// <com/sun/star/uno/Any.hxx>, but (for now) cannot be for some reason.
+
+namespace com { namespace sun { namespace star { namespace uno {
+    class XInterface;
+} } } }
+
+namespace o3tl {
+
+namespace detail {
+
+struct Void {};
+
+template<typename T> struct Optional { using type = T const *; };
+template<> struct Optional<void> { using type = boost::optional<Void>; };
+template<> struct Optional<bool> { using type = boost::optional<bool>; };
+template<> struct Optional<sal_Int8> {
+    using type = boost::optional<sal_Int8>;
+};
+template<> struct Optional<sal_Int16> {
+    using type = boost::optional<sal_Int16>;
+};
+template<> struct Optional<sal_uInt16> {
+    using type = boost::optional<sal_uInt16>;
+};
+template<> struct Optional<sal_Int32> {
+    using type = boost::optional<sal_Int32>;
+};
+template<> struct Optional<sal_uInt32> {
+    using type = boost::optional<sal_uInt32>;
+};
+template<> struct Optional<sal_Int64> {
+    using type = boost::optional<sal_Int64>;
+};
+template<> struct Optional<sal_uInt64> {
+    using type = boost::optional<sal_uInt64>;
+};
+template<> struct Optional<float> { using type = boost::optional<float>; };
+template<> struct Optional<double> { using type = boost::optional<double>; };
+template<typename T> struct Optional<css::uno::Reference<T>> {
+    using type = boost::optional<css::uno::Reference<T>>;
+};
+template<> struct Optional<css::uno::Reference<css::uno::XInterface>> {
+    using type = css::uno::Reference<css::uno::XInterface> const *;
+};
+
+template<typename> struct IsDerivedReference: std::false_type {};
+template<typename T> struct IsDerivedReference<css::uno::Reference<T>>:
+    std::true_type
+{};
+template<> struct 
IsDerivedReference<css::uno::Reference<css::uno::XInterface>>:
+    std::false_type
+{};
+
+template<typename> struct IsUnoSequenceType: std::false_type {};
+template<typename T> struct IsUnoSequenceType<cppu::UnoSequenceType<T>>:
+    std::true_type
+{};
+
+template<typename T> inline boost::optional<T> tryGetConverted(
+    css::uno::Any const & any)
+{
+    T v;
+    return (any >>= v)
+        ? boost::optional<T>(std::move(v)) : boost::optional<T>();
+}
+
+}
+
+/** Try to get the value of a specific type from an Any.
+
+    In trying to obtain a value, the same set of conversions as supported by
+    ">>=" are considere.
+
+    The returned object is a proxy.  Proxies can be either positive or 
negative.
+    Each proxy can be contextually converted to bool, yielding true iff the
+    proxy is positive.  For a positive proxy P representing a value of 
requested
+    type T, for any T other than void, the expression *P yields that value of
+    type T.  (Technically, the proxy is either a plain pointer or a
+    boost::optional, depending on whether a plain pointer into the given Any 
can
+    be returned for the specified type.)
+
+    @note Ideally this would be a public member function of css::uno::Any (at
+    least conditional on LIBO_INTERNAL_ONLY, as it requires C++11).  However, 
as
+    std::optional (which would be needed to implement the proxies) is only
+    available since C++14, we need to use boost::optional for now.  But To not
+    make every entity that includes <com/sun/star/uno/Any.hxx> depend on
+    boost_headers, keep this here for now.
+
+    @tparam T  the C++ representation of a UNO type that can be contained in a
+    UNO ANY (i.e., any UNO type other than ANY itself).  The legacy C++
+    representations sal_Bool, cppu::UnoVoidType, cppu::UnoUnsignedShortType,
+    cppu::UnoCharType, and cppu::UnoSequenceType are not supported.
+
+    @param any  an Any value.
+
+    @return a positive proxy for the value of the specfied type obtained from
+    the given Any, or a negative proxy if no such value can be obtained.
+*/
+template<typename T> inline
+typename std::enable_if<
+    !(detail::IsDerivedReference<T>::value
+      || detail::IsUnoSequenceType<T>::value),
+    typename detail::Optional<T>::type>::type
+tryGet(css::uno::Any const & any) {
+    // CHAR, STRING, TYPE, sequence types, enum types, struct types, exception
+    // types, and com.sun.star.uno.XInterface interface type:
+    return cppu::UnoType<T>::get().isAssignableFrom(any.getValueType())
+        ? static_cast<T const *>(any.getValue()) : nullptr;
+}
+
+template<> inline detail::Optional<void>::type tryGet<void>(
+    css::uno::Any const & any)
+{
+    return any.hasValue()
+        ? boost::optional<detail::Void>()
+        : boost::optional<detail::Void>(detail::Void());
+}
+
+template<> inline detail::Optional<bool>::type tryGet<bool>(
+    css::uno::Any const & any)
+{
+    return detail::tryGetConverted<bool>(any);
+}
+
+template<> inline detail::Optional<sal_Int8>::type tryGet<sal_Int8>(
+    css::uno::Any const & any)
+{
+    return detail::tryGetConverted<sal_Int8>(any);
+}
+
+template<> inline detail::Optional<sal_Int16>::type tryGet<sal_Int16>(
+    css::uno::Any const & any)
+{
+    return detail::tryGetConverted<sal_Int16>(any);
+}
+
+template<> inline detail::Optional<sal_uInt16>::type tryGet<sal_uInt16>(
+    css::uno::Any const & any)
+{
+    return detail::tryGetConverted<sal_uInt16>(any);
+}
+
+template<> inline detail::Optional<sal_Int32>::type tryGet<sal_Int32>(
+    css::uno::Any const & any)
+{
+    return detail::tryGetConverted<sal_Int32>(any);
+}
+
+template<> inline detail::Optional<sal_uInt32>::type tryGet<sal_uInt32>(
+    css::uno::Any const & any)
+{
+    return detail::tryGetConverted<sal_uInt32>(any);
+}
+
+template<> inline detail::Optional<sal_Int64>::type tryGet<sal_Int64>(
+    css::uno::Any const & any)
+{
+    return detail::tryGetConverted<sal_Int64>(any);
+}
+
+template<> inline detail::Optional<sal_uInt64>::type tryGet<sal_uInt64>(
+    css::uno::Any const & any)
+{
+    return detail::tryGetConverted<sal_uInt64>(any);
+}
+
+template<> inline detail::Optional<float>::type tryGet<float>(
+    css::uno::Any const & any)
+{
+    return detail::tryGetConverted<float>(any);
+}
+
+template<> inline detail::Optional<double>::type tryGet<double>(
+    css::uno::Any const & any)
+{
+    return detail::tryGetConverted<double>(any);
+}
+
+template<> detail::Optional<css::uno::Any>::type tryGet<css::uno::Any>(
+    css::uno::Any const &) = delete;
+
+template<> detail::Optional<sal_Bool>::type tryGet<sal_Bool>(
+    css::uno::Any const &) = delete;
+
+template<> detail::Optional<cppu::UnoVoidType>::type tryGet<cppu::UnoVoidType>(
+    css::uno::Any const &) = delete;
+
+template<> detail::Optional<cppu::UnoUnsignedShortType>::type
+tryGet<cppu::UnoUnsignedShortType>(css::uno::Any const &) = delete;
+
+template<> detail::Optional<cppu::UnoCharType>::type tryGet<cppu::UnoCharType>(
+    css::uno::Any const &) = delete;
+
+template<typename T> inline
+typename std::enable_if<
+    detail::IsDerivedReference<T>::value,
+    typename detail::Optional<T>::type>::type
+tryGet(css::uno::Any const & any) {
+    return detail::tryGetConverted<T>(any);
+}
+
+/** Get the value of a specific type from an Any, throwing an exception on
+    failure.
+
+    @note Ideally this would be a public member function of css::uno::Any.  See
+    tryGet for details.
+
+    @tparam T  the C++ representation of a UNO type that can be contained in a
+    UNO ANY.  See tryGet for details.
+
+    @param any  an Any value.
+
+    @return a positive proxy for the value of the specfied type obtained from
+    the given Any.  See tryGet for details.
+
+    @throws css::uno::RuntimeException  when a value of the requested type
+    cannot be obtained.
+*/
+template<typename T> inline typename detail::Optional<T>::type doGet(
+    css::uno::Any const & any)
+{
+    auto opt = tryGet<T>(any);
+    if (!opt) {
+        throw css::uno::RuntimeException(
+            OUString(
+                cppu_Any_extraction_failure_msg(
+                    &any, cppu::UnoType<T>::get().getTypeLibType()),
+                SAL_NO_ACQUIRE));
+    }
+    return opt;
+}
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/xmloff/source/core/unoatrcn.cxx b/xmloff/source/core/unoatrcn.cxx
index ed811df..ea84462 100644
--- a/xmloff/source/core/unoatrcn.cxx
+++ b/xmloff/source/core/unoatrcn.cxx
@@ -19,6 +19,7 @@
 
 #include <string.h>
 #include <com/sun/star/xml/AttributeData.hpp>
+#include <o3tl/any.hxx>
 #include <rtl/ustrbuf.hxx>
 #include <comphelper/servicehelper.hxx>
 #include <cppuhelper/supportsservice.hxx>
@@ -157,14 +158,12 @@ sal_Bool SAL_CALL 
SvUnoAttributeContainer::hasByName(const OUString& aName) thro
 void SAL_CALL SvUnoAttributeContainer::replaceByName(const OUString& aName, 
const uno::Any& aElement)
     throw( lang::IllegalArgumentException, container::NoSuchElementException, 
lang::WrappedTargetException, uno::RuntimeException, std::exception )
 {
-    if( aElement.hasValue() && aElement.getValueType() == 
cppu::UnoType<xml::AttributeData>::get())
+    if( auto pData = o3tl::tryGet<xml::AttributeData>(aElement) )
     {
         sal_uInt16 nAttr = getIndexByName(aName );
         if( nAttr == USHRT_MAX )
             throw container::NoSuchElementException();
 
-        xml::AttributeData const * pData = static_cast<xml::AttributeData 
const *>(aElement.getValue());
-
         sal_Int32 nPos = aName.indexOf( ':' );
         if( nPos != -1L )
         {
@@ -199,15 +198,14 @@ void SAL_CALL 
SvUnoAttributeContainer::replaceByName(const OUString& aName, cons
 void SAL_CALL SvUnoAttributeContainer::insertByName(const OUString& aName, 
const uno::Any& aElement)
 throw( lang::IllegalArgumentException, container::ElementExistException, 
lang::WrappedTargetException, uno::RuntimeException, std::exception )
 {
-    if( !aElement.hasValue() || aElement.getValueType() != 
cppu::UnoType<xml::AttributeData>::get())
+    auto pData = o3tl::tryGet<xml::AttributeData>(aElement);
+    if( !pData )
         throw lang::IllegalArgumentException();
 
     sal_uInt16 nAttr = getIndexByName(aName );
     if( nAttr != USHRT_MAX )
         throw container::ElementExistException();
 
-    xml::AttributeData const * pData = static_cast<xml::AttributeData const 
*>(aElement.getValue());
-
     sal_Int32 nPos = aName.indexOf( ':' );
     if( nPos != -1L )
     {
diff --git a/xmloff/source/draw/XMLImageMapExport.cxx 
b/xmloff/source/draw/XMLImageMapExport.cxx
index 9ea9b58..43ba083 100644
--- a/xmloff/source/draw/XMLImageMapExport.cxx
+++ b/xmloff/source/draw/XMLImageMapExport.cxx
@@ -18,6 +18,7 @@
  */
 
 #include "XMLImageMapExport.hxx"
+#include <o3tl/any.hxx>
 #include <rtl/ustring.hxx>
 #include <rtl/ustrbuf.hxx>
 #include <tools/debug.hxx>
@@ -199,7 +200,7 @@ void XMLImageMapExport::ExportMapEntry(
 
         // is-active
         aAny = rPropertySet->getPropertyValue(msIsActive);
-        if (! *static_cast<sal_Bool const *>(aAny.getValue()))
+        if (! *o3tl::doGet<bool>(aAny))
         {
             mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_NOHREF, XML_NOHREF);
         }
diff --git a/xmloff/source/draw/animationexport.cxx 
b/xmloff/source/draw/animationexport.cxx
index 97ae81c..b918057 100644
--- a/xmloff/source/draw/animationexport.cxx
+++ b/xmloff/source/draw/animationexport.cxx
@@ -49,7 +49,7 @@
 #include <com/sun/star/presentation/ShapeAnimationSubType.hpp>
 #include <com/sun/star/presentation/EffectCommands.hpp>
 #include <com/sun/star/drawing/XShape.hpp>
-
+#include <o3tl/any.hxx>
 #include <sax/tools/converter.hxx>
 
 #include <tools/debug.hxx>
@@ -513,7 +513,7 @@ public:
     void exportAudio( const Reference< XAudio >& xAudio );
     void exportCommand( const Reference< XCommand >& xCommand );
 
-    static Reference< XInterface > getParagraphTarget( const ParagraphTarget* 
pTarget );
+    static Reference< XInterface > getParagraphTarget( const ParagraphTarget& 
pTarget );
 
     static void convertPath( OUStringBuffer& sTmp, const Any& rPath );
     void convertValue( XMLTokenEnum eAttributeName, OUStringBuffer& sTmp, 
const Any& rValue ) const;
@@ -1412,14 +1412,14 @@ void AnimationsExporterImpl::exportCommand( const 
Reference< XCommand >& xComman
     }
 }
 
-Reference< XInterface > AnimationsExporterImpl::getParagraphTarget( const 
ParagraphTarget* pTarget )
+Reference< XInterface > AnimationsExporterImpl::getParagraphTarget( const 
ParagraphTarget& pTarget )
 {
-    if( pTarget ) try
+    try
     {
-        Reference< XEnumerationAccess > xParaEnumAccess( pTarget->Shape, 
UNO_QUERY_THROW );
+        Reference< XEnumerationAccess > xParaEnumAccess( pTarget.Shape, 
UNO_QUERY_THROW );
 
         Reference< XEnumeration > xEnumeration( 
xParaEnumAccess->createEnumeration(), UNO_QUERY_THROW );
-        sal_Int32 nParagraph = pTarget->Paragraph;
+        sal_Int32 nParagraph = pTarget.Paragraph;
 
         while( xEnumeration->hasMoreElements() )
         {
@@ -1450,18 +1450,16 @@ void AnimationsExporterImpl::convertValue( XMLTokenEnum 
eAttributeName, OUString
     if( !rValue.hasValue() )
         return;
 
-    if( rValue.getValueType() == cppu::UnoType<ValuePair>::get() )
+    if( auto pValuePair = o3tl::tryGet<ValuePair>(rValue) )
     {
-        const ValuePair* pValuePair = static_cast< const ValuePair* >( 
rValue.getValue() );
         OUStringBuffer sTmp2;
         convertValue( eAttributeName, sTmp, pValuePair->First );
         sTmp.append( ',' );
         convertValue( eAttributeName, sTmp2, pValuePair->Second );
         sTmp.append( sTmp2.makeStringAndClear() );
     }
-    else if( rValue.getValueType() == cppu::UnoType< Sequence<Any> >::get() )
+    else if( auto pSequence = o3tl::tryGet<Sequence<Any>>(rValue) )
     {
-        const Sequence<Any>* pSequence = static_cast< const Sequence<Any>* >( 
rValue.getValue() );
         const sal_Int32 nLength = pSequence->getLength();
         sal_Int32 nElement;
         const Any* pAny = pSequence->getConstArray();
@@ -1478,7 +1476,6 @@ void AnimationsExporterImpl::convertValue( XMLTokenEnum 
eAttributeName, OUString
     }
     else
     {
-        OUString aString;
         sal_Int32 nType;
 
         switch( eAttributeName )
@@ -1490,13 +1487,13 @@ void AnimationsExporterImpl::convertValue( XMLTokenEnum 
eAttributeName, OUString
         case XML_ANIMATETRANSFORM:
         case XML_ANIMATEMOTION:
         {
-            if( rValue >>= aString )
+            if( auto aString = o3tl::tryGet<OUString>(rValue) )
             {
-                sTmp.append( aString );
+                sTmp.append( *aString );
             }
-            else if( rValue.getValueType() == cppu::UnoType<double>::get() )
+            else if( auto x = o3tl::tryGet<double>(rValue) )
             {
-                sTmp.append( *(static_cast< const double* >( rValue.getValue() 
)) );
+                sTmp.append( *x );
             }
             else
             {
@@ -1530,6 +1527,7 @@ void AnimationsExporterImpl::convertValue( XMLTokenEnum 
eAttributeName, OUString
         const XMLPropertyHandler* pHandler = 
mpSdPropHdlFactory->GetPropertyHandler( nType );
         if( pHandler )
         {
+            OUString aString;
             pHandler->exportXML( aString, rValue, 
mrExport.GetMM100UnitConverter() );
             sTmp.append( aString );
         }
@@ -1541,9 +1539,8 @@ void AnimationsExporterImpl::convertTiming( 
OUStringBuffer& sTmp, const Any& rVa
     if( !rValue.hasValue() )
         return;
 
-    if( rValue.getValueType() == cppu::UnoType< Sequence<Any> >::get() )
+    if( auto pSequence = o3tl::tryGet<Sequence<Any>>(rValue) )
     {
-        const Sequence<Any>* pSequence = static_cast< const Sequence<Any>* >( 
rValue.getValue() );
         const sal_Int32 nLength = pSequence->getLength();
         sal_Int32 nElement;
         const Any* pAny = pSequence->getConstArray();
@@ -1558,22 +1555,19 @@ void AnimationsExporterImpl::convertTiming( 
OUStringBuffer& sTmp, const Any& rVa
             sTmp.append( sTmp2.makeStringAndClear() );
         }
     }
-    else if( rValue.getValueType() == cppu::UnoType<double>::get() )
+    else if( auto x = o3tl::tryGet<double>(rValue) )
     {
-        sTmp.append( *(static_cast< const double* >( rValue.getValue() )) );
+        sTmp.append( *x );
         sTmp.append( 's');
     }
-    else if( rValue.getValueType() == cppu::UnoType<Timing>::get() )
+    else if( auto pTiming = o3tl::tryGet<Timing>(rValue) )
     {
-        const Timing* pTiming = static_cast< const Timing* >( 
rValue.getValue() );
         sTmp.append( GetXMLToken( (*pTiming == Timing_MEDIA) ? XML_MEDIA : 
XML_INDEFINITE ) );
     }
-    else if( rValue.getValueType() == cppu::UnoType<Event>::get() )
+    else if( auto pEvent = o3tl::tryGet<Event>(rValue) )
     {
         OUStringBuffer sTmp2;
 
-        const Event* pEvent = static_cast< const Event* >( rValue.getValue() );
-
         if( pEvent->Trigger != EventTrigger::NONE )
         {
             if( pEvent->Source.hasValue() )
@@ -1615,13 +1609,12 @@ void AnimationsExporterImpl::convertTarget( 
OUStringBuffer& sTmp, const Any& rTa
 
     Reference< XInterface > xRef;
 
-    if( rTarget.getValueTypeClass() == css::uno::TypeClass_INTERFACE )
+    if( !(rTarget >>= xRef) )
     {
-        rTarget >>= xRef;
-    }
-    else if( rTarget.getValueType() == cppu::UnoType<ParagraphTarget>::get() )
-    {
-        xRef = getParagraphTarget( static_cast< const ParagraphTarget* >( 
rTarget.getValue() ) );
+        if( auto pt = o3tl::tryGet<ParagraphTarget>(rTarget) )
+        {
+            xRef = getParagraphTarget( *pt );
+        }
     }
 
     DBG_ASSERT( xRef.is(), "xmloff::AnimationsExporterImpl::convertTarget(), 
invalid target type!" );
@@ -1638,15 +1631,13 @@ void AnimationsExporterImpl::prepareValue( const Any& 
rValue )
     if( !rValue.hasValue() )
         return;
 
-    if( rValue.getValueType() == cppu::UnoType<ValuePair>::get() )
+    if( auto pValuePair = o3tl::tryGet<ValuePair>(rValue) )
     {
-        const ValuePair* pValuePair = static_cast< const ValuePair* >( 
rValue.getValue() );
         prepareValue( pValuePair->First );
         prepareValue( pValuePair->Second );
     }
-    else if( rValue.getValueType() == cppu::UnoType< Sequence<Any> >::get() )
+    else if( auto pSequence = o3tl::tryGet<Sequence<Any>>(rValue) )
     {
-        const Sequence<Any>* pSequence = static_cast< const Sequence<Any>* >( 
rValue.getValue() );
         const sal_Int32 nLength = pSequence->getLength();
         sal_Int32 nElement;
         const Any* pAny = pSequence->getConstArray();
@@ -1660,15 +1651,14 @@ void AnimationsExporterImpl::prepareValue( const Any& 
rValue )
         if( xRef.is() )
             mrExport.getInterfaceToIdentifierMapper().registerReference( xRef 
);
     }
-    else if( rValue.getValueType() == cppu::UnoType<ParagraphTarget>::get() )
+    else if( auto pt = o3tl::tryGet<ParagraphTarget>(rValue) )
     {
-        Reference< XInterface> xRef( getParagraphTarget( static_cast< const 
ParagraphTarget* >( rValue.getValue() ) ) );
+        Reference< XInterface> xRef( getParagraphTarget( *pt ) );
         if( xRef.is() )
             mrExport.getInterfaceToIdentifierMapper().registerReference( xRef 
);
     }
-    else if( rValue.getValueType() == cppu::UnoType<Event>::get() )
+    else if( auto pEvent = o3tl::tryGet<Event>(rValue) )
     {
-        const Event* pEvent = static_cast< const Event* >( rValue.getValue() );
         prepareValue( pEvent->Source );
     }
 }
diff --git a/xmloff/source/draw/shapeexport.cxx 
b/xmloff/source/draw/shapeexport.cxx
index ed70149..d851046 100644
--- a/xmloff/source/draw/shapeexport.cxx
+++ b/xmloff/source/draw/shapeexport.cxx
@@ -85,6 +85,8 @@
 #include <comphelper/processfactory.hxx>
 #include <comphelper/storagehelper.hxx>
 
+#include <o3tl/any.hxx>
+
 #include <rtl/math.hxx>
 #include <rtl/ustrbuf.hxx>
 
@@ -1995,9 +1997,8 @@ void XMLShapeExport::ImpExportLineShape(
 
         // get the two points
         uno::Any aAny(xPropSet->getPropertyValue("Geometry"));
-        drawing::PointSequenceSequence const * pSourcePolyPolygon = 
static_cast<drawing::PointSequenceSequence const *>(aAny.getValue());
-
-        if(pSourcePolyPolygon)
+        if (auto pSourcePolyPolygon
+                = o3tl::tryGet<drawing::PointSequenceSequence>(aAny))
         {
             drawing::PointSequence* pOuterSequence = 
const_cast<css::drawing::PointSequenceSequence 
*>(pSourcePolyPolygon)->getArray();
             if(pOuterSequence)
@@ -2172,7 +2173,7 @@ void XMLShapeExport::ImpExportPolygonShape(
             // get PolygonBezier
             uno::Any aAny( xPropSet->getPropertyValue("Geometry") );
             const basegfx::B2DPolyPolygon aPolyPolygon(
-                
basegfx::tools::UnoPolyPolygonBezierCoordsToB2DPolyPolygon(*static_cast<drawing::PolyPolygonBezierCoords
 const *>(aAny.getValue())));
+                
basegfx::tools::UnoPolyPolygonBezierCoordsToB2DPolyPolygon(*o3tl::doGet<drawing::PolyPolygonBezierCoords>(aAny)));
 
             if(aPolyPolygon.count())
             {
@@ -2193,7 +2194,7 @@ void XMLShapeExport::ImpExportPolygonShape(
             // get non-bezier polygon
             uno::Any aAny( xPropSet->getPropertyValue("Geometry") );
             const basegfx::B2DPolyPolygon aPolyPolygon(
-                
basegfx::tools::UnoPointSequenceSequenceToB2DPolyPolygon(*static_cast<drawing::PointSequenceSequence
 const *>(aAny.getValue())));
+                
basegfx::tools::UnoPointSequenceSequenceToB2DPolyPolygon(*o3tl::doGet<drawing::PointSequenceSequence>(aAny)));
 
             if(!aPolyPolygon.areControlPointsUsed() && 1 == 
aPolyPolygon.count())
             {
@@ -2585,7 +2586,7 @@ void XMLShapeExport::ImpExportConnectorShape(
     if( xProps->getPropertyValue("PolyPolygonBezier") >>= aAny )
     {
         // get PolygonBezier
-        drawing::PolyPolygonBezierCoords const * pSourcePolyPolygon = 
static_cast<drawing::PolyPolygonBezierCoords const *>(aAny.getValue());
+        auto pSourcePolyPolygon = 
o3tl::tryGet<drawing::PolyPolygonBezierCoords>(aAny);
 
         if(pSourcePolyPolygon && pSourcePolyPolygon->Coordinates.getLength())
         {
diff --git a/xmloff/source/draw/ximpcustomshape.cxx 
b/xmloff/source/draw/ximpcustomshape.cxx
index 9f482d9..bdd7524 100644
--- a/xmloff/source/draw/ximpcustomshape.cxx
+++ b/xmloff/source/draw/ximpcustomshape.cxx
@@ -19,6 +19,7 @@
 
 #include "ximpcustomshape.hxx"
 #include "ximpshap.hxx"
+#include <o3tl/any.hxx>
 #include <rtl/math.hxx>
 #include <rtl/ustrbuf.hxx>
 #include <rtl/ustring.hxx>
@@ -1219,8 +1220,8 @@ void XMLEnhancedCustomShapeContext::EndElement()
                 case EAS_GluePoints :
                 {
                     uno::Sequence< 
css::drawing::EnhancedCustomShapeParameterPair > const & rSeq =
-                        *static_cast<uno::Sequence< 
css::drawing::EnhancedCustomShapeParameterPair > const *>(
-                            aPathIter->Value.getValue());
+                        *o3tl::doGet<uno::Sequence< 
css::drawing::EnhancedCustomShapeParameterPair > >(
+                            aPathIter->Value);
                     for ( i = 0; i < rSeq.getLength(); i++ )
                     {
                         CheckAndResolveEquationParameter( 
const_cast<css::drawing::EnhancedCustomShapeParameter &>(rSeq[ i ].First), pH );
@@ -1231,8 +1232,8 @@ void XMLEnhancedCustomShapeContext::EndElement()
                 case EAS_TextFrames :
                 {
                     uno::Sequence< css::drawing::EnhancedCustomShapeTextFrame 
> const & rSeq =
-                        *static_cast<uno::Sequence< 
css::drawing::EnhancedCustomShapeTextFrame > const *>(
-                            aPathIter->Value.getValue());
+                        *o3tl::doGet<uno::Sequence< 
css::drawing::EnhancedCustomShapeTextFrame > >(
+                            aPathIter->Value);
                     for ( i = 0; i < rSeq.getLength(); i++ )
                     {
                         CheckAndResolveEquationParameter( 
const_cast<css::drawing::EnhancedCustomShapeParameter &>(rSeq[ i 
].TopLeft.First), pH );
@@ -1263,18 +1264,18 @@ void XMLEnhancedCustomShapeContext::EndElement()
                     case EAS_RadiusRangeMinimum :
                     case EAS_RadiusRangeMaximum :
                     {
-                        CheckAndResolveEquationParameter( 
*const_cast<css::drawing::EnhancedCustomShapeParameter 
*>(static_cast<css::drawing::EnhancedCustomShapeParameter const *>(
-                            pValues->Value.getValue())), pH );
+                        CheckAndResolveEquationParameter( 
const_cast<css::drawing::EnhancedCustomShapeParameter 
&>(*o3tl::doGet<css::drawing::EnhancedCustomShapeParameter>(
+                            pValues->Value)), pH );
                     }
                     break;
 
                     case EAS_Position :
                     case EAS_Polar :
                     {
-                        CheckAndResolveEquationParameter( 
const_cast<css::drawing::EnhancedCustomShapeParameter 
&>((*static_cast<css::drawing::EnhancedCustomShapeParameterPair const *>(
-                            pValues->Value.getValue())).First), pH );
-                        CheckAndResolveEquationParameter( 
const_cast<css::drawing::EnhancedCustomShapeParameter 
&>((*static_cast<css::drawing::EnhancedCustomShapeParameterPair const *>(
-                            pValues->Value.getValue())).Second), pH );
+                        CheckAndResolveEquationParameter( 
const_cast<css::drawing::EnhancedCustomShapeParameter 
&>((*o3tl::doGet<css::drawing::EnhancedCustomShapeParameterPair>(
+                            pValues->Value)).First), pH );
+                        CheckAndResolveEquationParameter( 
const_cast<css::drawing::EnhancedCustomShapeParameter 
&>((*o3tl::doGet<css::drawing::EnhancedCustomShapeParameterPair>(
+                            pValues->Value)).Second), pH );
                     }
                     break;
                     default:
diff --git a/xmloff/source/style/XMLPageExport.cxx 
b/xmloff/source/style/XMLPageExport.cxx
index 0d4f406..d7fc0c1 100644
--- a/xmloff/source/style/XMLPageExport.cxx
+++ b/xmloff/source/style/XMLPageExport.cxx
@@ -18,6 +18,7 @@
  */
 
 #include <xmloff/XMLPageExport.hxx>
+#include <o3tl/any.hxx>
 #include <tools/debug.hxx>
 #include <xmloff/xmlnmspe.hxx>
 #include <xmloff/xmltoken.hxx>
@@ -92,7 +93,7 @@ bool XMLPageExport::exportStyle(
     if( xPropSetInfo->hasPropertyByName( sIsPhysical ) )
     {
         Any aAny = xPropSet->getPropertyValue( sIsPhysical );
-        if( !*static_cast<sal_Bool const *>(aAny.getValue()) )
+        if( !*o3tl::doGet<bool>(aAny) )
             return false;
     }
 
diff --git a/xmloff/source/style/prstylei.cxx b/xmloff/source/style/prstylei.cxx
index e246be5..1092568 100644
--- a/xmloff/source/style/prstylei.cxx
+++ b/xmloff/source/style/prstylei.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 <tools/debug.hxx>
 #include <osl/diagnose.h>
 #include <set>
@@ -373,7 +376,7 @@ void XMLPropStyleContext::CreateAndInsert( bool bOverwrite )
         if( !bNew && xPropSetInfo->hasPropertyByName( msIsPhysical ) )
         {
             Any aAny = xPropSet->getPropertyValue( msIsPhysical );
-            bNew = !*static_cast<sal_Bool const *>(aAny.getValue());
+            bNew = !*o3tl::doGet<bool>(aAny);
         }
         SetNew( bNew );
         if( rName != GetName() )
diff --git a/xmloff/source/style/styleexp.cxx b/xmloff/source/style/styleexp.cxx
index f96e1c7..d87979d 100644
--- a/xmloff/source/style/styleexp.cxx
+++ b/xmloff/source/style/styleexp.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 <tools/debug.hxx>
 #include <xmloff/nmspmap.hxx>
 #include <xmloff/xmlnmspe.hxx>
@@ -96,7 +99,7 @@ bool XMLStyleExport::exportStyle(
     if( xPropSetInfo->hasPropertyByName( sIsPhysical ) )
     {
         aAny = xPropSet->getPropertyValue( sIsPhysical );
-        if( !*static_cast<sal_Bool const *>(aAny.getValue()) )
+        if( !*o3tl::doGet<bool>(aAny) )
             return false;
     }
 
@@ -164,7 +167,7 @@ bool XMLStyleExport::exportStyle(
     if( xPropSetInfo->hasPropertyByName( sIsAutoUpdate ) )
     {
         aAny = xPropSet->getPropertyValue( sIsAutoUpdate );
-        if( *static_cast<sal_Bool const *>(aAny.getValue()) )
+        if( *o3tl::doGet<bool>(aAny) )
             GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_AUTO_UPDATE,
                                       XML_TRUE );
     }
@@ -474,7 +477,7 @@ void XMLStyleExport::exportStyleFamily(
             if (xPropSetInfo->hasPropertyByName( sIsPhysical ))
             {
                 Any aAny( xPropSet->getPropertyValue( sIsPhysical ) );
-                if (!*static_cast<sal_Bool const *>(aAny.getValue()))
+                if (!*o3tl::doGet<bool>(aAny))
                     continue;
             }
 
diff --git a/xmloff/source/style/xmlbahdl.cxx b/xmloff/source/style/xmlbahdl.cxx
index 6020dcd..5574ad6 100644
--- a/xmloff/source/style/xmlbahdl.cxx
+++ b/xmloff/source/style/xmlbahdl.cxx
@@ -19,6 +19,7 @@
 
 #include <xmlbahdl.hxx>
 
+#include <o3tl/any.hxx>
 #include <tools/debug.hxx>
 #include <sax/tools/converter.hxx>
 #include <xmloff/xmluconv.hxx>
@@ -693,7 +694,7 @@ bool XMLIsTransparentPropHdl::exportXML( OUString& 
rStrExpValue, const Any& rVal
     // MIB: This looks a bit strange, because bTransPropValue == bValue should
     // do the same, but this only applies if 'true' is represented by the same
     // 8 bit value in bValue and bTransPropValue. Who will ensure this?
-    bool bValue = *static_cast<sal_Bool const *>(rValue.getValue());
+    bool bValue = *o3tl::doGet<bool>(rValue);
     bool bIsTrans = bTransPropValue ? bValue : !bValue;
 
     if( bIsTrans )
diff --git a/xmloff/source/style/xmlnume.cxx b/xmloff/source/style/xmlnume.cxx
index ee4cfdc..d8470b4 100644
--- a/xmloff/source/style/xmlnume.cxx
+++ b/xmloff/source/style/xmlnume.cxx
@@ -33,6 +33,8 @@
 #include <com/sun/star/beans/PropertyValue.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
 
+#include <o3tl/any.hxx>
+
 #include <rtl/ustrbuf.hxx>
 
 #include <tools/debug.hxx>
@@ -674,7 +676,7 @@ void SvxXMLNumRuleExport::exportNumberingRule(
         xPropSetInfo->hasPropertyByName( sIsContinuousNumbering ) )
     {
         Any aAny( xPropSet->getPropertyValue( sIsContinuousNumbering ) );
-        bContNumbering = *static_cast<sal_Bool const *>(aAny.getValue());
+        bContNumbering = *o3tl::doGet<bool>(aAny);
     }
     if( bContNumbering )
         GetExport().AddAttribute( XML_NAMESPACE_TEXT,
@@ -702,7 +704,7 @@ void SvxXMLNumRuleExport::exportStyle( const Reference< 
XStyle >& rStyle )
     if( xPropSetInfo->hasPropertyByName( sIsPhysical ) )
     {
         aAny = xPropSet->getPropertyValue( sIsPhysical );
-        if( !*static_cast<sal_Bool const *>(aAny.getValue()) )
+        if( !*o3tl::doGet<bool>(aAny) )
             return;
     }
 
diff --git a/xmloff/source/style/xmlnumi.cxx b/xmloff/source/style/xmlnumi.cxx
index 0a8b5b6..a5153de 100644
--- a/xmloff/source/style/xmlnumi.cxx
+++ b/xmloff/source/style/xmlnumi.cxx
@@ -30,6 +30,7 @@
 #include <com/sun/star/style/XStyle.hpp>
 #include <com/sun/star/io/XOutputStream.hpp>
 
+#include <o3tl/any.hxx>
 #include <rtl/ustrbuf.hxx>
 #include <osl/diagnose.h>
 
@@ -1183,7 +1184,7 @@ void SvxXMLListStyleContext::CreateAndInsertLate( bool 
bOverwrite )
         if( !bNew && xPropSetInfo->hasPropertyByName( sIsPhysical ) )
         {
             Any aAny = xPropSet->getPropertyValue( sIsPhysical );
-            bNew = !*static_cast<sal_Bool const *>(aAny.getValue());
+            bNew = !*o3tl::doGet<bool>(aAny);
         }
 
         if ( xPropSetInfo->hasPropertyByName( "Hidden" ) )
diff --git a/xmloff/source/style/xmlstyle.cxx b/xmloff/source/style/xmlstyle.cxx
index 73aa905..6d9e8d9 100644
--- a/xmloff/source/style/xmlstyle.cxx
+++ b/xmloff/source/style/xmlstyle.cxx
@@ -695,7 +695,7 @@ Reference < XAutoStyleFamily > 
SvXMLStylesContext::GetAutoStyles( sal_uInt16 nFa
             if (xAutoStyleFamilies->hasByName(sName))
             {
                 Any aAny = xAutoStyleFamilies->getByName( sName );
-                xAutoStyles = *static_cast<Reference<XAutoStyleFamily> const 
*>(aAny.getValue());
+                aAny >>= xAutoStyles;
                 if( bPara )
                     const_cast<SvXMLStylesContext *>(this)->mxParaAutoStyles = 
xAutoStyles;
                 else
diff --git a/xmloff/source/text/XMLIndexMarkExport.cxx 
b/xmloff/source/text/XMLIndexMarkExport.cxx
index b4f0ad1..14c983f 100644
--- a/xmloff/source/text/XMLIndexMarkExport.cxx
+++ b/xmloff/source/text/XMLIndexMarkExport.cxx
@@ -18,6 +18,7 @@
  */
 
 #include "XMLIndexMarkExport.hxx"
+#include <o3tl/any.hxx>
 #include <tools/debug.hxx>
 #include <rtl/ustring.hxx>
 #include <rtl/ustrbuf.hxx>
@@ -91,7 +92,7 @@ void XMLIndexMarkExport::ExportIndexMark(
 
         // collapsed/alternative text entry?
         aAny = rPropSet->getPropertyValue(sIsCollapsed);
-        if (*static_cast<sal_Bool const *>(aAny.getValue()))
+        if (*o3tl::doGet<bool>(aAny))
         {
             // collapsed entry: needs alternative text
             nElementNo = 0;
@@ -107,7 +108,7 @@ void XMLIndexMarkExport::ExportIndexMark(
         {
             // start and end entries: has ID
             aAny = rPropSet->getPropertyValue(sIsStart);
-            nElementNo = *static_cast<sal_Bool const *>(aAny.getValue()) ? 1 : 
2;
+            nElementNo = *o3tl::doGet<bool>(aAny) ? 1 : 2;
 
             // generate ID
             OUStringBuffer sBuf;
diff --git a/xmloff/source/text/XMLLineNumberingExport.cxx 
b/xmloff/source/text/XMLLineNumberingExport.cxx
index df91119..6394f81 100644
--- a/xmloff/source/text/XMLLineNumberingExport.cxx
+++ b/xmloff/source/text/XMLLineNumberingExport.cxx
@@ -21,6 +21,7 @@
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/text/XLineNumberingProperties.hpp>
 #include <com/sun/star/style/LineNumberPosition.hpp>
+#include <o3tl/any.hxx>
 #include <sax/tools/converter.hxx>
 #include <xmloff/xmlexp.hxx>
 #include <xmloff/xmluconv.hxx>
@@ -89,7 +90,7 @@ void XMLLineNumberingExport::Export()
 
             // enable
             aAny = xLineNumbering->getPropertyValue(sIsOn);
-            if (! *static_cast<sal_Bool const *>(aAny.getValue()))
+            if (! *o3tl::doGet<bool>(aAny))
             {
                 rExport.AddAttribute(XML_NAMESPACE_TEXT,
                                      XML_NUMBER_LINES, XML_FALSE);
@@ -97,7 +98,7 @@ void XMLLineNumberingExport::Export()
 
             // count empty lines
             aAny = xLineNumbering->getPropertyValue(sCountEmptyLines);
-            if (! *static_cast<sal_Bool const *>(aAny.getValue()))
+            if (! *o3tl::doGet<bool>(aAny))
             {
                 rExport.AddAttribute(XML_NAMESPACE_TEXT,
                                      XML_COUNT_EMPTY_LINES, XML_FALSE);
@@ -105,7 +106,7 @@ void XMLLineNumberingExport::Export()
 
             // count in frames
             aAny = xLineNumbering->getPropertyValue(sCountLinesInFrames);
-            if (*static_cast<sal_Bool const *>(aAny.getValue()))
+            if (*o3tl::doGet<bool>(aAny))
             {
                 rExport.AddAttribute(XML_NAMESPACE_TEXT,
                                      XML_COUNT_IN_TEXT_BOXES, XML_TRUE);
@@ -113,7 +114,7 @@ void XMLLineNumberingExport::Export()
 
             // restart numbering
             aAny = xLineNumbering->getPropertyValue(sRestartAtEachPage);
-            if (*static_cast<sal_Bool const *>(aAny.getValue()))
+            if (*o3tl::doGet<bool>(aAny))
             {
                 rExport.AddAttribute(XML_NAMESPACE_TEXT,
                                      XML_RESTART_ON_PAGE, XML_TRUE);
diff --git a/xmloff/source/text/XMLRedlineExport.cxx 
b/xmloff/source/text/XMLRedlineExport.cxx
index f7b38ef..ce9bfa3 100644
--- a/xmloff/source/text/XMLRedlineExport.cxx
+++ b/xmloff/source/text/XMLRedlineExport.cxx
@@ -18,6 +18,7 @@
  */
 
 #include "XMLRedlineExport.hxx"
+#include <o3tl/any.hxx>
 #include <tools/debug.hxx>
 #include <rtl/ustring.hxx>
 #include <rtl/ustrbuf.hxx>
@@ -213,8 +214,8 @@ void XMLRedlineExport::ExportChangesListElements()
         Reference<XPropertySet> aDocPropertySet( rExport.GetModel(),
                                                  uno::UNO_QUERY );
         // redlining enabled?
-        bool bEnabled = *static_cast<sal_Bool const 
*>(aDocPropertySet->getPropertyValue(
-                                                sRecordChanges ).getValue());
+        bool bEnabled = *o3tl::doGet<bool>(aDocPropertySet->getPropertyValue(
+                                                sRecordChanges ));
 
         // only export if we have redlines or attributes
         if ( aEnumAccess->hasElements() || bEnabled )
@@ -248,7 +249,7 @@ void XMLRedlineExport::ExportChangesListElements()
                     // export only if not in header or footer
                     // (those must be exported with their XText)
                     aAny = xPropSet->getPropertyValue(sIsInHeaderFooter);
-                    if (! *static_cast<sal_Bool const *>(aAny.getValue()))
+                    if (! *o3tl::doGet<bool>(aAny))
                     {
                         // and finally, export change
                         ExportChangedRegion(xPropSet);
@@ -272,8 +273,8 @@ void XMLRedlineExport::ExportChangeAutoStyle(
         Any aIsStart = rPropSet->getPropertyValue(sIsStart);
         Any aIsCollapsed = rPropSet->getPropertyValue(sIsCollapsed);
 
-        if ( *static_cast<sal_Bool const *>(aIsStart.getValue()) ||
-             *static_cast<sal_Bool const *>(aIsCollapsed.getValue()) )
+        if ( *o3tl::doGet<bool>(aIsStart) ||
+             *o3tl::doGet<bool>(aIsCollapsed) )
             pCurrentChangesList->push_back(rPropSet);
     }
 
@@ -315,7 +316,7 @@ void XMLRedlineExport::ExportChangesListAutoStyles()
                     // export only if not in header or footer
                     // (those must be exported with their XText)
                     aAny = xPropSet->getPropertyValue(sIsInHeaderFooter);
-                    if (! *static_cast<sal_Bool const *>(aAny.getValue()))
+                    if (! *o3tl::doGet<bool>(aAny))
                     {
                         ExportChangeAutoStyle(xPropSet);
                     }
@@ -331,7 +332,7 @@ void XMLRedlineExport::ExportChangeInline(
     // determine element name (depending on collapsed, start/end)
     enum XMLTokenEnum eElement = XML_TOKEN_INVALID;
     Any aAny = rPropSet->getPropertyValue(sIsCollapsed);
-    bool bCollapsed = *static_cast<sal_Bool const *>(aAny.getValue());
+    bool bCollapsed = *o3tl::doGet<bool>(aAny);
     if (bCollapsed)
     {
         eElement = XML_CHANGE;
@@ -339,7 +340,7 @@ void XMLRedlineExport::ExportChangeInline(
     else
     {
         aAny = rPropSet->getPropertyValue(sIsStart);
-        const bool bStart = *static_cast<sal_Bool const *>(aAny.getValue());
+        const bool bStart = *o3tl::doGet<bool>(aAny);
         eElement = bStart ? XML_CHANGE_START : XML_CHANGE_END;
     }
 
@@ -364,7 +365,7 @@ void XMLRedlineExport::ExportChangedRegion(
 
     // merge-last-paragraph
     Any aAny = rPropSet->getPropertyValue(sMergeLastPara);
-    if( ! *static_cast<sal_Bool const *>(aAny.getValue()) )
+    if( ! *o3tl::doGet<bool>(aAny) )
         rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_MERGE_LAST_PARAGRAPH,
                              XML_FALSE);
 
@@ -581,11 +582,11 @@ void XMLRedlineExport::ExportStartOrEndRedline(
         }
         else if (sIsCollapsed.equals(pValues[i].Name))
         {
-            bIsCollapsed = *static_cast<sal_Bool const 
*>(pValues[i].Value.getValue());
+            bIsCollapsed = *o3tl::doGet<bool>(pValues[i].Value);
         }
         else if (sIsStart.equals(pValues[i].Name))
         {
-            bIsStart = *static_cast<sal_Bool const 
*>(pValues[i].Value.getValue());
+            bIsStart = *o3tl::doGet<bool>(pValues[i].Value);
         }
     }
 
diff --git a/xmloff/source/text/XMLSectionExport.cxx 
b/xmloff/source/text/XMLSectionExport.cxx
index 3242abf..825e6a0 100644
--- a/xmloff/source/text/XMLSectionExport.cxx
+++ b/xmloff/source/text/XMLSectionExport.cxx
@@ -18,6 +18,7 @@
  */
 
 #include "XMLSectionExport.hxx"
+#include <o3tl/any.hxx>
 #include <rtl/ustring.hxx>
 #include <rtl/ustrbuf.hxx>
 
@@ -429,7 +430,7 @@ void XMLSectionExport::ExportRegularSectionStart(
 
         // #97450# store hidden-status (of conditional sections only)
         aAny = xPropSet->getPropertyValue(sIsCurrentlyVisible);
-        if (! *static_cast<sal_Bool const *>(aAny.getValue()))
+        if (! *o3tl::doGet<bool>(aAny))
         {
             GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_IS_HIDDEN,
                                      XML_TRUE);
@@ -440,14 +441,14 @@ void XMLSectionExport::ExportRegularSectionStart(
         eDisplay = XML_NONE;
     }
     aAny = xPropSet->getPropertyValue(sIsVisible);
-    if (! *static_cast<sal_Bool const *>(aAny.getValue()))
+    if (! *o3tl::doGet<bool>(aAny))
     {
         GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_DISPLAY, eDisplay);
     }
 
     // protect + protection key
     aAny = xPropSet->getPropertyValue(sIsProtected);
-    if (*static_cast<sal_Bool const *>(aAny.getValue()))
+    if (*o3tl::doGet<bool>(aAny))
     {
         GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_PROTECTED, XML_TRUE);
     }
@@ -531,7 +532,7 @@ void XMLSectionExport::ExportRegularSectionStart(
                                          sItem);
 
                 aAny = xPropSet->getPropertyValue(sIsAutomaticUpdate);
-                if (*static_cast<sal_Bool const *>(aAny.getValue()))
+                if (*o3tl::doGet<bool>(aAny))
                 {
                     GetExport().AddAttribute(XML_NAMESPACE_OFFICE,
                                              XML_AUTOMATIC_UPDATE, XML_TRUE);
@@ -765,7 +766,7 @@ void XMLSectionExport::ExportBaseIndexStart(
 {
     // protect + protection key
     Any aAny = rPropertySet->getPropertyValue(sIsProtected);
-    if (*static_cast<sal_Bool const *>(aAny.getValue()))
+    if (*o3tl::doGet<bool>(aAny))
     {
         GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_PROTECTED, XML_TRUE);
     }
@@ -809,7 +810,7 @@ void XMLSectionExport::ExportBaseIndexSource(
     {
         // document or chapter index?
         aAny = rPropertySet->getPropertyValue(sCreateFromChapter);
-        if (*static_cast<sal_Bool const *>(aAny.getValue()))
+        if (*o3tl::doGet<bool>(aAny))
         {
             GetExport().AddAttribute(XML_NAMESPACE_TEXT,
                                      XML_INDEX_SCOPE, XML_CHAPTER);
@@ -817,7 +818,7 @@ void XMLSectionExport::ExportBaseIndexSource(
 
         // tab-stops relative to margin?
         aAny = rPropertySet->getPropertyValue(sIsRelativeTabstops);
-        if (! *static_cast<sal_Bool const *>(aAny.getValue()))
+        if (! *o3tl::doGet<bool>(aAny))
         {
             GetExport().AddAttribute(XML_NAMESPACE_TEXT,
                                      XML_RELATIVE_TAB_STOP_POSITION,
@@ -914,7 +915,7 @@ void 
XMLSectionExport::ExportTableAndIllustrationIndexSourceAttributes(
 {
     // use caption
     Any aAny = rPropertySet->getPropertyValue(sCreateFromLabels);
-    if (! *static_cast<sal_Bool const *>(aAny.getValue()))
+    if (! *o3tl::doGet<bool>(aAny))
     {
         GetExport().AddAttribute(XML_NAMESPACE_TEXT,
                                  XML_USE_CAPTION, XML_FALSE);
@@ -1284,7 +1285,7 @@ void XMLSectionExport::ExportIndexTemplateElement(
 
                 case TOK_TPARAM_TAB_RIGHT_ALIGNED:
                     bRightAligned =
-                        *static_cast<sal_Bool const 
*>(rValues[i].Value.getValue());
+                        *o3tl::doGet<bool>(rValues[i].Value);
                     break;
 
                 case TOK_TPARAM_TAB_POSITION:
@@ -1294,7 +1295,7 @@ void XMLSectionExport::ExportIndexTemplateElement(
 
                 // #i21237#
                 case TOK_TPARAM_TAB_WITH_TAB:
-                    bWithTabStop = *static_cast<sal_Bool const 
*>(rValues[i].Value.getValue());
+                    bWithTabStop = *o3tl::doGet<bool>(rValues[i].Value);
                     bWithTabStopOK = true;
                     break;
 
@@ -1591,7 +1592,7 @@ void XMLSectionExport::ExportBoolean(
     OSL_ENSURE(eAttributeName != XML_TOKEN_INVALID, "Need attribute name");
 
     Any aAny = rPropSet->getPropertyValue(sPropertyName);
-    bool bTmp = *static_cast<sal_Bool const *>(aAny.getValue());
+    bool bTmp = *o3tl::doGet<bool>(aAny);
 
     // value = value ^ bInvert
     // omit if value == default
@@ -1647,14 +1648,14 @@ void 
XMLSectionExport::ExportBibliographyConfiguration(SvXMLExport& rExport)
             rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_SUFFIX, sTmp);
 
             aAny = xPropSet->getPropertyValue(sIsNumberEntries);
-            if (*static_cast<sal_Bool const *>(aAny.getValue()))
+            if (*o3tl::doGet<bool>(aAny))
             {
                 rExport.AddAttribute(XML_NAMESPACE_TEXT,
                                      XML_NUMBERED_ENTRIES, XML_TRUE);
             }
 
             aAny = xPropSet->getPropertyValue(sIsSortByPosition);
-            if (! *static_cast<sal_Bool const *>(aAny.getValue()))
+            if (! *o3tl::doGet<bool>(aAny))
             {
                 rExport.AddAttribute(XML_NAMESPACE_TEXT,
                                      XML_SORT_BY_POSITION, XML_FALSE);
@@ -1709,7 +1710,7 @@ void 
XMLSectionExport::ExportBibliographyConfiguration(SvXMLExport& rExport)
                     }
                     else if (rValue.Name == "IsSortAscending")
                     {
-                        bool bTmp = *static_cast<sal_Bool const 
*>(rValue.Value.getValue());
+                        bool bTmp = *o3tl::doGet<bool>(rValue.Value);
                         rExport.AddAttribute(XML_NAMESPACE_TEXT,
                                              XML_SORT_ASCENDING,
                                              bTmp ? XML_TRUE : XML_FALSE);
@@ -1749,7 +1750,7 @@ bool XMLSectionExport::IsMuteSection(
             {
                 Any aAny = 
xPropSet->getPropertyValue(sIsGlobalDocumentSection);
 
-                if ( *static_cast<sal_Bool const *>(aAny.getValue()) )
+                if ( *o3tl::doGet<bool>(aAny) )
                 {
                     Reference<XDocumentIndex> xIndex;
                     if (! GetIndex(rSection, xIndex))
diff --git a/xmloff/source/text/XMLTextColumnsExport.cxx 
b/xmloff/source/text/XMLTextColumnsExport.cxx
index ee797e2..4d5eee5 100644
--- a/xmloff/source/text/XMLTextColumnsExport.cxx
+++ b/xmloff/source/text/XMLTextColumnsExport.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 <rtl/ustrbuf.hxx>
 
 
@@ -72,7 +75,7 @@ void XMLTextColumnsExport::exportXML( const Any& rAny )
     if( xPropSet.is() )
     {
         Any aAny = xPropSet->getPropertyValue( sIsAutomatic );
-        if ( *static_cast<sal_Bool const *>(aAny.getValue()) )
+        if ( *o3tl::doGet<bool>(aAny) )
         {
             aAny = xPropSet->getPropertyValue( sAutomaticDistance );
             sal_Int32 nDistance = 0;
@@ -92,7 +95,7 @@ void XMLTextColumnsExport::exportXML( const Any& rAny )
     if( xPropSet.is() )
     {
         Any aAny = xPropSet->getPropertyValue( sSeparatorLineIsOn );
-        if( *static_cast<sal_Bool const *>(aAny.getValue()) )
+        if( *o3tl::doGet<bool>(aAny) )
         {
             // style:width
             aAny = xPropSet->getPropertyValue( sSeparatorLineWidth );
diff --git a/xmloff/source/text/XMLTextHeaderFooterContext.cxx 
b/xmloff/source/text/XMLTextHeaderFooterContext.cxx
index efa42e3..6dc6e25 100644
--- a/xmloff/source/text/XMLTextHeaderFooterContext.cxx
+++ b/xmloff/source/text/XMLTextHeaderFooterContext.cxx
@@ -20,6 +20,7 @@
 #include <com/sun/star/text/XText.hpp>
 #include <com/sun/star/text/XParagraphAppend.hpp>
 #include <com/sun/star/text/XRelativeTextContentRemove.hpp>
+#include <o3tl/any.hxx>
 #include <xmloff/nmspmap.hxx>
 #include <xmloff/xmlnmspe.hxx>
 #include "XMLTextHeaderFooterContext.hxx"
@@ -58,7 +59,7 @@ XMLTextHeaderFooterContext::XMLTextHeaderFooterContext( 
SvXMLImport& rImport, sa
         Any aAny;
 
         aAny = xPropSet->getPropertyValue( sOn );
-        bool bOn = *static_cast<sal_Bool const *>(aAny.getValue());
+        bool bOn = *o3tl::doGet<bool>(aAny);
 
         if( bOn )
         {
@@ -124,7 +125,7 @@ SvXMLImportContext 
*XMLTextHeaderFooterContext::CreateChildContext(
             else
             {
                 aAny = xPropSet->getPropertyValue( sOn );
-                bool bOn = *static_cast<sal_Bool const *>(aAny.getValue());
+                bool bOn = *o3tl::doGet<bool>(aAny);
 
                 if( !bOn )
                 {
@@ -138,7 +139,7 @@ SvXMLImportContext 
*XMLTextHeaderFooterContext::CreateChildContext(
 
                 // If a header or footer is not shared, share it now.
                 aAny = xPropSet->getPropertyValue( sShareContent );
-                bool bShared = *static_cast<sal_Bool const *>(aAny.getValue());
+                bool bShared = *o3tl::doGet<bool>(aAny);
                 if( !bShared )
                 {
                     xPropSet->setPropertyValue( sShareContent, Any(true) );
diff --git a/xmloff/source/text/XMLTextMasterPageContext.cxx 
b/xmloff/source/text/XMLTextMasterPageContext.cxx
index 155d296..8d39758 100644
--- a/xmloff/source/text/XMLTextMasterPageContext.cxx
+++ b/xmloff/source/text/XMLTextMasterPageContext.cxx
@@ -21,6 +21,7 @@
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/style/PageStyleLayout.hpp>
 #include <com/sun/star/beans/XMultiPropertyStates.hpp>
+#include <o3tl/any.hxx>
 #include <osl/diagnose.h>
 #include <xmloff/nmspmap.hxx>
 #include <xmloff/xmlnmspe.hxx>
@@ -147,7 +148,7 @@ XMLTextMasterPageContext::XMLTextMasterPageContext( 
SvXMLImport& rImport,
     if( !bNew && xPropSetInfo->hasPropertyByName( sIsPhysical ) )
     {
         aAny = xPropSet->getPropertyValue( sIsPhysical );
-        bNew = !*static_cast<sal_Bool const *>(aAny.getValue());
+        bNew = !*o3tl::doGet<bool>(aAny);
     }
     SetNew( bNew );
 
diff --git a/xmloff/source/text/txtexppr.cxx b/xmloff/source/text/txtexppr.cxx
index 687fa59..d77a548 100644
--- a/xmloff/source/text/txtexppr.cxx
+++ b/xmloff/source/text/txtexppr.cxx
@@ -26,6 +26,7 @@
 #include <com/sun/star/text/TextContentAnchorType.hpp>
 #include <com/sun/star/awt/FontUnderline.hpp>
 #include <com/sun/star/text/XChapterNumberingSupplier.hpp>
+#include <o3tl/any.hxx>
 #include <tools/debug.hxx>
 #include <tools/color.hxx>
 #include <xmloff/txtprmap.hxx>
@@ -148,7 +149,7 @@ void XMLTextExportPropertySetMapper::handleSpecialItem(
     {
     case CTF_DROPCAPWHOLEWORD:
         DBG_ASSERT( !bDropWholeWord, "drop whole word is set already!" );
-        pThis->bDropWholeWord = *static_cast<sal_Bool const 
*>(rProperty.maValue.getValue());
+        pThis->bDropWholeWord = *o3tl::doGet<bool>(rProperty.maValue);
         break;
     case CTF_DROPCAPCHARSTYLE:
         DBG_ASSERT( sDropCharStyle.isEmpty(), "drop char style is set 
already!" );
@@ -1004,7 +1005,7 @@ void XMLTextExportPropertySetMapper::ContextFilter(
         }
         if( pWrapContourModeState  &&
             (!pWrapContourState ||
-             !*static_cast<sal_Bool const *>(pWrapContourState 
->maValue.getValue()) ) )
+             !*o3tl::doGet<bool>(pWrapContourState ->maValue) ) )
             pWrapContourModeState->mnIndex = -1;
     }
 
@@ -1022,7 +1023,7 @@ void XMLTextExportPropertySetMapper::ContextFilter(
         if( pHoriOrientState && pHoriOrientMirroredState )
         {
             if( pHoriOrientMirrorState &&
-                *static_cast<sal_Bool const 
*>(pHoriOrientMirrorState->maValue.getValue()) )
+                *o3tl::doGet<bool>(pHoriOrientMirrorState->maValue) )
                 pHoriOrientState->mnIndex = -1;
             else
                 pHoriOrientMirroredState->mnIndex = -1;
@@ -1098,7 +1099,7 @@ void XMLTextExportPropertySetMapper::ContextFilter(
         if( pShapeHoriOrientState && pShapeHoriOrientMirroredState )
         {
             if( pShapeHoriOrientMirrorState &&
-                *static_cast<sal_Bool const 
*>(pShapeHoriOrientMirrorState->maValue.getValue()) )
+                *o3tl::doGet<bool>(pShapeHoriOrientMirrorState->maValue) )
                 pShapeHoriOrientState->mnIndex = -1;
             else
                 pShapeHoriOrientMirroredState->mnIndex = -1;
diff --git a/xmloff/source/text/txtflde.cxx b/xmloff/source/text/txtflde.cxx
index c198d27..b87e256 100644
--- a/xmloff/source/text/txtflde.cxx
+++ b/xmloff/source/text/txtflde.cxx
@@ -64,6 +64,7 @@
 #include <com/sun/star/text/BibliographyDataType.hpp>
 #include <com/sun/star/sdb/CommandType.hpp>
 #include <com/sun/star/rdf/XMetadatable.hpp>
+#include <o3tl/any.hxx>
 #include <rtl/ustrbuf.hxx>
 #include <tools/debug.hxx>
 #include <rtl/math.hxx>
@@ -2950,7 +2951,7 @@ enum XMLTokenEnum XMLTextFieldExport::MapPageNumberName(
     enum XMLTokenEnum eName = XML_TOKEN_INVALID;
     PageNumberType ePage;
     Any aAny = xPropSet->getPropertyValue(sPropertySubType);
-    ePage = *static_cast<PageNumberType const *>(aAny.getValue());
+    ePage = *o3tl::doGet<PageNumberType>(aAny);
 
     switch (ePage)
     {
@@ -3492,7 +3493,7 @@ inline bool GetBoolProperty(
     const Reference<XPropertySet> & xPropSet)
 {
     Any aAny = xPropSet->getPropertyValue(sPropName);
-    bool bBool = *static_cast<sal_Bool const *>(aAny.getValue());
+    bool bBool = *o3tl::doGet<bool>(aAny);
     return bBool;
 }
 
diff --git a/xmloff/source/text/txtftne.cxx b/xmloff/source/text/txtftne.cxx
index f990e2f..9732442 100644
--- a/xmloff/source/text/txtftne.cxx
+++ b/xmloff/source/text/txtftne.cxx
@@ -26,6 +26,10 @@
  * - footnote configuration elements
  * - endnote configuration elements
  */
+
+#include <sal/config.h>
+
+#include <o3tl/any.hxx>
 #include <tools/debug.hxx>
 #include <rtl/ustrbuf.hxx>
 #include <com/sun/star/lang/XServiceInfo.hpp>
@@ -315,7 +319,7 @@ void 
XMLTextParagraphExport::exportTextFootnoteConfigurationHelper(
         aAny = rFootnoteConfig->getPropertyValue(
             sPositionEndOfDoc);
         GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_FOOTNOTES_POSITION,
-                                 ( (*static_cast<sal_Bool const 
*>(aAny.getValue())) ?
+                                 ( (*o3tl::doGet<bool>(aAny)) ?
                                         XML_DOCUMENT : XML_PAGE ) );
 
         aAny = rFootnoteConfig->getPropertyValue(sFootnoteCounting);
diff --git a/xmloff/source/text/txtimppr.cxx b/xmloff/source/text/txtimppr.cxx
index f89a142..6bc35f5 100644
--- a/xmloff/source/text/txtimppr.cxx
+++ b/xmloff/source/text/txtimppr.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 <osl/thread.h>
 #include <com/sun/star/awt/FontFamily.hpp>
 #include <com/sun/star/awt/FontPitch.hpp>
@@ -671,7 +674,7 @@ void XMLTextImportPropertyMapper::finished(
     // #i5775# don't overwrite %transparency with binary transparency
     if( ( pBackTransparency != nullptr ) && ( pBackTransparent != nullptr ) )
     {
-        if( ! *static_cast<sal_Bool const 
*>(pBackTransparent->maValue.getValue()) )
+        if( ! *o3tl::doGet<bool>(pBackTransparent->maValue) )
             pBackTransparent->mnIndex = -1;
     }
 
diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx
index efe5a79..dfea038 100644
--- a/xmloff/source/text/txtparae.cxx
+++ b/xmloff/source/text/txtparae.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 <xmloff/unointerfacetouniqueidentifiermapper.hxx>
 #include <tools/debug.hxx>
 #include <rtl/ustrbuf.hxx>
@@ -513,13 +516,13 @@ void XMLTextParagraphExport::Add( sal_uInt16 nFamily,
                             xNumPropSet->getPropertySetInfo()
                                        ->hasPropertyByName( "IsAutomatic" ) )
                         {
-                            bAdd = *static_cast<sal_Bool const 
*>(xNumPropSet->getPropertyValue( "IsAutomatic" ).getValue());
+                            bAdd = 
*o3tl::doGet<bool>(xNumPropSet->getPropertyValue( "IsAutomatic" ));
                             // Check on outline style (#i73361#)
                             if ( bAdd &&
                                  xNumPropSet->getPropertySetInfo()
                                            ->hasPropertyByName( 
"NumberingIsOutline" ) )
                             {
-                                bAdd = !(*static_cast<sal_Bool const 
*>(xNumPropSet->getPropertyValue( "NumberingIsOutline" ).getValue()));
+                                bAdd = 
!(*o3tl::doGet<bool>(xNumPropSet->getPropertyValue( "NumberingIsOutline" )));
                             }
                         }
                         else
@@ -619,13 +622,13 @@ void XMLTextParagraphExport::Add( sal_uInt16 nFamily,
                     xNumPropSet->getPropertySetInfo()
                                ->hasPropertyByName( "IsAutomatic" ) )
                 {
-                    bAdd = *static_cast<sal_Bool const 
*>(xNumPropSet->getPropertyValue( "IsAutomatic" ).getValue());
+                    bAdd = *o3tl::doGet<bool>(xNumPropSet->getPropertyValue( 
"IsAutomatic" ));
                     // Check on outline style (#i73361#)
                     if ( bAdd &&
                          xNumPropSet->getPropertySetInfo()
                                    ->hasPropertyByName( "NumberingIsOutline" ) 
)
                     {
-                        bAdd = !(*static_cast<sal_Bool const 
*>(xNumPropSet->getPropertyValue( "NumberingIsOutline" ).getValue()));
+                        bAdd = 
!(*o3tl::doGet<bool>(xNumPropSet->getPropertyValue( "NumberingIsOutline" )));
                     }
                 }
                 else
@@ -1456,13 +1459,13 @@ bool 
XMLTextParagraphExport::collectTextAutoStylesOptimized( bool bIsProgress )
             }
 
             Any aAny = xAutoStyleFamilies->getByName( sName );
-            Reference< XAutoStyleFamily > xAutoStyles = 
*static_cast<Reference<XAutoStyleFamily> const *>(aAny.getValue());
+            Reference< XAutoStyleFamily > xAutoStyles = 
*o3tl::doGet<Reference<XAutoStyleFamily>>(aAny);
             Reference < XEnumeration > xAutoStylesEnum( 
xAutoStyles->createEnumeration() );
 
             while ( xAutoStylesEnum->hasMoreElements() )
             {
                 aAny = xAutoStylesEnum->nextElement();
-                Reference< XAutoStyle > xAutoStyle = 
*static_cast<Reference<XAutoStyle> const *>(aAny.getValue());
+                Reference< XAutoStyle > xAutoStyle = 
*o3tl::doGet<Reference<XAutoStyle>>(aAny);
                 Reference < XPropertySet > xPSet( xAutoStyle, uno::UNO_QUERY );
                 Add( nFamily, xPSet, nullptr, true );
             }
@@ -1479,7 +1482,7 @@ bool 
XMLTextParagraphExport::collectTextAutoStylesOptimized( bool bIsProgress )
         while ( xTextFieldsEnum->hasMoreElements() )
         {
             Any aAny = xTextFieldsEnum->nextElement();
-            Reference< XTextField > xTextField = 
*static_cast<Reference<XTextField> const *>(aAny.getValue());
+            Reference< XTextField > xTextField = 
*o3tl::doGet<Reference<XTextField>>(aAny);
             exportTextField( xTextField, bAutoStyles, bIsProgress,
                 !xAutoStylesSupp.is() );
             try
@@ -1557,7 +1560,7 @@ bool 
XMLTextParagraphExport::collectTextAutoStylesOptimized( bool bIsProgress )
             for( sal_Int32 i = 0; i < nCount; ++i )
             {
                 Any aAny = xSections->getByIndex( i );
-                Reference< XTextSection > xSection = 
*static_cast<Reference<XTextSection> const *>(aAny.getValue());
+                Reference< XTextSection > xSection = 
*o3tl::doGet<Reference<XTextSection>>(aAny);
                 Reference < XPropertySet > xPSet( xSection, uno::UNO_QUERY );
                 Add( XML_STYLE_FAMILY_TEXT_SECTION, xPSet );
             }
@@ -1575,7 +1578,7 @@ bool 
XMLTextParagraphExport::collectTextAutoStylesOptimized( bool bIsProgress )
             for( sal_Int32 i = 0; i < nCount; ++i )
             {
                 Any aAny = xTables->getByIndex( i );
-                Reference< XTextTable > xTable = 
*static_cast<Reference<XTextTable> const *>(aAny.getValue());
+                Reference< XTextTable > xTable = 
*o3tl::doGet<Reference<XTextTable>>(aAny);
                 exportTable( xTable, true, true );
             }
         }
@@ -1605,13 +1608,13 @@ bool 
XMLTextParagraphExport::collectTextAutoStylesOptimized( bool bIsProgress )
                         xNumPropSet->getPropertySetInfo()
                                    ->hasPropertyByName( "IsAutomatic" ) )
                     {
-                        bAdd = *static_cast<sal_Bool const 
*>(xNumPropSet->getPropertyValue( "IsAutomatic" ).getValue());
+                        bAdd = 
*o3tl::doGet<bool>(xNumPropSet->getPropertyValue( "IsAutomatic" ));
                         // Check on outline style (#i73361#)
                         if ( bAdd &&
                              xNumPropSet->getPropertySetInfo()
                                        ->hasPropertyByName( 
"NumberingIsOutline" ) )
                         {
-                            bAdd = !(*static_cast<sal_Bool const 
*>(xNumPropSet->getPropertyValue( "NumberingIsOutline" ).getValue()));
+                            bAdd = 
!(*o3tl::doGet<bool>(xNumPropSet->getPropertyValue( "NumberingIsOutline" )));
                         }
                     }
                     else
@@ -2503,13 +2506,13 @@ void XMLTextParagraphExport::exportTextMark(
 
         // start, end, or point-reference?
         sal_Int8 nElement;
-        if( *static_cast<sal_Bool const 
*>(rPropSet->getPropertyValue(sIsCollapsed).getValue()) )
+        if( *o3tl::doGet<bool>(rPropSet->getPropertyValue(sIsCollapsed)) )
         {
             nElement = 0;
         }
         else
         {
-            nElement = *static_cast<sal_Bool const 
*>(rPropSet->getPropertyValue(sIsStart).getValue()) ? 1 : 2;
+            nElement = 
*o3tl::doGet<bool>(rPropSet->getPropertyValue(sIsStart)) ? 1 : 2;
         }
 
         // bookmark, bookmark-start: xml:id and RDFa for RDF metadata
@@ -2669,7 +2672,7 @@ XMLShapeExportFlags 
XMLTextParagraphExport::addTextFrameAttributes(
     bool bSyncWidth = false;
     if( xPropSetInfo->hasPropertyByName( sIsSyncWidthToHeight ) )
     {
-        bSyncWidth = *static_cast<sal_Bool const 
*>(rPropSet->getPropertyValue( sIsSyncWidthToHeight ).getValue());
+        bSyncWidth = *o3tl::doGet<bool>(rPropSet->getPropertyValue( 
sIsSyncWidthToHeight ));
         if( bSyncWidth )
             GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_REL_WIDTH,
                                       XML_SCALE );
@@ -2697,7 +2700,7 @@ XMLShapeExportFlags 
XMLTextParagraphExport::addTextFrameAttributes(
     bool bSyncHeight = false;
     if( xPropSetInfo->hasPropertyByName( sIsSyncHeightToWidth ) )
     {
-        bSyncHeight = *static_cast<sal_Bool const 
*>(rPropSet->getPropertyValue( sIsSyncHeightToWidth ).getValue());
+        bSyncHeight = *o3tl::doGet<bool>(rPropSet->getPropertyValue( 
sIsSyncHeightToWidth ));
     }
     sal_Int16 nRelHeight =  0;
     if( !bSyncHeight && xPropSetInfo->hasPropertyByName( sRelativeHeight ) )
@@ -2964,7 +2967,7 @@ void XMLTextParagraphExport::exportContour(
 
     if( rPropSetInfo->hasPropertyByName( sIsPixelContour ) )
     {
-        bPixel = *static_cast<sal_Bool const *>(rPropSet->getPropertyValue( 
sIsPixelContour ).getValue());
+        bPixel = *o3tl::doGet<bool>(rPropSet->getPropertyValue( 
sIsPixelContour ));
     }
 
     // svg: width
@@ -3026,8 +3029,8 @@ void XMLTextParagraphExport::exportContour(
 
     if( rPropSetInfo->hasPropertyByName( sIsAutomaticContour ) )
     {
-        bool bTmp = *static_cast<sal_Bool const *>(rPropSet->getPropertyValue(
-                                            sIsAutomaticContour ).getValue());
+        bool bTmp = *o3tl::doGet<bool>(rPropSet->getPropertyValue(
+                                            sIsAutomaticContour ));
         GetExport().AddAttribute( XML_NAMESPACE_DRAW,
                       XML_RECREATE_ON_EDIT, bTmp ? XML_TRUE : XML_FALSE );
     }
@@ -3247,7 +3250,7 @@ bool XMLTextParagraphExport::addHyperlinkAttributes(
          && ( !rPropState.is()
               || PropertyState_DIRECT_VALUE == rPropState->getPropertyState( 
sServerMap ) ) )
     {
-        bServerMap = *static_cast<sal_Bool const 
*>(rPropSet->getPropertyValue( sServerMap ).getValue());
+        bServerMap = *o3tl::doGet<bool>(rPropSet->getPropertyValue( sServerMap 
));
         if ( bServerMap )
             bExport = true;
     }
@@ -3624,11 +3627,11 @@ void XMLTextParagraphExport::exportRuby(
     bool bAutoStyles )
 {
     // early out: a collapsed ruby makes no sense
-    if (*static_cast<sal_Bool const 
*>(rPropSet->getPropertyValue(sIsCollapsed).getValue()))
+    if (*o3tl::doGet<bool>(rPropSet->getPropertyValue(sIsCollapsed)))
         return;
 
     // start value ?
-    bool bStart = *static_cast<sal_Bool const 
*>(rPropSet->getPropertyValue(sIsStart).getValue());
+    bool bStart = *o3tl::doGet<bool>(rPropSet->getPropertyValue(sIsStart));
 
     if (bAutoStyles)
     {
diff --git a/xmloff/source/text/txtprhdl.cxx b/xmloff/source/text/txtprhdl.cxx
index 6d3a227..3d4d2fb 100644
--- a/xmloff/source/text/txtprhdl.cxx
+++ b/xmloff/source/text/txtprhdl.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 <tools/debug.hxx>
 #include <osl/diagnose.h>
 #include <rtl/ustrbuf.hxx>
@@ -351,7 +354,7 @@ bool XMLOpaquePropHdl_Impl::exportXML(
         const Any& rValue,
         const SvXMLUnitConverter& ) const
 {
-    if( *static_cast<sal_Bool const *>(rValue.getValue()) )
+    if( *o3tl::doGet<bool>(rValue) )
            rStrExpValue = GetXMLToken( XML_FOREGROUND );
     else
            rStrExpValue = GetXMLToken( XML_BACKGROUND );
@@ -401,7 +404,7 @@ bool XMLContourModePropHdl_Impl::exportXML(
         const Any& rValue,
         const SvXMLUnitConverter& ) const
 {
-    if( *static_cast<sal_Bool const *>(rValue.getValue()) )
+    if( *o3tl::doGet<bool>(rValue) )
            rStrExpValue = GetXMLToken( XML_OUTSIDE );
     else
            rStrExpValue = GetXMLToken( XML_FULL );
@@ -454,7 +457,7 @@ bool XMLParagraphOnlyPropHdl_Impl::exportXML(
         const Any& rValue,
         const SvXMLUnitConverter& ) const
 {
-    if( *static_cast<sal_Bool const *>(rValue.getValue()) )
+    if( *o3tl::doGet<bool>(rValue) )
            rStrExpValue = GetXMLToken( XML_1 );
     else
            rStrExpValue = GetXMLToken( XML_NO_LIMIT );
@@ -580,7 +583,7 @@ bool XMLFrameProtectPropHdl_Impl::exportXML(
         const Any& rValue,
         const SvXMLUnitConverter& ) const
 {
-    if( *static_cast<sal_Bool const *>(rValue.getValue()) )
+    if( *o3tl::doGet<bool>(rValue) )
     {
         if( rStrExpValue.isEmpty() ||
             IsXMLToken( rStrExpValue, XML_NONE ) )
@@ -822,7 +825,7 @@ bool XMLGrfMirrorPropHdl_Impl::exportXML(
         const Any& rValue,
         const SvXMLUnitConverter& ) const
 {
-    if( *static_cast<sal_Bool const *>(rValue.getValue()) )
+    if( *o3tl::doGet<bool>(rValue) )
     {
         if( rStrExpValue.isEmpty() ||
             IsXMLToken( rStrExpValue, XML_NONE ) )
@@ -1097,7 +1100,7 @@ bool XMLTextSyncWidthHeightPropHdl_Impl::exportXML(
         const SvXMLUnitConverter& ) const
 {
     bool bRet = false;
-    if( *static_cast<sal_Bool const *>(rValue.getValue()) )
+    if( *o3tl::doGet<bool>(rValue) )
     {
         rStrExpValue = sValue;
         bRet = true;
diff --git a/xmloff/source/text/txtstyli.cxx b/xmloff/source/text/txtstyli.cxx
index eb748ea..ccd3a4c 100644
--- a/xmloff/source/text/txtstyli.cxx
+++ b/xmloff/source/text/txtstyli.cxx
@@ -39,6 +39,8 @@
 #include <com/sun/star/style/ParagraphStyleCategory.hpp>
 #include <com/sun/star/style/XStyle.hpp>
 
+#include <o3tl/any.hxx>
+
 #include <sax/tools/converter.hxx>
 
 #include <tools/debug.hxx>
@@ -482,7 +484,7 @@ void XMLTextStyleContext::FillPropertySet(
         if ( nIndex != -1 )
         {
             Any& rAny = GetProperties()[nIndex].maValue;
-            bool bVal = *static_cast<sal_Bool const *>(rAny.getValue());
+            bool bVal = *o3tl::doGet<bool>(rAny);
             bHasCombinedCharactersLetter = bVal;
         }
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to