LCOV - code coverage report
Current view: top level - framework/source/fwe/helper - propertysetcontainer.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 59 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 12 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 <helper/propertysetcontainer.hxx>
      21             : 
      22             : #include <cppuhelper/queryinterface.hxx>
      23             : #include <vcl/svapp.hxx>
      24             : 
      25             : #define WRONG_TYPE_EXCEPTION    "Only XPropertSet allowed!"
      26             : 
      27             : using namespace cppu;
      28             : using namespace com::sun::star::uno;
      29             : using namespace com::sun::star::container;
      30             : using namespace com::sun::star::lang;
      31             : using namespace com::sun::star::beans;
      32             : 
      33             : namespace framework
      34             : {
      35             : 
      36           0 : PropertySetContainer::PropertySetContainer()
      37           0 :         :   OWeakObject()
      38             : 
      39             : {
      40           0 : }
      41             : 
      42           0 : PropertySetContainer::~PropertySetContainer()
      43             : {
      44           0 : }
      45             : 
      46             : // XInterface
      47           0 : void SAL_CALL PropertySetContainer::acquire() throw ()
      48             : {
      49           0 :     OWeakObject::acquire();
      50           0 : }
      51             : 
      52           0 : void SAL_CALL PropertySetContainer::release() throw ()
      53             : {
      54           0 :     OWeakObject::release();
      55           0 : }
      56             : 
      57           0 : Any SAL_CALL PropertySetContainer::queryInterface( const Type& rType )
      58             : throw ( RuntimeException, std::exception )
      59             : {
      60             :     Any a = ::cppu::queryInterface(
      61             :                 rType ,
      62             :                 (static_cast< XIndexContainer* >(this)),
      63             :                 (static_cast< XIndexReplace* >(this)),
      64             :                 (static_cast< XIndexAccess* >(this)),
      65           0 :                 (static_cast< XElementAccess* >(this)) );
      66             : 
      67           0 :     if( a.hasValue() )
      68             :     {
      69           0 :         return a;
      70             :     }
      71             : 
      72           0 :     return OWeakObject::queryInterface( rType );
      73             : }
      74             : 
      75             : // XIndexContainer
      76           0 : void SAL_CALL PropertySetContainer::insertByIndex( sal_Int32 Index, const ::com::sun::star::uno::Any& Element )
      77             :     throw ( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException, std::exception )
      78             : {
      79           0 :     SolarMutexGuard g;
      80             : 
      81           0 :     sal_Int32 nSize = m_aPropertySetVector.size();
      82             : 
      83           0 :     if ( nSize >= Index )
      84             :     {
      85           0 :         Reference< XPropertySet > aPropertySetElement;
      86             : 
      87           0 :         if ( Element >>= aPropertySetElement )
      88             :         {
      89           0 :             if ( nSize == Index )
      90           0 :                 m_aPropertySetVector.push_back( aPropertySetElement );
      91             :             else
      92             :             {
      93           0 :                 PropertySetVector::iterator aIter = m_aPropertySetVector.begin();
      94           0 :                 aIter += Index;
      95           0 :                 m_aPropertySetVector.insert( aIter, aPropertySetElement );
      96             :             }
      97             :         }
      98             :         else
      99             :         {
     100             :             throw IllegalArgumentException(
     101             :                 WRONG_TYPE_EXCEPTION,
     102           0 :                 static_cast<OWeakObject *>(this), 2 );
     103           0 :         }
     104             :     }
     105             :     else
     106           0 :         throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
     107           0 : }
     108             : 
     109           0 : void SAL_CALL PropertySetContainer::removeByIndex( sal_Int32 nIndex )
     110             :     throw ( IndexOutOfBoundsException, WrappedTargetException, RuntimeException, std::exception )
     111             : {
     112           0 :     SolarMutexGuard g;
     113             : 
     114           0 :     if ( (sal_Int32)m_aPropertySetVector.size() > nIndex )
     115             :     {
     116           0 :         m_aPropertySetVector.erase(m_aPropertySetVector.begin() +  nIndex);
     117             :     }
     118             :     else
     119           0 :         throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
     120           0 : }
     121             : 
     122             : // XIndexReplace
     123           0 : void SAL_CALL PropertySetContainer::replaceByIndex( sal_Int32 Index, const ::com::sun::star::uno::Any& Element )
     124             :     throw ( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException, std::exception)
     125             : {
     126           0 :     if ( (sal_Int32)m_aPropertySetVector.size() > Index )
     127             :     {
     128           0 :         Reference< XPropertySet > aPropertySetElement;
     129             : 
     130           0 :         if ( Element >>= aPropertySetElement )
     131             :         {
     132           0 :             m_aPropertySetVector[ Index ] = aPropertySetElement;
     133             :         }
     134             :         else
     135             :         {
     136             :             throw IllegalArgumentException(
     137             :                 WRONG_TYPE_EXCEPTION,
     138           0 :                 static_cast<OWeakObject *>(this), 2 );
     139           0 :         }
     140             :     }
     141             :     else
     142           0 :         throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
     143           0 : }
     144             : 
     145             : // XIndexAccess
     146           0 : sal_Int32 SAL_CALL PropertySetContainer::getCount()
     147             :     throw ( RuntimeException, std::exception )
     148             : {
     149           0 :     SolarMutexGuard g;
     150             : 
     151           0 :     return m_aPropertySetVector.size();
     152             : }
     153             : 
     154           0 : Any SAL_CALL PropertySetContainer::getByIndex( sal_Int32 Index )
     155             :     throw ( IndexOutOfBoundsException, WrappedTargetException, RuntimeException, std::exception )
     156             : {
     157           0 :     SolarMutexGuard g;
     158             : 
     159           0 :     if ( (sal_Int32)m_aPropertySetVector.size() > Index )
     160             :     {
     161           0 :         Any a;
     162             : 
     163           0 :         a <<= m_aPropertySetVector[ Index ];
     164           0 :         return a;
     165             :     }
     166             :     else
     167           0 :         throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
     168             : }
     169             : 
     170             : // XElementAccess
     171           0 : sal_Bool SAL_CALL PropertySetContainer::hasElements()
     172             :     throw (::com::sun::star::uno::RuntimeException, std::exception)
     173             : {
     174           0 :     SolarMutexGuard g;
     175             : 
     176           0 :     return !( m_aPropertySetVector.empty() );
     177             : }
     178             : 
     179             : }
     180             : 
     181             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11