update dev300-m58
[ooovba.git] / oox / source / drawingml / customshapegeometry.cxx
blobc79ba1988feae6a4344a8812c03a50d83e4b3507
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: customshapegeometry.cxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "oox/drawingml/customshapegeometry.hxx"
33 #include <com/sun/star/xml/sax/FastToken.hpp>
34 #include <comphelper/stl_types.hxx>
35 #include <hash_map>
37 #include "oox/helper/helper.hxx"
38 #include "oox/helper/propertymap.hxx"
39 #include "oox/core/namespaces.hxx"
40 #include "tokens.hxx"
42 using ::rtl::OUString;
43 using namespace ::oox::core;
44 using namespace ::com::sun::star::uno;
45 using namespace ::com::sun::star::xml::sax;
47 namespace oox { namespace drawingml {
49 enum FormularCommand
51 FC_MULDIV = 0,
52 FC_PLUSMINUS,
53 FC_PLUSDIV,
54 FC_IFELSE,
55 FC_ABS,
56 FC_AT2,
57 FC_CAT2,
58 FC_COS,
59 FC_MAX,
60 FC_MIN,
61 FC_MOD,
62 FC_PIN,
63 FC_SAT2,
64 FC_SIN,
65 FC_SQRT,
66 FC_TAN,
67 FC_VAL,
68 FC_LAST
70 struct FormularCommandNameTable
72 const char* pS;
73 FormularCommand pE;
75 static FormularCommandNameTable pFormularCommandNameTable[] =
77 { "*/", FC_MULDIV },
78 { "+-", FC_PLUSMINUS },
79 { "+/", FC_PLUSDIV },
80 { "ifelse", FC_IFELSE },
81 { "abs", FC_ABS },
82 { "at2", FC_AT2 },
83 { "cat2", FC_CAT2 },
84 { "cos", FC_COS },
85 { "max", FC_MAX },
86 { "min", FC_MIN },
87 { "mod", FC_MOD },
88 { "pin", FC_PIN },
89 { "sat2", FC_SAT2 },
90 { "sin", FC_SIN },
91 { "sqrt", FC_SQRT },
92 { "tan", FC_TAN },
93 { "val", FC_VAL }
96 typedef std::hash_map< rtl::OUString, FormularCommand, comphelper::UStringHash, comphelper::UStringEqual > FormulaCommandHMap;
98 static const FormulaCommandHMap* pCommandHashMap;
100 // ---------------------------------------------------------------------
101 // CT_GeomGuideList
102 class AdjustmentValueContext : public ContextHandler
104 public:
105 AdjustmentValueContext( ContextHandler& rParent, CustomShapeProperties& rCustomShapeProperties );
106 virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
108 protected:
109 CustomShapeProperties& mrCustomShapeProperties;
112 AdjustmentValueContext::AdjustmentValueContext( ContextHandler& rParent, CustomShapeProperties& rCustomShapeProperties )
113 : ContextHandler( rParent )
114 , mrCustomShapeProperties( rCustomShapeProperties )
118 static rtl::OUString convertToOOEquation( const rtl::OUString& rSource )
120 if ( !pCommandHashMap )
122 FormulaCommandHMap* pHM = new FormulaCommandHMap();
123 for( sal_Int32 i = 0; i < FC_LAST; i++ )
124 (*pHM)[ OUString::createFromAscii( pFormularCommandNameTable[ i ].pS ) ] = pFormularCommandNameTable[ i ].pE;
125 pCommandHashMap = pHM;
128 std::vector< rtl::OUString > aTokens;
129 sal_Int32 nIndex = 0;
132 rtl::OUString aToken( rSource.getToken( 0, ' ', nIndex ) );
133 if ( aToken.getLength() )
134 aTokens.push_back( aToken );
136 while ( nIndex >= 0 );
138 rtl::OUString aEquation;
139 if ( aTokens.size() )
141 const FormulaCommandHMap::const_iterator aIter( pCommandHashMap->find( aTokens[ 0 ] ) );
142 if ( aIter != pCommandHashMap->end() )
144 switch( aIter->second )
146 case FC_MULDIV :
147 case FC_PLUSMINUS :
148 case FC_PLUSDIV :
149 case FC_IFELSE :
150 case FC_ABS :
151 case FC_AT2 :
152 case FC_CAT2 :
153 case FC_COS :
154 case FC_MAX :
155 case FC_MIN :
156 case FC_MOD :
157 case FC_PIN :
158 case FC_SAT2 :
159 case FC_SIN :
160 case FC_SQRT :
161 case FC_TAN :
162 case FC_VAL :
163 default :
164 break;
168 return aEquation;
171 Reference< XFastContextHandler > AdjustmentValueContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
173 if ( aElementToken == ( NMSP_DRAWINGML | XML_gd ) ) // CT_GeomGuide
175 CustomShapeGuide aGuide;
176 aGuide.maName = xAttribs->getOptionalValue( XML_name );
177 aGuide.maFormula = convertToOOEquation( xAttribs->getOptionalValue( XML_fmla ) );
178 std::vector< CustomShapeGuide >& rAdjustmentValues( mrCustomShapeProperties.getAdjustmentValues() );
179 rAdjustmentValues.push_back( aGuide );
181 return this;
184 // ---------------------------------------------------------------------
186 OUString GetShapeType( sal_Int32 nType )
188 OUString sType;
189 switch( nType )
191 case XML_lineInv: // TODO
192 case XML_line: {
193 static const OUString sLine = CREATE_OUSTRING( "mso-spt20" );
194 sType = sLine;
195 } break;
196 case XML_triangle: {
197 static const OUString sTriangle = CREATE_OUSTRING( "isosceles-triangle" );
198 sType = sTriangle;
199 } break;
200 case XML_rtTriangle: {
201 static const OUString sRtTriangle = CREATE_OUSTRING( "right-triangle" );
202 sType = sRtTriangle;
203 } break;
204 case XML_rect: {
205 static const OUString sRectangle = CREATE_OUSTRING( "rectangle" );
206 sType = sRectangle;
207 } break;
208 case XML_diamond: {
209 static const OUString sDiamond = CREATE_OUSTRING( "diamond" );
210 sType = sDiamond;
211 } break;
212 case XML_parallelogram: {
213 static const OUString sParallelogram = CREATE_OUSTRING( "parallelogram" );
214 sType = sParallelogram;
215 } break;
216 case XML_nonIsoscelesTrapezoid: // TODO
217 case XML_trapezoid: {
218 static const OUString sTrapezoid = CREATE_OUSTRING( "trapezoid" );
219 sType = sTrapezoid;
220 } break;
221 case XML_pentagon: {
222 static const OUString sPentagon = CREATE_OUSTRING( "pentagon" );
223 sType = sPentagon;
224 } break;
225 case XML_heptagon: // TODO
226 case XML_hexagon: {
227 static const OUString sHexagon = CREATE_OUSTRING( "hexagon" );
228 sType = sHexagon;
229 } break;
230 case XML_decagon: // TODO
231 case XML_dodecagon: // TODO
232 case XML_octagon: {
233 static const OUString sOctagon = CREATE_OUSTRING( "octagon" );
234 sType = sOctagon;
235 } break;
236 case XML_star4: {
237 static const OUString sStar4 = CREATE_OUSTRING( "star4" );
238 sType = sStar4;
239 } break;
240 case XML_star6: // TODO
241 case XML_star7: // TODO
242 case XML_star5: {
243 static const OUString sStar5 = CREATE_OUSTRING( "star5" );
244 sType = sStar5;
245 } break;
246 case XML_star10: // TODO
247 case XML_star12: // TODO
248 case XML_star16: // TODO
249 case XML_star8: {
250 static const OUString sStar8 = CREATE_OUSTRING( "star8" );
251 sType = sStar8;
252 } break;
253 case XML_star32: // TODO
254 case XML_star24: {
255 static const OUString sStar24 = CREATE_OUSTRING( "star24" );
256 sType = sStar24;
257 } break;
258 case XML_round1Rect: // TODO
259 case XML_round2SameRect: // TODO
260 case XML_round2DiagRect: // TODO
261 case XML_snipRoundRect: // TODO
262 case XML_snip1Rect: // TODO
263 case XML_snip2SameRect: // TODO
264 case XML_snip2DiagRect: // TODO
265 case XML_roundRect: {
266 static const OUString sRoundRect = CREATE_OUSTRING( "round-rectangle" );
267 sType = sRoundRect;
268 } break;
269 case XML_plaque: {
270 static const OUString sPlaque = CREATE_OUSTRING( "mso-spt21" );
271 sType = sPlaque;
272 } break;
273 case XML_teardrop: // TODO
274 case XML_ellipse: {
275 static const OUString sEllipse = CREATE_OUSTRING( "ellipse" );
276 sType = sEllipse;
277 } break;
278 case XML_homePlate: {
279 static const OUString sHomePlate = CREATE_OUSTRING( "pentagon-right" );
280 sType = sHomePlate;
281 } break;
282 case XML_chevron: {
283 static const OUString sChevron = CREATE_OUSTRING( "chevron" );
284 sType = sChevron;
285 } break;
286 case XML_pieWedge: // TODO
287 case XML_pie: // TODO
288 case XML_blockArc: {
289 static const OUString sBlockArc = CREATE_OUSTRING( "block-arc" );
290 sType = sBlockArc;
291 } break;
292 case XML_donut: {
293 static const OUString sDonut = CREATE_OUSTRING( "ring" );
294 sType = sDonut;
295 } break;
296 case XML_noSmoking: {
297 static const OUString sNoSmoking = CREATE_OUSTRING( "forbidden" );
298 sType = sNoSmoking;
299 } break;
300 case XML_rightArrow: {
301 static const OUString sRightArrow = CREATE_OUSTRING( "right-arrow" );
302 sType = sRightArrow;
303 } break;
304 case XML_leftArrow: {
305 static const OUString sLeftArrow = CREATE_OUSTRING( "left-arrow" );
306 sType = sLeftArrow;
307 } break;
308 case XML_upArrow: {
309 static const OUString sUpArrow = CREATE_OUSTRING( "up-arrow" );
310 sType = sUpArrow;
311 } break;
312 case XML_downArrow: {
313 static const OUString sDownArrow = CREATE_OUSTRING( "down-arrow" );
314 sType = sDownArrow;
315 } break;
316 case XML_stripedRightArrow: {
317 static const OUString sStripedRightArrow = CREATE_OUSTRING( "striped-right-arrow" );
318 sType = sStripedRightArrow;
319 } break;
320 case XML_notchedRightArrow: {
321 static const OUString sNotchedRightArrow = CREATE_OUSTRING( "notched-right-arrow" );
322 sType = sNotchedRightArrow;
323 } break;
324 case XML_bentUpArrow: {
325 static const OUString sBentUpArrow = CREATE_OUSTRING( "mso-spt90" );
326 sType = sBentUpArrow;
327 } break;
328 case XML_leftRightArrow: {
329 static const OUString sLeftRightArrow = CREATE_OUSTRING( "left-right-arrow" );
330 sType = sLeftRightArrow;
331 } break;
332 case XML_upDownArrow: {
333 static const OUString sUpDownArrow = CREATE_OUSTRING( "up-down-arrow" );
334 sType = sUpDownArrow;
335 } break;
336 case XML_leftUpArrow: {
337 static const OUString sLeftUpArrow = CREATE_OUSTRING( "mso-spt89" );
338 sType = sLeftUpArrow;
339 } break;
340 case XML_leftRightUpArrow: {
341 static const OUString sLeftRightUpArrow = CREATE_OUSTRING( "mso-spt182" );
342 sType = sLeftRightUpArrow;
343 } break;
344 case XML_quadArrow: {
345 static const OUString sQuadArrow = CREATE_OUSTRING( "quad-arrow" );
346 sType = sQuadArrow;
347 } break;
348 case XML_leftArrowCallout: {
349 static const OUString sLeftArrowCallout = CREATE_OUSTRING( "left-arrow-callout" );
350 sType = sLeftArrowCallout;
351 } break;
352 case XML_rightArrowCallout: {
353 static const OUString sRightArrowCallout = CREATE_OUSTRING( "right-arrow-callout" );
354 sType = sRightArrowCallout;
355 } break;
356 case XML_upArrowCallout: {
357 static const OUString sUpArrowCallout = CREATE_OUSTRING( "up-arrow-callout" );
358 sType = sUpArrowCallout;
359 } break;
360 case XML_downArrowCallout: {
361 static const OUString sDownArrowCallout = CREATE_OUSTRING( "down-arrow-callout" );
362 sType = sDownArrowCallout;
363 } break;
364 case XML_leftRightArrowCallout: {
365 static const OUString sLeftRightArrowCallout = CREATE_OUSTRING( "left-right-arrow-callout" );
366 sType = sLeftRightArrowCallout;
367 } break;
368 case XML_upDownArrowCallout: {
369 static const OUString sUpDownArrowCallout = CREATE_OUSTRING( "up-down-arrow-callout" );
370 sType = sUpDownArrowCallout;
371 } break;
372 case XML_quadArrowCallout: {
373 static const OUString sQuadArrowCallout = CREATE_OUSTRING( "quad-arrow-callout" );
374 sType = sQuadArrowCallout;
375 } break;
376 case XML_bentArrow: {
377 static const OUString sBentArrow = CREATE_OUSTRING( "mso-spt91" );
378 sType = sBentArrow;
379 } break;
380 case XML_uturnArrow: {
381 static const OUString sUTurnArrow = CREATE_OUSTRING( "mso-spt101" );
382 sType = sUTurnArrow;
383 } break;
384 case XML_leftCircularArrow: // TODO
385 case XML_leftRightCircularArrow: // TODO
386 case XML_circularArrow: {
387 static const OUString sCircularArrow = CREATE_OUSTRING( "circular-arrow" );
388 sType = sCircularArrow;
389 } break;
390 case XML_curvedRightArrow: {
391 static const OUString sCurvedRightArrow = CREATE_OUSTRING( "mso-spt102" );
392 sType = sCurvedRightArrow;
393 } break;
394 case XML_curvedLeftArrow: {
395 static const OUString sCurvedLeftArrow = CREATE_OUSTRING( "mso-spt103" );
396 sType = sCurvedLeftArrow;
397 } break;
398 case XML_curvedUpArrow: {
399 static const OUString sCurvedUpArrow = CREATE_OUSTRING( "mso-spt104" );
400 sType = sCurvedUpArrow;
401 } break;
402 case XML_swooshArrow: // TODO
403 case XML_curvedDownArrow: {
404 static const OUString sCurvedDownArrow = CREATE_OUSTRING( "mso-spt105" );
405 sType = sCurvedDownArrow;
406 } break;
407 case XML_cube: {
408 static const OUString sCube = CREATE_OUSTRING( "cube" );
409 sType = sCube;
410 } break;
411 case XML_can: {
412 static const OUString sCan = CREATE_OUSTRING( "can" );
413 sType = sCan;
414 } break;
415 case XML_lightningBolt: {
416 static const OUString sLightningBolt = CREATE_OUSTRING( "lightning" );
417 sType = sLightningBolt;
418 } break;
419 case XML_heart: {
420 static const OUString sHeart = CREATE_OUSTRING( "heart" );
421 sType = sHeart;
422 } break;
423 case XML_sun: {
424 static const OUString sSun = CREATE_OUSTRING( "sun" );
425 sType = sSun;
426 } break;
427 case XML_moon: {
428 static const OUString sMoon = CREATE_OUSTRING( "moon" );
429 sType = sMoon;
430 } break;
431 case XML_smileyFace: {
432 static const OUString sSmileyFace = CREATE_OUSTRING( "smiley" );
433 sType = sSmileyFace;
434 } break;
435 case XML_irregularSeal1: {
436 static const OUString sIrregularSeal1 = CREATE_OUSTRING( "mso-spt71" );
437 sType = sIrregularSeal1;
438 } break;
439 case XML_irregularSeal2: {
440 static const OUString sIrregularSeal2 = CREATE_OUSTRING( "bang" );
441 sType = sIrregularSeal2;
442 } break;
443 case XML_foldedCorner: {
444 static const OUString sFoldedCorner = CREATE_OUSTRING( "paper" );
445 sType = sFoldedCorner;
446 } break;
447 case XML_bevel: {
448 static const OUString sBevel = CREATE_OUSTRING( "quad-bevel" );
449 sType = sBevel;
450 } break;
451 case XML_halfFrame: // TODO
452 case XML_corner: // TODO
453 case XML_diagStripe: // TODO
454 case XML_chord: // TODO
455 case XML_frame: {
456 static const OUString sFrame = CREATE_OUSTRING( "mso-spt75" );
457 sType = sFrame;
458 } break;
459 case XML_arc: {
460 static const OUString sArc = CREATE_OUSTRING( "mso-spt19" );
461 sType = sArc;
462 } break;
463 case XML_leftBracket: {
464 static const OUString sLeftBracket = CREATE_OUSTRING( "left-bracket" );
465 sType = sLeftBracket;
466 } break;
467 case XML_rightBracket: {
468 static const OUString sRightBracket = CREATE_OUSTRING( "right-bracket" );
469 sType = sRightBracket;
470 } break;
471 case XML_leftBrace: {
472 static const OUString sLeftBrace = CREATE_OUSTRING( "left-brace" );
473 sType = sLeftBrace;
474 } break;
475 case XML_rightBrace: {
476 static const OUString sRightBrace = CREATE_OUSTRING( "right-brace" );
477 sType = sRightBrace;
478 } break;
479 case XML_bracketPair: {
480 static const OUString sBracketPair = CREATE_OUSTRING( "bracket-pair" );
481 sType = sBracketPair;
482 } break;
483 case XML_bracePair: {
484 static const OUString sBracePair = CREATE_OUSTRING( "brace-pair" );
485 sType = sBracePair;
486 } break;
487 case XML_straightConnector1: {
488 static const OUString sStraightConnector1 = CREATE_OUSTRING( "mso-spt32" );
489 sType = sStraightConnector1;
490 } break;
491 case XML_bentConnector2: {
492 static const OUString sBentConnector2 = CREATE_OUSTRING( "mso-spt33" );
493 sType = sBentConnector2;
494 } break;
495 case XML_bentConnector3: {
496 static const OUString sBentConnector3 = CREATE_OUSTRING( "mso-spt34" );
497 sType = sBentConnector3;
498 } break;
499 case XML_bentConnector4: {
500 static const OUString sBentConnector4 = CREATE_OUSTRING( "mso-spt35" );
501 sType = sBentConnector4;
502 } break;
503 case XML_bentConnector5: {
504 static const OUString sBentConnector5 = CREATE_OUSTRING( "mso-spt36" );
505 sType = sBentConnector5;
506 } break;
507 case XML_curvedConnector2: {
508 static const OUString sCurvedConnector2 = CREATE_OUSTRING( "mso-spt37" );
509 sType = sCurvedConnector2;
510 } break;
511 case XML_curvedConnector3: {
512 static const OUString sCurvedConnector3 = CREATE_OUSTRING( "mso-spt38" );
513 sType = sCurvedConnector3;
514 } break;
515 case XML_curvedConnector4: {
516 static const OUString sCurvedConnector4 = CREATE_OUSTRING( "mso-spt39" );
517 sType = sCurvedConnector4;
518 } break;
519 case XML_curvedConnector5: {
520 static const OUString sCurvedConnector5 = CREATE_OUSTRING( "mso-spt40" );
521 sType = sCurvedConnector5;
522 } break;
523 case XML_callout1: {
524 static const OUString sCallout1 = CREATE_OUSTRING( "mso-spt41" );
525 sType = sCallout1;
526 } break;
527 case XML_callout2: {
528 static const OUString sCallout2 = CREATE_OUSTRING( "mso-spt42" );
529 sType = sCallout2;
530 } break;
531 case XML_callout3: {
532 static const OUString sCallout3 = CREATE_OUSTRING( "mso-spt43" );
533 sType = sCallout3;
534 } break;
535 case XML_accentCallout1: {
536 static const OUString sAccentCallout1 = CREATE_OUSTRING( "mso-spt44" );
537 sType = sAccentCallout1;
538 } break;
539 case XML_accentCallout2: {
540 static const OUString sAccentCallout2 = CREATE_OUSTRING( "mso-spt45" );
541 sType = sAccentCallout2;
542 } break;
543 case XML_accentCallout3: {
544 static const OUString sAccentCallout3 = CREATE_OUSTRING( "mso-spt46" );
545 sType = sAccentCallout3;
546 } break;
547 case XML_borderCallout1: {
548 static const OUString sBorderCallout1 = CREATE_OUSTRING( "line-callout-1" );
549 sType = sBorderCallout1;
550 } break;
551 case XML_borderCallout2: {
552 static const OUString sBorderCallout2 = CREATE_OUSTRING( "line-callout-2" );
553 sType = sBorderCallout2;
554 } break;
555 case XML_borderCallout3: {
556 static const OUString sBorderCallout3 = CREATE_OUSTRING( "mso-spt49" );
557 sType = sBorderCallout3;
558 } break;
559 case XML_accentBorderCallout1: {
560 static const OUString sAccentBorderCallout1 = CREATE_OUSTRING( "mso-spt50" );
561 sType = sAccentBorderCallout1;
562 } break;
563 case XML_accentBorderCallout2: {
564 static const OUString sAccentBorderCallout2 = CREATE_OUSTRING( "mso-spt51" );
565 sType = sAccentBorderCallout2;
566 } break;
567 case XML_accentBorderCallout3: {
568 static const OUString sAccentBorderCallout3 = CREATE_OUSTRING( "mso-spt52" );
569 sType = sAccentBorderCallout3;
570 } break;
571 case XML_wedgeRectCallout: {
572 static const OUString sWedgeRectCallout = CREATE_OUSTRING( "rectangular-callout" );
573 sType = sWedgeRectCallout;
574 } break;
575 case XML_wedgeRoundRectCallout: {
576 static const OUString sWedgeRoundRectCallout = CREATE_OUSTRING( "round-rectangular-callout" );
577 sType = sWedgeRoundRectCallout;
578 } break;
579 case XML_wedgeEllipseCallout: {
580 static const OUString sWedgeEllipseCallout = CREATE_OUSTRING( "round-callout" );
581 sType = sWedgeEllipseCallout;
582 } break;
583 case XML_cloud: // TODO
584 case XML_cloudCallout: {
585 static const OUString sCloudCallout = CREATE_OUSTRING( "cloud-callout" );
586 sType = sCloudCallout;
587 } break;
588 case XML_ribbon: {
589 static const OUString sRibbon = CREATE_OUSTRING( "mso-spt53" );
590 sType = sRibbon;
591 } break;
592 case XML_ribbon2: {
593 static const OUString sRibbon2 = CREATE_OUSTRING( "mso-spt54" );
594 sType = sRibbon2;
595 } break;
596 case XML_ellipseRibbon: {
597 static const OUString sEllipseRibbon = CREATE_OUSTRING( "mso-spt107" );
598 sType = sEllipseRibbon;
599 } break;
600 case XML_leftRightRibbon: // TODO
601 case XML_ellipseRibbon2: {
602 static const OUString sEllipseRibbon2 = CREATE_OUSTRING( "mso-spt108" );
603 sType = sEllipseRibbon2;
604 } break;
605 case XML_verticalScroll: {
606 static const OUString sVerticalScroll = CREATE_OUSTRING( "vertical-scroll" );
607 sType = sVerticalScroll;
608 } break;
609 case XML_horizontalScroll: {
610 static const OUString sHorizontalScroll = CREATE_OUSTRING( "horizontal-scroll" );
611 sType = sHorizontalScroll;
612 } break;
613 case XML_wave: {
614 static const OUString sWave = CREATE_OUSTRING( "mso-spt64" );
615 sType = sWave;
616 } break;
617 case XML_doubleWave: {
618 static const OUString sDoubleWave = CREATE_OUSTRING( "mso-spt188" );
619 sType = sDoubleWave;
620 } break;
621 case XML_plus: {
622 static const OUString sPlus = CREATE_OUSTRING( "cross" );
623 sType = sPlus;
624 } break;
625 case XML_flowChartProcess: {
626 static const OUString sFlowChartProcess = CREATE_OUSTRING( "flowchart-process" );
627 sType = sFlowChartProcess;
628 } break;
629 case XML_flowChartDecision: {
630 static const OUString sFlowChartDecision = CREATE_OUSTRING( "flowchart-decision" );
631 sType = sFlowChartDecision;
632 } break;
633 case XML_flowChartInputOutput: {
634 static const OUString sFlowChartInputOutput = CREATE_OUSTRING( "flowchart-data" );
635 sType = sFlowChartInputOutput;
636 } break;
637 case XML_flowChartPredefinedProcess: {
638 static const OUString sFlowChartPredefinedProcess = CREATE_OUSTRING( "flowchart-predefined-process" );
639 sType = sFlowChartPredefinedProcess;
640 } break;
641 case XML_flowChartInternalStorage: {
642 static const OUString sFlowChartInternalStorage = CREATE_OUSTRING( "flowchart-internal-storage" );
643 sType = sFlowChartInternalStorage;
644 } break;
645 case XML_flowChartDocument: {
646 static const OUString sFlowChartDocument = CREATE_OUSTRING( "flowchart-document" );
647 sType = sFlowChartDocument;
648 } break;
649 case XML_flowChartMultidocument: {
650 static const OUString sFlowChartMultidocument = CREATE_OUSTRING( "flowchart-multidocument" );
651 sType = sFlowChartMultidocument;
652 } break;
653 case XML_flowChartTerminator: {
654 static const OUString sFlowChartTerminator = CREATE_OUSTRING( "flowchart-terminator" );
655 sType = sFlowChartTerminator;
656 } break;
657 case XML_flowChartPreparation : {
658 static const OUString sFlowChartPreparation = CREATE_OUSTRING( "flowchart-preparation" );
659 sType = sFlowChartPreparation;
660 } break;
661 case XML_flowChartManualInput: {
662 static const OUString sFlowChartManualInput = CREATE_OUSTRING( "flowchart-manual-input" );
663 sType = sFlowChartManualInput;
664 } break;
665 case XML_flowChartManualOperation: {
666 static const OUString sFlowChartManualOperation = CREATE_OUSTRING( "flowchart-manual-operation" );
667 sType = sFlowChartManualOperation;
668 } break;
669 case XML_flowChartConnector: {
670 static const OUString sFlowChartConnector = CREATE_OUSTRING( "flowchart-connector" );
671 sType = sFlowChartConnector;
672 } break;
673 case XML_flowChartPunchedCard: {
674 static const OUString sFlowChartPunchedCard = CREATE_OUSTRING( "flowchart-card" );
675 sType = sFlowChartPunchedCard;
676 } break;
677 case XML_flowChartPunchedTape: {
678 static const OUString sFlowChartPunchedTape = CREATE_OUSTRING( "flowchart-punched-tape" );
679 sType = sFlowChartPunchedTape;
680 } break;
681 case XML_flowChartSummingJunction: {
682 static const OUString sFlowChartSummingJunction = CREATE_OUSTRING( "flowchart-summing-junction" );
683 sType = sFlowChartSummingJunction;
684 } break;
685 case XML_flowChartOr: {
686 static const OUString sFlowChartOr = CREATE_OUSTRING( "flowchart-or" );
687 sType = sFlowChartOr;
688 } break;
689 case XML_flowChartCollate: {
690 static const OUString sFlowChartCollate = CREATE_OUSTRING( "flowchart-collate" );
691 sType = sFlowChartCollate;
692 } break;
693 case XML_flowChartSort: {
694 static const OUString sFlowChartSort = CREATE_OUSTRING( "flowchart-sort" );
695 sType = sFlowChartSort;
696 } break;
697 case XML_flowChartExtract: {
698 static const OUString sFlowChartExtract = CREATE_OUSTRING( "flowchart-extract" );
699 sType = sFlowChartExtract;
700 } break;
701 case XML_flowChartMerge: {
702 static const OUString sFlowChartMerge = CREATE_OUSTRING( "flowchart-merge" );
703 sType = sFlowChartMerge;
704 } break;
705 case XML_flowChartOfflineStorage: {
706 static const OUString sFlowChartOfflineStorage = CREATE_OUSTRING( "mso-spt129" );
707 sType = sFlowChartOfflineStorage;
708 } break;
709 case XML_flowChartOnlineStorage: {
710 static const OUString sFlowChartOnlineStorage = CREATE_OUSTRING( "flowchart-stored-data" );
711 sType = sFlowChartOnlineStorage;
712 } break;
713 case XML_flowChartMagneticTape: {
714 static const OUString sFlowChartMagneticTape = CREATE_OUSTRING( "flowchart-sequential-access" );
715 sType = sFlowChartMagneticTape;
716 } break;
717 case XML_flowChartMagneticDisk: {
718 static const OUString sFlowChartMagneticDisk = CREATE_OUSTRING( "flowchart-magnetic-disk" );
719 sType = sFlowChartMagneticDisk;
720 } break;
721 case XML_flowChartMagneticDrum: {
722 static const OUString sFlowChartMagneticDrum = CREATE_OUSTRING( "flowchart-direct-access-storage" );
723 sType = sFlowChartMagneticDrum;
724 } break;
725 case XML_flowChartDisplay: {
726 static const OUString sFlowChartDisplay = CREATE_OUSTRING( "flowchart-display" );
727 sType = sFlowChartDisplay;
728 } break;
729 case XML_flowChartDelay: {
730 static const OUString sFlowChartDelay = CREATE_OUSTRING( "flowchart-delay" );
731 sType = sFlowChartDelay;
732 } break;
733 case XML_flowChartAlternateProcess: {
734 static const OUString sFlowChartAlternateProcess = CREATE_OUSTRING( "flowchart-alternate-process" );
735 sType = sFlowChartAlternateProcess;
736 } break;
737 case XML_flowChartOffpageConnector: {
738 static const OUString sFlowChartOffpageConnector = CREATE_OUSTRING( "flowchart-off-page-connector" );
739 sType = sFlowChartOffpageConnector;
740 } break;
741 case XML_actionButtonBlank: {
742 static const OUString sActionButtonBlank = CREATE_OUSTRING( "mso-spt189" );
743 sType = sActionButtonBlank;
744 } break;
745 case XML_actionButtonHome: {
746 static const OUString sActionButtonHome = CREATE_OUSTRING( "mso-spt190" );
747 sType = sActionButtonHome;
748 } break;
749 case XML_actionButtonHelp: {
750 static const OUString sActionButtonHelp = CREATE_OUSTRING( "mso-spt191" );
751 sType = sActionButtonHelp;
752 } break;
753 case XML_actionButtonInformation: {
754 static const OUString sActionButtonInformation = CREATE_OUSTRING( "mso-spt192" );
755 sType = sActionButtonInformation;
756 } break;
757 case XML_actionButtonForwardNext: {
758 static const OUString sActionButtonForwardNext = CREATE_OUSTRING( "mso-spt193" );
759 sType = sActionButtonForwardNext;
760 } break;
761 case XML_actionButtonBackPrevious: {
762 static const OUString sActionButtonBackPrevious = CREATE_OUSTRING( "mso-spt194" );
763 sType = sActionButtonBackPrevious;
764 } break;
765 case XML_actionButtonEnd: {
766 static const OUString sActionButtonEnd = CREATE_OUSTRING( "mso-spt195" );
767 sType = sActionButtonEnd;
768 } break;
769 case XML_actionButtonBeginning: {
770 static const OUString sActionButtonBeginning = CREATE_OUSTRING( "mso-spt196" );
771 sType = sActionButtonBeginning;
772 } break;
773 case XML_actionButtonReturn: {
774 static const OUString sActionButtonReturn = CREATE_OUSTRING( "mso-spt197" );
775 sType = sActionButtonReturn;
776 } break;
777 case XML_actionButtonDocument: {
778 static const OUString sActionButtonDocument = CREATE_OUSTRING( "mso-spt198" );
779 sType = sActionButtonDocument;
780 } break;
781 case XML_actionButtonSound: {
782 static const OUString sActionButtonSound = CREATE_OUSTRING( "mso-spt199" );
783 sType = sActionButtonSound;
784 } break;
785 case XML_actionButtonMovie: {
786 static const OUString sActionButtonMovie = CREATE_OUSTRING( "mso-spt200" );
787 sType = sActionButtonMovie;
788 } break;
789 case XML_gear6: // TODO
790 case XML_gear9: // TODO
791 case XML_funnel: // TODO
792 case XML_mathPlus: // TODO
793 case XML_mathMinus: // TODO
794 case XML_mathMultiply: // TODO
795 case XML_mathDivide: // TODO
796 case XML_mathEqual: // TODO
797 case XML_mathNotEqual: // TODO
798 case XML_cornerTabs: // TODO
799 case XML_squareTabs: // TODO
800 case XML_plaqueTabs: // TODO
801 case XML_chartX: // TODO
802 case XML_chartStar: // TODO
803 case XML_chartPlus: { // TODO
804 static const OUString sRectangle = CREATE_OUSTRING( "rectangle" );
805 sType = sRectangle;
806 } break;
807 default:
808 break;
810 return sType;
813 static OUString GetTextShapeType( sal_Int32 nType )
815 OUString sType;
816 switch( nType )
818 case XML_textNoShape: // TODO
819 case XML_textPlain: {
820 static const OUString sTextPlain = CREATE_OUSTRING( "fontwork-plain-text" );
821 sType = sTextPlain;
822 } break;
823 case XML_textStop: {
824 static const OUString sTextStop = CREATE_OUSTRING( "fontwork-stop" );
825 sType = sTextStop;
826 } break;
827 case XML_textTriangle: {
828 static const OUString sTextTriangle = CREATE_OUSTRING( "fontwork-triangle-up" );
829 sType = sTextTriangle;
830 } break;
831 case XML_textTriangleInverted: {
832 static const OUString sTextTriangleInverted = CREATE_OUSTRING( "fontwork-triangle-down" );
833 sType = sTextTriangleInverted;
834 } break;
835 case XML_textChevron: {
836 static const OUString sTextChevron = CREATE_OUSTRING( "fontwork-chevron-up" );
837 sType = sTextChevron;
838 } break;
839 case XML_textChevronInverted: {
840 static const OUString sTextChevronInverted = CREATE_OUSTRING( "fontwork-chevron-down" );
841 sType = sTextChevronInverted;
842 } break;
843 case XML_textRingInside: {
844 static const OUString sTextRingInside = CREATE_OUSTRING( "mso-spt142" );
845 sType = sTextRingInside;
846 } break;
847 case XML_textRingOutside: {
848 static const OUString sTextRingOutside = CREATE_OUSTRING( "mso-spt143" );
849 sType = sTextRingOutside;
850 } break;
851 case XML_textArchUp: {
852 static const OUString sTextArchUp = CREATE_OUSTRING( "fontwork-arch-up-curve" );
853 sType = sTextArchUp;
854 } break;
855 case XML_textArchDown: {
856 static const OUString sTextArchDown = CREATE_OUSTRING( "fontwork-arch-down-curve" );
857 sType = sTextArchDown;
858 } break;
859 case XML_textCircle: {
860 static const OUString sTextCircle = CREATE_OUSTRING( "fontwork-circle-curve" );
861 sType = sTextCircle;
862 } break;
863 case XML_textButton: {
864 static const OUString sTextButton = CREATE_OUSTRING( "fontwork-open-circle-curve" );
865 sType = sTextButton;
866 } break;
867 case XML_textArchUpPour: {
868 static const OUString sTextArchUpPour = CREATE_OUSTRING( "fontwork-arch-up-pour" );
869 sType = sTextArchUpPour;
870 } break;
871 case XML_textArchDownPour: {
872 static const OUString sTextArchDownPour = CREATE_OUSTRING( "fontwork-arch-down-pour" );
873 sType = sTextArchDownPour;
874 } break;
875 case XML_textCirclePour: {
876 static const OUString sTextCirclePour = CREATE_OUSTRING( "fontwork-circle-pour" );
877 sType = sTextCirclePour;
878 } break;
879 case XML_textButtonPour: {
880 static const OUString sTextButtonPour = CREATE_OUSTRING( "fontwork-open-circle-pour" );
881 sType = sTextButtonPour;
882 } break;
883 case XML_textCurveUp: {
884 static const OUString sTextCurveUp = CREATE_OUSTRING( "fontwork-curve-up" );
885 sType = sTextCurveUp;
886 } break;
887 case XML_textCurveDown: {
888 static const OUString sTextCurveDown = CREATE_OUSTRING( "fontwork-curve-down" );
889 sType = sTextCurveDown;
890 } break;
891 case XML_textCanUp: {
892 static const OUString sTextCanUp = CREATE_OUSTRING( "mso-spt174" );
893 sType = sTextCanUp;
894 } break;
895 case XML_textCanDown: {
896 static const OUString sTextCanDown = CREATE_OUSTRING( "mso-spt175" );
897 sType = sTextCanDown;
898 } break;
899 case XML_textWave1: {
900 static const OUString sTextWave1 = CREATE_OUSTRING( "fontwork-wave" );
901 sType = sTextWave1;
902 } break;
903 case XML_textWave2: {
904 static const OUString sTextWave2 = CREATE_OUSTRING( "mso-spt157" );
905 sType = sTextWave2;
906 } break;
907 case XML_textDoubleWave1: {
908 static const OUString sTextDoubleWave1 = CREATE_OUSTRING( "mso-spt158" );
909 sType = sTextDoubleWave1;
910 } break;
911 case XML_textWave4: {
912 static const OUString sTextWave4 = CREATE_OUSTRING( "mso-spt159" );
913 sType = sTextWave4;
914 } break;
915 case XML_textInflate: {
916 static const OUString sTextInflate = CREATE_OUSTRING( "fontwork-inflate" );
917 sType = sTextInflate;
918 } break;
919 case XML_textDeflate: {
920 static const OUString sTextDeflate = CREATE_OUSTRING( "mso-spt161" );
921 sType = sTextDeflate;
922 } break;
923 case XML_textInflateBottom: {
924 static const OUString sTextInflateBottom = CREATE_OUSTRING( "mso-spt162" );
925 sType = sTextInflateBottom;
926 } break;
927 case XML_textDeflateBottom: {
928 static const OUString sTextDeflateBottom = CREATE_OUSTRING( "mso-spt163" );
929 sType = sTextDeflateBottom;
930 } break;
931 case XML_textInflateTop: {
932 static const OUString sTextInflateTop = CREATE_OUSTRING( "mso-spt164" );
933 sType = sTextInflateTop;
934 } break;
935 case XML_textDeflateTop: {
936 static const OUString sTextDeflateTop = CREATE_OUSTRING( "mso-spt165" );
937 sType = sTextDeflateTop;
938 } break;
939 case XML_textDeflateInflate: {
940 static const OUString sTextDeflateInflate = CREATE_OUSTRING( "mso-spt166" );
941 sType = sTextDeflateInflate;
942 } break;
943 case XML_textDeflateInflateDeflate: {
944 static const OUString sTextDeflateInflateDeflate = CREATE_OUSTRING( "mso-spt167" );
945 sType = sTextDeflateInflateDeflate;
946 } break;
947 case XML_textFadeRight: {
948 static const OUString sTextFadeRight = CREATE_OUSTRING( "fontwork-fade-right" );
949 sType = sTextFadeRight;
950 } break;
951 case XML_textFadeLeft: {
952 static const OUString sTextFadeLeft = CREATE_OUSTRING( "fontwork-fade-left" );
953 sType = sTextFadeLeft;
954 } break;
955 case XML_textFadeUp: {
956 static const OUString sTextFadeUp = CREATE_OUSTRING( "fontwork-fade-up" );
957 sType = sTextFadeUp;
958 } break;
959 case XML_textFadeDown: {
960 static const OUString sTextFadeDown = CREATE_OUSTRING( "fontwork-fade-down" );
961 sType = sTextFadeDown;
962 } break;
963 case XML_textSlantUp: {
964 static const OUString sTextSlantUp = CREATE_OUSTRING( "fontwork-slant-up" );
965 sType = sTextSlantUp;
966 } break;
967 case XML_textSlantDown: {
968 static const OUString sTextSlantDown = CREATE_OUSTRING( "fontwork-slant-down" );
969 sType = sTextSlantDown;
970 } break;
971 case XML_textCascadeUp: {
972 static const OUString sTextCascadeUp = CREATE_OUSTRING( "fontwork-fade-up-and-right" );
973 sType = sTextCascadeUp;
974 } break;
975 case XML_textCascadeDown: {
976 static const OUString sTextCascadeDown = CREATE_OUSTRING( "fontwork-fade-up-and-left" );
977 sType = sTextCascadeDown;
978 } break;
979 default:
980 break;
982 return sType;
985 // ---------------------------------------------------------------------
986 // CT_CustomGeometry2D
987 CustomShapeGeometryContext::CustomShapeGeometryContext( ContextHandler& rParent, const Reference< XFastAttributeList >& /* xAttribs */, CustomShapeProperties& rCustomShapeProperties )
988 : ContextHandler( rParent )
989 , mrCustomShapeProperties( rCustomShapeProperties )
993 Reference< XFastContextHandler > CustomShapeGeometryContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& ) throw (SAXException, RuntimeException)
995 switch( aElementToken )
997 // todo
998 case NMSP_DRAWINGML|XML_avLst: // CT_GeomGuideList adjust value list
999 case NMSP_DRAWINGML|XML_gdLst: // CT_GeomGuideList guide list
1000 case NMSP_DRAWINGML|XML_ahLst: // CT_AdjustHandleList adjust handle list
1001 case NMSP_DRAWINGML|XML_cxnLst: // CT_ConnectionSiteList connection site list
1002 case NMSP_DRAWINGML|XML_rect: // CT_GeomRectList geometry rect list
1003 case NMSP_DRAWINGML|XML_pathLst: // CT_Path2DList 2d path list
1004 break;
1007 Reference< XFastContextHandler > xEmpty;
1008 return xEmpty;
1011 // ---------------------------------------------------------------------
1012 // CT_PresetGeometry2D
1013 PresetShapeGeometryContext::PresetShapeGeometryContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, CustomShapeProperties& rCustomShapeProperties )
1014 : ContextHandler( rParent )
1015 , mrCustomShapeProperties( rCustomShapeProperties )
1017 OUString sShapeType;
1018 sal_Int32 nShapeType = xAttribs->getOptionalValueToken( XML_prst, FastToken::DONTKNOW );
1019 if ( nShapeType != FastToken::DONTKNOW )
1020 sShapeType = GetShapeType( nShapeType );
1021 OSL_ENSURE( sShapeType.getLength(), "oox::drawingml::CustomShapeCustomGeometryContext::CustomShapeCustomGeometryContext(), unknown shape type" );
1022 mrCustomShapeProperties.setShapePresetType( sShapeType );
1025 Reference< XFastContextHandler > PresetShapeGeometryContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& ) throw (SAXException, RuntimeException)
1027 if ( aElementToken == ( NMSP_DRAWINGML | XML_avLst ) )
1028 return new AdjustmentValueContext( *this, mrCustomShapeProperties );
1029 else
1030 return this;
1033 // ---------------------------------------------------------------------
1034 // CT_PresetTextShape
1035 PresetTextShapeContext::PresetTextShapeContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, CustomShapeProperties& rCustomShapeProperties )
1036 : ContextHandler( rParent )
1037 , mrCustomShapeProperties( rCustomShapeProperties )
1039 OUString sShapeType;
1040 sal_Int32 nShapeType = xAttribs->getOptionalValueToken( XML_prst, FastToken::DONTKNOW );
1041 if ( nShapeType != FastToken::DONTKNOW )
1042 sShapeType = GetTextShapeType( nShapeType );
1043 OSL_ENSURE( sShapeType.getLength(), "oox::drawingml::CustomShapeCustomGeometryContext::CustomShapeCustomGeometryContext(), unknown shape type" );
1044 mrCustomShapeProperties.setShapePresetType( sShapeType );
1047 Reference< XFastContextHandler > PresetTextShapeContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& ) throw (SAXException, RuntimeException)
1049 switch( aElementToken )
1051 // todo
1052 case NMSP_DRAWINGML|XML_avLst: // CT_GeomGuideList adjust value list
1053 case NMSP_DRAWINGML|XML_gdLst: // CT_GeomGuideList guide list
1054 case NMSP_DRAWINGML|XML_ahLst: // CT_AdjustHandleList adjust handle list
1055 case NMSP_DRAWINGML|XML_cxnLst: // CT_ConnectionSiteList connection site list
1056 case NMSP_DRAWINGML|XML_rect: // CT_GeomRectList geometry rect list
1057 case NMSP_DRAWINGML|XML_pathLst: // CT_Path2DList 2d path list
1058 break;
1061 Reference< XFastContextHandler > xEmpty;
1062 return xEmpty;