xref: /trunk/main/oox/source/drawingml/customshapegeometry.cxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
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 );
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 )
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 );
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 )
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 );
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 )
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 );
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 )
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 );
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 )
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 );
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 )
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 );
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 )
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 );
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 )
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 );
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 )
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 
974 protected:
975     Path2D& mrPath2D;
976     std::vector< com::sun::star::drawing::EnhancedCustomShapeSegment >& mrSegments;
977     CustomShapeProperties& mrCustomShapeProperties;
978 };
979 
Path2DContext(ContextHandler & rParent,const Reference<XFastAttributeList> & xAttribs,CustomShapeProperties & rCustomShapeProperties,std::vector<com::sun::star::drawing::EnhancedCustomShapeSegment> & rSegments,Path2D & rPath2D)980 Path2DContext::Path2DContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, CustomShapeProperties& rCustomShapeProperties, std::vector< com::sun::star::drawing::EnhancedCustomShapeSegment >& rSegments, Path2D& rPath2D )
981 : ContextHandler( rParent )
982 , mrPath2D( rPath2D )
983 , mrSegments( rSegments )
984 , mrCustomShapeProperties( rCustomShapeProperties )
985 {
986     const rtl::OUString aEmptyString;
987 
988     AttributeList aAttribs( xAttribs );
989     rPath2D.w = aAttribs.getString( XML_w, aEmptyString ).toInt64();
990     rPath2D.h = aAttribs.getString( XML_h, aEmptyString ).toInt64();
991     rPath2D.fill = aAttribs.getToken( XML_fill, XML_norm );
992     rPath2D.stroke = aAttribs.getBool( XML_stroke, sal_True );
993     rPath2D.extrusionOk = aAttribs.getBool( XML_extrusionOk, sal_True );
994 }
995 
~Path2DContext()996 Path2DContext::~Path2DContext()
997 {
998     EnhancedCustomShapeSegment aNewSegment;
999     if ( mrPath2D.fill == XML_none )
1000     {
1001         aNewSegment.Command = EnhancedCustomShapeSegmentCommand::NOFILL;
1002         aNewSegment.Count = 0;
1003         mrSegments.push_back( aNewSegment );
1004     }
1005     aNewSegment.Command = EnhancedCustomShapeSegmentCommand::ENDSUBPATH;
1006     aNewSegment.Count = 0;
1007     mrSegments.push_back( aNewSegment );
1008 }
1009 
createFastChildContext(sal_Int32 aElementToken,const Reference<XFastAttributeList> & xAttribs)1010 Reference< XFastContextHandler > Path2DContext::createFastChildContext( sal_Int32 aElementToken,
1011     const Reference< XFastAttributeList >& xAttribs )
1012 {
1013     Reference< XFastContextHandler > xContext;
1014     switch( aElementToken )
1015     {
1016         case A_TOKEN( close ) :
1017         {
1018             EnhancedCustomShapeSegment aNewSegment;
1019             aNewSegment.Command = EnhancedCustomShapeSegmentCommand::CLOSESUBPATH;
1020             aNewSegment.Count = 0;
1021             mrSegments.push_back( aNewSegment );
1022         }
1023         break;
1024         case A_TOKEN( moveTo ) :
1025         {
1026             EnhancedCustomShapeSegment aNewSegment;
1027             aNewSegment.Command = EnhancedCustomShapeSegmentCommand::MOVETO;
1028             aNewSegment.Count = 1;
1029             mrSegments.push_back( aNewSegment );
1030 
1031             EnhancedCustomShapeParameterPair aAdjPoint2D;
1032             mrPath2D.parameter.push_back( aAdjPoint2D );
1033             xContext = new Path2DMoveToContext( *this, mrCustomShapeProperties, mrPath2D.parameter.back() );
1034         }
1035         break;
1036         case A_TOKEN( lnTo ) :
1037         {
1038 
1039             if ( !mrSegments.empty() && ( mrSegments.back().Command == EnhancedCustomShapeSegmentCommand::LINETO ) )
1040                 mrSegments.back().Count++;
1041             else
1042             {
1043                 EnhancedCustomShapeSegment aSegment;
1044                 aSegment.Command = EnhancedCustomShapeSegmentCommand::LINETO;
1045                 aSegment.Count = 1;
1046                 mrSegments.push_back( aSegment );
1047             }
1048             EnhancedCustomShapeParameterPair aAdjPoint2D;
1049             mrPath2D.parameter.push_back( aAdjPoint2D );
1050             xContext = new Path2DLineToContext( *this, mrCustomShapeProperties, mrPath2D.parameter.back() );
1051         }
1052         break;
1053         case A_TOKEN( arcTo ) : // CT_Path2DArcTo
1054         {
1055             if ( !mrSegments.empty() && ( mrSegments.back().Command == EnhancedCustomShapeSegmentCommand::ARCTO ) )
1056                 mrSegments.back().Count++;
1057             else
1058             {
1059                 EnhancedCustomShapeSegment aSegment;
1060                 aSegment.Command = EnhancedCustomShapeSegmentCommand::ARCTO;
1061                 aSegment.Count = 1;
1062                 mrSegments.push_back( aSegment );
1063             }
1064             EnhancedCustomShapeParameter aWidth = GetAdjCoordinate( mrCustomShapeProperties, xAttribs->getOptionalValue( XML_wR ), sal_True );
1065             EnhancedCustomShapeParameter aHeight = GetAdjCoordinate( mrCustomShapeProperties, xAttribs->getOptionalValue( XML_hR ), sal_True );
1066             EnhancedCustomShapeParameter aStartAngle = GetAdjAngle( mrCustomShapeProperties, xAttribs->getOptionalValue( XML_stAng ) );
1067             EnhancedCustomShapeParameter swAngle = GetAdjAngle( mrCustomShapeProperties, xAttribs->getOptionalValue( XML_swAng ) );
1068 
1069             EnhancedCustomShapeParameterPair aPt1;  // TODO: conversion from (wr hr stAng swAng)
1070             EnhancedCustomShapeParameterPair aPt2;  // to (x1 y1 x2 y2 x3 y3 x y) needed
1071             EnhancedCustomShapeParameterPair aPt3;
1072             EnhancedCustomShapeParameterPair aPt;
1073             mrPath2D.parameter.push_back( aPt1 );
1074             mrPath2D.parameter.push_back( aPt2 );
1075             mrPath2D.parameter.push_back( aPt3 );
1076             mrPath2D.parameter.push_back( aPt );
1077         }
1078         break;
1079         case A_TOKEN( quadBezTo ) :
1080         {
1081             if ( !mrSegments.empty() && ( mrSegments.back().Command == EnhancedCustomShapeSegmentCommand::QUADRATICCURVETO ) )
1082                 mrSegments.back().Count++;
1083             else
1084             {
1085                 EnhancedCustomShapeSegment aSegment;
1086                 aSegment.Command = EnhancedCustomShapeSegmentCommand::QUADRATICCURVETO;
1087                 aSegment.Count = 1;
1088                 mrSegments.push_back( aSegment );
1089             }
1090             EnhancedCustomShapeParameterPair aPt1;
1091             EnhancedCustomShapeParameterPair aPt2;
1092             mrPath2D.parameter.push_back( aPt1 );
1093             mrPath2D.parameter.push_back( aPt2 );
1094             xContext = new Path2DQuadBezierToContext( *this, mrCustomShapeProperties,
1095                             mrPath2D.parameter[ mrPath2D.parameter.size() - 2 ],
1096                                 mrPath2D.parameter.back() );
1097         }
1098         break;
1099         case A_TOKEN( cubicBezTo ) :
1100         {
1101             if ( !mrSegments.empty() && ( mrSegments.back().Command == EnhancedCustomShapeSegmentCommand::CURVETO ) )
1102                 mrSegments.back().Count++;
1103             else
1104             {
1105                 EnhancedCustomShapeSegment aSegment;
1106                 aSegment.Command = EnhancedCustomShapeSegmentCommand::CURVETO;
1107                 aSegment.Count = 1;
1108                 mrSegments.push_back( aSegment );
1109             }
1110             EnhancedCustomShapeParameterPair aControlPt1;
1111             EnhancedCustomShapeParameterPair aControlPt2;
1112             EnhancedCustomShapeParameterPair aEndPt;
1113             mrPath2D.parameter.push_back( aControlPt1 );
1114             mrPath2D.parameter.push_back( aControlPt2 );
1115             mrPath2D.parameter.push_back( aEndPt );
1116             xContext = new Path2DCubicBezierToContext( *this, mrCustomShapeProperties,
1117                             mrPath2D.parameter[ mrPath2D.parameter.size() - 3 ],
1118                                 mrPath2D.parameter[ mrPath2D.parameter.size() - 2 ],
1119                                     mrPath2D.parameter.back() );
1120         }
1121         break;
1122     }
1123     return xContext;
1124 }
1125 
1126 // ---------------------------------------------------------------------
1127 // CT_Path2DList
1128 class Path2DListContext : public ContextHandler
1129 {
1130 public:
1131     Path2DListContext( ContextHandler& rParent, CustomShapeProperties& rCustomShapeProperties, std::vector< EnhancedCustomShapeSegment >& rSegments,
1132         std::vector< Path2D >& rPath2DList );
1133 
1134     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 );
1135 
1136 protected:
1137 
1138     CustomShapeProperties& mrCustomShapeProperties;
1139     std::vector< com::sun::star::drawing::EnhancedCustomShapeSegment >& mrSegments;
1140     std::vector< Path2D >& mrPath2DList;
1141 };
1142 
Path2DListContext(ContextHandler & rParent,CustomShapeProperties & rCustomShapeProperties,std::vector<EnhancedCustomShapeSegment> & rSegments,std::vector<Path2D> & rPath2DList)1143 Path2DListContext::Path2DListContext( ContextHandler& rParent, CustomShapeProperties& rCustomShapeProperties, std::vector< EnhancedCustomShapeSegment >& rSegments,
1144                                         std::vector< Path2D >& rPath2DList )
1145 : ContextHandler( rParent )
1146 , mrCustomShapeProperties( rCustomShapeProperties )
1147 , mrSegments( rSegments )
1148 , mrPath2DList( rPath2DList )
1149 {
1150 }
1151 
createFastChildContext(sal_Int32 aElementToken,const::com::sun::star::uno::Reference<::com::sun::star::xml::sax::XFastAttributeList> & xAttribs)1152 ::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 )
1153 {
1154     Reference< XFastContextHandler > xContext;
1155     if ( aElementToken == A_TOKEN( path ) )
1156     {
1157         Path2D aPath2D;
1158         mrPath2DList.push_back( aPath2D );
1159         xContext = new Path2DContext( *this, xAttribs, mrCustomShapeProperties,  mrSegments, mrPath2DList.back() );
1160     }
1161     return xContext;
1162 }
1163 
1164 // ---------------------------------------------------------------------
1165 
GetShapeType(sal_Int32 nType)1166 OUString GetShapeType( sal_Int32 nType )
1167 {
1168     OUString sType;
1169     switch( nType )
1170     {
1171         case XML_lineInv:   // TODO
1172         case XML_line: {
1173             static const OUString sLine = CREATE_OUSTRING( "mso-spt20" );
1174             sType = sLine;
1175             } break;
1176         case XML_triangle: {
1177             static const OUString sTriangle = CREATE_OUSTRING( "isosceles-triangle" );
1178             sType = sTriangle;
1179             } break;
1180         case XML_rtTriangle: {
1181             static const OUString sRtTriangle = CREATE_OUSTRING( "right-triangle" );
1182             sType = sRtTriangle;
1183             } break;
1184         case XML_rect: {
1185             static const OUString sRectangle = CREATE_OUSTRING( "rectangle" );
1186             sType = sRectangle;
1187             } break;
1188         case XML_diamond: {
1189             static const OUString sDiamond = CREATE_OUSTRING( "diamond" );
1190             sType = sDiamond;
1191             } break;
1192         case XML_parallelogram: {
1193             static const OUString sParallelogram = CREATE_OUSTRING( "parallelogram" );
1194             sType = sParallelogram;
1195             } break;
1196         case XML_nonIsoscelesTrapezoid:     // TODO
1197         case XML_trapezoid: {
1198             static const OUString sTrapezoid = CREATE_OUSTRING( "trapezoid" );
1199             sType = sTrapezoid;
1200             } break;
1201         case XML_pentagon: {
1202             static const OUString sPentagon = CREATE_OUSTRING( "pentagon" );
1203             sType = sPentagon;
1204             } break;
1205         case XML_heptagon:                  // TODO
1206         case XML_hexagon: {
1207             static const OUString sHexagon = CREATE_OUSTRING( "hexagon" );
1208             sType = sHexagon;
1209             } break;
1210         case XML_decagon:                   // TODO
1211         case XML_dodecagon:                 // TODO
1212         case XML_octagon: {
1213             static const OUString sOctagon = CREATE_OUSTRING( "octagon" );
1214             sType = sOctagon;
1215             } break;
1216         case XML_star4: {
1217             static const OUString sStar4 = CREATE_OUSTRING( "star4" );
1218             sType = sStar4;
1219             } break;
1220         case XML_star6:                     // TODO
1221         case XML_star7:                     // TODO
1222         case XML_star5: {
1223             static const OUString sStar5 = CREATE_OUSTRING( "star5" );
1224             sType = sStar5;
1225             } break;
1226         case XML_star10:                    // TODO
1227         case XML_star12:                    // TODO
1228         case XML_star16:                    // TODO
1229         case XML_star8: {
1230             static const OUString sStar8 = CREATE_OUSTRING( "star8" );
1231             sType = sStar8;
1232             } break;
1233         case XML_star32:                    // TODO
1234         case XML_star24: {
1235             static const OUString sStar24 = CREATE_OUSTRING( "star24" );
1236             sType = sStar24;
1237             } break;
1238         case XML_round1Rect:                // TODO
1239         case XML_round2SameRect:            // TODO
1240         case XML_round2DiagRect:            // TODO
1241         case XML_snipRoundRect:             // TODO
1242         case XML_snip1Rect:                 // TODO
1243         case XML_snip2SameRect:             // TODO
1244         case XML_snip2DiagRect:             // TODO
1245         case XML_roundRect: {
1246             static const OUString sRoundRect = CREATE_OUSTRING( "round-rectangle" );
1247             sType = sRoundRect;
1248             } break;
1249         case XML_plaque: {
1250             static const OUString sPlaque = CREATE_OUSTRING( "mso-spt21" );
1251             sType = sPlaque;
1252             } break;
1253         case XML_teardrop:{
1254             static const OUString sTearDrop = CREATE_OUSTRING( "teardrop" );
1255             sType = sTearDrop;
1256             } break;
1257         case XML_ellipse: {
1258             static const OUString sEllipse = CREATE_OUSTRING( "ellipse" );
1259             sType = sEllipse;
1260             } break;
1261         case XML_homePlate: {
1262             static const OUString sHomePlate = CREATE_OUSTRING( "pentagon-right" );
1263             sType = sHomePlate;
1264             } break;
1265         case XML_chevron: {
1266             static const OUString sChevron = CREATE_OUSTRING( "chevron" );
1267             sType = sChevron;
1268             } break;
1269         case XML_pieWedge:                  // TODO
1270         case XML_pie:                       // TODO
1271         case XML_blockArc: {
1272             static const OUString sBlockArc = CREATE_OUSTRING( "block-arc" );
1273             sType = sBlockArc;
1274             } break;
1275         case XML_donut: {
1276             static const OUString sDonut = CREATE_OUSTRING( "ring" );
1277             sType = sDonut;
1278             } break;
1279         case XML_noSmoking: {
1280             static const OUString sNoSmoking = CREATE_OUSTRING( "forbidden" );
1281             sType = sNoSmoking;
1282             } break;
1283         case XML_rightArrow: {
1284             static const OUString sRightArrow = CREATE_OUSTRING( "right-arrow" );
1285             sType = sRightArrow;
1286             } break;
1287         case XML_leftArrow: {
1288             static const OUString sLeftArrow = CREATE_OUSTRING( "left-arrow" );
1289             sType = sLeftArrow;
1290             } break;
1291         case XML_upArrow: {
1292             static const OUString sUpArrow = CREATE_OUSTRING( "up-arrow" );
1293             sType = sUpArrow;
1294             } break;
1295         case XML_downArrow: {
1296             static const OUString sDownArrow = CREATE_OUSTRING( "down-arrow" );
1297             sType = sDownArrow;
1298             } break;
1299         case XML_stripedRightArrow: {
1300             static const OUString sStripedRightArrow = CREATE_OUSTRING( "striped-right-arrow" );
1301             sType = sStripedRightArrow;
1302             } break;
1303         case XML_notchedRightArrow: {
1304             static const OUString sNotchedRightArrow = CREATE_OUSTRING( "notched-right-arrow" );
1305             sType = sNotchedRightArrow;
1306             } break;
1307         case XML_bentUpArrow: {
1308             static const OUString sBentUpArrow = CREATE_OUSTRING( "mso-spt90" );
1309             sType = sBentUpArrow;
1310             } break;
1311         case XML_leftRightArrow: {
1312             static const OUString sLeftRightArrow = CREATE_OUSTRING( "left-right-arrow" );
1313             sType = sLeftRightArrow;
1314             } break;
1315         case XML_upDownArrow: {
1316             static const OUString sUpDownArrow = CREATE_OUSTRING( "up-down-arrow" );
1317             sType = sUpDownArrow;
1318             } break;
1319         case XML_leftUpArrow: {
1320             static const OUString sLeftUpArrow = CREATE_OUSTRING( "mso-spt89" );
1321             sType = sLeftUpArrow;
1322             } break;
1323         case XML_leftRightUpArrow: {
1324             static const OUString sLeftRightUpArrow = CREATE_OUSTRING( "mso-spt182" );
1325             sType = sLeftRightUpArrow;
1326             } break;
1327         case XML_quadArrow: {
1328             static const OUString sQuadArrow = CREATE_OUSTRING( "quad-arrow" );
1329             sType = sQuadArrow;
1330             } break;
1331         case XML_leftArrowCallout: {
1332             static const OUString sLeftArrowCallout = CREATE_OUSTRING( "left-arrow-callout" );
1333             sType = sLeftArrowCallout;
1334             } break;
1335         case XML_rightArrowCallout: {
1336             static const OUString sRightArrowCallout = CREATE_OUSTRING( "right-arrow-callout" );
1337             sType = sRightArrowCallout;
1338             } break;
1339         case XML_upArrowCallout: {
1340             static const OUString sUpArrowCallout = CREATE_OUSTRING( "up-arrow-callout" );
1341             sType = sUpArrowCallout;
1342             } break;
1343         case XML_downArrowCallout: {
1344             static const OUString sDownArrowCallout = CREATE_OUSTRING( "down-arrow-callout" );
1345             sType = sDownArrowCallout;
1346             } break;
1347         case XML_leftRightArrowCallout: {
1348             static const OUString sLeftRightArrowCallout = CREATE_OUSTRING( "left-right-arrow-callout" );
1349             sType = sLeftRightArrowCallout;
1350             } break;
1351         case XML_upDownArrowCallout: {
1352             static const OUString sUpDownArrowCallout = CREATE_OUSTRING( "up-down-arrow-callout" );
1353             sType = sUpDownArrowCallout;
1354             } break;
1355         case XML_quadArrowCallout: {
1356             static const OUString sQuadArrowCallout = CREATE_OUSTRING( "quad-arrow-callout" );
1357             sType = sQuadArrowCallout;
1358             } break;
1359         case XML_bentArrow: {
1360             static const OUString sBentArrow = CREATE_OUSTRING( "mso-spt91" );
1361             sType = sBentArrow;
1362             } break;
1363         case XML_uturnArrow: {
1364             static const OUString sUTurnArrow = CREATE_OUSTRING( "mso-spt101" );
1365             sType = sUTurnArrow;
1366             } break;
1367         case XML_leftCircularArrow:         // TODO
1368         case XML_leftRightCircularArrow:    // TODO
1369         case XML_circularArrow: {
1370             static const OUString sCircularArrow = CREATE_OUSTRING( "circular-arrow" );
1371             sType = sCircularArrow;
1372             } break;
1373         case XML_curvedRightArrow: {
1374             static const OUString sCurvedRightArrow = CREATE_OUSTRING( "mso-spt102" );
1375             sType = sCurvedRightArrow;
1376             } break;
1377         case XML_curvedLeftArrow: {
1378             static const OUString sCurvedLeftArrow = CREATE_OUSTRING( "mso-spt103" );
1379             sType = sCurvedLeftArrow;
1380             } break;
1381         case XML_curvedUpArrow: {
1382             static const OUString sCurvedUpArrow = CREATE_OUSTRING( "mso-spt104" );
1383             sType = sCurvedUpArrow;
1384             } break;
1385         case XML_swooshArrow:               // TODO
1386         case XML_curvedDownArrow: {
1387             static const OUString sCurvedDownArrow = CREATE_OUSTRING( "mso-spt105" );
1388             sType = sCurvedDownArrow;
1389             } break;
1390         case XML_cube: {
1391             static const OUString sCube = CREATE_OUSTRING( "cube" );
1392             sType = sCube;
1393             } break;
1394         case XML_can: {
1395             static const OUString sCan = CREATE_OUSTRING( "can" );
1396             sType = sCan;
1397             } break;
1398         case XML_lightningBolt: {
1399             static const OUString sLightningBolt = CREATE_OUSTRING( "lightning" );
1400             sType = sLightningBolt;
1401             } break;
1402         case XML_heart: {
1403             static const OUString sHeart = CREATE_OUSTRING( "heart" );
1404             sType = sHeart;
1405             } break;
1406         case XML_sun: {
1407             static const OUString sSun = CREATE_OUSTRING( "sun" );
1408             sType = sSun;
1409             } break;
1410         case XML_moon: {
1411             static const OUString sMoon = CREATE_OUSTRING( "moon" );
1412             sType = sMoon;
1413             } break;
1414         case XML_smileyFace: {
1415             static const OUString sSmileyFace = CREATE_OUSTRING( "smiley" );
1416             sType = sSmileyFace;
1417             } break;
1418         case XML_irregularSeal1: {
1419             static const OUString sIrregularSeal1 = CREATE_OUSTRING( "mso-spt71" );
1420             sType = sIrregularSeal1;
1421             } break;
1422         case XML_irregularSeal2: {
1423             static const OUString sIrregularSeal2 = CREATE_OUSTRING( "bang" );
1424             sType = sIrregularSeal2;
1425             } break;
1426         case XML_foldedCorner: {
1427             static const OUString sFoldedCorner = CREATE_OUSTRING( "paper" );
1428             sType = sFoldedCorner;
1429             } break;
1430         case XML_bevel: {
1431             static const OUString sBevel = CREATE_OUSTRING( "quad-bevel" );
1432             sType = sBevel;
1433             } break;
1434         case XML_halfFrame:                 // TODO
1435         case XML_corner:                    // TODO
1436         case XML_diagStripe:                // TODO
1437         case XML_chord:                     // TODO
1438         case XML_frame: {
1439             static const OUString sFrame = CREATE_OUSTRING( "mso-spt75" );
1440             sType = sFrame;
1441             } break;
1442         case XML_arc: {
1443             static const OUString sArc = CREATE_OUSTRING( "mso-spt19" );
1444             sType = sArc;
1445             } break;
1446         case XML_leftBracket: {
1447             static const OUString sLeftBracket = CREATE_OUSTRING( "left-bracket" );
1448             sType = sLeftBracket;
1449             } break;
1450         case XML_rightBracket: {
1451             static const OUString sRightBracket = CREATE_OUSTRING( "right-bracket" );
1452             sType = sRightBracket;
1453             } break;
1454         case XML_leftBrace: {
1455             static const OUString sLeftBrace = CREATE_OUSTRING( "left-brace" );
1456             sType = sLeftBrace;
1457             } break;
1458         case XML_rightBrace: {
1459             static const OUString sRightBrace = CREATE_OUSTRING( "right-brace" );
1460             sType = sRightBrace;
1461             } break;
1462         case XML_bracketPair: {
1463             static const OUString sBracketPair = CREATE_OUSTRING( "bracket-pair" );
1464             sType = sBracketPair;
1465             } break;
1466         case XML_bracePair: {
1467             static const OUString sBracePair = CREATE_OUSTRING( "brace-pair" );
1468             sType = sBracePair;
1469             } break;
1470         case XML_straightConnector1: {
1471             static const OUString sStraightConnector1 = CREATE_OUSTRING( "mso-spt32" );
1472             sType = sStraightConnector1;
1473             } break;
1474         case XML_bentConnector2: {
1475             static const OUString sBentConnector2 = CREATE_OUSTRING( "mso-spt33" );
1476             sType = sBentConnector2;
1477             } break;
1478         case XML_bentConnector3: {
1479             static const OUString sBentConnector3 = CREATE_OUSTRING( "mso-spt34" );
1480             sType = sBentConnector3;
1481             } break;
1482         case XML_bentConnector4: {
1483             static const OUString sBentConnector4 = CREATE_OUSTRING( "mso-spt35" );
1484             sType = sBentConnector4;
1485             } break;
1486         case XML_bentConnector5: {
1487             static const OUString sBentConnector5 = CREATE_OUSTRING( "mso-spt36" );
1488             sType = sBentConnector5;
1489             } break;
1490         case XML_curvedConnector2: {
1491             static const OUString sCurvedConnector2 = CREATE_OUSTRING( "mso-spt37" );
1492             sType = sCurvedConnector2;
1493             } break;
1494         case XML_curvedConnector3: {
1495             static const OUString sCurvedConnector3 = CREATE_OUSTRING( "mso-spt38" );
1496             sType = sCurvedConnector3;
1497             } break;
1498         case XML_curvedConnector4: {
1499             static const OUString sCurvedConnector4 = CREATE_OUSTRING( "mso-spt39" );
1500             sType = sCurvedConnector4;
1501             } break;
1502         case XML_curvedConnector5: {
1503             static const OUString sCurvedConnector5 = CREATE_OUSTRING( "mso-spt40" );
1504             sType = sCurvedConnector5;
1505             } break;
1506         case XML_callout1: {
1507             static const OUString sCallout1 = CREATE_OUSTRING( "mso-spt41" );
1508             sType = sCallout1;
1509             } break;
1510         case XML_callout2: {
1511             static const OUString sCallout2 = CREATE_OUSTRING( "mso-spt42" );
1512             sType = sCallout2;
1513             } break;
1514         case XML_callout3: {
1515             static const OUString sCallout3 = CREATE_OUSTRING( "mso-spt43" );
1516             sType = sCallout3;
1517             } break;
1518         case XML_accentCallout1: {
1519             static const OUString sAccentCallout1 = CREATE_OUSTRING( "mso-spt44" );
1520             sType = sAccentCallout1;
1521             } break;
1522         case XML_accentCallout2: {
1523             static const OUString sAccentCallout2 = CREATE_OUSTRING( "mso-spt45" );
1524             sType = sAccentCallout2;
1525             } break;
1526         case XML_accentCallout3: {
1527             static const OUString sAccentCallout3 = CREATE_OUSTRING( "mso-spt46" );
1528             sType = sAccentCallout3;
1529             } break;
1530         case XML_borderCallout1: {
1531             static const OUString sBorderCallout1 = CREATE_OUSTRING( "line-callout-1" );
1532             sType = sBorderCallout1;
1533             } break;
1534         case XML_borderCallout2: {
1535             static const OUString sBorderCallout2 = CREATE_OUSTRING( "line-callout-2" );
1536             sType = sBorderCallout2;
1537             } break;
1538         case XML_borderCallout3: {
1539             static const OUString sBorderCallout3 = CREATE_OUSTRING( "mso-spt49" );
1540             sType = sBorderCallout3;
1541             } break;
1542         case XML_accentBorderCallout1: {
1543             static const OUString sAccentBorderCallout1 = CREATE_OUSTRING( "mso-spt50" );
1544             sType = sAccentBorderCallout1;
1545             } break;
1546         case XML_accentBorderCallout2: {
1547             static const OUString sAccentBorderCallout2 = CREATE_OUSTRING( "mso-spt51" );
1548             sType = sAccentBorderCallout2;
1549             } break;
1550         case XML_accentBorderCallout3: {
1551             static const OUString sAccentBorderCallout3 = CREATE_OUSTRING( "mso-spt52" );
1552             sType = sAccentBorderCallout3;
1553             } break;
1554         case XML_wedgeRectCallout: {
1555             static const OUString sWedgeRectCallout = CREATE_OUSTRING( "rectangular-callout" );
1556             sType = sWedgeRectCallout;
1557             } break;
1558         case XML_wedgeRoundRectCallout: {
1559             static const OUString sWedgeRoundRectCallout = CREATE_OUSTRING( "round-rectangular-callout" );
1560             sType = sWedgeRoundRectCallout;
1561             } break;
1562         case XML_wedgeEllipseCallout: {
1563             static const OUString sWedgeEllipseCallout = CREATE_OUSTRING( "round-callout" );
1564             sType = sWedgeEllipseCallout;
1565             } break;
1566         case XML_cloud:                     // TODO
1567         case XML_cloudCallout: {
1568             static const OUString sCloudCallout = CREATE_OUSTRING( "cloud-callout" );
1569             sType = sCloudCallout;
1570             } break;
1571         case XML_ribbon: {
1572             static const OUString sRibbon = CREATE_OUSTRING( "mso-spt53" );
1573             sType = sRibbon;
1574             } break;
1575         case XML_ribbon2: {
1576             static const OUString sRibbon2 = CREATE_OUSTRING( "mso-spt54" );
1577             sType = sRibbon2;
1578             } break;
1579         case XML_ellipseRibbon: {
1580             static const OUString sEllipseRibbon = CREATE_OUSTRING( "mso-spt107" );
1581             sType = sEllipseRibbon;
1582             } break;
1583         case XML_leftRightRibbon:           // TODO
1584         case XML_ellipseRibbon2: {
1585             static const OUString sEllipseRibbon2 = CREATE_OUSTRING( "mso-spt108" );
1586             sType = sEllipseRibbon2;
1587             } break;
1588         case XML_verticalScroll: {
1589             static const OUString sVerticalScroll = CREATE_OUSTRING( "vertical-scroll" );
1590             sType = sVerticalScroll;
1591             } break;
1592         case XML_horizontalScroll: {
1593             static const OUString sHorizontalScroll = CREATE_OUSTRING( "horizontal-scroll" );
1594             sType = sHorizontalScroll;
1595             } break;
1596         case XML_wave: {
1597             static const OUString sWave = CREATE_OUSTRING( "mso-spt64" );
1598             sType = sWave;
1599             } break;
1600         case XML_doubleWave: {
1601             static const OUString sDoubleWave = CREATE_OUSTRING( "mso-spt188" );
1602             sType = sDoubleWave;
1603             } break;
1604         case XML_plus: {
1605             static const OUString sPlus = CREATE_OUSTRING( "cross" );
1606             sType = sPlus;
1607             } break;
1608         case XML_flowChartProcess: {
1609             static const OUString sFlowChartProcess = CREATE_OUSTRING( "flowchart-process" );
1610             sType = sFlowChartProcess;
1611             } break;
1612         case XML_flowChartDecision: {
1613             static const OUString sFlowChartDecision = CREATE_OUSTRING( "flowchart-decision" );
1614             sType = sFlowChartDecision;
1615             } break;
1616         case XML_flowChartInputOutput: {
1617             static const OUString sFlowChartInputOutput = CREATE_OUSTRING( "flowchart-data" );
1618             sType = sFlowChartInputOutput;
1619             } break;
1620         case XML_flowChartPredefinedProcess: {
1621             static const OUString sFlowChartPredefinedProcess = CREATE_OUSTRING( "flowchart-predefined-process" );
1622             sType = sFlowChartPredefinedProcess;
1623             } break;
1624         case XML_flowChartInternalStorage: {
1625             static const OUString sFlowChartInternalStorage = CREATE_OUSTRING( "flowchart-internal-storage" );
1626             sType = sFlowChartInternalStorage;
1627             } break;
1628         case XML_flowChartDocument: {
1629             static const OUString sFlowChartDocument = CREATE_OUSTRING( "flowchart-document" );
1630             sType = sFlowChartDocument;
1631             } break;
1632         case XML_flowChartMultidocument: {
1633             static const OUString sFlowChartMultidocument = CREATE_OUSTRING( "flowchart-multidocument" );
1634             sType = sFlowChartMultidocument;
1635             } break;
1636         case XML_flowChartTerminator: {
1637             static const OUString sFlowChartTerminator = CREATE_OUSTRING( "flowchart-terminator" );
1638             sType = sFlowChartTerminator;
1639             } break;
1640         case XML_flowChartPreparation : {
1641             static const OUString sFlowChartPreparation = CREATE_OUSTRING( "flowchart-preparation" );
1642             sType = sFlowChartPreparation;
1643             } break;
1644         case XML_flowChartManualInput: {
1645             static const OUString sFlowChartManualInput = CREATE_OUSTRING( "flowchart-manual-input" );
1646             sType = sFlowChartManualInput;
1647             } break;
1648         case XML_flowChartManualOperation: {
1649             static const OUString sFlowChartManualOperation = CREATE_OUSTRING( "flowchart-manual-operation" );
1650             sType = sFlowChartManualOperation;
1651             } break;
1652         case XML_flowChartConnector: {
1653             static const OUString sFlowChartConnector = CREATE_OUSTRING( "flowchart-connector" );
1654             sType = sFlowChartConnector;
1655             } break;
1656         case XML_flowChartPunchedCard: {
1657             static const OUString sFlowChartPunchedCard = CREATE_OUSTRING( "flowchart-card" );
1658             sType = sFlowChartPunchedCard;
1659             } break;
1660         case XML_flowChartPunchedTape: {
1661             static const OUString sFlowChartPunchedTape = CREATE_OUSTRING( "flowchart-punched-tape" );
1662             sType = sFlowChartPunchedTape;
1663             } break;
1664         case XML_flowChartSummingJunction: {
1665             static const OUString sFlowChartSummingJunction = CREATE_OUSTRING( "flowchart-summing-junction" );
1666             sType = sFlowChartSummingJunction;
1667             } break;
1668         case XML_flowChartOr: {
1669             static const OUString sFlowChartOr = CREATE_OUSTRING( "flowchart-or" );
1670             sType = sFlowChartOr;
1671             } break;
1672         case XML_flowChartCollate: {
1673             static const OUString sFlowChartCollate = CREATE_OUSTRING( "flowchart-collate" );
1674             sType = sFlowChartCollate;
1675             } break;
1676         case XML_flowChartSort: {
1677             static const OUString sFlowChartSort = CREATE_OUSTRING( "flowchart-sort" );
1678             sType = sFlowChartSort;
1679             } break;
1680         case XML_flowChartExtract: {
1681             static const OUString sFlowChartExtract = CREATE_OUSTRING( "flowchart-extract" );
1682             sType = sFlowChartExtract;
1683             } break;
1684         case XML_flowChartMerge: {
1685             static const OUString sFlowChartMerge = CREATE_OUSTRING( "flowchart-merge" );
1686             sType = sFlowChartMerge;
1687             } break;
1688         case XML_flowChartOfflineStorage: {
1689             static const OUString sFlowChartOfflineStorage = CREATE_OUSTRING( "mso-spt129" );
1690             sType = sFlowChartOfflineStorage;
1691             } break;
1692         case XML_flowChartOnlineStorage: {
1693             static const OUString sFlowChartOnlineStorage = CREATE_OUSTRING( "flowchart-stored-data" );
1694             sType = sFlowChartOnlineStorage;
1695             } break;
1696         case XML_flowChartMagneticTape: {
1697             static const OUString sFlowChartMagneticTape = CREATE_OUSTRING( "flowchart-sequential-access" );
1698             sType = sFlowChartMagneticTape;
1699             } break;
1700         case XML_flowChartMagneticDisk: {
1701             static const OUString sFlowChartMagneticDisk = CREATE_OUSTRING( "flowchart-magnetic-disk" );
1702             sType = sFlowChartMagneticDisk;
1703             } break;
1704         case XML_flowChartMagneticDrum: {
1705             static const OUString sFlowChartMagneticDrum = CREATE_OUSTRING( "flowchart-direct-access-storage" );
1706             sType = sFlowChartMagneticDrum;
1707             } break;
1708         case XML_flowChartDisplay: {
1709             static const OUString sFlowChartDisplay = CREATE_OUSTRING( "flowchart-display" );
1710             sType = sFlowChartDisplay;
1711             } break;
1712         case XML_flowChartDelay: {
1713             static const OUString sFlowChartDelay = CREATE_OUSTRING( "flowchart-delay" );
1714             sType = sFlowChartDelay;
1715             } break;
1716         case XML_flowChartAlternateProcess: {
1717             static const OUString sFlowChartAlternateProcess = CREATE_OUSTRING( "flowchart-alternate-process" );
1718             sType = sFlowChartAlternateProcess;
1719             } break;
1720         case XML_flowChartOffpageConnector: {
1721             static const OUString sFlowChartOffpageConnector = CREATE_OUSTRING( "flowchart-off-page-connector" );
1722             sType = sFlowChartOffpageConnector;
1723             } break;
1724         case XML_actionButtonBlank: {
1725             static const OUString sActionButtonBlank = CREATE_OUSTRING( "mso-spt189" );
1726             sType = sActionButtonBlank;
1727             } break;
1728         case XML_actionButtonHome: {
1729             static const OUString sActionButtonHome = CREATE_OUSTRING( "mso-spt190" );
1730             sType = sActionButtonHome;
1731             } break;
1732         case XML_actionButtonHelp: {
1733             static const OUString sActionButtonHelp = CREATE_OUSTRING( "mso-spt191" );
1734             sType = sActionButtonHelp;
1735             } break;
1736         case XML_actionButtonInformation: {
1737             static const OUString sActionButtonInformation = CREATE_OUSTRING( "mso-spt192" );
1738             sType = sActionButtonInformation;
1739             } break;
1740         case XML_actionButtonForwardNext: {
1741             static const OUString sActionButtonForwardNext = CREATE_OUSTRING( "mso-spt193" );
1742             sType = sActionButtonForwardNext;
1743             } break;
1744         case XML_actionButtonBackPrevious: {
1745             static const OUString sActionButtonBackPrevious = CREATE_OUSTRING( "mso-spt194" );
1746             sType = sActionButtonBackPrevious;
1747             } break;
1748         case XML_actionButtonEnd: {
1749             static const OUString sActionButtonEnd = CREATE_OUSTRING( "mso-spt195" );
1750             sType = sActionButtonEnd;
1751             } break;
1752         case XML_actionButtonBeginning: {
1753             static const OUString sActionButtonBeginning = CREATE_OUSTRING( "mso-spt196" );
1754             sType = sActionButtonBeginning;
1755             } break;
1756         case XML_actionButtonReturn: {
1757             static const OUString sActionButtonReturn = CREATE_OUSTRING( "mso-spt197" );
1758             sType = sActionButtonReturn;
1759             } break;
1760         case XML_actionButtonDocument: {
1761             static const OUString sActionButtonDocument = CREATE_OUSTRING( "mso-spt198" );
1762             sType = sActionButtonDocument;
1763             } break;
1764         case XML_actionButtonSound: {
1765             static const OUString sActionButtonSound = CREATE_OUSTRING( "mso-spt199" );
1766             sType = sActionButtonSound;
1767             } break;
1768         case XML_actionButtonMovie: {
1769             static const OUString sActionButtonMovie = CREATE_OUSTRING( "mso-spt200" );
1770             sType = sActionButtonMovie;
1771             } break;
1772         case XML_gear6:                     // TODO
1773         case XML_gear9:                     // TODO
1774         case XML_funnel:                    // TODO
1775         case XML_mathPlus:                  // TODO
1776         case XML_mathMinus:                 // TODO
1777         case XML_mathMultiply:              // TODO
1778         case XML_mathDivide:                // TODO
1779         case XML_mathEqual:                 // TODO
1780         case XML_mathNotEqual:              // TODO
1781         case XML_cornerTabs:                // TODO
1782         case XML_squareTabs:                // TODO
1783         case XML_plaqueTabs:                // TODO
1784         case XML_chartX:                    // TODO
1785         case XML_chartStar:                 // TODO
1786         case XML_chartPlus: {               // TODO
1787             static const OUString sRectangle = CREATE_OUSTRING( "rectangle" );
1788             sType = sRectangle;
1789             } break;
1790         default:
1791             break;
1792     }
1793     return sType;
1794 }
1795 
GetTextShapeType(sal_Int32 nType)1796 static OUString GetTextShapeType( sal_Int32 nType )
1797 {
1798     OUString sType;
1799     switch( nType )
1800     {
1801         case XML_textNoShape:               // TODO
1802         case XML_textPlain: {
1803             static const OUString sTextPlain = CREATE_OUSTRING( "fontwork-plain-text" );
1804             sType = sTextPlain;
1805             } break;
1806         case XML_textStop: {
1807             static const OUString sTextStop = CREATE_OUSTRING( "fontwork-stop" );
1808             sType = sTextStop;
1809             } break;
1810         case XML_textTriangle: {
1811             static const OUString sTextTriangle = CREATE_OUSTRING( "fontwork-triangle-up" );
1812             sType = sTextTriangle;
1813             } break;
1814         case XML_textTriangleInverted: {
1815             static const OUString sTextTriangleInverted = CREATE_OUSTRING( "fontwork-triangle-down" );
1816             sType = sTextTriangleInverted;
1817             } break;
1818         case XML_textChevron: {
1819             static const OUString sTextChevron = CREATE_OUSTRING( "fontwork-chevron-up" );
1820             sType = sTextChevron;
1821             } break;
1822         case XML_textChevronInverted: {
1823             static const OUString sTextChevronInverted = CREATE_OUSTRING( "fontwork-chevron-down" );
1824             sType = sTextChevronInverted;
1825             } break;
1826         case XML_textRingInside: {
1827             static const OUString sTextRingInside = CREATE_OUSTRING( "mso-spt142" );
1828             sType = sTextRingInside;
1829             } break;
1830         case XML_textRingOutside: {
1831             static const OUString sTextRingOutside = CREATE_OUSTRING( "mso-spt143" );
1832             sType = sTextRingOutside;
1833             } break;
1834         case XML_textArchUp: {
1835             static const OUString sTextArchUp = CREATE_OUSTRING( "fontwork-arch-up-curve" );
1836             sType = sTextArchUp;
1837             } break;
1838         case XML_textArchDown: {
1839             static const OUString sTextArchDown = CREATE_OUSTRING( "fontwork-arch-down-curve" );
1840             sType = sTextArchDown;
1841             } break;
1842         case XML_textCircle: {
1843             static const OUString sTextCircle = CREATE_OUSTRING( "fontwork-circle-curve" );
1844             sType = sTextCircle;
1845             } break;
1846         case XML_textButton: {
1847             static const OUString sTextButton = CREATE_OUSTRING( "fontwork-open-circle-curve" );
1848             sType = sTextButton;
1849             } break;
1850         case XML_textArchUpPour: {
1851             static const OUString sTextArchUpPour = CREATE_OUSTRING( "fontwork-arch-up-pour" );
1852             sType = sTextArchUpPour;
1853             } break;
1854         case XML_textArchDownPour: {
1855             static const OUString sTextArchDownPour = CREATE_OUSTRING( "fontwork-arch-down-pour" );
1856             sType = sTextArchDownPour;
1857             } break;
1858         case XML_textCirclePour: {
1859             static const OUString sTextCirclePour = CREATE_OUSTRING( "fontwork-circle-pour" );
1860             sType = sTextCirclePour;
1861             } break;
1862         case XML_textButtonPour: {
1863             static const OUString sTextButtonPour = CREATE_OUSTRING( "fontwork-open-circle-pour" );
1864             sType = sTextButtonPour;
1865             } break;
1866         case XML_textCurveUp: {
1867             static const OUString sTextCurveUp = CREATE_OUSTRING( "fontwork-curve-up" );
1868             sType = sTextCurveUp;
1869             } break;
1870         case XML_textCurveDown: {
1871             static const OUString sTextCurveDown = CREATE_OUSTRING( "fontwork-curve-down" );
1872             sType = sTextCurveDown;
1873             } break;
1874         case XML_textCanUp: {
1875             static const OUString sTextCanUp = CREATE_OUSTRING( "mso-spt174" );
1876             sType = sTextCanUp;
1877             } break;
1878         case XML_textCanDown: {
1879             static const OUString sTextCanDown = CREATE_OUSTRING( "mso-spt175" );
1880             sType = sTextCanDown;
1881             } break;
1882         case XML_textWave1: {
1883             static const OUString sTextWave1 = CREATE_OUSTRING( "fontwork-wave" );
1884             sType = sTextWave1;
1885             } break;
1886         case XML_textWave2: {
1887             static const OUString sTextWave2 = CREATE_OUSTRING( "mso-spt157" );
1888             sType = sTextWave2;
1889             } break;
1890         case XML_textDoubleWave1: {
1891             static const OUString sTextDoubleWave1 = CREATE_OUSTRING( "mso-spt158" );
1892             sType = sTextDoubleWave1;
1893             } break;
1894         case XML_textWave4: {
1895             static const OUString sTextWave4 = CREATE_OUSTRING( "mso-spt159" );
1896             sType = sTextWave4;
1897             } break;
1898         case XML_textInflate: {
1899             static const OUString sTextInflate = CREATE_OUSTRING( "fontwork-inflate" );
1900             sType = sTextInflate;
1901             } break;
1902         case XML_textDeflate: {
1903             static const OUString sTextDeflate = CREATE_OUSTRING( "mso-spt161" );
1904             sType = sTextDeflate;
1905             } break;
1906         case XML_textInflateBottom: {
1907             static const OUString sTextInflateBottom = CREATE_OUSTRING( "mso-spt162" );
1908             sType = sTextInflateBottom;
1909             } break;
1910         case XML_textDeflateBottom: {
1911             static const OUString sTextDeflateBottom = CREATE_OUSTRING( "mso-spt163" );
1912             sType = sTextDeflateBottom;
1913             } break;
1914         case XML_textInflateTop: {
1915             static const OUString sTextInflateTop = CREATE_OUSTRING( "mso-spt164" );
1916             sType = sTextInflateTop;
1917             } break;
1918         case XML_textDeflateTop: {
1919             static const OUString sTextDeflateTop = CREATE_OUSTRING( "mso-spt165" );
1920             sType = sTextDeflateTop;
1921             } break;
1922         case XML_textDeflateInflate: {
1923             static const OUString sTextDeflateInflate = CREATE_OUSTRING( "mso-spt166" );
1924             sType = sTextDeflateInflate;
1925             } break;
1926         case XML_textDeflateInflateDeflate: {
1927             static const OUString sTextDeflateInflateDeflate = CREATE_OUSTRING( "mso-spt167" );
1928             sType = sTextDeflateInflateDeflate;
1929             } break;
1930         case XML_textFadeRight: {
1931             static const OUString sTextFadeRight = CREATE_OUSTRING( "fontwork-fade-right" );
1932             sType = sTextFadeRight;
1933             } break;
1934         case XML_textFadeLeft: {
1935             static const OUString sTextFadeLeft = CREATE_OUSTRING( "fontwork-fade-left" );
1936             sType = sTextFadeLeft;
1937             } break;
1938         case XML_textFadeUp: {
1939             static const OUString sTextFadeUp = CREATE_OUSTRING( "fontwork-fade-up" );
1940             sType = sTextFadeUp;
1941             } break;
1942         case XML_textFadeDown: {
1943             static const OUString sTextFadeDown = CREATE_OUSTRING( "fontwork-fade-down" );
1944             sType = sTextFadeDown;
1945             } break;
1946         case XML_textSlantUp: {
1947             static const OUString sTextSlantUp = CREATE_OUSTRING( "fontwork-slant-up" );
1948             sType = sTextSlantUp;
1949             } break;
1950         case XML_textSlantDown: {
1951             static const OUString sTextSlantDown = CREATE_OUSTRING( "fontwork-slant-down" );
1952             sType = sTextSlantDown;
1953             } break;
1954         case XML_textCascadeUp: {
1955             static const OUString sTextCascadeUp = CREATE_OUSTRING( "fontwork-fade-up-and-right" );
1956             sType = sTextCascadeUp;
1957             } break;
1958         case XML_textCascadeDown: {
1959             static const OUString sTextCascadeDown = CREATE_OUSTRING( "fontwork-fade-up-and-left" );
1960             sType = sTextCascadeDown;
1961             } break;
1962         default:
1963         break;
1964     }
1965     return sType;
1966 }
1967 
1968 // ---------------------------------------------------------------------
1969 // CT_CustomGeometry2D
CustomShapeGeometryContext(ContextHandler & rParent,const Reference<XFastAttributeList> &,CustomShapeProperties & rCustomShapeProperties)1970 CustomShapeGeometryContext::CustomShapeGeometryContext( ContextHandler& rParent, const Reference< XFastAttributeList >& /* xAttribs */, CustomShapeProperties& rCustomShapeProperties )
1971 : ContextHandler( rParent )
1972 , mrCustomShapeProperties( rCustomShapeProperties )
1973 {
1974 }
1975 
createFastChildContext(sal_Int32 aElementToken,const Reference<XFastAttributeList> & xAttribs)1976 Reference< XFastContextHandler > CustomShapeGeometryContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs )
1977 {
1978     Reference< XFastContextHandler > xContext;
1979     switch( aElementToken )
1980     {
1981         case A_TOKEN( avLst ):          // CT_GeomGuideList adjust value list
1982             xContext = new GeomGuideListContext( *this, mrCustomShapeProperties, mrCustomShapeProperties.getAdjustmentGuideList() );
1983         break;
1984         case A_TOKEN( gdLst ):          // CT_GeomGuideList guide list
1985             xContext = new GeomGuideListContext( *this, mrCustomShapeProperties, mrCustomShapeProperties.getGuideList() );
1986         break;
1987         case A_TOKEN( ahLst ):          // CT_AdjustHandleList adjust handle list
1988             xContext = new AdjustHandleListContext( *this, mrCustomShapeProperties, mrCustomShapeProperties.getAdjustHandleList() );
1989         break;
1990         case A_TOKEN( cxnLst ):         // CT_ConnectionSiteList connection site list
1991             xContext = this;
1992         break;
1993         case A_TOKEN( rect ):           // CT_GeomRectList geometry rect list
1994         {
1995             GeomRect aGeomRect;
1996             aGeomRect.l = GetAdjCoordinate( mrCustomShapeProperties, xAttribs->getOptionalValue( XML_l ), sal_True );
1997             aGeomRect.t = GetAdjCoordinate( mrCustomShapeProperties, xAttribs->getOptionalValue( XML_t ), sal_True );
1998             aGeomRect.r = GetAdjCoordinate( mrCustomShapeProperties, xAttribs->getOptionalValue( XML_r ), sal_True );
1999             aGeomRect.b = GetAdjCoordinate( mrCustomShapeProperties, xAttribs->getOptionalValue( XML_b ), sal_True );
2000             mrCustomShapeProperties.getTextRect() = aGeomRect;
2001         }
2002         break;
2003         case A_TOKEN( pathLst ):        // CT_Path2DList 2d path list
2004             xContext = new Path2DListContext( *this, mrCustomShapeProperties, mrCustomShapeProperties.getSegments(), mrCustomShapeProperties.getPath2DList() );
2005         break;
2006 
2007         // from cxnLst:
2008         case A_TOKEN( cxn ):                // CT_ConnectionSite
2009         {
2010             ConnectionSite aConnectionSite;
2011             mrCustomShapeProperties.getConnectionSiteList().push_back( aConnectionSite );
2012             xContext = new ConnectionSiteContext( *this, xAttribs, mrCustomShapeProperties, mrCustomShapeProperties.getConnectionSiteList().back() );
2013         }
2014         break;
2015     }
2016     return xContext;
2017 }
2018 
2019 // ---------------------------------------------------------------------
2020 // CT_PresetGeometry2D
PresetShapeGeometryContext(ContextHandler & rParent,const Reference<XFastAttributeList> & xAttribs,CustomShapeProperties & rCustomShapeProperties)2021 PresetShapeGeometryContext::PresetShapeGeometryContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, CustomShapeProperties& rCustomShapeProperties )
2022 : ContextHandler( rParent )
2023 , mrCustomShapeProperties( rCustomShapeProperties )
2024 {
2025     OUString sShapeType;
2026     sal_Int32 nShapeType = xAttribs->getOptionalValueToken( XML_prst, FastToken::DONTKNOW );
2027     if ( nShapeType != FastToken::DONTKNOW )
2028         sShapeType = GetShapeType( nShapeType );
2029     OSL_ENSURE( sShapeType.getLength(), "oox::drawingml::CustomShapeCustomGeometryContext::CustomShapeCustomGeometryContext(), unknown shape type" );
2030     mrCustomShapeProperties.setShapePresetType( sShapeType );
2031 }
2032 
createFastChildContext(sal_Int32 aElementToken,const Reference<XFastAttributeList> &)2033 Reference< XFastContextHandler > PresetShapeGeometryContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& )
2034 {
2035     if ( aElementToken == A_TOKEN( avLst ) )
2036         return new GeomGuideListContext( *this, mrCustomShapeProperties, mrCustomShapeProperties.getAdjustmentGuideList() );
2037     else
2038         return this;
2039 }
2040 
2041 // ---------------------------------------------------------------------
2042 // CT_PresetTextShape
PresetTextShapeContext(ContextHandler & rParent,const Reference<XFastAttributeList> & xAttribs,CustomShapeProperties & rCustomShapeProperties)2043 PresetTextShapeContext::PresetTextShapeContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, CustomShapeProperties& rCustomShapeProperties )
2044 : ContextHandler( rParent )
2045 , mrCustomShapeProperties( rCustomShapeProperties )
2046 {
2047     OUString sShapeType;
2048     sal_Int32 nShapeType = xAttribs->getOptionalValueToken( XML_prst, FastToken::DONTKNOW );
2049     if ( nShapeType != FastToken::DONTKNOW )
2050         sShapeType = GetTextShapeType( nShapeType );
2051     OSL_ENSURE( sShapeType.getLength(), "oox::drawingml::CustomShapeCustomGeometryContext::CustomShapeCustomGeometryContext(), unknown shape type" );
2052     mrCustomShapeProperties.setShapePresetType( sShapeType );
2053 }
2054 
createFastChildContext(sal_Int32 aElementToken,const Reference<XFastAttributeList> &)2055 Reference< XFastContextHandler > PresetTextShapeContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& )
2056 {
2057     if ( aElementToken == A_TOKEN( avLst ) )
2058         return new GeomGuideListContext( *this, mrCustomShapeProperties, mrCustomShapeProperties.getAdjustmentGuideList() );
2059     else
2060         return this;
2061 }
2062 
2063 } }
2064