LCOV - code coverage report
Current view: top level - libreoffice/dbaccess/source/core/misc - PropertyForward.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 53 0.0 %
Date: 2012-12-27 Functions: 0 6 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 "PropertyForward.hxx"
      22             : #include "dbastrings.hrc"
      23             : 
      24             : #include <com/sun/star/beans/PropertyValue.hpp>
      25             : #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
      26             : #include <com/sun/star/sdbcx/XAppend.hpp>
      27             : 
      28             : #include <comphelper/property.hxx>
      29             : #include <tools/debug.hxx>
      30             : #include <tools/diagnose_ex.h>
      31             : 
      32             : 
      33             : //........................................................................
      34             : namespace dbaccess
      35             : {
      36             : //........................................................................
      37             : 
      38             :     using namespace ::com::sun::star::uno;
      39             :     using namespace ::com::sun::star::beans;
      40             :     using namespace ::com::sun::star::container;
      41             :     using namespace ::com::sun::star::sdbcx;
      42             :     using namespace ::com::sun::star::lang;
      43             : 
      44             :     DBG_NAME(OPropertyForward)
      45             : 
      46             :     //------------------------------------------------------------------------
      47           0 :     OPropertyForward::OPropertyForward( const Reference< XPropertySet>& _xSource, const Reference< XNameAccess>& _xDestContainer,
      48             :             const ::rtl::OUString& _sName, const ::std::vector< ::rtl::OUString>& _aPropertyList )
      49             :         :m_xSource( _xSource, UNO_SET_THROW )
      50             :         ,m_xDestContainer( _xDestContainer, UNO_SET_THROW )
      51             :         ,m_sName( _sName )
      52           0 :         ,m_bInInsert( sal_False )
      53             :     {
      54             :         DBG_CTOR(OPropertyForward,NULL);
      55             : 
      56           0 :         osl_atomic_increment(&m_refCount);
      57             :         try
      58             :         {
      59           0 :             if ( _aPropertyList.empty() )
      60           0 :                 _xSource->addPropertyChangeListener( ::rtl::OUString(), this );
      61             :             else
      62             :             {
      63           0 :                 ::std::vector< ::rtl::OUString >::const_iterator aIter = _aPropertyList.begin();
      64           0 :                 ::std::vector< ::rtl::OUString >::const_iterator aEnd = _aPropertyList.end();
      65           0 :                 for (; aIter != aEnd ; ++aIter )
      66           0 :                     _xSource->addPropertyChangeListener( *aIter, this );
      67             :             }
      68             :         }
      69           0 :         catch( const Exception& )
      70             :         {
      71             :             DBG_UNHANDLED_EXCEPTION();
      72             :         }
      73           0 :         osl_atomic_decrement( &m_refCount );
      74           0 :     }
      75             : 
      76             :     // -----------------------------------------------------------------------------
      77           0 :     OPropertyForward::~OPropertyForward()
      78             :     {
      79             :         DBG_DTOR(OPropertyForward,NULL);
      80           0 :     }
      81             : 
      82             :     // -----------------------------------------------------------------------------
      83           0 :     void SAL_CALL OPropertyForward::propertyChange( const PropertyChangeEvent& evt ) throw(RuntimeException)
      84             :     {
      85           0 :         ::osl::MutexGuard aGuard( m_aMutex );
      86             : 
      87           0 :         if ( !m_xDestContainer.is() )
      88           0 :             throw DisposedException( ::rtl::OUString(), *this );
      89             : 
      90             :         try
      91             :         {
      92           0 :             if ( !m_xDest.is() )
      93             :             {
      94           0 :                 if ( m_xDestContainer->hasByName( m_sName ) )
      95             :                 {
      96           0 :                     m_xDest.set( m_xDestContainer->getByName( m_sName ), UNO_QUERY_THROW );
      97             :                 }
      98             :                 else
      99             :                 {
     100           0 :                     Reference< XDataDescriptorFactory > xFactory( m_xDestContainer, UNO_QUERY_THROW );
     101           0 :                     m_xDest.set( xFactory->createDataDescriptor(), UNO_SET_THROW );
     102             : 
     103           0 :                     ::comphelper::copyProperties( m_xSource, m_xDest );
     104             : 
     105           0 :                     m_bInInsert = sal_True;
     106           0 :                     Reference< XAppend > xAppend( m_xDestContainer, UNO_QUERY_THROW );
     107           0 :                     xAppend->appendByDescriptor( m_xDest );
     108           0 :                     m_bInInsert = sal_False;
     109             :                 }
     110             : 
     111           0 :                 m_xDestInfo.set( m_xDest->getPropertySetInfo(), UNO_SET_THROW );
     112             :             }
     113             : 
     114           0 :             if ( m_xDestInfo->hasPropertyByName( evt.PropertyName ) )
     115             :             {
     116           0 :                 m_xDest->setPropertyValue( evt.PropertyName, evt.NewValue );
     117             :             }
     118             :         }
     119           0 :         catch( const Exception& )
     120             :         {
     121             :             DBG_UNHANDLED_EXCEPTION();
     122           0 :         }
     123           0 :     }
     124             : 
     125             :     // -----------------------------------------------------------------------------
     126           0 :     void SAL_CALL OPropertyForward::disposing( const ::com::sun::star::lang::EventObject& /*_rSource*/ ) throw (RuntimeException)
     127             :     {
     128           0 :         ::osl::MutexGuard aGuard(m_aMutex);
     129             : 
     130           0 :         if ( !m_xSource.is() )
     131           0 :             throw DisposedException( ::rtl::OUString(), *this );
     132             : 
     133           0 :         m_xSource->removePropertyChangeListener( ::rtl::OUString(), this );
     134           0 :         m_xSource = NULL;
     135           0 :         m_xDestContainer = NULL;
     136           0 :         m_xDestInfo = NULL;
     137           0 :         m_xDest = NULL;
     138           0 :     }
     139             : 
     140             :     // -----------------------------------------------------------------------------
     141           0 :     void OPropertyForward::setDefinition( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xDest )
     142             :     {
     143           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     144           0 :         if ( m_bInInsert )
     145           0 :             return;
     146             : 
     147             :         OSL_ENSURE( !m_xDest.is(), "OPropertyForward::setDefinition: definition object is already set!" );
     148             :         try
     149             :         {
     150           0 :             m_xDest.set( _xDest, UNO_SET_THROW );
     151           0 :             m_xDestInfo.set( m_xDest->getPropertySetInfo(), UNO_SET_THROW );
     152           0 :             ::comphelper::copyProperties( m_xDest, m_xSource );
     153             :         }
     154           0 :         catch( const Exception& )
     155             :         {
     156             :             DBG_UNHANDLED_EXCEPTION();
     157           0 :         }
     158             :     }
     159             : 
     160             : //........................................................................
     161             : }   // namespace dbaccess
     162             : //........................................................................
     163             : 
     164             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10