20#include <com/sun/star/beans/XPropertyState.hpp>
36 Reference< XPropertySet > mxPropSet1;
37 Reference< XPropertyState > mxPropSet1State;
38 Reference< XPropertySetInfo > mxPropSet1Info;
40 Reference< XPropertySet > mxPropSet2;
41 Reference< XPropertyState > mxPropSet2State;
42 Reference< XPropertySetInfo > mxPropSet2Info;
45 PropertySetMergerImpl(
const Reference< XPropertySet > & rPropSet1,
const Reference< XPropertySet > & rPropSet2 );
48 virtual Reference< XPropertySetInfo > SAL_CALL getPropertySetInfo( )
override;
49 virtual void SAL_CALL
setPropertyValue(
const OUString& aPropertyName,
const Any& aValue )
override;
51 virtual void SAL_CALL addPropertyChangeListener(
const OUString& aPropertyName,
const Reference< XPropertyChangeListener >& xListener )
override;
52 virtual void SAL_CALL removePropertyChangeListener(
const OUString& aPropertyName,
const Reference< XPropertyChangeListener >& aListener )
override;
53 virtual void SAL_CALL addVetoableChangeListener(
const OUString& PropertyName,
const Reference< XVetoableChangeListener >& aListener )
override;
54 virtual void SAL_CALL removeVetoableChangeListener(
const OUString& PropertyName,
const Reference< XVetoableChangeListener >& aListener )
override;
57 virtual PropertyState SAL_CALL getPropertyState(
const OUString& PropertyName )
override;
58 virtual Sequence< PropertyState > SAL_CALL getPropertyStates(
const Sequence< OUString >& aPropertyName )
override;
59 virtual void SAL_CALL setPropertyToDefault(
const OUString& PropertyName )
override;
60 virtual Any SAL_CALL getPropertyDefault(
const OUString& aPropertyName )
override;
63 virtual Sequence< Property > SAL_CALL getProperties( )
override;
64 virtual Property SAL_CALL getPropertyByName(
const OUString& aName )
override;
65 virtual sal_Bool SAL_CALL hasPropertyByName(
const OUString& Name )
override;
72PropertySetMergerImpl::PropertySetMergerImpl( Reference< XPropertySet >
const & rPropSet1, Reference< XPropertySet >
const & rPropSet2 )
73: mxPropSet1( rPropSet1 )
74, mxPropSet1State( rPropSet1, UNO_QUERY )
75, mxPropSet1Info( rPropSet1->getPropertySetInfo() )
76, mxPropSet2( rPropSet2 )
77, mxPropSet2State( rPropSet2, UNO_QUERY )
78, mxPropSet2Info( rPropSet2->getPropertySetInfo() )
83Reference< XPropertySetInfo > SAL_CALL PropertySetMergerImpl::getPropertySetInfo( )
88void SAL_CALL PropertySetMergerImpl::setPropertyValue(
const OUString& aPropertyName,
const Any& aValue )
90 if( mxPropSet1Info->hasPropertyByName( aPropertyName ) )
92 mxPropSet1->setPropertyValue( aPropertyName, aValue );
96 mxPropSet2->setPropertyValue( aPropertyName, aValue );
100Any SAL_CALL PropertySetMergerImpl::getPropertyValue(
const OUString& PropertyName )
102 if( mxPropSet1Info->hasPropertyByName( PropertyName ) )
104 return mxPropSet1->getPropertyValue( PropertyName );
108 return mxPropSet2->getPropertyValue( PropertyName );
112void SAL_CALL PropertySetMergerImpl::addPropertyChangeListener(
const OUString& ,
const Reference< XPropertyChangeListener >& )
116void SAL_CALL PropertySetMergerImpl::removePropertyChangeListener(
const OUString& ,
const Reference< XPropertyChangeListener >& )
120void SAL_CALL PropertySetMergerImpl::addVetoableChangeListener(
const OUString& ,
const Reference< XVetoableChangeListener >& )
124void SAL_CALL PropertySetMergerImpl::removeVetoableChangeListener(
const OUString& ,
const Reference< XVetoableChangeListener >& )
129PropertyState SAL_CALL PropertySetMergerImpl::getPropertyState(
const OUString& PropertyName )
131 if( mxPropSet1Info->hasPropertyByName( PropertyName ) )
133 if( mxPropSet1State.is() )
135 return mxPropSet1State->getPropertyState( PropertyName );
139 return PropertyState_DIRECT_VALUE;
144 if( mxPropSet2State.is() )
146 return mxPropSet2State->getPropertyState( PropertyName );
150 return PropertyState_DIRECT_VALUE;
155Sequence< PropertyState > SAL_CALL PropertySetMergerImpl::getPropertyStates(
const Sequence< OUString >& aPropertyName )
157 const sal_Int32
nCount = aPropertyName.getLength();
158 Sequence< PropertyState > aPropStates( nCount );
160 std::transform(aPropertyName.begin(), aPropertyName.end(), aPropStates.getArray(),
161 [
this](
const OUString& rPropName) -> PropertyState { return getPropertyState(rPropName); });
166void SAL_CALL PropertySetMergerImpl::setPropertyToDefault(
const OUString& PropertyName )
168 if( mxPropSet1State.is() && mxPropSet1Info->hasPropertyByName( PropertyName ) )
170 mxPropSet1State->setPropertyToDefault( PropertyName );
174 if( mxPropSet2State.is() )
176 mxPropSet2State->setPropertyToDefault( PropertyName );
181Any SAL_CALL PropertySetMergerImpl::getPropertyDefault(
const OUString& aPropertyName )
183 if( mxPropSet1State.is() && mxPropSet1Info->hasPropertyByName( aPropertyName ) )
185 return mxPropSet1State->getPropertyDefault( aPropertyName );
189 if( mxPropSet2State.is() )
191 return mxPropSet2State->getPropertyDefault( aPropertyName );
202Sequence< Property > SAL_CALL PropertySetMergerImpl::getProperties()
204 Sequence< Property > aProps1( mxPropSet1Info->getProperties() );
205 Sequence< Property > aProps2( mxPropSet2Info->getProperties() );
210Property SAL_CALL PropertySetMergerImpl::getPropertyByName(
const OUString& aName )
212 if( mxPropSet1Info->hasPropertyByName( aName ) )
213 return mxPropSet1Info->getPropertyByName( aName );
215 return mxPropSet2Info->getPropertyByName( aName );
218sal_Bool SAL_CALL PropertySetMergerImpl::hasPropertyByName(
const OUString& Name )
220 if(mxPropSet1Info->hasPropertyByName( Name ) )
223 return mxPropSet2Info->hasPropertyByName( Name );
228 return new PropertySetMergerImpl( rPropSet1, rPropSet2 );
Reference< XPropertySet > PropertySetMerger_CreateInstance(const Reference< XPropertySet > &rPropSet1, const Reference< XPropertySet > &rPropSet2) noexcept
css::uno::Sequence< T > concatSequences(const css::uno::Sequence< T > &rS1, const Ss &... rSn)
VBAHELPER_DLLPUBLIC bool setPropertyValue(css::uno::Sequence< css::beans::PropertyValue > &aProp, const OUString &aName, const css::uno::Any &aValue)
bool getPropertyValue(ValueType &rValue, css::uno::Reference< css::beans::XPropertySet > const &xPropSet, OUString const &propName)