LCOV - code coverage report
Current view: top level - slideshow/source/engine/animationnodes - generateevent.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 74 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 1 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             : // must be first
      22             : #include <canvas/debug.hxx>
      23             : #include <tools/diagnose_ex.h>
      24             : #include <canvas/verbosetrace.hxx>
      25             : 
      26             : #include <com/sun/star/drawing/XShape.hpp>
      27             : #include <com/sun/star/animations/XAnimationNode.hpp>
      28             : #include <com/sun/star/animations/Timing.hpp>
      29             : #include <com/sun/star/animations/EventTrigger.hpp>
      30             : #include <com/sun/star/animations/Event.hpp>
      31             : 
      32             : #include "generateevent.hxx"
      33             : #include "shape.hxx"
      34             : #include "subsettableshapemanager.hxx"
      35             : #include "usereventqueue.hxx"
      36             : #include "slideshowcontext.hxx"
      37             : #include "delayevent.hxx"
      38             : 
      39             : namespace slideshow {
      40             : namespace internal {
      41             : 
      42             : using namespace com::sun::star;
      43             : 
      44           0 : EventSharedPtr generateEvent(
      45             :     uno::Any const& rEventDescription,
      46             :     Delay::FunctorT const& rFunctor,
      47             :     SlideShowContext const& rContext,
      48             :     double nAdditionalDelay )
      49             : {
      50           0 :     EventSharedPtr pEvent;
      51             : 
      52           0 :     if (! rEventDescription.hasValue())
      53           0 :         return pEvent;
      54             : 
      55             :     animations::Timing eTiming;
      56           0 :     animations::Event aEvent;
      57           0 :     uno::Sequence<uno::Any> aSequence;
      58           0 :     double nDelay1 = 0;
      59             : 
      60           0 :     if (rEventDescription >>= eTiming) {
      61           0 :         switch (eTiming) {
      62             :         case animations::Timing_INDEFINITE:
      63           0 :             break; // don't schedule no event
      64             :         case animations::Timing_MEDIA:
      65             :             OSL_FAIL( "MEDIA timing not yet implemented!" );
      66           0 :             break;
      67             :         default:
      68           0 :             ENSURE_OR_THROW( false, "unexpected case!" );
      69             :         }
      70             :     }
      71           0 :     else if (rEventDescription >>= aEvent) {
      72             : 
      73             :         // try to extract additional event delay
      74           0 :         double nDelay2 = 0.0;
      75           0 :         if (aEvent.Offset.hasValue() && !(aEvent.Offset >>= nDelay2)) {
      76             :             OSL_FAIL( "offset values apart from DOUBLE not "
      77             :                         "recognized in animations::Event!" );
      78             :         }
      79             : 
      80             :         // common vars used inside switch
      81           0 :         uno::Reference<animations::XAnimationNode> xNode;
      82           0 :         uno::Reference<drawing::XShape> xShape;
      83           0 :         ShapeSharedPtr pShape;
      84             : 
      85             :         // TODO(F1): Respect aEvent.Repeat value
      86             : 
      87           0 :         switch (aEvent.Trigger) {
      88             :         default:
      89           0 :             ENSURE_OR_THROW( false, "unexpected event trigger!" );
      90             :         case animations::EventTrigger::NONE:
      91             :             // no event at all
      92           0 :             break;
      93             :         case animations::EventTrigger::ON_BEGIN:
      94             :             OSL_FAIL( "event trigger ON_BEGIN not yet implemented!" );
      95           0 :             break;
      96             :         case animations::EventTrigger::ON_END:
      97             :             OSL_FAIL( "event trigger ON_END not yet implemented!" );
      98           0 :             break;
      99             :         case animations::EventTrigger::BEGIN_EVENT:
     100             :             // try to extract XAnimationNode event source
     101           0 :             if (aEvent.Source >>= xNode) {
     102           0 :                 pEvent = makeDelay( rFunctor,
     103             :                                     nDelay2 + nAdditionalDelay,
     104           0 :                                     "generateEvent, BEGIN_EVENT");
     105             :                 rContext.mrUserEventQueue.registerAnimationStartEvent(
     106           0 :                     pEvent, xNode );
     107             :             }
     108             :             else {
     109             :                 OSL_FAIL("could not extract source XAnimationNode "
     110             :                            "for BEGIN_EVENT!" );
     111             :             }
     112           0 :             break;
     113             :         case animations::EventTrigger::END_EVENT:
     114             :             // try to extract XAnimationNode event source
     115           0 :             if (aEvent.Source >>= xNode) {
     116           0 :                 pEvent = makeDelay( rFunctor,
     117             :                                     nDelay2 + nAdditionalDelay,
     118           0 :                                     "generateEvent, END_EVENT");
     119             :                 rContext.mrUserEventQueue.registerAnimationEndEvent(
     120           0 :                     pEvent, xNode );
     121             :             }
     122             :             else {
     123             :                 OSL_FAIL( "could not extract source XAnimationNode "
     124             :                             "for END_EVENT!" );
     125             :             }
     126           0 :             break;
     127             :         case animations::EventTrigger::ON_CLICK:
     128             :             // try to extract XShape event source
     129           0 :             if ((aEvent.Source >>= xShape) &&
     130           0 :                 (pShape = rContext.mpSubsettableShapeManager->lookupShape(xShape)).get())
     131             :             {
     132           0 :                 pEvent = makeDelay( rFunctor,
     133             :                                     nDelay2 + nAdditionalDelay,
     134           0 :                                     "generateEvent, ON_CLICK");
     135             :                 rContext.mrUserEventQueue.registerShapeClickEvent(
     136           0 :                     pEvent, pShape );
     137             :             }
     138             :             else {
     139             :                 OSL_FAIL( "could not extract source XAnimationNode "
     140             :                             "for ON_CLICK!" );
     141             :             }
     142           0 :             break;
     143             :         case animations::EventTrigger::ON_DBL_CLICK:
     144             :             // try to extract XShape event source
     145           0 :             if ((aEvent.Source >>= xShape) &&
     146           0 :                 (pShape = rContext.mpSubsettableShapeManager->lookupShape(xShape)).get())
     147             :             {
     148           0 :                 pEvent = makeDelay( rFunctor,
     149             :                                     nDelay2 + nAdditionalDelay,
     150           0 :                                     "generateEvent, ON_DBL_CLICK");
     151             :                 rContext.mrUserEventQueue.registerShapeDoubleClickEvent(
     152           0 :                     pEvent, pShape );
     153             :             }
     154             :             else {
     155             :                 OSL_FAIL( "could not extract source XAnimationNode "
     156             :                             "for ON_DBL_CLICK!" );
     157             :             }
     158           0 :             break;
     159             :         case animations::EventTrigger::ON_MOUSE_ENTER:
     160             :             // try to extract XShape event source
     161           0 :             if ((aEvent.Source >>= xShape) &&
     162           0 :                 (pShape = rContext.mpSubsettableShapeManager->lookupShape(xShape)).get())
     163             :             {
     164           0 :                 pEvent = makeDelay( rFunctor,
     165             :                                     nDelay2 + nAdditionalDelay,
     166           0 :                                     "generateEvent, ON_MOUSE_ENTER");
     167             :                 rContext.mrUserEventQueue.registerMouseEnterEvent(
     168           0 :                     pEvent, pShape );
     169             :             }
     170             :             else {
     171             :                 OSL_FAIL( "could not extract source XAnimationNode "
     172             :                             "for ON_MOUSE_ENTER!" );
     173             :             }
     174           0 :             break;
     175             :         case animations::EventTrigger::ON_MOUSE_LEAVE:
     176             :             // try to extract XShape event source
     177           0 :             if ((aEvent.Source >>= xShape) &&
     178           0 :                 (pShape = rContext.mpSubsettableShapeManager->lookupShape(xShape)).get())
     179             :             {
     180           0 :                 pEvent = makeDelay( rFunctor,
     181             :                                     nDelay2 + nAdditionalDelay,
     182           0 :                                     "generateEvent, ON_MOUSE_LEAVE");
     183             :                 rContext.mrUserEventQueue.registerMouseLeaveEvent(
     184           0 :                     pEvent, pShape );
     185             :             }
     186             :             else {
     187             :                 OSL_FAIL( "could not extract source XAnimationNode "
     188             :                             "for ON_MOUSE_LEAVE!" );
     189             :             }
     190           0 :             break;
     191             :         case animations::EventTrigger::ON_PREV:
     192             :             OSL_FAIL( "event trigger ON_PREV not yet implemented, "
     193             :                         "mapped to ON_NEXT!" );
     194             :             // FALLTHROUGH intended
     195             :         case animations::EventTrigger::ON_NEXT:
     196           0 :             pEvent = makeDelay( rFunctor,
     197             :                                 nDelay2 + nAdditionalDelay,
     198           0 :                                 "generateEvent, ON_NEXT");
     199           0 :             rContext.mrUserEventQueue.registerNextEffectEvent( pEvent );
     200           0 :             break;
     201             :         case animations::EventTrigger::ON_STOP_AUDIO:
     202             :             // try to extract XAnimationNode event source
     203           0 :             if (aEvent.Source >>= xNode) {
     204           0 :                 pEvent = makeDelay( rFunctor,
     205             :                                     nDelay2 + nAdditionalDelay,
     206           0 :                                     "generateEvent, ON_STOP_AUDIO");
     207             :                 rContext.mrUserEventQueue.registerAudioStoppedEvent(
     208           0 :                     pEvent, xNode );
     209             :             }
     210             :             else {
     211             :                 OSL_FAIL( "could not extract source XAnimationNode "
     212             :                             "for ON_STOP_AUDIO!" );
     213             :             }
     214           0 :             break;
     215             :         case animations::EventTrigger::REPEAT:
     216             :             OSL_FAIL( "event trigger REPEAT not yet implemented!" );
     217           0 :             break;
     218           0 :         }
     219             :     }
     220           0 :     else if (rEventDescription >>= aSequence) {
     221             :         OSL_FAIL( "sequence of timing primitives "
     222             :                     "not yet implemented!" );
     223             :     }
     224           0 :     else if (rEventDescription >>= nDelay1) {
     225           0 :         pEvent = makeDelay( rFunctor,
     226             :                             nDelay1 + nAdditionalDelay,
     227           0 :                             "generateEvent with delay");
     228             :         // schedule delay event
     229           0 :         rContext.mrEventQueue.addEvent( pEvent );
     230             :     }
     231             : 
     232           0 :     return pEvent;
     233             : }
     234             : 
     235             : } // namespace internal
     236             : } // namespace slideshow
     237             : 
     238             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11