LCOV - code coverage report
Current view: top level - sd/source/ui/tools - PropertySet.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 49 0.0 %
Date: 2014-11-03 Functions: 0 13 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "tools/PropertySet.hxx"
      21             : #include <algorithm>
      22             : #include <o3tl/compat_functional.hxx>
      23             : 
      24             : using namespace ::com::sun::star;
      25             : using namespace ::com::sun::star::uno;
      26             : 
      27             : namespace sd { namespace tools {
      28             : 
      29           0 : PropertySet::PropertySet (void)
      30             :     : PropertySetInterfaceBase(m_aMutex),
      31           0 :       mpChangeListeners(new ChangeListenerContainer())
      32             : {
      33           0 : }
      34             : 
      35           0 : PropertySet::~PropertySet (void)
      36             : {
      37           0 : }
      38             : 
      39           0 : void SAL_CALL PropertySet::disposing (void)
      40             : {
      41           0 : }
      42             : 
      43             : //----- XPropertySet ----------------------------------------------------------
      44             : 
      45           0 : Reference<beans::XPropertySetInfo> SAL_CALL PropertySet::getPropertySetInfo (void)
      46             :     throw(RuntimeException, std::exception)
      47             : {
      48           0 :     return NULL;
      49             : }
      50             : 
      51           0 : void SAL_CALL PropertySet::setPropertyValue (
      52             :     const OUString& rsPropertyName,
      53             :     const css::uno::Any& rsPropertyValue)
      54             :     throw(css::beans::UnknownPropertyException,
      55             :         css::beans::PropertyVetoException,
      56             :         css::lang::IllegalArgumentException,
      57             :         css::lang::WrappedTargetException,
      58             :         css::uno::RuntimeException, std::exception)
      59             : {
      60           0 :     ThrowIfDisposed();
      61             : 
      62           0 :     Any aOldValue (SetPropertyValue(rsPropertyName,rsPropertyValue));
      63           0 :     if (aOldValue != rsPropertyValue)
      64             :     {
      65             :         // Inform listeners that are registered specifically for the
      66             :         // property and those registered for any property.
      67             :         beans::PropertyChangeEvent aEvent(
      68             :             static_cast<XWeak*>(this),
      69             :             rsPropertyName,
      70             :             sal_False,
      71             :             -1,
      72             :             aOldValue,
      73           0 :             rsPropertyValue);
      74           0 :         CallListeners(rsPropertyName, aEvent);
      75           0 :         CallListeners(OUString(), aEvent);
      76           0 :     }
      77           0 : }
      78             : 
      79           0 : Any SAL_CALL PropertySet::getPropertyValue (const OUString& rsPropertyName)
      80             :         throw(css::beans::UnknownPropertyException,
      81             :             css::lang::WrappedTargetException,
      82             :             css::uno::RuntimeException, std::exception)
      83             : {
      84           0 :     ThrowIfDisposed();
      85             : 
      86           0 :     return GetPropertyValue(rsPropertyName);
      87             : }
      88             : 
      89           0 : void SAL_CALL PropertySet::addPropertyChangeListener (
      90             :     const OUString& rsPropertyName,
      91             :     const css::uno::Reference<css::beans::XPropertyChangeListener>& rxListener)
      92             :     throw(css::beans::UnknownPropertyException,
      93             :         css::lang::WrappedTargetException,
      94             :         css::uno::RuntimeException, std::exception)
      95             : {
      96           0 :     if ( ! rxListener.is())
      97           0 :         throw lang::IllegalArgumentException();
      98             : 
      99           0 :     if (rBHelper.bDisposed || rBHelper.bInDispose)
     100           0 :         return;
     101             : 
     102             :     mpChangeListeners->insert(
     103             :         ChangeListenerContainer::value_type(
     104             :             rsPropertyName,
     105           0 :             rxListener));
     106             : }
     107             : 
     108           0 : void SAL_CALL PropertySet::removePropertyChangeListener (
     109             :     const OUString& rsPropertyName,
     110             :     const css::uno::Reference<css::beans::XPropertyChangeListener>& rxListener)
     111             :     throw(beans::UnknownPropertyException,
     112             :         css::lang::WrappedTargetException,
     113             :         css::uno::RuntimeException, std::exception)
     114             : {
     115             :     ::std::pair<ChangeListenerContainer::iterator,ChangeListenerContainer::iterator>
     116           0 :         aRange (mpChangeListeners->equal_range(rsPropertyName));
     117             : 
     118             :     ChangeListenerContainer::iterator iListener (
     119             :         ::std::find_if(
     120             :             aRange.first,
     121             :             aRange.second,
     122             :             o3tl::compose1(
     123             :                 std::bind1st(std::equal_to<Reference<beans::XPropertyChangeListener> >(),
     124             :                     rxListener),
     125           0 :                 o3tl::select2nd<ChangeListenerContainer::value_type>())));
     126           0 :     if (iListener != mpChangeListeners->end())
     127             :     {
     128           0 :         mpChangeListeners->erase(iListener);
     129             :     }
     130             :     else
     131             :     {
     132           0 :         throw lang::IllegalArgumentException();
     133             :     }
     134           0 : }
     135             : 
     136           0 : void SAL_CALL PropertySet::addVetoableChangeListener (
     137             :     const OUString& rsPropertyName,
     138             :     const css::uno::Reference<css::beans::XVetoableChangeListener>& rxListener)
     139             :     throw(css::beans::UnknownPropertyException,
     140             :         css::lang::WrappedTargetException,
     141             :         css::uno::RuntimeException, std::exception)
     142             : {
     143             :     // Constraint properties are not supported and thus no vetoable
     144             :     // listeners.
     145             :     (void)rsPropertyName;
     146             :     (void)rxListener;
     147           0 : }
     148             : 
     149           0 : void SAL_CALL PropertySet::removeVetoableChangeListener (
     150             :     const OUString& rsPropertyName,
     151             :     const css::uno::Reference<css::beans::XVetoableChangeListener>& rxListener)
     152             :     throw(css::beans::UnknownPropertyException,
     153             :         css::lang::WrappedTargetException,
     154             :         css::uno::RuntimeException, std::exception)
     155             : {
     156             :     // Constraint properties are not supported and thus no vetoable
     157             :     // listeners.
     158             :     (void)rsPropertyName;
     159             :     (void)rxListener;
     160           0 : }
     161             : 
     162           0 : void PropertySet::CallListeners (
     163             :     const OUString& rsPropertyName,
     164             :     const beans::PropertyChangeEvent& rEvent)
     165             : {
     166             :     ::std::pair<ChangeListenerContainer::iterator,ChangeListenerContainer::iterator>
     167           0 :         aRange (mpChangeListeners->equal_range(rsPropertyName));
     168           0 :     ChangeListenerContainer::const_iterator iListener;
     169           0 :     for (iListener=aRange.first; iListener!=aRange.second; ++iListener)
     170             :     {
     171           0 :         if (iListener->second.is())
     172           0 :             iListener->second->propertyChange(rEvent);
     173             :     }
     174           0 : }
     175             : 
     176           0 : void PropertySet::ThrowIfDisposed (void)
     177             :     throw (::com::sun::star::lang::DisposedException)
     178             : {
     179           0 :     if (rBHelper.bDisposed || rBHelper.bInDispose)
     180             :     {
     181             :         throw lang::DisposedException (
     182             :                 "PropertySet object has already been disposed",
     183           0 :             static_cast<uno::XWeak*>(this));
     184             :     }
     185           0 : }
     186             : 
     187             : } } // end of namespace ::sd::tools
     188             : 
     189             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10