Deprecate css::uno::makeAny; completely disable it for LIBO_INTERNAL_ONLY
There is just no good reason not to use a css::uno::Any constructor instead, so simplify the code base. For URE backwards compatibility, keep it around as deprecated for !LIBO_INTERNAL_ONLY. Change-Id: I9409d8853cac270d47377a31ba35a1fc23fa9800 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133879 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
@@ -22,7 +22,6 @@ int main()
|
||||
css::uno::Any b;
|
||||
a = b;
|
||||
a = getAny();
|
||||
a = css::uno::makeAny(true); // expected-error {{unnecessary copy, rather use <<= operator directly with the 'makeAny' argument [loplugin:unoany]}}
|
||||
a = css::uno::Any(true); // expected-error {{unnecessary copy, rather use <<= operator directly with the 'Any' constructor argument [loplugin:unoany]}}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ class Type;
|
||||
/** C++ class representing an IDL any.
|
||||
This class is used to transport any type defined in IDL. The class inherits from the
|
||||
binary C representation of uno_Any.
|
||||
You can insert a value by either using the <<= operators or the template function makeAny().
|
||||
You can insert a value by using the <<= operators.
|
||||
No any can hold an any. You can extract values from an any by using the >>= operators which
|
||||
return true if the any contains an assignable value (no data loss), e.g. the any contains a
|
||||
short and you >>= it into a long variable.
|
||||
@@ -303,12 +303,13 @@ template<> bool Any::has<sal_uInt16>() const SAL_DELETED_FUNCTION;
|
||||
/// @endcond
|
||||
#endif
|
||||
|
||||
#if !defined LIBO_INTERNAL_ONLY
|
||||
/** Template function to generically construct an any from a C++ value.
|
||||
|
||||
This can be useful with an explicitly specified template parameter, when the
|
||||
@deprecated Just use an Any constructor with an appropriately typed argument. (When the
|
||||
(UNO) type recorded in the Any instance shall be different from what would
|
||||
be deduced from the (C++) type of the argument if no template parameter were
|
||||
specified explicitly.
|
||||
be deduced from the (C++) type of the argument, cast the argument to the appropriate type
|
||||
first.)
|
||||
|
||||
@tparam C value type
|
||||
@param value a value
|
||||
@@ -317,16 +318,15 @@ template<> bool Any::has<sal_uInt16>() const SAL_DELETED_FUNCTION;
|
||||
template< class C >
|
||||
inline Any SAL_CALL makeAny( const C & value );
|
||||
|
||||
#if !defined LIBO_INTERNAL_ONLY
|
||||
template<> inline Any SAL_CALL makeAny(sal_uInt16 const & value);
|
||||
#endif
|
||||
|
||||
template<> Any SAL_CALL makeAny(Any const &) SAL_DELETED_FUNCTION;
|
||||
#endif
|
||||
|
||||
/** Wrap a value in an Any, if necessary.
|
||||
|
||||
The difference to makeAny is that makeAny cannot be called on an Any, while
|
||||
toAny just returns the given Any.
|
||||
(A difference to the deprecated makeAny is that makeAny cannot be called on an Any, while
|
||||
toAny just returns the given Any.)
|
||||
|
||||
@since LibreOffice 5.0
|
||||
*/
|
||||
|
||||
@@ -230,38 +230,32 @@ inline bool Any::operator != ( const Any & rAny ) const
|
||||
}
|
||||
|
||||
|
||||
#if !defined LIBO_INTERNAL_ONLY
|
||||
template< class C >
|
||||
inline Any SAL_CALL makeAny( const C & value )
|
||||
{
|
||||
return Any(value);
|
||||
}
|
||||
|
||||
#if !defined LIBO_INTERNAL_ONLY
|
||||
template<> Any makeAny(sal_uInt16 const & value)
|
||||
{ return Any(&value, cppu::UnoType<cppu::UnoUnsignedShortType>::get()); }
|
||||
#endif
|
||||
|
||||
template<typename T> Any toAny(T const & value) { return makeAny(value); }
|
||||
template<typename T> Any toAny(T const & value) {
|
||||
return Any(value);
|
||||
}
|
||||
|
||||
template<> Any toAny(Any const & value) { return value; }
|
||||
|
||||
#if defined LIBO_INTERNAL_ONLY
|
||||
|
||||
template<typename T1, typename T2>
|
||||
Any makeAny(rtl::OUStringConcat<T1, T2> && value)
|
||||
{ return Any(std::move(value)); }
|
||||
|
||||
template<typename T1, typename T2>
|
||||
Any toAny(rtl::OUStringConcat<T1, T2> && value)
|
||||
{ return makeAny(std::move(value)); }
|
||||
|
||||
template<typename T>
|
||||
Any makeAny(rtl::OUStringNumber<T> && value)
|
||||
{ return Any(OUString(std::move(value))); }
|
||||
{ return Any(std::move(value)); }
|
||||
|
||||
template<typename T>
|
||||
Any toAny(rtl::OUStringNumber<T> && value)
|
||||
{ return makeAny(std::move(value)); }
|
||||
{ return Any(std::move(value)); }
|
||||
|
||||
template<typename T> bool fromAny(Any const & any, T * value) {
|
||||
assert(value != nullptr);
|
||||
|
||||
@@ -438,12 +438,6 @@ inline void operator <<=( css::uno::Any & rAny, Color value )
|
||||
|
||||
namespace com::sun::star::uno {
|
||||
template<> inline Any::Any(Color const & value): Any(sal_Int32(value)) {}
|
||||
|
||||
template<>
|
||||
inline Any makeAny( Color const & value )
|
||||
{
|
||||
return Any(sal_Int32(value));
|
||||
}
|
||||
}
|
||||
|
||||
// Test compile time conversion of Color to sal_uInt32
|
||||
|
||||
Reference in New Issue
Block a user