LCOV - code coverage report
Current view: top level - libreoffice/svx/source/customshapes - EnhancedCustomShape2d.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 373 1215 30.7 %
Date: 2012-12-27 Functions: 14 33 42.4 %
Legend: Lines: hit not hit

          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 "svx/EnhancedCustomShape2d.hxx"
      21             : #include "svx/EnhancedCustomShapeGeometry.hxx"
      22             : #include "svx/EnhancedCustomShapeTypeNames.hxx"
      23             : #include <svx/svdoashp.hxx>
      24             : #include <svx/svdtrans.hxx>
      25             : #include <svx/svdocirc.hxx>
      26             : #include <svx/svdogrp.hxx>
      27             : #include <svx/svdopath.hxx>
      28             : #include <svx/svdocapt.hxx>
      29             : #include <svx/svdpage.hxx>
      30             : #include <svx/xflclit.hxx>
      31             : #include <svx/sdasaitm.hxx>
      32             : #include <svx/svdmodel.hxx>
      33             : #include <rtl/crc.h>
      34             : #include <rtl/math.hxx>
      35             : #include <svx/xfillit0.hxx>
      36             : #include <svx/xlnstit.hxx>
      37             : #include <svx/xlnedit.hxx>
      38             : #include <svx/xlnstwit.hxx>
      39             : #include <svx/xlnedwit.hxx>
      40             : #include <svx/xlnstcit.hxx>
      41             : #include <svx/xlnedcit.hxx>
      42             : #include <svx/xflgrit.hxx>
      43             : #include <svx/xflhtit.hxx>
      44             : #include <svx/xbtmpit.hxx>
      45             : #include <svx/xgrad.hxx>
      46             : #include <svx/xbitmap.hxx>
      47             : #include <svx/xhatch.hxx>
      48             : #include <com/sun/star/awt/Size.hpp>
      49             : #include <com/sun/star/drawing/EnhancedCustomShapeParameterType.hpp>
      50             : #include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp>
      51             : #include <boost/shared_ptr.hpp>
      52             : #include <basegfx/numeric/ftools.hxx>
      53             : #include <basegfx/color/bcolortools.hxx>
      54             : #include <basegfx/polygon/b2dpolygon.hxx>
      55             : 
      56             : // #i76201#
      57             : #include <basegfx/polygon/b2dpolygontools.hxx>
      58             : #include <rtl/strbuf.hxx>
      59             : #include <math.h>
      60             : 
      61             : using namespace ::com::sun::star::uno;
      62             : using namespace ::com::sun::star::drawing;
      63             : using namespace ::com::sun::star::drawing::EnhancedCustomShapeSegmentCommand;
      64             : 
      65        9080 : void EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( EnhancedCustomShapeParameter& rParameter, const sal_Int32 nValue )
      66             : {
      67        9080 :     sal_uInt32 nDat = (sal_uInt32)nValue;
      68        9080 :     sal_Int32  nNewValue = nValue;
      69             : 
      70             :     // check if this is a special point
      71        9080 :     if ( ( nDat >> 16 ) == 0x8000 )
      72             :     {
      73         639 :         nNewValue = (sal_uInt16)nDat;
      74         639 :         rParameter.Type = EnhancedCustomShapeParameterType::EQUATION;
      75             :     }
      76             :     else
      77        8441 :         rParameter.Type = EnhancedCustomShapeParameterType::NORMAL;
      78        9080 :     rParameter.Value <<= nNewValue;
      79        9080 : }
      80             : 
      81         603 : rtl::OUString EnhancedCustomShape2d::GetEquation( const sal_uInt16 nFlags, sal_Int16 nP1, sal_Int16 nP2, sal_Int16 nP3 )
      82             : {
      83         603 :     rtl::OUString aEquation;
      84         603 :     sal_Bool b1Special = ( nFlags & 0x2000 ) != 0;
      85         603 :     sal_Bool b2Special = ( nFlags & 0x4000 ) != 0;
      86         603 :     sal_Bool b3Special = ( nFlags & 0x8000 ) != 0;
      87         603 :     switch( nFlags & 0xff )
      88             :     {
      89             :         case 0 :
      90             :         case 14 :
      91             :         {
      92         315 :             sal_Int32 nOptimize = 0;
      93         315 :             if ( nP1 )
      94         311 :                 nOptimize |= 1;
      95         315 :             if ( nP2 )
      96         113 :                 nOptimize |= 2;
      97         315 :             if ( b1Special )
      98         260 :                 nOptimize |= 4;
      99         315 :             if ( b2Special )
     100          62 :                 nOptimize |= 8;
     101         315 :             switch( nOptimize )
     102             :             {
     103             :                 case 0 :
     104           0 :                 break;
     105             :                 case 1 :
     106             :                 case 4 :
     107             :                 case 5 :
     108         202 :                     EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
     109         202 :                 break;
     110             :                 case 2 :
     111             :                 case 8 :
     112             :                 case 10:
     113           4 :                     EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
     114           4 :                 break;
     115             :                 default :
     116             :                 {
     117         109 :                     EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
     118         109 :                     aEquation += rtl::OUString( (sal_Unicode)'+' );
     119         109 :                     EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
     120             :                 }
     121         109 :                 break;
     122             :             }
     123         315 :             if ( b3Special || nP3 )
     124             :             {
     125         164 :                 aEquation += rtl::OUString( (sal_Unicode)'-' );
     126         164 :                 EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
     127             :             }
     128             :         }
     129         315 :         break;
     130             :         case 1 :
     131             :         {
     132          87 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
     133          87 :             if ( b2Special || ( nP2 != 1 ) )
     134             :             {
     135          52 :                 aEquation += rtl::OUString( (sal_Unicode)'*' );
     136          52 :                 EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
     137             :             }
     138          87 :             if ( b3Special || ( ( nP3 != 1 ) && ( nP3 != 0 ) ) )
     139             :             {
     140          70 :                 aEquation += rtl::OUString( (sal_Unicode)'/' );
     141          70 :                 EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
     142             :             }
     143             :         }
     144          87 :         break;
     145             :         case 2 :
     146             :         {
     147           6 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "(" ) );
     148           6 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
     149           6 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "+" ) );
     150           6 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
     151           6 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")/2" ) );
     152             :         }
     153           6 :         break;
     154             :         case 3 :
     155             :         {
     156           6 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "abs(" ) );
     157           6 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
     158           6 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")" ) );
     159             :         }
     160           6 :         break;
     161             :         case 4 :
     162             :         {
     163           0 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "min(" ) );
     164           0 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
     165           0 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "," ) );
     166           0 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
     167           0 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")" ) );
     168             :         }
     169           0 :         break;
     170             :         case 5 :
     171             :         {
     172           0 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "max(" ) );
     173           0 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
     174           0 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "," ) );
     175           0 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
     176           0 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")" ) );
     177             :         }
     178           0 :         break;
     179             :         case 6 :
     180             :         {
     181         102 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "if(" ) );
     182         102 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
     183         102 :             aEquation += rtl::OUString( (sal_Unicode)',' );
     184         102 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
     185         102 :             aEquation += rtl::OUString( (sal_Unicode)',' );
     186         102 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
     187         102 :             aEquation += rtl::OUString( (sal_Unicode)')' );
     188             :         }
     189         102 :         break;
     190             :         case 7 :
     191             :         {
     192           0 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "sqrt(" ) );
     193           0 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
     194           0 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*" ) );
     195           0 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
     196           0 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "+" ) );
     197           0 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
     198           0 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*" ) );
     199           0 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
     200           0 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "+" ) );
     201           0 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
     202           0 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*" ) );
     203           0 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
     204           0 :             aEquation += rtl::OUString( (sal_Unicode)')' );
     205             :         }
     206           0 :         break;
     207             :         case 8 :
     208             :         {
     209           3 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "atan2(" ) );
     210           3 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
     211           3 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "," ) );
     212           3 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
     213           3 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")/(pi/180)" ) );
     214             :         }
     215           3 :         break;
     216             :         case 9 :
     217             :         {
     218          13 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
     219          13 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*sin(" ) );
     220          13 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
     221          13 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*(pi/180))" ) );
     222             :         }
     223          13 :         break;
     224             :         case 10 :
     225             :         {
     226           9 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
     227           9 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*cos(" ) );
     228           9 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
     229           9 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*(pi/180))" ) );
     230             :         }
     231           9 :         break;
     232             :         case 11 :
     233             :         {
     234           0 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
     235           0 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*" ) );
     236           0 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "cos(atan2(" ) );
     237           0 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
     238           0 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "," ) );
     239           0 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
     240           0 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "))" ) );
     241             :         }
     242           0 :         break;
     243             :         case 12 :
     244             :         {
     245           0 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
     246           0 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*" ) );
     247           0 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "sin(atan2(" ) );
     248           0 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
     249           0 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "," ) );
     250           0 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
     251           0 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "))" ) );
     252             :         }
     253           0 :         break;
     254             :         case 13 :
     255             :         {
     256           6 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "sqrt(" ) );
     257           6 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
     258           6 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")" ) );
     259             :         }
     260           6 :         break;
     261             :         case 15 :
     262             :         {
     263          12 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
     264          12 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*sqrt(1-(" ) );
     265          12 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
     266          12 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "/" ) );
     267          12 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
     268          12 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")" ) );
     269          12 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*(" ) );
     270          12 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
     271          12 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "/" ) );
     272          12 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
     273          12 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "))" ) );
     274             :         }
     275          12 :         break;
     276             :         case 16 :
     277             :         {
     278           0 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
     279           0 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*tan(" ) );
     280           0 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
     281           0 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")" ) );
     282             :         }
     283           0 :         break;
     284             :         case 0x80 :
     285             :         {
     286           0 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "sqrt(" ) );
     287           0 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
     288           0 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*" ) );
     289           0 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
     290           0 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "-" ) );
     291           0 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
     292           0 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*" ) );
     293           0 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
     294           0 :             aEquation += rtl::OUString( (sal_Unicode)')' );
     295             :         }
     296           0 :         break;
     297             :         case 0x81 :
     298             :         {
     299          23 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "(cos(" ) );
     300          23 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
     301          23 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*(pi/180))*(" ) );
     302          23 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
     303          23 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "-10800)+sin(" ) );
     304          23 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
     305          23 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*(pi/180))*(" ) );
     306          23 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
     307          23 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "-10800))+10800" ) );
     308             :         }
     309          23 :         break;
     310             :         case 0x82 :
     311             :         {
     312          21 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "-(sin(" ) );
     313          21 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
     314          21 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*(pi/180))*(" ) );
     315          21 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
     316          21 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "-10800)-cos(" ) );
     317          21 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
     318          21 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*(pi/180))*(" ) );
     319          21 :             EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
     320          21 :             aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "-10800))+10800" ) );
     321             :         }
     322          21 :         break;
     323             :     }
     324         603 :     return aEquation;
     325             : }
     326             : 
     327        1413 : void EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( rtl::OUString& rParameter, const sal_Int16 nPara, const sal_Bool bIsSpecialValue )
     328             : {
     329        1413 :     if ( bIsSpecialValue )
     330             :     {
     331         910 :         if ( nPara & 0x400 )
     332             :         {
     333         614 :             rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "?" ) );
     334         614 :             rParameter += rtl::OUString::valueOf( (sal_Int32)( nPara & 0xff ) );
     335         614 :             rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( " " ) );
     336             :         }
     337             :         else
     338             :         {
     339         296 :             switch( nPara )
     340             :             {
     341             :                 case DFF_Prop_adjustValue :
     342             :                 case DFF_Prop_adjust2Value :
     343             :                 case DFF_Prop_adjust3Value :
     344             :                 case DFF_Prop_adjust4Value :
     345             :                 case DFF_Prop_adjust5Value :
     346             :                 case DFF_Prop_adjust6Value :
     347             :                 case DFF_Prop_adjust7Value :
     348             :                 case DFF_Prop_adjust8Value :
     349             :                 case DFF_Prop_adjust9Value :
     350             :                 case DFF_Prop_adjust10Value :
     351             :                 {
     352         240 :                     rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "$" ) );
     353         240 :                     rParameter += rtl::OUString::valueOf( (sal_Int32)( nPara - DFF_Prop_adjustValue ) );
     354         240 :                     rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( " " ) );
     355             :                 }
     356         240 :                 break;
     357             :                 case DFF_Prop_geoLeft :
     358             :                 {
     359          10 :                     rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "left" ) );
     360             :                 }
     361          10 :                 break;
     362             :                 case DFF_Prop_geoTop :
     363             :                 {
     364          10 :                     rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "top" ) );
     365             :                 }
     366          10 :                 break;
     367             :                 case DFF_Prop_geoRight :
     368             :                 {
     369          17 :                     rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "right" ) );
     370             :                 }
     371          17 :                 break;
     372             :                 case DFF_Prop_geoBottom :
     373             :                 {
     374          19 :                     rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "bottom" ) );
     375             :                 }
     376          19 :                 break;
     377             :             }
     378             :         }
     379             :     }
     380             :     else
     381             :     {
     382         503 :         rParameter += rtl::OUString::valueOf( (sal_Int32)( nPara ) );
     383             :     }
     384        1413 : }
     385             : 
     386         192 : void EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( EnhancedCustomShapeParameter& rParameter, const sal_Int32 nPara, const sal_Bool bIsSpecialValue, sal_Bool bHorz )
     387             : {
     388         192 :     sal_Int32 nValue = 0;
     389         192 :     if ( bIsSpecialValue )
     390             :     {
     391         110 :         if ( ( nPara >= 0x100 ) && ( nPara <= 0x107 ) )
     392             :         {
     393          63 :             nValue = nPara & 0xff;
     394          63 :             rParameter.Type = EnhancedCustomShapeParameterType::ADJUSTMENT;
     395             :         }
     396          47 :         else if ( ( nPara >= 3 ) && ( nPara <= 0x82 ) )
     397             :         {
     398          18 :             nValue = nPara - 3;
     399          18 :             rParameter.Type = EnhancedCustomShapeParameterType::EQUATION;
     400             :         }
     401          29 :         else if ( nPara == 0 )
     402             :         {
     403           8 :             nValue = 0;
     404           8 :             if ( bHorz )
     405           1 :                 rParameter.Type = EnhancedCustomShapeParameterType::LEFT;
     406             :             else
     407           7 :                 rParameter.Type = EnhancedCustomShapeParameterType::TOP;
     408             :         }
     409          21 :         else if ( nPara == 1 )
     410             :         {
     411           3 :             nValue = 0;
     412           3 :             if ( bHorz )
     413           3 :                 rParameter.Type = EnhancedCustomShapeParameterType::RIGHT;
     414             :             else
     415           0 :                 rParameter.Type = EnhancedCustomShapeParameterType::BOTTOM;
     416             :         }
     417          18 :         else if ( nPara == 2 )  // means to be centered, but should not be
     418             :         {                       // used in our implementation
     419           0 :             nValue = 5600;
     420           0 :             rParameter.Type = EnhancedCustomShapeParameterType::NORMAL;
     421             :         }
     422             :         else
     423             :         {
     424          18 :             nValue = nPara;
     425          18 :             rParameter.Type = EnhancedCustomShapeParameterType::NORMAL;
     426             :         }
     427             :     }
     428             :     else
     429             :     {
     430          82 :         nValue = nPara;
     431          82 :         rParameter.Type = EnhancedCustomShapeParameterType::NORMAL;
     432             :     }
     433         192 :     rParameter.Value <<= nValue;
     434         192 : }
     435             : 
     436           0 : sal_Bool EnhancedCustomShape2d::ConvertSequenceToEnhancedCustomShape2dHandle(
     437             :     const com::sun::star::beans::PropertyValues& rHandleProperties,
     438             :         EnhancedCustomShape2d::Handle& rDestinationHandle )
     439             : {
     440           0 :     sal_Bool bRetValue = sal_False;
     441           0 :     sal_uInt32 i, nProperties = rHandleProperties.getLength();
     442           0 :     if ( nProperties )
     443             :     {
     444           0 :         rDestinationHandle.nFlags = 0;
     445           0 :         for ( i = 0; i < nProperties; i++ )
     446             :         {
     447           0 :             const com::sun::star::beans::PropertyValue& rPropVal = rHandleProperties[ i ];
     448             : 
     449           0 :             const rtl::OUString sPosition           ( RTL_CONSTASCII_USTRINGPARAM( "Position" ) );
     450           0 :             const rtl::OUString sMirroredX          ( RTL_CONSTASCII_USTRINGPARAM( "MirroredX" ) );
     451           0 :             const rtl::OUString sMirroredY          ( RTL_CONSTASCII_USTRINGPARAM( "MirroredY" ) );
     452           0 :             const rtl::OUString sSwitched           ( RTL_CONSTASCII_USTRINGPARAM( "Switched" ) );
     453           0 :             const rtl::OUString sPolar              ( RTL_CONSTASCII_USTRINGPARAM( "Polar" ) );
     454           0 :             const rtl::OUString sRefX               ( RTL_CONSTASCII_USTRINGPARAM( "RefX" ) );
     455           0 :             const rtl::OUString sRefY               ( RTL_CONSTASCII_USTRINGPARAM( "RefY" ) );
     456           0 :             const rtl::OUString sRefAngle           ( RTL_CONSTASCII_USTRINGPARAM( "RefAngle" ) );
     457           0 :             const rtl::OUString sRefR               ( RTL_CONSTASCII_USTRINGPARAM( "RefR" ) );
     458           0 :             const rtl::OUString sRadiusRangeMinimum ( RTL_CONSTASCII_USTRINGPARAM( "RadiusRangeMinimum" ) );
     459           0 :             const rtl::OUString sRadiusRangeMaximum ( RTL_CONSTASCII_USTRINGPARAM( "RadiusRangeMaximum" ) );
     460           0 :             const rtl::OUString sRangeXMinimum      ( RTL_CONSTASCII_USTRINGPARAM( "RangeXMinimum" ) );
     461           0 :             const rtl::OUString sRangeXMaximum      ( RTL_CONSTASCII_USTRINGPARAM( "RangeXMaximum" ) );
     462           0 :             const rtl::OUString sRangeYMinimum      ( RTL_CONSTASCII_USTRINGPARAM( "RangeYMinimum" ) );
     463           0 :             const rtl::OUString sRangeYMaximum      ( RTL_CONSTASCII_USTRINGPARAM( "RangeYMaximum" ) );
     464             : 
     465           0 :             if ( rPropVal.Name.equals( sPosition ) )
     466             :             {
     467           0 :                 if ( rPropVal.Value >>= rDestinationHandle.aPosition )
     468           0 :                     bRetValue = sal_True;
     469             :             }
     470           0 :             else if ( rPropVal.Name.equals( sMirroredX ) )
     471             :             {
     472           0 :                 sal_Bool bMirroredX = sal_Bool();
     473           0 :                 if ( rPropVal.Value >>= bMirroredX )
     474             :                 {
     475           0 :                     if ( bMirroredX )
     476           0 :                         rDestinationHandle.nFlags |= HANDLE_FLAGS_MIRRORED_X;
     477             :                 }
     478             :             }
     479           0 :             else if ( rPropVal.Name.equals( sMirroredY ) )
     480             :             {
     481           0 :                 sal_Bool bMirroredY = sal_Bool();
     482           0 :                 if ( rPropVal.Value >>= bMirroredY )
     483             :                 {
     484           0 :                     if ( bMirroredY )
     485           0 :                         rDestinationHandle.nFlags |= HANDLE_FLAGS_MIRRORED_Y;
     486             :                 }
     487             :             }
     488           0 :             else if ( rPropVal.Name.equals( sSwitched ) )
     489             :             {
     490           0 :                 sal_Bool bSwitched = sal_Bool();
     491           0 :                 if ( rPropVal.Value >>= bSwitched )
     492             :                 {
     493           0 :                     if ( bSwitched )
     494           0 :                         rDestinationHandle.nFlags |= HANDLE_FLAGS_SWITCHED;
     495             :                 }
     496             :             }
     497           0 :             else if ( rPropVal.Name.equals( sPolar ) )
     498             :             {
     499           0 :                 if ( rPropVal.Value >>= rDestinationHandle.aPolar )
     500           0 :                     rDestinationHandle.nFlags |= HANDLE_FLAGS_POLAR;
     501             :             }
     502           0 :             else if ( rPropVal.Name.equals( sRefX ) )
     503             :             {
     504           0 :                 if ( rPropVal.Value >>= rDestinationHandle.nRefX )
     505           0 :                     rDestinationHandle.nFlags |= HANDLE_FLAGS_REFX;
     506             :             }
     507           0 :             else if ( rPropVal.Name.equals( sRefY ) )
     508             :             {
     509           0 :                 if ( rPropVal.Value >>= rDestinationHandle.nRefY )
     510           0 :                     rDestinationHandle.nFlags |= HANDLE_FLAGS_REFY;
     511             :             }
     512           0 :             else if ( rPropVal.Name.equals( sRefAngle ) )
     513             :             {
     514           0 :                 if ( rPropVal.Value >>= rDestinationHandle.nRefAngle )
     515           0 :                     rDestinationHandle.nFlags |= HANDLE_FLAGS_REFANGLE;
     516             :             }
     517           0 :             else if ( rPropVal.Name.equals( sRefR ) )
     518             :             {
     519           0 :                 if ( rPropVal.Value >>= rDestinationHandle.nRefR )
     520           0 :                     rDestinationHandle.nFlags |= HANDLE_FLAGS_REFR;
     521             :             }
     522           0 :             else if ( rPropVal.Name.equals( sRadiusRangeMinimum ) )
     523             :             {
     524           0 :                 if ( rPropVal.Value >>= rDestinationHandle.aRadiusRangeMinimum )
     525           0 :                     rDestinationHandle.nFlags |= HANDLE_FLAGS_RADIUS_RANGE_MINIMUM;
     526             :             }
     527           0 :             else if ( rPropVal.Name.equals( sRadiusRangeMaximum ) )
     528             :             {
     529           0 :                 if ( rPropVal.Value >>= rDestinationHandle.aRadiusRangeMaximum )
     530           0 :                     rDestinationHandle.nFlags |= HANDLE_FLAGS_RADIUS_RANGE_MAXIMUM;
     531             :             }
     532           0 :             else if ( rPropVal.Name.equals( sRangeXMinimum ) )
     533             :             {
     534           0 :                 if ( rPropVal.Value >>= rDestinationHandle.aXRangeMinimum )
     535           0 :                     rDestinationHandle.nFlags |= HANDLE_FLAGS_RANGE_X_MINIMUM;
     536             :             }
     537           0 :             else if ( rPropVal.Name.equals( sRangeXMaximum ) )
     538             :             {
     539           0 :                 if ( rPropVal.Value >>= rDestinationHandle.aXRangeMaximum )
     540           0 :                     rDestinationHandle.nFlags |= HANDLE_FLAGS_RANGE_X_MAXIMUM;
     541             :             }
     542           0 :             else if ( rPropVal.Name.equals( sRangeYMinimum ) )
     543             :             {
     544           0 :                 if ( rPropVal.Value >>= rDestinationHandle.aYRangeMinimum )
     545           0 :                     rDestinationHandle.nFlags |= HANDLE_FLAGS_RANGE_Y_MINIMUM;
     546             :             }
     547           0 :             else if ( rPropVal.Name.equals( sRangeYMaximum ) )
     548             :             {
     549           0 :                 if ( rPropVal.Value >>= rDestinationHandle.aYRangeMaximum )
     550           0 :                     rDestinationHandle.nFlags |= HANDLE_FLAGS_RANGE_Y_MAXIMUM;
     551             :             }
     552           0 :         }
     553             :     }
     554           0 :     return bRetValue;
     555             : }
     556             : 
     557         778 : const sal_Int32* EnhancedCustomShape2d::ApplyShapeAttributes( const SdrCustomShapeGeometryItem& rGeometryItem )
     558             : {
     559         778 :     const sal_Int32* pDefData = NULL;
     560         778 :     const mso_CustomShape* pDefCustomShape = GetCustomShapeContent( eSpType );
     561         778 :     if ( pDefCustomShape )
     562         777 :         pDefData = pDefCustomShape->pDefData;
     563             : 
     564             :     //////////////////////
     565             :     // AdjustmentValues //
     566             :     //////////////////////
     567         778 :     const rtl::OUString sAdjustmentValues( RTL_CONSTASCII_USTRINGPARAM ( "AdjustmentValues" ) );
     568         778 :     const Any* pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sAdjustmentValues );
     569         778 :     if ( pAny )
     570         778 :         *pAny >>= seqAdjustmentValues;
     571             : 
     572             :     ///////////////
     573             :     // Coordsize //
     574             :     ///////////////
     575         778 :     const rtl::OUString sViewBox( RTL_CONSTASCII_USTRINGPARAM ( "ViewBox" ) );
     576         778 :     const Any* pViewBox = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sViewBox );
     577         778 :     com::sun::star::awt::Rectangle aViewBox;
     578         778 :     if ( pViewBox && (*pViewBox >>= aViewBox ) )
     579             :     {
     580         778 :         nCoordLeft    = aViewBox.X;
     581         778 :         nCoordTop     = aViewBox.Y;
     582         778 :         nCoordWidthG  = labs( aViewBox.Width );
     583         778 :         nCoordHeightG = labs( aViewBox.Height);
     584             :     }
     585         778 :     const rtl::OUString sPath( RTL_CONSTASCII_USTRINGPARAM ( "Path" ) );
     586             : 
     587             :     //////////////////////
     588             :     // Path/Coordinates //
     589             :     //////////////////////
     590         778 :     const rtl::OUString sCoordinates( RTL_CONSTASCII_USTRINGPARAM ( "Coordinates" ) );
     591         778 :     pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sPath, sCoordinates );
     592         778 :     if ( pAny )
     593         778 :         *pAny >>= seqCoordinates;
     594             : 
     595             :     /////////////////////
     596             :     // Path/GluePoints //
     597             :     /////////////////////
     598         778 :     const rtl::OUString sGluePoints( RTL_CONSTASCII_USTRINGPARAM ( "GluePoints" ) );
     599         778 :     pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sPath, sGluePoints );
     600         778 :     if ( pAny )
     601          29 :         *pAny >>= seqGluePoints;
     602             : 
     603             :     ///////////////////
     604             :     // Path/Segments //
     605             :     ///////////////////
     606         778 :     const rtl::OUString sSegments( RTL_CONSTASCII_USTRINGPARAM ( "Segments" ) );
     607         778 :     pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sPath, sSegments );
     608         778 :     if ( pAny )
     609          51 :         *pAny >>= seqSegments;
     610             : 
     611             :     //////////////////////
     612             :     // Path/SubViewSize //
     613             :     //////////////////////
     614         778 :     const rtl::OUString sSubViewSize( RTL_CONSTASCII_USTRINGPARAM ( "SubViewSize" ) );
     615         778 :     pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sPath, sSubViewSize );
     616         778 :     if ( pAny )
     617           0 :         *pAny >>= seqSubViewSize;
     618             : 
     619             :     ///////////////////
     620             :     // Path/StretchX //
     621             :     ///////////////////
     622         778 :     const rtl::OUString sStretchX( RTL_CONSTASCII_USTRINGPARAM ( "StretchX" ) );
     623         778 :     pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sPath, sStretchX );
     624         778 :     if ( pAny )
     625             :     {
     626           7 :         sal_Int32 nStretchX = 0;
     627           7 :         if ( *pAny >>= nStretchX )
     628           7 :             nXRef = nStretchX;
     629             :     }
     630             : 
     631             :     ///////////////////
     632             :     // Path/StretchY //
     633             :     ///////////////////
     634         778 :     const rtl::OUString sStretchY( RTL_CONSTASCII_USTRINGPARAM ( "StretchY" ) );
     635         778 :     pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sPath, sStretchY );
     636         778 :     if ( pAny )
     637             :     {
     638           7 :         sal_Int32 nStretchY = 0;
     639           7 :         if ( *pAny >>= nStretchY )
     640           7 :             nYRef = nStretchY;
     641             :     }
     642             : 
     643             :     /////////////////////
     644             :     // Path/TextFrames //
     645             :     /////////////////////
     646         778 :     const rtl::OUString sTextFrames( RTL_CONSTASCII_USTRINGPARAM ( "TextFrames" ) );
     647         778 :     pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sPath, sTextFrames );
     648         778 :     if ( pAny )
     649          47 :         *pAny >>= seqTextFrames;
     650             : 
     651             :     ///////////////
     652             :     // Equations //
     653             :     ///////////////
     654         778 :     const rtl::OUString sEquations( RTL_CONSTASCII_USTRINGPARAM( "Equations" ) );
     655         778 :     pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sEquations );
     656         778 :     if ( pAny )
     657          36 :         *pAny >>= seqEquations;
     658             : 
     659             :     /////////////
     660             :     // Handles //
     661             :     /////////////
     662         778 :     const rtl::OUString sHandles( RTL_CONSTASCII_USTRINGPARAM( "Handles" ) );
     663         778 :     pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sHandles );
     664         778 :     if ( pAny )
     665          35 :         *pAny >>= seqHandles;
     666             : 
     667         778 :     return pDefData;
     668             : }
     669             : 
     670         778 : EnhancedCustomShape2d::~EnhancedCustomShape2d()
     671             : {
     672         778 : }
     673             : 
     674         778 : void EnhancedCustomShape2d::SetPathSize( sal_Int32 nIndex )
     675             : {
     676         778 :     sal_Int32 nWidth = 0;
     677         778 :     sal_Int32 nHeight = 0;
     678             : 
     679         778 :     if ( seqSubViewSize.getLength() && nIndex < seqSubViewSize.getLength() ) {
     680           0 :         nWidth = seqSubViewSize[ nIndex ].Width;
     681           0 :         nHeight = seqSubViewSize[ nIndex ].Height;
     682             :         OSL_TRACE("set subpath %d size: %d x %d", nIndex, nWidth, nHeight);
     683             :     }
     684             : 
     685         778 :     if ( nWidth && nHeight ) {
     686           0 :         nCoordWidth = nWidth;
     687           0 :         nCoordHeight = nHeight;
     688             :     } else {
     689         778 :         nCoordWidth = nCoordWidthG;
     690         778 :         nCoordHeight = nCoordHeightG;
     691             :     }
     692             : 
     693         778 :     fXScale = nCoordWidth == 0 ? 0.0 : (double)aLogicRect.GetWidth() / (double)nCoordWidth;
     694         778 :     fYScale = nCoordHeight == 0 ? 0.0 : (double)aLogicRect.GetHeight() / (double)nCoordHeight;
     695         778 :     if ( bOOXMLShape )
     696             :     {
     697             :         OSL_TRACE("ooxml shape, path width: %d height: %d", nCoordWidth, nCoordHeight);
     698           0 :         if ( nCoordWidth == 0 )
     699           0 :             fXScale = 1.0;
     700           0 :         if ( nCoordHeight == 0 )
     701           0 :             fYScale = 1.0;
     702             :     }
     703         778 :     if ( (sal_uInt32)nXRef != 0x80000000 && aLogicRect.GetHeight() )
     704             :     {
     705           7 :         fXRatio = (double)aLogicRect.GetWidth() / (double)aLogicRect.GetHeight();
     706           7 :         if ( fXRatio > 1 )
     707           7 :             fXScale /= fXRatio;
     708             :         else
     709           0 :             fXRatio = 1.0;
     710             :     }
     711             :     else
     712         771 :         fXRatio = 1.0;
     713         778 :     if ( (sal_uInt32)nYRef != 0x80000000 && aLogicRect.GetWidth() )
     714             :     {
     715           7 :         fYRatio = (double)aLogicRect.GetHeight() / (double)aLogicRect.GetWidth();
     716           7 :         if ( fYRatio > 1 )
     717           0 :             fYScale /= fYRatio;
     718             :         else
     719           7 :             fYRatio = 1.0;
     720             :     }
     721             :     else
     722         771 :         fYRatio = 1.0;
     723         778 : }
     724             : 
     725         778 : EnhancedCustomShape2d::EnhancedCustomShape2d( SdrObject* pAObj ) :
     726         778 :     SfxItemSet          ( pAObj->GetMergedItemSet() ),
     727             :     pCustomShapeObj     ( pAObj ),
     728             :     eSpType             ( mso_sptNil ),
     729             :     nCoordLeft          ( 0 ),
     730             :     nCoordTop           ( 0 ),
     731             :     nCoordWidthG        ( 21600 ),
     732             :     nCoordHeightG       ( 21600 ),
     733             :     bOOXMLShape         ( sal_False ),
     734             :     nXRef               ( 0x80000000 ),
     735             :     nYRef               ( 0x80000000 ),
     736             :     nFlags              ( 0 ),
     737             :     nColorData          ( 0 ),
     738             :     bTextFlow           ( sal_False ),
     739         778 :     bFilled             ( ((const XFillStyleItem&)pAObj->GetMergedItem( XATTR_FILLSTYLE )).GetValue() != XFILL_NONE ),
     740         778 :     bStroked            ( ((const XLineStyleItem&)pAObj->GetMergedItem( XATTR_LINESTYLE )).GetValue() != XLINE_NONE ),
     741             :     bFlipH              ( sal_False ),
     742        2334 :     bFlipV              ( sal_False )
     743             : {
     744             :     // bTextFlow needs to be set before clearing the TextDirection Item
     745             : 
     746         778 :     ClearItem( SDRATTR_TEXTDIRECTION ); //SJ: vertical writing is not required, by removing this item no outliner is created
     747             : 
     748             :     // #i105323# For 2D AtoShapes, the shadow attirbute does not need to be applied to any
     749             :     // of the constucted helper SdrObjects. This would lead to problems since the shadow
     750             :     // of one helper object would fall on one helper object behind it (e.g. with the
     751             :     // eyes of the smiley shape). This is not wanted; instead a single shadow 'behind'
     752             :     // the AutoShape visualisation is wanted. This is done with primitive functionailty
     753             :     // now in SdrCustomShapePrimitive2D::create2DDecomposition, but only for 2D objects
     754             :     // (see there and in EnhancedCustomShape3d::Create3DObject to read more).
     755             :     // This exception may be removed later when AutoShapes will create primitives directly.
     756             :     // So, currently remove the ShadowAttribute from the ItemSet to not apply it to any
     757             :     // 2D helper shape.
     758         778 :     ClearItem(SDRATTR_SHADOW);
     759             : 
     760         778 :     Point aP( pCustomShapeObj->GetSnapRect().Center() );
     761         778 :     Size aS( pCustomShapeObj->GetLogicRect().GetSize() );
     762         778 :     aP.X() -= aS.Width() / 2;
     763         778 :     aP.Y() -= aS.Height() / 2;
     764         778 :     aLogicRect = Rectangle( aP, aS );
     765             : 
     766         778 :     const rtl::OUString sType( RTL_CONSTASCII_USTRINGPARAM ( "Type" ) );
     767         778 :     const rtl::OUString sMirroredX( RTL_CONSTASCII_USTRINGPARAM ( "MirroredX" ) );
     768         778 :     const rtl::OUString sMirroredY( RTL_CONSTASCII_USTRINGPARAM ( "MirroredY" ) );
     769             : 
     770         778 :     rtl::OUString sShapeType;
     771         778 :     SdrCustomShapeGeometryItem& rGeometryItem = (SdrCustomShapeGeometryItem&)(const SdrCustomShapeGeometryItem&)pCustomShapeObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
     772         778 :     Any* pAny = rGeometryItem.GetPropertyValueByName( sType );
     773         778 :     if ( pAny ) {
     774         778 :         *pAny >>= sShapeType;
     775         778 :         bOOXMLShape = ( sShapeType.compareToAscii( "ooxml-", 6 ) == 0 );
     776             :         OSL_TRACE("shape type: %s %d", OUStringToOString( sShapeType, RTL_TEXTENCODING_ASCII_US ).getStr(), bOOXMLShape);
     777             :     }
     778         778 :     eSpType = EnhancedCustomShapeTypeNames::Get( sShapeType );
     779             : 
     780         778 :     pAny = rGeometryItem.GetPropertyValueByName( sMirroredX );
     781         778 :     if ( pAny )
     782           0 :         *pAny >>= bFlipH;
     783         778 :     pAny = rGeometryItem.GetPropertyValueByName( sMirroredY );
     784         778 :     if ( pAny )
     785           0 :         *pAny >>= bFlipV;
     786             : 
     787         778 :     if ( pCustomShapeObj->ISA( SdrObjCustomShape ) )    // should always be a SdrObjCustomShape, but you don't know
     788         778 :         nRotateAngle = (sal_Int32)(((SdrObjCustomShape*)pCustomShapeObj)->GetObjectRotation() * 100.0);
     789             :     else
     790           0 :          nRotateAngle = pCustomShapeObj->GetRotateAngle();
     791             : 
     792         778 :     /*const sal_Int32* pDefData =*/ ApplyShapeAttributes( rGeometryItem );
     793         778 :     SetPathSize();
     794             : 
     795         778 :     switch( eSpType )
     796             :     {
     797           0 :         case mso_sptCan :                       nColorData = 0x20400000; break;
     798           0 :         case mso_sptCube :                      nColorData = 0x302e0000; break;
     799           0 :         case mso_sptActionButtonBlank :         nColorData = 0x502ce400; break;
     800           0 :         case mso_sptActionButtonHome :          nColorData = 0x702ce4ce; break;
     801           0 :         case mso_sptActionButtonHelp :          nColorData = 0x602ce4c0; break;
     802           0 :         case mso_sptActionButtonInformation :   nColorData = 0x702ce4c5; break;
     803           0 :         case mso_sptActionButtonBackPrevious :  nColorData = 0x602ce4c0; break;
     804           0 :         case mso_sptActionButtonForwardNext :   nColorData = 0x602ce4c0; break;
     805           0 :         case mso_sptActionButtonBeginning :     nColorData = 0x602ce4c0; break;
     806           0 :         case mso_sptActionButtonEnd :           nColorData = 0x602ce4c0; break;
     807           0 :         case mso_sptActionButtonReturn :        nColorData = 0x602ce4c0; break;
     808           0 :         case mso_sptActionButtonDocument :      nColorData = 0x702ce4ec; break;
     809           0 :         case mso_sptActionButtonSound :         nColorData = 0x602ce4c0; break;
     810           0 :         case mso_sptActionButtonMovie :         nColorData = 0x602ce4c0; break;
     811           1 :         case mso_sptBevel :                     nColorData = 0x502ce400; break;
     812           0 :         case mso_sptFoldedCorner :              nColorData = 0x20e00000; break;
     813           1 :         case mso_sptSmileyFace :                nColorData = 0x20e00000; break;
     814             :         case mso_sptNil :
     815             :         {
     816           0 :             if( sShapeType.getLength() > 4 &&
     817           0 :                 sShapeType.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "col-" )))
     818             :             {
     819           0 :                 nColorData = sShapeType.copy( 4 ).toInt32( 16 );
     820             :             }
     821             :         }
     822           0 :         break;
     823             :         case mso_sptCurvedLeftArrow :
     824             :         case mso_sptCurvedRightArrow :
     825             :         case mso_sptCurvedUpArrow :
     826           3 :         case mso_sptCurvedDownArrow :           nColorData = 0x20d00000; break;
     827           0 :         case mso_sptRibbon2 :                   nColorData = 0x30ee0000; break;
     828           0 :         case mso_sptRibbon :                    nColorData = 0x30ee0000; break;
     829             : 
     830           0 :         case mso_sptEllipseRibbon2 :            nColorData = 0x30ee0000; break;
     831           0 :         case mso_sptEllipseRibbon :             nColorData = 0x30ee0000; break;
     832             : 
     833           0 :         case mso_sptVerticalScroll :            nColorData = 0x30ee0000; break;
     834           2 :         case mso_sptHorizontalScroll :          nColorData = 0x30ee0000; break;
     835             :         default:
     836         771 :             break;
     837             :     }
     838             : 
     839         778 :     sal_Int32 i, nLength = seqEquations.getLength();
     840             : 
     841         778 :     if ( nLength )
     842             :     {
     843          36 :         vNodesSharedPtr.resize( nLength );
     844          36 :         vEquationResults.resize( nLength );
     845         639 :         for ( i = 0; i < seqEquations.getLength(); i++ )
     846             :         {
     847         603 :             vEquationResults[ i ].bReady = sal_False;
     848             :             try
     849             :             {
     850         603 :                 vNodesSharedPtr[ i ] = EnhancedCustomShape::FunctionParser::parseFunction( seqEquations[ i ], *this );
     851             :             }
     852           0 :             catch ( EnhancedCustomShape::ParseError& )
     853             :             {
     854             :                 OSL_TRACE("error: equation number: %d, parser failed ( %s )",
     855             :                           i, OUStringToOString( seqEquations[ i ], RTL_TEXTENCODING_ASCII_US ).getStr());
     856             :             }
     857             :         }
     858         778 :     }
     859         778 : }
     860          34 : double EnhancedCustomShape2d::GetEnumFunc( const EnumFunc eFunc ) const
     861             : {
     862          34 :     double fRet = 0.0;
     863          34 :     switch( eFunc )
     864             :     {
     865           8 :         case ENUM_FUNC_PI :         fRet = F_PI; break;
     866           5 :         case ENUM_FUNC_LEFT :       fRet = 0.0; break;
     867           5 :         case ENUM_FUNC_TOP :        fRet = 0.0; break;
     868           8 :         case ENUM_FUNC_RIGHT :      fRet = (double)nCoordWidth * fXRatio;   break;
     869           8 :         case ENUM_FUNC_BOTTOM :     fRet = (double)nCoordHeight * fYRatio; break;
     870           0 :         case ENUM_FUNC_XSTRETCH :   fRet = nXRef; break;
     871           0 :         case ENUM_FUNC_YSTRETCH :   fRet = nYRef; break;
     872           0 :         case ENUM_FUNC_HASSTROKE :  fRet = bStroked ? 1.0 : 0.0; break;
     873           0 :         case ENUM_FUNC_HASFILL :    fRet = bFilled ? 1.0 : 0.0; break;
     874           0 :         case ENUM_FUNC_WIDTH :      fRet = nCoordWidth; break;
     875           0 :         case ENUM_FUNC_HEIGHT :     fRet = nCoordHeight; break;
     876           0 :         case ENUM_FUNC_LOGWIDTH :   fRet = aLogicRect.GetWidth(); break;
     877           0 :         case ENUM_FUNC_LOGHEIGHT :  fRet = aLogicRect.GetHeight(); break;
     878             :     }
     879          34 :     return fRet;
     880             : }
     881          45 : double EnhancedCustomShape2d::GetAdjustValueAsDouble( const sal_Int32 nIndex ) const
     882             : {
     883          45 :     double fNumber = 0.0;
     884          45 :     if ( nIndex < seqAdjustmentValues.getLength() )
     885             :     {
     886          45 :         if ( seqAdjustmentValues[ nIndex ].Value.getValueTypeClass() == TypeClass_DOUBLE )
     887           0 :             seqAdjustmentValues[ nIndex ].Value >>= fNumber;
     888             :         else
     889             :         {
     890          45 :             sal_Int32 nNumber = 0;
     891          45 :             seqAdjustmentValues[ nIndex ].Value >>= nNumber;
     892          45 :             fNumber = (double)nNumber;
     893             :         }
     894             :     }
     895          45 :     return fNumber;
     896             : }
     897         158 : double EnhancedCustomShape2d::GetEquationValueAsDouble( const sal_Int32 nIndex ) const
     898             : {
     899         158 :     double fNumber = 0.0;
     900             : #if OSL_DEBUG_LEVEL > 1
     901             :     static sal_uInt32 nLevel = 0;
     902             : #endif
     903         158 :     if ( nIndex < (sal_Int32)vNodesSharedPtr.size() )
     904             :     {
     905         158 :         if ( vNodesSharedPtr[ nIndex ].get() ) {
     906             : #if OSL_DEBUG_LEVEL > 1
     907             :             nLevel ++;
     908             : #endif
     909             :             try
     910             :             {
     911         158 :                 if ( vEquationResults[ nIndex ].bReady )
     912          45 :                     fNumber = vEquationResults[ nIndex ].fValue;
     913             :                 else {
     914             :                     // cast to non const, so that we can optimize by caching
     915             :                     // equation results, without changing all the const in the stack
     916         113 :                     struct EquationResult &aResult = ((EnhancedCustomShape2d*)this)->vEquationResults[ nIndex ];
     917             : 
     918         113 :                     fNumber = aResult.fValue = (*vNodesSharedPtr[ nIndex ])();
     919         113 :                     aResult.bReady = sal_True;
     920             : 
     921         113 :                     if ( !rtl::math::isFinite( fNumber ) )
     922           0 :                         fNumber = 0.0;
     923             : #if OSL_DEBUG_LEVEL > 1
     924             :                     OSL_TRACE("equation %d (level: %d): %s --> %f (angle: %f)", nIndex,
     925             :                               nLevel, OUStringToOString( seqEquations[ nIndex ],
     926             :                                                          RTL_TEXTENCODING_ASCII_US ).getStr(), fNumber, 180.0*fNumber/10800000.0);
     927             : #endif
     928             :                 }
     929             :             }
     930           0 :             catch ( ... )
     931             :             {
     932             :                 /* sal_Bool bUps = sal_True; */
     933             :                 OSL_TRACE("error: EnhancedCustomShape2d::GetEquationValueAsDouble failed");
     934             :             }
     935             : #if OSL_DEBUG_LEVEL > 1
     936             :         nLevel --;
     937             : #endif
     938             :         }
     939             :         OSL_TRACE("  ?%d --> %f (angle: %f)", nIndex,
     940             :                   fNumber, 180.0*fNumber/10800000.0);
     941             :     }
     942             : 
     943         158 :     return fNumber;
     944             : }
     945           0 : sal_Int32 EnhancedCustomShape2d::GetAdjustValueAsInteger( const sal_Int32 nIndex, const sal_Int32 nDefault ) const
     946             : {
     947           0 :     sal_Int32 nNumber = nDefault;
     948           0 :     if ( nIndex < seqAdjustmentValues.getLength() )
     949             :     {
     950           0 :         if ( seqAdjustmentValues[ nIndex ].Value.getValueTypeClass() == TypeClass_DOUBLE )
     951             :         {
     952           0 :             double fNumber = 0;
     953           0 :             seqAdjustmentValues[ nIndex ].Value >>= fNumber;
     954           0 :             nNumber = (sal_Int32)fNumber;
     955             :         }
     956             :         else
     957           0 :             seqAdjustmentValues[ nIndex ].Value >>= nNumber;
     958             :     }
     959           0 :     return nNumber;
     960             : }
     961           0 : sal_Bool EnhancedCustomShape2d::SetAdjustValueAsDouble( const double& rValue, const sal_Int32 nIndex )
     962             : {
     963           0 :     sal_Bool bRetValue = sal_False;
     964           0 :     if ( nIndex < seqAdjustmentValues.getLength() )
     965             :     {
     966             :         // updating our local adjustment sequence
     967           0 :         seqAdjustmentValues[ nIndex ].Value <<= rValue;
     968           0 :         seqAdjustmentValues[ nIndex ].State = com::sun::star::beans::PropertyState_DIRECT_VALUE;
     969           0 :         bRetValue = sal_True;
     970             :     }
     971           0 :     return bRetValue;
     972             : }
     973             : 
     974          94 : Point EnhancedCustomShape2d::GetPoint( const com::sun::star::drawing::EnhancedCustomShapeParameterPair& rPair,
     975             :                                         const sal_Bool bScale, const sal_Bool bReplaceGeoSize ) const
     976             : {
     977          94 :     Point       aRetValue;
     978          94 :     sal_Bool    bExchange = ( nFlags & DFF_CUSTOMSHAPE_EXCH ) != 0; // x <-> y
     979          94 :     sal_uInt32  nPass = 0;
     980         188 :     do
     981             :     {
     982         188 :         sal_uInt32  nIndex = nPass;
     983             : 
     984         188 :         if ( bExchange )
     985           0 :             nIndex ^= 1;
     986             : 
     987             :         double      fVal;
     988         188 :         const EnhancedCustomShapeParameter& rParameter = nIndex ? rPair.Second : rPair.First;
     989         188 :         if ( nPass )    // height
     990             :         {
     991          94 :             GetParameter( fVal, rParameter, sal_False, bReplaceGeoSize );
     992          94 :             fVal -= nCoordTop;
     993          94 :             if ( bScale )
     994             :             {
     995          94 :                 fVal *= fYScale;
     996             : 
     997          94 :                 if ( nFlags & DFF_CUSTOMSHAPE_FLIP_V )
     998           0 :                     fVal = aLogicRect.GetHeight() - fVal;
     999             :             }
    1000          94 :             aRetValue.Y() = (sal_Int32)fVal;
    1001             :         }
    1002             :         else            // width
    1003             :         {
    1004          94 :             GetParameter( fVal, rParameter, bReplaceGeoSize, sal_False );
    1005          94 :             fVal -= nCoordLeft;
    1006          94 :             if ( bScale )
    1007             :             {
    1008          94 :                 fVal *= fXScale;
    1009             : 
    1010          94 :                 if ( nFlags & DFF_CUSTOMSHAPE_FLIP_H )
    1011           0 :                     fVal = aLogicRect.GetWidth() - fVal;
    1012             :             }
    1013          94 :             aRetValue.X() = (sal_Int32)fVal;
    1014             :         }
    1015             :     }
    1016             :     while ( ++nPass < 2 );
    1017          94 :     return aRetValue;
    1018             : }
    1019             : 
    1020         188 : sal_Bool EnhancedCustomShape2d::GetParameter( double& rRetValue, const EnhancedCustomShapeParameter& rParameter,
    1021             :                                               const sal_Bool bReplaceGeoWidth, const sal_Bool bReplaceGeoHeight ) const
    1022             : {
    1023         188 :     rRetValue = 0.0;
    1024         188 :     sal_Bool bRetValue = sal_False;
    1025         188 :     switch ( rParameter.Type )
    1026             :     {
    1027             :         case EnhancedCustomShapeParameterType::ADJUSTMENT :
    1028             :         {
    1029           0 :             sal_Int32 nAdjustmentIndex = 0;
    1030           0 :             if ( rParameter.Value >>= nAdjustmentIndex )
    1031             :             {
    1032           0 :                 rRetValue = GetAdjustValueAsDouble( nAdjustmentIndex );
    1033           0 :                 bRetValue = sal_True;
    1034             :             }
    1035             :         }
    1036           0 :         break;
    1037             :         case EnhancedCustomShapeParameterType::EQUATION :
    1038             :         {
    1039          78 :             sal_Int32 nEquationIndex = 0;
    1040          78 :             if ( rParameter.Value >>= nEquationIndex )
    1041             :             {
    1042          78 :                 rRetValue = GetEquationValueAsDouble( nEquationIndex );
    1043          78 :                 bRetValue = sal_True;
    1044             :             }
    1045             :         }
    1046          78 :         break;
    1047             :         case EnhancedCustomShapeParameterType::NORMAL :
    1048             :         {
    1049         110 :             if ( rParameter.Value.getValueTypeClass() == TypeClass_DOUBLE )
    1050             :             {
    1051           0 :                 double fValue(0.0);
    1052           0 :                 if ( rParameter.Value >>= fValue )
    1053             :                 {
    1054           0 :                     rRetValue = fValue;
    1055           0 :                     bRetValue = sal_True;
    1056             :                 }
    1057             :             }
    1058             :             else
    1059             :             {
    1060         110 :                 sal_Int32 nValue = 0;
    1061         110 :                 if ( rParameter.Value >>= nValue )
    1062             :                 {
    1063         110 :                     rRetValue = nValue;
    1064         110 :                     bRetValue = sal_True;
    1065         110 :                     if ( bReplaceGeoWidth && ( nValue == nCoordWidth ) )
    1066           5 :                         rRetValue *= fXRatio;
    1067         105 :                     else if ( bReplaceGeoHeight && ( nValue == nCoordHeight ) )
    1068           3 :                         rRetValue *= fYRatio;
    1069             :                 }
    1070             :             }
    1071             :         }
    1072         110 :         break;
    1073             :         case EnhancedCustomShapeParameterType::LEFT :
    1074             :         {
    1075           0 :             rRetValue  = 0.0;
    1076           0 :             bRetValue = sal_True;
    1077             :         }
    1078           0 :         break;
    1079             :         case EnhancedCustomShapeParameterType::TOP :
    1080             :         {
    1081           0 :             rRetValue  = 0.0;
    1082           0 :             bRetValue = sal_True;
    1083             :         }
    1084           0 :         break;
    1085             :         case EnhancedCustomShapeParameterType::RIGHT :
    1086             :         {
    1087           0 :             rRetValue = nCoordWidth;
    1088           0 :             bRetValue = sal_True;
    1089             :         }
    1090           0 :         break;
    1091             :         case EnhancedCustomShapeParameterType::BOTTOM :
    1092             :         {
    1093           0 :             rRetValue = nCoordHeight;
    1094           0 :             bRetValue = sal_True;
    1095             :         }
    1096           0 :         break;
    1097             :     }
    1098         188 :     return bRetValue;
    1099             : }
    1100             : 
    1101             : // nLumDat 28-31 = number of luminance entries in nLumDat
    1102             : // nLumDat 27-24 = nLumDatEntry 0
    1103             : // nLumDat 23-20 = nLumDatEntry 1 ...
    1104             : // each 4bit entry is to be interpreted as a 10 percent signed luminance changing
    1105           0 : sal_Int32 EnhancedCustomShape2d::GetLuminanceChange( sal_uInt32 nIndex ) const
    1106             : {
    1107           0 :     const sal_uInt32 nCount = nColorData >> 28;
    1108           0 :     if ( !nCount )
    1109           0 :         return 0;
    1110             : 
    1111           0 :     if ( nIndex >= nCount )
    1112           0 :         nIndex = nCount - 1;
    1113             : 
    1114           0 :     const sal_Int32 nLumDat = nColorData << ( ( 1 + nIndex ) << 2 );
    1115           0 :     return ( nLumDat >> 28 ) * 10;
    1116             : }
    1117             : 
    1118           0 : Color EnhancedCustomShape2d::GetColorData( const Color& rFillColor, sal_uInt32 nIndex, double dBrightness ) const
    1119             : {
    1120           0 :     const sal_Int32 nLuminance = GetLuminanceChange(nIndex);
    1121           0 :     if( !nLuminance && dBrightness == 1.0 )
    1122           0 :         return rFillColor;
    1123             : 
    1124             :     basegfx::BColor aHSVColor=
    1125             :         basegfx::tools::rgb2hsv(
    1126           0 :             basegfx::BColor(rFillColor.GetRed()/255.0,
    1127           0 :                             rFillColor.GetGreen()/255.0,
    1128           0 :                             rFillColor.GetBlue()/255.0));
    1129           0 :     if (nLuminance ) {
    1130           0 :         if( nLuminance > 0 )
    1131             :         {
    1132             :             aHSVColor.setGreen(
    1133           0 :                 aHSVColor.getGreen() * (1.0-nLuminance/100.0));
    1134             :             aHSVColor.setBlue(
    1135             :                 nLuminance/100.0 +
    1136           0 :                 (1.0-nLuminance/100.0)*aHSVColor.getBlue());
    1137             :         }
    1138           0 :         else if( nLuminance < 0 )
    1139             :         {
    1140             :             aHSVColor.setBlue(
    1141           0 :                 (1.0+nLuminance/100.0)*aHSVColor.getBlue());
    1142             :         }
    1143             :     }
    1144             : 
    1145           0 :     aHSVColor = basegfx::tools::hsv2rgb(aHSVColor);
    1146           0 :     return Color( (sal_uInt8)static_cast< sal_Int32 >( basegfx::clamp(dBrightness*aHSVColor.getRed(),0.0,1.0) * 255.0 + 0.5 ),
    1147           0 :                   (sal_uInt8)static_cast< sal_Int32 >( basegfx::clamp(dBrightness*aHSVColor.getGreen(),0.0,1.0) * 255.0 + 0.5 ),
    1148           0 :                   (sal_uInt8)static_cast< sal_Int32 >( basegfx::clamp(dBrightness*aHSVColor.getBlue(),0.0,1.0) * 255.0 + 0.5 ) );
    1149             : }
    1150             : 
    1151         778 : Rectangle EnhancedCustomShape2d::GetTextRect() const
    1152             : {
    1153         778 :     sal_Int32 nIndex, nSize = seqTextFrames.getLength();
    1154         778 :     if ( !nSize )
    1155         731 :         return aLogicRect;
    1156          47 :     nIndex = 0;
    1157          47 :     if ( bTextFlow && ( nSize > 1 ) )
    1158           0 :         nIndex++;
    1159          47 :     Point aTopLeft( GetPoint( seqTextFrames[ nIndex ].TopLeft, !bOOXMLShape, sal_True ) );
    1160          47 :     Point aBottomRight( GetPoint( seqTextFrames[ nIndex ].BottomRight, !bOOXMLShape, sal_True ) );
    1161          47 :     if ( bFlipH )
    1162             :     {
    1163           0 :         aTopLeft.X() = aLogicRect.GetWidth() - aTopLeft.X();
    1164           0 :         aBottomRight.X() = aLogicRect.GetWidth() - aBottomRight.X();
    1165             :     }
    1166          47 :     if ( bFlipV )
    1167             :     {
    1168           0 :         aTopLeft.Y() = aLogicRect.GetHeight() - aTopLeft.Y();
    1169           0 :         aBottomRight.Y() = aLogicRect.GetHeight() - aBottomRight.Y();
    1170             :     }
    1171          47 :     Rectangle aRect( aTopLeft, aBottomRight );
    1172             :     OSL_TRACE("EnhancedCustomShape2d::GetTextRect: %d x %d", aRect.GetWidth(), aRect.GetHeight());
    1173          47 :     if( aRect.GetWidth() <= 1 || aRect.GetHeight() <= 1 )
    1174           0 :         return aLogicRect;
    1175          47 :     aRect.Move( aLogicRect.Left(), aLogicRect.Top() );
    1176          47 :     aRect.Justify();
    1177          47 :     return aRect;
    1178             : }
    1179             : 
    1180           0 : sal_uInt32 EnhancedCustomShape2d::GetHdlCount() const
    1181             : {
    1182           0 :     return seqHandles.getLength();
    1183             : }
    1184             : 
    1185           0 : sal_Bool EnhancedCustomShape2d::GetHandlePosition( const sal_uInt32 nIndex, Point& rReturnPosition ) const
    1186             : {
    1187           0 :     sal_Bool bRetValue = sal_False;
    1188           0 :     if ( nIndex < GetHdlCount() )
    1189             :     {
    1190           0 :         Handle aHandle;
    1191           0 :         if ( ConvertSequenceToEnhancedCustomShape2dHandle( seqHandles[ nIndex ], aHandle ) )
    1192             :         {
    1193           0 :             if ( aHandle.nFlags & HANDLE_FLAGS_POLAR )
    1194             :             {
    1195           0 :                 Point aReferencePoint( GetPoint( aHandle.aPolar, sal_True, sal_False ) );
    1196             : 
    1197             :                 double      fAngle;
    1198             :                 double      fRadius;
    1199           0 :                 GetParameter( fRadius, aHandle.aPosition.First, sal_False, sal_False );
    1200           0 :                 GetParameter( fAngle,  aHandle.aPosition.Second, sal_False, sal_False );
    1201             : 
    1202           0 :                 double a = ( 360.0 - fAngle ) * F_PI180;
    1203           0 :                 double dx = fRadius * fXScale;
    1204           0 :                 double fX = dx * cos( a );
    1205           0 :                 double fY =-dx * sin( a );
    1206             :                 rReturnPosition =
    1207             :                     Point(
    1208           0 :                         Round( fX + aReferencePoint.X() ),
    1209           0 :                         basegfx::fTools::equalZero(fXScale) ? aReferencePoint.Y() :
    1210           0 :                         Round( ( fY * fYScale ) / fXScale + aReferencePoint.Y() ) );
    1211             :             }
    1212             :             else
    1213             :             {
    1214           0 :                 if ( aHandle.nFlags & HANDLE_FLAGS_SWITCHED )
    1215             :                 {
    1216           0 :                     if ( aLogicRect.GetHeight() > aLogicRect.GetWidth() )
    1217             :                     {
    1218           0 :                         com::sun::star::drawing::EnhancedCustomShapeParameter aFirst = aHandle.aPosition.First;
    1219           0 :                         com::sun::star::drawing::EnhancedCustomShapeParameter aSecond = aHandle.aPosition.Second;
    1220           0 :                         aHandle.aPosition.First = aSecond;
    1221           0 :                         aHandle.aPosition.Second = aFirst;
    1222             :                     }
    1223             :                 }
    1224           0 :                 rReturnPosition = GetPoint( aHandle.aPosition, sal_True, sal_False );
    1225             :             }
    1226           0 :             const GeoStat aGeoStat( ((SdrObjCustomShape*)pCustomShapeObj)->GetGeoStat() );
    1227           0 :             if ( aGeoStat.nShearWink )
    1228             :             {
    1229           0 :                 double nTan = aGeoStat.nTan;
    1230           0 :                 if ((bFlipV&&!bFlipH )||(bFlipH&&!bFlipV))
    1231           0 :                     nTan = -nTan;
    1232           0 :                 ShearPoint( rReturnPosition, Point( aLogicRect.GetWidth() / 2, aLogicRect.GetHeight() / 2 ), nTan );
    1233             :             }
    1234           0 :             if ( nRotateAngle )
    1235             :             {
    1236           0 :                 double a = nRotateAngle * F_PI18000;
    1237           0 :                 RotatePoint( rReturnPosition, Point( aLogicRect.GetWidth() / 2, aLogicRect.GetHeight() / 2 ), sin( a ), cos( a ) );
    1238             :             }
    1239           0 :             if ( bFlipH )
    1240           0 :                 rReturnPosition.X() = aLogicRect.GetWidth() - rReturnPosition.X();
    1241           0 :             if ( bFlipV )
    1242           0 :                 rReturnPosition.Y() = aLogicRect.GetHeight() - rReturnPosition.Y();
    1243           0 :             rReturnPosition.Move( aLogicRect.Left(), aLogicRect.Top() );
    1244           0 :             bRetValue = sal_True;
    1245           0 :         }
    1246             :     }
    1247           0 :     return bRetValue;
    1248             : }
    1249             : 
    1250           0 : sal_Bool EnhancedCustomShape2d::SetHandleControllerPosition( const sal_uInt32 nIndex, const com::sun::star::awt::Point& rPosition )
    1251             : {
    1252           0 :     sal_Bool bRetValue = sal_False;
    1253           0 :     if ( nIndex < GetHdlCount() )
    1254             :     {
    1255           0 :         Handle aHandle;
    1256           0 :         if ( ConvertSequenceToEnhancedCustomShape2dHandle( seqHandles[ nIndex ], aHandle ) )
    1257             :         {
    1258           0 :             Point aP( rPosition.X, rPosition.Y );
    1259             :             // apply the negative object rotation to the controller position
    1260             : 
    1261           0 :             aP.Move( -aLogicRect.Left(), -aLogicRect.Top() );
    1262           0 :             if ( bFlipH )
    1263           0 :                 aP.X() = aLogicRect.GetWidth() - aP.X();
    1264           0 :             if ( bFlipV )
    1265           0 :                 aP.Y() = aLogicRect.GetHeight() - aP.Y();
    1266           0 :             if ( nRotateAngle )
    1267             :             {
    1268           0 :                 double a = -nRotateAngle * F_PI18000;
    1269           0 :                 RotatePoint( aP, Point( aLogicRect.GetWidth() / 2, aLogicRect.GetHeight() / 2 ), sin( a ), cos( a ) );
    1270             :             }
    1271           0 :             const GeoStat aGeoStat( ((SdrObjCustomShape*)pCustomShapeObj)->GetGeoStat() );
    1272           0 :             if ( aGeoStat.nShearWink )
    1273             :             {
    1274           0 :                 double nTan = -aGeoStat.nTan;
    1275           0 :                 if ((bFlipV&&!bFlipH )||(bFlipH&&!bFlipV))
    1276           0 :                     nTan = -nTan;
    1277           0 :                 ShearPoint( aP, Point( aLogicRect.GetWidth() / 2, aLogicRect.GetHeight() / 2 ), nTan );
    1278             :             }
    1279             : 
    1280           0 :             double fPos1 = aP.X();  //( bFlipH ) ? aLogicRect.GetWidth() - aP.X() : aP.X();
    1281           0 :             double fPos2 = aP.Y();  //( bFlipV ) ? aLogicRect.GetHeight() -aP.Y() : aP.Y();
    1282           0 :             fPos1 /= fXScale;
    1283           0 :             fPos2 /= fYScale;
    1284             : 
    1285           0 :             if ( aHandle.nFlags & HANDLE_FLAGS_SWITCHED )
    1286             :             {
    1287           0 :                 if ( aLogicRect.GetHeight() > aLogicRect.GetWidth() )
    1288             :                 {
    1289           0 :                     double fX = fPos1;
    1290           0 :                     double fY = fPos2;
    1291           0 :                     fPos1 = fY;
    1292           0 :                     fPos2 = fX;
    1293             :                 }
    1294             :             }
    1295             : 
    1296           0 :             sal_Int32 nFirstAdjustmentValue = -1, nSecondAdjustmentValue = -1;
    1297             : 
    1298           0 :             if ( aHandle.aPosition.First.Type == EnhancedCustomShapeParameterType::ADJUSTMENT )
    1299           0 :                 aHandle.aPosition.First.Value >>= nFirstAdjustmentValue;
    1300           0 :             if ( aHandle.aPosition.Second.Type == EnhancedCustomShapeParameterType::ADJUSTMENT )
    1301           0 :                 aHandle.aPosition.Second.Value>>= nSecondAdjustmentValue;
    1302             : 
    1303           0 :             if ( aHandle.nFlags & HANDLE_FLAGS_POLAR )
    1304             :             {
    1305             :                 double fXRef, fYRef, fAngle;
    1306           0 :                 GetParameter( fXRef, aHandle.aPolar.First, sal_False, sal_False );
    1307           0 :                 GetParameter( fYRef, aHandle.aPolar.Second, sal_False, sal_False );
    1308           0 :                 const double fDX = fPos1 - fXRef;
    1309           0 :                 fAngle = -( atan2( -fPos2 + fYRef, ( ( fDX == 0.0L ) ? 0.000000001 : fDX ) ) / F_PI180 );
    1310           0 :                 double fX = ( fPos1 - fXRef );
    1311           0 :                 double fY = ( fPos2 - fYRef );
    1312           0 :                 double fRadius = sqrt( fX * fX + fY * fY );
    1313           0 :                 if ( aHandle.nFlags & HANDLE_FLAGS_RADIUS_RANGE_MINIMUM )
    1314             :                 {
    1315             :                     double fMin;
    1316           0 :                     GetParameter( fMin,  aHandle.aRadiusRangeMinimum, sal_False, sal_False );
    1317           0 :                     if ( fRadius < fMin )
    1318           0 :                         fRadius = fMin;
    1319             :                 }
    1320           0 :                 if ( aHandle.nFlags & HANDLE_FLAGS_RADIUS_RANGE_MAXIMUM )
    1321             :                 {
    1322             :                     double fMax;
    1323           0 :                     GetParameter( fMax, aHandle.aRadiusRangeMaximum, sal_False, sal_False );
    1324           0 :                     if ( fRadius > fMax )
    1325           0 :                         fRadius = fMax;
    1326             :                 }
    1327           0 :                 if ( nFirstAdjustmentValue >= 0 )
    1328           0 :                     SetAdjustValueAsDouble( fRadius, nFirstAdjustmentValue );
    1329           0 :                 if ( nSecondAdjustmentValue >= 0 )
    1330           0 :                     SetAdjustValueAsDouble( fAngle,  nSecondAdjustmentValue );
    1331             :             }
    1332             :             else
    1333             :             {
    1334           0 :                 if ( aHandle.nFlags & HANDLE_FLAGS_REFX )
    1335             :                 {
    1336           0 :                     nFirstAdjustmentValue = aHandle.nRefX;
    1337           0 :                     fPos1 *= 100000.0;
    1338           0 :                     fPos1 /= nCoordWidth;
    1339             :                 }
    1340           0 :                 if ( aHandle.nFlags & HANDLE_FLAGS_REFY )
    1341             :                 {
    1342           0 :                     nSecondAdjustmentValue = aHandle.nRefY;
    1343           0 :                     fPos2 *= 100000.0;
    1344           0 :                     fPos2 /= nCoordHeight;
    1345             :                 }
    1346           0 :                 if ( nFirstAdjustmentValue >= 0 )
    1347             :                 {
    1348           0 :                     if ( aHandle.nFlags & HANDLE_FLAGS_RANGE_X_MINIMUM )        // check if horizontal handle needs to be within a range
    1349             :                     {
    1350             :                         double fXMin;
    1351           0 :                         GetParameter( fXMin, aHandle.aXRangeMinimum, sal_False, sal_False );
    1352           0 :                         if ( fPos1 < fXMin )
    1353           0 :                             fPos1 = fXMin;
    1354             :                     }
    1355           0 :                     if ( aHandle.nFlags & HANDLE_FLAGS_RANGE_X_MAXIMUM )        // check if horizontal handle needs to be within a range
    1356             :                     {
    1357             :                         double fXMax;
    1358           0 :                         GetParameter( fXMax, aHandle.aXRangeMaximum, sal_False, sal_False );
    1359           0 :                         if ( fPos1 > fXMax )
    1360           0 :                             fPos1 = fXMax;
    1361             :                     }
    1362           0 :                     SetAdjustValueAsDouble( fPos1, nFirstAdjustmentValue );
    1363             :                 }
    1364           0 :                 if ( nSecondAdjustmentValue >= 0 )
    1365             :                 {
    1366           0 :                     if ( aHandle.nFlags & HANDLE_FLAGS_RANGE_Y_MINIMUM )        // check if vertical handle needs to be within a range
    1367             :                     {
    1368             :                         double fYMin;
    1369           0 :                         GetParameter( fYMin, aHandle.aYRangeMinimum, sal_False, sal_False );
    1370           0 :                         if ( fPos2 < fYMin )
    1371           0 :                             fPos2 = fYMin;
    1372             :                     }
    1373           0 :                     if ( aHandle.nFlags & HANDLE_FLAGS_RANGE_Y_MAXIMUM )        // check if vertical handle needs to be within a range
    1374             :                     {
    1375             :                         double fYMax;
    1376           0 :                         GetParameter( fYMax, aHandle.aYRangeMaximum, sal_False, sal_False );
    1377           0 :                         if ( fPos2 > fYMax )
    1378           0 :                             fPos2 = fYMax;
    1379             :                     }
    1380           0 :                     SetAdjustValueAsDouble( fPos2, nSecondAdjustmentValue );
    1381             :                 }
    1382             :             }
    1383             :             // and writing them back into the GeometryItem
    1384             :             SdrCustomShapeGeometryItem aGeometryItem((SdrCustomShapeGeometryItem&)
    1385           0 :                 (const SdrCustomShapeGeometryItem&)pCustomShapeObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ));
    1386           0 :             const rtl::OUString sAdjustmentValues( RTL_CONSTASCII_USTRINGPARAM ( "AdjustmentValues" ) );
    1387           0 :             com::sun::star::beans::PropertyValue aPropVal;
    1388           0 :             aPropVal.Name = sAdjustmentValues;
    1389           0 :             aPropVal.Value <<= seqAdjustmentValues;
    1390           0 :             aGeometryItem.SetPropertyValue( aPropVal );
    1391           0 :             pCustomShapeObj->SetMergedItem( aGeometryItem );
    1392           0 :             bRetValue = sal_True;
    1393           0 :         }
    1394             :     }
    1395           0 :     return bRetValue;
    1396             : }
    1397             : 
    1398           0 : void EnhancedCustomShape2d::SwapStartAndEndArrow( SdrObject* pObj ) //#108274
    1399             : {
    1400           0 :     XLineStartItem       aLineStart;
    1401           0 :     aLineStart.SetLineStartValue(((XLineStartItem&)pObj->GetMergedItem( XATTR_LINEEND )).GetLineStartValue());
    1402           0 :     XLineStartWidthItem  aLineStartWidth(((XLineStartWidthItem&)pObj->GetMergedItem( XATTR_LINEENDWIDTH )).GetValue());
    1403           0 :     XLineStartCenterItem aLineStartCenter(((XLineStartCenterItem&)pObj->GetMergedItem( XATTR_LINEENDCENTER )).GetValue());
    1404             : 
    1405           0 :     XLineEndItem         aLineEnd;
    1406           0 :     aLineEnd.SetLineEndValue(((XLineEndItem&)pObj->GetMergedItem( XATTR_LINESTART )).GetLineEndValue());
    1407           0 :     XLineEndWidthItem    aLineEndWidth(((XLineEndWidthItem&)pObj->GetMergedItem( XATTR_LINESTARTWIDTH )).GetValue());
    1408           0 :     XLineEndCenterItem   aLineEndCenter(((XLineEndCenterItem&)pObj->GetMergedItem( XATTR_LINESTARTCENTER )).GetValue());
    1409             : 
    1410           0 :     pObj->SetMergedItem( aLineStart );
    1411           0 :     pObj->SetMergedItem( aLineStartWidth );
    1412           0 :     pObj->SetMergedItem( aLineStartCenter );
    1413           0 :     pObj->SetMergedItem( aLineEnd );
    1414           0 :     pObj->SetMergedItem( aLineEndWidth );
    1415           0 :     pObj->SetMergedItem( aLineEndCenter );
    1416           0 : }
    1417             : 
    1418           0 : basegfx::B2DPolygon CreateArc( const Rectangle& rRect, const Point& rStart, const Point& rEnd, const sal_Bool bClockwise, sal_Bool bFullCircle = sal_False )
    1419             : {
    1420           0 :     Rectangle aRect( rRect );
    1421           0 :     Point aStart( rStart );
    1422           0 :     Point aEnd( rEnd );
    1423             : 
    1424           0 :     sal_Int32 bSwapStartEndAngle = 0;
    1425             : 
    1426           0 :     if ( aRect.Left() > aRect.Right() )
    1427           0 :         bSwapStartEndAngle ^= 0x01;
    1428           0 :     if ( aRect.Top() > aRect.Bottom() )
    1429           0 :         bSwapStartEndAngle ^= 0x11;
    1430           0 :     if ( bSwapStartEndAngle )
    1431             :     {
    1432           0 :         aRect.Justify();
    1433           0 :         if ( bSwapStartEndAngle & 1 )
    1434             :         {
    1435           0 :             Point aTmp( aStart );
    1436           0 :             aStart = aEnd;
    1437           0 :             aEnd = aTmp;
    1438             :         }
    1439             :     }
    1440             : 
    1441           0 :     Polygon aTempPoly( aRect, aStart, aEnd, POLY_ARC, bFullCircle );
    1442           0 :     basegfx::B2DPolygon aRetval;
    1443             : 
    1444           0 :     if ( bClockwise )
    1445             :     {
    1446           0 :         for ( sal_uInt16 j = aTempPoly.GetSize(); j--; )
    1447             :         {
    1448           0 :             aRetval.append(basegfx::B2DPoint(aTempPoly[ j ].X(), aTempPoly[ j ].Y()));
    1449             :         }
    1450             :     }
    1451             :     else
    1452             :     {
    1453           0 :         for ( sal_uInt16 j = 0; j < aTempPoly.GetSize(); j++ )
    1454             :         {
    1455           0 :             aRetval.append(basegfx::B2DPoint(aTempPoly[ j ].X(), aTempPoly[ j ].Y()));
    1456             :         }
    1457             :     }
    1458             : 
    1459           0 :     return aRetval;
    1460             : }
    1461             : 
    1462           0 : void EnhancedCustomShape2d::CreateSubPath( sal_uInt16& rSrcPt, sal_uInt16& rSegmentInd, std::vector< SdrPathObj* >& rObjectList,
    1463             :                                            const sal_Bool bLineGeometryNeededOnly,
    1464             :                                            const sal_Bool bSortFilledObjectsToBack,
    1465             :                                            sal_Int32 nIndex )
    1466             : {
    1467           0 :     sal_Bool bNoFill = sal_False;
    1468           0 :     sal_Bool bNoStroke = sal_False;
    1469           0 :     double dBrightness = 1.0;
    1470             : 
    1471           0 :     basegfx::B2DPolyPolygon aNewB2DPolyPolygon;
    1472           0 :     basegfx::B2DPolygon aNewB2DPolygon;
    1473             : 
    1474           0 :     SetPathSize( nIndex );
    1475             : 
    1476           0 :     sal_Int32 nCoordSize = seqCoordinates.getLength();
    1477           0 :     sal_Int32 nSegInfoSize = seqSegments.getLength();
    1478           0 :     if ( !nSegInfoSize )
    1479             :     {
    1480           0 :         const EnhancedCustomShapeParameterPair* pTmp = seqCoordinates.getArray();
    1481             : 
    1482           0 :         for ( sal_Int32 nPtNum(0L); nPtNum < nCoordSize; nPtNum++ )
    1483             :         {
    1484           0 :             const Point aTempPoint(GetPoint( *pTmp++, sal_True, sal_True ));
    1485           0 :             aNewB2DPolygon.append(basegfx::B2DPoint(aTempPoint.X(), aTempPoint.Y()));
    1486             :         }
    1487             : 
    1488           0 :         aNewB2DPolygon.setClosed(true);
    1489             :     }
    1490             :     else
    1491             :     {
    1492           0 :         for ( ;rSegmentInd < nSegInfoSize; )
    1493             :         {
    1494           0 :             sal_Int16 nCommand = seqSegments[ rSegmentInd ].Command;
    1495           0 :             sal_Int16 nPntCount= seqSegments[ rSegmentInd++ ].Count;
    1496             : 
    1497           0 :             switch ( nCommand )
    1498             :             {
    1499             :                 case NOFILL :
    1500           0 :                     bNoFill = sal_True;
    1501           0 :                 break;
    1502             :                 case NOSTROKE :
    1503           0 :                     bNoStroke = sal_True;
    1504           0 :                 break;
    1505             :                 case DARKEN :
    1506           0 :                     dBrightness = 0.66666666;
    1507           0 :                     break;
    1508             :                 case DARKENLESS :
    1509           0 :                     dBrightness = 0.83333333;
    1510           0 :                     break;
    1511             :                 case LIGHTEN :
    1512           0 :                     dBrightness = 1.16666666;
    1513           0 :                     break;
    1514             :                 case LIGHTENLESS :
    1515           0 :                     dBrightness = 1.33333333;
    1516           0 :                     break;
    1517             :                 case MOVETO :
    1518             :                 {
    1519           0 :                     if(aNewB2DPolygon.count() > 1L)
    1520             :                     {
    1521             :                         // #i76201# Add conversion to closed polygon when first and last points are equal
    1522           0 :                         basegfx::tools::checkClosed(aNewB2DPolygon);
    1523           0 :                         aNewB2DPolyPolygon.append(aNewB2DPolygon);
    1524             :                     }
    1525             : 
    1526           0 :                     aNewB2DPolygon.clear();
    1527             : 
    1528           0 :                     if ( rSrcPt < nCoordSize )
    1529             :                     {
    1530           0 :                         const Point aTempPoint(GetPoint( seqCoordinates[ rSrcPt++ ], sal_True, sal_True ));
    1531             :                         OSL_TRACE("moveTo: %d,%d", aTempPoint.X(), aTempPoint.Y());
    1532           0 :                         aNewB2DPolygon.append(basegfx::B2DPoint(aTempPoint.X(), aTempPoint.Y()));
    1533             :                     }
    1534             :                 }
    1535           0 :                 break;
    1536             :                 case ENDSUBPATH :
    1537           0 :                 break;
    1538             :                 case CLOSESUBPATH :
    1539             :                 {
    1540           0 :                     if(aNewB2DPolygon.count())
    1541             :                     {
    1542           0 :                         if(aNewB2DPolygon.count() > 1L)
    1543             :                         {
    1544           0 :                             aNewB2DPolygon.setClosed(true);
    1545           0 :                             aNewB2DPolyPolygon.append(aNewB2DPolygon);
    1546             :                         }
    1547             : 
    1548           0 :                         aNewB2DPolygon.clear();
    1549             :                     }
    1550             :                 }
    1551           0 :                 break;
    1552             :                 case CURVETO :
    1553             :                 {
    1554           0 :                     for ( sal_uInt16 i = 0; ( i < nPntCount ) && ( ( rSrcPt + 2 ) < nCoordSize ); i++ )
    1555             :                     {
    1556           0 :                         const Point aControlA(GetPoint( seqCoordinates[ rSrcPt++ ], sal_True, sal_True ));
    1557           0 :                         const Point aControlB(GetPoint( seqCoordinates[ rSrcPt++ ], sal_True, sal_True ));
    1558           0 :                         const Point aEnd(GetPoint( seqCoordinates[ rSrcPt++ ], sal_True, sal_True ));
    1559             : 
    1560             :                         DBG_ASSERT(aNewB2DPolygon.count(), "EnhancedCustomShape2d::CreateSubPath: Error in adding control point (!)");
    1561             :                         aNewB2DPolygon.appendBezierSegment(
    1562           0 :                             basegfx::B2DPoint(aControlA.X(), aControlA.Y()),
    1563           0 :                             basegfx::B2DPoint(aControlB.X(), aControlB.Y()),
    1564           0 :                             basegfx::B2DPoint(aEnd.X(), aEnd.Y()));
    1565             :                     }
    1566             :                 }
    1567           0 :                 break;
    1568             : 
    1569             :                 case ANGLEELLIPSE :
    1570             :                 {
    1571           0 :                     if(aNewB2DPolygon.count() > 1L)
    1572             :                     {
    1573             :                         // #i76201# Add conversion to closed polygon when first and last points are equal
    1574           0 :                         basegfx::tools::checkClosed(aNewB2DPolygon);
    1575           0 :                         aNewB2DPolyPolygon.append(aNewB2DPolygon);
    1576             :                     }
    1577             : 
    1578           0 :                     aNewB2DPolygon.clear();
    1579             :                 }
    1580             :                 case ANGLEELLIPSETO :
    1581             :                 {
    1582           0 :                     for ( sal_uInt16 i = 0; ( i < nPntCount ) && ( ( rSrcPt + 2 ) < nCoordSize ); i++ )
    1583             :                     {
    1584             :                         // create a circle
    1585           0 :                         Point _aCenter( GetPoint( seqCoordinates[ rSrcPt ], sal_True, sal_True ) );
    1586             :                         double fWidth, fHeight;
    1587           0 :                         GetParameter( fWidth,  seqCoordinates[ rSrcPt + 1 ].First, sal_True, sal_False );
    1588           0 :                         GetParameter( fHeight,  seqCoordinates[ rSrcPt + 1 ].Second, sal_False, sal_True );
    1589           0 :                         fWidth *= fXScale;
    1590           0 :                         fHeight*= fYScale;
    1591           0 :                         Point aP( (sal_Int32)( _aCenter.X() - fWidth ), (sal_Int32)( _aCenter.Y() - fHeight ) );
    1592           0 :                         Size  aS( (sal_Int32)( fWidth * 2.0 ), (sal_Int32)( fHeight * 2.0 ) );
    1593           0 :                         Rectangle aRect( aP, aS );
    1594           0 :                         if ( aRect.GetWidth() && aRect.GetHeight() )
    1595             :                         {
    1596             :                             double fStartAngle, fEndAngle;
    1597           0 :                             GetParameter( fStartAngle, seqCoordinates[ rSrcPt + 2 ].First,  sal_False, sal_False );
    1598           0 :                             GetParameter( fEndAngle  , seqCoordinates[ rSrcPt + 2 ].Second, sal_False, sal_False );
    1599             : 
    1600           0 :                             if ( ((sal_Int32)fStartAngle % 360) != ((sal_Int32)fEndAngle % 360) )
    1601             :                             {
    1602           0 :                                 if ( (sal_Int32)fStartAngle & 0x7fff0000 )  // SJ: if the angle was imported from our escher import, then the
    1603           0 :                                     fStartAngle /= 65536.0;                 // value is shifted by 16. TODO: already change the fixed float to a
    1604           0 :                                 if ( (sal_Int32)fEndAngle & 0x7fff0000 )    // double in the import filter
    1605             :                                 {
    1606           0 :                                     fEndAngle /= 65536.0;
    1607           0 :                                     fEndAngle = fEndAngle + fStartAngle;
    1608           0 :                                     if ( fEndAngle < 0 )
    1609             :                                     {   // in the binary filter the endangle is the amount
    1610           0 :                                         double fTemp = fStartAngle;
    1611           0 :                                         fStartAngle = fEndAngle;
    1612           0 :                                         fEndAngle = fTemp;
    1613             :                                     }
    1614             :                                 }
    1615           0 :                                 double fCenterX = aRect.Center().X();
    1616           0 :                                 double fCenterY = aRect.Center().Y();
    1617           0 :                                 double fx1 = ( cos( fStartAngle * F_PI180 ) * 65536.0 * fXScale ) + fCenterX;
    1618           0 :                                 double fy1 = ( -sin( fStartAngle * F_PI180 ) * 65536.0 * fYScale ) + fCenterY;
    1619           0 :                                 double fx2 = ( cos( fEndAngle * F_PI180 ) * 65536.0 * fXScale ) + fCenterX;
    1620           0 :                                 double fy2 = ( -sin( fEndAngle * F_PI180 ) * 65536.0 * fYScale ) + fCenterY;
    1621           0 :                                 aNewB2DPolygon.append(CreateArc( aRect, Point( (sal_Int32)fx1, (sal_Int32)fy1 ), Point( (sal_Int32)fx2, (sal_Int32)fy2 ), sal_False));
    1622             :                             }
    1623             :                             else
    1624             :                             {   /* SJ: TODO: this block should be replaced sometimes, because the current point
    1625             :                                    is not set correct, it also does not use the correct moveto
    1626             :                                    point if ANGLEELLIPSETO was used, but the method CreateArc
    1627             :                                    is at the moment not able to draw full circles (if startangle is 0
    1628             :                                    and endangle 360 nothing is painted :-( */
    1629           0 :                                 sal_Int32 nXControl = (sal_Int32)((double)aRect.GetWidth() * 0.2835 );
    1630           0 :                                 sal_Int32 nYControl = (sal_Int32)((double)aRect.GetHeight() * 0.2835 );
    1631           0 :                                 Point aCenter( aRect.Center() );
    1632             : 
    1633             :                                 // append start point
    1634           0 :                                 aNewB2DPolygon.append(basegfx::B2DPoint(aCenter.X(), aRect.Top()));
    1635             : 
    1636             :                                 // append four bezier segments
    1637             :                                 aNewB2DPolygon.appendBezierSegment(
    1638           0 :                                     basegfx::B2DPoint(aCenter.X() + nXControl, aRect.Top()),
    1639           0 :                                     basegfx::B2DPoint(aRect.Right(), aCenter.Y() - nYControl),
    1640           0 :                                     basegfx::B2DPoint(aRect.Right(), aCenter.Y()));
    1641             : 
    1642             :                                 aNewB2DPolygon.appendBezierSegment(
    1643           0 :                                     basegfx::B2DPoint(aRect.Right(), aCenter.Y() + nYControl),
    1644           0 :                                     basegfx::B2DPoint(aCenter.X() + nXControl, aRect.Bottom()),
    1645           0 :                                     basegfx::B2DPoint(aCenter.X(), aRect.Bottom()));
    1646             : 
    1647             :                                 aNewB2DPolygon.appendBezierSegment(
    1648           0 :                                     basegfx::B2DPoint(aCenter.X() - nXControl, aRect.Bottom()),
    1649           0 :                                     basegfx::B2DPoint(aRect.Left(), aCenter.Y() + nYControl),
    1650           0 :                                     basegfx::B2DPoint(aRect.Left(), aCenter.Y()));
    1651             : 
    1652             :                                 aNewB2DPolygon.appendBezierSegment(
    1653           0 :                                     basegfx::B2DPoint(aRect.Left(), aCenter.Y() - nYControl),
    1654           0 :                                     basegfx::B2DPoint(aCenter.X() - nXControl, aRect.Top()),
    1655           0 :                                     basegfx::B2DPoint(aCenter.X(), aRect.Top()));
    1656             : 
    1657             :                                 // close, rescue last controlpoint, remove double last point
    1658           0 :                                 basegfx::tools::closeWithGeometryChange(aNewB2DPolygon);
    1659             :                             }
    1660             :                         }
    1661           0 :                         rSrcPt += 3;
    1662             :                     }
    1663             :                 }
    1664           0 :                 break;
    1665             : 
    1666             :                 case QUADRATICCURVETO :
    1667           0 :                     for ( sal_Int32 i(0L); ( i < nPntCount ) && ( rSrcPt + 1 < nCoordSize ); i++ )
    1668             :                     {
    1669           0 :                         const Point aControl(GetPoint( seqCoordinates[ rSrcPt++ ], sal_True, sal_True ));
    1670           0 :                         const Point aEnd(GetPoint( seqCoordinates[ rSrcPt++ ], sal_True, sal_True ));
    1671             : 
    1672             :                         DBG_ASSERT(aNewB2DPolygon.count(), "EnhancedCustomShape2d::CreateSubPath: Error in adding control point (!)");
    1673           0 :                         basegfx::B2DPoint aStartPointB2D( aNewB2DPolygon.getB2DPoint(aNewB2DPolygon.count() - 1 ) );
    1674           0 :                         Point aStartPoint( aStartPointB2D.getX(), aStartPointB2D.getY() );
    1675             : 
    1676             :                         aNewB2DPolygon.appendBezierSegment(
    1677           0 :                             basegfx::B2DPoint(aStartPoint.X() + 2.0*(aControl.X() - aStartPoint.X())/3.0, aStartPoint.Y() + 2.0*(aControl.Y() - aStartPoint.Y())/3.0),
    1678           0 :                             basegfx::B2DPoint(aEnd.X() + 2.0*(aControl.X() - aEnd.X())/3.0, aEnd.Y() + 2.0*(aControl.Y() - aEnd.Y())/3.0),
    1679           0 :                             basegfx::B2DPoint(aEnd.X(), aEnd.Y()));
    1680           0 :                     }
    1681           0 :                     break;
    1682             : 
    1683             :                 case LINETO :
    1684             :                 {
    1685           0 :                     for ( sal_Int32 i(0L); ( i < nPntCount ) && ( rSrcPt < nCoordSize ); i++ )
    1686             :                     {
    1687           0 :                         const Point aTempPoint(GetPoint( seqCoordinates[ rSrcPt++ ], sal_True, sal_True ));
    1688             :                         OSL_TRACE("lineTo: %d,%d", aTempPoint.X(), aTempPoint.Y());
    1689           0 :                         aNewB2DPolygon.append(basegfx::B2DPoint(aTempPoint.X(), aTempPoint.Y()));
    1690             :                     }
    1691             :                 }
    1692           0 :                 break;
    1693             : 
    1694             :                 case ARC :
    1695             :                 case CLOCKWISEARC :
    1696             :                 {
    1697           0 :                     if(aNewB2DPolygon.count() > 1L)
    1698             :                     {
    1699             :                         // #i76201# Add conversion to closed polygon when first and last points are equal
    1700           0 :                         basegfx::tools::checkClosed(aNewB2DPolygon);
    1701           0 :                         aNewB2DPolyPolygon.append(aNewB2DPolygon);
    1702             :                     }
    1703             : 
    1704           0 :                     aNewB2DPolygon.clear();
    1705             :                 }
    1706             :                 case ARCTO :
    1707             :                 case CLOCKWISEARCTO :
    1708             :                 {
    1709           0 :                     sal_Bool bClockwise = ( nCommand == CLOCKWISEARC ) || ( nCommand == CLOCKWISEARCTO );
    1710           0 :                     sal_uInt32 nXor = bClockwise ? 3 : 2;
    1711           0 :                     for ( sal_uInt16 i = 0; ( i < nPntCount ) && ( ( rSrcPt + 3 ) < nCoordSize ); i++ )
    1712             :                     {
    1713           0 :                         Rectangle aRect( GetPoint( seqCoordinates[ rSrcPt ], sal_True, sal_True ), GetPoint( seqCoordinates[ rSrcPt + 1 ], sal_True, sal_True ) );
    1714           0 :                         if ( aRect.GetWidth() && aRect.GetHeight() )
    1715             :                         {
    1716           0 :                             Point aCenter( aRect.Center() );
    1717           0 :                             Point aStart( GetPoint( seqCoordinates[ (sal_uInt16)( rSrcPt + nXor ) ], sal_True, sal_True ) );
    1718           0 :                             Point aEnd( GetPoint( seqCoordinates[ (sal_uInt16)( rSrcPt + ( nXor ^ 1 ) ) ], sal_True, sal_True ) );
    1719           0 :                             aStart.X() = (sal_Int32)( ( (double)( aStart.X() - aCenter.X() ) ) ) + aCenter.X();
    1720           0 :                             aStart.Y() = (sal_Int32)( ( (double)( aStart.Y() - aCenter.Y() ) ) ) + aCenter.Y();
    1721           0 :                             aEnd.X() = (sal_Int32)( ( (double)( aEnd.X() - aCenter.X() ) ) ) + aCenter.X();
    1722           0 :                             aEnd.Y() = (sal_Int32)( ( (double)( aEnd.Y() - aCenter.Y() ) ) ) + aCenter.Y();
    1723           0 :                             aNewB2DPolygon.append(CreateArc( aRect, aStart, aEnd, bClockwise));
    1724             :                         }
    1725           0 :                         rSrcPt += 4;
    1726             :                     }
    1727             :                 }
    1728           0 :                 break;
    1729             : 
    1730             :                 case ARCANGLETO :
    1731             :                 {
    1732             :                     double fWR, fHR, fStartAngle, fSwingAngle;
    1733             : 
    1734           0 :                     for ( sal_uInt16 i = 0; ( i < nPntCount ) && ( rSrcPt + 1 < nCoordSize ); i++ )
    1735             :                     {
    1736           0 :                         GetParameter ( fWR, seqCoordinates[ (sal_uInt16)( rSrcPt ) ].First, sal_True, sal_False );
    1737           0 :                         GetParameter ( fHR, seqCoordinates[ (sal_uInt16)( rSrcPt ) ].Second, sal_False, sal_True );
    1738             : 
    1739           0 :                         GetParameter ( fStartAngle, seqCoordinates[ (sal_uInt16)( rSrcPt + 1) ].First, sal_False, sal_False );
    1740           0 :                         GetParameter ( fSwingAngle, seqCoordinates[ (sal_uInt16)( rSrcPt + 1 ) ].Second, sal_False, sal_False );
    1741             : 
    1742           0 :                         fWR *= fXScale;
    1743           0 :                         fHR *= fYScale;
    1744             : 
    1745           0 :                         fStartAngle *= F_PI180;
    1746           0 :                         fSwingAngle *= F_PI180;
    1747             : 
    1748             :                         OSL_TRACE("ARCANGLETO scale: %f x %f angles: %f, %f", fWR, fHR, fStartAngle, fSwingAngle);
    1749             : 
    1750           0 :                         sal_Bool bClockwise = fSwingAngle >= 0.0;
    1751             : 
    1752           0 :                         if (aNewB2DPolygon.count() > 0)
    1753             :                         {
    1754           0 :                             basegfx::B2DPoint aStartPointB2D( aNewB2DPolygon.getB2DPoint(aNewB2DPolygon.count() - 1 ) );
    1755           0 :                             Point aStartPoint( aStartPointB2D.getX(), aStartPointB2D.getY() );
    1756             : 
    1757           0 :                             double fT = atan2((fWR*sin(fStartAngle)), (fHR*cos(fStartAngle)));
    1758           0 :                             double fTE = atan2((fWR*sin(fStartAngle + fSwingAngle)), fHR*cos(fStartAngle + fSwingAngle));
    1759             : 
    1760             :                             OSL_TRACE("ARCANGLETO angles: %f, %f --> parameters: %f, %f", fStartAngle, fSwingAngle, fT, fTE );
    1761             : 
    1762           0 :                             Rectangle aRect ( Point ( aStartPoint.getX() - fWR*cos(fT) - fWR, aStartPoint.getY() - fHR*sin(fT) - fHR ),
    1763           0 :                                               Point ( aStartPoint.getX() - fWR*cos(fT) + fWR, aStartPoint.getY() - fHR*sin(fT) + fHR) );
    1764             : 
    1765           0 :                             Point aEndPoint ( aStartPoint.getX() - fWR*(cos(fT) - cos(fTE)), aStartPoint.getY() - fHR*(sin(fT) - sin(fTE)) );
    1766             : 
    1767             :                             OSL_TRACE("ARCANGLETO rect: %d, %d   x   %d, %d   start: %d, %d end: %d, %d clockwise: %d",
    1768             :                                       aRect.Left(), aRect.Top(), aRect.Right(), aRect.Bottom(),
    1769             :                                       aStartPoint.X(), aStartPoint.Y(), aEndPoint.X(), aEndPoint.Y(), bClockwise);
    1770           0 :                             aNewB2DPolygon.append(CreateArc( aRect, bClockwise ? aEndPoint : aStartPoint, bClockwise ? aStartPoint : aEndPoint, bClockwise, aStartPoint == aEndPoint && fSwingAngle > F_PI));
    1771             :                         }
    1772             : 
    1773           0 :                         rSrcPt += 2;
    1774             :                     }
    1775             :                 }
    1776           0 :                 break;
    1777             : 
    1778             :                 case ELLIPTICALQUADRANTX :
    1779             :                 case ELLIPTICALQUADRANTY :
    1780             :                 {
    1781           0 :                     bool bFirstDirection(true);
    1782           0 :                     basegfx::B2DPoint aControlPointA;
    1783           0 :                     basegfx::B2DPoint aControlPointB;
    1784             : 
    1785           0 :                     for ( sal_uInt16 i = 0; ( i < nPntCount ) && ( rSrcPt < nCoordSize ); i++ )
    1786             :                     {
    1787           0 :                         sal_uInt32 nModT = ( nCommand == ELLIPTICALQUADRANTX ) ? 1 : 0;
    1788           0 :                         Point aCurrent( GetPoint( seqCoordinates[ rSrcPt ], sal_True, sal_True ) );
    1789             : 
    1790           0 :                         if ( rSrcPt )   // we need a previous point
    1791             :                         {
    1792           0 :                             Point aPrev( GetPoint( seqCoordinates[ rSrcPt - 1 ], sal_True, sal_True ) );
    1793             :                             sal_Int32 nX, nY;
    1794           0 :                             nX = aCurrent.X() - aPrev.X();
    1795           0 :                             nY = aCurrent.Y() - aPrev.Y();
    1796           0 :                             if ( ( nY ^ nX ) & 0x80000000 )
    1797             :                             {
    1798           0 :                                 if ( !i )
    1799           0 :                                     bFirstDirection = true;
    1800           0 :                                 else if ( !bFirstDirection )
    1801           0 :                                     nModT ^= 1;
    1802             :                             }
    1803             :                             else
    1804             :                             {
    1805           0 :                                 if ( !i )
    1806           0 :                                     bFirstDirection = false;
    1807           0 :                                 else if ( bFirstDirection )
    1808           0 :                                     nModT ^= 1;
    1809             :                             }
    1810           0 :                             if ( nModT )            // get the right corner
    1811             :                             {
    1812           0 :                                 nX = aCurrent.X();
    1813           0 :                                 nY = aPrev.Y();
    1814             :                             }
    1815             :                             else
    1816             :                             {
    1817           0 :                                 nX = aPrev.X();
    1818           0 :                                 nY = aCurrent.Y();
    1819             :                             }
    1820           0 :                             sal_Int32 nXVec = ( nX - aPrev.X() ) >> 1;
    1821           0 :                             sal_Int32 nYVec = ( nY - aPrev.Y() ) >> 1;
    1822           0 :                             Point aControl1( aPrev.X() + nXVec, aPrev.Y() + nYVec );
    1823             : 
    1824           0 :                             aControlPointA = basegfx::B2DPoint(aControl1.X(), aControl1.Y());
    1825             : 
    1826           0 :                             nXVec = ( nX - aCurrent.X() ) >> 1;
    1827           0 :                             nYVec = ( nY - aCurrent.Y() ) >> 1;
    1828           0 :                             Point aControl2( aCurrent.X() + nXVec, aCurrent.Y() + nYVec );
    1829             : 
    1830           0 :                             aControlPointB = basegfx::B2DPoint(aControl2.X(), aControl2.Y());
    1831             : 
    1832             :                             aNewB2DPolygon.appendBezierSegment(
    1833             :                                 aControlPointA,
    1834             :                                 aControlPointB,
    1835           0 :                                 basegfx::B2DPoint(aCurrent.X(), aCurrent.Y()));
    1836             :                         }
    1837             :                         else
    1838             :                         {
    1839           0 :                             aNewB2DPolygon.append(basegfx::B2DPoint(aCurrent.X(), aCurrent.Y()));
    1840             :                         }
    1841             : 
    1842           0 :                         rSrcPt++;
    1843           0 :                     }
    1844             :                 }
    1845           0 :                 break;
    1846             : 
    1847             : #ifdef DBG_CUSTOMSHAPE
    1848             :                 case UNKNOWN :
    1849             :                 default :
    1850             :                 {
    1851             :                     rtl::OStringBuffer aString(RTL_CONSTASCII_STRINGPARAM(
    1852             :                         "CustomShapes::unknown PolyFlagValue :"));
    1853             :                     aString.append(static_cast<sal_Int32>(nCommand));
    1854             :                     OSL_FAIL(aString.getStr());
    1855             :                 }
    1856             :                 break;
    1857             : #endif
    1858             :             }
    1859           0 :             if ( nCommand == ENDSUBPATH )
    1860           0 :                 break;
    1861             :         }
    1862             :     }
    1863           0 :     if ( rSegmentInd == nSegInfoSize )
    1864           0 :         rSegmentInd++;
    1865             : 
    1866           0 :     if(aNewB2DPolygon.count() > 1L)
    1867             :     {
    1868             :         // #i76201# Add conversion to closed polygon when first and last points are equal
    1869           0 :         basegfx::tools::checkClosed(aNewB2DPolygon);
    1870           0 :         aNewB2DPolyPolygon.append(aNewB2DPolygon);
    1871             :     }
    1872             : 
    1873           0 :     if(aNewB2DPolyPolygon.count())
    1874             :     {
    1875           0 :         if( !bLineGeometryNeededOnly )
    1876             :         {
    1877             :             // hack aNewB2DPolyPolygon to fill logic rect - this is
    1878             :             // needed to produce gradient fills that look like mso
    1879           0 :             aNewB2DPolygon.clear();
    1880           0 :             aNewB2DPolygon.append(basegfx::B2DPoint(0,0));
    1881           0 :             aNewB2DPolygon.setClosed(true);
    1882           0 :             aNewB2DPolyPolygon.append(aNewB2DPolygon);
    1883             : 
    1884           0 :             aNewB2DPolygon.clear();
    1885           0 :             aNewB2DPolygon.append(basegfx::B2DPoint(aLogicRect.GetWidth(),
    1886           0 :                                                     aLogicRect.GetHeight()));
    1887           0 :             aNewB2DPolygon.setClosed(true);
    1888           0 :             aNewB2DPolyPolygon.append(aNewB2DPolygon);
    1889             :         }
    1890             : 
    1891             :         // #i37011#
    1892           0 :         bool bForceCreateTwoObjects(false);
    1893             : 
    1894           0 :         if(!bSortFilledObjectsToBack && !aNewB2DPolyPolygon.isClosed() && !bNoStroke)
    1895             :         {
    1896           0 :             bForceCreateTwoObjects = true;
    1897             :         }
    1898             : 
    1899           0 :         if(bLineGeometryNeededOnly)
    1900             :         {
    1901           0 :             bForceCreateTwoObjects = true;
    1902           0 :             bNoFill = true;
    1903           0 :             bNoStroke = false;
    1904             :         }
    1905             : 
    1906           0 :         if(bForceCreateTwoObjects || bSortFilledObjectsToBack)
    1907             :         {
    1908           0 :             if(bFilled && !bNoFill)
    1909             :             {
    1910           0 :                 basegfx::B2DPolyPolygon aClosedPolyPolygon(aNewB2DPolyPolygon);
    1911           0 :                 aClosedPolyPolygon.setClosed(true);
    1912           0 :                 SdrPathObj* pFill = new SdrPathObj(OBJ_POLY, aClosedPolyPolygon, dBrightness);
    1913           0 :                 SfxItemSet aTempSet(*this);
    1914           0 :                 aTempSet.Put(SdrShadowItem(sal_False));
    1915           0 :                 aTempSet.Put(XLineStyleItem(XLINE_NONE));
    1916           0 :                 pFill->SetMergedItemSet(aTempSet);
    1917           0 :                 rObjectList.push_back(pFill);
    1918             :             }
    1919             : 
    1920           0 :             if(!bNoStroke)
    1921             :             {
    1922             :                 // there is no reason to use OBJ_PLIN here when the polygon is actually closed,
    1923             :                 // the non-fill is defined by XFILL_NONE. Since SdrPathObj::ImpForceKind() needs
    1924             :                 // to correct the polygon (here: open it) using the type, the last edge may get lost.
    1925             :                 // Thus, use a type that fits the polygon
    1926             :                 SdrPathObj* pStroke = new SdrPathObj(
    1927           0 :                     aNewB2DPolyPolygon.isClosed() ? OBJ_POLY : OBJ_PLIN,
    1928           0 :                     aNewB2DPolyPolygon, dBrightness);
    1929           0 :                 SfxItemSet aTempSet(*this);
    1930           0 :                 aTempSet.Put(SdrShadowItem(sal_False));
    1931           0 :                 aTempSet.Put(XFillStyleItem(XFILL_NONE));
    1932           0 :                 pStroke->SetMergedItemSet(aTempSet);
    1933           0 :                 rObjectList.push_back(pStroke);
    1934           0 :             }
    1935             :         }
    1936             :         else
    1937             :         {
    1938           0 :             SdrPathObj* pObj = 0;
    1939           0 :             SfxItemSet aTempSet(*this);
    1940           0 :             aTempSet.Put(SdrShadowItem(sal_False));
    1941             : 
    1942           0 :             if(bNoFill)
    1943             :             {
    1944             :                 // see comment above about OBJ_PLIN
    1945             :                 pObj = new SdrPathObj(
    1946           0 :                     aNewB2DPolyPolygon.isClosed() ? OBJ_POLY : OBJ_PLIN,
    1947           0 :                     aNewB2DPolyPolygon, dBrightness);
    1948           0 :                 aTempSet.Put(XFillStyleItem(XFILL_NONE));
    1949             :             }
    1950             :             else
    1951             :             {
    1952           0 :                 aNewB2DPolyPolygon.setClosed(true);
    1953           0 :                 pObj = new SdrPathObj(OBJ_POLY, aNewB2DPolyPolygon, dBrightness);
    1954             :             }
    1955             : 
    1956           0 :             if(bNoStroke)
    1957             :             {
    1958           0 :                 aTempSet.Put(XLineStyleItem(XLINE_NONE));
    1959             :             }
    1960             : 
    1961           0 :             if(pObj)
    1962             :             {
    1963           0 :                 pObj->SetMergedItemSet(aTempSet);
    1964           0 :                 rObjectList.push_back(pObj);
    1965           0 :             }
    1966             :         }
    1967           0 :     }
    1968           0 : }
    1969             : 
    1970           0 : void CorrectCalloutArrows( MSO_SPT eSpType, sal_uInt32 nLineObjectCount, std::vector< SdrPathObj* >& vObjectList )
    1971             : {
    1972           0 :     sal_Bool bAccent = sal_False;
    1973           0 :     switch( eSpType )
    1974             :     {
    1975             :         case mso_sptCallout1 :
    1976             :         case mso_sptBorderCallout1 :
    1977             :         case mso_sptCallout90 :
    1978             :         case mso_sptBorderCallout90 :
    1979             :         default:
    1980           0 :         break;
    1981             : 
    1982             :         case mso_sptAccentCallout1 :
    1983             :         case mso_sptAccentBorderCallout1 :
    1984             :         case mso_sptAccentCallout90 :
    1985             :         case mso_sptAccentBorderCallout90 :
    1986             :         {
    1987           0 :             sal_uInt32 i, nLine = 0;
    1988           0 :             for ( i = 0; i < vObjectList.size(); i++ )
    1989             :             {
    1990           0 :                 SdrPathObj* pObj( vObjectList[ i ] );
    1991           0 :                 if(pObj->IsLine())
    1992             :                 {
    1993           0 :                     nLine++;
    1994           0 :                     if ( nLine == nLineObjectCount )
    1995             :                     {
    1996           0 :                         pObj->ClearMergedItem( XATTR_LINESTART );
    1997           0 :                         pObj->ClearMergedItem( XATTR_LINEEND );
    1998             :                     }
    1999             :                 }
    2000             :             }
    2001             :         }
    2002           0 :         break;
    2003             : 
    2004             :         // switch start & end
    2005             :         case mso_sptAccentCallout2 :
    2006             :         case mso_sptAccentBorderCallout2 :
    2007           0 :             bAccent = sal_True;
    2008             :         case mso_sptCallout2 :
    2009             :         case mso_sptBorderCallout2 :
    2010             :         {
    2011           0 :             sal_uInt32 i, nLine = 0;
    2012           0 :             for ( i = 0; i < vObjectList.size(); i++ )
    2013             :             {
    2014           0 :                 SdrPathObj* pObj( vObjectList[ i ] );
    2015           0 :                 if(pObj->IsLine())
    2016             :                 {
    2017           0 :                     nLine++;
    2018           0 :                     if ( nLine == 1 )
    2019           0 :                         pObj->ClearMergedItem( XATTR_LINEEND );
    2020           0 :                     else if ( ( bAccent && ( nLine == nLineObjectCount - 1 ) ) || ( !bAccent && ( nLine == nLineObjectCount ) ) )
    2021           0 :                         pObj->ClearMergedItem( XATTR_LINESTART );
    2022             :                     else
    2023             :                     {
    2024           0 :                         pObj->ClearMergedItem( XATTR_LINESTART );
    2025           0 :                         pObj->ClearMergedItem( XATTR_LINEEND );
    2026             :                     }
    2027             :                 }
    2028             :             }
    2029             :         }
    2030           0 :         break;
    2031             : 
    2032             :         case mso_sptAccentCallout3 :
    2033             :         case mso_sptAccentBorderCallout3 :
    2034           0 :             bAccent = sal_False;
    2035             :         case mso_sptCallout3 :
    2036             :         case mso_sptBorderCallout3 :
    2037             :         {
    2038           0 :             sal_uInt32 i, nLine = 0;
    2039           0 :             for ( i = 0; i < vObjectList.size(); i++ )
    2040             :             {
    2041           0 :                 SdrPathObj* pObj( vObjectList[ i ] );
    2042           0 :                 if(pObj->IsLine())
    2043             :                 {
    2044           0 :                     if ( nLine )
    2045             :                     {
    2046           0 :                         pObj->ClearMergedItem( XATTR_LINESTART );
    2047           0 :                         pObj->ClearMergedItem( XATTR_LINEEND );
    2048             :                     }
    2049             :                     else
    2050           0 :                         EnhancedCustomShape2d::SwapStartAndEndArrow( pObj );
    2051             : 
    2052           0 :                     nLine++;
    2053             :                 }
    2054             :             }
    2055             :         }
    2056           0 :         break;
    2057             :     }
    2058           0 : }
    2059             : 
    2060           0 : void EnhancedCustomShape2d::AdaptObjColor(SdrPathObj& rObj, const SfxItemSet& rCustomShapeSet,
    2061             :                                           sal_uInt32& nColorIndex, sal_uInt32 nColorCount)
    2062             : {
    2063           0 :     if ( !rObj.IsLine() )
    2064             :     {
    2065           0 :         const XFillStyle eFillStyle = ((const XFillStyleItem&)rObj.GetMergedItem(XATTR_FILLSTYLE)).GetValue();
    2066           0 :         switch( eFillStyle )
    2067             :         {
    2068             :             default:
    2069             :             case XFILL_SOLID:
    2070             :             {
    2071           0 :                 Color aFillColor;
    2072           0 :                 if ( nColorCount || rObj.GetBrightness() != 1.0 )
    2073             :                 {
    2074             :                     aFillColor = GetColorData(
    2075           0 :                         ((XFillColorItem&)rCustomShapeSet.Get( XATTR_FILLCOLOR )).GetColorValue(),
    2076           0 :                         std::min(nColorIndex, nColorCount-1), rObj.GetBrightness() );
    2077           0 :                     rObj.SetMergedItem( XFillColorItem( String(), aFillColor ) );
    2078             :                 }
    2079             :                 break;
    2080             :             }
    2081             :             case XFILL_GRADIENT:
    2082             :             {
    2083           0 :                 XGradient aXGradient(((const XFillGradientItem&)rObj.GetMergedItem(XATTR_FILLGRADIENT)).GetGradientValue());
    2084           0 :                 if ( nColorCount || rObj.GetBrightness() != 1.0 )
    2085             :                 {
    2086             :                     aXGradient.SetStartColor(
    2087             :                         GetColorData(
    2088             :                             aXGradient.GetStartColor(),
    2089           0 :                             std::min(nColorIndex, nColorCount-1), rObj.GetBrightness() ));
    2090             :                     aXGradient.SetEndColor(
    2091             :                         GetColorData(
    2092             :                             aXGradient.GetEndColor(),
    2093           0 :                             std::min(nColorIndex, nColorCount-1), rObj.GetBrightness() ));
    2094             :                 }
    2095             : 
    2096           0 :                 rObj.SetMergedItem( XFillGradientItem( String(), aXGradient ) );
    2097             :                 break;
    2098             :             }
    2099             :             case XFILL_HATCH:
    2100             :             {
    2101           0 :                 XHatch aXHatch(((const XFillHatchItem&)rObj.GetMergedItem(XATTR_FILLHATCH)).GetHatchValue());
    2102           0 :                 if ( nColorCount || rObj.GetBrightness() != 1.0 )
    2103             :                 {
    2104             :                     aXHatch.SetColor(
    2105             :                         GetColorData(
    2106             :                             aXHatch.GetColor(),
    2107           0 :                             std::min(nColorIndex, nColorCount-1), rObj.GetBrightness() ));
    2108             :                 }
    2109             : 
    2110           0 :                 rObj.SetMergedItem( XFillHatchItem( String(), aXHatch ) );
    2111             :                 break;
    2112             :             }
    2113             :             case XFILL_BITMAP:
    2114             :             {
    2115           0 :                 Bitmap aBitmap(((const XFillBitmapItem&)rObj.GetMergedItem(XATTR_FILLBITMAP)).GetBitmapValue().GetBitmap());
    2116           0 :                 if ( nColorCount || rObj.GetBrightness() != 1.0 )
    2117             :                 {
    2118             :                     aBitmap.Adjust(
    2119             :                         static_cast< short > ( GetLuminanceChange(
    2120           0 :                             std::min(nColorIndex, nColorCount-1))));
    2121             :                 }
    2122             : 
    2123           0 :                 rObj.SetMergedItem( XFillBitmapItem( String(), aBitmap ) );
    2124           0 :                 break;
    2125             :             }
    2126             :         }
    2127             : 
    2128           0 :         if ( nColorIndex < nColorCount )
    2129           0 :             nColorIndex++;
    2130             :     }
    2131           0 : }
    2132             : 
    2133           0 : SdrObject* EnhancedCustomShape2d::CreatePathObj( sal_Bool bLineGeometryNeededOnly )
    2134             : {
    2135           0 :     sal_Int32 nCoordSize = seqCoordinates.getLength();
    2136           0 :     if ( !nCoordSize )
    2137           0 :         return NULL;
    2138             : 
    2139           0 :     sal_uInt16 nSrcPt = 0;
    2140           0 :     sal_uInt16 nSegmentInd = 0;
    2141             : 
    2142           0 :     std::vector< SdrPathObj* > vObjectList;
    2143           0 :     sal_Bool bSortFilledObjectsToBack = SortFilledObjectsToBackByDefault( eSpType );
    2144             : 
    2145           0 :     sal_Int32 nSubPathIndex = 0;
    2146             : 
    2147           0 :     while( nSegmentInd <= seqSegments.getLength() )
    2148             :     {
    2149           0 :         CreateSubPath( nSrcPt, nSegmentInd, vObjectList, bLineGeometryNeededOnly, bSortFilledObjectsToBack, nSubPathIndex );
    2150           0 :         nSubPathIndex ++;
    2151             :     }
    2152             : 
    2153           0 :     SdrObject* pRet = NULL;
    2154             :     sal_uInt32 i;
    2155             : 
    2156           0 :     if ( !vObjectList.empty() )
    2157             :     {
    2158           0 :         const SfxItemSet& rCustomShapeSet = pCustomShapeObj->GetMergedItemSet();
    2159           0 :         Color           aFillColor;
    2160           0 :         sal_uInt32      nColorCount = nColorData >> 28;
    2161           0 :         sal_uInt32      nColorIndex = 0;
    2162             : 
    2163             :         // #i37011# remove invisible objects
    2164           0 :         if(!vObjectList.empty())
    2165             :         {
    2166           0 :             std::vector< SdrPathObj* > vTempList;
    2167             : 
    2168           0 :             for(i = 0L; i < vObjectList.size(); i++)
    2169             :             {
    2170           0 :                 SdrPathObj* pObj(vObjectList[i]);
    2171           0 :                 const XLineStyle eLineStyle = ((const XLineStyleItem&)pObj->GetMergedItem(XATTR_LINESTYLE)).GetValue();
    2172           0 :                 const XFillStyle eFillStyle = ((const XFillStyleItem&)pObj->GetMergedItem(XATTR_FILLSTYLE)).GetValue();
    2173             : 
    2174             :                 //SJ: #i40600# if bLineGeometryNeededOnly is set linystyle does not matter
    2175           0 :                 if( !bLineGeometryNeededOnly && ( XLINE_NONE == eLineStyle ) && ( XFILL_NONE == eFillStyle ) )
    2176           0 :                     delete pObj;
    2177             :                 else
    2178           0 :                     vTempList.push_back(pObj);
    2179             :             }
    2180             : 
    2181           0 :             vObjectList = vTempList;
    2182             :         }
    2183             : 
    2184           0 :         if(1L == vObjectList.size())
    2185             :         {
    2186             :             // a single object, correct some values
    2187           0 :             AdaptObjColor(*vObjectList[0L],rCustomShapeSet,nColorIndex,nColorCount);
    2188             :         }
    2189             :         else
    2190             :         {
    2191           0 :             sal_Int32 nLineObjectCount = 0;
    2192           0 :             sal_Int32 nAreaObjectCount = 0;
    2193             : 
    2194             :             // correct some values and collect content data
    2195           0 :             for ( i = 0; i < vObjectList.size(); i++ )
    2196             :             {
    2197           0 :                 SdrPathObj* pObj( vObjectList[ i ] );
    2198             : 
    2199           0 :                 if(pObj->IsLine())
    2200             :                 {
    2201           0 :                     nLineObjectCount++;
    2202             :                 }
    2203             :                 else
    2204             :                 {
    2205           0 :                     nAreaObjectCount++;
    2206           0 :                     AdaptObjColor(*pObj,rCustomShapeSet,nColorIndex,nColorCount);
    2207             :                 }
    2208             :             }
    2209             : 
    2210             :             // #i88870# correct line arrows for callouts
    2211           0 :             if ( nLineObjectCount )
    2212           0 :                 CorrectCalloutArrows( eSpType, nLineObjectCount, vObjectList );
    2213             : 
    2214             :             // sort objects so that filled ones are in front. Necessary
    2215             :             // for some strange objects
    2216           0 :             if ( bSortFilledObjectsToBack )
    2217             :             {
    2218           0 :                 std::vector< SdrPathObj* > vTempList;
    2219             : 
    2220           0 :                 for ( i = 0; i < vObjectList.size(); i++ )
    2221             :                 {
    2222           0 :                     SdrPathObj* pObj( vObjectList[ i ] );
    2223             : 
    2224           0 :                     if ( !pObj->IsLine() )
    2225             :                     {
    2226           0 :                         vTempList.push_back(pObj);
    2227             :                     }
    2228             :                 }
    2229             : 
    2230           0 :                 for ( i = 0; i < vObjectList.size(); i++ )
    2231             :                 {
    2232           0 :                     SdrPathObj* pObj( vObjectList[ i ] );
    2233             : 
    2234           0 :                     if ( pObj->IsLine() )
    2235             :                     {
    2236           0 :                         vTempList.push_back(pObj);
    2237             :                     }
    2238             :                 }
    2239             : 
    2240           0 :                 vObjectList = vTempList;
    2241             :             }
    2242             :         }
    2243             :     }
    2244             : 
    2245             :     // #i37011#
    2246           0 :     if(!vObjectList.empty())
    2247             :     {
    2248             :         // copy remaining objects to pRet
    2249           0 :         if(vObjectList.size() > 1L)
    2250             :         {
    2251           0 :             pRet = new SdrObjGroup;
    2252             : 
    2253           0 :             for (i = 0L; i < vObjectList.size(); i++)
    2254             :             {
    2255           0 :                 SdrObject* pObj(vObjectList[i]);
    2256           0 :                 pRet->GetSubList()->NbcInsertObject(pObj);
    2257             :             }
    2258             :         }
    2259           0 :         else if(1L == vObjectList.size())
    2260             :         {
    2261           0 :             pRet = vObjectList[0L];
    2262             :         }
    2263             : 
    2264           0 :         if(pRet)
    2265             :         {
    2266             :             // move to target position
    2267           0 :             Rectangle aCurRect(pRet->GetSnapRect());
    2268           0 :             aCurRect.Move(aLogicRect.Left(), aLogicRect.Top());
    2269           0 :             pRet->NbcSetSnapRect(aCurRect);
    2270             :         }
    2271             :     }
    2272             : 
    2273           0 :     return pRet;
    2274             : }
    2275             : 
    2276           0 : SdrObject* EnhancedCustomShape2d::CreateObject( sal_Bool bLineGeometryNeededOnly )
    2277             : {
    2278           0 :     SdrObject* pRet = NULL;
    2279             : 
    2280           0 :     if ( eSpType == mso_sptRectangle )
    2281             :     {
    2282           0 :         pRet = new SdrRectObj( aLogicRect );
    2283           0 :         pRet->SetMergedItemSet( *this );
    2284             :     }
    2285           0 :     if ( !pRet )
    2286           0 :         pRet = CreatePathObj( bLineGeometryNeededOnly );
    2287             : 
    2288           0 :     return pRet;
    2289             : }
    2290             : 
    2291           0 : void EnhancedCustomShape2d::ApplyGluePoints( SdrObject* pObj )
    2292             : {
    2293           0 :     if ( pObj && seqGluePoints.getLength() )
    2294             :     {
    2295           0 :         sal_uInt32 i, nCount = seqGluePoints.getLength();
    2296           0 :         for ( i = 0; i < nCount; i++ )
    2297             :         {
    2298           0 :             SdrGluePoint aGluePoint;
    2299             : 
    2300           0 :             aGluePoint.SetPos( GetPoint( seqGluePoints[ i ], sal_True, sal_True ) );
    2301           0 :             aGluePoint.SetPercent( sal_False );
    2302           0 :             aGluePoint.SetAlign( SDRVERTALIGN_TOP | SDRHORZALIGN_LEFT );
    2303           0 :             aGluePoint.SetEscDir( SDRESC_SMART );
    2304           0 :             SdrGluePointList* pList = pObj->ForceGluePointList();
    2305           0 :             if( pList )
    2306           0 :                 /* sal_uInt16 nId = */ pList->Insert( aGluePoint );
    2307             :         }
    2308             :     }
    2309           0 : }
    2310             : 
    2311           0 : bool EnhancedCustomShape2d::IsPostRotate() const
    2312             : {
    2313           0 :     return pCustomShapeObj->ISA( SdrObjCustomShape ) ? ((SdrObjCustomShape*)pCustomShapeObj)->IsPostRotate() : false;
    2314             : }
    2315             : 
    2316           0 : SdrObject* EnhancedCustomShape2d::CreateLineGeometry()
    2317             : {
    2318           0 :     return CreateObject( sal_True );
    2319             : }
    2320             : 
    2321             : 
    2322             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10