1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include "oox/drawingml/customshapegeometry.hxx"
29 
30 #include <com/sun/star/xml/sax/FastToken.hpp>
31 #include <comphelper/stl_types.hxx>
32 #include <hash_map>
33 #include "oox/helper/helper.hxx"
34 #include "oox/helper/attributelist.hxx"
35 #include "oox/helper/propertymap.hxx"
36 
37 using ::rtl::OUString;
38 using namespace ::oox::core;
39 using namespace ::com::sun::star::uno;
40 using namespace ::com::sun::star::beans;
41 using namespace ::com::sun::star::drawing;
42 using namespace ::com::sun::star::xml::sax;
43 
44 namespace oox { namespace drawingml {
45 
46 enum FormularCommand
47 {
48     FC_MULDIV = 0,
49     FC_PLUSMINUS,
50     FC_PLUSDIV,
51     FC_IFELSE,
52     FC_ABS,
53     FC_AT2,
54 	FC_CAT2,
55 	FC_COS,
56 	FC_MAX,
57 	FC_MIN,
58 	FC_MOD,
59 	FC_PIN,
60 	FC_SAT2,
61 	FC_SIN,
62 	FC_SQRT,
63 	FC_TAN,
64 	FC_VAL,
65 	FC_LAST
66 };
67 struct FormularCommandNameTable
68 {
69 	const char*		pS;
70 	FormularCommand	pE;
71 };
72 static FormularCommandNameTable pFormularCommandNameTable[] =
73 {
74 	{ "*/",		FC_MULDIV },
75 	{ "+-",		FC_PLUSMINUS },
76 	{ "+/",		FC_PLUSDIV },
77 	{ "ifelse",	FC_IFELSE },
78 	{ "abs",	FC_ABS },
79 	{ "at2",	FC_AT2 },
80 	{ "cat2",	FC_CAT2 },
81 	{ "cos",	FC_COS },
82 	{ "max",	FC_MAX },
83 	{ "min",	FC_MIN },
84 	{ "mod",	FC_MOD },
85 	{ "pin",	FC_PIN },
86 	{ "sat2",	FC_SAT2 },
87 	{ "sin",	FC_SIN },
88 	{ "sqrt",	FC_SQRT },
89 	{ "tan",	FC_TAN },
90 	{ "val",	FC_VAL }
91 
92 };
93 typedef std::hash_map< rtl::OUString, FormularCommand, comphelper::UStringHash, comphelper::UStringEqual > FormulaCommandHMap;
94 
95 static const FormulaCommandHMap* pCommandHashMap;
96 
97 //
98 rtl::OUString GetFormulaParameter( const EnhancedCustomShapeParameter& rParameter )
99 {
100 	rtl::OUString aRet;
101 	switch( rParameter.Type )
102 	{
103 		case EnhancedCustomShapeParameterType::NORMAL :
104 		{
105 			if ( rParameter.Value.getValueTypeClass() == TypeClass_DOUBLE )
106 			{
107 				double fValue = 0.0;
108 				if ( rParameter.Value >>= fValue )
109 					aRet = rtl::OUString::valueOf( fValue );
110 			}
111 			else
112 			{
113 				sal_Int32 nValue = 0;
114 				if ( rParameter.Value >>= nValue )
115 					aRet = rtl::OUString::valueOf( nValue );
116 			}
117 		}
118 		break;
119 		case EnhancedCustomShapeParameterType::EQUATION :
120 		{
121 			if ( rParameter.Value.getValueTypeClass() == TypeClass_LONG )
122 			{
123 				sal_Int32 nFormulaIndex;
124 				if ( rParameter.Value >>= nFormulaIndex )
125 				{
126 					aRet = CREATE_OUSTRING( "?" )
127 						+ rtl::OUString::valueOf( nFormulaIndex )
128 							+ CREATE_OUSTRING( " " );
129 				}
130 			}
131 			else
132 			{
133 				// ups... we should have an index here and not the formula name
134 			}
135 		}
136 		break;
137 		case EnhancedCustomShapeParameterType::ADJUSTMENT :
138 		{
139 			if ( rParameter.Value.getValueTypeClass() == TypeClass_LONG )
140 			{
141 				sal_Int32 nAdjustmentIndex;
142 				if ( rParameter.Value >>= nAdjustmentIndex )
143 				{
144 					aRet = CREATE_OUSTRING( "$" )
145 						+ rtl::OUString::valueOf( nAdjustmentIndex )
146 							+ CREATE_OUSTRING( " " );
147 				}
148 			}
149 			else
150 			{
151 				// ups... we should have an index here and not the formula name
152 			}
153 		}
154 		break;
155 		case EnhancedCustomShapeParameterType::LEFT :
156 		{
157 			const rtl::OUString sLeft( CREATE_OUSTRING( "left" ) );
158 			aRet = sLeft;
159 		}
160 		break;
161 		case EnhancedCustomShapeParameterType::TOP :
162 		{
163 			const rtl::OUString sTop( CREATE_OUSTRING( "top" ) );
164 			aRet = sTop;
165 		}
166 		break;
167 		case EnhancedCustomShapeParameterType::RIGHT :
168 		{
169 			const rtl::OUString sRight( CREATE_OUSTRING( "right" ) );
170 			aRet = sRight;
171 		}
172 		break;
173 		case EnhancedCustomShapeParameterType::BOTTOM :
174 		{
175 			const rtl::OUString sBottom( CREATE_OUSTRING( "bottom" ) );
176 			aRet = sBottom;
177 		}
178 		break;
179 		case EnhancedCustomShapeParameterType::XSTRETCH :
180 		{
181 			const rtl::OUString sXStretch( CREATE_OUSTRING( "xstretch" ) );
182 			aRet = sXStretch;
183 		}
184 		break;
185 		case EnhancedCustomShapeParameterType::YSTRETCH :
186 		{
187 			const rtl::OUString sYStretch( CREATE_OUSTRING( "ystretch" ) );
188 			aRet = sYStretch;
189 		}
190 		break;
191 		case EnhancedCustomShapeParameterType::HASSTROKE :
192 		{
193 			const rtl::OUString sHasStroke( CREATE_OUSTRING( "hasstroke" ) );
194 			aRet = sHasStroke;
195 		}
196 		break;
197 		case EnhancedCustomShapeParameterType::HASFILL :
198 		{
199 			const rtl::OUString sHasFill( CREATE_OUSTRING( "hasfill" ) );
200 			aRet = sHasFill;
201 		}
202 		break;
203 		case EnhancedCustomShapeParameterType::WIDTH :
204 		{
205 			const rtl::OUString sWidth( CREATE_OUSTRING( "width" ) );
206 			aRet = sWidth;
207 		}
208 		break;
209 		case EnhancedCustomShapeParameterType::HEIGHT :
210 		{
211 			const rtl::OUString sHeight( CREATE_OUSTRING( "height" ) );
212 			aRet = sHeight;
213 		}
214 		break;
215 		case EnhancedCustomShapeParameterType::LOGWIDTH :
216 		{
217 			const rtl::OUString sLogWidth( CREATE_OUSTRING( "logwidth" ) );
218 			aRet = sLogWidth;
219 		}
220 		break;
221 		case EnhancedCustomShapeParameterType::LOGHEIGHT :
222 		{
223 			const rtl::OUString sLogHeight( CREATE_OUSTRING( "logheight" ) );
224 			aRet = sLogHeight;
225 		}
226 		break;
227 	}
228 	return aRet;
229 }
230 
231 // ---------------------------------------------------------------------
232 
233 static EnhancedCustomShapeParameter GetAdjCoordinate( CustomShapeProperties& rCustomShapeProperties, const::rtl::OUString& rValue, sal_Bool bNoSymbols )
234 {
235 	com::sun::star::drawing::EnhancedCustomShapeParameter aRet;
236 	if ( rValue.getLength() )
237 	{
238 		sal_Bool	bConstant = sal_True;
239 		sal_Int32	nConstant = 0;
240 		sal_Char	nVal = 0;
241 
242 		// first check if its a constant value
243 		switch( AttributeConversion::decodeToken( rValue ) )
244 		{
245 			case XML_3cd4 :	nConstant = 270 * 60000; break;
246 			case XML_3cd8 :	nConstant = 135 * 60000; break;
247 			case XML_5cd8 : nConstant = 225 * 60000; break;
248 			case XML_7cd8 : nConstant = 315 * 60000; break;
249 			case XML_cd2  : nConstant = 180 * 60000; break;
250 			case XML_cd4  : nConstant =  90 * 60000; break;
251 			case XML_cd8  : nConstant =  45 * 60000; break;
252 
253 			case XML_b :	// variable height of the shape defined in spPr
254 			case XML_h :
255 			{
256 				if ( bNoSymbols )
257 				{
258 					CustomShapeGuide aGuide;
259 					aGuide.maName = rValue;
260 					aGuide.maFormula = CREATE_OUSTRING( "height" );
261 
262 					aRet.Value = Any( CustomShapeProperties::SetCustomShapeGuideValue( rCustomShapeProperties.getGuideList(), aGuide ) );
263 					aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
264 				}
265 				else
266 					aRet.Type = EnhancedCustomShapeParameterType::HEIGHT;	// TODO: HEIGHT needs to be implemented
267 			}
268 			break;
269 
270 
271 			case XML_hd8 :	// !!PASSTHROUGH INTENDED
272 				nVal += 2;	// */ h 1.0 8.0
273 			case XML_hd6 :	// */ h 1.0 6.0
274 				nVal++;
275 			case XML_hd5 :	// */ h 1.0 5.0
276 				nVal++;
277 			case XML_hd4 :	// */ h 1.0 4.0
278 				nVal += 2;
279 			case XML_hd2 :	// */ h 1.0 2.0
280 			case XML_vc :	// */ h 1.0 2.0
281 			{
282 				nVal += '2';
283 
284 				CustomShapeGuide aGuide;
285 				aGuide.maName = rValue;
286 				aGuide.maFormula = CREATE_OUSTRING( "height/" ) + rtl::OUString( nVal );
287 
288 				aRet.Value = Any( CustomShapeProperties::SetCustomShapeGuideValue( rCustomShapeProperties.getGuideList(), aGuide ) );
289 				aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
290 			}
291 			break;
292 
293 			case XML_t :
294 			case XML_l :
295 			{
296 				nConstant = 0;
297 				aRet.Type = EnhancedCustomShapeParameterType::NORMAL;
298 			}
299 			break;
300 
301 			case XML_ls :	// longest side: max w h
302 			{
303 				CustomShapeGuide aGuide;
304 				aGuide.maName = rValue;
305 				aGuide.maFormula = CREATE_OUSTRING( "max(width,height)" );
306 
307 				aRet.Value = Any( CustomShapeProperties::SetCustomShapeGuideValue( rCustomShapeProperties.getGuideList(), aGuide ) );
308 				aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
309 			}
310 			break;
311 			case XML_ss :	// shortest side: min w h
312 			{
313 				CustomShapeGuide aGuide;
314 				aGuide.maName = rValue;
315 				aGuide.maFormula = CREATE_OUSTRING( "min(width,height)" );
316 
317 				aRet.Value = Any( CustomShapeProperties::SetCustomShapeGuideValue( rCustomShapeProperties.getGuideList(), aGuide ) );
318 				aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
319 			}
320 			break;
321 			case XML_ssd8 : // */ ss 1.0 8.0
322 				nVal += 2;
323 			case XML_ssd6 : // */ ss 1.0 6.0
324 				nVal += 2;
325 			case XML_ssd4 :	// */ ss 1.0 4.0
326 				nVal += 2;
327 			case XML_ssd2 :	// */ ss 1.0 2.0
328 			{
329 				nVal += '2';
330 
331 				CustomShapeGuide aGuide;
332 				aGuide.maName = rValue;
333 				aGuide.maFormula = CREATE_OUSTRING( "min(width,height)/" ) + rtl::OUString( nVal );
334 
335 				aRet.Value = Any( CustomShapeProperties::SetCustomShapeGuideValue( rCustomShapeProperties.getGuideList(), aGuide ) );
336 				aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
337 			}
338 			break;
339 
340 			case XML_r :	// variable width of the shape defined in spPr
341 			case XML_w :
342 			{
343 				if ( bNoSymbols )
344 				{
345 					CustomShapeGuide aGuide;
346 					aGuide.maName = rValue;
347 					aGuide.maFormula = CREATE_OUSTRING( "width" );
348 
349 					aRet.Value = Any( CustomShapeProperties::SetCustomShapeGuideValue( rCustomShapeProperties.getGuideList(), aGuide ) );
350 					aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
351 				}
352 				else
353 					aRet.Type = EnhancedCustomShapeParameterType::WIDTH;
354 			}
355 			break;
356 
357 			case XML_wd10 :	// */ w 1.0 10.0
358 				nVal += 2;
359 			case XML_wd8 :	// */ w 1.0 8.0
360 				nVal += 2;
361 			case XML_wd6 :	// */ w 1.0 6.0
362 				nVal++;
363 			case XML_wd5 :	// */ w 1.0 5.0
364 				nVal++;
365 			case XML_wd4 :	// */ w 1.0 4.0
366 				nVal += 2;
367 			case XML_hc :	// */ w 1.0 2.0
368 			case XML_wd2 :	// */ w 1.0 2.0
369 			{
370 				nVal += '2';
371 
372 				CustomShapeGuide aGuide;
373 				aGuide.maName = rValue;
374 				aGuide.maFormula = CREATE_OUSTRING( "width/" ) + rtl::OUString( nVal );
375 
376 				aRet.Value = Any( CustomShapeProperties::SetCustomShapeGuideValue( rCustomShapeProperties.getGuideList(), aGuide ) );
377 				aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
378 			}
379 			break;
380 
381 			default:
382 				bConstant = sal_False;
383 			break;
384 		}
385 		if ( bConstant )
386 		{
387 			if ( nConstant )
388 			{
389 				aRet.Value = Any( nConstant );
390 				aRet.Type = EnhancedCustomShapeParameterType::NORMAL;
391 			}
392 		}
393 		else
394 		{
395 			sal_Unicode n = rValue[ 0 ];
396 			if ( ( n == '+' ) || ( n == '-' ) )
397 			{
398 				if ( rValue.getLength() > 0 )
399 					n = rValue[ 1 ];
400 			}
401 			if ( ( n >= '0' ) && ( n <= '9' ) )
402 			{	// seems to be a ST_Coordinate
403 				aRet.Value = Any( rValue.toInt32() );
404 				aRet.Type = EnhancedCustomShapeParameterType::NORMAL;
405 			}
406 			else
407 			{
408 				sal_Int32 nGuideIndex = CustomShapeProperties::GetCustomShapeGuideValue( rCustomShapeProperties.getAdjustmentGuideList(), rValue );
409 				if ( nGuideIndex >= 0 )
410 				{
411 					aRet.Value = Any( nGuideIndex );
412 					aRet.Type = EnhancedCustomShapeParameterType::ADJUSTMENT;
413 				}
414 				else
415 				{
416 					nGuideIndex = CustomShapeProperties::GetCustomShapeGuideValue( rCustomShapeProperties.getGuideList(), rValue );
417 					if ( nGuideIndex >= 0 )
418 					{
419 						aRet.Value = Any( nGuideIndex );
420 						aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
421 					}
422 					else
423 						aRet.Value = Any( rValue );
424 				}
425 			}
426 		}
427 	}
428 	return aRet;
429 }
430 
431 static EnhancedCustomShapeParameter GetAdjAngle( CustomShapeProperties& rCustomShapeProperties, const ::rtl::OUString& rValue )
432 {
433 	EnhancedCustomShapeParameter aAngle( GetAdjCoordinate( rCustomShapeProperties, rValue, sal_True ) );
434 	if ( aAngle.Type == EnhancedCustomShapeParameterType::NORMAL )
435 	{
436 		sal_Int32 nValue = 0;
437 		aAngle.Value >>= nValue;
438 		double fValue = ( static_cast< double >( nValue ) / 60000.0 ) * 360.0;
439 		aAngle.Value <<= fValue;
440 	}
441 	return aAngle;
442 }
443 
444 // ---------------------------------------------------------------------
445 // CT_GeomGuideList
446 class GeomGuideListContext : public ContextHandler
447 {
448 public:
449 	GeomGuideListContext( ContextHandler& rParent, CustomShapeProperties& rCustomShapeProperties, std::vector< CustomShapeGuide >& rGuideList );
450 	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);
451 
452 protected:
453     std::vector< CustomShapeGuide >&	mrGuideList;
454 	CustomShapeProperties&				mrCustomShapeProperties;
455 };
456 
457 GeomGuideListContext::GeomGuideListContext( ContextHandler& rParent, CustomShapeProperties& rCustomShapeProperties, std::vector< CustomShapeGuide >& rGuideList )
458 : ContextHandler( rParent )
459 , mrGuideList( rGuideList )
460 , mrCustomShapeProperties( rCustomShapeProperties )
461 {
462 }
463 
464 static rtl::OUString convertToOOEquation( CustomShapeProperties& rCustomShapeProperties, const rtl::OUString& rSource )
465 {
466 	if ( !pCommandHashMap )
467 	{
468 		FormulaCommandHMap* pHM = new FormulaCommandHMap();
469 		for( sal_Int32 i = 0; i < FC_LAST; i++ )
470 			(*pHM)[ OUString::createFromAscii( pFormularCommandNameTable[ i ].pS ) ] =  pFormularCommandNameTable[ i ].pE;
471 		pCommandHashMap = pHM;
472 	}
473 
474 	std::vector< rtl::OUString > aTokens;
475 	sal_Int32 nIndex = 0;
476 	do
477 	{
478 		rtl::OUString aToken( rSource.getToken( 0, ' ', nIndex ) );
479 		if ( aToken.getLength() )
480 			aTokens.push_back( aToken );
481 	}
482 	while ( nIndex >= 0 );
483 
484 	rtl::OUString aEquation;
485 	if ( aTokens.size() )
486 	{
487 		sal_Int32 i, nParameters = aTokens.size() - 1;
488 		if ( nParameters > 3 )
489 			nParameters = 3;
490 
491 		rtl::OUString sParameters[ 3 ];
492 
493 		for ( i = 0; i < nParameters; i++ )
494 			sParameters[ i ] = GetFormulaParameter( GetAdjCoordinate( rCustomShapeProperties, aTokens[ i + 1 ], sal_False ) );
495 
496 		const FormulaCommandHMap::const_iterator aIter( pCommandHashMap->find( aTokens[ 0 ] ) );
497 		if ( aIter != pCommandHashMap->end() )
498 		{
499 			switch( aIter->second )
500 			{
501 				case FC_MULDIV :
502 				{
503 					if ( nParameters == 3 )
504 						aEquation = sParameters[ 0 ] + CREATE_OUSTRING( "*" ) + sParameters[ 1 ]
505 							+ CREATE_OUSTRING( "/" ) + sParameters[ 2 ];
506 				}
507 				break;
508 				case FC_PLUSMINUS :
509 				{
510 					if ( nParameters == 3 )
511 						aEquation = sParameters[ 0 ] + CREATE_OUSTRING( "+" ) + sParameters[ 1 ]
512 							+ CREATE_OUSTRING( "-" ) + sParameters[ 2 ];
513 				}
514 				break;
515 				case FC_PLUSDIV :
516 				{
517 					if ( nParameters == 3 )
518 						aEquation = CREATE_OUSTRING( "(" ) + sParameters[ 0 ] + CREATE_OUSTRING( "+" )
519 							+ sParameters[ 1 ] + CREATE_OUSTRING( ")/" ) + sParameters[ 2 ];
520 				}
521 				break;
522 				case FC_IFELSE :
523 				{
524 					if ( nParameters == 3 )
525 						aEquation = CREATE_OUSTRING( "if(" ) + sParameters[ 0 ] + CREATE_OUSTRING( "," )
526 							+ sParameters[ 1 ] + CREATE_OUSTRING( "," ) + sParameters[ 2 ] + CREATE_OUSTRING( ")" );
527 				}
528 				break;
529 				case FC_ABS :
530 				{
531 					if ( nParameters == 1 )
532 						aEquation = CREATE_OUSTRING( "abs(" ) + sParameters[ 0 ] + CREATE_OUSTRING( ")" );
533 				}
534 				break;
535 				case FC_AT2 :
536 				{
537 					if ( nParameters == 2 )
538 						aEquation = CREATE_OUSTRING( "atan2(" ) + sParameters[ 0 ] + CREATE_OUSTRING( "," )
539 						+ sParameters[ 1 ] + CREATE_OUSTRING( ")" );
540 				}
541 				break;
542 				case FC_CAT2 :
543 				{
544 					if ( nParameters == 3 )
545 						aEquation = sParameters[ 0 ] + CREATE_OUSTRING( "*(cos(arctan(" ) +
546 							sParameters[ 1 ] + CREATE_OUSTRING( "," ) + sParameters[ 2 ] + CREATE_OUSTRING( ")))" );
547 				}
548 				break;
549 				case FC_COS :
550 				{
551 					if ( nParameters == 2 )
552 						aEquation = sParameters[ 0 ] + CREATE_OUSTRING( "*cos(" ) +
553 						sParameters[ 1 ] + CREATE_OUSTRING( ")" );
554 				}
555 				break;
556 				case FC_MAX :
557 				{
558 					if ( nParameters == 2 )
559 						aEquation = CREATE_OUSTRING( "max(" ) + sParameters[ 0 ] + CREATE_OUSTRING( "," ) +
560 							sParameters[ 1 ] + CREATE_OUSTRING( ")" );
561 				}
562 				break;
563 				case FC_MIN :
564 				{
565 					if ( nParameters == 2 )
566 						aEquation = CREATE_OUSTRING( "min(" ) + sParameters[ 0 ] + CREATE_OUSTRING( "," ) +
567 							sParameters[ 1 ] + CREATE_OUSTRING( ")" );
568 				}
569 				break;
570 				case FC_MOD :
571 				{
572 					if ( nParameters == 3 )
573 						aEquation = CREATE_OUSTRING( "sqrt(" )
574 							+ sParameters[ 0 ] + CREATE_OUSTRING( "*" ) + sParameters[ 0 ] + CREATE_OUSTRING( "+" )
575 							+ sParameters[ 1 ] + CREATE_OUSTRING( "*" ) + sParameters[ 1 ] + CREATE_OUSTRING( "+" )
576 							+ sParameters[ 2 ] + CREATE_OUSTRING( "*" ) + sParameters[ 2 ] + CREATE_OUSTRING( ")" );
577 				}
578 				break;
579 				case FC_PIN :
580 				{
581 					if ( nParameters == 3 )	// if(x-y,x,if(y-z,z,y))
582 						aEquation = CREATE_OUSTRING( "if(" ) + sParameters[ 0 ] + CREATE_OUSTRING( "-" ) + sParameters[ 1 ]
583 							+ CREATE_OUSTRING( "," ) + sParameters[ 0 ] + CREATE_OUSTRING( ",if(" ) + sParameters[ 2 ]
584 							+ CREATE_OUSTRING( "-" ) + sParameters[ 1 ] + CREATE_OUSTRING( "," ) + sParameters[ 1 ]
585 							+ CREATE_OUSTRING( "," ) + sParameters[ 2 ] + CREATE_OUSTRING( "))" );
586 				}
587 				break;
588 				case FC_SAT2 :
589 				{
590 					if ( nParameters == 3 )
591 						aEquation = sParameters[ 0 ] + CREATE_OUSTRING( "*(sin(arctan(" ) +
592 							sParameters[ 1 ] + CREATE_OUSTRING( "," ) + sParameters[ 2 ] + CREATE_OUSTRING( ")))" );
593 				}
594 				break;
595 				case FC_SIN :
596 				{
597 					if ( nParameters == 2 )
598 						aEquation = sParameters[ 0 ] + CREATE_OUSTRING( "*sin(" ) +
599 						sParameters[ 1 ] + CREATE_OUSTRING( ")" );
600 				}
601 				break;
602 				case FC_SQRT :
603 				{
604 					if ( nParameters == 1 )
605 						aEquation = CREATE_OUSTRING( "sqrt(" ) + sParameters[ 0 ] + CREATE_OUSTRING( ")" );
606 				}
607 				break;
608 				case FC_TAN :
609 				{
610 					if ( nParameters == 2 )
611 						aEquation = sParameters[ 0 ] + CREATE_OUSTRING( "*tan(" ) +
612 						sParameters[ 1 ] + CREATE_OUSTRING( ")" );
613 				}
614 				break;
615 				case FC_VAL :
616 				{
617 					if ( nParameters == 1 )
618 						aEquation = sParameters[ 0 ];
619 				}
620 				break;
621 				default :
622 					break;
623 			}
624 		}
625 	}
626 	return aEquation;
627 }
628 
629 Reference< XFastContextHandler > GeomGuideListContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
630 {
631 	if ( aElementToken == A_TOKEN( gd ) )	// CT_GeomGuide
632 	{
633 		CustomShapeGuide aGuide;
634 		aGuide.maName = xAttribs->getOptionalValue( XML_name );
635 		aGuide.maFormula = convertToOOEquation( mrCustomShapeProperties, xAttribs->getOptionalValue( XML_fmla ) );
636 		mrGuideList.push_back( aGuide );
637 	}
638 	return this;
639 }
640 
641 // ---------------------------------------------------------------------
642 
643 static const rtl::OUString GetGeomGuideName( const ::rtl::OUString& rValue )
644 {
645 	return rValue;
646 }
647 
648 // ---------------------------------------------------------------------
649 // CT_AdjPoint2D
650 class AdjPoint2DContext : public ContextHandler
651 {
652 public:
653     AdjPoint2DContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, CustomShapeProperties& rCustomShapeProperties, EnhancedCustomShapeParameterPair& rAdjPoint2D );
654 };
655 
656 AdjPoint2DContext::AdjPoint2DContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, CustomShapeProperties& rCustomShapeProperties, EnhancedCustomShapeParameterPair& rAdjPoint2D )
657 : ContextHandler( rParent )
658 {
659 	rAdjPoint2D.First = GetAdjCoordinate( rCustomShapeProperties, xAttribs->getOptionalValue( XML_x ), sal_True );
660 	rAdjPoint2D.Second = GetAdjCoordinate( rCustomShapeProperties, xAttribs->getOptionalValue( XML_y ), sal_True );
661 }
662 
663 // ---------------------------------------------------------------------
664 // CT_XYAdjustHandle
665 class XYAdjustHandleContext : public ContextHandler
666 {
667 public:
668     XYAdjustHandleContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, CustomShapeProperties& rCustomShapeProperties, AdjustHandle& rAdjustHandle );
669 	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);
670 
671 protected:
672     AdjustHandle& mrAdjustHandle;
673 	CustomShapeProperties& mrCustomShapeProperties;
674 };
675 
676 XYAdjustHandleContext::XYAdjustHandleContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, CustomShapeProperties& rCustomShapeProperties, AdjustHandle& rAdjustHandle )
677 : ContextHandler( rParent )
678 , mrAdjustHandle( rAdjustHandle )
679 , mrCustomShapeProperties( rCustomShapeProperties )
680 {
681 	const rtl::OUString aEmptyDefault;
682 	AttributeList aAttribs( xAttribs );
683 	if ( aAttribs.hasAttribute( XML_gdRefX ) )
684 	{
685 		mrAdjustHandle.gdRef1 = GetGeomGuideName( aAttribs.getString( XML_gdRefX, aEmptyDefault ) );
686 	}
687 	if ( aAttribs.hasAttribute( XML_minX ) )
688 	{
689 		mrAdjustHandle.min1 = GetAdjCoordinate( mrCustomShapeProperties, aAttribs.getString( XML_minX, aEmptyDefault ), sal_True );
690 	}
691 	if ( aAttribs.hasAttribute( XML_maxX ) )
692 	{
693 		mrAdjustHandle.max1 = GetAdjCoordinate( mrCustomShapeProperties, aAttribs.getString( XML_maxX, aEmptyDefault ), sal_True );
694 	}
695 	if ( aAttribs.hasAttribute( XML_gdRefY ) )
696 	{
697 		mrAdjustHandle.gdRef2 = GetGeomGuideName( aAttribs.getString( XML_gdRefY, aEmptyDefault ) );
698 	}
699 	if ( aAttribs.hasAttribute( XML_minY ) )
700 	{
701 		mrAdjustHandle.min2 = GetAdjCoordinate( mrCustomShapeProperties, aAttribs.getString( XML_minY, aEmptyDefault ), sal_True );
702 	}
703 	if ( aAttribs.hasAttribute( XML_maxY ) )
704 	{
705 		mrAdjustHandle.max2 = GetAdjCoordinate( mrCustomShapeProperties, aAttribs.getString( XML_maxY, aEmptyDefault ), sal_True );
706 	}
707 }
708 
709 Reference< XFastContextHandler > XYAdjustHandleContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
710 {
711 	Reference< XFastContextHandler > xContext;
712 	if ( aElementToken == A_TOKEN( pos ) )
713 		xContext = new AdjPoint2DContext( *this, xAttribs, mrCustomShapeProperties, mrAdjustHandle.pos );	// CT_AdjPoint2D
714 	return xContext;
715 }
716 
717 // ---------------------------------------------------------------------
718 // CT_PolarAdjustHandle
719 class PolarAdjustHandleContext : public ContextHandler
720 {
721 public:
722     PolarAdjustHandleContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, CustomShapeProperties& rCustomShapeProperties, AdjustHandle& rAdjustHandle );
723 	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);
724 
725 protected:
726     AdjustHandle& mrAdjustHandle;
727 	CustomShapeProperties& mrCustomShapeProperties;
728 };
729 
730 PolarAdjustHandleContext::PolarAdjustHandleContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, CustomShapeProperties& rCustomShapeProperties, AdjustHandle& rAdjustHandle )
731 : ContextHandler( rParent )
732 , mrAdjustHandle( rAdjustHandle )
733 , mrCustomShapeProperties( rCustomShapeProperties )
734 {
735 	const rtl::OUString aEmptyDefault;
736 	AttributeList aAttribs( xAttribs );
737 	if ( aAttribs.hasAttribute( XML_gdRefR ) )
738 	{
739 		mrAdjustHandle.gdRef1 = GetGeomGuideName( aAttribs.getString( XML_gdRefR, aEmptyDefault ) );
740 	}
741 	if ( aAttribs.hasAttribute( XML_minR ) )
742 	{
743 		mrAdjustHandle.min1 = GetAdjCoordinate( mrCustomShapeProperties, aAttribs.getString( XML_minR, aEmptyDefault ), sal_True );
744 	}
745 	if ( aAttribs.hasAttribute( XML_maxR ) )
746 	{
747 		mrAdjustHandle.max1 = GetAdjCoordinate( mrCustomShapeProperties, aAttribs.getString( XML_maxR, aEmptyDefault ), sal_True );
748 	}
749 	if ( aAttribs.hasAttribute( XML_gdRefAng ) )
750 	{
751 		mrAdjustHandle.gdRef2 = GetGeomGuideName( aAttribs.getString( XML_gdRefAng, aEmptyDefault ) );
752 	}
753 	if ( aAttribs.hasAttribute( XML_minAng ) )
754 	{
755 		mrAdjustHandle.min2 = GetAdjAngle( mrCustomShapeProperties, aAttribs.getString( XML_minAng, aEmptyDefault ) );
756 	}
757 	if ( aAttribs.hasAttribute( XML_maxAng ) )
758 	{
759 		mrAdjustHandle.max2 = GetAdjAngle( mrCustomShapeProperties, aAttribs.getString( XML_maxAng, aEmptyDefault ) );
760 	}
761 }
762 
763 Reference< XFastContextHandler > PolarAdjustHandleContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
764 {
765 	Reference< XFastContextHandler > xContext;
766 	if ( aElementToken == A_TOKEN( pos ) )
767 		xContext = new AdjPoint2DContext( *this, xAttribs, mrCustomShapeProperties, mrAdjustHandle.pos );	// CT_AdjPoint2D
768 	return xContext;
769 }
770 
771 // ---------------------------------------------------------------------
772 // CT_AdjustHandleList
773 class AdjustHandleListContext : public ContextHandler
774 {
775 public:
776     AdjustHandleListContext( ContextHandler& rParent, CustomShapeProperties& rCustomShapeProperties, std::vector< AdjustHandle >& rAdjustHandleList );
777 	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);
778 
779 protected:
780     std::vector< AdjustHandle >& mrAdjustHandleList;
781 	CustomShapeProperties& mrCustomShapeProperties;
782 };
783 
784 AdjustHandleListContext::AdjustHandleListContext( ContextHandler& rParent, CustomShapeProperties& rCustomShapeProperties, std::vector< AdjustHandle >& rAdjustHandleList )
785 : ContextHandler( rParent )
786 , mrAdjustHandleList( rAdjustHandleList )
787 , mrCustomShapeProperties( rCustomShapeProperties )
788 {
789 }
790 
791 Reference< XFastContextHandler > AdjustHandleListContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
792 {
793 	Reference< XFastContextHandler > xContext;
794 	if ( aElementToken == A_TOKEN( ahXY ) )			// CT_XYAdjustHandle
795 	{
796 		AdjustHandle aAdjustHandle( sal_False );
797 		mrAdjustHandleList.push_back( aAdjustHandle );
798         xContext = new XYAdjustHandleContext( *this, xAttribs, mrCustomShapeProperties, mrAdjustHandleList.back() );
799 	}
800 	else if ( aElementToken == A_TOKEN( ahPolar ) )	// CT_PolarAdjustHandle
801 	{
802 		AdjustHandle aAdjustHandle( sal_True );
803 		mrAdjustHandleList.push_back( aAdjustHandle );
804 		xContext = new PolarAdjustHandleContext( *this, xAttribs, mrCustomShapeProperties, mrAdjustHandleList.back() );
805 	}
806 	return xContext;
807 }
808 
809 // ---------------------------------------------------------------------
810 // CT_ConnectionSite
811 class ConnectionSiteContext : public ContextHandler
812 {
813 public:
814     ConnectionSiteContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, CustomShapeProperties& rCustomShapeProperties, ConnectionSite& rConnectionSite );
815 	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);
816 
817 protected:
818     ConnectionSite& mrConnectionSite;
819 	CustomShapeProperties& mrCustomShapeProperties;
820 };
821 
822 ConnectionSiteContext::ConnectionSiteContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, CustomShapeProperties& rCustomShapeProperties, ConnectionSite& rConnectionSite )
823 : ContextHandler( rParent )
824 , mrConnectionSite( rConnectionSite )
825 , mrCustomShapeProperties( rCustomShapeProperties )
826 {
827 	mrConnectionSite.ang = GetAdjAngle( mrCustomShapeProperties, xAttribs->getOptionalValue( XML_ang ) );
828 }
829 
830 Reference< XFastContextHandler > ConnectionSiteContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
831 {
832 	Reference< XFastContextHandler > xContext;
833 	if ( aElementToken == A_TOKEN( pos ) )
834 		xContext = new AdjPoint2DContext( *this, xAttribs, mrCustomShapeProperties, mrConnectionSite.pos );	// CT_AdjPoint2D
835 	return xContext;
836 }
837 
838 // ---------------------------------------------------------------------
839 // CT_Path2DMoveTo
840 class Path2DMoveToContext : public ContextHandler
841 {
842 public:
843     Path2DMoveToContext( ContextHandler& rParent, CustomShapeProperties& rCustomShapeProperties, EnhancedCustomShapeParameterPair& rAdjPoint2D );
844 	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);
845 
846 protected:
847     EnhancedCustomShapeParameterPair& mrAdjPoint2D;
848 	CustomShapeProperties& mrCustomShapeProperties;
849 };
850 
851 Path2DMoveToContext::Path2DMoveToContext( ContextHandler& rParent, CustomShapeProperties& rCustomShapeProperties, EnhancedCustomShapeParameterPair& rAdjPoint2D )
852 : ContextHandler( rParent )
853 , mrAdjPoint2D( rAdjPoint2D )
854 , mrCustomShapeProperties( rCustomShapeProperties )
855 {
856 }
857 
858 Reference< XFastContextHandler > Path2DMoveToContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
859 {
860 	Reference< XFastContextHandler > xContext;
861 	if ( aElementToken == A_TOKEN( pt ) )
862 		xContext = new AdjPoint2DContext( *this, xAttribs, mrCustomShapeProperties, mrAdjPoint2D );		// CT_AdjPoint2D
863 	return xContext;
864 }
865 
866 // ---------------------------------------------------------------------
867 // CT_Path2DLineTo
868 class Path2DLineToContext : public ContextHandler
869 {
870 public:
871     Path2DLineToContext( ContextHandler& rParent, CustomShapeProperties& rCustomShapeProperties, EnhancedCustomShapeParameterPair& rAdjPoint2D );
872 	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);
873 
874 protected:
875     EnhancedCustomShapeParameterPair& mrAdjPoint2D;
876 	CustomShapeProperties& mrCustomShapeProperties;
877 };
878 
879 Path2DLineToContext::Path2DLineToContext( ContextHandler& rParent, CustomShapeProperties& rCustomShapeProperties, EnhancedCustomShapeParameterPair& rAdjPoint2D )
880 : ContextHandler( rParent )
881 , mrAdjPoint2D( rAdjPoint2D )
882 , mrCustomShapeProperties( rCustomShapeProperties )
883 {
884 }
885 
886 Reference< XFastContextHandler > Path2DLineToContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
887 {
888 	Reference< XFastContextHandler > xContext;
889 	if ( aElementToken == A_TOKEN( pt ) )
890 		xContext = new AdjPoint2DContext( *this, xAttribs, mrCustomShapeProperties, mrAdjPoint2D );		// CT_AdjPoint2D
891 	return xContext;
892 }
893 
894 // ---------------------------------------------------------------------
895 // CT_Path2DQuadBezierTo
896 class Path2DQuadBezierToContext : public ContextHandler
897 {
898 public:
899     Path2DQuadBezierToContext( ContextHandler& rParent, CustomShapeProperties& rCustomShapeProperties, EnhancedCustomShapeParameterPair& rPt1, EnhancedCustomShapeParameterPair& rPt2 );
900 	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);
901 
902 protected:
903     EnhancedCustomShapeParameterPair& mrPt1;
904     EnhancedCustomShapeParameterPair& mrPt2;
905 	int nCount;
906 	CustomShapeProperties& mrCustomShapeProperties;
907 };
908 
909 Path2DQuadBezierToContext::Path2DQuadBezierToContext( ContextHandler& rParent,
910 	CustomShapeProperties& rCustomShapeProperties,
911 		EnhancedCustomShapeParameterPair& rPt1,
912 			EnhancedCustomShapeParameterPair& rPt2 )
913 : ContextHandler( rParent )
914 , mrPt1( rPt1 )
915 , mrPt2( rPt2 )
916 , nCount( 0 )
917 , mrCustomShapeProperties( rCustomShapeProperties )
918 {
919 }
920 
921 Reference< XFastContextHandler > Path2DQuadBezierToContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
922 {
923 	Reference< XFastContextHandler > xContext;
924 	if ( aElementToken == A_TOKEN( pt ) )
925 		xContext = new AdjPoint2DContext( *this, xAttribs, mrCustomShapeProperties, nCount++ ? mrPt2 : mrPt1 );	// CT_AdjPoint2D
926 	return xContext;
927 }
928 
929 // ---------------------------------------------------------------------
930 // CT_Path2DCubicBezierTo
931 class Path2DCubicBezierToContext : public ContextHandler
932 {
933 public:
934     Path2DCubicBezierToContext( ContextHandler& rParent, CustomShapeProperties& rCustomShapeProperties,
935 		EnhancedCustomShapeParameterPair&, EnhancedCustomShapeParameterPair&, EnhancedCustomShapeParameterPair& );
936 	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);
937 
938 protected:
939 	CustomShapeProperties& mrCustomShapeProperties;
940 	EnhancedCustomShapeParameterPair& mrControlPt1;
941     EnhancedCustomShapeParameterPair& mrControlPt2;
942     EnhancedCustomShapeParameterPair& mrEndPt;
943 	int nCount;
944 };
945 
946 Path2DCubicBezierToContext::Path2DCubicBezierToContext( ContextHandler& rParent, CustomShapeProperties& rCustomShapeProperties,
947 	EnhancedCustomShapeParameterPair& rControlPt1,
948 		EnhancedCustomShapeParameterPair& rControlPt2,
949 			EnhancedCustomShapeParameterPair& rEndPt )
950 : ContextHandler( rParent )
951 , mrCustomShapeProperties( rCustomShapeProperties )
952 , mrControlPt1( rControlPt1 )
953 , mrControlPt2( rControlPt2 )
954 , mrEndPt( rEndPt )
955 , nCount( 0 )
956 {
957 }
958 
959 Reference< XFastContextHandler > Path2DCubicBezierToContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
960 {
961 	Reference< XFastContextHandler > xContext;
962 	if ( aElementToken == A_TOKEN( pt ) )
963 		xContext = new AdjPoint2DContext( *this, xAttribs, mrCustomShapeProperties,
964 			nCount++ ? nCount == 2 ? mrControlPt2 : mrEndPt : mrControlPt1 );	// CT_AdjPoint2D
965 	return xContext;
966 }
967 
968 // ---------------------------------------------------------------------
969 // CT_Path2DContext
970 class Path2DContext : public ContextHandler
971 {
972 public:
973     Path2DContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, CustomShapeProperties& rCustomShapeProperties, std::vector< com::sun::star::drawing::EnhancedCustomShapeSegment >& rSegments, Path2D& rPath2D );
974 	virtual ~Path2DContext();
975 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL
976 		createFastChildContext( sal_Int32 aElementToken, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs )
977 			throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
978 
979 protected:
980 	Path2D& mrPath2D;
981 	std::vector< com::sun::star::drawing::EnhancedCustomShapeSegment >& mrSegments;
982 	CustomShapeProperties& mrCustomShapeProperties;
983 };
984 
985 Path2DContext::Path2DContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, CustomShapeProperties& rCustomShapeProperties, std::vector< com::sun::star::drawing::EnhancedCustomShapeSegment >& rSegments, Path2D& rPath2D )
986 : ContextHandler( rParent )
987 , mrPath2D( rPath2D )
988 , mrSegments( rSegments )
989 , mrCustomShapeProperties( rCustomShapeProperties )
990 {
991 	const rtl::OUString aEmptyString;
992 
993 	AttributeList aAttribs( xAttribs );
994 	rPath2D.w = aAttribs.getString( XML_w, aEmptyString ).toInt64();
995 	rPath2D.h = aAttribs.getString( XML_h, aEmptyString ).toInt64();
996 	rPath2D.fill = aAttribs.getToken( XML_fill, XML_norm );
997 	rPath2D.stroke = aAttribs.getBool( XML_stroke, sal_True );
998 	rPath2D.extrusionOk = aAttribs.getBool( XML_extrusionOk, sal_True );
999 }
1000 
1001 Path2DContext::~Path2DContext()
1002 {
1003 	EnhancedCustomShapeSegment aNewSegment;
1004 	if ( mrPath2D.fill == XML_none )
1005 	{
1006 		aNewSegment.Command = EnhancedCustomShapeSegmentCommand::NOFILL;
1007 		aNewSegment.Count = 0;
1008 		mrSegments.push_back( aNewSegment );
1009 	}
1010 	aNewSegment.Command = EnhancedCustomShapeSegmentCommand::ENDSUBPATH;
1011 	aNewSegment.Count = 0;
1012 	mrSegments.push_back( aNewSegment );
1013 }
1014 
1015 Reference< XFastContextHandler > Path2DContext::createFastChildContext( sal_Int32 aElementToken,
1016 	const Reference< XFastAttributeList >& xAttribs ) throw ( SAXException, RuntimeException )
1017 {
1018 	Reference< XFastContextHandler > xContext;
1019 	switch( aElementToken )
1020 	{
1021 		case A_TOKEN( close ) :
1022 		{
1023 			EnhancedCustomShapeSegment aNewSegment;
1024 			aNewSegment.Command = EnhancedCustomShapeSegmentCommand::CLOSESUBPATH;
1025 			aNewSegment.Count = 0;
1026 			mrSegments.push_back( aNewSegment );
1027 		}
1028 		break;
1029 		case A_TOKEN( moveTo ) :
1030 		{
1031 			EnhancedCustomShapeSegment aNewSegment;
1032 			aNewSegment.Command = EnhancedCustomShapeSegmentCommand::MOVETO;
1033 			aNewSegment.Count = 1;
1034 			mrSegments.push_back( aNewSegment );
1035 
1036 			EnhancedCustomShapeParameterPair aAdjPoint2D;
1037 			mrPath2D.parameter.push_back( aAdjPoint2D );
1038 			xContext = new Path2DMoveToContext( *this, mrCustomShapeProperties, mrPath2D.parameter.back() );
1039 		}
1040 		break;
1041 		case A_TOKEN( lnTo ) :
1042 		{
1043 
1044 			if ( !mrSegments.empty() && ( mrSegments.back().Command == EnhancedCustomShapeSegmentCommand::LINETO ) )
1045 				mrSegments.back().Count++;
1046 			else
1047 			{
1048 				EnhancedCustomShapeSegment aSegment;
1049 				aSegment.Command = EnhancedCustomShapeSegmentCommand::LINETO;
1050 				aSegment.Count = 1;
1051 				mrSegments.push_back( aSegment );
1052 			}
1053 			EnhancedCustomShapeParameterPair aAdjPoint2D;
1054 			mrPath2D.parameter.push_back( aAdjPoint2D );
1055 			xContext = new Path2DLineToContext( *this, mrCustomShapeProperties, mrPath2D.parameter.back() );
1056 		}
1057 		break;
1058 		case A_TOKEN( arcTo ) :	// CT_Path2DArcTo
1059 		{
1060 			if ( !mrSegments.empty() && ( mrSegments.back().Command == EnhancedCustomShapeSegmentCommand::ARCTO ) )
1061 				mrSegments.back().Count++;
1062 			else
1063 			{
1064 				EnhancedCustomShapeSegment aSegment;
1065 				aSegment.Command = EnhancedCustomShapeSegmentCommand::ARCTO;
1066 				aSegment.Count = 1;
1067 				mrSegments.push_back( aSegment );
1068 			}
1069 			EnhancedCustomShapeParameter aWidth = GetAdjCoordinate( mrCustomShapeProperties, xAttribs->getOptionalValue( XML_wR ), sal_True );
1070 			EnhancedCustomShapeParameter aHeight = GetAdjCoordinate( mrCustomShapeProperties, xAttribs->getOptionalValue( XML_hR ), sal_True );
1071 			EnhancedCustomShapeParameter aStartAngle = GetAdjAngle( mrCustomShapeProperties, xAttribs->getOptionalValue( XML_stAng ) );
1072 			EnhancedCustomShapeParameter swAngle = GetAdjAngle( mrCustomShapeProperties, xAttribs->getOptionalValue( XML_swAng ) );
1073 
1074 			EnhancedCustomShapeParameterPair aPt1;	// TODO: conversion from (wr hr stAng swAng)
1075 			EnhancedCustomShapeParameterPair aPt2;	// to (x1 y1 x2 y2 x3 y3 x y) needed
1076 			EnhancedCustomShapeParameterPair aPt3;
1077 			EnhancedCustomShapeParameterPair aPt;
1078 			mrPath2D.parameter.push_back( aPt1 );
1079 			mrPath2D.parameter.push_back( aPt2 );
1080 			mrPath2D.parameter.push_back( aPt3 );
1081 			mrPath2D.parameter.push_back( aPt );
1082 		}
1083 		break;
1084 		case A_TOKEN( quadBezTo ) :
1085 		{
1086 			if ( !mrSegments.empty() && ( mrSegments.back().Command == EnhancedCustomShapeSegmentCommand::QUADRATICCURVETO ) )
1087 				mrSegments.back().Count++;
1088 			else
1089 			{
1090 				EnhancedCustomShapeSegment aSegment;
1091 				aSegment.Command = EnhancedCustomShapeSegmentCommand::QUADRATICCURVETO;
1092 				aSegment.Count = 1;
1093 				mrSegments.push_back( aSegment );
1094 			}
1095 			EnhancedCustomShapeParameterPair aPt1;
1096 			EnhancedCustomShapeParameterPair aPt2;
1097 			mrPath2D.parameter.push_back( aPt1 );
1098 			mrPath2D.parameter.push_back( aPt2 );
1099 			xContext = new Path2DQuadBezierToContext( *this, mrCustomShapeProperties,
1100 							mrPath2D.parameter[ mrPath2D.parameter.size() - 2 ],
1101 								mrPath2D.parameter.back() );
1102 		}
1103 		break;
1104 		case A_TOKEN( cubicBezTo ) :
1105 		{
1106 			if ( !mrSegments.empty() && ( mrSegments.back().Command == EnhancedCustomShapeSegmentCommand::CURVETO ) )
1107 				mrSegments.back().Count++;
1108 			else
1109 			{
1110 				EnhancedCustomShapeSegment aSegment;
1111 				aSegment.Command = EnhancedCustomShapeSegmentCommand::CURVETO;
1112 				aSegment.Count = 1;
1113 				mrSegments.push_back( aSegment );
1114 			}
1115 			EnhancedCustomShapeParameterPair aControlPt1;
1116 			EnhancedCustomShapeParameterPair aControlPt2;
1117 			EnhancedCustomShapeParameterPair aEndPt;
1118 			mrPath2D.parameter.push_back( aControlPt1 );
1119 			mrPath2D.parameter.push_back( aControlPt2 );
1120 			mrPath2D.parameter.push_back( aEndPt );
1121 			xContext = new Path2DCubicBezierToContext( *this, mrCustomShapeProperties,
1122 							mrPath2D.parameter[ mrPath2D.parameter.size() - 3 ],
1123 								mrPath2D.parameter[ mrPath2D.parameter.size() - 2 ],
1124 									mrPath2D.parameter.back() );
1125 		}
1126 		break;
1127 	}
1128 	return xContext;
1129 }
1130 
1131 // ---------------------------------------------------------------------
1132 // CT_Path2DList
1133 class Path2DListContext : public ContextHandler
1134 {
1135 public:
1136 	Path2DListContext( ContextHandler& rParent, CustomShapeProperties& rCustomShapeProperties, std::vector< EnhancedCustomShapeSegment >& rSegments,
1137 		std::vector< Path2D >& rPath2DList );
1138 
1139 	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);
1140 
1141 protected:
1142 
1143 	CustomShapeProperties& mrCustomShapeProperties;
1144 	std::vector< com::sun::star::drawing::EnhancedCustomShapeSegment >& mrSegments;
1145 	std::vector< Path2D >& mrPath2DList;
1146 };
1147 
1148 Path2DListContext::Path2DListContext( ContextHandler& rParent, CustomShapeProperties& rCustomShapeProperties, std::vector< EnhancedCustomShapeSegment >& rSegments,
1149 										std::vector< Path2D >& rPath2DList )
1150 : ContextHandler( rParent )
1151 , mrCustomShapeProperties( rCustomShapeProperties )
1152 , mrSegments( rSegments )
1153 , mrPath2DList( rPath2DList )
1154 {
1155 }
1156 
1157 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL Path2DListContext::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)
1158 {
1159 	Reference< XFastContextHandler > xContext;
1160 	if ( aElementToken == A_TOKEN( path ) )
1161 	{
1162 		Path2D aPath2D;
1163 		mrPath2DList.push_back( aPath2D );
1164 		xContext = new Path2DContext( *this, xAttribs, mrCustomShapeProperties,  mrSegments, mrPath2DList.back() );
1165 	}
1166 	return xContext;
1167 }
1168 
1169 // ---------------------------------------------------------------------
1170 
1171 OUString GetShapeType( sal_Int32 nType )
1172 {
1173 	OUString sType;
1174  	switch( nType )
1175 	{
1176 		case XML_lineInv:	// TODO
1177 		case XML_line: {
1178             static const OUString sLine = CREATE_OUSTRING( "mso-spt20" );
1179 			sType = sLine;
1180 			} break;
1181 		case XML_triangle: {
1182             static const OUString sTriangle = CREATE_OUSTRING( "isosceles-triangle" );
1183 			sType = sTriangle;
1184 			} break;
1185 		case XML_rtTriangle: {
1186             static const OUString sRtTriangle = CREATE_OUSTRING( "right-triangle" );
1187 			sType = sRtTriangle;
1188 			} break;
1189 		case XML_rect: {
1190             static const OUString sRectangle = CREATE_OUSTRING( "rectangle" );
1191 			sType = sRectangle;
1192 			} break;
1193 		case XML_diamond: {
1194             static const OUString sDiamond = CREATE_OUSTRING( "diamond" );
1195 			sType = sDiamond;
1196 			} break;
1197 		case XML_parallelogram: {
1198             static const OUString sParallelogram = CREATE_OUSTRING( "parallelogram" );
1199 			sType = sParallelogram;
1200 			} break;
1201 		case XML_nonIsoscelesTrapezoid:		// TODO
1202 		case XML_trapezoid: {
1203             static const OUString sTrapezoid = CREATE_OUSTRING( "trapezoid" );
1204 			sType = sTrapezoid;
1205 			} break;
1206 		case XML_pentagon: {
1207             static const OUString sPentagon = CREATE_OUSTRING( "pentagon" );
1208 			sType = sPentagon;
1209 			} break;
1210 		case XML_heptagon:					// TODO
1211 		case XML_hexagon: {
1212             static const OUString sHexagon = CREATE_OUSTRING( "hexagon" );
1213 			sType = sHexagon;
1214 			} break;
1215 		case XML_decagon:					// TODO
1216 		case XML_dodecagon:					// TODO
1217 		case XML_octagon: {
1218             static const OUString sOctagon = CREATE_OUSTRING( "octagon" );
1219 			sType = sOctagon;
1220 			} break;
1221 		case XML_star4: {
1222             static const OUString sStar4 = CREATE_OUSTRING( "star4" );
1223 			sType = sStar4;
1224 			} break;
1225 		case XML_star6:						// TODO
1226 		case XML_star7:						// TODO
1227 		case XML_star5: {
1228             static const OUString sStar5 = CREATE_OUSTRING( "star5" );
1229 			sType = sStar5;
1230 			} break;
1231 		case XML_star10:					// TODO
1232 		case XML_star12:					// TODO
1233 		case XML_star16:					// TODO
1234 		case XML_star8: {
1235             static const OUString sStar8 = CREATE_OUSTRING( "star8" );
1236 			sType = sStar8;
1237 			} break;
1238 		case XML_star32:					// TODO
1239 		case XML_star24: {
1240             static const OUString sStar24 = CREATE_OUSTRING( "star24" );
1241 			sType = sStar24;
1242 			} break;
1243 		case XML_round1Rect:				// TODO
1244 		case XML_round2SameRect:			// TODO
1245 		case XML_round2DiagRect:			// TODO
1246 		case XML_snipRoundRect:				// TODO
1247 		case XML_snip1Rect:					// TODO
1248 		case XML_snip2SameRect:				// TODO
1249 		case XML_snip2DiagRect:				// TODO
1250 		case XML_roundRect: {
1251             static const OUString sRoundRect = CREATE_OUSTRING( "round-rectangle" );
1252 			sType = sRoundRect;
1253 			} break;
1254 		case XML_plaque: {
1255             static const OUString sPlaque = CREATE_OUSTRING( "mso-spt21" );
1256 			sType = sPlaque;
1257 			} break;
1258 		case XML_teardrop:					// TODO
1259 		case XML_ellipse: {
1260             static const OUString sEllipse = CREATE_OUSTRING( "ellipse" );
1261 			sType = sEllipse;
1262 			} break;
1263 		case XML_homePlate: {
1264             static const OUString sHomePlate = CREATE_OUSTRING( "pentagon-right" );
1265 			sType = sHomePlate;
1266 			} break;
1267 		case XML_chevron: {
1268             static const OUString sChevron = CREATE_OUSTRING( "chevron" );
1269 			sType = sChevron;
1270 			} break;
1271 		case XML_pieWedge:					// TODO
1272 		case XML_pie:						// TODO
1273 		case XML_blockArc: {
1274             static const OUString sBlockArc = CREATE_OUSTRING( "block-arc" );
1275 			sType = sBlockArc;
1276 			} break;
1277 		case XML_donut: {
1278             static const OUString sDonut = CREATE_OUSTRING( "ring" );
1279 			sType = sDonut;
1280 			} break;
1281 		case XML_noSmoking: {
1282             static const OUString sNoSmoking = CREATE_OUSTRING( "forbidden" );
1283 			sType = sNoSmoking;
1284 			} break;
1285 		case XML_rightArrow: {
1286             static const OUString sRightArrow = CREATE_OUSTRING( "right-arrow" );
1287 			sType = sRightArrow;
1288 			} break;
1289 		case XML_leftArrow: {
1290             static const OUString sLeftArrow = CREATE_OUSTRING( "left-arrow" );
1291 			sType = sLeftArrow;
1292 			} break;
1293 		case XML_upArrow: {
1294             static const OUString sUpArrow = CREATE_OUSTRING( "up-arrow" );
1295 			sType = sUpArrow;
1296 			} break;
1297 		case XML_downArrow: {
1298             static const OUString sDownArrow = CREATE_OUSTRING( "down-arrow" );
1299 			sType = sDownArrow;
1300 			} break;
1301 		case XML_stripedRightArrow: {
1302             static const OUString sStripedRightArrow = CREATE_OUSTRING( "striped-right-arrow" );
1303 			sType = sStripedRightArrow;
1304 			} break;
1305 		case XML_notchedRightArrow: {
1306             static const OUString sNotchedRightArrow = CREATE_OUSTRING( "notched-right-arrow" );
1307 			sType = sNotchedRightArrow;
1308 			} break;
1309 		case XML_bentUpArrow: {
1310             static const OUString sBentUpArrow = CREATE_OUSTRING( "mso-spt90" );
1311 			sType = sBentUpArrow;
1312 			} break;
1313 		case XML_leftRightArrow: {
1314             static const OUString sLeftRightArrow = CREATE_OUSTRING( "left-right-arrow" );
1315 			sType = sLeftRightArrow;
1316 			} break;
1317 		case XML_upDownArrow: {
1318             static const OUString sUpDownArrow = CREATE_OUSTRING( "up-down-arrow" );
1319 			sType = sUpDownArrow;
1320 			} break;
1321 		case XML_leftUpArrow: {
1322             static const OUString sLeftUpArrow = CREATE_OUSTRING( "mso-spt89" );
1323 			sType = sLeftUpArrow;
1324 			} break;
1325 		case XML_leftRightUpArrow: {
1326             static const OUString sLeftRightUpArrow = CREATE_OUSTRING( "mso-spt182" );
1327 			sType = sLeftRightUpArrow;
1328 			} break;
1329 		case XML_quadArrow: {
1330             static const OUString sQuadArrow = CREATE_OUSTRING( "quad-arrow" );
1331 			sType = sQuadArrow;
1332 			} break;
1333 		case XML_leftArrowCallout: {
1334             static const OUString sLeftArrowCallout = CREATE_OUSTRING( "left-arrow-callout" );
1335 			sType = sLeftArrowCallout;
1336 			} break;
1337 		case XML_rightArrowCallout: {
1338             static const OUString sRightArrowCallout = CREATE_OUSTRING( "right-arrow-callout" );
1339 			sType = sRightArrowCallout;
1340 			} break;
1341 		case XML_upArrowCallout: {
1342             static const OUString sUpArrowCallout = CREATE_OUSTRING( "up-arrow-callout" );
1343 			sType = sUpArrowCallout;
1344 			} break;
1345 		case XML_downArrowCallout: {
1346             static const OUString sDownArrowCallout = CREATE_OUSTRING( "down-arrow-callout" );
1347 			sType = sDownArrowCallout;
1348 			} break;
1349 		case XML_leftRightArrowCallout: {
1350             static const OUString sLeftRightArrowCallout = CREATE_OUSTRING( "left-right-arrow-callout" );
1351 			sType = sLeftRightArrowCallout;
1352 			} break;
1353 		case XML_upDownArrowCallout: {
1354             static const OUString sUpDownArrowCallout = CREATE_OUSTRING( "up-down-arrow-callout" );
1355 			sType = sUpDownArrowCallout;
1356 			} break;
1357 		case XML_quadArrowCallout: {
1358             static const OUString sQuadArrowCallout = CREATE_OUSTRING( "quad-arrow-callout" );
1359 			sType = sQuadArrowCallout;
1360 			} break;
1361 		case XML_bentArrow: {
1362             static const OUString sBentArrow = CREATE_OUSTRING( "mso-spt91" );
1363 			sType = sBentArrow;
1364 			} break;
1365 		case XML_uturnArrow: {
1366             static const OUString sUTurnArrow = CREATE_OUSTRING( "mso-spt101" );
1367 			sType = sUTurnArrow;
1368 			} break;
1369 		case XML_leftCircularArrow:			// TODO
1370 		case XML_leftRightCircularArrow:	// TODO
1371 		case XML_circularArrow: {
1372             static const OUString sCircularArrow = CREATE_OUSTRING( "circular-arrow" );
1373 			sType = sCircularArrow;
1374 			} break;
1375 		case XML_curvedRightArrow: {
1376             static const OUString sCurvedRightArrow = CREATE_OUSTRING( "mso-spt102" );
1377 			sType = sCurvedRightArrow;
1378 			} break;
1379 		case XML_curvedLeftArrow: {
1380             static const OUString sCurvedLeftArrow = CREATE_OUSTRING( "mso-spt103" );
1381 			sType = sCurvedLeftArrow;
1382 			} break;
1383 		case XML_curvedUpArrow: {
1384             static const OUString sCurvedUpArrow = CREATE_OUSTRING( "mso-spt104" );
1385 			sType = sCurvedUpArrow;
1386 			} break;
1387 		case XML_swooshArrow:				// TODO
1388 		case XML_curvedDownArrow: {
1389             static const OUString sCurvedDownArrow = CREATE_OUSTRING( "mso-spt105" );
1390 			sType = sCurvedDownArrow;
1391 			} break;
1392 		case XML_cube: {
1393             static const OUString sCube = CREATE_OUSTRING( "cube" );
1394 			sType = sCube;
1395 			} break;
1396 		case XML_can: {
1397             static const OUString sCan = CREATE_OUSTRING( "can" );
1398 			sType = sCan;
1399 			} break;
1400 		case XML_lightningBolt: {
1401             static const OUString sLightningBolt = CREATE_OUSTRING( "lightning" );
1402 			sType = sLightningBolt;
1403 			} break;
1404 		case XML_heart: {
1405             static const OUString sHeart = CREATE_OUSTRING( "heart" );
1406 			sType = sHeart;
1407 			} break;
1408 		case XML_sun: {
1409             static const OUString sSun = CREATE_OUSTRING( "sun" );
1410 			sType = sSun;
1411 			} break;
1412 		case XML_moon: {
1413             static const OUString sMoon = CREATE_OUSTRING( "moon" );
1414 			sType = sMoon;
1415 			} break;
1416 		case XML_smileyFace: {
1417             static const OUString sSmileyFace = CREATE_OUSTRING( "smiley" );
1418 			sType = sSmileyFace;
1419 			} break;
1420 		case XML_irregularSeal1: {
1421             static const OUString sIrregularSeal1 = CREATE_OUSTRING( "mso-spt71" );
1422 			sType = sIrregularSeal1;
1423 			} break;
1424 		case XML_irregularSeal2: {
1425             static const OUString sIrregularSeal2 = CREATE_OUSTRING( "bang" );
1426 			sType = sIrregularSeal2;
1427 			} break;
1428 		case XML_foldedCorner: {
1429             static const OUString sFoldedCorner = CREATE_OUSTRING( "paper" );
1430 			sType = sFoldedCorner;
1431 			} break;
1432 		case XML_bevel: {
1433             static const OUString sBevel = CREATE_OUSTRING( "quad-bevel" );
1434 			sType = sBevel;
1435 			} break;
1436 		case XML_halfFrame:					// TODO
1437 		case XML_corner:					// TODO
1438 		case XML_diagStripe:				// TODO
1439 		case XML_chord:						// TODO
1440 		case XML_frame: {
1441             static const OUString sFrame = CREATE_OUSTRING( "mso-spt75" );
1442 			sType = sFrame;
1443 			} break;
1444 		case XML_arc: {
1445             static const OUString sArc = CREATE_OUSTRING( "mso-spt19" );
1446 			sType = sArc;
1447 			} break;
1448 		case XML_leftBracket: {
1449             static const OUString sLeftBracket = CREATE_OUSTRING( "left-bracket" );
1450 			sType = sLeftBracket;
1451 			} break;
1452 		case XML_rightBracket: {
1453             static const OUString sRightBracket = CREATE_OUSTRING( "right-bracket" );
1454 			sType = sRightBracket;
1455 			} break;
1456 		case XML_leftBrace: {
1457             static const OUString sLeftBrace = CREATE_OUSTRING( "left-brace" );
1458 			sType = sLeftBrace;
1459 			} break;
1460 		case XML_rightBrace: {
1461             static const OUString sRightBrace = CREATE_OUSTRING( "right-brace" );
1462 			sType = sRightBrace;
1463 			} break;
1464 		case XML_bracketPair: {
1465             static const OUString sBracketPair = CREATE_OUSTRING( "bracket-pair" );
1466 			sType = sBracketPair;
1467 			} break;
1468 		case XML_bracePair: {
1469             static const OUString sBracePair = CREATE_OUSTRING( "brace-pair" );
1470 			sType = sBracePair;
1471 			} break;
1472 		case XML_straightConnector1: {
1473             static const OUString sStraightConnector1 = CREATE_OUSTRING( "mso-spt32" );
1474 			sType = sStraightConnector1;
1475 			} break;
1476 		case XML_bentConnector2: {
1477             static const OUString sBentConnector2 = CREATE_OUSTRING( "mso-spt33" );
1478 			sType = sBentConnector2;
1479 			} break;
1480 		case XML_bentConnector3: {
1481             static const OUString sBentConnector3 = CREATE_OUSTRING( "mso-spt34" );
1482 			sType = sBentConnector3;
1483 			} break;
1484 		case XML_bentConnector4: {
1485             static const OUString sBentConnector4 = CREATE_OUSTRING( "mso-spt35" );
1486 			sType = sBentConnector4;
1487 			} break;
1488 		case XML_bentConnector5: {
1489             static const OUString sBentConnector5 = CREATE_OUSTRING( "mso-spt36" );
1490 			sType = sBentConnector5;
1491 			} break;
1492 		case XML_curvedConnector2: {
1493             static const OUString sCurvedConnector2 = CREATE_OUSTRING( "mso-spt37" );
1494 			sType = sCurvedConnector2;
1495 			} break;
1496 		case XML_curvedConnector3: {
1497             static const OUString sCurvedConnector3 = CREATE_OUSTRING( "mso-spt38" );
1498 			sType = sCurvedConnector3;
1499 			} break;
1500 		case XML_curvedConnector4: {
1501             static const OUString sCurvedConnector4 = CREATE_OUSTRING( "mso-spt39" );
1502 			sType = sCurvedConnector4;
1503 			} break;
1504 		case XML_curvedConnector5: {
1505             static const OUString sCurvedConnector5 = CREATE_OUSTRING( "mso-spt40" );
1506 			sType = sCurvedConnector5;
1507 			} break;
1508 		case XML_callout1: {
1509             static const OUString sCallout1 = CREATE_OUSTRING( "mso-spt41" );
1510 			sType = sCallout1;
1511 			} break;
1512 		case XML_callout2: {
1513             static const OUString sCallout2 = CREATE_OUSTRING( "mso-spt42" );
1514 			sType = sCallout2;
1515 			} break;
1516 		case XML_callout3: {
1517             static const OUString sCallout3 = CREATE_OUSTRING( "mso-spt43" );
1518 			sType = sCallout3;
1519 			} break;
1520 		case XML_accentCallout1: {
1521             static const OUString sAccentCallout1 = CREATE_OUSTRING( "mso-spt44" );
1522 			sType = sAccentCallout1;
1523 			} break;
1524 		case XML_accentCallout2: {
1525             static const OUString sAccentCallout2 = CREATE_OUSTRING( "mso-spt45" );
1526 			sType = sAccentCallout2;
1527 			} break;
1528 		case XML_accentCallout3: {
1529             static const OUString sAccentCallout3 = CREATE_OUSTRING( "mso-spt46" );
1530 			sType = sAccentCallout3;
1531 			} break;
1532 		case XML_borderCallout1: {
1533             static const OUString sBorderCallout1 = CREATE_OUSTRING( "line-callout-1" );
1534 			sType = sBorderCallout1;
1535 			} break;
1536 		case XML_borderCallout2: {
1537             static const OUString sBorderCallout2 = CREATE_OUSTRING( "line-callout-2" );
1538 			sType = sBorderCallout2;
1539 			} break;
1540 		case XML_borderCallout3: {
1541             static const OUString sBorderCallout3 = CREATE_OUSTRING( "mso-spt49" );
1542 			sType = sBorderCallout3;
1543 			} break;
1544 		case XML_accentBorderCallout1: {
1545             static const OUString sAccentBorderCallout1 = CREATE_OUSTRING( "mso-spt50" );
1546 			sType = sAccentBorderCallout1;
1547 			} break;
1548 		case XML_accentBorderCallout2: {
1549             static const OUString sAccentBorderCallout2 = CREATE_OUSTRING( "mso-spt51" );
1550 			sType = sAccentBorderCallout2;
1551 			} break;
1552 		case XML_accentBorderCallout3: {
1553             static const OUString sAccentBorderCallout3 = CREATE_OUSTRING( "mso-spt52" );
1554 			sType = sAccentBorderCallout3;
1555 			} break;
1556 		case XML_wedgeRectCallout: {
1557             static const OUString sWedgeRectCallout = CREATE_OUSTRING( "rectangular-callout" );
1558 			sType = sWedgeRectCallout;
1559 			} break;
1560 		case XML_wedgeRoundRectCallout: {
1561             static const OUString sWedgeRoundRectCallout = CREATE_OUSTRING( "round-rectangular-callout" );
1562 			sType = sWedgeRoundRectCallout;
1563 			} break;
1564 		case XML_wedgeEllipseCallout: {
1565             static const OUString sWedgeEllipseCallout = CREATE_OUSTRING( "round-callout" );
1566 			sType = sWedgeEllipseCallout;
1567 			} break;
1568 		case XML_cloud:						// TODO
1569 		case XML_cloudCallout: {
1570             static const OUString sCloudCallout = CREATE_OUSTRING( "cloud-callout" );
1571 			sType = sCloudCallout;
1572 			} break;
1573 		case XML_ribbon: {
1574             static const OUString sRibbon = CREATE_OUSTRING( "mso-spt53" );
1575 			sType = sRibbon;
1576 			} break;
1577 		case XML_ribbon2: {
1578             static const OUString sRibbon2 = CREATE_OUSTRING( "mso-spt54" );
1579 			sType = sRibbon2;
1580 			} break;
1581 		case XML_ellipseRibbon: {
1582             static const OUString sEllipseRibbon = CREATE_OUSTRING( "mso-spt107" );
1583 			sType = sEllipseRibbon;
1584 			} break;
1585 		case XML_leftRightRibbon:			// TODO
1586 		case XML_ellipseRibbon2: {
1587             static const OUString sEllipseRibbon2 = CREATE_OUSTRING( "mso-spt108" );
1588 			sType = sEllipseRibbon2;
1589 			} break;
1590 		case XML_verticalScroll: {
1591             static const OUString sVerticalScroll = CREATE_OUSTRING( "vertical-scroll" );
1592 			sType = sVerticalScroll;
1593 			} break;
1594 		case XML_horizontalScroll: {
1595             static const OUString sHorizontalScroll = CREATE_OUSTRING( "horizontal-scroll" );
1596 			sType = sHorizontalScroll;
1597 			} break;
1598 		case XML_wave: {
1599             static const OUString sWave = CREATE_OUSTRING( "mso-spt64" );
1600 			sType = sWave;
1601 			} break;
1602 		case XML_doubleWave: {
1603             static const OUString sDoubleWave = CREATE_OUSTRING( "mso-spt188" );
1604 			sType = sDoubleWave;
1605 			} break;
1606 		case XML_plus: {
1607             static const OUString sPlus = CREATE_OUSTRING( "cross" );
1608 			sType = sPlus;
1609 			} break;
1610 		case XML_flowChartProcess: {
1611             static const OUString sFlowChartProcess = CREATE_OUSTRING( "flowchart-process" );
1612 			sType = sFlowChartProcess;
1613 			} break;
1614 		case XML_flowChartDecision: {
1615             static const OUString sFlowChartDecision = CREATE_OUSTRING( "flowchart-decision" );
1616 			sType = sFlowChartDecision;
1617 			} break;
1618 		case XML_flowChartInputOutput: {
1619             static const OUString sFlowChartInputOutput = CREATE_OUSTRING( "flowchart-data" );
1620 			sType = sFlowChartInputOutput;
1621 			} break;
1622 		case XML_flowChartPredefinedProcess: {
1623             static const OUString sFlowChartPredefinedProcess = CREATE_OUSTRING( "flowchart-predefined-process" );
1624 			sType = sFlowChartPredefinedProcess;
1625 			} break;
1626 		case XML_flowChartInternalStorage: {
1627             static const OUString sFlowChartInternalStorage = CREATE_OUSTRING( "flowchart-internal-storage" );
1628 			sType = sFlowChartInternalStorage;
1629 			} break;
1630 		case XML_flowChartDocument: {
1631             static const OUString sFlowChartDocument = CREATE_OUSTRING( "flowchart-document" );
1632 			sType = sFlowChartDocument;
1633 			} break;
1634 		case XML_flowChartMultidocument: {
1635             static const OUString sFlowChartMultidocument = CREATE_OUSTRING( "flowchart-multidocument" );
1636 			sType = sFlowChartMultidocument;
1637 			} break;
1638 		case XML_flowChartTerminator: {
1639             static const OUString sFlowChartTerminator = CREATE_OUSTRING( "flowchart-terminator" );
1640 			sType = sFlowChartTerminator;
1641 			} break;
1642 		case XML_flowChartPreparation : {
1643             static const OUString sFlowChartPreparation = CREATE_OUSTRING( "flowchart-preparation" );
1644 			sType = sFlowChartPreparation;
1645 			} break;
1646 		case XML_flowChartManualInput: {
1647             static const OUString sFlowChartManualInput = CREATE_OUSTRING( "flowchart-manual-input" );
1648 			sType = sFlowChartManualInput;
1649 			} break;
1650 		case XML_flowChartManualOperation: {
1651             static const OUString sFlowChartManualOperation = CREATE_OUSTRING( "flowchart-manual-operation" );
1652 			sType = sFlowChartManualOperation;
1653 			} break;
1654 		case XML_flowChartConnector: {
1655             static const OUString sFlowChartConnector = CREATE_OUSTRING( "flowchart-connector" );
1656 			sType = sFlowChartConnector;
1657 			} break;
1658 		case XML_flowChartPunchedCard: {
1659             static const OUString sFlowChartPunchedCard = CREATE_OUSTRING( "flowchart-card" );
1660 			sType = sFlowChartPunchedCard;
1661 			} break;
1662 		case XML_flowChartPunchedTape: {
1663             static const OUString sFlowChartPunchedTape = CREATE_OUSTRING( "flowchart-punched-tape" );
1664 			sType = sFlowChartPunchedTape;
1665 			} break;
1666 		case XML_flowChartSummingJunction: {
1667             static const OUString sFlowChartSummingJunction = CREATE_OUSTRING( "flowchart-summing-junction" );
1668 			sType = sFlowChartSummingJunction;
1669 			} break;
1670 		case XML_flowChartOr: {
1671             static const OUString sFlowChartOr = CREATE_OUSTRING( "flowchart-or" );
1672 			sType = sFlowChartOr;
1673 			} break;
1674 		case XML_flowChartCollate: {
1675             static const OUString sFlowChartCollate = CREATE_OUSTRING( "flowchart-collate" );
1676 			sType = sFlowChartCollate;
1677 			} break;
1678 		case XML_flowChartSort: {
1679             static const OUString sFlowChartSort = CREATE_OUSTRING( "flowchart-sort" );
1680 			sType = sFlowChartSort;
1681 			} break;
1682 		case XML_flowChartExtract: {
1683             static const OUString sFlowChartExtract = CREATE_OUSTRING( "flowchart-extract" );
1684 			sType = sFlowChartExtract;
1685 			} break;
1686 		case XML_flowChartMerge: {
1687             static const OUString sFlowChartMerge = CREATE_OUSTRING( "flowchart-merge" );
1688 			sType = sFlowChartMerge;
1689 			} break;
1690 		case XML_flowChartOfflineStorage: {
1691             static const OUString sFlowChartOfflineStorage = CREATE_OUSTRING( "mso-spt129" );
1692 			sType = sFlowChartOfflineStorage;
1693 			} break;
1694 		case XML_flowChartOnlineStorage: {
1695             static const OUString sFlowChartOnlineStorage = CREATE_OUSTRING( "flowchart-stored-data" );
1696 			sType = sFlowChartOnlineStorage;
1697 			} break;
1698 		case XML_flowChartMagneticTape: {
1699             static const OUString sFlowChartMagneticTape = CREATE_OUSTRING( "flowchart-sequential-access" );
1700 			sType = sFlowChartMagneticTape;
1701 			} break;
1702 		case XML_flowChartMagneticDisk: {
1703             static const OUString sFlowChartMagneticDisk = CREATE_OUSTRING( "flowchart-magnetic-disk" );
1704 			sType = sFlowChartMagneticDisk;
1705 			} break;
1706 		case XML_flowChartMagneticDrum: {
1707             static const OUString sFlowChartMagneticDrum = CREATE_OUSTRING( "flowchart-direct-access-storage" );
1708 			sType = sFlowChartMagneticDrum;
1709 			} break;
1710 		case XML_flowChartDisplay: {
1711             static const OUString sFlowChartDisplay = CREATE_OUSTRING( "flowchart-display" );
1712 			sType = sFlowChartDisplay;
1713 			} break;
1714 		case XML_flowChartDelay: {
1715             static const OUString sFlowChartDelay = CREATE_OUSTRING( "flowchart-delay" );
1716 			sType = sFlowChartDelay;
1717 			} break;
1718 		case XML_flowChartAlternateProcess: {
1719             static const OUString sFlowChartAlternateProcess = CREATE_OUSTRING( "flowchart-alternate-process" );
1720 			sType = sFlowChartAlternateProcess;
1721 			} break;
1722 		case XML_flowChartOffpageConnector: {
1723             static const OUString sFlowChartOffpageConnector = CREATE_OUSTRING( "flowchart-off-page-connector" );
1724 			sType = sFlowChartOffpageConnector;
1725 			} break;
1726 		case XML_actionButtonBlank: {
1727             static const OUString sActionButtonBlank = CREATE_OUSTRING( "mso-spt189" );
1728 			sType = sActionButtonBlank;
1729 			} break;
1730 		case XML_actionButtonHome: {
1731             static const OUString sActionButtonHome = CREATE_OUSTRING( "mso-spt190" );
1732 			sType = sActionButtonHome;
1733 			} break;
1734 		case XML_actionButtonHelp: {
1735             static const OUString sActionButtonHelp = CREATE_OUSTRING( "mso-spt191" );
1736 			sType = sActionButtonHelp;
1737 			} break;
1738 		case XML_actionButtonInformation: {
1739             static const OUString sActionButtonInformation = CREATE_OUSTRING( "mso-spt192" );
1740 			sType = sActionButtonInformation;
1741 			} break;
1742 		case XML_actionButtonForwardNext: {
1743             static const OUString sActionButtonForwardNext = CREATE_OUSTRING( "mso-spt193" );
1744 			sType = sActionButtonForwardNext;
1745 			} break;
1746 		case XML_actionButtonBackPrevious: {
1747             static const OUString sActionButtonBackPrevious = CREATE_OUSTRING( "mso-spt194" );
1748 			sType = sActionButtonBackPrevious;
1749 			} break;
1750 		case XML_actionButtonEnd: {
1751             static const OUString sActionButtonEnd = CREATE_OUSTRING( "mso-spt195" );
1752 			sType = sActionButtonEnd;
1753 			} break;
1754 		case XML_actionButtonBeginning: {
1755             static const OUString sActionButtonBeginning = CREATE_OUSTRING( "mso-spt196" );
1756 			sType = sActionButtonBeginning;
1757 			} break;
1758 		case XML_actionButtonReturn: {
1759             static const OUString sActionButtonReturn = CREATE_OUSTRING( "mso-spt197" );
1760 			sType = sActionButtonReturn;
1761 			} break;
1762 		case XML_actionButtonDocument: {
1763             static const OUString sActionButtonDocument = CREATE_OUSTRING( "mso-spt198" );
1764 			sType = sActionButtonDocument;
1765 			} break;
1766 		case XML_actionButtonSound: {
1767             static const OUString sActionButtonSound = CREATE_OUSTRING( "mso-spt199" );
1768 			sType = sActionButtonSound;
1769 			} break;
1770 		case XML_actionButtonMovie: {
1771             static const OUString sActionButtonMovie = CREATE_OUSTRING( "mso-spt200" );
1772 			sType = sActionButtonMovie;
1773 			} break;
1774 		case XML_gear6:						// TODO
1775 		case XML_gear9:						// TODO
1776 		case XML_funnel:					// TODO
1777 		case XML_mathPlus:					// TODO
1778 		case XML_mathMinus:					// TODO
1779 		case XML_mathMultiply:				// TODO
1780 		case XML_mathDivide:				// TODO
1781 		case XML_mathEqual:					// TODO
1782 		case XML_mathNotEqual:				// TODO
1783 		case XML_cornerTabs:				// TODO
1784 		case XML_squareTabs:				// TODO
1785 		case XML_plaqueTabs:				// TODO
1786 		case XML_chartX:					// TODO
1787 		case XML_chartStar:					// TODO
1788 		case XML_chartPlus: {				// TODO
1789             static const OUString sRectangle = CREATE_OUSTRING( "rectangle" );
1790 			sType = sRectangle;
1791 			} break;
1792 		default:
1793 			break;
1794 	}
1795 	return sType;
1796 }
1797 
1798 static OUString GetTextShapeType( sal_Int32 nType )
1799 {
1800 	OUString sType;
1801 	switch( nType )
1802 	{
1803 		case XML_textNoShape:				// TODO
1804 		case XML_textPlain: {
1805             static const OUString sTextPlain = CREATE_OUSTRING( "fontwork-plain-text" );
1806 			sType = sTextPlain;
1807 			} break;
1808 		case XML_textStop: {
1809             static const OUString sTextStop = CREATE_OUSTRING( "fontwork-stop" );
1810 			sType = sTextStop;
1811 			} break;
1812 		case XML_textTriangle: {
1813             static const OUString sTextTriangle = CREATE_OUSTRING( "fontwork-triangle-up" );
1814 			sType = sTextTriangle;
1815 			} break;
1816 		case XML_textTriangleInverted: {
1817             static const OUString sTextTriangleInverted = CREATE_OUSTRING( "fontwork-triangle-down" );
1818 			sType = sTextTriangleInverted;
1819 			} break;
1820 		case XML_textChevron: {
1821             static const OUString sTextChevron = CREATE_OUSTRING( "fontwork-chevron-up" );
1822 			sType = sTextChevron;
1823 			} break;
1824 		case XML_textChevronInverted: {
1825             static const OUString sTextChevronInverted = CREATE_OUSTRING( "fontwork-chevron-down" );
1826 			sType = sTextChevronInverted;
1827 			} break;
1828 		case XML_textRingInside: {
1829             static const OUString sTextRingInside = CREATE_OUSTRING( "mso-spt142" );
1830 			sType = sTextRingInside;
1831 			} break;
1832 		case XML_textRingOutside: {
1833             static const OUString sTextRingOutside = CREATE_OUSTRING( "mso-spt143" );
1834 			sType = sTextRingOutside;
1835 			} break;
1836 		case XML_textArchUp: {
1837             static const OUString sTextArchUp = CREATE_OUSTRING( "fontwork-arch-up-curve" );
1838 			sType = sTextArchUp;
1839 			} break;
1840 		case XML_textArchDown: {
1841             static const OUString sTextArchDown = CREATE_OUSTRING( "fontwork-arch-down-curve" );
1842 			sType = sTextArchDown;
1843 			} break;
1844 		case XML_textCircle: {
1845             static const OUString sTextCircle = CREATE_OUSTRING( "fontwork-circle-curve" );
1846 			sType = sTextCircle;
1847 			} break;
1848 		case XML_textButton: {
1849             static const OUString sTextButton = CREATE_OUSTRING( "fontwork-open-circle-curve" );
1850 			sType = sTextButton;
1851 			} break;
1852 		case XML_textArchUpPour: {
1853             static const OUString sTextArchUpPour = CREATE_OUSTRING( "fontwork-arch-up-pour" );
1854 			sType = sTextArchUpPour;
1855 			} break;
1856 		case XML_textArchDownPour: {
1857             static const OUString sTextArchDownPour = CREATE_OUSTRING( "fontwork-arch-down-pour" );
1858 			sType = sTextArchDownPour;
1859 			} break;
1860 		case XML_textCirclePour: {
1861             static const OUString sTextCirclePour = CREATE_OUSTRING( "fontwork-circle-pour" );
1862 			sType = sTextCirclePour;
1863 			} break;
1864 		case XML_textButtonPour: {
1865             static const OUString sTextButtonPour = CREATE_OUSTRING( "fontwork-open-circle-pour" );
1866 			sType = sTextButtonPour;
1867 			} break;
1868 		case XML_textCurveUp: {
1869             static const OUString sTextCurveUp = CREATE_OUSTRING( "fontwork-curve-up" );
1870 			sType = sTextCurveUp;
1871 			} break;
1872 		case XML_textCurveDown: {
1873             static const OUString sTextCurveDown = CREATE_OUSTRING( "fontwork-curve-down" );
1874 			sType = sTextCurveDown;
1875 			} break;
1876 		case XML_textCanUp: {
1877             static const OUString sTextCanUp = CREATE_OUSTRING( "mso-spt174" );
1878 			sType = sTextCanUp;
1879 			} break;
1880 		case XML_textCanDown: {
1881             static const OUString sTextCanDown = CREATE_OUSTRING( "mso-spt175" );
1882 			sType = sTextCanDown;
1883 			} break;
1884 		case XML_textWave1: {
1885             static const OUString sTextWave1 = CREATE_OUSTRING( "fontwork-wave" );
1886 			sType = sTextWave1;
1887 			} break;
1888 		case XML_textWave2: {
1889             static const OUString sTextWave2 = CREATE_OUSTRING( "mso-spt157" );
1890 			sType = sTextWave2;
1891 			} break;
1892 		case XML_textDoubleWave1: {
1893             static const OUString sTextDoubleWave1 = CREATE_OUSTRING( "mso-spt158" );
1894 			sType = sTextDoubleWave1;
1895 			} break;
1896 		case XML_textWave4: {
1897             static const OUString sTextWave4 = CREATE_OUSTRING( "mso-spt159" );
1898 			sType = sTextWave4;
1899 			} break;
1900 		case XML_textInflate: {
1901             static const OUString sTextInflate = CREATE_OUSTRING( "fontwork-inflate" );
1902 			sType = sTextInflate;
1903 			} break;
1904 		case XML_textDeflate: {
1905             static const OUString sTextDeflate = CREATE_OUSTRING( "mso-spt161" );
1906 			sType = sTextDeflate;
1907 			} break;
1908 		case XML_textInflateBottom: {
1909             static const OUString sTextInflateBottom = CREATE_OUSTRING( "mso-spt162" );
1910 			sType = sTextInflateBottom;
1911 			} break;
1912 		case XML_textDeflateBottom: {
1913             static const OUString sTextDeflateBottom = CREATE_OUSTRING( "mso-spt163" );
1914 			sType = sTextDeflateBottom;
1915 			} break;
1916 		case XML_textInflateTop: {
1917             static const OUString sTextInflateTop = CREATE_OUSTRING( "mso-spt164" );
1918 			sType = sTextInflateTop;
1919 			} break;
1920 		case XML_textDeflateTop: {
1921             static const OUString sTextDeflateTop = CREATE_OUSTRING( "mso-spt165" );
1922 			sType = sTextDeflateTop;
1923 			} break;
1924 		case XML_textDeflateInflate: {
1925             static const OUString sTextDeflateInflate = CREATE_OUSTRING( "mso-spt166" );
1926 			sType = sTextDeflateInflate;
1927 			} break;
1928 		case XML_textDeflateInflateDeflate: {
1929             static const OUString sTextDeflateInflateDeflate = CREATE_OUSTRING( "mso-spt167" );
1930 			sType = sTextDeflateInflateDeflate;
1931 			} break;
1932 		case XML_textFadeRight: {
1933             static const OUString sTextFadeRight = CREATE_OUSTRING( "fontwork-fade-right" );
1934 			sType = sTextFadeRight;
1935 			} break;
1936 		case XML_textFadeLeft: {
1937             static const OUString sTextFadeLeft = CREATE_OUSTRING( "fontwork-fade-left" );
1938 			sType = sTextFadeLeft;
1939 			} break;
1940 		case XML_textFadeUp: {
1941             static const OUString sTextFadeUp = CREATE_OUSTRING( "fontwork-fade-up" );
1942 			sType = sTextFadeUp;
1943 			} break;
1944 		case XML_textFadeDown: {
1945             static const OUString sTextFadeDown = CREATE_OUSTRING( "fontwork-fade-down" );
1946 			sType = sTextFadeDown;
1947 			} break;
1948 		case XML_textSlantUp: {
1949             static const OUString sTextSlantUp = CREATE_OUSTRING( "fontwork-slant-up" );
1950 			sType = sTextSlantUp;
1951 			} break;
1952 		case XML_textSlantDown: {
1953             static const OUString sTextSlantDown = CREATE_OUSTRING( "fontwork-slant-down" );
1954 			sType = sTextSlantDown;
1955 			} break;
1956 		case XML_textCascadeUp: {
1957             static const OUString sTextCascadeUp = CREATE_OUSTRING( "fontwork-fade-up-and-right" );
1958 			sType = sTextCascadeUp;
1959 			} break;
1960 		case XML_textCascadeDown: {
1961             static const OUString sTextCascadeDown = CREATE_OUSTRING( "fontwork-fade-up-and-left" );
1962 			sType = sTextCascadeDown;
1963 			} break;
1964 		default:
1965 		break;
1966 	}
1967 	return sType;
1968 }
1969 
1970 // ---------------------------------------------------------------------
1971 // CT_CustomGeometry2D
1972 CustomShapeGeometryContext::CustomShapeGeometryContext( ContextHandler& rParent, const Reference< XFastAttributeList >& /* xAttribs */, CustomShapeProperties& rCustomShapeProperties )
1973 : ContextHandler( rParent )
1974 , mrCustomShapeProperties( rCustomShapeProperties )
1975 {
1976 }
1977 
1978 Reference< XFastContextHandler > CustomShapeGeometryContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
1979 {
1980 	Reference< XFastContextHandler > xContext;
1981 	switch( aElementToken )
1982 	{
1983 		case A_TOKEN( avLst ):			// CT_GeomGuideList adjust value list
1984 			xContext = new GeomGuideListContext( *this, mrCustomShapeProperties, mrCustomShapeProperties.getAdjustmentGuideList() );
1985 		break;
1986 		case A_TOKEN( gdLst ):			// CT_GeomGuideList guide list
1987 			xContext = new GeomGuideListContext( *this, mrCustomShapeProperties, mrCustomShapeProperties.getGuideList() );
1988 		break;
1989 		case A_TOKEN( ahLst ):			// CT_AdjustHandleList adjust handle list
1990 			xContext = new AdjustHandleListContext( *this, mrCustomShapeProperties, mrCustomShapeProperties.getAdjustHandleList() );
1991 		break;
1992 		case A_TOKEN( cxnLst ):			// CT_ConnectionSiteList connection site list
1993 			xContext = this;
1994 		break;
1995 		case A_TOKEN( rect ):			// CT_GeomRectList geometry rect list
1996 		{
1997 			GeomRect aGeomRect;
1998 			aGeomRect.l = GetAdjCoordinate( mrCustomShapeProperties, xAttribs->getOptionalValue( XML_l ), sal_True );
1999 			aGeomRect.t = GetAdjCoordinate( mrCustomShapeProperties, xAttribs->getOptionalValue( XML_t ), sal_True );
2000 			aGeomRect.r = GetAdjCoordinate( mrCustomShapeProperties, xAttribs->getOptionalValue( XML_r ), sal_True );
2001 			aGeomRect.b = GetAdjCoordinate( mrCustomShapeProperties, xAttribs->getOptionalValue( XML_b ), sal_True );
2002 			mrCustomShapeProperties.getTextRect() = aGeomRect;
2003 		}
2004 		break;
2005 		case A_TOKEN( pathLst ):		// CT_Path2DList 2d path list
2006 			xContext = new Path2DListContext( *this, mrCustomShapeProperties, mrCustomShapeProperties.getSegments(), mrCustomShapeProperties.getPath2DList() );
2007 		break;
2008 
2009 		// from cxnLst:
2010 		case A_TOKEN( cxn ):				// CT_ConnectionSite
2011 		{
2012 			ConnectionSite aConnectionSite;
2013 			mrCustomShapeProperties.getConnectionSiteList().push_back( aConnectionSite );
2014 			xContext = new ConnectionSiteContext( *this, xAttribs, mrCustomShapeProperties, mrCustomShapeProperties.getConnectionSiteList().back() );
2015 		}
2016 		break;
2017 	}
2018 	return xContext;
2019 }
2020 
2021 // ---------------------------------------------------------------------
2022 // CT_PresetGeometry2D
2023 PresetShapeGeometryContext::PresetShapeGeometryContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, CustomShapeProperties& rCustomShapeProperties )
2024 : ContextHandler( rParent )
2025 , mrCustomShapeProperties( rCustomShapeProperties )
2026 {
2027 	OUString sShapeType;
2028 	sal_Int32 nShapeType = xAttribs->getOptionalValueToken( XML_prst, FastToken::DONTKNOW );
2029 	if ( nShapeType != FastToken::DONTKNOW )
2030 		sShapeType = GetShapeType( nShapeType );
2031 	OSL_ENSURE( sShapeType.getLength(), "oox::drawingml::CustomShapeCustomGeometryContext::CustomShapeCustomGeometryContext(), unknown shape type" );
2032 	mrCustomShapeProperties.setShapePresetType( sShapeType );
2033 }
2034 
2035 Reference< XFastContextHandler > PresetShapeGeometryContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& ) throw (SAXException, RuntimeException)
2036 {
2037 	if ( aElementToken == A_TOKEN( avLst ) )
2038         return new GeomGuideListContext( *this, mrCustomShapeProperties, mrCustomShapeProperties.getAdjustmentGuideList() );
2039 	else
2040 		return this;
2041 }
2042 
2043 // ---------------------------------------------------------------------
2044 // CT_PresetTextShape
2045 PresetTextShapeContext::PresetTextShapeContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, CustomShapeProperties& rCustomShapeProperties )
2046 : ContextHandler( rParent )
2047 , mrCustomShapeProperties( rCustomShapeProperties )
2048 {
2049 	OUString sShapeType;
2050 	sal_Int32 nShapeType = xAttribs->getOptionalValueToken( XML_prst, FastToken::DONTKNOW );
2051 	if ( nShapeType != FastToken::DONTKNOW )
2052 		sShapeType = GetTextShapeType( nShapeType );
2053 	OSL_ENSURE( sShapeType.getLength(), "oox::drawingml::CustomShapeCustomGeometryContext::CustomShapeCustomGeometryContext(), unknown shape type" );
2054 	mrCustomShapeProperties.setShapePresetType( sShapeType );
2055 }
2056 
2057 Reference< XFastContextHandler > PresetTextShapeContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& ) throw (SAXException, RuntimeException)
2058 {
2059 	if ( aElementToken == A_TOKEN( avLst ) )
2060         return new GeomGuideListContext( *this, mrCustomShapeProperties, mrCustomShapeProperties.getAdjustmentGuideList() );
2061 	else
2062 		return this;
2063 }
2064 
2065 } }
2066