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

Generated by: LCOV version 1.11