LCOV - code coverage report
Current view: top level - libreoffice/slideshow/source/engine/animationnodes - sequentialtimecontainer.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 50 0.0 %
Date: 2012-12-27 Functions: 0 8 0.0 %
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 <canvas/verbosetrace.hxx>
      23             : 
      24             : #include "delayevent.hxx"
      25             : #include "eventqueue.hxx"
      26             : #include "usereventqueue.hxx"
      27             : #include "sequentialtimecontainer.hxx"
      28             : #include "tools.hxx"
      29             : 
      30             : #include <boost/bind.hpp>
      31             : #include <algorithm>
      32             : 
      33             : namespace slideshow {
      34             : namespace internal {
      35             : 
      36           0 : void SequentialTimeContainer::activate_st()
      37             : {
      38             :     // resolve first possible child, ignore
      39           0 :     for ( ; mnFinishedChildren < maChildren.size(); ++mnFinishedChildren ) {
      40           0 :         if (resolveChild( maChildren[mnFinishedChildren] ))
      41           0 :             break;
      42             :         else {
      43             :             // node still UNRESOLVED, no need to deactivate or end...
      44             :             OSL_FAIL( "### resolving child failed!" );
      45             :         }
      46             :     }
      47             : 
      48           0 :     if (isDurationIndefinite() &&
      49           0 :         (maChildren.empty() || mnFinishedChildren >= maChildren.size()))
      50             :     {
      51             :         // deactivate ASAP:
      52             :         scheduleDeactivationEvent(
      53           0 :             makeEvent(
      54             :                  boost::bind< void >( boost::mem_fn( &AnimationNode::deactivate ), getSelf() ),
      55           0 :                  "SequentialTimeContainer::deactivate") );
      56             :     }
      57             :     else // use default
      58           0 :         scheduleDeactivationEvent();
      59           0 : }
      60             : 
      61           0 : void SequentialTimeContainer::dispose()
      62             : {
      63           0 :     BaseContainerNode::dispose();
      64           0 :     if (mpCurrentSkipEvent) {
      65           0 :         mpCurrentSkipEvent->dispose();
      66           0 :         mpCurrentSkipEvent.reset();
      67             :     }
      68           0 :     if (mpCurrentRewindEvent) {
      69           0 :         mpCurrentRewindEvent->dispose();
      70           0 :         mpCurrentRewindEvent.reset();
      71             :     }
      72           0 : }
      73             : 
      74           0 : void SequentialTimeContainer::skipEffect(
      75             :     AnimationNodeSharedPtr const& pChildNode )
      76             : {
      77           0 :     if (isChildNode(pChildNode)) {
      78             :         // empty all events ignoring timings => until next effect
      79           0 :         getContext().mrEventQueue.forceEmpty();
      80           0 :         getContext().mrEventQueue.addEvent(
      81             :             makeEvent(
      82             :                 boost::bind<void>( boost::mem_fn( &AnimationNode::deactivate ), pChildNode ),
      83           0 :                 "SequentialTimeContainer::deactivate, skipEffect with delay") );
      84             :     }
      85             :     else
      86             :         OSL_FAIL( "unknown notifier!" );
      87           0 : }
      88             : 
      89           0 : void SequentialTimeContainer::rewindEffect(
      90             :     AnimationNodeSharedPtr const& /*pChildNode*/ )
      91             : {
      92             :     // xxx todo: ...
      93           0 : }
      94             : 
      95           0 : bool SequentialTimeContainer::resolveChild(
      96             :     AnimationNodeSharedPtr const& pChildNode )
      97             : {
      98           0 :     bool const bResolved = pChildNode->resolve();
      99           0 :     if (bResolved && isMainSequenceRootNode()) {
     100             :         // discharge events:
     101           0 :         if (mpCurrentSkipEvent)
     102           0 :             mpCurrentSkipEvent->dispose();
     103           0 :         if (mpCurrentRewindEvent)
     104           0 :             mpCurrentRewindEvent->dispose();
     105             : 
     106             :         // event that will deactivate the resolved/running child:
     107           0 :         mpCurrentSkipEvent = makeEvent(
     108             :             boost::bind( &SequentialTimeContainer::skipEffect,
     109             :                          boost::dynamic_pointer_cast<SequentialTimeContainer>( getSelf() ),
     110             :                          pChildNode ),
     111           0 :             "SequentialTimeContainer::skipEffect, resolveChild");
     112             :         // event that will reresolve the resolved/activated child:
     113           0 :         mpCurrentRewindEvent = makeEvent(
     114             :             boost::bind( &SequentialTimeContainer::rewindEffect,
     115             :                          boost::dynamic_pointer_cast<SequentialTimeContainer>( getSelf() ),
     116             :                          pChildNode ),
     117           0 :             "SequentialTimeContainer::rewindEffect, resolveChild");
     118             : 
     119             :         // deactivate child node when skip event occurs:
     120           0 :         getContext().mrUserEventQueue.registerSkipEffectEvent(
     121             :             mpCurrentSkipEvent,
     122           0 :             mnFinishedChildren+1<maChildren.size());
     123             :         // rewind to previous child:
     124           0 :         getContext().mrUserEventQueue.registerRewindEffectEvent(
     125           0 :             mpCurrentRewindEvent );
     126             :     }
     127           0 :     return bResolved;
     128             : }
     129             : 
     130           0 : void SequentialTimeContainer::notifyDeactivating(
     131             :     AnimationNodeSharedPtr const& rNotifier )
     132             : {
     133           0 :     if (notifyDeactivatedChild( rNotifier ))
     134           0 :         return;
     135             : 
     136             :     OSL_ASSERT( mnFinishedChildren < maChildren.size() );
     137           0 :     AnimationNodeSharedPtr const& pNextChild = maChildren[mnFinishedChildren];
     138             :     OSL_ASSERT( pNextChild->getState() == UNRESOLVED );
     139             : 
     140           0 :     if (! resolveChild( pNextChild )) {
     141             :         // could not resolve child - since we risk to
     142             :         // stall the chain of events here, play it safe
     143             :         // and deactivate this node (only if we have
     144             :         // indefinite duration - otherwise, we'll get a
     145             :         // deactivation event, anyways).
     146           0 :         deactivate();
     147             :     }
     148             : }
     149             : 
     150             : } // namespace internal
     151           0 : } // namespace slideshow
     152             : 
     153             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10