2010-10-12 15:51:52 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2004-11-26 18:00:38 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 23:29:24 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2004-11-26 18:00:38 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2004-11-26 18:00:38 +00:00
|
|
|
*
|
2008-04-10 23:29:24 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2004-11-26 18:00:38 +00:00
|
|
|
*
|
2008-04-10 23:29:24 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2004-11-26 18:00:38 +00:00
|
|
|
*
|
2008-04-10 23:29:24 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2004-11-26 18:00:38 +00:00
|
|
|
*
|
2008-04-10 23:29:24 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2004-11-26 18:00:38 +00:00
|
|
|
*
|
2008-04-10 23:29:24 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2004-11-26 18:00:38 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 07:29:46 +00:00
|
|
|
|
2004-11-26 18:00:38 +00:00
|
|
|
#include <canvas/debug.hxx>
|
|
|
|
#include <unoviewcontainer.hxx>
|
|
|
|
|
|
|
|
#include <boost/bind.hpp>
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2006-12-13 14:21:35 +00:00
|
|
|
namespace slideshow
|
2004-11-26 18:00:38 +00:00
|
|
|
{
|
|
|
|
namespace internal
|
|
|
|
{
|
|
|
|
UnoViewContainer::UnoViewContainer() :
|
|
|
|
maViews()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool UnoViewContainer::addView( const UnoViewSharedPtr& rView )
|
|
|
|
{
|
|
|
|
// check whether same view is already added
|
|
|
|
const UnoViewVector::iterator aEnd( maViews.end() );
|
|
|
|
|
|
|
|
// already added?
|
|
|
|
if( ::std::find_if( maViews.begin(),
|
|
|
|
aEnd,
|
|
|
|
::boost::bind(
|
2006-12-13 14:21:35 +00:00
|
|
|
::std::equal_to< uno::Reference< presentation::XSlideShowView > >(),
|
2004-11-26 18:00:38 +00:00
|
|
|
::boost::cref( rView->getUnoView() ),
|
|
|
|
::boost::bind(
|
|
|
|
&UnoView::getUnoView,
|
|
|
|
_1 ) ) ) != aEnd )
|
|
|
|
{
|
|
|
|
// yes, nothing to do
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// add locally
|
|
|
|
maViews.push_back( rView );
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2006-12-13 14:21:35 +00:00
|
|
|
UnoViewSharedPtr UnoViewContainer::removeView( const uno::Reference< presentation::XSlideShowView >& xView )
|
2004-11-26 18:00:38 +00:00
|
|
|
{
|
|
|
|
// check whether same view is already added
|
|
|
|
const UnoViewVector::iterator aEnd( maViews.end() );
|
|
|
|
UnoViewVector::iterator aIter;
|
|
|
|
|
|
|
|
// added in the first place?
|
2007-08-17 11:43:29 +00:00
|
|
|
if( (aIter=::std::find_if( maViews.begin(),
|
|
|
|
aEnd,
|
|
|
|
::boost::bind(
|
|
|
|
::std::equal_to< uno::Reference< presentation::XSlideShowView > >(),
|
|
|
|
::boost::cref( xView ),
|
|
|
|
::boost::bind(
|
|
|
|
&UnoView::getUnoView,
|
|
|
|
_1 ) ) ) ) == aEnd )
|
2004-11-26 18:00:38 +00:00
|
|
|
{
|
|
|
|
// nope, nothing to do
|
|
|
|
return UnoViewSharedPtr();
|
|
|
|
}
|
|
|
|
|
2007-08-17 11:43:29 +00:00
|
|
|
OSL_ENSURE(
|
|
|
|
::std::count_if(
|
|
|
|
maViews.begin(),
|
|
|
|
aEnd,
|
|
|
|
::boost::bind(
|
|
|
|
::std::equal_to< uno::Reference< presentation::XSlideShowView > >(),
|
|
|
|
::boost::cref( xView ),
|
|
|
|
::boost::bind(
|
|
|
|
&UnoView::getUnoView,
|
|
|
|
_1 ))) == 1,
|
|
|
|
"UnoViewContainer::removeView(): View was added multiple times" );
|
2004-11-26 18:00:38 +00:00
|
|
|
|
|
|
|
UnoViewSharedPtr pView( *aIter );
|
|
|
|
|
|
|
|
// actually erase from container
|
2007-08-17 11:43:29 +00:00
|
|
|
maViews.erase( aIter );
|
2004-11-26 18:00:38 +00:00
|
|
|
|
|
|
|
return pView;
|
|
|
|
}
|
|
|
|
|
2006-12-13 14:21:35 +00:00
|
|
|
void UnoViewContainer::dispose()
|
2004-11-26 18:00:38 +00:00
|
|
|
{
|
2006-12-13 14:21:35 +00:00
|
|
|
::std::for_each( maViews.begin(),
|
|
|
|
maViews.end(),
|
|
|
|
::boost::mem_fn(&UnoView::_dispose) );
|
2004-11-26 18:00:38 +00:00
|
|
|
maViews.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-10-12 15:51:52 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|