1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #include "oox/ppt/slidetransitioncontext.hxx"
25 
26 #include "comphelper/anytostring.hxx"
27 #include "cppuhelper/exc_hlp.hxx"
28 
29 #include <com/sun/star/beans/XMultiPropertySet.hpp>
30 #include <com/sun/star/container/XNamed.hpp>
31 
32 #include <oox/ppt/backgroundproperties.hxx>
33 #include "oox/ppt/slidefragmenthandler.hxx"
34 #include "oox/ppt/soundactioncontext.hxx"
35 #include "oox/drawingml/shapegroupcontext.hxx"
36 #include "oox/helper/attributelist.hxx"
37 
38 using rtl::OUString;
39 using namespace ::com::sun::star;
40 using namespace ::oox::core;
41 using namespace ::oox::drawingml;
42 using namespace ::com::sun::star::uno;
43 using namespace ::com::sun::star::xml::sax;
44 using namespace ::com::sun::star::container;
45 
46 namespace oox { namespace ppt {
47 
48 
SlideTransitionContext(ContextHandler & rParent,const Reference<XFastAttributeList> & xAttribs,PropertyMap & aProperties)49 SlideTransitionContext::SlideTransitionContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, PropertyMap & aProperties ) throw()
50 : ContextHandler( rParent )
51 , maSlideProperties( aProperties )
52 , mbHasTransition( sal_False )
53 {
54 	AttributeList attribs(xAttribs);
55 
56 	// ST_TransitionSpeed
57 	maTransition.setOoxTransitionSpeed( xAttribs->getOptionalValueToken( XML_spd, XML_fast ) );
58 
59 	// TODO
60 	attribs.getBool( XML_advClick, true );
61 
62 	// careful. if missing, no auto advance... 0 looks like a valid value
63   // for auto advance
64 	if(attribs.hasAttribute( XML_advTm ))
65 	{
66 		// TODO
67 		xAttribs->getOptionalValue( XML_advTm );
68 	}
69 }
70 
~SlideTransitionContext()71 SlideTransitionContext::~SlideTransitionContext() throw()
72 {
73 
74 }
75 
createFastChildContext(sal_Int32 aElementToken,const Reference<XFastAttributeList> & xAttribs)76 Reference< XFastContextHandler > SlideTransitionContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
77 {
78 	Reference< XFastContextHandler > xRet;
79 
80 	switch( aElementToken )
81 	{
82 	case PPT_TOKEN( blinds ):
83 	case PPT_TOKEN( checker ):
84 	case PPT_TOKEN( comb ):
85 	case PPT_TOKEN( randomBar ):
86 		if (!mbHasTransition)
87 		{
88 			mbHasTransition = true;
89 			maTransition.setOoxTransitionType( aElementToken, xAttribs->getOptionalValueToken( XML_dir, XML_horz ), 0);
90 			// ST_Direction { XML_horz, XML_vert }
91 		}
92 		break;
93 	case PPT_TOKEN( cover ):
94 	case PPT_TOKEN( pull ):
95 		if (!mbHasTransition)
96 		{
97 			mbHasTransition = true;
98 			maTransition.setOoxTransitionType( aElementToken, xAttribs->getOptionalValueToken( XML_dir, XML_l ), 0 );
99 			// ST_TransitionEightDirectionType { ST_TransitionSideDirectionType {
100 			//                                   XML_d, XML_d, XML_r, XML_u },
101 			//                                   ST_TransitionCornerDirectionType {
102 			//                                   XML_ld, XML_lu, XML_rd, XML_ru }
103 		}
104 		break;
105 	case PPT_TOKEN( cut ):
106 	case PPT_TOKEN( fade ):
107 		if (!mbHasTransition)
108 		{
109 			mbHasTransition = true;
110 			AttributeList attribs(xAttribs);
111 			// CT_OptionalBlackTransition xdb:bool
112 			maTransition.setOoxTransitionType( aElementToken, attribs.getBool( XML_thruBlk, false ), 0);
113 		}
114 		break;
115 	case PPT_TOKEN( push ):
116 	case PPT_TOKEN( wipe ):
117 		if (!mbHasTransition)
118 		{
119 			mbHasTransition = true;
120 			maTransition.setOoxTransitionType( aElementToken, xAttribs->getOptionalValueToken( XML_dir, XML_l ), 0 );
121 			// ST_TransitionSideDirectionType { XML_d, XML_l, XML_r, XML_u }
122 		}
123 		break;
124 	case PPT_TOKEN( split ):
125 		if (!mbHasTransition)
126 		{
127 			mbHasTransition = true;
128 			maTransition.setOoxTransitionType( aElementToken, xAttribs->getOptionalValueToken( XML_orient, XML_horz ),	xAttribs->getOptionalValueToken( XML_dir, XML_out ) );
129 			// ST_Direction { XML_horz, XML_vert }
130 			// ST_TransitionInOutDirectionType { XML_out, XML_in }
131 		}
132 		break;
133 	case PPT_TOKEN( zoom ):
134 		if (!mbHasTransition)
135 		{
136 			mbHasTransition = true;
137 			maTransition.setOoxTransitionType( aElementToken, xAttribs->getOptionalValueToken( XML_dir, XML_out ), 0 );
138 			// ST_TransitionInOutDirectionType { XML_out, XML_in }
139 		}
140 		break;
141 	case PPT_TOKEN( wheel ):
142 		if (!mbHasTransition)
143 		{
144 			mbHasTransition = true;
145 			AttributeList attribs(xAttribs);
146             maTransition.setOoxTransitionType( aElementToken, attribs.getUnsigned( XML_spokes, 4 ), 0 );
147 			// unsignedInt
148 		}
149 		break;
150 	case PPT_TOKEN( circle ):
151 	case PPT_TOKEN( diamond ):
152 	case PPT_TOKEN( dissolve ):
153 	case PPT_TOKEN( newsflash ):
154 	case PPT_TOKEN( plus ):
155 	case PPT_TOKEN( random ):
156 	case PPT_TOKEN( wedge ):
157 		// CT_Empty
158 		if (!mbHasTransition)
159 		{
160 			mbHasTransition = true;
161 			maTransition.setOoxTransitionType( aElementToken, 0, 0 );
162 		}
163 		break;
164 
165 
166 	case PPT_TOKEN( sndAc ): // CT_TransitionSoundAction
167 		//"Sound"
168         xRet.set( new SoundActionContext ( *this, maSlideProperties ) );
169 		break;
170 	case PPT_TOKEN( extLst ): // CT_OfficeArtExtensionList
171         return xRet;
172 	default:
173 		break;
174 	}
175 
176 	if( !xRet.is() )
177 		xRet.set(this);
178 
179 	return xRet;
180 }
181 
endFastElement(sal_Int32 aElement)182 void SlideTransitionContext::endFastElement( sal_Int32 aElement ) throw (::com::sun::star::xml::sax::SAXException, RuntimeException)
183 {
184 	if( aElement == (PPT_TOKEN( transition )) )
185 	{
186 		if( mbHasTransition )
187 		{
188 			maTransition.setSlideProperties( maSlideProperties );
189 			mbHasTransition = false;
190 		}
191 	}
192 }
193 
194 
195 } }
196 
197