LCOV - code coverage report
Current view: top level - cppuhelper/source - propertysetmixin.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 154 530 29.1 %
Date: 2012-08-25 Functions: 23 49 46.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 183 1256 14.6 %

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

Generated by: LCOV version 1.10