24#include <com/sun/star/lang/XServiceInfo.hpp>
25#include <com/sun/star/lang/XTypeProvider.hpp>
36using namespace ::
cppu;
47 class GenericPropertySet :
public OWeakAggObject,
50 public PropertySetHelper
58 virtual void _setPropertyValues(
const PropertyMapEntry** ppEntries,
const Any* pValues )
override;
59 virtual void _getPropertyValues(
const PropertyMapEntry** ppEntries, Any* pValue )
override;
62 explicit GenericPropertySet( PropertySetInfo* pInfo )
noexcept;
65 virtual Any SAL_CALL queryAggregation(
const Type & rType )
override;
67 virtual void SAL_CALL acquire() noexcept override;
68 virtual
void SAL_CALL release() noexcept override;
71 virtual Sequence<
Type > SAL_CALL getTypes( ) override;
72 virtual Sequence<
sal_Int8 > SAL_CALL getImplementationId( ) override;
75 virtual OUString SAL_CALL getImplementationName() override;
76 virtual
sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
77 virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
80 virtual
void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::
uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
81 virtual
void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::
uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
88GenericPropertySet::GenericPropertySet( PropertySetInfo* pInfo ) noexcept
89: PropertySetHelper( pInfo )
93void SAL_CALL GenericPropertySet::addPropertyChangeListener(
const OUString& aPropertyName,
const Reference< XPropertyChangeListener >& xListener )
95 Reference < XPropertySetInfo > xInfo = getPropertySetInfo( );
99 std::unique_lock aGuard(
maMutex);
100 if ( aPropertyName.isEmpty() )
102 Sequence< Property>
aSeq = xInfo->getProperties();
105 for( ; pIter != pEnd ; ++pIter)
107 m_aListener.addInterface(aGuard, pIter->Name,xListener);
110 else if ( xInfo->hasPropertyByName(aPropertyName) )
111 m_aListener.addInterface(aGuard, aPropertyName,xListener);
113 throw UnknownPropertyException( aPropertyName, *
this );
116void SAL_CALL GenericPropertySet::removePropertyChangeListener(
const OUString& aPropertyName,
const Reference< XPropertyChangeListener >& xListener )
118 Reference < XPropertySetInfo > xInfo = getPropertySetInfo( );
122 std::unique_lock aGuard(
maMutex);
123 if ( aPropertyName.isEmpty() )
125 Sequence< Property>
aSeq = xInfo->getProperties();
128 for( ; pIter != pEnd ; ++pIter)
130 m_aListener.removeInterface(aGuard, pIter->Name,xListener);
133 else if ( xInfo->hasPropertyByName(aPropertyName) )
134 m_aListener.removeInterface(aGuard, aPropertyName,xListener);
136 throw UnknownPropertyException( aPropertyName, *
this );
139void GenericPropertySet::_setPropertyValues(
const PropertyMapEntry** ppEntries,
const Any* pValues )
141 std::unique_lock aGuard(
maMutex);
145 OInterfaceContainerHelper4<XPropertyChangeListener> * pHelper =
m_aListener.getContainer(aGuard, (*ppEntries)->maName);
151 PropertyChangeEvent aEvt;
152 aEvt.PropertyName = (*ppEntries)->maName;
154 pHelper->notifyEach( aGuard, &XPropertyChangeListener::propertyChange, aEvt );
164 std::unique_lock aGuard(
maMutex);
168 *pValue =
maAnyMap[ (*ppEntries)->maName ];
177Any SAL_CALL GenericPropertySet::queryInterface(
const Type & rType )
179 return OWeakAggObject::queryInterface( rType );
182Any SAL_CALL GenericPropertySet::queryAggregation(
const Type & rType )
187 aAny <<= Reference< XServiceInfo >(
this);
189 aAny <<= Reference< XTypeProvider >(
this);
191 aAny <<= Reference< XPropertySet >(
this);
193 aAny <<= Reference< XMultiPropertySet >(
this);
195 aAny = OWeakAggObject::queryAggregation( rType );
200void SAL_CALL GenericPropertySet::acquire() noexcept
202 OWeakAggObject::acquire();
205void SAL_CALL GenericPropertySet::release() noexcept
207 OWeakAggObject::release();
210uno::Sequence< uno::Type > SAL_CALL GenericPropertySet::getTypes()
212 return uno::Sequence {
220uno::Sequence< sal_Int8 > SAL_CALL GenericPropertySet::getImplementationId()
222 return css::uno::Sequence<sal_Int8>();
226sal_Bool SAL_CALL GenericPropertySet::supportsService(
const OUString& ServiceName )
231OUString SAL_CALL GenericPropertySet::getImplementationName()
233 return "com.sun.star.comp.comphelper.GenericPropertySet";
236Sequence< OUString > SAL_CALL GenericPropertySet::getSupportedServiceNames( )
238 return {
"com.sun.star.beans.XPropertySet" };
243 return static_cast<XPropertySet*
>(
new GenericPropertySet( pInfo ));
const PropertyValue * pValues
A helper class to store interface references of different types.
this class implements a XPropertySetInfo that is initialized with arrays of PropertyMapEntry.
css::uno::Type const & get()
std::map< OUString, Any > maAnyMap
comphelper::OMultiTypeInterfaceContainerHelperVar4< OUString, XPropertyChangeListener > m_aListener
Sequence< sal_Int8 > aSeq
class SAL_NO_VTABLE XPropertySet
COMPHELPER_DLLPUBLIC css::uno::Reference< css::beans::XPropertySet > GenericPropertySet_CreateInstance(PropertySetInfo *pInfo)
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
std::pair< OUString const, DataAccessDescriptorProperty > PropertyMapEntry