1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "conditioncontext.hxx"
22 #include <com/sun/star/animations/AnimationEndSync.hpp>
23 #include <com/sun/star/animations/EventTrigger.hpp>
25 #include <oox/helper/attributelist.hxx>
26 #include <oox/ppt/animationspersist.hxx>
27 #include "animationtypes.hxx"
28 #include <oox/token/namespaces.hxx>
29 #include <oox/token/tokens.hxx>
31 #include "timetargetelementcontext.hxx"
33 using namespace ::oox::core
;
34 using namespace ::com::sun::star::uno
;
35 using namespace ::com::sun::star::xml::sax
;
36 using namespace ::com::sun::star::animations
;
40 CondContext::CondContext( FragmentHandler2
const & rParent
, const Reference
< XFastAttributeList
>& xAttribs
,
41 const TimeNodePtr
& pNode
, AnimationCondition
& aValue
)
42 : TimeNodeContext( rParent
, PPT_TOKEN( cond
), pNode
)
45 maEvent
.Trigger
= EventTrigger::NONE
;
48 AttributeList
attribs( xAttribs
);
49 if( attribs
.hasAttribute( XML_evt
) )
51 sal_Int32 nEvent
= xAttribs
->getOptionalValueToken( XML_evt
, 0 );
55 maEvent
.Trigger
= EventTrigger::ON_BEGIN
;
58 maEvent
.Trigger
= EventTrigger::ON_END
;
61 maEvent
.Trigger
= EventTrigger::BEGIN_EVENT
;
64 maEvent
.Trigger
= EventTrigger::END_EVENT
;
67 maEvent
.Trigger
= EventTrigger::ON_CLICK
;
70 maEvent
.Trigger
= EventTrigger::ON_DBL_CLICK
;
73 maEvent
.Trigger
= EventTrigger::ON_MOUSE_ENTER
;
76 maEvent
.Trigger
= EventTrigger::ON_MOUSE_LEAVE
;
79 maEvent
.Trigger
= EventTrigger::ON_NEXT
;
82 maEvent
.Trigger
= EventTrigger::ON_PREV
;
85 maEvent
.Trigger
= EventTrigger::ON_STOP_AUDIO
;
91 if( attribs
.hasAttribute( XML_delay
) || ( maEvent
.Trigger
== EventTrigger::NONE
) )
93 maEvent
.Offset
= GetTime( xAttribs
->getOptionalValue( XML_delay
) );
97 CondContext::~CondContext( ) noexcept
99 if( maCond
.mnType
== 0 || maCond
.mnType
== PPT_TOKEN(tn
))
101 maCond
.maValue
= (maEvent
.Trigger
== EventTrigger::NONE
) ? maEvent
.Offset
: Any( maEvent
);
105 ::oox::core::ContextHandlerRef
CondContext::onCreateContext( sal_Int32 aElementToken
, const AttributeList
& rAttribs
)
107 switch( aElementToken
)
109 case PPT_TOKEN( rtn
):
111 // ST_TLTriggerRuntimeNode { first, last, all }
114 aTok
= rAttribs
.getToken( XML_val
, XML_first
);
118 nEnum
= AnimationEndSync::FIRST
;
121 nEnum
= AnimationEndSync::LAST
;
124 nEnum
= AnimationEndSync::ALL
;
129 maCond
.mnType
= aElementToken
;
130 maCond
.maValue
<<= nEnum
;
133 case PPT_TOKEN( tn
):
135 maCond
.mnType
= aElementToken
;
136 // Convert the node id string to XAnimationNode later
137 maEvent
.Source
<<= rAttribs
.getStringDefaulted(XML_val
);
140 case PPT_TOKEN( tgtEl
):
141 // CT_TLTimeTargetElement
142 return new TimeTargetElementContext( *this, maCond
.getTarget() );
151 /** CT_TLTimeConditionList */
152 CondListContext::CondListContext(
153 FragmentHandler2
const & rParent
, sal_Int32 aElement
,
154 const TimeNodePtr
& pNode
,
155 AnimationConditionList
& aCond
)
156 : TimeNodeContext( rParent
, aElement
, pNode
)
157 , maConditions( aCond
)
161 CondListContext::~CondListContext( )
166 ::oox::core::ContextHandlerRef
CondListContext::onCreateContext( sal_Int32 aElement
, const AttributeList
& rAttribs
)
170 case PPT_TOKEN( cond
):
171 // add a condition to the list
172 maConditions
.emplace_back( );
173 return new CondContext( *this, rAttribs
.getFastAttributeList(), mpNode
, maConditions
.back() );
182 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */