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