LCOV - code coverage report
Current view: top level - svx/source/customshapes - EnhancedCustomShape2d.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 337 1216 27.7 %
Date: 2012-08-25 Functions: 14 33 42.4 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 287 1933 14.8 %

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

Generated by: LCOV version 1.10