LCOV - code coverage report
Current view: top level - slideshow/source/engine - unoviewcontainer.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 8 25 32.0 %
Date: 2014-11-03 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 <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           2 :         UnoViewContainer::UnoViewContainer() :
      38           2 :             maViews()
      39             :         {
      40           2 :         }
      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 :             uno::Reference<presentation::XSlideShowView> xView (rView->getUnoView());
      49           0 :             if( ::std::find_if( maViews.begin(),
      50             :                                 aEnd,
      51             :                                 ::boost::bind(
      52             :                                     ::std::equal_to< uno::Reference< presentation::XSlideShowView > >(),
      53             :                                     ::boost::cref( xView ),
      54             :                                     ::boost::bind(
      55             :                                         &UnoView::getUnoView,
      56           0 :                                         _1 ) ) ) != aEnd )
      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           2 :         void UnoViewContainer::dispose()
     109             :         {
     110             :             ::std::for_each( maViews.begin(),
     111             :                              maViews.end(),
     112           2 :                              ::boost::mem_fn(&UnoView::_dispose) );
     113           2 :             maViews.clear();
     114           2 :         }
     115             :     }
     116           6 : }
     117             : 
     118             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10