LCOV - code coverage report
Current view: top level - libreoffice/slideshow/source/engine - unoviewcontainer.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 25 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 <canvas/debug.hxx>
      22             : #include <unoviewcontainer.hxx>
      23             : 
      24             : #include <boost/bind.hpp>
      25             : 
      26             : #include <algorithm>
      27             : 
      28             : 
      29             : using namespace ::com::sun::star;
      30             : 
      31             : // -----------------------------------------------------------------------------
      32             : 
      33             : namespace slideshow
      34             : {
      35             :     namespace internal
      36             :     {
      37           0 :         UnoViewContainer::UnoViewContainer() :
      38           0 :             maViews()
      39             :         {
      40           0 :         }
      41             : 
      42           0 :         bool UnoViewContainer::addView( const UnoViewSharedPtr& rView )
      43             :         {
      44             :             // check whether same view is already added
      45           0 :             const UnoViewVector::iterator aEnd( maViews.end() );
      46             : 
      47             :             // already added?
      48           0 :             if( ::std::find_if( maViews.begin(),
      49             :                                 aEnd,
      50             :                                 ::boost::bind(
      51             :                                     ::std::equal_to< uno::Reference< presentation::XSlideShowView > >(),
      52           0 :                                     ::boost::cref( rView->getUnoView() ),
      53             :                                     ::boost::bind(
      54             :                                         &UnoView::getUnoView,
      55           0 :                                         _1 ) ) ) != aEnd )
      56             :             {
      57             :                 // yes, nothing to do
      58           0 :                 return false;
      59             :             }
      60             : 
      61             :             // add locally
      62           0 :             maViews.push_back( rView );
      63             : 
      64           0 :             return true;
      65             :         }
      66             : 
      67           0 :         UnoViewSharedPtr UnoViewContainer::removeView( const uno::Reference< presentation::XSlideShowView >& xView )
      68             :         {
      69             :             // check whether same view is already added
      70           0 :             const UnoViewVector::iterator aEnd( maViews.end() );
      71           0 :             UnoViewVector::iterator aIter;
      72             : 
      73             :             // added in the first place?
      74           0 :             if( (aIter=::std::find_if( maViews.begin(),
      75             :                                        aEnd,
      76             :                                        ::boost::bind(
      77             :                                            ::std::equal_to< uno::Reference< presentation::XSlideShowView > >(),
      78             :                                            ::boost::cref( xView ),
      79             :                                            ::boost::bind(
      80             :                                                &UnoView::getUnoView,
      81           0 :                                                _1 ) ) ) ) == aEnd )
      82             :             {
      83             :                 // nope, nothing to do
      84           0 :                 return UnoViewSharedPtr();
      85             :             }
      86             : 
      87             :             OSL_ENSURE(
      88             :                 ::std::count_if(
      89             :                     maViews.begin(),
      90             :                     aEnd,
      91             :                     ::boost::bind(
      92             :                         ::std::equal_to< uno::Reference< presentation::XSlideShowView > >(),
      93             :                         ::boost::cref( xView ),
      94             :                         ::boost::bind(
      95             :                             &UnoView::getUnoView,
      96             :                             _1 ))) == 1,
      97             :                 "UnoViewContainer::removeView(): View was added multiple times" );
      98             : 
      99           0 :             UnoViewSharedPtr pView( *aIter );
     100             : 
     101             :             // actually erase from container
     102           0 :             maViews.erase( aIter );
     103             : 
     104           0 :             return pView;
     105             :         }
     106             : 
     107           0 :         void UnoViewContainer::dispose()
     108             :         {
     109             :             ::std::for_each( maViews.begin(),
     110             :                              maViews.end(),
     111           0 :                              ::boost::mem_fn(&UnoView::_dispose) );
     112           0 :             maViews.clear();
     113           0 :         }
     114             :     }
     115           0 : }
     116             : 
     117             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10