Added 20 words to autocorrect pt_PT
[LibreOffice.git] / oox / source / ppt / conditioncontext.cxx
blob122ec7585403033e038c2b4cdc9562b9c6735bd9
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 "comphelper/anytostring.hxx"
23 #include "cppuhelper/exc_hlp.hxx"
25 #include <com/sun/star/animations/AnimationEndSync.hpp>
26 #include <com/sun/star/animations/EventTrigger.hpp>
28 #include "oox/helper/attributelist.hxx"
29 #include "oox/ppt/animationspersist.hxx"
30 #include "animationtypes.hxx"
31 #include <oox/token/namespaces.hxx>
32 #include <oox/token/tokens.hxx>
34 #include "timetargetelementcontext.hxx"
36 using namespace ::oox::core;
37 using namespace ::com::sun::star::uno;
38 using namespace ::com::sun::star::xml::sax;
39 using namespace ::com::sun::star::animations;
41 namespace oox { namespace ppt {
43 CondContext::CondContext( FragmentHandler2& rParent, const Reference< XFastAttributeList >& xAttribs,
44 const TimeNodePtr & pNode, AnimationCondition & aValue )
45 : TimeNodeContext( rParent, PPT_TOKEN( cond ), xAttribs, pNode )
46 , maCond( aValue )
48 maEvent.Trigger = EventTrigger::NONE;
49 maEvent.Repeat = 0;
51 AttributeList attribs( xAttribs );
52 if( attribs.hasAttribute( XML_evt ) )
54 sal_Int32 nEvent = xAttribs->getOptionalValueToken( XML_evt, 0 );
55 switch( nEvent )
57 case XML_onBegin:
58 maEvent.Trigger = EventTrigger::ON_BEGIN;
59 break;
60 case XML_onEnd:
61 maEvent.Trigger = EventTrigger::ON_END;
62 break;
63 case XML_begin:
64 maEvent.Trigger = EventTrigger::BEGIN_EVENT;
65 break;
66 case XML_end:
67 maEvent.Trigger = EventTrigger::END_EVENT;
68 break;
69 case XML_onClick:
70 maEvent.Trigger = EventTrigger::ON_CLICK;
71 break;
72 case XML_onDblClick:
73 maEvent.Trigger = EventTrigger::ON_DBL_CLICK;
74 break;
75 case XML_onMouseOver:
76 maEvent.Trigger = EventTrigger::ON_MOUSE_ENTER;
77 break;
78 case XML_onMouseOut:
79 maEvent.Trigger = EventTrigger::ON_MOUSE_LEAVE;
80 break;
81 case XML_onNext:
82 maEvent.Trigger = EventTrigger::ON_NEXT;
83 break;
84 case XML_onPrev:
85 maEvent.Trigger = EventTrigger::ON_PREV;
86 break;
87 case XML_onStopAudio:
88 maEvent.Trigger = EventTrigger::ON_STOP_AUDIO;
89 break;
90 default:
91 break;
94 if( attribs.hasAttribute( XML_delay ) || ( maEvent.Trigger == EventTrigger::NONE ) )
96 maEvent.Offset = GetTime( xAttribs->getOptionalValue( XML_delay ) );
100 CondContext::~CondContext( ) throw( )
102 if( maCond.mnType == 0 )
104 maCond.maValue = (maEvent.Trigger == EventTrigger::NONE) ? maEvent.Offset : makeAny( maEvent );
108 ::oox::core::ContextHandlerRef CondContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
110 switch( aElementToken )
112 case PPT_TOKEN( rtn ):
114 // ST_TLTriggerRuntimeNode { first, last, all }
115 sal_Int32 aTok;
116 sal_Int16 nEnum;
117 aTok = rAttribs.getToken( XML_val, XML_first );
118 switch( aTok )
120 case XML_first:
121 nEnum = AnimationEndSync::FIRST;
122 break;
123 case XML_last:
124 nEnum = AnimationEndSync::LAST;
125 break;
126 case XML_all:
127 nEnum = AnimationEndSync::ALL;
128 break;
129 default:
130 break;
132 maCond.mnType = aElementToken;
133 maCond.maValue <<= nEnum;
134 return this;
136 case PPT_TOKEN( tn ):
138 maCond.mnType = aElementToken;
139 sal_uInt32 nId = rAttribs.getUnsigned( XML_val, 0 );
140 maCond.maValue <<= nId;
141 return this;
143 case PPT_TOKEN( tgtEl ):
144 // CT_TLTimeTargetElement
145 return new TimeTargetElementContext( *this, maCond.getTarget() );
146 default:
147 break;
150 return this;
154 /** CT_TLTimeConditionList */
155 CondListContext::CondListContext(
156 FragmentHandler2& rParent, sal_Int32 aElement,
157 const Reference< XFastAttributeList >& xAttribs,
158 const TimeNodePtr & pNode,
159 AnimationConditionList & aCond )
160 : TimeNodeContext( rParent, aElement, xAttribs, pNode )
161 , maConditions( aCond )
165 CondListContext::~CondListContext( )
166 throw( )
170 ::oox::core::ContextHandlerRef CondListContext::onCreateContext( sal_Int32 aElement, const AttributeList& rAttribs )
172 switch( aElement )
174 case PPT_TOKEN( cond ):
175 // add a condition to the list
176 maConditions.push_back( AnimationCondition() );
177 return new CondContext( *this, rAttribs.getFastAttributeList(), mpNode, maConditions.back() );
178 default:
179 break;
181 return this;
186 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */