LCOV - code coverage report
Current view: top level - reportdesign/source/core/sdr - PropertyForward.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 92 0.0 %
Date: 2012-08-25 Functions: 0 8 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 276 0.0 %

           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                 :            : #include "PropertyForward.hxx"
      29                 :            : #include <com/sun/star/beans/PropertyValue.hpp>
      30                 :            : #include <com/sun/star/beans/PropertyAttribute.hpp>
      31                 :            : #include <comphelper/property.hxx>
      32                 :            : #include <com/sun/star/sdbcx/XAppend.hpp>
      33                 :            : #include <tools/debug.hxx>
      34                 :            : #include <tools/diagnose_ex.h>
      35                 :            : #include "corestrings.hrc"
      36                 :            : #include <o3tl/compat_functional.hxx>
      37                 :            : 
      38                 :            : //........................................................................
      39                 :            : namespace rptui
      40                 :            : {
      41                 :            : //........................................................................
      42                 :            :     using namespace ::com::sun::star::uno;
      43                 :            :     using namespace ::com::sun::star::beans;
      44                 :            :     using namespace reportdesign;
      45                 :            : 
      46                 :            : DBG_NAME( rpt_OPropertyMediator )
      47                 :          0 : OPropertyMediator::OPropertyMediator(const Reference< XPropertySet>& _xSource
      48                 :            :                                      ,const Reference< XPropertySet>& _xDest
      49                 :            :                                      ,const TPropertyNamePair& _aNameMap
      50                 :            :                                      ,sal_Bool _bReverse)
      51                 :            :                                 : OPropertyForward_Base(m_aMutex)
      52                 :            :                                 ,m_aNameMap(_aNameMap)
      53                 :            :                                 ,m_xSource(_xSource)
      54                 :            :                                 ,m_xDest(_xDest)
      55         [ #  # ]:          0 :                                 ,m_bInChange(sal_False)
      56                 :            : {
      57                 :            :     DBG_CTOR( rpt_OPropertyMediator,NULL);
      58         [ #  # ]:          0 :     osl_incrementInterlockedCount(&m_refCount);
      59                 :            :     OSL_ENSURE(m_xDest.is(),"Dest is NULL!");
      60                 :            :     OSL_ENSURE(m_xSource.is(),"Source is NULL!");
      61 [ #  # ][ #  # ]:          0 :     if ( m_xDest.is() && m_xSource.is() )
                 [ #  # ]
      62                 :            :     {
      63                 :            :         try
      64                 :            :         {
      65 [ #  # ][ #  # ]:          0 :             m_xDestInfo = m_xDest->getPropertySetInfo();
                 [ #  # ]
      66 [ #  # ][ #  # ]:          0 :             m_xSourceInfo = m_xSource->getPropertySetInfo();
                 [ #  # ]
      67         [ #  # ]:          0 :             if ( _bReverse )
      68                 :            :             {
      69         [ #  # ]:          0 :                 ::comphelper::copyProperties(m_xDest,m_xSource);
      70                 :          0 :                 TPropertyNamePair::iterator aIter = m_aNameMap.begin();
      71                 :          0 :                 TPropertyNamePair::iterator aEnd = m_aNameMap.end();
      72         [ #  # ]:          0 :                 for (; aIter != aEnd; ++aIter)
      73                 :            :                 {
      74 [ #  # ][ #  # ]:          0 :                     Property aProp = m_xSourceInfo->getPropertyByName(aIter->first);
      75         [ #  # ]:          0 :                     if (0 == (aProp.Attributes & PropertyAttribute::READONLY))
      76                 :            :                     {
      77 [ #  # ][ #  # ]:          0 :                         Any aValue = _xDest->getPropertyValue(aIter->second.first);
      78 [ #  # ][ #  # ]:          0 :                         if ( 0 != (aProp.Attributes & PropertyAttribute::MAYBEVOID) || aValue.hasValue() )
                 [ #  # ]
      79 [ #  # ][ #  # ]:          0 :                             _xSource->setPropertyValue(aIter->first,aIter->second.second->operator()(aIter->second.first,aValue));
                 [ #  # ]
      80                 :            :                     }
      81                 :          0 :                 }
      82                 :            :             }
      83                 :            :             else
      84                 :            :             {
      85         [ #  # ]:          0 :                 ::comphelper::copyProperties(m_xSource,m_xDest);
      86                 :          0 :                 TPropertyNamePair::iterator aIter = m_aNameMap.begin();
      87                 :          0 :                 TPropertyNamePair::iterator aEnd = m_aNameMap.end();
      88         [ #  # ]:          0 :                 for (; aIter != aEnd; ++aIter)
      89 [ #  # ][ #  # ]:          0 :                     _xDest->setPropertyValue(aIter->second.first,aIter->second.second->operator()(aIter->second.first,_xSource->getPropertyValue(aIter->first)));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      90                 :            :             }
      91         [ #  # ]:          0 :             startListening();
      92                 :            :         }
      93         [ #  # ]:          0 :         catch(Exception& e)
      94                 :            :         {
      95                 :            :             DBG_UNHANDLED_EXCEPTION();
      96                 :            :             (void)e;
      97                 :            :         }
      98                 :            :     }
      99         [ #  # ]:          0 :     osl_decrementInterlockedCount(&m_refCount);
     100                 :          0 : }
     101                 :            : // -----------------------------------------------------------------------------
     102         [ #  # ]:          0 : OPropertyMediator::~OPropertyMediator()
     103                 :            : {
     104                 :            :     DBG_DTOR( rpt_OPropertyMediator,NULL);
     105         [ #  # ]:          0 : }
     106                 :            : // -----------------------------------------------------------------------------
     107                 :          0 : void SAL_CALL OPropertyMediator::propertyChange( const PropertyChangeEvent& evt ) throw(RuntimeException)
     108                 :            : {
     109         [ #  # ]:          0 :     ::osl::MutexGuard aGuard(m_aMutex);
     110         [ #  # ]:          0 :     if ( !m_bInChange )
     111                 :            :     {
     112                 :          0 :         m_bInChange = sal_True;
     113                 :            :         try
     114                 :            :         {
     115         [ #  # ]:          0 :             sal_Bool bDest = (evt.Source == m_xDest);
     116         [ #  # ]:          0 :             Reference<XPropertySet> xProp =  bDest ? m_xSource : m_xDest;
     117         [ #  # ]:          0 :             Reference<XPropertySetInfo> xPropInfo = bDest ? m_xSourceInfo : m_xDestInfo;
     118         [ #  # ]:          0 :             if ( xProp.is() )
     119                 :            :             {
     120         [ #  # ]:          0 :                 if ( xPropInfo.is() )
     121                 :            :                 {
     122 [ #  # ][ #  # ]:          0 :                     if ( xPropInfo->hasPropertyByName(evt.PropertyName) )
                 [ #  # ]
     123 [ #  # ][ #  # ]:          0 :                         xProp->setPropertyValue(evt.PropertyName,evt.NewValue);
     124                 :            :                     else
     125                 :            :                     {
     126         [ #  # ]:          0 :                         TPropertyNamePair::iterator aFind = m_aNameMap.find(evt.PropertyName);
     127                 :          0 :                         ::rtl::OUString sPropName;
     128         [ #  # ]:          0 :                         if ( aFind != m_aNameMap.end() )
     129                 :          0 :                             sPropName = aFind->second.first;
     130                 :            :                         else
     131                 :            :                         {
     132                 :            :                             aFind = ::std::find_if(
     133                 :            :                                 m_aNameMap.begin(),
     134                 :            :                                 m_aNameMap.end(),
     135                 :            :                                 ::o3tl::compose1(
     136                 :            :                                 ::std::bind2nd(::std::equal_to< ::rtl::OUString >(), evt.PropertyName),
     137         [ #  # ]:          0 :                                     ::o3tl::compose1(::o3tl::select1st<TPropertyConverter>(),::o3tl::select2nd<TPropertyNamePair::value_type>())
     138                 :            :                                 )
     139 [ #  # ][ #  # ]:          0 :                             );
                 [ #  # ]
     140         [ #  # ]:          0 :                             if ( aFind != m_aNameMap.end() )
     141                 :          0 :                                 sPropName = aFind->first;
     142                 :            :                         }
     143 [ #  # ][ #  # ]:          0 :                         if ( !sPropName.isEmpty() && xPropInfo->hasPropertyByName(sPropName) )
         [ #  # ][ #  # ]
                 [ #  # ]
     144 [ #  # ][ #  # ]:          0 :                             xProp->setPropertyValue(sPropName,aFind->second.second->operator()(sPropName,evt.NewValue));
                 [ #  # ]
     145 [ #  # ][ #  #  :          0 :                         else if (   evt.PropertyName == PROPERTY_CHARFONTNAME
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
             #  #  #  # ]
                 [ #  # ]
           [ #  #  #  # ]
     146 [ #  # ][ #  # ]:          0 :                                 ||  evt.PropertyName == PROPERTY_CHARFONTSTYLENAME
                 [ #  # ]
     147 [ #  # ][ #  # ]:          0 :                                 ||  evt.PropertyName == PROPERTY_CHARSTRIKEOUT
                 [ #  # ]
     148 [ #  # ][ #  # ]:          0 :                                 ||  evt.PropertyName == PROPERTY_CHARWORDMODE
                 [ #  # ]
     149 [ #  # ][ #  # ]:          0 :                                 ||  evt.PropertyName == PROPERTY_CHARROTATION
                 [ #  # ]
     150 [ #  # ][ #  # ]:          0 :                                 ||  evt.PropertyName == PROPERTY_CHARSCALEWIDTH
                 [ #  # ]
     151 [ #  # ][ #  # ]:          0 :                                 ||  evt.PropertyName == PROPERTY_CHARFONTFAMILY
                 [ #  # ]
     152 [ #  # ][ #  # ]:          0 :                                 ||  evt.PropertyName == PROPERTY_CHARFONTCHARSET
                 [ #  # ]
     153 [ #  # ][ #  # ]:          0 :                                 ||  evt.PropertyName == PROPERTY_CHARFONTPITCH
                 [ #  # ]
     154 [ #  # ][ #  # ]:          0 :                                 ||  evt.PropertyName == PROPERTY_CHARHEIGHT
                 [ #  # ]
     155 [ #  # ][ #  # ]:          0 :                                 ||  evt.PropertyName == PROPERTY_CHARUNDERLINE
                 [ #  # ]
     156 [ #  # ][ #  # ]:          0 :                                 ||  evt.PropertyName == PROPERTY_CHARWEIGHT
                 [ #  # ]
     157 [ #  # ][ #  # ]:          0 :                                 ||  evt.PropertyName == PROPERTY_CHARPOSTURE)
                 [ #  # ]
     158                 :            :                         {
     159 [ #  # ][ #  # ]:          0 :                             xProp->setPropertyValue(PROPERTY_FONTDESCRIPTOR,m_xSource->getPropertyValue(PROPERTY_FONTDESCRIPTOR));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     160                 :          0 :                         }
     161                 :            :                     }
     162                 :            :                 }
     163         [ #  # ]:          0 :             }
     164                 :            :         }
     165         [ #  # ]:          0 :         catch(Exception&)
     166                 :            :         {
     167                 :            :             OSL_FAIL("Exception catched!");
     168                 :            :         }
     169                 :          0 :         m_bInChange = sal_False;
     170         [ #  # ]:          0 :     }
     171                 :          0 : }
     172                 :            : // -----------------------------------------------------------------------------
     173                 :          0 : void SAL_CALL OPropertyMediator::disposing( const ::com::sun::star::lang::EventObject& /*_rSource*/ ) throw (RuntimeException)
     174                 :            : {
     175         [ #  # ]:          0 :     ::osl::MutexGuard aGuard(m_aMutex);
     176 [ #  # ][ #  # ]:          0 :     disposing();
     177                 :          0 : }
     178                 :            : // -----------------------------------------------------------------------------
     179                 :          0 : void SAL_CALL OPropertyMediator::disposing()
     180                 :            : {
     181                 :          0 :     stopListening();
     182                 :          0 :     m_xSource.clear();
     183                 :          0 :     m_xSourceInfo.clear();
     184                 :          0 :     m_xDest.clear();
     185                 :          0 :     m_xDestInfo.clear();
     186                 :          0 : }
     187                 :            : // -----------------------------------------------------------------------------
     188                 :          0 : void OPropertyMediator::stopListening()
     189                 :            : {
     190         [ #  # ]:          0 :     if ( m_xSource.is() )
     191         [ #  # ]:          0 :         m_xSource->removePropertyChangeListener(::rtl::OUString(), this);
     192         [ #  # ]:          0 :     if ( m_xDest.is() )
     193         [ #  # ]:          0 :         m_xDest->removePropertyChangeListener(::rtl::OUString(), this);
     194                 :          0 : }
     195                 :            : // -----------------------------------------------------------------------------
     196                 :          0 : void OPropertyMediator::startListening()
     197                 :            : {
     198         [ #  # ]:          0 :     if ( m_xSource.is() )
     199         [ #  # ]:          0 :         m_xSource->addPropertyChangeListener(::rtl::OUString(), this);
     200         [ #  # ]:          0 :     if ( m_xDest.is() )
     201         [ #  # ]:          0 :         m_xDest->addPropertyChangeListener(::rtl::OUString(), this);
     202                 :          0 : }
     203                 :            : // -----------------------------------------------------------------------------
     204                 :            : //........................................................................
     205                 :            : }   // namespace dbaccess
     206                 :            : //........................................................................
     207                 :            : 
     208                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10