xref: /AOO41X/main/cppuhelper/source/propertysetmixin.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_cppuhelper.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "sal/config.h"
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include "cppuhelper/propertysetmixin.hxx"
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include "com/sun/star/beans/Property.hpp"
36*cdf0e10cSrcweir #include "com/sun/star/beans/PropertyChangeEvent.hpp"
37*cdf0e10cSrcweir #include "com/sun/star/beans/PropertyAttribute.hpp"
38*cdf0e10cSrcweir #include "com/sun/star/beans/PropertyValue.hpp"
39*cdf0e10cSrcweir #include "com/sun/star/beans/PropertyVetoException.hpp"
40*cdf0e10cSrcweir #include "com/sun/star/beans/UnknownPropertyException.hpp"
41*cdf0e10cSrcweir #include "com/sun/star/beans/XFastPropertySet.hpp"
42*cdf0e10cSrcweir #include "com/sun/star/beans/XPropertyAccess.hpp"
43*cdf0e10cSrcweir #include "com/sun/star/beans/XPropertyChangeListener.hpp"
44*cdf0e10cSrcweir #include "com/sun/star/beans/XPropertySet.hpp"
45*cdf0e10cSrcweir #include "com/sun/star/beans/XPropertySetInfo.hpp"
46*cdf0e10cSrcweir #include "com/sun/star/beans/XVetoableChangeListener.hpp"
47*cdf0e10cSrcweir #include "com/sun/star/container/NoSuchElementException.hpp"
48*cdf0e10cSrcweir #include "com/sun/star/container/XHierarchicalNameAccess.hpp"
49*cdf0e10cSrcweir #include "com/sun/star/lang/DisposedException.hpp"
50*cdf0e10cSrcweir #include "com/sun/star/lang/EventObject.hpp"
51*cdf0e10cSrcweir #include "com/sun/star/lang/IllegalAccessException.hpp"
52*cdf0e10cSrcweir #include "com/sun/star/lang/IllegalArgumentException.hpp"
53*cdf0e10cSrcweir #include "com/sun/star/lang/WrappedTargetException.hpp"
54*cdf0e10cSrcweir #include "com/sun/star/lang/WrappedTargetRuntimeException.hpp"
55*cdf0e10cSrcweir #include "com/sun/star/lang/XComponent.hpp"
56*cdf0e10cSrcweir #include "com/sun/star/lang/XMultiComponentFactory.hpp"
57*cdf0e10cSrcweir #include "com/sun/star/reflection/XCompoundTypeDescription.hpp"
58*cdf0e10cSrcweir #include "com/sun/star/reflection/XIdlClass.hpp"
59*cdf0e10cSrcweir #include "com/sun/star/reflection/XIdlField2.hpp"
60*cdf0e10cSrcweir #include "com/sun/star/reflection/XIdlReflection.hpp"
61*cdf0e10cSrcweir #include "com/sun/star/reflection/XIndirectTypeDescription.hpp"
62*cdf0e10cSrcweir #include "com/sun/star/reflection/XInterfaceAttributeTypeDescription2.hpp"
63*cdf0e10cSrcweir #include "com/sun/star/reflection/XInterfaceMemberTypeDescription.hpp"
64*cdf0e10cSrcweir #include "com/sun/star/reflection/XInterfaceTypeDescription2.hpp"
65*cdf0e10cSrcweir #include "com/sun/star/reflection/XStructTypeDescription.hpp"
66*cdf0e10cSrcweir #include "com/sun/star/reflection/XTypeDescription.hpp"
67*cdf0e10cSrcweir #include "com/sun/star/uno/Any.hxx"
68*cdf0e10cSrcweir #include "com/sun/star/uno/DeploymentException.hpp"
69*cdf0e10cSrcweir #include "com/sun/star/uno/Exception.hpp"
70*cdf0e10cSrcweir #include "com/sun/star/uno/Reference.hxx"
71*cdf0e10cSrcweir #include "com/sun/star/uno/RuntimeException.hpp"
72*cdf0e10cSrcweir #include "com/sun/star/uno/Sequence.hxx"
73*cdf0e10cSrcweir #include "com/sun/star/uno/Type.hxx"
74*cdf0e10cSrcweir #include "com/sun/star/uno/TypeClass.hpp"
75*cdf0e10cSrcweir #include "com/sun/star/uno/XComponentContext.hpp"
76*cdf0e10cSrcweir #include "com/sun/star/uno/XInterface.hpp"
77*cdf0e10cSrcweir #include "cppuhelper/implbase1.hxx"
78*cdf0e10cSrcweir #include "cppuhelper/weak.hxx"
79*cdf0e10cSrcweir #include "osl/diagnose.h"
80*cdf0e10cSrcweir #include "osl/mutex.hxx"
81*cdf0e10cSrcweir #include "rtl/ref.hxx"
82*cdf0e10cSrcweir #include "rtl/string.h"
83*cdf0e10cSrcweir #include "rtl/ustring.h"
84*cdf0e10cSrcweir #include "rtl/ustring.hxx"
85*cdf0e10cSrcweir #include "sal/types.h"
86*cdf0e10cSrcweir #include "salhelper/simplereferenceobject.hxx"
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir #include <algorithm>
89*cdf0e10cSrcweir #include <map>
90*cdf0e10cSrcweir #include <new>
91*cdf0e10cSrcweir #include <set>
92*cdf0e10cSrcweir #include <vector>
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir using cppu::PropertySetMixinImpl;
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir namespace css = com::sun::star;
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir namespace {
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir template< typename T > struct AutoDispose {
101*cdf0e10cSrcweir     AutoDispose() {}
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir     ~AutoDispose() {
104*cdf0e10cSrcweir         try {
105*cdf0e10cSrcweir             dispose();
106*cdf0e10cSrcweir         } catch (...) {}
107*cdf0e10cSrcweir     }
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir     void dispose() {
110*cdf0e10cSrcweir         css::uno::Reference< css::lang::XComponent > comp(
111*cdf0e10cSrcweir             ifc, css::uno::UNO_QUERY);
112*cdf0e10cSrcweir         if (comp.is()) {
113*cdf0e10cSrcweir             comp->dispose();
114*cdf0e10cSrcweir         }
115*cdf0e10cSrcweir         ifc.clear();
116*cdf0e10cSrcweir     }
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir     css::uno::Reference< T > ifc;
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir private:
121*cdf0e10cSrcweir     AutoDispose(AutoDispose &); // not defined
122*cdf0e10cSrcweir     void operator =(AutoDispose); // not defined
123*cdf0e10cSrcweir };
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir struct PropertyData {
126*cdf0e10cSrcweir     explicit PropertyData(
127*cdf0e10cSrcweir         css::beans::Property const & theProperty, bool thePresent):
128*cdf0e10cSrcweir         property(theProperty), present(thePresent) {}
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir     css::beans::Property property;
131*cdf0e10cSrcweir     bool present;
132*cdf0e10cSrcweir };
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir struct Data: public salhelper::SimpleReferenceObject {
135*cdf0e10cSrcweir     typedef std::map< rtl::OUString, PropertyData > PropertyMap;
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir     PropertyMap properties;
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir     PropertyMap::const_iterator get(
140*cdf0e10cSrcweir         css::uno::Reference< css::uno::XInterface > const & object,
141*cdf0e10cSrcweir         rtl::OUString const & name) const;
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir protected:
144*cdf0e10cSrcweir     void initProperties(
145*cdf0e10cSrcweir         css::uno::Reference< css::reflection::XTypeDescription > const & type,
146*cdf0e10cSrcweir         css::uno::Sequence< rtl::OUString > const & absentOptional,
147*cdf0e10cSrcweir         std::vector< rtl::OUString > * handleNames)
148*cdf0e10cSrcweir     {
149*cdf0e10cSrcweir         TypeSet seen;
150*cdf0e10cSrcweir         initProperties(type, absentOptional, handleNames, &seen);
151*cdf0e10cSrcweir     }
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir private:
154*cdf0e10cSrcweir     typedef std::set< rtl::OUString > TypeSet;
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir     void initProperties(
157*cdf0e10cSrcweir         css::uno::Reference< css::reflection::XTypeDescription > const & type,
158*cdf0e10cSrcweir         css::uno::Sequence< rtl::OUString > const & absentOptional,
159*cdf0e10cSrcweir         std::vector< rtl::OUString > * handleNames, TypeSet * seen);
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir     static css::uno::Reference< css::reflection::XTypeDescription >
162*cdf0e10cSrcweir     resolveTypedefs(
163*cdf0e10cSrcweir         css::uno::Reference< css::reflection::XTypeDescription > const & type);
164*cdf0e10cSrcweir };
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir Data::PropertyMap::const_iterator Data::get(
167*cdf0e10cSrcweir     css::uno::Reference< css::uno::XInterface > const & object,
168*cdf0e10cSrcweir     rtl::OUString const & name) const
169*cdf0e10cSrcweir {
170*cdf0e10cSrcweir     PropertyMap::const_iterator i(properties.find(name));
171*cdf0e10cSrcweir     if (i == properties.end() || !i->second.present) {
172*cdf0e10cSrcweir         throw css::beans::UnknownPropertyException(name, object);
173*cdf0e10cSrcweir     }
174*cdf0e10cSrcweir     return i;
175*cdf0e10cSrcweir }
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir void Data::initProperties(
178*cdf0e10cSrcweir     css::uno::Reference< css::reflection::XTypeDescription > const & type,
179*cdf0e10cSrcweir     css::uno::Sequence< rtl::OUString > const & absentOptional,
180*cdf0e10cSrcweir     std::vector< rtl::OUString > * handleNames, TypeSet * seen)
181*cdf0e10cSrcweir {
182*cdf0e10cSrcweir     css::uno::Reference< css::reflection::XInterfaceTypeDescription2 > ifc(
183*cdf0e10cSrcweir         resolveTypedefs(type), css::uno::UNO_QUERY_THROW);
184*cdf0e10cSrcweir     if (seen->insert(ifc->getName()).second) {
185*cdf0e10cSrcweir         css::uno::Sequence<
186*cdf0e10cSrcweir         css::uno::Reference< css::reflection::XTypeDescription > > bases(
187*cdf0e10cSrcweir             ifc->getBaseTypes());
188*cdf0e10cSrcweir         for (sal_Int32 i = 0; i < bases.getLength(); ++i) {
189*cdf0e10cSrcweir             initProperties(bases[i], absentOptional, handleNames, seen);
190*cdf0e10cSrcweir         }
191*cdf0e10cSrcweir         css::uno::Sequence<
192*cdf0e10cSrcweir         css::uno::Reference<
193*cdf0e10cSrcweir         css::reflection::XInterfaceMemberTypeDescription > > members(
194*cdf0e10cSrcweir             ifc->getMembers());
195*cdf0e10cSrcweir         rtl::OUString const * absentBegin = absentOptional.getConstArray();
196*cdf0e10cSrcweir         rtl::OUString const * absentEnd =
197*cdf0e10cSrcweir             absentBegin + absentOptional.getLength();
198*cdf0e10cSrcweir         for (sal_Int32 i = 0; i < members.getLength(); ++i) {
199*cdf0e10cSrcweir             if (members[i]->getTypeClass()
200*cdf0e10cSrcweir                 == css::uno::TypeClass_INTERFACE_ATTRIBUTE)
201*cdf0e10cSrcweir             {
202*cdf0e10cSrcweir                 css::uno::Reference<
203*cdf0e10cSrcweir                 css::reflection::XInterfaceAttributeTypeDescription2 > attr(
204*cdf0e10cSrcweir                     members[i], css::uno::UNO_QUERY_THROW);
205*cdf0e10cSrcweir                 sal_Int16 attrAttribs = 0;
206*cdf0e10cSrcweir                 if (attr->isBound()) {
207*cdf0e10cSrcweir                     attrAttribs |= css::beans::PropertyAttribute::BOUND;
208*cdf0e10cSrcweir                 }
209*cdf0e10cSrcweir                 bool setUnknown = false;
210*cdf0e10cSrcweir                 if (attr->isReadOnly()) {
211*cdf0e10cSrcweir                     attrAttribs |= css::beans::PropertyAttribute::READONLY;
212*cdf0e10cSrcweir                     setUnknown = true;
213*cdf0e10cSrcweir                 }
214*cdf0e10cSrcweir                 css::uno::Sequence<
215*cdf0e10cSrcweir                 css::uno::Reference<
216*cdf0e10cSrcweir                 css::reflection::XCompoundTypeDescription > > excs(
217*cdf0e10cSrcweir                     attr->getGetExceptions());
218*cdf0e10cSrcweir                 bool getUnknown = false;
219*cdf0e10cSrcweir                 //XXX  Special interpretation of getter/setter exceptions only
220*cdf0e10cSrcweir                 // works if the specified exceptions are of the exact type, not
221*cdf0e10cSrcweir                 // of a supertype:
222*cdf0e10cSrcweir                 for (sal_Int32 j = 0; j < excs.getLength(); ++j) {
223*cdf0e10cSrcweir                     if (excs[j]->getName().equalsAsciiL(
224*cdf0e10cSrcweir                             RTL_CONSTASCII_STRINGPARAM(
225*cdf0e10cSrcweir                                 "com.sun.star.beans.UnknownPropertyException")))
226*cdf0e10cSrcweir                     {
227*cdf0e10cSrcweir                         getUnknown = true;
228*cdf0e10cSrcweir                         break;
229*cdf0e10cSrcweir                     }
230*cdf0e10cSrcweir                 }
231*cdf0e10cSrcweir                 excs = attr->getSetExceptions();
232*cdf0e10cSrcweir                 for (sal_Int32 j = 0; j < excs.getLength(); ++j) {
233*cdf0e10cSrcweir                     if (excs[j]->getName().equalsAsciiL(
234*cdf0e10cSrcweir                             RTL_CONSTASCII_STRINGPARAM(
235*cdf0e10cSrcweir                                 "com.sun.star.beans.UnknownPropertyException")))
236*cdf0e10cSrcweir                     {
237*cdf0e10cSrcweir                         setUnknown = true;
238*cdf0e10cSrcweir                     } else if (excs[j]->getName().equalsAsciiL(
239*cdf0e10cSrcweir                                    RTL_CONSTASCII_STRINGPARAM(
240*cdf0e10cSrcweir                                        "com.sun.star.beans."
241*cdf0e10cSrcweir                                        "PropertyVetoException")))
242*cdf0e10cSrcweir                     {
243*cdf0e10cSrcweir                         attrAttribs
244*cdf0e10cSrcweir                             |= css::beans::PropertyAttribute::CONSTRAINED;
245*cdf0e10cSrcweir                     }
246*cdf0e10cSrcweir                 }
247*cdf0e10cSrcweir                 if (getUnknown && setUnknown) {
248*cdf0e10cSrcweir                     attrAttribs |= css::beans::PropertyAttribute::OPTIONAL;
249*cdf0e10cSrcweir                 }
250*cdf0e10cSrcweir                 css::uno::Reference< css::reflection::XTypeDescription > t(
251*cdf0e10cSrcweir                     attr->getType());
252*cdf0e10cSrcweir                 for (;;)
253*cdf0e10cSrcweir                 {
254*cdf0e10cSrcweir                     t = resolveTypedefs(t);
255*cdf0e10cSrcweir                     sal_Int16 n;
256*cdf0e10cSrcweir                     if (t->getName().matchAsciiL(
257*cdf0e10cSrcweir                             RTL_CONSTASCII_STRINGPARAM(
258*cdf0e10cSrcweir                                 "com.sun.star.beans.Ambiguous<")))
259*cdf0e10cSrcweir                     {
260*cdf0e10cSrcweir                         n = css::beans::PropertyAttribute::MAYBEAMBIGUOUS;
261*cdf0e10cSrcweir                     } else if (t->getName().matchAsciiL(
262*cdf0e10cSrcweir                                    RTL_CONSTASCII_STRINGPARAM(
263*cdf0e10cSrcweir                                        "com.sun.star.beans.Defaulted<")))
264*cdf0e10cSrcweir                     {
265*cdf0e10cSrcweir                         n = css::beans::PropertyAttribute::MAYBEDEFAULT;
266*cdf0e10cSrcweir                     } else if (t->getName().matchAsciiL(
267*cdf0e10cSrcweir                                    RTL_CONSTASCII_STRINGPARAM(
268*cdf0e10cSrcweir                                        "com.sun.star.beans.Optional<")))
269*cdf0e10cSrcweir                     {
270*cdf0e10cSrcweir                         n = css::beans::PropertyAttribute::MAYBEVOID;
271*cdf0e10cSrcweir                     } else {
272*cdf0e10cSrcweir                         break;
273*cdf0e10cSrcweir                     }
274*cdf0e10cSrcweir                     if ((attrAttribs & n) != 0) {
275*cdf0e10cSrcweir                         break;
276*cdf0e10cSrcweir                     }
277*cdf0e10cSrcweir                     attrAttribs |= n;
278*cdf0e10cSrcweir                     css::uno::Sequence<
279*cdf0e10cSrcweir                     css::uno::Reference< css::reflection::XTypeDescription > >
280*cdf0e10cSrcweir                         args(
281*cdf0e10cSrcweir                             css::uno::Reference<
282*cdf0e10cSrcweir                             css::reflection::XStructTypeDescription >(
283*cdf0e10cSrcweir                                 t,
284*cdf0e10cSrcweir                                 css::uno::UNO_QUERY_THROW)->getTypeArguments());
285*cdf0e10cSrcweir                     if (args.getLength() != 1) {
286*cdf0e10cSrcweir                         throw css::uno::RuntimeException(
287*cdf0e10cSrcweir                             rtl::OUString(
288*cdf0e10cSrcweir                                 RTL_CONSTASCII_USTRINGPARAM(
289*cdf0e10cSrcweir                                     "inconsistent UNO type registry")),
290*cdf0e10cSrcweir                             css::uno::Reference< css::uno::XInterface >());
291*cdf0e10cSrcweir                     }
292*cdf0e10cSrcweir                     t = args[0];
293*cdf0e10cSrcweir                 }
294*cdf0e10cSrcweir                 std::vector< rtl::OUString >::size_type handles
295*cdf0e10cSrcweir                     = handleNames->size();
296*cdf0e10cSrcweir                 if (handles > SAL_MAX_INT32) {
297*cdf0e10cSrcweir                     throw css::uno::RuntimeException(
298*cdf0e10cSrcweir                         rtl::OUString(
299*cdf0e10cSrcweir                             RTL_CONSTASCII_USTRINGPARAM(
300*cdf0e10cSrcweir                                 "interface type has too many attributes")),
301*cdf0e10cSrcweir                         css::uno::Reference< css::uno::XInterface >());
302*cdf0e10cSrcweir                 }
303*cdf0e10cSrcweir                 rtl::OUString name(members[i]->getMemberName());
304*cdf0e10cSrcweir                 if (!properties.insert(
305*cdf0e10cSrcweir                         PropertyMap::value_type(
306*cdf0e10cSrcweir                             name,
307*cdf0e10cSrcweir                             PropertyData(
308*cdf0e10cSrcweir                                 css::beans::Property(
309*cdf0e10cSrcweir                                     name, static_cast< sal_Int32 >(handles),
310*cdf0e10cSrcweir                                     css::uno::Type(
311*cdf0e10cSrcweir                                         t->getTypeClass(), t->getName()),
312*cdf0e10cSrcweir                                     attrAttribs),
313*cdf0e10cSrcweir                                 (std::find(absentBegin, absentEnd, name)
314*cdf0e10cSrcweir                                  == absentEnd)))).
315*cdf0e10cSrcweir                     second)
316*cdf0e10cSrcweir                 {
317*cdf0e10cSrcweir                     throw css::uno::RuntimeException(
318*cdf0e10cSrcweir                         rtl::OUString(
319*cdf0e10cSrcweir                             RTL_CONSTASCII_USTRINGPARAM(
320*cdf0e10cSrcweir                                 "inconsistent UNO type registry")),
321*cdf0e10cSrcweir                         css::uno::Reference< css::uno::XInterface >());
322*cdf0e10cSrcweir                 }
323*cdf0e10cSrcweir                 handleNames->push_back(name);
324*cdf0e10cSrcweir             }
325*cdf0e10cSrcweir         }
326*cdf0e10cSrcweir     }
327*cdf0e10cSrcweir }
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir css::uno::Reference< css::reflection::XTypeDescription > Data::resolveTypedefs(
330*cdf0e10cSrcweir     css::uno::Reference< css::reflection::XTypeDescription > const & type)
331*cdf0e10cSrcweir {
332*cdf0e10cSrcweir     css::uno::Reference< css::reflection::XTypeDescription > t(type);
333*cdf0e10cSrcweir     while (t->getTypeClass() == css::uno::TypeClass_TYPEDEF) {
334*cdf0e10cSrcweir         t = css::uno::Reference< css::reflection::XIndirectTypeDescription >(
335*cdf0e10cSrcweir             t, css::uno::UNO_QUERY_THROW)->getReferencedType();
336*cdf0e10cSrcweir     }
337*cdf0e10cSrcweir     return t;
338*cdf0e10cSrcweir }
339*cdf0e10cSrcweir 
340*cdf0e10cSrcweir class Info: public cppu::WeakImplHelper1< css::beans::XPropertySetInfo > {
341*cdf0e10cSrcweir public:
342*cdf0e10cSrcweir     explicit Info(Data * data): m_data(data) {}
343*cdf0e10cSrcweir 
344*cdf0e10cSrcweir     virtual css::uno::Sequence< css::beans::Property > SAL_CALL getProperties()
345*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir     virtual css::beans::Property SAL_CALL getPropertyByName(
348*cdf0e10cSrcweir         rtl::OUString const & name)
349*cdf0e10cSrcweir         throw (
350*cdf0e10cSrcweir             css::beans::UnknownPropertyException, css::uno::RuntimeException);
351*cdf0e10cSrcweir 
352*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL hasPropertyByName(rtl::OUString const & name)
353*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir private:
356*cdf0e10cSrcweir     rtl::Reference< Data > m_data;
357*cdf0e10cSrcweir };
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir css::uno::Sequence< css::beans::Property > Info::getProperties()
360*cdf0e10cSrcweir     throw (css::uno::RuntimeException)
361*cdf0e10cSrcweir {
362*cdf0e10cSrcweir     try {
363*cdf0e10cSrcweir         OSL_ASSERT(m_data->properties.size() <= SAL_MAX_INT32);
364*cdf0e10cSrcweir         css::uno::Sequence< css::beans::Property > s(
365*cdf0e10cSrcweir             static_cast< sal_Int32 >(m_data->properties.size()));
366*cdf0e10cSrcweir         sal_Int32 n = 0;
367*cdf0e10cSrcweir         for (Data::PropertyMap::iterator i(m_data->properties.begin());
368*cdf0e10cSrcweir              i != m_data->properties.end(); ++i)
369*cdf0e10cSrcweir         {
370*cdf0e10cSrcweir             if (i->second.present) {
371*cdf0e10cSrcweir                 s[n++] = i->second.property;
372*cdf0e10cSrcweir             }
373*cdf0e10cSrcweir         }
374*cdf0e10cSrcweir         s.realloc(n);
375*cdf0e10cSrcweir         return s;
376*cdf0e10cSrcweir     } catch (std::bad_alloc &) {
377*cdf0e10cSrcweir         //TODO  OutOfMemoryException:
378*cdf0e10cSrcweir         throw css::uno::RuntimeException(
379*cdf0e10cSrcweir             rtl::OUString(), static_cast< cppu::OWeakObject * >(this));
380*cdf0e10cSrcweir     }
381*cdf0e10cSrcweir }
382*cdf0e10cSrcweir 
383*cdf0e10cSrcweir css::beans::Property Info::getPropertyByName(rtl::OUString const & name)
384*cdf0e10cSrcweir     throw (css::beans::UnknownPropertyException, css::uno::RuntimeException)
385*cdf0e10cSrcweir {
386*cdf0e10cSrcweir     return m_data->get(static_cast< cppu::OWeakObject * >(this), name)->
387*cdf0e10cSrcweir         second.property;
388*cdf0e10cSrcweir }
389*cdf0e10cSrcweir 
390*cdf0e10cSrcweir sal_Bool Info::hasPropertyByName(rtl::OUString const & name)
391*cdf0e10cSrcweir     throw (css::uno::RuntimeException)
392*cdf0e10cSrcweir {
393*cdf0e10cSrcweir     Data::PropertyMap::iterator i(m_data->properties.find(name));
394*cdf0e10cSrcweir     return i != m_data->properties.end() && i->second.present;
395*cdf0e10cSrcweir }
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir typedef
398*cdf0e10cSrcweir std::multiset< css::uno::Reference< css::beans::XPropertyChangeListener > >
399*cdf0e10cSrcweir BoundListenerBag;
400*cdf0e10cSrcweir 
401*cdf0e10cSrcweir }
402*cdf0e10cSrcweir 
403*cdf0e10cSrcweir class PropertySetMixinImpl::BoundListeners::Impl {
404*cdf0e10cSrcweir public:
405*cdf0e10cSrcweir     BoundListenerBag specificListeners;
406*cdf0e10cSrcweir     BoundListenerBag unspecificListeners;
407*cdf0e10cSrcweir     css::beans::PropertyChangeEvent event;
408*cdf0e10cSrcweir };
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir PropertySetMixinImpl::BoundListeners::BoundListeners(): m_impl(new Impl) {}
411*cdf0e10cSrcweir 
412*cdf0e10cSrcweir PropertySetMixinImpl::BoundListeners::~BoundListeners() {
413*cdf0e10cSrcweir     delete m_impl;
414*cdf0e10cSrcweir }
415*cdf0e10cSrcweir 
416*cdf0e10cSrcweir void PropertySetMixinImpl::BoundListeners::notify() const {
417*cdf0e10cSrcweir     for (BoundListenerBag::const_iterator i(m_impl->specificListeners.begin());
418*cdf0e10cSrcweir          i != m_impl->specificListeners.end(); ++i)
419*cdf0e10cSrcweir     {
420*cdf0e10cSrcweir         try {
421*cdf0e10cSrcweir             (*i)->propertyChange(m_impl->event);
422*cdf0e10cSrcweir         } catch (css::lang::DisposedException &) {}
423*cdf0e10cSrcweir     }
424*cdf0e10cSrcweir     for (BoundListenerBag::const_iterator i(
425*cdf0e10cSrcweir              m_impl->unspecificListeners.begin());
426*cdf0e10cSrcweir          i != m_impl->unspecificListeners.end(); ++i)
427*cdf0e10cSrcweir     {
428*cdf0e10cSrcweir         try {
429*cdf0e10cSrcweir             (*i)->propertyChange(m_impl->event);
430*cdf0e10cSrcweir         } catch (css::lang::DisposedException &) {}
431*cdf0e10cSrcweir     }
432*cdf0e10cSrcweir }
433*cdf0e10cSrcweir 
434*cdf0e10cSrcweir class PropertySetMixinImpl::Impl: public Data {
435*cdf0e10cSrcweir public:
436*cdf0e10cSrcweir     Impl(
437*cdf0e10cSrcweir         css::uno::Reference< css::uno::XComponentContext > const & context,
438*cdf0e10cSrcweir         Implements theImplements,
439*cdf0e10cSrcweir         css::uno::Sequence< rtl::OUString > const & absentOptional,
440*cdf0e10cSrcweir         css::uno::Type const & type);
441*cdf0e10cSrcweir 
442*cdf0e10cSrcweir     rtl::OUString translateHandle(
443*cdf0e10cSrcweir         css::uno::Reference< css::uno::XInterface > const & object,
444*cdf0e10cSrcweir         sal_Int32 handle) const;
445*cdf0e10cSrcweir 
446*cdf0e10cSrcweir     void setProperty(
447*cdf0e10cSrcweir         css::uno::Reference< css::uno::XInterface > const & object,
448*cdf0e10cSrcweir         rtl::OUString const & name, css::uno::Any const & value,
449*cdf0e10cSrcweir         bool isAmbiguous, bool isDefaulted, sal_Int16 illegalArgumentPosition)
450*cdf0e10cSrcweir         const;
451*cdf0e10cSrcweir 
452*cdf0e10cSrcweir     css::uno::Any getProperty(
453*cdf0e10cSrcweir         css::uno::Reference< css::uno::XInterface > const & object,
454*cdf0e10cSrcweir         rtl::OUString const & name, css::beans::PropertyState * state) const;
455*cdf0e10cSrcweir 
456*cdf0e10cSrcweir     PropertySetMixinImpl::Implements implements;
457*cdf0e10cSrcweir     css::uno::Sequence< rtl::OUString > handleMap;
458*cdf0e10cSrcweir 
459*cdf0e10cSrcweir     typedef std::map< rtl::OUString, BoundListenerBag > BoundListenerMap;
460*cdf0e10cSrcweir 
461*cdf0e10cSrcweir     typedef
462*cdf0e10cSrcweir     std::multiset< css::uno::Reference< css::beans::XVetoableChangeListener > >
463*cdf0e10cSrcweir     VetoListenerBag;
464*cdf0e10cSrcweir 
465*cdf0e10cSrcweir     typedef std::map< rtl::OUString, VetoListenerBag > VetoListenerMap;
466*cdf0e10cSrcweir 
467*cdf0e10cSrcweir     mutable osl::Mutex mutex;
468*cdf0e10cSrcweir     BoundListenerMap boundListeners;
469*cdf0e10cSrcweir     VetoListenerMap vetoListeners;
470*cdf0e10cSrcweir     bool disposed;
471*cdf0e10cSrcweir 
472*cdf0e10cSrcweir private:
473*cdf0e10cSrcweir     css::uno::Reference< css::reflection::XIdlClass > getReflection(
474*cdf0e10cSrcweir         rtl::OUString const & typeName) const;
475*cdf0e10cSrcweir 
476*cdf0e10cSrcweir     static css::uno::Any wrapValue(
477*cdf0e10cSrcweir         css::uno::Reference< css::uno::XInterface > const & object,
478*cdf0e10cSrcweir         css::uno::Any const & value,
479*cdf0e10cSrcweir         css::uno::Reference< css::reflection::XIdlClass > const & type,
480*cdf0e10cSrcweir         bool wrapAmbiguous, bool isAmbiguous, bool wrapDefaulted,
481*cdf0e10cSrcweir         bool isDefaulted, bool wrapOptional);
482*cdf0e10cSrcweir 
483*cdf0e10cSrcweir     css::uno::Reference< css::uno::XComponentContext > const & m_context;
484*cdf0e10cSrcweir     css::uno::Sequence< rtl::OUString > m_absentOptional;
485*cdf0e10cSrcweir     css::uno::Type m_type;
486*cdf0e10cSrcweir     css::uno::Reference< css::reflection::XIdlClass > m_idlClass;
487*cdf0e10cSrcweir };
488*cdf0e10cSrcweir 
489*cdf0e10cSrcweir PropertySetMixinImpl::Impl::Impl(
490*cdf0e10cSrcweir     css::uno::Reference< css::uno::XComponentContext > const & context,
491*cdf0e10cSrcweir     Implements theImplements,
492*cdf0e10cSrcweir     css::uno::Sequence< rtl::OUString > const & absentOptional,
493*cdf0e10cSrcweir     css::uno::Type const & type):
494*cdf0e10cSrcweir     implements(theImplements), disposed(false), m_context(context),
495*cdf0e10cSrcweir     m_absentOptional(absentOptional), m_type(type)
496*cdf0e10cSrcweir {
497*cdf0e10cSrcweir     OSL_ASSERT(
498*cdf0e10cSrcweir         context.is()
499*cdf0e10cSrcweir         && ((implements
500*cdf0e10cSrcweir              & ~(IMPLEMENTS_PROPERTY_SET | IMPLEMENTS_FAST_PROPERTY_SET
501*cdf0e10cSrcweir                  | IMPLEMENTS_PROPERTY_ACCESS))
502*cdf0e10cSrcweir             == 0));
503*cdf0e10cSrcweir     m_idlClass = getReflection(m_type.getTypeName());
504*cdf0e10cSrcweir     css::uno::Reference< css::reflection::XTypeDescription > ifc;
505*cdf0e10cSrcweir     try {
506*cdf0e10cSrcweir         ifc = css::uno::Reference< css::reflection::XTypeDescription >(
507*cdf0e10cSrcweir             css::uno::Reference< css::container::XHierarchicalNameAccess >(
508*cdf0e10cSrcweir                 m_context->getValueByName(
509*cdf0e10cSrcweir                     rtl::OUString(
510*cdf0e10cSrcweir                         RTL_CONSTASCII_USTRINGPARAM(
511*cdf0e10cSrcweir                             "/singletons/com.sun.star.reflection."
512*cdf0e10cSrcweir                             "theTypeDescriptionManager"))),
513*cdf0e10cSrcweir                 css::uno::UNO_QUERY_THROW)->getByHierarchicalName(
514*cdf0e10cSrcweir                     m_type.getTypeName()),
515*cdf0e10cSrcweir             css::uno::UNO_QUERY_THROW);
516*cdf0e10cSrcweir     } catch (css::container::NoSuchElementException & e) {
517*cdf0e10cSrcweir         throw css::uno::RuntimeException(
518*cdf0e10cSrcweir             (rtl::OUString(
519*cdf0e10cSrcweir                 RTL_CONSTASCII_USTRINGPARAM(
520*cdf0e10cSrcweir                     "unexpected"
521*cdf0e10cSrcweir                     " com.sun.star.container.NoSuchElementException: "))
522*cdf0e10cSrcweir              + e.Message),
523*cdf0e10cSrcweir             css::uno::Reference< css::uno::XInterface >());
524*cdf0e10cSrcweir     }
525*cdf0e10cSrcweir     std::vector< rtl::OUString > handleNames;
526*cdf0e10cSrcweir     initProperties(ifc, m_absentOptional, &handleNames);
527*cdf0e10cSrcweir     std::vector< rtl::OUString >::size_type size = handleNames.size();
528*cdf0e10cSrcweir     OSL_ASSERT(size <= SAL_MAX_INT32);
529*cdf0e10cSrcweir     handleMap.realloc(static_cast< sal_Int32 >(size));
530*cdf0e10cSrcweir     std::copy(handleNames.begin(), handleNames.end(), handleMap.getArray());
531*cdf0e10cSrcweir }
532*cdf0e10cSrcweir 
533*cdf0e10cSrcweir rtl::OUString PropertySetMixinImpl::Impl::translateHandle(
534*cdf0e10cSrcweir     css::uno::Reference< css::uno::XInterface > const & object,
535*cdf0e10cSrcweir     sal_Int32 handle) const
536*cdf0e10cSrcweir {
537*cdf0e10cSrcweir     if (handle < 0 || handle >= handleMap.getLength()) {
538*cdf0e10cSrcweir         throw css::beans::UnknownPropertyException(
539*cdf0e10cSrcweir             (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("bad handle "))
540*cdf0e10cSrcweir              + rtl::OUString::valueOf(handle)),
541*cdf0e10cSrcweir             object);
542*cdf0e10cSrcweir     }
543*cdf0e10cSrcweir     return handleMap[handle];
544*cdf0e10cSrcweir }
545*cdf0e10cSrcweir 
546*cdf0e10cSrcweir void PropertySetMixinImpl::Impl::setProperty(
547*cdf0e10cSrcweir     css::uno::Reference< css::uno::XInterface > const & object,
548*cdf0e10cSrcweir     rtl::OUString const & name, css::uno::Any const & value, bool isAmbiguous,
549*cdf0e10cSrcweir     bool isDefaulted, sal_Int16 illegalArgumentPosition) const
550*cdf0e10cSrcweir {
551*cdf0e10cSrcweir     PropertyMap::const_iterator i(properties.find(name));
552*cdf0e10cSrcweir     if (i == properties.end()) {
553*cdf0e10cSrcweir         throw css::beans::UnknownPropertyException(name, object);
554*cdf0e10cSrcweir     }
555*cdf0e10cSrcweir     if ((isAmbiguous
556*cdf0e10cSrcweir          && ((i->second.property.Attributes
557*cdf0e10cSrcweir               & css::beans::PropertyAttribute::MAYBEAMBIGUOUS)
558*cdf0e10cSrcweir              == 0))
559*cdf0e10cSrcweir         || (isDefaulted
560*cdf0e10cSrcweir             && ((i->second.property.Attributes
561*cdf0e10cSrcweir                  & css::beans::PropertyAttribute::MAYBEDEFAULT)
562*cdf0e10cSrcweir                 == 0)))
563*cdf0e10cSrcweir     {
564*cdf0e10cSrcweir         throw css::lang::IllegalArgumentException(
565*cdf0e10cSrcweir             (rtl::OUString(
566*cdf0e10cSrcweir                 RTL_CONSTASCII_USTRINGPARAM(
567*cdf0e10cSrcweir                     "flagging as ambiguous/defaulted non-ambiguous/defaulted"
568*cdf0e10cSrcweir                     " property "))
569*cdf0e10cSrcweir              + name),
570*cdf0e10cSrcweir             object, illegalArgumentPosition);
571*cdf0e10cSrcweir     }
572*cdf0e10cSrcweir     css::uno::Reference< css::reflection::XIdlField2 > f(
573*cdf0e10cSrcweir         m_idlClass->getField(name), css::uno::UNO_QUERY_THROW);
574*cdf0e10cSrcweir     css::uno::Any o(object->queryInterface(m_type));
575*cdf0e10cSrcweir     css::uno::Any v(
576*cdf0e10cSrcweir         wrapValue(
577*cdf0e10cSrcweir             object, value,
578*cdf0e10cSrcweir             (css::uno::Reference< css::reflection::XIdlField2 >(
579*cdf0e10cSrcweir                 m_idlClass->getField(name), css::uno::UNO_QUERY_THROW)->
580*cdf0e10cSrcweir              getType()),
581*cdf0e10cSrcweir             ((i->second.property.Attributes
582*cdf0e10cSrcweir               & css::beans::PropertyAttribute::MAYBEAMBIGUOUS)
583*cdf0e10cSrcweir              != 0),
584*cdf0e10cSrcweir             isAmbiguous,
585*cdf0e10cSrcweir             ((i->second.property.Attributes
586*cdf0e10cSrcweir               & css::beans::PropertyAttribute::MAYBEDEFAULT)
587*cdf0e10cSrcweir              != 0),
588*cdf0e10cSrcweir             isDefaulted,
589*cdf0e10cSrcweir             ((i->second.property.Attributes
590*cdf0e10cSrcweir               & css::beans::PropertyAttribute::MAYBEVOID)
591*cdf0e10cSrcweir              != 0)));
592*cdf0e10cSrcweir     try {
593*cdf0e10cSrcweir         f->set(o, v);
594*cdf0e10cSrcweir     } catch (css::lang::IllegalArgumentException & e) {
595*cdf0e10cSrcweir         if (e.ArgumentPosition == 1) {
596*cdf0e10cSrcweir             throw css::lang::IllegalArgumentException(
597*cdf0e10cSrcweir                 e.Message, object, illegalArgumentPosition);
598*cdf0e10cSrcweir         } else {
599*cdf0e10cSrcweir             throw css::uno::RuntimeException(
600*cdf0e10cSrcweir                 (rtl::OUString(
601*cdf0e10cSrcweir                     RTL_CONSTASCII_USTRINGPARAM(
602*cdf0e10cSrcweir                         "unexpected"
603*cdf0e10cSrcweir                         " com.sun.star.lang.IllegalArgumentException: "))
604*cdf0e10cSrcweir                  + e.Message),
605*cdf0e10cSrcweir                 object);
606*cdf0e10cSrcweir         }
607*cdf0e10cSrcweir     } catch (css::lang::IllegalAccessException &) {
608*cdf0e10cSrcweir         //TODO  Clarify whether PropertyVetoException is the correct exception
609*cdf0e10cSrcweir         // to throw when trying to set a read-only property:
610*cdf0e10cSrcweir         throw css::beans::PropertyVetoException(
611*cdf0e10cSrcweir             (rtl::OUString(
612*cdf0e10cSrcweir                 RTL_CONSTASCII_USTRINGPARAM("cannot set read-only property "))
613*cdf0e10cSrcweir              + name),
614*cdf0e10cSrcweir             object);
615*cdf0e10cSrcweir     } catch (css::lang::WrappedTargetRuntimeException & e) {
616*cdf0e10cSrcweir         //FIXME  A WrappedTargetRuntimeException from XIdlField2.get is not
617*cdf0e10cSrcweir         // guaranteed to originate directly within XIdlField2.get (and thus have
618*cdf0e10cSrcweir         // the expected semantics); it might also be passed through from lower
619*cdf0e10cSrcweir         // layers.
620*cdf0e10cSrcweir         if (e.TargetException.isExtractableTo(
621*cdf0e10cSrcweir                 getCppuType(
622*cdf0e10cSrcweir                     static_cast< css::beans::UnknownPropertyException * >(0)))
623*cdf0e10cSrcweir             && ((i->second.property.Attributes
624*cdf0e10cSrcweir                  & css::beans::PropertyAttribute::OPTIONAL)
625*cdf0e10cSrcweir                 != 0))
626*cdf0e10cSrcweir         {
627*cdf0e10cSrcweir             throw css::beans::UnknownPropertyException(name, object);
628*cdf0e10cSrcweir         } else if (e.TargetException.isExtractableTo(
629*cdf0e10cSrcweir                        getCppuType(
630*cdf0e10cSrcweir                            static_cast< css::beans::PropertyVetoException * >(
631*cdf0e10cSrcweir                                0)))
632*cdf0e10cSrcweir                    && ((i->second.property.Attributes
633*cdf0e10cSrcweir                         & css::beans::PropertyAttribute::CONSTRAINED)
634*cdf0e10cSrcweir                        != 0))
635*cdf0e10cSrcweir         {
636*cdf0e10cSrcweir             throw css::beans::PropertyVetoException(name, object);
637*cdf0e10cSrcweir         } else {
638*cdf0e10cSrcweir             throw css::lang::WrappedTargetException(
639*cdf0e10cSrcweir                 e.Message, object, e.TargetException);
640*cdf0e10cSrcweir         }
641*cdf0e10cSrcweir     }
642*cdf0e10cSrcweir }
643*cdf0e10cSrcweir 
644*cdf0e10cSrcweir css::uno::Any PropertySetMixinImpl::Impl::getProperty(
645*cdf0e10cSrcweir     css::uno::Reference< css::uno::XInterface > const & object,
646*cdf0e10cSrcweir     rtl::OUString const & name, css::beans::PropertyState * state) const
647*cdf0e10cSrcweir {
648*cdf0e10cSrcweir     PropertyMap::const_iterator i(properties.find(name));
649*cdf0e10cSrcweir     if (i == properties.end()) {
650*cdf0e10cSrcweir         throw css::beans::UnknownPropertyException(name, object);
651*cdf0e10cSrcweir     }
652*cdf0e10cSrcweir     css::uno::Reference< css::reflection::XIdlField2 > field(
653*cdf0e10cSrcweir         m_idlClass->getField(name), css::uno::UNO_QUERY_THROW);
654*cdf0e10cSrcweir     css::uno::Any value;
655*cdf0e10cSrcweir     try {
656*cdf0e10cSrcweir         value = field->get(object->queryInterface(m_type));
657*cdf0e10cSrcweir     } catch (css::lang::IllegalArgumentException & e) {
658*cdf0e10cSrcweir         throw css::uno::RuntimeException(
659*cdf0e10cSrcweir             (rtl::OUString(
660*cdf0e10cSrcweir                 RTL_CONSTASCII_USTRINGPARAM(
661*cdf0e10cSrcweir                     "unexpected com.sun.star.lang.IllegalArgumentException: "))
662*cdf0e10cSrcweir              + e.Message),
663*cdf0e10cSrcweir             object);
664*cdf0e10cSrcweir     } catch (css::lang::WrappedTargetRuntimeException & e) {
665*cdf0e10cSrcweir         //FIXME  A WrappedTargetRuntimeException from XIdlField2.get is not
666*cdf0e10cSrcweir         // guaranteed to originate directly within XIdlField2.get (and thus have
667*cdf0e10cSrcweir         // the expected semantics); it might also be passed through from lower
668*cdf0e10cSrcweir         // layers.
669*cdf0e10cSrcweir         if (e.TargetException.isExtractableTo(
670*cdf0e10cSrcweir                 getCppuType(
671*cdf0e10cSrcweir                     static_cast< css::beans::UnknownPropertyException * >(0)))
672*cdf0e10cSrcweir             && ((i->second.property.Attributes
673*cdf0e10cSrcweir                  & css::beans::PropertyAttribute::OPTIONAL)
674*cdf0e10cSrcweir                 != 0))
675*cdf0e10cSrcweir         {
676*cdf0e10cSrcweir             throw css::beans::UnknownPropertyException(name, object);
677*cdf0e10cSrcweir         } else {
678*cdf0e10cSrcweir             throw css::lang::WrappedTargetException(
679*cdf0e10cSrcweir                 e.Message, object, e.TargetException);
680*cdf0e10cSrcweir         }
681*cdf0e10cSrcweir     }
682*cdf0e10cSrcweir     bool undoAmbiguous
683*cdf0e10cSrcweir         = ((i->second.property.Attributes
684*cdf0e10cSrcweir             & css::beans::PropertyAttribute::MAYBEAMBIGUOUS)
685*cdf0e10cSrcweir            != 0);
686*cdf0e10cSrcweir     bool undoDefaulted
687*cdf0e10cSrcweir         = ((i->second.property.Attributes
688*cdf0e10cSrcweir             & css::beans::PropertyAttribute::MAYBEDEFAULT)
689*cdf0e10cSrcweir            != 0);
690*cdf0e10cSrcweir     bool undoOptional
691*cdf0e10cSrcweir         = ((i->second.property.Attributes
692*cdf0e10cSrcweir             & css::beans::PropertyAttribute::MAYBEVOID)
693*cdf0e10cSrcweir            != 0);
694*cdf0e10cSrcweir     bool isAmbiguous = false;
695*cdf0e10cSrcweir     bool isDefaulted = false;
696*cdf0e10cSrcweir     while (undoAmbiguous || undoDefaulted || undoOptional) {
697*cdf0e10cSrcweir         if (undoAmbiguous
698*cdf0e10cSrcweir             && value.getValueTypeName().matchAsciiL(
699*cdf0e10cSrcweir                 RTL_CONSTASCII_STRINGPARAM("com.sun.star.beans.Ambiguous<")))
700*cdf0e10cSrcweir         {
701*cdf0e10cSrcweir             css::uno::Reference< css::reflection::XIdlClass > ambiguous(
702*cdf0e10cSrcweir                 getReflection(value.getValueTypeName()));
703*cdf0e10cSrcweir             try {
704*cdf0e10cSrcweir                 if (!(css::uno::Reference< css::reflection::XIdlField2 >(
705*cdf0e10cSrcweir                           ambiguous->getField(
706*cdf0e10cSrcweir                               rtl::OUString(
707*cdf0e10cSrcweir                                   RTL_CONSTASCII_USTRINGPARAM("IsAmbiguous"))),
708*cdf0e10cSrcweir                           css::uno::UNO_QUERY_THROW)->get(value)
709*cdf0e10cSrcweir                       >>= isAmbiguous))
710*cdf0e10cSrcweir                 {
711*cdf0e10cSrcweir                     throw css::uno::RuntimeException(
712*cdf0e10cSrcweir                         rtl::OUString(
713*cdf0e10cSrcweir                             RTL_CONSTASCII_USTRINGPARAM(
714*cdf0e10cSrcweir                                 "unexpected type of"
715*cdf0e10cSrcweir                                 " com.sun.star.beans.Ambiguous IsAmbiguous"
716*cdf0e10cSrcweir                                 " member")),
717*cdf0e10cSrcweir                         object);
718*cdf0e10cSrcweir                 }
719*cdf0e10cSrcweir                 value = css::uno::Reference< css::reflection::XIdlField2 >(
720*cdf0e10cSrcweir                     ambiguous->getField(
721*cdf0e10cSrcweir                         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Value"))),
722*cdf0e10cSrcweir                     css::uno::UNO_QUERY_THROW)->get(value);
723*cdf0e10cSrcweir             } catch (css::lang::IllegalArgumentException & e) {
724*cdf0e10cSrcweir                 throw css::uno::RuntimeException(
725*cdf0e10cSrcweir                     (rtl::OUString(
726*cdf0e10cSrcweir                         RTL_CONSTASCII_USTRINGPARAM(
727*cdf0e10cSrcweir                             "unexpected com.sun.star.lang."
728*cdf0e10cSrcweir                             "IllegalArgumentException: "))
729*cdf0e10cSrcweir                      + e.Message),
730*cdf0e10cSrcweir                     object);
731*cdf0e10cSrcweir             }
732*cdf0e10cSrcweir             undoAmbiguous = false;
733*cdf0e10cSrcweir         } else if (undoDefaulted
734*cdf0e10cSrcweir                    && value.getValueTypeName().matchAsciiL(
735*cdf0e10cSrcweir                        RTL_CONSTASCII_STRINGPARAM(
736*cdf0e10cSrcweir                            "com.sun.star.beans.Defaulted<")))
737*cdf0e10cSrcweir         {
738*cdf0e10cSrcweir             css::uno::Reference< css::reflection::XIdlClass > defaulted(
739*cdf0e10cSrcweir                 getReflection(value.getValueTypeName()));
740*cdf0e10cSrcweir             try {
741*cdf0e10cSrcweir 
742*cdf0e10cSrcweir                 if (!(css::uno::Reference< css::reflection::XIdlField2 >(
743*cdf0e10cSrcweir                           defaulted->getField(
744*cdf0e10cSrcweir                               rtl::OUString(
745*cdf0e10cSrcweir                                   RTL_CONSTASCII_USTRINGPARAM("IsDefaulted"))),
746*cdf0e10cSrcweir                           css::uno::UNO_QUERY_THROW)->get(value)
747*cdf0e10cSrcweir                       >>= isDefaulted))
748*cdf0e10cSrcweir                 {
749*cdf0e10cSrcweir                     throw css::uno::RuntimeException(
750*cdf0e10cSrcweir                         rtl::OUString(
751*cdf0e10cSrcweir                             RTL_CONSTASCII_USTRINGPARAM(
752*cdf0e10cSrcweir                                 "unexpected type of"
753*cdf0e10cSrcweir                                 " com.sun.star.beans.Defaulted IsDefaulted"
754*cdf0e10cSrcweir                                 " member")),
755*cdf0e10cSrcweir                         object);
756*cdf0e10cSrcweir                 }
757*cdf0e10cSrcweir                 value = css::uno::Reference< css::reflection::XIdlField2 >(
758*cdf0e10cSrcweir                     defaulted->getField(
759*cdf0e10cSrcweir                         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Value"))),
760*cdf0e10cSrcweir                     css::uno::UNO_QUERY_THROW)->get(value);
761*cdf0e10cSrcweir             } catch (css::lang::IllegalArgumentException & e) {
762*cdf0e10cSrcweir                 throw css::uno::RuntimeException(
763*cdf0e10cSrcweir                     (rtl::OUString(
764*cdf0e10cSrcweir                         RTL_CONSTASCII_USTRINGPARAM(
765*cdf0e10cSrcweir                             "unexpected com.sun.star.lang."
766*cdf0e10cSrcweir                             "IllegalArgumentException: "))
767*cdf0e10cSrcweir                      + e.Message),
768*cdf0e10cSrcweir                     object);
769*cdf0e10cSrcweir             }
770*cdf0e10cSrcweir             undoDefaulted = false;
771*cdf0e10cSrcweir         } else if (undoOptional
772*cdf0e10cSrcweir                    && value.getValueTypeName().matchAsciiL(
773*cdf0e10cSrcweir                        RTL_CONSTASCII_STRINGPARAM(
774*cdf0e10cSrcweir                            "com.sun.star.beans.Optional<")))
775*cdf0e10cSrcweir         {
776*cdf0e10cSrcweir             css::uno::Reference< css::reflection::XIdlClass > optional(
777*cdf0e10cSrcweir                 getReflection(value.getValueTypeName()));
778*cdf0e10cSrcweir             try {
779*cdf0e10cSrcweir                 bool present = false;
780*cdf0e10cSrcweir                 if (!(css::uno::Reference< css::reflection::XIdlField2 >(
781*cdf0e10cSrcweir                           optional->getField(
782*cdf0e10cSrcweir                               rtl::OUString(
783*cdf0e10cSrcweir                                   RTL_CONSTASCII_USTRINGPARAM("IsPresent"))),
784*cdf0e10cSrcweir                           css::uno::UNO_QUERY_THROW)->get(value)
785*cdf0e10cSrcweir                       >>= present))
786*cdf0e10cSrcweir                 {
787*cdf0e10cSrcweir                     throw css::uno::RuntimeException(
788*cdf0e10cSrcweir                         rtl::OUString(
789*cdf0e10cSrcweir                             RTL_CONSTASCII_USTRINGPARAM(
790*cdf0e10cSrcweir                                 "unexpected type of com.sun.star.beans.Optional"
791*cdf0e10cSrcweir                                 " IsPresent member")),
792*cdf0e10cSrcweir                         object);
793*cdf0e10cSrcweir                 }
794*cdf0e10cSrcweir                 if (!present) {
795*cdf0e10cSrcweir                     value.clear();
796*cdf0e10cSrcweir                     break;
797*cdf0e10cSrcweir                 }
798*cdf0e10cSrcweir                 value = css::uno::Reference< css::reflection::XIdlField2 >(
799*cdf0e10cSrcweir                     optional->getField(
800*cdf0e10cSrcweir                         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Value"))),
801*cdf0e10cSrcweir                     css::uno::UNO_QUERY_THROW)->get(value);
802*cdf0e10cSrcweir             } catch (css::lang::IllegalArgumentException & e) {
803*cdf0e10cSrcweir                 throw css::uno::RuntimeException(
804*cdf0e10cSrcweir                     (rtl::OUString(
805*cdf0e10cSrcweir                         RTL_CONSTASCII_USTRINGPARAM(
806*cdf0e10cSrcweir                             "unexpected com.sun.star.lang."
807*cdf0e10cSrcweir                             "IllegalArgumentException: "))
808*cdf0e10cSrcweir                      + e.Message),
809*cdf0e10cSrcweir                     object);
810*cdf0e10cSrcweir             }
811*cdf0e10cSrcweir             undoOptional = false;
812*cdf0e10cSrcweir         } else {
813*cdf0e10cSrcweir             throw css::uno::RuntimeException(
814*cdf0e10cSrcweir                 (rtl::OUString(
815*cdf0e10cSrcweir                     RTL_CONSTASCII_USTRINGPARAM(
816*cdf0e10cSrcweir                         "unexpected type of attribute "))
817*cdf0e10cSrcweir                  + name),
818*cdf0e10cSrcweir                 object);
819*cdf0e10cSrcweir         }
820*cdf0e10cSrcweir     }
821*cdf0e10cSrcweir     if (state != 0) {
822*cdf0e10cSrcweir         //XXX  If isAmbiguous && isDefaulted, arbitrarily choose AMBIGUOUS_VALUE
823*cdf0e10cSrcweir         // over DEFAULT_VALUE:
824*cdf0e10cSrcweir         *state = isAmbiguous
825*cdf0e10cSrcweir             ? css::beans::PropertyState_AMBIGUOUS_VALUE
826*cdf0e10cSrcweir             : isDefaulted
827*cdf0e10cSrcweir             ? css::beans::PropertyState_DEFAULT_VALUE
828*cdf0e10cSrcweir             : css::beans::PropertyState_DIRECT_VALUE;
829*cdf0e10cSrcweir     }
830*cdf0e10cSrcweir     return value;
831*cdf0e10cSrcweir }
832*cdf0e10cSrcweir 
833*cdf0e10cSrcweir css::uno::Reference< css::reflection::XIdlClass >
834*cdf0e10cSrcweir PropertySetMixinImpl::Impl::getReflection(rtl::OUString const & typeName) const
835*cdf0e10cSrcweir {
836*cdf0e10cSrcweir     css::uno::Reference< css::lang::XMultiComponentFactory > factory(
837*cdf0e10cSrcweir         m_context->getServiceManager(), css::uno::UNO_QUERY_THROW);
838*cdf0e10cSrcweir     AutoDispose< css::reflection::XIdlReflection > refl;
839*cdf0e10cSrcweir     try {
840*cdf0e10cSrcweir         refl.ifc = css::uno::Reference< css::reflection::XIdlReflection >(
841*cdf0e10cSrcweir             factory->createInstanceWithContext(
842*cdf0e10cSrcweir                 rtl::OUString(
843*cdf0e10cSrcweir                     RTL_CONSTASCII_USTRINGPARAM(
844*cdf0e10cSrcweir                         "com.sun.star.reflection.CoreReflection")),
845*cdf0e10cSrcweir                 m_context),
846*cdf0e10cSrcweir             css::uno::UNO_QUERY_THROW);
847*cdf0e10cSrcweir     } catch (css::uno::RuntimeException &) {
848*cdf0e10cSrcweir         throw;
849*cdf0e10cSrcweir     } catch (css::uno::Exception & e) {
850*cdf0e10cSrcweir         throw css::uno::DeploymentException(
851*cdf0e10cSrcweir             (rtl::OUString(
852*cdf0e10cSrcweir                 RTL_CONSTASCII_USTRINGPARAM(
853*cdf0e10cSrcweir                     "component context fails to supply service"
854*cdf0e10cSrcweir                     " com.sun.star.reflection.CoreReflection: "))
855*cdf0e10cSrcweir              + e.Message),
856*cdf0e10cSrcweir             m_context);
857*cdf0e10cSrcweir     }
858*cdf0e10cSrcweir     css::uno::Reference< css::reflection::XIdlClass > idlClass(
859*cdf0e10cSrcweir         refl.ifc->forName(typeName), css::uno::UNO_QUERY_THROW);
860*cdf0e10cSrcweir     refl.dispose();
861*cdf0e10cSrcweir     return idlClass;
862*cdf0e10cSrcweir }
863*cdf0e10cSrcweir 
864*cdf0e10cSrcweir css::uno::Any PropertySetMixinImpl::Impl::wrapValue(
865*cdf0e10cSrcweir     css::uno::Reference< css::uno::XInterface > const & object,
866*cdf0e10cSrcweir     css::uno::Any const & value,
867*cdf0e10cSrcweir     css::uno::Reference< css::reflection::XIdlClass > const & type,
868*cdf0e10cSrcweir     bool wrapAmbiguous, bool isAmbiguous, bool wrapDefaulted, bool isDefaulted,
869*cdf0e10cSrcweir     bool wrapOptional)
870*cdf0e10cSrcweir {
871*cdf0e10cSrcweir     OSL_ASSERT(
872*cdf0e10cSrcweir         (wrapAmbiguous || !isAmbiguous) && (wrapDefaulted || !isDefaulted));
873*cdf0e10cSrcweir     if (wrapAmbiguous
874*cdf0e10cSrcweir         && type->getName().matchAsciiL(
875*cdf0e10cSrcweir             RTL_CONSTASCII_STRINGPARAM("com.sun.star.beans.Ambiguous<")))
876*cdf0e10cSrcweir     {
877*cdf0e10cSrcweir         css::uno::Any strct;
878*cdf0e10cSrcweir         type->createObject(strct);
879*cdf0e10cSrcweir         try {
880*cdf0e10cSrcweir             css::uno::Reference< css::reflection::XIdlField2 > field(
881*cdf0e10cSrcweir                 type->getField(
882*cdf0e10cSrcweir                     rtl::OUString(
883*cdf0e10cSrcweir                         RTL_CONSTASCII_USTRINGPARAM("Value"))),
884*cdf0e10cSrcweir                 css::uno::UNO_QUERY_THROW);
885*cdf0e10cSrcweir             field->set(
886*cdf0e10cSrcweir                 strct,
887*cdf0e10cSrcweir                 wrapValue(
888*cdf0e10cSrcweir                     object, value, field->getType(), false, false,
889*cdf0e10cSrcweir                     wrapDefaulted, isDefaulted, wrapOptional));
890*cdf0e10cSrcweir             css::uno::Reference< css::reflection::XIdlField2 >(
891*cdf0e10cSrcweir                 type->getField(
892*cdf0e10cSrcweir                     rtl::OUString(
893*cdf0e10cSrcweir                         RTL_CONSTASCII_USTRINGPARAM("IsAmbiguous"))),
894*cdf0e10cSrcweir                 css::uno::UNO_QUERY_THROW)->set(
895*cdf0e10cSrcweir                     strct, css::uno::makeAny(isAmbiguous));
896*cdf0e10cSrcweir         } catch (css::lang::IllegalArgumentException & e) {
897*cdf0e10cSrcweir             throw css::uno::RuntimeException(
898*cdf0e10cSrcweir                 (rtl::OUString(
899*cdf0e10cSrcweir                     RTL_CONSTASCII_USTRINGPARAM(
900*cdf0e10cSrcweir                         "unexpected"
901*cdf0e10cSrcweir                         " com.sun.star.lang.IllegalArgumentException: "))
902*cdf0e10cSrcweir                  + e.Message),
903*cdf0e10cSrcweir                 object);
904*cdf0e10cSrcweir         } catch (css::lang::IllegalAccessException & e) {
905*cdf0e10cSrcweir             throw css::uno::RuntimeException(
906*cdf0e10cSrcweir                 (rtl::OUString(
907*cdf0e10cSrcweir                     RTL_CONSTASCII_USTRINGPARAM(
908*cdf0e10cSrcweir                         "unexpected"
909*cdf0e10cSrcweir                         " com.sun.star.lang.IllegalAccessException: "))
910*cdf0e10cSrcweir                  + e.Message),
911*cdf0e10cSrcweir                 object);
912*cdf0e10cSrcweir         }
913*cdf0e10cSrcweir         return strct;
914*cdf0e10cSrcweir     } else if (wrapDefaulted
915*cdf0e10cSrcweir                && type->getName().matchAsciiL(
916*cdf0e10cSrcweir                    RTL_CONSTASCII_STRINGPARAM("com.sun.star.beans.Defaulted<")))
917*cdf0e10cSrcweir     {
918*cdf0e10cSrcweir         css::uno::Any strct;
919*cdf0e10cSrcweir         type->createObject(strct);
920*cdf0e10cSrcweir         try {
921*cdf0e10cSrcweir             css::uno::Reference< css::reflection::XIdlField2 > field(
922*cdf0e10cSrcweir                 type->getField(
923*cdf0e10cSrcweir                     rtl::OUString(
924*cdf0e10cSrcweir                         RTL_CONSTASCII_USTRINGPARAM("Value"))),
925*cdf0e10cSrcweir                 css::uno::UNO_QUERY_THROW);
926*cdf0e10cSrcweir             field->set(
927*cdf0e10cSrcweir                 strct,
928*cdf0e10cSrcweir                 wrapValue(
929*cdf0e10cSrcweir                     object, value, field->getType(), wrapAmbiguous, isAmbiguous,
930*cdf0e10cSrcweir                     false, false, wrapOptional));
931*cdf0e10cSrcweir             css::uno::Reference< css::reflection::XIdlField2 >(
932*cdf0e10cSrcweir                 type->getField(
933*cdf0e10cSrcweir                     rtl::OUString(
934*cdf0e10cSrcweir                         RTL_CONSTASCII_USTRINGPARAM("IsDefaulted"))),
935*cdf0e10cSrcweir                 css::uno::UNO_QUERY_THROW)->set(
936*cdf0e10cSrcweir                     strct, css::uno::makeAny(isDefaulted));
937*cdf0e10cSrcweir         } catch (css::lang::IllegalArgumentException & e) {
938*cdf0e10cSrcweir             throw css::uno::RuntimeException(
939*cdf0e10cSrcweir                 (rtl::OUString(
940*cdf0e10cSrcweir                     RTL_CONSTASCII_USTRINGPARAM(
941*cdf0e10cSrcweir                         "unexpected"
942*cdf0e10cSrcweir                         " com.sun.star.lang.IllegalArgumentException: "))
943*cdf0e10cSrcweir                  + e.Message),
944*cdf0e10cSrcweir                 object);
945*cdf0e10cSrcweir         } catch (css::lang::IllegalAccessException & e) {
946*cdf0e10cSrcweir             throw css::uno::RuntimeException(
947*cdf0e10cSrcweir                 (rtl::OUString(
948*cdf0e10cSrcweir                     RTL_CONSTASCII_USTRINGPARAM(
949*cdf0e10cSrcweir                         "unexpected"
950*cdf0e10cSrcweir                         " com.sun.star.lang.IllegalAccessException: "))
951*cdf0e10cSrcweir                  + e.Message),
952*cdf0e10cSrcweir                 object);
953*cdf0e10cSrcweir         }
954*cdf0e10cSrcweir         return strct;
955*cdf0e10cSrcweir     } else if (wrapOptional
956*cdf0e10cSrcweir                && type->getName().matchAsciiL(
957*cdf0e10cSrcweir                    RTL_CONSTASCII_STRINGPARAM("com.sun.star.beans.Optional<")))
958*cdf0e10cSrcweir     {
959*cdf0e10cSrcweir         css::uno::Any strct;
960*cdf0e10cSrcweir         type->createObject(strct);
961*cdf0e10cSrcweir         bool present = value.hasValue();
962*cdf0e10cSrcweir         try {
963*cdf0e10cSrcweir             css::uno::Reference< css::reflection::XIdlField2 >(
964*cdf0e10cSrcweir                 type->getField(
965*cdf0e10cSrcweir                     rtl::OUString(
966*cdf0e10cSrcweir                         RTL_CONSTASCII_USTRINGPARAM("IsPresent"))),
967*cdf0e10cSrcweir                 css::uno::UNO_QUERY_THROW)->set(
968*cdf0e10cSrcweir                     strct, css::uno::makeAny(present));
969*cdf0e10cSrcweir             if (present) {
970*cdf0e10cSrcweir                 css::uno::Reference< css::reflection::XIdlField2 > field(
971*cdf0e10cSrcweir                     type->getField(
972*cdf0e10cSrcweir                         rtl::OUString(
973*cdf0e10cSrcweir                             RTL_CONSTASCII_USTRINGPARAM("Value"))),
974*cdf0e10cSrcweir                     css::uno::UNO_QUERY_THROW);
975*cdf0e10cSrcweir                 field->set(
976*cdf0e10cSrcweir                     strct,
977*cdf0e10cSrcweir                     wrapValue(
978*cdf0e10cSrcweir                         object, value, field->getType(), wrapAmbiguous,
979*cdf0e10cSrcweir                         isAmbiguous, wrapDefaulted, isDefaulted, false));
980*cdf0e10cSrcweir             }
981*cdf0e10cSrcweir         } catch (css::lang::IllegalArgumentException & e) {
982*cdf0e10cSrcweir             throw css::uno::RuntimeException(
983*cdf0e10cSrcweir                 (rtl::OUString(
984*cdf0e10cSrcweir                     RTL_CONSTASCII_USTRINGPARAM(
985*cdf0e10cSrcweir                         "unexpected"
986*cdf0e10cSrcweir                         " com.sun.star.lang.IllegalArgumentException: "))
987*cdf0e10cSrcweir                  + e.Message),
988*cdf0e10cSrcweir                 object);
989*cdf0e10cSrcweir         } catch (css::lang::IllegalAccessException & e) {
990*cdf0e10cSrcweir             throw css::uno::RuntimeException(
991*cdf0e10cSrcweir                 (rtl::OUString(
992*cdf0e10cSrcweir                     RTL_CONSTASCII_USTRINGPARAM(
993*cdf0e10cSrcweir                         "unexpected"
994*cdf0e10cSrcweir                         " com.sun.star.lang.IllegalAccessException: "))
995*cdf0e10cSrcweir                  + e.Message),
996*cdf0e10cSrcweir                 object);
997*cdf0e10cSrcweir         }
998*cdf0e10cSrcweir         return strct;
999*cdf0e10cSrcweir     } else {
1000*cdf0e10cSrcweir         if (wrapAmbiguous || wrapDefaulted || wrapOptional) {
1001*cdf0e10cSrcweir             throw css::uno::RuntimeException(
1002*cdf0e10cSrcweir                 rtl::OUString(
1003*cdf0e10cSrcweir                     RTL_CONSTASCII_USTRINGPARAM(
1004*cdf0e10cSrcweir                         "unexpected type of attribute")),
1005*cdf0e10cSrcweir                 object);
1006*cdf0e10cSrcweir         }
1007*cdf0e10cSrcweir         return value;
1008*cdf0e10cSrcweir     }
1009*cdf0e10cSrcweir }
1010*cdf0e10cSrcweir 
1011*cdf0e10cSrcweir PropertySetMixinImpl::PropertySetMixinImpl(
1012*cdf0e10cSrcweir     css::uno::Reference< css::uno::XComponentContext > const & context,
1013*cdf0e10cSrcweir     Implements implements,
1014*cdf0e10cSrcweir     css::uno::Sequence< rtl::OUString > const & absentOptional,
1015*cdf0e10cSrcweir     css::uno::Type const & type)
1016*cdf0e10cSrcweir {
1017*cdf0e10cSrcweir     m_impl = new Impl(context, implements, absentOptional, type);
1018*cdf0e10cSrcweir     m_impl->acquire();
1019*cdf0e10cSrcweir }
1020*cdf0e10cSrcweir 
1021*cdf0e10cSrcweir PropertySetMixinImpl::~PropertySetMixinImpl() {
1022*cdf0e10cSrcweir     m_impl->release();
1023*cdf0e10cSrcweir }
1024*cdf0e10cSrcweir 
1025*cdf0e10cSrcweir void PropertySetMixinImpl::checkUnknown(rtl::OUString const & propertyName) {
1026*cdf0e10cSrcweir     if (propertyName.getLength() != 0) {
1027*cdf0e10cSrcweir         m_impl->get(
1028*cdf0e10cSrcweir             static_cast< css::beans::XPropertySet * >(this), propertyName);
1029*cdf0e10cSrcweir     }
1030*cdf0e10cSrcweir }
1031*cdf0e10cSrcweir 
1032*cdf0e10cSrcweir void PropertySetMixinImpl::prepareSet(
1033*cdf0e10cSrcweir     rtl::OUString const & propertyName, css::uno::Any const & oldValue,
1034*cdf0e10cSrcweir     css::uno::Any const & newValue, BoundListeners * boundListeners)
1035*cdf0e10cSrcweir {
1036*cdf0e10cSrcweir     Impl::PropertyMap::const_iterator it(m_impl->properties.find(propertyName));
1037*cdf0e10cSrcweir     OSL_ASSERT(it != m_impl->properties.end());
1038*cdf0e10cSrcweir     Impl::VetoListenerBag specificVeto;
1039*cdf0e10cSrcweir     Impl::VetoListenerBag unspecificVeto;
1040*cdf0e10cSrcweir     {
1041*cdf0e10cSrcweir         osl::MutexGuard g(m_impl->mutex);
1042*cdf0e10cSrcweir         if (m_impl->disposed) {
1043*cdf0e10cSrcweir             throw css::lang::DisposedException(
1044*cdf0e10cSrcweir                 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("disposed")),
1045*cdf0e10cSrcweir                 static_cast< css::beans::XPropertySet * >(this));
1046*cdf0e10cSrcweir         }
1047*cdf0e10cSrcweir         if ((it->second.property.Attributes
1048*cdf0e10cSrcweir              & css::beans::PropertyAttribute::CONSTRAINED)
1049*cdf0e10cSrcweir             != 0)
1050*cdf0e10cSrcweir         {
1051*cdf0e10cSrcweir             Impl::VetoListenerMap::const_iterator i(
1052*cdf0e10cSrcweir                 m_impl->vetoListeners.find(propertyName));
1053*cdf0e10cSrcweir             if (i != m_impl->vetoListeners.end()) {
1054*cdf0e10cSrcweir                 specificVeto = i->second;
1055*cdf0e10cSrcweir             }
1056*cdf0e10cSrcweir             i = m_impl->vetoListeners.find(rtl::OUString());
1057*cdf0e10cSrcweir             if (i != m_impl->vetoListeners.end()) {
1058*cdf0e10cSrcweir                 unspecificVeto = i->second;
1059*cdf0e10cSrcweir             }
1060*cdf0e10cSrcweir         }
1061*cdf0e10cSrcweir         if ((it->second.property.Attributes
1062*cdf0e10cSrcweir              & css::beans::PropertyAttribute::BOUND)
1063*cdf0e10cSrcweir             != 0)
1064*cdf0e10cSrcweir         {
1065*cdf0e10cSrcweir             OSL_ASSERT(boundListeners != 0);
1066*cdf0e10cSrcweir             Impl::BoundListenerMap::const_iterator i(
1067*cdf0e10cSrcweir                 m_impl->boundListeners.find(propertyName));
1068*cdf0e10cSrcweir             if (i != m_impl->boundListeners.end()) {
1069*cdf0e10cSrcweir                 boundListeners->m_impl->specificListeners = i->second;
1070*cdf0e10cSrcweir             }
1071*cdf0e10cSrcweir             i = m_impl->boundListeners.find(rtl::OUString());
1072*cdf0e10cSrcweir             if (i != m_impl->boundListeners.end()) {
1073*cdf0e10cSrcweir                 boundListeners->m_impl->unspecificListeners = i->second;
1074*cdf0e10cSrcweir             }
1075*cdf0e10cSrcweir         }
1076*cdf0e10cSrcweir     }
1077*cdf0e10cSrcweir     if ((it->second.property.Attributes
1078*cdf0e10cSrcweir          & css::beans::PropertyAttribute::CONSTRAINED)
1079*cdf0e10cSrcweir         != 0)
1080*cdf0e10cSrcweir     {
1081*cdf0e10cSrcweir         css::beans::PropertyChangeEvent event(
1082*cdf0e10cSrcweir             static_cast< css::beans::XPropertySet * >(this), propertyName,
1083*cdf0e10cSrcweir             false, it->second.property.Handle, oldValue, newValue);
1084*cdf0e10cSrcweir         for (Impl::VetoListenerBag::iterator i(specificVeto.begin());
1085*cdf0e10cSrcweir              i != specificVeto.end(); ++i)
1086*cdf0e10cSrcweir         {
1087*cdf0e10cSrcweir             try {
1088*cdf0e10cSrcweir                 (*i)->vetoableChange(event);
1089*cdf0e10cSrcweir             } catch (css::lang::DisposedException &) {}
1090*cdf0e10cSrcweir         }
1091*cdf0e10cSrcweir         for (Impl::VetoListenerBag::iterator i(unspecificVeto.begin());
1092*cdf0e10cSrcweir              i != unspecificVeto.end(); ++i)
1093*cdf0e10cSrcweir         {
1094*cdf0e10cSrcweir             try {
1095*cdf0e10cSrcweir                 (*i)->vetoableChange(event);
1096*cdf0e10cSrcweir             } catch (css::lang::DisposedException &) {}
1097*cdf0e10cSrcweir         }
1098*cdf0e10cSrcweir     }
1099*cdf0e10cSrcweir     if ((it->second.property.Attributes & css::beans::PropertyAttribute::BOUND)
1100*cdf0e10cSrcweir         != 0)
1101*cdf0e10cSrcweir     {
1102*cdf0e10cSrcweir         OSL_ASSERT(boundListeners != 0);
1103*cdf0e10cSrcweir         boundListeners->m_impl->event = css::beans::PropertyChangeEvent(
1104*cdf0e10cSrcweir             static_cast< css::beans::XPropertySet * >(this), propertyName,
1105*cdf0e10cSrcweir             false, it->second.property.Handle, oldValue, newValue);
1106*cdf0e10cSrcweir     }
1107*cdf0e10cSrcweir }
1108*cdf0e10cSrcweir 
1109*cdf0e10cSrcweir void PropertySetMixinImpl::dispose() {
1110*cdf0e10cSrcweir     Impl::BoundListenerMap boundListeners;
1111*cdf0e10cSrcweir     Impl::VetoListenerMap vetoListeners;
1112*cdf0e10cSrcweir     {
1113*cdf0e10cSrcweir         osl::MutexGuard g(m_impl->mutex);
1114*cdf0e10cSrcweir         boundListeners.swap(m_impl->boundListeners);
1115*cdf0e10cSrcweir         vetoListeners.swap(m_impl->vetoListeners);
1116*cdf0e10cSrcweir         m_impl->disposed = true;
1117*cdf0e10cSrcweir     }
1118*cdf0e10cSrcweir     css::lang::EventObject event(
1119*cdf0e10cSrcweir         static_cast< css::beans::XPropertySet * >(this));
1120*cdf0e10cSrcweir     for (Impl::BoundListenerMap::iterator i(boundListeners.begin());
1121*cdf0e10cSrcweir          i != boundListeners.end(); ++i)
1122*cdf0e10cSrcweir     {
1123*cdf0e10cSrcweir         for (BoundListenerBag::iterator j(i->second.begin());
1124*cdf0e10cSrcweir              j != i->second.end(); ++j)
1125*cdf0e10cSrcweir         {
1126*cdf0e10cSrcweir             (*j)->disposing(event);
1127*cdf0e10cSrcweir         }
1128*cdf0e10cSrcweir     }
1129*cdf0e10cSrcweir     for (Impl::VetoListenerMap::iterator i(vetoListeners.begin());
1130*cdf0e10cSrcweir          i != vetoListeners.end(); ++i)
1131*cdf0e10cSrcweir     {
1132*cdf0e10cSrcweir         for (Impl::VetoListenerBag::iterator j(i->second.begin());
1133*cdf0e10cSrcweir              j != i->second.end(); ++j)
1134*cdf0e10cSrcweir         {
1135*cdf0e10cSrcweir             (*j)->disposing(event);
1136*cdf0e10cSrcweir         }
1137*cdf0e10cSrcweir     }
1138*cdf0e10cSrcweir }
1139*cdf0e10cSrcweir 
1140*cdf0e10cSrcweir css::uno::Any PropertySetMixinImpl::queryInterface(css::uno::Type const & type)
1141*cdf0e10cSrcweir     throw (css::uno::RuntimeException)
1142*cdf0e10cSrcweir {
1143*cdf0e10cSrcweir     if (((m_impl->implements & IMPLEMENTS_PROPERTY_SET) != 0
1144*cdf0e10cSrcweir          && type == css::beans::XPropertySet::static_type()))
1145*cdf0e10cSrcweir     {
1146*cdf0e10cSrcweir         css::uno::Reference< css::uno::XInterface > ifc(
1147*cdf0e10cSrcweir             static_cast< css::beans::XPropertySet * >(this));
1148*cdf0e10cSrcweir         return css::uno::Any(&ifc, type);
1149*cdf0e10cSrcweir     } else if ((m_impl->implements & IMPLEMENTS_FAST_PROPERTY_SET) != 0
1150*cdf0e10cSrcweir                && type == css::beans::XFastPropertySet::static_type())
1151*cdf0e10cSrcweir     {
1152*cdf0e10cSrcweir         css::uno::Reference< css::uno::XInterface > ifc(
1153*cdf0e10cSrcweir             static_cast< css::beans::XFastPropertySet * >(this));
1154*cdf0e10cSrcweir         return css::uno::Any(&ifc, type);
1155*cdf0e10cSrcweir     } else if ((m_impl->implements & IMPLEMENTS_PROPERTY_ACCESS) != 0
1156*cdf0e10cSrcweir                && type == css::beans::XPropertyAccess::static_type())
1157*cdf0e10cSrcweir     {
1158*cdf0e10cSrcweir         css::uno::Reference< css::uno::XInterface > ifc(
1159*cdf0e10cSrcweir             static_cast< css::beans::XPropertyAccess * >(this));
1160*cdf0e10cSrcweir         return css::uno::Any(&ifc, type);
1161*cdf0e10cSrcweir     } else {
1162*cdf0e10cSrcweir         return css::uno::Any();
1163*cdf0e10cSrcweir     }
1164*cdf0e10cSrcweir }
1165*cdf0e10cSrcweir 
1166*cdf0e10cSrcweir css::uno::Reference< css::beans::XPropertySetInfo >
1167*cdf0e10cSrcweir PropertySetMixinImpl::getPropertySetInfo() throw (css::uno::RuntimeException) {
1168*cdf0e10cSrcweir     try {
1169*cdf0e10cSrcweir         return new Info(m_impl);
1170*cdf0e10cSrcweir     } catch (std::bad_alloc &) {
1171*cdf0e10cSrcweir         //TODO  OutOfMemoryException:
1172*cdf0e10cSrcweir         throw css::uno::RuntimeException(
1173*cdf0e10cSrcweir             rtl::OUString(), static_cast< css::beans::XPropertySet * >(this));
1174*cdf0e10cSrcweir     }
1175*cdf0e10cSrcweir }
1176*cdf0e10cSrcweir 
1177*cdf0e10cSrcweir void PropertySetMixinImpl::setPropertyValue(
1178*cdf0e10cSrcweir     rtl::OUString const & propertyName, css::uno::Any const & value)
1179*cdf0e10cSrcweir     throw (
1180*cdf0e10cSrcweir         css::beans::UnknownPropertyException, css::beans::PropertyVetoException,
1181*cdf0e10cSrcweir         css::lang::IllegalArgumentException, css::lang::WrappedTargetException,
1182*cdf0e10cSrcweir         css::uno::RuntimeException)
1183*cdf0e10cSrcweir {
1184*cdf0e10cSrcweir     try {
1185*cdf0e10cSrcweir         m_impl->setProperty(
1186*cdf0e10cSrcweir             static_cast< css::beans::XPropertySet * >(this), propertyName,
1187*cdf0e10cSrcweir             value, false, false, 1);
1188*cdf0e10cSrcweir     } catch (std::bad_alloc &) {
1189*cdf0e10cSrcweir         //TODO  OutOfMemoryException:
1190*cdf0e10cSrcweir         throw css::uno::RuntimeException(
1191*cdf0e10cSrcweir             rtl::OUString(), static_cast< css::beans::XPropertySet * >(this));
1192*cdf0e10cSrcweir     }
1193*cdf0e10cSrcweir }
1194*cdf0e10cSrcweir 
1195*cdf0e10cSrcweir css::uno::Any PropertySetMixinImpl::getPropertyValue(
1196*cdf0e10cSrcweir     rtl::OUString const & propertyName)
1197*cdf0e10cSrcweir     throw (
1198*cdf0e10cSrcweir         css::beans::UnknownPropertyException, css::lang::WrappedTargetException,
1199*cdf0e10cSrcweir         css::uno::RuntimeException)
1200*cdf0e10cSrcweir {
1201*cdf0e10cSrcweir     try {
1202*cdf0e10cSrcweir         return m_impl->getProperty(
1203*cdf0e10cSrcweir             static_cast< css::beans::XPropertySet * >(this), propertyName, 0);
1204*cdf0e10cSrcweir     } catch (std::bad_alloc &) {
1205*cdf0e10cSrcweir         //TODO  OutOfMemoryException:
1206*cdf0e10cSrcweir         throw css::uno::RuntimeException(
1207*cdf0e10cSrcweir             rtl::OUString(), static_cast< css::beans::XPropertySet * >(this));
1208*cdf0e10cSrcweir     }
1209*cdf0e10cSrcweir }
1210*cdf0e10cSrcweir 
1211*cdf0e10cSrcweir void PropertySetMixinImpl::addPropertyChangeListener(
1212*cdf0e10cSrcweir     rtl::OUString const & propertyName,
1213*cdf0e10cSrcweir     css::uno::Reference< css::beans::XPropertyChangeListener > const & listener)
1214*cdf0e10cSrcweir     throw (
1215*cdf0e10cSrcweir         css::beans::UnknownPropertyException, css::lang::WrappedTargetException,
1216*cdf0e10cSrcweir         css::uno::RuntimeException)
1217*cdf0e10cSrcweir {
1218*cdf0e10cSrcweir     css::uno::Reference< css::beans::XPropertyChangeListener >(
1219*cdf0e10cSrcweir         listener, css::uno::UNO_QUERY_THROW); // reject NULL listener
1220*cdf0e10cSrcweir     checkUnknown(propertyName);
1221*cdf0e10cSrcweir     try {
1222*cdf0e10cSrcweir         bool disposed;
1223*cdf0e10cSrcweir         {
1224*cdf0e10cSrcweir             osl::MutexGuard g(m_impl->mutex);
1225*cdf0e10cSrcweir             disposed = m_impl->disposed;
1226*cdf0e10cSrcweir             if (!disposed) {
1227*cdf0e10cSrcweir                 m_impl->boundListeners[propertyName].insert(listener);
1228*cdf0e10cSrcweir             }
1229*cdf0e10cSrcweir         }
1230*cdf0e10cSrcweir         if (disposed) {
1231*cdf0e10cSrcweir             listener->disposing(
1232*cdf0e10cSrcweir                 css::lang::EventObject(
1233*cdf0e10cSrcweir                     static_cast< css::beans::XPropertySet * >(this)));
1234*cdf0e10cSrcweir         }
1235*cdf0e10cSrcweir     } catch (std::bad_alloc &) {
1236*cdf0e10cSrcweir         //TODO  OutOfMemoryException:
1237*cdf0e10cSrcweir         throw css::uno::RuntimeException(
1238*cdf0e10cSrcweir             rtl::OUString(), static_cast< css::beans::XPropertySet * >(this));
1239*cdf0e10cSrcweir     }
1240*cdf0e10cSrcweir }
1241*cdf0e10cSrcweir 
1242*cdf0e10cSrcweir void PropertySetMixinImpl::removePropertyChangeListener(
1243*cdf0e10cSrcweir     rtl::OUString const & propertyName,
1244*cdf0e10cSrcweir     css::uno::Reference< css::beans::XPropertyChangeListener > const & listener)
1245*cdf0e10cSrcweir     throw (
1246*cdf0e10cSrcweir         css::beans::UnknownPropertyException, css::lang::WrappedTargetException,
1247*cdf0e10cSrcweir         css::uno::RuntimeException)
1248*cdf0e10cSrcweir {
1249*cdf0e10cSrcweir     OSL_ASSERT(listener.is());
1250*cdf0e10cSrcweir     checkUnknown(propertyName);
1251*cdf0e10cSrcweir     try {
1252*cdf0e10cSrcweir         osl::MutexGuard g(m_impl->mutex);
1253*cdf0e10cSrcweir         Impl::BoundListenerMap::iterator i(
1254*cdf0e10cSrcweir             m_impl->boundListeners.find(propertyName));
1255*cdf0e10cSrcweir         if (i != m_impl->boundListeners.end()) {
1256*cdf0e10cSrcweir             BoundListenerBag::iterator j(i->second.find(listener));
1257*cdf0e10cSrcweir             if (j != i->second.end()) {
1258*cdf0e10cSrcweir                 i->second.erase(j);
1259*cdf0e10cSrcweir             }
1260*cdf0e10cSrcweir         }
1261*cdf0e10cSrcweir     } catch (std::bad_alloc &) {
1262*cdf0e10cSrcweir         //TODO  OutOfMemoryException:
1263*cdf0e10cSrcweir         throw css::uno::RuntimeException(
1264*cdf0e10cSrcweir             rtl::OUString(), static_cast< css::beans::XPropertySet * >(this));
1265*cdf0e10cSrcweir     }
1266*cdf0e10cSrcweir }
1267*cdf0e10cSrcweir 
1268*cdf0e10cSrcweir void PropertySetMixinImpl::addVetoableChangeListener(
1269*cdf0e10cSrcweir     rtl::OUString const & propertyName,
1270*cdf0e10cSrcweir     css::uno::Reference< css::beans::XVetoableChangeListener > const & listener)
1271*cdf0e10cSrcweir     throw (
1272*cdf0e10cSrcweir         css::beans::UnknownPropertyException, css::lang::WrappedTargetException,
1273*cdf0e10cSrcweir         css::uno::RuntimeException)
1274*cdf0e10cSrcweir {
1275*cdf0e10cSrcweir     css::uno::Reference< css::beans::XVetoableChangeListener >(
1276*cdf0e10cSrcweir         listener, css::uno::UNO_QUERY_THROW); // reject NULL listener
1277*cdf0e10cSrcweir     checkUnknown(propertyName);
1278*cdf0e10cSrcweir     try {
1279*cdf0e10cSrcweir         bool disposed;
1280*cdf0e10cSrcweir         {
1281*cdf0e10cSrcweir             osl::MutexGuard g(m_impl->mutex);
1282*cdf0e10cSrcweir             disposed = m_impl->disposed;
1283*cdf0e10cSrcweir             if (!disposed) {
1284*cdf0e10cSrcweir                 m_impl->vetoListeners[propertyName].insert(listener);
1285*cdf0e10cSrcweir             }
1286*cdf0e10cSrcweir         }
1287*cdf0e10cSrcweir         if (disposed) {
1288*cdf0e10cSrcweir             listener->disposing(
1289*cdf0e10cSrcweir                 css::lang::EventObject(
1290*cdf0e10cSrcweir                     static_cast< css::beans::XPropertySet * >(this)));
1291*cdf0e10cSrcweir         }
1292*cdf0e10cSrcweir     } catch (std::bad_alloc &) {
1293*cdf0e10cSrcweir         //TODO  OutOfMemoryException:
1294*cdf0e10cSrcweir         throw css::uno::RuntimeException(
1295*cdf0e10cSrcweir             rtl::OUString(), static_cast< css::beans::XPropertySet * >(this));
1296*cdf0e10cSrcweir     }
1297*cdf0e10cSrcweir }
1298*cdf0e10cSrcweir 
1299*cdf0e10cSrcweir void PropertySetMixinImpl::removeVetoableChangeListener(
1300*cdf0e10cSrcweir     rtl::OUString const & propertyName,
1301*cdf0e10cSrcweir     css::uno::Reference< css::beans::XVetoableChangeListener > const & listener)
1302*cdf0e10cSrcweir     throw (
1303*cdf0e10cSrcweir         css::beans::UnknownPropertyException, css::lang::WrappedTargetException,
1304*cdf0e10cSrcweir         css::uno::RuntimeException)
1305*cdf0e10cSrcweir {
1306*cdf0e10cSrcweir     OSL_ASSERT(listener.is());
1307*cdf0e10cSrcweir     checkUnknown(propertyName);
1308*cdf0e10cSrcweir     try {
1309*cdf0e10cSrcweir         osl::MutexGuard g(m_impl->mutex);
1310*cdf0e10cSrcweir         Impl::VetoListenerMap::iterator i(
1311*cdf0e10cSrcweir             m_impl->vetoListeners.find(propertyName));
1312*cdf0e10cSrcweir         if (i != m_impl->vetoListeners.end()) {
1313*cdf0e10cSrcweir             Impl::VetoListenerBag::iterator j(i->second.find(listener));
1314*cdf0e10cSrcweir             if (j != i->second.end()) {
1315*cdf0e10cSrcweir                 i->second.erase(j);
1316*cdf0e10cSrcweir             }
1317*cdf0e10cSrcweir         }
1318*cdf0e10cSrcweir     } catch (std::bad_alloc &) {
1319*cdf0e10cSrcweir         //TODO  OutOfMemoryException:
1320*cdf0e10cSrcweir         throw css::uno::RuntimeException(
1321*cdf0e10cSrcweir             rtl::OUString(), static_cast< css::beans::XPropertySet * >(this));
1322*cdf0e10cSrcweir     }
1323*cdf0e10cSrcweir }
1324*cdf0e10cSrcweir 
1325*cdf0e10cSrcweir void PropertySetMixinImpl::setFastPropertyValue(
1326*cdf0e10cSrcweir     sal_Int32 handle, css::uno::Any const & value)
1327*cdf0e10cSrcweir     throw (
1328*cdf0e10cSrcweir         css::beans::UnknownPropertyException, css::beans::PropertyVetoException,
1329*cdf0e10cSrcweir         css::lang::IllegalArgumentException, css::lang::WrappedTargetException,
1330*cdf0e10cSrcweir         css::uno::RuntimeException)
1331*cdf0e10cSrcweir {
1332*cdf0e10cSrcweir     try {
1333*cdf0e10cSrcweir         m_impl->setProperty(
1334*cdf0e10cSrcweir             static_cast< css::beans::XPropertySet * >(this),
1335*cdf0e10cSrcweir             m_impl->translateHandle(
1336*cdf0e10cSrcweir                 static_cast< css::beans::XPropertySet * >(this), handle),
1337*cdf0e10cSrcweir             value, false, false, 1);
1338*cdf0e10cSrcweir     } catch (std::bad_alloc &) {
1339*cdf0e10cSrcweir         //TODO  OutOfMemoryException:
1340*cdf0e10cSrcweir         throw css::uno::RuntimeException(
1341*cdf0e10cSrcweir             rtl::OUString(), static_cast< css::beans::XPropertySet * >(this));
1342*cdf0e10cSrcweir     }
1343*cdf0e10cSrcweir }
1344*cdf0e10cSrcweir 
1345*cdf0e10cSrcweir css::uno::Any PropertySetMixinImpl::getFastPropertyValue(sal_Int32 handle)
1346*cdf0e10cSrcweir     throw (
1347*cdf0e10cSrcweir         css::beans::UnknownPropertyException, css::lang::WrappedTargetException,
1348*cdf0e10cSrcweir         css::uno::RuntimeException)
1349*cdf0e10cSrcweir {
1350*cdf0e10cSrcweir     try {
1351*cdf0e10cSrcweir         return m_impl->getProperty(
1352*cdf0e10cSrcweir             static_cast< css::beans::XPropertySet * >(this),
1353*cdf0e10cSrcweir             m_impl->translateHandle(
1354*cdf0e10cSrcweir                 static_cast< css::beans::XPropertySet * >(this), handle),
1355*cdf0e10cSrcweir             0);
1356*cdf0e10cSrcweir     } catch (std::bad_alloc &) {
1357*cdf0e10cSrcweir         //TODO  OutOfMemoryException:
1358*cdf0e10cSrcweir         throw css::uno::RuntimeException(
1359*cdf0e10cSrcweir             rtl::OUString(), static_cast< css::beans::XPropertySet * >(this));
1360*cdf0e10cSrcweir     }
1361*cdf0e10cSrcweir }
1362*cdf0e10cSrcweir 
1363*cdf0e10cSrcweir css::uno::Sequence< css::beans::PropertyValue >
1364*cdf0e10cSrcweir PropertySetMixinImpl::getPropertyValues() throw (css::uno::RuntimeException) {
1365*cdf0e10cSrcweir     try {
1366*cdf0e10cSrcweir         css::uno::Sequence< css::beans::PropertyValue > s(
1367*cdf0e10cSrcweir             m_impl->handleMap.getLength());
1368*cdf0e10cSrcweir         sal_Int32 n = 0;
1369*cdf0e10cSrcweir         for (sal_Int32 i = 0; i < m_impl->handleMap.getLength(); ++i) {
1370*cdf0e10cSrcweir             try {
1371*cdf0e10cSrcweir                 s[n].Value = m_impl->getProperty(
1372*cdf0e10cSrcweir                     static_cast< css::beans::XPropertySet * >(this),
1373*cdf0e10cSrcweir                     m_impl->handleMap[i], &s[n].State);
1374*cdf0e10cSrcweir             } catch (css::beans::UnknownPropertyException &) {
1375*cdf0e10cSrcweir                 continue;
1376*cdf0e10cSrcweir             } catch (css::lang::WrappedTargetException & e) {
1377*cdf0e10cSrcweir                 throw css::lang::WrappedTargetRuntimeException(
1378*cdf0e10cSrcweir                     e.Message, static_cast< css::beans::XPropertySet * >(this),
1379*cdf0e10cSrcweir                     e.TargetException);
1380*cdf0e10cSrcweir             }
1381*cdf0e10cSrcweir             s[n].Name = m_impl->handleMap[i];
1382*cdf0e10cSrcweir             s[n].Handle = i;
1383*cdf0e10cSrcweir             ++n;
1384*cdf0e10cSrcweir         }
1385*cdf0e10cSrcweir         s.realloc(n);
1386*cdf0e10cSrcweir         return s;
1387*cdf0e10cSrcweir     } catch (std::bad_alloc &) {
1388*cdf0e10cSrcweir         //TODO  OutOfMemoryException:
1389*cdf0e10cSrcweir         throw css::uno::RuntimeException(
1390*cdf0e10cSrcweir             rtl::OUString(), static_cast< css::beans::XPropertySet * >(this));
1391*cdf0e10cSrcweir     }
1392*cdf0e10cSrcweir }
1393*cdf0e10cSrcweir 
1394*cdf0e10cSrcweir void PropertySetMixinImpl::setPropertyValues(
1395*cdf0e10cSrcweir     css::uno::Sequence< css::beans::PropertyValue > const & props)
1396*cdf0e10cSrcweir     throw (
1397*cdf0e10cSrcweir         css::beans::UnknownPropertyException, css::beans::PropertyVetoException,
1398*cdf0e10cSrcweir         css::lang::IllegalArgumentException, css::lang::WrappedTargetException,
1399*cdf0e10cSrcweir         css::uno::RuntimeException)
1400*cdf0e10cSrcweir {
1401*cdf0e10cSrcweir     try {
1402*cdf0e10cSrcweir         for (sal_Int32 i = 0; i < props.getLength(); ++i) {
1403*cdf0e10cSrcweir             if (props[i].Handle != -1
1404*cdf0e10cSrcweir                 && (props[i].Name
1405*cdf0e10cSrcweir                     != m_impl->translateHandle(
1406*cdf0e10cSrcweir                         static_cast< css::beans::XPropertySet * >(this),
1407*cdf0e10cSrcweir                         props[i].Handle)))
1408*cdf0e10cSrcweir             {
1409*cdf0e10cSrcweir                 throw css::beans::UnknownPropertyException(
1410*cdf0e10cSrcweir                     (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("name "))
1411*cdf0e10cSrcweir                      + props[i].Name
1412*cdf0e10cSrcweir                      + rtl::OUString(
1413*cdf0e10cSrcweir                          RTL_CONSTASCII_USTRINGPARAM(" does not match handle "))
1414*cdf0e10cSrcweir                      + rtl::OUString::valueOf(props[i].Handle)),
1415*cdf0e10cSrcweir                     static_cast< css::beans::XPropertySet * >(this));
1416*cdf0e10cSrcweir             }
1417*cdf0e10cSrcweir             m_impl->setProperty(
1418*cdf0e10cSrcweir                 static_cast< css::beans::XPropertySet * >(this), props[i].Name,
1419*cdf0e10cSrcweir                 props[i].Value,
1420*cdf0e10cSrcweir                 props[i].State == css::beans::PropertyState_AMBIGUOUS_VALUE,
1421*cdf0e10cSrcweir                 props[i].State == css::beans::PropertyState_DEFAULT_VALUE, 0);
1422*cdf0e10cSrcweir         }
1423*cdf0e10cSrcweir     } catch (std::bad_alloc &) {
1424*cdf0e10cSrcweir         //TODO  OutOfMemoryException:
1425*cdf0e10cSrcweir         throw css::uno::RuntimeException(
1426*cdf0e10cSrcweir             rtl::OUString(), static_cast< css::beans::XPropertySet * >(this));
1427*cdf0e10cSrcweir     }
1428*cdf0e10cSrcweir }
1429