Files
libreoffice/slideshow/source/engine/waitsymbol.cxx
Kurt Zenker 937e484a11 INTEGRATION: CWS presfixes09 (1.6.16); FILE MERGED
2006/10/18 19:52:26 thb 1.6.16.6: RESYNC: (1.6-1.7); FILE MERGED
2006/04/24 13:25:27 thb 1.6.16.5: #i53194# Unified include statements (local headers always have double quotes; external headers angle brackets); reverted EventMultiplexer pause events to shared_ptr; removed EventMultiplexer::removeViewHandler(), since the handler is held weakly, anyway.
2006/04/12 19:25:06 thb 1.6.16.4: #i37778# Making slideshow engine much more robust against missing/unsupported interfaces and properties; fixed RehearseTimings output offset issue; fixed WaitSymbol output position
2006/04/03 16:18:58 thb 1.6.16.3: #i37778# Now passing down ComponentContext to all interested parties; building a second, all-exports version of the slideshow component (to facilitate unit testing also for internal classes) - this made necessary renaming ImportFailedException to ShapeLoadFailedException (because of silly i63703); applied relevant parts of #i63770# (const-correctness); reworked view handling in such a way that views are now kept in one central repository (and are not duplicated across all interested objects); moved code from namespace presentation to namespace slideshow
2006/03/24 18:23:12 thb 1.6.16.2: #i37778# Moved whole slideshow engine from namespace presentation (which conflicts with one of the UNO subnamespaces) to slideshow
2006/03/06 22:14:30 thb 1.6.16.1: #i53194# #i55294# #i59324# Overhauled IntrinsicAnimationActivity; fixes GIF animation import; corrected rehearse timings sprite size; several cosmetic changes (removed external header guards); prepared scene for sprite prio
2006-12-13 14:23:22 +00:00

190 lines
6.1 KiB
C++

/*************************************************************************
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: waitsymbol.cxx,v $
*
* $Revision: 1.8 $
*
* last change: $Author: kz $ $Date: 2006-12-13 15:23:22 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
*
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2005 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_slideshow.hxx"
#include <canvas/canvastools.hxx>
#include <comphelper/anytostring.hxx>
#include <cppuhelper/exc_hlp.hxx>
#include "waitsymbol.hxx"
#include <algorithm>
using namespace com::sun::star;
using namespace com::sun::star::uno;
namespace slideshow {
namespace internal {
const sal_Int32 LEFT_BORDER_SPACE = 10;
const sal_Int32 LOWER_BORDER_SPACE = 10;
WaitSymbolSharedPtr WaitSymbol::create( const uno::Reference<rendering::XBitmap>& xBitmap,
EventMultiplexer& rEventMultiplexer,
const UnoViewContainer& rViewContainer )
{
WaitSymbolSharedPtr pRet( new WaitSymbol( xBitmap, rEventMultiplexer, rViewContainer ));
rEventMultiplexer.addViewHandler( pRet );
return pRet;
}
WaitSymbol::WaitSymbol(
Reference<rendering::XBitmap> const & xBitmap,
EventMultiplexer& rEventMultiplexer,
const UnoViewContainer& rViewContainer )
: m_xBitmap(xBitmap),
m_views(),
mrEventMultiplexer( rEventMultiplexer ),
m_bVisible(false)
{
std::for_each( rViewContainer.begin(),
rViewContainer.end(),
boost::bind( &WaitSymbol::viewAdded,
this,
_1 ));
}
void WaitSymbol::setVisible( const bool bVisible )
{
if (m_bVisible != bVisible)
{
m_bVisible = bVisible;
for_each_sprite( boost::bind( bVisible ? &cppcanvas::Sprite::show
: &cppcanvas::Sprite::hide,
_1 ) );
// force screen update, this implementation bypasses the layer
// manager.
mrEventMultiplexer.updateScreenContent( true );
}
}
// Disposable:
void WaitSymbol::dispose()
{
m_xBitmap.clear();
ViewsVecT().swap( m_views );
}
basegfx::B2DPoint WaitSymbol::calcSpritePos(
UnoViewSharedPtr const & rView ) const
{
const Reference<rendering::XBitmap> xBitmap(
rView->getCanvas()->getUNOCanvas(), UNO_QUERY_THROW );
const geometry::IntegerSize2D realSize( xBitmap->getSize() );
return basegfx::B2DPoint(
std::min<sal_Int32>( realSize.Width, LEFT_BORDER_SPACE ),
std::max<sal_Int32>( 0, realSize.Height - m_xBitmap->getSize().Height
- LOWER_BORDER_SPACE ) );
}
void WaitSymbol::viewAdded( const UnoViewSharedPtr& rView )
{
const geometry::IntegerSize2D spriteSize( m_xBitmap->getSize() );
cppcanvas::CustomSpriteSharedPtr sprite(
rView->createSprite( basegfx::B2DSize( spriteSize.Width,
spriteSize.Height ) ));
try
{
rendering::ViewState viewState;
canvas::tools::initViewState( viewState );
rendering::RenderState renderState;
canvas::tools::initRenderState( renderState );
sprite->getContentCanvas()->getUNOCanvas()->drawBitmap(
m_xBitmap, viewState, renderState );
}
catch (RuntimeException &)
{
throw;
}
catch (Exception &)
{
OSL_ENSURE( false,
rtl::OUStringToOString(
comphelper::anyToString( cppu::getCaughtException() ),
RTL_TEXTENCODING_UTF8 ).getStr() );
}
sprite->setPriority(1000.0); // sprite should be in front of all
// other sprites
sprite->setAlpha( 0.9 );
sprite->movePixel( calcSpritePos( rView ) );
m_views.push_back( ViewsVecT::value_type( rView, sprite ) );
if (m_bVisible)
sprite->show();
}
void WaitSymbol::viewRemoved( const UnoViewSharedPtr& rView )
{
m_views.erase(
std::remove_if(
m_views.begin(), m_views.end(),
boost::bind(
std::equal_to<UnoViewSharedPtr>(),
rView,
// select view:
boost::bind( std::select1st<ViewsVecT::value_type>(), _1 ) ) ),
m_views.end() );
}
void WaitSymbol::viewChanged( const UnoViewSharedPtr& rView )
{
// find entry corresponding to modified view
ViewsVecT::iterator aModifiedEntry(
std::find_if(
m_views.begin(),
m_views.end(),
boost::bind(
std::equal_to<UnoViewSharedPtr>(),
rView,
// select view:
boost::bind( std::select1st<ViewsVecT::value_type>(), _1 ))));
OSL_ASSERT( aModifiedEntry != m_views.end() );
if( aModifiedEntry == m_views.end() )
return;
aModifiedEntry->second->movePixel( calcSpritePos( m_views.begin()->first ));
}
} // namespace internal
} // namespace presentation