GPU-Calc: remove Alloc_Host_Ptr for clmem of NAN vector
[LibreOffice.git] / oox / source / ppt / pptfilterhelpers.cxx
blobe4f45fbcafa9521240a38de9a57a4dd10905a02b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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
30 static const transition gTransitions[] =
32 { "wipe(up)", ::com::sun::star::animations::TransitionType::BARWIPE, ::com::sun::star::animations::TransitionSubType::TOPTOBOTTOM, sal_True },
33 { "wipe(right)", ::com::sun::star::animations::TransitionType::BARWIPE, ::com::sun::star::animations::TransitionSubType::LEFTTORIGHT, sal_False },
34 { "wipe(left)", ::com::sun::star::animations::TransitionType::BARWIPE, ::com::sun::star::animations::TransitionSubType::LEFTTORIGHT, sal_True },
35 { "wipe(down)", ::com::sun::star::animations::TransitionType::BARWIPE, ::com::sun::star::animations::TransitionSubType::TOPTOBOTTOM, sal_False },
36 { "wheel(1)", ::com::sun::star::animations::TransitionType::PINWHEELWIPE, ::com::sun::star::animations::TransitionSubType::ONEBLADE, sal_True },
37 { "wheel(2)", ::com::sun::star::animations::TransitionType::PINWHEELWIPE, ::com::sun::star::animations::TransitionSubType::TWOBLADEVERTICAL, sal_True },
38 { "wheel(3)", ::com::sun::star::animations::TransitionType::PINWHEELWIPE, ::com::sun::star::animations::TransitionSubType::THREEBLADE, sal_True },
39 { "wheel(4)", ::com::sun::star::animations::TransitionType::PINWHEELWIPE, ::com::sun::star::animations::TransitionSubType::FOURBLADE, sal_True },
40 { "wheel(8)", ::com::sun::star::animations::TransitionType::PINWHEELWIPE, ::com::sun::star::animations::TransitionSubType::EIGHTBLADE, sal_True },
41 { "strips(downLeft)", ::com::sun::star::animations::TransitionType::WATERFALLWIPE, ::com::sun::star::animations::TransitionSubType::HORIZONTALRIGHT, sal_True },
42 { "strips(upLeft)", ::com::sun::star::animations::TransitionType::WATERFALLWIPE, ::com::sun::star::animations::TransitionSubType::HORIZONTALLEFT, sal_False },
43 { "strips(downRight)", ::com::sun::star::animations::TransitionType::WATERFALLWIPE, ::com::sun::star::animations::TransitionSubType::HORIZONTALLEFT, sal_True },
44 { "strips(upRight)", ::com::sun::star::animations::TransitionType::WATERFALLWIPE, ::com::sun::star::animations::TransitionSubType::HORIZONTALRIGHT, sal_False },
45 { "barn(inVertical)", ::com::sun::star::animations::TransitionType::BARNDOORWIPE, ::com::sun::star::animations::TransitionSubType::VERTICAL, sal_False },
46 { "barn(outVertical)", ::com::sun::star::animations::TransitionType::BARNDOORWIPE, ::com::sun::star::animations::TransitionSubType::VERTICAL, sal_True },
47 { "barn(inHorizontal)", ::com::sun::star::animations::TransitionType::BARNDOORWIPE, ::com::sun::star::animations::TransitionSubType::HORIZONTAL, sal_False },
48 { "barn(outHorizontal)", ::com::sun::star::animations::TransitionType::BARNDOORWIPE, ::com::sun::star::animations::TransitionSubType::HORIZONTAL, sal_True },
49 { "randombar(vertical)", ::com::sun::star::animations::TransitionType::RANDOMBARWIPE, ::com::sun::star::animations::TransitionSubType::VERTICAL, sal_True},
50 { "randombar(horizontal)", ::com::sun::star::animations::TransitionType::RANDOMBARWIPE, ::com::sun::star::animations::TransitionSubType::HORIZONTAL, sal_True },
51 { "checkerboard(down)", ::com::sun::star::animations::TransitionType::CHECKERBOARDWIPE, ::com::sun::star::animations::TransitionSubType::DOWN, sal_True},
52 { "checkerboard(across)", ::com::sun::star::animations::TransitionType::CHECKERBOARDWIPE, ::com::sun::star::animations::TransitionSubType::ACROSS, sal_True },
53 { "plus(out)", ::com::sun::star::animations::TransitionType::FOURBOXWIPE, ::com::sun::star::animations::TransitionSubType::CORNERSIN, sal_False },
54 { "plus(in)", ::com::sun::star::animations::TransitionType::FOURBOXWIPE, ::com::sun::star::animations::TransitionSubType::CORNERSIN, sal_True },
55 { "diamond(out)", ::com::sun::star::animations::TransitionType::IRISWIPE, ::com::sun::star::animations::TransitionSubType::DIAMOND, sal_True },
56 { "diamond(in)", ::com::sun::star::animations::TransitionType::IRISWIPE, ::com::sun::star::animations::TransitionSubType::DIAMOND, sal_False },
57 { "circle(out)", ::com::sun::star::animations::TransitionType::ELLIPSEWIPE, ::com::sun::star::animations::TransitionSubType::HORIZONTAL, sal_True },
58 { "circle(in)", ::com::sun::star::animations::TransitionType::ELLIPSEWIPE, ::com::sun::star::animations::TransitionSubType::HORIZONTAL, sal_False },
59 { "box(out)", ::com::sun::star::animations::TransitionType::IRISWIPE, ::com::sun::star::animations::TransitionSubType::RECTANGLE, sal_True },
60 { "box(in)", ::com::sun::star::animations::TransitionType::IRISWIPE, ::com::sun::star::animations::TransitionSubType::RECTANGLE, sal_False },
61 { "wedge", ::com::sun::star::animations::TransitionType::FANWIPE, ::com::sun::star::animations::TransitionSubType::CENTERTOP, sal_True },
62 { "blinds(vertical)", ::com::sun::star::animations::TransitionType::BLINDSWIPE, ::com::sun::star::animations::TransitionSubType::VERTICAL, sal_True },
63 { "blinds(horizontal)", ::com::sun::star::animations::TransitionType::BLINDSWIPE, ::com::sun::star::animations::TransitionSubType::HORIZONTAL, sal_True },
64 { "fade", ::com::sun::star::animations::TransitionType::FADE, ::com::sun::star::animations::TransitionSubType::CROSSFADE, sal_True },
65 { "slide(fromTop)", ::com::sun::star::animations::TransitionType::SLIDEWIPE, ::com::sun::star::animations::TransitionSubType::FROMTOP, sal_True },
66 { "slide(fromRight)", ::com::sun::star::animations::TransitionType::SLIDEWIPE, ::com::sun::star::animations::TransitionSubType::FROMRIGHT, sal_True },
67 { "slide(fromLeft)", ::com::sun::star::animations::TransitionType::SLIDEWIPE, ::com::sun::star::animations::TransitionSubType::FROMLEFT, sal_True },
68 { "slide(fromBottom)", ::com::sun::star::animations::TransitionType::SLIDEWIPE, ::com::sun::star::animations::TransitionSubType::FROMBOTTOM, sal_True },
69 { "dissolve", ::com::sun::star::animations::TransitionType::DISSOLVE, ::com::sun::star::animations::TransitionSubType::DEFAULT, sal_True },
70 { "image", ::com::sun::star::animations::TransitionType::DISSOLVE, ::com::sun::star::animations::TransitionSubType::DEFAULT, sal_True }, // TODO
71 { NULL, 0, 0, sal_False }
74 const transition* transition::find( const OUString& rName )
76 const transition* p = gTransitions;
78 while( p->mpName )
80 if( rName.equalsAscii( p->mpName ) )
81 return p;
83 p++;
86 return NULL;
90 bool convertMeasure( OUString& rString )
92 bool bRet = false;
94 /* here we want to substitute all occurance of
95 * [#]ppt_[xyhw] with
96 * x,y,height and width respectively
98 sal_Int32 nIndex = 0;
99 sal_Int32 nLastIndex = 0;
101 nIndex = rString.indexOf("ppt_");
102 // bail out early if there is no substitution to be made
103 if(nIndex >= 0)
105 OUStringBuffer sRes(rString.getLength());
109 // copy the non matching inverval verbatim
110 if(nIndex > nLastIndex)
112 sRes.append(rString.getStr() + nLastIndex, (nIndex - nLastIndex));
114 // we are searching for ppt_[xywh] so we need and extra char behind the match
115 if(nIndex + 4 < rString.getLength())
117 switch(rString[nIndex + 4])
119 case (sal_Unicode)'h': // we found ppt_h
120 // if it was #ppt_h we already copied the #
121 // which we do not want in the target, so remove it
122 if(nIndex && (rString[nIndex - 1] == (sal_Unicode)'#'))
124 sRes.remove(sRes.getLength() - 1, 1);
126 sRes.append("height");
127 bRet = true;
128 break;
129 case (sal_Unicode)'w':
130 if(nIndex && (rString[nIndex - 1] == (sal_Unicode)'#'))
132 sRes.remove(sRes.getLength() - 1, 1);
134 sRes.append("width");
135 bRet = true;
136 break;
137 case (sal_Unicode)'x':
138 if(nIndex && (rString[nIndex - 1] == (sal_Unicode)'#'))
140 sRes[sRes.getLength() - 1] = (sal_Unicode)'x';
142 else
144 sRes.append((sal_Unicode)'x');
146 bRet = true;
147 break;
148 case (sal_Unicode)'y':
149 if(nIndex && (rString[nIndex - 1] == (sal_Unicode)'#'))
151 sRes[sRes.getLength() - 1] = (sal_Unicode)'y';
153 else
155 sRes.append((sal_Unicode)'y');
157 bRet = true;
158 break;
159 default:
160 // this was ppt_ without an interesting thing after that
161 // just copy it verbatim
162 sRes.append("ppt_");
163 // we are going to ajust for ppt_@ after the swtich
164 // so compensate for the fact we did not really process
165 // an extra character after ppt_
166 nIndex -= 1;
167 break;
170 else
172 sRes.append("ppt_");
173 nIndex += 4;
174 nLastIndex = nIndex;
175 break;
177 nIndex += 5;
178 nLastIndex = nIndex;
180 while((nIndex = rString.indexOf("ppt_", nIndex)) > 0);
181 // copy the non matching tail if any
182 if(nLastIndex < rString.getLength())
184 sRes.append(rString.getStr() + nLastIndex, rString.getLength() - nLastIndex );
186 rString = sRes.makeStringAndClear();
188 return bRet;
194 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */