20#include <com/sun/star/container/XNameContainer.hpp>
21#include <com/sun/star/uno/Sequence.h>
22#include <com/sun/star/beans/PropertyValue.hpp>
25#include <com/sun/star/lang/XServiceInfo.hpp>
37class NamedPropertyValuesContainer :
public cppu::WeakImplHelper< container::XNameContainer, lang::XServiceInfo >
40 NamedPropertyValuesContainer()
noexcept;
43 virtual void SAL_CALL insertByName(
const OUString&
aName,
const css::uno::Any& aElement )
override;
44 virtual void SAL_CALL removeByName(
const OUString&
Name )
override;
47 virtual void SAL_CALL replaceByName(
const OUString&
aName,
const css::uno::Any& aElement )
override;
50 virtual css::uno::Any SAL_CALL getByName(
const OUString&
aName )
override;
51 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames( )
override;
52 virtual sal_Bool SAL_CALL hasByName(
const OUString&
aName )
override;
55 virtual css::uno::Type SAL_CALL getElementType( )
override;
56 virtual sal_Bool SAL_CALL hasElements( )
override;
69NamedPropertyValuesContainer::NamedPropertyValuesContainer() noexcept
74void SAL_CALL NamedPropertyValuesContainer::insertByName(
const OUString& aName,
const uno::Any& aElement )
77 throw container::ElementExistException();
79 uno::Sequence<beans::PropertyValue> aProps;
80 if( !(aElement >>= aProps ) )
81 throw lang::IllegalArgumentException(
"element is not beans::PropertyValue",
static_cast<cppu::OWeakObject*
>(
this), 2);
86void SAL_CALL NamedPropertyValuesContainer::removeByName(
const OUString& Name )
88 NamedPropertyValues::iterator aIter =
maProperties.find( Name );
90 throw container::NoSuchElementException();
96void SAL_CALL NamedPropertyValuesContainer::replaceByName(
const OUString& aName,
const css::uno::Any& aElement )
98 NamedPropertyValues::iterator aIter =
maProperties.find( aName );
100 throw container::NoSuchElementException();
102 uno::Sequence<beans::PropertyValue> aProps;
103 if( !(aElement >>= aProps) )
104 throw lang::IllegalArgumentException(
"element is not beans::PropertyValue",
static_cast<cppu::OWeakObject*
>(
this), 2);
106 (*aIter).second = aProps;
110css::uno::Any SAL_CALL NamedPropertyValuesContainer::getByName(
const OUString& aName )
112 NamedPropertyValues::iterator aIter =
maProperties.find( aName );
114 throw container::NoSuchElementException();
118 aElement <<= (*aIter).second;
123css::uno::Sequence< OUString > SAL_CALL NamedPropertyValuesContainer::getElementNames( )
128sal_Bool SAL_CALL NamedPropertyValuesContainer::hasByName(
const OUString& aName )
130 NamedPropertyValues::iterator aIter =
maProperties.find( aName );
135css::uno::Type SAL_CALL NamedPropertyValuesContainer::getElementType( )
140sal_Bool SAL_CALL NamedPropertyValuesContainer::hasElements( )
146OUString SAL_CALL NamedPropertyValuesContainer::getImplementationName( )
148 return "NamedPropertyValuesContainer";
151sal_Bool SAL_CALL NamedPropertyValuesContainer::supportsService(
const OUString& ServiceName )
156css::uno::Sequence< OUString > SAL_CALL NamedPropertyValuesContainer::getSupportedServiceNames( )
158 return {
"com.sun.star.document.NamedPropertyValues" };
161extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
163 css::uno::XComponentContext *,
164 css::uno::Sequence<css::uno::Any>
const &)
166 return cppu::acquire(
new NamedPropertyValuesContainer());
std::map< OUString, uno::Sequence< beans::PropertyValue > > NamedPropertyValues
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * NamedPropertyValuesContainer_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
SvGenericNameContainerMapImpl maProperties
css::uno::Sequence< typename M::key_type > mapKeysToSequence(M const &map)
Copy (keys or values) from an associate container into a Sequence.
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)