Update ooo320-m1
[ooovba.git] / oox / source / ppt / slidetransitioncontext.cxx
blob6c07b7c377525b0c29b79c397c911a79ce15363c
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: slidetransitioncontext.cxx,v $
10 * $Revision: 1.4 $
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 "oox/ppt/slidetransitioncontext.hxx"
33 #include "comphelper/anytostring.hxx"
34 #include "cppuhelper/exc_hlp.hxx"
36 #include <com/sun/star/beans/XMultiPropertySet.hpp>
37 #include <com/sun/star/container/XNamed.hpp>
39 #include <oox/ppt/backgroundproperties.hxx>
40 #include "oox/ppt/slidefragmenthandler.hxx"
41 #include "oox/ppt/soundactioncontext.hxx"
42 #include "oox/drawingml/shapegroupcontext.hxx"
43 #include "oox/helper/attributelist.hxx"
44 #include "oox/core/namespaces.hxx"
46 #include "tokens.hxx"
48 using rtl::OUString;
49 using namespace ::com::sun::star;
50 using namespace ::oox::core;
51 using namespace ::oox::drawingml;
52 using namespace ::com::sun::star::uno;
53 using namespace ::com::sun::star::xml::sax;
54 using namespace ::com::sun::star::container;
56 namespace oox { namespace ppt {
59 SlideTransitionContext::SlideTransitionContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, PropertyMap & aProperties ) throw()
60 : ContextHandler( rParent )
61 , maSlideProperties( aProperties )
62 , mbHasTransition( sal_False )
64 AttributeList attribs(xAttribs);
66 // ST_TransitionSpeed
67 maTransition.setOoxTransitionSpeed( xAttribs->getOptionalValueToken( XML_spd, XML_fast ) );
69 // TODO
70 attribs.getBool( XML_advClick, true );
72 // careful. if missing, no auto advance... 0 looks like a valid value
73 // for auto advance
74 if(attribs.hasAttribute( XML_advTm ))
75 maTransition.setOoxAdvanceTime( attribs.getInteger( XML_advTm, -1 ) );
78 SlideTransitionContext::~SlideTransitionContext() throw()
83 Reference< XFastContextHandler > SlideTransitionContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
85 Reference< XFastContextHandler > xRet;
87 switch( aElementToken )
89 case NMSP_PPT|XML_blinds:
90 case NMSP_PPT|XML_checker:
91 case NMSP_PPT|XML_comb:
92 case NMSP_PPT|XML_randomBar:
93 if (!mbHasTransition)
95 mbHasTransition = true;
96 maTransition.setOoxTransitionType( aElementToken, xAttribs->getOptionalValueToken( XML_dir, XML_horz ), 0);
97 // ST_Direction { XML_horz, XML_vert }
99 break;
100 case NMSP_PPT|XML_cover:
101 case NMSP_PPT|XML_pull:
102 if (!mbHasTransition)
104 mbHasTransition = true;
105 maTransition.setOoxTransitionType( aElementToken, xAttribs->getOptionalValueToken( XML_dir, XML_l ), 0 );
106 // ST_TransitionEightDirectionType { ST_TransitionSideDirectionType {
107 // XML_d, XML_d, XML_r, XML_u },
108 // ST_TransitionCornerDirectionType {
109 // XML_ld, XML_lu, XML_rd, XML_ru }
111 break;
112 case NMSP_PPT|XML_cut:
113 case NMSP_PPT|XML_fade:
114 if (!mbHasTransition)
116 mbHasTransition = true;
117 AttributeList attribs(xAttribs);
118 // CT_OptionalBlackTransition xdb:bool
119 maTransition.setOoxTransitionType( aElementToken, attribs.getBool( XML_thruBlk, false ), 0);
121 break;
122 case NMSP_PPT|XML_push:
123 case NMSP_PPT|XML_wipe:
124 if (!mbHasTransition)
126 mbHasTransition = true;
127 maTransition.setOoxTransitionType( aElementToken, xAttribs->getOptionalValueToken( XML_dir, XML_l ), 0 );
128 // ST_TransitionSideDirectionType { XML_d, XML_l, XML_r, XML_u }
130 break;
131 case NMSP_PPT|XML_split:
132 if (!mbHasTransition)
134 mbHasTransition = true;
135 maTransition.setOoxTransitionType( aElementToken, xAttribs->getOptionalValueToken( XML_orient, XML_horz ), xAttribs->getOptionalValueToken( XML_dir, XML_out ) );
136 // ST_Direction { XML_horz, XML_vert }
137 // ST_TransitionInOutDirectionType { XML_out, XML_in }
139 break;
140 case NMSP_PPT|XML_zoom:
141 if (!mbHasTransition)
143 mbHasTransition = true;
144 maTransition.setOoxTransitionType( aElementToken, xAttribs->getOptionalValueToken( XML_dir, XML_out ), 0 );
145 // ST_TransitionInOutDirectionType { XML_out, XML_in }
147 break;
148 case NMSP_PPT|XML_wheel:
149 if (!mbHasTransition)
151 mbHasTransition = true;
152 AttributeList attribs(xAttribs);
153 maTransition.setOoxTransitionType( aElementToken, attribs.getUnsigned( XML_spokes, 4 ), 0 );
154 // unsignedInt
156 break;
157 case NMSP_PPT|XML_circle:
158 case NMSP_PPT|XML_diamond:
159 case NMSP_PPT|XML_dissolve:
160 case NMSP_PPT|XML_newsflash:
161 case NMSP_PPT|XML_plus:
162 case NMSP_PPT|XML_random:
163 case NMSP_PPT|XML_wedge:
164 // CT_Empty
165 if (!mbHasTransition)
167 mbHasTransition = true;
168 maTransition.setOoxTransitionType( aElementToken, 0, 0 );
170 break;
173 case NMSP_PPT|XML_sndAc: // CT_TransitionSoundAction
174 //"Sound"
175 xRet.set( new SoundActionContext ( *this, maSlideProperties ) );
176 break;
177 case NMSP_PPT|XML_extLst: // CT_OfficeArtExtensionList
178 return xRet;
179 default:
180 break;
183 if( !xRet.is() )
184 xRet.set(this);
186 return xRet;
189 void SlideTransitionContext::endFastElement( sal_Int32 aElement ) throw (::com::sun::star::xml::sax::SAXException, RuntimeException)
191 if( aElement == (NMSP_PPT|XML_transition) )
193 if( mbHasTransition )
195 maTransition.setSlideProperties( maSlideProperties );
196 mbHasTransition = false;