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