LCOV - code coverage report
Current view: top level - sd/source/ui/tools - PropertySet.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 49 0.0 %
Date: 2014-04-11 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             : 
      21             : #include "tools/PropertySet.hxx"
      22             : #include <algorithm>
      23             : #include <o3tl/compat_functional.hxx>
      24             : 
      25             : using namespace ::com::sun::star;
      26             : using namespace ::com::sun::star::uno;
      27             : 
      28             : namespace sd { namespace tools {
      29             : 
      30           0 : PropertySet::PropertySet (void)
      31             :     : PropertySetInterfaceBase(m_aMutex),
      32           0 :       mpChangeListeners(new ChangeListenerContainer())
      33             : {
      34           0 : }
      35             : 
      36             : 
      37             : 
      38             : 
      39           0 : PropertySet::~PropertySet (void)
      40             : {
      41           0 : }
      42             : 
      43             : 
      44             : 
      45             : 
      46           0 : void SAL_CALL PropertySet::disposing (void)
      47             : {
      48           0 : }
      49             : 
      50             : //----- XPropertySet ----------------------------------------------------------
      51             : 
      52           0 : Reference<beans::XPropertySetInfo> SAL_CALL PropertySet::getPropertySetInfo (void)
      53             :     throw(RuntimeException, std::exception)
      54             : {
      55           0 :     return NULL;
      56             : }
      57             : 
      58             : 
      59             : 
      60             : 
      61           0 : void SAL_CALL PropertySet::setPropertyValue (
      62             :     const OUString& rsPropertyName,
      63             :     const css::uno::Any& rsPropertyValue)
      64             :     throw(css::beans::UnknownPropertyException,
      65             :         css::beans::PropertyVetoException,
      66             :         css::lang::IllegalArgumentException,
      67             :         css::lang::WrappedTargetException,
      68             :         css::uno::RuntimeException, std::exception)
      69             : {
      70           0 :     ThrowIfDisposed();
      71             : 
      72           0 :     Any aOldValue (SetPropertyValue(rsPropertyName,rsPropertyValue));
      73           0 :     if (aOldValue != rsPropertyValue)
      74             :     {
      75             :         // Inform listeners that are registered specifically for the
      76             :         // property and those registered for any property.
      77             :         beans::PropertyChangeEvent aEvent(
      78             :             static_cast<XWeak*>(this),
      79             :             rsPropertyName,
      80             :             sal_False,
      81             :             -1,
      82             :             aOldValue,
      83           0 :             rsPropertyValue);
      84           0 :         CallListeners(rsPropertyName, aEvent);
      85           0 :         CallListeners(OUString(), aEvent);
      86           0 :     }
      87           0 : }
      88             : 
      89             : 
      90             : 
      91             : 
      92           0 : Any SAL_CALL PropertySet::getPropertyValue (const OUString& rsPropertyName)
      93             :         throw(css::beans::UnknownPropertyException,
      94             :             css::lang::WrappedTargetException,
      95             :             css::uno::RuntimeException, std::exception)
      96             : {
      97           0 :     ThrowIfDisposed();
      98             : 
      99           0 :     return GetPropertyValue(rsPropertyName);
     100             : }
     101             : 
     102             : 
     103             : 
     104             : 
     105           0 : void SAL_CALL PropertySet::addPropertyChangeListener (
     106             :     const OUString& rsPropertyName,
     107             :     const css::uno::Reference<css::beans::XPropertyChangeListener>& rxListener)
     108             :     throw(css::beans::UnknownPropertyException,
     109             :         css::lang::WrappedTargetException,
     110             :         css::uno::RuntimeException, std::exception)
     111             : {
     112           0 :     if ( ! rxListener.is())
     113           0 :         throw lang::IllegalArgumentException();
     114             : 
     115           0 :     if (rBHelper.bDisposed || rBHelper.bInDispose)
     116           0 :         return;
     117             : 
     118             :     mpChangeListeners->insert(
     119             :         ChangeListenerContainer::value_type(
     120             :             rsPropertyName,
     121           0 :             rxListener));
     122             : }
     123             : 
     124             : 
     125             : 
     126             : 
     127           0 : void SAL_CALL PropertySet::removePropertyChangeListener (
     128             :     const OUString& rsPropertyName,
     129             :     const css::uno::Reference<css::beans::XPropertyChangeListener>& rxListener)
     130             :     throw(beans::UnknownPropertyException,
     131             :         css::lang::WrappedTargetException,
     132             :         css::uno::RuntimeException, std::exception)
     133             : {
     134             :     ::std::pair<ChangeListenerContainer::iterator,ChangeListenerContainer::iterator>
     135           0 :         aRange (mpChangeListeners->equal_range(rsPropertyName));
     136             : 
     137             :     ChangeListenerContainer::iterator iListener (
     138             :         ::std::find_if(
     139             :             aRange.first,
     140             :             aRange.second,
     141             :             o3tl::compose1(
     142             :                 std::bind1st(std::equal_to<Reference<beans::XPropertyChangeListener> >(),
     143             :                     rxListener),
     144           0 :                 o3tl::select2nd<ChangeListenerContainer::value_type>())));
     145           0 :     if (iListener != mpChangeListeners->end())
     146             :     {
     147           0 :         mpChangeListeners->erase(iListener);
     148             :     }
     149             :     else
     150             :     {
     151           0 :         throw lang::IllegalArgumentException();
     152             :     }
     153           0 : }
     154             : 
     155             : 
     156             : 
     157             : 
     158           0 : void SAL_CALL PropertySet::addVetoableChangeListener (
     159             :     const OUString& rsPropertyName,
     160             :     const css::uno::Reference<css::beans::XVetoableChangeListener>& rxListener)
     161             :     throw(css::beans::UnknownPropertyException,
     162             :         css::lang::WrappedTargetException,
     163             :         css::uno::RuntimeException, std::exception)
     164             : {
     165             :     // Constraint properties are not supported and thus no vetoable
     166             :     // listeners.
     167             :     (void)rsPropertyName;
     168             :     (void)rxListener;
     169           0 : }
     170             : 
     171             : 
     172             : 
     173             : 
     174           0 : void SAL_CALL PropertySet::removeVetoableChangeListener (
     175             :     const OUString& rsPropertyName,
     176             :     const css::uno::Reference<css::beans::XVetoableChangeListener>& rxListener)
     177             :     throw(css::beans::UnknownPropertyException,
     178             :         css::lang::WrappedTargetException,
     179             :         css::uno::RuntimeException, std::exception)
     180             : {
     181             :     // Constraint properties are not supported and thus no vetoable
     182             :     // listeners.
     183             :     (void)rsPropertyName;
     184             :     (void)rxListener;
     185           0 : }
     186             : 
     187             : 
     188             : 
     189             : 
     190             : 
     191             : 
     192           0 : void PropertySet::CallListeners (
     193             :     const OUString& rsPropertyName,
     194             :     const beans::PropertyChangeEvent& rEvent)
     195             : {
     196             :     ::std::pair<ChangeListenerContainer::iterator,ChangeListenerContainer::iterator>
     197           0 :         aRange (mpChangeListeners->equal_range(rsPropertyName));
     198           0 :     ChangeListenerContainer::const_iterator iListener;
     199           0 :     for (iListener=aRange.first; iListener!=aRange.second; ++iListener)
     200             :     {
     201           0 :         if (iListener->second.is())
     202           0 :             iListener->second->propertyChange(rEvent);
     203             :     }
     204           0 : }
     205             : 
     206             : 
     207             : 
     208             : 
     209           0 : void PropertySet::ThrowIfDisposed (void)
     210             :     throw (::com::sun::star::lang::DisposedException)
     211             : {
     212           0 :     if (rBHelper.bDisposed || rBHelper.bInDispose)
     213             :     {
     214             :         throw lang::DisposedException (
     215             :                 "PropertySet object has already been disposed",
     216           0 :             static_cast<uno::XWeak*>(this));
     217             :     }
     218           0 : }
     219             : 
     220             : } } // end of namespace ::sd::tools
     221             : 
     222             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10