fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / oox / source / drawingml / texteffectscontext.cxx
blobe996e1a1afe85530c0f3b7a94cd50486f2baf411
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 */
11 #include "drawingml/texteffectscontext.hxx"
13 #include <map>
15 namespace oox { namespace drawingml {
17 namespace
20 OUString lclGetNameForElementId(sal_uInt32 aId)
22 static std::map<sal_uInt32, OUString> aIdMap;
23 if(aIdMap.empty())
25 aIdMap[OOX_TOKEN(w14, srgbClr)] = "srgbClr";
26 aIdMap[OOX_TOKEN(w14, schemeClr)] = "schemeClr";
27 aIdMap[OOX_TOKEN(w14, tint)] = "tint";
28 aIdMap[OOX_TOKEN(w14, shade)] = "shade";
29 aIdMap[OOX_TOKEN(w14, alpha)] = "alpha";
30 aIdMap[OOX_TOKEN(w14, hueMod)] = "hueMod";
31 aIdMap[OOX_TOKEN(w14, sat)] = "sat";
32 aIdMap[OOX_TOKEN(w14, satOff)] = "satOff";
33 aIdMap[OOX_TOKEN(w14, satMod)] = "satMod";
34 aIdMap[OOX_TOKEN(w14, lum)] = "lum";
35 aIdMap[OOX_TOKEN(w14, lumOff)] = "lumOff";
36 aIdMap[OOX_TOKEN(w14, lumMod)] = "lumMod";
37 aIdMap[OOX_TOKEN(w14, noFill)] = "noFill";
38 aIdMap[OOX_TOKEN(w14, solidFill)] = "solidFill";
39 aIdMap[OOX_TOKEN(w14, gradFill)] = "gradFill";
40 aIdMap[OOX_TOKEN(w14, gsLst)] = "gsLst";
41 aIdMap[OOX_TOKEN(w14, gs)] = "gs";
42 aIdMap[OOX_TOKEN(w14, pos)] = "pos";
43 aIdMap[OOX_TOKEN(w14, lin)] = "lin";
44 aIdMap[OOX_TOKEN(w14, path)] = "path";
45 aIdMap[OOX_TOKEN(w14, fillToRect)] = "fillToRect";
46 aIdMap[OOX_TOKEN(w14, prstDash)] = "prstDash";
47 aIdMap[OOX_TOKEN(w14, round)] = "round";
48 aIdMap[OOX_TOKEN(w14, bevel)] = "bevel";
49 aIdMap[OOX_TOKEN(w14, miter)] = "miter";
50 aIdMap[OOX_TOKEN(w14, camera)] = "camera";
51 aIdMap[OOX_TOKEN(w14, lightRig)] = "lightRig";
52 aIdMap[OOX_TOKEN(w14, rot)] = "rot";
53 aIdMap[OOX_TOKEN(w14, bevelT)] = "bevelT";
54 aIdMap[OOX_TOKEN(w14, bevelB)] = "bevelB";
55 aIdMap[OOX_TOKEN(w14, extrusionClr)] = "extrusionClr";
56 aIdMap[OOX_TOKEN(w14, contourClr)] = "contourClr";
57 aIdMap[OOX_TOKEN(w14, styleSet)] = "styleSet";
59 aIdMap[OOX_TOKEN(w14, glow)] = "glow";
60 aIdMap[OOX_TOKEN(w14, shadow)] = "shadow";
61 aIdMap[OOX_TOKEN(w14, reflection)] = "reflection";
62 aIdMap[OOX_TOKEN(w14, textOutline)] = "textOutline";
63 aIdMap[OOX_TOKEN(w14, textFill)] = "textFill";
64 aIdMap[OOX_TOKEN(w14, scene3d)] = "scene3d";
65 aIdMap[OOX_TOKEN(w14, props3d)] = "props3d";
66 aIdMap[OOX_TOKEN(w14, ligatures)] = "ligatures";
67 aIdMap[OOX_TOKEN(w14, numForm)] = "numForm";
68 aIdMap[OOX_TOKEN(w14, numSpacing)] = "numSpacing";
69 aIdMap[OOX_TOKEN(w14, stylisticSets)]= "stylisticSets";
70 aIdMap[OOX_TOKEN(w14, cntxtAlts)] = "cntxtAlts";
73 return aIdMap[aId];
76 OUString lclGetGrabBagName(sal_uInt32 aId)
78 static std::map<sal_uInt32, OUString> aGrabBagNameMap;
79 if(aGrabBagNameMap.empty())
81 aGrabBagNameMap[OOX_TOKEN(w14, glow)] = "CharGlowTextEffect";
82 aGrabBagNameMap[OOX_TOKEN(w14, shadow)] = "CharShadowTextEffect";
83 aGrabBagNameMap[OOX_TOKEN(w14, reflection)] = "CharReflectionTextEffect";
84 aGrabBagNameMap[OOX_TOKEN(w14, textOutline)] = "CharTextOutlineTextEffect";
85 aGrabBagNameMap[OOX_TOKEN(w14, textFill)] = "CharTextFillTextEffect";
86 aGrabBagNameMap[OOX_TOKEN(w14, scene3d)] = "CharScene3DTextEffect";
87 aGrabBagNameMap[OOX_TOKEN(w14, props3d)] = "CharProps3DTextEffect";
88 aGrabBagNameMap[OOX_TOKEN(w14, ligatures)] = "CharLigaturesTextEffect";
89 aGrabBagNameMap[OOX_TOKEN(w14, numForm)] = "CharNumFormTextEffect";
90 aGrabBagNameMap[OOX_TOKEN(w14, numSpacing)] = "CharNumSpacingTextEffect";
91 aGrabBagNameMap[OOX_TOKEN(w14, stylisticSets)]= "CharStylisticSetsTextEffect";
92 aGrabBagNameMap[OOX_TOKEN(w14, cntxtAlts)] = "CharCntxtAltsTextEffect";
95 return aGrabBagNameMap[aId];
98 const char constAttributesSequenceName[] = "attributes";
102 using namespace oox::core;
103 using namespace com::sun::star::uno;
104 using namespace com::sun::star::beans;
106 TextEffectsContext::TextEffectsContext(
107 ContextHandler2Helper& rParent,
108 sal_Int32 aElementToken,
109 std::vector<PropertyValue>& rTextEffectsProperties)
110 : ContextHandler2(rParent)
111 , mrTextEffectsProperties(rTextEffectsProperties)
112 , mpGrabBagStack(NULL)
113 , mnCurrentElement(aElementToken)
117 TextEffectsContext::~TextEffectsContext()
121 void TextEffectsContext::pushAttributeToGrabBag (const sal_Int32& aAttributeId, const OUString& rElementName, const AttributeList& rAttribs)
123 if (!rAttribs.hasAttribute(aAttributeId))
124 return;
125 OUString aString = rAttribs.getString(aAttributeId).get();
126 mpGrabBagStack->addString(rElementName, aString);
129 void TextEffectsContext::processAttributes(const AttributeList& rAttribs)
131 mpGrabBagStack->push(constAttributesSequenceName);
132 switch(mnCurrentElement)
134 case OOX_TOKEN(w14, glow):
136 pushAttributeToGrabBag(OOX_TOKEN(w14, rad), "rad", rAttribs);
138 break;
139 case OOX_TOKEN(w14, srgbClr):
140 case OOX_TOKEN(w14, schemeClr):
141 case OOX_TOKEN(w14, tint):
142 case OOX_TOKEN(w14, shade):
143 case OOX_TOKEN(w14, alpha):
144 case OOX_TOKEN(w14, hueMod):
145 case OOX_TOKEN(w14, sat):
146 case OOX_TOKEN(w14, satOff):
147 case OOX_TOKEN(w14, satMod):
148 case OOX_TOKEN(w14, lum):
149 case OOX_TOKEN(w14, lumOff):
150 case OOX_TOKEN(w14, lumMod):
152 pushAttributeToGrabBag(OOX_TOKEN(w14, val), "val", rAttribs);
154 break;
155 case OOX_TOKEN(w14, shadow):
157 pushAttributeToGrabBag(OOX_TOKEN(w14, blurRad), "blurRad", rAttribs);
158 pushAttributeToGrabBag(OOX_TOKEN(w14, dist), "dist", rAttribs);
159 pushAttributeToGrabBag(OOX_TOKEN(w14, dir), "dir", rAttribs);
160 pushAttributeToGrabBag(OOX_TOKEN(w14, sx), "sx", rAttribs);
161 pushAttributeToGrabBag(OOX_TOKEN(w14, sy), "sy", rAttribs);
162 pushAttributeToGrabBag(OOX_TOKEN(w14, kx), "kx", rAttribs);
163 pushAttributeToGrabBag(OOX_TOKEN(w14, ky), "ky", rAttribs);
164 pushAttributeToGrabBag(OOX_TOKEN(w14, algn), "algn", rAttribs);
166 break;
167 case OOX_TOKEN(w14, reflection):
169 pushAttributeToGrabBag(OOX_TOKEN(w14, blurRad), "blurRad", rAttribs);
170 pushAttributeToGrabBag(OOX_TOKEN(w14, stA), "stA", rAttribs);
171 pushAttributeToGrabBag(OOX_TOKEN(w14, stPos), "stPos", rAttribs);
172 pushAttributeToGrabBag(OOX_TOKEN(w14, endA), "endA", rAttribs);
173 pushAttributeToGrabBag(OOX_TOKEN(w14, endPos), "endPos", rAttribs);
174 pushAttributeToGrabBag(OOX_TOKEN(w14, dist), "dist", rAttribs);
175 pushAttributeToGrabBag(OOX_TOKEN(w14, dir), "dir", rAttribs);
176 pushAttributeToGrabBag(OOX_TOKEN(w14, fadeDir), "fadeDir", rAttribs);
177 pushAttributeToGrabBag(OOX_TOKEN(w14, sx), "sx", rAttribs);
178 pushAttributeToGrabBag(OOX_TOKEN(w14, sy), "sy", rAttribs);
179 pushAttributeToGrabBag(OOX_TOKEN(w14, kx), "kx", rAttribs);
180 pushAttributeToGrabBag(OOX_TOKEN(w14, ky), "ky", rAttribs);
181 pushAttributeToGrabBag(OOX_TOKEN(w14, algn), "algn", rAttribs);
183 break;
184 case OOX_TOKEN(w14, textOutline):
186 pushAttributeToGrabBag(OOX_TOKEN(w14, w), "w", rAttribs);
187 pushAttributeToGrabBag(OOX_TOKEN(w14, cap), "cap", rAttribs);
188 pushAttributeToGrabBag(OOX_TOKEN(w14, cmpd), "cmpd", rAttribs);
189 pushAttributeToGrabBag(OOX_TOKEN(w14, algn), "algn", rAttribs);
191 break;
192 case OOX_TOKEN(w14, prstDash):
194 pushAttributeToGrabBag(OOX_TOKEN(w14, val), "val", rAttribs);
196 break;
197 case OOX_TOKEN(w14, gs):
199 pushAttributeToGrabBag(OOX_TOKEN(w14, pos), "pos", rAttribs);
201 break;
202 case OOX_TOKEN(w14, lin):
204 pushAttributeToGrabBag(OOX_TOKEN(w14, ang), "ang", rAttribs);
205 pushAttributeToGrabBag(OOX_TOKEN(w14, scaled), "scaled", rAttribs);
207 break;
208 case OOX_TOKEN(w14, path):
210 pushAttributeToGrabBag(OOX_TOKEN(w14, path), "path", rAttribs);
212 break;
213 case OOX_TOKEN(w14, fillToRect):
215 pushAttributeToGrabBag(OOX_TOKEN(w14, l), "l", rAttribs);
216 pushAttributeToGrabBag(OOX_TOKEN(w14, t), "t", rAttribs);
217 pushAttributeToGrabBag(OOX_TOKEN(w14, r), "r", rAttribs);
218 pushAttributeToGrabBag(OOX_TOKEN(w14, b), "b", rAttribs);
220 break;
221 case OOX_TOKEN(w14, miter):
223 pushAttributeToGrabBag(OOX_TOKEN(w14, lim), "lim", rAttribs);
225 break;
226 case OOX_TOKEN(w14, camera):
228 pushAttributeToGrabBag(OOX_TOKEN(w14, prst), "prst", rAttribs);
230 break;
231 case OOX_TOKEN(w14, lightRig):
233 pushAttributeToGrabBag(OOX_TOKEN(w14, rig), "rig", rAttribs);
234 pushAttributeToGrabBag(OOX_TOKEN(w14, dir), "dir", rAttribs);
236 break;
237 case OOX_TOKEN(w14, rot):
239 pushAttributeToGrabBag(OOX_TOKEN(w14, lat), "lat", rAttribs);
240 pushAttributeToGrabBag(OOX_TOKEN(w14, lon), "lon", rAttribs);
241 pushAttributeToGrabBag(OOX_TOKEN(w14, rev), "rev", rAttribs);
243 break;
244 case OOX_TOKEN(w14, props3d):
246 pushAttributeToGrabBag(OOX_TOKEN(w14, extrusionH), "extrusionH", rAttribs);
247 pushAttributeToGrabBag(OOX_TOKEN(w14, contourW), "contourW", rAttribs);
248 pushAttributeToGrabBag(OOX_TOKEN(w14, prstMaterial), "prstMaterial", rAttribs);
250 break;
251 case OOX_TOKEN(w14, bevelT):
252 case OOX_TOKEN(w14, bevelB):
254 pushAttributeToGrabBag(OOX_TOKEN(w14, w), "w", rAttribs);
255 pushAttributeToGrabBag(OOX_TOKEN(w14, h), "h", rAttribs);
256 pushAttributeToGrabBag(OOX_TOKEN(w14, prst), "prst", rAttribs);
258 break;
259 case OOX_TOKEN(w14, ligatures):
260 case OOX_TOKEN(w14, numForm):
261 case OOX_TOKEN(w14, numSpacing):
263 pushAttributeToGrabBag(OOX_TOKEN(w14, val), "val", rAttribs);
265 break;
266 case OOX_TOKEN(w14, styleSet):
268 pushAttributeToGrabBag(OOX_TOKEN(w14, id), "id", rAttribs);
269 pushAttributeToGrabBag(OOX_TOKEN(w14, val), "val", rAttribs);
271 break;
272 case OOX_TOKEN(w14, cntxtAlts):
274 pushAttributeToGrabBag(OOX_TOKEN(w14, val), "val", rAttribs);
276 break;
277 default:
278 break;
281 mpGrabBagStack->pop();
284 void TextEffectsContext::onStartElement(const oox::AttributeList& rAttribs)
286 if(mpGrabBagStack.get() == NULL)
288 OUString aGrabBagName = lclGetGrabBagName(mnCurrentElement);
289 mpGrabBagStack.reset(new GrabBagStack(aGrabBagName));
292 OUString aElementName = lclGetNameForElementId(mnCurrentElement);
293 mpGrabBagStack->push(aElementName);
294 processAttributes(rAttribs);
297 void TextEffectsContext::onEndElement()
299 mpGrabBagStack->pop();
301 if (mpGrabBagStack->isStackEmpty())
303 Sequence<PropertyValue> aSeq;
304 PropertyValue aPropertyValue = mpGrabBagStack->getRootProperty();
305 aPropertyValue.Value >>= aSeq;
306 aPropertyValue.Value = makeAny(aSeq[0]);
308 mrTextEffectsProperties.push_back(aPropertyValue);
313 ContextHandlerRef TextEffectsContext::onCreateContext(sal_Int32 aElementToken, const AttributeList& /*rAttribs*/)
315 mnCurrentElement = aElementToken;
316 return this;
321 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */