LCOV - code coverage report
Current view: top level - dbaccess/source/ui/misc - propertystorage.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 28 0.0 %
Date: 2012-08-25 Functions: 0 8 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 62 0.0 %

           Branch data     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 "propertystorage.hxx"
      21                 :            : 
      22                 :            : #include <svl/itemset.hxx>
      23                 :            : #include <svl/stritem.hxx>
      24                 :            : #include <svl/eitem.hxx>
      25                 :            : 
      26                 :            : #include <memory>
      27                 :            : 
      28                 :            : //........................................................................
      29                 :            : namespace dbaui
      30                 :            : {
      31                 :            : //........................................................................
      32                 :            : 
      33                 :            :     /** === begin UNO using === **/
      34                 :            :     using ::com::sun::star::uno::Reference;
      35                 :            :     using ::com::sun::star::uno::XInterface;
      36                 :            :     using ::com::sun::star::uno::UNO_QUERY;
      37                 :            :     using ::com::sun::star::uno::Exception;
      38                 :            :     using ::com::sun::star::uno::RuntimeException;
      39                 :            :     using ::com::sun::star::uno::Any;
      40                 :            :     using ::com::sun::star::uno::makeAny;
      41                 :            :     /** === end UNO using === **/
      42                 :            : 
      43                 :            :     //====================================================================
      44                 :            :     //= PropertyStorage
      45                 :            :     //====================================================================
      46                 :            :     //--------------------------------------------------------------------
      47                 :          0 :     PropertyStorage::~PropertyStorage()
      48                 :            :     {
      49         [ #  # ]:          0 :     }
      50                 :            : 
      51                 :            :     //====================================================================
      52                 :            :     //= helper
      53                 :            :     //====================================================================
      54                 :            :     namespace
      55                 :            :     {
      56                 :            :         //----------------------------------------------------------------
      57                 :            :         template < class ITEMTYPE, class UNOTYPE >
      58                 :            :         class ItemAdapter
      59                 :            :         {
      60                 :            :         public:
      61                 :          0 :             static bool trySet( SfxItemSet& _rSet, ItemId _nItemId, const Any& _rValue )
      62                 :            :             {
      63 [ #  # ][ #  # ]:          0 :                 const SfxPoolItem& rItem( _rSet.Get( _nItemId ) );
      64 [ #  # ][ #  # ]:          0 :                 const ITEMTYPE* pTypedItem = dynamic_cast< const ITEMTYPE* >( &rItem );
      65 [ #  # ][ #  # ]:          0 :                 if ( !pTypedItem )
      66                 :          0 :                     return false;
      67                 :            : 
      68         [ #  # ]:          0 :                 UNOTYPE aValue( pTypedItem->GetValue() );
      69                 :          0 :                 OSL_VERIFY( _rValue >>= aValue );
      70                 :            :                 // TODO: one could throw an IllegalArgumentException here - finally, this method
      71                 :            :                 // is (to be) used from within an XPropertySet::setPropertyValue implementation,
      72                 :            :                 // where this would be the appropriate reaction on wrong value types
      73 [ #  # ][ #  # ]:          0 :                 ::std::auto_ptr< ITEMTYPE > pClone( dynamic_cast< ITEMTYPE* >( pTypedItem->Clone() ) );
         [ #  # ][ #  # ]
      74 [ #  # ][ #  # ]:          0 :                 pClone->SetValue( aValue );
                 [ #  # ]
      75   [ #  #  #  # ]:          0 :                 _rSet.Put( *pClone );
      76 [ #  # ][ #  # ]:          0 :                 return true;
      77                 :            :             }
      78                 :            : 
      79                 :          0 :             static bool tryGet( const SfxPoolItem& _rItem, Any& _out_rValue )
      80                 :            :             {
      81 [ #  # ][ #  # ]:          0 :                 const ITEMTYPE* pTypedItem = dynamic_cast< const ITEMTYPE* >( &_rItem );
      82 [ #  # ][ #  # ]:          0 :                 if ( !pTypedItem )
      83                 :          0 :                     return false;
      84                 :            : 
      85 [ #  # ][ #  # ]:          0 :                 _out_rValue <<= UNOTYPE( pTypedItem->GetValue() );
      86                 :          0 :                 return true;
      87                 :            :             }
      88                 :            :         };
      89                 :            :     }
      90                 :            : 
      91                 :            :     //====================================================================
      92                 :            :     //= SetItemPropertyStorage
      93                 :            :     //====================================================================
      94                 :            :     //--------------------------------------------------------------------
      95                 :          0 :     void SetItemPropertyStorage::getPropertyValue( Any& _out_rValue ) const
      96                 :            :     {
      97                 :          0 :         const SfxPoolItem& rItem( m_rItemSet.Get( m_nItemID ) );
      98                 :            : 
      99                 :            :         // try some known item types
     100         [ #  # ]:          0 :         if  (   ItemAdapter< SfxBoolItem, sal_Bool >::tryGet( rItem, _out_rValue )
           [ #  #  #  # ]
     101                 :          0 :             ||  ItemAdapter< SfxStringItem, ::rtl::OUString >::tryGet( rItem, _out_rValue )
     102                 :            :             )
     103                 :          0 :             return;
     104                 :            : 
     105                 :            :         OSL_FAIL( "SetItemPropertyStorage::getPropertyValue: unsupported item type!" );
     106                 :            :     }
     107                 :            : 
     108                 :            :     //--------------------------------------------------------------------
     109                 :          0 :     void SetItemPropertyStorage::setPropertyValue( const Any& _rValue )
     110                 :            :     {
     111                 :            :         // try some known item types
     112   [ #  #  #  # ]:          0 :         if  (   ItemAdapter< SfxBoolItem, sal_Bool >::trySet( m_rItemSet, m_nItemID, _rValue )
                 [ #  # ]
     113                 :          0 :             ||  ItemAdapter< SfxStringItem, ::rtl::OUString >::trySet( m_rItemSet, m_nItemID, _rValue )
     114                 :            :             )
     115                 :          0 :             return;
     116                 :            : 
     117                 :            :         OSL_FAIL( "SetItemPropertyStorage::setPropertyValue: unsupported item type!" );
     118                 :            :     }
     119                 :            : 
     120                 :            : //........................................................................
     121                 :            : } // namespace dbaui
     122                 :            : //........................................................................
     123                 :            : 
     124                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10