2005-01-21 16:07:44 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 23:46:29 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2005-01-21 16:07:44 +00:00
|
|
|
*
|
2008-04-10 23:46:29 +00:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2005-01-21 16:07:44 +00:00
|
|
|
*
|
2008-04-10 23:46:29 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2005-01-21 16:07:44 +00:00
|
|
|
*
|
2008-04-10 23:46:29 +00:00
|
|
|
* $RCSfile: sequentialtimecontainer.cxx,v $
|
|
|
|
* $Revision: 1.12 $
|
2005-01-21 16:07:44 +00:00
|
|
|
*
|
2008-04-10 23:46:29 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2005-01-21 16:07:44 +00:00
|
|
|
*
|
2008-04-10 23:46:29 +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.
|
2005-01-21 16:07:44 +00:00
|
|
|
*
|
2008-04-10 23:46:29 +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).
|
2005-01-21 16:07:44 +00:00
|
|
|
*
|
2008-04-10 23:46:29 +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.
|
2005-01-21 16:07:44 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 07:36:50 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_slideshow.hxx"
|
|
|
|
|
2007-07-17 13:50:28 +00:00
|
|
|
#include <canvas/debug.hxx>
|
|
|
|
#include <canvas/verbosetrace.hxx>
|
|
|
|
|
|
|
|
#include "eventqueue.hxx"
|
|
|
|
#include "usereventqueue.hxx"
|
2005-10-11 07:44:25 +00:00
|
|
|
#include "sequentialtimecontainer.hxx"
|
|
|
|
#include "tools.hxx"
|
|
|
|
#include "delayevent.hxx"
|
2007-07-17 13:50:28 +00:00
|
|
|
|
|
|
|
#include <boost/bind.hpp>
|
2005-01-21 16:07:44 +00:00
|
|
|
#include <algorithm>
|
|
|
|
|
2006-12-13 14:35:05 +00:00
|
|
|
namespace slideshow {
|
2006-07-26 06:36:50 +00:00
|
|
|
namespace internal {
|
2005-01-21 16:07:44 +00:00
|
|
|
|
2006-07-26 06:36:50 +00:00
|
|
|
void SequentialTimeContainer::activate_st()
|
2005-01-21 16:07:44 +00:00
|
|
|
{
|
2006-07-26 06:36:50 +00:00
|
|
|
// resolve first possible child, ignore
|
|
|
|
for ( ; mnFinishedChildren < maChildren.size(); ++mnFinishedChildren ) {
|
|
|
|
if (resolveChild( maChildren[mnFinishedChildren] ))
|
|
|
|
break;
|
|
|
|
else {
|
|
|
|
// node still UNRESOLVED, no need to deactivate or end...
|
|
|
|
OSL_ENSURE( false, "### resolving child failed!" );
|
2005-01-21 16:07:44 +00:00
|
|
|
}
|
2006-07-26 06:36:50 +00:00
|
|
|
}
|
2005-01-21 16:07:44 +00:00
|
|
|
|
2006-07-26 06:36:50 +00:00
|
|
|
if (isDurationIndefinite() &&
|
|
|
|
(maChildren.empty() || mnFinishedChildren >= maChildren.size()))
|
|
|
|
{
|
|
|
|
// deactivate ASAP:
|
|
|
|
scheduleDeactivationEvent(
|
|
|
|
makeEvent( boost::bind( &AnimationNode::deactivate, getSelf() ) ) );
|
|
|
|
}
|
|
|
|
else // use default
|
|
|
|
scheduleDeactivationEvent();
|
|
|
|
}
|
2005-01-21 16:07:44 +00:00
|
|
|
|
2006-07-26 06:36:50 +00:00
|
|
|
void SequentialTimeContainer::dispose()
|
|
|
|
{
|
|
|
|
BaseContainerNode::dispose();
|
|
|
|
if (mpCurrentSkipEvent) {
|
|
|
|
mpCurrentSkipEvent->dispose();
|
|
|
|
mpCurrentSkipEvent.reset();
|
|
|
|
}
|
|
|
|
if (mpCurrentRewindEvent) {
|
|
|
|
mpCurrentRewindEvent->dispose();
|
|
|
|
mpCurrentRewindEvent.reset();
|
|
|
|
}
|
|
|
|
}
|
2005-01-21 16:07:44 +00:00
|
|
|
|
2006-07-26 06:36:50 +00:00
|
|
|
void SequentialTimeContainer::skipEffect(
|
|
|
|
AnimationNodeSharedPtr const& pChildNode )
|
|
|
|
{
|
|
|
|
if (isChildNode(pChildNode)) {
|
|
|
|
// empty all events ignoring timings => until next effect
|
|
|
|
getContext().mrEventQueue.forceEmpty();
|
2009-03-04 13:41:44 +00:00
|
|
|
getContext().mrEventQueue.addEvent(
|
2006-07-26 06:36:50 +00:00
|
|
|
makeEvent( boost::bind(&AnimationNode::deactivate, pChildNode) ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
OSL_ENSURE( false, "unknown notifier!" );
|
|
|
|
}
|
2005-01-21 16:07:44 +00:00
|
|
|
|
2006-07-26 06:36:50 +00:00
|
|
|
void SequentialTimeContainer::rewindEffect(
|
2006-10-12 13:00:37 +00:00
|
|
|
AnimationNodeSharedPtr const& /*pChildNode*/ )
|
2006-07-26 06:36:50 +00:00
|
|
|
{
|
|
|
|
// xxx todo: ...
|
|
|
|
}
|
2005-01-21 16:07:44 +00:00
|
|
|
|
2006-07-26 06:36:50 +00:00
|
|
|
bool SequentialTimeContainer::resolveChild(
|
|
|
|
AnimationNodeSharedPtr const& pChildNode )
|
|
|
|
{
|
|
|
|
bool const bResolved = pChildNode->resolve();
|
|
|
|
if (bResolved && isMainSequenceRootNode()) {
|
|
|
|
// discharge events:
|
|
|
|
if (mpCurrentSkipEvent)
|
|
|
|
mpCurrentSkipEvent->dispose();
|
|
|
|
if (mpCurrentRewindEvent)
|
|
|
|
mpCurrentRewindEvent->dispose();
|
|
|
|
|
|
|
|
// event that will deactivate the resolved/running child:
|
|
|
|
mpCurrentSkipEvent = makeEvent(
|
2007-08-03 10:54:59 +00:00
|
|
|
boost::bind( &SequentialTimeContainer::skipEffect,
|
|
|
|
boost::dynamic_pointer_cast<SequentialTimeContainer>( getSelf() ),
|
2006-07-26 06:36:50 +00:00
|
|
|
pChildNode ) );
|
|
|
|
// event that will reresolve the resolved/activated child:
|
|
|
|
mpCurrentRewindEvent = makeEvent(
|
2007-08-03 10:54:59 +00:00
|
|
|
boost::bind( &SequentialTimeContainer::rewindEffect,
|
|
|
|
boost::dynamic_pointer_cast<SequentialTimeContainer>( getSelf() ),
|
2006-07-26 06:36:50 +00:00
|
|
|
pChildNode ) );
|
|
|
|
|
|
|
|
// deactivate child node when skip event occurs:
|
|
|
|
getContext().mrUserEventQueue.registerSkipEffectEvent(
|
2009-03-04 13:41:44 +00:00
|
|
|
mpCurrentSkipEvent,
|
|
|
|
mnFinishedChildren+1<maChildren.size());
|
2006-07-26 06:36:50 +00:00
|
|
|
// rewind to previous child:
|
|
|
|
getContext().mrUserEventQueue.registerRewindEffectEvent(
|
|
|
|
mpCurrentRewindEvent );
|
|
|
|
}
|
|
|
|
return bResolved;
|
|
|
|
}
|
2005-01-21 16:07:44 +00:00
|
|
|
|
2006-07-26 06:36:50 +00:00
|
|
|
void SequentialTimeContainer::notifyDeactivating(
|
|
|
|
AnimationNodeSharedPtr const& rNotifier )
|
|
|
|
{
|
2009-03-04 13:41:44 +00:00
|
|
|
OSL_TRACE(" SequentialTimeContainer::notifyDeactivating\r");
|
2006-07-26 06:36:50 +00:00
|
|
|
if (notifyDeactivatedChild( rNotifier ))
|
|
|
|
return;
|
|
|
|
|
|
|
|
OSL_ASSERT( mnFinishedChildren < maChildren.size() );
|
|
|
|
AnimationNodeSharedPtr const& pNextChild = maChildren[mnFinishedChildren];
|
|
|
|
OSL_ASSERT( pNextChild->getState() == UNRESOLVED );
|
|
|
|
|
|
|
|
if (! resolveChild( pNextChild )) {
|
|
|
|
// could not resolve child - since we risk to
|
|
|
|
// stall the chain of events here, play it safe
|
|
|
|
// and deactivate this node (only if we have
|
|
|
|
// indefinite duration - otherwise, we'll get a
|
|
|
|
// deactivation event, anyways).
|
|
|
|
deactivate();
|
2005-01-21 16:07:44 +00:00
|
|
|
}
|
|
|
|
}
|
2006-07-26 06:36:50 +00:00
|
|
|
|
|
|
|
} // namespace internal
|
2006-12-13 14:35:05 +00:00
|
|
|
} // namespace slideshow
|
2006-07-26 06:36:50 +00:00
|
|
|
|