1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <com/sun/star/animations/TransitionType.hpp>
21 #include <com/sun/star/animations/TransitionSubType.hpp>
22 #include <rtl/ustrbuf.hxx>
23 #include "pptfilterhelpers.hxx"
25 namespace oox
{ namespace ppt
{
27 // BEGIN CUT&PASTE from sd pptanimations.hxx
29 static const transition gTransitions
[] =
31 { "wipe(up)", ::com::sun::star::animations::TransitionType::BARWIPE
, ::com::sun::star::animations::TransitionSubType::TOPTOBOTTOM
, true },
32 { "wipe(right)", ::com::sun::star::animations::TransitionType::BARWIPE
, ::com::sun::star::animations::TransitionSubType::LEFTTORIGHT
, false },
33 { "wipe(left)", ::com::sun::star::animations::TransitionType::BARWIPE
, ::com::sun::star::animations::TransitionSubType::LEFTTORIGHT
, true },
34 { "wipe(down)", ::com::sun::star::animations::TransitionType::BARWIPE
, ::com::sun::star::animations::TransitionSubType::TOPTOBOTTOM
, false },
35 { "wheel(1)", ::com::sun::star::animations::TransitionType::PINWHEELWIPE
, ::com::sun::star::animations::TransitionSubType::ONEBLADE
, true },
36 { "wheel(2)", ::com::sun::star::animations::TransitionType::PINWHEELWIPE
, ::com::sun::star::animations::TransitionSubType::TWOBLADEVERTICAL
, true },
37 { "wheel(3)", ::com::sun::star::animations::TransitionType::PINWHEELWIPE
, ::com::sun::star::animations::TransitionSubType::THREEBLADE
, true },
38 { "wheel(4)", ::com::sun::star::animations::TransitionType::PINWHEELWIPE
, ::com::sun::star::animations::TransitionSubType::FOURBLADE
, true },
39 { "wheel(8)", ::com::sun::star::animations::TransitionType::PINWHEELWIPE
, ::com::sun::star::animations::TransitionSubType::EIGHTBLADE
, true },
40 { "strips(downLeft)", ::com::sun::star::animations::TransitionType::WATERFALLWIPE
, ::com::sun::star::animations::TransitionSubType::HORIZONTALRIGHT
, true },
41 { "strips(upLeft)", ::com::sun::star::animations::TransitionType::WATERFALLWIPE
, ::com::sun::star::animations::TransitionSubType::HORIZONTALLEFT
, false },
42 { "strips(downRight)", ::com::sun::star::animations::TransitionType::WATERFALLWIPE
, ::com::sun::star::animations::TransitionSubType::HORIZONTALLEFT
, true },
43 { "strips(upRight)", ::com::sun::star::animations::TransitionType::WATERFALLWIPE
, ::com::sun::star::animations::TransitionSubType::HORIZONTALRIGHT
, false },
44 { "barn(inVertical)", ::com::sun::star::animations::TransitionType::BARNDOORWIPE
, ::com::sun::star::animations::TransitionSubType::VERTICAL
, false },
45 { "barn(outVertical)", ::com::sun::star::animations::TransitionType::BARNDOORWIPE
, ::com::sun::star::animations::TransitionSubType::VERTICAL
, true },
46 { "barn(inHorizontal)", ::com::sun::star::animations::TransitionType::BARNDOORWIPE
, ::com::sun::star::animations::TransitionSubType::HORIZONTAL
, false },
47 { "barn(outHorizontal)", ::com::sun::star::animations::TransitionType::BARNDOORWIPE
, ::com::sun::star::animations::TransitionSubType::HORIZONTAL
, true },
48 { "randombar(vertical)", ::com::sun::star::animations::TransitionType::RANDOMBARWIPE
, ::com::sun::star::animations::TransitionSubType::VERTICAL
, true},
49 { "randombar(horizontal)", ::com::sun::star::animations::TransitionType::RANDOMBARWIPE
, ::com::sun::star::animations::TransitionSubType::HORIZONTAL
, true },
50 { "checkerboard(down)", ::com::sun::star::animations::TransitionType::CHECKERBOARDWIPE
, ::com::sun::star::animations::TransitionSubType::DOWN
, true},
51 { "checkerboard(across)", ::com::sun::star::animations::TransitionType::CHECKERBOARDWIPE
, ::com::sun::star::animations::TransitionSubType::ACROSS
, true },
52 { "plus(out)", ::com::sun::star::animations::TransitionType::FOURBOXWIPE
, ::com::sun::star::animations::TransitionSubType::CORNERSIN
, false },
53 { "plus(in)", ::com::sun::star::animations::TransitionType::FOURBOXWIPE
, ::com::sun::star::animations::TransitionSubType::CORNERSIN
, true },
54 { "diamond(out)", ::com::sun::star::animations::TransitionType::IRISWIPE
, ::com::sun::star::animations::TransitionSubType::DIAMOND
, true },
55 { "diamond(in)", ::com::sun::star::animations::TransitionType::IRISWIPE
, ::com::sun::star::animations::TransitionSubType::DIAMOND
, false },
56 { "circle(out)", ::com::sun::star::animations::TransitionType::ELLIPSEWIPE
, ::com::sun::star::animations::TransitionSubType::HORIZONTAL
, true },
57 { "circle(in)", ::com::sun::star::animations::TransitionType::ELLIPSEWIPE
, ::com::sun::star::animations::TransitionSubType::HORIZONTAL
, false },
58 { "box(out)", ::com::sun::star::animations::TransitionType::IRISWIPE
, ::com::sun::star::animations::TransitionSubType::RECTANGLE
, true },
59 { "box(in)", ::com::sun::star::animations::TransitionType::IRISWIPE
, ::com::sun::star::animations::TransitionSubType::RECTANGLE
, false },
60 { "wedge", ::com::sun::star::animations::TransitionType::FANWIPE
, ::com::sun::star::animations::TransitionSubType::CENTERTOP
, true },
61 { "blinds(vertical)", ::com::sun::star::animations::TransitionType::BLINDSWIPE
, ::com::sun::star::animations::TransitionSubType::VERTICAL
, true },
62 { "blinds(horizontal)", ::com::sun::star::animations::TransitionType::BLINDSWIPE
, ::com::sun::star::animations::TransitionSubType::HORIZONTAL
, true },
63 { "fade", ::com::sun::star::animations::TransitionType::FADE
, ::com::sun::star::animations::TransitionSubType::CROSSFADE
, true },
64 { "slide(fromTop)", ::com::sun::star::animations::TransitionType::SLIDEWIPE
, ::com::sun::star::animations::TransitionSubType::FROMTOP
, true },
65 { "slide(fromRight)", ::com::sun::star::animations::TransitionType::SLIDEWIPE
, ::com::sun::star::animations::TransitionSubType::FROMRIGHT
, true },
66 { "slide(fromLeft)", ::com::sun::star::animations::TransitionType::SLIDEWIPE
, ::com::sun::star::animations::TransitionSubType::FROMLEFT
, true },
67 { "slide(fromBottom)", ::com::sun::star::animations::TransitionType::SLIDEWIPE
, ::com::sun::star::animations::TransitionSubType::FROMBOTTOM
, true },
68 { "dissolve", ::com::sun::star::animations::TransitionType::DISSOLVE
, ::com::sun::star::animations::TransitionSubType::DEFAULT
, true },
69 { "image", ::com::sun::star::animations::TransitionType::DISSOLVE
, ::com::sun::star::animations::TransitionSubType::DEFAULT
, true }, // TODO
73 const transition
* transition::find( const OUString
& rName
)
75 const transition
* p
= gTransitions
;
79 if( rName
.equalsAscii( p
->mpName
) )
88 bool convertMeasure( OUString
& rString
)
92 /* here we want to substitute all occurrences of
94 * x,y,height and width respectively
97 sal_Int32 nLastIndex
= 0;
99 nIndex
= rString
.indexOf("ppt_");
100 // bail out early if there is no substitution to be made
103 OUStringBuffer
sRes(rString
.getLength());
107 // copy the non matching inverval verbatim
108 if(nIndex
> nLastIndex
)
110 sRes
.append(rString
.getStr() + nLastIndex
, (nIndex
- nLastIndex
));
112 // we are searching for ppt_[xywh] so we need and extra char behind the match
113 if(nIndex
+ 4 < rString
.getLength())
115 switch(rString
[nIndex
+ 4])
117 case (sal_Unicode
)'h': // we found ppt_h
118 // if it was #ppt_h we already copied the #
119 // which we do not want in the target, so remove it
120 if(nIndex
&& (rString
[nIndex
- 1] == (sal_Unicode
)'#'))
122 sRes
.remove(sRes
.getLength() - 1, 1);
124 sRes
.append("height");
127 case (sal_Unicode
)'w':
128 if(nIndex
&& (rString
[nIndex
- 1] == (sal_Unicode
)'#'))
130 sRes
.remove(sRes
.getLength() - 1, 1);
132 sRes
.append("width");
135 case (sal_Unicode
)'x':
136 if(nIndex
&& (rString
[nIndex
- 1] == (sal_Unicode
)'#'))
138 sRes
[sRes
.getLength() - 1] = (sal_Unicode
)'x';
146 case (sal_Unicode
)'y':
147 if(nIndex
&& (rString
[nIndex
- 1] == (sal_Unicode
)'#'))
149 sRes
[sRes
.getLength() - 1] = (sal_Unicode
)'y';
158 // this was ppt_ without an interesting thing after that
159 // just copy it verbatim
161 // we are going to adjust for ppt_@ after the swtich
162 // so compensate for the fact we did not really process
163 // an extra character after ppt_
178 while((nIndex
= rString
.indexOf("ppt_", nIndex
)) > 0);
179 // copy the non matching tail if any
180 if(nLastIndex
< rString
.getLength())
182 sRes
.append(rString
.getStr() + nLastIndex
, rString
.getLength() - nLastIndex
);
184 rString
= sRes
.makeStringAndClear();
191 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */