LCOV - code coverage report
Current view: top level - oox/source/drawingml - customshapegeometry.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 14 544 2.6 %
Date: 2012-08-25 Functions: 7 59 11.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 8 945 0.8 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * This file is part of the LibreOffice project.
       4                 :            :  *
       5                 :            :  * This Source Code Form is subject to the terms of the Mozilla Public
       6                 :            :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7                 :            :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8                 :            :  *
       9                 :            :  * This file incorporates work covered by the following license notice:
      10                 :            :  *
      11                 :            :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12                 :            :  *   contributor license agreements. See the NOTICE file distributed
      13                 :            :  *   with this work for additional information regarding copyright
      14                 :            :  *   ownership. The ASF licenses this file to you under the Apache
      15                 :            :  *   License, Version 2.0 (the "License"); you may not use this file
      16                 :            :  *   except in compliance with the License. You may obtain a copy of
      17                 :            :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18                 :            :  */
      19                 :            : 
      20                 :            : #include "oox/drawingml/customshapegeometry.hxx"
      21                 :            : 
      22                 :            : #include <com/sun/star/xml/sax/FastToken.hpp>
      23                 :            : #include <comphelper/stl_types.hxx>
      24                 :            : #include <boost/unordered_map.hpp>
      25                 :            : #include "oox/helper/helper.hxx"
      26                 :            : #include "oox/helper/attributelist.hxx"
      27                 :            : #include "oox/helper/propertymap.hxx"
      28                 :            : 
      29                 :            : using ::rtl::OUString;
      30                 :            : using namespace ::oox::core;
      31                 :            : using namespace ::com::sun::star::uno;
      32                 :            : using namespace ::com::sun::star::beans;
      33                 :            : using namespace ::com::sun::star::drawing;
      34                 :            : using namespace ::com::sun::star::xml::sax;
      35                 :            : 
      36                 :            : namespace oox { namespace drawingml {
      37                 :            : 
      38                 :            : enum FormularCommand
      39                 :            : {
      40                 :            :     FC_MULDIV = 0,
      41                 :            :     FC_PLUSMINUS,
      42                 :            :     FC_PLUSDIV,
      43                 :            :     FC_IFELSE,
      44                 :            :     FC_IFELSE1,
      45                 :            :     FC_ABS,
      46                 :            :     FC_AT2,
      47                 :            :     FC_CAT2,
      48                 :            :     FC_COS,
      49                 :            :     FC_MAX,
      50                 :            :     FC_MIN,
      51                 :            :     FC_MOD,
      52                 :            :     FC_PIN,
      53                 :            :     FC_SAT2,
      54                 :            :     FC_SIN,
      55                 :            :     FC_SQRT,
      56                 :            :     FC_TAN,
      57                 :            :     FC_VAL,
      58                 :            :     FC_LAST
      59                 :            : };
      60                 :            : struct FormularCommandNameTable
      61                 :            : {
      62                 :            :     const char*     pS;
      63                 :            :     FormularCommand pE;
      64                 :            : };
      65                 :            : static FormularCommandNameTable pFormularCommandNameTable[] =
      66                 :            : {
      67                 :            :     { "*/",     FC_MULDIV },
      68                 :            :     { "+-",     FC_PLUSMINUS },
      69                 :            :     { "+/",     FC_PLUSDIV },
      70                 :            :     { "ifelse", FC_IFELSE },
      71                 :            :     { "?:",     FC_IFELSE1 },
      72                 :            :     { "abs",    FC_ABS },
      73                 :            :     { "at2",    FC_AT2 },
      74                 :            :     { "cat2",   FC_CAT2 },
      75                 :            :     { "cos",    FC_COS },
      76                 :            :     { "max",    FC_MAX },
      77                 :            :     { "min",    FC_MIN },
      78                 :            :     { "mod",    FC_MOD },
      79                 :            :     { "pin",    FC_PIN },
      80                 :            :     { "sat2",   FC_SAT2 },
      81                 :            :     { "sin",    FC_SIN },
      82                 :            :     { "sqrt",   FC_SQRT },
      83                 :            :     { "tan",    FC_TAN },
      84                 :            :     { "val",    FC_VAL }
      85                 :            : 
      86                 :            : };
      87                 :            : typedef boost::unordered_map< rtl::OUString, FormularCommand, rtl::OUStringHash, comphelper::UStringEqual > FormulaCommandHMap;
      88                 :            : 
      89                 :            : static const FormulaCommandHMap* pCommandHashMap;
      90                 :            : 
      91                 :            : //
      92                 :          0 : rtl::OUString GetFormulaParameter( const EnhancedCustomShapeParameter& rParameter )
      93                 :            : {
      94                 :          0 :     rtl::OUString aRet;
      95   [ #  #  #  #  :          0 :     switch( rParameter.Type )
          #  #  #  #  #  
          #  #  #  #  #  
                   #  # ]
      96                 :            :     {
      97                 :            :         case EnhancedCustomShapeParameterType::NORMAL :
      98                 :            :         {
      99         [ #  # ]:          0 :             if ( rParameter.Value.getValueTypeClass() == TypeClass_DOUBLE )
     100                 :            :             {
     101                 :          0 :                 double fValue = 0.0;
     102         [ #  # ]:          0 :                 if ( rParameter.Value >>= fValue )
     103                 :          0 :                     aRet = rtl::OUString::valueOf( fValue );
     104                 :            :             }
     105                 :            :             else
     106                 :            :             {
     107                 :          0 :                 sal_Int32 nValue = 0;
     108         [ #  # ]:          0 :                 if ( rParameter.Value >>= nValue )
     109                 :          0 :                     aRet = rtl::OUString::valueOf( nValue );
     110                 :            :             }
     111                 :            :         }
     112                 :          0 :         break;
     113                 :            :         case EnhancedCustomShapeParameterType::EQUATION :
     114                 :            :         {
     115         [ #  # ]:          0 :             if ( rParameter.Value.getValueTypeClass() == TypeClass_LONG )
     116                 :            :             {
     117                 :            :                 sal_Int32 nFormulaIndex;
     118         [ #  # ]:          0 :                 if ( rParameter.Value >>= nFormulaIndex )
     119                 :            :                 {
     120                 :            :                     aRet = CREATE_OUSTRING( "?" )
     121                 :            :                         + rtl::OUString::valueOf( nFormulaIndex )
     122 [ #  # ][ #  # ]:          0 :                             + CREATE_OUSTRING( " " );
     123                 :            :                 }
     124                 :            :             }
     125                 :            :             else
     126                 :            :             {
     127                 :            :                 // ups... we should have an index here and not the formula name
     128                 :            :             }
     129                 :            :         }
     130                 :          0 :         break;
     131                 :            :         case EnhancedCustomShapeParameterType::ADJUSTMENT :
     132                 :            :         {
     133         [ #  # ]:          0 :             if ( rParameter.Value.getValueTypeClass() == TypeClass_LONG )
     134                 :            :             {
     135                 :            :                 sal_Int32 nAdjustmentIndex;
     136         [ #  # ]:          0 :                 if ( rParameter.Value >>= nAdjustmentIndex )
     137                 :            :                 {
     138                 :            :                     aRet = CREATE_OUSTRING( "$" )
     139                 :            :                         + rtl::OUString::valueOf( nAdjustmentIndex )
     140 [ #  # ][ #  # ]:          0 :                             + CREATE_OUSTRING( " " );
     141                 :            :                 }
     142                 :            :             }
     143                 :            :             else
     144                 :            :             {
     145                 :            :                 // ups... we should have an index here and not the formula name
     146                 :            :             }
     147                 :            :         }
     148                 :          0 :         break;
     149                 :            :         case EnhancedCustomShapeParameterType::LEFT :
     150                 :            :         {
     151         [ #  # ]:          0 :             const rtl::OUString sLeft( CREATE_OUSTRING( "left" ) );
     152                 :          0 :             aRet = sLeft;
     153                 :            :         }
     154                 :          0 :         break;
     155                 :            :         case EnhancedCustomShapeParameterType::TOP :
     156                 :            :         {
     157         [ #  # ]:          0 :             const rtl::OUString sTop( CREATE_OUSTRING( "top" ) );
     158                 :          0 :             aRet = sTop;
     159                 :            :         }
     160                 :          0 :         break;
     161                 :            :         case EnhancedCustomShapeParameterType::RIGHT :
     162                 :            :         {
     163         [ #  # ]:          0 :             const rtl::OUString sRight( CREATE_OUSTRING( "right" ) );
     164                 :          0 :             aRet = sRight;
     165                 :            :         }
     166                 :          0 :         break;
     167                 :            :         case EnhancedCustomShapeParameterType::BOTTOM :
     168                 :            :         {
     169         [ #  # ]:          0 :             const rtl::OUString sBottom( CREATE_OUSTRING( "bottom" ) );
     170                 :          0 :             aRet = sBottom;
     171                 :            :         }
     172                 :          0 :         break;
     173                 :            :         case EnhancedCustomShapeParameterType::XSTRETCH :
     174                 :            :         {
     175         [ #  # ]:          0 :             const rtl::OUString sXStretch( CREATE_OUSTRING( "xstretch" ) );
     176                 :          0 :             aRet = sXStretch;
     177                 :            :         }
     178                 :          0 :         break;
     179                 :            :         case EnhancedCustomShapeParameterType::YSTRETCH :
     180                 :            :         {
     181         [ #  # ]:          0 :             const rtl::OUString sYStretch( CREATE_OUSTRING( "ystretch" ) );
     182                 :          0 :             aRet = sYStretch;
     183                 :            :         }
     184                 :          0 :         break;
     185                 :            :         case EnhancedCustomShapeParameterType::HASSTROKE :
     186                 :            :         {
     187         [ #  # ]:          0 :             const rtl::OUString sHasStroke( CREATE_OUSTRING( "hasstroke" ) );
     188                 :          0 :             aRet = sHasStroke;
     189                 :            :         }
     190                 :          0 :         break;
     191                 :            :         case EnhancedCustomShapeParameterType::HASFILL :
     192                 :            :         {
     193         [ #  # ]:          0 :             const rtl::OUString sHasFill( CREATE_OUSTRING( "hasfill" ) );
     194                 :          0 :             aRet = sHasFill;
     195                 :            :         }
     196                 :          0 :         break;
     197                 :            :         case EnhancedCustomShapeParameterType::WIDTH :
     198                 :            :         {
     199         [ #  # ]:          0 :             const rtl::OUString sWidth( CREATE_OUSTRING( "width" ) );
     200                 :          0 :             aRet = sWidth;
     201                 :            :         }
     202                 :          0 :         break;
     203                 :            :         case EnhancedCustomShapeParameterType::HEIGHT :
     204                 :            :         {
     205         [ #  # ]:          0 :             const rtl::OUString sHeight( CREATE_OUSTRING( "height" ) );
     206                 :          0 :             aRet = sHeight;
     207                 :            :         }
     208                 :          0 :         break;
     209                 :            :         case EnhancedCustomShapeParameterType::LOGWIDTH :
     210                 :            :         {
     211         [ #  # ]:          0 :             const rtl::OUString sLogWidth( CREATE_OUSTRING( "logwidth" ) );
     212                 :          0 :             aRet = sLogWidth;
     213                 :            :         }
     214                 :          0 :         break;
     215                 :            :         case EnhancedCustomShapeParameterType::LOGHEIGHT :
     216                 :            :         {
     217         [ #  # ]:          0 :             const rtl::OUString sLogHeight( CREATE_OUSTRING( "logheight" ) );
     218                 :          0 :             aRet = sLogHeight;
     219                 :            :         }
     220                 :          0 :         break;
     221                 :            :     }
     222                 :          0 :     return aRet;
     223                 :            : }
     224                 :            : 
     225                 :            : // ---------------------------------------------------------------------
     226                 :            : 
     227                 :          0 : static EnhancedCustomShapeParameter GetAdjCoordinate( CustomShapeProperties& rCustomShapeProperties, const::rtl::OUString& rValue, sal_Bool bNoSymbols = sal_True )
     228                 :            : {
     229                 :          0 :     com::sun::star::drawing::EnhancedCustomShapeParameter aRet;
     230         [ #  # ]:          0 :     if ( !rValue.isEmpty() )
     231                 :            :     {
     232                 :          0 :         sal_Bool    bConstant = sal_True;
     233                 :          0 :         sal_Int32   nConstant = -1;
     234                 :          0 :         sal_Int32   nIntVal = 0;
     235                 :            : 
     236                 :            :         // first check if its a constant value
     237 [ #  # ][ #  #  :          0 :         switch( AttributeConversion::decodeToken( rValue ) )
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
             #  #  #  # ]
     238                 :            :         {
     239                 :          0 :             case XML_3cd4 : nConstant = 270 * 60000; break;
     240                 :          0 :             case XML_3cd8 : nConstant = 135 * 60000; break;
     241                 :          0 :             case XML_5cd8 : nConstant = 225 * 60000; break;
     242                 :          0 :             case XML_7cd8 : nConstant = 315 * 60000; break;
     243                 :          0 :             case XML_cd2  : nConstant = 180 * 60000; break;
     244                 :          0 :             case XML_cd3  : nConstant = 120 * 60000; break;
     245                 :          0 :             case XML_cd4  : nConstant =  90 * 60000; break;
     246                 :          0 :             case XML_cd8  : nConstant =  45 * 60000; break;
     247                 :            : 
     248                 :            :             case XML_b :    // variable height of the shape defined in spPr
     249                 :            :             case XML_h :
     250                 :            :             {
     251         [ #  # ]:          0 :                 if ( bNoSymbols )
     252                 :            :                 {
     253                 :          0 :                     CustomShapeGuide aGuide;
     254                 :          0 :                     aGuide.maName = rValue;
     255         [ #  # ]:          0 :                     aGuide.maFormula = CREATE_OUSTRING( "logheight" );
     256                 :            : 
     257 [ #  # ][ #  # ]:          0 :                     aRet.Value = Any( CustomShapeProperties::SetCustomShapeGuideValue( rCustomShapeProperties.getGuideList(), aGuide ) );
     258                 :          0 :                     aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
     259                 :            :                 }
     260                 :            :                 else
     261                 :          0 :                     aRet.Type = EnhancedCustomShapeParameterType::LOGHEIGHT;   // TODO: HEIGHT needs to be implemented
     262                 :            :             }
     263                 :          0 :             break;
     264                 :            : 
     265                 :            : 
     266                 :            :             case XML_hd10 :   // !!PASSTHROUGH INTENDED
     267                 :          0 :                 nIntVal += 2; // */ h 1.0 10.0
     268                 :            :             case XML_hd8 :    // */ h 1.0 8.0
     269                 :          0 :                 nIntVal += 2;
     270                 :            :             case XML_hd6 :    // */ h 1.0 6.0
     271                 :          0 :                 nIntVal++;
     272                 :            :             case XML_hd5 :    // */ h 1.0 5.0
     273                 :          0 :                 nIntVal++;
     274                 :            :             case XML_hd4 :    // */ h 1.0 4.0
     275                 :          0 :                 nIntVal++;
     276                 :            :             case XML_hd3 :    // */ h 1.0 3.0
     277                 :          0 :                 nIntVal++;
     278                 :            :             case XML_hd2 :    // */ h 1.0 2.0
     279                 :            :             case XML_vc :     // */ h 1.0 2.0
     280                 :            :             {
     281                 :          0 :                 nIntVal += 2;
     282                 :            : 
     283                 :          0 :                 CustomShapeGuide aGuide;
     284                 :          0 :                 aGuide.maName = rValue;
     285         [ #  # ]:          0 :                 aGuide.maFormula = CREATE_OUSTRING( "logheight/" ) + rtl::OUString::valueOf( nIntVal );
     286                 :            : 
     287 [ #  # ][ #  # ]:          0 :                 aRet.Value = Any( CustomShapeProperties::SetCustomShapeGuideValue( rCustomShapeProperties.getGuideList(), aGuide ) );
     288                 :          0 :                 aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
     289                 :            :             }
     290                 :          0 :             break;
     291                 :            : 
     292                 :            :             case XML_t :
     293                 :            :             case XML_l :
     294                 :            :             {
     295                 :          0 :                 nConstant = 0;
     296                 :          0 :                 aRet.Type = EnhancedCustomShapeParameterType::NORMAL;
     297                 :            :             }
     298                 :          0 :             break;
     299                 :            : 
     300                 :            :             case XML_ls :   // longest side: max w h
     301                 :            :             {
     302                 :          0 :                 CustomShapeGuide aGuide;
     303                 :          0 :                 aGuide.maName = rValue;
     304         [ #  # ]:          0 :                 aGuide.maFormula = CREATE_OUSTRING( "max(logwidth,logheight)" );
     305                 :            : 
     306 [ #  # ][ #  # ]:          0 :                 aRet.Value = Any( CustomShapeProperties::SetCustomShapeGuideValue( rCustomShapeProperties.getGuideList(), aGuide ) );
     307                 :          0 :                 aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
     308                 :            :             }
     309                 :          0 :             break;
     310                 :            :             case XML_ss :   // shortest side: min w h
     311                 :            :             {
     312                 :          0 :                 CustomShapeGuide aGuide;
     313                 :          0 :                 aGuide.maName = rValue;
     314         [ #  # ]:          0 :                 aGuide.maFormula = CREATE_OUSTRING( "min(logwidth,logheight)" );
     315                 :            : 
     316 [ #  # ][ #  # ]:          0 :                 aRet.Value = Any( CustomShapeProperties::SetCustomShapeGuideValue( rCustomShapeProperties.getGuideList(), aGuide ) );
     317                 :          0 :                 aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
     318                 :            :             }
     319                 :          0 :             break;
     320                 :            :             case XML_ssd32 : // */ ss 1.0 32.0
     321                 :          0 :                 nIntVal += 16;
     322                 :            :             case XML_ssd16 : // */ ss 1.0 16.0
     323                 :          0 :                 nIntVal += 8;
     324                 :            :             case XML_ssd8 :  // */ ss 1.0 8.0
     325                 :          0 :                 nIntVal += 2;
     326                 :            :             case XML_ssd6 :  // */ ss 1.0 6.0
     327                 :          0 :                 nIntVal += 2;
     328                 :            :             case XML_ssd4 :  // */ ss 1.0 4.0
     329                 :          0 :                 nIntVal += 2;
     330                 :            :             case XML_ssd2 :  // */ ss 1.0 2.0
     331                 :            :             {
     332                 :          0 :                 nIntVal += 2;
     333                 :            : 
     334                 :          0 :                 CustomShapeGuide aGuide;
     335                 :          0 :                 aGuide.maName = rValue;
     336         [ #  # ]:          0 :                 aGuide.maFormula = CREATE_OUSTRING( "min(logwidth,logheight)/" ) + rtl::OUString::valueOf( nIntVal );
     337                 :            : 
     338 [ #  # ][ #  # ]:          0 :                 aRet.Value = Any( CustomShapeProperties::SetCustomShapeGuideValue( rCustomShapeProperties.getGuideList(), aGuide ) );
     339                 :          0 :                 aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
     340                 :            :             }
     341                 :          0 :             break;
     342                 :            : 
     343                 :            :             case XML_r :    // variable width of the shape defined in spPr
     344                 :            :             case XML_w :
     345                 :            :             {
     346         [ #  # ]:          0 :                 if ( bNoSymbols )
     347                 :            :                 {
     348                 :          0 :                     CustomShapeGuide aGuide;
     349                 :          0 :                     aGuide.maName = rValue;
     350         [ #  # ]:          0 :                     aGuide.maFormula = CREATE_OUSTRING( "logwidth" );
     351                 :            : 
     352 [ #  # ][ #  # ]:          0 :                     aRet.Value = Any( CustomShapeProperties::SetCustomShapeGuideValue( rCustomShapeProperties.getGuideList(), aGuide ) );
     353                 :          0 :                     aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
     354                 :            :                 }
     355                 :            :                 else
     356                 :          0 :                     aRet.Type = EnhancedCustomShapeParameterType::LOGWIDTH;
     357                 :            :             }
     358                 :          0 :             break;
     359                 :            : 
     360                 :            :             case XML_wd32 : // */ w 1.0 32.0
     361                 :          0 :                 nIntVal += 20;
     362                 :            :             case XML_wd12 : // */ w 1.0 12.0
     363                 :          0 :                 nIntVal += 2;
     364                 :            :             case XML_wd10 : // */ w 1.0 10.0
     365                 :          0 :                 nIntVal += 2;
     366                 :            :             case XML_wd8 :  // */ w 1.0 8.0
     367                 :          0 :                 nIntVal += 2;
     368                 :            :             case XML_wd6 :  // */ w 1.0 6.0
     369                 :          0 :                 nIntVal++;
     370                 :            :             case XML_wd5 :  // */ w 1.0 5.0
     371                 :          0 :                 nIntVal++;
     372                 :            :             case XML_wd4 :  // */ w 1.0 4.0
     373                 :          0 :                 nIntVal++;
     374                 :            :             case XML_wd3 :  // */ w 1.0 3.0
     375                 :          0 :                 nIntVal++;
     376                 :            :             case XML_hc :   // */ w 1.0 2.0
     377                 :            :             case XML_wd2 :  // */ w 1.0 2.0
     378                 :            :             {
     379                 :          0 :                 nIntVal += 2;
     380                 :            : 
     381                 :          0 :                 CustomShapeGuide aGuide;
     382                 :          0 :                 aGuide.maName = rValue;
     383         [ #  # ]:          0 :                 aGuide.maFormula = CREATE_OUSTRING( "logwidth/" ) + rtl::OUString::valueOf( nIntVal );
     384                 :            : 
     385 [ #  # ][ #  # ]:          0 :                 aRet.Value = Any( CustomShapeProperties::SetCustomShapeGuideValue( rCustomShapeProperties.getGuideList(), aGuide ) );
     386                 :          0 :                 aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
     387                 :            :             }
     388                 :          0 :             break;
     389                 :            : 
     390                 :            :             default:
     391                 :          0 :                 bConstant = sal_False;
     392                 :          0 :             break;
     393                 :            :         }
     394         [ #  # ]:          0 :         if ( bConstant )
     395                 :            :         {
     396         [ #  # ]:          0 :             if (nConstant != -1) {
     397         [ #  # ]:          0 :                 aRet.Value = Any( nConstant );
     398                 :          0 :                 aRet.Type = EnhancedCustomShapeParameterType::NORMAL;
     399                 :            :             }
     400                 :            :         }
     401                 :            :         else
     402                 :            :         {
     403                 :          0 :             sal_Unicode n = rValue[ 0 ];
     404 [ #  # ][ #  # ]:          0 :             if ( ( n == '+' ) || ( n == '-' ) )
     405                 :            :             {
     406         [ #  # ]:          0 :                 if ( !rValue.isEmpty() )
     407                 :          0 :                     n = rValue[ 1 ];
     408                 :            :             }
     409 [ #  # ][ #  # ]:          0 :             if ( ( n >= '0' ) && ( n <= '9' ) )
     410                 :            :             {   // seems to be a ST_Coordinate
     411         [ #  # ]:          0 :                 aRet.Value = Any( (sal_Int32)(rValue.toInt32() ) );
     412                 :          0 :                 aRet.Type = EnhancedCustomShapeParameterType::NORMAL;
     413                 :            :             }
     414                 :            :             else
     415                 :            :             {
     416         [ #  # ]:          0 :                 sal_Int32 nGuideIndex = CustomShapeProperties::GetCustomShapeGuideValue( rCustomShapeProperties.getAdjustmentGuideList(), rValue );
     417         [ #  # ]:          0 :                 if ( nGuideIndex >= 0 )
     418                 :            :                 {
     419         [ #  # ]:          0 :                     aRet.Value = Any( nGuideIndex );
     420                 :          0 :                     aRet.Type = EnhancedCustomShapeParameterType::ADJUSTMENT;
     421                 :            :                 }
     422                 :            :                 else
     423                 :            :                 {
     424         [ #  # ]:          0 :                     nGuideIndex = CustomShapeProperties::GetCustomShapeGuideValue( rCustomShapeProperties.getGuideList(), rValue );
     425         [ #  # ]:          0 :                     if ( nGuideIndex >= 0 )
     426                 :            :                     {
     427         [ #  # ]:          0 :                         aRet.Value = Any( nGuideIndex );
     428                 :          0 :                         aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
     429                 :            :                     }
     430                 :            :                     else
     431                 :            :                     {
     432                 :            :                         OSL_TRACE("error: unhandled value '%s'", OUStringToOString( rValue, RTL_TEXTENCODING_ASCII_US ).getStr());
     433         [ #  # ]:          0 :                         aRet.Value = Any( rValue );
     434                 :            :                     }
     435                 :            :                 }
     436                 :            :             }
     437                 :            :         }
     438                 :            :     }
     439                 :          0 :     return aRet;
     440                 :            : }
     441                 :            : 
     442                 :            : // ---------------------------------------------------------------------
     443                 :            : // CT_GeomGuideList
     444         [ -  + ]:        228 : class GeomGuideListContext : public ContextHandler
     445                 :            : {
     446                 :            : public:
     447                 :            :     GeomGuideListContext( ContextHandler& rParent, CustomShapeProperties& rCustomShapeProperties, std::vector< CustomShapeGuide >& rGuideList );
     448                 :            :     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);
     449                 :            : 
     450                 :            : protected:
     451                 :            :     std::vector< CustomShapeGuide >&    mrGuideList;
     452                 :            :     CustomShapeProperties&              mrCustomShapeProperties;
     453                 :            : };
     454                 :            : 
     455                 :        114 : GeomGuideListContext::GeomGuideListContext( ContextHandler& rParent, CustomShapeProperties& rCustomShapeProperties, std::vector< CustomShapeGuide >& rGuideList )
     456                 :            : : ContextHandler( rParent )
     457                 :            : , mrGuideList( rGuideList )
     458                 :        114 : , mrCustomShapeProperties( rCustomShapeProperties )
     459                 :            : {
     460                 :        114 : }
     461                 :            : 
     462                 :          0 : static rtl::OUString convertToOOEquation( CustomShapeProperties& rCustomShapeProperties, const rtl::OUString& rSource )
     463                 :            : {
     464         [ #  # ]:          0 :     if ( !pCommandHashMap )
     465                 :            :     {
     466 [ #  # ][ #  # ]:          0 :         FormulaCommandHMap* pHM = new FormulaCommandHMap();
     467         [ #  # ]:          0 :         for( sal_Int32 i = 0; i < FC_LAST; i++ )
     468         [ #  # ]:          0 :             (*pHM)[ OUString::createFromAscii( pFormularCommandNameTable[ i ].pS ) ] =  pFormularCommandNameTable[ i ].pE;
     469                 :          0 :         pCommandHashMap = pHM;
     470                 :            :     }
     471                 :            : 
     472         [ #  # ]:          0 :     std::vector< rtl::OUString > aTokens;
     473                 :          0 :     sal_Int32 nIndex = 0;
     474         [ #  # ]:          0 :     do
     475                 :            :     {
     476                 :          0 :         rtl::OUString aToken( rSource.getToken( 0, ' ', nIndex ) );
     477         [ #  # ]:          0 :         if ( !aToken.isEmpty() )
     478         [ #  # ]:          0 :             aTokens.push_back( aToken );
     479                 :            :     }
     480                 :            :     while ( nIndex >= 0 );
     481                 :            : 
     482                 :          0 :     rtl::OUString aEquation;
     483         [ #  # ]:          0 :     if ( !aTokens.empty() )
     484                 :            :     {
     485                 :          0 :         sal_Int32 i, nParameters = aTokens.size() - 1;
     486         [ #  # ]:          0 :         if ( nParameters > 3 )
     487                 :          0 :             nParameters = 3;
     488                 :            : 
     489         [ #  # ]:          0 :         rtl::OUString sParameters[ 3 ];
     490                 :            : 
     491         [ #  # ]:          0 :         for ( i = 0; i < nParameters; i++ )
     492 [ #  # ][ #  # ]:          0 :             sParameters[ i ] = GetFormulaParameter( GetAdjCoordinate( rCustomShapeProperties, aTokens[ i + 1 ], sal_False ) );
     493                 :            : 
     494         [ #  # ]:          0 :         const FormulaCommandHMap::const_iterator aIter( pCommandHashMap->find( aTokens[ 0 ] ) );
     495 [ #  # ][ #  # ]:          0 :         if ( aIter != pCommandHashMap->end() )
     496                 :            :         {
     497 [ #  # ][ #  #  :          0 :             switch( aIter->second )
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
                      # ]
     498                 :            :             {
     499                 :            :                 case FC_MULDIV :
     500                 :            :                 {
     501         [ #  # ]:          0 :                     if ( nParameters == 3 )
     502                 :            :                         aEquation = sParameters[ 0 ] + CREATE_OUSTRING( "*" ) + sParameters[ 1 ]
     503 [ #  # ][ #  # ]:          0 :                             + CREATE_OUSTRING( "/" ) + sParameters[ 2 ];
     504                 :            :                 }
     505                 :          0 :                 break;
     506                 :            :                 case FC_PLUSMINUS :
     507                 :            :                 {
     508         [ #  # ]:          0 :                     if ( nParameters == 3 )
     509                 :            :                         aEquation = sParameters[ 0 ] + CREATE_OUSTRING( "+" ) + sParameters[ 1 ]
     510 [ #  # ][ #  # ]:          0 :                             + CREATE_OUSTRING( "-" ) + sParameters[ 2 ];
     511                 :            :                 }
     512                 :          0 :                 break;
     513                 :            :                 case FC_PLUSDIV :
     514                 :            :                 {
     515         [ #  # ]:          0 :                     if ( nParameters == 3 )
     516                 :            :                         aEquation = CREATE_OUSTRING( "(" ) + sParameters[ 0 ] + CREATE_OUSTRING( "+" )
     517 [ #  # ][ #  # ]:          0 :                             + sParameters[ 1 ] + CREATE_OUSTRING( ")/" ) + sParameters[ 2 ];
                 [ #  # ]
     518                 :            :                 }
     519                 :          0 :                 break;
     520                 :            :                 case FC_IFELSE :
     521                 :            :                 case FC_IFELSE1 :
     522                 :            :                 {
     523         [ #  # ]:          0 :                     if ( nParameters == 3 )
     524                 :            :                         aEquation = CREATE_OUSTRING( "if(" ) + sParameters[ 0 ] + CREATE_OUSTRING( "," )
     525 [ #  # ][ #  # ]:          0 :                             + sParameters[ 1 ] + CREATE_OUSTRING( "," ) + sParameters[ 2 ] + CREATE_OUSTRING( ")" );
         [ #  # ][ #  # ]
     526                 :            :                 }
     527                 :          0 :                 break;
     528                 :            :                 case FC_ABS :
     529                 :            :                 {
     530         [ #  # ]:          0 :                     if ( nParameters == 1 )
     531 [ #  # ][ #  # ]:          0 :                         aEquation = CREATE_OUSTRING( "abs(" ) + sParameters[ 0 ] + CREATE_OUSTRING( ")" );
     532                 :            :                 }
     533                 :          0 :                 break;
     534                 :            :                 case FC_AT2 :
     535                 :            :                 {
     536         [ #  # ]:          0 :                     if ( nParameters == 2 )
     537                 :            :                         aEquation = CREATE_OUSTRING( "(10800000*atan2(" ) + sParameters[ 1 ] + CREATE_OUSTRING( "," )
     538 [ #  # ][ #  # ]:          0 :                         + sParameters[ 0 ] + CREATE_OUSTRING( "))/pi" );
                 [ #  # ]
     539                 :            :                 }
     540                 :          0 :                 break;
     541                 :            :                 case FC_CAT2 :
     542                 :            :                 {
     543         [ #  # ]:          0 :                     if ( nParameters == 3 )
     544                 :            :                         aEquation = sParameters[ 0 ] + CREATE_OUSTRING( "*(cos(atan2(" ) +
     545 [ #  # ][ #  # ]:          0 :                             sParameters[ 2 ] + CREATE_OUSTRING( "," ) + sParameters[ 1 ] + CREATE_OUSTRING( ")))" );
                 [ #  # ]
     546                 :            :                 }
     547                 :          0 :                 break;
     548                 :            :                 case FC_COS :
     549                 :            :                 {
     550         [ #  # ]:          0 :                     if ( nParameters == 2 )
     551                 :            :                         aEquation = sParameters[ 0 ] + CREATE_OUSTRING( "*cos(pi*(" ) +
     552 [ #  # ][ #  # ]:          0 :                         sParameters[ 1 ] + CREATE_OUSTRING( ")/10800000)" );
     553                 :            :                 }
     554                 :          0 :                 break;
     555                 :            :                 case FC_MAX :
     556                 :            :                 {
     557         [ #  # ]:          0 :                     if ( nParameters == 2 )
     558                 :            :                         aEquation = CREATE_OUSTRING( "max(" ) + sParameters[ 0 ] + CREATE_OUSTRING( "," ) +
     559 [ #  # ][ #  # ]:          0 :                             sParameters[ 1 ] + CREATE_OUSTRING( ")" );
                 [ #  # ]
     560                 :            :                 }
     561                 :          0 :                 break;
     562                 :            :                 case FC_MIN :
     563                 :            :                 {
     564         [ #  # ]:          0 :                     if ( nParameters == 2 )
     565                 :            :                         aEquation = CREATE_OUSTRING( "min(" ) + sParameters[ 0 ] + CREATE_OUSTRING( "," ) +
     566 [ #  # ][ #  # ]:          0 :                             sParameters[ 1 ] + CREATE_OUSTRING( ")" );
                 [ #  # ]
     567                 :            :                 }
     568                 :          0 :                 break;
     569                 :            :                 case FC_MOD :
     570                 :            :                 {
     571         [ #  # ]:          0 :                     if ( nParameters == 3 )
     572                 :            :                         aEquation = CREATE_OUSTRING( "sqrt(" )
     573                 :            :                             + sParameters[ 0 ] + CREATE_OUSTRING( "*" ) + sParameters[ 0 ] + CREATE_OUSTRING( "+" )
     574                 :            :                             + sParameters[ 1 ] + CREATE_OUSTRING( "*" ) + sParameters[ 1 ] + CREATE_OUSTRING( "+" )
     575 [ #  # ][ #  # ]:          0 :                             + sParameters[ 2 ] + CREATE_OUSTRING( "*" ) + sParameters[ 2 ] + CREATE_OUSTRING( ")" );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     576                 :            :                 }
     577                 :          0 :                 break;
     578                 :            :                 case FC_PIN :
     579                 :            :                 {
     580         [ #  # ]:          0 :                     if ( nParameters == 3 ) // if(x-y,x,if(y-z,z,y))
     581                 :            :                         aEquation = CREATE_OUSTRING( "if(" ) + sParameters[ 0 ] + CREATE_OUSTRING( "-" ) + sParameters[ 1 ]
     582                 :            :                             + CREATE_OUSTRING( "," ) + sParameters[ 0 ] + CREATE_OUSTRING( ",if(" ) + sParameters[ 2 ]
     583                 :            :                             + CREATE_OUSTRING( "-" ) + sParameters[ 1 ] + CREATE_OUSTRING( "," ) + sParameters[ 1 ]
     584 [ #  # ][ #  # ]:          0 :                             + CREATE_OUSTRING( "," ) + sParameters[ 2 ] + CREATE_OUSTRING( "))" );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     585                 :            :                 }
     586                 :          0 :                 break;
     587                 :            :                 case FC_SAT2 :
     588                 :            :                 {
     589         [ #  # ]:          0 :                     if ( nParameters == 3 )
     590                 :            :                         aEquation = sParameters[ 0 ] + CREATE_OUSTRING( "*(sin(atan2(" ) +
     591 [ #  # ][ #  # ]:          0 :                             sParameters[ 2 ] + CREATE_OUSTRING( "," ) + sParameters[ 1 ] + CREATE_OUSTRING( ")))" );
                 [ #  # ]
     592                 :            :                 }
     593                 :          0 :                 break;
     594                 :            :                 case FC_SIN :
     595                 :            :                 {
     596         [ #  # ]:          0 :                     if ( nParameters == 2 )
     597                 :            :                         aEquation = sParameters[ 0 ] + CREATE_OUSTRING( "*sin(pi*(" ) +
     598 [ #  # ][ #  # ]:          0 :                         sParameters[ 1 ] + CREATE_OUSTRING( ")/10800000)" );
     599                 :            :                 }
     600                 :          0 :                 break;
     601                 :            :                 case FC_SQRT :
     602                 :            :                 {
     603         [ #  # ]:          0 :                     if ( nParameters == 1 )
     604 [ #  # ][ #  # ]:          0 :                         aEquation = CREATE_OUSTRING( "sqrt(" ) + sParameters[ 0 ] + CREATE_OUSTRING( ")" );
     605                 :            :                 }
     606                 :          0 :                 break;
     607                 :            :                 case FC_TAN :
     608                 :            :                 {
     609         [ #  # ]:          0 :                     if ( nParameters == 2 )
     610                 :            :                         aEquation = sParameters[ 0 ] + CREATE_OUSTRING( "*tan(pi*(" ) +
     611 [ #  # ][ #  # ]:          0 :                         sParameters[ 1 ] + CREATE_OUSTRING( ")/10800000)" );
     612                 :            :                 }
     613                 :          0 :                 break;
     614                 :            :                 case FC_VAL :
     615                 :            :                 {
     616         [ #  # ]:          0 :                     if ( nParameters == 1 )
     617                 :          0 :                         aEquation = sParameters[ 0 ];
     618                 :            :                 }
     619                 :          0 :                 break;
     620                 :            :                 default :
     621                 :          0 :                     break;
     622                 :            :             }
     623 [ #  # ][ #  # ]:          0 :         }
     624                 :            :     }
     625                 :          0 :     return aEquation;
     626                 :            : }
     627                 :            : 
     628                 :          0 : Reference< XFastContextHandler > GeomGuideListContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
     629                 :            : {
     630         [ #  # ]:          0 :     if ( aElementToken == A_TOKEN( gd ) )   // CT_GeomGuide
     631                 :            :     {
     632                 :          0 :         CustomShapeGuide aGuide;
     633 [ #  # ][ #  # ]:          0 :         aGuide.maName = xAttribs->getOptionalValue( XML_name );
     634 [ #  # ][ #  # ]:          0 :         aGuide.maFormula = convertToOOEquation( mrCustomShapeProperties, xAttribs->getOptionalValue( XML_fmla ) );
                 [ #  # ]
     635         [ #  # ]:          0 :         mrGuideList.push_back( aGuide );
     636                 :            :     }
     637                 :          0 :     return this;
     638                 :            : }
     639                 :            : 
     640                 :            : // ---------------------------------------------------------------------
     641                 :            : 
     642                 :          0 : static const rtl::OUString GetGeomGuideName( const ::rtl::OUString& rValue )
     643                 :            : {
     644                 :          0 :     return rValue;
     645                 :            : }
     646                 :            : 
     647                 :            : // ---------------------------------------------------------------------
     648                 :            : // CT_AdjPoint2D
     649         [ #  # ]:          0 : class AdjPoint2DContext : public ContextHandler
     650                 :            : {
     651                 :            : public:
     652                 :            :     AdjPoint2DContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, CustomShapeProperties& rCustomShapeProperties, EnhancedCustomShapeParameterPair& rAdjPoint2D );
     653                 :            : };
     654                 :            : 
     655                 :          0 : AdjPoint2DContext::AdjPoint2DContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, CustomShapeProperties& rCustomShapeProperties, EnhancedCustomShapeParameterPair& rAdjPoint2D )
     656                 :          0 : : ContextHandler( rParent )
     657                 :            : {
     658 [ #  # ][ #  # ]:          0 :     rAdjPoint2D.First = GetAdjCoordinate( rCustomShapeProperties, xAttribs->getOptionalValue( XML_x ), sal_True );
                 [ #  # ]
     659 [ #  # ][ #  # ]:          0 :     rAdjPoint2D.Second = GetAdjCoordinate( rCustomShapeProperties, xAttribs->getOptionalValue( XML_y ), sal_True );
                 [ #  # ]
     660                 :          0 : }
     661                 :            : 
     662                 :            : // ---------------------------------------------------------------------
     663                 :            : // CT_XYAdjustHandle
     664         [ #  # ]:          0 : class XYAdjustHandleContext : public ContextHandler
     665                 :            : {
     666                 :            : public:
     667                 :            :     XYAdjustHandleContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, CustomShapeProperties& rCustomShapeProperties, AdjustHandle& rAdjustHandle );
     668                 :            :     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);
     669                 :            : 
     670                 :            : protected:
     671                 :            :     AdjustHandle& mrAdjustHandle;
     672                 :            :     CustomShapeProperties& mrCustomShapeProperties;
     673                 :            : };
     674                 :            : 
     675                 :          0 : XYAdjustHandleContext::XYAdjustHandleContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, CustomShapeProperties& rCustomShapeProperties, AdjustHandle& rAdjustHandle )
     676                 :            : : ContextHandler( rParent )
     677                 :            : , mrAdjustHandle( rAdjustHandle )
     678                 :          0 : , mrCustomShapeProperties( rCustomShapeProperties )
     679                 :            : {
     680                 :          0 :     const rtl::OUString aEmptyDefault;
     681         [ #  # ]:          0 :     AttributeList aAttribs( xAttribs );
     682 [ #  # ][ #  # ]:          0 :     if ( aAttribs.hasAttribute( XML_gdRefX ) )
     683                 :            :     {
     684 [ #  # ][ #  # ]:          0 :         mrAdjustHandle.gdRef1 = GetGeomGuideName( aAttribs.getString( XML_gdRefX, aEmptyDefault ) );
     685                 :            :     }
     686 [ #  # ][ #  # ]:          0 :     if ( aAttribs.hasAttribute( XML_minX ) )
     687                 :            :     {
     688 [ #  # ][ #  # ]:          0 :         mrAdjustHandle.min1 = GetAdjCoordinate( mrCustomShapeProperties, aAttribs.getString( XML_minX, aEmptyDefault ), sal_True );
                 [ #  # ]
     689                 :            :     }
     690 [ #  # ][ #  # ]:          0 :     if ( aAttribs.hasAttribute( XML_maxX ) )
     691                 :            :     {
     692 [ #  # ][ #  # ]:          0 :         mrAdjustHandle.max1 = GetAdjCoordinate( mrCustomShapeProperties, aAttribs.getString( XML_maxX, aEmptyDefault ), sal_True );
                 [ #  # ]
     693                 :            :     }
     694 [ #  # ][ #  # ]:          0 :     if ( aAttribs.hasAttribute( XML_gdRefY ) )
     695                 :            :     {
     696 [ #  # ][ #  # ]:          0 :         mrAdjustHandle.gdRef2 = GetGeomGuideName( aAttribs.getString( XML_gdRefY, aEmptyDefault ) );
     697                 :            :     }
     698 [ #  # ][ #  # ]:          0 :     if ( aAttribs.hasAttribute( XML_minY ) )
     699                 :            :     {
     700 [ #  # ][ #  # ]:          0 :         mrAdjustHandle.min2 = GetAdjCoordinate( mrCustomShapeProperties, aAttribs.getString( XML_minY, aEmptyDefault ), sal_True );
                 [ #  # ]
     701                 :            :     }
     702 [ #  # ][ #  # ]:          0 :     if ( aAttribs.hasAttribute( XML_maxY ) )
     703                 :            :     {
     704 [ #  # ][ #  # ]:          0 :         mrAdjustHandle.max2 = GetAdjCoordinate( mrCustomShapeProperties, aAttribs.getString( XML_maxY, aEmptyDefault ), sal_True );
                 [ #  # ]
     705         [ #  # ]:          0 :     }
     706                 :          0 : }
     707                 :            : 
     708                 :          0 : Reference< XFastContextHandler > XYAdjustHandleContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
     709                 :            : {
     710                 :          0 :     Reference< XFastContextHandler > xContext;
     711         [ #  # ]:          0 :     if ( aElementToken == A_TOKEN( pos ) )
     712 [ #  # ][ #  # ]:          0 :         xContext = new AdjPoint2DContext( *this, xAttribs, mrCustomShapeProperties, mrAdjustHandle.pos );   // CT_AdjPoint2D
                 [ #  # ]
     713                 :          0 :     return xContext;
     714                 :            : }
     715                 :            : 
     716                 :            : // ---------------------------------------------------------------------
     717                 :            : // CT_PolarAdjustHandle
     718         [ #  # ]:          0 : class PolarAdjustHandleContext : public ContextHandler
     719                 :            : {
     720                 :            : public:
     721                 :            :     PolarAdjustHandleContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, CustomShapeProperties& rCustomShapeProperties, AdjustHandle& rAdjustHandle );
     722                 :            :     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);
     723                 :            : 
     724                 :            : protected:
     725                 :            :     AdjustHandle& mrAdjustHandle;
     726                 :            :     CustomShapeProperties& mrCustomShapeProperties;
     727                 :            : };
     728                 :            : 
     729                 :          0 : PolarAdjustHandleContext::PolarAdjustHandleContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, CustomShapeProperties& rCustomShapeProperties, AdjustHandle& rAdjustHandle )
     730                 :            : : ContextHandler( rParent )
     731                 :            : , mrAdjustHandle( rAdjustHandle )
     732                 :          0 : , mrCustomShapeProperties( rCustomShapeProperties )
     733                 :            : {
     734                 :          0 :     const rtl::OUString aEmptyDefault;
     735         [ #  # ]:          0 :     AttributeList aAttribs( xAttribs );
     736 [ #  # ][ #  # ]:          0 :     if ( aAttribs.hasAttribute( XML_gdRefR ) )
     737                 :            :     {
     738 [ #  # ][ #  # ]:          0 :         mrAdjustHandle.gdRef1 = GetGeomGuideName( aAttribs.getString( XML_gdRefR, aEmptyDefault ) );
     739                 :            :     }
     740 [ #  # ][ #  # ]:          0 :     if ( aAttribs.hasAttribute( XML_minR ) )
     741                 :            :     {
     742 [ #  # ][ #  # ]:          0 :         mrAdjustHandle.min1 = GetAdjCoordinate( mrCustomShapeProperties, aAttribs.getString( XML_minR, aEmptyDefault ), sal_True );
                 [ #  # ]
     743                 :            :     }
     744 [ #  # ][ #  # ]:          0 :     if ( aAttribs.hasAttribute( XML_maxR ) )
     745                 :            :     {
     746 [ #  # ][ #  # ]:          0 :         mrAdjustHandle.max1 = GetAdjCoordinate( mrCustomShapeProperties, aAttribs.getString( XML_maxR, aEmptyDefault ), sal_True );
                 [ #  # ]
     747                 :            :     }
     748 [ #  # ][ #  # ]:          0 :     if ( aAttribs.hasAttribute( XML_gdRefAng ) )
     749                 :            :     {
     750 [ #  # ][ #  # ]:          0 :         mrAdjustHandle.gdRef2 = GetGeomGuideName( aAttribs.getString( XML_gdRefAng, aEmptyDefault ) );
     751                 :            :     }
     752 [ #  # ][ #  # ]:          0 :     if ( aAttribs.hasAttribute( XML_minAng ) )
     753                 :            :     {
     754 [ #  # ][ #  # ]:          0 :         mrAdjustHandle.min2 = GetAdjCoordinate( mrCustomShapeProperties, aAttribs.getString( XML_minAng, aEmptyDefault ) );
                 [ #  # ]
     755                 :            :     }
     756 [ #  # ][ #  # ]:          0 :     if ( aAttribs.hasAttribute( XML_maxAng ) )
     757                 :            :     {
     758 [ #  # ][ #  # ]:          0 :         mrAdjustHandle.max2 = GetAdjCoordinate( mrCustomShapeProperties, aAttribs.getString( XML_maxAng, aEmptyDefault ) );
                 [ #  # ]
     759         [ #  # ]:          0 :     }
     760                 :          0 : }
     761                 :            : 
     762                 :          0 : Reference< XFastContextHandler > PolarAdjustHandleContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
     763                 :            : {
     764                 :          0 :     Reference< XFastContextHandler > xContext;
     765         [ #  # ]:          0 :     if ( aElementToken == A_TOKEN( pos ) )
     766 [ #  # ][ #  # ]:          0 :         xContext = new AdjPoint2DContext( *this, xAttribs, mrCustomShapeProperties, mrAdjustHandle.pos );   // CT_AdjPoint2D
                 [ #  # ]
     767                 :          0 :     return xContext;
     768                 :            : }
     769                 :            : 
     770                 :            : // ---------------------------------------------------------------------
     771                 :            : // CT_AdjustHandleList
     772         [ #  # ]:          0 : class AdjustHandleListContext : public ContextHandler
     773                 :            : {
     774                 :            : public:
     775                 :            :     AdjustHandleListContext( ContextHandler& rParent, CustomShapeProperties& rCustomShapeProperties, std::vector< AdjustHandle >& rAdjustHandleList );
     776                 :            :     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);
     777                 :            : 
     778                 :            : protected:
     779                 :            :     std::vector< AdjustHandle >& mrAdjustHandleList;
     780                 :            :     CustomShapeProperties& mrCustomShapeProperties;
     781                 :            : };
     782                 :            : 
     783                 :          0 : AdjustHandleListContext::AdjustHandleListContext( ContextHandler& rParent, CustomShapeProperties& rCustomShapeProperties, std::vector< AdjustHandle >& rAdjustHandleList )
     784                 :            : : ContextHandler( rParent )
     785                 :            : , mrAdjustHandleList( rAdjustHandleList )
     786                 :          0 : , mrCustomShapeProperties( rCustomShapeProperties )
     787                 :            : {
     788                 :          0 : }
     789                 :            : 
     790                 :          0 : Reference< XFastContextHandler > AdjustHandleListContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
     791                 :            : {
     792                 :          0 :     Reference< XFastContextHandler > xContext;
     793         [ #  # ]:          0 :     if ( aElementToken == A_TOKEN( ahXY ) )         // CT_XYAdjustHandle
     794                 :            :     {
     795         [ #  # ]:          0 :         AdjustHandle aAdjustHandle( sal_False );
     796         [ #  # ]:          0 :         mrAdjustHandleList.push_back( aAdjustHandle );
     797 [ #  # ][ #  # ]:          0 :         xContext = new XYAdjustHandleContext( *this, xAttribs, mrCustomShapeProperties, mrAdjustHandleList.back() );
         [ #  # ][ #  # ]
     798                 :            :     }
     799         [ #  # ]:          0 :     else if ( aElementToken == A_TOKEN( ahPolar ) ) // CT_PolarAdjustHandle
     800                 :            :     {
     801         [ #  # ]:          0 :         AdjustHandle aAdjustHandle( sal_True );
     802         [ #  # ]:          0 :         mrAdjustHandleList.push_back( aAdjustHandle );
     803 [ #  # ][ #  # ]:          0 :         xContext = new PolarAdjustHandleContext( *this, xAttribs, mrCustomShapeProperties, mrAdjustHandleList.back() );
         [ #  # ][ #  # ]
     804                 :            :     }
     805                 :          0 :     return xContext;
     806                 :            : }
     807                 :            : 
     808                 :            : // ---------------------------------------------------------------------
     809                 :            : // CT_ConnectionSite
     810         [ #  # ]:          0 : class ConnectionSiteContext : public ContextHandler
     811                 :            : {
     812                 :            : public:
     813                 :            :     ConnectionSiteContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, CustomShapeProperties& rCustomShapeProperties, ConnectionSite& rConnectionSite );
     814                 :            :     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);
     815                 :            : 
     816                 :            : protected:
     817                 :            :     ConnectionSite& mrConnectionSite;
     818                 :            :     CustomShapeProperties& mrCustomShapeProperties;
     819                 :            : };
     820                 :            : 
     821                 :          0 : ConnectionSiteContext::ConnectionSiteContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, CustomShapeProperties& rCustomShapeProperties, ConnectionSite& rConnectionSite )
     822                 :            : : ContextHandler( rParent )
     823                 :            : , mrConnectionSite( rConnectionSite )
     824                 :          0 : , mrCustomShapeProperties( rCustomShapeProperties )
     825                 :            : {
     826 [ #  # ][ #  # ]:          0 :     mrConnectionSite.ang = GetAdjCoordinate( mrCustomShapeProperties, xAttribs->getOptionalValue( XML_ang ) );
                 [ #  # ]
     827                 :          0 : }
     828                 :            : 
     829                 :          0 : Reference< XFastContextHandler > ConnectionSiteContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
     830                 :            : {
     831                 :          0 :     Reference< XFastContextHandler > xContext;
     832         [ #  # ]:          0 :     if ( aElementToken == A_TOKEN( pos ) )
     833 [ #  # ][ #  # ]:          0 :         xContext = new AdjPoint2DContext( *this, xAttribs, mrCustomShapeProperties, mrConnectionSite.pos ); // CT_AdjPoint2D
                 [ #  # ]
     834                 :          0 :     return xContext;
     835                 :            : }
     836                 :            : 
     837                 :            : // ---------------------------------------------------------------------
     838                 :            : // CT_Path2DMoveTo
     839         [ #  # ]:          0 : class Path2DMoveToContext : public ContextHandler
     840                 :            : {
     841                 :            : public:
     842                 :            :     Path2DMoveToContext( ContextHandler& rParent, CustomShapeProperties& rCustomShapeProperties, EnhancedCustomShapeParameterPair& rAdjPoint2D );
     843                 :            :     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);
     844                 :            : 
     845                 :            : protected:
     846                 :            :     EnhancedCustomShapeParameterPair& mrAdjPoint2D;
     847                 :            :     CustomShapeProperties& mrCustomShapeProperties;
     848                 :            : };
     849                 :            : 
     850                 :          0 : Path2DMoveToContext::Path2DMoveToContext( ContextHandler& rParent, CustomShapeProperties& rCustomShapeProperties, EnhancedCustomShapeParameterPair& rAdjPoint2D )
     851                 :            : : ContextHandler( rParent )
     852                 :            : , mrAdjPoint2D( rAdjPoint2D )
     853                 :          0 : , mrCustomShapeProperties( rCustomShapeProperties )
     854                 :            : {
     855                 :          0 : }
     856                 :            : 
     857                 :          0 : Reference< XFastContextHandler > Path2DMoveToContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
     858                 :            : {
     859                 :          0 :     Reference< XFastContextHandler > xContext;
     860         [ #  # ]:          0 :     if ( aElementToken == A_TOKEN( pt ) )
     861 [ #  # ][ #  # ]:          0 :         xContext = new AdjPoint2DContext( *this, xAttribs, mrCustomShapeProperties, mrAdjPoint2D );     // CT_AdjPoint2D
                 [ #  # ]
     862                 :          0 :     return xContext;
     863                 :            : }
     864                 :            : 
     865                 :            : // ---------------------------------------------------------------------
     866                 :            : // CT_Path2DLineTo
     867         [ #  # ]:          0 : class Path2DLineToContext : public ContextHandler
     868                 :            : {
     869                 :            : public:
     870                 :            :     Path2DLineToContext( ContextHandler& rParent, CustomShapeProperties& rCustomShapeProperties, EnhancedCustomShapeParameterPair& rAdjPoint2D );
     871                 :            :     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);
     872                 :            : 
     873                 :            : protected:
     874                 :            :     EnhancedCustomShapeParameterPair& mrAdjPoint2D;
     875                 :            :     CustomShapeProperties& mrCustomShapeProperties;
     876                 :            : };
     877                 :            : 
     878                 :          0 : Path2DLineToContext::Path2DLineToContext( ContextHandler& rParent, CustomShapeProperties& rCustomShapeProperties, EnhancedCustomShapeParameterPair& rAdjPoint2D )
     879                 :            : : ContextHandler( rParent )
     880                 :            : , mrAdjPoint2D( rAdjPoint2D )
     881                 :          0 : , mrCustomShapeProperties( rCustomShapeProperties )
     882                 :            : {
     883                 :          0 : }
     884                 :            : 
     885                 :          0 : Reference< XFastContextHandler > Path2DLineToContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
     886                 :            : {
     887                 :          0 :     Reference< XFastContextHandler > xContext;
     888         [ #  # ]:          0 :     if ( aElementToken == A_TOKEN( pt ) )
     889 [ #  # ][ #  # ]:          0 :         xContext = new AdjPoint2DContext( *this, xAttribs, mrCustomShapeProperties, mrAdjPoint2D );     // CT_AdjPoint2D
                 [ #  # ]
     890                 :          0 :     return xContext;
     891                 :            : }
     892                 :            : 
     893                 :            : // ---------------------------------------------------------------------
     894                 :            : // CT_Path2DQuadBezierTo
     895         [ #  # ]:          0 : class Path2DQuadBezierToContext : public ContextHandler
     896                 :            : {
     897                 :            : public:
     898                 :            :     Path2DQuadBezierToContext( ContextHandler& rParent, CustomShapeProperties& rCustomShapeProperties, EnhancedCustomShapeParameterPair& rPt1, EnhancedCustomShapeParameterPair& rPt2 );
     899                 :            :     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);
     900                 :            : 
     901                 :            : protected:
     902                 :            :     EnhancedCustomShapeParameterPair& mrPt1;
     903                 :            :     EnhancedCustomShapeParameterPair& mrPt2;
     904                 :            :     int nCount;
     905                 :            :     CustomShapeProperties& mrCustomShapeProperties;
     906                 :            : };
     907                 :            : 
     908                 :          0 : Path2DQuadBezierToContext::Path2DQuadBezierToContext( ContextHandler& rParent,
     909                 :            :     CustomShapeProperties& rCustomShapeProperties,
     910                 :            :         EnhancedCustomShapeParameterPair& rPt1,
     911                 :            :             EnhancedCustomShapeParameterPair& rPt2 )
     912                 :            : : ContextHandler( rParent )
     913                 :            : , mrPt1( rPt1 )
     914                 :            : , mrPt2( rPt2 )
     915                 :            : , nCount( 0 )
     916                 :          0 : , mrCustomShapeProperties( rCustomShapeProperties )
     917                 :            : {
     918                 :          0 : }
     919                 :            : 
     920                 :          0 : Reference< XFastContextHandler > Path2DQuadBezierToContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
     921                 :            : {
     922                 :          0 :     Reference< XFastContextHandler > xContext;
     923         [ #  # ]:          0 :     if ( aElementToken == A_TOKEN( pt ) )
     924 [ #  # ][ #  # ]:          0 :         xContext = new AdjPoint2DContext( *this, xAttribs, mrCustomShapeProperties, nCount++ ? mrPt2 : mrPt1 ); // CT_AdjPoint2D
         [ #  # ][ #  # ]
     925                 :          0 :     return xContext;
     926                 :            : }
     927                 :            : 
     928                 :            : // ---------------------------------------------------------------------
     929                 :            : // CT_Path2DCubicBezierTo
     930         [ #  # ]:          0 : class Path2DCubicBezierToContext : public ContextHandler
     931                 :            : {
     932                 :            : public:
     933                 :            :     Path2DCubicBezierToContext( ContextHandler& rParent, CustomShapeProperties& rCustomShapeProperties,
     934                 :            :         EnhancedCustomShapeParameterPair&, EnhancedCustomShapeParameterPair&, EnhancedCustomShapeParameterPair& );
     935                 :            :     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);
     936                 :            : 
     937                 :            : protected:
     938                 :            :     CustomShapeProperties& mrCustomShapeProperties;
     939                 :            :     EnhancedCustomShapeParameterPair& mrControlPt1;
     940                 :            :     EnhancedCustomShapeParameterPair& mrControlPt2;
     941                 :            :     EnhancedCustomShapeParameterPair& mrEndPt;
     942                 :            :     int nCount;
     943                 :            : };
     944                 :            : 
     945                 :          0 : Path2DCubicBezierToContext::Path2DCubicBezierToContext( ContextHandler& rParent, CustomShapeProperties& rCustomShapeProperties,
     946                 :            :     EnhancedCustomShapeParameterPair& rControlPt1,
     947                 :            :         EnhancedCustomShapeParameterPair& rControlPt2,
     948                 :            :             EnhancedCustomShapeParameterPair& rEndPt )
     949                 :            : : ContextHandler( rParent )
     950                 :            : , mrCustomShapeProperties( rCustomShapeProperties )
     951                 :            : , mrControlPt1( rControlPt1 )
     952                 :            : , mrControlPt2( rControlPt2 )
     953                 :            : , mrEndPt( rEndPt )
     954                 :          0 : , nCount( 0 )
     955                 :            : {
     956                 :          0 : }
     957                 :            : 
     958                 :          0 : Reference< XFastContextHandler > Path2DCubicBezierToContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
     959                 :            : {
     960                 :          0 :     Reference< XFastContextHandler > xContext;
     961         [ #  # ]:          0 :     if ( aElementToken == A_TOKEN( pt ) )
     962                 :            :         xContext = new AdjPoint2DContext( *this, xAttribs, mrCustomShapeProperties,
     963 [ #  # ][ #  # ]:          0 :             nCount++ ? nCount == 2 ? mrControlPt2 : mrEndPt : mrControlPt1 );   // CT_AdjPoint2D
         [ #  # ][ #  # ]
                 [ #  # ]
     964                 :          0 :     return xContext;
     965                 :            : }
     966                 :            : 
     967                 :            : // ---------------------------------------------------------------------
     968                 :            : // CT_Path2DContext
     969                 :            : class Path2DContext : public ContextHandler
     970                 :            : {
     971                 :            : public:
     972                 :            :     Path2DContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, CustomShapeProperties& rCustomShapeProperties, std::vector< com::sun::star::drawing::EnhancedCustomShapeSegment >& rSegments, Path2D& rPath2D );
     973                 :            :     virtual ~Path2DContext();
     974                 :            :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL
     975                 :            :         createFastChildContext( sal_Int32 aElementToken, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs )
     976                 :            :             throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
     977                 :            : 
     978                 :            : protected:
     979                 :            :     Path2D& mrPath2D;
     980                 :            :     std::vector< com::sun::star::drawing::EnhancedCustomShapeSegment >& mrSegments;
     981                 :            :     CustomShapeProperties& mrCustomShapeProperties;
     982                 :            : };
     983                 :            : 
     984                 :          0 : Path2DContext::Path2DContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, CustomShapeProperties& rCustomShapeProperties, std::vector< com::sun::star::drawing::EnhancedCustomShapeSegment >& rSegments, Path2D& rPath2D )
     985                 :            : : ContextHandler( rParent )
     986                 :            : , mrPath2D( rPath2D )
     987                 :            : , mrSegments( rSegments )
     988                 :          0 : , mrCustomShapeProperties( rCustomShapeProperties )
     989                 :            : {
     990                 :          0 :     const rtl::OUString aEmptyString;
     991                 :            : 
     992         [ #  # ]:          0 :     AttributeList aAttribs( xAttribs );
     993         [ #  # ]:          0 :     rPath2D.w = aAttribs.getString( XML_w, aEmptyString ).toInt64();
     994         [ #  # ]:          0 :     rPath2D.h = aAttribs.getString( XML_h, aEmptyString ).toInt64();
     995         [ #  # ]:          0 :     rPath2D.fill = aAttribs.getToken( XML_fill, XML_norm );
     996         [ #  # ]:          0 :     rPath2D.stroke = aAttribs.getBool( XML_stroke, sal_True );
     997 [ #  # ][ #  # ]:          0 :     rPath2D.extrusionOk = aAttribs.getBool( XML_extrusionOk, sal_True );
     998                 :          0 : }
     999                 :            : 
    1000                 :          0 : Path2DContext::~Path2DContext()
    1001                 :            : {
    1002                 :          0 :     EnhancedCustomShapeSegment aNewSegment;
    1003   [ #  #  #  #  :          0 :     switch ( mrPath2D.fill )
                   #  # ]
    1004                 :            :     {
    1005                 :            :         case XML_none:
    1006                 :          0 :             aNewSegment.Command = EnhancedCustomShapeSegmentCommand::NOFILL;
    1007                 :          0 :             break;
    1008                 :            :         case XML_darken:
    1009                 :          0 :             aNewSegment.Command = EnhancedCustomShapeSegmentCommand::DARKEN;
    1010                 :          0 :             break;
    1011                 :            :         case XML_darkenLess:
    1012                 :          0 :             aNewSegment.Command = EnhancedCustomShapeSegmentCommand::DARKENLESS;
    1013                 :          0 :             break;
    1014                 :            :         case XML_lighten:
    1015                 :          0 :             aNewSegment.Command = EnhancedCustomShapeSegmentCommand::LIGHTEN;
    1016                 :          0 :             break;
    1017                 :            :         case XML_lightenLess:
    1018                 :          0 :             aNewSegment.Command = EnhancedCustomShapeSegmentCommand::LIGHTENLESS;
    1019                 :          0 :             break;
    1020                 :            :     }
    1021         [ #  # ]:          0 :     if (mrPath2D.fill != XML_norm) {
    1022                 :          0 :         aNewSegment.Count = 0;
    1023         [ #  # ]:          0 :         mrSegments.push_back( aNewSegment );
    1024                 :            :     }
    1025         [ #  # ]:          0 :     if ( !mrPath2D.stroke )
    1026                 :            :     {
    1027                 :          0 :         aNewSegment.Command = EnhancedCustomShapeSegmentCommand::NOSTROKE;
    1028                 :          0 :         aNewSegment.Count = 0;
    1029         [ #  # ]:          0 :         mrSegments.push_back( aNewSegment );
    1030                 :            :     }
    1031                 :          0 :     aNewSegment.Command = EnhancedCustomShapeSegmentCommand::ENDSUBPATH;
    1032                 :          0 :     aNewSegment.Count = 0;
    1033         [ #  # ]:          0 :     mrSegments.push_back( aNewSegment );
    1034         [ #  # ]:          0 : }
    1035                 :            : 
    1036                 :          0 : Reference< XFastContextHandler > Path2DContext::createFastChildContext( sal_Int32 aElementToken,
    1037                 :            :     const Reference< XFastAttributeList >& xAttribs ) throw ( SAXException, RuntimeException )
    1038                 :            : {
    1039                 :          0 :     Reference< XFastContextHandler > xContext;
    1040   [ #  #  #  #  :          0 :     switch( aElementToken )
                #  #  # ]
    1041                 :            :     {
    1042                 :            :         case A_TOKEN( close ) :
    1043                 :            :         {
    1044                 :            :             // ignore close after move to (ppt does seems to do the same, see accentCallout2 preset for example)
    1045 [ #  # ][ #  # ]:          0 :             if ( mrSegments.empty() || ( mrSegments.back().Command != EnhancedCustomShapeSegmentCommand::MOVETO ) ) {
         [ #  # ][ #  # ]
    1046                 :          0 :                 EnhancedCustomShapeSegment aNewSegment;
    1047                 :          0 :                 aNewSegment.Command = EnhancedCustomShapeSegmentCommand::CLOSESUBPATH;
    1048                 :          0 :                 aNewSegment.Count = 0;
    1049         [ #  # ]:          0 :                 mrSegments.push_back( aNewSegment );
    1050                 :            :             }
    1051                 :            :         }
    1052                 :          0 :         break;
    1053                 :            :         case A_TOKEN( moveTo ) :
    1054                 :            :         {
    1055                 :          0 :             EnhancedCustomShapeSegment aNewSegment;
    1056                 :          0 :             aNewSegment.Command = EnhancedCustomShapeSegmentCommand::MOVETO;
    1057                 :          0 :             aNewSegment.Count = 1;
    1058         [ #  # ]:          0 :             mrSegments.push_back( aNewSegment );
    1059                 :            : 
    1060                 :          0 :             EnhancedCustomShapeParameterPair aAdjPoint2D;
    1061         [ #  # ]:          0 :             mrPath2D.parameter.push_back( aAdjPoint2D );
    1062 [ #  # ][ #  # ]:          0 :             xContext = new Path2DMoveToContext( *this, mrCustomShapeProperties, mrPath2D.parameter.back() );
         [ #  # ][ #  # ]
    1063                 :            :         }
    1064                 :          0 :         break;
    1065                 :            :         case A_TOKEN( lnTo ) :
    1066                 :            :         {
    1067                 :            : 
    1068 [ #  # ][ #  # ]:          0 :             if ( !mrSegments.empty() && ( mrSegments.back().Command == EnhancedCustomShapeSegmentCommand::LINETO ) )
         [ #  # ][ #  # ]
    1069         [ #  # ]:          0 :                 mrSegments.back().Count++;
    1070                 :            :             else
    1071                 :            :             {
    1072                 :          0 :                 EnhancedCustomShapeSegment aSegment;
    1073                 :          0 :                 aSegment.Command = EnhancedCustomShapeSegmentCommand::LINETO;
    1074                 :          0 :                 aSegment.Count = 1;
    1075         [ #  # ]:          0 :                 mrSegments.push_back( aSegment );
    1076                 :            :             }
    1077                 :          0 :             EnhancedCustomShapeParameterPair aAdjPoint2D;
    1078         [ #  # ]:          0 :             mrPath2D.parameter.push_back( aAdjPoint2D );
    1079 [ #  # ][ #  # ]:          0 :             xContext = new Path2DLineToContext( *this, mrCustomShapeProperties, mrPath2D.parameter.back() );
         [ #  # ][ #  # ]
    1080                 :            :         }
    1081                 :          0 :         break;
    1082                 :            :         case A_TOKEN( arcTo ) : // CT_Path2DArcTo
    1083                 :            :         {
    1084 [ #  # ][ #  # ]:          0 :             if ( !mrSegments.empty() && ( mrSegments.back().Command == EnhancedCustomShapeSegmentCommand::ARCANGLETO ) )
         [ #  # ][ #  # ]
    1085         [ #  # ]:          0 :                 mrSegments.back().Count++;
    1086                 :            :             else
    1087                 :            :             {
    1088                 :          0 :                 EnhancedCustomShapeSegment aSegment;
    1089                 :          0 :                 aSegment.Command = EnhancedCustomShapeSegmentCommand::ARCANGLETO;
    1090                 :          0 :                 aSegment.Count = 1;
    1091         [ #  # ]:          0 :                 mrSegments.push_back( aSegment );
    1092                 :            :             }
    1093                 :            : 
    1094                 :          0 :             EnhancedCustomShapeParameterPair aScale;
    1095                 :          0 :             EnhancedCustomShapeParameterPair aAngles;
    1096                 :            : 
    1097 [ #  # ][ #  # ]:          0 :             aScale.First = GetAdjCoordinate( mrCustomShapeProperties, xAttribs->getOptionalValue( XML_wR ), sal_True );
                 [ #  # ]
    1098 [ #  # ][ #  # ]:          0 :             aScale.Second = GetAdjCoordinate( mrCustomShapeProperties, xAttribs->getOptionalValue( XML_hR ), sal_True );
                 [ #  # ]
    1099                 :            : 
    1100                 :          0 :             CustomShapeGuide aGuide;
    1101                 :          0 :             sal_Int32 nArcNum = mrCustomShapeProperties.getArcNum();
    1102                 :            : 
    1103                 :            :             // start angle
    1104         [ #  # ]:          0 :             aGuide.maName = CREATE_OUSTRING("arctosa") + rtl::OUString::valueOf( nArcNum );
    1105                 :            :             aGuide.maFormula = CREATE_OUSTRING( "(")
    1106         [ #  # ]:          0 :                 + GetFormulaParameter( GetAdjCoordinate( mrCustomShapeProperties, xAttribs->getOptionalValue( XML_stAng ) ) )
    1107 [ #  # ][ #  # ]:          0 :                 + CREATE_OUSTRING( ")/60000.0" );
         [ #  # ][ #  # ]
                 [ #  # ]
    1108 [ #  # ][ #  # ]:          0 :             aAngles.First.Value = Any( CustomShapeProperties::SetCustomShapeGuideValue( mrCustomShapeProperties.getGuideList(), aGuide ) );
    1109                 :          0 :             aAngles.First.Type = EnhancedCustomShapeParameterType::EQUATION;
    1110                 :            : 
    1111                 :            :             // swing angle
    1112         [ #  # ]:          0 :             aGuide.maName = CREATE_OUSTRING("arctosw") + rtl::OUString::valueOf( nArcNum );
    1113                 :            :             aGuide.maFormula = CREATE_OUSTRING( "(")
    1114         [ #  # ]:          0 :                 + GetFormulaParameter( GetAdjCoordinate( mrCustomShapeProperties, xAttribs->getOptionalValue( XML_swAng ) ) )
    1115 [ #  # ][ #  # ]:          0 :                 + CREATE_OUSTRING( ")/60000.0" );
         [ #  # ][ #  # ]
                 [ #  # ]
    1116 [ #  # ][ #  # ]:          0 :             aAngles.Second.Value = Any( CustomShapeProperties::SetCustomShapeGuideValue( mrCustomShapeProperties.getGuideList(), aGuide ) );
    1117                 :          0 :             aAngles.Second.Type = EnhancedCustomShapeParameterType::EQUATION;
    1118                 :            : 
    1119         [ #  # ]:          0 :             mrPath2D.parameter.push_back( aScale );
    1120         [ #  # ]:          0 :             mrPath2D.parameter.push_back( aAngles );
    1121                 :            :         }
    1122                 :          0 :         break;
    1123                 :            :         case A_TOKEN( quadBezTo ) :
    1124                 :            :         {
    1125 [ #  # ][ #  # ]:          0 :             if ( !mrSegments.empty() && ( mrSegments.back().Command == EnhancedCustomShapeSegmentCommand::QUADRATICCURVETO ) )
         [ #  # ][ #  # ]
    1126         [ #  # ]:          0 :                 mrSegments.back().Count++;
    1127                 :            :             else
    1128                 :            :             {
    1129                 :          0 :                 EnhancedCustomShapeSegment aSegment;
    1130                 :          0 :                 aSegment.Command = EnhancedCustomShapeSegmentCommand::QUADRATICCURVETO;
    1131                 :          0 :                 aSegment.Count = 1;
    1132         [ #  # ]:          0 :                 mrSegments.push_back( aSegment );
    1133                 :            :             }
    1134                 :          0 :             EnhancedCustomShapeParameterPair aPt1;
    1135                 :          0 :             EnhancedCustomShapeParameterPair aPt2;
    1136         [ #  # ]:          0 :             mrPath2D.parameter.push_back( aPt1 );
    1137         [ #  # ]:          0 :             mrPath2D.parameter.push_back( aPt2 );
    1138                 :            :             xContext = new Path2DQuadBezierToContext( *this, mrCustomShapeProperties,
    1139                 :          0 :                             mrPath2D.parameter[ mrPath2D.parameter.size() - 2 ],
    1140 [ #  # ][ #  # ]:          0 :                                 mrPath2D.parameter.back() );
         [ #  # ][ #  # ]
    1141                 :            :         }
    1142                 :          0 :         break;
    1143                 :            :         case A_TOKEN( cubicBezTo ) :
    1144                 :            :         {
    1145 [ #  # ][ #  # ]:          0 :             if ( !mrSegments.empty() && ( mrSegments.back().Command == EnhancedCustomShapeSegmentCommand::CURVETO ) )
         [ #  # ][ #  # ]
    1146         [ #  # ]:          0 :                 mrSegments.back().Count++;
    1147                 :            :             else
    1148                 :            :             {
    1149                 :          0 :                 EnhancedCustomShapeSegment aSegment;
    1150                 :          0 :                 aSegment.Command = EnhancedCustomShapeSegmentCommand::CURVETO;
    1151                 :          0 :                 aSegment.Count = 1;
    1152         [ #  # ]:          0 :                 mrSegments.push_back( aSegment );
    1153                 :            :             }
    1154                 :          0 :             EnhancedCustomShapeParameterPair aControlPt1;
    1155                 :          0 :             EnhancedCustomShapeParameterPair aControlPt2;
    1156                 :          0 :             EnhancedCustomShapeParameterPair aEndPt;
    1157         [ #  # ]:          0 :             mrPath2D.parameter.push_back( aControlPt1 );
    1158         [ #  # ]:          0 :             mrPath2D.parameter.push_back( aControlPt2 );
    1159         [ #  # ]:          0 :             mrPath2D.parameter.push_back( aEndPt );
    1160                 :            :             xContext = new Path2DCubicBezierToContext( *this, mrCustomShapeProperties,
    1161                 :          0 :                             mrPath2D.parameter[ mrPath2D.parameter.size() - 3 ],
    1162                 :          0 :                                 mrPath2D.parameter[ mrPath2D.parameter.size() - 2 ],
    1163 [ #  # ][ #  # ]:          0 :                                     mrPath2D.parameter.back() );
         [ #  # ][ #  # ]
    1164                 :            :         }
    1165                 :          0 :         break;
    1166                 :            :     }
    1167                 :          0 :     return xContext;
    1168                 :            : }
    1169                 :            : 
    1170                 :            : // ---------------------------------------------------------------------
    1171                 :            : // CT_Path2DList
    1172         [ #  # ]:          0 : class Path2DListContext : public ContextHandler
    1173                 :            : {
    1174                 :            : public:
    1175                 :            :     Path2DListContext( ContextHandler& rParent, CustomShapeProperties& rCustomShapeProperties, std::vector< EnhancedCustomShapeSegment >& rSegments,
    1176                 :            :         std::vector< Path2D >& rPath2DList );
    1177                 :            : 
    1178                 :            :     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);
    1179                 :            : 
    1180                 :            : protected:
    1181                 :            : 
    1182                 :            :     CustomShapeProperties& mrCustomShapeProperties;
    1183                 :            :     std::vector< com::sun::star::drawing::EnhancedCustomShapeSegment >& mrSegments;
    1184                 :            :     std::vector< Path2D >& mrPath2DList;
    1185                 :            : };
    1186                 :            : 
    1187                 :          0 : Path2DListContext::Path2DListContext( ContextHandler& rParent, CustomShapeProperties& rCustomShapeProperties, std::vector< EnhancedCustomShapeSegment >& rSegments,
    1188                 :            :                                         std::vector< Path2D >& rPath2DList )
    1189                 :            : : ContextHandler( rParent )
    1190                 :            : , mrCustomShapeProperties( rCustomShapeProperties )
    1191                 :            : , mrSegments( rSegments )
    1192                 :          0 : , mrPath2DList( rPath2DList )
    1193                 :            : {
    1194                 :          0 : }
    1195                 :            : 
    1196                 :          0 : ::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)
    1197                 :            : {
    1198                 :          0 :     Reference< XFastContextHandler > xContext;
    1199         [ #  # ]:          0 :     if ( aElementToken == A_TOKEN( path ) )
    1200                 :            :     {
    1201         [ #  # ]:          0 :         Path2D aPath2D;
    1202         [ #  # ]:          0 :         mrPath2DList.push_back( aPath2D );
    1203 [ #  # ][ #  # ]:          0 :         xContext = new Path2DContext( *this, xAttribs, mrCustomShapeProperties,  mrSegments, mrPath2DList.back() );
         [ #  # ][ #  # ]
    1204                 :            :     }
    1205                 :          0 :     return xContext;
    1206                 :            : }
    1207                 :            : 
    1208                 :            : // ---------------------------------------------------------------------
    1209                 :            : // CT_CustomGeometry2D
    1210                 :          0 : CustomShapeGeometryContext::CustomShapeGeometryContext( ContextHandler& rParent, const Reference< XFastAttributeList >& /* xAttribs */, CustomShapeProperties& rCustomShapeProperties )
    1211                 :            : : ContextHandler( rParent )
    1212                 :          0 : , mrCustomShapeProperties( rCustomShapeProperties )
    1213                 :            : {
    1214                 :          0 : }
    1215                 :            : 
    1216                 :          0 : Reference< XFastContextHandler > CustomShapeGeometryContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
    1217                 :            : {
    1218                 :          0 :     Reference< XFastContextHandler > xContext;
    1219   [ #  #  #  #  :          0 :     switch( aElementToken )
             #  #  #  # ]
    1220                 :            :     {
    1221                 :            :         case A_TOKEN( avLst ):          // CT_GeomGuideList adjust value list
    1222 [ #  # ][ #  # ]:          0 :             xContext = new GeomGuideListContext( *this, mrCustomShapeProperties, mrCustomShapeProperties.getAdjustmentGuideList() );
                 [ #  # ]
    1223                 :          0 :         break;
    1224                 :            :         case A_TOKEN( gdLst ):          // CT_GeomGuideList guide list
    1225 [ #  # ][ #  # ]:          0 :             xContext = new GeomGuideListContext( *this, mrCustomShapeProperties, mrCustomShapeProperties.getGuideList() );
                 [ #  # ]
    1226                 :          0 :         break;
    1227                 :            :         case A_TOKEN( ahLst ):          // CT_AdjustHandleList adjust handle list
    1228 [ #  # ][ #  # ]:          0 :             xContext = new AdjustHandleListContext( *this, mrCustomShapeProperties, mrCustomShapeProperties.getAdjustHandleList() );
                 [ #  # ]
    1229                 :          0 :         break;
    1230                 :            :         case A_TOKEN( cxnLst ):         // CT_ConnectionSiteList connection site list
    1231         [ #  # ]:          0 :             xContext = this;
    1232                 :          0 :         break;
    1233                 :            :         case A_TOKEN( rect ):           // CT_GeomRectList geometry rect list
    1234                 :            :         {
    1235                 :          0 :             GeomRect aGeomRect;
    1236 [ #  # ][ #  # ]:          0 :             aGeomRect.l = GetAdjCoordinate( mrCustomShapeProperties, xAttribs->getOptionalValue( XML_l ), sal_True );
                 [ #  # ]
    1237 [ #  # ][ #  # ]:          0 :             aGeomRect.t = GetAdjCoordinate( mrCustomShapeProperties, xAttribs->getOptionalValue( XML_t ), sal_True );
                 [ #  # ]
    1238 [ #  # ][ #  # ]:          0 :             aGeomRect.r = GetAdjCoordinate( mrCustomShapeProperties, xAttribs->getOptionalValue( XML_r ), sal_True );
                 [ #  # ]
    1239 [ #  # ][ #  # ]:          0 :             aGeomRect.b = GetAdjCoordinate( mrCustomShapeProperties, xAttribs->getOptionalValue( XML_b ), sal_True );
                 [ #  # ]
    1240         [ #  # ]:          0 :             mrCustomShapeProperties.getTextRect() = aGeomRect;
    1241                 :            :         }
    1242                 :          0 :         break;
    1243                 :            :         case A_TOKEN( pathLst ):        // CT_Path2DList 2d path list
    1244 [ #  # ][ #  # ]:          0 :             xContext = new Path2DListContext( *this, mrCustomShapeProperties, mrCustomShapeProperties.getSegments(), mrCustomShapeProperties.getPath2DList() );
                 [ #  # ]
    1245                 :          0 :         break;
    1246                 :            : 
    1247                 :            :         // from cxnLst:
    1248                 :            :         case A_TOKEN( cxn ):                // CT_ConnectionSite
    1249                 :            :         {
    1250                 :          0 :             ConnectionSite aConnectionSite;
    1251         [ #  # ]:          0 :             mrCustomShapeProperties.getConnectionSiteList().push_back( aConnectionSite );
    1252 [ #  # ][ #  # ]:          0 :             xContext = new ConnectionSiteContext( *this, xAttribs, mrCustomShapeProperties, mrCustomShapeProperties.getConnectionSiteList().back() );
         [ #  # ][ #  # ]
    1253                 :            :         }
    1254                 :          0 :         break;
    1255                 :            :     }
    1256                 :          0 :     return xContext;
    1257                 :            : }
    1258                 :            : 
    1259                 :            : // ---------------------------------------------------------------------
    1260                 :            : // CT_PresetGeometry2D
    1261                 :        114 : PresetShapeGeometryContext::PresetShapeGeometryContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, CustomShapeProperties& rCustomShapeProperties )
    1262                 :            : : ContextHandler( rParent )
    1263                 :        114 : , mrCustomShapeProperties( rCustomShapeProperties )
    1264                 :            : {
    1265 [ +  - ][ +  - ]:        114 :     sal_Int32 nShapeType = xAttribs->getOptionalValueToken( XML_prst, FastToken::DONTKNOW );
    1266                 :            :     OSL_ENSURE( nShapeType != FastToken::DONTKNOW, "oox::drawingml::CustomShapeCustomGeometryContext::CustomShapeCustomGeometryContext(), unknown shape type" );
    1267                 :        114 :     mrCustomShapeProperties.setShapePresetType( nShapeType );
    1268                 :        114 : }
    1269                 :            : 
    1270                 :        114 : Reference< XFastContextHandler > PresetShapeGeometryContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& ) throw (SAXException, RuntimeException)
    1271                 :            : {
    1272         [ +  - ]:        114 :     if ( aElementToken == A_TOKEN( avLst ) )
    1273 [ +  - ][ +  - ]:        114 :         return new GeomGuideListContext( *this, mrCustomShapeProperties, mrCustomShapeProperties.getAdjustmentGuideList() );
    1274                 :            :     else
    1275                 :        114 :         return this;
    1276                 :            : }
    1277                 :            : 
    1278                 :            : // ---------------------------------------------------------------------
    1279                 :            : // CT_PresetTextShape
    1280                 :          0 : PresetTextShapeContext::PresetTextShapeContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, CustomShapeProperties& rCustomShapeProperties )
    1281                 :            : : ContextHandler( rParent )
    1282                 :          0 : , mrCustomShapeProperties( rCustomShapeProperties )
    1283                 :            : {
    1284 [ #  # ][ #  # ]:          0 :     sal_Int32 nShapeType = xAttribs->getOptionalValueToken( XML_prst, FastToken::DONTKNOW );
    1285                 :            :     OSL_ENSURE( nShapeType != FastToken::DONTKNOW, "oox::drawingml::CustomShapeCustomGeometryContext::CustomShapeCustomGeometryContext(), unknown shape type" );
    1286                 :          0 :     mrCustomShapeProperties.setShapePresetType( nShapeType );
    1287                 :          0 : }
    1288                 :            : 
    1289                 :          0 : Reference< XFastContextHandler > PresetTextShapeContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& ) throw (SAXException, RuntimeException)
    1290                 :            : {
    1291         [ #  # ]:          0 :     if ( aElementToken == A_TOKEN( avLst ) )
    1292 [ #  # ][ #  # ]:          0 :         return new GeomGuideListContext( *this, mrCustomShapeProperties, mrCustomShapeProperties.getAdjustmentGuideList() );
    1293                 :            :     else
    1294                 :          0 :         return this;
    1295                 :            : }
    1296                 :            : 
    1297 [ +  - ][ +  - ]:        285 : } }
    1298                 :            : 
    1299                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10