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 "comphelper/anytostring.hxx"
23 #include "cppuhelper/exc_hlp.hxx"
24 #include <osl/diagnose.h>
26 #include <com/sun/star/animations/XTimeContainer.hpp>
27 #include <com/sun/star/animations/XAnimationNode.hpp>
28 #include <com/sun/star/animations/AnimationEndSync.hpp>
29 #include <com/sun/star/animations/EventTrigger.hpp>
31 #include "oox/helper/attributelist.hxx"
32 #include "oox/ppt/animationspersist.hxx"
33 #include "animationtypes.hxx"
35 #include "timetargetelementcontext.hxx"
37 using namespace ::oox::core
;
38 using namespace ::com::sun::star::uno
;
39 using namespace ::com::sun::star::xml::sax
;
40 using namespace ::com::sun::star::animations
;
42 namespace oox
{ namespace ppt
{
44 CondContext::CondContext( FragmentHandler2
& rParent
, const Reference
< XFastAttributeList
>& xAttribs
,
45 const TimeNodePtr
& pNode
, AnimationCondition
& aValue
)
46 : TimeNodeContext( rParent
, PPT_TOKEN( cond
), xAttribs
, pNode
)
49 maEvent
.Trigger
= EventTrigger::NONE
;
52 AttributeList
attribs( xAttribs
);
53 if( attribs
.hasAttribute( XML_evt
) )
55 sal_Int32 nEvent
= xAttribs
->getOptionalValueToken( XML_evt
, 0 );
59 maEvent
.Trigger
= EventTrigger::ON_BEGIN
;
62 maEvent
.Trigger
= EventTrigger::ON_END
;
65 maEvent
.Trigger
= EventTrigger::BEGIN_EVENT
;
68 maEvent
.Trigger
= EventTrigger::END_EVENT
;
71 maEvent
.Trigger
= EventTrigger::ON_CLICK
;
74 maEvent
.Trigger
= EventTrigger::ON_DBL_CLICK
;
77 maEvent
.Trigger
= EventTrigger::ON_MOUSE_ENTER
;
80 maEvent
.Trigger
= EventTrigger::ON_MOUSE_LEAVE
;
83 maEvent
.Trigger
= EventTrigger::ON_NEXT
;
86 maEvent
.Trigger
= EventTrigger::ON_PREV
;
89 maEvent
.Trigger
= EventTrigger::ON_STOP_AUDIO
;
95 if( attribs
.hasAttribute( XML_delay
) || ( maEvent
.Trigger
== EventTrigger::NONE
) )
97 maEvent
.Offset
= GetTime( xAttribs
->getOptionalValue( XML_delay
) );
101 CondContext::~CondContext( ) throw( )
103 if( maCond
.mnType
== 0 )
105 maCond
.maValue
= (maEvent
.Trigger
== EventTrigger::NONE
) ? maEvent
.Offset
: makeAny( maEvent
);
109 ::oox::core::ContextHandlerRef
CondContext::onCreateContext( sal_Int32 aElementToken
, const AttributeList
& rAttribs
)
111 switch( aElementToken
)
113 case PPT_TOKEN( rtn
):
115 // ST_TLTriggerRuntimeNode { first, last, all }
118 aTok
= rAttribs
.getToken( XML_val
, XML_first
);
122 nEnum
= AnimationEndSync::FIRST
;
125 nEnum
= AnimationEndSync::LAST
;
128 nEnum
= AnimationEndSync::ALL
;
133 maCond
.mnType
= aElementToken
;
134 maCond
.maValue
= makeAny( nEnum
);
137 case PPT_TOKEN( tn
):
139 maCond
.mnType
= aElementToken
;
140 sal_uInt32 nId
= rAttribs
.getUnsigned( XML_val
, 0 );
141 maCond
.maValue
= makeAny( nId
);
144 case PPT_TOKEN( tgtEl
):
145 // CT_TLTimeTargetElement
146 return new TimeTargetElementContext( *this, maCond
.getTarget() );
157 /** CT_TLTimeConditionList */
158 CondListContext::CondListContext(
159 FragmentHandler2
& rParent
, sal_Int32 aElement
,
160 const Reference
< XFastAttributeList
>& xAttribs
,
161 const TimeNodePtr
& pNode
,
162 AnimationConditionList
& aCond
)
163 : TimeNodeContext( rParent
, aElement
, xAttribs
, pNode
)
164 , maConditions( aCond
)
168 CondListContext::~CondListContext( )
173 ::oox::core::ContextHandlerRef
CondListContext::onCreateContext( sal_Int32 aElement
, const AttributeList
& rAttribs
)
177 case PPT_TOKEN( cond
):
178 // add a condition to the list
179 maConditions
.push_back( AnimationCondition() );
180 return new CondContext( *this, rAttribs
.getFastAttributeList(), mpNode
, maConditions
.back() );
190 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */