xref: /trunk/main/oox/source/ppt/slidetransitioncontext.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include "oox/ppt/slidetransitioncontext.hxx"
29 
30 #include "comphelper/anytostring.hxx"
31 #include "cppuhelper/exc_hlp.hxx"
32 
33 #include <com/sun/star/beans/XMultiPropertySet.hpp>
34 #include <com/sun/star/container/XNamed.hpp>
35 
36 #include <oox/ppt/backgroundproperties.hxx>
37 #include "oox/ppt/slidefragmenthandler.hxx"
38 #include "oox/ppt/soundactioncontext.hxx"
39 #include "oox/drawingml/shapegroupcontext.hxx"
40 #include "oox/helper/attributelist.hxx"
41 
42 using rtl::OUString;
43 using namespace ::com::sun::star;
44 using namespace ::oox::core;
45 using namespace ::oox::drawingml;
46 using namespace ::com::sun::star::uno;
47 using namespace ::com::sun::star::xml::sax;
48 using namespace ::com::sun::star::container;
49 
50 namespace oox { namespace ppt {
51 
52 
53 SlideTransitionContext::SlideTransitionContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, PropertyMap & aProperties ) throw()
54 : ContextHandler( rParent )
55 , maSlideProperties( aProperties )
56 , mbHasTransition( sal_False )
57 {
58     AttributeList attribs(xAttribs);
59 
60     // ST_TransitionSpeed
61     maTransition.setOoxTransitionSpeed( xAttribs->getOptionalValueToken( XML_spd, XML_fast ) );
62 
63     // TODO
64     attribs.getBool( XML_advClick, true );
65 
66     // careful. if missing, no auto advance... 0 looks like a valid value
67   // for auto advance
68     if(attribs.hasAttribute( XML_advTm ))
69     {
70         // TODO
71         xAttribs->getOptionalValue( XML_advTm );
72     }
73 }
74 
75 SlideTransitionContext::~SlideTransitionContext() throw()
76 {
77 
78 }
79 
80 Reference< XFastContextHandler > SlideTransitionContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
81 {
82     Reference< XFastContextHandler > xRet;
83 
84     switch( aElementToken )
85     {
86     case PPT_TOKEN( blinds ):
87     case PPT_TOKEN( checker ):
88     case PPT_TOKEN( comb ):
89     case PPT_TOKEN( randomBar ):
90         if (!mbHasTransition)
91         {
92             mbHasTransition = true;
93             maTransition.setOoxTransitionType( aElementToken, xAttribs->getOptionalValueToken( XML_dir, XML_horz ), 0);
94             // ST_Direction { XML_horz, XML_vert }
95         }
96         break;
97     case PPT_TOKEN( cover ):
98     case PPT_TOKEN( pull ):
99         if (!mbHasTransition)
100         {
101             mbHasTransition = true;
102             maTransition.setOoxTransitionType( aElementToken, xAttribs->getOptionalValueToken( XML_dir, XML_l ), 0 );
103             // ST_TransitionEightDirectionType { ST_TransitionSideDirectionType {
104             //                                   XML_d, XML_d, XML_r, XML_u },
105             //                                   ST_TransitionCornerDirectionType {
106             //                                   XML_ld, XML_lu, XML_rd, XML_ru }
107         }
108         break;
109     case PPT_TOKEN( cut ):
110     case PPT_TOKEN( fade ):
111         if (!mbHasTransition)
112         {
113             mbHasTransition = true;
114             AttributeList attribs(xAttribs);
115             // CT_OptionalBlackTransition xdb:bool
116             maTransition.setOoxTransitionType( aElementToken, attribs.getBool( XML_thruBlk, false ), 0);
117         }
118         break;
119     case PPT_TOKEN( push ):
120     case PPT_TOKEN( wipe ):
121         if (!mbHasTransition)
122         {
123             mbHasTransition = true;
124             maTransition.setOoxTransitionType( aElementToken, xAttribs->getOptionalValueToken( XML_dir, XML_l ), 0 );
125             // ST_TransitionSideDirectionType { XML_d, XML_l, XML_r, XML_u }
126         }
127         break;
128     case PPT_TOKEN( split ):
129         if (!mbHasTransition)
130         {
131             mbHasTransition = true;
132             maTransition.setOoxTransitionType( aElementToken, xAttribs->getOptionalValueToken( XML_orient, XML_horz ),  xAttribs->getOptionalValueToken( XML_dir, XML_out ) );
133             // ST_Direction { XML_horz, XML_vert }
134             // ST_TransitionInOutDirectionType { XML_out, XML_in }
135         }
136         break;
137     case PPT_TOKEN( zoom ):
138         if (!mbHasTransition)
139         {
140             mbHasTransition = true;
141             maTransition.setOoxTransitionType( aElementToken, xAttribs->getOptionalValueToken( XML_dir, XML_out ), 0 );
142             // ST_TransitionInOutDirectionType { XML_out, XML_in }
143         }
144         break;
145     case PPT_TOKEN( wheel ):
146         if (!mbHasTransition)
147         {
148             mbHasTransition = true;
149             AttributeList attribs(xAttribs);
150             maTransition.setOoxTransitionType( aElementToken, attribs.getUnsigned( XML_spokes, 4 ), 0 );
151             // unsignedInt
152         }
153         break;
154     case PPT_TOKEN( circle ):
155     case PPT_TOKEN( diamond ):
156     case PPT_TOKEN( dissolve ):
157     case PPT_TOKEN( newsflash ):
158     case PPT_TOKEN( plus ):
159     case PPT_TOKEN( random ):
160     case PPT_TOKEN( wedge ):
161         // CT_Empty
162         if (!mbHasTransition)
163         {
164             mbHasTransition = true;
165             maTransition.setOoxTransitionType( aElementToken, 0, 0 );
166         }
167         break;
168 
169 
170     case PPT_TOKEN( sndAc ): // CT_TransitionSoundAction
171         //"Sound"
172         xRet.set( new SoundActionContext ( *this, maSlideProperties ) );
173         break;
174     case PPT_TOKEN( extLst ): // CT_OfficeArtExtensionList
175         return xRet;
176     default:
177         break;
178     }
179 
180     if( !xRet.is() )
181         xRet.set(this);
182 
183     return xRet;
184 }
185 
186 void SlideTransitionContext::endFastElement( sal_Int32 aElement ) throw (::com::sun::star::xml::sax::SAXException, RuntimeException)
187 {
188     if( aElement == (PPT_TOKEN( transition )) )
189     {
190         if( mbHasTransition )
191         {
192             maTransition.setSlideProperties( maSlideProperties );
193             mbHasTransition = false;
194         }
195     }
196 }
197 
198 
199 } }
200 
201