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