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