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

Generated by: LCOV version 1.11