LibreOffice Module sd (master) 1
pptx-animations-cond.cxx
Go to the documentation of this file.
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
10#include <com/sun/star/animations/Timing.hpp>
11#include <com/sun/star/animations/Event.hpp>
12#include <com/sun/star/animations/EventTrigger.hpp>
13#include <com/sun/star/drawing/XShape.hpp>
14#include <com/sun/star/animations/XAnimationNode.hpp>
16
17using namespace ::com::sun::star::animations;
18using namespace ::com::sun::star::drawing;
19using namespace ::com::sun::star::uno;
20
21namespace
22{
23const char* convertEventTrigger(sal_Int16 nTrigger)
24{
25 const char* pEvent = nullptr;
26 switch (nTrigger)
27 {
28 case EventTrigger::ON_NEXT:
29 pEvent = "onNext";
30 break;
31 case EventTrigger::ON_PREV:
32 pEvent = "onPrev";
33 break;
34 case EventTrigger::BEGIN_EVENT:
35 pEvent = "begin";
36 break;
37 case EventTrigger::END_EVENT:
38 pEvent = "end";
39 break;
40 case EventTrigger::ON_BEGIN:
41 pEvent = "onBegin";
42 break;
43 case EventTrigger::ON_END:
44 pEvent = "onEnd";
45 break;
46 case EventTrigger::ON_CLICK:
47 pEvent = "onClick";
48 break;
49 case EventTrigger::ON_DBL_CLICK:
50 pEvent = "onDblClick";
51 break;
52 case EventTrigger::ON_STOP_AUDIO:
53 pEvent = "onStopAudio";
54 break;
55 case EventTrigger::ON_MOUSE_ENTER:
56 pEvent = "onMouseOver"; // not exact?
57 break;
58 case EventTrigger::ON_MOUSE_LEAVE:
59 pEvent = "onMouseOut";
60 break;
61 }
62 return pEvent;
63}
64}
65
66namespace oox::core
67{
68Cond::Cond(const Any& rAny, bool bIsMainSeqChild)
69 : mpEvent(nullptr)
70{
71 bool bHasFDelay = false;
72 double fDelay = 0;
73 Timing eTiming;
74 Event aEvent;
75
76 if (rAny >>= eTiming)
77 {
78 if (eTiming == Timing_INDEFINITE)
79 msDelay = "indefinite";
80 }
81 else if (rAny >>= aEvent)
82 {
83 if (aEvent.Trigger == EventTrigger::ON_NEXT && bIsMainSeqChild)
84 msDelay = "indefinite";
85 else
86 {
87 mpEvent = convertEventTrigger(aEvent.Trigger);
88 if (!(aEvent.Source >>= mxShape))
89 aEvent.Source >>= mxNode;
90
91 if (aEvent.Offset >>= fDelay)
92 bHasFDelay = true;
93 }
94 }
95 else if (rAny >>= fDelay)
96 bHasFDelay = true;
97
98 if (bHasFDelay)
99 {
100 sal_Int32 nDelay = static_cast<sal_uInt32>(fDelay * 1000.0);
101 msDelay = OString::number(nDelay);
102 }
103}
104}
105/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
AnyEventRef aEvent
css::uno::Reference< css::drawing::XShape > mxShape
Cond(const css::uno::Any &rAny, bool bIsMainSeqChild)
css::uno::Reference< css::animations::XAnimationNode > mxNode