Bump version to 24.04.3.4
[LibreOffice.git] / oox / source / ppt / conditioncontext.cxx
blob39fa33bc6b7931be97cc456fd2900aeccfc4c71b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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;
38 namespace oox::ppt {
40 CondContext::CondContext( FragmentHandler2 const & rParent, const Reference< XFastAttributeList >& xAttribs,
41 const TimeNodePtr & pNode, AnimationCondition & aValue )
42 : TimeNodeContext( rParent, PPT_TOKEN( cond ), pNode )
43 , maCond( aValue )
45 maEvent.Trigger = EventTrigger::NONE;
46 maEvent.Repeat = 0;
48 AttributeList attribs( xAttribs );
49 if( attribs.hasAttribute( XML_evt ) )
51 sal_Int32 nEvent = xAttribs->getOptionalValueToken( XML_evt, 0 );
52 switch( nEvent )
54 case XML_onBegin:
55 maEvent.Trigger = EventTrigger::ON_BEGIN;
56 break;
57 case XML_onEnd:
58 maEvent.Trigger = EventTrigger::ON_END;
59 break;
60 case XML_begin:
61 maEvent.Trigger = EventTrigger::BEGIN_EVENT;
62 break;
63 case XML_end:
64 maEvent.Trigger = EventTrigger::END_EVENT;
65 break;
66 case XML_onClick:
67 maEvent.Trigger = EventTrigger::ON_CLICK;
68 break;
69 case XML_onDblClick:
70 maEvent.Trigger = EventTrigger::ON_DBL_CLICK;
71 break;
72 case XML_onMouseOver:
73 maEvent.Trigger = EventTrigger::ON_MOUSE_ENTER;
74 break;
75 case XML_onMouseOut:
76 maEvent.Trigger = EventTrigger::ON_MOUSE_LEAVE;
77 break;
78 case XML_onNext:
79 maEvent.Trigger = EventTrigger::ON_NEXT;
80 break;
81 case XML_onPrev:
82 maEvent.Trigger = EventTrigger::ON_PREV;
83 break;
84 case XML_onStopAudio:
85 maEvent.Trigger = EventTrigger::ON_STOP_AUDIO;
86 break;
87 default:
88 break;
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 }
112 sal_Int32 aTok;
113 sal_Int16 nEnum;
114 aTok = rAttribs.getToken( XML_val, XML_first );
115 switch( aTok )
117 case XML_first:
118 nEnum = AnimationEndSync::FIRST;
119 break;
120 case XML_last:
121 nEnum = AnimationEndSync::LAST;
122 break;
123 case XML_all:
124 nEnum = AnimationEndSync::ALL;
125 break;
126 default:
127 break;
129 maCond.mnType = aElementToken;
130 maCond.maValue <<= nEnum;
131 return this;
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);
138 return this;
140 case PPT_TOKEN( tgtEl ):
141 // CT_TLTimeTargetElement
142 return new TimeTargetElementContext( *this, maCond.getTarget() );
143 default:
144 break;
147 return this;
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( )
162 noexcept
166 ::oox::core::ContextHandlerRef CondListContext::onCreateContext( sal_Int32 aElement, const AttributeList& rAttribs )
168 switch( aElement )
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() );
174 default:
175 break;
177 return this;
182 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */