30#include <com/sun/star/beans/Property.hpp>
31#include <com/sun/star/beans/PropertyChangeEvent.hpp>
32#include <com/sun/star/beans/PropertyAttribute.hpp>
33#include <com/sun/star/beans/PropertyValue.hpp>
34#include <com/sun/star/beans/PropertyVetoException.hpp>
35#include <com/sun/star/beans/UnknownPropertyException.hpp>
36#include <com/sun/star/beans/XFastPropertySet.hpp>
37#include <com/sun/star/beans/XPropertyAccess.hpp>
38#include <com/sun/star/beans/XPropertyChangeListener.hpp>
39#include <com/sun/star/beans/XPropertySet.hpp>
40#include <com/sun/star/beans/XPropertySetInfo.hpp>
41#include <com/sun/star/beans/XVetoableChangeListener.hpp>
42#include <com/sun/star/container/NoSuchElementException.hpp>
43#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
44#include <com/sun/star/lang/DisposedException.hpp>
45#include <com/sun/star/lang/EventObject.hpp>
46#include <com/sun/star/lang/IllegalAccessException.hpp>
47#include <com/sun/star/lang/IllegalArgumentException.hpp>
48#include <com/sun/star/lang/WrappedTargetException.hpp>
49#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
50#include <com/sun/star/reflection/XCompoundTypeDescription.hpp>
51#include <com/sun/star/reflection/XIdlClass.hpp>
52#include <com/sun/star/reflection/XIdlField2.hpp>
53#include <com/sun/star/reflection/XIndirectTypeDescription.hpp>
54#include <com/sun/star/reflection/XInterfaceAttributeTypeDescription2.hpp>
55#include <com/sun/star/reflection/XInterfaceMemberTypeDescription.hpp>
56#include <com/sun/star/reflection/XInterfaceTypeDescription2.hpp>
57#include <com/sun/star/reflection/XStructTypeDescription.hpp>
58#include <com/sun/star/reflection/XTypeDescription.hpp>
59#include <com/sun/star/reflection/theCoreReflection.hpp>
60#include <com/sun/star/uno/Any.hxx>
61#include <com/sun/star/uno/Reference.hxx>
62#include <com/sun/star/uno/RuntimeException.hpp>
63#include <com/sun/star/uno/Sequence.hxx>
64#include <com/sun/star/uno/Type.hxx>
65#include <com/sun/star/uno/TypeClass.hpp>
66#include <com/sun/star/uno/XComponentContext.hpp>
67#include <com/sun/star/uno/XInterface.hpp>
74#include <rtl/ustring.hxx>
83 explicit PropertyData(
84 css::beans::Property theProperty,
bool thePresent):
85 property(
std::move(theProperty)), present(thePresent) {}
92 typedef std::map< OUString, PropertyData >
PropertyMap;
96 PropertyMap::const_iterator
get(
97 css::uno::Reference< css::uno::XInterface >
const &
object,
98 OUString
const & name)
const;
102 css::uno::Reference< css::reflection::XTypeDescription >
const & type,
103 css::uno::Sequence< OUString >
const & absentOptional,
104 std::vector< OUString > * handleNames)
106 std::set<OUString> seen;
107 initProperties(type, absentOptional, handleNames, &seen);
112 css::uno::Reference< css::reflection::XTypeDescription >
const & type,
113 css::uno::Sequence< OUString >
const & absentOptional,
114 std::vector< OUString > * handleNames, std::set<OUString> * seen);
116 static css::uno::Reference< css::reflection::XTypeDescription >
118 css::uno::Reference< css::reflection::XTypeDescription >
const & type);
121Data::PropertyMap::const_iterator Data::get(
122 css::uno::Reference< css::uno::XInterface >
const &
object,
123 OUString
const & name)
const
125 PropertyMap::const_iterator
i(
properties.find(name));
127 throw css::beans::UnknownPropertyException(name,
object);
132void Data::initProperties(
133 css::uno::Reference< css::reflection::XTypeDescription >
const & type,
134 css::uno::Sequence< OUString >
const & absentOptional,
135 std::vector< OUString > * handleNames, std::set<OUString> * seen)
137 css::uno::Reference< css::reflection::XInterfaceTypeDescription2 > ifc(
138 resolveTypedefs(type), css::uno::UNO_QUERY_THROW);
139 if (!seen->insert(ifc->getName()).second)
142 const css::uno::Sequence<
143 css::uno::Reference< css::reflection::XTypeDescription > > bases(
144 ifc->getBaseTypes());
145 for (
const auto & i : bases) {
146 initProperties(i, absentOptional, handleNames, seen);
148 const css::uno::Sequence<
150 css::reflection::XInterfaceMemberTypeDescription > >
members(
152 OUString
const * absentBegin = absentOptional.getConstArray();
153 OUString
const * absentEnd =
154 absentBegin + absentOptional.getLength();
155 for (
const auto & m : members) {
156 if (
m->getTypeClass()
157 == css::uno::TypeClass_INTERFACE_ATTRIBUTE)
160 css::reflection::XInterfaceAttributeTypeDescription2 > attr(
161 m, css::uno::UNO_QUERY_THROW);
162 sal_Int16 attrAttribs = 0;
163 if (attr->isBound()) {
164 attrAttribs |= css::beans::PropertyAttribute::BOUND;
166 bool bSetUnknown =
false;
167 if (attr->isReadOnly()) {
168 attrAttribs |= css::beans::PropertyAttribute::READONLY;
173 css::reflection::XCompoundTypeDescription > > excs(
174 attr->getGetExceptions());
175 bool bGetUnknown =
false;
179 for (
const auto & ex : std::as_const(excs)) {
180 if (
ex->getName() ==
"com.sun.star.beans.UnknownPropertyException" )
186 excs = attr->getSetExceptions();
187 for (
const auto & ex : std::as_const(excs)) {
188 if (
ex->getName() ==
"com.sun.star.beans.UnknownPropertyException" )
191 }
else if (
ex->getName() ==
"com.sun.star.beans.PropertyVetoException" )
194 |= css::beans::PropertyAttribute::CONSTRAINED;
197 if (bGetUnknown && bSetUnknown) {
198 attrAttribs |= css::beans::PropertyAttribute::OPTIONAL;
200 css::uno::Reference< css::reflection::XTypeDescription >
t(
204 t = resolveTypedefs(t);
206 if (
t->getName().startsWith(
207 "com.sun.star.beans.Ambiguous<"))
209 n = css::beans::PropertyAttribute::MAYBEAMBIGUOUS;
210 }
else if (
t->getName().startsWith(
211 "com.sun.star.beans.Defaulted<"))
213 n = css::beans::PropertyAttribute::MAYBEDEFAULT;
214 }
else if (
t->getName().startsWith(
215 "com.sun.star.beans.Optional<"))
217 n = css::beans::PropertyAttribute::MAYBEVOID;
221 if ((attrAttribs & n) != 0) {
225 const css::uno::Sequence<
226 css::uno::Reference< css::reflection::XTypeDescription > >
229 css::reflection::XStructTypeDescription >(
230 t, css::uno::UNO_QUERY_THROW)->
232 if (
args.getLength() != 1) {
233 throw css::uno::RuntimeException(
234 "inconsistent UNO type registry");
238 std::vector< OUString >::size_type handles
239 = handleNames->size();
240 if (handles > SAL_MAX_INT32) {
241 throw css::uno::RuntimeException(
242 "interface type has too many attributes");
244 OUString
name(
m->getMemberName());
248 css::beans::Property(
249 name,
static_cast< sal_Int32
>(handles),
251 t->getTypeClass(),
t->getName()),
253 (std::find(absentBegin, absentEnd, name)
257 throw css::uno::RuntimeException(
258 "inconsistent UNO type registry");
260 handleNames->push_back(name);
265css::uno::Reference< css::reflection::XTypeDescription > Data::resolveTypedefs(
266 css::uno::Reference< css::reflection::XTypeDescription >
const & type)
268 css::uno::Reference< css::reflection::XTypeDescription >
t(type);
269 while (
t->getTypeClass() == css::uno::TypeClass_TYPEDEF) {
270 t = css::uno::Reference< css::reflection::XIndirectTypeDescription >(
271 t, css::uno::UNO_QUERY_THROW)->getReferencedType();
276class Info:
public cppu::WeakImplHelper< css::beans::XPropertySetInfo > {
278 explicit Info(Data * data): m_data(data) {}
280 virtual css::uno::Sequence< css::beans::Property > SAL_CALL getProperties()
override;
282 virtual css::beans::Property SAL_CALL getPropertyByName(
283 OUString
const & name)
override;
285 virtual sal_Bool SAL_CALL hasPropertyByName(OUString
const & name)
override;
291css::uno::Sequence< css::beans::Property > Info::getProperties()
293 assert(m_data->properties.size() <= SAL_MAX_INT32);
294 css::uno::Sequence< css::beans::Property > s(
295 static_cast< sal_Int32
>(m_data->properties.size()));
296 auto r = asNonConstRange(s);
298 for (
const auto& rEntry : m_data->properties)
300 if (rEntry.second.present) {
301 r[
n++] = rEntry.second.property;
308css::beans::Property Info::getPropertyByName(OUString
const & name)
314sal_Bool Info::hasPropertyByName(OUString
const & name)
316 Data::PropertyMap::iterator
i(m_data->properties.find(name));
317 return i != m_data->properties.end() &&
i->second.present;
321std::multiset< css::uno::Reference< css::beans::XPropertyChangeListener > >
330 css::beans::PropertyChangeEvent
event;
333PropertySetMixinImpl::BoundListeners::BoundListeners(): m_impl(new
Impl) {}
340 for (
const auto& rxListener :
m_impl->specificListeners)
343 rxListener->propertyChange(
m_impl->event);
344 }
catch (css::lang::DisposedException &) {}
346 for (
const auto& rxListener :
m_impl->unspecificListeners)
349 rxListener->propertyChange(
m_impl->event);
350 }
catch (css::lang::DisposedException &) {}
357 css::uno::Reference< css::uno::XComponentContext >
const & context,
359 css::uno::Sequence< OUString >
const & absentOptional,
360 css::uno::Type
const &
type);
362 OUString
const & translateHandle(
363 css::uno::Reference< css::uno::XInterface >
const &
object,
364 sal_Int32 handle)
const;
367 css::uno::Reference< css::uno::XInterface >
const &
object,
368 OUString
const &
name, css::uno::Any
const &
value,
369 bool isAmbiguous,
bool isDefaulted, sal_Int16 illegalArgumentPosition)
373 css::uno::Reference< css::uno::XInterface >
const &
object,
374 OUString
const &
name, css::beans::PropertyState * state)
const;
382 std::multiset< css::uno::Reference< css::beans::XVetoableChangeListener > >
393 css::uno::Reference< css::reflection::XIdlClass > getReflection(
394 OUString
const & typeName)
const;
396 static css::uno::Any wrapValue(
397 css::uno::Reference< css::uno::XInterface >
const &
object,
398 css::uno::Any
const & value,
399 css::uno::Reference< css::reflection::XIdlClass >
const & type,
400 bool wrapAmbiguous,
bool isAmbiguous,
bool wrapDefaulted,
401 bool isDefaulted,
bool wrapOptional);
403 css::uno::Reference< css::uno::XComponentContext >
const &
m_context;
405 css::uno::Reference< css::reflection::XIdlClass >
m_idlClass;
409 css::uno::Reference< css::uno::XComponentContext >
const & context,
411 css::uno::Sequence< OUString >
const & absentOptional,
412 css::uno::Type
const & type):
413 implements(theImplements), disposed(false), m_context(context),
416 assert(context.is());
419 & ~(IMPLEMENTS_PROPERTY_SET | IMPLEMENTS_FAST_PROPERTY_SET
420 | IMPLEMENTS_PROPERTY_ACCESS))
423 css::uno::Reference< css::reflection::XTypeDescription > ifc;
426 css::uno::Reference< css::container::XHierarchicalNameAccess >(
428 "/singletons/com.sun.star.reflection."
429 "theTypeDescriptionManager"),
430 css::uno::UNO_QUERY_THROW)->getByHierarchicalName(
432 css::uno::UNO_QUERY_THROW);
433 }
catch (css::container::NoSuchElementException & e) {
435 throw css::lang::WrappedTargetRuntimeException(
436 "unexpected com.sun.star.container.NoSuchElementException: "
440 std::vector< OUString > handleNames;
441 initProperties(ifc, absentOptional, &handleNames);
442 std::vector< OUString >::size_type
size = handleNames.size();
445 std::copy(handleNames.begin(), handleNames.end(),
handleMap.getArray());
449 css::uno::Reference< css::uno::XInterface >
const &
object,
450 sal_Int32 handle)
const
452 if (handle < 0 || handle >= handleMap.getLength()) {
453 throw css::beans::UnknownPropertyException(
454 "bad handle " + OUString::number(handle),
object);
456 return handleMap[handle];
460 css::uno::Reference< css::uno::XInterface >
const &
object,
461 OUString
const & name, css::uno::Any
const & value,
bool isAmbiguous,
462 bool isDefaulted, sal_Int16 illegalArgumentPosition)
const
466 throw css::beans::UnknownPropertyException(
name,
object);
469 && ((
i->second.property.Attributes
470 & css::beans::PropertyAttribute::MAYBEAMBIGUOUS)
473 && ((
i->second.property.Attributes
474 & css::beans::PropertyAttribute::MAYBEDEFAULT)
477 throw css::lang::IllegalArgumentException(
478 (
"flagging as ambiguous/defaulted non-ambiguous/defaulted property "
480 object, illegalArgumentPosition);
482 css::uno::Reference< css::reflection::XIdlField2 > f(
483 m_idlClass->getField(
name), css::uno::UNO_QUERY_THROW);
484 css::uno::Any o(object->queryInterface(
m_type));
488 (css::uno::Reference< css::reflection::XIdlField2 >(
489 m_idlClass->getField(
name), css::uno::UNO_QUERY_THROW)->
491 ((
i->second.property.Attributes
492 & css::beans::PropertyAttribute::MAYBEAMBIGUOUS)
495 ((
i->second.property.Attributes
496 & css::beans::PropertyAttribute::MAYBEDEFAULT)
499 ((
i->second.property.Attributes
500 & css::beans::PropertyAttribute::MAYBEVOID)
504 }
catch (css::lang::IllegalArgumentException & e) {
505 if (e.ArgumentPosition == 1) {
506 throw css::lang::IllegalArgumentException(
507 e.Message,
object, illegalArgumentPosition);
510 throw css::lang::WrappedTargetRuntimeException(
511 "unexpected com.sun.star.lang.IllegalArgumentException: "
515 }
catch (css::lang::IllegalAccessException &) {
518 throw css::beans::PropertyVetoException(
519 "cannot set read-only property " +
name,
object);
520 }
catch (css::lang::WrappedTargetRuntimeException & e) {
525 if (e.TargetException.isExtractableTo(
527 && ((
i->second.property.Attributes
528 & css::beans::PropertyAttribute::OPTIONAL)
531 throw css::beans::UnknownPropertyException(
name,
object);
532 }
else if (e.TargetException.isExtractableTo(
534 && ((
i->second.property.Attributes
535 & css::beans::PropertyAttribute::CONSTRAINED)
538 css::beans::PropertyVetoException exc;
539 e.TargetException >>= exc;
540 if (exc.Message.isEmpty() )
541 throw css::beans::PropertyVetoException(
"Invalid " +
name,
object);
545 throw css::lang::WrappedTargetException(
546 e.Message,
object, e.TargetException);
552 css::uno::Reference< css::uno::XInterface >
const &
object,
553 OUString
const & name, css::beans::PropertyState * state)
const
557 throw css::beans::UnknownPropertyException(
name,
object);
559 css::uno::Reference< css::reflection::XIdlField2 > field(
560 m_idlClass->getField(
name), css::uno::UNO_QUERY_THROW);
563 value = field->get(object->queryInterface(
m_type));
564 }
catch (css::lang::IllegalArgumentException & e) {
566 throw css::lang::WrappedTargetRuntimeException(
567 "unexpected com.sun.star.lang.IllegalArgumentException: "
570 }
catch (css::lang::WrappedTargetRuntimeException & e) {
575 if (e.TargetException.isExtractableTo(
577 && ((
i->second.property.Attributes
578 & css::beans::PropertyAttribute::OPTIONAL)
581 throw css::beans::UnknownPropertyException(
name,
object);
583 throw css::lang::WrappedTargetException(
584 e.Message,
object, e.TargetException);
588 = ((
i->second.property.Attributes
589 & css::beans::PropertyAttribute::MAYBEAMBIGUOUS)
592 = ((
i->second.property.Attributes
593 & css::beans::PropertyAttribute::MAYBEDEFAULT)
596 = ((
i->second.property.Attributes
597 & css::beans::PropertyAttribute::MAYBEVOID)
599 bool isAmbiguous =
false;
600 bool isDefaulted =
false;
601 while (undoAmbiguous || undoDefaulted || undoOptional) {
603 &&
value.getValueTypeName().startsWith(
604 "com.sun.star.beans.Ambiguous<"))
606 css::uno::Reference< css::reflection::XIdlClass > ambiguous(
607 getReflection(
value.getValueTypeName()));
609 if (!(css::uno::Reference< css::reflection::XIdlField2 >(
610 ambiguous->getField(
"IsAmbiguous"),
611 css::uno::UNO_QUERY_THROW)->get(
value)
614 throw css::uno::RuntimeException(
615 (
"unexpected type of com.sun.star.beans.Ambiguous"
616 " IsAmbiguous member"),
619 value = css::uno::Reference< css::reflection::XIdlField2 >(
620 ambiguous->getField(
"Value"), css::uno::UNO_QUERY_THROW)->
622 }
catch (css::lang::IllegalArgumentException & e) {
624 throw css::lang::WrappedTargetRuntimeException(
625 "unexpected com.sun.star.lang.IllegalArgumentException: "
629 undoAmbiguous =
false;
630 }
else if (undoDefaulted
631 &&
value.getValueTypeName().startsWith(
632 "com.sun.star.beans.Defaulted<"))
634 css::uno::Reference< css::reflection::XIdlClass > defaulted(
635 getReflection(
value.getValueTypeName()));
638 if (!(css::uno::Reference< css::reflection::XIdlField2 >(
639 defaulted->getField(
"IsDefaulted"),
640 css::uno::UNO_QUERY_THROW)->get(
value)
643 throw css::uno::RuntimeException(
644 (
"unexpected type of com.sun.star.beans.Defaulted"
645 " IsDefaulted member"),
648 value = css::uno::Reference< css::reflection::XIdlField2 >(
649 defaulted->getField(
"Value"), css::uno::UNO_QUERY_THROW)->
651 }
catch (css::lang::IllegalArgumentException & e) {
653 throw css::lang::WrappedTargetRuntimeException(
654 "unexpected com.sun.star.lang.IllegalArgumentException: "
658 undoDefaulted =
false;
659 }
else if (undoOptional
660 &&
value.getValueTypeName().startsWith(
661 "com.sun.star.beans.Optional<"))
663 css::uno::Reference< css::reflection::XIdlClass > optional(
664 getReflection(
value.getValueTypeName()));
666 bool present =
false;
667 if (!(css::uno::Reference< css::reflection::XIdlField2 >(
668 optional->getField(
"IsPresent"),
669 css::uno::UNO_QUERY_THROW)->get(
value)
672 throw css::uno::RuntimeException(
673 (
"unexpected type of com.sun.star.beans.Optional"
674 " IsPresent member"),
681 value = css::uno::Reference< css::reflection::XIdlField2 >(
682 optional->getField(
"Value"), css::uno::UNO_QUERY_THROW)->
684 }
catch (css::lang::IllegalArgumentException & e) {
686 throw css::lang::WrappedTargetRuntimeException(
687 "unexpected com.sun.star.lang.IllegalArgumentException: "
691 undoOptional =
false;
693 throw css::uno::RuntimeException(
694 "unexpected type of attribute " +
name,
object);
697 if (state !=
nullptr) {
701 ? css::beans::PropertyState_AMBIGUOUS_VALUE
703 ? css::beans::PropertyState_DEFAULT_VALUE
704 : css::beans::PropertyState_DIRECT_VALUE;
709css::uno::Reference< css::reflection::XIdlClass >
712 return css::uno::Reference< css::reflection::XIdlClass >(
713 css::reflection::theCoreReflection::get(m_context)->forName(
typeName),
714 css::uno::UNO_SET_THROW);
718 css::uno::Reference< css::uno::XInterface >
const &
object,
719 css::uno::Any
const & value,
720 css::uno::Reference< css::reflection::XIdlClass >
const & type,
721 bool wrapAmbiguous,
bool isAmbiguous,
bool wrapDefaulted,
bool isDefaulted,
724 assert(wrapAmbiguous || !isAmbiguous);
725 assert(wrapDefaulted || !isDefaulted);
727 &&
type->getName().startsWith(
"com.sun.star.beans.Ambiguous<"))
730 type->createObject(strct);
732 css::uno::Reference< css::reflection::XIdlField2 > field(
733 type->getField(
"Value"), css::uno::UNO_QUERY_THROW);
737 object,
value, field->getType(),
false,
false,
738 wrapDefaulted, isDefaulted, wrapOptional));
739 css::uno::Reference< css::reflection::XIdlField2 >(
740 type->getField(
"IsAmbiguous"), css::uno::UNO_QUERY_THROW)->set(
741 strct, css::uno::Any(isAmbiguous));
742 }
catch (css::lang::IllegalArgumentException & e) {
744 throw css::lang::WrappedTargetRuntimeException(
745 "unexpected com.sun.star.lang.IllegalArgumentException: "
748 }
catch (css::lang::IllegalAccessException & e) {
750 throw css::lang::WrappedTargetRuntimeException(
751 "unexpected com.sun.star.lang.IllegalAccessException: "
758 &&
type->getName().startsWith(
"com.sun.star.beans.Defaulted<"))
761 type->createObject(strct);
763 css::uno::Reference< css::reflection::XIdlField2 > field(
764 type->getField(
"Value"), css::uno::UNO_QUERY_THROW);
768 object,
value, field->getType(), wrapAmbiguous, isAmbiguous,
769 false,
false, wrapOptional));
770 css::uno::Reference< css::reflection::XIdlField2 >(
771 type->getField(
"IsDefaulted"), css::uno::UNO_QUERY_THROW)->set(
772 strct, css::uno::Any(isDefaulted));
773 }
catch (css::lang::IllegalArgumentException & e) {
775 throw css::lang::WrappedTargetRuntimeException(
776 "unexpected com.sun.star.lang.IllegalArgumentException: "
779 }
catch (css::lang::IllegalAccessException & e) {
781 throw css::lang::WrappedTargetRuntimeException(
782 "unexpected com.sun.star.lang.IllegalAccessException: "
789 &&
type->getName().startsWith(
"com.sun.star.beans.Optional<"))
792 type->createObject(strct);
793 bool present =
value.hasValue();
795 css::uno::Reference< css::reflection::XIdlField2 >(
796 type->getField(
"IsPresent"), css::uno::UNO_QUERY_THROW)->set(
797 strct, css::uno::Any(present));
799 css::uno::Reference< css::reflection::XIdlField2 > field(
800 type->getField(
"Value"), css::uno::UNO_QUERY_THROW);
804 object,
value, field->getType(), wrapAmbiguous,
805 isAmbiguous, wrapDefaulted, isDefaulted,
false));
807 }
catch (css::lang::IllegalArgumentException & e) {
809 throw css::lang::WrappedTargetRuntimeException(
810 "unexpected com.sun.star.lang.IllegalArgumentException: "
813 }
catch (css::lang::IllegalAccessException & e) {
815 throw css::lang::WrappedTargetRuntimeException(
816 "unexpected com.sun.star.lang.IllegalAccessException: "
822 if (wrapAmbiguous || wrapDefaulted || wrapOptional) {
823 throw css::uno::RuntimeException(
824 "unexpected type of attribute",
object);
829PropertySetMixinImpl::PropertySetMixinImpl(
830 css::uno::Reference< css::uno::XComponentContext >
const & context,
832 css::uno::Sequence< OUString >
const & absentOptional,
833 css::uno::Type
const & type)
835 m_impl =
new Impl(context, implements, absentOptional, type);
839PropertySetMixinImpl::~PropertySetMixinImpl() {
843void PropertySetMixinImpl::checkUnknown(OUString
const & propertyName) {
844 if (!propertyName.isEmpty()) {
846 static_cast< css::beans::XPropertySet *
>(
this), propertyName);
850void PropertySetMixinImpl::prepareSet(
851 OUString
const & propertyName, css::uno::Any
const & oldValue,
854 Impl::PropertyMap::const_iterator it(m_impl->properties.find(propertyName));
855 assert(it != m_impl->properties.end());
859 std::scoped_lock g(m_impl->mutex);
860 if (m_impl->disposed) {
861 throw css::lang::DisposedException(
862 "disposed",
static_cast< css::beans::XPropertySet *
>(
this));
864 if ((it->second.property.Attributes
865 & css::beans::PropertyAttribute::CONSTRAINED)
868 Impl::VetoListenerMap::const_iterator
i(
869 m_impl->vetoListeners.find(propertyName));
870 if (
i != m_impl->vetoListeners.end()) {
871 specificVeto =
i->second;
873 i = m_impl->vetoListeners.find(
"");
874 if (
i != m_impl->vetoListeners.end()) {
875 unspecificVeto =
i->second;
878 if ((it->second.property.Attributes
879 & css::beans::PropertyAttribute::BOUND)
882 assert(boundListeners !=
nullptr);
883 Impl::BoundListenerMap::const_iterator
i(
884 m_impl->boundListeners.find(propertyName));
885 if (
i != m_impl->boundListeners.end()) {
886 boundListeners->
m_impl->specificListeners =
i->second;
888 i = m_impl->boundListeners.find(
"");
889 if (
i != m_impl->boundListeners.end()) {
890 boundListeners->
m_impl->unspecificListeners =
i->second;
894 if ((it->second.property.Attributes
895 & css::beans::PropertyAttribute::CONSTRAINED)
898 css::beans::PropertyChangeEvent event(
899 static_cast< css::beans::XPropertySet *
>(
this), propertyName,
900 false, it->second.property.Handle, oldValue, newValue);
901 for (
auto& rxVetoListener : specificVeto)
904 rxVetoListener->vetoableChange(event);
905 }
catch (css::lang::DisposedException &) {}
907 for (
auto& rxVetoListener : unspecificVeto)
910 rxVetoListener->vetoableChange(event);
911 }
catch (css::lang::DisposedException &) {}
914 if ((it->second.property.Attributes & css::beans::PropertyAttribute::BOUND)
917 assert(boundListeners !=
nullptr);
918 boundListeners->
m_impl->event = css::beans::PropertyChangeEvent(
919 static_cast< css::beans::XPropertySet *
>(
this), propertyName,
920 false, it->second.property.Handle, oldValue, newValue);
924void PropertySetMixinImpl::dispose() {
928 std::scoped_lock g(m_impl->mutex);
929 boundListeners.swap(m_impl->boundListeners);
930 vetoListeners.swap(m_impl->vetoListeners);
931 m_impl->disposed =
true;
933 css::lang::EventObject event(
934 static_cast< css::beans::XPropertySet *
>(
this));
935 for (
const auto& rEntry : boundListeners)
937 for (
auto& rxBoundListener : rEntry.second)
939 rxBoundListener->disposing(event);
942 for (
const auto& rEntry : vetoListeners)
944 for (
auto& rxVetoListener : rEntry.second)
946 rxVetoListener->disposing(event);
953 if ((m_impl->implements & IMPLEMENTS_PROPERTY_SET) != 0
956 css::uno::Reference< css::uno::XInterface > ifc(
957 static_cast< css::beans::XPropertySet *
>(
this));
958 return css::uno::Any(&ifc,
type);
960 if ((m_impl->implements & IMPLEMENTS_FAST_PROPERTY_SET) != 0
963 css::uno::Reference< css::uno::XInterface > ifc(
964 static_cast< css::beans::XFastPropertySet *
>(
this));
965 return css::uno::Any(&ifc,
type);
967 if ((m_impl->implements & IMPLEMENTS_PROPERTY_ACCESS) != 0
970 css::uno::Reference< css::uno::XInterface > ifc(
971 static_cast< css::beans::XPropertyAccess *
>(
this));
972 return css::uno::Any(&ifc,
type);
974 return css::uno::Any();
977css::uno::Reference< css::beans::XPropertySetInfo >
978PropertySetMixinImpl::getPropertySetInfo()
980 return new Info(m_impl);
983void PropertySetMixinImpl::setPropertyValue(
984 OUString
const & propertyName, css::uno::Any
const & value)
987 static_cast< css::beans::XPropertySet *
>(
this), propertyName,
value,
991css::uno::Any PropertySetMixinImpl::getPropertyValue(
992 OUString
const & propertyName)
994 return m_impl->getProperty(
995 static_cast< css::beans::XPropertySet *
>(
this), propertyName,
nullptr);
998void PropertySetMixinImpl::addPropertyChangeListener(
999 OUString
const & propertyName,
1000 css::uno::Reference< css::beans::XPropertyChangeListener >
const & listener)
1002 css::uno::Reference< css::beans::XPropertyChangeListener >(
1003 listener, css::uno::UNO_SET_THROW);
1004 checkUnknown(propertyName);
1007 std::scoped_lock g(m_impl->mutex);
1008 disposed = m_impl->disposed;
1010 m_impl->boundListeners[propertyName].insert(listener);
1014 listener->disposing(
1015 css::lang::EventObject(
1016 static_cast< css::beans::XPropertySet *
>(
this)));
1020void PropertySetMixinImpl::removePropertyChangeListener(
1021 OUString
const & propertyName,
1022 css::uno::Reference< css::beans::XPropertyChangeListener >
const & listener)
1024 assert(listener.is());
1025 checkUnknown(propertyName);
1026 std::scoped_lock g(m_impl->mutex);
1027 Impl::BoundListenerMap::iterator
i(
1028 m_impl->boundListeners.find(propertyName));
1029 if (
i != m_impl->boundListeners.end()) {
1030 BoundListenerBag::iterator j(
i->second.find(listener));
1031 if (j !=
i->second.end()) {
1037void PropertySetMixinImpl::addVetoableChangeListener(
1038 OUString
const & propertyName,
1039 css::uno::Reference< css::beans::XVetoableChangeListener >
const & listener)
1041 css::uno::Reference< css::beans::XVetoableChangeListener >(
1042 listener, css::uno::UNO_SET_THROW);
1043 checkUnknown(propertyName);
1046 std::scoped_lock g(m_impl->mutex);
1047 disposed = m_impl->disposed;
1049 m_impl->vetoListeners[propertyName].insert(listener);
1053 listener->disposing(
1054 css::lang::EventObject(
1055 static_cast< css::beans::XPropertySet *
>(
this)));
1059void PropertySetMixinImpl::removeVetoableChangeListener(
1060 OUString
const & propertyName,
1061 css::uno::Reference< css::beans::XVetoableChangeListener >
const & listener)
1063 assert(listener.is());
1064 checkUnknown(propertyName);
1065 std::scoped_lock g(m_impl->mutex);
1066 Impl::VetoListenerMap::iterator
i(m_impl->vetoListeners.find(propertyName));
1067 if (
i != m_impl->vetoListeners.end()) {
1068 Impl::VetoListenerBag::iterator j(
i->second.find(listener));
1069 if (j !=
i->second.end()) {
1075void PropertySetMixinImpl::setFastPropertyValue(
1076 sal_Int32 handle, css::uno::Any
const & value)
1078 m_impl->setProperty(
1079 static_cast< css::beans::XPropertySet *
>(
this),
1080 m_impl->translateHandle(
1081 static_cast< css::beans::XPropertySet *
>(
this), handle),
1082 value,
false,
false, 1);
1085css::uno::Any PropertySetMixinImpl::getFastPropertyValue(sal_Int32 handle)
1087 return m_impl->getProperty(
1088 static_cast< css::beans::XPropertySet *
>(
this),
1089 m_impl->translateHandle(
1090 static_cast< css::beans::XPropertySet *
>(
this), handle),
1094css::uno::Sequence< css::beans::PropertyValue >
1095PropertySetMixinImpl::getPropertyValues()
1097 css::uno::Sequence< css::beans::PropertyValue > s(
1098 m_impl->handleMap.getLength());
1099 auto r = asNonConstRange(s);
1101 for (sal_Int32
i = 0;
i < m_impl->handleMap.getLength(); ++
i) {
1103 r[
n].Value = m_impl->getProperty(
1104 static_cast< css::beans::XPropertySet *
>(
this),
1105 m_impl->handleMap[
i], &r[
n].State);
1106 }
catch (css::beans::UnknownPropertyException &) {
1108 }
catch (css::lang::WrappedTargetException & e) {
1109 throw css::lang::WrappedTargetRuntimeException(
1110 e.Message,
static_cast< css::beans::XPropertySet *
>(
this),
1113 r[
n].Name = m_impl->handleMap[
i];
1121void PropertySetMixinImpl::setPropertyValues(
1122 css::uno::Sequence< css::beans::PropertyValue >
const & props)
1124 for (
const auto &
p :
props) {
1127 != m_impl->translateHandle(
1128 static_cast< css::beans::XPropertySet *
>(
this),
1131 throw css::beans::UnknownPropertyException(
1132 (
"name " +
p.Name +
" does not match handle "
1133 + OUString::number(
p.Handle)),
1134 static_cast< css::beans::XPropertySet *
>(
this));
1136 m_impl->setProperty(
1137 static_cast< css::beans::XPropertySet *
>(
this),
p.Name,
1139 p.State == css::beans::PropertyState_AMBIGUOUS_VALUE,
1140 p.State == css::beans::PropertyState_DEFAULT_VALUE, 0);
css::beans::PropertyChangeEvent event
BoundListenerBag unspecificListeners
BoundListenerBag specificListeners
std::map< OUString, BoundListenerBag > BoundListenerMap
OUString const & translateHandle(css::uno::Reference< css::uno::XInterface > const &object, sal_Int32 handle) const
css::uno::Reference< css::reflection::XIdlClass > m_idlClass
static css::uno::Any wrapValue(css::uno::Reference< css::uno::XInterface > const &object, css::uno::Any const &value, css::uno::Reference< css::reflection::XIdlClass > const &type, bool wrapAmbiguous, bool isAmbiguous, bool wrapDefaulted, bool isDefaulted, bool wrapOptional)
css::uno::Reference< css::reflection::XIdlClass > getReflection(OUString const &typeName) const
std::map< OUString, VetoListenerBag > VetoListenerMap
VetoListenerMap vetoListeners
std::multiset< css::uno::Reference< css::beans::XVetoableChangeListener > > VetoListenerBag
Impl(css::uno::Reference< css::uno::XComponentContext > const &context, Implements theImplements, css::uno::Sequence< OUString > const &absentOptional, css::uno::Type const &type)
css::uno::Sequence< OUString > handleMap
void setProperty(css::uno::Reference< css::uno::XInterface > const &object, OUString const &name, css::uno::Any const &value, bool isAmbiguous, bool isDefaulted, sal_Int16 illegalArgumentPosition) const
BoundListenerMap boundListeners
PropertySetMixinImpl::Implements implements
css::uno::Reference< css::uno::XComponentContext > const & m_context
css::uno::Any getProperty(css::uno::Reference< css::uno::XInterface > const &object, OUString const &name, css::beans::PropertyState *state) const
Base class to implement a UNO object supporting weak references, i.e.
A class used by subclasses of cppu::PropertySetMixin when implementing UNO interface type attribute s...
void notify() const
Notifies any css::beans::XPropertyChangeListeners.
~BoundListeners()
The destructor.
A helper base class for cppu::PropertySetMixin.
Implements
Flags used by subclasses of cppu::PropertySetMixin to specify what UNO interface types shall be suppo...
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)
Compares demanded type to given template argument types.
Any SAL_CALL getCaughtException()
Use this function to get the dynamic type of a caught C++-UNO exception; completes the above function...
std::map< sal_Int32, STLPropertyMapEntry > PropertyMap
SVX_DLLPUBLIC OUString getProperty(css::uno::Reference< css::beans::XPropertyContainer > const &rxPropertyContainer, OUString const &rName)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
bool getType(BSTR name, Type &type)
PyObject_HEAD PyUNO_callable_Internals * members