20#ifndef INCLUDED_COMPHELPER_NAMEDVALUECOLLECTION_HXX
21#define INCLUDED_COMPHELPER_NAMEDVALUECOLLECTION_HXX
25#include <com/sun/star/uno/Sequence.hxx>
26#include <com/sun/star/uno/Any.hxx>
27#include <com/sun/star/beans/PropertyValue.hpp>
28#include <com/sun/star/beans/NamedValue.hpp>
31#include <unordered_map>
43 std::unordered_map< OUString, css::uno::Any >
maValues;
79 void assign(
const css::uno::Sequence< css::uno::Any >& _rArguments )
81 impl_assign( _rArguments );
86 impl_assign( css::uno::Sequence< css::beans::NamedValue >() );
95 static bool canExtractFrom( css::uno::Any
const & i_value );
105 ::std::vector< OUString >
119 bool _bOverwriteExisting
143 template <
typename VALUE_TYPE >
144 bool get_ensureType(
const OUString& _rValueName, VALUE_TYPE& _out_rValue )
const
152 template <
typename VALUE_TYPE >
153 VALUE_TYPE
getOrDefault(
const OUString& _rValueName,
const VALUE_TYPE& _rDefault )
const
155 VALUE_TYPE retVal( _rDefault );
156 get_ensureType( _rValueName, retVal );
164 template <
typename VALUE_TYPE >
165 static VALUE_TYPE
getOrDefault(
const css::uno::Sequence<css::beans::PropertyValue> & rPropSeq,
166 std::u16string_view _rValueName,
const VALUE_TYPE& _rDefault )
168 VALUE_TYPE retVal( _rDefault );
178 const css::uno::Any&
get(
const OUString& _rValueName )
const
180 return impl_get( _rValueName );
188 static const css::uno::Any&
get(
const css::uno::Sequence<css::beans::PropertyValue>& rPropSeq, std::u16string_view _rValueName );
191 bool has(
const OUString& _rValueName )
const
193 return impl_has( _rValueName );
201 template <
typename VALUE_TYPE >
202 bool put(
const OUString& _rValueName,
const VALUE_TYPE& _rValue )
204 return impl_put( _rValueName, css::uno::Any( _rValue ) );
207 bool put(
const OUString& _rValueName,
const css::uno::Any& _rValue )
209 return impl_put( _rValueName, _rValue );
216 bool remove(
const OUString& _rValueName )
218 return impl_remove( _rValueName );
226 sal_Int32 operator >>= ( css::uno::Sequence< css::beans::PropertyValue >& _out_rValues )
const;
233 sal_Int32 operator >>= ( css::uno::Sequence< css::beans::NamedValue >& _out_rValues )
const;
237 css::uno::Sequence< css::beans::PropertyValue >
240 css::uno::Sequence< css::beans::PropertyValue > aValues;
247 css::uno::Sequence< css::uno::Any >
250 return impl_wrap< css::beans::PropertyValue >();
255 css::uno::Sequence< css::uno::Any >
258 return impl_wrap< css::beans::NamedValue >();
263 css::uno::Sequence< css::beans::NamedValue >
266 css::uno::Sequence< css::beans::NamedValue > aValues;
273 void impl_assign(
const css::uno::Sequence< css::uno::Any >& _rArguments );
274 void impl_assign(
const css::uno::Sequence< css::beans::PropertyValue >& _rArguments );
275 void impl_assign(
const css::uno::Sequence< css::beans::NamedValue >& _rArguments );
278 const OUString& _rValueName,
279 void* _pValueLocation,
280 const css::uno::Type& _rExpectedValueType
284 const css::uno::Sequence<css::beans::PropertyValue> & rPropSeq,
285 std::u16string_view _rValueName,
286 void* _pValueLocation,
287 const css::uno::Type& _rExpectedValueType
291 impl_get(
const OUString& _rValueName )
const;
293 bool impl_has(
const OUString& _rValueName )
const;
295 bool impl_put(
const OUString& _rValueName,
const css::uno::Any& _rValue );
297 bool impl_remove(
const OUString& _rValueName );
299 template<
class VALUE_TYPE >
302 css::uno::Sequence< VALUE_TYPE > aValues;
304 css::uno::Sequence< css::uno::Any > aWrappedValues( aValues.getLength() );
306 css::uno::Any* pO = aWrappedValues.getArray();
307 const VALUE_TYPE* pV = aValues.getConstArray();
308 const sal_Int32 nLen = aValues.getLength();
309 for( sal_Int32
i = 0;
i < nLen; ++
i )
310 *(pO++) = css::uno::Any( *(pV++) );
312 return aWrappedValues;
a collection of named values, packed in various formats.
css::uno::Sequence< css::uno::Any > impl_wrap() const
bool get_ensureType(const OUString &_rValueName, void *_pValueLocation, const css::uno::Type &_rExpectedValueType) const
void impl_assign(const css::uno::Sequence< css::uno::Any > &_rArguments)
css::uno::Sequence< css::uno::Any > getWrappedPropertyValues() const
returns a Sequence< Any >, containing PropertyValues
NamedValueCollection(const css::uno::Sequence< css::beans::NamedValue > &_rArguments)
constructs a collection
NamedValueCollection(const css::uno::Sequence< css::beans::PropertyValue > &_rArguments)
constructs a collection
bool has(const OUString &_rValueName) const
determines whether a value with a given name is present in the collection
bool get_ensureType(const OUString &_rValueName, VALUE_TYPE &_out_rValue) const
retrieves a value with a given name from the collection, if it is present
NamedValueCollection(NamedValueCollection &&_rCopySource) noexcept=default
const css::uno::Any & get(const OUString &_rValueName) const
retrieves a (untyped) value with a given name
NamedValueCollection & operator=(NamedValueCollection &&i_rCopySource) noexcept=default
static bool get_ensureType(const css::uno::Sequence< css::beans::PropertyValue > &rPropSeq, std::u16string_view _rValueName, void *_pValueLocation, const css::uno::Type &_rExpectedValueType)
NamedValueCollection()=default
bool remove(const OUString &_rValueName)
removes the value with the given name from the collection
NamedValueCollection(const css::uno::Any &_rElements)
constructs a collection
css::uno::Sequence< css::uno::Any > getWrappedNamedValues() const
returns a Sequence< Any >, containing NamedValues
void impl_assign(const css::uno::Any &i_rWrappedElements)
NamedValueCollection(const css::uno::Sequence< css::uno::Any > &_rArguments)
constructs a collection
bool put(const OUString &_rValueName, const VALUE_TYPE &_rValue)
puts a value into the collection
NamedValueCollection(const NamedValueCollection &_rCopySource)=default
std::unordered_map< OUString, css::uno::Any > maValues
css::uno::Sequence< css::beans::NamedValue > getNamedValues() const
transforms the collection into a sequence of NamedValues
NamedValueCollection & operator=(const NamedValueCollection &i_rCopySource)=default
void impl_assign(const css::uno::Sequence< css::beans::NamedValue > &_rArguments)
void impl_assign(const css::uno::Sequence< css::beans::PropertyValue > &_rArguments)
css::uno::Sequence< css::beans::PropertyValue > getPropertyValues() const
transforms the collection into a sequence of PropertyValues
static VALUE_TYPE getOrDefault(const css::uno::Sequence< css::beans::PropertyValue > &rPropSeq, std::u16string_view _rValueName, const VALUE_TYPE &_rDefault)
Retrieves a value with a given name, or defaults it to a given value, if it's not present in the coll...
VALUE_TYPE getOrDefault(const OUString &_rValueName, const VALUE_TYPE &_rDefault) const
retrieves a value with a given name, or defaults it to a given value, if it's not present in the coll...
void assign(const css::uno::Sequence< css::uno::Any > &_rArguments)
bool put(const OUString &_rValueName, const css::uno::Any &_rValue)
#define COMPHELPER_DLLPUBLIC
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)