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

Generated by: LCOV version 1.10