1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: conditioncontext.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "conditioncontext.hxx"
33 #include "comphelper/anytostring.hxx"
34 #include "cppuhelper/exc_hlp.hxx"
35 #include <osl/diagnose.h>
37 #include <com/sun/star/animations/XTimeContainer.hpp>
38 #include <com/sun/star/animations/XAnimationNode.hpp>
39 #include <com/sun/star/animations/AnimationEndSync.hpp>
40 #include <com/sun/star/animations/EventTrigger.hpp>
42 #include "oox/helper/attributelist.hxx"
43 #include "oox/core/namespaces.hxx"
44 #include "oox/core/contexthandler.hxx"
45 #include "oox/ppt/animationspersist.hxx"
46 #include "animationtypes.hxx"
48 #include "timetargetelementcontext.hxx"
51 using namespace ::oox::core
;
52 using namespace ::com::sun::star::uno
;
53 using namespace ::com::sun::star::xml::sax
;
54 using namespace ::com::sun::star::animations
;
56 namespace oox
{ namespace ppt
{
58 CondContext::CondContext( ContextHandler
& rParent
, const Reference
< XFastAttributeList
>& xAttribs
,
59 const TimeNodePtr
& pNode
, AnimationCondition
& aValue
)
60 : TimeNodeContext( rParent
, NMSP_PPT
|XML_cond
, xAttribs
, pNode
)
63 maEvent
.Trigger
= EventTrigger::NONE
;
66 AttributeList
attribs( xAttribs
);
67 if( attribs
.hasAttribute( XML_evt
) )
69 sal_Int32 nEvent
= xAttribs
->getOptionalValueToken( XML_evt
, 0 );
73 maEvent
.Trigger
= EventTrigger::ON_BEGIN
;
76 maEvent
.Trigger
= EventTrigger::ON_END
;
79 maEvent
.Trigger
= EventTrigger::BEGIN_EVENT
;
82 maEvent
.Trigger
= EventTrigger::END_EVENT
;
85 maEvent
.Trigger
= EventTrigger::ON_CLICK
;
88 maEvent
.Trigger
= EventTrigger::ON_DBL_CLICK
;
91 maEvent
.Trigger
= EventTrigger::ON_MOUSE_ENTER
;
94 maEvent
.Trigger
= EventTrigger::ON_MOUSE_LEAVE
;
97 maEvent
.Trigger
= EventTrigger::ON_NEXT
;
100 maEvent
.Trigger
= EventTrigger::ON_PREV
;
102 case XML_onStopAudio
:
103 maEvent
.Trigger
= EventTrigger::ON_STOP_AUDIO
;
109 if( attribs
.hasAttribute( XML_delay
) || ( maEvent
.Trigger
== EventTrigger::NONE
) )
111 maEvent
.Offset
= GetTime( xAttribs
->getOptionalValue( XML_delay
) );
115 CondContext::~CondContext( ) throw( )
117 if( maCond
.mnType
== 0 )
119 maCond
.maValue
= (maEvent
.Trigger
== EventTrigger::NONE
) ? maEvent
.Offset
: makeAny( maEvent
);
123 Reference
< XFastContextHandler
> SAL_CALL
CondContext::createFastChildContext( ::sal_Int32 aElementToken
, const Reference
< XFastAttributeList
>& xAttribs
) throw ( SAXException
, RuntimeException
)
125 Reference
< XFastContextHandler
> xRet
;
127 switch( aElementToken
)
129 case NMSP_PPT
|XML_rtn
:
131 // ST_TLTriggerRuntimeNode { first, last, all }
134 aTok
= xAttribs
->getOptionalValueToken( XML_val
, XML_first
);
138 nEnum
= AnimationEndSync::FIRST
;
141 nEnum
= AnimationEndSync::LAST
;
144 nEnum
= AnimationEndSync::ALL
;
149 maCond
.mnType
= aElementToken
;
150 maCond
.maValue
= makeAny( nEnum
);
153 case NMSP_PPT
|XML_tn
:
155 maCond
.mnType
= aElementToken
;
156 AttributeList
attribs( xAttribs
);
157 sal_uInt32 nId
= attribs
.getUnsigned( XML_val
, 0 );
158 maCond
.maValue
= makeAny( nId
);
161 case NMSP_PPT
|XML_tgtEl
:
162 // CT_TLTimeTargetElement
163 xRet
.set( new TimeTargetElementContext( *this, maCond
.getTarget() ) );
178 /** CT_TLTimeConditionList */
179 CondListContext::CondListContext(
180 ContextHandler
& rParent
, sal_Int32 aElement
,
181 const Reference
< XFastAttributeList
>& xAttribs
,
182 const TimeNodePtr
& pNode
,
183 AnimationConditionList
& aCond
)
184 : TimeNodeContext( rParent
, aElement
, xAttribs
, pNode
)
185 , maConditions( aCond
)
189 CondListContext::~CondListContext( )
194 Reference
< XFastContextHandler
> CondListContext::createFastChildContext( ::sal_Int32 aElement
, const Reference
< XFastAttributeList
>& xAttribs
) throw ( SAXException
, RuntimeException
)
196 Reference
< XFastContextHandler
> xRet
;
200 case NMSP_PPT
|XML_cond
:
201 // add a condition to the list
202 maConditions
.push_back( AnimationCondition() );
203 xRet
.set( new CondContext( *this, xAttribs
, mpNode
, maConditions
.back() ) );