Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / oox / source / ppt / conditioncontext.cxx
blobcdecaa12089172accfda9df0d82495e468c0a787
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 <cppuhelper/exc_hlp.hxx>
24 #include <com/sun/star/animations/AnimationEndSync.hpp>
25 #include <com/sun/star/animations/EventTrigger.hpp>
27 #include <oox/helper/attributelist.hxx>
28 #include <oox/ppt/animationspersist.hxx>
29 #include "animationtypes.hxx"
30 #include <oox/token/namespaces.hxx>
31 #include <oox/token/tokens.hxx>
33 #include "timetargetelementcontext.hxx"
35 using namespace ::oox::core;
36 using namespace ::com::sun::star::uno;
37 using namespace ::com::sun::star::xml::sax;
38 using namespace ::com::sun::star::animations;
40 namespace oox { namespace ppt {
42 CondContext::CondContext( FragmentHandler2 const & rParent, const Reference< XFastAttributeList >& xAttribs,
43 const TimeNodePtr & pNode, AnimationCondition & aValue )
44 : TimeNodeContext( rParent, PPT_TOKEN( cond ), pNode )
45 , maCond( aValue )
47 maEvent.Trigger = EventTrigger::NONE;
48 maEvent.Repeat = 0;
50 AttributeList attribs( xAttribs );
51 if( attribs.hasAttribute( XML_evt ) )
53 sal_Int32 nEvent = xAttribs->getOptionalValueToken( XML_evt, 0 );
54 switch( nEvent )
56 case XML_onBegin:
57 maEvent.Trigger = EventTrigger::ON_BEGIN;
58 break;
59 case XML_onEnd:
60 maEvent.Trigger = EventTrigger::ON_END;
61 break;
62 case XML_begin:
63 maEvent.Trigger = EventTrigger::BEGIN_EVENT;
64 break;
65 case XML_end:
66 maEvent.Trigger = EventTrigger::END_EVENT;
67 break;
68 case XML_onClick:
69 maEvent.Trigger = EventTrigger::ON_CLICK;
70 break;
71 case XML_onDblClick:
72 maEvent.Trigger = EventTrigger::ON_DBL_CLICK;
73 break;
74 case XML_onMouseOver:
75 maEvent.Trigger = EventTrigger::ON_MOUSE_ENTER;
76 break;
77 case XML_onMouseOut:
78 maEvent.Trigger = EventTrigger::ON_MOUSE_LEAVE;
79 break;
80 case XML_onNext:
81 maEvent.Trigger = EventTrigger::ON_NEXT;
82 break;
83 case XML_onPrev:
84 maEvent.Trigger = EventTrigger::ON_PREV;
85 break;
86 case XML_onStopAudio:
87 maEvent.Trigger = EventTrigger::ON_STOP_AUDIO;
88 break;
89 default:
90 break;
93 if( attribs.hasAttribute( XML_delay ) || ( maEvent.Trigger == EventTrigger::NONE ) )
95 maEvent.Offset = GetTime( xAttribs->getOptionalValue( XML_delay ) );
99 CondContext::~CondContext( ) throw( )
101 if( maCond.mnType == 0 )
103 maCond.maValue = (maEvent.Trigger == EventTrigger::NONE) ? maEvent.Offset : makeAny( maEvent );
107 ::oox::core::ContextHandlerRef CondContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
109 switch( aElementToken )
111 case PPT_TOKEN( rtn ):
113 // ST_TLTriggerRuntimeNode { first, last, all }
114 sal_Int32 aTok;
115 sal_Int16 nEnum;
116 aTok = rAttribs.getToken( XML_val, XML_first );
117 switch( aTok )
119 case XML_first:
120 nEnum = AnimationEndSync::FIRST;
121 break;
122 case XML_last:
123 nEnum = AnimationEndSync::LAST;
124 break;
125 case XML_all:
126 nEnum = AnimationEndSync::ALL;
127 break;
128 default:
129 break;
131 maCond.mnType = aElementToken;
132 maCond.maValue <<= nEnum;
133 return this;
135 case PPT_TOKEN( tn ):
137 maCond.mnType = aElementToken;
138 sal_uInt32 nId = rAttribs.getUnsigned( XML_val, 0 );
139 maCond.maValue <<= nId;
140 return this;
142 case PPT_TOKEN( tgtEl ):
143 // CT_TLTimeTargetElement
144 return new TimeTargetElementContext( *this, maCond.getTarget() );
145 default:
146 break;
149 return this;
153 /** CT_TLTimeConditionList */
154 CondListContext::CondListContext(
155 FragmentHandler2 const & rParent, sal_Int32 aElement,
156 const TimeNodePtr & pNode,
157 AnimationConditionList & aCond )
158 : TimeNodeContext( rParent, aElement, pNode )
159 , maConditions( aCond )
163 CondListContext::~CondListContext( )
164 throw( )
168 ::oox::core::ContextHandlerRef CondListContext::onCreateContext( sal_Int32 aElement, const AttributeList& rAttribs )
170 switch( aElement )
172 case PPT_TOKEN( cond ):
173 // add a condition to the list
174 maConditions.emplace_back( );
175 return new CondContext( *this, rAttribs.getFastAttributeList(), mpNode, maConditions.back() );
176 default:
177 break;
179 return this;
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */