LCOV - code coverage report
Current view: top level - svx/source/customshapes - EnhancedCustomShape3d.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 19 469 4.1 %
Date: 2014-04-11 Functions: 2 15 13.3 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10