LibreOffice Module oox (master) 1
slidetransitioncontext.cxx
Go to the documentation of this file.
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
21
25#include <oox/token/namespaces.hxx>
26#include <oox/token/tokens.hxx>
27
28using namespace ::com::sun::star;
29using namespace ::oox::core;
30using namespace ::oox::drawingml;
31using namespace ::com::sun::star::uno;
32using namespace ::com::sun::star::xml::sax;
33
34namespace oox::ppt {
35
36SlideTransitionContext::SlideTransitionContext( FragmentHandler2 const & rParent, const AttributeList& rAttribs, PropertyMap & aProperties )
37: FragmentHandler2( rParent )
38, maSlideProperties( aProperties )
39, mbHasTransition( false )
40, mbHasTransitionDuration( false )
41{
42 // ST_TransitionSpeed
43 maTransition.setOoxTransitionSpeed( rAttribs.getToken( XML_spd, XML_fast ) );
44
45 // p14:dur
46 sal_Int32 nDurationInMs = rAttribs.getInteger( P14_TOKEN( dur ), -1 );
47 if( nDurationInMs > -1 )
48 {
49 // In MSO 0 is visible as 0.01s
50 if( nDurationInMs == 0.0 )
51 nDurationInMs = 10;
52 maTransition.setOoxTransitionSpeed( nDurationInMs / 1000.0 );
54 }
55
56 // TODO
57 rAttribs.getBool( XML_advClick, true );
58
59 // careful. if missing, no auto advance... 0 looks like a valid value
60 // for auto advance
61 if(rAttribs.hasAttribute( XML_advTm ))
62 maTransition.setOoxAdvanceTime( rAttribs.getInteger( XML_advTm, -1 ) );
63}
64
66{
67
68}
69
71{
72 switch( aElementToken )
73 {
74 case PPT_TOKEN( blinds ):
75 case PPT_TOKEN( checker ):
76 case PPT_TOKEN( comb ):
77 case PPT_TOKEN( randomBar ):
78 if (!mbHasTransition)
79 {
80 mbHasTransition = true;
81 maTransition.setOoxTransitionType( aElementToken, rAttribs.getToken( XML_dir, XML_horz ), 0);
82 }
83 return this;
84 case PPT_TOKEN( cover ):
85 case PPT_TOKEN( pull ):
86 if (!mbHasTransition)
87 {
88 mbHasTransition = true;
89 maTransition.setOoxTransitionType( aElementToken, rAttribs.getToken( XML_dir, XML_l ), 0 );
90 }
91 return this;
92 case PPT_TOKEN( cut ):
93 case PPT_TOKEN( fade ):
94 if (!mbHasTransition)
95 {
96 mbHasTransition = true;
97 maTransition.setOoxTransitionType( aElementToken, sal_Int32(rAttribs.getBool( XML_thruBlk, false )), 0);
98 }
99 return this;
100 case PPT_TOKEN( push ):
101 case PPT_TOKEN( wipe ):
102 if (!mbHasTransition)
103 {
104 mbHasTransition = true;
105 maTransition.setOoxTransitionType( aElementToken, rAttribs.getToken( XML_dir, XML_l ), 0 );
106 }
107 return this;
108 case PPT_TOKEN( split ):
109 if (!mbHasTransition)
110 {
111 mbHasTransition = true;
112 maTransition.setOoxTransitionType( aElementToken, rAttribs.getToken( XML_orient, XML_horz ), rAttribs.getToken( XML_dir, XML_out ) );
113 }
114 return this;
115 case PPT_TOKEN( zoom ):
116 if (!mbHasTransition)
117 {
118 mbHasTransition = true;
119 maTransition.setOoxTransitionType( aElementToken, rAttribs.getToken( XML_dir, XML_out ), 0 );
120 }
121 return this;
122 case PPT_TOKEN( wheel ):
123 if (!mbHasTransition)
124 {
125 mbHasTransition = true;
126 maTransition.setOoxTransitionType( aElementToken, rAttribs.getUnsigned( XML_spokes, 4 ), 0 );
127 // unsignedInt
128 }
129 return this;
130 case PPT_TOKEN( circle ):
131 case PPT_TOKEN( diamond ):
132 case PPT_TOKEN( dissolve ):
133 case PPT_TOKEN( newsflash ):
134 case PPT_TOKEN( plus ):
135 case PPT_TOKEN( random ):
136 case PPT_TOKEN( wedge ):
137 case P14_TOKEN( vortex ):
138 case P14_TOKEN( ripple ):
139 case P14_TOKEN( glitter ):
140 case P14_TOKEN( honeycomb ):
141 case P14_TOKEN( flash ):
142 // CT_Empty
143 if (!mbHasTransition)
144 {
145 mbHasTransition = true;
146 maTransition.setOoxTransitionType( aElementToken, 0, 0 );
147 }
148 return this;
149
150 case PPT_TOKEN( sndAc ): // CT_TransitionSoundAction
151 //"Sound"
152 return new SoundActionContext ( *this, maSlideProperties );
153 case PPT_TOKEN( extLst ): // CT_OfficeArtExtensionList
154 return this;
155
156 case P14_TOKEN(prism):
157 if (!mbHasTransition)
158 {
159 mbHasTransition = true;
160 maTransition.setOoxTransitionType(aElementToken, sal_Int32(rAttribs.getBool(XML_isInverted, false)), 0);
161 }
162 return this;
163 case P15_TOKEN(prstTrans):
164 if (!mbHasTransition)
165 {
166 mbHasTransition = true;
168 }
169 return this;
170 case PPT_TOKEN( strips ):
171 if (!mbHasTransition)
172 {
173 mbHasTransition = true;
174 maTransition.setOoxTransitionType( aElementToken, rAttribs.getToken( XML_dir, XML_ld ), 0 );
175 }
176 return this;
177
178
179 default:
180 break;
181 }
182
183 return this;
184}
185
187{
188 if( isCurrentElement(PPT_TOKEN( transition )) )
189 {
191 {
193 mbHasTransition = false;
194 }
195 }
196}
197
198}
199
200/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
PropertiesInfo aProperties
Provides access to attribute values of an element.
OUString getStringDefaulted(sal_Int32 nAttrToken) const
Returns the string value of the specified attribute, returns an empty string if attribute not present...
bool hasAttribute(sal_Int32 nAttrToken) const
Returns true, if the specified attribute is present.
std::optional< sal_uInt32 > getUnsigned(sal_Int32 nAttrToken) const
Returns the 32-bit unsigned integer value of the specified attribute (decimal).
std::optional< sal_Int32 > getInteger(sal_Int32 nAttrToken) const
Returns the 32-bit signed integer value of the specified attribute (decimal).
std::optional< bool > getBool(sal_Int32 nAttrToken) const
Returns the boolean value of the specified attribute.
std::optional< sal_Int32 > getToken(sal_Int32 nAttrToken) const
Returns the token identifier of the value of the specified attribute.
A helper that maps property identifiers to property values.
Definition: propertymap.hxx:52
SlideTransitionContext(::oox::core::FragmentHandler2 const &rParent, const AttributeList &rAttributes, PropertyMap &aProperties)
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 aElementToken, const AttributeList &rAttribs) override
virtual ~SlideTransitionContext() noexcept override
void setPresetTransition(std::u16string_view sPresetTransition)
void setOoxTransitionSpeed(sal_Int32 nToken)
Set one of standard values for slide transition duration.
void setOoxTransitionType(::sal_Int32 OoxType, ::sal_Int32 param1, ::sal_Int32 param2)
void setSlideProperties(PropertyMap &props)
void setOoxAdvanceTime(sal_Int32 nAdvanceTime)
std::vector< OUString > split(std::u16string_view rStr, sal_Unicode cSeparator)