LCOV - code coverage report
Current view: top level - libreoffice/reportdesign/source/core/api - Functions.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 88 0.0 %
Date: 2012-12-27 Functions: 0 18 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             : #include "Functions.hxx"
      20             : #include "Function.hxx"
      21             : #include <tools/debug.hxx>
      22             : #include "core_resource.hxx"
      23             : #include "core_resource.hrc"
      24             : #include <comphelper/property.hxx>
      25             : #include <boost/mem_fn.hpp>
      26             : #include <algorithm>
      27             : // =============================================================================
      28             : namespace reportdesign
      29             : {
      30             : // =============================================================================
      31             :     using namespace com::sun::star;
      32             : DBG_NAME( rpt_OFunctions )
      33             : // -----------------------------------------------------------------------------
      34           0 : OFunctions::OFunctions(const uno::Reference< report::XFunctionsSupplier >& _xParent,const uno::Reference< uno::XComponentContext >& context)
      35             : :FunctionsBase(m_aMutex)
      36             : ,m_aContainerListeners(m_aMutex)
      37             : ,m_xContext(context)
      38           0 : ,m_xParent(_xParent)
      39             : {
      40             :     DBG_CTOR( rpt_OFunctions,NULL);
      41           0 : }
      42             : //--------------------------------------------------------------------------
      43             : // TODO: VirtualFunctionFinder: This is virtual function!
      44             : //
      45           0 : OFunctions::~OFunctions()
      46             : {
      47             :     DBG_DTOR( rpt_OFunctions,NULL);
      48           0 : }
      49             : //--------------------------------------------------------------------------
      50           0 : void SAL_CALL OFunctions::dispose() throw(uno::RuntimeException)
      51             : {
      52           0 :     cppu::WeakComponentImplHelperBase::dispose();
      53           0 : }
      54             : // -----------------------------------------------------------------------------
      55             : // TODO: VirtualFunctionFinder: This is virtual function!
      56             : //
      57           0 : void SAL_CALL OFunctions::disposing()
      58             : {
      59           0 :     ::std::for_each(m_aFunctions.begin(),m_aFunctions.end(),::boost::mem_fn(&com::sun::star::report::XFunction::dispose));
      60           0 :     m_aFunctions.clear();
      61           0 :     lang::EventObject aDisposeEvent( static_cast< ::cppu::OWeakObject* >( this ) );
      62           0 :     m_aContainerListeners.disposeAndClear( aDisposeEvent );
      63           0 :     m_xContext.clear();
      64           0 : }
      65             : // -----------------------------------------------------------------------------
      66             : // XFunctionsSupplier
      67             : // -----------------------------------------------------------------------------
      68           0 : uno::Reference< report::XFunction > SAL_CALL OFunctions::createFunction(  ) throw (uno::RuntimeException)
      69             : {
      70           0 :     return new OFunction(m_xContext);
      71             : }
      72             : // -----------------------------------------------------------------------------
      73             : // XIndexContainer
      74           0 : void SAL_CALL OFunctions::insertByIndex( ::sal_Int32 Index, const uno::Any& aElement ) throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
      75             : {
      76             :     {
      77           0 :         ::osl::MutexGuard aGuard(m_aMutex);
      78           0 :         sal_Bool bAdd = (Index == static_cast<sal_Int32>(m_aFunctions.size()));
      79           0 :         if ( !bAdd )
      80           0 :             checkIndex(Index);
      81           0 :         uno::Reference< report::XFunction > xFunction(aElement,uno::UNO_QUERY);
      82           0 :         if ( !xFunction.is() )
      83           0 :             throw lang::IllegalArgumentException(RPT_RESSTRING(RID_STR_ARGUMENT_IS_NULL,m_xContext->getServiceManager()),*this,2);
      84             : 
      85           0 :         if ( bAdd )
      86           0 :             m_aFunctions.push_back(xFunction);
      87             :         else
      88             :         {
      89           0 :             TFunctions::iterator aPos = m_aFunctions.begin();
      90           0 :             ::std::advance(aPos,Index);
      91           0 :             m_aFunctions.insert(aPos, xFunction);
      92             :         }
      93           0 :         xFunction->setParent(*this);
      94             :     }
      95             :     // notify our container listeners
      96           0 :     container::ContainerEvent aEvent(static_cast<container::XContainer*>(this), uno::makeAny(Index), aElement, uno::Any());
      97           0 :     m_aContainerListeners.notifyEach(&container::XContainerListener::elementInserted,aEvent);
      98           0 : }
      99             : 
     100             : // -----------------------------------------------------------------------------
     101           0 : void SAL_CALL OFunctions::removeByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
     102             : {
     103           0 :     uno::Reference< report::XFunction > xFunction;
     104             :     {
     105           0 :         ::osl::MutexGuard aGuard(m_aMutex);
     106           0 :         checkIndex(Index);
     107           0 :         TFunctions::iterator aPos = m_aFunctions.begin();
     108           0 :         ::std::advance(aPos,Index);
     109           0 :         xFunction = *aPos;
     110           0 :         m_aFunctions.erase(aPos);
     111           0 :         xFunction->setParent(NULL);
     112             :     }
     113           0 :     container::ContainerEvent aEvent(static_cast<container::XContainer*>(this), uno::makeAny(Index), uno::makeAny(xFunction), uno::Any());
     114           0 :     m_aContainerListeners.notifyEach(&container::XContainerListener::elementRemoved,aEvent);
     115           0 : }
     116             : // -----------------------------------------------------------------------------
     117             : // XIndexReplace
     118           0 : void SAL_CALL OFunctions::replaceByIndex( ::sal_Int32 Index, const uno::Any& Element ) throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
     119             : {
     120           0 :     uno::Any aOldElement;
     121             :     {
     122           0 :         ::osl::MutexGuard aGuard(m_aMutex);
     123           0 :         checkIndex(Index);
     124           0 :         uno::Reference< report::XFunction > xFunction(Element,uno::UNO_QUERY);
     125           0 :         if ( !xFunction.is() )
     126           0 :             throw lang::IllegalArgumentException(RPT_RESSTRING(RID_STR_ARGUMENT_IS_NULL,m_xContext->getServiceManager()),*this,2);
     127           0 :         TFunctions::iterator aPos = m_aFunctions.begin();
     128           0 :         ::std::advance(aPos,Index);
     129           0 :         aOldElement <<= *aPos;
     130           0 :         *aPos = xFunction;
     131             :     }
     132             : 
     133           0 :     container::ContainerEvent aEvent(static_cast<container::XContainer*>(this), uno::makeAny(Index), Element, aOldElement);
     134           0 :     m_aContainerListeners.notifyEach(&container::XContainerListener::elementReplaced,aEvent);
     135           0 : }
     136             : // -----------------------------------------------------------------------------
     137             : // XIndexAccess
     138           0 : ::sal_Int32 SAL_CALL OFunctions::getCount(  ) throw (uno::RuntimeException)
     139             : {
     140           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     141           0 :     return m_aFunctions.size();
     142             : }
     143             : // -----------------------------------------------------------------------------
     144           0 : uno::Any SAL_CALL OFunctions::getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
     145             : {
     146           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     147           0 :     checkIndex(Index);
     148           0 :     TFunctions::iterator aPos = m_aFunctions.begin();
     149           0 :     ::std::advance(aPos,Index);
     150           0 :     return uno::makeAny(*aPos);
     151             : }
     152             : // -----------------------------------------------------------------------------
     153             : // XElementAccess
     154           0 : uno::Type SAL_CALL OFunctions::getElementType(  ) throw (uno::RuntimeException)
     155             : {
     156           0 :     return ::getCppuType(static_cast< uno::Reference<report::XFunction>*>(NULL));
     157             : }
     158             : // -----------------------------------------------------------------------------
     159           0 : ::sal_Bool SAL_CALL OFunctions::hasElements(  ) throw (uno::RuntimeException)
     160             : {
     161           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     162           0 :     return !m_aFunctions.empty();
     163             : }
     164             : // -----------------------------------------------------------------------------
     165             : // XChild
     166           0 : uno::Reference< uno::XInterface > SAL_CALL OFunctions::getParent(  ) throw (uno::RuntimeException)
     167             : {
     168           0 :     return m_xParent;
     169             : }
     170             : // -----------------------------------------------------------------------------
     171           0 : void SAL_CALL OFunctions::setParent( const uno::Reference< uno::XInterface >& /*Parent*/ ) throw (lang::NoSupportException, uno::RuntimeException)
     172             : {
     173           0 :     throw lang::NoSupportException();
     174             : }
     175             : // -----------------------------------------------------------------------------
     176             : // XContainer
     177           0 : void SAL_CALL OFunctions::addContainerListener( const uno::Reference< container::XContainerListener >& xListener ) throw (uno::RuntimeException)
     178             : {
     179           0 :     m_aContainerListeners.addInterface(xListener);
     180           0 : }
     181             : // -----------------------------------------------------------------------------
     182           0 : void SAL_CALL OFunctions::removeContainerListener( const uno::Reference< container::XContainerListener >& xListener ) throw (uno::RuntimeException)
     183             : {
     184           0 :     m_aContainerListeners.removeInterface(xListener);
     185           0 : }
     186             : // -----------------------------------------------------------------------------
     187           0 : void OFunctions::checkIndex(sal_Int32 _nIndex)
     188             : {
     189           0 :     if ( _nIndex < 0 || static_cast<sal_Int32>(m_aFunctions.size()) <= _nIndex )
     190           0 :         throw lang::IndexOutOfBoundsException();
     191           0 : }
     192             : // =============================================================================
     193             : }
     194             : // =============================================================================
     195             : 
     196             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10