LCOV - code coverage report
Current view: top level - filter/source/msfilter - escherex.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 825 2799 29.5 %
Date: 2012-08-25 Functions: 78 133 58.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 594 4044 14.7 %

           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 "eschesdo.hxx"
      30                 :            : #include <filter/msfilter/escherex.hxx>
      31                 :            : #include <svx/unoapi.hxx>
      32                 :            : #include <svx/svdobj.hxx>
      33                 :            : #include <svx/svdoashp.hxx>
      34                 :            : #include <svx/svdoole2.hxx>
      35                 :            : #include <svx/svdmodel.hxx>
      36                 :            : #include <vcl/gradient.hxx>
      37                 :            : #include <vcl/graph.hxx>
      38                 :            : #include <vcl/cvtgrf.hxx>
      39                 :            : #include <vcl/svapp.hxx>
      40                 :            : #include <vcl/wrkwin.hxx>
      41                 :            : #include <tools/stream.hxx>
      42                 :            : #include <tools/zcodec.hxx>
      43                 :            : #include <svx/svdopath.hxx>
      44                 :            : #include <stdlib.h>
      45                 :            : #include <svtools/filter.hxx>
      46                 :            : #include "svx/EnhancedCustomShapeTypeNames.hxx"
      47                 :            : #include "svx/EnhancedCustomShapeGeometry.hxx"
      48                 :            : #include <svx/EnhancedCustomShapeFunctionParser.hxx>
      49                 :            : #include "svx/EnhancedCustomShape2d.hxx"
      50                 :            : #include <com/sun/star/beans/PropertyValues.hpp>
      51                 :            : #include <com/sun/star/beans/XPropertyState.hpp>
      52                 :            : #include <com/sun/star/awt/GradientStyle.hpp>
      53                 :            : #include <com/sun/star/awt/RasterOperation.hpp>
      54                 :            : #include <com/sun/star/awt/Gradient.hpp>
      55                 :            : #include <com/sun/star/drawing/LineStyle.hpp>
      56                 :            : #include <com/sun/star/drawing/LineJoint.hpp>
      57                 :            : #include <com/sun/star/drawing/FillStyle.hpp>
      58                 :            : #include <com/sun/star/drawing/LineDash.hpp>
      59                 :            : #include <com/sun/star/drawing/BezierPoint.hpp>
      60                 :            : #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
      61                 :            : #include <com/sun/star/drawing/ConnectorType.hpp>
      62                 :            : #include <com/sun/star/drawing/ConnectionType.hpp>
      63                 :            : #include <com/sun/star/drawing/CircleKind.hpp>
      64                 :            : #include <com/sun/star/drawing/PointSequence.hpp>
      65                 :            : #include <com/sun/star/drawing/FlagSequence.hpp>
      66                 :            : #include <com/sun/star/drawing/PolygonFlags.hpp>
      67                 :            : #include <com/sun/star/text/WritingMode.hpp>
      68                 :            : #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
      69                 :            : #include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
      70                 :            : #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
      71                 :            : #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
      72                 :            : #include <com/sun/star/drawing/EnhancedCustomShapeParameterType.hpp>
      73                 :            : #include <com/sun/star/drawing/EnhancedCustomShapeGluePointType.hpp>
      74                 :            : #include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp>
      75                 :            : #include <com/sun/star/drawing/EnhancedCustomShapeTextFrame.hpp>
      76                 :            : #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
      77                 :            : #include <com/sun/star/drawing/EnhancedCustomShapeTextPathMode.hpp>
      78                 :            : #include <com/sun/star/drawing/ProjectionMode.hpp>
      79                 :            : #include <com/sun/star/text/XSimpleText.hpp>
      80                 :            : #include <com/sun/star/drawing/ShadeMode.hpp>
      81                 :            : #include <vcl/hatch.hxx>
      82                 :            : #include <com/sun/star/awt/XGraphics.hpp>
      83                 :            : #include <com/sun/star/awt/FontSlant.hpp>
      84                 :            : #include <com/sun/star/awt/FontWeight.hpp>
      85                 :            : #include <com/sun/star/drawing/ColorMode.hpp>
      86                 :            : #include <com/sun/star/drawing/Position3D.hpp>
      87                 :            : #include <com/sun/star/drawing/Direction3D.hpp>
      88                 :            : #include <com/sun/star/text/GraphicCrop.hpp>
      89                 :            : #include <unotools/ucbstreamhelper.hxx>
      90                 :            : #include <unotools/localfilehelper.hxx>
      91                 :            : #include <comphelper/extract.hxx>
      92                 :            : #include <comphelper/string.hxx>
      93                 :            : #include <toolkit/unohlp.hxx>
      94                 :            : #include <vcl/virdev.hxx>
      95                 :            : #include <rtl/crc.h>
      96                 :            : #include <rtl/strbuf.hxx>
      97                 :            : 
      98                 :            : using namespace ::rtl;
      99                 :            : using namespace ::com::sun::star;
     100                 :            : 
     101                 :            : 
     102                 :          0 : EscherExContainer::EscherExContainer( SvStream& rSt, const sal_uInt16 nRecType, const sal_uInt16 nInstance ) :
     103                 :          0 :     rStrm   ( rSt )
     104                 :            : {
     105                 :          0 :     rStrm << (sal_uInt32)( ( 0xf | ( nInstance << 4 ) ) | ( nRecType << 16 ) ) << (sal_uInt32)0;
     106                 :          0 :     nContPos = rStrm.Tell();
     107                 :          0 : }
     108                 :          0 : EscherExContainer::~EscherExContainer()
     109                 :            : {
     110                 :          0 :     sal_uInt32 nPos = rStrm.Tell();
     111                 :          0 :     sal_uInt32 nSize= nPos - nContPos;
     112         [ #  # ]:          0 :     if ( nSize )
     113                 :            :     {
     114                 :          0 :         rStrm.Seek( nContPos - 4 );
     115                 :          0 :         rStrm << nSize;
     116                 :          0 :         rStrm.Seek( nPos );
     117                 :            :     }
     118                 :          0 : }
     119                 :            : 
     120                 :          0 : EscherExAtom::EscherExAtom( SvStream& rSt, const sal_uInt16 nRecType, const sal_uInt16 nInstance, const sal_uInt8 nVersion ) :
     121                 :          0 :     rStrm   ( rSt )
     122                 :            : {
     123                 :          0 :     rStrm << (sal_uInt32)( ( nVersion | ( nInstance << 4 ) ) | ( nRecType << 16 ) ) << (sal_uInt32)0;
     124                 :          0 :     nContPos = rStrm.Tell();
     125                 :          0 : }
     126                 :          0 : EscherExAtom::~EscherExAtom()
     127                 :            : {
     128                 :          0 :     sal_uInt32 nPos = rStrm.Tell();
     129                 :          0 :     sal_uInt32 nSize= nPos - nContPos;
     130         [ #  # ]:          0 :     if ( nSize )
     131                 :            :     {
     132                 :          0 :         rStrm.Seek( nContPos - 4 );
     133                 :          0 :         rStrm << nSize;
     134                 :          0 :         rStrm.Seek( nPos );
     135                 :            :     }
     136                 :          0 : }
     137                 :            : 
     138                 :          6 : EscherExClientRecord_Base::~EscherExClientRecord_Base()
     139                 :            : {
     140         [ -  + ]:          6 : }
     141                 :            : 
     142                 :          0 : EscherExClientAnchor_Base::~EscherExClientAnchor_Base()
     143                 :            : {
     144         [ #  # ]:          0 : }
     145                 :            : 
     146                 :         15 : void EscherPropertyContainer::ImplInit()
     147                 :            : {
     148                 :         15 :     nSortCount = 0;
     149                 :         15 :     nCountCount = 0;
     150                 :         15 :     nCountSize = 0;
     151                 :         15 :     nSortBufSize = 64;
     152                 :         15 :     bHasComplexData = sal_False;
     153                 :         15 :     bSuppressRotation = sal_False;
     154                 :         15 :     pSortStruct = new EscherPropSortStruct[ nSortBufSize ];
     155                 :         15 : }
     156                 :            : 
     157                 :         12 : EscherPropertyContainer::EscherPropertyContainer() :
     158                 :            :     pGraphicProvider    ( NULL ),
     159                 :         12 :     pPicOutStrm         ( NULL )
     160                 :            : {
     161                 :         12 :     ImplInit();
     162                 :         12 : };
     163                 :            : 
     164                 :          3 : EscherPropertyContainer::EscherPropertyContainer(
     165                 :            :     EscherGraphicProvider& rGraphProv,
     166                 :            :             SvStream* pPiOutStrm,
     167                 :            :                 Rectangle& rBoundRect ) :
     168                 :            : 
     169                 :            :     pGraphicProvider    ( &rGraphProv ),
     170                 :            :     pPicOutStrm         ( pPiOutStrm ),
     171                 :          3 :     pShapeBoundRect     ( &rBoundRect )
     172                 :            : {
     173                 :          3 :     ImplInit();
     174                 :          3 : }
     175                 :            : 
     176                 :         15 : EscherPropertyContainer::~EscherPropertyContainer()
     177                 :            : {
     178         [ +  + ]:         15 :     if ( bHasComplexData )
     179                 :            :     {
     180         [ +  + ]:         51 :         while ( nSortCount-- )
     181         [ +  + ]:         48 :             delete[] pSortStruct[ nSortCount ].pBuf;
     182                 :            :     }
     183         [ +  - ]:         15 :     delete[] pSortStruct;
     184                 :         15 : };
     185                 :            : 
     186                 :        159 : void EscherPropertyContainer::AddOpt( sal_uInt16 nPropID, sal_uInt32 nPropValue, sal_Bool bBlib )
     187                 :            : {
     188                 :        159 :     AddOpt( nPropID, bBlib, nPropValue, NULL, 0 );
     189                 :        159 : }
     190                 :            : 
     191                 :          0 : void EscherPropertyContainer::AddOpt( sal_uInt16 nPropID, const rtl::OUString& rString )
     192                 :            : {
     193                 :          0 :     sal_Int32 j, i, nLen = rString.getLength() * 2 + 2;
     194                 :          0 :     sal_uInt8* pBuf = new sal_uInt8[ nLen ];
     195         [ #  # ]:          0 :     for ( j = i = 0; i < rString.getLength(); i++ )
     196                 :            :     {
     197                 :          0 :         sal_uInt16 nChar = (sal_uInt16)rString[ i ];
     198                 :          0 :         pBuf[ j++ ] = (sal_uInt8)nChar;
     199                 :          0 :         pBuf[ j++ ] = (sal_uInt8)( nChar >> 8 );
     200                 :            :     }
     201                 :          0 :     pBuf[ j++ ] = 0;
     202                 :          0 :     pBuf[ j++ ] = 0;
     203                 :          0 :     AddOpt( nPropID, sal_True, nLen, pBuf, nLen );
     204                 :          0 : }
     205                 :            : 
     206                 :        165 : void EscherPropertyContainer::AddOpt( sal_uInt16 nPropID, sal_Bool bBlib, sal_uInt32 nPropValue, sal_uInt8* pProp, sal_uInt32 nPropSize )
     207                 :            : {
     208         [ +  + ]:        165 :     if ( bBlib )                // bBlib is only valid when fComplex = 0
     209                 :          9 :         nPropID |= 0x4000;
     210         [ +  + ]:        165 :     if ( pProp )
     211                 :          6 :         nPropID |= 0x8000;      // fComplex = sal_True;
     212                 :            : 
     213                 :            :     sal_uInt32 i;
     214         [ +  + ]:       1110 :     for( i = 0; i < nSortCount; i++ )
     215                 :            :     {
     216         [ +  + ]:        957 :         if ( ( pSortStruct[ i ].nPropId &~0xc000 ) == ( nPropID &~0xc000 ) )    // check, whether the Property only gets replaced
     217                 :            :         {
     218                 :         12 :             pSortStruct[ i ].nPropId = nPropID;
     219         [ -  + ]:         12 :             if ( pSortStruct[ i ].pBuf )
     220                 :            :             {
     221                 :          0 :                 nCountSize -= pSortStruct[ i ].nPropSize;
     222         [ #  # ]:          0 :                 delete[] pSortStruct[ i ].pBuf;
     223                 :            :             }
     224                 :         12 :             pSortStruct[ i ].pBuf = pProp;
     225                 :         12 :             pSortStruct[ i ].nPropSize = nPropSize;
     226                 :         12 :             pSortStruct[ i ].nPropValue = nPropValue;
     227         [ -  + ]:         12 :             if ( pProp )
     228                 :          0 :                 nCountSize += nPropSize;
     229                 :        165 :             return;
     230                 :            :         }
     231                 :            :     }
     232                 :        153 :     nCountCount++;
     233                 :        153 :     nCountSize += 6;
     234         [ -  + ]:        153 :     if ( nSortCount == nSortBufSize )                                           // increase buffer
     235                 :            :     {
     236                 :          0 :         nSortBufSize <<= 1;
     237                 :          0 :         EscherPropSortStruct* pTemp = new EscherPropSortStruct[ nSortBufSize ];
     238         [ #  # ]:          0 :         for( i = 0; i < nSortCount; i++ )
     239                 :            :         {
     240                 :          0 :             pTemp[ i ] = pSortStruct[ i ];
     241                 :            :         }
     242                 :          0 :         delete pSortStruct;
     243                 :          0 :         pSortStruct = pTemp;
     244                 :            :     }
     245                 :        153 :     pSortStruct[ nSortCount ].nPropId = nPropID;                                // insert property
     246                 :        153 :     pSortStruct[ nSortCount ].pBuf = pProp;
     247                 :        153 :     pSortStruct[ nSortCount ].nPropSize = nPropSize;
     248                 :        153 :     pSortStruct[ nSortCount++ ].nPropValue = nPropValue;
     249                 :            : 
     250         [ +  + ]:        153 :     if ( pProp )
     251                 :            :     {
     252                 :          6 :         nCountSize += nPropSize;
     253                 :          6 :         bHasComplexData = sal_True;
     254                 :            :     }
     255                 :            : }
     256                 :            : 
     257                 :         42 : sal_Bool EscherPropertyContainer::GetOpt( sal_uInt16 nPropId, sal_uInt32& rPropValue ) const
     258                 :            : {
     259                 :            :     EscherPropSortStruct aPropStruct;
     260                 :            : 
     261 [ +  - ][ +  + ]:         42 :     if ( GetOpt( nPropId, aPropStruct ) )
     262                 :            :     {
     263                 :         30 :         rPropValue = aPropStruct.nPropValue;
     264                 :         30 :         return sal_True;
     265                 :            :     }
     266                 :         42 :     return sal_False;
     267                 :            : }
     268                 :            : 
     269                 :         54 : sal_Bool EscherPropertyContainer::GetOpt( sal_uInt16 nPropId, EscherPropSortStruct& rPropValue ) const
     270                 :            : {
     271         [ +  + ]:        339 :     for( sal_uInt32 i = 0; i < nSortCount; i++ )
     272                 :            :     {
     273         [ +  + ]:        327 :         if ( ( pSortStruct[ i ].nPropId &~0xc000 ) == ( nPropId &~0xc000 ) )
     274                 :            :         {
     275                 :         42 :             rPropValue = pSortStruct[ i ];
     276                 :         42 :             return sal_True;
     277                 :            :         }
     278                 :            :     }
     279                 :         54 :     return sal_False;
     280                 :            : }
     281                 :            : 
     282                 :          3 : EscherProperties EscherPropertyContainer::GetOpts() const
     283                 :            : {
     284                 :          3 :     EscherProperties aVector;
     285                 :            : 
     286         [ +  + ]:         51 :     for ( sal_uInt32 i = 0; i < nSortCount; ++i )
     287         [ +  - ]:         48 :         aVector.push_back( pSortStruct[ i ] );
     288                 :            : 
     289                 :          3 :     return aVector;
     290                 :            : }
     291                 :            : 
     292                 :        234 : extern "C" int __LOADONCALLAPI EscherPropSortFunc( const void* p1, const void* p2 )
     293                 :            : {
     294                 :        234 :     sal_Int16   nID1 = ((EscherPropSortStruct*)p1)->nPropId &~0xc000;
     295                 :        234 :     sal_Int16   nID2 = ((EscherPropSortStruct*)p2)->nPropId &~0xc000;
     296                 :            : 
     297         [ +  + ]:        234 :     if( nID1  < nID2 )
     298                 :        147 :         return -1;
     299         [ +  - ]:         87 :     else if( nID1 > nID2 )
     300                 :         87 :         return 1;
     301                 :            :     else
     302                 :        234 :         return 0;
     303                 :            : }
     304                 :            : 
     305                 :         12 : void EscherPropertyContainer::Commit( SvStream& rSt, sal_uInt16 nVersion, sal_uInt16 nRecType )
     306                 :            : {
     307                 :         12 :     rSt << (sal_uInt16)( ( nCountCount << 4 ) | ( nVersion & 0xf ) ) << nRecType << nCountSize;
     308         [ +  - ]:         12 :     if ( nSortCount )
     309                 :            :     {
     310                 :         12 :         qsort( pSortStruct, nSortCount, sizeof( EscherPropSortStruct ), EscherPropSortFunc );
     311                 :            :         sal_uInt32 i;
     312                 :            : 
     313         [ +  + ]:        117 :         for ( i = 0; i < nSortCount; i++ )
     314                 :            :         {
     315                 :        105 :             sal_uInt32 nPropValue = pSortStruct[ i ].nPropValue;
     316                 :        105 :             sal_uInt16 nPropId = pSortStruct[ i ].nPropId;
     317                 :            : 
     318 [ -  + ][ #  # ]:        105 :             if ( bSuppressRotation && ( nPropId == ESCHER_Prop_Rotation ) )
     319                 :          0 :                 nPropValue = 0;
     320                 :            : 
     321                 :        105 :             rSt << nPropId
     322                 :        105 :                 << nPropValue;
     323                 :            :         }
     324         [ -  + ]:         12 :         if ( bHasComplexData )
     325                 :            :         {
     326         [ #  # ]:          0 :             for ( i = 0; i < nSortCount; i++ )
     327                 :            :             {
     328         [ #  # ]:          0 :                 if ( pSortStruct[ i ].pBuf )
     329                 :          0 :                     rSt.Write( pSortStruct[ i ].pBuf, pSortStruct[ i ].nPropSize );
     330                 :            :             }
     331                 :            :         }
     332                 :            :     }
     333                 :         12 : }
     334                 :            : 
     335                 :          0 : sal_Bool EscherPropertyContainer::IsFontWork() const
     336                 :            : {
     337                 :          0 :     sal_uInt32 nTextPathFlags = 0;
     338         [ #  # ]:          0 :     GetOpt( DFF_Prop_gtextFStrikethrough, nTextPathFlags );
     339                 :          0 :     return ( nTextPathFlags & 0x4000 ) != 0;
     340                 :            : }
     341                 :            : 
     342                 :          6 : sal_uInt32 EscherPropertyContainer::ImplGetColor( const sal_uInt32 nSOColor, sal_Bool bSwap )
     343                 :            : {
     344         [ +  - ]:          6 :     if ( bSwap )
     345                 :            :     {
     346                 :          6 :         sal_uInt32 nColor = nSOColor & 0xff00;      // green
     347                 :          6 :         nColor |= (sal_uInt8)( nSOColor ) << 16;    // red
     348                 :          6 :         nColor |= (sal_uInt8)( nSOColor >> 16 );    // blue
     349                 :          6 :         return nColor;
     350                 :            :     }
     351                 :            :     else
     352                 :          6 :         return nSOColor & 0xffffff;
     353                 :            : }
     354                 :            : 
     355                 :          0 : sal_uInt32 EscherPropertyContainer::GetGradientColor(
     356                 :            :     const ::com::sun::star::awt::Gradient* pGradient,
     357                 :            :         sal_uInt32 nStartColor )
     358                 :            : {
     359                 :          0 :     sal_uInt32  nIntensity = 100;
     360                 :          0 :     Color       aColor;
     361                 :            : 
     362         [ #  # ]:          0 :     if ( pGradient )
     363                 :            :     {
     364         [ #  # ]:          0 :         if ( nStartColor & 1 )
     365                 :            :         {
     366                 :          0 :             nIntensity = pGradient->StartIntensity;
     367                 :          0 :             aColor = pGradient->StartColor;
     368                 :            :         }
     369                 :            :         else
     370                 :            :         {
     371                 :          0 :             nIntensity = pGradient->EndIntensity;
     372                 :          0 :             aColor = pGradient->EndColor;
     373                 :            :         }
     374                 :            :     }
     375                 :          0 :     sal_uInt32  nRed = ( ( aColor.GetRed() * nIntensity ) / 100 );
     376                 :          0 :     sal_uInt32  nGreen = ( ( aColor.GetGreen() * nIntensity ) / 100 ) << 8;
     377                 :          0 :     sal_uInt32  nBlue = ( ( aColor.GetBlue() * nIntensity ) / 100 ) << 16;
     378                 :          0 :     return nRed | nGreen | nBlue;
     379                 :            : }
     380                 :            : 
     381                 :          0 : void EscherPropertyContainer::CreateGradientProperties(
     382                 :            :     const ::com::sun::star::awt::Gradient & rGradient )
     383                 :            : {
     384                 :          0 :     sal_uInt32  nFillType = ESCHER_FillShadeScale;
     385                 :          0 :     sal_uInt32  nAngle = 0;
     386                 :          0 :     sal_uInt32  nFillFocus = 0;
     387                 :          0 :     sal_uInt32  nFillLR = 0;
     388                 :          0 :     sal_uInt32  nFillTB = 0;
     389                 :          0 :     sal_uInt32  nFirstColor = 0;
     390                 :          0 :     bool        bWriteFillTo = false;
     391                 :            : 
     392   [ #  #  #  # ]:          0 :     switch ( rGradient.Style )
     393                 :            :     {
     394                 :            :         case ::com::sun::star::awt::GradientStyle_LINEAR :
     395                 :            :         case ::com::sun::star::awt::GradientStyle_AXIAL :
     396                 :            :         {
     397                 :          0 :             nFillType = ESCHER_FillShadeScale;
     398                 :          0 :             nAngle = (rGradient.Angle * 0x10000) / 10;
     399                 :          0 :             nFillFocus = (sal::static_int_cast<int>(rGradient.Style) ==
     400         [ #  # ]:          0 :                           sal::static_int_cast<int>(GradientStyle_LINEAR)) ? 0 : 50;
     401                 :            :         }
     402                 :          0 :         break;
     403                 :            :         case ::com::sun::star::awt::GradientStyle_RADIAL :
     404                 :            :         case ::com::sun::star::awt::GradientStyle_ELLIPTICAL :
     405                 :            :         case ::com::sun::star::awt::GradientStyle_SQUARE :
     406                 :            :         case ::com::sun::star::awt::GradientStyle_RECT :
     407                 :            :         {
     408                 :          0 :             nFillLR = (rGradient.XOffset * 0x10000) / 100;
     409                 :          0 :             nFillTB = (rGradient.YOffset * 0x10000) / 100;
     410 [ #  # ][ #  # ]:          0 :             if ( ((nFillLR > 0) && (nFillLR < 0x10000)) || ((nFillTB > 0) && (nFillTB < 0x10000)) )
         [ #  # ][ #  # ]
     411                 :          0 :                 nFillType = ESCHER_FillShadeShape;
     412                 :            :             else
     413                 :          0 :                 nFillType = ESCHER_FillShadeCenter;
     414                 :          0 :             nFirstColor = 1;
     415                 :          0 :             bWriteFillTo = true;
     416                 :            :         }
     417                 :          0 :         break;
     418                 :          0 :         case ::com::sun::star::awt::GradientStyle_MAKE_FIXED_SIZE : break;
     419                 :            :     }
     420                 :          0 :     AddOpt( ESCHER_Prop_fillType, nFillType );
     421                 :          0 :     AddOpt( ESCHER_Prop_fillAngle, nAngle );
     422                 :          0 :     AddOpt( ESCHER_Prop_fillColor, GetGradientColor( &rGradient, nFirstColor ) );
     423                 :          0 :     AddOpt( ESCHER_Prop_fillBackColor, GetGradientColor( &rGradient, nFirstColor ^ 1 ) );
     424                 :          0 :     AddOpt( ESCHER_Prop_fillFocus, nFillFocus );
     425         [ #  # ]:          0 :     if ( bWriteFillTo )
     426                 :            :     {
     427                 :          0 :         AddOpt( ESCHER_Prop_fillToLeft, nFillLR );
     428                 :          0 :         AddOpt( ESCHER_Prop_fillToTop, nFillTB );
     429                 :          0 :         AddOpt( ESCHER_Prop_fillToRight, nFillLR );
     430                 :          0 :         AddOpt( ESCHER_Prop_fillToBottom, nFillTB );
     431                 :            :     }
     432                 :          0 : }
     433                 :            : 
     434                 :          0 : void EscherPropertyContainer::CreateGradientProperties(
     435                 :            :     const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rXPropSet )
     436                 :            : {
     437                 :          0 :     ::com::sun::star::uno::Any aAny;
     438                 :          0 :     ::com::sun::star::awt::Gradient aGradient;
     439         [ #  # ]:          0 :     if ( EscherPropertyValueHelper::GetPropertyValue(
     440 [ #  # ][ #  # ]:          0 :             aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "FillGradient" ) ), sal_False ) )
                 [ #  # ]
     441                 :            :     {
     442                 :          0 :         aGradient = *static_cast< const ::com::sun::star::awt::Gradient* >( aAny.getValue() );
     443                 :            :     }
     444         [ #  # ]:          0 :     CreateGradientProperties( aGradient );
     445                 :          0 : };
     446                 :            : 
     447                 :          3 : void EscherPropertyContainer::CreateFillProperties(
     448                 :            :     const uno::Reference< beans::XPropertySet > & rXPropSet,
     449                 :            :         sal_Bool bEdge )
     450                 :            : {
     451                 :          3 :     ::com::sun::star::uno::Any aAny;
     452         [ +  - ]:          3 :     AddOpt( ESCHER_Prop_WrapText, ESCHER_WrapNone );
     453         [ +  - ]:          3 :     AddOpt( ESCHER_Prop_AnchorText, ESCHER_AnchorMiddle );
     454 [ +  - ][ +  - ]:          3 :     const rtl::OUString aPropName( String( RTL_CONSTASCII_USTRINGPARAM( "FillStyle" ) ) );
                 [ +  - ]
     455                 :            : 
     456         [ +  - ]:          3 :     if ( EscherPropertyValueHelper::GetPropertyValue(
     457 [ +  - ][ +  - ]:          3 :             aAny, rXPropSet, aPropName, sal_False ) )
                 [ +  - ]
     458                 :            :     {
     459                 :            :         ::com::sun::star::drawing::FillStyle eFS;
     460 [ +  - ][ -  + ]:          3 :         if ( ! ( aAny >>= eFS ) )
     461                 :          0 :             eFS = ::com::sun::star::drawing::FillStyle_SOLID;
     462                 :          3 :         sal_uInt32 nFillBackColor = 0;
     463   [ -  -  -  +  :          3 :         switch( eFS )
                      - ]
     464                 :            :         {
     465                 :            :             case ::com::sun::star::drawing::FillStyle_GRADIENT :
     466                 :            :             {
     467         [ #  # ]:          0 :                 CreateGradientProperties( rXPropSet );
     468         [ #  # ]:          0 :                 AddOpt( ESCHER_Prop_fNoFillHitTest, 0x140014 );
     469                 :            :             }
     470                 :          0 :             break;
     471                 :            : 
     472                 :            :             case ::com::sun::star::drawing::FillStyle_BITMAP :
     473                 :            :             {
     474 [ #  # ][ #  # ]:          0 :                 CreateGraphicProperties( rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "FillBitmapURL" ) ), sal_True );
                 [ #  # ]
     475         [ #  # ]:          0 :                 AddOpt( ESCHER_Prop_fNoFillHitTest, 0x140014 );
     476         [ #  # ]:          0 :                 AddOpt( ESCHER_Prop_fillBackColor, nFillBackColor  );
     477                 :            :             }
     478                 :          0 :             break;
     479                 :            :             case ::com::sun::star::drawing::FillStyle_HATCH :
     480                 :            :             {
     481 [ #  # ][ #  # ]:          0 :                 CreateGraphicProperties( rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "FillHatch" ) ), sal_True );
                 [ #  # ]
     482                 :            :             }
     483                 :          0 :             break;
     484                 :            :             case ::com::sun::star::drawing::FillStyle_SOLID :
     485                 :            :             default:
     486                 :            :             {
     487                 :            :                 ::com::sun::star::beans::PropertyState ePropState = EscherPropertyValueHelper::GetPropertyState(
     488 [ +  - ][ +  - ]:          3 :                     rXPropSet, aPropName );
                 [ +  - ]
     489         [ -  + ]:          3 :                 if ( ePropState == ::com::sun::star::beans::PropertyState_DIRECT_VALUE )
     490         [ #  # ]:          0 :                     AddOpt( ESCHER_Prop_fillType, ESCHER_FillSolid );
     491                 :            : 
     492         [ +  - ]:          3 :                 if ( EscherPropertyValueHelper::GetPropertyValue(
     493 [ +  - ][ +  - ]:          3 :                         aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "FillColor" ) ), sal_False ) )
                 [ +  - ]
     494                 :            :                 {
     495         [ +  - ]:          3 :                     sal_uInt32 nFillColor = ImplGetColor( *((sal_uInt32*)aAny.getValue()) );
     496                 :          3 :                     nFillBackColor = nFillColor ^ 0xffffff;
     497         [ +  - ]:          3 :                     AddOpt( ESCHER_Prop_fillColor, nFillColor );
     498                 :            :                 }
     499         [ +  - ]:          3 :                 AddOpt( ESCHER_Prop_fNoFillHitTest, 0x100010 );
     500         [ +  - ]:          3 :                 AddOpt( ESCHER_Prop_fillBackColor, nFillBackColor );
     501                 :          3 :                 break;
     502                 :            :             }
     503                 :            :             case ::com::sun::star::drawing::FillStyle_NONE :
     504         [ #  # ]:          0 :                 AddOpt( ESCHER_Prop_fNoFillHitTest, 0x100000 );
     505                 :          0 :             break;
     506                 :            :         }
     507         [ +  - ]:          3 :         if ( eFS != ::com::sun::star::drawing::FillStyle_NONE )
     508                 :            :         {
     509                 :            :             sal_uInt16 nTransparency = ( EscherPropertyValueHelper::GetPropertyValue(
     510 [ +  - ][ +  - ]:          6 :                                     aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "FillTransparence" ) ), sal_True ) )
                 [ +  - ]
     511                 :          3 :                                     ? *((sal_Int16*)aAny.getValue() )
     512         [ +  - ]:          6 :                                     : 0;
     513         [ -  + ]:          3 :             if (  nTransparency )
     514         [ #  # ]:          3 :                 AddOpt( ESCHER_Prop_fillOpacity, ( ( 100 - nTransparency ) << 16 ) / 100 );
     515                 :            :         }
     516                 :            :     }
     517         [ +  - ]:          3 :     CreateLineProperties( rXPropSet, bEdge );
     518                 :          3 : }
     519                 :            : 
     520                 :          0 : void EscherPropertyContainer::CreateTextProperties(
     521                 :            :     const uno::Reference< beans::XPropertySet > & rXPropSet, sal_uInt32 nTextId,
     522                 :            :         const sal_Bool bIsCustomShape, const sal_Bool bIsTextFrame )
     523                 :            : {
     524                 :          0 :     uno::Any aAny;
     525                 :          0 :     text::WritingMode               eWM( text::WritingMode_LR_TB );
     526                 :          0 :     drawing::TextVerticalAdjust     eVA( drawing::TextVerticalAdjust_TOP );
     527                 :          0 :     drawing::TextHorizontalAdjust   eHA( drawing::TextHorizontalAdjust_LEFT );
     528                 :            : 
     529                 :          0 :     sal_Int32 nLeft             ( 0 );
     530                 :          0 :     sal_Int32 nTop              ( 0 );
     531                 :          0 :     sal_Int32 nRight            ( 0 );
     532                 :          0 :     sal_Int32 nBottom           ( 0 );
     533                 :            : 
     534                 :            :     // used with normal shapes:
     535                 :          0 :     sal_Bool bAutoGrowWidth     ( sal_False );
     536                 :          0 :     sal_Bool bAutoGrowHeight    ( sal_False );
     537                 :            :     // used with ashapes:
     538                 :          0 :     sal_Bool bWordWrap          ( sal_False );
     539                 :          0 :     sal_Bool bAutoGrowSize      ( sal_False );
     540                 :            : 
     541 [ #  # ][ #  # ]:          0 :     if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "TextWritingMode" ) ), sal_True ) )
         [ #  # ][ #  # ]
     542         [ #  # ]:          0 :         aAny >>= eWM;
     543 [ #  # ][ #  # ]:          0 :     if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "TextVerticalAdjust" ) ), sal_True ) )
         [ #  # ][ #  # ]
     544         [ #  # ]:          0 :         aAny >>= eVA;
     545 [ #  # ][ #  # ]:          0 :     if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "TextHorizontalAdjust" ) ), sal_True ) )
         [ #  # ][ #  # ]
     546         [ #  # ]:          0 :         aAny >>= eHA;
     547         [ #  # ]:          0 :     if ( bIsCustomShape )
     548                 :            :     {
     549 [ #  # ][ #  # ]:          0 :         if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "TextWordWrap" ) ), sal_False ) )
         [ #  # ][ #  # ]
     550                 :          0 :             aAny >>= bWordWrap;
     551 [ #  # ][ #  # ]:          0 :         if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "TextAutoGrowHeight" ) ), sal_True ) )
         [ #  # ][ #  # ]
     552                 :          0 :             aAny >>= bAutoGrowSize;
     553                 :            :     }
     554         [ #  # ]:          0 :     else if ( bIsTextFrame )
     555                 :            :     {
     556 [ #  # ][ #  # ]:          0 :         if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "TextAutoGrowWidth" ) ), sal_True ) )
         [ #  # ][ #  # ]
     557                 :          0 :             aAny >>= bAutoGrowWidth;
     558                 :            : 
     559                 :            : // i63936 not setting autogrowheight, because otherwise
     560                 :            : // the minframeheight of the text will be ignored
     561                 :            : //
     562                 :            : //      if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "TextAutoGrowHeight" ) ), sal_True ) )
     563                 :            : //          aAny >>= bAutoGrowHeight;
     564                 :            :     }
     565 [ #  # ][ #  # ]:          0 :     if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "TextLeftDistance" ) ) ) )
         [ #  # ][ #  # ]
     566                 :          0 :         aAny >>= nLeft;
     567 [ #  # ][ #  # ]:          0 :     if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "TextUpperDistance" ) ) ) )
         [ #  # ][ #  # ]
     568                 :          0 :         aAny >>= nTop;
     569 [ #  # ][ #  # ]:          0 :     if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "TextRightDistance" ) ) ) )
         [ #  # ][ #  # ]
     570                 :          0 :         aAny >>= nRight;
     571 [ #  # ][ #  # ]:          0 :     if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "TextLowerDistance" ) ) ) )
         [ #  # ][ #  # ]
     572                 :          0 :         aAny >>= nBottom;
     573                 :            : 
     574                 :          0 :     ESCHER_AnchorText eAnchor = ESCHER_AnchorTop;
     575                 :          0 :     ESCHER_WrapMode eWrapMode = ESCHER_WrapSquare;
     576                 :          0 :     sal_uInt32 nTextAttr = 0x40004;     // rotate text with shape
     577                 :            : 
     578         [ #  # ]:          0 :     if ( eWM == text::WritingMode_TB_RL )
     579                 :            :     {   // verical writing
     580      [ #  #  # ]:          0 :         switch ( eHA )
     581                 :            :         {
     582                 :            :             case drawing::TextHorizontalAdjust_LEFT :
     583                 :          0 :                 eAnchor = ESCHER_AnchorBottom;
     584                 :          0 :             break;
     585                 :            :             case drawing::TextHorizontalAdjust_CENTER :
     586                 :          0 :                 eAnchor = ESCHER_AnchorMiddle;
     587                 :          0 :             break;
     588                 :            :             default :
     589                 :            :             case drawing::TextHorizontalAdjust_BLOCK :
     590                 :            :             case drawing::TextHorizontalAdjust_RIGHT :
     591                 :          0 :                 eAnchor = ESCHER_AnchorTop;
     592                 :          0 :             break;
     593                 :            :         }
     594         [ #  # ]:          0 :         if ( eVA == drawing::TextVerticalAdjust_CENTER )
     595                 :            :         {
     596      [ #  #  # ]:          0 :             switch ( eAnchor )
     597                 :            :             {
     598                 :            :                 case ESCHER_AnchorMiddle :
     599                 :          0 :                     eAnchor = ESCHER_AnchorMiddleCentered;
     600                 :          0 :                 break;
     601                 :            :                 case ESCHER_AnchorBottom :
     602                 :          0 :                     eAnchor = ESCHER_AnchorBottomCentered;
     603                 :          0 :                 break;
     604                 :            :                 default :
     605                 :            :                 case ESCHER_AnchorTop :
     606                 :          0 :                     eAnchor = ESCHER_AnchorTopCentered;
     607                 :          0 :                 break;
     608                 :            :             }
     609                 :            :         }
     610         [ #  # ]:          0 :         if ( bIsCustomShape )
     611                 :            :         {
     612         [ #  # ]:          0 :             if ( bWordWrap )
     613                 :          0 :                 eWrapMode = ESCHER_WrapSquare;
     614                 :            :             else
     615                 :          0 :                 eWrapMode = ESCHER_WrapNone;
     616         [ #  # ]:          0 :             if ( bAutoGrowSize )
     617                 :          0 :                 nTextAttr |= 0x20002;
     618                 :            :         }
     619                 :            :         else
     620                 :            :         {
     621         [ #  # ]:          0 :             if ( bAutoGrowHeight )
     622                 :          0 :                 eWrapMode = ESCHER_WrapNone;
     623         [ #  # ]:          0 :             if ( bAutoGrowWidth )
     624                 :          0 :                 nTextAttr |= 0x20002;
     625                 :            :         }
     626                 :            : 
     627         [ #  # ]:          0 :         AddOpt( ESCHER_Prop_txflTextFlow, ESCHER_txflTtoBA ); // rotate text within shape by 90
     628                 :            :     }
     629                 :            :     else
     630                 :            :     {   // normal from left to right
     631      [ #  #  # ]:          0 :         switch ( eVA )
     632                 :            :         {
     633                 :            :             case drawing::TextVerticalAdjust_CENTER :
     634                 :          0 :                 eAnchor = ESCHER_AnchorMiddle;
     635                 :          0 :             break;
     636                 :            : 
     637                 :            :             case drawing::TextVerticalAdjust_BOTTOM :
     638                 :          0 :                 eAnchor = ESCHER_AnchorBottom;
     639                 :          0 :             break;
     640                 :            : 
     641                 :            :             default :
     642                 :            :             case drawing::TextVerticalAdjust_TOP :
     643                 :          0 :                 eAnchor = ESCHER_AnchorTop;
     644                 :          0 :             break;
     645                 :            :         }
     646         [ #  # ]:          0 :         if ( eHA == drawing::TextHorizontalAdjust_CENTER )
     647                 :            :         {
     648   [ #  #  #  # ]:          0 :             switch( eAnchor )
     649                 :            :             {
     650                 :            :                 case ESCHER_AnchorMiddle :
     651                 :          0 :                     eAnchor = ESCHER_AnchorMiddleCentered;
     652                 :          0 :                 break;
     653                 :            :                 case ESCHER_AnchorBottom :
     654                 :          0 :                     eAnchor = ESCHER_AnchorBottomCentered;
     655                 :          0 :                 break;
     656                 :            :                 case ESCHER_AnchorTop :
     657                 :          0 :                     eAnchor = ESCHER_AnchorTopCentered;
     658                 :          0 :                 break;
     659                 :          0 :                 default: break;
     660                 :            :             }
     661                 :            :         }
     662         [ #  # ]:          0 :         if ( bIsCustomShape )
     663                 :            :         {
     664         [ #  # ]:          0 :             if ( bWordWrap )
     665                 :          0 :                 eWrapMode = ESCHER_WrapSquare;
     666                 :            :             else
     667                 :          0 :                 eWrapMode = ESCHER_WrapNone;
     668         [ #  # ]:          0 :             if ( bAutoGrowSize )
     669                 :          0 :                 nTextAttr |= 0x20002;
     670                 :            :         }
     671                 :            :         else
     672                 :            :         {
     673         [ #  # ]:          0 :             if ( bAutoGrowWidth )
     674                 :          0 :                 eWrapMode = ESCHER_WrapNone;
     675         [ #  # ]:          0 :             if ( bAutoGrowHeight )
     676                 :          0 :                 nTextAttr |= 0x20002;
     677                 :            :         }
     678                 :            :     }
     679         [ #  # ]:          0 :     AddOpt( ESCHER_Prop_dxTextLeft, nLeft * 360 );
     680         [ #  # ]:          0 :     AddOpt( ESCHER_Prop_dxTextRight, nRight * 360 );
     681         [ #  # ]:          0 :     AddOpt( ESCHER_Prop_dyTextTop, nTop * 360 );
     682         [ #  # ]:          0 :     AddOpt( ESCHER_Prop_dyTextBottom, nBottom * 360 );
     683                 :            : 
     684         [ #  # ]:          0 :     AddOpt( ESCHER_Prop_WrapText, eWrapMode );
     685         [ #  # ]:          0 :     AddOpt( ESCHER_Prop_AnchorText, eAnchor );
     686         [ #  # ]:          0 :     AddOpt( ESCHER_Prop_FitTextToShape, nTextAttr );
     687                 :            : 
     688         [ #  # ]:          0 :     if ( nTextId )
     689         [ #  # ]:          0 :         AddOpt( ESCHER_Prop_lTxid, nTextId );
     690                 :            : 
     691                 :            :     // n#404221: In case of rotation we need to write the txtflTextFlow
     692                 :            :     // attribute too.
     693         [ #  # ]:          0 :     if (bIsTextFrame) {
     694                 :            :         sal_uInt16 nAngle = EscherPropertyValueHelper::GetPropertyValue(
     695                 :            :         aAny,
     696                 :            :         rXPropSet,
     697                 :            :         String( RTL_CONSTASCII_USTRINGPARAM( "RotateAngle" ) ),
     698 [ #  # ][ #  # ]:          0 :         sal_True )
                 [ #  # ]
     699         [ #  # ]:          0 :         ? (sal_uInt16)( ( *((sal_Int32*)aAny.getValue() ) ) + 5 ) / 10 : 0;
     700         [ #  # ]:          0 :         if (nAngle==900) {
     701         [ #  # ]:          0 :         AddOpt( ESCHER_Prop_txflTextFlow, 1 );
     702                 :          0 :         bSuppressRotation=true;
     703                 :            :         }
     704         [ #  # ]:          0 :         if (nAngle==1800) {
     705         [ #  # ]:          0 :         AddOpt( ESCHER_Prop_txflTextFlow, 2 );
     706                 :          0 :         bSuppressRotation=true;
     707                 :            :         }
     708         [ #  # ]:          0 :         if (nAngle==2700) {
     709         [ #  # ]:          0 :         AddOpt( ESCHER_Prop_txflTextFlow, 3 );
     710                 :          0 :         bSuppressRotation=true;
     711                 :            :         }
     712                 :          0 :     }
     713                 :          0 : }
     714                 :            : 
     715                 :          6 : sal_Bool EscherPropertyContainer::GetLineArrow( const sal_Bool bLineStart,
     716                 :            :     const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rXPropSet,
     717                 :            :         ESCHER_LineEnd& reLineEnd, sal_Int32& rnArrowLength, sal_Int32& rnArrowWidth )
     718                 :            : {
     719 [ +  + ][ +  - ]:          6 :     static String sLineStart    ( RTL_CONSTASCII_USTRINGPARAM( "LineStart" ) );
         [ +  - ][ #  # ]
     720 [ +  + ][ +  - ]:          6 :     static String sLineStartName( RTL_CONSTASCII_USTRINGPARAM( "LineStartName" ) );
         [ +  - ][ #  # ]
     721 [ +  + ][ +  - ]:          6 :     static String sLineEnd      ( RTL_CONSTASCII_USTRINGPARAM( "LineEnd" ) );
         [ +  - ][ #  # ]
     722 [ +  + ][ +  - ]:          6 :     static String sLineEndName  ( RTL_CONSTASCII_USTRINGPARAM( "LineEndName" ) );
         [ +  - ][ #  # ]
     723                 :            : 
     724 [ +  + ][ +  - ]:          6 :     const String sLine      ( bLineStart ? sLineStart : sLineEnd );
     725 [ +  + ][ +  - ]:          6 :     const String sLineName  ( bLineStart ? sLineStartName : sLineEndName );
     726                 :            : 
     727                 :          6 :     sal_Bool bIsArrow = sal_False;
     728                 :            : 
     729                 :          6 :     ::com::sun::star::uno::Any aAny;
     730         [ +  - ]:          6 :     if ( EscherPropertyValueHelper::GetPropertyValue(
     731         [ +  - ]:          6 :             aAny, rXPropSet, sLine, sal_False ) )
     732                 :            :     {
     733         [ +  - ]:          6 :         PolyPolygon aPolyPoly( EscherPropertyContainer::GetPolyPolygon( aAny ) );
     734 [ +  - ][ -  + ]:          6 :         if ( aPolyPoly.Count() && aPolyPoly[ 0 ].GetSize() )
         [ #  # ][ #  # ]
         [ #  # ][ -  + ]
     735                 :            :         {
     736                 :          0 :             bIsArrow = sal_True;
     737                 :            : 
     738                 :          0 :             reLineEnd     = ESCHER_LineArrowEnd;
     739                 :          0 :             rnArrowLength = 1;
     740                 :          0 :             rnArrowWidth  = 1;
     741                 :            : 
     742         [ #  # ]:          0 :             if ( EscherPropertyValueHelper::GetPropertyValue(
     743         [ #  # ]:          0 :                 aAny, rXPropSet, sLineName, sal_False ) )
     744                 :            :             {
     745         [ #  # ]:          0 :                 String          aArrowStartName = *(::rtl::OUString*)aAny.getValue();
     746                 :          0 :                 rtl::OUString   aApiName;
     747         [ #  # ]:          0 :                 sal_Int16       nWhich = bLineStart ? XATTR_LINESTART : XATTR_LINEEND;
     748                 :            : 
     749                 :          0 :                 SvxUnogetApiNameForItem( nWhich, aArrowStartName, aApiName );
     750         [ #  # ]:          0 :                 if ( !aApiName.isEmpty() )
     751                 :            :                 {
     752                 :            : 
     753                 :            :                     /* todo:
     754                 :            :                     calculate the best option for ArrowLenght and ArrowWidth
     755                 :            :                     */
     756         [ #  # ]:          0 :                     if ( aApiName == "Arrow concave" )
     757                 :          0 :                         reLineEnd = ESCHER_LineArrowStealthEnd;
     758         [ #  # ]:          0 :                     else if ( aApiName == "Square 45" )
     759                 :          0 :                         reLineEnd = ESCHER_LineArrowDiamondEnd;
     760         [ #  # ]:          0 :                     else if ( aApiName == "Small Arrow" )
     761                 :          0 :                         reLineEnd = ESCHER_LineArrowEnd;
     762         [ #  # ]:          0 :                     else if ( aApiName == "Dimension Lines" )
     763                 :            :                     {
     764                 :          0 :                         rnArrowLength = 0;
     765                 :          0 :                         rnArrowWidth  = 2;
     766                 :          0 :                         reLineEnd = ESCHER_LineArrowOvalEnd;
     767                 :            :                     }
     768         [ #  # ]:          0 :                     else if ( aApiName == "Double Arrow" )
     769                 :          0 :                         reLineEnd = ESCHER_LineArrowEnd;
     770         [ #  # ]:          0 :                     else if ( aApiName == "Rounded short Arrow" )
     771                 :          0 :                         reLineEnd = ESCHER_LineArrowEnd;
     772         [ #  # ]:          0 :                     else if ( aApiName == "Symmetric Arrow" )
     773                 :          0 :                         reLineEnd = ESCHER_LineArrowEnd;
     774         [ #  # ]:          0 :                     else if ( aApiName == "Line Arrow" )
     775                 :          0 :                         reLineEnd = ESCHER_LineArrowOpenEnd;
     776         [ #  # ]:          0 :                     else if ( aApiName == "Rounded large Arrow" )
     777                 :          0 :                         reLineEnd = ESCHER_LineArrowEnd;
     778         [ #  # ]:          0 :                     else if ( aApiName == "Circle" )
     779                 :          0 :                         reLineEnd = ESCHER_LineArrowOvalEnd;
     780         [ #  # ]:          0 :                     else if ( aApiName == "Square" )
     781                 :          0 :                         reLineEnd = ESCHER_LineArrowDiamondEnd;
     782         [ #  # ]:          0 :                     else if ( aApiName == "Arrow" )
     783                 :          0 :                         reLineEnd = ESCHER_LineArrowEnd;
     784                 :            :                 }
     785 [ #  # ][ #  # ]:          0 :                 else if ( comphelper::string::getTokenCount(aArrowStartName, ' ') == 2 )
                 [ #  # ]
     786                 :            :                 {
     787                 :          0 :                     sal_Bool b = sal_True;
     788         [ #  # ]:          0 :                     String aArrowName( aArrowStartName.GetToken( 0, ' ' ) );
     789 [ #  # ][ #  # ]:          0 :                     if (  aArrowName.EqualsAscii( "msArrowEnd" ) )
     790                 :          0 :                         reLineEnd = ESCHER_LineArrowEnd;
     791 [ #  # ][ #  # ]:          0 :                     else if (  aArrowName.EqualsAscii( "msArrowOpenEnd" ) )
     792                 :          0 :                         reLineEnd = ESCHER_LineArrowOpenEnd;
     793 [ #  # ][ #  # ]:          0 :                     else if ( aArrowName.EqualsAscii( "msArrowStealthEnd" ) )
     794                 :          0 :                         reLineEnd = ESCHER_LineArrowStealthEnd;
     795 [ #  # ][ #  # ]:          0 :                     else if ( aArrowName.EqualsAscii( "msArrowDiamondEnd" ) )
     796                 :          0 :                         reLineEnd = ESCHER_LineArrowDiamondEnd;
     797 [ #  # ][ #  # ]:          0 :                     else if ( aArrowName.EqualsAscii( "msArrowOvalEnd" ) )
     798                 :          0 :                         reLineEnd = ESCHER_LineArrowOvalEnd;
     799                 :            :                     else
     800                 :          0 :                         b = sal_False;
     801                 :            : 
     802                 :            :                     // now we have the arrow, and try to determine the arrow size;
     803         [ #  # ]:          0 :                     if ( b )
     804                 :            :                     {
     805         [ #  # ]:          0 :                         String aArrowSize( aArrowStartName.GetToken( 1, ' ' ) );
     806         [ #  # ]:          0 :                         sal_Int32 nArrowSize = aArrowSize.ToInt32();
     807                 :          0 :                         rnArrowWidth = ( nArrowSize - 1 ) / 3;
     808         [ #  # ]:          0 :                         rnArrowLength = nArrowSize - ( rnArrowWidth * 3 ) - 1;
     809         [ #  # ]:          0 :                     }
     810         [ #  # ]:          0 :                 }
     811                 :            :             }
     812         [ +  - ]:          6 :         }
     813                 :            :     }
     814 [ +  - ][ +  - ]:          6 :     return bIsArrow;
     815                 :            : }
     816                 :            : 
     817                 :          3 : void EscherPropertyContainer::CreateLineProperties(
     818                 :            :     const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rXPropSet,
     819                 :            :         sal_Bool bEdge )
     820                 :            : {
     821                 :          3 :     ::com::sun::star::uno::Any aAny;
     822                 :          3 :     sal_uInt32 nLineFlags = 0x80008;
     823                 :            : 
     824                 :            :     ESCHER_LineEnd eLineEnd;
     825                 :            :     sal_Int32 nArrowLength;
     826                 :            :     sal_Int32 nArrowWidth;
     827                 :            : 
     828                 :          3 :     sal_Bool bSwapLineEnds = sal_False;
     829 [ +  - ][ +  - ]:          3 :     if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "CircleKind" ) ), sal_True ) )
         [ -  + ][ +  - ]
     830                 :            :     {
     831                 :            :         ::com::sun::star::drawing::CircleKind  eCircleKind;
     832 [ #  # ][ #  # ]:          0 :         if ( aAny >>= eCircleKind )
     833                 :            :         {
     834         [ #  # ]:          0 :             if ( eCircleKind == ::com::sun::star::drawing::CircleKind_ARC )
     835                 :          0 :                 bSwapLineEnds = sal_True;
     836                 :            :         }
     837                 :            :     }
     838 [ +  - ][ -  + ]:          3 :     if ( GetLineArrow( bSwapLineEnds ? sal_False : sal_True, rXPropSet, eLineEnd, nArrowLength, nArrowWidth ) )
     839                 :            :     {
     840         [ #  # ]:          0 :         AddOpt( ESCHER_Prop_lineStartArrowLength, nArrowLength );
     841         [ #  # ]:          0 :         AddOpt( ESCHER_Prop_lineStartArrowWidth, nArrowWidth );
     842         [ #  # ]:          0 :         AddOpt( ESCHER_Prop_lineStartArrowhead, eLineEnd );
     843                 :          0 :         nLineFlags |= 0x100010;
     844                 :            :     }
     845 [ -  + ][ +  - ]:          3 :     if ( GetLineArrow( bSwapLineEnds ? sal_True : sal_False, rXPropSet, eLineEnd, nArrowLength, nArrowWidth ) )
                 [ -  + ]
     846                 :            :     {
     847         [ #  # ]:          0 :         AddOpt( ESCHER_Prop_lineEndArrowLength, nArrowLength );
     848         [ #  # ]:          0 :         AddOpt( ESCHER_Prop_lineEndArrowWidth, nArrowWidth );
     849         [ #  # ]:          0 :         AddOpt( ESCHER_Prop_lineEndArrowhead, eLineEnd );
     850                 :          0 :         nLineFlags |= 0x100010;
     851                 :            :     }
     852         [ +  - ]:          3 :     if ( EscherPropertyValueHelper::GetPropertyValue(
     853 [ +  - ][ +  - ]:          3 :         aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "LineStyle"  ) ), sal_False ) )
                 [ +  - ]
     854                 :            :     {
     855                 :            :         ::com::sun::star::drawing::LineStyle eLS;
     856 [ +  - ][ +  - ]:          3 :         if ( aAny >>= eLS )
     857                 :            :         {
     858      [ -  -  + ]:          3 :             switch ( eLS )
     859                 :            :             {
     860                 :            :                 case ::com::sun::star::drawing::LineStyle_NONE :
     861         [ #  # ]:          0 :                     AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x90000 );           // 80000
     862                 :          0 :                 break;
     863                 :            : 
     864                 :            :                 case ::com::sun::star::drawing::LineStyle_DASH :
     865                 :            :                 {
     866         [ #  # ]:          0 :                     if ( EscherPropertyValueHelper::GetPropertyValue(
     867 [ #  # ][ #  # ]:          0 :                         aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "LineDash" ) ), sal_False ) )
                 [ #  # ]
     868                 :            :                     {
     869                 :          0 :                         ESCHER_LineDashing eDash = ESCHER_LineSolid;
     870                 :          0 :                         ::com::sun::star::drawing::LineDash* pLineDash = (::com::sun::star::drawing::LineDash*)aAny.getValue();
     871                 :          0 :                         sal_Int32 nDistance = pLineDash->Distance << 1;
     872         [ #  # ]:          0 :                         switch ( pLineDash->Style )
     873                 :            :                         {
     874                 :            :                             case ::com::sun::star::drawing::DashStyle_ROUND :
     875                 :            :                             case ::com::sun::star::drawing::DashStyle_ROUNDRELATIVE :
     876         [ #  # ]:          0 :                                 AddOpt( ESCHER_Prop_lineEndCapStyle, 0 ); // set Style Round
     877                 :          0 :                             break;
     878                 :          0 :                             default : break;
     879                 :            :                         }
     880 [ #  # ][ #  # ]:          0 :                         if ( ((!(pLineDash->Dots )) || (!(pLineDash->Dashes )) ) || ( pLineDash->DotLen == pLineDash->DashLen ) )
                 [ #  # ]
     881                 :            :                         {
     882                 :          0 :                             sal_Int32 nLen = pLineDash->DotLen;
     883         [ #  # ]:          0 :                             if ( pLineDash->Dashes )
     884                 :          0 :                                 nLen = pLineDash->DashLen;
     885                 :            : 
     886         [ #  # ]:          0 :                             if ( nLen >= nDistance )
     887                 :          0 :                                 eDash = ESCHER_LineLongDashGEL;
     888         [ #  # ]:          0 :                             else if ( pLineDash->Dots )
     889                 :          0 :                                 eDash = ESCHER_LineDotSys;
     890                 :            :                             else
     891                 :          0 :                                 eDash = ESCHER_LineDashGEL;
     892                 :            :                         }
     893                 :            :                         else                                                            // X Y
     894                 :            :                         {
     895         [ #  # ]:          0 :                             if ( pLineDash->Dots != pLineDash->Dashes )
     896                 :            :                             {
     897 [ #  # ][ #  # ]:          0 :                                 if ( ( pLineDash->DashLen > nDistance ) || ( pLineDash->DotLen > nDistance ) )
     898                 :          0 :                                     eDash = ESCHER_LineLongDashDotDotGEL;
     899                 :            :                                 else
     900                 :          0 :                                     eDash = ESCHER_LineDashDotDotSys;
     901                 :            :                             }
     902                 :            :                             else                                                        // X Y Y
     903                 :            :                             {
     904 [ #  # ][ #  # ]:          0 :                                 if ( ( pLineDash->DashLen > nDistance ) || ( pLineDash->DotLen > nDistance ) )
     905                 :          0 :                                     eDash = ESCHER_LineLongDashDotGEL;
     906                 :            :                                 else
     907                 :          0 :                                     eDash = ESCHER_LineDashDotGEL;
     908                 :            : 
     909                 :            :                             }
     910                 :            :                         }
     911         [ #  # ]:          0 :                         AddOpt( ESCHER_Prop_lineDashing, eDash );
     912                 :            :                     }
     913                 :            :                 }
     914                 :            :                 case ::com::sun::star::drawing::LineStyle_SOLID :
     915                 :            :                 default:
     916                 :            :                 {
     917         [ +  - ]:          3 :                     AddOpt( ESCHER_Prop_fNoLineDrawDash, nLineFlags );
     918                 :            :                 }
     919                 :          3 :                 break;
     920                 :            :             }
     921                 :            :         }
     922         [ +  - ]:          3 :         if ( EscherPropertyValueHelper::GetPropertyValue(
     923 [ +  - ][ +  - ]:          3 :             aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "LineColor"  ) ), sal_False ) )
                 [ +  - ]
     924                 :            :         {
     925         [ +  - ]:          3 :             sal_uInt32 nLineColor = ImplGetColor( *((sal_uInt32*)aAny.getValue()) );
     926         [ +  - ]:          3 :             AddOpt( ESCHER_Prop_lineColor, nLineColor );
     927         [ +  - ]:          3 :             AddOpt( ESCHER_Prop_lineBackColor, nLineColor ^ 0xffffff );
     928                 :            :         }
     929                 :            :     }
     930                 :            : 
     931                 :            :     sal_uInt32 nLineSize = ( EscherPropertyValueHelper::GetPropertyValue(
     932 [ +  - ][ +  - ]:          6 :         aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "LineWidth"  ) ), sal_False ) )
                 [ +  - ]
     933                 :          3 :         ? *((sal_uInt32*)aAny.getValue())
     934         [ +  - ]:          6 :         : 0;
     935         [ -  + ]:          3 :     if ( nLineSize > 1 )
     936         [ #  # ]:          0 :         AddOpt( ESCHER_Prop_lineWidth, nLineSize * 360 );       // 100TH MM -> PT , 1PT = 12700 EMU
     937                 :            : 
     938                 :          3 :     ESCHER_LineJoin eLineJoin = ESCHER_LineJoinMiter;
     939         [ +  - ]:          3 :     if ( EscherPropertyValueHelper::GetPropertyValue(
     940 [ +  - ][ +  - ]:          3 :         aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "LineJoint" ) ), sal_True ) )
                 [ +  - ]
     941                 :            :     {
     942                 :            :         ::com::sun::star::drawing::LineJoint eLJ;
     943 [ +  - ][ +  - ]:          3 :         if ( aAny >>= eLJ )
     944                 :            :         {
     945      [ -  -  + ]:          3 :             switch ( eLJ )
     946                 :            :             {
     947                 :            :                 case com::sun::star::drawing::LineJoint_NONE :
     948                 :            :                 case com::sun::star::drawing::LineJoint_MIDDLE :
     949                 :            :                 case com::sun::star::drawing::LineJoint_BEVEL :
     950                 :          0 :                     eLineJoin = ESCHER_LineJoinBevel;
     951                 :          0 :                 break;
     952                 :            :                 default:
     953                 :            :                 case com::sun::star::drawing::LineJoint_MITER :
     954                 :          0 :                     eLineJoin = ESCHER_LineJoinMiter;
     955                 :          0 :                 break;
     956                 :            :                 case com::sun::star::drawing::LineJoint_ROUND :
     957                 :          3 :                     eLineJoin = ESCHER_LineJoinRound;
     958                 :          3 :                 break;
     959                 :            :             }
     960                 :            :         }
     961                 :            :     }
     962         [ +  - ]:          3 :     AddOpt( ESCHER_Prop_lineJoinStyle, eLineJoin );
     963                 :            : 
     964         [ -  + ]:          3 :     if ( bEdge == sal_False )
     965                 :            :     {
     966         [ #  # ]:          0 :         AddOpt( ESCHER_Prop_fFillOK, 0x1001 );
     967         [ #  # ]:          0 :         AddOpt( ESCHER_Prop_fNoFillHitTest, 0x100000 );
     968                 :          3 :     }
     969                 :          3 : }
     970                 :            : 
     971                 :          3 : static Size lcl_SizeToEmu(Size aPrefSize, MapMode aPrefMapMode)
     972                 :            : {
     973                 :          3 :     Size aRetSize;
     974 [ -  + ][ +  - ]:          3 :     if (aPrefMapMode == MAP_PIXEL)
     975 [ #  # ][ #  # ]:          0 :         aRetSize = Application::GetDefaultDevice()->PixelToLogic( aPrefSize, MAP_100TH_MM );
     976                 :            :     else
     977         [ +  - ]:          3 :         aRetSize = Application::GetDefaultDevice()->LogicToLogic( aPrefSize, aPrefMapMode, MAP_100TH_MM );
     978                 :          3 :     return aRetSize;
     979                 :            : }
     980                 :            : 
     981                 :          0 : void EscherPropertyContainer::ImplCreateGraphicAttributes( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rXPropSet,
     982                 :            :                                                             sal_uInt32 nBlibId, sal_Bool bCreateCroppingAttributes )
     983                 :            : {
     984                 :          0 :     ::com::sun::star::uno::Any aAny;
     985                 :            : 
     986                 :          0 :     sal_uInt32 nPicFlags = 0;
     987                 :          0 :     ::com::sun::star::drawing::ColorMode eColorMode( ::com::sun::star::drawing::ColorMode_STANDARD );
     988                 :          0 :     sal_Int16 nLuminance = 0;
     989                 :          0 :     sal_Int32 nContrast = 0;
     990                 :          0 :     sal_Int16 nRed = 0;
     991                 :          0 :     sal_Int16 nGreen = 0;
     992                 :          0 :     sal_Int16 nBlue = 0;
     993                 :          0 :     double fGamma = 1.0;
     994                 :          0 :     sal_Int16 nTransparency = 0;
     995                 :            : 
     996 [ #  # ][ #  # ]:          0 :     if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "GraphicColorMode" ) ) ) )
         [ #  # ][ #  # ]
     997         [ #  # ]:          0 :         aAny >>= eColorMode;
     998 [ #  # ][ #  # ]:          0 :     if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "AdjustLuminance" ) ) ) )
         [ #  # ][ #  # ]
     999                 :          0 :         aAny >>= nLuminance;
    1000 [ #  # ][ #  # ]:          0 :     if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "AdjustContrast" ) ) ) )
         [ #  # ][ #  # ]
    1001                 :            :     {
    1002                 :          0 :         sal_Int16 nC = sal_Int16();
    1003                 :          0 :         aAny >>= nC;
    1004                 :          0 :         nContrast = nC;
    1005                 :            :     }
    1006 [ #  # ][ #  # ]:          0 :     if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "AdjustRed" ) ) ) )
         [ #  # ][ #  # ]
    1007                 :          0 :         aAny >>= nRed;
    1008 [ #  # ][ #  # ]:          0 :     if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "AdjustGreen" ) ) ) )
         [ #  # ][ #  # ]
    1009                 :          0 :         aAny >>= nGreen;
    1010 [ #  # ][ #  # ]:          0 :     if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "AdjustBlue" ) ) ) )
         [ #  # ][ #  # ]
    1011                 :          0 :         aAny >>= nBlue;
    1012 [ #  # ][ #  # ]:          0 :     if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "Gamma" ) ) ) )
         [ #  # ][ #  # ]
    1013                 :          0 :         aAny >>= fGamma;
    1014 [ #  # ][ #  # ]:          0 :     if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "Transparency" ) ) ) )
         [ #  # ][ #  # ]
    1015                 :          0 :         aAny >>= nTransparency;
    1016                 :            : 
    1017         [ #  # ]:          0 :     if ( eColorMode == ::com::sun::star::drawing::ColorMode_WATERMARK )
    1018                 :            :     {
    1019                 :          0 :         eColorMode = ::com::sun::star::drawing::ColorMode_STANDARD;
    1020                 :          0 :         nLuminance += 70;
    1021         [ #  # ]:          0 :         if ( nLuminance > 100 )
    1022                 :          0 :             nLuminance = 100;
    1023                 :          0 :         nContrast -= 70;
    1024         [ #  # ]:          0 :         if ( nContrast < -100 )
    1025                 :          0 :             nContrast = -100;
    1026                 :            :     }
    1027         [ #  # ]:          0 :     if ( eColorMode == ::com::sun::star::drawing::ColorMode_GREYS )
    1028                 :          0 :         nPicFlags |= 0x40004;
    1029         [ #  # ]:          0 :     else if ( eColorMode == ::com::sun::star::drawing::ColorMode_MONO )
    1030                 :          0 :         nPicFlags |= 0x60006;
    1031                 :            : 
    1032         [ #  # ]:          0 :     if ( nContrast )
    1033                 :            :     {
    1034                 :          0 :         nContrast += 100;
    1035         [ #  # ]:          0 :         if ( nContrast == 100)
    1036                 :          0 :             nContrast = 0x10000;
    1037         [ #  # ]:          0 :         else if ( nContrast < 100 )
    1038                 :            :         {
    1039                 :          0 :             nContrast *= 0x10000;
    1040                 :          0 :             nContrast /= 100;
    1041                 :            :         }
    1042         [ #  # ]:          0 :         else if ( nContrast < 200 )
    1043                 :          0 :             nContrast = ( 100 * 0x10000 ) / ( 200 - nContrast );
    1044                 :            :         else
    1045                 :          0 :             nContrast = 0x7fffffff;
    1046         [ #  # ]:          0 :         AddOpt( ESCHER_Prop_pictureContrast, nContrast );
    1047                 :            :     }
    1048         [ #  # ]:          0 :     if ( nLuminance )
    1049         [ #  # ]:          0 :         AddOpt( ESCHER_Prop_pictureBrightness, nLuminance * 327 );
    1050         [ #  # ]:          0 :     if ( nPicFlags )
    1051         [ #  # ]:          0 :         AddOpt( ESCHER_Prop_pictureActive, nPicFlags );
    1052                 :            : 
    1053 [ #  # ][ #  # ]:          0 :     if ( bCreateCroppingAttributes && pGraphicProvider )
    1054                 :            :     {
    1055                 :          0 :         Size    aPrefSize;
    1056         [ #  # ]:          0 :         MapMode aPrefMapMode;
    1057 [ #  # ][ #  # ]:          0 :         if ( pGraphicProvider->GetPrefSize( nBlibId, aPrefSize, aPrefMapMode ) )
    1058                 :            :         {
    1059 [ #  # ][ #  # ]:          0 :             Size aCropSize(lcl_SizeToEmu(aPrefSize, aPrefMapMode));
                 [ #  # ]
    1060 [ #  # ][ #  # ]:          0 :             if ( aCropSize.Width() && aCropSize.Height() )
                 [ #  # ]
    1061                 :            :             {
    1062 [ #  # ][ #  # ]:          0 :                 if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "GraphicCrop" ) ) ) )
         [ #  # ][ #  # ]
    1063                 :            :                 {
    1064                 :          0 :                     ::com::sun::star::text::GraphicCrop aGraphCrop;
    1065 [ #  # ][ #  # ]:          0 :                     if ( aAny >>= aGraphCrop )
    1066                 :            :                     {
    1067         [ #  # ]:          0 :                         if ( aGraphCrop.Left )
    1068                 :            :                         {
    1069                 :          0 :                             sal_uInt32 nLeft = ( aGraphCrop.Left * 65536 ) / aCropSize.Width();
    1070         [ #  # ]:          0 :                             AddOpt( ESCHER_Prop_cropFromLeft, nLeft );
    1071                 :            :                         }
    1072         [ #  # ]:          0 :                         if ( aGraphCrop.Top )
    1073                 :            :                         {
    1074                 :          0 :                             sal_uInt32 nTop = ( aGraphCrop.Top * 65536 ) / aCropSize.Height();
    1075         [ #  # ]:          0 :                             AddOpt( ESCHER_Prop_cropFromTop, nTop );
    1076                 :            :                         }
    1077         [ #  # ]:          0 :                         if ( aGraphCrop.Right )
    1078                 :            :                         {
    1079                 :          0 :                             sal_uInt32 nRight = ( aGraphCrop.Right * 65536 ) / aCropSize.Width();
    1080         [ #  # ]:          0 :                             AddOpt( ESCHER_Prop_cropFromRight, nRight );
    1081                 :            :                         }
    1082         [ #  # ]:          0 :                         if ( aGraphCrop.Bottom )
    1083                 :            :                         {
    1084                 :          0 :                             sal_uInt32 nBottom = ( aGraphCrop.Bottom * 65536 ) / aCropSize.Height();
    1085         [ #  # ]:          0 :                             AddOpt( ESCHER_Prop_cropFromBottom, nBottom );
    1086                 :            :                         }
    1087                 :            :                     }
    1088                 :            :                 }
    1089                 :            :             }
    1090         [ #  # ]:          0 :         }
    1091                 :          0 :     }
    1092                 :          0 : }
    1093                 :            : 
    1094                 :          3 : sal_Bool EscherPropertyContainer::CreateShapeProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & rXShape )
    1095                 :            : {
    1096         [ +  - ]:          3 :     uno::Reference< beans::XPropertySet > aXPropSet( rXShape, uno::UNO_QUERY );
    1097         [ +  - ]:          3 :     if ( aXPropSet.is() )
    1098                 :            :     {
    1099                 :          3 :         sal_Bool bVal = false;
    1100                 :          3 :         ::com::sun::star::uno::Any aAny;
    1101                 :          3 :         sal_uInt32 nShapeAttr = 0;
    1102 [ +  - ][ +  - ]:          3 :         EscherPropertyValueHelper::GetPropertyValue( aAny, aXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "Visible" ) ), sal_True );
                 [ +  - ]
    1103         [ +  - ]:          3 :         if ( aAny >>= bVal )
    1104                 :            :         {
    1105         [ -  + ]:          3 :             if ( !bVal )
    1106                 :          0 :                 nShapeAttr |= 0x20002;  // set fHidden = true
    1107                 :            :         }
    1108 [ +  - ][ +  - ]:          3 :         EscherPropertyValueHelper::GetPropertyValue( aAny, aXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "Printable" ) ), sal_True );
                 [ +  - ]
    1109         [ +  - ]:          3 :         if ( aAny >>= bVal )
    1110                 :            :         {
    1111         [ -  + ]:          3 :             if ( !bVal )
    1112                 :          0 :                 nShapeAttr |= 0x10000;  // set fPrint = false;
    1113                 :            :         }
    1114         [ -  + ]:          3 :         if ( nShapeAttr )
    1115         [ #  # ]:          3 :             AddOpt( ESCHER_Prop_fPrint, nShapeAttr );
    1116                 :            :     }
    1117                 :          3 :     return sal_True;
    1118                 :            : }
    1119                 :            : 
    1120                 :          0 : sal_Bool EscherPropertyContainer::CreateOLEGraphicProperties(
    1121                 :            :     const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & rXShape )
    1122                 :            : {
    1123                 :          0 :     sal_Bool    bRetValue = sal_False;
    1124                 :            : 
    1125         [ #  # ]:          0 :     if ( rXShape.is() )
    1126                 :            :     {
    1127                 :          0 :         SdrObject* pSdrOLE2( GetSdrObjectFromXShape( rXShape ) );   // SJ: leaving unoapi, because currently there is
    1128 [ #  # ][ #  # ]:          0 :         if ( pSdrOLE2 && pSdrOLE2->ISA( SdrOle2Obj ) )              // no access to the native graphic object
                 [ #  # ]
    1129                 :            :         {
    1130                 :          0 :             Graphic* pGraphic = ((SdrOle2Obj*)pSdrOLE2)->GetGraphic();
    1131         [ #  # ]:          0 :             if ( pGraphic )
    1132                 :            :             {
    1133         [ #  # ]:          0 :                 GraphicObject aGraphicObject( *pGraphic );
    1134         [ #  # ]:          0 :                 rtl::OString aUniqueId( aGraphicObject.GetUniqueID() );
    1135         [ #  # ]:          0 :                 if ( !aUniqueId.isEmpty() )
    1136                 :            :                 {
    1137         [ #  # ]:          0 :                     AddOpt( ESCHER_Prop_fillType, ESCHER_FillPicture );
    1138         [ #  # ]:          0 :                     uno::Reference< beans::XPropertySet > aXPropSet( rXShape, uno::UNO_QUERY );
    1139                 :            : 
    1140 [ #  # ][ #  # ]:          0 :                     if ( pGraphicProvider && pPicOutStrm && pShapeBoundRect && aXPropSet.is() )
         [ #  # ][ #  # ]
                 [ #  # ]
    1141                 :            :                     {
    1142                 :          0 :                         ::com::sun::star::uno::Any aAny;
    1143                 :          0 :                         ::com::sun::star::awt::Rectangle* pVisArea = NULL;
    1144 [ #  # ][ #  # ]:          0 :                         if ( EscherPropertyValueHelper::GetPropertyValue( aAny, aXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "VisibleArea" ) ) ) )
         [ #  # ][ #  # ]
    1145                 :            :                         {
    1146         [ #  # ]:          0 :                             pVisArea = new ::com::sun::star::awt::Rectangle;
    1147         [ #  # ]:          0 :                             aAny >>= (*pVisArea);
    1148                 :            :                         }
    1149 [ #  # ][ #  # ]:          0 :                         Rectangle aRect( Point( 0, 0 ), pShapeBoundRect->GetSize() );
    1150         [ #  # ]:          0 :                         sal_uInt32 nBlibId = pGraphicProvider->GetBlibID( *pPicOutStrm, aUniqueId, aRect, pVisArea, NULL );
    1151         [ #  # ]:          0 :                         if ( nBlibId )
    1152                 :            :                         {
    1153         [ #  # ]:          0 :                             AddOpt( ESCHER_Prop_pib, nBlibId, sal_True );
    1154         [ #  # ]:          0 :                             ImplCreateGraphicAttributes( aXPropSet, nBlibId, sal_False );
    1155                 :          0 :                             bRetValue = sal_True;
    1156                 :            :                         }
    1157                 :          0 :                         delete pVisArea;
    1158                 :          0 :                     }
    1159         [ #  # ]:          0 :                 }
    1160                 :            :             }
    1161                 :            :         }
    1162                 :            :     }
    1163                 :          0 :     return bRetValue;
    1164                 :            : }
    1165                 :            : 
    1166                 :            : 
    1167                 :          0 : sal_Bool EscherPropertyContainer::ImplCreateEmbeddedBmp( const rtl::OString& rUniqueId )
    1168                 :            : {
    1169         [ #  # ]:          0 :     if( !rUniqueId.isEmpty() )
    1170                 :            :     {
    1171         [ #  # ]:          0 :         EscherGraphicProvider aProvider;
    1172         [ #  # ]:          0 :         SvMemoryStream aMemStrm;
    1173         [ #  # ]:          0 :         Rectangle aRect;
    1174 [ #  # ][ #  # ]:          0 :         if ( aProvider.GetBlibID( aMemStrm, rUniqueId, aRect ) )
    1175                 :            :         {
    1176                 :            :             // grab BLIP from stream and insert directly as complex property
    1177                 :            :             // ownership of stream memory goes to complex property
    1178                 :          0 :             aMemStrm.ObjectOwnsMemory( sal_False );
    1179         [ #  # ]:          0 :             sal_uInt8* pBuf = (sal_uInt8*) aMemStrm.GetData();
    1180         [ #  # ]:          0 :             sal_uInt32 nSize = aMemStrm.Seek( STREAM_SEEK_TO_END );
    1181         [ #  # ]:          0 :             AddOpt( ESCHER_Prop_fillBlip, sal_True, nSize, pBuf, nSize );
    1182                 :          0 :             return sal_True;
    1183 [ #  # ][ #  # ]:          0 :         }
         [ #  # ][ #  # ]
    1184                 :            :     }
    1185                 :          0 :     return sal_False;
    1186                 :            : }
    1187                 :            : 
    1188                 :          0 : sal_Bool EscherPropertyContainer::CreateEmbeddedBitmapProperties(
    1189                 :            :     const ::rtl::OUString& rBitmapUrl, ::com::sun::star::drawing::BitmapMode eBitmapMode )
    1190                 :            : {
    1191                 :          0 :     sal_Bool bRetValue = sal_False;
    1192         [ #  # ]:          0 :     String aVndUrl( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.GraphicObject:" ) );
    1193         [ #  # ]:          0 :     String aBmpUrl( rBitmapUrl );
    1194         [ #  # ]:          0 :     xub_StrLen nIndex = aBmpUrl.Search( aVndUrl, 0 );
    1195         [ #  # ]:          0 :     if( nIndex != STRING_NOTFOUND )
    1196                 :            :     {
    1197                 :            :         // note: += ist not defined for xub_StrLen -> conversion to int and back to xub_StrLen
    1198                 :          0 :         nIndex = nIndex + aVndUrl.Len();
    1199         [ #  # ]:          0 :         if( aBmpUrl.Len() > nIndex )
    1200                 :            :         {
    1201 [ #  # ][ #  # ]:          0 :             rtl::OString aUniqueId(rtl::OUStringToOString(aBmpUrl.Copy(nIndex, aBmpUrl.Len() - nIndex), RTL_TEXTENCODING_UTF8));
         [ #  # ][ #  # ]
    1202         [ #  # ]:          0 :             bRetValue = ImplCreateEmbeddedBmp( aUniqueId );
    1203         [ #  # ]:          0 :             if( bRetValue )
    1204                 :            :             {
    1205                 :            :                 // bitmap mode property
    1206                 :          0 :                 bool bRepeat = eBitmapMode == ::com::sun::star::drawing::BitmapMode_REPEAT;
    1207 [ #  # ][ #  # ]:          0 :                 AddOpt( ESCHER_Prop_fillType, bRepeat ? ESCHER_FillTexture : ESCHER_FillPicture );
    1208                 :          0 :             }
    1209                 :            :         }
    1210                 :            :     }
    1211 [ #  # ][ #  # ]:          0 :     return bRetValue;
    1212                 :            : }
    1213                 :            : 
    1214                 :            : 
    1215                 :            : namespace {
    1216                 :            : 
    1217                 :          0 : GraphicObject lclDrawHatch( const ::com::sun::star::drawing::Hatch& rHatch, const Color& rBackColor, bool bFillBackground )
    1218                 :            : {
    1219         [ #  # ]:          0 :     const MapMode aMap100( MAP_100TH_MM );
    1220 [ #  # ][ #  # ]:          0 :     VirtualDevice aVDev( *Application::GetDefaultDevice(), 0, 1 );
    1221         [ #  # ]:          0 :     aVDev.SetMapMode( aMap100 );
    1222                 :            : 
    1223         [ #  # ]:          0 :     const Size aOutSize = aVDev.PixelToLogic( Size( 28, 28 ) );
    1224         [ #  # ]:          0 :     aVDev.SetOutputSize( aOutSize );
    1225                 :            : 
    1226         [ #  # ]:          0 :     Rectangle aRectangle( Point( 0, 0 ), aOutSize );
    1227 [ #  # ][ #  # ]:          0 :     const PolyPolygon aPolyPoly( aRectangle );
                 [ #  # ]
    1228                 :            : 
    1229         [ #  # ]:          0 :     aVDev.SetLineColor();
    1230 [ #  # ][ #  # ]:          0 :     aVDev.SetFillColor( bFillBackground ? rBackColor : Color( COL_TRANSPARENT ) );
    1231 [ #  # ][ #  # ]:          0 :     aVDev.DrawRect( Rectangle( Point(), aOutSize ) );
    1232                 :            : 
    1233         [ #  # ]:          0 :     Hatch aVclHatch( (HatchStyle) rHatch.Style, Color( rHatch.Color ), rHatch.Distance, (sal_uInt16)rHatch.Angle );
    1234         [ #  # ]:          0 :     aVDev.DrawHatch( aPolyPoly, aVclHatch );
    1235                 :            : 
    1236 [ #  # ][ #  # ]:          0 :     return GraphicObject( Graphic( aVDev.GetBitmapEx( Point(), aOutSize ) ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1237                 :            : }
    1238                 :            : 
    1239                 :            : } // namespace
    1240                 :            : 
    1241                 :            : 
    1242                 :          0 : sal_Bool EscherPropertyContainer::CreateEmbeddedHatchProperties( const ::com::sun::star::drawing::Hatch& rHatch, const Color& rBackColor, bool bFillBackground )
    1243                 :            : {
    1244         [ #  # ]:          0 :     GraphicObject aGraphicObject = lclDrawHatch( rHatch, rBackColor, bFillBackground );
    1245         [ #  # ]:          0 :     rtl::OString aUniqueId = aGraphicObject.GetUniqueID();
    1246         [ #  # ]:          0 :     sal_Bool bRetValue = ImplCreateEmbeddedBmp( aUniqueId );
    1247         [ #  # ]:          0 :     if ( bRetValue )
    1248         [ #  # ]:          0 :         AddOpt( ESCHER_Prop_fillType, ESCHER_FillTexture );
    1249         [ #  # ]:          0 :     return bRetValue;
    1250                 :            : }
    1251                 :            : 
    1252                 :            : 
    1253                 :          0 : sal_Bool EscherPropertyContainer::CreateGraphicProperties(
    1254                 :            :     const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rXPropSet,
    1255                 :            :         const String& rSource, const sal_Bool bCreateFillBitmap, const sal_Bool bCreateCroppingAttributes,
    1256                 :            :             const sal_Bool bFillBitmapModeAllowed )
    1257                 :            : {
    1258                 :          0 :     sal_Bool        bRetValue = sal_False;
    1259                 :          0 :     sal_Bool        bCreateFillStyles = sal_False;
    1260                 :            : 
    1261                 :          0 :     sal_Bool        bMirrored = sal_False;
    1262                 :          0 :     sal_Bool        bRotate   = sal_True;
    1263                 :          0 :     GraphicAttr*    pGraphicAttr = NULL;
    1264         [ #  # ]:          0 :     GraphicObject   aGraphicObject;
    1265         [ #  # ]:          0 :     String          aGraphicUrl;
    1266                 :          0 :     rtl::OString    aUniqueId;
    1267                 :          0 :     bool            bIsGraphicMtf(false);
    1268                 :            : 
    1269                 :          0 :     ::com::sun::star::drawing::BitmapMode   eBitmapMode( ::com::sun::star::drawing::BitmapMode_NO_REPEAT );
    1270                 :          0 :     ::com::sun::star::uno::Any aAny;
    1271                 :            : 
    1272 [ #  # ][ #  # ]:          0 :     if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet, rSource ) )
    1273                 :            :     {
    1274                 :          0 :         sal_uInt16 nAngle = 0;
    1275 [ #  # ][ #  # ]:          0 :         if ( rSource == String( RTL_CONSTASCII_USTRINGPARAM( "MetaFile" ) ) )
         [ #  # ][ #  # ]
    1276                 :            :         {
    1277         [ #  # ]:          0 :             ::com::sun::star::uno::Sequence<sal_uInt8> aSeq = *(::com::sun::star::uno::Sequence<sal_uInt8>*)aAny.getValue();
    1278         [ #  # ]:          0 :             const sal_uInt8*    pAry = aSeq.getArray();
    1279                 :          0 :             sal_uInt32          nAryLen = aSeq.getLength();
    1280                 :            : 
    1281                 :            :             // the metafile is already rotated
    1282                 :          0 :             bRotate = sal_False;
    1283                 :            : 
    1284 [ #  # ][ #  # ]:          0 :             if ( pAry && nAryLen )
    1285                 :            :             {
    1286         [ #  # ]:          0 :                 Graphic         aGraphic;
    1287         [ #  # ]:          0 :                 SvMemoryStream  aTemp( (void*)pAry, nAryLen, STREAM_READ );
    1288         [ #  # ]:          0 :                 sal_uInt32 nErrCode = GraphicConverter::Import( aTemp, aGraphic, CVT_WMF );
    1289         [ #  # ]:          0 :                 if ( nErrCode == ERRCODE_NONE )
    1290                 :            :                 {
    1291 [ #  # ][ #  # ]:          0 :                     aGraphicObject = aGraphic;
                 [ #  # ]
    1292         [ #  # ]:          0 :                     aUniqueId = aGraphicObject.GetUniqueID();
    1293                 :          0 :                     bIsGraphicMtf = aGraphicObject.GetType() == GRAPHIC_GDIMETAFILE;
    1294 [ #  # ][ #  # ]:          0 :                 }
    1295         [ #  # ]:          0 :             }
    1296                 :            :         }
    1297 [ #  # ][ #  # ]:          0 :         else if ( rSource == String( RTL_CONSTASCII_USTRINGPARAM( "Bitmap" ) ) )
         [ #  # ][ #  # ]
    1298                 :            :         {
    1299                 :          0 :             ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap >xBitmap;
    1300 [ #  # ][ #  # ]:          0 :             if ( ::cppu::extractInterface( xBitmap, aAny ) )
    1301                 :            :             {
    1302                 :          0 :                 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap > xBmp;
    1303 [ #  # ][ #  # ]:          0 :                 if ( aAny >>= xBmp )
    1304                 :            :                 {
    1305         [ #  # ]:          0 :                     BitmapEx    aBitmapEx( VCLUnoHelper::GetBitmap( xBmp ) );
    1306         [ #  # ]:          0 :                     Graphic     aGraphic( aBitmapEx );
    1307 [ #  # ][ #  # ]:          0 :                     aGraphicObject = aGraphic;
                 [ #  # ]
    1308         [ #  # ]:          0 :                     aUniqueId = aGraphicObject.GetUniqueID();
    1309 [ #  # ][ #  # ]:          0 :                     bIsGraphicMtf = aGraphicObject.GetType() == GRAPHIC_GDIMETAFILE;
    1310                 :          0 :                 }
    1311                 :          0 :             }
    1312                 :            :         }
    1313 [ #  # ][ #  # ]:          0 :         else if ( rSource == String( RTL_CONSTASCII_USTRINGPARAM( "FillBitmapURL" ) ) )
         [ #  # ][ #  # ]
    1314                 :            :         {
    1315         [ #  # ]:          0 :             aGraphicUrl = *(::rtl::OUString*)aAny.getValue();
    1316                 :            :         }
    1317 [ #  # ][ #  # ]:          0 :         else if ( rSource == String( RTL_CONSTASCII_USTRINGPARAM( "GraphicURL" ) ) )
         [ #  # ][ #  # ]
    1318                 :            :         {
    1319         [ #  # ]:          0 :             aGraphicUrl = *(::rtl::OUString*)aAny.getValue();
    1320                 :          0 :             bCreateFillStyles = sal_True;
    1321                 :            :         }
    1322 [ #  # ][ #  # ]:          0 :         else if ( rSource == String( RTL_CONSTASCII_USTRINGPARAM( "FillHatch" ) ) )
         [ #  # ][ #  # ]
    1323                 :            :         {
    1324                 :          0 :             ::com::sun::star::drawing::Hatch aHatch;
    1325 [ #  # ][ #  # ]:          0 :             if ( aAny >>= aHatch )
    1326                 :            :             {
    1327                 :          0 :                 Color aBackColor;
    1328         [ #  # ]:          0 :                 if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet,
    1329 [ #  # ][ #  # ]:          0 :                     String( RTL_CONSTASCII_USTRINGPARAM( "FillColor" ) ), sal_False ) )
                 [ #  # ]
    1330                 :            :                 {
    1331         [ #  # ]:          0 :                     aBackColor = ImplGetColor( *((sal_uInt32*)aAny.getValue()), sal_False );
    1332                 :            :                 }
    1333                 :          0 :                 bool bFillBackground = false;
    1334         [ #  # ]:          0 :                 if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet,
    1335 [ #  # ][ #  # ]:          0 :                         String( RTL_CONSTASCII_USTRINGPARAM( "FillBackground" ) ), sal_True ) )
                 [ #  # ]
    1336                 :            :                 {
    1337                 :          0 :                     aAny >>= bFillBackground;
    1338                 :            :                 }
    1339 [ #  # ][ #  # ]:          0 :                 aGraphicObject = lclDrawHatch( aHatch, aBackColor, bFillBackground );
                 [ #  # ]
    1340         [ #  # ]:          0 :                 aUniqueId = aGraphicObject.GetUniqueID();
    1341                 :          0 :                 eBitmapMode = ::com::sun::star::drawing::BitmapMode_REPEAT;
    1342                 :          0 :                 bIsGraphicMtf = aGraphicObject.GetType() == GRAPHIC_GDIMETAFILE;
    1343                 :            :             }
    1344                 :            :         }
    1345                 :            : 
    1346 [ #  # ][ #  # ]:          0 :         if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "IsMirrored" ) ), sal_True ) )
         [ #  # ][ #  # ]
    1347                 :          0 :             aAny >>= bMirrored;
    1348                 :            : 
    1349 [ #  # ][ #  # ]:          0 :         if ( bCreateFillBitmap && bFillBitmapModeAllowed )
    1350                 :            :         {
    1351 [ #  # ][ #  # ]:          0 :             if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "FillBitmapMode" ) ), sal_True ) )
         [ #  # ][ #  # ]
    1352         [ #  # ]:          0 :                 aAny >>= eBitmapMode;
    1353                 :            :         }
    1354                 :            :         else
    1355                 :            :         {
    1356                 :            :             nAngle = bRotate && EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet,
    1357 [ #  # ][ #  # ]:          0 :                                                                              String( RTL_CONSTASCII_USTRINGPARAM( "RotateAngle" ) ), sal_True )
         [ #  # ][ #  # ]
                 [ #  # ]
    1358                 :          0 :                 ? (sal_uInt16)( ( *((sal_Int32*)aAny.getValue() ) ) + 5 ) / 10
    1359 [ #  # ][ #  # ]:          0 :                 : 0;
    1360                 :            :         }
    1361                 :            : 
    1362         [ #  # ]:          0 :         if ( aGraphicUrl.Len() )
    1363                 :            :         {
    1364         [ #  # ]:          0 :             String aVndUrl( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.GraphicObject:" ) );
    1365         [ #  # ]:          0 :             xub_StrLen nIndex = aGraphicUrl.Search( aVndUrl, 0 );
    1366         [ #  # ]:          0 :             if ( nIndex != STRING_NOTFOUND )
    1367                 :            :             {
    1368                 :          0 :                 nIndex = nIndex + aVndUrl.Len();
    1369         [ #  # ]:          0 :                 if ( aGraphicUrl.Len() > nIndex  )
    1370 [ #  # ][ #  # ]:          0 :                     aUniqueId = rtl::OUStringToOString(aGraphicUrl.Copy(nIndex, aGraphicUrl.Len() - nIndex), RTL_TEXTENCODING_UTF8);
         [ #  # ][ #  # ]
    1371                 :            :             }
    1372                 :            :             else
    1373                 :            :             {
    1374                 :            :                 // externally, linked graphic? convert to embedded
    1375                 :            :                 // one, if transformations are needed. this is because
    1376                 :            :                 // everything < msoxp cannot even handle rotated
    1377                 :            :                 // bitmaps.
    1378                 :            :                 // And check whether the graphic link target is
    1379                 :            :                 // actually supported by mso.
    1380 [ #  # ][ #  # ]:          0 :                 INetURLObject   aTmp( aGraphicUrl );
    1381         [ #  # ]:          0 :                 GraphicDescriptor aDescriptor(aTmp);
    1382         [ #  # ]:          0 :                 aDescriptor.Detect();
    1383                 :          0 :                 const sal_uInt16 nFormat = aDescriptor.GetFileFormat();
    1384                 :            : 
    1385                 :            :                 // can MSO handle it?
    1386 [ #  # ][ #  # ]:          0 :                 if ( bMirrored || nAngle ||
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1387                 :            :                      (nFormat != GFF_BMP &&
    1388                 :            :                       nFormat != GFF_GIF &&
    1389                 :            :                       nFormat != GFF_JPG &&
    1390                 :            :                       nFormat != GFF_PNG &&
    1391                 :            :                       nFormat != GFF_TIF &&
    1392                 :            :                       nFormat != GFF_PCT &&
    1393                 :            :                       nFormat != GFF_WMF &&
    1394                 :            :                       nFormat != GFF_EMF) )
    1395                 :            :                 {
    1396                 :            :                     SvStream* pIn = ::utl::UcbStreamHelper::CreateStream(
    1397 [ #  # ][ #  # ]:          0 :                         aTmp.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ );
         [ #  # ][ #  # ]
    1398         [ #  # ]:          0 :                     if ( pIn )
    1399                 :            :                     {
    1400         [ #  # ]:          0 :                         Graphic aGraphic;
    1401         [ #  # ]:          0 :                         sal_uInt32 nErrCode = GraphicConverter::Import( *pIn, aGraphic );
    1402                 :            : 
    1403         [ #  # ]:          0 :                         if ( nErrCode == ERRCODE_NONE )
    1404                 :            :                         {
    1405                 :            :                             // no.
    1406 [ #  # ][ #  # ]:          0 :                             aGraphicObject = aGraphic;
                 [ #  # ]
    1407         [ #  # ]:          0 :                             aUniqueId = aGraphicObject.GetUniqueID();
    1408                 :            :                         }
    1409                 :            :                         // else: simply keep the graphic link
    1410 [ #  # ][ #  # ]:          0 :                         delete pIn;
                 [ #  # ]
    1411                 :            :                     }
    1412                 :            :                 }
    1413         [ #  # ]:          0 :                 if ( aUniqueId.isEmpty() )
    1414                 :            :                 {
    1415         [ #  # ]:          0 :                     if ( pGraphicProvider )
    1416                 :            :                     {
    1417                 :          0 :                         const rtl::OUString& rBaseURI( pGraphicProvider->GetBaseURI() );
    1418         [ #  # ]:          0 :                         INetURLObject aBaseURI( rBaseURI );
    1419         [ #  # ]:          0 :                         if( aBaseURI.GetProtocol() == aTmp.GetProtocol() )
    1420                 :            :                         {
    1421                 :            :                             rtl::OUString aRelUrl( INetURLObject::GetRelURL( rBaseURI, aGraphicUrl,
    1422 [ #  # ][ #  # ]:          0 :                                                     INetURLObject::WAS_ENCODED, INetURLObject::DECODE_TO_IURI, RTL_TEXTENCODING_UTF8, INetURLObject::FSYS_DETECT ) );
    1423         [ #  # ]:          0 :                             if ( !aRelUrl.isEmpty() )
    1424         [ #  # ]:          0 :                                 aGraphicUrl = aRelUrl;
    1425         [ #  # ]:          0 :                         }
    1426                 :            :                     }
    1427 [ #  # ][ #  # ]:          0 :                 }
    1428         [ #  # ]:          0 :             }
    1429                 :            :         }
    1430                 :            : 
    1431 [ #  # ][ #  # ]:          0 :         if ( aGraphicUrl.Len() || !aUniqueId.isEmpty() )
                 [ #  # ]
    1432                 :            :         {
    1433 [ #  # ][ #  # ]:          0 :             if ( bMirrored || nAngle )
    1434                 :            :             {
    1435 [ #  # ][ #  # ]:          0 :                 pGraphicAttr = new GraphicAttr;
    1436         [ #  # ]:          0 :                 if ( bMirrored )
    1437                 :          0 :                     pGraphicAttr->SetMirrorFlags( BMP_MIRROR_HORZ );
    1438         [ #  # ]:          0 :                 if ( bIsGraphicMtf )
    1439         [ #  # ]:          0 :                     AddOpt( ESCHER_Prop_Rotation, ( ( ((sal_Int32)nAngle << 16 ) / 10 ) + 0x8000 ) &~ 0xffff );
    1440                 :            :                 else
    1441                 :            :                 {
    1442                 :          0 :                     pGraphicAttr->SetRotation( nAngle );
    1443 [ #  # ][ #  # ]:          0 :                     if ( nAngle && pShapeBoundRect )   // up to xp ppoint does not rotate bitmaps !
    1444                 :            :                     {
    1445         [ #  # ]:          0 :                         Polygon aPoly( *pShapeBoundRect );
    1446         [ #  # ]:          0 :                         aPoly.Rotate( pShapeBoundRect->TopLeft(), nAngle );
    1447         [ #  # ]:          0 :                         *pShapeBoundRect = aPoly.GetBoundRect();
    1448         [ #  # ]:          0 :                         bSuppressRotation = sal_True;
    1449                 :            :                     }
    1450                 :            :                 }
    1451                 :            :             }
    1452                 :            : 
    1453         [ #  # ]:          0 :             if ( eBitmapMode == ::com::sun::star::drawing::BitmapMode_REPEAT )
    1454         [ #  # ]:          0 :                 AddOpt( ESCHER_Prop_fillType, ESCHER_FillTexture );
    1455                 :            :             else
    1456         [ #  # ]:          0 :                 AddOpt( ESCHER_Prop_fillType, ESCHER_FillPicture );
    1457                 :            : 
    1458         [ #  # ]:          0 :             if ( !aUniqueId.isEmpty() )
    1459                 :            :             {
    1460                 :            :                 // write out embedded graphic
    1461 [ #  # ][ #  # ]:          0 :                 if ( pGraphicProvider && pPicOutStrm && pShapeBoundRect )
                 [ #  # ]
    1462                 :            :                 {
    1463 [ #  # ][ #  # ]:          0 :                     Rectangle aRect( Point( 0, 0 ), pShapeBoundRect->GetSize() );
    1464                 :            : 
    1465                 :          0 :                     sal_uInt32 nBlibId = 0;
    1466         [ #  # ]:          0 :                     nBlibId = pGraphicProvider->GetBlibID( *pPicOutStrm, aUniqueId, aRect, NULL, pGraphicAttr );
    1467         [ #  # ]:          0 :                     if ( nBlibId )
    1468                 :            :                     {
    1469         [ #  # ]:          0 :                         if ( bCreateFillBitmap )
    1470         [ #  # ]:          0 :                             AddOpt( ESCHER_Prop_fillBlip, nBlibId, sal_True );
    1471                 :            :                         else
    1472                 :            :                         {
    1473         [ #  # ]:          0 :                             AddOpt( ESCHER_Prop_pib, nBlibId, sal_True );
    1474         [ #  # ]:          0 :                             ImplCreateGraphicAttributes( rXPropSet, nBlibId, bCreateCroppingAttributes );
    1475                 :            :                         }
    1476                 :          0 :                         bRetValue = sal_True;
    1477                 :          0 :                     }
    1478                 :            :                 }
    1479                 :            :                 else
    1480                 :            :                 {
    1481         [ #  # ]:          0 :                     EscherGraphicProvider aProvider;
    1482         [ #  # ]:          0 :                     SvMemoryStream aMemStrm;
    1483         [ #  # ]:          0 :                     Rectangle aRect;
    1484                 :            : 
    1485 [ #  # ][ #  # ]:          0 :                     if ( aProvider.GetBlibID( aMemStrm, aUniqueId, aRect, NULL, pGraphicAttr ) )
    1486                 :            :                     {
    1487                 :            :                         // grab BLIP from stream and insert directly as complex property
    1488                 :            :                         // ownership of stream memory goes to complex property
    1489                 :          0 :                         aMemStrm.ObjectOwnsMemory( sal_False );
    1490         [ #  # ]:          0 :                         sal_uInt8* pBuf = (sal_uInt8*) aMemStrm.GetData();
    1491         [ #  # ]:          0 :                         sal_uInt32 nSize = aMemStrm.Seek( STREAM_SEEK_TO_END );
    1492         [ #  # ]:          0 :                         AddOpt( ESCHER_Prop_fillBlip, sal_True, nSize, pBuf, nSize );
    1493                 :          0 :                         bRetValue = sal_True;
    1494 [ #  # ][ #  # ]:          0 :                     }
    1495                 :            :                 }
    1496                 :            :             }
    1497                 :            :             // write out link to graphic
    1498                 :            :             else
    1499                 :            :             {
    1500                 :            :                 OSL_ASSERT(aGraphicUrl.Len());
    1501                 :            : 
    1502 [ #  # ][ #  # ]:          0 :                 AddOpt( ESCHER_Prop_pibName, aGraphicUrl );
    1503                 :          0 :                 sal_uInt32  nPibFlags=0;
    1504         [ #  # ]:          0 :                 GetOpt( ESCHER_Prop_pibFlags, nPibFlags );
    1505                 :            :                 AddOpt( ESCHER_Prop_pibFlags,
    1506         [ #  # ]:          0 :                         ESCHER_BlipFlagLinkToFile|ESCHER_BlipFlagFile|ESCHER_BlipFlagDoNotSave | nPibFlags );
    1507                 :            :             }
    1508                 :            :         }
    1509                 :            :     }
    1510 [ #  # ][ #  # ]:          0 :     delete pGraphicAttr;
    1511         [ #  # ]:          0 :     if ( bCreateFillStyles )
    1512         [ #  # ]:          0 :         CreateFillProperties( rXPropSet, sal_True );
    1513                 :            : 
    1514 [ #  # ][ #  # ]:          0 :     return bRetValue;
    1515                 :            : }
    1516                 :            : 
    1517                 :          0 : PolyPolygon EscherPropertyContainer::GetPolyPolygon( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & rXShape )
    1518                 :            : {
    1519         [ #  # ]:          0 :     PolyPolygon aRetPolyPoly;
    1520                 :          0 :     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > aXPropSet;
    1521         [ #  # ]:          0 :     ::com::sun::star::uno::Any aAny( rXShape->queryInterface(
    1522 [ #  # ][ #  # ]:          0 :         ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >*) 0 ) ));
    1523                 :            : 
    1524         [ #  # ]:          0 :     String sPolyPolygonBezier( RTL_CONSTASCII_USTRINGPARAM( "PolyPolygonBezier" ) );
    1525         [ #  # ]:          0 :     String sPolyPolygon     ( RTL_CONSTASCII_USTRINGPARAM( "PolyPolygon" ) );
    1526         [ #  # ]:          0 :     String sPolygon         ( RTL_CONSTASCII_USTRINGPARAM( "Polygon" ) );
    1527                 :            : 
    1528 [ #  # ][ #  # ]:          0 :     if ( aAny >>= aXPropSet )
    1529                 :            :     {
    1530         [ #  # ]:          0 :         sal_Bool bHasProperty = EscherPropertyValueHelper::GetPropertyValue( aAny, aXPropSet, sPolyPolygonBezier, sal_True );
    1531         [ #  # ]:          0 :         if ( !bHasProperty )
    1532         [ #  # ]:          0 :             bHasProperty = EscherPropertyValueHelper::GetPropertyValue( aAny, aXPropSet, sPolyPolygon, sal_True );
    1533         [ #  # ]:          0 :         if ( !bHasProperty )
    1534         [ #  # ]:          0 :             bHasProperty = EscherPropertyValueHelper::GetPropertyValue( aAny, aXPropSet, sPolygon, sal_True );
    1535         [ #  # ]:          0 :         if ( bHasProperty )
    1536 [ #  # ][ #  # ]:          0 :             aRetPolyPoly = GetPolyPolygon( aAny );
                 [ #  # ]
    1537                 :            :     }
    1538 [ #  # ][ #  # ]:          0 :     return aRetPolyPoly;
                 [ #  # ]
    1539                 :            : }
    1540                 :            : 
    1541                 :          6 : PolyPolygon EscherPropertyContainer::GetPolyPolygon( const ::com::sun::star::uno::Any& rAny )
    1542                 :            : {
    1543                 :          6 :     sal_Bool bNoError = sal_True;
    1544                 :            : 
    1545         [ +  - ]:          6 :     Polygon aPolygon;
    1546         [ +  - ]:          6 :     PolyPolygon aPolyPolygon;
    1547                 :            : 
    1548 [ +  - ][ +  - ]:          6 :     if ( rAny.getValueType() == ::getCppuType( ( const ::com::sun::star::drawing::PolyPolygonBezierCoords* ) 0 ) )
    1549                 :            :     {
    1550                 :            :         ::com::sun::star::drawing::PolyPolygonBezierCoords* pSourcePolyPolygon
    1551                 :          6 :             = (::com::sun::star::drawing::PolyPolygonBezierCoords*)rAny.getValue();
    1552                 :          6 :         sal_uInt16 nOuterSequenceCount = (sal_uInt16)pSourcePolyPolygon->Coordinates.getLength();
    1553                 :            : 
    1554                 :            :         // Zeiger auf innere sequences holen
    1555         [ +  - ]:          6 :         ::com::sun::star::drawing::PointSequence* pOuterSequence = pSourcePolyPolygon->Coordinates.getArray();
    1556         [ +  - ]:          6 :         ::com::sun::star::drawing::FlagSequence*  pOuterFlags = pSourcePolyPolygon->Flags.getArray();
    1557                 :            : 
    1558 [ +  - ][ +  - ]:          6 :         bNoError = pOuterSequence && pOuterFlags;
    1559         [ +  - ]:          6 :         if ( bNoError )
    1560                 :            :         {
    1561                 :            :             sal_uInt16  a, b, nInnerSequenceCount;
    1562                 :            :             ::com::sun::star::awt::Point* pArray;
    1563                 :            : 
    1564                 :            :             // dies wird ein Polygon set
    1565         [ -  + ]:          6 :             for ( a = 0; a < nOuterSequenceCount; a++ )
    1566                 :            :             {
    1567                 :          0 :                 ::com::sun::star::drawing::PointSequence* pInnerSequence = pOuterSequence++;
    1568                 :          0 :                 ::com::sun::star::drawing::FlagSequence*  pInnerFlags = pOuterFlags++;
    1569                 :            : 
    1570 [ #  # ][ #  # ]:          0 :                 bNoError = pInnerSequence && pInnerFlags;
    1571         [ #  # ]:          0 :                 if  ( bNoError )
    1572                 :            :                 {
    1573                 :            :                     // Zeiger auf Arrays holen
    1574         [ #  # ]:          0 :                     pArray = pInnerSequence->getArray();
    1575         [ #  # ]:          0 :                     ::com::sun::star::drawing::PolygonFlags* pFlags = pInnerFlags->getArray();
    1576                 :            : 
    1577 [ #  # ][ #  # ]:          0 :                     if ( pArray && pFlags )
    1578                 :            :                     {
    1579                 :          0 :                         nInnerSequenceCount = (sal_uInt16)pInnerSequence->getLength();
    1580 [ #  # ][ #  # ]:          0 :                         aPolygon = Polygon( nInnerSequenceCount );
                 [ #  # ]
    1581         [ #  # ]:          0 :                         for( b = 0; b < nInnerSequenceCount; b++)
    1582                 :            :                         {
    1583                 :          0 :                             PolyFlags   ePolyFlags( *( (PolyFlags*)pFlags++ ) );
    1584                 :          0 :                             ::com::sun::star::awt::Point aPoint( (::com::sun::star::awt::Point)*(pArray++) );
    1585         [ #  # ]:          0 :                             aPolygon[ b ] = Point( aPoint.X, aPoint.Y );
    1586         [ #  # ]:          0 :                             aPolygon.SetFlags( b, ePolyFlags );
    1587                 :            : 
    1588         [ #  # ]:          0 :                             if ( ePolyFlags == POLY_CONTROL )
    1589                 :          0 :                                 continue;
    1590                 :            :                         }
    1591         [ #  # ]:          0 :                         aPolyPolygon.Insert( aPolygon, POLYPOLY_APPEND );
    1592                 :            :                     }
    1593                 :            :                 }
    1594                 :            :             }
    1595                 :            :         }
    1596                 :            :     }
    1597 [ #  # ][ #  # ]:          0 :     else if ( rAny.getValueType() == ::getCppuType( ( const ::com::sun::star::drawing::PointSequenceSequence* ) 0 ) )
    1598                 :            :     {
    1599                 :            :         ::com::sun::star::drawing::PointSequenceSequence* pSourcePolyPolygon
    1600                 :          0 :             = (::com::sun::star::drawing::PointSequenceSequence*)rAny.getValue();
    1601                 :          0 :         sal_uInt16 nOuterSequenceCount = (sal_uInt16)pSourcePolyPolygon->getLength();
    1602                 :            : 
    1603                 :            :         // Zeiger auf innere sequences holen
    1604         [ #  # ]:          0 :         ::com::sun::star::drawing::PointSequence* pOuterSequence = pSourcePolyPolygon->getArray();
    1605                 :          0 :         bNoError = pOuterSequence != NULL;
    1606         [ #  # ]:          0 :         if ( bNoError )
    1607                 :            :         {
    1608                 :            :             sal_uInt16 a, b, nInnerSequenceCount;
    1609                 :            : 
    1610                 :            :             // dies wird ein Polygon set
    1611         [ #  # ]:          0 :             for( a = 0; a < nOuterSequenceCount; a++ )
    1612                 :            :             {
    1613                 :          0 :                 ::com::sun::star::drawing::PointSequence* pInnerSequence = pOuterSequence++;
    1614                 :          0 :                 bNoError = pInnerSequence != NULL;
    1615         [ #  # ]:          0 :                 if ( bNoError )
    1616                 :            :                 {
    1617                 :            :                     // Zeiger auf Arrays holen
    1618                 :            :                     ::com::sun::star::awt::Point* pArray =
    1619         [ #  # ]:          0 :                           pInnerSequence->getArray();
    1620         [ #  # ]:          0 :                     if ( pArray != NULL )
    1621                 :            :                     {
    1622                 :          0 :                         nInnerSequenceCount = (sal_uInt16)pInnerSequence->getLength();
    1623 [ #  # ][ #  # ]:          0 :                         aPolygon = Polygon( nInnerSequenceCount );
                 [ #  # ]
    1624         [ #  # ]:          0 :                         for( b = 0; b < nInnerSequenceCount; b++)
    1625                 :            :                         {
    1626         [ #  # ]:          0 :                             aPolygon[ b ] = Point( pArray->X, pArray->Y );
    1627                 :          0 :                             pArray++;
    1628                 :            :                         }
    1629         [ #  # ]:          0 :                         aPolyPolygon.Insert( aPolygon, POLYPOLY_APPEND );
    1630                 :            :                     }
    1631                 :            :                 }
    1632                 :            :             }
    1633                 :            :         }
    1634                 :            :     }
    1635 [ #  # ][ #  # ]:          0 :     else if ( rAny.getValueType() == ::getCppuType( ( const ::com::sun::star::drawing::PointSequence* ) 0 ) )
    1636                 :            :     {
    1637                 :            :         ::com::sun::star::drawing::PointSequence* pInnerSequence =
    1638                 :          0 :             (::com::sun::star::drawing::PointSequence*)rAny.getValue();
    1639                 :            : 
    1640                 :          0 :         bNoError = pInnerSequence != NULL;
    1641         [ #  # ]:          0 :         if ( bNoError )
    1642                 :            :         {
    1643                 :            :             sal_uInt16 a, nInnerSequenceCount;
    1644                 :            : 
    1645                 :            :             // Zeiger auf Arrays holen
    1646         [ #  # ]:          0 :             ::com::sun::star::awt::Point* pArray = pInnerSequence->getArray();
    1647         [ #  # ]:          0 :             if ( pArray != NULL )
    1648                 :            :             {
    1649                 :          0 :                 nInnerSequenceCount = (sal_uInt16)pInnerSequence->getLength();
    1650 [ #  # ][ #  # ]:          0 :                 aPolygon = Polygon( nInnerSequenceCount );
                 [ #  # ]
    1651         [ #  # ]:          0 :                 for( a = 0; a < nInnerSequenceCount; a++)
    1652                 :            :                 {
    1653         [ #  # ]:          0 :                     aPolygon[ a ] = Point( pArray->X, pArray->Y );
    1654                 :          0 :                     pArray++;
    1655                 :            :                 }
    1656         [ #  # ]:          0 :                 aPolyPolygon.Insert( aPolygon, POLYPOLY_APPEND );
    1657                 :            :             }
    1658                 :            :         }
    1659                 :            :     }
    1660         [ +  - ]:          6 :     return aPolyPolygon;
    1661                 :            : }
    1662                 :            : 
    1663                 :          0 : sal_Bool EscherPropertyContainer::CreatePolygonProperties(
    1664                 :            :     const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rXPropSet,
    1665                 :            :         sal_uInt32 nFlags,
    1666                 :            :             sal_Bool bBezier,
    1667                 :            :                 ::com::sun::star::awt::Rectangle& rGeoRect,
    1668                 :            :                     Polygon* pPolygon )
    1669                 :            : {
    1670 [ #  # ][ #  # ]:          0 :     static String sPolyPolygonBezier( RTL_CONSTASCII_USTRINGPARAM( "PolyPolygonBezier" ) );
         [ #  # ][ #  # ]
    1671 [ #  # ][ #  # ]:          0 :     static String sPolyPolygon      ( RTL_CONSTASCII_USTRINGPARAM( "PolyPolygon" ) );
         [ #  # ][ #  # ]
    1672                 :            : 
    1673                 :          0 :     sal_Bool    bRetValue = sal_True;
    1674                 :          0 :     sal_Bool    bLine = ( nFlags & ESCHER_CREATEPOLYGON_LINE ) != 0;
    1675                 :            : 
    1676         [ #  # ]:          0 :     PolyPolygon aPolyPolygon;
    1677                 :            : 
    1678         [ #  # ]:          0 :     if ( pPolygon )
    1679         [ #  # ]:          0 :         aPolyPolygon.Insert( *pPolygon, POLYPOLY_APPEND );
    1680                 :            :     else
    1681                 :            :     {
    1682                 :          0 :         ::com::sun::star::uno::Any aAny;
    1683                 :            :         bRetValue = EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet,
    1684 [ #  # ][ #  # ]:          0 :                         ( bBezier ) ? sPolyPolygonBezier : sPolyPolygon, sal_True );
    1685         [ #  # ]:          0 :         if ( bRetValue )
    1686                 :            :         {
    1687 [ #  # ][ #  # ]:          0 :             aPolyPolygon = GetPolyPolygon( aAny );
                 [ #  # ]
    1688         [ #  # ]:          0 :             bRetValue = aPolyPolygon.Count() != 0;
    1689                 :          0 :         }
    1690                 :            :     }
    1691         [ #  # ]:          0 :     if ( bRetValue )
    1692                 :            :     {
    1693         [ #  # ]:          0 :         if ( bLine )
    1694                 :            :         {
    1695 [ #  # ][ #  # ]:          0 :             if ( ( aPolyPolygon.Count() == 1 ) && ( aPolyPolygon[ 0 ].GetSize() == 2 ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1696                 :            :             {
    1697         [ #  # ]:          0 :                 const Polygon& rPoly = aPolyPolygon[ 0 ];
    1698                 :            :                 rGeoRect = ::com::sun::star::awt::Rectangle(
    1699         [ #  # ]:          0 :                     rPoly[ 0 ].X(),
    1700         [ #  # ]:          0 :                         rPoly[ 0 ].Y(),
    1701 [ #  # ][ #  # ]:          0 :                             rPoly[ 1 ].X() - rPoly[ 0 ].X(),
    1702 [ #  # ][ #  # ]:          0 :                                 rPoly[ 1 ].Y() - rPoly[ 0 ].Y() );
    1703                 :            :             }
    1704                 :            :             else
    1705                 :          0 :                 bRetValue = sal_False;
    1706                 :            :         }
    1707                 :            :         else
    1708                 :            :         {
    1709         [ #  # ]:          0 :             Polygon aPolygon;
    1710                 :            : 
    1711         [ #  # ]:          0 :             sal_uInt16 i, j, k, nPoints, nBezPoints, nPolyCount = aPolyPolygon.Count();
    1712         [ #  # ]:          0 :             Rectangle aRect( aPolyPolygon.GetBoundRect() );
    1713 [ #  # ][ #  # ]:          0 :             rGeoRect = ::com::sun::star::awt::Rectangle( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight() );
    1714                 :            : 
    1715         [ #  # ]:          0 :             for ( nBezPoints = nPoints = i = 0; i < nPolyCount; i++ )
    1716                 :            :             {
    1717 [ #  # ][ #  # ]:          0 :                 k = aPolyPolygon[ i ].GetSize();
    1718                 :          0 :                 nPoints = nPoints + k;
    1719         [ #  # ]:          0 :                 for ( j = 0; j < k; j++ )
    1720                 :            :                 {
    1721 [ #  # ][ #  # ]:          0 :                     if ( aPolyPolygon[ i ].GetFlags( j ) != POLY_CONTROL )
                 [ #  # ]
    1722                 :          0 :                         nBezPoints++;
    1723                 :            :                 }
    1724                 :            :             }
    1725                 :          0 :             sal_uInt32 nVerticesBufSize = ( nPoints << 2 ) + 6;
    1726         [ #  # ]:          0 :             sal_uInt8* pVerticesBuf = new sal_uInt8[ nVerticesBufSize ];
    1727                 :            : 
    1728                 :            : 
    1729                 :          0 :             sal_uInt32 nSegmentBufSize = ( ( nBezPoints << 2 ) + 8 );
    1730         [ #  # ]:          0 :             if ( nPolyCount > 1 )
    1731                 :          0 :                 nSegmentBufSize += ( nPolyCount << 1 );
    1732         [ #  # ]:          0 :             sal_uInt8* pSegmentBuf = new sal_uInt8[ nSegmentBufSize ];
    1733                 :            : 
    1734                 :          0 :             sal_uInt8* pPtr = pVerticesBuf;
    1735                 :          0 :             *pPtr++ = (sal_uInt8)( nPoints );                    // Little endian
    1736                 :          0 :             *pPtr++ = (sal_uInt8)( nPoints >> 8 );
    1737                 :          0 :             *pPtr++ = (sal_uInt8)( nPoints );
    1738                 :          0 :             *pPtr++ = (sal_uInt8)( nPoints >> 8 );
    1739                 :          0 :             *pPtr++ = (sal_uInt8)0xf0;
    1740                 :          0 :             *pPtr++ = (sal_uInt8)0xff;
    1741                 :            : 
    1742         [ #  # ]:          0 :             for ( j = 0; j < nPolyCount; j++ )
    1743                 :            :             {
    1744 [ #  # ][ #  # ]:          0 :                 aPolygon = aPolyPolygon[ j ];
    1745         [ #  # ]:          0 :                 nPoints = aPolygon.GetSize();
    1746         [ #  # ]:          0 :                 for ( i = 0; i < nPoints; i++ )             // write points from polygon to buffer
    1747                 :            :                 {
    1748         [ #  # ]:          0 :                     Point aPoint = aPolygon[ i ];
    1749                 :          0 :                     aPoint.X() -= rGeoRect.X;
    1750                 :          0 :                     aPoint.Y() -= rGeoRect.Y;
    1751                 :            : 
    1752                 :          0 :                     *pPtr++ = (sal_uInt8)( aPoint.X() );
    1753                 :          0 :                     *pPtr++ = (sal_uInt8)( aPoint.X() >> 8 );
    1754                 :          0 :                     *pPtr++ = (sal_uInt8)( aPoint.Y() );
    1755                 :          0 :                     *pPtr++ = (sal_uInt8)( aPoint.Y() >> 8 );
    1756                 :            :                 }
    1757                 :            :             }
    1758                 :            : 
    1759                 :          0 :             pPtr = pSegmentBuf;
    1760                 :          0 :             *pPtr++ = (sal_uInt8)( ( nSegmentBufSize - 6 ) >> 1 );
    1761                 :          0 :             *pPtr++ = (sal_uInt8)( ( nSegmentBufSize - 6 ) >> 9 );
    1762                 :          0 :             *pPtr++ = (sal_uInt8)( ( nSegmentBufSize - 6 ) >> 1 );
    1763                 :          0 :             *pPtr++ = (sal_uInt8)( ( nSegmentBufSize - 6 ) >> 9 );
    1764                 :          0 :             *pPtr++ = (sal_uInt8)2;
    1765                 :          0 :             *pPtr++ = (sal_uInt8)0;
    1766                 :            : 
    1767         [ #  # ]:          0 :             for ( j = 0; j < nPolyCount; j++ )
    1768                 :            :             {
    1769                 :          0 :                 *pPtr++ = 0x0;          // Polygon start
    1770                 :          0 :                 *pPtr++ = 0x40;
    1771 [ #  # ][ #  # ]:          0 :                 aPolygon = aPolyPolygon[ j ];
    1772         [ #  # ]:          0 :                 nPoints = aPolygon.GetSize();
    1773         [ #  # ]:          0 :                 for ( i = 0; i < nPoints; i++ )         // write Polyflags to Buffer
    1774                 :            :                 {
    1775                 :          0 :                     *pPtr++ = 0;
    1776         [ #  # ]:          0 :                     if ( bBezier )
    1777                 :          0 :                         *pPtr++ = 0xb3;
    1778                 :            :                     else
    1779                 :          0 :                         *pPtr++ = 0xac;
    1780         [ #  # ]:          0 :                     if ( ( i + 1 ) != nPoints )
    1781                 :            :                     {
    1782                 :          0 :                         *pPtr++ = 1;
    1783 [ #  # ][ #  # ]:          0 :                         if ( aPolygon.GetFlags( i + 1 ) == POLY_CONTROL )
    1784                 :            :                         {
    1785                 :          0 :                             *pPtr++ = 0x20;
    1786                 :          0 :                             i += 2;
    1787                 :            :                         }
    1788                 :            :                         else
    1789                 :          0 :                             *pPtr++ = 0;
    1790                 :            :                     }
    1791                 :            :                 }
    1792         [ #  # ]:          0 :                 if ( nPolyCount > 1 )
    1793                 :            :                 {
    1794                 :          0 :                     *pPtr++ = 1;                        // end of polygon
    1795                 :          0 :                     *pPtr++ = 0x60;
    1796                 :            :                 }
    1797                 :            :             }
    1798                 :          0 :             *pPtr++ = 0;
    1799                 :          0 :             *pPtr++ = 0x80;
    1800                 :            : 
    1801         [ #  # ]:          0 :             AddOpt( ESCHER_Prop_geoRight, rGeoRect.Width );
    1802         [ #  # ]:          0 :             AddOpt( ESCHER_Prop_geoBottom, rGeoRect.Height );
    1803                 :            : 
    1804         [ #  # ]:          0 :             AddOpt( ESCHER_Prop_shapePath, ESCHER_ShapeComplex );
    1805         [ #  # ]:          0 :             AddOpt( ESCHER_Prop_pVertices, sal_True, nVerticesBufSize - 6, (sal_uInt8*)pVerticesBuf, nVerticesBufSize );
    1806 [ #  # ][ #  # ]:          0 :             AddOpt( ESCHER_Prop_pSegmentInfo, sal_True, nSegmentBufSize, (sal_uInt8*)pSegmentBuf, nSegmentBufSize );
    1807                 :            :         }
    1808                 :            :     }
    1809         [ #  # ]:          0 :     return bRetValue;
    1810                 :            : }
    1811                 :            : 
    1812                 :          0 : sal_Bool EscherPropertyContainer::CreateConnectorProperties(
    1813                 :            :     const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & rXShape,
    1814                 :            :     EscherSolverContainer& rSolverContainer, ::com::sun::star::awt::Rectangle& rGeoRect,
    1815                 :            :             sal_uInt16& rShapeType, sal_uInt16& rShapeFlags )
    1816                 :            : {
    1817 [ #  # ][ #  # ]:          0 :     static String sEdgeKind             ( RTL_CONSTASCII_USTRINGPARAM( "EdgeKind" ) );
         [ #  # ][ #  # ]
    1818 [ #  # ][ #  # ]:          0 :     static String sEdgeStartPoint       ( RTL_CONSTASCII_USTRINGPARAM( "EdgeStartPoint" ) );
         [ #  # ][ #  # ]
    1819 [ #  # ][ #  # ]:          0 :     static String sEdgeEndPoint         ( RTL_CONSTASCII_USTRINGPARAM( "EdgeEndPoint" ) );
         [ #  # ][ #  # ]
    1820 [ #  # ][ #  # ]:          0 :     static String sEdgeStartConnection  ( RTL_CONSTASCII_USTRINGPARAM( "EdgeStartConnection" ) );
         [ #  # ][ #  # ]
    1821 [ #  # ][ #  # ]:          0 :     static String sEdgeEndConnection    ( RTL_CONSTASCII_USTRINGPARAM( "EdgeEndConnection" ) );
         [ #  # ][ #  # ]
    1822                 :            : 
    1823                 :          0 :     sal_Bool bRetValue = sal_False;
    1824                 :          0 :     rShapeType = rShapeFlags = 0;
    1825                 :            : 
    1826         [ #  # ]:          0 :     if ( rXShape.is() )
    1827                 :            :     {
    1828                 :          0 :         ::com::sun::star::awt::Point aStartPoint, aEndPoint;
    1829                 :          0 :         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > aXPropSet;
    1830                 :          0 :         ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > aShapeA, aShapeB;
    1831 [ #  # ][ #  # ]:          0 :         ::com::sun::star::uno::Any aAny( rXShape->queryInterface( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >*) 0 ) ));
                 [ #  # ]
    1832 [ #  # ][ #  # ]:          0 :         if ( aAny >>= aXPropSet )
    1833                 :            :         {
    1834 [ #  # ][ #  # ]:          0 :             if ( EscherPropertyValueHelper::GetPropertyValue( aAny, aXPropSet, sEdgeKind, sal_True ) )
    1835                 :            :             {
    1836                 :            :                 ::com::sun::star::drawing::ConnectorType eCt;
    1837         [ #  # ]:          0 :                 aAny >>= eCt;
    1838 [ #  # ][ #  # ]:          0 :                 if ( EscherPropertyValueHelper::GetPropertyValue( aAny, aXPropSet, sEdgeStartPoint ) )
    1839                 :            :                 {
    1840                 :          0 :                     aStartPoint = *(::com::sun::star::awt::Point*)aAny.getValue();
    1841 [ #  # ][ #  # ]:          0 :                     if ( EscherPropertyValueHelper::GetPropertyValue( aAny, aXPropSet, sEdgeEndPoint ) )
    1842                 :            :                     {
    1843                 :          0 :                         aEndPoint = *(::com::sun::star::awt::Point*)aAny.getValue();
    1844                 :            : 
    1845                 :          0 :                         rShapeFlags = SHAPEFLAG_HAVEANCHOR | SHAPEFLAG_HAVESPT | SHAPEFLAG_CONNECTOR;
    1846                 :            :                         rGeoRect = ::com::sun::star::awt::Rectangle( aStartPoint.X, aStartPoint.Y,
    1847                 :          0 :                                                             ( aEndPoint.X - aStartPoint.X ) + 1, ( aEndPoint.Y - aStartPoint.Y ) + 1 );
    1848         [ #  # ]:          0 :                         if ( rGeoRect.Height < 0 )          // justify
    1849                 :            :                         {
    1850                 :          0 :                             rShapeFlags |= SHAPEFLAG_FLIPV;
    1851                 :          0 :                             rGeoRect.Y = aEndPoint.Y;
    1852                 :          0 :                             rGeoRect.Height = -rGeoRect.Height;
    1853                 :            :                         }
    1854         [ #  # ]:          0 :                         if ( rGeoRect.Width < 0 )
    1855                 :            :                         {
    1856                 :          0 :                             rShapeFlags |= SHAPEFLAG_FLIPH;
    1857                 :          0 :                             rGeoRect.X = aEndPoint.X;
    1858                 :          0 :                             rGeoRect.Width = -rGeoRect.Width;
    1859                 :            :                         }
    1860                 :            :                         sal_uInt32 nAdjustValue1, nAdjustValue2, nAdjustValue3;
    1861                 :          0 :                         nAdjustValue1 = nAdjustValue2 = nAdjustValue3 = 0x2a30;
    1862                 :            : 
    1863 [ #  # ][ #  # ]:          0 :                         if ( EscherPropertyValueHelper::GetPropertyValue( aAny, aXPropSet, sEdgeStartConnection ) )
    1864         [ #  # ]:          0 :                             aAny >>= aShapeA;
    1865 [ #  # ][ #  # ]:          0 :                         if ( EscherPropertyValueHelper::GetPropertyValue( aAny, aXPropSet, sEdgeEndConnection ) )
    1866         [ #  # ]:          0 :                             aAny >>= aShapeB;
    1867         [ #  # ]:          0 :                         rSolverContainer.AddConnector( rXShape, aStartPoint, aShapeA, aEndPoint, aShapeB );
    1868      [ #  #  # ]:          0 :                         switch ( eCt )
    1869                 :            :                         {
    1870                 :            :                             case ::com::sun::star::drawing::ConnectorType_CURVE :
    1871                 :            :                             {
    1872                 :          0 :                                 rShapeType = ESCHER_ShpInst_CurvedConnector3;
    1873         [ #  # ]:          0 :                                 AddOpt( ESCHER_Prop_cxstyle, ESCHER_cxstyleCurved );
    1874         [ #  # ]:          0 :                                 AddOpt( ESCHER_Prop_adjustValue, nAdjustValue1 );
    1875         [ #  # ]:          0 :                                 AddOpt( ESCHER_Prop_adjust2Value, -(sal_Int32)nAdjustValue2 );
    1876                 :            :                             }
    1877                 :          0 :                             break;
    1878                 :            : 
    1879                 :            :                             case ::com::sun::star::drawing::ConnectorType_STANDARD :// Connector 2->5
    1880                 :            :                             {
    1881                 :          0 :                                 rShapeType = ESCHER_ShpInst_BentConnector3;
    1882         [ #  # ]:          0 :                                 AddOpt( ESCHER_Prop_cxstyle, ESCHER_cxstyleBent );
    1883                 :            :                             }
    1884                 :          0 :                             break;
    1885                 :            : 
    1886                 :            :                             default:
    1887                 :            :                             case ::com::sun::star::drawing::ConnectorType_LINE :
    1888                 :            :                             case ::com::sun::star::drawing::ConnectorType_LINES :   // Connector 2->5
    1889                 :            :                             {
    1890                 :          0 :                                 rShapeType = ESCHER_ShpInst_StraightConnector1;
    1891         [ #  # ]:          0 :                                 AddOpt( ESCHER_Prop_cxstyle, ESCHER_cxstyleStraight );
    1892                 :            :                             }
    1893                 :          0 :                             break;
    1894                 :            :                         }
    1895         [ #  # ]:          0 :                         CreateLineProperties( aXPropSet, sal_False );
    1896                 :          0 :                         bRetValue = bSuppressRotation = sal_True;
    1897                 :            :                     }
    1898                 :            :                 }
    1899                 :            :             }
    1900                 :          0 :         }
    1901                 :            :     }
    1902                 :          0 :     return bRetValue;
    1903                 :            : }
    1904                 :            : 
    1905                 :          3 : sal_Bool EscherPropertyContainer::CreateShadowProperties(
    1906                 :            :     const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rXPropSet )
    1907                 :            : {
    1908                 :          3 :     ::com::sun::star::uno::Any aAny;
    1909                 :            : 
    1910                 :          3 :     sal_Bool    bHasShadow = sal_False; // shadow is possible only if at least a fillcolor, linecolor or graphic is set
    1911                 :          3 :     sal_uInt32  nLineFlags = 0;         // default : shape has no line
    1912                 :          3 :     sal_uInt32  nFillFlags = 0x10;      //           shape is filled
    1913                 :            : 
    1914         [ +  - ]:          3 :     GetOpt( ESCHER_Prop_fNoLineDrawDash, nLineFlags );
    1915         [ +  - ]:          3 :     GetOpt( ESCHER_Prop_fNoFillHitTest, nFillFlags );
    1916                 :            : 
    1917                 :            :     sal_uInt32 nDummy;
    1918 [ +  - ][ +  - ]:          3 :     sal_Bool bGraphic = GetOpt( DFF_Prop_pib, nDummy ) || GetOpt( DFF_Prop_pibName, nDummy ) || GetOpt( DFF_Prop_pibFlags, nDummy );
         [ +  - ][ +  - ]
         [ +  - ][ -  + ]
    1919                 :            : 
    1920                 :          3 :     sal_uInt32 nShadowFlags = 0x20000;
    1921 [ -  + ][ #  # ]:          3 :     if ( ( nLineFlags & 8 ) || ( nFillFlags & 0x10 ) || bGraphic )
                 [ #  # ]
    1922                 :            :     {
    1923         [ +  - ]:          3 :         if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet,
    1924 [ +  - ][ +  - ]:          3 :                 String( RTL_CONSTASCII_USTRINGPARAM( "Shadow" ) ), sal_True ) )
                 [ +  - ]
    1925                 :            :         {
    1926         [ +  - ]:          3 :             if ( aAny >>= bHasShadow )
    1927                 :            :             {
    1928         [ -  + ]:          3 :                 if ( bHasShadow )
    1929                 :            :                 {
    1930                 :          0 :                     nShadowFlags |= 2;
    1931         [ #  # ]:          0 :                     if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet,
    1932 [ #  # ][ #  # ]:          0 :                             String( RTL_CONSTASCII_USTRINGPARAM( "ShadowColor" ) ), sal_False ) )
                 [ #  # ]
    1933 [ #  # ][ #  # ]:          0 :                         AddOpt( ESCHER_Prop_shadowColor, ImplGetColor( *((sal_uInt32*)aAny.getValue()) ) );
    1934         [ #  # ]:          0 :                     if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet,
    1935 [ #  # ][ #  # ]:          0 :                             String( RTL_CONSTASCII_USTRINGPARAM( "ShadowXDistance" ) ), sal_False ) )
                 [ #  # ]
    1936         [ #  # ]:          0 :                         AddOpt( ESCHER_Prop_shadowOffsetX, *((sal_Int32*)aAny.getValue()) * 360 );
    1937         [ #  # ]:          0 :                     if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet,
    1938 [ #  # ][ #  # ]:          0 :                             String( RTL_CONSTASCII_USTRINGPARAM( "ShadowYDistance" ) ), sal_False ) )
                 [ #  # ]
    1939         [ #  # ]:          0 :                         AddOpt( ESCHER_Prop_shadowOffsetY, *((sal_Int32*)aAny.getValue()) * 360 );
    1940         [ #  # ]:          0 :                     if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet,
    1941 [ #  # ][ #  # ]:          0 :                             String( RTL_CONSTASCII_USTRINGPARAM( "ShadowTransparence" ) ), sal_False ) )
                 [ #  # ]
    1942         [ #  # ]:          0 :                         AddOpt( ESCHER_Prop_shadowOpacity,  0x10000 - (((sal_uInt32)*((sal_uInt16*)aAny.getValue())) * 655 ) );
    1943                 :            :                 }
    1944                 :            :             }
    1945                 :            :         }
    1946                 :            :     }
    1947         [ +  - ]:          3 :     AddOpt( ESCHER_Prop_fshadowObscured, nShadowFlags );
    1948                 :          3 :     return bHasShadow;
    1949                 :            : }
    1950                 :            : 
    1951                 :         96 : sal_Int32 GetValueForEnhancedCustomShapeParameter( const com::sun::star::drawing::EnhancedCustomShapeParameter& rParameter, const std::vector< sal_Int32 >& rEquationOrder )
    1952                 :            : {
    1953                 :         96 :     sal_Int32 nValue = 0;
    1954         [ -  + ]:         96 :     if ( rParameter.Value.getValueTypeClass() == uno::TypeClass_DOUBLE )
    1955                 :            :     {
    1956                 :          0 :         double fValue(0.0);
    1957         [ #  # ]:          0 :         if ( rParameter.Value >>= fValue )
    1958                 :          0 :             nValue = (sal_Int32)fValue;
    1959                 :            :     }
    1960                 :            :     else
    1961                 :         96 :         rParameter.Value >>= nValue;
    1962                 :            : 
    1963      [ -  +  - ]:         96 :     switch( rParameter.Type )
    1964                 :            :     {
    1965                 :            :         case com::sun::star::drawing::EnhancedCustomShapeParameterType::EQUATION :
    1966                 :            :         {
    1967         [ #  # ]:          0 :             nValue = (sal_uInt16)rEquationOrder[ nValue ];
    1968                 :          0 :             nValue |= (sal_uInt32)0x80000000;
    1969                 :            :         }
    1970                 :          0 :         break;
    1971                 :            :         case com::sun::star::drawing::EnhancedCustomShapeParameterType::NORMAL :
    1972                 :            :         {
    1973                 :            : 
    1974                 :            :         }
    1975                 :         96 :         break;
    1976                 :            :     }
    1977                 :         96 :     return nValue;
    1978                 :            : }
    1979                 :            : 
    1980                 :          0 : sal_Bool GetValueForEnhancedCustomShapeHandleParameter( sal_Int32& nRetValue, const com::sun::star::drawing::EnhancedCustomShapeParameter& rParameter )
    1981                 :            : {
    1982                 :          0 :     sal_Bool bSpecial = sal_False;
    1983                 :          0 :     nRetValue = 0;
    1984         [ #  # ]:          0 :     if ( rParameter.Value.getValueTypeClass() == uno::TypeClass_DOUBLE )
    1985                 :            :     {
    1986                 :          0 :         double fValue(0.0);
    1987         [ #  # ]:          0 :         if ( rParameter.Value >>= fValue )
    1988                 :          0 :             nRetValue = (sal_Int32)fValue;
    1989                 :            :     }
    1990                 :            :     else
    1991                 :          0 :         rParameter.Value >>= nRetValue;
    1992                 :            : 
    1993   [ #  #  #  #  :          0 :     switch( rParameter.Type )
                   #  # ]
    1994                 :            :     {
    1995                 :            :         case com::sun::star::drawing::EnhancedCustomShapeParameterType::EQUATION :
    1996                 :            :         {
    1997                 :          0 :             nRetValue += 3;
    1998                 :          0 :             bSpecial = sal_True;
    1999                 :            :         }
    2000                 :          0 :         break;
    2001                 :            :         case com::sun::star::drawing::EnhancedCustomShapeParameterType::ADJUSTMENT :
    2002                 :            :         {
    2003                 :          0 :             nRetValue += 0x100;
    2004                 :          0 :             bSpecial = sal_True;
    2005                 :            :         }
    2006                 :          0 :         break;
    2007                 :            :         case com::sun::star::drawing::EnhancedCustomShapeParameterType::TOP :
    2008                 :            :         case com::sun::star::drawing::EnhancedCustomShapeParameterType::LEFT :
    2009                 :            :         {
    2010                 :          0 :             nRetValue = 0;
    2011                 :          0 :             bSpecial = sal_True;
    2012                 :            :         }
    2013                 :          0 :         break;
    2014                 :            :         case com::sun::star::drawing::EnhancedCustomShapeParameterType::RIGHT :
    2015                 :            :         case com::sun::star::drawing::EnhancedCustomShapeParameterType::BOTTOM :
    2016                 :            :         {
    2017                 :          0 :             nRetValue = 1;
    2018                 :          0 :             bSpecial = sal_True;
    2019                 :            :         }
    2020                 :          0 :         break;
    2021                 :            :         case com::sun::star::drawing::EnhancedCustomShapeParameterType::NORMAL :
    2022                 :            :         {
    2023                 :            : 
    2024                 :            :         }
    2025                 :          0 :         break;
    2026                 :            :     }
    2027                 :          0 :     return bSpecial;
    2028                 :            : }
    2029                 :            : 
    2030                 :          3 : void ConvertEnhancedCustomShapeEquation( SdrObjCustomShape* pCustoShape,
    2031                 :            :         std::vector< EnhancedCustomShapeEquation >& rEquations, std::vector< sal_Int32 >& rEquationOrder )
    2032                 :            : {
    2033         [ +  - ]:          3 :     if ( pCustoShape )
    2034                 :            :     {
    2035         [ +  - ]:          3 :         uno::Sequence< rtl::OUString > sEquationSource;
    2036                 :          3 :         const rtl::OUString sEquations( "Equations"  );
    2037                 :            :         SdrCustomShapeGeometryItem& rGeometryItem = (SdrCustomShapeGeometryItem&)(const SdrCustomShapeGeometryItem&)
    2038         [ +  - ]:          3 :             pCustoShape->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
    2039         [ +  - ]:          3 :         const uno::Any* pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sEquations );
    2040         [ -  + ]:          3 :         if ( pAny )
    2041         [ #  # ]:          0 :             *pAny >>= sEquationSource;
    2042                 :          3 :         sal_Int32 nEquationSourceCount = sEquationSource.getLength();
    2043         [ -  + ]:          3 :         if ( nEquationSourceCount )
    2044                 :            :         {
    2045                 :            :             sal_Int32 i;
    2046         [ #  # ]:          0 :             for ( i = 0; i < nEquationSourceCount; i++ )
    2047                 :            :             {
    2048         [ #  # ]:          0 :                 EnhancedCustomShape2d aCustoShape2d( pCustoShape );
    2049                 :            :                 try
    2050                 :            :                 {
    2051                 :            :                     ::boost::shared_ptr< EnhancedCustomShape::ExpressionNode > aExpressNode(
    2052 [ #  # ][ #  # ]:          0 :                         EnhancedCustomShape::FunctionParser::parseFunction( sEquationSource[ i ], aCustoShape2d ) );
    2053         [ #  # ]:          0 :                     com::sun::star::drawing::EnhancedCustomShapeParameter aPara( aExpressNode->fillNode( rEquations, NULL, 0 ) );
    2054         [ #  # ]:          0 :                     if ( aPara.Type != com::sun::star::drawing::EnhancedCustomShapeParameterType::EQUATION )
    2055                 :            :                     {
    2056                 :          0 :                         EnhancedCustomShapeEquation aEquation;
    2057                 :          0 :                         aEquation.nOperation = 0;
    2058         [ #  # ]:          0 :                         EnhancedCustomShape::FillEquationParameter( aPara, 0, aEquation );
    2059         [ #  # ]:          0 :                         rEquations.push_back( aEquation );
    2060         [ #  # ]:          0 :                     }
    2061                 :            :                 }
    2062                 :          0 :                 catch ( const EnhancedCustomShape::ParseError& )
    2063                 :            :                 {
    2064                 :          0 :                     EnhancedCustomShapeEquation aEquation;      // ups, we should not be here,
    2065                 :          0 :                     aEquation.nOperation = 0;                   // creating a default equation with value 1
    2066                 :          0 :                     aEquation.nPara[ 0 ] = 1;                   // hoping that this will not break anything
    2067         [ #  # ]:          0 :                     rEquations.push_back( aEquation );
    2068                 :            :                 }
    2069   [ #  #  #  # ]:          0 :                 catch ( ... )
    2070                 :            :                 {
    2071                 :          0 :                     EnhancedCustomShapeEquation aEquation;      // #i112309# EnhancedCustomShape::Parse error
    2072                 :          0 :                     aEquation.nOperation = 0;                   // not catched on linux platform
    2073                 :          0 :                     aEquation.nPara[ 0 ] = 1;
    2074         [ #  # ]:          0 :                     rEquations.push_back( aEquation );
    2075                 :            :                 }
    2076         [ #  # ]:          0 :                 rEquationOrder.push_back( rEquations.size() - 1 );
    2077         [ #  # ]:          0 :             }
    2078                 :            :             // now updating our old equation indices, they are marked with a bit in the hiword of nOperation
    2079                 :          0 :             std::vector< EnhancedCustomShapeEquation >::iterator aIter( rEquations.begin() );
    2080                 :          0 :             std::vector< EnhancedCustomShapeEquation >::iterator aEnd ( rEquations.end() );
    2081 [ #  # ][ #  # ]:          0 :             while( aIter != aEnd )
    2082                 :            :             {
    2083                 :          0 :                 sal_Int32 nMask = 0x20000000;
    2084         [ #  # ]:          0 :                 for( i = 0; i < 3; i++ )
    2085                 :            :                 {
    2086         [ #  # ]:          0 :                     if ( aIter->nOperation & nMask )
    2087                 :            :                     {
    2088                 :          0 :                         aIter->nOperation ^= nMask;
    2089         [ #  # ]:          0 :                         aIter->nPara[ i ] = rEquationOrder[ aIter->nPara[ i ] & 0x3ff ] | 0x400;
    2090                 :            :                     }
    2091                 :          0 :                     nMask <<= 1;
    2092                 :            :                 }
    2093                 :          0 :                 ++aIter;
    2094                 :            :             }
    2095         [ +  - ]:          3 :         }
    2096                 :            :     }
    2097                 :          3 : }
    2098                 :            : 
    2099                 :          3 : sal_Bool EscherPropertyContainer::IsDefaultObject( SdrObjCustomShape* pCustoShape )
    2100                 :            : {
    2101                 :          3 :     sal_Bool bIsDefaultObject = sal_False;
    2102         [ +  - ]:          3 :     if ( pCustoShape )
    2103                 :            :     {
    2104   [ -  +  #  #  :          3 :     if (   pCustoShape->IsDefaultGeometry( SdrObjCustomShape::DEFAULT_EQUATIONS )
          #  #  #  #  #  
          #  #  #  #  #  
           #  # ][ -  + ]
    2105                 :          0 :            && pCustoShape->IsDefaultGeometry( SdrObjCustomShape::DEFAULT_VIEWBOX )
    2106                 :          0 :            && pCustoShape->IsDefaultGeometry( SdrObjCustomShape::DEFAULT_PATH )
    2107                 :          0 :            && pCustoShape->IsDefaultGeometry( SdrObjCustomShape::DEFAULT_GLUEPOINTS )
    2108                 :          0 :            && pCustoShape->IsDefaultGeometry( SdrObjCustomShape::DEFAULT_SEGMENTS )
    2109                 :          0 :            && pCustoShape->IsDefaultGeometry( SdrObjCustomShape::DEFAULT_STRETCHX )
    2110                 :          0 :            && pCustoShape->IsDefaultGeometry( SdrObjCustomShape::DEFAULT_STRETCHY )
    2111                 :          0 :            && pCustoShape->IsDefaultGeometry( SdrObjCustomShape::DEFAULT_TEXTFRAMES ) )
    2112                 :          0 :         bIsDefaultObject = sal_True;
    2113                 :            :     }
    2114                 :            : 
    2115                 :          3 :     return bIsDefaultObject;
    2116                 :            : }
    2117                 :            : 
    2118                 :          3 : void EscherPropertyContainer::LookForPolarHandles( const MSO_SPT eShapeType, sal_Int32& nAdjustmentsWhichNeedsToBeConverted )
    2119                 :            : {
    2120                 :          3 :     const mso_CustomShape* pDefCustomShape = GetCustomShapeContent( eShapeType );
    2121 [ #  # ][ #  # ]:          3 :     if ( pDefCustomShape && pDefCustomShape->nHandles && pDefCustomShape->pHandles )
                 [ -  + ]
    2122                 :            :     {
    2123                 :          0 :     sal_Int32 k, nkCount = pDefCustomShape->nHandles;
    2124                 :          0 :     const SvxMSDffHandle* pData = pDefCustomShape->pHandles;
    2125         [ #  # ]:          0 :     for ( k = 0; k < nkCount; k++, pData++ )
    2126                 :            :     {
    2127         [ #  # ]:          0 :         if ( pData->nFlags & MSDFF_HANDLE_FLAGS_POLAR )
    2128                 :            :         {
    2129 [ #  # ][ #  # ]:          0 :         if ( ( pData->nPositionY >= 0x256 ) || ( pData->nPositionY <= 0x107 ) )
    2130                 :          0 :             nAdjustmentsWhichNeedsToBeConverted |= ( 1 << k );
    2131                 :            :         }
    2132                 :            :     }
    2133                 :            :     }
    2134                 :          3 : }
    2135                 :            : 
    2136                 :          0 : sal_Bool EscherPropertyContainer::GetAdjustmentValue( const com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue & rkProp, sal_Int32 nIndex, sal_Int32 nAdjustmentsWhichNeedsToBeConverted, sal_Int32& nValue )
    2137                 :            : {
    2138         [ #  # ]:          0 :     if ( rkProp.State != beans::PropertyState_DIRECT_VALUE )
    2139                 :          0 :     return sal_False;
    2140                 :            : 
    2141                 :          0 :     sal_Bool bUseFixedFloat = ( nAdjustmentsWhichNeedsToBeConverted & ( 1 << nIndex ) ) != 0;
    2142         [ #  # ]:          0 :     if ( rkProp.Value.getValueTypeClass() == uno::TypeClass_DOUBLE )
    2143                 :            :     {
    2144                 :          0 :     double fValue(0.0);
    2145                 :          0 :     rkProp.Value >>= fValue;
    2146         [ #  # ]:          0 :     if ( bUseFixedFloat )
    2147                 :          0 :         fValue *= 65536.0;
    2148                 :          0 :     nValue = (sal_Int32)fValue;
    2149                 :            :     }
    2150                 :            :     else
    2151                 :            :     {
    2152                 :          0 :     rkProp.Value >>= nValue;
    2153         [ #  # ]:          0 :     if ( bUseFixedFloat )
    2154                 :          0 :         nValue <<= 16;
    2155                 :            :     }
    2156                 :            : 
    2157                 :          0 :     return sal_True;
    2158                 :            : }
    2159                 :            : 
    2160                 :          3 : void EscherPropertyContainer::CreateCustomShapeProperties( const MSO_SPT eShapeType, const uno::Reference< drawing::XShape > & rXShape )
    2161                 :            : {
    2162         [ +  - ]:          3 :     uno::Reference< beans::XPropertySet > aXPropSet( rXShape, uno::UNO_QUERY );
    2163         [ +  - ]:          3 :     if ( aXPropSet.is() )
    2164                 :            :     {
    2165                 :          3 :         SdrObjCustomShape* pCustoShape = (SdrObjCustomShape*)GetSdrObjectFromXShape( rXShape );
    2166                 :          3 :         const rtl::OUString sCustomShapeGeometry( "CustomShapeGeometry"  );
    2167 [ +  - ][ +  - ]:          3 :         uno::Any aGeoPropSet = aXPropSet->getPropertyValue( sCustomShapeGeometry );
    2168         [ +  - ]:          3 :         uno::Sequence< beans::PropertyValue > aGeoPropSeq;
    2169 [ +  - ][ +  - ]:          3 :         if ( aGeoPropSet >>= aGeoPropSeq )
    2170                 :            :         {
    2171                 :          3 :             const rtl::OUString sViewBox            ( "ViewBox"  );
    2172                 :          3 :             const rtl::OUString sTextRotateAngle    ( "TextRotateAngle"  );
    2173                 :          3 :             const rtl::OUString sExtrusion          ( "Extrusion"  );
    2174                 :          3 :             const rtl::OUString sEquations          ( "Equations"  );
    2175                 :          3 :             const rtl::OUString sPath               ( "Path"  );
    2176                 :          3 :             const rtl::OUString sTextPath           ( "TextPath"  );
    2177                 :          3 :             const rtl::OUString sHandles            ( "Handles"  );
    2178                 :          3 :             const rtl::OUString sAdjustmentValues   ( "AdjustmentValues"  );
    2179                 :            : 
    2180                 :          3 :             const beans::PropertyValue* pAdjustmentValuesProp = NULL;
    2181                 :          3 :             sal_Int32 nAdjustmentsWhichNeedsToBeConverted = 0;
    2182         [ +  - ]:          3 :             uno::Sequence< beans::PropertyValues > aHandlesPropSeq;
    2183                 :          3 :             sal_Bool bPredefinedHandlesUsed = sal_True;
    2184         [ +  - ]:          3 :             sal_Bool bIsDefaultObject = IsDefaultObject( pCustoShape );
    2185                 :            : 
    2186                 :            :             // convert property "Equations" into std::vector< EnhancedCustomShapeEquationEquation >
    2187         [ +  - ]:          3 :             std::vector< EnhancedCustomShapeEquation >  aEquations;
    2188         [ +  - ]:          3 :             std::vector< sal_Int32 >                    aEquationOrder;
    2189         [ +  - ]:          3 :             ConvertEnhancedCustomShapeEquation( pCustoShape, aEquations, aEquationOrder );
    2190                 :            : 
    2191                 :          3 :             sal_Int32 i, nCount = aGeoPropSeq.getLength();
    2192         [ +  + ]:         15 :             for ( i = 0; i < nCount; i++ )
    2193                 :            :             {
    2194         [ +  - ]:         12 :                 const beans::PropertyValue& rProp = aGeoPropSeq[ i ];
    2195         [ +  + ]:         12 :                 if ( rProp.Name.equals( sViewBox ) )
    2196                 :            :                 {
    2197         [ +  - ]:          3 :                     if ( !bIsDefaultObject )
    2198                 :            :                     {
    2199                 :          3 :                         awt::Rectangle aViewBox;
    2200 [ +  - ][ +  - ]:          3 :                         if ( rProp.Value >>= aViewBox )
    2201                 :            :                         {
    2202         [ +  - ]:          3 :                             AddOpt( DFF_Prop_geoLeft,  aViewBox.X );
    2203         [ +  - ]:          3 :                             AddOpt( DFF_Prop_geoTop,   aViewBox.Y );
    2204         [ +  - ]:          3 :                             AddOpt( DFF_Prop_geoRight, aViewBox.X + aViewBox.Width );
    2205         [ +  - ]:          3 :                             AddOpt( DFF_Prop_geoBottom,aViewBox.Y + aViewBox.Height );
    2206                 :            :                         }
    2207                 :            :                     }
    2208                 :            :                 }
    2209         [ -  + ]:          9 :                 else if ( rProp.Name.equals( sTextRotateAngle ) )
    2210                 :            :                 {
    2211                 :          0 :                     double f = 0;
    2212         [ #  # ]:          0 :                     if ( rProp.Value >>= f )
    2213                 :            :                     {
    2214                 :          0 :                         double fTextRotateAngle = fmod( f, 360.0 );
    2215         [ #  # ]:          0 :                         if ( fTextRotateAngle < 0 )
    2216                 :          0 :                             fTextRotateAngle = 360 + fTextRotateAngle;
    2217 [ #  # ][ #  # ]:          0 :                         if ( ( fTextRotateAngle < 271.0 ) && ( fTextRotateAngle > 269.0 ) )
    2218         [ #  # ]:          0 :                             AddOpt( DFF_Prop_cdirFont, mso_cdir90 );
    2219 [ #  # ][ #  # ]:          0 :                         else if ( ( fTextRotateAngle < 181.0 ) && ( fTextRotateAngle > 179.0 ) )
    2220         [ #  # ]:          0 :                             AddOpt( DFF_Prop_cdirFont, mso_cdir180 );
    2221 [ #  # ][ #  # ]:          0 :                         else if ( ( fTextRotateAngle < 91.0 ) && ( fTextRotateAngle > 79.0 ) )
    2222         [ #  # ]:          0 :                             AddOpt( DFF_Prop_cdirFont, mso_cdir270 );
    2223                 :            :                     }
    2224                 :            :                 }
    2225         [ -  + ]:          9 :                 else if ( rProp.Name.equals( sExtrusion ) )
    2226                 :            :                 {
    2227         [ #  # ]:          0 :                     uno::Sequence< beans::PropertyValue > aExtrusionPropSeq;
    2228 [ #  # ][ #  # ]:          0 :                     if ( rProp.Value >>= aExtrusionPropSeq )
    2229                 :            :                     {
    2230                 :            :                         sal_uInt32 nLightFaceFlagsOrg, nLightFaceFlags;
    2231                 :            :                         sal_uInt32 nFillHarshFlagsOrg, nFillHarshFlags;
    2232                 :          0 :                         nLightFaceFlagsOrg = nLightFaceFlags = 0x000001;
    2233                 :          0 :                         nFillHarshFlagsOrg = nFillHarshFlags = 0x00001e;
    2234 [ #  # ][ #  # ]:          0 :                         if ( GetOpt( DFF_Prop_fc3DLightFace, nLightFaceFlags ) )
    2235                 :          0 :                             nLightFaceFlagsOrg = nLightFaceFlags;
    2236 [ #  # ][ #  # ]:          0 :                         if ( GetOpt( DFF_Prop_fc3DFillHarsh, nFillHarshFlags ) )
    2237                 :          0 :                             nFillHarshFlagsOrg = nFillHarshFlags;
    2238                 :            : 
    2239                 :          0 :                         sal_Int32 r, nrCount = aExtrusionPropSeq.getLength();
    2240         [ #  # ]:          0 :                         for ( r = 0; r < nrCount; r++ )
    2241                 :            :                         {
    2242         [ #  # ]:          0 :                             const beans::PropertyValue& rrProp = aExtrusionPropSeq[ r ];
    2243                 :          0 :                             const rtl::OUString sExtrusionBrightness            ( "Brightness"  );
    2244                 :          0 :                             const rtl::OUString sExtrusionDepth                 ( "Depth"  );
    2245                 :          0 :                             const rtl::OUString sExtrusionDiffusion             ( "Diffusion"  );
    2246                 :          0 :                             const rtl::OUString sExtrusionNumberOfLineSegments  ( "NumberOfLineSegments"  );
    2247                 :          0 :                             const rtl::OUString sExtrusionLightFace             ( "LightFace"  );
    2248                 :          0 :                             const rtl::OUString sExtrusionFirstLightHarsh       ( "FirstLightHarsh"  );
    2249                 :          0 :                             const rtl::OUString sExtrusionSecondLightHarsh      ( "SecondLightHarsh"  );
    2250                 :          0 :                             const rtl::OUString sExtrusionFirstLightLevel       ( "FirstLightLevel"  );
    2251                 :          0 :                             const rtl::OUString sExtrusionSecondLightLevel      ( "SecondLightLevel"  );
    2252                 :          0 :                             const rtl::OUString sExtrusionFirstLightDirection   ( "FirstLightDirection"  );
    2253                 :          0 :                             const rtl::OUString sExtrusionSecondLightDirection  ( "SecondLightDirection"  );
    2254                 :          0 :                             const rtl::OUString sExtrusionMetal                 ( "Metal"  );
    2255                 :          0 :                             const rtl::OUString sExtrusionShadeMode             ( "ShadeMode"  );
    2256                 :          0 :                             const rtl::OUString sExtrusionRotateAngle           ( "RotateAngle"  );
    2257                 :          0 :                             const rtl::OUString sExtrusionRotationCenter        ( "RotationCenter"  );
    2258                 :          0 :                             const rtl::OUString sExtrusionShininess             ( "Shininess"  );
    2259                 :          0 :                             const rtl::OUString sExtrusionSkew                  ( "Skew"  );
    2260                 :          0 :                             const rtl::OUString sExtrusionSpecularity           ( "Specularity"  );
    2261                 :          0 :                             const rtl::OUString sExtrusionProjectionMode        ( "ProjectionMode"  );
    2262                 :          0 :                             const rtl::OUString sExtrusionViewPoint             ( "ViewPoint"  );
    2263                 :          0 :                             const rtl::OUString sExtrusionOrigin                ( "Origin"  );
    2264                 :          0 :                             const rtl::OUString sExtrusionColor                 ( "Color"  );
    2265                 :            : 
    2266         [ #  # ]:          0 :                             if ( rrProp.Name.equals( sExtrusion ) )
    2267                 :            :                             {
    2268                 :          0 :                                 sal_Bool bExtrusionOn = sal_Bool();
    2269         [ #  # ]:          0 :                                 if ( rrProp.Value >>= bExtrusionOn )
    2270                 :            :                                 {
    2271                 :          0 :                                     nLightFaceFlags |= 0x80000;
    2272         [ #  # ]:          0 :                                     if ( bExtrusionOn )
    2273                 :          0 :                                         nLightFaceFlags |= 8;
    2274                 :            :                                     else
    2275                 :          0 :                                         nLightFaceFlags &=~8;
    2276                 :            :                                 }
    2277                 :            :                             }
    2278         [ #  # ]:          0 :                             else if ( rrProp.Name.equals( sExtrusionBrightness ) )
    2279                 :            :                             {
    2280                 :          0 :                                 double fExtrusionBrightness = 0;
    2281         [ #  # ]:          0 :                                 if ( rrProp.Value >>= fExtrusionBrightness )
    2282         [ #  # ]:          0 :                                     AddOpt( DFF_Prop_c3DAmbientIntensity, (sal_Int32)( fExtrusionBrightness * 655.36 ) );
    2283                 :            :                             }
    2284         [ #  # ]:          0 :                             else if ( rrProp.Name.equals( sExtrusionDepth ) )
    2285                 :            :                             {
    2286                 :          0 :                                 double fDepth = 0;
    2287                 :          0 :                                 double fFraction = 0;
    2288                 :          0 :                                 com::sun::star::drawing::EnhancedCustomShapeParameterPair aDepthParaPair;
    2289 [ #  # ][ #  # ]:          0 :                                 if ( ( rrProp.Value >>= aDepthParaPair ) && ( aDepthParaPair.First.Value >>= fDepth ) && ( aDepthParaPair.Second.Value >>= fFraction ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    2290                 :            :                                 {
    2291                 :          0 :                                     double fForeDepth = fDepth * fFraction;
    2292                 :          0 :                                     double fBackDepth = fDepth - fForeDepth;
    2293                 :            : 
    2294                 :          0 :                                     fBackDepth *= 360.0;
    2295         [ #  # ]:          0 :                                     AddOpt( DFF_Prop_c3DExtrudeBackward, (sal_Int32)fBackDepth );
    2296                 :            : 
    2297         [ #  # ]:          0 :                                     if ( fForeDepth != 0.0 )
    2298                 :            :                                     {
    2299                 :          0 :                                         fForeDepth *= 360.0;
    2300         [ #  # ]:          0 :                                         AddOpt( DFF_Prop_c3DExtrudeForward, (sal_Int32)fForeDepth );
    2301                 :            :                                     }
    2302                 :          0 :                                 }
    2303                 :            :                             }
    2304         [ #  # ]:          0 :                             else if ( rrProp.Name.equals( sExtrusionDiffusion ) )
    2305                 :            :                             {
    2306                 :          0 :                                 double fExtrusionDiffusion = 0;
    2307         [ #  # ]:          0 :                                 if ( rrProp.Value >>= fExtrusionDiffusion )
    2308         [ #  # ]:          0 :                                     AddOpt( DFF_Prop_c3DDiffuseAmt, (sal_Int32)( fExtrusionDiffusion * 655.36 ) );
    2309                 :            :                             }
    2310         [ #  # ]:          0 :                             else if ( rrProp.Name.equals( sExtrusionNumberOfLineSegments ) )
    2311                 :            :                             {
    2312                 :          0 :                                 sal_Int32 nExtrusionNumberOfLineSegments = 0;
    2313         [ #  # ]:          0 :                                 if ( rrProp.Value >>= nExtrusionNumberOfLineSegments )
    2314         [ #  # ]:          0 :                                     AddOpt( DFF_Prop_c3DTolerance, nExtrusionNumberOfLineSegments );
    2315                 :            :                             }
    2316         [ #  # ]:          0 :                             else if ( rrProp.Name.equals( sExtrusionLightFace ) )
    2317                 :            :                             {
    2318                 :          0 :                                 sal_Bool bExtrusionLightFace = sal_Bool();
    2319         [ #  # ]:          0 :                                 if ( rrProp.Value >>= bExtrusionLightFace )
    2320                 :            :                                 {
    2321                 :          0 :                                     nLightFaceFlags |= 0x10000;
    2322         [ #  # ]:          0 :                                     if ( bExtrusionLightFace )
    2323                 :          0 :                                         nLightFaceFlags |= 1;
    2324                 :            :                                     else
    2325                 :          0 :                                         nLightFaceFlags &=~1;
    2326                 :            :                                 }
    2327                 :            :                             }
    2328         [ #  # ]:          0 :                             else if ( rrProp.Name.equals( sExtrusionFirstLightHarsh ) )
    2329                 :            :                             {
    2330                 :          0 :                                 sal_Bool bExtrusionFirstLightHarsh = sal_Bool();
    2331         [ #  # ]:          0 :                                 if ( rrProp.Value >>= bExtrusionFirstLightHarsh )
    2332                 :            :                                 {
    2333                 :          0 :                                     nFillHarshFlags |= 0x20000;
    2334         [ #  # ]:          0 :                                     if ( bExtrusionFirstLightHarsh )
    2335                 :          0 :                                         nFillHarshFlags |= 2;
    2336                 :            :                                     else
    2337                 :          0 :                                         nFillHarshFlags &=~2;
    2338                 :            :                                 }
    2339                 :            :                             }
    2340         [ #  # ]:          0 :                             else if ( rrProp.Name.equals( sExtrusionSecondLightHarsh ) )
    2341                 :            :                             {
    2342                 :          0 :                                 sal_Bool bExtrusionSecondLightHarsh = sal_Bool();
    2343         [ #  # ]:          0 :                                 if ( rrProp.Value >>= bExtrusionSecondLightHarsh )
    2344                 :            :                                 {
    2345                 :          0 :                                     nFillHarshFlags |= 0x10000;
    2346         [ #  # ]:          0 :                                     if ( bExtrusionSecondLightHarsh )
    2347                 :          0 :                                         nFillHarshFlags |= 1;
    2348                 :            :                                     else
    2349                 :          0 :                                         nFillHarshFlags &=~1;
    2350                 :            :                                 }
    2351                 :            :                             }
    2352         [ #  # ]:          0 :                             else if ( rrProp.Name.equals( sExtrusionFirstLightLevel ) )
    2353                 :            :                             {
    2354                 :          0 :                                 double fExtrusionFirstLightLevel = 0;
    2355         [ #  # ]:          0 :                                 if ( rrProp.Value >>= fExtrusionFirstLightLevel )
    2356         [ #  # ]:          0 :                                     AddOpt( DFF_Prop_c3DKeyIntensity, (sal_Int32)( fExtrusionFirstLightLevel * 655.36 ) );
    2357                 :            :                             }
    2358         [ #  # ]:          0 :                             else if ( rrProp.Name.equals( sExtrusionSecondLightLevel ) )
    2359                 :            :                             {
    2360                 :          0 :                                 double fExtrusionSecondLightLevel = 0;
    2361         [ #  # ]:          0 :                                 if ( rrProp.Value >>= fExtrusionSecondLightLevel )
    2362         [ #  # ]:          0 :                                     AddOpt( DFF_Prop_c3DFillIntensity, (sal_Int32)( fExtrusionSecondLightLevel * 655.36 ) );
    2363                 :            :                             }
    2364         [ #  # ]:          0 :                             else if ( rrProp.Name.equals( sExtrusionFirstLightDirection ) )
    2365                 :            :                             {
    2366                 :          0 :                                 drawing::Direction3D aExtrusionFirstLightDirection;
    2367 [ #  # ][ #  # ]:          0 :                                 if ( rrProp.Value >>= aExtrusionFirstLightDirection )
    2368                 :            :                                 {
    2369         [ #  # ]:          0 :                                     AddOpt( DFF_Prop_c3DKeyX, (sal_Int32)aExtrusionFirstLightDirection.DirectionX  );
    2370         [ #  # ]:          0 :                                     AddOpt( DFF_Prop_c3DKeyY, (sal_Int32)aExtrusionFirstLightDirection.DirectionY  );
    2371         [ #  # ]:          0 :                                     AddOpt( DFF_Prop_c3DKeyZ, (sal_Int32)aExtrusionFirstLightDirection.DirectionZ  );
    2372                 :            :                                 }
    2373                 :            :                             }
    2374         [ #  # ]:          0 :                             else if ( rrProp.Name.equals( sExtrusionSecondLightDirection ) )
    2375                 :            :                             {
    2376                 :          0 :                                 drawing::Direction3D aExtrusionSecondLightPosition;
    2377 [ #  # ][ #  # ]:          0 :                                 if ( rrProp.Value >>= aExtrusionSecondLightPosition )
    2378                 :            :                                 {
    2379         [ #  # ]:          0 :                                     AddOpt( DFF_Prop_c3DFillX, (sal_Int32)aExtrusionSecondLightPosition.DirectionX  );
    2380         [ #  # ]:          0 :                                     AddOpt( DFF_Prop_c3DFillY, (sal_Int32)aExtrusionSecondLightPosition.DirectionY  );
    2381         [ #  # ]:          0 :                                     AddOpt( DFF_Prop_c3DFillZ, (sal_Int32)aExtrusionSecondLightPosition.DirectionZ  );
    2382                 :            :                                 }
    2383                 :            :                             }
    2384         [ #  # ]:          0 :                             else if ( rrProp.Name.equals( sExtrusionMetal ) )
    2385                 :            :                             {
    2386                 :          0 :                                 sal_Bool bExtrusionMetal = sal_Bool();
    2387         [ #  # ]:          0 :                                 if ( rrProp.Value >>= bExtrusionMetal )
    2388                 :            :                                 {
    2389                 :          0 :                                     nLightFaceFlags |= 0x40000;
    2390         [ #  # ]:          0 :                                     if ( bExtrusionMetal )
    2391                 :          0 :                                         nLightFaceFlags |= 4;
    2392                 :            :                                     else
    2393                 :          0 :                                         nLightFaceFlags &=~4;
    2394                 :            :                                 }
    2395                 :            :                             }
    2396         [ #  # ]:          0 :                             else if ( rrProp.Name.equals( sExtrusionShadeMode ) )
    2397                 :            :                             {
    2398                 :            :                                 drawing::ShadeMode eExtrusionShadeMode;
    2399 [ #  # ][ #  # ]:          0 :                                 if ( rrProp.Value >>= eExtrusionShadeMode )
    2400                 :            :                                 {
    2401                 :            :                                     sal_uInt32 nRenderMode;
    2402         [ #  # ]:          0 :                                     switch( eExtrusionShadeMode )
    2403                 :            :                                     {
    2404                 :            :                                         default:
    2405                 :            :                                         case drawing::ShadeMode_FLAT :
    2406                 :            :                                         case drawing::ShadeMode_PHONG :
    2407                 :            :                                         case drawing::ShadeMode_SMOOTH :
    2408                 :          0 :                                             nRenderMode = mso_FullRender;
    2409                 :          0 :                                         break;
    2410                 :            :                                         case drawing::ShadeMode_DRAFT :
    2411                 :            :                                         {
    2412                 :          0 :                                             nRenderMode = mso_Wireframe;
    2413                 :            :                                         }
    2414                 :          0 :                                         break;
    2415                 :            :                                     }
    2416         [ #  # ]:          0 :                                     AddOpt( DFF_Prop_c3DRenderMode, nRenderMode );
    2417                 :            :                                 }
    2418                 :            :                             }
    2419         [ #  # ]:          0 :                             else if ( rrProp.Name.equals( sExtrusionRotateAngle ) )
    2420                 :            :                             {
    2421                 :          0 :                                 double fExtrusionAngleX = 0;
    2422                 :          0 :                                 double fExtrusionAngleY = 0;
    2423                 :          0 :                                 com::sun::star::drawing::EnhancedCustomShapeParameterPair aRotateAnglePair;
    2424 [ #  # ][ #  # ]:          0 :                                 if ( ( rrProp.Value >>= aRotateAnglePair ) && ( aRotateAnglePair.First.Value >>= fExtrusionAngleX ) && ( aRotateAnglePair.Second.Value >>= fExtrusionAngleY ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    2425                 :            :                                 {
    2426                 :          0 :                                     fExtrusionAngleX *= 65536;
    2427                 :          0 :                                     fExtrusionAngleY *= 65536;
    2428         [ #  # ]:          0 :                                     AddOpt( DFF_Prop_c3DXRotationAngle, (sal_Int32)fExtrusionAngleX );
    2429         [ #  # ]:          0 :                                     AddOpt( DFF_Prop_c3DYRotationAngle, (sal_Int32)fExtrusionAngleY );
    2430                 :          0 :                                 }
    2431                 :            :                             }
    2432         [ #  # ]:          0 :                             else if ( rrProp.Name.equals( sExtrusionRotationCenter ) )
    2433                 :            :                             {
    2434                 :          0 :                                 drawing::Direction3D aExtrusionRotationCenter;
    2435 [ #  # ][ #  # ]:          0 :                                 if ( rrProp.Value >>= aExtrusionRotationCenter )
    2436                 :            :                                 {
    2437         [ #  # ]:          0 :                                     AddOpt( DFF_Prop_c3DRotationCenterX, (sal_Int32)( aExtrusionRotationCenter.DirectionX * 360.0 ) );
    2438         [ #  # ]:          0 :                                     AddOpt( DFF_Prop_c3DRotationCenterY, (sal_Int32)( aExtrusionRotationCenter.DirectionY * 360.0 ) );
    2439         [ #  # ]:          0 :                                     AddOpt( DFF_Prop_c3DRotationCenterZ, (sal_Int32)( aExtrusionRotationCenter.DirectionZ * 360.0 ) );
    2440                 :          0 :                                     nFillHarshFlags &=~8; // don't use AutoRotationCenter;
    2441                 :            :                                 }
    2442                 :            :                             }
    2443         [ #  # ]:          0 :                             else if ( rrProp.Name.equals( sExtrusionShininess ) )
    2444                 :            :                             {
    2445                 :          0 :                                 double fExtrusionShininess = 0;
    2446         [ #  # ]:          0 :                                 if ( rrProp.Value >>= fExtrusionShininess )
    2447         [ #  # ]:          0 :                                     AddOpt( DFF_Prop_c3DShininess, (sal_Int32)( fExtrusionShininess * 655.36 ) );
    2448                 :            :                             }
    2449         [ #  # ]:          0 :                             else if ( rrProp.Name.equals( sExtrusionSkew ) )
    2450                 :            :                             {
    2451                 :          0 :                                 double fSkewAmount = 0;
    2452                 :          0 :                                 double fSkewAngle = 0;
    2453                 :          0 :                                 com::sun::star::drawing::EnhancedCustomShapeParameterPair aSkewParaPair;
    2454 [ #  # ][ #  # ]:          0 :                                 if ( ( rrProp.Value >>= aSkewParaPair ) && ( aSkewParaPair.First.Value >>= fSkewAmount ) && ( aSkewParaPair.Second.Value >>= fSkewAngle ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    2455                 :            :                                 {
    2456         [ #  # ]:          0 :                                     AddOpt( DFF_Prop_c3DSkewAmount, (sal_Int32)fSkewAmount );
    2457         [ #  # ]:          0 :                                     AddOpt( DFF_Prop_c3DSkewAngle, (sal_Int32)( fSkewAngle * 65536 ) );
    2458                 :          0 :                                 }
    2459                 :            :                             }
    2460         [ #  # ]:          0 :                             else if ( rrProp.Name.equals( sExtrusionSpecularity ) )
    2461                 :            :                             {
    2462                 :          0 :                                 double fExtrusionSpecularity = 0;
    2463         [ #  # ]:          0 :                                 if ( rrProp.Value >>= fExtrusionSpecularity )
    2464         [ #  # ]:          0 :                                     AddOpt( DFF_Prop_c3DSpecularAmt, (sal_Int32)( fExtrusionSpecularity * 1333 ) );
    2465                 :            :                             }
    2466         [ #  # ]:          0 :                             else if ( rrProp.Name.equals( sExtrusionProjectionMode ) )
    2467                 :            :                             {
    2468                 :            :                                 drawing::ProjectionMode eExtrusionProjectionMode;
    2469 [ #  # ][ #  # ]:          0 :                                 if ( rrProp.Value >>= eExtrusionProjectionMode )
    2470                 :            :                                 {
    2471                 :          0 :                                     nFillHarshFlags |= 0x40000;
    2472         [ #  # ]:          0 :                                     if ( eExtrusionProjectionMode == drawing::ProjectionMode_PARALLEL )
    2473                 :          0 :                                         nFillHarshFlags |= 4;
    2474                 :            :                                     else
    2475                 :          0 :                                         nFillHarshFlags &=~4;
    2476                 :            :                                 }
    2477                 :            :                             }
    2478         [ #  # ]:          0 :                             else if ( rrProp.Name.equals( sExtrusionViewPoint ) )
    2479                 :            :                             {
    2480                 :          0 :                                 drawing::Position3D aExtrusionViewPoint;
    2481 [ #  # ][ #  # ]:          0 :                                 if ( rrProp.Value >>= aExtrusionViewPoint )
    2482                 :            :                                 {
    2483                 :          0 :                                     aExtrusionViewPoint.PositionX *= 360.0;
    2484                 :          0 :                                     aExtrusionViewPoint.PositionY *= 360.0;
    2485                 :          0 :                                     aExtrusionViewPoint.PositionZ *= 360.0;
    2486         [ #  # ]:          0 :                                     AddOpt( DFF_Prop_c3DXViewpoint, (sal_Int32)aExtrusionViewPoint.PositionX  );
    2487         [ #  # ]:          0 :                                     AddOpt( DFF_Prop_c3DYViewpoint, (sal_Int32)aExtrusionViewPoint.PositionY  );
    2488         [ #  # ]:          0 :                                     AddOpt( DFF_Prop_c3DZViewpoint, (sal_Int32)aExtrusionViewPoint.PositionZ  );
    2489                 :            :                                 }
    2490                 :            :                             }
    2491         [ #  # ]:          0 :                             else if ( rrProp.Name.equals( sExtrusionOrigin ) )
    2492                 :            :                             {
    2493                 :          0 :                                 double fExtrusionOriginX = 0;
    2494                 :          0 :                                 double fExtrusionOriginY = 0;
    2495                 :          0 :                                 com::sun::star::drawing::EnhancedCustomShapeParameterPair aOriginPair;
    2496 [ #  # ][ #  # ]:          0 :                                 if ( ( rrProp.Value >>= aOriginPair ) && ( aOriginPair.First.Value >>= fExtrusionOriginX ) && ( aOriginPair.Second.Value >>= fExtrusionOriginY ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    2497                 :            :                                 {
    2498         [ #  # ]:          0 :                                     AddOpt( DFF_Prop_c3DOriginX, (sal_Int32)( fExtrusionOriginX * 65536 ) );
    2499         [ #  # ]:          0 :                                     AddOpt( DFF_Prop_c3DOriginY, (sal_Int32)( fExtrusionOriginY * 65536 ) );
    2500                 :          0 :                                 }
    2501                 :            :                             }
    2502         [ #  # ]:          0 :                             else if ( rrProp.Name.equals( sExtrusionColor ) )
    2503                 :            :                             {
    2504                 :          0 :                                 sal_Bool bExtrusionColor = sal_Bool();
    2505         [ #  # ]:          0 :                                 if ( rrProp.Value >>= bExtrusionColor )
    2506                 :            :                                 {
    2507                 :          0 :                                     nLightFaceFlags |= 0x20000;
    2508         [ #  # ]:          0 :                                     if ( bExtrusionColor )
    2509                 :            :                                     {
    2510                 :          0 :                                         nLightFaceFlags |= 2;
    2511                 :          0 :                                         uno::Any aFillColor2;
    2512         [ #  # ]:          0 :                                         if ( EscherPropertyValueHelper::GetPropertyValue( aFillColor2, aXPropSet,
    2513 [ #  # ][ #  # ]:          0 :                                             String( RTL_CONSTASCII_USTRINGPARAM( "FillColor2" ) ), sal_True ) )
                 [ #  # ]
    2514                 :            :                                         {
    2515         [ #  # ]:          0 :                                             sal_uInt32 nFillColor = ImplGetColor( *((sal_uInt32*)aFillColor2.getValue()) );
    2516         [ #  # ]:          0 :                                             AddOpt( DFF_Prop_c3DExtrusionColor, nFillColor );
    2517                 :          0 :                                         }
    2518                 :            :                                     }
    2519                 :            :                                     else
    2520                 :          0 :                                         nLightFaceFlags &=~2;
    2521                 :            :                                 }
    2522                 :            :                             }
    2523                 :          0 :                         }
    2524         [ #  # ]:          0 :                         if ( nLightFaceFlags != nLightFaceFlagsOrg )
    2525         [ #  # ]:          0 :                             AddOpt( DFF_Prop_fc3DLightFace, nLightFaceFlags );
    2526         [ #  # ]:          0 :                         if ( nFillHarshFlags != nFillHarshFlagsOrg )
    2527         [ #  # ]:          0 :                             AddOpt( DFF_Prop_fc3DFillHarsh, nFillHarshFlags );
    2528         [ #  # ]:          0 :                     }
    2529                 :            :                 }
    2530         [ -  + ]:          9 :                 else if ( rProp.Name.equals( sEquations ) )
    2531                 :            :                 {
    2532         [ #  # ]:          0 :                     if ( !bIsDefaultObject )
    2533                 :            :                     {
    2534                 :          0 :                         sal_uInt16 nElements = (sal_uInt16)aEquations.size();
    2535         [ #  # ]:          0 :                         if ( nElements )
    2536                 :            :                         {
    2537                 :          0 :                             sal_uInt16 nElementSize = 8;
    2538                 :          0 :                             sal_uInt32 nStreamSize = nElementSize * nElements + 6;
    2539         [ #  # ]:          0 :                             SvMemoryStream aOut( nStreamSize );
    2540         [ #  # ]:          0 :                             aOut << nElements
    2541         [ #  # ]:          0 :                                 << nElements
    2542         [ #  # ]:          0 :                                 << nElementSize;
    2543                 :            : 
    2544         [ #  # ]:          0 :                             std::vector< EnhancedCustomShapeEquation >::const_iterator aIter( aEquations.begin() );
    2545         [ #  # ]:          0 :                             std::vector< EnhancedCustomShapeEquation >::const_iterator aEnd ( aEquations.end() );
    2546 [ #  # ][ #  # ]:          0 :                             while( aIter != aEnd )
    2547                 :            :                             {
    2548         [ #  # ]:          0 :                                 aOut << (sal_uInt16)aIter->nOperation
    2549         [ #  # ]:          0 :                                      << (sal_Int16)aIter->nPara[ 0 ]
    2550         [ #  # ]:          0 :                                      << (sal_Int16)aIter->nPara[ 1 ]
    2551         [ #  # ]:          0 :                                      << (sal_Int16)aIter->nPara[ 2 ];
    2552                 :          0 :                                 ++aIter;
    2553                 :            :                             }
    2554         [ #  # ]:          0 :                             sal_uInt8* pBuf = new sal_uInt8[ nStreamSize ];
    2555         [ #  # ]:          0 :                             memcpy( pBuf, aOut.GetData(), nStreamSize );
    2556 [ #  # ][ #  # ]:          0 :                             AddOpt( DFF_Prop_pFormulas, sal_True, nStreamSize - 6, pBuf, nStreamSize );
    2557                 :            :                         }
    2558                 :            :                         else
    2559                 :            :                         {
    2560         [ #  # ]:          0 :                             sal_uInt8* pBuf = new sal_uInt8[ 1 ];
    2561         [ #  # ]:          0 :                             AddOpt( DFF_Prop_pFormulas, sal_True, 0, pBuf, 0 );
    2562                 :            :                         }
    2563                 :            :                     }
    2564                 :            :                 }
    2565         [ +  + ]:          9 :                 else if ( rProp.Name.equals( sPath ) )
    2566                 :            :                 {
    2567         [ +  - ]:          3 :                     uno::Sequence< beans::PropertyValue > aPathPropSeq;
    2568 [ +  - ][ +  - ]:          3 :                     if ( rProp.Value >>= aPathPropSeq )
    2569                 :            :                     {
    2570                 :            :                         sal_uInt32 nPathFlags, nPathFlagsOrg;
    2571                 :          3 :                         nPathFlagsOrg = nPathFlags = 0x39;
    2572 [ +  - ][ -  + ]:          3 :                         if ( GetOpt( DFF_Prop_fFillOK, nPathFlags ) )
    2573                 :          0 :                             nPathFlagsOrg = nPathFlags;
    2574                 :            : 
    2575                 :          3 :                         sal_Int32 r, nrCount = aPathPropSeq.getLength();
    2576         [ +  + ]:          9 :                         for ( r = 0; r < nrCount; r++ )
    2577                 :            :                         {
    2578         [ +  - ]:          6 :                             const beans::PropertyValue& rrProp = aPathPropSeq[ r ];
    2579                 :          6 :                             const rtl::OUString sPathExtrusionAllowed               ( "ExtrusionAllowed"  );
    2580                 :          6 :                             const rtl::OUString sPathConcentricGradientFillAllowed  ( "ConcentricGradientFillAllowed"  );
    2581                 :          6 :                             const rtl::OUString sPathTextPathAllowed                ( "TextPathAllowed"  );
    2582                 :          6 :                             const rtl::OUString sPathCoordinates                    ( "Coordinates"  );
    2583                 :          6 :                             const rtl::OUString sPathGluePoints                     ( "GluePoints"  );
    2584                 :          6 :                             const rtl::OUString sPathGluePointType                  ( "GluePointType"  );
    2585                 :          6 :                             const rtl::OUString sPathSegments                       ( "Segments"  );
    2586                 :          6 :                             const rtl::OUString sPathStretchX                       ( "StretchX"  );
    2587                 :          6 :                             const rtl::OUString sPathStretchY                       ( "StretchY"  );
    2588                 :          6 :                             const rtl::OUString sPathTextFrames                     ( "TextFrames"  );
    2589                 :            : 
    2590         [ -  + ]:          6 :                             if ( rrProp.Name.equals( sPathExtrusionAllowed ) )
    2591                 :            :                             {
    2592                 :          0 :                                 sal_Bool bExtrusionAllowed = sal_Bool();
    2593         [ #  # ]:          0 :                                 if ( rrProp.Value >>= bExtrusionAllowed )
    2594                 :            :                                 {
    2595                 :          0 :                                     nPathFlags |= 0x100000;
    2596         [ #  # ]:          0 :                                     if ( bExtrusionAllowed )
    2597                 :          0 :                                         nPathFlags |= 16;
    2598                 :            :                                     else
    2599                 :          0 :                                         nPathFlags &=~16;
    2600                 :            :                                 }
    2601                 :            :                             }
    2602         [ -  + ]:          6 :                             else if ( rrProp.Name.equals( sPathConcentricGradientFillAllowed ) )
    2603                 :            :                             {
    2604                 :          0 :                                 sal_Bool bConcentricGradientFillAllowed = sal_Bool();
    2605         [ #  # ]:          0 :                                 if ( rrProp.Value >>= bConcentricGradientFillAllowed )
    2606                 :            :                                 {
    2607                 :          0 :                                     nPathFlags |= 0x20000;
    2608         [ #  # ]:          0 :                                     if ( bConcentricGradientFillAllowed )
    2609                 :          0 :                                         nPathFlags |= 2;
    2610                 :            :                                     else
    2611                 :          0 :                                         nPathFlags &=~2;
    2612                 :            :                                 }
    2613                 :            :                             }
    2614         [ -  + ]:          6 :                             else if ( rrProp.Name.equals( sPathTextPathAllowed ) )
    2615                 :            :                             {
    2616                 :          0 :                                 sal_Bool bTextPathAllowed = sal_Bool();
    2617         [ #  # ]:          0 :                                 if ( rrProp.Value >>= bTextPathAllowed )
    2618                 :            :                                 {
    2619                 :          0 :                                     nPathFlags |= 0x40000;
    2620         [ #  # ]:          0 :                                     if ( bTextPathAllowed )
    2621                 :          0 :                                         nPathFlags |= 4;
    2622                 :            :                                     else
    2623                 :          0 :                                         nPathFlags &=~4;
    2624                 :            :                                 }
    2625                 :            :                             }
    2626         [ +  + ]:          6 :                             else if ( rrProp.Name.equals( sPathCoordinates ) )
    2627                 :            :                             {
    2628         [ +  - ]:          3 :                                 if ( !bIsDefaultObject )
    2629                 :            :                                 {
    2630         [ +  - ]:          3 :                                     com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair > aCoordinates;
    2631 [ +  - ][ +  - ]:          3 :                                     if ( rrProp.Value >>= aCoordinates )
    2632                 :            :                                     {
    2633                 :            :                                         // creating the vertices
    2634         [ +  - ]:          3 :                                         if ( (sal_uInt16)aCoordinates.getLength() )
    2635                 :            :                                         {
    2636                 :          3 :                                             sal_uInt16 j, nElements = (sal_uInt16)aCoordinates.getLength();
    2637                 :          3 :                                             sal_uInt16 nElementSize = 8;
    2638                 :          3 :                                             sal_uInt32 nStreamSize = nElementSize * nElements + 6;
    2639         [ +  - ]:          3 :                                             SvMemoryStream aOut( nStreamSize );
    2640         [ +  - ]:          3 :                                             aOut << nElements
    2641         [ +  - ]:          3 :                                                 << nElements
    2642         [ +  - ]:          3 :                                                 << nElementSize;
    2643         [ +  + ]:         51 :                                             for( j = 0; j < nElements; j++ )
    2644                 :            :                                             {
    2645 [ +  - ][ +  - ]:         48 :                                                 sal_Int32 X = GetValueForEnhancedCustomShapeParameter( aCoordinates[ j ].First, aEquationOrder );
    2646 [ +  - ][ +  - ]:         48 :                                                 sal_Int32 Y = GetValueForEnhancedCustomShapeParameter( aCoordinates[ j ].Second, aEquationOrder );
    2647         [ +  - ]:         48 :                                                 aOut << X
    2648         [ +  - ]:         48 :                                                     << Y;
    2649                 :            :                                             }
    2650         [ +  - ]:          3 :                                             sal_uInt8* pBuf = new sal_uInt8[ nStreamSize ];
    2651         [ +  - ]:          3 :                                             memcpy( pBuf, aOut.GetData(), nStreamSize );
    2652 [ +  - ][ +  - ]:          3 :                                             AddOpt( DFF_Prop_pVertices, sal_True, nStreamSize - 6, pBuf, nStreamSize ); // -6
    2653                 :            :                                         }
    2654                 :            :                                         else
    2655                 :            :                                         {
    2656         [ #  # ]:          0 :                                             sal_uInt8* pBuf = new sal_uInt8[ 1 ];
    2657         [ #  # ]:          0 :                                             AddOpt( DFF_Prop_pVertices, sal_True, 0, pBuf, 0 );
    2658                 :            :                                         }
    2659         [ +  - ]:          3 :                                     }
    2660                 :            :                                 }
    2661                 :            :                             }
    2662         [ -  + ]:          3 :                             else if ( rrProp.Name.equals( sPathGluePoints ) )
    2663                 :            :                             {
    2664         [ #  # ]:          0 :                                 if ( !bIsDefaultObject )
    2665                 :            :                                 {
    2666         [ #  # ]:          0 :                                     com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair> aGluePoints;
    2667 [ #  # ][ #  # ]:          0 :                                     if ( rrProp.Value >>= aGluePoints )
    2668                 :            :                                     {
    2669                 :            :                                         // creating the vertices
    2670                 :          0 :                                         sal_uInt16 nElements = (sal_uInt16)aGluePoints.getLength();
    2671         [ #  # ]:          0 :                                         if ( nElements )
    2672                 :            :                                         {
    2673                 :          0 :                                             sal_uInt16 j, nElementSize = 8;
    2674                 :          0 :                                             sal_uInt32 nStreamSize = nElementSize * nElements + 6;
    2675         [ #  # ]:          0 :                                             SvMemoryStream aOut( nStreamSize );
    2676         [ #  # ]:          0 :                                             aOut << nElements
    2677         [ #  # ]:          0 :                                                 << nElements
    2678         [ #  # ]:          0 :                                                 << nElementSize;
    2679         [ #  # ]:          0 :                                             for( j = 0; j < nElements; j++ )
    2680                 :            :                                             {
    2681 [ #  # ][ #  # ]:          0 :                                                 sal_Int32 X = GetValueForEnhancedCustomShapeParameter( aGluePoints[ j ].First, aEquationOrder );
    2682 [ #  # ][ #  # ]:          0 :                                                 sal_Int32 Y = GetValueForEnhancedCustomShapeParameter( aGluePoints[ j ].Second, aEquationOrder );
    2683         [ #  # ]:          0 :                                                 aOut << X
    2684         [ #  # ]:          0 :                                                     << Y;
    2685                 :            :                                             }
    2686         [ #  # ]:          0 :                                             sal_uInt8* pBuf = new sal_uInt8[ nStreamSize ];
    2687         [ #  # ]:          0 :                                             memcpy( pBuf, aOut.GetData(), nStreamSize );
    2688 [ #  # ][ #  # ]:          0 :                                             AddOpt( DFF_Prop_connectorPoints, sal_True, nStreamSize - 6, pBuf, nStreamSize );   // -6
    2689                 :            :                                         }
    2690                 :            :                                         else
    2691                 :            :                                         {
    2692         [ #  # ]:          0 :                                             sal_uInt8* pBuf = new sal_uInt8[ 1 ];
    2693         [ #  # ]:          0 :                                             AddOpt( DFF_Prop_connectorPoints, sal_True, 0, pBuf, 0 );
    2694                 :            :                                         }
    2695         [ #  # ]:          0 :                                     }
    2696                 :            :                                 }
    2697                 :            :                             }
    2698         [ -  + ]:          3 :                             else if ( rrProp.Name.equals( sPathGluePointType ) )
    2699                 :            :                             {
    2700                 :          0 :                                 sal_Int16 nGluePointType = sal_Int16();
    2701         [ #  # ]:          0 :                                 if ( rrProp.Value >>= nGluePointType )
    2702         [ #  # ]:          0 :                                     AddOpt( DFF_Prop_connectorType, (sal_uInt16)nGluePointType );
    2703                 :            :                             }
    2704         [ +  - ]:          3 :                             else if ( rrProp.Name.equals( sPathSegments ) )
    2705                 :            :                             {
    2706         [ +  - ]:          3 :                                 if ( !bIsDefaultObject )
    2707                 :            :                                 {
    2708         [ +  - ]:          3 :                                     com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeSegment > aSegments;
    2709 [ +  - ][ +  - ]:          3 :                                     if ( rrProp.Value >>= aSegments )
    2710                 :            :                                     {
    2711                 :            :                                         // creating seginfo
    2712         [ +  - ]:          3 :                                         if ( (sal_uInt16)aSegments.getLength() )
    2713                 :            :                                         {
    2714                 :          3 :                                             sal_uInt16 j, nElements = (sal_uInt16)aSegments.getLength();
    2715                 :          3 :                                             sal_uInt16 nElementSize = 2;
    2716                 :          3 :                                             sal_uInt32 nStreamSize = nElementSize * nElements + 6;
    2717         [ +  - ]:          3 :                                             SvMemoryStream aOut( nStreamSize );
    2718         [ +  - ]:          3 :                                             aOut << nElements
    2719         [ +  - ]:          3 :                                                 << nElements
    2720         [ +  - ]:          3 :                                                 << nElementSize;
    2721         [ +  + ]:         15 :                                             for ( j = 0; j < nElements; j++ )
    2722                 :            :                                             {
    2723         [ +  - ]:         12 :                                                 sal_uInt16 nVal = (sal_uInt16)aSegments[ j ].Count;
    2724 [ +  - ][ +  +  :         12 :                                                 switch( aSegments[ j ].Command )
          -  +  +  -  -  
          -  -  -  -  -  
             -  -  -  - ]
    2725                 :            :                                                 {
    2726                 :            :                                                     case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::UNKNOWN :
    2727                 :          3 :                                                     case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::LINETO : break;
    2728                 :            :                                                     case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::MOVETO :
    2729                 :            :                                                     {
    2730                 :          3 :                                                         nVal = 0x4000;
    2731                 :            :                                                     }
    2732                 :          3 :                                                     break;
    2733                 :            :                                                     case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::CURVETO :
    2734                 :            :                                                     {
    2735                 :          0 :                                                         nVal |= 0x2000;
    2736                 :            :                                                     }
    2737                 :          0 :                                                     break;
    2738                 :            :                                                     case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::CLOSESUBPATH :
    2739                 :            :                                                     {
    2740                 :          3 :                                                         nVal = 0x6001;
    2741                 :            :                                                     }
    2742                 :          3 :                                                     break;
    2743                 :            :                                                     case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ENDSUBPATH :
    2744                 :            :                                                     {
    2745                 :          3 :                                                         nVal = 0x8000;
    2746                 :            :                                                     }
    2747                 :          3 :                                                     break;
    2748                 :            :                                                     case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::NOFILL :
    2749                 :            :                                                     {
    2750                 :          0 :                                                         nVal = 0xaa00;
    2751                 :            :                                                     }
    2752                 :          0 :                                                     break;
    2753                 :            :                                                     case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::NOSTROKE :
    2754                 :            :                                                     {
    2755                 :          0 :                                                         nVal = 0xab00;
    2756                 :            :                                                     }
    2757                 :          0 :                                                     break;
    2758                 :            :                                                     case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ANGLEELLIPSETO :
    2759                 :            :                                                     {
    2760                 :          0 :                                                         nVal *= 3;
    2761                 :          0 :                                                         nVal |= 0xa100;
    2762                 :            :                                                     }
    2763                 :          0 :                                                     break;
    2764                 :            :                                                     case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ANGLEELLIPSE :
    2765                 :            :                                                     {
    2766                 :          0 :                                                         nVal *= 3;
    2767                 :          0 :                                                         nVal |= 0xa200;
    2768                 :            :                                                     }
    2769                 :          0 :                                                     break;
    2770                 :            :                                                     case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ARCTO :
    2771                 :            :                                                     {
    2772                 :          0 :                                                         nVal <<= 2;
    2773                 :          0 :                                                         nVal |= 0xa300;
    2774                 :            :                                                     }
    2775                 :          0 :                                                     break;
    2776                 :            :                                                     case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ARC :
    2777                 :            :                                                     {
    2778                 :          0 :                                                         nVal <<= 2;
    2779                 :          0 :                                                         nVal |= 0xa400;
    2780                 :            :                                                     }
    2781                 :          0 :                                                     break;
    2782                 :            :                                                     case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::CLOCKWISEARCTO :
    2783                 :            :                                                     {
    2784                 :          0 :                                                         nVal <<= 2;
    2785                 :          0 :                                                         nVal |= 0xa500;
    2786                 :            :                                                     }
    2787                 :          0 :                                                     break;
    2788                 :            :                                                     case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::CLOCKWISEARC :
    2789                 :            :                                                     {
    2790                 :          0 :                                                         nVal <<= 2;
    2791                 :          0 :                                                         nVal |= 0xa600;
    2792                 :            :                                                     }
    2793                 :          0 :                                                     break;
    2794                 :            :                                                     case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTX :
    2795                 :            :                                                     {
    2796                 :          0 :                                                         nVal |= 0xa700;
    2797                 :            :                                                     }
    2798                 :          0 :                                                     break;
    2799                 :            :                                                     case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTY :
    2800                 :            :                                                     {
    2801                 :          0 :                                                         nVal |= 0xa800;
    2802                 :            :                                                     }
    2803                 :          0 :                                                     break;
    2804                 :            :                                                 }
    2805         [ +  - ]:         12 :                                                 aOut << nVal;
    2806                 :            :                                             }
    2807         [ +  - ]:          3 :                                             sal_uInt8* pBuf = new sal_uInt8[ nStreamSize ];
    2808         [ +  - ]:          3 :                                             memcpy( pBuf, aOut.GetData(), nStreamSize );
    2809 [ +  - ][ +  - ]:          3 :                                             AddOpt( DFF_Prop_pSegmentInfo, sal_False, nStreamSize - 6, pBuf, nStreamSize );
    2810                 :            :                                         }
    2811                 :            :                                         else
    2812                 :            :                                         {
    2813         [ #  # ]:          0 :                                             sal_uInt8* pBuf = new sal_uInt8[ 1 ];
    2814         [ #  # ]:          0 :                                             AddOpt( DFF_Prop_pSegmentInfo, sal_True, 0, pBuf, 0 );
    2815                 :            :                                         }
    2816         [ +  - ]:          3 :                                     }
    2817                 :            :                                 }
    2818                 :            :                             }
    2819         [ #  # ]:          0 :                             else if ( rrProp.Name.equals( sPathStretchX ) )
    2820                 :            :                             {
    2821         [ #  # ]:          0 :                                 if ( !bIsDefaultObject )
    2822                 :            :                                 {
    2823                 :          0 :                                     sal_Int32 nStretchX = 0;
    2824         [ #  # ]:          0 :                                     if ( rrProp.Value >>= nStretchX )
    2825         [ #  # ]:          0 :                                         AddOpt( DFF_Prop_stretchPointX, nStretchX );
    2826                 :            :                                 }
    2827                 :            :                             }
    2828         [ #  # ]:          0 :                             else if ( rrProp.Name.equals( sPathStretchY ) )
    2829                 :            :                             {
    2830         [ #  # ]:          0 :                                 if ( !bIsDefaultObject )
    2831                 :            :                                 {
    2832                 :          0 :                                     sal_Int32 nStretchY = 0;
    2833         [ #  # ]:          0 :                                     if ( rrProp.Value >>= nStretchY )
    2834         [ #  # ]:          0 :                                         AddOpt( DFF_Prop_stretchPointY, nStretchY );
    2835                 :            :                                 }
    2836                 :            :                             }
    2837         [ #  # ]:          0 :                             else if ( rrProp.Name.equals( sPathTextFrames ) )
    2838                 :            :                             {
    2839         [ #  # ]:          0 :                                 if ( !bIsDefaultObject )
    2840                 :            :                                 {
    2841         [ #  # ]:          0 :                                     com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeTextFrame > aPathTextFrames;
    2842 [ #  # ][ #  # ]:          0 :                                     if ( rrProp.Value >>= aPathTextFrames )
    2843                 :            :                                     {
    2844         [ #  # ]:          0 :                                         if ( (sal_uInt16)aPathTextFrames.getLength() )
    2845                 :            :                                         {
    2846                 :          0 :                                             sal_uInt16 j, nElements = (sal_uInt16)aPathTextFrames.getLength();
    2847                 :          0 :                                             sal_uInt16 nElementSize = 16;
    2848                 :          0 :                                             sal_uInt32 nStreamSize = nElementSize * nElements + 6;
    2849         [ #  # ]:          0 :                                             SvMemoryStream aOut( nStreamSize );
    2850         [ #  # ]:          0 :                                             aOut << nElements
    2851         [ #  # ]:          0 :                                                 << nElements
    2852         [ #  # ]:          0 :                                                 << nElementSize;
    2853         [ #  # ]:          0 :                                             for ( j = 0; j < nElements; j++ )
    2854                 :            :                                             {
    2855 [ #  # ][ #  # ]:          0 :                                                 sal_Int32 nLeft = GetValueForEnhancedCustomShapeParameter( aPathTextFrames[ j ].TopLeft.First, aEquationOrder );
    2856 [ #  # ][ #  # ]:          0 :                                                 sal_Int32 nTop  = GetValueForEnhancedCustomShapeParameter( aPathTextFrames[ j ].TopLeft.Second, aEquationOrder );
    2857 [ #  # ][ #  # ]:          0 :                                                 sal_Int32 nRight = GetValueForEnhancedCustomShapeParameter( aPathTextFrames[ j ].BottomRight.First, aEquationOrder );
    2858 [ #  # ][ #  # ]:          0 :                                                 sal_Int32 nBottom = GetValueForEnhancedCustomShapeParameter( aPathTextFrames[ j ].BottomRight.Second, aEquationOrder );
    2859                 :            : 
    2860         [ #  # ]:          0 :                                                 aOut << nLeft
    2861         [ #  # ]:          0 :                                                     << nTop
    2862         [ #  # ]:          0 :                                                     << nRight
    2863         [ #  # ]:          0 :                                                     << nBottom;
    2864                 :            :                                             }
    2865         [ #  # ]:          0 :                                             sal_uInt8* pBuf = new sal_uInt8[ nStreamSize ];
    2866         [ #  # ]:          0 :                                             memcpy( pBuf, aOut.GetData(), nStreamSize );
    2867 [ #  # ][ #  # ]:          0 :                                             AddOpt( DFF_Prop_textRectangles, sal_True, nStreamSize - 6, pBuf, nStreamSize );
    2868                 :            :                                         }
    2869                 :            :                                         else
    2870                 :            :                                         {
    2871         [ #  # ]:          0 :                                             sal_uInt8* pBuf = new sal_uInt8[ 1 ];
    2872         [ #  # ]:          0 :                                             AddOpt( DFF_Prop_textRectangles, sal_True, 0, pBuf, 0 );
    2873                 :            :                                         }
    2874         [ #  # ]:          0 :                                     }
    2875                 :            :                                 }
    2876                 :            :                             }
    2877                 :          6 :                         }
    2878         [ -  + ]:          3 :                         if ( nPathFlags != nPathFlagsOrg )
    2879         [ #  # ]:          3 :                             AddOpt( DFF_Prop_fFillOK, nPathFlags );
    2880         [ +  - ]:          3 :                     }
    2881                 :            :                 }
    2882         [ -  + ]:          6 :                 else if ( rProp.Name.equals( sTextPath ) )
    2883                 :            :                 {
    2884         [ #  # ]:          0 :                     uno::Sequence< beans::PropertyValue > aTextPathPropSeq;
    2885 [ #  # ][ #  # ]:          0 :                     if ( rProp.Value >>= aTextPathPropSeq )
    2886                 :            :                     {
    2887                 :            :                         sal_uInt32 nTextPathFlagsOrg, nTextPathFlags;
    2888                 :          0 :                         nTextPathFlagsOrg = nTextPathFlags = 0xffff1000;        // default
    2889 [ #  # ][ #  # ]:          0 :                         if ( GetOpt( DFF_Prop_gtextFStrikethrough, nTextPathFlags ) )
    2890                 :          0 :                             nTextPathFlagsOrg = nTextPathFlags;
    2891                 :            : 
    2892                 :          0 :                         sal_Int32 r, nrCount = aTextPathPropSeq.getLength();
    2893         [ #  # ]:          0 :                         for ( r = 0; r < nrCount; r++ )
    2894                 :            :                         {
    2895         [ #  # ]:          0 :                             const beans::PropertyValue& rrProp = aTextPathPropSeq[ r ];
    2896                 :          0 :                             const rtl::OUString sTextPathMode       ( "TextPathMode"  );
    2897                 :          0 :                             const rtl::OUString sTextPathScaleX     ( "ScaleX"  );
    2898                 :          0 :                             const rtl::OUString sSameLetterHeights  ( "SameLetterHeights"  );
    2899                 :            : 
    2900         [ #  # ]:          0 :                             if ( rrProp.Name.equals( sTextPath ) )
    2901                 :            :                             {
    2902                 :          0 :                                 sal_Bool bTextPathOn = sal_Bool();
    2903         [ #  # ]:          0 :                                 if ( rrProp.Value >>= bTextPathOn )
    2904                 :            :                                 {
    2905                 :          0 :                                     nTextPathFlags |= 0x40000000;
    2906         [ #  # ]:          0 :                                     if ( bTextPathOn )
    2907                 :            :                                     {
    2908                 :          0 :                                         nTextPathFlags |= 0x4000;
    2909                 :            : 
    2910                 :          0 :                                         sal_uInt32 nPathFlags = 0x39;
    2911         [ #  # ]:          0 :                                         GetOpt( DFF_Prop_fFillOK, nPathFlags ); // SJ: can be removed if we are supporting the TextPathAllowed property in XML
    2912                 :          0 :                                         nPathFlags |= 0x40004;
    2913         [ #  # ]:          0 :                                         AddOpt( DFF_Prop_fFillOK, nPathFlags );
    2914                 :            :                                     }
    2915                 :            :                                     else
    2916                 :          0 :                                         nTextPathFlags &=~0x4000;
    2917                 :            :                                 }
    2918                 :            :                             }
    2919         [ #  # ]:          0 :                             else if ( rrProp.Name.equals( sTextPathMode ) )
    2920                 :            :                             {
    2921                 :            :                                 com::sun::star::drawing::EnhancedCustomShapeTextPathMode eTextPathMode;
    2922 [ #  # ][ #  # ]:          0 :                                 if ( rrProp.Value >>= eTextPathMode )
    2923                 :            :                                 {
    2924                 :          0 :                                     nTextPathFlags |= 0x05000000;
    2925                 :          0 :                                     nTextPathFlags &=~0x500;    // TextPathMode_NORMAL
    2926         [ #  # ]:          0 :                                     if ( eTextPathMode == com::sun::star::drawing::EnhancedCustomShapeTextPathMode_PATH )
    2927                 :          0 :                                         nTextPathFlags |= 0x100;
    2928         [ #  # ]:          0 :                                     else if ( eTextPathMode == com::sun::star::drawing::EnhancedCustomShapeTextPathMode_SHAPE )
    2929                 :          0 :                                         nTextPathFlags |= 0x500;
    2930                 :            :                                 }
    2931                 :            :                             }
    2932         [ #  # ]:          0 :                             else if ( rrProp.Name.equals( sTextPathScaleX ) )
    2933                 :            :                             {
    2934                 :          0 :                                 sal_Bool bTextPathScaleX = sal_Bool();
    2935         [ #  # ]:          0 :                                 if ( rrProp.Value >>= bTextPathScaleX )
    2936                 :            :                                 {
    2937                 :          0 :                                     nTextPathFlags |= 0x00400000;
    2938         [ #  # ]:          0 :                                     if ( bTextPathScaleX )
    2939                 :          0 :                                         nTextPathFlags |= 0x40;
    2940                 :            :                                     else
    2941                 :          0 :                                         nTextPathFlags &=~0x40;
    2942                 :            :                                 }
    2943                 :            :                             }
    2944         [ #  # ]:          0 :                             else if ( rrProp.Name.equals( sSameLetterHeights ) )
    2945                 :            :                             {
    2946                 :          0 :                                 sal_Bool bSameLetterHeights = sal_Bool();
    2947         [ #  # ]:          0 :                                 if ( rrProp.Value >>= bSameLetterHeights )
    2948                 :            :                                 {
    2949                 :          0 :                                     nTextPathFlags |= 0x00800000;
    2950         [ #  # ]:          0 :                                     if ( bSameLetterHeights )
    2951                 :          0 :                                         nTextPathFlags |= 0x80;
    2952                 :            :                                     else
    2953                 :          0 :                                         nTextPathFlags &=~0x80;
    2954                 :            :                                 }
    2955                 :            :                             }
    2956                 :          0 :                         }
    2957         [ #  # ]:          0 :                         if ( nTextPathFlags & 0x4000 )      // Is FontWork ?
    2958                 :            :                         {
    2959                 :            :                             // FontWork Text
    2960                 :          0 :                             rtl::OUString aText;
    2961         [ #  # ]:          0 :                             uno::Reference< text::XSimpleText > xText( rXShape, uno::UNO_QUERY );
    2962         [ #  # ]:          0 :                             if ( xText.is() )
    2963 [ #  # ][ #  # ]:          0 :                                 aText = xText->getString();
    2964         [ #  # ]:          0 :                             if ( aText.isEmpty() )
    2965                 :          0 :                                 aText = ::rtl::OUString( "your text" );   // TODO: moving into a resource
    2966         [ #  # ]:          0 :                             AddOpt( DFF_Prop_gtextUNICODE, aText );
    2967                 :            : 
    2968                 :            :                             // FontWork Font
    2969                 :          0 :                             rtl::OUString aFontName;
    2970                 :          0 :                             const rtl::OUString sCharFontName           ( "CharFontName"  );
    2971 [ #  # ][ #  # ]:          0 :                             uno::Any aAny = aXPropSet->getPropertyValue( sCharFontName );
    2972                 :          0 :                             aAny >>= aFontName;
    2973         [ #  # ]:          0 :                             if ( aFontName.isEmpty() )
    2974                 :          0 :                                 aFontName = ::rtl::OUString( "Arial Black" );
    2975         [ #  # ]:          0 :                             AddOpt( DFF_Prop_gtextFont, aFontName );
    2976                 :            : 
    2977 [ #  # ][ #  # ]:          0 :                             if ( EscherPropertyValueHelper::GetPropertyValue( aAny, aXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "CharScaleWidth" ) ), sal_True ) )
         [ #  # ][ #  # ]
    2978                 :            :                             {
    2979                 :          0 :                                 sal_Int16 nCharScaleWidth = 100;
    2980         [ #  # ]:          0 :                                 if ( aAny >>= nCharScaleWidth )
    2981                 :            :                                 {
    2982         [ #  # ]:          0 :                                     if ( nCharScaleWidth != 100 )
    2983                 :            :                                     {
    2984                 :          0 :                                         sal_Int32 nVal = nCharScaleWidth * 655;
    2985         [ #  # ]:          0 :                                         AddOpt( DFF_Prop_gtextSpacing, nVal );
    2986                 :            :                                     }
    2987                 :            :                                 }
    2988                 :            :                             }
    2989 [ #  # ][ #  # ]:          0 :                             if ( EscherPropertyValueHelper::GetPropertyValue( aAny, aXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "CharKerning" ) ), sal_True ) )
         [ #  # ][ #  # ]
    2990                 :            :                             {
    2991                 :          0 :                                 sal_Int16 nCharKerning = sal_Int16();
    2992         [ #  # ]:          0 :                                 if ( aAny >>= nCharKerning )
    2993                 :            :                             {
    2994                 :          0 :                                     nTextPathFlags |= 0x10000000;
    2995         [ #  # ]:          0 :                                     if ( nCharKerning )
    2996                 :          0 :                                         nTextPathFlags |= 0x1000;
    2997                 :            :                                     else
    2998                 :          0 :                                         nTextPathFlags &=~0x1000;
    2999                 :            :                                 }
    3000                 :            :                             }
    3001 [ #  # ][ #  # ]:          0 :                             if ( EscherPropertyValueHelper::GetPropertyValue( aAny, aXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "CharPosture" ) ), sal_True ) )
         [ #  # ][ #  # ]
    3002                 :            :                             {
    3003                 :            :                                 awt::FontSlant eFontSlant;
    3004 [ #  # ][ #  # ]:          0 :                                 if ( aAny >>= eFontSlant )
    3005                 :            :                                 {
    3006                 :          0 :                                     nTextPathFlags |= 0x100010;
    3007         [ #  # ]:          0 :                                     if ( eFontSlant != awt::FontSlant_NONE )
    3008                 :          0 :                                         nTextPathFlags |= 0x10;
    3009                 :            :                                     else
    3010                 :          0 :                                         nTextPathFlags &=~0x10;
    3011                 :            :                                 }
    3012                 :            :                             }
    3013 [ #  # ][ #  # ]:          0 :                             if ( EscherPropertyValueHelper::GetPropertyValue( aAny, aXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "CharWeight" ) ), sal_True ) )
         [ #  # ][ #  # ]
    3014                 :            :                             {
    3015                 :          0 :                                 float fFontWidth = 0;
    3016         [ #  # ]:          0 :                                 if ( aAny >>= fFontWidth )
    3017                 :            :                                 {
    3018                 :          0 :                                     nTextPathFlags |= 0x200020;
    3019         [ #  # ]:          0 :                                     if ( fFontWidth > awt::FontWeight::NORMAL )
    3020                 :          0 :                                         nTextPathFlags |= 0x20;
    3021                 :            :                                     else
    3022                 :          0 :                                         nTextPathFlags &=~0x20;
    3023                 :            :                                 }
    3024                 :          0 :                             }
    3025                 :            :                         }
    3026         [ #  # ]:          0 :                         if ( nTextPathFlags != nTextPathFlagsOrg )
    3027         [ #  # ]:          0 :                             AddOpt( DFF_Prop_gtextFStrikethrough, nTextPathFlags );
    3028         [ #  # ]:          0 :                     }
    3029                 :            :                 }
    3030         [ -  + ]:          6 :                 else if ( rProp.Name.equals( sHandles ) )
    3031                 :            :                 {
    3032         [ #  # ]:          0 :                     if ( !bIsDefaultObject )
    3033                 :            :                     {
    3034                 :          0 :                         bPredefinedHandlesUsed = sal_False;
    3035 [ #  # ][ #  # ]:          0 :                         if ( rProp.Value >>= aHandlesPropSeq )
    3036                 :            :                         {
    3037                 :          0 :                             sal_uInt16 nElements = (sal_uInt16)aHandlesPropSeq.getLength();
    3038         [ #  # ]:          0 :                             if ( nElements )
    3039                 :            :                             {
    3040                 :          0 :                                 sal_uInt16 k, j, nElementSize = 36;
    3041                 :          0 :                                 sal_uInt32 nStreamSize = nElementSize * nElements + 6;
    3042         [ #  # ]:          0 :                                 SvMemoryStream aOut( nStreamSize );
    3043         [ #  # ]:          0 :                                 aOut << nElements
    3044         [ #  # ]:          0 :                                     << nElements
    3045         [ #  # ]:          0 :                                     << nElementSize;
    3046                 :            : 
    3047         [ #  # ]:          0 :                                 for ( k = 0; k < nElements; k++ )
    3048                 :            :                                 {
    3049                 :          0 :                                     sal_uInt32 nFlags = 0;
    3050                 :          0 :                                     sal_Int32 nXPosition = 0;
    3051                 :          0 :                                     sal_Int32 nYPosition = 0;
    3052                 :          0 :                                     sal_Int32 nXMap = 0;
    3053                 :          0 :                                     sal_Int32 nYMap = 0;
    3054                 :          0 :                                     sal_Int32 nXRangeMin = 0x80000000;
    3055                 :          0 :                                     sal_Int32 nXRangeMax = 0x7fffffff;
    3056                 :          0 :                                     sal_Int32 nYRangeMin = 0x80000000;
    3057                 :          0 :                                     sal_Int32 nYRangeMax = 0x7fffffff;
    3058                 :            : 
    3059         [ #  # ]:          0 :                                     const uno::Sequence< beans::PropertyValue >& rPropSeq = aHandlesPropSeq[ k ];
    3060         [ #  # ]:          0 :                                     for ( j = 0; j < rPropSeq.getLength(); j++ )
    3061                 :            :                                     {
    3062                 :          0 :                                         const beans::PropertyValue& rPropVal = rPropSeq[ j ];
    3063                 :            : 
    3064                 :          0 :                                         const rtl::OUString sPosition           ( "Position"  );
    3065                 :          0 :                                         const rtl::OUString sMirroredX          ( "MirroredX"  );
    3066                 :          0 :                                         const rtl::OUString sMirroredY          ( "MirroredY"  );
    3067                 :          0 :                                         const rtl::OUString sSwitched           ( "Switched"  );
    3068                 :          0 :                                         const rtl::OUString sPolar              ( "Polar"  );
    3069                 :          0 :                                         const rtl::OUString sRadiusRangeMinimum ( "RadiusRangeMinimum"  );
    3070                 :          0 :                                         const rtl::OUString sRadiusRangeMaximum ( "RadiusRangeMaximum"  );
    3071                 :          0 :                                         const rtl::OUString sRangeXMinimum      ( "RangeXMinimum"  );
    3072                 :          0 :                                         const rtl::OUString sRangeXMaximum      ( "RangeXMaximum"  );
    3073                 :          0 :                                         const rtl::OUString sRangeYMinimum      ( "RangeYMinimum"  );
    3074                 :          0 :                                         const rtl::OUString sRangeYMaximum      ( "RangeYMaximum"  );
    3075                 :            : 
    3076         [ #  # ]:          0 :                                         if ( rPropVal.Name.equals( sPosition ) )
    3077                 :            :                                         {
    3078                 :          0 :                                             com::sun::star::drawing::EnhancedCustomShapeParameterPair aPosition;
    3079 [ #  # ][ #  # ]:          0 :                                             if ( rPropVal.Value >>= aPosition )
    3080                 :            :                                             {
    3081                 :          0 :                                                 GetValueForEnhancedCustomShapeHandleParameter( nXPosition, aPosition.First );
    3082                 :          0 :                                                 GetValueForEnhancedCustomShapeHandleParameter( nYPosition, aPosition.Second );
    3083                 :          0 :                                             }
    3084                 :            :                                         }
    3085         [ #  # ]:          0 :                                         else if ( rPropVal.Name.equals( sMirroredX ) )
    3086                 :            :                                         {
    3087                 :          0 :                                             sal_Bool bMirroredX = sal_Bool();
    3088         [ #  # ]:          0 :                                             if ( rPropVal.Value >>= bMirroredX )
    3089                 :            :                                             {
    3090         [ #  # ]:          0 :                                                 if ( bMirroredX )
    3091                 :          0 :                                                     nFlags |= 1;
    3092                 :            :                                             }
    3093                 :            :                                         }
    3094         [ #  # ]:          0 :                                         else if ( rPropVal.Name.equals( sMirroredY ) )
    3095                 :            :                                         {
    3096                 :          0 :                                             sal_Bool bMirroredY = sal_Bool();
    3097         [ #  # ]:          0 :                                             if ( rPropVal.Value >>= bMirroredY )
    3098                 :            :                                             {
    3099         [ #  # ]:          0 :                                                 if ( bMirroredY )
    3100                 :          0 :                                                     nFlags |= 2;
    3101                 :            :                                             }
    3102                 :            :                                         }
    3103         [ #  # ]:          0 :                                         else if ( rPropVal.Name.equals( sSwitched ) )
    3104                 :            :                                         {
    3105                 :          0 :                                             sal_Bool bSwitched = sal_Bool();
    3106         [ #  # ]:          0 :                                             if ( rPropVal.Value >>= bSwitched )
    3107                 :            :                                             {
    3108         [ #  # ]:          0 :                                                 if ( bSwitched )
    3109                 :          0 :                                                     nFlags |= 4;
    3110                 :            :                                             }
    3111                 :            :                                         }
    3112         [ #  # ]:          0 :                                         else if ( rPropVal.Name.equals( sPolar ) )
    3113                 :            :                                         {
    3114                 :          0 :                                             com::sun::star::drawing::EnhancedCustomShapeParameterPair aPolar;
    3115 [ #  # ][ #  # ]:          0 :                                             if ( rPropVal.Value >>= aPolar )
    3116                 :            :                                             {
    3117         [ #  # ]:          0 :                                                 if ( GetValueForEnhancedCustomShapeHandleParameter( nXMap, aPolar.First ) )
    3118                 :          0 :                                                     nFlags |= 0x800;
    3119         [ #  # ]:          0 :                                                 if ( GetValueForEnhancedCustomShapeHandleParameter( nYMap, aPolar.Second ) )
    3120                 :          0 :                                                     nFlags |= 0x1000;
    3121                 :          0 :                                                 nFlags |= 8;
    3122                 :          0 :                                             }
    3123                 :            :                                         }
    3124         [ #  # ]:          0 :                                         else if ( rPropVal.Name.equals( sRadiusRangeMinimum ) )
    3125                 :            :                                         {
    3126                 :          0 :                                             nYRangeMin = (sal_Int32)0xff4c0000; // the range of angles seems to be a not
    3127                 :          0 :                                             nYRangeMax = (sal_Int32)0x00b40000; // used feature, so we are defaulting this
    3128                 :            : 
    3129                 :          0 :                                             com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMinimum;
    3130 [ #  # ][ #  # ]:          0 :                                             if ( rPropVal.Value >>= aRadiusRangeMinimum )
    3131                 :            :                                             {
    3132         [ #  # ]:          0 :                                                 if ( GetValueForEnhancedCustomShapeHandleParameter( nXRangeMin, aRadiusRangeMinimum ) )
    3133                 :          0 :                                                     nFlags |= 0x80;
    3134                 :          0 :                                                 nFlags |= 0x2000;
    3135                 :          0 :                                             }
    3136                 :            :                                         }
    3137         [ #  # ]:          0 :                                         else if ( rPropVal.Name.equals( sRadiusRangeMaximum ) )
    3138                 :            :                                         {
    3139                 :          0 :                                             nYRangeMin = (sal_Int32)0xff4c0000; // the range of angles seems to be a not
    3140                 :          0 :                                             nYRangeMax = (sal_Int32)0x00b40000; // used feature, so we are defaulting this
    3141                 :            : 
    3142                 :          0 :                                             com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMaximum;
    3143 [ #  # ][ #  # ]:          0 :                                             if ( rPropVal.Value >>= aRadiusRangeMaximum )
    3144                 :            :                                             {
    3145         [ #  # ]:          0 :                                                 if ( GetValueForEnhancedCustomShapeHandleParameter( nXRangeMax, aRadiusRangeMaximum ) )
    3146                 :          0 :                                                     nFlags |= 0x100;
    3147                 :          0 :                                                 nFlags |= 0x2000;
    3148                 :          0 :                                             }
    3149                 :            :                                         }
    3150         [ #  # ]:          0 :                                         else if ( rPropVal.Name.equals( sRangeXMinimum ) )
    3151                 :            :                                         {
    3152                 :          0 :                                             com::sun::star::drawing::EnhancedCustomShapeParameter aXRangeMinimum;
    3153 [ #  # ][ #  # ]:          0 :                                             if ( rPropVal.Value >>= aXRangeMinimum )
    3154                 :            :                                             {
    3155         [ #  # ]:          0 :                                                 if ( GetValueForEnhancedCustomShapeHandleParameter( nXRangeMin, aXRangeMinimum ) )
    3156                 :          0 :                                                     nFlags |= 0x80;
    3157                 :          0 :                                                 nFlags |= 0x20;
    3158                 :          0 :                                             }
    3159                 :            :                                         }
    3160         [ #  # ]:          0 :                                         else if ( rPropVal.Name.equals( sRangeXMaximum ) )
    3161                 :            :                                         {
    3162                 :          0 :                                             com::sun::star::drawing::EnhancedCustomShapeParameter aXRangeMaximum;
    3163 [ #  # ][ #  # ]:          0 :                                             if ( rPropVal.Value >>= aXRangeMaximum )
    3164                 :            :                                             {
    3165         [ #  # ]:          0 :                                                 if ( GetValueForEnhancedCustomShapeHandleParameter( nXRangeMax, aXRangeMaximum ) )
    3166                 :          0 :                                                     nFlags |= 0x100;
    3167                 :          0 :                                                 nFlags |= 0x20;
    3168                 :          0 :                                             }
    3169                 :            :                                         }
    3170         [ #  # ]:          0 :                                         else if ( rPropVal.Name.equals( sRangeYMinimum ) )
    3171                 :            :                                         {
    3172                 :          0 :                                             com::sun::star::drawing::EnhancedCustomShapeParameter aYRangeMinimum;
    3173 [ #  # ][ #  # ]:          0 :                                             if ( rPropVal.Value >>= aYRangeMinimum )
    3174                 :            :                                             {
    3175         [ #  # ]:          0 :                                                 if ( GetValueForEnhancedCustomShapeHandleParameter( nYRangeMin, aYRangeMinimum ) )
    3176                 :          0 :                                                     nFlags |= 0x200;
    3177                 :          0 :                                                 nFlags |= 0x20;
    3178                 :          0 :                                             }
    3179                 :            :                                         }
    3180         [ #  # ]:          0 :                                         else if ( rPropVal.Name.equals( sRangeYMaximum ) )
    3181                 :            :                                         {
    3182                 :          0 :                                             com::sun::star::drawing::EnhancedCustomShapeParameter aYRangeMaximum;
    3183 [ #  # ][ #  # ]:          0 :                                             if ( rPropVal.Value >>= aYRangeMaximum )
    3184                 :            :                                             {
    3185         [ #  # ]:          0 :                                                 if ( GetValueForEnhancedCustomShapeHandleParameter( nYRangeMax, aYRangeMaximum ) )
    3186                 :          0 :                                                     nFlags |= 0x400;
    3187                 :          0 :                                                 nFlags |= 0x20;
    3188                 :          0 :                                             }
    3189                 :            :                                         }
    3190                 :          0 :                                     }
    3191         [ #  # ]:          0 :                                     aOut << nFlags
    3192         [ #  # ]:          0 :                                         << nXPosition
    3193         [ #  # ]:          0 :                                         << nYPosition
    3194         [ #  # ]:          0 :                                         << nXMap
    3195         [ #  # ]:          0 :                                         << nYMap
    3196         [ #  # ]:          0 :                                         << nXRangeMin
    3197         [ #  # ]:          0 :                                         << nXRangeMax
    3198         [ #  # ]:          0 :                                         << nYRangeMin
    3199         [ #  # ]:          0 :                                         << nYRangeMax;
    3200                 :            : 
    3201         [ #  # ]:          0 :                                     if ( nFlags & 8 )
    3202                 :          0 :                                         nAdjustmentsWhichNeedsToBeConverted |= ( 1 << ( nYPosition - 0x100 ) );
    3203                 :            :                                 }
    3204         [ #  # ]:          0 :                                 sal_uInt8* pBuf = new sal_uInt8[ nStreamSize ];
    3205         [ #  # ]:          0 :                                 memcpy( pBuf, aOut.GetData(), nStreamSize );
    3206 [ #  # ][ #  # ]:          0 :                                 AddOpt( DFF_Prop_Handles, sal_True, nStreamSize - 6, pBuf, nStreamSize );
    3207                 :            :                             }
    3208                 :            :                             else
    3209                 :            :                             {
    3210         [ #  # ]:          0 :                                 sal_uInt8* pBuf = new sal_uInt8[ 1 ];
    3211         [ #  # ]:          0 :                                 AddOpt( DFF_Prop_Handles, sal_True, 0, pBuf, 0 );
    3212                 :            :                             }
    3213                 :            :                         }
    3214                 :            :                     }
    3215                 :            :                 }
    3216         [ +  + ]:          6 :                 else if ( rProp.Name.equals( sAdjustmentValues ) )
    3217                 :            :                 {
    3218                 :            :                     // it is required, that the information which handle is polar has already be read,
    3219                 :            :                     // so we are able to change the polar value to a fixed float
    3220                 :          3 :                     pAdjustmentValuesProp = &rProp;
    3221                 :            :                 }
    3222                 :            :             }
    3223         [ +  - ]:          3 :             if ( pAdjustmentValuesProp )
    3224                 :            :             {
    3225         [ +  - ]:          3 :                 uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue > aAdjustmentSeq;
    3226 [ +  - ][ +  - ]:          3 :                 if ( pAdjustmentValuesProp->Value >>= aAdjustmentSeq )
    3227                 :            :                 {
    3228         [ +  - ]:          3 :                     if ( bPredefinedHandlesUsed )
    3229         [ +  - ]:          3 :                         LookForPolarHandles( eShapeType, nAdjustmentsWhichNeedsToBeConverted );
    3230                 :            : 
    3231                 :          3 :                     sal_Int32 k, nValue = 0, nAdjustmentValues = aAdjustmentSeq.getLength();
    3232         [ -  + ]:          3 :                     for ( k = 0; k < nAdjustmentValues; k++ )
    3233 [ #  # ][ #  # ]:          0 :                         if( GetAdjustmentValue( aAdjustmentSeq[ k ], k, nAdjustmentsWhichNeedsToBeConverted, nValue ) )
                 [ #  # ]
    3234         [ #  # ]:          0 :                             AddOpt( (sal_uInt16)( DFF_Prop_adjustValue + k ), (sal_uInt32)nValue );
    3235         [ +  - ]:          3 :                 }
    3236         [ +  - ]:          3 :             }
    3237         [ +  - ]:          3 :         }
    3238                 :          3 :     }
    3239                 :          3 : }
    3240                 :            : 
    3241                 :          3 : MSO_SPT EscherPropertyContainer::GetCustomShapeType( const uno::Reference< drawing::XShape > & rXShape, sal_uInt32& nMirrorFlags, rtl::OUString& rShapeType )
    3242                 :            : {
    3243                 :          3 :     MSO_SPT eShapeType = mso_sptNil;
    3244                 :          3 :     nMirrorFlags = 0;
    3245         [ +  - ]:          3 :     uno::Reference< beans::XPropertySet > aXPropSet( rXShape, uno::UNO_QUERY );
    3246         [ +  - ]:          3 :     if ( aXPropSet.is() )
    3247                 :            :     {
    3248                 :            :         try
    3249                 :            :         {
    3250         [ +  - ]:          3 :             const OUString  sCustomShapeGeometry( RTL_CONSTASCII_USTRINGPARAM ( "CustomShapeGeometry" ) );
    3251 [ +  - ][ +  - ]:          3 :             uno::Any aGeoPropSet = aXPropSet->getPropertyValue( sCustomShapeGeometry );
    3252         [ +  - ]:          3 :             uno::Sequence< beans::PropertyValue > aGeoPropSeq;
    3253 [ +  - ][ +  - ]:          3 :             if ( aGeoPropSet >>= aGeoPropSeq )
    3254                 :            :             {
    3255                 :          3 :                 sal_Int32 i, nCount = aGeoPropSeq.getLength();
    3256         [ +  + ]:         15 :                 for ( i = 0; i < nCount; i++ )
    3257                 :            :                 {
    3258         [ +  - ]:         12 :                     const beans::PropertyValue& rProp = aGeoPropSeq[ i ];
    3259         [ +  + ]:         12 :                     if ( rProp.Name == "Type" )
    3260                 :            :                     {
    3261         [ +  - ]:          3 :                         if ( rProp.Value >>= rShapeType )
    3262         [ +  - ]:          3 :                             eShapeType = EnhancedCustomShapeTypeNames::Get( rShapeType );
    3263                 :            :                     }
    3264         [ -  + ]:          9 :                     else if ( rProp.Name == "MirroredX" )
    3265                 :            :                     {
    3266                 :          0 :                         sal_Bool bMirroredX = sal_Bool();
    3267 [ #  # ][ #  # ]:          0 :                         if ( ( rProp.Value >>= bMirroredX ) && bMirroredX )
                 [ #  # ]
    3268                 :          0 :                             nMirrorFlags  |= SHAPEFLAG_FLIPH;
    3269                 :            :                     }
    3270         [ -  + ]:          9 :                     else if ( rProp.Name == "MirroredY" )
    3271                 :            :                     {
    3272                 :          0 :                         sal_Bool bMirroredY = sal_Bool();
    3273 [ #  # ][ #  # ]:          0 :                         if ( ( rProp.Value >>= bMirroredY ) && bMirroredY )
                 [ #  # ]
    3274                 :          0 :                             nMirrorFlags  |= SHAPEFLAG_FLIPV;
    3275                 :            :                     }
    3276                 :            :                 }
    3277 [ +  - ][ #  # ]:          3 :             }
    3278                 :            :         }
    3279         [ #  # ]:          0 :         catch( const ::com::sun::star::uno::Exception& )
    3280                 :            :         {
    3281                 :            :         }
    3282                 :            :     }
    3283                 :          3 :     return eShapeType;
    3284                 :            : }
    3285                 :            : 
    3286                 :          0 : MSO_SPT EscherPropertyContainer::GetCustomShapeType( const uno::Reference< drawing::XShape > & rXShape, sal_uInt32& nMirrorFlags )
    3287                 :            : {
    3288                 :          0 :     rtl::OUString aShapeType;
    3289         [ #  # ]:          0 :     return GetCustomShapeType( rXShape, nMirrorFlags, aShapeType );
    3290                 :            : }
    3291                 :            : 
    3292                 :        141 : EscherPersistTable::EscherPersistTable()
    3293                 :            : {
    3294                 :        141 : }
    3295                 :            : 
    3296                 :        141 : EscherPersistTable::~EscherPersistTable()
    3297                 :            : {
    3298         [ +  + ]:        156 :     for( size_t i = 0, n = maPersistTable.size(); i < n; ++i ) {
    3299                 :         15 :         delete maPersistTable[ i ];
    3300                 :            :     }
    3301         [ -  + ]:        141 : }
    3302                 :            : 
    3303                 :          0 : sal_Bool EscherPersistTable::PtIsID( sal_uInt32 nID )
    3304                 :            : {
    3305         [ #  # ]:          0 :     for( size_t i = 0, n = maPersistTable.size(); i < n; ++i ) {
    3306                 :          0 :         EscherPersistEntry* pPtr = maPersistTable[ i ];
    3307         [ #  # ]:          0 :         if ( pPtr->mnID == nID ) {
    3308                 :          0 :             return sal_True;
    3309                 :            :         }
    3310                 :            :     }
    3311                 :          0 :     return sal_False;
    3312                 :            : }
    3313                 :            : 
    3314                 :         30 : void EscherPersistTable::PtInsert( sal_uInt32 nID, sal_uInt32 nOfs )
    3315                 :            : {
    3316         [ +  - ]:         30 :     maPersistTable.push_back( new EscherPersistEntry( nID, nOfs ) );
    3317                 :         30 : }
    3318                 :            : 
    3319                 :         24 : sal_uInt32 EscherPersistTable::PtDelete( sal_uInt32 nID )
    3320                 :            : {
    3321                 :         24 :     EscherPersistTable_impl::iterator it = maPersistTable.begin();
    3322 [ +  - ][ +  + ]:         66 :     for( ; it != maPersistTable.end() ; ++it )
    3323                 :            :     {
    3324         [ +  + ]:         57 :         if ( (*it)->mnID == nID ) {
    3325                 :         15 :             delete *it;
    3326         [ +  - ]:         15 :             maPersistTable.erase( it );
    3327                 :         15 :             break;
    3328                 :            :         }
    3329                 :            :     }
    3330                 :         24 :     return 0;
    3331                 :            : }
    3332                 :            : 
    3333                 :         21 : sal_uInt32 EscherPersistTable::PtGetOffsetByID( sal_uInt32 nID )
    3334                 :            : {
    3335         [ +  - ]:         42 :     for( size_t i = 0, n = maPersistTable.size(); i < n; ++i ) {
    3336                 :         42 :         EscherPersistEntry* pPtr = maPersistTable[ i ];
    3337         [ +  + ]:         42 :         if ( pPtr->mnID == nID ) {
    3338                 :         21 :             return pPtr->mnOffset;
    3339                 :            :         }
    3340                 :            :     }
    3341                 :         21 :     return 0;
    3342                 :            : };
    3343                 :            : 
    3344                 :          0 : sal_uInt32 EscherPersistTable::PtReplace( sal_uInt32 nID, sal_uInt32 nOfs )
    3345                 :            : {
    3346         [ #  # ]:          0 :     for( size_t i = 0, n = maPersistTable.size(); i < n; ++i ) {
    3347                 :          0 :         EscherPersistEntry* pPtr = maPersistTable[ i ];
    3348         [ #  # ]:          0 :         if ( pPtr->mnID == nID ) {
    3349                 :          0 :             sal_uInt32 nRetValue = pPtr->mnOffset;
    3350                 :          0 :             pPtr->mnOffset = nOfs;
    3351                 :          0 :             return nRetValue;
    3352                 :            :         }
    3353                 :            :     }
    3354                 :          0 :     return 0;
    3355                 :            : }
    3356                 :            : 
    3357                 :         30 : sal_uInt32 EscherPersistTable::PtReplaceOrInsert( sal_uInt32 nID, sal_uInt32 nOfs )
    3358                 :            : {
    3359         [ +  + ]:         78 :     for( size_t i = 0, n = maPersistTable.size(); i < n; ++i ) {
    3360                 :         48 :         EscherPersistEntry* pPtr = maPersistTable[ i ];
    3361         [ -  + ]:         48 :         if ( pPtr->mnID == nID ) {
    3362                 :          0 :             sal_uInt32 nRetValue = pPtr->mnOffset;
    3363                 :          0 :             pPtr->mnOffset = nOfs;
    3364                 :          0 :             return nRetValue;
    3365                 :            :         }
    3366                 :            :     }
    3367                 :         30 :     PtInsert( nID, nOfs );
    3368                 :         30 :     return 0;
    3369                 :            : }
    3370                 :            : 
    3371                 :         39 : sal_Bool EscherPropertyValueHelper::GetPropertyValue(
    3372                 :            :     ::com::sun::star::uno::Any& rAny,
    3373                 :            :     const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rXPropSet,
    3374                 :            :     const String& rString,
    3375                 :            :     sal_Bool bTestPropertyAvailability
    3376                 :            : ) {
    3377                 :         39 :     sal_Bool bRetValue = sal_True;
    3378         [ +  + ]:         39 :     if ( bTestPropertyAvailability )
    3379                 :            :     {
    3380                 :         18 :         bRetValue = sal_False;
    3381                 :            :         try
    3382                 :            :         {
    3383                 :            :             ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
    3384 [ +  - ][ +  - ]:         18 :                 aXPropSetInfo( rXPropSet->getPropertySetInfo() );
    3385         [ +  - ]:         18 :             if ( aXPropSetInfo.is() )
    3386 [ +  - ][ +  - ]:         18 :                 bRetValue = aXPropSetInfo->hasPropertyByName( rString );
         [ +  - ][ #  # ]
    3387                 :            :         }
    3388                 :          0 :         catch( const ::com::sun::star::uno::Exception& )
    3389                 :            :         {
    3390                 :          0 :             bRetValue = sal_False;
    3391                 :            :         }
    3392                 :            :     }
    3393         [ +  + ]:         39 :     if ( bRetValue )
    3394                 :            :     {
    3395                 :            :         try
    3396                 :            :         {
    3397 [ +  - ][ +  - ]:         36 :             rAny = rXPropSet->getPropertyValue( rString );
         [ +  - ][ #  # ]
    3398         [ -  + ]:         36 :             if ( !rAny.hasValue() )
    3399                 :          0 :                 bRetValue = sal_False;
    3400                 :            :         }
    3401                 :          0 :         catch( const ::com::sun::star::uno::Exception& )
    3402                 :            :         {
    3403                 :          0 :             bRetValue = sal_False;
    3404                 :            :         }
    3405                 :            :     }
    3406                 :         39 :     return bRetValue;
    3407                 :            : }
    3408                 :            : 
    3409                 :          3 : ::com::sun::star::beans::PropertyState EscherPropertyValueHelper::GetPropertyState(
    3410                 :            :     const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rXPropSet,
    3411                 :            :         const String& rPropertyName )
    3412                 :            : {
    3413                 :          3 :     ::com::sun::star::beans::PropertyState eRetValue = ::com::sun::star::beans::PropertyState_AMBIGUOUS_VALUE;
    3414                 :            :     try
    3415                 :            :     {
    3416                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState > aXPropState
    3417         [ +  - ]:          3 :                 ( rXPropSet, ::com::sun::star::uno::UNO_QUERY );
    3418         [ +  - ]:          3 :         if ( aXPropState.is() )
    3419 [ +  - ][ +  - ]:          3 :             eRetValue = aXPropState->getPropertyState( rPropertyName );
         [ +  - ][ #  # ]
    3420                 :            :     }
    3421                 :          0 :     catch( const ::com::sun::star::uno::Exception& )
    3422                 :            :     {
    3423                 :            :     }
    3424                 :          3 :     return eRetValue;
    3425                 :            : }
    3426                 :            : 
    3427                 :          6 : EscherBlibEntry::EscherBlibEntry( sal_uInt32 nPictureOffset, const GraphicObject& rObject, const rtl::OString& rId,
    3428                 :            :                                         const GraphicAttr* pGraphicAttr ) :
    3429                 :            :     mnPictureOffset ( nPictureOffset ),
    3430                 :            :     mnRefCount      ( 1 ),
    3431                 :            :     mnSizeExtra     ( 0 ),
    3432                 :          6 :     maPrefSize      ( rObject.GetPrefSize() ),
    3433                 :          6 :     maPrefMapMode   ( rObject.GetPrefMapMode() ),
    3434                 :          6 :     mbIsEmpty       ( sal_True )
    3435                 :            : {
    3436                 :          6 :     mbIsNativeGraphicPossible = ( pGraphicAttr == NULL );
    3437                 :          6 :     meBlibType = UNKNOWN;
    3438                 :          6 :     mnSize = 0;
    3439                 :            : 
    3440                 :          6 :     sal_uInt32      nLen = static_cast<sal_uInt32>(rId.getLength());
    3441                 :          6 :     const sal_Char* pData = rId.getStr();
    3442                 :          6 :     GraphicType     eType( rObject.GetType() );
    3443 [ +  - ][ +  - ]:          6 :     if ( nLen && pData && ( eType != GRAPHIC_NONE ) )
                 [ +  - ]
    3444                 :            :     {
    3445                 :          6 :         mnIdentifier[ 0 ] = rtl_crc32( 0,pData, nLen );
    3446                 :          6 :         mnIdentifier[ 1 ] = 0;
    3447                 :            : 
    3448         [ -  + ]:          6 :         if ( pGraphicAttr )
    3449                 :            :         {
    3450   [ #  #  #  #  :          0 :             if ( pGraphicAttr->IsSpecialDrawMode()
          #  #  #  #  #  
                #  #  # ]
                 [ #  # ]
    3451                 :          0 :                     || pGraphicAttr->IsMirrored()
    3452                 :          0 :                          || pGraphicAttr->IsCropped()
    3453                 :          0 :                             || pGraphicAttr->IsRotated()
    3454                 :          0 :                                 || pGraphicAttr->IsTransparent()
    3455                 :          0 :                                     || pGraphicAttr->IsAdjusted() )
    3456                 :            :             {
    3457         [ #  # ]:          0 :                 SvMemoryStream aSt( sizeof( GraphicAttr ) );
    3458         [ #  # ]:          0 :                 aSt << static_cast<sal_uInt16>(pGraphicAttr->GetDrawMode())
    3459         [ #  # ]:          0 :                     << static_cast<sal_uInt32>(pGraphicAttr->GetMirrorFlags())
    3460         [ #  # ]:          0 :                     << static_cast<sal_Int32>(pGraphicAttr->GetLeftCrop())
    3461         [ #  # ]:          0 :                     << static_cast<sal_Int32>(pGraphicAttr->GetTopCrop())
    3462         [ #  # ]:          0 :                     << static_cast<sal_Int32>(pGraphicAttr->GetRightCrop())
    3463         [ #  # ]:          0 :                     << static_cast<sal_Int32>(pGraphicAttr->GetBottomCrop())
    3464         [ #  # ]:          0 :                     << pGraphicAttr->GetRotation()
    3465         [ #  # ]:          0 :                     << pGraphicAttr->GetLuminance()
    3466         [ #  # ]:          0 :                     << pGraphicAttr->GetContrast()
    3467         [ #  # ]:          0 :                     << pGraphicAttr->GetChannelR()
    3468         [ #  # ]:          0 :                     << pGraphicAttr->GetChannelG()
    3469         [ #  # ]:          0 :                     << pGraphicAttr->GetChannelB()
    3470         [ #  # ]:          0 :                     << pGraphicAttr->GetGamma()
    3471         [ #  # ]:          0 :                     << (sal_Bool)( pGraphicAttr->IsInvert() == sal_True )
    3472         [ #  # ]:          0 :                     << pGraphicAttr->GetTransparency();
    3473 [ #  # ][ #  # ]:          0 :                 mnIdentifier[ 1 ] = rtl_crc32( 0, aSt.GetData(), aSt.Tell() );
    3474                 :            :             }
    3475                 :            :             else
    3476                 :          0 :                 mbIsNativeGraphicPossible = sal_True;
    3477                 :            :         }
    3478                 :            :         sal_uInt32 i, nTmp, n1, n2;
    3479                 :          6 :         n1 = n2 = 0;
    3480         [ +  + ]:        198 :         for ( i = 0; i < nLen; i++ )
    3481                 :            :         {
    3482                 :        192 :             nTmp = n2 >> 28;    // rotating 4 bit
    3483                 :        192 :             n2 <<= 4;
    3484                 :        192 :             n2 |= n1 >> 28;
    3485                 :        192 :             n1 <<= 4;
    3486                 :        192 :             n1 |= nTmp;
    3487                 :        192 :             n1 ^= *pData++ - '0';
    3488                 :            :         }
    3489                 :          6 :         mnIdentifier[ 2 ] = n1;
    3490                 :          6 :         mnIdentifier[ 3 ] = n2;
    3491                 :          6 :         mbIsEmpty = sal_False;
    3492                 :            :     }
    3493                 :          6 : };
    3494                 :            : 
    3495                 :          6 : void EscherBlibEntry::WriteBlibEntry( SvStream& rSt, sal_Bool bWritePictureOffset, sal_uInt32 nResize )
    3496                 :            : {
    3497         [ +  - ]:          6 :     sal_uInt32  nPictureOffset = ( bWritePictureOffset ) ? mnPictureOffset : 0;
    3498                 :            : 
    3499                 :          6 :     rSt << (sal_uInt32)( ( ESCHER_BSE << 16 ) | ( ( (sal_uInt16)meBlibType << 4 ) | 2 ) )
    3500                 :          6 :         << (sal_uInt32)( 36 + nResize )
    3501                 :          6 :         << (sal_uInt8)meBlibType;
    3502                 :            : 
    3503         [ +  + ]:          6 :     switch ( meBlibType )
    3504                 :            :     {
    3505                 :            :         case EMF :
    3506                 :            :         case WMF :  // converting EMF/WMF on OS2 to Pict
    3507                 :          3 :             rSt << (sal_uInt8)PICT;
    3508                 :          3 :         break;
    3509                 :            :         default:
    3510                 :          3 :             rSt << (sal_uInt8)meBlibType;
    3511                 :            :     };
    3512                 :            : 
    3513                 :          6 :     rSt.Write( &mnIdentifier[ 0 ], 16 );
    3514                 :          6 :     rSt << (sal_uInt16)0
    3515                 :          6 :         << (sal_uInt32)( mnSize + mnSizeExtra )
    3516                 :          6 :         << mnRefCount
    3517                 :          6 :         << nPictureOffset
    3518                 :          6 :         << (sal_uInt32)0;
    3519                 :          6 : }
    3520                 :            : 
    3521                 :          6 : EscherBlibEntry::~EscherBlibEntry()
    3522                 :            : {
    3523                 :          6 : };
    3524                 :            : 
    3525                 :          0 : sal_Bool EscherBlibEntry::operator==( const EscherBlibEntry& rEscherBlibEntry ) const
    3526                 :            : {
    3527         [ #  # ]:          0 :     for ( int i = 0; i < 3; i++ )
    3528                 :            :     {
    3529         [ #  # ]:          0 :         if ( mnIdentifier[ i ] != rEscherBlibEntry.mnIdentifier[ i ] )
    3530                 :          0 :             return sal_False;
    3531                 :            :     }
    3532                 :          0 :     return sal_True;
    3533                 :            : }
    3534                 :            : 
    3535                 :        141 : EscherGraphicProvider::EscherGraphicProvider( sal_uInt32 nFlags ) :
    3536                 :            :     mnFlags         ( nFlags ),
    3537                 :            :     mpBlibEntrys    ( NULL ),
    3538                 :            :     mnBlibBufSize   ( 0 ),
    3539                 :        141 :     mnBlibEntrys    ( 0 )
    3540                 :            : {
    3541                 :        141 : }
    3542                 :            : 
    3543                 :        141 : EscherGraphicProvider::~EscherGraphicProvider()
    3544                 :            : {
    3545 [ +  - ][ +  - ]:        147 :     for ( sal_uInt32 i = 0; i < mnBlibEntrys; delete mpBlibEntrys[ i++ ] ) ;
                 [ +  + ]
    3546         [ +  + ]:        141 :     delete[] mpBlibEntrys;
    3547                 :        141 : }
    3548                 :            : 
    3549                 :          6 : void EscherGraphicProvider::SetNewBlipStreamOffset( sal_Int32 nOffset )
    3550                 :            : {
    3551         [ +  + ]:         12 :     for( sal_uInt32 i = 0; i < mnBlibEntrys; i++ )
    3552                 :            :     {
    3553                 :          6 :         EscherBlibEntry* pBlibEntry = mpBlibEntrys[ i ];
    3554                 :          6 :         pBlibEntry->mnPictureOffset += nOffset;
    3555                 :            :     }
    3556                 :          6 : }
    3557                 :            : 
    3558                 :          6 : sal_uInt32 EscherGraphicProvider::ImplInsertBlib( EscherBlibEntry* p_EscherBlibEntry )
    3559                 :            : {
    3560         [ +  - ]:          6 :     if ( mnBlibBufSize == mnBlibEntrys )
    3561                 :            :     {
    3562                 :          6 :         mnBlibBufSize += 64;
    3563                 :          6 :         EscherBlibEntry** pTemp = new EscherBlibEntry*[ mnBlibBufSize ];
    3564         [ -  + ]:          6 :         for ( sal_uInt32 i = 0; i < mnBlibEntrys; i++ )
    3565                 :            :         {
    3566                 :          0 :             pTemp[ i ] = mpBlibEntrys[ i ];
    3567                 :            :         }
    3568         [ -  + ]:          6 :         delete[] mpBlibEntrys;
    3569                 :          6 :         mpBlibEntrys = pTemp;
    3570                 :            :     }
    3571                 :          6 :     mpBlibEntrys[ mnBlibEntrys++ ] = p_EscherBlibEntry;
    3572                 :          6 :     return mnBlibEntrys;
    3573                 :            : }
    3574                 :            : 
    3575                 :         12 : sal_uInt32 EscherGraphicProvider::GetBlibStoreContainerSize( SvStream* pMergePicStreamBSE ) const
    3576                 :            : {
    3577                 :         12 :     sal_uInt32 nSize = 44 * mnBlibEntrys + 8;
    3578         [ -  + ]:         12 :     if ( pMergePicStreamBSE )
    3579                 :            :     {
    3580         [ #  # ]:          0 :         for ( sal_uInt32 i = 0; i < mnBlibEntrys; i++ )
    3581                 :          0 :             nSize += mpBlibEntrys[ i ]->mnSize + mpBlibEntrys[ i ]->mnSizeExtra;
    3582                 :            :     }
    3583                 :         12 :     return nSize;
    3584                 :            : }
    3585                 :            : 
    3586                 :          0 : sal_Bool EscherGraphicProvider::WriteBlibStoreEntry(SvStream& rSt,
    3587                 :            :     sal_uInt32 nBlipId, sal_Bool bWritePictureOffSet, sal_uInt32 nResize)
    3588                 :            : {
    3589 [ #  # ][ #  # ]:          0 :     if (nBlipId > mnBlibEntrys || nBlipId == 0)
    3590                 :          0 :         return sal_False;
    3591                 :          0 :     mpBlibEntrys[nBlipId-1]->WriteBlibEntry(rSt, bWritePictureOffSet, nResize);
    3592                 :          0 :     return sal_True;
    3593                 :            : }
    3594                 :            : 
    3595                 :          6 : void EscherGraphicProvider::WriteBlibStoreContainer( SvStream& rSt, SvStream* pMergePicStreamBSE )
    3596                 :            : {
    3597                 :          6 :     sal_uInt32  nSize = GetBlibStoreContainerSize( pMergePicStreamBSE );
    3598         [ +  - ]:          6 :     if ( nSize )
    3599                 :            :     {
    3600                 :          6 :         rSt << (sal_uInt32)( ( ESCHER_BstoreContainer << 16 ) | 0x1f )
    3601                 :          6 :             << (sal_uInt32)( nSize - 8 );
    3602                 :            : 
    3603         [ -  + ]:          6 :         if ( pMergePicStreamBSE )
    3604                 :            :         {
    3605                 :          0 :             sal_uInt32 i, nBlipSize, nOldPos = pMergePicStreamBSE->Tell();
    3606                 :          0 :             const sal_uInt32 nBuf = 0x40000;    // 256KB buffer
    3607                 :          0 :             sal_uInt8* pBuf = new sal_uInt8[ nBuf ];
    3608                 :            : 
    3609         [ #  # ]:          0 :             for ( i = 0; i < mnBlibEntrys; i++ )
    3610                 :            :             {
    3611                 :          0 :                 EscherBlibEntry* pBlibEntry = mpBlibEntrys[ i ];
    3612                 :            : 
    3613                 :          0 :                 ESCHER_BlibType nBlibType = pBlibEntry->meBlibType;
    3614                 :          0 :                 nBlipSize = pBlibEntry->mnSize + pBlibEntry->mnSizeExtra;
    3615         [ #  # ]:          0 :                 pBlibEntry->WriteBlibEntry( rSt, sal_False, nBlipSize );
    3616                 :            : 
    3617                 :            :                 // BLIP
    3618         [ #  # ]:          0 :                 pMergePicStreamBSE->Seek( pBlibEntry->mnPictureOffset );
    3619                 :            :                 sal_uInt16 n16;
    3620                 :            :                 // record version and instance
    3621         [ #  # ]:          0 :                 *pMergePicStreamBSE >> n16;
    3622         [ #  # ]:          0 :                 rSt << n16;
    3623                 :            :                 // record type
    3624         [ #  # ]:          0 :                 *pMergePicStreamBSE >> n16;
    3625         [ #  # ]:          0 :                 rSt << sal_uInt16( ESCHER_BlipFirst + nBlibType );
    3626                 :            :                 DBG_ASSERT( n16 == ESCHER_BlipFirst + nBlibType , "EscherGraphicProvider::WriteBlibStoreContainer: BLIP record types differ" );
    3627                 :            :                 sal_uInt32 n32;
    3628                 :            :                 // record size
    3629         [ #  # ]:          0 :                 *pMergePicStreamBSE >> n32;
    3630                 :          0 :                 nBlipSize -= 8;
    3631         [ #  # ]:          0 :                 rSt << nBlipSize;
    3632                 :            :                 DBG_ASSERT( nBlipSize == n32, "EscherGraphicProvider::WriteBlibStoreContainer: BLIP sizes differ" );
    3633                 :            :                 // record
    3634         [ #  # ]:          0 :                 while ( nBlipSize )
    3635                 :            :                 {
    3636                 :          0 :                     sal_uInt32 nBytes = ( nBlipSize > nBuf ? nBuf : nBlipSize );
    3637         [ #  # ]:          0 :                     pMergePicStreamBSE->Read( pBuf, nBytes );
    3638         [ #  # ]:          0 :                     rSt.Write( pBuf, nBytes );
    3639                 :          0 :                     nBlipSize -= nBytes;
    3640                 :            :                 }
    3641                 :            :             }
    3642         [ #  # ]:          0 :             delete[] pBuf;
    3643                 :          0 :             pMergePicStreamBSE->Seek( nOldPos );
    3644                 :            :         }
    3645                 :            :         else
    3646                 :            :         {
    3647         [ +  + ]:         12 :             for ( sal_uInt32 i = 0; i < mnBlibEntrys; i++ )
    3648                 :          6 :                 mpBlibEntrys[ i ]->WriteBlibEntry( rSt, sal_True );
    3649                 :            :         }
    3650                 :            :     }
    3651                 :          6 : }
    3652                 :            : 
    3653                 :          0 : sal_Bool EscherGraphicProvider::GetPrefSize( const sal_uInt32 nBlibId, Size& rPrefSize, MapMode& rPrefMapMode )
    3654                 :            : {
    3655 [ #  # ][ #  # ]:          0 :     sal_Bool bInRange = nBlibId && ( ( nBlibId - 1 ) < mnBlibEntrys );
    3656         [ #  # ]:          0 :     if ( bInRange )
    3657                 :            :     {
    3658                 :          0 :         EscherBlibEntry* pEntry = mpBlibEntrys[ nBlibId - 1 ];
    3659                 :          0 :         rPrefSize = pEntry->maPrefSize;
    3660                 :          0 :         rPrefMapMode = pEntry->maPrefMapMode;
    3661                 :            :     }
    3662                 :          0 :     return bInRange;
    3663                 :            : }
    3664                 :            : 
    3665                 :          6 : sal_uInt32 EscherGraphicProvider::GetBlibID( SvStream& rPicOutStrm, const rtl::OString& rId,
    3666                 :            :                                             const Rectangle& /* rBoundRect */, const com::sun::star::awt::Rectangle* pVisArea, const GraphicAttr* pGraphicAttr )
    3667                 :            : {
    3668                 :          6 :     sal_uInt32          nBlibId = 0;
    3669         [ +  - ]:          6 :     GraphicObject       aGraphicObject( rId );
    3670                 :            : 
    3671 [ +  - ][ +  - ]:          6 :     EscherBlibEntry* p_EscherBlibEntry = new EscherBlibEntry( rPicOutStrm.Tell(), aGraphicObject, rId, pGraphicAttr );
    3672         [ +  - ]:          6 :     if ( !p_EscherBlibEntry->IsEmpty() )
    3673                 :            :     {
    3674         [ -  + ]:          6 :         for ( sal_uInt32 i = 0; i < mnBlibEntrys; i++ )
    3675                 :            :         {
    3676         [ #  # ]:          0 :             if ( *( mpBlibEntrys[ i ] ) == *p_EscherBlibEntry )
    3677                 :            :             {
    3678                 :          0 :                 mpBlibEntrys[ i ]->mnRefCount++;
    3679 [ #  # ][ #  # ]:          0 :                 delete p_EscherBlibEntry;
    3680                 :          0 :                 return i + 1;
    3681                 :            :             }
    3682                 :            :         }
    3683                 :            : 
    3684                 :          6 :         sal_Bool            bUseNativeGraphic( sal_False );
    3685                 :            : 
    3686         [ +  - ]:          6 :         Graphic             aGraphic( aGraphicObject.GetTransformedGraphic( pGraphicAttr ) );
    3687         [ +  - ]:          6 :         GfxLink             aGraphicLink;
    3688         [ +  - ]:          6 :         SvMemoryStream      aStream;
    3689                 :            : 
    3690                 :          6 :         const sal_uInt8*    pGraphicAry = NULL;
    3691                 :            : 
    3692 [ +  - ][ +  - ]:          6 :         if ( p_EscherBlibEntry->mbIsNativeGraphicPossible && aGraphic.IsLink() )
         [ +  + ][ +  + ]
    3693                 :            :         {
    3694 [ +  - ][ +  - ]:          3 :             aGraphicLink = aGraphic.GetLink();
                 [ +  - ]
    3695                 :            : 
    3696         [ +  - ]:          3 :             p_EscherBlibEntry->mnSize = aGraphicLink.GetDataSize();
    3697         [ +  - ]:          3 :             pGraphicAry = aGraphicLink.GetData();
    3698                 :            : 
    3699 [ +  - ][ +  - ]:          3 :             if ( p_EscherBlibEntry->mnSize && pGraphicAry )
    3700                 :            :             {
    3701         [ +  - ]:          3 :                 switch ( aGraphicLink.GetType() )
           [ -  +  -  - ]
    3702                 :            :                 {
    3703                 :          0 :                     case GFX_LINK_TYPE_NATIVE_JPG : p_EscherBlibEntry->meBlibType = PEG; break;
    3704                 :          3 :                     case GFX_LINK_TYPE_NATIVE_PNG : p_EscherBlibEntry->meBlibType = PNG; break;
    3705                 :            :                     case GFX_LINK_TYPE_NATIVE_WMF :
    3706                 :            :                     {
    3707 [ #  # ][ #  # ]:          0 :                         if ( pGraphicAry && ( p_EscherBlibEntry->mnSize > 0x2c ) )
    3708                 :            :                         {
    3709 [ #  # ][ #  # ]:          0 :                             if ( ( pGraphicAry[ 0x28 ] == 0x20 ) && ( pGraphicAry[ 0x29 ] == 0x45 )     // check the magic
         [ #  # ][ #  # ]
    3710                 :          0 :                                 && ( pGraphicAry[ 0x2a ] == 0x4d ) && ( pGraphicAry[ 0x2b ] == 0x46 ) ) // number ( emf detection )
    3711                 :            :                             {
    3712                 :          0 :                                 p_EscherBlibEntry->meBlibType = EMF;
    3713                 :            :                             }
    3714                 :            :                             else
    3715                 :            :                             {
    3716                 :          0 :                                 p_EscherBlibEntry->meBlibType = WMF;
    3717 [ #  # ][ #  # ]:          0 :                                 if ( ( pGraphicAry[ 0 ] == 0xd7 ) && ( pGraphicAry[ 1 ] == 0xcd )
         [ #  # ][ #  # ]
    3718                 :          0 :                                     && ( pGraphicAry[ 2 ] == 0xc6 ) && ( pGraphicAry[ 3 ] == 0x9a ) )
    3719                 :            :                                 {   // we have to get rid of the metafileheader
    3720                 :          0 :                                     pGraphicAry += 22;
    3721                 :          0 :                                     p_EscherBlibEntry->mnSize -= 22;
    3722                 :            :                                 }
    3723                 :            :                             }
    3724                 :            :                         }
    3725                 :            :                     }
    3726                 :          0 :                     break;
    3727                 :          0 :                     default: break;
    3728                 :            :                 }
    3729         [ +  - ]:          3 :                 if ( p_EscherBlibEntry->meBlibType != UNKNOWN )
    3730                 :          3 :                     bUseNativeGraphic = sal_True;
    3731                 :            :             }
    3732                 :            :         }
    3733         [ +  + ]:          6 :         if ( !bUseNativeGraphic )
    3734                 :            :         {
    3735         [ +  - ]:          3 :             GraphicType eGraphicType = aGraphic.GetType();
    3736 [ +  - ][ +  - ]:          3 :             if ( ( eGraphicType == GRAPHIC_BITMAP ) || ( eGraphicType == GRAPHIC_GDIMETAFILE ) )
    3737                 :            :             {
    3738                 :            :                 sal_uInt32 nErrCode;
    3739 [ +  - ][ +  - ]:          3 :                 if ( !aGraphic.IsAnimated() )
    3740 [ -  + ][ +  - ]:          3 :                     nErrCode = GraphicConverter::Export( aStream, aGraphic, ( eGraphicType == GRAPHIC_BITMAP ) ? CVT_PNG  : CVT_EMF );
    3741                 :            :                 else
    3742                 :            :                 {   // to store a animation, a gif has to be included into the msOG chunk of a png  #I5583#
    3743         [ #  # ]:          0 :                     GraphicFilter &rFilter = GraphicFilter::GetGraphicFilter();
    3744         [ #  # ]:          0 :                     SvMemoryStream  aGIFStream;
    3745         [ #  # ]:          0 :                     aGIFStream.Write(RTL_CONSTASCII_STRINGPARAM("MSOFFICE9.0"));
    3746                 :            :                     nErrCode = rFilter.ExportGraphic( aGraphic, String(), aGIFStream,
    3747 [ #  # ][ #  # ]:          0 :                         rFilter.GetExportFormatNumberForShortName( String( RTL_CONSTASCII_USTRINGPARAM( "GIF" ) ) ), NULL );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    3748         [ #  # ]:          0 :                     com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > aFilterData( 1 );
    3749         [ #  # ]:          0 :                     com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > aAdditionalChunkSequence( 1 );
    3750                 :          0 :                     sal_uInt32 nGIFSreamLen = aGIFStream.Tell();
    3751         [ #  # ]:          0 :                     com::sun::star::uno::Sequence< sal_Int8 > aGIFSeq( nGIFSreamLen );
    3752         [ #  # ]:          0 :                     sal_Int8* pSeq = aGIFSeq.getArray();
    3753         [ #  # ]:          0 :                     aGIFStream.Seek( STREAM_SEEK_TO_BEGIN );
    3754         [ #  # ]:          0 :                     aGIFStream.Read( pSeq, nGIFSreamLen );
    3755                 :          0 :                     com::sun::star::beans::PropertyValue aChunkProp, aFilterProp;
    3756 [ #  # ][ #  # ]:          0 :                     aChunkProp.Name = String( RTL_CONSTASCII_USTRINGPARAM( "msOG" ) );
                 [ #  # ]
    3757         [ #  # ]:          0 :                     aChunkProp.Value <<= aGIFSeq;
    3758         [ #  # ]:          0 :                     aAdditionalChunkSequence[ 0 ] = aChunkProp;
    3759 [ #  # ][ #  # ]:          0 :                     aFilterProp.Name = String( RTL_CONSTASCII_USTRINGPARAM( "AdditionalChunks" ) );
                 [ #  # ]
    3760         [ #  # ]:          0 :                     aFilterProp.Value <<= aAdditionalChunkSequence;
    3761         [ #  # ]:          0 :                     aFilterData[ 0 ] = aFilterProp;
    3762                 :            :                     nErrCode = rFilter.ExportGraphic( aGraphic, String(), aStream,
    3763 [ #  # ][ #  # ]:          0 :                         rFilter.GetExportFormatNumberForShortName( String( RTL_CONSTASCII_USTRINGPARAM( "PNG" ) ) ), &aFilterData );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    3764                 :            :                 }
    3765         [ +  - ]:          3 :                 if ( nErrCode == ERRCODE_NONE )
    3766                 :            :                 {
    3767         [ -  + ]:          3 :                     p_EscherBlibEntry->meBlibType = ( eGraphicType == GRAPHIC_BITMAP ) ? PNG : EMF;
    3768         [ +  - ]:          3 :                     aStream.Seek( STREAM_SEEK_TO_END );
    3769                 :          3 :                     p_EscherBlibEntry->mnSize = aStream.Tell();
    3770         [ +  - ]:          3 :                     pGraphicAry = (sal_uInt8*)aStream.GetData();
    3771                 :            : 
    3772         [ -  + ]:          3 :                     if ( p_EscherBlibEntry->meBlibType == WMF )     // the fileheader is not used
    3773                 :            :                     {
    3774                 :          0 :                         p_EscherBlibEntry->mnSize -= 22;
    3775                 :          0 :                         pGraphicAry += 22;
    3776                 :            :                     }
    3777                 :            :                 }
    3778                 :            :             }
    3779                 :            :         }
    3780                 :            : 
    3781                 :          6 :         ESCHER_BlibType eBlibType = p_EscherBlibEntry->meBlibType;
    3782 [ +  - ][ +  - ]:          6 :         if ( p_EscherBlibEntry->mnSize && pGraphicAry && ( eBlibType != UNKNOWN ) )
                 [ +  - ]
    3783                 :            :         {
    3784                 :          6 :             sal_uInt32 nExtra, nAtomSize = 0;
    3785                 :          6 :             sal_uInt32 nInstance, nUncompressedSize = p_EscherBlibEntry->mnSize;
    3786                 :            : 
    3787         [ -  + ]:          6 :             if ( mnFlags & _E_GRAPH_PROV_USE_INSTANCES )
    3788                 :            :             {
    3789         [ #  # ]:          0 :                 rPicOutStrm << (sal_uInt32)( 0x7f90000 | (sal_uInt16)( mnBlibEntrys << 4 ) )
    3790         [ #  # ]:          0 :                             << (sal_uInt32)0;
    3791                 :          0 :                 nAtomSize = rPicOutStrm.Tell();
    3792         [ #  # ]:          0 :                  if ( eBlibType == PNG )
    3793         [ #  # ]:          0 :                     rPicOutStrm << (sal_uInt16)0x0606;
    3794         [ #  # ]:          0 :                 else if ( eBlibType == WMF )
    3795         [ #  # ]:          0 :                     rPicOutStrm << (sal_uInt16)0x0403;
    3796         [ #  # ]:          0 :                 else if ( eBlibType == EMF )
    3797         [ #  # ]:          0 :                     rPicOutStrm << (sal_uInt16)0x0402;
    3798         [ #  # ]:          0 :                 else if ( eBlibType == PEG )
    3799         [ #  # ]:          0 :                     rPicOutStrm << (sal_uInt16)0x0505;
    3800                 :            :             }
    3801 [ +  - ][ +  + ]:          6 :             if ( ( eBlibType == PEG ) || ( eBlibType == PNG ) )
    3802                 :            :             {
    3803                 :          3 :                 nExtra = 17;
    3804                 :          3 :                 p_EscherBlibEntry->mnSizeExtra = nExtra + 8;
    3805         [ +  - ]:          3 :                 nInstance = ( eBlibType == PNG ) ? 0xf01e6e00 : 0xf01d46a0;
    3806 [ +  - ][ +  - ]:          3 :                 rPicOutStrm << nInstance << (sal_uInt32)( p_EscherBlibEntry->mnSize + nExtra );
    3807         [ +  - ]:          3 :                 rPicOutStrm.Write( p_EscherBlibEntry->mnIdentifier, 16 );
    3808         [ +  - ]:          3 :                 rPicOutStrm << (sal_uInt8)0xff;
    3809         [ +  - ]:          3 :                 rPicOutStrm.Write( pGraphicAry, p_EscherBlibEntry->mnSize );
    3810                 :            :             }
    3811                 :            :             else
    3812                 :            :             {
    3813         [ +  - ]:          3 :                 ZCodec aZCodec( 0x8000, 0x8000 );
    3814         [ +  - ]:          3 :                 aZCodec.BeginCompression();
    3815         [ +  - ]:          3 :                 SvMemoryStream aDestStrm;
    3816         [ +  - ]:          3 :                 aZCodec.Write( aDestStrm, pGraphicAry, p_EscherBlibEntry->mnSize );
    3817         [ +  - ]:          3 :                 aZCodec.EndCompression();
    3818         [ +  - ]:          3 :                 aDestStrm.Seek( STREAM_SEEK_TO_END );
    3819                 :          3 :                 p_EscherBlibEntry->mnSize = aDestStrm.Tell();
    3820         [ +  - ]:          3 :                 pGraphicAry = (sal_uInt8*)aDestStrm.GetData();
    3821 [ +  - ][ +  - ]:          3 :                 if ( p_EscherBlibEntry->mnSize && pGraphicAry )
    3822                 :            :                 {
    3823         [ -  + ]:          3 :                     nExtra = eBlibType == WMF ? 0x42 : 0x32;                                    // !EMF -> no change
    3824                 :          3 :                     p_EscherBlibEntry->mnSizeExtra = nExtra + 8;
    3825         [ -  + ]:          3 :                     nInstance = ( eBlibType == WMF ) ? 0xf01b2170 : 0xf01a3d40;                 // !EMF -> no change
    3826 [ +  - ][ +  - ]:          3 :                     rPicOutStrm << nInstance << (sal_uInt32)( p_EscherBlibEntry->mnSize + nExtra );
    3827         [ -  + ]:          3 :                     if ( eBlibType == WMF )                                                     // !EMF -> no change
    3828         [ #  # ]:          0 :                         rPicOutStrm.Write( p_EscherBlibEntry->mnIdentifier, 16 );
    3829         [ +  - ]:          3 :                     rPicOutStrm.Write( p_EscherBlibEntry->mnIdentifier, 16 );
    3830                 :            : 
    3831                 :            :                     /*
    3832                 :            :                      ##913##
    3833                 :            :                      For Word the stored size of the graphic is critical the
    3834                 :            :                      metafile boundaries must match the actual graphics
    3835                 :            :                      boundaries, and the width and height must be in EMU's
    3836                 :            : 
    3837                 :            :                      If you don't do it this way then objects edited in the
    3838                 :            :                      msoffice app may show strange behaviour as the size jumps
    3839                 :            :                      around, and the original size and scaling factor in word
    3840                 :            :                      will be a very strange figure
    3841                 :            :                     */
    3842                 :          3 :                     sal_uInt32 nPrefWidth = p_EscherBlibEntry->maPrefSize.Width();
    3843                 :          3 :                     sal_uInt32 nPrefHeight = p_EscherBlibEntry->maPrefSize.Height();
    3844                 :            :                     sal_uInt32 nWidth, nHeight;
    3845         [ -  + ]:          3 :                     if ( pVisArea )
    3846                 :            :                     {
    3847                 :          0 :                         nWidth = pVisArea->Width * 360;
    3848                 :          0 :                         nHeight = pVisArea->Height * 360;
    3849                 :            :                     }
    3850                 :            :                     else
    3851                 :            :                     {
    3852 [ +  - ][ +  - ]:          3 :                         Size aPrefSize(lcl_SizeToEmu(p_EscherBlibEntry->maPrefSize, p_EscherBlibEntry->maPrefMapMode));
                 [ +  - ]
    3853                 :          3 :                         nWidth = aPrefSize.Width() * 360;
    3854                 :          3 :                         nHeight = aPrefSize.Height() * 360;
    3855                 :            :                     }
    3856         [ +  - ]:          3 :                     rPicOutStrm << nUncompressedSize // WMFSize without FileHeader
    3857         [ +  - ]:          3 :                     << (sal_Int32)0     // since we can't find out anymore what the original size of
    3858         [ +  - ]:          3 :                     << (sal_Int32)0     // the WMF (without Fileheader) was we write 10cm / x
    3859         [ +  - ]:          3 :                     << nPrefWidth
    3860         [ +  - ]:          3 :                     << nPrefHeight
    3861         [ +  - ]:          3 :                     << nWidth
    3862         [ +  - ]:          3 :                     << nHeight
    3863         [ +  - ]:          3 :                     << p_EscherBlibEntry->mnSize
    3864         [ +  - ]:          3 :                     << (sal_uInt16)0xfe00;  // compression Flags
    3865         [ +  - ]:          3 :                     rPicOutStrm.Write( pGraphicAry, p_EscherBlibEntry->mnSize );
    3866 [ +  - ][ +  - ]:          3 :                 }
    3867                 :            :             }
    3868         [ -  + ]:          6 :             if ( nAtomSize )
    3869                 :            :             {
    3870                 :          0 :                 sal_uInt32  nPos = rPicOutStrm.Tell();
    3871         [ #  # ]:          0 :                 rPicOutStrm.Seek( nAtomSize - 4 );
    3872         [ #  # ]:          0 :                 rPicOutStrm << (sal_uInt32)( nPos - nAtomSize );
    3873         [ #  # ]:          0 :                 rPicOutStrm.Seek( nPos );
    3874                 :            :             }
    3875         [ +  - ]:          6 :             nBlibId = ImplInsertBlib( p_EscherBlibEntry ), p_EscherBlibEntry = NULL;
    3876 [ +  - ][ +  - ]:          6 :         }
                 [ +  - ]
    3877                 :            :     }
    3878         [ -  + ]:          6 :     if ( p_EscherBlibEntry )
    3879 [ #  # ][ #  # ]:          0 :         delete p_EscherBlibEntry;
    3880         [ +  - ]:          6 :     return nBlibId;
    3881                 :            : }
    3882                 :            : 
    3883                 :            : struct EscherConnectorRule
    3884                 :            : {
    3885                 :            :     sal_uInt32  nRuleId;
    3886                 :            :     sal_uInt32  nShapeA;        // SPID of shape A
    3887                 :            :     sal_uInt32  nShapeB;        // SPID of shape B
    3888                 :            :     sal_uInt32  nShapeC;        // SPID of connector shape
    3889                 :            :     sal_uInt32  ncptiA;         // Connection site Index of shape A
    3890                 :            :     sal_uInt32  ncptiB;         // Connection site Index of shape B
    3891                 :            : };
    3892                 :            : 
    3893                 :          3 : struct EscherShapeListEntry
    3894                 :            : {
    3895                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >   aXShape;
    3896                 :            :     sal_uInt32          n_EscherId;
    3897                 :            : 
    3898                 :          3 :                         EscherShapeListEntry( const ::com::sun::star::uno::Reference
    3899                 :            :                             < ::com::sun::star::drawing::XShape > & rShape, sal_uInt32 nId ) :
    3900                 :            :                                         aXShape     ( rShape ),
    3901                 :          3 :                                         n_EscherId  ( nId ) {}
    3902                 :            : };
    3903                 :            : 
    3904                 :          0 : sal_uInt32 EscherConnectorListEntry::GetClosestPoint( const Polygon& rPoly, const ::com::sun::star::awt::Point& rPoint )
    3905                 :            : {
    3906                 :          0 :     sal_uInt16 nCount = rPoly.GetSize();
    3907                 :          0 :     sal_uInt16 nClosest = nCount;
    3908                 :          0 :     double fDist = (sal_uInt32)0xffffffff;
    3909         [ #  # ]:          0 :     while( nCount-- )
    3910                 :            :     {
    3911                 :          0 :         double fDistance = hypot( rPoint.X - rPoly[ nCount ].X(), rPoint.Y - rPoly[ nCount ].Y() );
    3912         [ #  # ]:          0 :         if ( fDistance < fDist )
    3913                 :            :         {
    3914                 :          0 :             nClosest =  nCount;
    3915                 :          0 :             fDist = fDistance;
    3916                 :            :         }
    3917                 :            :     }
    3918                 :          0 :     return nClosest;
    3919                 :            : };
    3920                 :            : 
    3921                 :            : // ---------------------------------------------------------------------------------------------
    3922                 :            : // for rectangles          for ellipses     for polygons
    3923                 :            : //
    3924                 :            : // nRule =  0 ->Top         0 ->Top         nRule = Index auf ein (Poly)Polygon Punkt
    3925                 :            : //          1 ->Left        2 ->Left
    3926                 :            : //          2 ->Bottom      4 ->Bottom
    3927                 :            : //          3 ->Right       6 ->Right
    3928                 :            : 
    3929                 :          0 : sal_uInt32 EscherConnectorListEntry::GetConnectorRule( sal_Bool bFirst )
    3930                 :            : {
    3931                 :          0 :     sal_uInt32 nRule = 0;
    3932                 :            : 
    3933                 :          0 :     ::com::sun::star::uno::Any aAny;
    3934         [ #  # ]:          0 :     ::com::sun::star::awt::Point aRefPoint( ( bFirst ) ? maPointA : maPointB );
    3935                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
    3936         [ #  # ]:          0 :         aXShape( ( bFirst ) ? mXConnectToA : mXConnectToB );
    3937                 :            : 
    3938 [ #  # ][ #  # ]:          0 :     rtl::OUString aString(aXShape->getShapeType());
    3939 [ #  # ][ #  # ]:          0 :     rtl::OStringBuffer aBuf(rtl::OUStringToOString(aString, RTL_TEXTENCODING_UTF8));
    3940         [ #  # ]:          0 :     aBuf.remove( 0, 13 );   // removing "com.sun.star."
    3941                 :          0 :     sal_Int16 nPos = aBuf.toString().indexOf("Shape");
    3942         [ #  # ]:          0 :     aBuf.remove(nPos, 5);
    3943                 :          0 :     rtl::OString aType = aBuf.makeStringAndClear();
    3944                 :            : 
    3945                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
    3946         [ #  # ]:          0 :         aPropertySet( aXShape, ::com::sun::star::uno::UNO_QUERY );
    3947                 :            : 
    3948 [ #  # ][ #  # ]:          0 :     if (aType.equalsL(RTL_CONSTASCII_STRINGPARAM("drawing.PolyPolygon")) || aType.equalsL(RTL_CONSTASCII_STRINGPARAM("drawing.PolyLine")))
                 [ #  # ]
    3949                 :            :     {
    3950         [ #  # ]:          0 :         if ( aPropertySet.is() )
    3951                 :            :         {
    3952         [ #  # ]:          0 :             if ( EscherPropertyValueHelper::GetPropertyValue( aAny,
    3953 [ #  # ][ #  # ]:          0 :                     aPropertySet, String( RTL_CONSTASCII_USTRINGPARAM( "PolyPolygon" ) ) ) )
                 [ #  # ]
    3954                 :            :             {
    3955                 :            :                 ::com::sun::star::drawing::PointSequenceSequence* pSourcePolyPolygon =
    3956                 :          0 :                     (::com::sun::star::drawing::PointSequenceSequence*)aAny.getValue();
    3957                 :          0 :                 sal_Int32 nOuterSequenceCount = pSourcePolyPolygon->getLength();
    3958         [ #  # ]:          0 :                 ::com::sun::star::drawing::PointSequence* pOuterSequence = pSourcePolyPolygon->getArray();
    3959                 :            : 
    3960         [ #  # ]:          0 :                 if ( pOuterSequence )
    3961                 :            :                 {
    3962                 :          0 :                     sal_Int32 a, b, nIndex = 0;
    3963                 :          0 :                     sal_uInt32 nDistance = 0xffffffff;
    3964         [ #  # ]:          0 :                     for( a = 0; a < nOuterSequenceCount; a++ )
    3965                 :            :                     {
    3966                 :          0 :                         ::com::sun::star::drawing::PointSequence* pInnerSequence = pOuterSequence++;
    3967         [ #  # ]:          0 :                         if ( pInnerSequence )
    3968                 :            :                         {
    3969         [ #  # ]:          0 :                             ::com::sun::star::awt::Point* pArray = pInnerSequence->getArray();
    3970         [ #  # ]:          0 :                             if ( pArray )
    3971                 :            :                             {
    3972         [ #  # ]:          0 :                                 for ( b = 0; b < pInnerSequence->getLength(); b++, nIndex++, pArray++ )
    3973                 :            :                                 {
    3974                 :          0 :                                     sal_uInt32 nDist = (sal_uInt32)hypot( aRefPoint.X - pArray->X, aRefPoint.Y - pArray->Y );
    3975         [ #  # ]:          0 :                                     if ( nDist < nDistance )
    3976                 :            :                                     {
    3977                 :          0 :                                         nRule = nIndex;
    3978                 :          0 :                                         nDistance = nDist;
    3979                 :            :                                     }
    3980                 :            :                                 }
    3981                 :            :                             }
    3982                 :            :                         }
    3983                 :            :                     }
    3984                 :            :                 }
    3985                 :            :             }
    3986                 :            :         }
    3987                 :            :     }
    3988 [ #  # ][ #  # ]:          0 :     else if ( (aType.equalsL(RTL_CONSTASCII_STRINGPARAM("drawing.OpenBezier"))) || (aType.equalsL(RTL_CONSTASCII_STRINGPARAM("drawing.OpenFreeHand"))) || (aType.equalsL(RTL_CONSTASCII_STRINGPARAM("drawing.PolyLinePath")))
           [ #  #  #  #  
             #  #  #  # ]
                 [ #  # ]
    3989                 :          0 :         || (aType.equalsL(RTL_CONSTASCII_STRINGPARAM("drawing.ClosedBezier"))) || ( aType.equalsL(RTL_CONSTASCII_STRINGPARAM("drawing.ClosedFreeHand"))) || (aType.equalsL(RTL_CONSTASCII_STRINGPARAM("drawing.PolyPolygonPath"))) )
    3990                 :            :     {
    3991                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
    3992         [ #  # ]:          0 :             aPropertySet2( aXShape, ::com::sun::star::uno::UNO_QUERY );
    3993         [ #  # ]:          0 :         if ( aPropertySet2.is() )
    3994                 :            :         {
    3995         [ #  # ]:          0 :             if ( EscherPropertyValueHelper::GetPropertyValue( aAny,
    3996 [ #  # ][ #  # ]:          0 :                     aPropertySet2, String( RTL_CONSTASCII_USTRINGPARAM( "PolyPolygonBezier" ) ) ) )
                 [ #  # ]
    3997                 :            :             {
    3998                 :            :                 ::com::sun::star::drawing::PolyPolygonBezierCoords* pSourcePolyPolygon =
    3999                 :          0 :                     (::com::sun::star::drawing::PolyPolygonBezierCoords*)aAny.getValue();
    4000                 :          0 :                 sal_Int32 nOuterSequenceCount = pSourcePolyPolygon->Coordinates.getLength();
    4001                 :            : 
    4002                 :            :                 // Zeiger auf innere sequences holen
    4003                 :            :                 ::com::sun::star::drawing::PointSequence* pOuterSequence =
    4004         [ #  # ]:          0 :                     pSourcePolyPolygon->Coordinates.getArray();
    4005                 :            :                 ::com::sun::star::drawing::FlagSequence*  pOuterFlags =
    4006         [ #  # ]:          0 :                     pSourcePolyPolygon->Flags.getArray();
    4007                 :            : 
    4008 [ #  # ][ #  # ]:          0 :                 if ( pOuterSequence && pOuterFlags )
    4009                 :            :                 {
    4010                 :          0 :                     sal_Int32 a, b, nIndex = 0;
    4011                 :          0 :                     sal_uInt32 nDistance = 0xffffffff;
    4012                 :            : 
    4013         [ #  # ]:          0 :                     for ( a = 0; a < nOuterSequenceCount; a++ )
    4014                 :            :                     {
    4015                 :          0 :                         ::com::sun::star::drawing::PointSequence* pInnerSequence = pOuterSequence++;
    4016                 :          0 :                         ::com::sun::star::drawing::FlagSequence*  pInnerFlags = pOuterFlags++;
    4017 [ #  # ][ #  # ]:          0 :                         if ( pInnerSequence && pInnerFlags )
    4018                 :            :                         {
    4019         [ #  # ]:          0 :                             ::com::sun::star::awt::Point* pArray = pInnerSequence->getArray();
    4020         [ #  # ]:          0 :                             ::com::sun::star::drawing::PolygonFlags* pFlags = pInnerFlags->getArray();
    4021 [ #  # ][ #  # ]:          0 :                             if ( pArray && pFlags )
    4022                 :            :                             {
    4023         [ #  # ]:          0 :                                 for ( b = 0; b < pInnerSequence->getLength(); b++, pArray++ )
    4024                 :            :                                 {
    4025                 :          0 :                                     PolyFlags ePolyFlags = *( (PolyFlags*)pFlags++ );
    4026         [ #  # ]:          0 :                                     if ( ePolyFlags == POLY_CONTROL )
    4027                 :          0 :                                         continue;
    4028                 :          0 :                                     sal_uInt32 nDist = (sal_uInt32)hypot( aRefPoint.X - pArray->X, aRefPoint.Y - pArray->Y );
    4029         [ #  # ]:          0 :                                     if ( nDist < nDistance )
    4030                 :            :                                     {
    4031                 :          0 :                                         nRule = nIndex;
    4032                 :          0 :                                         nDistance = nDist;
    4033                 :            :                                     }
    4034                 :          0 :                                     nIndex++;
    4035                 :            :                                 }
    4036                 :            :                             }
    4037                 :            :                         }
    4038                 :            :                     }
    4039                 :            :                 }
    4040                 :            :             }
    4041                 :          0 :         }
    4042                 :            :     }
    4043                 :            :     else
    4044                 :            :     {
    4045                 :          0 :         bool bRectangularConnection = true;
    4046                 :            : 
    4047         [ #  # ]:          0 :         if (aType.equalsL(RTL_CONSTASCII_STRINGPARAM("drawing.Custom")))
    4048                 :            :         {
    4049                 :          0 :             SdrObject* pCustoShape( GetSdrObjectFromXShape( aXShape ) );
    4050 [ #  # ][ #  # ]:          0 :             if ( pCustoShape && pCustoShape->ISA( SdrObjCustomShape ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    4051                 :            :             {
    4052                 :            :                 SdrCustomShapeGeometryItem& rGeometryItem = (SdrCustomShapeGeometryItem&)(const SdrCustomShapeGeometryItem&)
    4053         [ #  # ]:          0 :                     pCustoShape->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
    4054                 :            : 
    4055                 :          0 :                 const rtl::OUString sPath( "Path"  );
    4056                 :          0 :                 const rtl::OUString sType( "Type"  );
    4057                 :          0 :                 const rtl::OUString sGluePointType( "GluePointType"  );
    4058                 :            : 
    4059                 :          0 :                 rtl::OUString sShapeType;
    4060         [ #  # ]:          0 :                 uno::Any* pType = rGeometryItem.GetPropertyValueByName( sType );
    4061         [ #  # ]:          0 :                 if ( pType )
    4062                 :          0 :                     *pType >>= sShapeType;
    4063         [ #  # ]:          0 :                 MSO_SPT eSpType = EnhancedCustomShapeTypeNames::Get( sShapeType );
    4064                 :            : 
    4065         [ #  # ]:          0 :                 uno::Any* pGluePointType = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sPath, sGluePointType );
    4066                 :            : 
    4067                 :          0 :                 sal_Int16 nGluePointType = sal_Int16();
    4068         [ #  # ]:          0 :                 if ( !( pGluePointType &&
    4069 [ #  # ][ #  # ]:          0 :                         ( *pGluePointType >>= nGluePointType ) ) )
    4070         [ #  # ]:          0 :                     nGluePointType = GetCustomShapeConnectionTypeDefault( eSpType );
    4071                 :            : 
    4072         [ #  # ]:          0 :                 if ( nGluePointType == com::sun::star::drawing::EnhancedCustomShapeGluePointType::CUSTOM )
    4073                 :            :                 {
    4074         [ #  # ]:          0 :                     const SdrGluePointList* pList = pCustoShape->GetGluePointList();
    4075         [ #  # ]:          0 :                     if ( pList )
    4076                 :            :                     {
    4077         [ #  # ]:          0 :                         Polygon aPoly;
    4078                 :          0 :                         sal_uInt16 nNum, nAnz = pList->GetCount();
    4079         [ #  # ]:          0 :                         if ( nAnz )
    4080                 :            :                         {
    4081         [ #  # ]:          0 :                             for ( nNum = 0; nNum < nAnz; nNum++ )
    4082                 :            :                             {
    4083         [ #  # ]:          0 :                                 const SdrGluePoint& rGP = (*pList)[ nNum ];
    4084         [ #  # ]:          0 :                                 Point aPt( rGP.GetAbsolutePos( *pCustoShape ) );
    4085         [ #  # ]:          0 :                                 aPoly.Insert( POLY_APPEND, aPt );
    4086                 :            :                             }
    4087         [ #  # ]:          0 :                             nRule = GetClosestPoint( aPoly, aRefPoint );
    4088                 :          0 :                             bRectangularConnection = false;
    4089         [ #  # ]:          0 :                         }
    4090                 :            :                     }
    4091                 :            :                 }
    4092         [ #  # ]:          0 :                 else if ( nGluePointType == com::sun::star::drawing::EnhancedCustomShapeGluePointType::SEGMENTS )
    4093                 :            :                 {
    4094         [ #  # ]:          0 :                     SdrObject* pPoly = pCustoShape->DoConvertToPolyObj( sal_True );
    4095 [ #  # ][ #  # ]:          0 :                     if ( pPoly && pPoly->ISA( SdrPathObj ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    4096                 :            :                     {
    4097                 :          0 :                         sal_Int16 a, b, nIndex = 0;
    4098                 :          0 :                         sal_uInt32 nDistance = 0xffffffff;
    4099                 :            : 
    4100                 :            :                         // #i74631# use explicit constructor here. Also XPolyPolygon is not necessary,
    4101                 :            :                         // reducing to PolyPolygon
    4102         [ #  # ]:          0 :                         const PolyPolygon aPolyPoly(((SdrPathObj*)pPoly)->GetPathPoly());
    4103                 :            : 
    4104 [ #  # ][ #  # ]:          0 :                         for ( a = 0; a < aPolyPoly.Count(); a++ )
    4105                 :            :                         {
    4106         [ #  # ]:          0 :                             const Polygon& rPoly = aPolyPoly.GetObject( a );
    4107 [ #  # ][ #  # ]:          0 :                             for ( b = 0; b < rPoly.GetSize(); b++ )
    4108                 :            :                             {
    4109 [ #  # ][ #  # ]:          0 :                                 if ( rPoly.GetFlags( b ) != POLY_NORMAL )
    4110                 :          0 :                                     continue;
    4111         [ #  # ]:          0 :                                 const Point& rPt = rPoly[ b ];
    4112                 :          0 :                                 sal_uInt32 nDist = (sal_uInt32)hypot( aRefPoint.X - rPt.X(), aRefPoint.Y - rPt.Y() );
    4113         [ #  # ]:          0 :                                 if ( nDist < nDistance )
    4114                 :            :                                 {
    4115                 :          0 :                                     nRule = nIndex;
    4116                 :          0 :                                     nDistance = nDist;
    4117                 :            :                                 }
    4118                 :          0 :                                 nIndex++;
    4119                 :            :                             }
    4120                 :            :                         }
    4121         [ #  # ]:          0 :                         if ( nDistance != 0xffffffff )
    4122         [ #  # ]:          0 :                             bRectangularConnection = false;
    4123                 :            :                     }
    4124                 :          0 :                 }
    4125                 :            :             }
    4126                 :            :         }
    4127         [ #  # ]:          0 :         if ( bRectangularConnection )
    4128                 :            :         {
    4129 [ #  # ][ #  # ]:          0 :             ::com::sun::star::awt::Point aPoint( aXShape->getPosition() );
    4130 [ #  # ][ #  # ]:          0 :             ::com::sun::star::awt::Size  aSize( aXShape->getSize() );
    4131                 :            : 
    4132         [ #  # ]:          0 :             Rectangle   aRect( Point( aPoint.X, aPoint.Y ), Size( aSize.Width, aSize.Height ) );
    4133         [ #  # ]:          0 :             Point       aCenter( aRect.Center() );
    4134         [ #  # ]:          0 :             Polygon     aPoly( 4 );
    4135                 :            : 
    4136         [ #  # ]:          0 :             aPoly[ 0 ] = Point( aCenter.X(), aRect.Top() );
    4137         [ #  # ]:          0 :             aPoly[ 1 ] = Point( aRect.Left(), aCenter.Y() );
    4138         [ #  # ]:          0 :             aPoly[ 2 ] = Point( aCenter.X(), aRect.Bottom() );
    4139         [ #  # ]:          0 :             aPoly[ 3 ] = Point( aRect.Right(), aCenter.Y() );
    4140                 :            : 
    4141                 :            :             sal_Int32 nAngle = ( EscherPropertyValueHelper::GetPropertyValue( aAny,
    4142 [ #  # ][ #  # ]:          0 :                 aPropertySet, String( RTL_CONSTASCII_USTRINGPARAM( "RotateAngle" ) ), sal_True ) )
                 [ #  # ]
    4143                 :          0 :                     ? *((sal_Int32*)aAny.getValue() )
    4144         [ #  # ]:          0 :                     : 0;
    4145         [ #  # ]:          0 :             if ( nAngle )
    4146         [ #  # ]:          0 :                 aPoly.Rotate( aRect.TopLeft(), (sal_uInt16)( ( nAngle + 5 ) / 10 ) );
    4147         [ #  # ]:          0 :             nRule = GetClosestPoint( aPoly, aRefPoint );
    4148                 :            : 
    4149         [ #  # ]:          0 :             if (aType.equalsL(RTL_CONSTASCII_STRINGPARAM("drawing.Ellipse")))
    4150         [ #  # ]:          0 :                 nRule <<= 1;    // In PPT an ellipse has 8 ways to connect
    4151                 :            :         }
    4152                 :            :     }
    4153                 :          0 :     return nRule;
    4154                 :            : }
    4155                 :            : 
    4156                 :          3 : EscherSolverContainer::~EscherSolverContainer()
    4157                 :            : {
    4158         [ +  + ]:          6 :     for( size_t i = 0, n = maShapeList.size(); i < n; ++i ) {
    4159 [ +  - ][ +  - ]:          3 :         delete maShapeList[ i ];
    4160                 :            :     }
    4161         [ -  + ]:          3 :     for( size_t i = 0, n = maConnectorList.size(); i < n; ++i ) {
    4162 [ #  # ][ #  # ]:          0 :         delete maConnectorList[ i ];
                 [ #  # ]
    4163                 :            :     }
    4164                 :          3 : }
    4165                 :            : 
    4166                 :          3 : void EscherSolverContainer::AddShape( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & rXShape, sal_uInt32 nId )
    4167                 :            : {
    4168 [ +  - ][ +  - ]:          3 :     maShapeList.push_back( new EscherShapeListEntry( rXShape, nId ) );
    4169                 :          3 : }
    4170                 :            : 
    4171                 :          0 : void EscherSolverContainer::AddConnector(
    4172                 :            :     const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & rConnector,
    4173                 :            :     const ::com::sun::star::awt::Point& rPA,
    4174                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & rConA,
    4175                 :            :     const ::com::sun::star::awt::Point& rPB,
    4176                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & rConB
    4177                 :            : )
    4178                 :            : {
    4179 [ #  # ][ #  # ]:          0 :     maConnectorList.push_back( new EscherConnectorListEntry( rConnector, rPA, rConA, rPB, rConB ) );
    4180                 :          0 : }
    4181                 :            : 
    4182                 :          0 : sal_uInt32 EscherSolverContainer::GetShapeId( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & rXShape ) const
    4183                 :            : {
    4184         [ #  # ]:          0 :     for ( size_t i = 0, n = maShapeList.size(); i < n; ++i )
    4185                 :            :     {
    4186                 :          0 :         EscherShapeListEntry* pPtr = maShapeList[ i ];
    4187         [ #  # ]:          0 :         if ( rXShape == pPtr->aXShape )
    4188                 :          0 :             return ( pPtr->n_EscherId );
    4189                 :            :     }
    4190                 :          0 :     return 0;
    4191                 :            : }
    4192                 :            : 
    4193                 :          0 : void EscherSolverContainer::WriteSolver( SvStream& rStrm )
    4194                 :            : {
    4195                 :          0 :     sal_uInt32 nCount = maConnectorList.size();
    4196         [ #  # ]:          0 :     if ( nCount )
    4197                 :            :     {
    4198                 :            :         sal_uInt32  nRecHdPos, nCurrentPos, nSize;
    4199         [ #  # ]:          0 :         rStrm   << (sal_uInt16)( ( nCount << 4 ) | 0xf )    // open an ESCHER_SolverContainer
    4200         [ #  # ]:          0 :                 << (sal_uInt16)ESCHER_SolverContainer       //
    4201         [ #  # ]:          0 :                 << (sal_uInt32)0;                           //
    4202                 :            : 
    4203                 :          0 :         nRecHdPos = rStrm.Tell() - 4;
    4204                 :            : 
    4205                 :            :         EscherConnectorRule aConnectorRule;
    4206                 :          0 :         aConnectorRule.nRuleId = 2;
    4207         [ #  # ]:          0 :         for ( size_t i = 0, n = maConnectorList.size(); i < n; ++i )
    4208                 :            :         {
    4209         [ #  # ]:          0 :             EscherConnectorListEntry* pPtr = maConnectorList[ i ];
    4210                 :          0 :             aConnectorRule.ncptiA  = aConnectorRule.ncptiB = 0xffffffff;
    4211         [ #  # ]:          0 :             aConnectorRule.nShapeC = GetShapeId( pPtr->mXConnector );
    4212         [ #  # ]:          0 :             aConnectorRule.nShapeA = GetShapeId( pPtr->mXConnectToA );
    4213         [ #  # ]:          0 :             aConnectorRule.nShapeB = GetShapeId( pPtr->mXConnectToB );
    4214                 :            : 
    4215         [ #  # ]:          0 :             if ( aConnectorRule.nShapeC )
    4216                 :            :             {
    4217         [ #  # ]:          0 :                 if ( aConnectorRule.nShapeA )
    4218         [ #  # ]:          0 :                     aConnectorRule.ncptiA = pPtr->GetConnectorRule( sal_True );
    4219         [ #  # ]:          0 :                 if ( aConnectorRule.nShapeB )
    4220         [ #  # ]:          0 :                     aConnectorRule.ncptiB = pPtr->GetConnectorRule( sal_False );
    4221                 :            :             }
    4222         [ #  # ]:          0 :             rStrm   << (sal_uInt32)( ( ESCHER_ConnectorRule << 16 ) | 1 )   // atom hd
    4223         [ #  # ]:          0 :                     << (sal_uInt32)24                                       //
    4224         [ #  # ]:          0 :                     << aConnectorRule.nRuleId
    4225         [ #  # ]:          0 :                     << aConnectorRule.nShapeA
    4226         [ #  # ]:          0 :                     << aConnectorRule.nShapeB
    4227         [ #  # ]:          0 :                     << aConnectorRule.nShapeC
    4228         [ #  # ]:          0 :                     << aConnectorRule.ncptiA
    4229         [ #  # ]:          0 :                     << aConnectorRule.ncptiB;
    4230                 :            : 
    4231                 :          0 :             aConnectorRule.nRuleId += 2;
    4232                 :            :         }
    4233                 :            : 
    4234                 :          0 :         nCurrentPos = rStrm.Tell();             // close the ESCHER_SolverContainer
    4235                 :          0 :         nSize = ( nCurrentPos - nRecHdPos ) - 4;//
    4236         [ #  # ]:          0 :         rStrm.Seek( nRecHdPos );                //
    4237         [ #  # ]:          0 :         rStrm << nSize;                         //
    4238         [ #  # ]:          0 :         rStrm.Seek( nCurrentPos );              //
    4239                 :            :     }
    4240                 :          0 : }
    4241                 :            : 
    4242                 :        141 : EscherExGlobal::EscherExGlobal( sal_uInt32 nGraphicProvFlags ) :
    4243                 :            :     EscherGraphicProvider( nGraphicProvFlags ),
    4244                 :            :     mpPicStrm( 0 ),
    4245                 :            :     mbHasDggCont( false ),
    4246 [ +  - ][ +  - ]:        141 :     mbPicStrmQueried( false )
    4247                 :            : {
    4248                 :        141 : }
    4249                 :            : 
    4250                 :        141 : EscherExGlobal::~EscherExGlobal()
    4251                 :            : {
    4252         [ -  + ]:        276 : }
    4253                 :            : 
    4254                 :          9 : sal_uInt32 EscherExGlobal::GenerateDrawingId()
    4255                 :            : {
    4256                 :            :     // new drawing starts a new cluster in the cluster table (cluster identifiers are one-based)
    4257                 :          9 :     sal_uInt32 nClusterId = static_cast< sal_uInt32 >( maClusterTable.size() + 1 );
    4258                 :            :     // drawing identifiers are one-based
    4259                 :          9 :     sal_uInt32 nDrawingId = static_cast< sal_uInt32 >( maDrawingInfos.size() + 1 );
    4260                 :            :     // prepare new entries in the tables
    4261         [ +  - ]:          9 :     maClusterTable.push_back( ClusterEntry( nDrawingId ) );
    4262         [ +  - ]:          9 :     maDrawingInfos.push_back( DrawingInfo( nClusterId ) );
    4263                 :            :     // return the new drawing identifier
    4264                 :          9 :     return nDrawingId;
    4265                 :            : }
    4266                 :            : 
    4267                 :         24 : sal_uInt32 EscherExGlobal::GenerateShapeId( sal_uInt32 nDrawingId, bool bIsInSpgr )
    4268                 :            : {
    4269                 :            :     // drawing identifier is one-based
    4270                 :            :     // make sure the drawing is valid (bnc#656503)
    4271         [ +  + ]:         24 :     if ( nDrawingId == 0 )
    4272                 :          3 :         return 0;
    4273                 :            :     // create index from the identifier
    4274                 :         21 :     size_t nDrawingIdx = nDrawingId - 1;
    4275                 :            :     OSL_ENSURE( nDrawingIdx < maDrawingInfos.size(), "EscherExGlobal::GenerateShapeId - invalid drawing ID" );
    4276         [ -  + ]:         21 :     if( nDrawingIdx >= maDrawingInfos.size() )
    4277                 :          0 :         return 0;
    4278                 :         21 :     DrawingInfo& rDrawingInfo = maDrawingInfos[ nDrawingIdx ];
    4279                 :            : 
    4280                 :            :     // cluster identifier in drawing info struct is one-based
    4281                 :         21 :     ClusterEntry* pClusterEntry = &maClusterTable[ rDrawingInfo.mnClusterId - 1 ];
    4282                 :            : 
    4283                 :            :     // check cluster overflow, create new cluster entry
    4284         [ -  + ]:         21 :     if( pClusterEntry->mnNextShapeId == DFF_DGG_CLUSTER_SIZE )
    4285                 :            :     {
    4286                 :            :         // start a new cluster in the cluster table
    4287         [ #  # ]:          0 :         maClusterTable.push_back( ClusterEntry( nDrawingId ) );
    4288                 :          0 :         pClusterEntry = &maClusterTable.back();
    4289                 :            :         // new size of maClusterTable is equal to one-based identifier of the new cluster
    4290                 :          0 :         rDrawingInfo.mnClusterId = static_cast< sal_uInt32 >( maClusterTable.size() );
    4291                 :            :     }
    4292                 :            : 
    4293                 :            :     // build shape identifier from cluster identifier and next free cluster shape identifier
    4294                 :         21 :     rDrawingInfo.mnLastShapeId = static_cast< sal_uInt32 >( rDrawingInfo.mnClusterId * DFF_DGG_CLUSTER_SIZE + pClusterEntry->mnNextShapeId );
    4295                 :            :     // update free shape identifier in cluster entry
    4296                 :         21 :     ++pClusterEntry->mnNextShapeId;
    4297                 :            :     /*  Old code has counted the shapes only, if we are in a SPGRCONTAINER. Is
    4298                 :            :         this really intended? Maybe it's always true... */
    4299         [ +  - ]:         21 :     if( bIsInSpgr )
    4300                 :         21 :         ++rDrawingInfo.mnShapeCount;
    4301                 :            : 
    4302                 :            :     // return the new shape identifier
    4303                 :         24 :     return rDrawingInfo.mnLastShapeId;
    4304                 :            : }
    4305                 :            : 
    4306                 :          9 : sal_uInt32 EscherExGlobal::GetDrawingShapeCount( sal_uInt32 nDrawingId ) const
    4307                 :            : {
    4308                 :          9 :     size_t nDrawingIdx = nDrawingId - 1;
    4309                 :            :     OSL_ENSURE( nDrawingIdx < maDrawingInfos.size(), "EscherExGlobal::GetDrawingShapeCount - invalid drawing ID" );
    4310         [ +  - ]:          9 :     return (nDrawingIdx < maDrawingInfos.size()) ? maDrawingInfos[ nDrawingIdx ].mnShapeCount : 0;
    4311                 :            : }
    4312                 :            : 
    4313                 :          9 : sal_uInt32 EscherExGlobal::GetLastShapeId( sal_uInt32 nDrawingId ) const
    4314                 :            : {
    4315                 :          9 :     size_t nDrawingIdx = nDrawingId - 1;
    4316                 :            :     OSL_ENSURE( nDrawingIdx < maDrawingInfos.size(), "EscherExGlobal::GetLastShapeId - invalid drawing ID" );
    4317         [ +  - ]:          9 :     return (nDrawingIdx < maDrawingInfos.size()) ? maDrawingInfos[ nDrawingIdx ].mnLastShapeId : 0;
    4318                 :            : }
    4319                 :            : 
    4320                 :         12 : sal_uInt32 EscherExGlobal::GetDggAtomSize() const
    4321                 :            : {
    4322                 :            :     // 8 bytes header, 16 bytes fixed DGG data, 8 bytes for each cluster
    4323                 :         12 :     return static_cast< sal_uInt32 >( 24 + 8 * maClusterTable.size() );
    4324                 :            : }
    4325                 :            : 
    4326                 :          6 : void EscherExGlobal::WriteDggAtom( SvStream& rStrm ) const
    4327                 :            : {
    4328         [ +  - ]:          6 :     sal_uInt32 nDggSize = GetDggAtomSize();
    4329                 :            : 
    4330                 :            :     // write the DGG record header (do not include the 8 bytes of the header in the data size)
    4331 [ +  - ][ +  - ]:          6 :     rStrm << static_cast< sal_uInt32 >( ESCHER_Dgg << 16 ) << static_cast< sal_uInt32 >( nDggSize - 8 );
    4332                 :            : 
    4333                 :            :     // claculate and write the fixed DGG data
    4334                 :          6 :     sal_uInt32 nShapeCount = 0;
    4335                 :          6 :     sal_uInt32 nLastShapeId = 0;
    4336 [ +  - ][ +  - ]:         15 :     for( DrawingInfoVector::const_iterator aIt = maDrawingInfos.begin(), aEnd = maDrawingInfos.end(); aIt != aEnd; ++aIt )
                 [ +  + ]
    4337                 :            :     {
    4338         [ +  - ]:          9 :         nShapeCount += aIt->mnShapeCount;
    4339 [ +  - ][ +  - ]:          9 :         nLastShapeId = ::std::max( nLastShapeId, aIt->mnLastShapeId );
    4340                 :            :     }
    4341                 :            :     // the non-existing cluster with index #0 is counted too
    4342                 :          6 :     sal_uInt32 nClusterCount = static_cast< sal_uInt32 >( maClusterTable.size() + 1 );
    4343                 :          6 :     sal_uInt32 nDrawingCount = static_cast< sal_uInt32 >( maDrawingInfos.size() );
    4344 [ +  - ][ +  - ]:          6 :     rStrm << nLastShapeId << nClusterCount << nShapeCount << nDrawingCount;
         [ +  - ][ +  - ]
    4345                 :            : 
    4346                 :            :     // write the cluster table
    4347 [ +  - ][ +  - ]:         15 :     for( ClusterTable::const_iterator aIt = maClusterTable.begin(), aEnd = maClusterTable.end(); aIt != aEnd; ++aIt )
                 [ +  + ]
    4348 [ +  - ][ +  - ]:          9 :         rStrm << aIt->mnDrawingId << aIt->mnNextShapeId;
         [ +  - ][ +  - ]
    4349                 :          6 : }
    4350                 :            : 
    4351                 :          9 : SvStream* EscherExGlobal::QueryPictureStream()
    4352                 :            : {
    4353         [ +  - ]:          9 :     if( !mbPicStrmQueried )
    4354                 :            :     {
    4355                 :          9 :         mpPicStrm = ImplQueryPictureStream();
    4356                 :          9 :         mbPicStrmQueried = true;
    4357                 :            :     }
    4358                 :          9 :     return mpPicStrm;
    4359                 :            : }
    4360                 :            : 
    4361                 :          3 : SvStream* EscherExGlobal::ImplQueryPictureStream()
    4362                 :            : {
    4363                 :          3 :     return 0;
    4364                 :            : }
    4365                 :            : 
    4366                 :            : /// Implementation of an empty stream that silently succeeds, but does nothing.
    4367                 :            : ///
    4368                 :            : /// In fact, this is a hack.  The right solution is to abstract EscherEx to be
    4369                 :            : /// able to work without SvStream; but at the moment it is better to live with
    4370                 :            : /// this I guess.
    4371                 :            : class SvNullStream : public SvStream
    4372                 :            : {
    4373                 :            : protected:
    4374                 :          0 :     virtual sal_Size GetData( void* pData, sal_Size nSize ) { memset( pData, 0, nSize ); return nSize; }
    4375                 :         12 :     virtual sal_Size PutData( const void*, sal_Size nSize ) { return nSize; }
    4376                 :          6 :     virtual sal_Size SeekPos( sal_Size nPos ) { return nPos; }
    4377                 :          0 :     virtual void SetSize( sal_Size ) {}
    4378                 :          0 :     virtual void FlushData() {}
    4379                 :            : 
    4380                 :            : public:
    4381                 :        135 :     SvNullStream() : SvStream() {}
    4382         [ -  + ]:        270 :     virtual ~SvNullStream() {}
    4383                 :            : };
    4384                 :            : 
    4385                 :        141 : EscherEx::EscherEx( const EscherExGlobalRef& rxGlobal, SvStream* pOutStrm ) :
    4386                 :            :     mxGlobal                ( rxGlobal ),
    4387                 :            :     mpOutStrm               ( pOutStrm ),
    4388                 :            :     mbOwnsStrm              ( false ),
    4389                 :            : 
    4390                 :            :     mnCurrentDg                         ( 0 ),
    4391                 :            : 
    4392                 :            :     mnGroupLevel            ( 0 ),
    4393                 :            :     mnHellLayerId           ( USHRT_MAX ),
    4394                 :            : 
    4395                 :            :     mbEscherSpgr            ( sal_False ),
    4396 [ +  - ][ +  - ]:        141 :     mbEscherDg              ( sal_False )
                 [ +  - ]
    4397                 :            : {
    4398         [ +  + ]:        141 :     if (!mpOutStrm)
    4399                 :            :     {
    4400 [ +  - ][ +  - ]:        135 :         mpOutStrm = new SvNullStream();
    4401                 :        135 :         mbOwnsStrm = true;
    4402                 :            :     }
    4403                 :        141 :     mnStrmStartOfs = mpOutStrm->Tell();
    4404 [ +  - ][ +  - ]:        141 :     mpImplEscherExSdr.reset( new ImplEscherExSdr( *this ) );
    4405                 :        141 : }
    4406                 :            : 
    4407 [ +  - ][ +  - ]:        141 : EscherEx::~EscherEx()
    4408                 :            : {
    4409         [ +  + ]:        141 :     if (mbOwnsStrm)
    4410 [ -  + ][ #  # ]:        135 :         delete mpOutStrm;
    4411         [ -  + ]:        141 : }
    4412                 :            : 
    4413                 :          6 : void EscherEx::Flush( SvStream* pPicStreamMergeBSE /* = NULL */ )
    4414                 :            : {
    4415         [ +  - ]:          6 :     if ( mxGlobal->HasDggContainer() )
    4416                 :            :     {
    4417                 :            :         // store the current stream position at ESCHER_Persist_CurrentPosition key
    4418                 :          6 :         PtReplaceOrInsert( ESCHER_Persist_CurrentPosition, mpOutStrm->Tell() );
    4419         [ +  - ]:          6 :         if ( DoSeek( ESCHER_Persist_Dgg ) )
    4420                 :            :         {
    4421                 :            :             /*  The DGG record is still not written. ESCHER_Persist_Dgg seeks
    4422                 :            :                 to the place where the complete record has to be inserted. */
    4423                 :          6 :             InsertAtCurrentPos( mxGlobal->GetDggAtomSize(), false );
    4424                 :          6 :             mxGlobal->WriteDggAtom( *mpOutStrm );
    4425                 :            : 
    4426         [ +  - ]:          6 :             if ( mxGlobal->HasGraphics() )
    4427                 :            :             {
    4428                 :            :                 /*  Calculate the total size of the BSTORECONTAINER including
    4429                 :            :                     all BSE records containing the picture data contained in
    4430                 :            :                     the passed in pPicStreamMergeBSE. */
    4431                 :          6 :                 sal_uInt32 nBSCSize = mxGlobal->GetBlibStoreContainerSize( pPicStreamMergeBSE );
    4432         [ +  - ]:          6 :                 if ( nBSCSize > 0 )
    4433                 :            :                 {
    4434                 :          6 :                     InsertAtCurrentPos( nBSCSize, false );
    4435                 :          6 :                     mxGlobal->WriteBlibStoreContainer( *mpOutStrm, pPicStreamMergeBSE );
    4436                 :            :                 }
    4437                 :            :             }
    4438                 :            : 
    4439                 :            :             /*  Forget the stream position stored for the DGG which is invalid
    4440                 :            :                 after the call to InsertAtCurrentPos() anyway. */
    4441                 :          6 :             PtDelete( ESCHER_Persist_Dgg );
    4442                 :            :         }
    4443                 :            :         // seek to initial position (may be different due to inserted DGG and BLIPs)
    4444                 :          6 :         mpOutStrm->Seek( PtGetOffsetByID( ESCHER_Persist_CurrentPosition ) );
    4445                 :            :     }
    4446                 :          6 : }
    4447                 :            : 
    4448                 :         12 : void EscherEx::InsertAtCurrentPos( sal_uInt32 nBytes, bool bExpandEndOfAtom )
    4449                 :            : {
    4450                 :         12 :     sal_uInt32  nSize, nType, nSource, nBufSize, nToCopy, nCurPos = mpOutStrm->Tell();
    4451                 :            :     sal_uInt8*  pBuf;
    4452                 :            : 
    4453                 :            :     // Persist table anpassen
    4454         [ +  + ]:         54 :     for( size_t i = 0, n = maPersistTable.size(); i < n; ++i ) {
    4455                 :         42 :         EscherPersistEntry* pPtr = maPersistTable[ i ];
    4456                 :         42 :         sal_uInt32 nOfs = pPtr->mnOffset;
    4457         [ +  - ]:         42 :         if ( nOfs >= nCurPos ) {
    4458                 :         42 :             pPtr->mnOffset += nBytes;
    4459                 :            :         }
    4460                 :            :     }
    4461                 :            : 
    4462                 :            :     // adapt container and atom sizes
    4463         [ +  - ]:         12 :     mpOutStrm->Seek( mnStrmStartOfs );
    4464         [ +  + ]:         30 :     while ( mpOutStrm->Tell() < nCurPos )
    4465                 :            :     {
    4466 [ +  - ][ +  - ]:         18 :         *mpOutStrm >> nType >> nSize;
    4467                 :         18 :         sal_uInt32 nEndOfRecord = mpOutStrm->Tell() + nSize;
    4468                 :         18 :         bool bContainer = (nType & 0x0F) == 0x0F;
    4469                 :            :         /*  Expand the record, if the insertion position is inside, or if the
    4470                 :            :             position is at the end of a container (expands always), or at the
    4471                 :            :             end of an atom and bExpandEndOfAtom is set. */
    4472 [ +  - ][ +  - ]:         18 :         if ( (nCurPos < nEndOfRecord) || ((nCurPos == nEndOfRecord) && (bContainer || bExpandEndOfAtom)) )
         [ -  + ][ +  + ]
    4473                 :            :         {
    4474         [ +  - ]:         12 :             mpOutStrm->SeekRel( -4 );
    4475         [ +  - ]:         12 :             *mpOutStrm << (sal_uInt32)( nSize + nBytes );
    4476         [ -  + ]:         12 :             if ( !bContainer )
    4477         [ #  # ]:          0 :                 mpOutStrm->SeekRel( nSize );
    4478                 :            :         }
    4479                 :            :         else
    4480         [ +  - ]:          6 :             mpOutStrm->SeekRel( nSize );
    4481                 :            :     }
    4482                 :         12 :     std::vector< sal_uInt32 >::iterator aIter( mOffsets.begin() );
    4483                 :         12 :     std::vector< sal_uInt32 >::iterator aEnd( mOffsets.end() );
    4484 [ +  - ][ -  + ]:         12 :     while( aIter != aEnd )
    4485                 :            :     {
    4486 [ #  # ][ #  # ]:          0 :         if ( *aIter > nCurPos )
    4487         [ #  # ]:          0 :             *aIter += nBytes;
    4488         [ #  # ]:          0 :         aIter++;
    4489                 :            :     }
    4490         [ +  - ]:         12 :     mpOutStrm->Seek( STREAM_SEEK_TO_END );
    4491                 :         12 :     nSource = mpOutStrm->Tell();
    4492                 :         12 :     nToCopy = nSource - nCurPos;                        // increase the size of the tream by nBytes
    4493         [ +  - ]:         12 :     pBuf = new sal_uInt8[ 0x40000 ];                            // 256KB Buffer
    4494         [ +  + ]:         24 :     while ( nToCopy )
    4495                 :            :     {
    4496                 :         12 :         nBufSize = ( nToCopy >= 0x40000 ) ? 0x40000 : nToCopy;
    4497                 :         12 :         nToCopy -= nBufSize;
    4498                 :         12 :         nSource -= nBufSize;
    4499         [ +  - ]:         12 :         mpOutStrm->Seek( nSource );
    4500         [ +  - ]:         12 :         mpOutStrm->Read( pBuf, nBufSize );
    4501         [ +  - ]:         12 :         mpOutStrm->Seek( nSource + nBytes );
    4502         [ +  - ]:         12 :         mpOutStrm->Write( pBuf, nBufSize );
    4503                 :            :     }
    4504         [ +  - ]:         12 :     delete[] pBuf;
    4505         [ +  - ]:         12 :     mpOutStrm->Seek( nCurPos );
    4506                 :         12 : }
    4507                 :            : 
    4508                 :          0 : sal_Bool EscherEx::SeekBehindRecHeader( sal_uInt16 nRecType )
    4509                 :            : {
    4510                 :            :     sal_uInt32  nOldPos, nStreamEnd, nType, nSize;
    4511                 :            : 
    4512                 :          0 :     nOldPos = mpOutStrm->Tell();
    4513         [ #  # ]:          0 :     nStreamEnd = mpOutStrm->Seek( STREAM_SEEK_TO_END );
    4514         [ #  # ]:          0 :     mpOutStrm->Seek( nOldPos );
    4515         [ #  # ]:          0 :     while ( mpOutStrm->Tell() < nStreamEnd )
    4516                 :            :     {
    4517 [ #  # ][ #  # ]:          0 :         *mpOutStrm >> nType >> nSize;
    4518         [ #  # ]:          0 :         if ( ( nType >> 16 ) == nRecType )
    4519                 :          0 :             return sal_True;
    4520         [ #  # ]:          0 :         if ( ( nType & 0xf ) != 0xf )
    4521         [ #  # ]:          0 :             mpOutStrm->SeekRel( nSize );
    4522                 :            :     }
    4523         [ #  # ]:          0 :     mpOutStrm->Seek( nOldPos );
    4524                 :          0 :     return sal_False;
    4525                 :            : }
    4526                 :            : 
    4527                 :          0 : void EscherEx::InsertPersistOffset( sal_uInt32 nKey, sal_uInt32 nOffset )
    4528                 :            : {
    4529                 :          0 :     PtInsert( ESCHER_Persist_PrivateEntry | nKey, nOffset );
    4530                 :          0 : }
    4531                 :            : 
    4532                 :          0 : void EscherEx::ReplacePersistOffset( sal_uInt32 nKey, sal_uInt32 nOffset )
    4533                 :            : {
    4534                 :          0 :     PtReplace( ESCHER_Persist_PrivateEntry | nKey, nOffset );
    4535                 :          0 : }
    4536                 :            : 
    4537                 :          0 : sal_uInt32 EscherEx::GetPersistOffset( sal_uInt32 nKey )
    4538                 :            : {
    4539                 :          0 :     return PtGetOffsetByID( ESCHER_Persist_PrivateEntry | nKey );
    4540                 :            : }
    4541                 :            : 
    4542                 :         15 : sal_Bool EscherEx::DoSeek( sal_uInt32 nKey )
    4543                 :            : {
    4544                 :         15 :     sal_uInt32 nPos = PtGetOffsetByID( nKey );
    4545         [ +  - ]:         15 :     if ( nPos )
    4546                 :         15 :         mpOutStrm->Seek( nPos );
    4547                 :            :     else
    4548                 :            :     {
    4549         [ #  # ]:          0 :         if (! PtIsID( nKey ) )
    4550                 :          0 :             return sal_False;
    4551                 :          0 :         mpOutStrm->Seek( 0 );
    4552                 :            :     }
    4553                 :         15 :     return sal_True;
    4554                 :            : }
    4555                 :            : 
    4556                 :          0 : sal_Bool EscherEx::SeekToPersistOffset( sal_uInt32 nKey )
    4557                 :            : {
    4558                 :          0 :     return DoSeek( ESCHER_Persist_PrivateEntry | nKey );
    4559                 :            : }
    4560                 :            : 
    4561                 :          0 : sal_Bool EscherEx::InsertAtPersistOffset( sal_uInt32 nKey, sal_uInt32 nValue )
    4562                 :            : {
    4563                 :          0 :     sal_uInt32  nOldPos = mpOutStrm->Tell();
    4564                 :          0 :     sal_Bool    bRetValue = SeekToPersistOffset( nKey );
    4565         [ #  # ]:          0 :     if ( bRetValue )
    4566                 :            :     {
    4567                 :          0 :         *mpOutStrm << nValue;
    4568                 :          0 :         mpOutStrm->Seek( nOldPos );
    4569                 :            :     }
    4570                 :          0 :     return bRetValue;
    4571                 :            : }
    4572                 :            : 
    4573                 :         48 : void EscherEx::OpenContainer( sal_uInt16 nEscherContainer, int nRecInstance )
    4574                 :            : {
    4575                 :         48 :     *mpOutStrm << (sal_uInt16)( ( nRecInstance << 4 ) | 0xf  ) << nEscherContainer << (sal_uInt32)0;
    4576         [ +  - ]:         48 :     mOffsets.push_back( mpOutStrm->Tell() - 4 );
    4577                 :         48 :     mRecTypes.push_back( nEscherContainer );
    4578   [ +  +  +  +  :         48 :     switch( nEscherContainer )
                      - ]
    4579                 :            :     {
    4580                 :            :         case ESCHER_DggContainer :
    4581                 :            :         {
    4582                 :          6 :             mxGlobal->SetDggContainer();
    4583                 :          6 :             mnCurrentDg = 0;
    4584                 :            :             /*  Remember the current position as start position of the DGG
    4585                 :            :                 record and BSTORECONTAINER, but do not write them actually.
    4586                 :            :                 This will be done later in Flush() when the number of drawings,
    4587                 :            :                 the size and contents of the FIDCL cluster table, and the size
    4588                 :            :                 of the BLIP container are known. */
    4589                 :          6 :             PtReplaceOrInsert( ESCHER_Persist_Dgg, mpOutStrm->Tell() );
    4590                 :            :         }
    4591                 :          6 :         break;
    4592                 :            : 
    4593                 :            :         case ESCHER_DgContainer :
    4594                 :            :         {
    4595         [ +  - ]:          9 :             if ( mxGlobal->HasDggContainer() )
    4596                 :            :             {
    4597         [ +  - ]:          9 :                 if ( !mbEscherDg )
    4598                 :            :                 {
    4599                 :          9 :                     mbEscherDg = sal_True;
    4600                 :          9 :                     mnCurrentDg = mxGlobal->GenerateDrawingId();
    4601                 :          9 :                     AddAtom( 8, ESCHER_Dg, 0, mnCurrentDg );
    4602                 :          9 :                     PtReplaceOrInsert( ESCHER_Persist_Dg | mnCurrentDg, mpOutStrm->Tell() );
    4603                 :          9 :                     *mpOutStrm << (sal_uInt32)0     // The number of shapes in this drawing
    4604                 :          9 :                                << (sal_uInt32)0;    // The last MSOSPID given to an SP in this DG
    4605                 :            :                 }
    4606                 :            :             }
    4607                 :            :         }
    4608                 :          9 :         break;
    4609                 :            : 
    4610                 :            :         case ESCHER_SpgrContainer :
    4611                 :            :         {
    4612         [ +  - ]:          9 :             if ( mbEscherDg )
    4613                 :            :             {
    4614                 :          9 :                 mbEscherSpgr = sal_True;
    4615                 :            :             }
    4616                 :            :         }
    4617                 :          9 :         break;
    4618                 :            : 
    4619                 :            :         case ESCHER_SpContainer :
    4620                 :            :         {
    4621                 :            :         }
    4622                 :         24 :         break;
    4623                 :            : 
    4624                 :            :         default:
    4625                 :          0 :         break;
    4626                 :            :     }
    4627                 :         48 : }
    4628                 :            : 
    4629                 :         48 : void EscherEx::CloseContainer()
    4630                 :            : {
    4631                 :         48 :     sal_uInt32 nSize, nPos = mpOutStrm->Tell();
    4632                 :         48 :     nSize = ( nPos - mOffsets.back() ) - 4;
    4633                 :         48 :     mpOutStrm->Seek( mOffsets.back() );
    4634                 :         48 :     *mpOutStrm << nSize;
    4635                 :            : 
    4636      [ +  +  + ]:         48 :     switch( mRecTypes.back() )
    4637                 :            :     {
    4638                 :            :         case ESCHER_DgContainer :
    4639                 :            :         {
    4640         [ +  - ]:          9 :             if ( mbEscherDg )
    4641                 :            :             {
    4642                 :          9 :                 mbEscherDg = sal_False;
    4643         [ +  - ]:          9 :                 if ( DoSeek( ESCHER_Persist_Dg | mnCurrentDg ) )
    4644                 :          9 :                     *mpOutStrm << mxGlobal->GetDrawingShapeCount( mnCurrentDg ) << mxGlobal->GetLastShapeId( mnCurrentDg );
    4645                 :            :             }
    4646                 :            :         }
    4647                 :          9 :         break;
    4648                 :            : 
    4649                 :            :         case ESCHER_SpgrContainer :
    4650                 :            :         {
    4651         [ +  - ]:          9 :             if ( mbEscherSpgr )
    4652                 :            :             {
    4653                 :          9 :                 mbEscherSpgr = sal_False;
    4654                 :            : 
    4655                 :            :             }
    4656                 :            :         }
    4657                 :          9 :         break;
    4658                 :            : 
    4659                 :            :         default:
    4660                 :         30 :         break;
    4661                 :            :     }
    4662                 :         48 :     mOffsets.pop_back();
    4663                 :         48 :     mRecTypes.pop_back();
    4664                 :         48 :     mpOutStrm->Seek( nPos );
    4665                 :         48 : }
    4666                 :            : 
    4667                 :          0 : void EscherEx::BeginAtom()
    4668                 :            : {
    4669                 :          0 :     mnCountOfs = mpOutStrm->Tell();
    4670                 :          0 :     *mpOutStrm << (sal_uInt32)0 << (sal_uInt32)0;       // record header wird spaeter geschrieben
    4671                 :          0 : }
    4672                 :            : 
    4673                 :          0 : void EscherEx::EndAtom( sal_uInt16 nRecType, int nRecVersion, int nRecInstance )
    4674                 :            : {
    4675                 :          0 :     sal_uInt32  nOldPos = mpOutStrm->Tell();
    4676                 :          0 :     mpOutStrm->Seek( mnCountOfs );
    4677                 :          0 :     sal_uInt32 nSize = nOldPos - mnCountOfs;
    4678                 :          0 :     *mpOutStrm << (sal_uInt16)( ( nRecInstance << 4 ) | ( nRecVersion & 0xf ) ) << nRecType << (sal_uInt32)( nSize - 8 );
    4679                 :          0 :     mpOutStrm->Seek( nOldPos );
    4680                 :          0 : }
    4681                 :            : 
    4682                 :         63 : void EscherEx::AddAtom( sal_uInt32 nAtomSize, sal_uInt16 nRecType, int nRecVersion, int nRecInstance )
    4683                 :            : {
    4684                 :         63 :     *mpOutStrm << (sal_uInt16)( ( nRecInstance << 4 ) | ( nRecVersion & 0xf ) ) << nRecType << nAtomSize;
    4685                 :         63 : }
    4686                 :            : 
    4687                 :          0 : void EscherEx::AddChildAnchor( const Rectangle& rRect )
    4688                 :            : {
    4689                 :          0 :     AddAtom( 16, ESCHER_ChildAnchor );
    4690                 :          0 :     *mpOutStrm  << (sal_Int32)rRect.Left()
    4691                 :          0 :                 << (sal_Int32)rRect.Top()
    4692                 :          0 :                 << (sal_Int32)rRect.Right()
    4693                 :          0 :                 << (sal_Int32)rRect.Bottom();
    4694                 :          0 : }
    4695                 :            : 
    4696                 :          0 : void EscherEx::AddClientAnchor( const Rectangle& rRect )
    4697                 :            : {
    4698                 :          0 :     AddAtom( 8, ESCHER_ClientAnchor );
    4699                 :          0 :     *mpOutStrm << (sal_Int16)rRect.Top()
    4700                 :          0 :                << (sal_Int16)rRect.Left()
    4701                 :          0 :                << (sal_Int16)( rRect.GetWidth()  + rRect.Left() )
    4702                 :          0 :                << (sal_Int16)( rRect.GetHeight() + rRect.Top() );
    4703                 :          0 : }
    4704                 :            : 
    4705                 :          0 : EscherExHostAppData* EscherEx::EnterAdditionalTextGroup()
    4706                 :            : {
    4707                 :          0 :     return NULL;
    4708                 :            : }
    4709                 :            : 
    4710                 :          9 : sal_uInt32 EscherEx::EnterGroup( const String& rShapeName, const Rectangle* pBoundRect )
    4711                 :            : {
    4712         [ +  - ]:          9 :     Rectangle aRect;
    4713         [ -  + ]:          9 :     if( pBoundRect )
    4714                 :          0 :         aRect = *pBoundRect;
    4715                 :            : 
    4716         [ +  - ]:          9 :     OpenContainer( ESCHER_SpgrContainer );
    4717         [ +  - ]:          9 :     OpenContainer( ESCHER_SpContainer );
    4718         [ +  - ]:          9 :     AddAtom( 16, ESCHER_Spgr, 1 );
    4719                 :            :     PtReplaceOrInsert( ESCHER_Persist_Grouping_Snap | mnGroupLevel,
    4720         [ +  - ]:          9 :                         mpOutStrm->Tell() );
    4721         [ +  - ]:          9 :     *mpOutStrm  << (sal_Int32)aRect.Left()  // Bounding box for the grouped shapes the wich they will be attached
    4722         [ +  - ]:         18 :                 << (sal_Int32)aRect.Top()
    4723         [ +  - ]:         18 :                 << (sal_Int32)aRect.Right()
    4724         [ +  - ]:         18 :                 << (sal_Int32)aRect.Bottom();
    4725                 :            : 
    4726         [ +  - ]:          9 :     sal_uInt32 nShapeId = GenerateShapeId();
    4727         [ +  - ]:          9 :     if ( !mnGroupLevel )
    4728         [ +  - ]:          9 :         AddShape( ESCHER_ShpInst_Min, 5, nShapeId );                    // Flags: Group | Patriarch
    4729                 :            :     else
    4730                 :            :     {
    4731         [ #  # ]:          0 :         AddShape( ESCHER_ShpInst_Min, 0x201, nShapeId );                // Flags: Group | HaveAnchor
    4732         [ #  # ]:          0 :         EscherPropertyContainer aPropOpt;
    4733         [ #  # ]:          0 :         aPropOpt.AddOpt( ESCHER_Prop_LockAgainstGrouping, 0x00040004 );
    4734         [ #  # ]:          0 :         aPropOpt.AddOpt( ESCHER_Prop_dxWrapDistLeft, 0 );
    4735         [ #  # ]:          0 :         aPropOpt.AddOpt( ESCHER_Prop_dxWrapDistRight, 0 );
    4736                 :            : 
    4737                 :            :         // #i51348# shape name
    4738         [ #  # ]:          0 :         if( rShapeName.Len() > 0 )
    4739 [ #  # ][ #  # ]:          0 :             aPropOpt.AddOpt( ESCHER_Prop_wzName, rShapeName );
    4740                 :            : 
    4741         [ #  # ]:          0 :         Commit( aPropOpt, aRect );
    4742         [ #  # ]:          0 :         if ( mnGroupLevel > 1 )
    4743         [ #  # ]:          0 :             AddChildAnchor( aRect );
    4744                 :            : 
    4745                 :          0 :         EscherExHostAppData* pAppData = mpImplEscherExSdr->ImplGetHostData();
    4746         [ #  # ]:          0 :         if( pAppData )
    4747                 :            :         {
    4748         [ #  # ]:          0 :             if ( mnGroupLevel <= 1 )
    4749         [ #  # ]:          0 :                 pAppData->WriteClientAnchor( *this, aRect );
    4750         [ #  # ]:          0 :             pAppData->WriteClientData( *this );
    4751         [ #  # ]:          0 :         }
    4752                 :            :     }
    4753         [ +  - ]:          9 :     CloseContainer();                                               // ESCHER_SpContainer
    4754                 :          9 :     mnGroupLevel++;
    4755                 :          9 :     return nShapeId;
    4756                 :            : }
    4757                 :            : 
    4758                 :          9 : sal_uInt32 EscherEx::EnterGroup( const Rectangle* pBoundRect )
    4759                 :            : {
    4760                 :          9 :     return EnterGroup( String::EmptyString(), pBoundRect );
    4761                 :            : }
    4762                 :            : 
    4763                 :          0 : sal_Bool EscherEx::SetGroupSnapRect( sal_uInt32 nGroupLevel, const Rectangle& rRect )
    4764                 :            : {
    4765                 :          0 :     sal_Bool bRetValue = sal_False;
    4766         [ #  # ]:          0 :     if ( nGroupLevel )
    4767                 :            :     {
    4768                 :          0 :         sal_uInt32 nCurrentPos = mpOutStrm->Tell();
    4769         [ #  # ]:          0 :         if ( DoSeek( ESCHER_Persist_Grouping_Snap | ( nGroupLevel - 1 ) ) )
    4770                 :            :         {
    4771                 :          0 :             *mpOutStrm  << (sal_Int32)rRect.Left()  // Bounding box for the grouped shapes the wich they will be attached
    4772                 :          0 :                         << (sal_Int32)rRect.Top()
    4773                 :          0 :                         << (sal_Int32)rRect.Right()
    4774                 :          0 :                         << (sal_Int32)rRect.Bottom();
    4775                 :          0 :             mpOutStrm->Seek( nCurrentPos );
    4776                 :            :         }
    4777                 :            :     }
    4778                 :          0 :     return bRetValue;
    4779                 :            : }
    4780                 :            : 
    4781                 :          0 : sal_Bool EscherEx::SetGroupLogicRect( sal_uInt32 nGroupLevel, const Rectangle& rRect )
    4782                 :            : {
    4783                 :          0 :     sal_Bool bRetValue = sal_False;
    4784         [ #  # ]:          0 :     if ( nGroupLevel )
    4785                 :            :     {
    4786                 :          0 :         sal_uInt32 nCurrentPos = mpOutStrm->Tell();
    4787         [ #  # ]:          0 :         if ( DoSeek( ESCHER_Persist_Grouping_Logic | ( nGroupLevel - 1 ) ) )
    4788                 :            :         {
    4789                 :          0 :             *mpOutStrm << (sal_Int16)rRect.Top() << (sal_Int16)rRect.Left() << (sal_Int16)rRect.Right() << (sal_Int16)rRect.Bottom();
    4790                 :          0 :             mpOutStrm->Seek( nCurrentPos );
    4791                 :            :         }
    4792                 :            :     }
    4793                 :          0 :     return bRetValue;
    4794                 :            : }
    4795                 :            : 
    4796                 :          9 : void EscherEx::LeaveGroup()
    4797                 :            : {
    4798                 :          9 :     --mnGroupLevel;
    4799                 :          9 :     PtDelete( ESCHER_Persist_Grouping_Snap | mnGroupLevel );
    4800                 :          9 :     PtDelete( ESCHER_Persist_Grouping_Logic | mnGroupLevel );
    4801                 :          9 :     CloseContainer();
    4802                 :          9 : }
    4803                 :            : 
    4804                 :         21 : void EscherEx::AddShape( sal_uInt32 nShpInstance, sal_uInt32 nFlags, sal_uInt32 nShapeID )
    4805                 :            : {
    4806                 :         21 :     AddAtom( 8, ESCHER_Sp, 2, nShpInstance );
    4807                 :            : 
    4808         [ -  + ]:         21 :     if ( !nShapeID )
    4809                 :          0 :         nShapeID = GenerateShapeId();
    4810                 :            : 
    4811         [ +  - ]:         21 :     if ( nFlags ^ 1 )                           // is this a group shape ?
    4812                 :            :     {                                           // if not
    4813         [ -  + ]:         21 :         if ( mnGroupLevel > 1 )
    4814                 :          0 :             nFlags |= 2;                        // this not a topmost shape
    4815                 :            :     }
    4816                 :         21 :     *mpOutStrm << nShapeID << nFlags;
    4817                 :         21 : }
    4818                 :            : 
    4819                 :          0 : void EscherEx::Commit( EscherPropertyContainer& rProps, const Rectangle& )
    4820                 :            : {
    4821                 :          0 :     rProps.Commit( GetStream() );
    4822                 :          0 : }
    4823                 :            : 
    4824                 :          6 : sal_uInt32 EscherEx::GetColor( const sal_uInt32 nSOColor, sal_Bool bSwap )
    4825                 :            : {
    4826         [ +  - ]:          6 :     if ( bSwap )
    4827                 :            :     {
    4828                 :          6 :         sal_uInt32 nColor = nSOColor & 0xff00;          // Green
    4829                 :          6 :         nColor |= (sal_uInt8)( nSOColor ) << 16;        // Red
    4830                 :          6 :         nColor |= (sal_uInt8)( nSOColor >> 16 );        // Blue
    4831                 :          6 :         return nColor;
    4832                 :            :     }
    4833                 :            :     else
    4834                 :          6 :         return nSOColor & 0xffffff;
    4835                 :            : }
    4836                 :            : 
    4837                 :          6 : sal_uInt32 EscherEx::GetColor( const Color& rSOColor, sal_Bool bSwap )
    4838                 :            : {
    4839                 :          6 :     sal_uInt32 nColor = ( rSOColor.GetRed() << 16 );
    4840                 :          6 :     nColor |= ( rSOColor.GetGreen() << 8 );
    4841                 :          6 :     nColor |= rSOColor.GetBlue();
    4842                 :            : 
    4843         [ +  - ]:          6 :     if ( !bSwap )
    4844                 :          6 :         nColor = GetColor( nColor, sal_True );
    4845                 :            : 
    4846                 :          6 :     return nColor;
    4847                 :            : }
    4848                 :            : 
    4849                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10