LCOV - code coverage report
Current view: top level - svx/source/customshapes - EnhancedCustomShape3d.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 455 0.0 %
Date: 2012-08-25 Functions: 0 17 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 982 0.0 %

           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 "EnhancedCustomShape3d.hxx"
      30                 :            : #include <svx/svdetc.hxx>
      31                 :            : #include <svx/svdmodel.hxx>
      32                 :            : #include <tools/poly.hxx>
      33                 :            : #include <svx/svditer.hxx>
      34                 :            : #include <svx/svdobj.hxx>
      35                 :            : #include <svx/svdoashp.hxx>
      36                 :            : #include <svl/poolitem.hxx>
      37                 :            : #include <svl/itemset.hxx>
      38                 :            : #include <svx/xfillit0.hxx>
      39                 :            : #include <svx/xsflclit.hxx>
      40                 :            : #include <svx/xit.hxx>
      41                 :            : #include <svx/xbtmpit.hxx>
      42                 :            : #include <svx/xflclit.hxx>
      43                 :            : #include <svx/svdopath.hxx>
      44                 :            : #include <svx/svdogrp.hxx>
      45                 :            : #include <svx/svdpage.hxx>
      46                 :            : #include <svx/polysc3d.hxx>
      47                 :            : #include <svx/svddef.hxx>
      48                 :            : #include <svx/svx3ditems.hxx>
      49                 :            : #include <svx/extrud3d.hxx>
      50                 :            : #include <svx/xflbmtit.hxx>
      51                 :            : #include <vcl/svapp.hxx>
      52                 :            : #include <svx/xlnclit.hxx>
      53                 :            : #include <svx/sdasitm.hxx>
      54                 :            : #include <com/sun/star/awt/Point.hpp>
      55                 :            : #include <com/sun/star/drawing/Position3D.hpp>
      56                 :            : #include <com/sun/star/drawing/Direction3D.hpp>
      57                 :            : #include <com/sun/star/drawing/ShadeMode.hpp>
      58                 :            : #include <svx/sdr/properties/properties.hxx>
      59                 :            : #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
      60                 :            : #include <basegfx/polygon/b2dpolypolygontools.hxx>
      61                 :            : #include <basegfx/range/b2drange.hxx>
      62                 :            : 
      63                 :            : #define ITEMVALUE(ItemSet,Id,Cast)  ((const Cast&)(ItemSet).Get(Id)).GetValue()
      64                 :            : using namespace com::sun::star;
      65                 :            : using namespace com::sun::star::uno;
      66                 :            : 
      67                 :            : const char aExtrusion[] = "Extrusion";
      68                 :            : 
      69                 :          0 : void GetOrigin( SdrCustomShapeGeometryItem& rItem, double& rOriginX, double& rOriginY )
      70                 :            : {
      71                 :          0 :     ::com::sun::star::drawing::EnhancedCustomShapeParameterPair aOriginParaPair;
      72         [ #  # ]:          0 :      const rtl::OUString    sOrigin( RTL_CONSTASCII_USTRINGPARAM ( "Origin" ) );
      73         [ #  # ]:          0 :     Any* pAny = rItem.GetPropertyValueByName( rtl::OUString(aExtrusion), sOrigin );
      74 [ #  # ][ #  # ]:          0 :     if ( ! ( pAny && ( *pAny >>= aOriginParaPair ) && ( aOriginParaPair.First.Value >>= rOriginX ) && ( aOriginParaPair.Second.Value >>= rOriginY ) ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      75                 :            :     {
      76                 :          0 :         rOriginX = 0.50;
      77                 :          0 :         rOriginY =-0.50;
      78                 :          0 :     }
      79                 :          0 : }
      80                 :            : 
      81                 :          0 : void GetRotateAngle( SdrCustomShapeGeometryItem& rItem, double& rAngleX, double& rAngleY )
      82                 :            : {
      83                 :          0 :     ::com::sun::star::drawing::EnhancedCustomShapeParameterPair aRotateAngleParaPair;
      84         [ #  # ]:          0 :      const rtl::OUString    sRotateAngle( RTL_CONSTASCII_USTRINGPARAM ( "RotateAngle" ) );
      85         [ #  # ]:          0 :     Any* pAny = rItem.GetPropertyValueByName( rtl::OUString(aExtrusion), sRotateAngle );
      86 [ #  # ][ #  # ]:          0 :     if ( ! ( pAny && ( *pAny >>= aRotateAngleParaPair ) && ( aRotateAngleParaPair.First.Value >>= rAngleX ) && ( aRotateAngleParaPair.Second.Value >>= rAngleY ) ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      87                 :            :     {
      88                 :          0 :         rAngleX = 0.0;
      89                 :          0 :         rAngleY = 0.0;
      90                 :            :     }
      91                 :          0 :     rAngleX *= F_PI180;
      92                 :          0 :     rAngleY *= F_PI180;
      93                 :          0 : }
      94                 :            : 
      95                 :          0 : void GetSkew( SdrCustomShapeGeometryItem& rItem, double& rSkewAmount, double& rSkewAngle )
      96                 :            : {
      97                 :          0 :     ::com::sun::star::drawing::EnhancedCustomShapeParameterPair aSkewParaPair;
      98         [ #  # ]:          0 :      const rtl::OUString    sSkew( RTL_CONSTASCII_USTRINGPARAM ( "Skew" ) );
      99         [ #  # ]:          0 :     Any* pAny = rItem.GetPropertyValueByName( rtl::OUString(aExtrusion), sSkew );
     100 [ #  # ][ #  # ]:          0 :     if ( ! ( pAny && ( *pAny >>= aSkewParaPair ) && ( aSkewParaPair.First.Value >>= rSkewAmount ) && ( aSkewParaPair.Second.Value >>= rSkewAngle ) ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     101                 :            :     {
     102                 :          0 :         rSkewAmount = 50;
     103                 :          0 :         rSkewAngle = -135;
     104                 :            :     }
     105                 :          0 :     rSkewAngle *= F_PI180;
     106                 :          0 : }
     107                 :            : 
     108                 :          0 : void GetExtrusionDepth( SdrCustomShapeGeometryItem& rItem, const double* pMap, double& rBackwardDepth, double& rForwardDepth )
     109                 :            : {
     110                 :          0 :     ::com::sun::star::drawing::EnhancedCustomShapeParameterPair aDepthParaPair;
     111                 :          0 :     double fDepth = 0, fFraction = 0;
     112         [ #  # ]:          0 :     const rtl::OUString sDepth( RTL_CONSTASCII_USTRINGPARAM ( "Depth" ) );
     113         [ #  # ]:          0 :     Any* pAny = rItem.GetPropertyValueByName( rtl::OUString(aExtrusion), sDepth );
     114 [ #  # ][ #  # ]:          0 :     if ( pAny && ( *pAny >>= aDepthParaPair ) && ( aDepthParaPair.First.Value >>= fDepth ) && ( aDepthParaPair.Second.Value >>= fFraction ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     115                 :            :     {
     116                 :          0 :         rForwardDepth = fDepth * fFraction;
     117                 :          0 :         rBackwardDepth = fDepth - rForwardDepth;
     118                 :            :     }
     119                 :            :     else
     120                 :            :     {
     121                 :          0 :         rBackwardDepth = 1270;
     122                 :          0 :         rForwardDepth = 0;
     123                 :            :     }
     124         [ #  # ]:          0 :     if ( pMap )
     125                 :            :     {
     126                 :          0 :         double fMap = *pMap;
     127                 :          0 :         rBackwardDepth *= fMap;
     128                 :          0 :         rForwardDepth *= fMap;
     129                 :          0 :     }
     130                 :          0 : }
     131                 :            : 
     132                 :          0 : double GetDouble( SdrCustomShapeGeometryItem& rItem, const rtl::OUString& rPropertyName, double fDefault, const double* pMap )
     133                 :            : {
     134                 :          0 :     double fRetValue = fDefault;
     135         [ #  # ]:          0 :     Any* pAny = rItem.GetPropertyValueByName( rtl::OUString(aExtrusion), rPropertyName );
     136         [ #  # ]:          0 :     if ( pAny )
     137                 :          0 :         *pAny >>= fRetValue;
     138         [ #  # ]:          0 :     if ( pMap )
     139                 :          0 :         fRetValue *= *pMap;
     140                 :          0 :     return fRetValue;
     141                 :            : }
     142                 :            : 
     143                 :          0 : drawing::ShadeMode GetShadeMode( SdrCustomShapeGeometryItem& rItem, const drawing::ShadeMode eDefault )
     144                 :            : {
     145                 :          0 :     drawing::ShadeMode eRet( eDefault );
     146         [ #  # ]:          0 :     const rtl::OUString sShadeMode( RTL_CONSTASCII_USTRINGPARAM ( "ShadeMode" ) );
     147         [ #  # ]:          0 :     Any* pAny = rItem.GetPropertyValueByName( rtl::OUString(aExtrusion), sShadeMode );
     148         [ #  # ]:          0 :     if ( pAny )
     149         [ #  # ]:          0 :         *pAny >>= eRet;
     150                 :          0 :     return eRet;
     151                 :            : }
     152                 :            : 
     153                 :          0 : sal_Int32 GetInt32( SdrCustomShapeGeometryItem& rItem, const rtl::OUString& rPropertyName, const sal_Int32 nDefault )
     154                 :            : {
     155                 :          0 :     sal_Int32 nRetValue = nDefault;
     156         [ #  # ]:          0 :     Any* pAny = rItem.GetPropertyValueByName( rtl::OUString(aExtrusion), rPropertyName );
     157         [ #  # ]:          0 :     if ( pAny )
     158                 :          0 :         *pAny >>= nRetValue;
     159                 :          0 :     return nRetValue;
     160                 :            : }
     161                 :            : 
     162                 :          0 : sal_Bool GetBool( SdrCustomShapeGeometryItem& rItem, const rtl::OUString& rPropertyName, const sal_Bool bDefault )
     163                 :            : {
     164                 :          0 :     sal_Bool bRetValue = bDefault;
     165         [ #  # ]:          0 :     const Any* pAny = rItem.GetPropertyValueByName( rtl::OUString(aExtrusion), rPropertyName );
     166         [ #  # ]:          0 :     if ( pAny )
     167                 :          0 :         *pAny >>= bRetValue;
     168                 :          0 :     return bRetValue;
     169                 :            : }
     170                 :            : 
     171                 :          0 : awt::Point GetPoint( SdrCustomShapeGeometryItem& rItem, const rtl::OUString& rPropertyName, const awt::Point& rDefault )
     172                 :            : {
     173                 :          0 :     awt::Point aRetValue( rDefault );
     174         [ #  # ]:          0 :     const Any* pAny = rItem.GetPropertyValueByName( rtl::OUString(aExtrusion), rPropertyName );
     175         [ #  # ]:          0 :     if ( pAny )
     176                 :          0 :         *pAny >>= aRetValue;
     177                 :          0 :     return aRetValue;
     178                 :            : }
     179                 :            : 
     180                 :          0 : drawing::Position3D GetPosition3D( SdrCustomShapeGeometryItem& rItem, const rtl::OUString& rPropertyName,
     181                 :            :                                     const drawing::Position3D& rDefault, const double* pMap )
     182                 :            : {
     183                 :          0 :     drawing::Position3D aRetValue( rDefault );
     184         [ #  # ]:          0 :     const Any* pAny = rItem.GetPropertyValueByName( rtl::OUString(aExtrusion), rPropertyName );
     185         [ #  # ]:          0 :     if ( pAny )
     186                 :          0 :         *pAny >>= aRetValue;
     187         [ #  # ]:          0 :     if ( pMap )
     188                 :            :     {
     189                 :          0 :         aRetValue.PositionX *= *pMap;
     190                 :          0 :         aRetValue.PositionY *= *pMap;
     191                 :          0 :         aRetValue.PositionZ *= *pMap;
     192                 :            :     }
     193                 :          0 :     return aRetValue;
     194                 :            : }
     195                 :            : 
     196                 :          0 : drawing::Direction3D GetDirection3D( SdrCustomShapeGeometryItem& rItem, const rtl::OUString& rPropertyName, const drawing::Direction3D& rDefault )
     197                 :            : {
     198                 :          0 :     drawing::Direction3D aRetValue( rDefault );
     199         [ #  # ]:          0 :     const Any* pAny = rItem.GetPropertyValueByName( rtl::OUString(aExtrusion), rPropertyName );
     200         [ #  # ]:          0 :     if ( pAny )
     201                 :          0 :         *pAny >>= aRetValue;
     202                 :          0 :     return aRetValue;
     203                 :            : }
     204                 :            : 
     205                 :          0 : EnhancedCustomShape3d::Transformation2D::Transformation2D( const SdrObject* pCustomShape, const Rectangle& /*rBoundRect*/, const double *pM )
     206                 :          0 : :   aCenter( pCustomShape->GetSnapRect().Center() )
     207                 :            : ,   eProjectionMode( drawing::ProjectionMode_PARALLEL )
     208                 :          0 : ,   pMap( pM )
     209                 :            : {
     210         [ #  # ]:          0 :     SdrCustomShapeGeometryItem& rGeometryItem = (SdrCustomShapeGeometryItem&)pCustomShape->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
     211         [ #  # ]:          0 :     const rtl::OUString sProjectionMode( RTL_CONSTASCII_USTRINGPARAM ( "ProjectionMode" ) );
     212         [ #  # ]:          0 :     Any* pAny = rGeometryItem.GetPropertyValueByName( rtl::OUString(aExtrusion), sProjectionMode );
     213         [ #  # ]:          0 :     if ( pAny )
     214         [ #  # ]:          0 :         *pAny >>= eProjectionMode;
     215                 :            : 
     216         [ #  # ]:          0 :     if ( eProjectionMode == drawing::ProjectionMode_PARALLEL )
     217         [ #  # ]:          0 :         GetSkew( rGeometryItem, fSkew, fSkewAngle );
     218                 :            :     else
     219                 :            :     {
     220                 :          0 :         fZScreen = 0.0;
     221         [ #  # ]:          0 :         GetOrigin( rGeometryItem, fOriginX, fOriginY );
     222 [ #  # ][ #  # ]:          0 :         fOriginX = fOriginX * pCustomShape->GetLogicRect().GetWidth();
     223 [ #  # ][ #  # ]:          0 :         fOriginY = fOriginY * pCustomShape->GetLogicRect().GetHeight();
     224                 :            : 
     225         [ #  # ]:          0 :         const rtl::OUString sViewPoint( RTL_CONSTASCII_USTRINGPARAM ( "ViewPoint" ) );
     226                 :          0 :         drawing::Position3D aViewPointDefault( 3472, -3472, 25000 );
     227         [ #  # ]:          0 :         drawing::Position3D aViewPoint( GetPosition3D( rGeometryItem, sViewPoint, aViewPointDefault, pMap ) );
     228                 :          0 :         fViewPoint.setX(aViewPoint.PositionX);
     229                 :          0 :         fViewPoint.setY(aViewPoint.PositionY);
     230                 :          0 :         fViewPoint.setZ(-aViewPoint.PositionZ);
     231                 :          0 :     }
     232                 :          0 : }
     233                 :            : 
     234                 :          0 : basegfx::B3DPolygon EnhancedCustomShape3d::Transformation2D::ApplySkewSettings( const basegfx::B3DPolygon& rPoly3D ) const
     235                 :            : {
     236                 :          0 :     basegfx::B3DPolygon aRetval;
     237                 :            : 
     238                 :            :     sal_uInt32 j;
     239 [ #  # ][ #  # ]:          0 :     for ( j = 0L; j < rPoly3D.count(); j++ )
     240                 :            :     {
     241         [ #  # ]:          0 :         const basegfx::B3DPoint aPoint(rPoly3D.getB3DPoint(j));
     242                 :          0 :         double fDepth(-( aPoint.getZ() * fSkew ) / 100.0);
     243                 :            :         aRetval.append(basegfx::B3DPoint(
     244                 :          0 :             aPoint.getX() + (fDepth * cos( fSkewAngle )),
     245                 :          0 :             aPoint.getY() - (fDepth * sin( fSkewAngle )),
     246         [ #  # ]:          0 :             aPoint.getZ()));
     247                 :          0 :     }
     248                 :            : 
     249                 :          0 :     return aRetval;
     250                 :            : }
     251                 :            : 
     252                 :          0 : Point EnhancedCustomShape3d::Transformation2D::Transform2D( const basegfx::B3DPoint& rPoint3D ) const
     253                 :            : {
     254                 :          0 :     Point aPoint2D;
     255         [ #  # ]:          0 :     if ( eProjectionMode == drawing::ProjectionMode_PARALLEL )
     256                 :            :     {
     257                 :          0 :         aPoint2D.X() = (sal_Int32)rPoint3D.getX();
     258                 :          0 :         aPoint2D.Y() = (sal_Int32)rPoint3D.getY();
     259                 :            :     }
     260                 :            :     else
     261                 :            :     {
     262                 :          0 :         double fX = rPoint3D.getX() - fOriginX;
     263                 :          0 :         double fY = rPoint3D.getY() - fOriginY;
     264                 :          0 :         double f = ( fZScreen - fViewPoint.getZ() ) / ( rPoint3D.getZ() - fViewPoint.getZ() );
     265                 :          0 :         aPoint2D.X() = (sal_Int32)(( fX - fViewPoint.getX() ) * f + fViewPoint.getX() + fOriginX );
     266                 :          0 :         aPoint2D.Y() = (sal_Int32)(( fY - fViewPoint.getY() ) * f + fViewPoint.getY() + fOriginY );
     267                 :            :     }
     268                 :          0 :     aPoint2D.Move( aCenter.X(), aCenter.Y() );
     269                 :          0 :     return aPoint2D;
     270                 :            : }
     271                 :            : 
     272                 :          0 : sal_Bool EnhancedCustomShape3d::Transformation2D::IsParallel() const
     273                 :            : {
     274                 :          0 :     return eProjectionMode == com::sun::star::drawing::ProjectionMode_PARALLEL;
     275                 :            : }
     276                 :            : 
     277                 :          0 : SdrObject* EnhancedCustomShape3d::Create3DObject( const SdrObject* pShape2d, const SdrObject* pCustomShape )
     278                 :            : {
     279                 :          0 :     SdrObject*  pRet = NULL;
     280         [ #  # ]:          0 :     SdrModel*   pModel = pCustomShape->GetModel();
     281         [ #  # ]:          0 :     SdrCustomShapeGeometryItem& rGeometryItem = (SdrCustomShapeGeometryItem&)pCustomShape->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
     282                 :            : 
     283                 :          0 :     double      fMap, *pMap = NULL;
     284         [ #  # ]:          0 :     if ( pModel )
     285                 :            :     {
     286                 :          0 :         fMap = 1.0;
     287         [ #  # ]:          0 :         Fraction aFraction( pModel->GetScaleFraction() );
     288 [ #  # ][ #  # ]:          0 :         if ( ( aFraction.GetNumerator() ) != 1 || ( aFraction.GetDenominator() != 1 ) )
                 [ #  # ]
     289                 :            :         {
     290                 :          0 :             fMap *= aFraction.GetNumerator();
     291                 :          0 :             fMap /= aFraction.GetDenominator();
     292                 :          0 :             pMap = &fMap;
     293                 :            :         }
     294         [ #  # ]:          0 :         if ( pModel->GetScaleUnit() != MAP_100TH_MM )
     295                 :            :         {
     296                 :            :             DBG_ASSERT( pModel->GetScaleUnit() == MAP_TWIP, "EnhancedCustomShape3d::Current MapMode is Unsupported" );
     297                 :          0 :             fMap *= 1440.0 / 2540.0;
     298                 :          0 :             pMap = &fMap;
     299                 :            :         }
     300                 :            :     }
     301 [ #  # ][ #  # ]:          0 :     if ( GetBool( rGeometryItem, aExtrusion, sal_False ) )
     302                 :            :     {
     303         [ #  # ]:          0 :         sal_Bool bIsMirroredX = ((SdrObjCustomShape*)pCustomShape)->IsMirroredX();
     304         [ #  # ]:          0 :         sal_Bool bIsMirroredY = ((SdrObjCustomShape*)pCustomShape)->IsMirroredY();
     305         [ #  # ]:          0 :         Rectangle aSnapRect( pCustomShape->GetLogicRect() );
     306         [ #  # ]:          0 :         long nObjectRotation = pCustomShape->GetRotateAngle();
     307         [ #  # ]:          0 :         if ( nObjectRotation )
     308                 :            :         {
     309                 :          0 :             double a = ( 36000 - nObjectRotation ) * nPi180;
     310                 :          0 :             long dx = aSnapRect.Right() - aSnapRect.Left();
     311                 :          0 :             long dy = aSnapRect.Bottom()- aSnapRect.Top();
     312                 :          0 :             Point aP( aSnapRect.TopLeft() );
     313 [ #  # ][ #  # ]:          0 :             RotatePoint( aP, pCustomShape->GetSnapRect().Center(), sin( a ), cos( a ) );
     314                 :          0 :             aSnapRect.Left() = aP.X();
     315                 :          0 :             aSnapRect.Top() = aP.Y();
     316                 :          0 :             aSnapRect.Right() = aSnapRect.Left() + dx;
     317                 :          0 :             aSnapRect.Bottom() = aSnapRect.Top() + dy;
     318                 :            :         }
     319         [ #  # ]:          0 :         Point aCenter( aSnapRect.Center() );
     320                 :            : 
     321 [ #  # ][ #  # ]:          0 :         SfxItemSet aSet( pCustomShape->GetMergedItemSet() );
     322                 :            : 
     323                 :            :         //SJ: vertical writing is not required, by removing this item no outliner is created
     324         [ #  # ]:          0 :         aSet.ClearItem( SDRATTR_TEXTDIRECTION );
     325                 :            : 
     326                 :            :         // #i105323# For 3D AutoShapes, the shadow attribute has to be applied to each
     327                 :            :         // created visualisation helper model shape individually. The shadow itself
     328                 :            :         // will then be rendered from the 3D renderer correctly for the whole 3D scene
     329                 :            :         // (and thus behind all objects of which the visualisation may be built). So,
     330                 :            :         // dio NOT remove it from the ItemSet here.
     331                 :            :         // aSet.ClearItem(SDRATTR_SHADOW);
     332                 :            : 
     333         [ #  # ]:          0 :         std::vector< E3dCompoundObject* > aPlaceholderObjectList;
     334                 :            : 
     335                 :            :         double fExtrusionBackward, fExtrusionForward;
     336         [ #  # ]:          0 :         GetExtrusionDepth( rGeometryItem, pMap, fExtrusionBackward, fExtrusionForward );
     337                 :          0 :         double fDepth = fExtrusionBackward - fExtrusionForward;
     338         [ #  # ]:          0 :         if ( fDepth < 1.0 )
     339                 :          0 :             fDepth = 1.0;
     340                 :            : 
     341                 :          0 :         drawing::ProjectionMode eProjectionMode( drawing::ProjectionMode_PARALLEL );
     342         [ #  # ]:          0 :         const rtl::OUString sProjectionMode( RTL_CONSTASCII_USTRINGPARAM ( "ProjectionMode" ) );
     343         [ #  # ]:          0 :         Any* pAny = rGeometryItem.GetPropertyValueByName( aExtrusion, sProjectionMode );
     344         [ #  # ]:          0 :         if ( pAny )
     345         [ #  # ]:          0 :             *pAny >>= eProjectionMode;
     346                 :          0 :         ProjectionType eProjectionType( eProjectionMode == drawing::ProjectionMode_PARALLEL ? PR_PARALLEL : PR_PERSPECTIVE );
     347                 :            :         // pShape2d Convert in scenes which include 3D Objects
     348         [ #  # ]:          0 :         E3dDefaultAttributes a3DDefaultAttr;
     349                 :          0 :         a3DDefaultAttr.SetDefaultLatheCharacterMode( sal_True );
     350                 :          0 :         a3DDefaultAttr.SetDefaultExtrudeCharacterMode( sal_True );
     351                 :            : 
     352 [ #  # ][ #  # ]:          0 :         E3dScene* pScene = new E3dPolyScene( a3DDefaultAttr );
     353                 :            : 
     354                 :          0 :         sal_Bool bSceneHasObjects ( sal_False );
     355                 :          0 :         sal_Bool bUseTwoFillStyles( sal_False );
     356                 :            : 
     357         [ #  # ]:          0 :         drawing::ShadeMode eShadeMode( GetShadeMode( rGeometryItem, drawing::ShadeMode_FLAT ) );
     358         [ #  # ]:          0 :         const rtl::OUString aExtrusionColor( RTL_CONSTASCII_USTRINGPARAM ( "Color" ) );
     359         [ #  # ]:          0 :         sal_Bool bUseExtrusionColor = GetBool( rGeometryItem, aExtrusionColor, sal_False );
     360                 :            : 
     361         [ #  # ]:          0 :         XFillStyle eFillStyle( ITEMVALUE( aSet, XATTR_FILLSTYLE, XFillStyleItem ) );
     362 [ #  # ][ #  # ]:          0 :         pScene->GetProperties().SetObjectItem( Svx3DShadeModeItem( 0 ) );
         [ #  # ][ #  # ]
     363 [ #  # ][ #  # ]:          0 :         aSet.Put( Svx3DPercentDiagonalItem( 0 ) );
                 [ #  # ]
     364 [ #  # ][ #  # ]:          0 :         aSet.Put( Svx3DTextureModeItem( 1 ) );
                 [ #  # ]
     365 [ #  # ][ #  # ]:          0 :         aSet.Put( Svx3DNormalsKindItem( 1 ) );
                 [ #  # ]
     366                 :            : 
     367         [ #  # ]:          0 :         if ( eShadeMode == drawing::ShadeMode_DRAFT )
     368                 :            :         {
     369 [ #  # ][ #  # ]:          0 :             aSet.Put( XLineStyleItem( XLINE_SOLID ) );
                 [ #  # ]
     370 [ #  # ][ #  # ]:          0 :             aSet.Put( XFillStyleItem ( XFILL_NONE ) );
                 [ #  # ]
     371 [ #  # ][ #  # ]:          0 :             aSet.Put( Svx3DDoubleSidedItem( sal_True ) );
                 [ #  # ]
     372                 :            :         }
     373                 :            :         else
     374                 :            :         {
     375 [ #  # ][ #  # ]:          0 :             aSet.Put( XLineStyleItem( XLINE_NONE ) );
                 [ #  # ]
     376         [ #  # ]:          0 :             if ( eFillStyle == XFILL_NONE )
     377 [ #  # ][ #  # ]:          0 :                 aSet.Put( XFillStyleItem( XFILL_SOLID ) );
                 [ #  # ]
     378 [ #  # ][ #  # ]:          0 :             else if ( ( eFillStyle == XFILL_BITMAP ) || ( eFillStyle == XFILL_GRADIENT ) || bUseExtrusionColor )
                 [ #  # ]
     379                 :          0 :                 bUseTwoFillStyles = sal_True;
     380                 :            : 
     381                 :            :             // #116336#
     382                 :            :             // If shapes are mirrored once (mirroring two times correct geometry again)
     383                 :            :             // double-sided at the object and two-sided-lighting at the scene need to be set.
     384 [ #  # ][ #  # ]:          0 :             if((bIsMirroredX && !bIsMirroredY) || (!bIsMirroredX && bIsMirroredY))
         [ #  # ][ #  # ]
     385                 :            :             {
     386 [ #  # ][ #  # ]:          0 :                 aSet.Put( Svx3DDoubleSidedItem( sal_True ) );
                 [ #  # ]
     387 [ #  # ][ #  # ]:          0 :                 pScene->GetProperties().SetObjectItem( Svx3DTwoSidedLightingItem( sal_True ) );
         [ #  # ][ #  # ]
     388                 :            :             }
     389                 :            :         }
     390                 :            : 
     391         [ #  # ]:          0 :         Rectangle aBoundRect2d;
     392         [ #  # ]:          0 :         SdrObjListIter aIter( *pShape2d, IM_DEEPWITHGROUPS );
     393         [ #  # ]:          0 :         while( aIter.IsMore() )
     394                 :            :         {
     395         [ #  # ]:          0 :             const SdrObject* pNext = aIter.Next();
     396         [ #  # ]:          0 :             sal_Bool bIsPlaceholderObject = (((XFillStyleItem&)pNext->GetMergedItem( XATTR_FILLSTYLE )).GetValue() == XFILL_NONE )
     397 [ #  # ][ #  # ]:          0 :                                         && (((XLineStyleItem&)pNext->GetMergedItem( XATTR_LINESTYLE )).GetValue() == XLINE_NONE );
                 [ #  # ]
     398         [ #  # ]:          0 :             basegfx::B2DPolyPolygon aPolyPoly;
     399                 :            : 
     400 [ #  # ][ #  # ]:          0 :             if ( pNext->ISA( SdrPathObj ) )
                 [ #  # ]
     401                 :            :             {
     402         [ #  # ]:          0 :                 aPolyPoly = ((SdrPathObj*)pNext)->GetPathPoly();
     403                 :            : 
     404 [ #  # ][ #  # ]:          0 :                 if(aPolyPoly.areControlPointsUsed())
     405                 :            :                 {
     406 [ #  # ][ #  # ]:          0 :                     aPolyPoly = basegfx::tools::adaptiveSubdivideByAngle(aPolyPoly);
                 [ #  # ]
     407                 :            :                 }
     408                 :            :             }
     409                 :            :             else
     410                 :            :             {
     411         [ #  # ]:          0 :                 SdrObject* pNewObj = pNext->ConvertToPolyObj( sal_False, sal_False );
     412 [ #  # ][ #  # ]:          0 :                 SdrPathObj* pPath = PTR_CAST( SdrPathObj, pNewObj );
         [ #  # ][ #  # ]
     413         [ #  # ]:          0 :                 if ( pPath )
     414         [ #  # ]:          0 :                     aPolyPoly = pPath->GetPathPoly();
     415         [ #  # ]:          0 :                 SdrObject::Free( pNewObj );
     416                 :            :             }
     417                 :            : 
     418 [ #  # ][ #  # ]:          0 :             if( aPolyPoly.count() )
     419                 :            :             {
     420         [ #  # ]:          0 :                 const basegfx::B2DRange aTempRange(basegfx::tools::getRange(aPolyPoly));
     421 [ #  # ][ #  # ]:          0 :                 const Rectangle aBoundRect(basegfx::fround(aTempRange.getMinX()), basegfx::fround(aTempRange.getMinY()), basegfx::fround(aTempRange.getMaxX()), basegfx::fround(aTempRange.getMaxY()));
         [ #  # ][ #  # ]
                 [ #  # ]
     422         [ #  # ]:          0 :                 aBoundRect2d.Union( aBoundRect );
     423                 :            : 
     424 [ #  # ][ #  # ]:          0 :                 E3dCompoundObject* p3DObj = new E3dExtrudeObj( a3DDefaultAttr, aPolyPoly, bUseTwoFillStyles ? 10 : fDepth );
                 [ #  # ]
     425 [ #  # ][ #  # ]:          0 :                 p3DObj->NbcSetLayer( pShape2d->GetLayer() );
     426         [ #  # ]:          0 :                 p3DObj->SetMergedItemSet( aSet );
     427         [ #  # ]:          0 :                 if ( bIsPlaceholderObject )
     428         [ #  # ]:          0 :                     aPlaceholderObjectList.push_back( p3DObj );
     429         [ #  # ]:          0 :                 else if ( bUseTwoFillStyles )
     430                 :            :                 {
     431         [ #  # ]:          0 :                     Bitmap aFillBmp;
     432         [ #  # ]:          0 :                     sal_Bool bFillBmpTile = ((XFillBmpTileItem&)p3DObj->GetMergedItem( XATTR_FILLBMP_TILE )).GetValue();
     433         [ #  # ]:          0 :                     if ( bFillBmpTile )
     434                 :            :                     {
     435         [ #  # ]:          0 :                         const XFillBitmapItem& rBmpItm = (XFillBitmapItem&)p3DObj->GetMergedItem( XATTR_FILLBITMAP );
     436         [ #  # ]:          0 :                         const XOBitmap& rXOBmp = rBmpItm.GetBitmapValue();
     437 [ #  # ][ #  # ]:          0 :                         aFillBmp = rXOBmp.GetBitmap();
                 [ #  # ]
     438                 :          0 :                         Size aLogicalSize = aFillBmp.GetPrefSize();
     439 [ #  # ][ #  # ]:          0 :                         if ( aFillBmp.GetPrefMapMode() == MAP_PIXEL )
         [ #  # ][ #  # ]
     440 [ #  # ][ #  # ]:          0 :                             aLogicalSize = Application::GetDefaultDevice()->PixelToLogic( aLogicalSize, MAP_100TH_MM );
         [ #  # ][ #  # ]
     441                 :            :                         else
     442 [ #  # ][ #  # ]:          0 :                             aLogicalSize = OutputDevice::LogicToLogic( aLogicalSize, aFillBmp.GetPrefMapMode(), MAP_100TH_MM );
                 [ #  # ]
     443                 :          0 :                         aLogicalSize.Width()  *= 5;         ;//             :-(     nice scaling, look at engine3d/obj3d.cxx
     444                 :          0 :                         aLogicalSize.Height() *= 5;
     445                 :          0 :                         aFillBmp.SetPrefSize( aLogicalSize );
     446 [ #  # ][ #  # ]:          0 :                         aFillBmp.SetPrefMapMode( MAP_100TH_MM );
                 [ #  # ]
     447 [ #  # ][ #  # ]:          0 :                         p3DObj->SetMergedItem( XFillBitmapItem( String(), aFillBmp ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     448                 :            :                     }
     449                 :            :                     else
     450                 :            :                     {
     451 [ #  # ][ #  # ]:          0 :                         if ( aSnapRect != aBoundRect )
     452                 :            :                         {
     453         [ #  # ]:          0 :                             const XFillBitmapItem& rBmpItm = (XFillBitmapItem&)p3DObj->GetMergedItem( XATTR_FILLBITMAP );
     454         [ #  # ]:          0 :                             const XOBitmap& rXOBmp = rBmpItm.GetBitmapValue();
     455 [ #  # ][ #  # ]:          0 :                             aFillBmp = rXOBmp.GetBitmap();
                 [ #  # ]
     456         [ #  # ]:          0 :                             Size aBmpSize( aFillBmp.GetSizePixel() );
     457 [ #  # ][ #  # ]:          0 :                             double fXScale = (double)aBoundRect.GetWidth() / (double)aSnapRect.GetWidth();
     458 [ #  # ][ #  # ]:          0 :                             double fYScale = (double)aBoundRect.GetHeight() / (double)aSnapRect.GetHeight();
     459                 :            : 
     460         [ #  # ]:          0 :                             Point aPt( (sal_Int32)( (double)( aBoundRect.Left() - aSnapRect.Left() )* (double)aBmpSize.Width() / (double)aSnapRect.GetWidth() ),
     461         [ #  # ]:          0 :                                                 (sal_Int32)( (double)( aBoundRect.Top() - aSnapRect.Top() ) * (double)aBmpSize.Height() / (double)aSnapRect.GetHeight() ) );
     462                 :          0 :                             Size aSize( (sal_Int32)( aBmpSize.Width() * fXScale ),
     463                 :          0 :                                                     (sal_Int32)( aBmpSize.Height() * fYScale ) );
     464         [ #  # ]:          0 :                             Rectangle aCropRect( aPt, aSize );
     465         [ #  # ]:          0 :                              aFillBmp.Crop( aCropRect );
     466 [ #  # ][ #  # ]:          0 :                             p3DObj->SetMergedItem( XFillBitmapItem( String(), aFillBmp ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     467                 :            :                         }
     468                 :            :                     }
     469         [ #  # ]:          0 :                     pScene->Insert3DObj( p3DObj );
     470 [ #  # ][ #  # ]:          0 :                     p3DObj = new E3dExtrudeObj( a3DDefaultAttr, aPolyPoly, fDepth );
     471 [ #  # ][ #  # ]:          0 :                     p3DObj->NbcSetLayer( pShape2d->GetLayer() );
     472         [ #  # ]:          0 :                     p3DObj->SetMergedItemSet( aSet );
     473         [ #  # ]:          0 :                     if ( bUseExtrusionColor )
     474 [ #  # ][ #  # ]:          0 :                         p3DObj->SetMergedItem( XFillColorItem( String(), ((XSecondaryFillColorItem&)pCustomShape->GetMergedItem( XATTR_SECONDARYFILLCOLOR )).GetColorValue() ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     475 [ #  # ][ #  # ]:          0 :                     p3DObj->SetMergedItem( XFillStyleItem( XFILL_SOLID ) );
                 [ #  # ]
     476 [ #  # ][ #  # ]:          0 :                     p3DObj->SetMergedItem( Svx3DCloseFrontItem( sal_False ) );
                 [ #  # ]
     477 [ #  # ][ #  # ]:          0 :                     p3DObj->SetMergedItem( Svx3DCloseBackItem( sal_False ) );
                 [ #  # ]
     478         [ #  # ]:          0 :                     pScene->Insert3DObj( p3DObj );
     479 [ #  # ][ #  # ]:          0 :                     p3DObj = new E3dExtrudeObj( a3DDefaultAttr, aPolyPoly, 10 );
     480 [ #  # ][ #  # ]:          0 :                     p3DObj->NbcSetLayer( pShape2d->GetLayer() );
     481         [ #  # ]:          0 :                     p3DObj->SetMergedItemSet( aSet );
     482                 :            : 
     483 [ #  # ][ #  # ]:          0 :                     basegfx::B3DHomMatrix aFrontTransform( p3DObj->GetTransform() );
     484         [ #  # ]:          0 :                     aFrontTransform.translate( 0.0, 0.0, fDepth );
     485         [ #  # ]:          0 :                     p3DObj->NbcSetTransform( aFrontTransform );
     486                 :            : 
     487 [ #  # ][ #  # ]:          0 :                     if ( ( eFillStyle == XFILL_BITMAP ) && !aFillBmp.IsEmpty() )
                 [ #  # ]
     488 [ #  # ][ #  # ]:          0 :                         p3DObj->SetMergedItem( XFillBitmapItem( String(), aFillBmp ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     489                 :            :                 }
     490         [ #  # ]:          0 :                 else if ( eFillStyle == XFILL_NONE )
     491                 :            :                 {
     492         [ #  # ]:          0 :                     XLineColorItem& rLineColor = (XLineColorItem&)p3DObj->GetMergedItem( XATTR_LINECOLOR );
     493 [ #  # ][ #  # ]:          0 :                     p3DObj->SetMergedItem( XFillColorItem( String(), rLineColor.GetColorValue() ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     494 [ #  # ][ #  # ]:          0 :                     p3DObj->SetMergedItem( Svx3DDoubleSidedItem( sal_True ) );
                 [ #  # ]
     495 [ #  # ][ #  # ]:          0 :                     p3DObj->SetMergedItem( Svx3DCloseFrontItem( sal_False ) );
                 [ #  # ]
     496 [ #  # ][ #  # ]:          0 :                     p3DObj->SetMergedItem( Svx3DCloseBackItem( sal_False ) );
                 [ #  # ]
     497                 :            :                 }
     498         [ #  # ]:          0 :                 pScene->Insert3DObj( p3DObj );
     499                 :          0 :                 bSceneHasObjects = sal_True;
     500                 :            :             }
     501         [ #  # ]:          0 :         }
     502                 :            : 
     503         [ #  # ]:          0 :         if ( bSceneHasObjects ) // is the SdrObject properly converted
     504                 :            :         {
     505                 :            :             // then we can change the return value
     506                 :          0 :             pRet = pScene;
     507                 :            : 
     508                 :            :             // Camera settings, Perspective ...
     509                 :          0 :             Camera3D& rCamera = (Camera3D&)pScene->GetCamera();
     510         [ #  # ]:          0 :             const basegfx::B3DRange& rVolume = pScene->GetBoundVolume();
     511         [ #  # ]:          0 :             pScene->NbcSetSnapRect( aSnapRect );
     512                 :            : 
     513                 :            :             // InitScene replacement
     514         [ #  # ]:          0 :             double fW = rVolume.getWidth();
     515         [ #  # ]:          0 :             double fH = rVolume.getHeight();
     516                 :            : 
     517                 :          0 :             rCamera.SetAutoAdjustProjection( sal_False );
     518         [ #  # ]:          0 :             rCamera.SetViewWindow( -fW / 2, - fH / 2, fW, fH);
     519                 :          0 :             basegfx::B3DPoint aLookAt( 0.0, 0.0, 0.0 );
     520                 :          0 :             basegfx::B3DPoint aCamPos( 0.0, 0.0, 100.0 );
     521         [ #  # ]:          0 :             rCamera.SetDefaults( basegfx::B3DPoint( 0.0, 0.0, 100.0 ), aLookAt, 100.0 );
     522         [ #  # ]:          0 :             rCamera.SetPosAndLookAt( aCamPos, aLookAt );
     523         [ #  # ]:          0 :             rCamera.SetFocalLength( 1.0 );
     524                 :          0 :             rCamera.SetProjection( eProjectionType );
     525         [ #  # ]:          0 :             pScene->SetCamera( rCamera );
     526         [ #  # ]:          0 :             pScene->SetRectsDirty();
     527                 :            : 
     528                 :            :             double fOriginX, fOriginY;
     529         [ #  # ]:          0 :             GetOrigin( rGeometryItem, fOriginX, fOriginY );
     530         [ #  # ]:          0 :             fOriginX = fOriginX * aSnapRect.GetWidth();
     531         [ #  # ]:          0 :             fOriginY = fOriginY * aSnapRect.GetHeight();
     532                 :            : 
     533 [ #  # ][ #  # ]:          0 :             basegfx::B3DHomMatrix aNewTransform( pScene->GetTransform() );
     534 [ #  # ][ #  # ]:          0 :             aNewTransform.translate( -aCenter.X(), aCenter.Y(), -pScene->GetBoundVolume().getDepth() );
                 [ #  # ]
     535                 :            : 
     536                 :            :             double fXRotate, fYRotate;
     537         [ #  # ]:          0 :             GetRotateAngle( rGeometryItem, fXRotate, fYRotate );
     538         [ #  # ]:          0 :             double fZRotate = ((SdrObjCustomShape*)pCustomShape)->GetObjectRotation() * F_PI180;
     539         [ #  # ]:          0 :             if ( fZRotate != 0.0 )
     540         [ #  # ]:          0 :                 aNewTransform.rotate( 0.0, 0.0, fZRotate );
     541         [ #  # ]:          0 :             if ( bIsMirroredX )
     542         [ #  # ]:          0 :                 aNewTransform.scale( -1.0, 1, 1 );
     543         [ #  # ]:          0 :             if ( bIsMirroredY )
     544         [ #  # ]:          0 :                 aNewTransform.scale( 1, -1.0, 1 );
     545         [ #  # ]:          0 :             if( fYRotate != 0.0 )
     546         [ #  # ]:          0 :                 aNewTransform.rotate( 0.0, -fYRotate, 0.0 );
     547         [ #  # ]:          0 :             if( fXRotate != 0.0 )
     548         [ #  # ]:          0 :                 aNewTransform.rotate( -fXRotate, 0.0, 0.0 );
     549         [ #  # ]:          0 :             if ( eProjectionType == PR_PARALLEL )
     550                 :            :             {
     551                 :            :                 double fSkew, fAlpha;
     552         [ #  # ]:          0 :                 GetSkew( rGeometryItem, fSkew, fAlpha );
     553         [ #  # ]:          0 :                 if ( fSkew != 0.0 )
     554                 :            :                 {
     555                 :          0 :                     double fInvTanBeta( fSkew / 100.0 );
     556         [ #  # ]:          0 :                     if(fInvTanBeta)
     557                 :            :                     {
     558                 :            :                         aNewTransform.shearXY(
     559                 :          0 :                             fInvTanBeta * cos(fAlpha),
     560         [ #  # ]:          0 :                             fInvTanBeta * sin(fAlpha));
     561                 :            :                     }
     562                 :            :                 }
     563                 :          0 :                 basegfx::B3DPoint _aLookAt( 0.0, 0.0, 0.0 );
     564                 :          0 :                 basegfx::B3DPoint _aNewCamPos( 0.0, 0.0, 25000.0 );
     565         [ #  # ]:          0 :                 rCamera.SetPosAndLookAt( _aNewCamPos, _aLookAt );
     566         [ #  # ]:          0 :                 pScene->SetCamera( rCamera );
     567                 :            :             }
     568                 :            :             else
     569                 :            :             {
     570         [ #  # ]:          0 :                 aNewTransform.translate( -fOriginX, fOriginY, 0.0 );
     571                 :            :                 // now set correct camera position
     572         [ #  # ]:          0 :                 const rtl::OUString sViewPoint( RTL_CONSTASCII_USTRINGPARAM ( "ViewPoint" ) );
     573                 :          0 :                 drawing::Position3D aViewPointDefault( 3472, -3472, 25000 );
     574         [ #  # ]:          0 :                 drawing::Position3D aViewPoint( GetPosition3D( rGeometryItem, sViewPoint, aViewPointDefault, pMap ) );
     575                 :          0 :                 double fViewPointX = aViewPoint.PositionX;
     576                 :          0 :                 double fViewPointY = aViewPoint.PositionY;
     577                 :          0 :                 double fViewPointZ = aViewPoint.PositionZ;
     578                 :          0 :                 basegfx::B3DPoint _aLookAt( fViewPointX, -fViewPointY, 0.0 );
     579                 :          0 :                 basegfx::B3DPoint aNewCamPos( fViewPointX, -fViewPointY, fViewPointZ );
     580         [ #  # ]:          0 :                 rCamera.SetPosAndLookAt( aNewCamPos, _aLookAt );
     581         [ #  # ]:          0 :                 pScene->SetCamera( rCamera );
     582                 :            :             }
     583                 :            : 
     584         [ #  # ]:          0 :             pScene->NbcSetTransform( aNewTransform );
     585                 :            : 
     586                 :            :             ///////////
     587                 :            :             // light //
     588                 :            :             ///////////
     589                 :            : 
     590         [ #  # ]:          0 :             const rtl::OUString sBrightness( RTL_CONSTASCII_USTRINGPARAM ( "Brightness" ) );
     591         [ #  # ]:          0 :             double fAmbientIntensity = GetDouble( rGeometryItem, sBrightness, 22178.0 / 655.36, NULL ) / 100.0;
     592                 :            : 
     593                 :            : 
     594         [ #  # ]:          0 :             const rtl::OUString sFirstLightDirection( RTL_CONSTASCII_USTRINGPARAM ( "FirstLightDirection" ) );
     595                 :          0 :             drawing::Direction3D aFirstLightDirectionDefault( 50000, 0, 10000 );
     596         [ #  # ]:          0 :             drawing::Direction3D aFirstLightDirection( GetDirection3D( rGeometryItem, sFirstLightDirection, aFirstLightDirectionDefault ) );
     597         [ #  # ]:          0 :             if ( aFirstLightDirection.DirectionZ == 0.0 )
     598                 :          0 :                 aFirstLightDirection.DirectionZ = 1.0;
     599                 :            : 
     600         [ #  # ]:          0 :             const rtl::OUString sFirstLightLevel( RTL_CONSTASCII_USTRINGPARAM ( "FirstLightLevel" ) );
     601         [ #  # ]:          0 :             double fLightIntensity = GetDouble( rGeometryItem, sFirstLightLevel, 43712.0 / 655.36, NULL ) / 100.0;
     602                 :            : 
     603         [ #  # ]:          0 :             const rtl::OUString sFirstLightHarsh( RTL_CONSTASCII_USTRINGPARAM ( "FirstLightHarsh" ) );
     604         [ #  # ]:          0 :             /* sal_Bool bFirstLightHarsh = */ GetBool( rGeometryItem, sFirstLightHarsh, sal_False );
     605                 :            : 
     606         [ #  # ]:          0 :             const rtl::OUString sSecondLightDirection( RTL_CONSTASCII_USTRINGPARAM ( "SecondLightDirection" ) );
     607                 :          0 :             drawing::Direction3D aSecondLightDirectionDefault( -50000, 0, 10000 );
     608         [ #  # ]:          0 :             drawing::Direction3D aSecondLightDirection( GetDirection3D( rGeometryItem, sSecondLightDirection, aSecondLightDirectionDefault ) );
     609         [ #  # ]:          0 :             if ( aSecondLightDirection.DirectionZ == 0.0 )
     610                 :          0 :                 aSecondLightDirection.DirectionZ = -1;
     611                 :            : 
     612         [ #  # ]:          0 :             const rtl::OUString sSecondLightLevel( RTL_CONSTASCII_USTRINGPARAM ( "SecondLightLevel" ) );
     613         [ #  # ]:          0 :             double fLight2Intensity = GetDouble( rGeometryItem, sSecondLightLevel, 43712.0 / 655.36, NULL ) / 100.0;
     614                 :            : 
     615         [ #  # ]:          0 :             const rtl::OUString sSecondLightHarsh( RTL_CONSTASCII_USTRINGPARAM ( "SecondLightHarsh" ) );
     616         [ #  # ]:          0 :             const rtl::OUString sLightFace( RTL_CONSTASCII_USTRINGPARAM ( "LightFace" ) );
     617         [ #  # ]:          0 :             /* sal_Bool bLight2Harsh = */ GetBool( rGeometryItem, sSecondLightHarsh, sal_False );
     618         [ #  # ]:          0 :             /* sal_Bool bLightFace = */ GetBool( rGeometryItem, sLightFace, sal_False );
     619                 :            : 
     620                 :          0 :             sal_uInt16 nAmbientColor = (sal_uInt16)( fAmbientIntensity * 255.0 );
     621         [ #  # ]:          0 :             if ( nAmbientColor > 255 )
     622                 :          0 :                 nAmbientColor = 255;
     623                 :          0 :             Color aGlobalAmbientColor( (sal_uInt8)nAmbientColor, (sal_uInt8)nAmbientColor, (sal_uInt8)nAmbientColor );
     624 [ #  # ][ #  # ]:          0 :             pScene->GetProperties().SetObjectItem( Svx3DAmbientcolorItem( aGlobalAmbientColor ) );
         [ #  # ][ #  # ]
     625                 :            : 
     626                 :          0 :             sal_uInt8 nSpotLight1 = (sal_uInt8)( fLightIntensity * 255.0 );
     627                 :          0 :             basegfx::B3DVector aSpotLight1( aFirstLightDirection.DirectionX, - ( aFirstLightDirection.DirectionY ), -( aFirstLightDirection.DirectionZ ) );
     628         [ #  # ]:          0 :             aSpotLight1.normalize();
     629 [ #  # ][ #  # ]:          0 :             pScene->GetProperties().SetObjectItem( Svx3DLightOnOff1Item( sal_True ) );
         [ #  # ][ #  # ]
     630                 :          0 :             Color aAmbientSpot1Color( nSpotLight1, nSpotLight1, nSpotLight1 );
     631 [ #  # ][ #  # ]:          0 :             pScene->GetProperties().SetObjectItem( Svx3DLightcolor1Item( aAmbientSpot1Color ) );
         [ #  # ][ #  # ]
     632 [ #  # ][ #  # ]:          0 :             pScene->GetProperties().SetObjectItem( Svx3DLightDirection1Item( aSpotLight1 ) );
         [ #  # ][ #  # ]
     633                 :            : 
     634                 :          0 :             sal_uInt8 nSpotLight2 = (sal_uInt8)( fLight2Intensity * 255.0 );
     635                 :          0 :             basegfx::B3DVector aSpotLight2( aSecondLightDirection.DirectionX, -aSecondLightDirection.DirectionY, -aSecondLightDirection.DirectionZ );
     636         [ #  # ]:          0 :             aSpotLight2.normalize();
     637 [ #  # ][ #  # ]:          0 :             pScene->GetProperties().SetObjectItem( Svx3DLightOnOff2Item( sal_True ) );
         [ #  # ][ #  # ]
     638                 :          0 :             Color aAmbientSpot2Color( nSpotLight2, nSpotLight2, nSpotLight2 );
     639 [ #  # ][ #  # ]:          0 :             pScene->GetProperties().SetObjectItem( Svx3DLightcolor2Item( aAmbientSpot2Color ) );
         [ #  # ][ #  # ]
     640 [ #  # ][ #  # ]:          0 :             pScene->GetProperties().SetObjectItem( Svx3DLightDirection2Item( aSpotLight2 ) );
         [ #  # ][ #  # ]
     641                 :            : 
     642                 :          0 :                 sal_uInt8 nSpotLight3 = 70;
     643                 :          0 :                 basegfx::B3DVector aSpotLight3( 0.0, 0.0, 1.0 );
     644 [ #  # ][ #  # ]:          0 :                 pScene->GetProperties().SetObjectItem( Svx3DLightOnOff3Item( sal_True ) );
         [ #  # ][ #  # ]
     645                 :          0 :                 Color aAmbientSpot3Color( nSpotLight3, nSpotLight3, nSpotLight3 );
     646 [ #  # ][ #  # ]:          0 :                 pScene->GetProperties().SetObjectItem( Svx3DLightcolor3Item( aAmbientSpot3Color ) );
         [ #  # ][ #  # ]
     647 [ #  # ][ #  # ]:          0 :                 pScene->GetProperties().SetObjectItem( Svx3DLightDirection3Item( aSpotLight3 ) );
         [ #  # ][ #  # ]
     648                 :            : 
     649         [ #  # ]:          0 :             const rtl::OUString sSpecularity( RTL_CONSTASCII_USTRINGPARAM ( "Specularity" ) );
     650         [ #  # ]:          0 :             const rtl::OUString sMetal( RTL_CONSTASCII_USTRINGPARAM ( "Metal" ) );
     651         [ #  # ]:          0 :             double fSpecular = GetDouble( rGeometryItem, sSpecularity, 0, NULL ) / 100;
     652         [ #  # ]:          0 :             sal_Bool bMetal = GetBool( rGeometryItem, sMetal, sal_False );
     653                 :            : 
     654                 :          0 :             Color aSpecularCol( 225,225,225 );
     655         [ #  # ]:          0 :             if ( bMetal )
     656                 :            :             {
     657                 :          0 :                 aSpecularCol = Color( 200, 200, 200 );
     658                 :          0 :                 fSpecular += 0.15;
     659                 :            :             }
     660                 :          0 :             sal_Int32 nIntensity = (sal_Int32)fSpecular * 100;
     661         [ #  # ]:          0 :             if ( nIntensity > 100 )
     662                 :          0 :                 nIntensity = 100;
     663         [ #  # ]:          0 :             else if ( nIntensity < 0 )
     664                 :          0 :                 nIntensity = 0;
     665                 :          0 :             nIntensity = 100 - nIntensity;
     666 [ #  # ][ #  # ]:          0 :             pScene->GetProperties().SetObjectItem( Svx3DMaterialSpecularItem( aSpecularCol ) );
         [ #  # ][ #  # ]
     667 [ #  # ][ #  # ]:          0 :             pScene->GetProperties().SetObjectItem( Svx3DMaterialSpecularIntensityItem( (sal_uInt16)nIntensity ) );
         [ #  # ][ #  # ]
     668                 :            : 
     669 [ #  # ][ #  # ]:          0 :             pScene->SetLogicRect( CalculateNewSnapRect( pCustomShape, aSnapRect, aBoundRect2d, pMap ) );
     670                 :            : 
     671                 :            :             // removing placeholder objects
     672                 :          0 :             std::vector< E3dCompoundObject* >::iterator aObjectListIter( aPlaceholderObjectList.begin() );
     673 [ #  # ][ #  # ]:          0 :             while ( aObjectListIter != aPlaceholderObjectList.end() )
     674                 :            :             {
     675 [ #  # ][ #  # ]:          0 :                 pScene->Remove3DObj( *aObjectListIter );
     676 [ #  # ][ #  # ]:          0 :                 delete *aObjectListIter++;
         [ #  # ][ #  # ]
     677         [ #  # ]:          0 :             }
     678                 :            :         }
     679                 :            :         else
     680 [ #  # ][ #  # ]:          0 :             delete pScene;
         [ #  # ][ #  # ]
     681                 :            :     }
     682                 :          0 :     return pRet;
     683                 :            : }
     684                 :            : 
     685                 :          0 : Rectangle EnhancedCustomShape3d::CalculateNewSnapRect( const SdrObject* pCustomShape, const Rectangle& rSnapRect, const Rectangle& rBoundRect, const double* pMap )
     686                 :            : {
     687         [ #  # ]:          0 :     SdrCustomShapeGeometryItem& rGeometryItem = (SdrCustomShapeGeometryItem&)pCustomShape->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
     688         [ #  # ]:          0 :     const Point aCenter( rSnapRect.Center() );
     689                 :            :     double fExtrusionBackward, fExtrusionForward;
     690         [ #  # ]:          0 :     GetExtrusionDepth( rGeometryItem, pMap, fExtrusionBackward, fExtrusionForward );
     691                 :            :     sal_uInt32 i;
     692                 :            : 
     693                 :            :     // creating initial bound volume ( without rotation. skewing.and camera )
     694         [ #  # ]:          0 :     basegfx::B3DPolygon aBoundVolume;
     695         [ #  # ]:          0 :     const Polygon aPolygon( rBoundRect );
     696                 :            : 
     697         [ #  # ]:          0 :     for ( i = 0L; i < 4L; i++ )
     698                 :            :     {
     699 [ #  # ][ #  # ]:          0 :         aBoundVolume.append(basegfx::B3DPoint(aPolygon[ (sal_uInt16)i ].X() - aCenter.X(), aPolygon[ (sal_uInt16)i ].Y() - aCenter.Y(), fExtrusionForward));
                 [ #  # ]
     700                 :            :     }
     701                 :            : 
     702         [ #  # ]:          0 :     for ( i = 0L; i < 4L; i++ )
     703                 :            :     {
     704 [ #  # ][ #  # ]:          0 :         aBoundVolume.append(basegfx::B3DPoint(aPolygon[ (sal_uInt16)i ].X() - aCenter.X(), aPolygon[ (sal_uInt16)i ].Y() - aCenter.Y(), fExtrusionBackward));
                 [ #  # ]
     705                 :            :     }
     706                 :            : 
     707         [ #  # ]:          0 :     const rtl::OUString sRotationCenter( RTL_CONSTASCII_USTRINGPARAM ( "RotationCenter" ) );
     708                 :          0 :     drawing::Direction3D aRotationCenterDefault( 0, 0, 0 ); // default seems to be wrong, a fractional size of shape has to be used!!
     709         [ #  # ]:          0 :     drawing::Direction3D aRotationCenter( GetDirection3D( rGeometryItem, sRotationCenter, aRotationCenterDefault ) );
     710                 :            : 
     711                 :            :     double fXRotate, fYRotate;
     712         [ #  # ]:          0 :     GetRotateAngle( rGeometryItem, fXRotate, fYRotate );
     713         [ #  # ]:          0 :     double fZRotate = - ((SdrObjCustomShape*)pCustomShape)->GetObjectRotation() * F_PI180;
     714                 :            : 
     715                 :            :     // rotating bound volume
     716         [ #  # ]:          0 :     basegfx::B3DHomMatrix aMatrix;
     717         [ #  # ]:          0 :     aMatrix.translate(-aRotationCenter.DirectionX, -aRotationCenter.DirectionY, -aRotationCenter.DirectionZ);
     718         [ #  # ]:          0 :     if ( fZRotate != 0.0 )
     719         [ #  # ]:          0 :         aMatrix.rotate( 0.0, 0.0, fZRotate );
     720 [ #  # ][ #  # ]:          0 :     if ( ((SdrObjCustomShape*)pCustomShape)->IsMirroredX() )
     721         [ #  # ]:          0 :         aMatrix.scale( -1.0, 1, 1 );
     722 [ #  # ][ #  # ]:          0 :     if ( ((SdrObjCustomShape*)pCustomShape)->IsMirroredY() )
     723         [ #  # ]:          0 :         aMatrix.scale( 1, -1.0, 1 );
     724         [ #  # ]:          0 :     if( fYRotate != 0.0 )
     725         [ #  # ]:          0 :         aMatrix.rotate( 0.0, fYRotate, 0.0 );
     726         [ #  # ]:          0 :     if( fXRotate != 0.0 )
     727         [ #  # ]:          0 :         aMatrix.rotate( -fXRotate, 0.0, 0.0 );
     728         [ #  # ]:          0 :     aMatrix.translate(aRotationCenter.DirectionX, aRotationCenter.DirectionY, aRotationCenter.DirectionZ);
     729         [ #  # ]:          0 :     aBoundVolume.transform(aMatrix);
     730                 :            : 
     731         [ #  # ]:          0 :     Transformation2D aTransformation2D( pCustomShape, rSnapRect, pMap );
     732         [ #  # ]:          0 :     if ( aTransformation2D.IsParallel() )
     733 [ #  # ][ #  # ]:          0 :         aBoundVolume = aTransformation2D.ApplySkewSettings( aBoundVolume );
                 [ #  # ]
     734                 :            : 
     735         [ #  # ]:          0 :     Polygon aTransformed( 8 );
     736         [ #  # ]:          0 :     for ( i = 0L; i < 8L; i++ )
     737 [ #  # ][ #  # ]:          0 :         aTransformed[ (sal_uInt16)i ] = aTransformation2D.Transform2D( aBoundVolume.getB3DPoint( i ) );
     738                 :            : 
     739 [ #  # ][ #  # ]:          0 :     return aTransformed.GetBoundRect();
         [ #  # ][ #  # ]
                 [ #  # ]
     740                 :            : }
     741                 :            : 
     742                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10