Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "oox/ppt/slidetransitioncontext.hxx"
21 :
22 : #include "comphelper/anytostring.hxx"
23 : #include "cppuhelper/exc_hlp.hxx"
24 :
25 : #include <com/sun/star/beans/XMultiPropertySet.hpp>
26 : #include <com/sun/star/container/XNamed.hpp>
27 :
28 : #include <oox/ppt/backgroundproperties.hxx>
29 : #include "oox/ppt/slidefragmenthandler.hxx"
30 : #include "oox/ppt/soundactioncontext.hxx"
31 : #include "oox/drawingml/shapegroupcontext.hxx"
32 : #include "oox/helper/attributelist.hxx"
33 :
34 : using namespace ::com::sun::star;
35 : using namespace ::oox::core;
36 : using namespace ::oox::drawingml;
37 : using namespace ::com::sun::star::uno;
38 : using namespace ::com::sun::star::xml::sax;
39 : using namespace ::com::sun::star::container;
40 :
41 : namespace oox { namespace ppt {
42 :
43 4 : SlideTransitionContext::SlideTransitionContext( FragmentHandler2& rParent, const AttributeList& rAttribs, PropertyMap & aProperties ) throw()
44 : : FragmentHandler2( rParent )
45 : , maSlideProperties( aProperties )
46 4 : , mbHasTransition( false )
47 : {
48 : // ST_TransitionSpeed
49 4 : maTransition.setOoxTransitionSpeed( rAttribs.getToken( XML_spd, XML_fast ) );
50 :
51 : // TODO
52 4 : rAttribs.getBool( XML_advClick, true );
53 :
54 : // careful. if missing, no auto advance... 0 looks like a valid value
55 : // for auto advance
56 4 : if(rAttribs.hasAttribute( XML_advTm ))
57 0 : maTransition.setOoxAdvanceTime( rAttribs.getInteger( XML_advTm, -1 ) );
58 4 : }
59 :
60 8 : SlideTransitionContext::~SlideTransitionContext() throw()
61 : {
62 :
63 8 : }
64 :
65 4 : ::oox::core::ContextHandlerRef SlideTransitionContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
66 : {
67 4 : switch( aElementToken )
68 : {
69 : case PPT_TOKEN( blinds ):
70 : case PPT_TOKEN( checker ):
71 : case PPT_TOKEN( comb ):
72 : case PPT_TOKEN( randomBar ):
73 0 : if (!mbHasTransition)
74 : {
75 0 : mbHasTransition = true;
76 0 : maTransition.setOoxTransitionType( aElementToken, rAttribs.getToken( XML_dir, XML_horz ), 0);
77 : }
78 0 : return this;
79 : case PPT_TOKEN( cover ):
80 : case PPT_TOKEN( pull ):
81 0 : if (!mbHasTransition)
82 : {
83 0 : mbHasTransition = true;
84 0 : maTransition.setOoxTransitionType( aElementToken, rAttribs.getToken( XML_dir, XML_l ), 0 );
85 : }
86 0 : return this;
87 : case PPT_TOKEN( cut ):
88 : case PPT_TOKEN( fade ):
89 0 : if (!mbHasTransition)
90 : {
91 0 : mbHasTransition = true;
92 0 : maTransition.setOoxTransitionType( aElementToken, sal_Int32(rAttribs.getBool( XML_thruBlk, false )), 0);
93 : }
94 0 : return this;
95 : case PPT_TOKEN( push ):
96 : case PPT_TOKEN( wipe ):
97 2 : if (!mbHasTransition)
98 : {
99 2 : mbHasTransition = true;
100 2 : maTransition.setOoxTransitionType( aElementToken, rAttribs.getToken( XML_dir, XML_l ), 0 );
101 : }
102 2 : return this;
103 : case PPT_TOKEN( split ):
104 0 : if (!mbHasTransition)
105 : {
106 0 : mbHasTransition = true;
107 0 : maTransition.setOoxTransitionType( aElementToken, rAttribs.getToken( XML_orient, XML_horz ), rAttribs.getToken( XML_dir, XML_out ) );
108 : }
109 0 : return this;
110 : case PPT_TOKEN( zoom ):
111 2 : if (!mbHasTransition)
112 : {
113 2 : mbHasTransition = true;
114 2 : maTransition.setOoxTransitionType( aElementToken, rAttribs.getToken( XML_dir, XML_out ), 0 );
115 : }
116 2 : return this;
117 : case PPT_TOKEN( wheel ):
118 0 : if (!mbHasTransition)
119 : {
120 0 : mbHasTransition = true;
121 0 : maTransition.setOoxTransitionType( aElementToken, rAttribs.getUnsigned( XML_spokes, 4 ), 0 );
122 : // unsignedInt
123 : }
124 0 : return this;
125 : case PPT_TOKEN( circle ):
126 : case PPT_TOKEN( diamond ):
127 : case PPT_TOKEN( dissolve ):
128 : case PPT_TOKEN( newsflash ):
129 : case PPT_TOKEN( plus ):
130 : case PPT_TOKEN( random ):
131 : case PPT_TOKEN( wedge ):
132 : // CT_Empty
133 0 : if (!mbHasTransition)
134 : {
135 0 : mbHasTransition = true;
136 0 : maTransition.setOoxTransitionType( aElementToken, 0, 0 );
137 : }
138 0 : return this;
139 :
140 : case PPT_TOKEN( sndAc ): // CT_TransitionSoundAction
141 : //"Sound"
142 0 : return new SoundActionContext ( *this, maSlideProperties );
143 : case PPT_TOKEN( extLst ): // CT_OfficeArtExtensionList
144 0 : return this;
145 : default:
146 0 : break;
147 : }
148 :
149 0 : return this;
150 : }
151 :
152 8 : void SlideTransitionContext::onEndElement()
153 : {
154 8 : if( isCurrentElement(PPT_TOKEN( transition )) )
155 : {
156 4 : if( mbHasTransition )
157 : {
158 4 : maTransition.setSlideProperties( maSlideProperties );
159 4 : mbHasTransition = false;
160 : }
161 : }
162 8 : }
163 :
164 408 : } }
165 :
166 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|